linear_regression: linear_regression

Description Usage Arguments Value Examples

View source: R/linear_regression.R

Description

This function will do almost exactly the same thing as the famous lm function. To be specific, It will compute linear regression with the given data. The data can have factor type and our function will automatically transform it by one-hot encoding. It will also compute feature siginificance through t-test and an overall F-test just like the lm function.

Usage

1

Arguments

X

input X, it should be a data.frame object with/without colnames.

y

input y, this is the respond variable.

Value

it will return a list with model coefficients, t statistics and pvalue of every coefficient, and F-stat for the overall model. It will also return R^2 and adjusted R^2, just like everything lm function will return.

Examples

1
2
3
4
library(MASS)
X=Boston[,-ncol(Boston)]
y=Boston[,ncol(Boston)]
linear_regression(X,y)

keyuchen886/OLSregression documentation built on Jan. 1, 2021, 7:17 a.m.