Description Usage Arguments Value Details References See Also Examples
View source: R/CI_mdiff_contrast_bs.R
CI_mdiff_contrast_bs
returns the point estimate and confidence interval
for the mean difference in a linear contrast:
\mjdeqn \psi = \sum_i=1^ac_iM_i psi = sum(contrasts*means)
Where there are a groups, and M is each group mean and c is each group
weight; see Kline, equation 7.1
1 2 3 4 5 6 7 8 | CI_mdiff_contrast_bs(
means,
sds,
ns,
contrast,
conf_level = 0.95,
assume_equal_variance = FALSE
)
|
means |
A vector of 2 or more means |
sds |
A vector of standard deviations, same length as means |
ns |
A vector of sample sizes, same length as means |
contrast |
A vector of group weights, same length as means. |
conf_level |
The confidence level for the confidence interval in decimal form. Defaults to 0.95. |
assume_equal_variance |
Defaults to FALSE |
Returns a list with these named elements:
effect_size - the point estimate from the sample
lower - lower bound of the CI
upper - upper bound of the CI
df - degrees of freedom for the contrast
se - standard error
moe - margin of error
variability_component - if equal variance is assumed, returns sd_pooled; otherwise returns sd_avg
This function only takes in summary data and provides only the
minimal output. For a friendlier version of this function,
see estimate_mdiff_contrast_bs
If equal variance is assumed, the standard error is calculated as given in Kline, equation 7.8: \mjdeqn s_ \psi = \sqrtsd_pooled * (\sum_i=1^ac_i^2/n_i) s_psi = sd_pooled * sqrt(sum(contrast^2/ns)) where n is each group size and sd_pooled is the pooled standard deviation as given in Kline, equation 3.11: \mjdeqn sd_pooled = \frac \sum_i=1^a (n_i -1) s_i^2 \sum_i=1^a (n_i-1) sqrt(sum(variances*dfs) / sum(dfs))
where s is the standard deviation for each group.
Degrees of freedom for the analysis are calculated as given in Kline, equation 3.9: \mjdeqn df = \sum_i=1^an_i -1 sum(n-1)
If equal variance is not assumed, the standard error is calculated as given in Baguley, equation 15.11: \mjdeqn s_ \psi = \sqrt \sum_i=1^a \frac c_i^2 s_i^2 n_i s_psi = sqrt(sum(contrast^2 * variances / ns))
The degrees of freedom for the analysis are calculated as in Baguley, equation 15.12: \mjdeqn df = \frac s_ \psi ^4 \sum_i=1^a \fracc_i^4 s_i^4 n_i^2 (n_i -1) se_psi^4 / sum( (contrast^4) * (sds^4) / (ns^2*dfs))
And the analysis also returns sd_avg, the square root of the average of the group variances, as given in Bonett, explanation of equation 6: \mjdeqn sd_avg = \sqrt \frac \sum_i=1^a s_i^2 a sqrt(mean(variances))
Baguley, T. (2012). Serious Stats. In Serious stats: A guide to advanced statistics for the behavioral sciences. Macmillan Education UK. https://doi.org/10.1007/978-0-230-36355-7
Bonett, D. G. (2018). R code posted to personal website. https://people.ucsc.edu/~dgbonett/psyc204.html
Bonett, D. G. (2008). Confidence Intervals for Standardized Linear Contrasts of Means. Psychological Methods, 13(2), 99–109. https://doi.org/10.1037/1082-989X.13.2.99
Kline, R. B. (2013). Beyond significance testing: Statistics reform in the behavioral sciences (2nd ed.). American Psychological Association. https://doi.org/10.1037/14136-000
estimate_mdiff_contrast_bs
for friendly version of
this function
CI_smd_contrast_bs
to obtain a standardized
mean difference
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 | # Example from Kline, 2013
# Data in Table 3.4
# Worked out in Chapter 7
# See note to table 7.2
# With equal variance assumed and no correction, should give:
# psi = -2 95% CI [-5.23, 1.23] (see note to Table 7.2)
CI_mdiff_contrast_bs(
means = c(13, 11, 15),
sds = c(2.738613, 2.236068, 2.000000),
ns = c(5, 5, 5),
contrast = contrast <- c(1, 0, -1),
conf_level = 0.95,
assume_equal_variance = TRUE
)
# Example from Kline, 2013
# Data in Table 3.4
# Worked out in Chapter 7
# See note to table 7.2
# With equal variance assumed and no correction, should give:
# psi = 3 95% CI [0.20, 5.80] (see note to Table 7.2)
CI_mdiff_contrast_bs(
means = c(13, 11, 15),
sds = c(2.738613, 2.236068, 2.000000),
ns = c(5, 5, 5),
contrast = contrast <- c(1/2, -1, 1/2),
conf_level = 0.95,
assume_equal_variance = TRUE
)
# Example from Bonett, 2018, ci.lc.mean.bs,
# https://people.ucsc.edu/~dgbonett/psyc204.html
# Should give:
# Estimate SE df LL UL
# Equal Variances Assumed: -5.35 1.300136 36.00000 -7.986797 -2.713203
# Equal Variances Not Assumed: -5.35 1.300136 33.52169 -7.993583 -2.706417
CI_mdiff_contrast_bs(
means = c(33.5, 37.9, 38.0, 44.1),
sds = c(3.84, 3.84, 3.65, 4.98),
ns = c(10,10,10,10),
contrast = contrast <- c(.5, .5, -.5, -.5),
conf_level = 0.95,
assume_equal_variance = FALSE
)
|
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.