Learn R Programming

jmv (version 0.7.3.1)

linReg: Linear Regression

Description

Linear Regression

Usage

linReg(data, dep, blocks = list(list()), fitMeasures = list("r", "r2"),
  modelTest = NULL, modelComp = list("f"), stdEst = FALSE, ci = FALSE,
  ciWidth = 95, coefPlot = FALSE, qqPlot = FALSE, resPlots = FALSE,
  durbin = FALSE, collin = FALSE, desc = FALSE, cooks = FALSE,
  modelSelected = -1)

Arguments

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<U+00B2>, adjusted R<U+00B2>, 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)

Examples

Run this code
data('Prestige', package='car')

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

#
#  Model Fit Measures
#  ---------------------------
#    Model    R        R<U+00B2>
#  ---------------------------
#    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
#  -----------------------------------------------------------------
#

Run the code above in your browser using DataLab