linear: Linear Regression and Prediction

Description Usage Arguments Value Examples

View source: R/linear.R

Description

Linear Regression and Prediction

Usage

1
linear(X, y, add_intercept = T, to_predict = NULL)

Arguments

X

n by p design matrix of numeric covariates where n is the sample size and p is the parameter space.

y

n by 1 vector of numeric continuous outcomes

add_intercept

do you need to add an intercept column to your design matrix? we assume TRUE

to_predict

optional observation(s) for which you would like the outcomes predicted

Value

coefficients, fitted values, residuals, predictions (if you asked for them), t- statistics and conclusions to the hypothesis test that the coefficient is 0.

Examples

1
2
3
4
5
6
data(mtcars)
y = mtcars$mpg
X = mtcars$cyl
# can also make X a matrix, no problem
fit = linear(X,y) # this assumes your design matrix does not have an intercept in it
betas = fit$coeffs # these are your OLS regression coefficients

benbren/some.models documentation built on Nov. 25, 2019, 3:27 p.m.