
Trend and heterogeneity tests
trend_heterogeneity.RmdTrend test
The trend() function carries out a chi-squared test for
trend (on 1 degree of freedom) on a vector of independent estimates. The
function arguments are a vector beta of independent
estimates and a vector se of their standard errors. The
function returns the test statistic and p-value in a named list.
Heterogeneity test
The heterogeneity() function carries out a a chi-squared
test (on
degrees of freedom) for heterogeneity on a vector of
independent estimates. The function arguments are a vector
beta of independent estimates and a vector se
of their standard errors. The function returns the test statistic,
degrees of freedom and p-value in a named list.
Example
These data are taken from Figure 3 of Du et al.
beta <- c(-0.47804, -0.46204, -0.40048)
se <- c(0.090005, 0.176823, 0.106565)
heterogeneity(beta, se)# $`test statistic`
# [1] 0.3165459
#
# $`degrees of freedom`
# [1] 2
#
# $p
# [1] 0.8536168
Methods
Trend
Suppose that we want to check whether estimates change progressively from one stratum (subgroup) to the next then we could use a chi-squared test for trend (on 1 degree of freedom).
The test statistic for trend given a vector of independent estimates and their standard errors is
where
and . This test statistic has a chi-squared distribution with 1 degree of freedom under the null hypothesis of no linear trend.
Heterogeneity
Suppose that information on the estimates for different strata (subgroups) are to be assessed in order to see if they differ between strata (i.e. effect modification) then a chi-squared test (on degrees of freedom) for heterogeneity between the estimates for the different strata can used.
The test statistic for heterogeneity given a vector of independent estimates and their standard errors is
where , which has a chi-squared distribution with degrees of freedom under the null hypothesis.
The test statistic can also be written as:
If there are only two strata (subgroups) then the tests for trend and heterogeneity are identical.
References
Armitage, P. Tests for Linear Trends in Proportions and Frequencies. Biometrics 11, 375–386 (1955). (Not open access)