prop.test.clust: Test of Marginal Proportion for Clustered Data

Description Usage Arguments Details Value References Examples

View source: R/proptestclust.R

Description

prop.test.clust can be used for testing the null that the marginal proportion (probability of success) is equal to certain given values in clustered data with potentially informative cluster size.

Usage

1
2
3
4
5
6
7
8
prop.test.clust(
  x,
  id,
  p = NULL,
  alternative = c("two.sided", "less", "greater"),
  variance = c("sand.null", "sand.est", "emp", "MoM"),
  conf.level = 0.95
)

Arguments

x

a vector of binary indicators denoting success/failure of each observation, or a two-dimensional table (or matrix) with 2 columns giving the aggregate counts of failures and successes (respectively) across clusters.

id

a vector which identifies the clusters; ignored if x is a matrix or table. The length of id must be the same as the length of x.

p

the null hypothesized value of the marginal proportion. Must be a single number greater than 0 and less than 1.

alternative

a character string specifying the alternative hypothesis. Must be one of "two.sided", "greater", or "less". You can specify just the initial letter.

variance

character string specifying the method of variance estimation. Must be one of "sand.null", "sand.est", "emp", or "MoM".

conf.level

confidence level of the returned confidence interval. Must be a single number between 0 and 1.

Details

If p is not given, the null tested is that the underlying marginal probablity of success is .5.

The variance argument allows the user to specify the method of variance estimation, selecting from the sandwich estimate evaluated at the null hypothesis (sand.null), the sandwich estimate evaluated at the cluster-weighted proportion (sand.est), the emperical estimate (emp), or the method of moments estimate (MoM).

Value

A list with class "htest" containing the following compoments:

statistic

the value of the test statistic.

p.value

the p-value of the test.

estimate

the estimated marginal proportion.

null.value

the value of p under the null hypothesis.

conf.int

a confidence interval for the true marginal proportion.

alternative

a character string describing the alternative hypothesis.

method

a character string indicating the test performed and method of construction.

data.name

a character string giving the name of the data and the total number of clusters.

m

the number of clusters.

References

Gregg, M., Datta, S., Lorenz, D. (2020) Variance Estimation in Tests of Clustered Categorical Data with Informative Cluster Size. Submitted, xx, xx–xx.

Examples

1
2
3
data(icsdat)
prop.test.clust(icsdat$cat1, icsdat$id)
prop.test.clust(table(icsdat$id, icsdat$cat1), variance="emp")

megregg/TestPackage2 documentation built on Feb. 7, 2020, 12:24 a.m.