Learn R Programming

Publish (version 2017.10.24)

glmSeries: Run a series of generalized linear regression analyses

Description

Run a series of generalized linear regression analyses for a list of predictor variables and summarize the results in a table. The regression models can be adjusted for a fixed set of covariates.

Usage

glmSeries(formula, data, vars, ...)

Arguments

formula

The fixed part of the regression formula. For univariate analyses this is simply y~1 where y is the outcome variable. When the aim is to control the effect of vars in each element of the series by a fixed set of variables it is y~x1+x2 where again y is the outcome and x1 and x2 are confounders.

data

A data.frame in which we evaluate the formula.

vars

A list of variable names, the changing part of the regression formula.

...

passed to glm

Value

Matrix with regression coefficients, one for each element of vars.

Examples

Run this code
# NOT RUN {
data(Diabetes)
Diabetes$hyper1 <- factor(1*(Diabetes$bp.1s>140))
## collect odds ratios from three univariate logistic regression analyses
uni.odds <- glmSeries(hyper1~1,vars=c("chol","hdl","location"),data=Diabetes,family=binomial)
uni.odds
## control the logistic regression analyses for age and gender
## but collect only information on the variables in `vars'.
controlled.odds <- glmSeries(hyper1~age+gender,
                             vars=c("chol","hdl","location"),
                             data=Diabetes, family=binomial)
controlled.odds
# }

Run the code above in your browser using DataLab