achisq.stat | R Documentation |
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.
achisq.stat(data, lambda=NULL)
achisq.test(formula, data, model, R, ...)
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. |
A list with three components
T |
The value of the statistic. |
df |
Degrees of freedom of the asinthotic Chi-square distribution. |
pvalue |
Related pvalue. |
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.
DCluster, achisq, achisq.boot, achisq.pboot
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)
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.