regression_predict: regression_predict

Description Usage Arguments Value Examples

View source: R/regression_predict.R

Description

This function mimic the predict function. It takes input of a linear_regression object, designed in the same package. And it wll use the coefficients in the object to predict by calculating yhat given the other input of a new data. This function will check the input of your new dataframe object. If one of the feature used in model training is not appear in the new data, then this function will not compute, and raise an error.

Usage

1
regression_predict(regression_object, X)

Arguments

regression_object

this should be a result computed by linear_regression()

X

new_data you want to predict

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
5
6
7
library(MASS)
X=Boston[,-ncol(Boston)]
y=Boston[,ncol(Boston)]
reg_model = linear_regression(X,y)
yhat = regression_predict(reg_model, X)
#If the new data contains more than necessary columns that are not used, it will be fine.
#'@export

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