Learn R Programming

quickReg (version 1.0.0)

reg: Apply univariate regression models

Description

Apply general linear model, generalized linear model, cox regression model,etc.

Usage

reg(data = NULL, x = NULL, y = NULL, factor = NULL, model = NULL, time = NULL, ...)

Arguments

data
A data.frame
x
Column indices or names of the variables to be included in univariate analysis, the default columns are all the variables except dependent
y
Column indice of dependent variable or name
factor
Column indices of the variables or names to be treated as factor
model
Univariate analysis method, see lm, glm, coxph
time
Column indice of survival time or name, used in cox regression, see coxph for more details
...
Further arguments passed to regression model

Value

The return result is a list including two componets, the first part is a detailed anaysis result, the second part is a concentrated result in a data.frame

Examples

Run this code
reg_glm<-reg(data = diabetes, x = c(1:4, 6), y = 5, factor = c(1, 3, 4), model = 'glm')
##  subset result like a list
reg_glm$detail
reg_glm$dataframe
reg_glm[2]
reg_glm$detail[2:4]
##  other methods
reg(data = diabetes, x = c(1, 3:6), y = 10, factor = c(1, 3, 4), model = 'lm')
reg(data = diabetes, x = c( "sex","education","BMI"), y = "diabetes",
time ="age", factor = c("sex","smoking","education"), model = 'coxph')

Run the code above in your browser using DataLab