SLR_prediction_vis.data.frame: SLR prediction visualization S3 method for data frames

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

View source: R/SLR_prediction_vis.R

Description

Simple visualization tool for predictions within a simple linear regression model.

Usage

1
2
3
4
## S3 method for class 'data.frame'
SLR_prediction_vis(y, col_response = 1,
  col_exploratory = 2, pre_x_value = mean(y[, col_exploratory]),
  pre_col = "red", reg_col = "blue")

Arguments

y

a numeric data.frame containing the response and exploratory variable

col_response

column number of the response variable within y (default is 1)

col_exploratory

column number of the exploratory variable within y (default is 2)

pre_x_value

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

pre_col

color of the highlighted prediction within the scatterplot

reg_col

color of the regression line

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 computed.(see SLR_prediction) Finally using these bits of information a scatterplot of the two variables with the regression line gets returned. Moreover the predicition will be highlighted in the scatterplot and the exact values of the predicition will be displayed above the plot.

Value

a scatterplot of the two variables + regression line + highlighted prediction

Author(s)

Emanuel Sommer

See Also

SLR_prediction

Examples

1
2
3
4
5
response <- c(1:5)
exploratory <- c(1,3,4.5,7,8)
Y <- data.frame(response,exploratory)
special <- 6
SLR_prediction_vis(Y,pre_x_value = special)

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