probPlot: Probability plots to check the goodness of fit of parametric...

Description Usage Arguments Details Value Author(s) References Examples

View source: R/probPlot.R

Description

probPlot provides four types of probability plots: P-P plot, Q-Q plot, Stabilised probability plot, and Empirically Rescaled plot to check if a certain distribution is an appropiate choice for the data.

Usage

1
2
3
4
5
6
7
8
9
probPlot(times, cens = rep(1, length(times)), 
         distr = c("exponential", "gumbel", "weibull", "normal", 
                   "lognormal", "logistic", "loglogistic", "beta"), 
         plots = c("PP", "QQ", "SP", "ER"), 
         colour = c("green4", "deepskyblue4", "yellow3", "mediumvioletred"), 
         betaLimits = c(0, 1), igumb = c(10, 10), mtitle = TRUE, ggplo = FALSE, 
         m = NULL, prnt = TRUE, decdig = 7, 
         params = list(shape = NULL, shape2 = NULL, location = NULL, 
                       scale = NULL), ...)

Arguments

times

Numeric vector of times until the event of interest.

cens

Status indicator (1, exact time; 0, right-censored time). If not provided, all times are assumed to be exact.

distr

A string specifying the name of the distribution to be studied. The possible distributions are the exponential ("exponential"), the Weibull ("weibull"), the Gumbel ("gumbel"), the normal ("normal"), the lognormal ("lognormal"), the logistic ("logistic"), the loglogistic ("loglogistic"), and the beta ("beta") distribution.

plots

Vector stating the plots to be displayed. Possible choices are the P-P plot ("PP"), the Q-Q plot ("QQ"), the Stabilised Probability plot ("SP"), and the Empirically Rescaled plot ("ER"). By default, all four plots are displayed.

colour

Vector indicating the colours of the displayed plots. The vector will be recycled if its length is smaller than the number of plots to be displayed.

betaLimits

Two-components vector with the lower and upper bounds of the Beta distribution. This argument is only required, if the beta distribution is considered.

igumb

Two-components vector with the initial values for the estimation of the Gumbel distribution parameters.

mtitle

Logical to add or not the title "Probability plots for a distr distribution" to the plot. Default is TRUE.

ggplo

Logical to use or not the ggplot2 package to draw the plots. Default is FALSE.

m

Optional layout for the plots to be displayed.

prnt

Logical to indicate if the maximum likelihood estimates of the parameters should be printed. Default is TRUE.

decdig

Number of significant (see signif) digits to print when printing the parameter estimates. It is a suggestion only.

params

List specifying the parameters of the theoretical distribution. By default, parameters are set to NULL and estimated with the maximum likelihood method. This argument is only considered, if all parameters of the studied distribution are specified.

...

Optional arguments for function par, if ggplo = FALSE.

Details

By default, function probPlot draws four plots: P-P plot, SP plot, Q-Q plot, and EP plot. Following, a description is given for each plot.

The Probability-Probability plot (P-P plot) depicts the empirical distribution, \widehat{F}(t), which is obtained with the Kaplan-Meier estimator if data are right-censored, versus the theoretical cumulative distribution function (cdf), \widehat{F_0}(t). If the data come from the chosen distribution, the points of the resulting graph are expected to lie on the identity line.

The Stabilised Probability plot (SP plot), proposed by Michael (1983), is a transformation of the P-P plot. It stabilises the variance of the plotted points. If F_0 = F and the parameters of F_0 are known, \widehat{F_0}(t) corresponds to the cdf of a uniform order statistic, and the arcsin transformation stabilises its variance. If the data come from distribution F_0, the SP plot will resemble the identity line.

The Quartile-Quartile plot (Q-Q plot) is similar to the P-P plot, but it represents the sample quantiles versus the theoretical ones, that is, it plots t versus \widehat{F}_0^{-1}(\widehat{F}(t)). Hence, if F_0 fits the data well, the resulting plot will resemble the identity line.

A drawback of the Q-Q plot is that the plotted points are not evenly spread. Waller and Turnbull (1992) proposed the Empirically Rescaled plot (EP plot), which plots \widehat{F}_u(t) against \widehat{F}_u(\widehat{F}_0^{-1}(\widehat{F}(t))), where \widehat{F}_u(t) is the empirical cdf of the points corresponding to the uncensored observations. Again, if \widehat{F}_0 fits the data well, the ER plot will resemble the identity line.

By default, all four probability plots are drawn and the maximum likelihood estimates of the parameters of the chosen parametric model are returned. The parameter estimation is acomplished with the fitdistcens function of the fitdistrplus package.

Value

A list containing the following components

Distribution

Distribution under study.

Parameters

List with the maximum likelihood estimates of the parameters of the distribution under study.

Author(s)

K. Langohr, M. Besalú, G. Gómez.

References

J. R. Michael. The Stabilized Probability Plot. In: Biometrika 70 (1) (1983), 11-17.

L.A. Waller and B.W. Turnbull. Probability Plotting with Censored Data. In: American Statistician 46 (1) (1992), 5-12.

Examples

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
# P-P, Q-Q, SP, and EP plots for complete data
set.seed(123)
x <- rlnorm(1000, 3, 2)
probPlot(x) 
probPlot(x, distr = "lognormal") 

# P-P, Q-Q, SP, and EP plots for censored data using ggplot2
library(survival)
probPlot(aml$time, aml$status, ggplo = TRUE) 

# P-P, Q-Q and SP plots for censored data and lognormal distribution
data(nba)
probPlot(nba$survtime, nba$cens, "lognorm", plots = c("PP", "QQ", "SP"),
         ggplo = TRUE, m = matrix(1:3, nr = 1))

GofCens documentation built on Jan. 6, 2022, 1:06 a.m.