View source: R/addContinuous.R
addContinuous | R Documentation |
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.
addContinuous(linearModel = NULL, binWidth = 20, newData = NULL)
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 |
A linear regression model is the easiest model to use for the demonstration purposes of this function.
a data.frame with four columns:
newObservedOutcome New observed outcome, linearly transformed to a variable that ranges between 0 and 100.
newPrediction New predicted outcome, linearly transformed to a variable that ranges between 0 and 100.
diff Difference between newObservedOutcome and newPrediction.
binDiff Absolute difference in terms of bins (see binWidth
).
Marcel Miché
# 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)
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.