achisq.stat: Another Implementation of Pearson's Chi-square Statistic

View source: R/achisq.stat.R

achisq.statR Documentation

Another Implementation of Pearson's Chi-square Statistic

Description

Compute Pearson's Chi-square statistic. See achisq manual page for more details.

achisq.stat computes the test statistic and the test using a hi-square distribution whilst achisq.test performs a bootstrap test.

Usage

achisq.stat(data, lambda=NULL)
achisq.test(formula, data, model, R, ...)

Arguments

formula

Formula that specifies the underlying model. The observed cases are the response and the expected number of cases must be specified as an offset in the log scale (see example below). Note that now it is not necessary to use Observed and Expected and that any other names can be used to specify the observed and expected cases.

model

Parametric model to be used in the bootstrap test. One of "param", "multinom", "poisson" or "negbin". See the DCluster manpage for details.

...

The remaining arguments in 'achisq.stat' not included in 'achisq.test'. This is done so because achisq.test calls achisq.stat in order to perform the test.

R

Number of replicates used in the test to compute the significance of the observed value of the test statistic.

data

A dataframe containing the data, as specified in the DCluster manpage.

lambda

The value of the relative risks under the null hypotheses. If its NULL, the second hypotheses commented above is considered and the expected number of cases will automatically be corrected.

Value

A list with three components

T

The value of the statistic.

df

Degrees of freedom of the asinthotic Chi-square distribution.

pvalue

Related pvalue.

References

Potthoff, R. F. and Whittinghill, M.(1966). Testing for Homogeneity: I. The Binomial and Multinomial Distributions. Biometrika 53, 167-182.

Potthoff, R. F. and Whittinghill, M.(1966). Testing for Homogeneity: The Poisson Distribution. Biometrika 53, 183-190.

See Also

DCluster, achisq, achisq.boot, achisq.pboot

Examples

library(spdep)

data(nc.sids)

sids<-data.frame(Observed=nc.sids$SID74)
sids<-cbind(sids, Expected=nc.sids$BIR74*sum(nc.sids$SID74)/sum(nc.sids$BIR74))

#Compute the statistic under the assumption that lambda = 1.
achisq.stat(sids, lambda=1)

#Perform test
achisq.test(Observed~offset(log(Expected)), sids, model="poisson", R=99)

DCluster documentation built on May 29, 2024, 3:41 a.m.