coefFrame | R Documentation |
Fits a model to each subgroup defined by by
, then returns a data
frame with one row for each fit and one column for each parameter.
coefFrame(
mod,
data,
by = NULL,
fit.on = TRUE,
fitfun,
keep.unused.levels = TRUE,
byvar.sep = "\001",
...
)
mod |
a model formula, to be passed to by |
data |
a data frame, row subsets of which will be used as the
|
by |
names of columns in |
fit.on |
a logical vector indicating which rows of |
fitfun |
a model fitting function (e.g. lm, nls). More specifically, a
function that expects at least a formula object (as the first argument) and
a data.frame object (passed as an argument named |
keep.unused.levels |
Include rows in output for all unique values of
|
byvar.sep |
passed to frameApply, used to form the subsets of the data. |
... |
other arguments to pass to |
a data frame with a row for each unique row of x[by]
, and
column for each model paramter, as well as columns specified in by
.
Jim Rogers james.a.rogers@pfizer.com
# load example data
library(gtools)
data(ELISA)
# Coefficients for four parameter logistic fits:
coefFrame(log(Signal) ~ SSfpl(log(Concentration), A, B, xmid, scal),
data = ELISA, fitfun = nls,
by = c("PlateDay", "Read"),
fit.on = Description == "Standard" & Concentration != 0)
# Coefficients for linear fits:
coefFrame(log(Signal) ~ log(Concentration),
data = ELISA, fitfun = lm,
by = c("PlateDay", "Read"),
fit.on = Description == "Standard" & Concentration != 0 )
# Example passing arguments to fitfun, and example of
# error handling during model fitting:
ELISA$Signal[1] <- NA
coefFrame(log(Signal) ~ log(Concentration),
data = ELISA, fitfun = lm, na.action = na.fail,
by = c("PlateDay", "Read"),
fit.on = Description == "Standard" & Concentration != 0 )
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.