regress.Rd
regress
fits a multiple linear or
a logistic regression model, depending on the response variable.
regress(formula, data, ...)
on object of class "formula"
a data frame
optional parameters pass to the fitting functions
an object of class "lm"
or "glm"
.
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.
# 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