plotCalibration {PredictABEL} | R Documentation |
Function for calibration plot and Hosmer-Lemeshow goodness of fit test.
Description
The function produces a calibration plot and provides Hosmer-Lemeshow goodness of fit test statistics.
Usage
plotCalibration(data, cOutcome, predRisk, groups, rangeaxis,
plottitle, xlabel, ylabel, filename, fileplot, plottype)
Arguments
data |
Data frame or numeric matrix that includes the outcome and predictor variables. |
cOutcome |
Column number of the outcome variable. |
predRisk |
Vector of predicted risks of all individuals in the dataset. |
groups |
Number of groups considered in
Hosmer-Lemeshow test. Specification of |
rangeaxis |
Range of x-axis and y-axis. Specification of |
plottitle |
Title of the plot. Specification of |
xlabel |
Label of x-axis Default. Specification of |
ylabel |
Label of y-axis. Specification of |
filename |
Name of the output file in which the calibration table is saved.
The file is saved as a txt file in the working directory. When no
|
fileplot |
Name of the file that contains the calibation plot.
The file is saved in the working directory in the format specified under |
plottype |
The format in which the plot is saved. Available formats are
wmf, emf, png, jpg, jpeg, bmp, tif, tiff, ps,
eps or pdf. Foe example, |
Details
Hosmer-Lemeshow test statistic is a measure of the fit of the model, comparing observed and predicted risks across subgroups of the population. The default number of groups is 10.
The function requires the outcome of interest and predicted risks of
all individuals. Predicted risks can be obtained from the
functions fitLogRegModel
and predRisk
or
be imported from other packages or methods.
Value
The function creates a calibration plot and returns the following measures:
Chi_square |
Chi square value of Hosmer-Lemeshow test |
df |
Degrees of freedom, which is |
p_value |
p-value of Hosmer-Lemeshow test for goodness of fit |
References
Hosmer DW, Hosmer T, Le Cessie S, Lemeshow S. A comparison of goodness-of-fit tests for the logistic regression model. Stat Med 1997; 16:965-980.
See Also
Examples
# specify dataset with outcome and predictor variables
data(ExampleData)
# specify column number of the outcome variable
cOutcome <- 2
# fit a logistic regression model
# all steps needed to construct a logistic regression model are written in a function
# called 'ExampleModels', which is described on page 4-5
riskmodel <- ExampleModels()$riskModel2
# obtain predicted risks
predRisk <- predRisk(riskmodel)
# specify range of x-axis and y-axis
rangeaxis <- c(0,1)
# specify number of groups for Hosmer-Lemeshow test
groups <- 10
# compute calibration measures and produce calibration plot
plotCalibration(data=ExampleData, cOutcome=cOutcome, predRisk=predRisk,
groups=groups, rangeaxis=rangeaxis)