# test.fit: Goodness-of-Fit Test In qrcm: Quantile Regression Coefficients Modeling

## 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 estimated with Monte Carlo.

## Usage

 `1` ```test.fit(object, R = 100, zcmodel = 1, trace = FALSE) ```

## Arguments

 `object` an object of class “`iqr`”. `R` number of Monte Carlo replications. `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 be printed.

## 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 its option `splinex = splinex()`.

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

• If zcmodel = 1 (the default), it is assumed that C = Z + U, where U is a positive variable and is independent of Z, given covariates. This is the most common situation, and is verified when censoring occurs at the end of the follow-up. Under this scenario, C and Z are correlated with P(C > Z) = 1.

• If zcmodel = 2, it is assumed that C and Z are conditionally independent. This situation is more plausible when all censoring is due to drop-out.

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 [email protected]

## 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``` ```y <- rnorm(1000) m1 <- iqr(y ~ 1, formula.p = ~ I(qnorm(p))) # correct m2 <- iqr(y ~ 1, formula.p = ~ p) # misspecified test.fit(m1, R = 25) test.fit(m2, R = 25) ```

qrcm documentation built on May 29, 2017, 10:54 a.m.