ntest.res: Normality Check for Interval-Censored Data with Repeated...

View source: R/ntest.res.R

ntest.resR Documentation

Normality Check for Interval-Censored Data with Repeated Measurements - Residuals

Description

The function checks whether interval-censored data with two repeated measurements meet the normality assumption for subjects' residuals. This is a prerequisite for the random effects model used in ICC calculation.

Usage

ntest.res(r1, r2, predefined.classes=FALSE, classes, c.limits, optim.method=1, bins=10)

Arguments

r1

argument passed to intervalICC; see documentation for that function.

r2

argument passed to intervalICC; see documentation for that function.

predefined.classes

argument passed to intervalICC; see documentation for that function.

classes

argument passed to intervalICC; see documentation for that function.

c.limits

argument passed to intervalICC; see documentation for that function.

optim.method

argument passed to intervalICC; see documentation for that function.

bins

number of categories in chi-square test; see details below (default is 10).

Details

For ICC estimation the random effects data model

Y_{ij} = \mu + b_i + e_{ij},

is used, where b_i and e_{ij} are normally distributed with means 0 and variances \sigma^2_b and \sigma^2, respectively. This function assesses the assumption that the subjects' "residuals" Y_{i1} - 0.5 (Y_{i1}+Y_{i2}) and Y_{i2} - 0.5 (Y_{i1}+Y_{i2}) are normally distributed with mean 0 and variance 0.5 \sigma^2, as is expected under the specified model.

To test normality, chi-square goodness-of-fit test with bins subsequent data categories is used (call to chisq.test from package stats). The categories (bins) are determined using the equidistant quantiles of expected normal distribution, with corresponding maximum likelihood parameters. Maximum likelihood estimates for parameters \mu, \sigma^2_b and \sigma^2 are obtained by calling the function intervalICC. The probability corresponding to each bin is 1/bins (expected relative frequencies; this corresponds to p = rep(1/bins,bins) in chisq.test function). Since residuals are interval-censored and censoring intervals overlap, the observed relative frequencies are calculated in the following way. If one of the original intervals representing subjects residual spans multiple bins, each bin receives a share of votes from the original interval. This share is calculated using the expected normal density function and it is proportional to the probability of data falling within the intersection of the original interval and bin.

Residuals for the first time point (Y_{i1} - 0.5 (Y_{i1}+Y_{i2})) and residuals for the second (Y_{i2} - 0.5 (Y_{i1}+Y_{i2})) are tested separately; therefore two test results in the output are given.

Value

An object of class "ntestRes". The object is a list with the components:

statistic.res1

value of chi-squared statistic corresponding to the first residual; statistic in the output of chisq.test

p.value.res1

p-value of test corresponding to the first residual; p.value in the output of chisq.test

statistic.res2

value of chi-squared statistic corresponding to the second residual; statistic in the output of chisq.test

p.value.res2

p-value of test corresponding to the second residual; p.value in the output of chisq.test

parameter

number of degrees of freedom for chi-squared distribution (the same for both residuals); parameter in the output of chisq.test

data

character string with value ,,residuals”

mu

mean of the expected normal distribution for subjects' residuals; equal to 0

var

variance of the expected normal distribution for subjects' residuals; equal to maximum likelihood estimate for 0.5 \sigma^2 from intervalICC

bins

number of categories in chi-square test

Note

This function was designed as a help in assessing goodness of model fit. However, it has not been tested in simulations nor in any other way. It is the responsibility of the user to provide appropriate number of bins; the function checks only if bins is a positive integer. Testing normality with low number of bins is unreliable. On the other hand, if the number of bins is too large, chisq.test will complain since the expected frequencies will be too low.

Author(s)

Jelena Kovacic jkovacic@imi.hr

References

Kovacic J, Varnai VM. Intraclass correlation coefficient for grouped data. Epidemiology 2014;25(5):769–770.

See Also

summary.ntestRes, intervalICC, chisq.test

Examples

# Example with 6 predefined classes (grouped data)
classes <- 1:6
class.limits <- cbind(classes-0.5,classes+0.5)
r1 <- sample(classes,30,replace=TRUE)
r2 <- sample(classes,30,replace=TRUE)
ntest.res(r1,r2,predefined.classes=TRUE,classes,class.limits,bins=10)

iRepro documentation built on Aug. 8, 2023, 5:13 p.m.