SLR_prediction: SLR prediction

Description Usage Arguments Details Value Author(s) See Also Examples

View source: R/SLR_prediction.R

Description

Predicting with a simple linear regression model. (S3 generic function)

Usage

1
SLR_prediction(y, exploratory, col_response, col_exploratory, pre_x_value)

Arguments

y

depends on the class of the input: for

numeric vectors

a numeric vector representing the response variable

data frames

a numeric data.frame containing the response and exploratory variable

matrix

a numeric matrix containing the response and exploratory variable

exploratory

numeric vector representing the exploratory variable, must have the same length as y (for the input class numeric only)

col_response

column number of the response variable within y (default is 1) (for data frames and matrices only)

col_exploratory

column number of the exploratory variable within y (default is 2) (for data frames and matrices only)

pre_x_value

the numeric value (within the range of the exploratory vector) for which the prediction is made

Details

The generic function first builds a simple linear regression model with one response and one exploratory variable. Then the prediction for a given value of the exploratory variable (default the mean and no out of sample predictions) gets returned.

Value

the predicted value of the response variable

Author(s)

Emanuel Sommer

See Also

SLR_prediction_vis SLR_prediction.numeric SLR_prediction.data.frame SLR_prediction.matrix

Examples

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
##numeric S3 method
response <- c(1:5)
exploratory <- c(1,3,4.5,7,8)
special <- 6
SLR_prediction(response,exploratory,pre_x_value = special)

##data.frame S3 method
Y<-data.frame(c(1:5),c(1,3,4.5,7,8))
SLR_prediction(Y,pre_x_value = special)

##matrix S3 method is eqivalently used as the one for data frames

EmanuelSommer/SLRprediction documentation built on Nov. 22, 2020, 3:18 p.m.