addContinuous: Add individual new predictor and outcome values (for...

View source: R/addContinuous.R

addContinuousR Documentation

Add individual new predictor and outcome values (for demonstration purposes).

Description

Add single predictor and outcome values. This function is for demonstration purposes, especially in terms of visualizing how far from perfect prediction a new outcome value may be.

Usage

addContinuous(linearModel = NULL, binWidth = 20, newData = NULL)

Arguments

linearModel

The linear model that has been fitted to a data set (see Details).

binWidth

A single integer value greater than 0 and less than 100, which separates 100 into equal bins, e.g., 20 (100/20 = 5 equal bins).

newData

A data.frame with exactly as many columns (and the same column names) as the data set to which the linear model has been fitted (see linearModel).

Details

A linear regression model is the easiest model to use for the demonstration purposes of this function.

Value

a data.frame with four columns:

  1. newObservedOutcome New observed outcome, linearly transformed to a variable that ranges between 0 and 100.

  2. newPrediction New predicted outcome, linearly transformed to a variable that ranges between 0 and 100.

  3. diff Difference between newObservedOutcome and newPrediction.

  4. binDiff Absolute difference in terms of bins (see binWidth).

Author(s)

Marcel Miché

Examples

# Simulate data set with continuous outcome (use all default values)
dfContinuous <- quickSim()
# Use multiple linear regression as algorithm to predict the outcome.
lmRes <- lm(y~x1+x2,data=dfContinuous)
# Set new predictor values and observed outcome values for 2 individuals.
newData <- data.frame(x2=c(-.2, .25),
                   x1=c(.3, .4),
                   y=c(5, 8))
# Execute the function 'addContinuous'.
addContinuous(linearModel=lmRes, binWidth = 20, newData=newData)

mmiche/predictMe documentation built on Nov. 13, 2022, 12:50 p.m.