regress fits a multiple linear or a logistic regression model, depending on the response variable.

regress(formula, data, ...)

Arguments

formula

on object of class "formula"

data

a data frame

...

optional parameters pass to the fitting functions

Value

an object of class "lm" or "glm".

Details

The function is a wrapper for the lm and glm functions. If the response variable has only two possible values, a logistic regression model is fit using glm with family=binomial. Otherwise a linear model (lm) is returned.

See also

Examples

# multiple linear regression
fit <- regress(mpg ~ hp + wt, mtcars)
fit
#> 
#> Call:
#> lm(formula = mpg ~ hp + wt, data = mtcars)
#> 
#> Coefficients:
#> (Intercept)           hp           wt  
#>    37.22727     -0.03177     -3.87783  
#> 

# logistic regression
fit <- regress(am ~ hp + wt, mtcars)
fit
#> 
#> Call:  glm(formula = am ~ hp + wt, family = binomial, data = mtcars)
#> 
#> Coefficients:
#> (Intercept)           hp           wt  
#>    18.86630      0.03626     -8.08348  
#> 
#> Degrees of Freedom: 31 Total (i.e. Null);  29 Residual
#> Null Deviance:	    43.23 
#> Residual Deviance: 10.06 	AIC: 16.06