makeDiffPlot {predictMe}R Documentation

Plot individual differences between measured and predicted outcome values.

Description

Plot the differences between measured and predicted outcome for all individuals.

Usage

makeDiffPlot(xd = NULL, idCol = NULL)

Arguments

xd

A data.frame with exactly two columns, one of the columns must be the identifier of all individuals, the other column must be the differences between the measured and the predicted outcome values.

idCol

A single integer that denotes which of the columns of the data.frame contains the identifier of the individuals.

Details

The d in 'xd' stands for differences, meaning that the column of interest contain the differences between the measured and the predicted outcome values, logically requiring the column that identifies the individuals.

Irrespective of whether the original outcome was continuous or binary, outcome values always range between 0 and 100. For instance, for a binary outcome the 'probabilities' are represented as percentage.

Use the column diff (from function binContinuous) or diffPerc (from function binBinary) and column xAxisIds, both columns being part of both data.frames that are returned by the two mentioned functions.

Value

a list with the plot that shows the differences between the measured and predicted outcome for all individuals. See Details.

Author(s)

Marcel Miché

References

Wickham H (2016). ggplot2: Elegant Graphics for Data Analysis. Springer-Verlag New York. ISBN 978-3-319-24277-4, https://ggplot2.tidyverse.org.

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)
# Extract measured outcome and the predicted outcome (fitted values)
# from the regression output, put both in a data.frame.
lmDf <- data.frame(measOutcome=dfContinuous$y,
                   fitted=lmRes$fitted.values)
# Apply function binContinuous.
x100c <- binContinuous(x=lmDf, measColumn = 1, binWidth = 20)
# Apply function makeDiffPlot, using columns 5 and 6 from x100c[["xTrans"]]
# The second of columns 5 and 6 contains the identifiers of the individuals.
dp <- makeDiffPlot(x100c[["xTrans"]][,5:6], idCol = 2)
# dp is the plot that shows the individual differences.
# makeDiffPlot works the same way if binBinary had be used instead of
# binContinuous.

[Package predictMe version 0.1 Index]