LRT.trend.test: Compute a test of trend in prevalences based on a...

View source: R/LRT.trend.R

LRT.trend.testR Documentation

Compute a test of trend in prevalences based on a likelihood-ratio statistic

Description

This function takes a series of point estimates and their associated standard errors and computes the p-value for the test of a monotone decrease in the population prevalences (in sequence order). The p-value for a monotone increase is also reported. An optional plot of the estimates and the null distribution of the test statistics is provided. More formally, let the K population prevalences in sequence order be p_1, \ldots, p_K. We test the null hypothesis:

H_0 : p_1 = \ldots = p_K

vs

H_1 : p_1 \ge p_2 \ldots \ge p_K

with at least one equality strict. The alternatie hypothesis is for a monotone decreasing trend. A likelihood ratio statistic for this test has been derived (Bartholomew 1959). The null distribution of the likelihood ratio statistic is very complex but can be determined by a simple Monte Carlo process.
Alternatively, we can test the null hypothesis:

H_0 : p_1 \ge p_2 \ldots \ge p_K

vs

H_1 : \overline{H_0}

The null distribution of the likelihood ratio statistic is very complex but can be determined by a simple Monte Carlo process. In both cases we also test for:

H : p_1 \le p_2 \ldots \le p_K

that is, a monotonically increasing trend. The function requires the isotone library.

Usage

LRT.trend.test(
  data,
  variables = colnames(data),
  null = "monotone",
  confidence.level = 0.95,
  number.of.bootstrap.samples = 5000,
  plot = NULL,
  seed = 1
)

Arguments

data

A two row matrix or data.frame of prevalence estimates and their standard errors. The first row is the prevalence estimates and the second are the standard errors. The column are the comparison groups in the order (e.g., time) there are to be assessed. The row names of data should be "estimate" and "sigma". This is

variables

A character vector of column names it select from data.

null

A character string indicating the null hypothesis to use. The value "monotone" uses the various monotone hypotheses as the nulls. If not "monotone", the null is chosen to be that of equality of the means over all periods.

confidence.level

The confidence level for the confidence intervals. The default is 0.95 for 95%.

number.of.bootstrap.samples

The number of Monte Carlo draws to determine the null distribution of the likelihood ratio statistic.

plot

A character vector of choices, a subset of estimates, distributions. If estimates is given then a plot of the estimates and nominal 95% confidence bands (as error bars) is produced. If distributions is given then a plot is produced of the null distributions of the likelihood ratio statistic with the observed likelihood ratio statistics plotted as a vertical dashed line.

seed

The value of the random number seed. Preset by default to allow reproducibility.

Value

A list with components

  • pvalue.increasing: The p-value for the test of a monotone increase in population prevalence.

  • pvalue.decreasing: The p-value for the test of a monotone decrease in population prevalence.

  • L: The value of the likelihood-ratio statistic.

  • x: The passed vector of prevalence estimates in the order (e.g., time).

  • sigma The passed vector of standard error estimates corresponding to x.

Author(s)

Mark S. Handcock

References

Bartholomew, D. J. (1959). A test of homogeneity for ordered alternatives. Biometrika 46 36-48.

Examples


d <- t(data.frame(estimate=c(0.16,0.15,0.3), sigma=c(0.04,0.04,0.1)))
colnames(d) <- c("time_1","time_2","time_3") 
LRT.trend.test(d,number.of.bootstrap.samples=1000)

RDS documentation built on Aug. 20, 2023, 9:06 a.m.