Linear Regression

Linear Regression

Example usage

data('Prestige', package='car')

linReg(data = Prestige, dep = 'income',
       blocks = list(c('education', 'prestige', 'women')))

#  Model Fit Measures
#  ───────────────────────────
#    Model    R        R²
#  ───────────────────────────
#    1        0.802    0.643
#  ───────────────────────────
#  Model Coefficients
#  ─────────────────────────────────────────────────────────────────
#    Model    Predictor    Estimate    SE         t         p
#  ─────────────────────────────────────────────────────────────────
#    1        Intercept      -253.8    1086.16    -0.234     0.816
#             education       177.2     187.63     0.944     0.347
#             prestige        141.4      29.91     4.729    < .001
#             women           -50.9       8.56    -5.948    < .001
#  ─────────────────────────────────────────────────────────────────


data the data as a data frame
dep a string naming the dependent variable from data, variable must be numeric
blocks a list containing vectors of strings that name the covariates that are added to the model. The elements are added to the model according to their order in the list
fitMeasures one or more of 'r', 'r2', 'r2Adj', 'aic', 'bic', or 'rmse'; use R, R², adjusted R², AIC, BIC, and RMSE model fit measures, respectively
modelTest one or more of 'f', or 'bf'; Use classical F-test, and Bayes factor respectively as overall model tests.
modelComp one or more of 'f', or 'bf'; Use classical F-test, and Bayes factor respectively as model comparison tests.
stdEst TRUE or FALSE (default), provide a standardized estimate for the model coefficients
ci TRUE or FALSE (default), provide a confidence interval for the model coefficients
ciWidth a number between 50 and 99.9 (default: 95) specifying the confidence interval width
coefPlot TRUE or FALSE (default), provide a coefficient plot where for each predictor the estimated coefficient and confidence intervals are plotted.
qqPlot TRUE or FALSE (default), provide a Q-Q plot of residuals
resPlots TRUE or FALSE (default), provide residual plots where the dependent variable and each covariate is plotted against the standardized residuals.
durbin TRUE or FALSE (default), provide results of the Durbin- Watson test for autocorrelation
collin TRUE or FALSE (default), provide VIF and tolerence collinearity statistics
desc TRUE or FALSE (default), provide descriptive statistics
cooks TRUE or FALSE (default), provide summary statistics for the Cook's distance
modelSelected an integer defining the model for which the model specific output needs to be calculated (defaults to most complex model)


A results object containing:

results$modelFit a table
results$modelComp a table
results$coef a table
results$coefPlot an image
results$dataSummary$desc a table
results$dataSummary$cooks a table
results$assump$durbin a table
results$assump$collin a table

Tables can be converted to data frames with asDF or For example: