Learn R Programming

RVAideMemoire (version 0.9-45-2)

wald.ptheo.test: Wald test for comparison of a proportion to a theoretical value

Description

Performs a Wald test for comparison of a proportion to a theoretical value.

Usage

wald.ptheo.test(y, blocks = NULL, p = 0.5)

Arguments

y
either a binary response (numeric vector or factor, with only two possible values except NA) or a two-column matrix with the columns giving the numbers of successes (left) and failures (right).
blocks
optional blocking (random) factor.
p
hypothesized probability of success.

Value

  • methodname of the test.
  • data.namea character string giving the name(s) of the data.
  • statistictest statistics of the test.
  • p.valuep-value of the test.
  • estimatethe estimated proportion (calculated without taking into account the blocking factor, if present).
  • alternativea character string describing the alternative hypothesis, always "two.sided".
  • null.valuethe value of the proportion under the null hypothesis.

Details

The function builds a logistic (mixed) regression and applies a Wald test to compare the estimated value of the intercept to its theoretical value under H0. If the response is a 0/1 vector, the probability of the '1' group is tested. With other vectors, the response is transformed into a factor and the probability of the second level is tested. If the response is a two-column matrix, the probability of the left column is tested. If the reponse is a vector and no blocking factor is present, the exact binomial test performed by binom.test should be preferred since it is an exact test, whereas the Wald test is an approximate test.

See Also

binom.test, glm, glmer

Examples

Run this code
set.seed(2006)
response <- sample(0:1,60,replace=TRUE)

# Comparison to p=0.5
wald.ptheo.test(response)

# Comparison to p=0.8
wald.ptheo.test(response,p=0.8)

# With a blocking factor

require(lme4)
blocks <- gl(3,20)
wald.ptheo.test(response,blocks)

Run the code above in your browser using DataLab