# The examples reproduce the tolerance-of-antisocial-thinking illustration
# of Kelley and Rausch (2011, Tables 1 and 2), which draws on the National
# Youth Survey data also used by Raudenbush and Liu (2001). The level-one
# error variance is 0.0262 and the between-subject slope variance is 0.003.
# The planner finds the sample size needed for a confidence interval on the
# group-by-time slope difference that is no wider than `width`. The returned
# necessary_n_per_group is per group, so the total study size is twice that. Unlike
# power analysis, the value of the slope is not needed here: the confidence
# interval width does not depend on it.
# (1) Expected-width planning. With five measurement occasions
# (M = frequency * duration + 1 = 1 * 4 + 1) and a target width of
# 0.025, the expected 95% confidence interval is sufficiently narrow at
# 278 subjects per group (Kelley & Rausch, 2011, Table 1, T = 5).
ss_aipe_pcm(variance_trend = 0.003, error_variance = 0.0262,
duration = 4, frequency = 1, width = 0.025, conf_level = .95)
# (2) More measurement occasions sharpen the estimate. Extending the study
# so that M = 10 (duration = 9, frequency = 1) cuts the expected-width
# requirement from 278 to 165 per group (Kelley & Rausch, 2011, Table 1,
# T = 10).
ss_aipe_pcm(variance_trend = 0.003, error_variance = 0.0262,
duration = 9, frequency = 1, width = 0.025, conf_level = .95)
# (3) A wider tolerated interval costs less. Relaxing the target width from
# 0.025 to 0.05 at M = 5 drops the requirement from 278 to 71 per group
# (Kelley & Rausch, 2011, Table 1, T = 5).
ss_aipe_pcm(variance_trend = 0.003, error_variance = 0.0262,
duration = 4, frequency = 1, width = 0.05, conf_level = .95)
# (4) Adding an assurance parameter. Requiring 85% assurance that the
# realized confidence interval will be no wider than 0.025 raises the
# M = 5 requirement from 278 to 295 per group (Kelley & Rausch, 2011,
# Table 2, T = 5). Assurance guards against the expected-width plan being
# too small for the particular sample obtained.
ss_aipe_pcm(variance_trend = 0.003, error_variance = 0.0262,
duration = 4, frequency = 1, width = 0.025, conf_level = .95,
assurance = .85)
# (5) A higher assurance costs more. Demanding 99% assurance rather than 85%
# raises the per-group requirement further, from 295 to 316.
ss_aipe_pcm(variance_trend = 0.003, error_variance = 0.0262,
duration = 4, frequency = 1, width = 0.025, conf_level = .95,
assurance = .99)
Run the code above in your browser using DataLab