Learn R Programming

arsenal (version 0.5.0)

modelsum: Fit models over each of a set of independent variables with a response variable

Description

Fit and summarize models for each independent (x) variable with a response variable (y), with options to adjust by variables for each model.

Usage

modelsum(formula, family = "gaussian", data, adjust = NULL,
  na.action = na.modelsum, subset = NULL, weights = NULL,
  control = NULL, ...)

# S3 method for modelsum print(x, ...)

# S3 method for modelsumList print(x, ...)

Arguments

formula

an object of class formula; a symbolic description of the variables to be modeled. See "Details" for more information.

family

similar mechanism to glm, where the model to be fit is driven by the family, options include: binomial, gaussian, survival, Poisson. Family options supported in glm can be in quotes or not, but survival requires quotes.

data

an optional data.frame, list or environment (or object coercible by as.data.frame to a data frame) containing the variables in the model. If not found in data, the variables are taken from environment(formula), typically the environment from which modelsum is called.

adjust

an object of class formula, listing variables to adjust by in all models. Specify as a one-sided formula, like: ~Age+ Sex.

na.action

a function which indicates what should happen when the data contain NAs. The default is set by the na.modelsum setting of options, and is na.fail if that is unset. The default is to include observations with NAs in x variables, but remove those with NA in response variable.

subset

an optional vector specifying a subset of observations (rows of data) to be used in the results. Works as vector of logicals or an index.

weights

an optional vector specifying the weights to apply to each data observation (rows of data)

control

control parameters to handle optional settings within modelsum. Arguments for modelsum.control can be passed to modelsum via the ... argument, but if a control object and ... arguments are both supplied, the latter are used. See modelsum.control for other details.

...

additional arguments to be passed to internal modelsum functions.

x

An object of class 'modelsum', or a list of such objects.

Value

An object with class 'modelsum', which is effectively a list with the variables from the right-side in x and the group variable in y. Then, each item in x has these:

fits

a list with an item in X for each x in y ~ X + adjust variables

family

family used in glm

Call

Original call to modelsum

control

list of control parameters used in modelsum, and to be used in summary.modelsum, the result of modelsum.control

See Also

modelsum.control, summary.modelsum, formulize

Examples

Run this code
# NOT RUN {
data(mockstudy)

tab1 <- modelsum(bmi ~ sex + age, data = mockstudy)
summary(tab1, text = TRUE)

tab2 <- modelsum(alk.phos ~ arm + ps + hgb, adjust = ~ age + sex,
                 family = "gaussian", data = mockstudy)
summary(tab2, text = TRUE)

summary(tab2, show.intercept = FALSE, text = TRUE)

tab2.df <- as.data.frame(tab2)

tab2.df[1:5,]
# }

Run the code above in your browser using DataLab