test.fit.iqr: Goodness-of-Fit Test

Description Usage Arguments Details Value Author(s) References Examples

View source: R/iqr3_test_fit.R

Description

Goodness-of-fit test for a model fitted with iqr. The Kolmogorov-Smirnov statistic and the Cramer-Von Mises statistic are computed. Their distribution under the null hypothesis is evaluated with Monte Carlo.

Usage

1
2
## S3 method for class 'iqr'
test.fit(object, R = 100, zcmodel = 1, trace = FALSE, ...)

Arguments

object

an object of class “iqr”.

R

number of Monte Carlo replications. If R = 0, the function only returns the test statistics.

zcmodel

a numeric value indicating how to model the joint distribution of censoring (C) and truncation (Z). Only used when data are censored and truncated. See ‘Details’.

trace

logical. If TRUE, the progress will be printed.

...

for future arguments.

Details

This function permits assessing goodness of fit by testing the null hypothesis that the CDF values follow a U(0,1) distribution, indicating that the model is correctly specified. Since the CDF values depend on estimated parameters, the distribution of the test statistic is not known. To evaluate it, the model is fitted on R simulated datasets generated under the null hypothesis.

If the data are censored and truncated, object$CDF is as well a censored and truncated outcome, and its quantiles must be estimated with Kaplan-Meier. The fitted survival curve is then compared with a U(0,1).

To run Monte Carlo simulations when data are censored or truncated, the distribution of the censoring and that of the truncation variable must be estimated: the function pchreg from the pch package is used, with default settings.

The joint distribution of the censoring variable (C) and the truncation variable (Z) can be specified in two ways:

The testing procedure is described in details by Frumento and Bottai (2016, 2017).

Value

a matrix with columns statistic and p.value, reporting the Kolmogorov-Smirnov and Cramer-Von Mises statistic and the associated p-values evaluated with Monte Carlo.

Author(s)

Paolo Frumento paolo.frumento@unipi.it

References

Frumento, P., and Bottai, M. (2016). Parametric modeling of quantile regression coefficient functions. Biometrics, 72 (1), pp 74-84, doi: 10.1111/biom.12410.

Frumento, P., and Bottai, M. (2017). Parametric modeling of quantile regression coefficient functions with censored and truncated data. Biometrics, doi: 10.1111/biom.12675.

Examples

1
2
3
4
5
6
y <- rnorm(1000)
m1 <- iqr(y ~ 1, formula.p = ~ I(qnorm(p))) # correct
m2 <- iqr(y ~ 1, formula.p = ~ p)  # misspecified

test.fit(m1)
test.fit(m2)

qrcm documentation built on Feb. 2, 2021, 9:07 a.m.