regr: regr: a simple regression analysis wrapper

Description Usage Arguments Value Author(s) Examples

View source: R/regr.R

Description

The regr function wraps a number of linear regression functions into one convenient interface that provides similar output to the regression function in SPSS. It automatically provides confidence intervals and standardized coefficients. Note that this function is meant for teaching purposes, and therefore it's only for very basic regression analyses.

Usage

1
2
3
4
5
6
7
regr(formula, data = NULL, conf.level = .95,
     digits = 2, pvalueDigits = 3,
     coefficients = c("raw", "scaled"),
     plot = FALSE, pointAlpha = .5,
     collinearity = FALSE, influential = FALSE,
     ci.method = c("widest", "r.con", "olkinfinn"),
     ci.method.note = FALSE, env = parent.frame())

Arguments

formula

The formula of the regression analysis, of the form y ~ x1 + x2, where y is the dependent variable and x1 and x2 are the predictors.

data

If the terms in the formula aren't vectors but variable names, this should be the dataframe where those variables are stored.

conf.level

The confidence of the confidence interval around the regression coefficients.

digits

Number of digits to round the output to.

pvalueDigits

The number of digits to show for p-values; smaller p-values will be shown as <.001 or <.0001 etc.

coefficients

Which coefficients to show; can be "raw" to only show the raw (unstandardized) coefficients; "scaled" to only show the scaled (standardized) coefficients), or c("raw", "scaled') to show both.

plot

For regression analyses with only one predictor (also sometimes confusingly referred to as 'univariate' regression analyses), scatterplots with regression lines and their standard errors can be produced.

pointAlpha

The alpha channel (transparency, or rather: 'opaqueness') of the points drawn in the plot.

collinearity

Whether to compute and show collinearity diagnostics (specifically, the tolerance (1 - R^2, where R^2 is the one obtained when regressing each predictor on all the other predictors) and the Variance Inflation Factor (VIF), which is the reciprocal of the tolerance, i.e. VIF = 1 / tolerance).

influential

Whether to compute diagnostics for influential cases. These are stored in the returned object in the lm.influence.raw and lm.influence.scaled objects in the intermediate object.

ci.method, ci.method.note

Which method to use for the confidence interval around R squared, and whether to display a note about this choice.

env

The enviroment where to evaluate the formula.

Value

A list of three elements:

input

List with input arguments

intermediate

List of intermediate objects, such as the lm and confint objects.

output

List with two dataframes, one with the raw coefficients, and one with the scaled coefficients.

Author(s)

Gjalt-Jorn Peters

Maintainer: Gjalt-Jorn Peters <gjalt-jorn@userfriendlyscience.com>

Examples

1
2
3
4
5
### Do a simple regression analysis
regr(age ~ circumference, dat=Orange);

### Show more digits for the p-value
regr(Orange$age ~ Orange$circumference, pvalueDigits=18);

userfriendlyscience documentation built on May 2, 2019, 1:09 p.m.