ntest.means {iRepro}R Documentation

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

Description

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

Usage

ntest.means(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' means 0.5 (Y_{i1}+Y_{i2}) are normally distributed with mean \mu and variance \sigma^2_b + 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 means 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 mean 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.

Value

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

statistic

value of chi-squared statistic; statistic in the output of chisq.test

parameter

number of degrees of freedom for chi-squared distribution; parameter in the output of chisq.test

p.value

p-value of test; p.value in the output of chisq.test

data

character string with value "means"

mu

mean of the expected normal distribution for subjects' means; equal to maximum likelihood estimate for \mu from intervalICC

var

variance of the expected normal distribution for subjects' means; equal to maximum likelihood estimate for \sigma^2_b + 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.ntestMeans, 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.means(r1,r2,predefined.classes=TRUE,classes,class.limits,bins=10)

[Package iRepro version 1.2 Index]