| Title: | Statistical Methods for Psychologists |
|---|---|
| Description: | Implements confidence interval and sample size methods that are especially useful in psychological research, but are also useful in business, social science, and biological research. The methods can be applied in 1-group, 2-group, paired-samples, and multiple-group designs and to a variety of parameters including means, medians, proportions, slopes, standardized mean differences, standardized linear contrasts of means, plus several measures of correlation and association. Confidence interval and sample size functions are given for single parameters as well as differences, ratios, and linear contrasts of parameters. The sample size functions can be used to approximate the sample size needed to estimate a parameter or function of parameters with desired confidence interval precision or to perform a variety of hypothesis tests (directional two-sided, equivalence, superiority, noninferiority) with desired power. For details see: Statistical Methods for Psychologists, Volumes 1 – 4, <https://dgbonett.sites.ucsc.edu/>. |
| Authors: | Douglas G. Bonett [aut, cre], Robert J. Calin-Jageman [ctb] |
| Maintainer: | Douglas G. Bonett <[email protected]> |
| License: | GPL-3 |
| Version: | 1.9.0 |
| Built: | 2026-05-17 20:29:14 UTC |
| Source: | https://github.com/dgbonett/statpsych |
Computes adjusted standard errors in a general linear model after one or more predictor variables with nonsignificant slopes have been dropped from the model. The adjusted standard errors are then used to compute adjusted t-values, p-values, and confidence intervals. The mean square error and error degrees of freedom from the full model are used to compute the adjusted standard errors. These adjusted results are less susceptible to the negative effects of an exploratory model selection.
For more details, see Section 2.25 of Bonett (2021, Volume 2)
adj.se(alpha, mse1, mse2, dfe1, se, b)adj.se(alpha, mse1, mse2, dfe1, se, b)
alpha |
alpha level for 1-alpha confidence |
mse1 |
mean squared error in full model |
mse2 |
mean squared error in selected model |
dfe1 |
error df in full model |
se |
vector of slope standard errors in selected model |
b |
vector of estimated slopes in selected model |
Returns adjusted standard error, t-statistic, p-value, and confidence interval for each slope coefficient
Bonett DG (2021). Statistical Methods for Psychologists https://dgbonett.sites.ucsc.edu/.
se <- c(1.57, 3.15, 0.982) b <- c(3.78, 8.21, 2.99) adj.se(.05, 10.26, 8.37, 114, se, b) # Should return: # Estimate adj SE t df p LL UL # [1,] 3.78 1.738243 2.174609 114 0.03173 0.3365531 7.223447 # [2,] 8.21 3.487559 2.354082 114 0.02028 1.3011734 15.118827 # [3,] 2.99 1.087233 2.750102 114 0.00693 0.8362007 5.143799se <- c(1.57, 3.15, 0.982) b <- c(3.78, 8.21, 2.99) adj.se(.05, 10.26, 8.37, 114, se, b) # Should return: # Estimate adj SE t df p LL UL # [1,] 3.78 1.738243 2.174609 114 0.03173 0.3365531 7.223447 # [2,] 8.21 3.487559 2.354082 114 0.02028 1.3011734 15.118827 # [3,] 2.99 1.087233 2.750102 114 0.00693 0.8362007 5.143799
Computes confidence intervals and tests for the AB interaction effect, main effect of A, main effect of B, simple main effects of A, and simple main effects of B in a 2x2 between-subjects factorial design with a quantitative response variable. A Satterthwaite adjustment to the degrees of freedom is used and equality of population variances is not assumed.
For more details, see Sections 3.8 and 3.9 of Bonett (2021, Volume 1)
ci.2x2.mean.bs(alpha, y11, y12, y21, y22)ci.2x2.mean.bs(alpha, y11, y12, y21, y22)
alpha |
alpha level for 1-alpha confidence |
y11 |
vector of scores at level 1 of A and level 1 of B |
y12 |
vector of scores at level 1 of A and level 2 of B |
y21 |
vector of scores at level 2 of A and level 1 of B |
y22 |
vector of scores at level 2 of A and level 2 of B |
Returns a 7-row matrix (one row per effect). The columns are:
Estimate - estimate of effect
SE - standard error
t - t test statistic
df - degrees of freedom
p - two-sided p-value
LL - lower limit of the confidence interval
UL - upper limit of the confidence interval
Bonett DG (2021). Statistical Methods for Psychologists https://dgbonett.sites.ucsc.edu/.
y11 <- c(14, 15, 11, 7, 16, 12, 15, 16, 10, 9) y12 <- c(18, 24, 14, 18, 22, 21, 16, 17, 14, 13) y21 <- c(16, 11, 10, 17, 13, 18, 12, 16, 6, 15) y22 <- c(18, 17, 11, 9, 9, 13, 18, 15, 14, 11) ci.2x2.mean.bs(.05, y11, y12, y21, y22) # Should return: # Estimate SE t df p LL UL # AB: -5.10 2.224860 -2.2923 35.48 0.02793 -9.6145264 -0.5854736 # A: 1.65 1.112430 1.4832 35.48 0.14684 -0.6072632 3.9072632 # B: -2.65 1.112430 -2.3822 35.48 0.02270 -4.9072632 -0.3927368 # A at b1: -0.90 1.545244 -0.5824 17.56 0.56768 -4.1522367 2.3522367 # A at b2: 4.20 1.600694 2.6239 17.94 0.01725 0.8362274 7.5637726 # B at a1: -5.20 1.536952 -3.3833 17.61 0.00339 -8.4341379 -1.9658621 # B at a2: -0.10 1.608657 -0.0622 17.92 0.95112 -3.4807927 3.2807927y11 <- c(14, 15, 11, 7, 16, 12, 15, 16, 10, 9) y12 <- c(18, 24, 14, 18, 22, 21, 16, 17, 14, 13) y21 <- c(16, 11, 10, 17, 13, 18, 12, 16, 6, 15) y22 <- c(18, 17, 11, 9, 9, 13, 18, 15, 14, 11) ci.2x2.mean.bs(.05, y11, y12, y21, y22) # Should return: # Estimate SE t df p LL UL # AB: -5.10 2.224860 -2.2923 35.48 0.02793 -9.6145264 -0.5854736 # A: 1.65 1.112430 1.4832 35.48 0.14684 -0.6072632 3.9072632 # B: -2.65 1.112430 -2.3822 35.48 0.02270 -4.9072632 -0.3927368 # A at b1: -0.90 1.545244 -0.5824 17.56 0.56768 -4.1522367 2.3522367 # A at b2: 4.20 1.600694 2.6239 17.94 0.01725 0.8362274 7.5637726 # B at a1: -5.20 1.536952 -3.3833 17.61 0.00339 -8.4341379 -1.9658621 # B at a2: -0.10 1.608657 -0.0622 17.92 0.95112 -3.4807927 3.2807927
Computes confidence intervals and tests for the AB interaction effect, main effect of A, main effect of B, simple main effects of A, and simple main effects of B in a 2x2 mixed factorial design with a quantitative response variable where Factor A is a within-subjects factor and Factor B is a between-subjects factor. A Satterthwaite adjustment to the degrees of freedom is used and equality of population variances is not assumed.
For more details, see Section 4.16 of Bonett (2021, Volume 1)
ci.2x2.mean.mixed(alpha, y11, y12, y21, y22)ci.2x2.mean.mixed(alpha, y11, y12, y21, y22)
alpha |
alpha level for 1-alpha confidence |
y11 |
vector of scores at level 1 of A and level 1 of B (group 1) |
y12 |
vector of scores at level 1 of A and level 2 of B (group 2) |
y21 |
vector of scores at level 2 of A and level 1 of B (group 1) |
y22 |
vector of scores at level 2 of A and level 2 of B (group 2) |
Returns a 7-row matrix (one row per effect). The columns are:
Estimate - estimate of effect
SE - standard error
t - t test statistic
df - degrees of freedom
p - two-sided p-value
LL - lower limit of the confidence interval
UL - upper limit of the confidence interval
Bonett DG (2021). Statistical Methods for Psychologists https://dgbonett.sites.ucsc.edu/.
y11 <- c(18, 19, 20, 17, 20, 16) y12 <- c(19, 16, 16, 14, 16, 18) y21 <- c(19, 18, 19, 20, 17, 16) y22 <- c(16, 10, 12, 9, 13, 15) ci.2x2.mean.mixed(.05, y11, y12, y21, y22) # Should return: # Estimate SE t df p LL UL # AB: -3.8333333 0.9803627 -3.9101 8.35 0.00412 -6.0778198 -1.588847 # A: 2.0833333 0.4901814 4.2501 8.35 0.00254 0.9610901 3.205577 # B: 3.7500000 1.0226599 3.6669 7.60 0.00693 1.3700362 6.129964 # A at b1: 0.1666667 0.8333333 0.2000 5.00 0.84936 -1.9754849 2.308818 # A at b2: 4.0000000 0.5163978 7.7460 5.00 0.00057 2.6725572 5.327443 # B at a1: 1.8333333 0.9803627 1.8701 9.94 0.09117 -0.3527241 4.019391 # B at a2: 5.6666667 1.2692955 4.4644 7.67 0.00233 2.7173445 8.615989y11 <- c(18, 19, 20, 17, 20, 16) y12 <- c(19, 16, 16, 14, 16, 18) y21 <- c(19, 18, 19, 20, 17, 16) y22 <- c(16, 10, 12, 9, 13, 15) ci.2x2.mean.mixed(.05, y11, y12, y21, y22) # Should return: # Estimate SE t df p LL UL # AB: -3.8333333 0.9803627 -3.9101 8.35 0.00412 -6.0778198 -1.588847 # A: 2.0833333 0.4901814 4.2501 8.35 0.00254 0.9610901 3.205577 # B: 3.7500000 1.0226599 3.6669 7.60 0.00693 1.3700362 6.129964 # A at b1: 0.1666667 0.8333333 0.2000 5.00 0.84936 -1.9754849 2.308818 # A at b2: 4.0000000 0.5163978 7.7460 5.00 0.00057 2.6725572 5.327443 # B at a1: 1.8333333 0.9803627 1.8701 9.94 0.09117 -0.3527241 4.019391 # B at a2: 5.6666667 1.2692955 4.4644 7.67 0.00233 2.7173445 8.615989
Computes confidence intervals and tests for the AB interaction effect, main effect of A, main effect of B, simple main effects of A, and simple main effects of B in a 2x2 within-subjects factorial design with a quantitative response variable.
For more details, see Section 4.14 of Bonett (2021, Volume 1)
ci.2x2.mean.ws(alpha, y11, y12, y21, y22)ci.2x2.mean.ws(alpha, y11, y12, y21, y22)
alpha |
alpha level for 1-alpha confidence |
y11 |
vector of scores at level 1 of A and level 1 of B |
y12 |
vector of scores at level 1 of A and level 2 of B |
y21 |
vector of scores at level 2 of A and level 1 of B |
y22 |
vector of scores at level 2 of A and level 2 of B |
Returns a 7-row matrix (one row per effect). The columns are:
Estimate - estimate of effect
SE - standard error
t - t test statistic
df - degrees of freedom
p - two-sided p-value
LL - lower limit of the confidence interval
UL - upper limit of the confidence interval
Bonett DG (2021). Statistical Methods for Psychologists https://dgbonett.sites.ucsc.edu/.
y11 <- c(1,2,3,4,5,7,7) y12 <- c(1,0,2,4,3,8,7) y21 <- c(4,5,6,7,8,9,8) y22 <- c(5,6,8,7,8,9,9) ci.2x2.mean.ws(.05, y11, y12, y21, y22) # Should return: # Estimate SE t df p LL UL # AB: 1.28571429 0.5654449 2.2738 6 0.06334 -0.09787945 2.66930802 # A: -3.21428571 0.4862042 -6.6110 6 0.00058 -4.40398462 -2.02458681 # B: -0.07142857 0.2296107 -0.3111 6 0.76626 -0.63326579 0.49040865 # A at b1: -2.57142857 0.2973809 -8.6469 6 0.00013 -3.29909331 -1.84376383 # A at b2: -3.85714286 0.7377111 -5.2285 6 0.00196 -5.66225692 -2.05202879 # B at a1: 0.57142857 0.4285714 1.3333 6 0.23081 -0.47724794 1.62010508 # B at a2: -0.71428571 0.2857143 -2.5000 6 0.04653 -1.41340339 -0.01516804y11 <- c(1,2,3,4,5,7,7) y12 <- c(1,0,2,4,3,8,7) y21 <- c(4,5,6,7,8,9,8) y22 <- c(5,6,8,7,8,9,9) ci.2x2.mean.ws(.05, y11, y12, y21, y22) # Should return: # Estimate SE t df p LL UL # AB: 1.28571429 0.5654449 2.2738 6 0.06334 -0.09787945 2.66930802 # A: -3.21428571 0.4862042 -6.6110 6 0.00058 -4.40398462 -2.02458681 # B: -0.07142857 0.2296107 -0.3111 6 0.76626 -0.63326579 0.49040865 # A at b1: -2.57142857 0.2973809 -8.6469 6 0.00013 -3.29909331 -1.84376383 # A at b2: -3.85714286 0.7377111 -5.2285 6 0.00196 -5.66225692 -2.05202879 # B at a1: 0.57142857 0.4285714 1.3333 6 0.23081 -0.47724794 1.62010508 # B at a2: -0.71428571 0.2857143 -2.5000 6 0.04653 -1.41340339 -0.01516804
Computes distribution-free confidence intervals for the AB interaction effect, main effect of A, main effect of B, simple main effects of A, and simple main effects of B in a 2x2 between-subjects factorial design with a quantitative response variable. The effects are defined in terms of medians rather than means. Tied scores within each group are assumed to be rare.
For more details, see Section 3.21 of Bonett (2021, Volume 1)
ci.2x2.median.bs(alpha, y11, y12, y21, y22)ci.2x2.median.bs(alpha, y11, y12, y21, y22)
alpha |
alpha level for 1-alpha confidence |
y11 |
vector of scores at level 1 of A and level 1 of B |
y12 |
vector of scores at level 1 of A and level 2 of B |
y21 |
vector of scores at level 2 of A and level 1 of B |
y22 |
vector of scores at level 2 of A and level 2 of B |
Returns a 7-row matrix (one row per effect). The columns are:
Estimate - estimate of effect
SE - standard error
LL - lower limit of the confidence interval
UL - upper limit of the confidence interval
Bonett DG, Price RM (2002). “Statistical inference for a linear function of medians: Confidence intervals, hypothesis testing, and sample size requirements.” Psychological Methods, 7(3), 370–383. ISSN 1939-1463. doi:10.1037/1082-989X.7.3.370.
Bonett DG (2021). Statistical Methods for Psychologists https://dgbonett.sites.ucsc.edu/.
y11 <- c(19.2, 21.1, 14.4, 13.3, 19.8, 15.9, 18.0, 19.1, 16.2, 14.6) y12 <- c(21.3, 27.0, 19.1, 21.5, 25.2, 24.1, 19.8, 19.7, 17.5, 16.0) y21 <- c(16.5, 11.3, 10.3, 17.7, 13.8, 18.2, 12.8, 16.2, 6.1, 15.2) y22 <- c(18.7, 17.3, 11.4, 12.4, 13.6, 13.8, 18.3, 15.0, 14.4, 11.9) ci.2x2.median.bs(.05, y11, y12, y21, y22) # Should return: # Estimate SE LL UL # AB: -3.850 2.951019 -9.633891 1.9338914 # A: 4.525 1.475510 1.633054 7.4169457 # B: -1.525 1.475510 -4.416946 1.3669457 # A at b1: 2.600 1.992028 -1.304302 6.5043022 # A at b2: 6.450 2.177232 2.182703 10.7172971 # B at a1: -3.450 2.045086 -7.458294 0.5582944 # B at a2: 0.400 2.127472 -3.769769 4.5697694y11 <- c(19.2, 21.1, 14.4, 13.3, 19.8, 15.9, 18.0, 19.1, 16.2, 14.6) y12 <- c(21.3, 27.0, 19.1, 21.5, 25.2, 24.1, 19.8, 19.7, 17.5, 16.0) y21 <- c(16.5, 11.3, 10.3, 17.7, 13.8, 18.2, 12.8, 16.2, 6.1, 15.2) y22 <- c(18.7, 17.3, 11.4, 12.4, 13.6, 13.8, 18.3, 15.0, 14.4, 11.9) ci.2x2.median.bs(.05, y11, y12, y21, y22) # Should return: # Estimate SE LL UL # AB: -3.850 2.951019 -9.633891 1.9338914 # A: 4.525 1.475510 1.633054 7.4169457 # B: -1.525 1.475510 -4.416946 1.3669457 # A at b1: 2.600 1.992028 -1.304302 6.5043022 # A at b2: 6.450 2.177232 2.182703 10.7172971 # B at a1: -3.450 2.045086 -7.458294 0.5582944 # B at a2: 0.400 2.127472 -3.769769 4.5697694
Computes distribution-free confidence intervals for the AB interaction effect, main effect of A, main effect of B, simple main effects of A, and simple main effects of B in a 2x2 mixed factorial design where Factor A is the within-subjects factor and Factor B is the between subjects factor. Tied scores within each group and within each within-subjects level are assumed to be rare.
ci.2x2.median.mixed(alpha, y11, y12, y21, y22)ci.2x2.median.mixed(alpha, y11, y12, y21, y22)
alpha |
alpha level for 1-alpha confidence |
y11 |
vector of scores at level 1 of A and level 1 of B (group 1) |
y12 |
vector of scores at level 1 of A and level 2 of B (group 2) |
y21 |
vector of scores at level 2 of A and level 1 of B (group 1) |
y22 |
vector of scores at level 2 of A and level 2 of B (group 2) |
Returns a 7-row matrix (one row per effect). The columns are:
Estimate - estimate of effect
SE - standard error
LL - lower limit of the confidence interval
UL - upper limit of the confidence interval
Bonett DG, Price RM (2020). “Interval estimation for linear functions of medians in within-subjects and mixed designs.” British Journal of Mathematical and Statistical Psychology, 73(2), 333–346. ISSN 0007-1102. doi:10.1111/bmsp.12171.
y11 <- c(18.3, 19.5, 20.1, 17.4, 20.5, 16.1) y12 <- c(19.2, 16.4, 16.5, 14.0, 16.9, 18.3) y21 <- c(19.1, 18.4, 19.8, 20.0, 17.2, 16.8) y22 <- c(16.5, 10.2, 12.7, 9.9, 13.5, 15.0) ci.2x2.median.mixed(.05, y11, y12, y21, y22) # Should return: # Estimate SE LL UL # AB: -3.450 1.6317863 -6.6482423 -0.2517577 # A: 1.875 0.8158931 0.2758788 3.4741212 # B: 3.925 1.4262367 1.1296274 6.7203726 # A at b1: 0.150 1.4243192 -2.6416144 2.9416144 # A at b2: 3.600 0.7962670 2.0393454 5.1606546 # B at a1: 2.200 1.5812792 -0.8992503 5.2992503 # B at a2: 5.650 1.7027101 2.3127496 8.9872504y11 <- c(18.3, 19.5, 20.1, 17.4, 20.5, 16.1) y12 <- c(19.2, 16.4, 16.5, 14.0, 16.9, 18.3) y21 <- c(19.1, 18.4, 19.8, 20.0, 17.2, 16.8) y22 <- c(16.5, 10.2, 12.7, 9.9, 13.5, 15.0) ci.2x2.median.mixed(.05, y11, y12, y21, y22) # Should return: # Estimate SE LL UL # AB: -3.450 1.6317863 -6.6482423 -0.2517577 # A: 1.875 0.8158931 0.2758788 3.4741212 # B: 3.925 1.4262367 1.1296274 6.7203726 # A at b1: 0.150 1.4243192 -2.6416144 2.9416144 # A at b2: 3.600 0.7962670 2.0393454 5.1606546 # B at a1: 2.200 1.5812792 -0.8992503 5.2992503 # B at a2: 5.650 1.7027101 2.3127496 8.9872504
Computes distribution-free confidence intervals for the AB interaction effect, main effect of A, main effect of B, simple main effects of A, and simple main effects of B in a 2x2 within-subjects factorial design. The effects are defined in terms of medians rather than means. Tied scores within each level combination are assumed to be rare.
ci.2x2.median.ws(alpha, y11, y12, y21, y22)ci.2x2.median.ws(alpha, y11, y12, y21, y22)
alpha |
alpha level for 1-alpha confidence |
y11 |
vector of scores at level 1 of A and level 1 of B |
y12 |
vector of scores at level 1 of A and level 2 of B |
y21 |
vector of scores at level 2 of A and level 1 of B |
y22 |
vector of scores at level 2 of A and level 2 of B |
Returns a 7-row matrix (one row per effect). The columns are:
Estimate - estimate of effect
SE - standard error
LL - lower limit of the confidence interval
UL - upper limit of the confidence interval
Bonett DG, Price RM (2020). “Interval estimation for linear functions of medians in within-subjects and mixed designs.” British Journal of Mathematical and Statistical Psychology, 73(2), 333–346. ISSN 0007-1102. doi:10.1111/bmsp.12171.
y11 <- c(222, 402, 333, 301, 284, 182, 281, 230, 290, 182, 133, 278) y12 <- c(221, 371, 340, 288, 293, 150, 317, 211, 286, 161, 126, 234) y21 <- c(219, 371, 314, 279, 284, 155, 278, 185, 296, 169, 118, 229) y22 <- c(170, 332, 280, 273, 272, 160, 260, 204, 252, 153, 137, 223) ci.2x2.median.ws(.05, y11, y12, y21, y22) # Should return: # Estimate SE LL UL # AB: 3.50 21.050122 -37.75748155 44.75748 # A: 24.25 9.603490 5.42750463 43.07250 # B: 17.75 9.101881 -0.08935904 35.58936 # A at b1: 26.00 11.813742 2.84549058 49.15451 # A at b2: 22.50 16.323093 -9.49267494 54.49267 # B at a1: 19.50 15.710347 -11.29171468 50.29171 # B at a2: 16.00 11.850202 -7.22596953 39.22597y11 <- c(222, 402, 333, 301, 284, 182, 281, 230, 290, 182, 133, 278) y12 <- c(221, 371, 340, 288, 293, 150, 317, 211, 286, 161, 126, 234) y21 <- c(219, 371, 314, 279, 284, 155, 278, 185, 296, 169, 118, 229) y22 <- c(170, 332, 280, 273, 272, 160, 260, 204, 252, 153, 137, 223) ci.2x2.median.ws(.05, y11, y12, y21, y22) # Should return: # Estimate SE LL UL # AB: 3.50 21.050122 -37.75748155 44.75748 # A: 24.25 9.603490 5.42750463 43.07250 # B: 17.75 9.101881 -0.08935904 35.58936 # A at b1: 26.00 11.813742 2.84549058 49.15451 # A at b2: 22.50 16.323093 -9.49267494 54.49267 # B at a1: 19.50 15.710347 -11.29171468 50.29171 # B at a2: 16.00 11.850202 -7.22596953 39.22597
Computes adjusted Wald confidence intervals and tests for the AB interaction effect, main effect of A, main effect of B, simple main effects of A, and simple main effects of B in a 2x2 between-subjects factorial design with a dichotomous response variable. The input vector of frequency counts is f = [ f11, f12, f21, f22 ], and the input vector of sample sizes is n = [ n11, n12, n21, n22 ] where the first subscript represents the levels of Factor A and the second subscript represents the levels of Factor B.
For more details, see Section 2.14 of Bonett (2021, Volume 3)
ci.2x2.prop.bs(alpha, f, n)ci.2x2.prop.bs(alpha, f, n)
alpha |
alpha level for 1-alpha confidence |
f |
vector of frequency counts of participants who have the attribute |
n |
vector of sample sizes |
Returns a 7-row matrix (one row per effect). The columns are:
Estimate - adjusted estimate of effect
SE - standard error
z - z test statistic
p - two-sided p-value
LL - lower limit of the adjusted Wald confidence interval
UL - upper limit of the adjusted Wald confidence interval
Bonett DG (2021). Statistical Methods for Psychologists https://dgbonett.sites.ucsc.edu/.
Price RM, Bonett DG (2004). “An improved confidence interval for a linear function of binomial proportions.” Computational Statistics & Data Analysis, 45(3), 449–456. ISSN 01679473. doi:10.1016/S0167-9473(03)00007-0.
f <- c(15, 24, 28, 23) n <- c(50, 50, 50, 50) ci.2x2.prop.bs(.05, f, n) # Should return: # Estimate SE z p LL UL # AB: -0.27450980 0.13692496 -2.0048 0.04498 -0.54287780 -0.00614181 # A: -0.11764706 0.06846248 -1.7184 0.08572 -0.25183106 0.01653694 # B: -0.03921569 0.06846248 -0.5728 0.56678 -0.17339968 0.09496831 # A at b1: -0.25000000 0.09402223 -2.6589 0.00784 -0.43428019 -0.06571981 # A at b2: 0.01923077 0.09787658 0.1965 0.84423 -0.17260380 0.21106534 # B at a1: -0.17307692 0.09432431 -1.8349 0.06652 -0.35794917 0.01179533 # B at a2: 0.09615385 0.09758550 0.9853 0.32446 -0.09511021 0.28741790f <- c(15, 24, 28, 23) n <- c(50, 50, 50, 50) ci.2x2.prop.bs(.05, f, n) # Should return: # Estimate SE z p LL UL # AB: -0.27450980 0.13692496 -2.0048 0.04498 -0.54287780 -0.00614181 # A: -0.11764706 0.06846248 -1.7184 0.08572 -0.25183106 0.01653694 # B: -0.03921569 0.06846248 -0.5728 0.56678 -0.17339968 0.09496831 # A at b1: -0.25000000 0.09402223 -2.6589 0.00784 -0.43428019 -0.06571981 # A at b2: 0.01923077 0.09787658 0.1965 0.84423 -0.17260380 0.21106534 # B at a1: -0.17307692 0.09432431 -1.8349 0.06652 -0.35794917 0.01179533 # B at a2: 0.09615385 0.09758550 0.9853 0.32446 -0.09511021 0.28741790
Computes adjusted Wald confidence intervals and tests for the AB interaction effect, main effect of A, main effect of B, simple main effects of A, and simple main effects of B in a 2x2 mixed factorial design with a dichotomous response variable where Factor A is a within-subjects factor and Factor B is a between-subjects factor. The 4x1 vector of frequency counts for Factor A within each group is f00, f01, f10, f11 where fij is the number of participants with a response of i = 0 or 1 at level 1 of Factor A and a response of j = 0 or 1 at level 2 of Factor A.
For more details, see Section 2.2 of Bonett (2021, Volume 3)
ci.2x2.prop.mixed(alpha, group1, group2)ci.2x2.prop.mixed(alpha, group1, group2)
alpha |
alpha level for 1-alpha confidence |
group1 |
vector of frequency counts from 2x2 contingency table in group 1 |
group2 |
vector of frequency counts from 2x2 contingency table in group 2 |
Returns a 7-row matrix (one row per effect). The columns are:
Estimate - adjusted estimate of effect
SE - standard error of estimate
z - z test statistic
p - two-sided p-value
LL - lower limit of the adjusted Wald confidence interval
UL - upper limit of the adjusted Wald confidence interval
Bonett DG (2021). Statistical Methods for Psychologists https://dgbonett.sites.ucsc.edu/.
group1 <- c(125, 14, 10, 254) group2 <- c(100, 16, 9, 275) ci.2x2.prop.mixed (.05, group1, group2) # Should return: # Estimate SE z p LL UL # AB: 0.007555369 0.017716073 0.4265 0.66976 -0.02716750 0.042278234 # A: -0.013678675 0.008858036 -1.5442 0.12254 -0.03104011 0.003682758 # B: -0.058393219 0.023032656 -2.5352 0.01124 -0.10353640 -0.013250043 # A at b1: -0.009876543 0.012580603 -0.7851 0.43242 -0.03453407 0.014780985 # A at b2: -0.017412935 0.012896543 -1.3502 0.17695 -0.04268969 0.007863824 # B at a1: -0.054634236 0.032737738 -1.6688 0.09515 -0.11879902 0.009530550 # B at a2: -0.062170628 0.032328556 -1.9231 0.05447 -0.12553343 0.001192177group1 <- c(125, 14, 10, 254) group2 <- c(100, 16, 9, 275) ci.2x2.prop.mixed (.05, group1, group2) # Should return: # Estimate SE z p LL UL # AB: 0.007555369 0.017716073 0.4265 0.66976 -0.02716750 0.042278234 # A: -0.013678675 0.008858036 -1.5442 0.12254 -0.03104011 0.003682758 # B: -0.058393219 0.023032656 -2.5352 0.01124 -0.10353640 -0.013250043 # A at b1: -0.009876543 0.012580603 -0.7851 0.43242 -0.03453407 0.014780985 # A at b2: -0.017412935 0.012896543 -1.3502 0.17695 -0.04268969 0.007863824 # B at a1: -0.054634236 0.032737738 -1.6688 0.09515 -0.11879902 0.009530550 # B at a2: -0.062170628 0.032328556 -1.9231 0.05447 -0.12553343 0.001192177
Computes confidence intervals for standardized AB interaction effect, main effect of A, main effect of B, simple main effects of A, and simple main effects of B in a 2x2 between-subjects factorial design with a quantitative response variable. Equality of population variances is not assumed. A square root unweighted average variance standardizer is used, which is the recommended standardizer when both factors are treatment factors.
ci.2x2.stdmean.bs(alpha, y11, y12, y21, y22)ci.2x2.stdmean.bs(alpha, y11, y12, y21, y22)
alpha |
alpha level for 1-alpha confidence |
y11 |
vector of scores at level 1 of A and level 1 of B |
y12 |
vector of scores at level 1 of A and level 2 of B |
y21 |
vector of scores at level 2 of A and level 1 of B |
y22 |
vector of scores at level 2 of A and level 2 of B |
Returns a 7-row matrix (one row per effect). The columns are:
Estimate - estimate of standardized effect
adj Estimate - bias adjusted estimate of standardized effect
SE - standard error
LL - lower limit of the confidence interval
UL - upper limit of the confidence interval
Bonett DG (2008). “Confidence intervals for standardized linear contrasts of means.” Psychological Methods, 13(2), 99–109. ISSN 1939-1463. doi:10.1037/1082-989X.13.2.99.
y11 <- c(14, 15, 11, 7, 16, 12, 15, 16, 10, 9) y12 <- c(18, 24, 14, 18, 22, 21, 16, 17, 14, 13) y21 <- c(16, 11, 10, 17, 13, 18, 12, 16, 6, 15) y22 <- c(18, 17, 11, 9, 9, 13, 18, 15, 14, 11) ci.2x2.stdmean.bs(.05, y11, y12, y21, y22) # Should return: # Estimate adj Estimate SE LL UL # AB: -1.4498 -1.4194 0.68852 -2.7992 -0.1003 # A: 0.4690 0.4592 0.33795 -0.1933 1.1314 # B: -0.7533 -0.7375 0.34512 -1.4297 -0.0769 # A at b1: -0.2558 -0.2505 0.46402 -1.1653 0.6536 # A at b2: 1.1939 1.1689 0.50014 0.2137 2.1742 # B at a1: -1.4782 -1.4472 0.49284 -2.4441 -0.5122 # B at a2: -0.0284 -0.0278 0.48204 -0.9732 0.9163y11 <- c(14, 15, 11, 7, 16, 12, 15, 16, 10, 9) y12 <- c(18, 24, 14, 18, 22, 21, 16, 17, 14, 13) y21 <- c(16, 11, 10, 17, 13, 18, 12, 16, 6, 15) y22 <- c(18, 17, 11, 9, 9, 13, 18, 15, 14, 11) ci.2x2.stdmean.bs(.05, y11, y12, y21, y22) # Should return: # Estimate adj Estimate SE LL UL # AB: -1.4498 -1.4194 0.68852 -2.7992 -0.1003 # A: 0.4690 0.4592 0.33795 -0.1933 1.1314 # B: -0.7533 -0.7375 0.34512 -1.4297 -0.0769 # A at b1: -0.2558 -0.2505 0.46402 -1.1653 0.6536 # A at b2: 1.1939 1.1689 0.50014 0.2137 2.1742 # B at a1: -1.4782 -1.4472 0.49284 -2.4441 -0.5122 # B at a2: -0.0284 -0.0278 0.48204 -0.9732 0.9163
Computes confidence intervals for the standardized AB interaction effect, main effect of A, main effect of B, simple main effects of A, and simple main effects of B in a 2x2 mixed factorial design where Factor A is a within-subjects factor, and Factor B is a between-subjects factor. Equality of population variances is not assumed. A square root unweighted average variance standardizer is used.
ci.2x2.stdmean.mixed(alpha, y11, y12, y21, y22)ci.2x2.stdmean.mixed(alpha, y11, y12, y21, y22)
alpha |
alpha level for 1-alpha confidence |
y11 |
vector of scores at level 1 of A and level 1 of B (group 1) |
y12 |
vector of scores at level 1 of A and level 2 of B (group 2) |
y21 |
vector of scores at level 2 of A and level 1 of B (group 1) |
y22 |
vector of scores at level 2 of A and level 2 of B (group 2) |
Returns a 7-row matrix (one row per effect). The columns are:
Estimate - estimated standardized effect
adj Estimate - bias adjusted standardized effect estimate
SE - standard error
LL - lower limit of the confidence interval
UL - upper limit of the confidence interval
Bonett DG (2008). “Confidence intervals for standardized linear contrasts of means.” Psychological Methods, 13(2), 99–109. ISSN 1939-1463. doi:10.1037/1082-989X.13.2.99.
y11 <- c(18, 19, 20, 17, 20, 16) y12 <- c(19, 16, 16, 14, 16, 18) y21 <- c(19, 18, 19, 20, 17, 16) y22 <- c(16, 10, 12, 9, 13, 15) ci.2x2.stdmean.mixed(.05, y11, y12, y21, y22) # Should return: # Estimate adj Estimate SE LL UL # AB: -1.9515 -1.8014 0.54074 -3.0114 -0.8917 # A: 1.0606 1.0113 0.27977 0.5123 1.6090 # B: 1.9091 1.7623 0.57589 0.7804 3.0378 # A at b1: 0.0848 0.0759 0.46504 -0.8266 0.9963 # A at b2: 2.0364 1.8214 0.29956 1.4493 2.6235 # B at a1: 0.9333 0.8615 0.50364 -0.0538 1.9205 # B at a2: 2.8849 2.6630 0.74772 1.4194 4.3504y11 <- c(18, 19, 20, 17, 20, 16) y12 <- c(19, 16, 16, 14, 16, 18) y21 <- c(19, 18, 19, 20, 17, 16) y22 <- c(16, 10, 12, 9, 13, 15) ci.2x2.stdmean.mixed(.05, y11, y12, y21, y22) # Should return: # Estimate adj Estimate SE LL UL # AB: -1.9515 -1.8014 0.54074 -3.0114 -0.8917 # A: 1.0606 1.0113 0.27977 0.5123 1.6090 # B: 1.9091 1.7623 0.57589 0.7804 3.0378 # A at b1: 0.0848 0.0759 0.46504 -0.8266 0.9963 # A at b2: 2.0364 1.8214 0.29956 1.4493 2.6235 # B at a1: 0.9333 0.8615 0.50364 -0.0538 1.9205 # B at a2: 2.8849 2.6630 0.74772 1.4194 4.3504
Computes confidence intervals for standardized AB interaction effect, main effect of A, main effect of B, simple main effects of A, and simple main effects of B in a 2x2 within-subjects factorial design. Equality of population variances is not assumed. A square root unweighted average variance standardizer is used.
ci.2x2.stdmean.ws(alpha, y11, y12, y21, y22)ci.2x2.stdmean.ws(alpha, y11, y12, y21, y22)
alpha |
alpha level for 1-alpha confidence |
y11 |
vector of scores at level 1 of A and level 1 of B |
y12 |
vector of scores at level 1 of A and level 2 of B |
y21 |
vector of scores at level 2 of A and level 1 of B |
y22 |
vector of scores at level 2 of A and level 2 of B |
Returns a 7-row matrix (one row per effect). The columns are:
Estimate - estimated standardized effect
adj Estimate - bias adjusted standardized effect estimate
SE - standard error
LL - lower limit of the confidence interval
UL - upper limit of the confidence interval
Bonett DG (2008). “Confidence intervals for standardized linear contrasts of means.” Psychological Methods, 13(2), 99–109. ISSN 1939-1463. doi:10.1037/1082-989X.13.2.99.
y11 <- c(21, 39, 32, 29, 27, 17, 27, 21, 28, 17, 12, 27) y12 <- c(20, 36, 33, 27, 28, 14, 30, 20, 27, 15, 11, 22) y21 <- c(21, 36, 30, 27, 28, 15, 27, 18, 29, 16, 11, 22) y22 <- c(18, 34, 29, 28, 28, 17, 27, 21, 26, 16, 14, 23) ci.2x2.stdmean.ws(.05, y11, y12, y21, y22) # Should return: # Estimate adj Estimate SE LL UL # AB: 0.1725 0.1645 0.13655 -0.0951 0.4401 # A: 0.1092 0.1042 0.05753 -0.0035 0.2220 # B: 0.0747 0.0713 0.05921 -0.0413 0.1908 # A at b1: 0.1955 0.1864 0.08461 0.0297 0.3613 # A at b2: 0.0230 0.0219 0.09372 -0.1607 0.2067 # B at a1: 0.1610 0.1535 0.09457 -0.0244 0.3463 # B at a2: -0.0115 -0.0110 0.08596 -0.1800 0.1570y11 <- c(21, 39, 32, 29, 27, 17, 27, 21, 28, 17, 12, 27) y12 <- c(20, 36, 33, 27, 28, 14, 30, 20, 27, 15, 11, 22) y21 <- c(21, 36, 30, 27, 28, 15, 27, 18, 29, 16, 11, 22) y22 <- c(18, 34, 29, 28, 28, 17, 27, 21, 26, 16, 14, 23) ci.2x2.stdmean.ws(.05, y11, y12, y21, y22) # Should return: # Estimate adj Estimate SE LL UL # AB: 0.1725 0.1645 0.13655 -0.0951 0.4401 # A: 0.1092 0.1042 0.05753 -0.0035 0.2220 # B: 0.0747 0.0713 0.05921 -0.0413 0.1908 # A at b1: 0.1955 0.1864 0.08461 0.0297 0.3613 # A at b2: 0.0230 0.0219 0.09372 -0.1607 0.2067 # B at a1: 0.1610 0.1535 0.09457 -0.0244 0.3463 # B at a2: -0.0115 -0.0110 0.08596 -0.1800 0.1570
Computes an adjusted Wald confidence interval for a G-index of agreement between two polychotomous ratings. This function requires the number of objects that were given the same rating by both raters. The G-index corrects for chance agreement. The G-index is a better measure of agreement than Cohen's kappa, and the confidence interval for the G-index used here has better small-sample properties than the confidence interval for Cohen's kappa.
For more details, see Section 3.5 of Bonett (2021, Volume 3)
ci.agree(alpha, n, f, k)ci.agree(alpha, n, f, k)
alpha |
alpha level for 1-alpha confidence |
n |
sample size |
f |
number of objects rated in agreement |
k |
number of rating categories |
Returns a 1-row matrix. The columns are:
Estimate - maximum likelihood estimate of G-index
SE - standard error
LL - lower limit of the adjusted Wald confidence interval
UL - upper limit of the adjusted Wald confidence interval
Bonett DG (2022). “Statistical inference for G-indices of agreement.” Journal of Educational and Behavioral Statistics, 47(4), 438–458. doi:10.3102/10769986221088561.
Bonett DG (2021). Statistical Methods for Psychologists https://dgbonett.sites.ucsc.edu/.
ci.agree(.05, 250, 214, 3) # Should return: # Estimate SE LL UL # 0.784 0.03331 0.7098 0.8414ci.agree(.05, 250, 214, 3) # Should return: # Estimate SE LL UL # 0.784 0.03331 0.7098 0.8414
Computes adjusted Wald confidence intervals for a G-index of agreement for all pairs of raters in a 3-rater design with a dichotomous rating, and computes adjusted Wald confidence intervals for differences of all pairs of G agreement. An adjusted Wald confidence interval for unanimous G agreement among the three raters is also computed. In the three-rater design, unanimous G agreement is equal to the average of all pairs of G agreement. The G-index corrects for chance agreement.
ci.agree.3rater(alpha, f)ci.agree.3rater(alpha, f)
alpha |
alpha level for 1-alpha confidence |
f |
vector of frequency counts from 2x2x2 table where f = [ f111, f112, f121, f122, f211, f212, f221, f222 ], first subscript represents the rating of rater 1, second subscript represents the rating of rater 2, and third subscript represents the rating of rater 3 |
Returns a 7-row matrix. The rows are:
G(1,2): G-index for raters 1 and 2
G(1,3): G-index for raters 1 and 3
G(2,3): G-index for raters 2 and 3
G(1,2)-G(1,3): difference in G(1,2) and G(1,3)
G(1,2)-G(2,3): difference in G(1,2) and G(2,3)
G(2,3)-G(1,3): difference in G(2,3) and G(1,3)
G(3): G-index of unanimous agreement for all three raters
The columns are:
Estimate - estimate of G-index (two-rater, difference, or unanimous)
LL - lower limit of adjusted Wald confidence interval
UL - upper limit of adjusted Wald confidence interval
Bonett DG (2022). “Statistical inference for G-indices of agreement.” Journal of Educational and Behavioral Statistics, 47(4), 438–458. doi:10.3102/10769986221088561.
f <- c(100, 6, 4, 40, 20, 1, 9, 120) ci.agree.3rater(.05, f) # Should return: # Estimate LL UL # G(1,2) 0.5667 0.4660 0.6524 # G(1,3) 0.5000 0.3956 0.5912 # G(2,3) 0.8667 0.7970 0.9135 # G(1,2)-G(1,3) 0.0667 0.0058 0.1266 # G(1,2)-G(2,3) -0.3000 -0.4068 -0.1892 # G(2,3)-G(1,3) -0.3667 -0.4622 -0.2663 # G(3) 0.6444 0.5738 0.7069f <- c(100, 6, 4, 40, 20, 1, 9, 120) ci.agree.3rater(.05, f) # Should return: # Estimate LL UL # G(1,2) 0.5667 0.4660 0.6524 # G(1,3) 0.5000 0.3956 0.5912 # G(2,3) 0.8667 0.7970 0.9135 # G(1,2)-G(1,3) 0.0667 0.0058 0.1266 # G(1,2)-G(2,3) -0.3000 -0.4068 -0.1892 # G(2,3)-G(1,3) -0.3667 -0.4622 -0.2663 # G(3) 0.6444 0.5738 0.7069
Computes adjusted Wald confidence intervals for the G-index of agreement within each group and the difference of G-indices.
For more details, see Section 3.5 of Bonett (2021, Volume 3)
ci.agree2(alpha, n1, f1, n2, f2, k)ci.agree2(alpha, n1, f1, n2, f2, k)
alpha |
alpha level for 1-alpha confidence |
n1 |
sample size (objects) in group 1 |
f1 |
number of objects rated in agreement in group 1 |
n2 |
sample size (objects) in group 2 |
f2 |
number of objects rated in agreement in group 2 |
k |
number of rating categories |
Returns a 3-row matrix. The rows are:
Row 1: G-index for group 1
Row 2: G-index for group 2
Row 3: G-index difference
The columns are:
Estimate - maximum likelihood estimate of G-index and difference
SE - standard error
LL - lower limit of adjusted Wald confidence interval
UL - upper limit of adjusted Wald confidence interval
Bonett DG (2022). “Statistical inference for G-indices of agreement.” Journal of Educational and Behavioral Statistics, 47(4), 438–458. doi:10.3102/10769986221088561.
Bonett DG (2021). Statistical Methods for Psychologists https://dgbonett.sites.ucsc.edu/.
ci.agree2(.05, 75, 70, 60, 45, 2) # Should return: # Estimate SE LL UL # G1 0.8667 0.02880 0.6975 0.9481 # G2 0.5000 0.05590 0.2523 0.6852 # G1 - G2 0.3667 0.06289 0.1117 0.6089ci.agree2(.05, 75, 70, 60, 45, 2) # Should return: # Estimate SE LL UL # G1 0.8667 0.02880 0.6975 0.9481 # G2 0.5000 0.05590 0.2523 0.6852 # G1 - G2 0.3667 0.06289 0.1117 0.6089
Computes an approximate Bayesian credible interval for a Pearson or partial correlation with a skeptical prior. The skeptical prior distribution is Normal with a mean of 0 and a small standard deviation. A skeptical prior assumes that the population correlation is within a range of small values (-r to r). If the skeptic is 95% confident that the population correlation is between -r and r, then the prior standard deviation can be set to r/1.96. A correlation that is less than .2 in absolute value is typically considered to be "small", and the prior standard deviation could then be set to .2/1.96. A correlation value that is considered to be small will depend on the application. Set s = 0 for a Pearson correlation.
For more details, see Section 1.33 of Bonett (2021, Volume 2)
ci.bayes.cor(alpha, prior_sd, cor, s, n)ci.bayes.cor(alpha, prior_sd, cor, s, n)
alpha |
alpha level for 1-alpha credibility interval |
prior_sd |
standard deviation of skeptical prior distribution |
cor |
estimated Pearson or partial correlation |
s |
number of control variables |
n |
sample size |
Returns a 1-row matrix. The columns are:
Posterior mean - posterior mean (Bayesian estimate of correlation)
LL - lower limit of the credible interval
UL - upper limit of the credible interval
Bonett DG (2021). Statistical Methods for Psychologists https://dgbonett.sites.ucsc.edu/.
ci.bayes.cor(.05, .1, .536, 0, 50) # Should return: # Posterior mean LL UL # 0.1874 0.028 0.3375 ci.bayes.cor(.05, .1, .536, 0, 300) # Should return: # Posterior mean LL UL # 0.4195 0.3352 0.4971ci.bayes.cor(.05, .1, .536, 0, 50) # Should return: # Posterior mean LL UL # 0.1874 0.028 0.3375 ci.bayes.cor(.05, .1, .536, 0, 300) # Should return: # Posterior mean LL UL # 0.4195 0.3352 0.4971
Computes an approximate Bayesian credible interval for a normal prior distribution. This function can be used with any parameter estimator (e.g., mean, mean difference, linear contrast of means, slope coefficient, standardized mean difference, standardized linear contrast of means, median, median difference, linear contrast of medians, etc.) that has an approximate normal sampling distribution. The mean and standard deviation of the posterior normal distribution are also reported.
For more details, see Section 1.32 of Bonett (2021, Volume 1)
ci.bayes.normal(alpha, prior_mean, prior_sd, est, se)ci.bayes.normal(alpha, prior_mean, prior_sd, est, se)
alpha |
alpha level for 1-alpha credibility interval |
prior_mean |
mean of prior Normal distribution |
prior_sd |
standard deviation of prior Normal distribution |
est |
sample estimate |
se |
standard error of sample estimate |
Returns a 1-row matrix. The columns are:
Posterior mean - posterior mean of Normal distribution
Posterior SD - posterior standard deviation of Normal distribution
LL - lower limit of the credible interval
UL - upper limit of the credible interval
Gelman A, Carlin JB, Stern HS, Rubin DB (2004). Bayesian Data Analysis, 2nd edition. Chapman & Hall.
Bonett DG (2021). Statistical Methods for Psychologists https://dgbonett.sites.ucsc.edu/.
ci.bayes.normal(.05, 50, 5, 38.3, 2.57) # Should return: # Posterior mean Posterior SD LL UL # 40.74511 2.285735 36.26515 45.22506ci.bayes.normal(.05, 50, 5, 38.3, 2.57) # Should return: # Posterior mean Posterior SD LL UL # 40.74511 2.285735 36.26515 45.22506
Computes a Bayesian credible interval for a population proportion using the mean and standard deviation of a prior Beta distribution along with sample information. The mean and standard deviation of the posterior Beta distribution are also reported. For a noninformative prior, set the prior mean to .5 and the prior standard deviation to 1/sqrt(12) (which corresponds to a Beta(1,1) distribution). The prior variance must be less than m(1 - m) where m is the prior mean.
For more details, see Section 1.18 of Bonett (2021, Volume 3)
ci.bayes.prop(alpha, prior_mean, prior_sd, f, n)ci.bayes.prop(alpha, prior_mean, prior_sd, f, n)
alpha |
alpha level for 1-alpha credibility interval |
prior_mean |
mean of prior Beta distribution |
prior_sd |
standard deviation of prior Beta distribution |
f |
number of participants who have the attribute |
n |
sample size |
Returns a 1-row matrix. The columns are:
Posterior mean - posterior mean of Beta distribution
Posterior SD - posterior standard deviation of Beta distribution
LL - lower limit of the credible interval
UL - upper limit of the credible interval
Gelman A, Carlin JB, Stern HS, Rubin DB (2004). Bayesian Data Analysis, 2nd edition. Chapman & Hall.
Bonett DG (2021). Statistical Methods for Psychologists https://dgbonett.sites.ucsc.edu/.
ci.bayes.prop(.05, .25, .1, 120, 300) # Should return: # Posterior mean Posterior SD LL UL # 0.3916208 0.02742595 0.3387206 0.4458133ci.bayes.prop(.05, .25, .1, 120, 300) # Should return: # Posterior mean Posterior SD LL UL # 0.3916208 0.02742595 0.3387206 0.4458133
Computes an approximate Bayesian credible interval for a semipartial correlation with a skeptical prior. The skeptical prior distribution is Normal with a mean of 0 and a small standard deviation. A skeptical prior assumes that the population semipartial correlation is within a range of small values (-r to r). If the skeptic is 95% confident that the population correlation is between -r and r, then the prior standard deviation can be set to r/1.96. A semipartial correlation that is less than .2 in absolute value is typically considered to be "small", and the prior standard deviation could then be set to .2/1.96. A semipartial correlation value that is considered to be small will depend on the application. This function requires the standard error of the estimated semipartial correlation which can be obtained from the ci.spcor function.
For more details, see Section 2.36 of Bonett (2021, Volume 2)
ci.bayes.spcor(alpha, prior_sd, cor, se)ci.bayes.spcor(alpha, prior_sd, cor, se)
alpha |
alpha level for 1-alpha credibility interval |
prior_sd |
standard deviation of skeptical prior distribution |
cor |
estimated semipartial partial correlation |
se |
standard error of estimated semipartial correlation |
Returns a 1-row matrix. The columns are:
Posterior mean - posterior mean (Bayesian estimate of correlation)
LL - lower limit of the credible interval
UL - upper limit of the credible interval
Bonett DG (2021). Statistical Methods for Psychologists https://dgbonett.sites.ucsc.edu/.
ci.bayes.spcor(.05, .1, .582, .137) # Should return: # Posterior mean LL UL # 0.2273 0.0729 0.371ci.bayes.spcor(.05, .1, .582, .137) # Should return: # Posterior mean LL UL # 0.2273 0.0729 0.371
Computes a confidence interval for a population biserial-phi correlation using a transformation of a confidence interval for an odds ratio with .5 added to each cell frequency. This measure of association assumes the group variable is naturally dichotomous and the response variable is artificially dichotomous.
For more details, see Section 3.4 of Bonett (2021, Volume 3)
ci.biphi(alpha, f1, f2, n1, n2)ci.biphi(alpha, f1, f2, n1, n2)
alpha |
alpha level for 1-alpha confidence |
f1 |
number of participants in group 1 who have the attribute |
f2 |
number of participants in group 2 who have the attribute |
n1 |
sample size for group 1 |
n2 |
sample size for group 2 |
Returns a 1-row matrix. The columns are:
Estimate - estimate of biserial-phi correlation
SE - standard error
LL - lower limit of the confidence interval
UL - upper limit of the confidence interval
Ulrich R, Wirtz M (2004). “On the correlation of a naturally and an artificially dichotomized variable.” British Journal of Mathematical and Statistical Psychology, 57(2), 235–251. ISSN 00071102. doi:10.1348/0007110042307203.
Bonett DG (2021). Statistical Methods for Psychologists https://dgbonett.sites.ucsc.edu/.
ci.biphi(.05, 34, 22, 50, 50) # Should return: # Estimate SE LL UL # 0.275 0.1075 0.049 0.464ci.biphi(.05, 34, 22, 50, 50) # Should return: # Estimate SE LL UL # 0.275 0.1075 0.049 0.464
Computes a confidence interval for a population biserial correlation. A biserial correlation can be used when one variable is quantitative and the other variable has been artificially dichotomized to create two groups. The biserial correlation estimates the correlation between the observed quantitative variable and the unobserved quantitative variable that has been measured on a dichotomous scale.
ci.bscor(alpha, m1, m2, sd1, sd2, n1, n2)ci.bscor(alpha, m1, m2, sd1, sd2, n1, n2)
alpha |
alpha level for 1-alpha confidence |
m1 |
estimated mean for group 1 |
m2 |
estimated mean for group 2 |
sd1 |
estimated standard deviation for group 1 |
sd2 |
estimated standard deviation for group 2 |
n1 |
sample size for group 1 |
n2 |
sample size for group 2 |
This function computes a point-biserial correlation and its standard error as a function of a standardized mean difference with a weighted variance standardizer. Then the point-biserial estimate is transformed into a biserial correlation using the traditional adjustment. The adjustment is also applied to the point-biserial standard error to obtain the standard error for the biserial correlation.
The biserial correlation assumes that the observed quantitative variable and the unobserved quantitative variable have a bivariate normal distribution. Bivariate normality is a crucial assumption underlying the transformation of a point-biserial correlation to a biserial correlation. Bivariate normality also implies equal variances of the observed quantitative variable at each level of the dichotomized variable, and this assumption is made in the computation of the standard error.
Returns a 1-row matrix. The columns are:
Estimate - estimated biserial correlation
SE - standard error
LL - lower limit of the confidence interval
UL - upper limit of the confidence interval
Bonett DG (2020). “Point-biserial correlation: Interval estimation, hypothesis testing, meta-analysis, and sample size determination.” British Journal of Mathematical and Statistical Psychology, 73(S1), 113–144. ISSN 0007-1102. doi:10.1111/bmsp.12189.
ci.bscor(.05, 28.32, 21.48, 3.81, 3.09, 40, 40) # Should return: # Estimate SE LL UL # 0.8856 0.0613 0.7376 0.9844ci.bscor(.05, 28.32, 21.48, 3.81, 3.09, 40, 40) # Should return: # Estimate SE LL UL # 0.8856 0.0613 0.7376 0.9844
Computes a confidence interval for a population coefficient of dispersion (COD). The COD is a mean absolute deviation from the median divided by the median. The coefficient of dispersion assumes ratio-scale scores and is a robust alternative to the coefficient of variation (see ci.cv). An approximate standard error is recovered from the confidence interval.
For more details, see Section 1.27 of Bonett (2021, Volume 1)
ci.cod(alpha, y)ci.cod(alpha, y)
alpha |
alpha level for 1-alpha confidence |
y |
vector of scores |
Returns a 1-row matrix. The columns are:
Estimate - estimated coefficient of dispersion
SE - recovered standard error
LL - lower limit of the confidence interval
UL - upper limit of the confidence interval
Bonett DG, Seier E (2006). “Confidence interval for a coefficient of dispersion in nonnormal distributions.” Biometrical Journal, 48(1), 144–148. ISSN 0323-3847. doi:10.1002/bimj.200410148.
Bonett DG (2021). Statistical Methods for Psychologists https://dgbonett.sites.ucsc.edu/.
y <- c(30, 20, 15, 10, 10, 60, 20, 25, 20, 30, 10, 5, 50, 40, 20, 10, 0, 20, 50) ci.cod(.05, y) # Should return: # Estimate SE LL UL # 0.5921053 0.1814708 0.3813259 1.092679y <- c(30, 20, 15, 10, 10, 60, 20, 25, 20, 30, 10, 5, 50, 40, 20, 10, 0, 20, 50) ci.cod(.05, y) # Should return: # Estimate SE LL UL # 0.5921053 0.1814708 0.3813259 1.092679
Computes confidence intervals and test statistics for population conditional slopes (simple slopes) in a general linear model that includes a predictor variable (x1), a moderator variable (x2), and a product predictor variable (x1*x2). Conditional slopes are computed at specified low and high values of the moderator variable.
For more details, see Section 2.13 of Bonett (2021, Volume 2)
ci.condslope(alpha, b1, b2, se1, se2, cov, lo, hi, dfe)ci.condslope(alpha, b1, b2, se1, se2, cov, lo, hi, dfe)
alpha |
alpha level for 1-alpha confidence |
b1 |
estimated slope coefficient for predictor variable |
b2 |
estimated slope coefficient for product variable |
se1 |
standard error for predictor coefficient |
se2 |
standard error for product coefficient |
cov |
estimated covariance between predictor and product coefficients |
lo |
low value of moderator variable |
hi |
high value of moderator variable |
dfe |
error degrees of freedom |
Returns a 2-row matrix. The columns are:
Estimate - estimated conditional slope
t - t test statistic
p - two-sided p-value
LL - lower limit of the confidence interval
UL - upper limit of the confidence interval
Bonett DG (2021). Statistical Methods for Psychologists https://dgbonett.sites.ucsc.edu/.
ci.condslope(.05, .132, .154, .031, .021, .015, 5.2, 10.6, 122) # Should return: # Estimate SE t df p # At low moderator 0.9328 0.4109570 2.269824 122 0.024973618 # At high moderator 1.7644 0.6070517 2.906507 122 0.004342076 # LL UL # At low moderator 0.1192696 1.746330 # At high moderator 0.5626805 2.966119ci.condslope(.05, .132, .154, .031, .021, .015, 5.2, 10.6, 122) # Should return: # Estimate SE t df p # At low moderator 0.9328 0.4109570 2.269824 122 0.024973618 # At high moderator 1.7644 0.6070517 2.906507 122 0.004342076 # LL UL # At low moderator 0.1192696 1.746330 # At high moderator 0.5626805 2.966119
Computes confidence intervals and test statistics for population conditional slopes (simple slopes) in a logistic model that includes a predictor variable (x1), a moderator variable (x2), and a product predictor variable (x1*x2). Conditional slopes are computed at low and high values of the moderator variable.
For more details, see Section 4.9 of Bonett (2021, Volume 3)
ci.condslope.log(alpha, b1, b2, se1, se2, cov, lo, hi)ci.condslope.log(alpha, b1, b2, se1, se2, cov, lo, hi)
alpha |
alpha level for 1-alpha confidence |
b1 |
estimated slope coefficient for predictor variable |
b2 |
estimated slope coefficient for product variable |
se1 |
standard error for predictor coefficient |
se2 |
standard error for product coefficient |
cov |
estimated covariance between predictor and product coefficients |
lo |
low value of moderator variable |
hi |
high value of moderator variable |
Returns a 2-row matrix. The columns are:
Estimate - estimated conditional slope
exp(Estimate) - estimated exponentiated conditional slope
z - z test statistic
p - two-sided p-value
LL - lower limit of the exponentiated confidence interval
UL - upper limit of the exponentiated confidence interval
Bonett DG (2021). Statistical Methods for Psychologists https://dgbonett.sites.ucsc.edu/.
ci.condslope.log(.05, .132, .154, .031, .021, .015, 5.2, 10.6) # Should return: # Estimate exp(Estimate) z p # At low moderator 0.9328 2.541616 2.2698 0.02322 # At high moderator 1.7644 5.838068 2.9065 0.00365 # LL UL # At low moderator 1.135802 5.687444 # At high moderator 1.776421 19.186357ci.condslope.log(.05, .132, .154, .031, .021, .015, 5.2, 10.6) # Should return: # Estimate exp(Estimate) z p # At low moderator 0.9328 2.541616 2.2698 0.02322 # At high moderator 1.7644 5.838068 2.9065 0.00365 # LL UL # At low moderator 1.135802 5.687444 # At high moderator 1.776421 19.186357
Computes a Fisher confidence interval for a population Pearson correlation or partial correlation with s control variables. Set s = 0 for a Pearson correlation. A bias adjustment is used to reduce the bias of the Fisher transformed correlation. This function uses an estimated correlation as input. Use the cor.test function for raw data input.
For more details, see Section 1.14 of Bonett (2021, Volume 2)
ci.cor(alpha, cor, s, n)ci.cor(alpha, cor, s, n)
alpha |
alpha level for 1-alpha confidence |
cor |
estimated Pearson or partial correlation |
s |
number of control variables |
n |
sample size |
Returns a 1-row matrix. The columns are:
Estimate - estimated correlation (from input)
SE - standard error
LL - lower limit of the confidence interval
UL - upper limit of the confidence interval
Snedecor GW, Cochran WG (1989). Statistical Methods, 8th edition. ISU University Pres, Ames, Iowa.
Bonett DG (2021). Statistical Methods for Psychologists https://dgbonett.sites.ucsc.edu/.
ci.cor(.05, .60, 0, 150) # Should return: # Estimate SE LL UL # 0.6 0.05243 0.485 0.6925 ci.cor(.05, .70, 1, 135) # Should return: # Estimate SE LL UL # 0.7 0.04406 0.6002 0.7763ci.cor(.05, .60, 0, 150) # Should return: # Estimate SE LL UL # 0.6 0.05243 0.485 0.6925 ci.cor(.05, .70, 1, 135) # Should return: # Estimate SE LL UL # 0.7 0.04406 0.6002 0.7763
Computes a confidence interval for a difference in population Pearson correlations that are estimated from the same sample and have one variable in common. A bias adjustment is used to reduce the bias of each Fisher transformed correlation. An approximate standard error is recovered from the confidence interval.
For more details, see Section 2.17 of Bonett (2021, Volume 2)
ci.cor.dep(alpha, cor1, cor2, cor12, n)ci.cor.dep(alpha, cor1, cor2, cor12, n)
alpha |
alpha level for 1-alpha confidence |
cor1 |
estimated Pearson correlation between y and x1 |
cor2 |
estimated Pearson correlation between y and x2 |
cor12 |
estimated Pearson correlation between x1 and x2 |
n |
sample size |
Returns a 1-row matrix. The columns are:
Estimate - estimated correlation difference
SE - recovered standard error
LL - lower limit of the confidence interval
UL - upper limit of the confidence interval
Zou GY (2007). “Toward using confidence intervals to compare correlations.” Psychological Methods, 12(4), 399–413. ISSN 1939-1463. doi:10.1037/1082-989X.12.4.399.
Bonett DG (2021). Statistical Methods for Psychologists https://dgbonett.sites.ucsc.edu/.
ci.cor.dep(.05, .396, .179, .088, 166) # Should return: # Estimate SE LL UL # 0.217 0.1027 0.0132 0.4158ci.cor.dep(.05, .396, .179, .088, 166) # Should return: # Estimate SE LL UL # 0.217 0.1027 0.0132 0.4158
Computes a confidence interval for a difference in population Pearson correlations in a 2-group design. A bias adjustment is used to reduce the bias of each Fisher transformed correlation.
For more details, see Section 2.17 of Bonett (2021, Volume 2)
ci.cor2(alpha, cor1, cor2, n1, n2)ci.cor2(alpha, cor1, cor2, n1, n2)
alpha |
alpha level for 1-alpha confidence |
cor1 |
estimated Pearson correlation for group 1 |
cor2 |
estimated Pearson correlation for group 2 |
n1 |
sample size for group 1 |
n2 |
sample size for group 2 |
Returns a 1-row matrix. The columns are:
Estimate - estimated correlation difference
SE - standard error
LL - lower limit of the confidence interval
UL - upper limit of the confidence interval
Zou GY (2007). “Toward using confidence intervals to compare correlations.” Psychological Methods, 12(4), 399–413. ISSN 1939-1463. doi:10.1037/1082-989X.12.4.399.
Bonett DG (2021). Statistical Methods for Psychologists https://dgbonett.sites.ucsc.edu/.
ci.cor2(.05, .64, .31, 200, 200) # Should return: # Estimate SE LL UL # 0.33 0.07692 0.1797 0.4814ci.cor2(.05, .64, .31, 200, 200) # Should return: # Estimate SE LL UL # 0.33 0.07692 0.1797 0.4814
Computes a 100(1 - alpha)% confidence interval for a difference in population correlations in a 2-group design. The correlations can be Pearson, Spearman, partial, semipartial, or point-biserial correlations. The correlations could also be correlations between two latent factors. The function requires a point estimate and a 100(1 - alpha)% confidence interval for each correlation as input. The confidence intervals for each correlation can be obtained using ci.fisher.
For more details, see Section 2.17 of Bonett (2021, Volume 2)
ci.cor2.gen(cor1, ll1, ul1, cor2, ll2, ul2)ci.cor2.gen(cor1, ll1, ul1, cor2, ll2, ul2)
cor1 |
estimated correlation for group 1 |
ll1 |
lower limit for group 1 correlation |
ul1 |
upper limit for group 1 correlation |
cor2 |
estimated correlation for group 2 |
ll2 |
lower limit for group 2 correlation |
ul2 |
upper limit for group 2 correlation |
Returns a 1-row matrix. The columns are:
Estimate - estimated correlation difference
LL - lower limit of the confidence interval
UL - upper limit of the confidence interval
Zou GY (2007). “Toward using confidence intervals to compare correlations.” Psychological Methods, 12(4), 399–413. ISSN 1939-1463. doi:10.1037/1082-989X.12.4.399.
Bonett DG (2021). Statistical Methods for Psychologists https://dgbonett.sites.ucsc.edu/.
ci.cor2.gen(.64, .55, .71, .31, .18, .43) # Should return: # Estimate LL UL # 0.33 0.18 0.4776ci.cor2.gen(.64, .55, .71, .31, .18, .43) # Should return: # Estimate LL UL # 0.33 0.18 0.4776
Computes a distribution-free confidence interval for a population coefficient of quartile variation which is defined as (Q3 - Q1)/(Q3 + Q1) where Q1 is the 25th percentile and Q3 is the 75th percentile. The coefficient of quartile variation assumes ratio-scale scores and is a robust alternative to the coefficient of variation (see ci.cv). The 25th and 75th percentiles are computed using the type = 2 method (SAS default).
For more details, see Section 1.27 of Bonett (2021, Volume 1)
ci.cqv(alpha, y)ci.cqv(alpha, y)
alpha |
alpha level for 1-alpha confidence |
y |
vector of scores |
Returns a 1-row matrix. The columns are:
Estimate - estimated coefficient of quartile variation
SE - standard error
LL - lower limit of the confidence interval
UL - upper limit of the confidence interval
Bonett DG (2006). “Confidence interval for a coefficient of quartile variation.” Computational Statistics and Data Analysis, 50(11), 2953–2957. doi:10.1016/j.csda.2005.05.007.
Bonett DG (2021). Statistical Methods for Psychologists https://dgbonett.sites.ucsc.edu/.
y <- c(30, 20, 15, 10, 10, 60, 20, 25, 20, 30, 10, 5, 50, 40, 20, 10, 0, 20, 50) ci.cqv(.05, y) # Should return: # Estimate SE LL UL # 0.5 0.1552485 0.2617885 0.8841821y <- c(30, 20, 15, 10, 10, 60, 20, 25, 20, 30, 10, 5, 50, 40, 20, 10, 0, 20, 50) ci.cqv(.05, y) # Should return: # Estimate SE LL UL # 0.5 0.1552485 0.2617885 0.8841821
Computes a confidence interval for a population Cramer's V coefficient of nominal association for an r x s contingency table. The confidence interval is based on a noncentral chi-square distribution, and an approximate standard error is recovered from the confidence interval.
For more details, see Section 3.10 of Bonett (2021, Volume 3)
ci.cramer(alpha, chisqr, r, c, n)ci.cramer(alpha, chisqr, r, c, n)
alpha |
alpha value for 1-alpha confidence |
chisqr |
Pearson chi-square test statistic of independence |
r |
number of rows in contingency table |
c |
number of columns in contingency table |
n |
sample size |
Returns a 1-row matrix. The columns are:
Estimate - estimate of Cramer's V
SE - recovered standard error
LL - lower limit of the confidence interval
UL - upper limit of the confidence interval
Smithson M (2003). Confidence Intervals. Sage.
Bonett DG (2021). Statistical Methods for Psychologists https://dgbonett.sites.ucsc.edu/.
ci.cramer(.05, 19.21, 2, 3, 200) # Should return: # Estimate SE LL UL # 0.31 0.0718 0.16 0.442ci.cramer(.05, 19.21, 2, 3, 200) # Should return: # Estimate SE LL UL # 0.31 0.0718 0.16 0.442
Computes a confidence interval for a population Cronbach reliability. The point estimate of Cronbach reliability assumes essentially tau-equivalent measurements and the confidence interval assumes parallel measurements.
For more details, see Section 4.19 of Bonett (2021, Volume 1)
ci.cronbach(alpha, rel, r, n)ci.cronbach(alpha, rel, r, n)
alpha |
alpha level for 1-alpha confidence |
rel |
estimated Cronbach reliability |
r |
number of measurements (items, raters, forms) |
n |
sample size |
Returns a 1-row matrix. The columns are:
Estimate - estimated Cronbach reliability (from input)
LL - lower limit of the confidence interval
UL - upper limit of the confidence interval
Feldt LS (1965). “The approximate sampling distribution of Kuder-Richardson reliability coefficient twenty.” Psychometrika, 30(3), 357–370. ISSN 0033-3123. doi:10.1007/BF02289499.
Bonett DG (2021). Statistical Methods for Psychologists https://dgbonett.sites.ucsc.edu/.
ci.cronbach(.05, .85, 7, 89) # Should return: # Estimate SE LL UL # 0.85 0.02457 0.7971 0.8932ci.cronbach(.05, .85, 7, 89) # Should return: # Estimate SE LL UL # 0.85 0.02457 0.7971 0.8932
Computes a confidence interval for a difference in population Cronbach reliability coefficients in a 2-group design. The number of measurements (items, raters, forms) used in each group need not be equal.
For more details, see Section 2.15 of Bonett (2021, Volume 4)
ci.cronbach2(alpha, rel1, rel2, r1, r2, n1, n2)ci.cronbach2(alpha, rel1, rel2, r1, r2, n1, n2)
alpha |
alpha level for 1-alpha confidence |
rel1 |
estimated Cronbach reliability for group 1 |
rel2 |
estimated Cronbach reliability for group 2 |
r1 |
number of measurements used in group 1 |
r2 |
number of measurements used in group 2 |
n1 |
sample size for group 1 |
n2 |
sample size for group 2 |
Returns a 1-row matrix. The columns are:
Estimate - estimated reliability difference
LL - lower limit of the confidence interval
UL - upper limit of the confidence interval
Bonett DG (2021). Statistical Methods for Psychologists https://dgbonett.sites.ucsc.edu/.
Bonett DG, Wright TA (2015). “Cronbach's alpha reliability: Interval estimation, hypothesis testing, and sample size planning.” Journal of Organizational Behavior, 36(1), 3–15. ISSN 08943796. doi:10.1002/job.1960.
ci.cronbach2(.05, .88, .76, 8, 8, 200, 250) # Should return: # Estimate LL UL # 0.12 0.0697 0.1733ci.cronbach2(.05, .88, .76, 8, 8, 200, 250) # Should return: # Estimate LL UL # 0.12 0.0697 0.1733
Computes a confidence interval for a population coefficient of variation (standard deviation divided by mean). This confidence interval is the reciprocal of a confidence interval for a standardized mean (see ci.stdmean). An approximate standard error is recovered from the confidence interval. The coefficient of variation assumes ratio-scale scores.
For more details, see Section 1.27 of Bonett (2021, Volume 1)
ci.cv(alpha, m, sd, n)ci.cv(alpha, m, sd, n)
alpha |
alpha level for 1-alpha confidence |
m |
estimated mean |
sd |
estimated standard deviation |
n |
sample size |
Returns a 1-row matrix. The columns are:
Estimate - estimated coefficient of variation
SE - recovered standard error
LL - lower limit of the confidence interval
UL - upper limit of the confidence interval
Bonett DG (2021). Statistical Methods for Psychologists https://dgbonett.sites.ucsc.edu/.
ci.cv(.05, 24.5, 3.65, 40) # Should return: # Estimate SE LL UL # 0.1489796 0.01817373 0.1214381 0.1926778ci.cv(.05, 24.5, 3.65, 40) # Should return: # Estimate SE LL UL # 0.1489796 0.01817373 0.1214381 0.1926778
Computes estimates, standard errors, and approximate confidence intervals for the Berger-Parker, Simpson, and Shannon diversity indices. For the Shannon index, the value 1/r is added to each frequency count where r is the number of categories. These indices have a range of 0 to 1 where 0 indicates no diversity and 1 indicates maximum diversity.
For more details, see Section 1.13 of Bonett (2021, Volume 3)
ci.diversity(alpha, f)ci.diversity(alpha, f)
alpha |
alpha level for 1 - alpha confidence |
f |
vector of multinomial frequency counts |
Returns a 3-row matrix. The columns are:
Estimate - estimate of diversity index
SE - standard error of estimate
LL - lower limit of the confidence interval
UL - upper limit of the confidence interval
Bonett DG (2021). Statistical Methods for Psychologists https://dgbonett.sites.ucsc.edu/.
f = c(847, 320, 57, 274, 36) ci.diversity(.05, f) # Should return: # Estimate SE LL UL # Berger 0.5598 0.01587 0.5287 0.5909 # Simpson 0.7722 0.01229 0.7481 0.7963 # Shannon 0.7292 0.01224 0.7052 0.7532f = c(847, 320, 57, 274, 36) ci.diversity(.05, f) # Should return: # Estimate SE LL UL # Berger 0.5598 0.01587 0.5287 0.5909 # Simpson 0.7722 0.01229 0.7481 0.7963 # Shannon 0.7292 0.01224 0.7052 0.7532
Computes a confidence interval for a population eta-squared, partial eta-squared, or generalized eta-squared in a fixed-factor between-subjects design. An approximate bias adjusted estimate is computed, and an approximate standard error is recovered from the confidence interval.
For more details, see Section 3.7 of Bonett (2021, Volume 1)
ci.etasqr(alpha, etasqr, df1, df2)ci.etasqr(alpha, etasqr, df1, df2)
alpha |
alpha value for 1-alpha confidence |
etasqr |
estimated eta-squared |
df1 |
degrees of freedom for effect |
df2 |
error degrees of freedom |
Returns a 1-row matrix. The columns are:
Eta-squared - eta-squared (from input)
adj Eta-squared - bias adjusted eta-squared estimate
SE - recovered standard error
LL - lower limit of the confidence interval
UL - upper limit of the confidence interval
Bonett DG (2021). Statistical Methods for Psychologists https://dgbonett.sites.ucsc.edu/.
ci.etasqr(.05, .15, 2, 57) # Should return: # Eta-squared adj Eta-squared SE LL UL # 0.15 0.1202 0.07414 0.0102 0.3008ci.etasqr(.05, .15, 2, 57) # Should return: # Eta-squared adj Eta-squared SE LL UL # 0.15 0.1202 0.07414 0.0102 0.3008
Computes a Fisher confidence interval for any type of correlation (e.g., Pearson, Spearman, Kendall-tau, tetrachoric, phi, partial, semipartial, etc.) or ordinal association such as gamma, Somers' d, or tau-b. The correlation could also be between two latent factors obtained from a SEM analysis (the Fisher CI will be more accurate than the large-sample CI from a SEM analysis). The standard error can be a traditional standard error, a bootstrap standard error, or a robust standard error from a SEM analysis.
ci.fisher(alpha, cor, se)ci.fisher(alpha, cor, se)
alpha |
alpha value for 1-alpha confidence |
cor |
estimated correlation or association coefficient |
se |
standard error of correlation or association coefficient |
Returns a 1-row matrix. The columns are:
Estimate - correlation (from input)
LL - lower limit of the confidence interval
UL - upper limit of the confidence interval
ci.fisher(.05, .692, .049) # Should return: # Estimate LL UL # 0.692 0.5833 0.7763ci.fisher(.05, .692, .049) # Should return: # Estimate LL UL # 0.692 0.5833 0.7763
Computes a confidence interval for a population intraclass reliability coefficient using mean squared estimates from a two-way ANOVA. This function will compute point and interval estimates of the ICC(C, 1) and ICC(C, r) reliability coefficients where ICC(C, 1) is the reliability of a single measurements (e.g., a single rater or a single form of a test) and ICC(C, r) is the reliability of a sum or average of r measurements. ICC(C, r) is the same as Cronbach's reliability coefficient. The ci.cronbach function uses a point estimate of Cronbach's reliability as input. The confidence intervals used in this function assume parallel measurements which implies a compound symmetric covariance matrix of the r measurements.
ci.icc(alpha, MSr, MSe, r, n)ci.icc(alpha, MSr, MSe, r, n)
alpha |
alpha level for 1-alpha confidence |
MSr |
mean square for rows |
MSe |
error mean square |
r |
number of measurements (items, raters, forms) |
n |
sample size |
Returns a 2-row matrix. The first row results are for ICC(C, 1) and the second row results are for ICC(C, r). The columns are:
Estimate - estimated reliability
SE - standard error
LL - lower limit of the confidence interval
UL - upper limit of the confidence interval
McGraw KO, Wong SP (1996). “Forming inferences about some intraclass correlation coefficients.” Psychological Methods, 1(1), 30–46. doi:10.1037/1082-989X.1.1.30.
Bonett DG (2021). Statistical Methods for Psychologists https://dgbonett.sites.ucsc.edu/.
ci.icc(.05, 48.2, 11.3, 5, 30) # Should return: # Estimate SE LL UL # ICC(C, 1) 0.3951 0.09166 0.2311 0.5853 # ICC(C, r) 0.7656 0.07005 0.6005 0.8759ci.icc(.05, 48.2, 11.3, 5, 30) # Should return: # Estimate SE LL UL # ICC(C, 1) 0.3951 0.09166 0.2311 0.5853 # ICC(C, r) 0.7656 0.07005 0.6005 0.8759
Computes a Monte Carlo confidence interval (500,000 trials) for a population unstandardized or standardized indirect effect in a path model and a Sobel standard error. This function is not recommended for a standardized indirect if the standardized slopes are greater than .4 The Monte Carlo method is general in that the slope estimates and standard errors do not need to be OLS estimates with homoscedastic standard errors. For example, LAD slope estimates and their standard errors, OLS slope estimates and heteroscedastic-consistent standard errors also could be used. In models with no direct effects, distribution-free Theil-Sen slope estimates with recovered standard errors (see ci.theil) also could be used.
For more details, see Section 1.18 of Bonett (2021, Volume 4)
ci.indirect(alpha, b1, b2, se1, se2)ci.indirect(alpha, b1, b2, se1, se2)
alpha |
alpha level for 1-alpha confidence |
b1 |
slope estimate for first path |
b2 |
slope estimate for second path |
se1 |
standard error for b1 |
se2 |
standard error for b2 |
Returns a 1-row matrix. The columns are:
Estimate - estimated indirect effect
SE - standard error
LL - lower limit of the confidence interval
UL - upper limit of the confidence interval
Bonett DG (2021). Statistical Methods for Psychologists https://dgbonett.sites.ucsc.edu/.
ci.indirect (.05, 2.48, 1.92, .586, .379) # Should return (within sampling error): # Estimate SE LL UL # 4.7616 1.625282 2.178812 7.972262ci.indirect (.05, 2.48, 1.92, .586, .379) # Should return (within sampling error): # Estimate SE LL UL # 4.7616 1.625282 2.178812 7.972262
Computes confidence intervals for the intraclass kappa coefficient and Cohen's kappa coefficient with two dichotomous ratings. The G-index of agreement (see ci.agree) is arguably a better measure of agreement.
For more details, see Section 3.5 of Bonett (2021, Volume 3)
ci.kappa(alpha, f00, f01, f10, f11)ci.kappa(alpha, f00, f01, f10, f11)
alpha |
alpha level for 1-alpha confidence |
f00 |
number of objects rated 0 by both Rater 1 and Rater 2 |
f01 |
number of objects rated 0 by Rater 1 and 1 by Rater 2 |
f10 |
number of objects rated 1 by Rater 1 and 0 by Rater 2 |
f11 |
number of objects rated 1 by both Rater 1 and Rater 2 |
Returns a 2-row matrix. The results in row 1 are for the intraclass kappa. The results in row 2 are for Cohen's kappa. The columns are:
Estimate - estimate of interrater reliability
SE - standard error
LL - lower limit of the confidence interval
UL - upper limit of the confidence interval
Fleiss JL, Paik MC (2003). Statistical Methods for Rates and Proportions, 3rd edition. Wiley.
Bonett DG (2021). Statistical Methods for Psychologists https://dgbonett.sites.ucsc.edu/.
ci.kappa(.05, 31, 12, 4, 58) # Should return: # Estimate SE LL UL # IC kappa: 0.674 0.0748 0.527 0.821 # Cohen kappa: 0.676 0.0734 0.532 0.820ci.kappa(.05, 31, 12, 4, 58) # Should return: # Estimate SE LL UL # IC kappa: 0.674 0.0748 0.527 0.821 # Cohen kappa: 0.676 0.0734 0.532 0.820
Computes the estimate, standard error, and approximate confidence interval for a linear contrast of any type of parameter where each parameter value has been estimated from a different sample. The parameter values are assumed to be of the same type and their sampling distributions are assumed to be approximately normal.
ci.lc.gen.bs(alpha, est, se, v)ci.lc.gen.bs(alpha, est, se, v)
alpha |
alpha level for 1-alpha confidence |
est |
vector of parameter estimates |
se |
vector of standard errors |
v |
vector of contrast coefficients |
Returns a 1-row matrix. The columns are:
Estimate - estimate of linear contrast
SE - standard error of linear contrast
LL - lower limit of confidence interval
UL - upper limit of confidence interval
est <- c(3.86, 4.57, 2.29, 2.88) se <- c(0.185, 0.365, 0.275, 0.148) v <- c(.5, .5, -.5, -.5) ci.lc.gen.bs(.05, est, se, v) # Should return: # Estimate SE LL UL # 1.63 0.2573806 1.125543 2.134457est <- c(3.86, 4.57, 2.29, 2.88) se <- c(0.185, 0.365, 0.275, 0.148) v <- c(.5, .5, -.5, -.5) ci.lc.gen.bs(.05, est, se, v) # Should return: # Estimate SE LL UL # 1.63 0.2573806 1.125543 2.134457
Computes the estimate, standard error, and confidence interval for a linear contrast of parameters in a general linear model using coef(object) and vcov(object) where "object" is a fitted model object from the lm function.
For more details, see Section 2.28 of Bonett (2021, Volume 2)
ci.lc.glm(alpha, n, b, V, q)ci.lc.glm(alpha, n, b, V, q)
alpha |
alpha for 1 - alpha confidence |
n |
sample size |
b |
vector of parameter estimates from coef(object) |
V |
covariance matrix of parameter estimates from vcov(object) |
q |
vector of contrast coefficients |
Returns a 1-row matrix. The columns are:
Estimate - estimate of linear function
SE - standard error
t - t test statistic
df - degrees of freedom
p - two-sided p-value
LL - lower limit of the confidence interval
UL - upper limit of the confidence interval
Bonett DG (2021). Statistical Methods for Psychologists https://dgbonett.sites.ucsc.edu/.
y <- c(43, 62, 49, 60, 36, 79, 55, 42, 67, 50) x1 <- c(3, 6, 4, 6, 2, 7, 4, 2, 7, 5) x2 <- c(4, 6, 3, 7, 1, 9, 3, 3, 8, 4) out <- lm(y ~ x1 + x2) b <- coef(out) V <- vcov(out) n <- length(y) q <- c(0, .5, .5) b ci.lc.glm(.05, n, b, V, q) # Should return: # (Intercept) x1 x2 # 26.891111 3.648889 2.213333 # # Estimate SE t df p LL UL # 2.931111 0.4462518 6.5683 7 0.00031 1.875893 3.986329y <- c(43, 62, 49, 60, 36, 79, 55, 42, 67, 50) x1 <- c(3, 6, 4, 6, 2, 7, 4, 2, 7, 5) x2 <- c(4, 6, 3, 7, 1, 9, 3, 3, 8, 4) out <- lm(y ~ x1 + x2) b <- coef(out) V <- vcov(out) n <- length(y) q <- c(0, .5, .5) b ci.lc.glm(.05, n, b, V, q) # Should return: # (Intercept) x1 x2 # 26.891111 3.648889 2.213333 # # Estimate SE t df p LL UL # 2.931111 0.4462518 6.5683 7 0.00031 1.875893 3.986329
Computes a test statistic and confidence interval for a linear contrast of means in a between-subjects design. This function computes both unequal variance and equal variance confidence intervals and test statistics. A Satterthwaite adjustment to the degrees of freedom is used with the unequal variance method.
For more details, see Section 3.3 of Bonett (2021, Volume 1)
ci.lc.mean.bs(alpha, m, sd, n, v)ci.lc.mean.bs(alpha, m, sd, n, v)
alpha |
alpha level for 1-alpha confidence |
m |
vector of estimated group means |
sd |
vector of estimated group standard deviations |
n |
vector of sample sizes |
v |
vector of between-subjects contrast coefficients |
Returns a 2-row matrix. The columns are:
Estimate - estimated linear contrast
SE - standard error
t - t test statistic
df - degrees of freedom
p - two-sided p-value
LL - lower limit of the confidence interval
UL - upper limit of the confidence interval
Snedecor GW, Cochran WG (1989). Statistical Methods, 8th edition. ISU University Pres, Ames, Iowa.
Bonett DG (2021). Statistical Methods for Psychologists https://dgbonett.sites.ucsc.edu/.
m <- c(24.9, 23.1, 16.4) sd <- c(5.21, 4.67, 4.98) n <- c(30, 30, 30) v <- c(.5, .5, -1) ci.lc.mean.bs(.05, m, sd, n, v) # Should return: # Estimate SE t df p LL UL # Equal Variances Assumed: 7.6 1.108703 6.8549 87.00 0 5.396332 9.803668 # Equal Variances Not Assumed: 7.6 1.111135 6.8399 57.59 0 5.375484 9.824516 m <- c(33.5, 37.9, 38.0, 44.1) sd <- c(3.84, 3.84, 3.65, 4.98) n <- c(10, 10, 10, 10) v <- c(.5, .5, -.5, -.5) ci.lc.mean.bs(.05, m, sd, n, v) # Should return: # Estimate SE t df p # Equal Variances Assumed: -5.35 1.300136 -4.115 36.00 0.00022 # Equal Variances Not Assumed: -5.35 1.300136 -4.115 33.52 0.00024 # LL UL # Equal Variances Assumed: -7.986797 -2.713203 # Equal Variances Not Assumed: -7.993583 -2.706417m <- c(24.9, 23.1, 16.4) sd <- c(5.21, 4.67, 4.98) n <- c(30, 30, 30) v <- c(.5, .5, -1) ci.lc.mean.bs(.05, m, sd, n, v) # Should return: # Estimate SE t df p LL UL # Equal Variances Assumed: 7.6 1.108703 6.8549 87.00 0 5.396332 9.803668 # Equal Variances Not Assumed: 7.6 1.111135 6.8399 57.59 0 5.375484 9.824516 m <- c(33.5, 37.9, 38.0, 44.1) sd <- c(3.84, 3.84, 3.65, 4.98) n <- c(10, 10, 10, 10) v <- c(.5, .5, -.5, -.5) ci.lc.mean.bs(.05, m, sd, n, v) # Should return: # Estimate SE t df p # Equal Variances Assumed: -5.35 1.300136 -4.115 36.00 0.00022 # Equal Variances Not Assumed: -5.35 1.300136 -4.115 33.52 0.00024 # LL UL # Equal Variances Assumed: -7.986797 -2.713203 # Equal Variances Not Assumed: -7.993583 -2.706417
Computes a Scheffe confidence interval for a linear contrast of population means in a between-subjects design. A Scheffe p-value is computed for the test statistic. The Scheffe method assumes equal population variances. This function is useful in exploratory studies where the linear contrast of means was not planned but was suggested by the pattern of sample means. Use the ci.lc.mean.bs function with a Bonferroni adjusted alpha value to compute simultaneous confidence intervals for two or more planned linear contrasts of means.
ci.lc.mean.scheffe(alpha, m, sd, n, v)ci.lc.mean.scheffe(alpha, m, sd, n, v)
alpha |
alpha level for 1-alpha confidence |
m |
vector of estimated group means |
sd |
vector of estimated group standard deviations |
n |
vector of sample sizes |
v |
vector of between-subjects contrast coefficients |
Returns a 2-row matrix. The columns are:
Estimate - estimated linear contrast
SE - standard error
t - t test statistic
df - degrees of freedom
p - two-sided Scheffe p-value
LL - lower limit of the Scheffe confidence interval
UL - upper limit of the Scheffe confidence interval
Snedecor GW, Cochran WG (1989). Statistical Methods, 8th edition. ISU University Pres, Ames, Iowa.
m <- c(33.5, 37.9, 38.0, 44.1) sd <- c(3.49, 3.84, 3.65, 4.98) n <- c(10, 10, 10, 10) v <- c(.5, .5, -.5, -.5) ci.lc.mean.scheffe(.05, m, sd, n, v) # Should return: # Estimate SE t p LL UL # -5.35 1.275231 -4.1953 0.00228 -9.089451 -1.610549m <- c(33.5, 37.9, 38.0, 44.1) sd <- c(3.49, 3.84, 3.65, 4.98) n <- c(10, 10, 10, 10) v <- c(.5, .5, -.5, -.5) ci.lc.mean.scheffe(.05, m, sd, n, v) # Should return: # Estimate SE t p LL UL # -5.35 1.275231 -4.1953 0.00228 -9.089451 -1.610549
Computes a distribution-free confidence interval for a linear contrast of medians in a between-subjects design using estimated medians and their standard errors. The sample median and standard error for each group can be computed using the ci.median function.
For more details, see Section 3.21 of Bonett (2021, Volume 1)
ci.lc.median.bs(alpha, m, se, v)ci.lc.median.bs(alpha, m, se, v)
alpha |
alpha level for 1-alpha confidence |
m |
vector of estimated group medians |
se |
vector of estimated group standard errors |
v |
vector of between-subjects contrast coefficients |
Returns a 1-row matrix. The columns are:
Estimate - estimated linear contrast of medians
SE - standard error
LL - lower limit of the confidence interval
UL - upper limit of the confidence interval
Bonett DG, Price RM (2002). “Statistical inference for a linear function of medians: Confidence intervals, hypothesis testing, and sample size requirements.” Psychological Methods, 7(3), 370–383. ISSN 1939-1463. doi:10.1037/1082-989X.7.3.370.
Bonett DG (2021). Statistical Methods for Psychologists https://dgbonett.sites.ucsc.edu/.
m <- c(46.13, 29.19, 30.32, 49.15) se <- c(6.361, 5.892, 4.887, 6.103) v <- c(1, -1, -1, 1) ci.lc.median.bs(.05, m, se, v) # Should return: # Estimate SE LL UL # 35.77 11.67507 12.88727 58.65273m <- c(46.13, 29.19, 30.32, 49.15) se <- c(6.361, 5.892, 4.887, 6.103) v <- c(1, -1, -1, 1) ci.lc.median.bs(.05, m, se, v) # Should return: # Estimate SE LL UL # 35.77 11.67507 12.88727 58.65273
Computes an adjusted Wald confidence interval for a linear contrast of population proportions in a between-subjects design.
For more details, see Section 2.8 of Bonett (2021, Volume 3)
ci.lc.prop.bs(alpha, f, n, v)ci.lc.prop.bs(alpha, f, n, v)
alpha |
alpha level for 1-alpha confidence |
f |
vector of frequency counts of participants who have the attribute |
n |
vector of sample sizes |
v |
vector of between-subjects contrast coefficients |
Returns a 1-row matrix. The columns are:
Estimate - adjusted estimate of proportion linear contrast
SE - adjusted standard error
z - z test statistic
p - two-sided p-value
LL - lower limit of the adjusted Wald confidence interval
UL - upper limit of the adjusted Wald confidence interval
Price RM, Bonett DG (2004). “An improved confidence interval for a linear function of binomial proportions.” Computational Statistics & Data Analysis, 45(3), 449–456. ISSN 01679473. doi:10.1016/S0167-9473(03)00007-0.
Bonett DG (2021). Statistical Methods for Psychologists https://dgbonett.sites.ucsc.edu/.
f <- c(26, 24, 38) n <- c(60, 60, 60) v1 <- c(-.5, -.5, 1) ci.lc.prop.bs(.05/2, f, n, v1) # Should return: # Estimate SE z p LL UL # 0.2119565 0.07602892 2.7878 0.00531 0.0415451 0.3823679 v2 <- c(1, -1, 0) ci.lc.prop.bs(.05/2, f, n, v2) # Should return: # Estimate SE z p LL UL # 0.03225806 0.08857951 0.36417 0.71573 -0.1662843 0.2308004f <- c(26, 24, 38) n <- c(60, 60, 60) v1 <- c(-.5, -.5, 1) ci.lc.prop.bs(.05/2, f, n, v1) # Should return: # Estimate SE z p LL UL # 0.2119565 0.07602892 2.7878 0.00531 0.0415451 0.3823679 v2 <- c(1, -1, 0) ci.lc.prop.bs(.05/2, f, n, v2) # Should return: # Estimate SE z p LL UL # 0.03225806 0.08857951 0.36417 0.71573 -0.1662843 0.2308004
Computes an adjusted Wald confidence interval for a linear contrast of population proportions in a between-subjects design using a Scheffe critical value. A Scheffe p-value is computed for the test statistic. This function is useful in exploratory studies where the linear contrast of proportions was not planned but was suggested by the pattern of sample proportions. Use the ci.lc.prop.bs function with a Bonferroni adjusted alpha value to compute simultaneous confidence intervals for two or more planned linear contrasts of proportions.
For more details, see Section 2.9 of Bonett (2021, Volume 3)
ci.lc.prop.scheffe(alpha, f, n, v)ci.lc.prop.scheffe(alpha, f, n, v)
alpha |
alpha level for 1-alpha confidence |
f |
vector of frequency counts of participants who have the attribute |
n |
vector of sample sizes |
v |
vector of between-subjects contrast coefficients |
Returns a 1-row matrix. The columns are:
Estimate - adjusted estimate of proportion linear contrast
SE - adjusted standard error
z - z test statistic
p - two-sided Scheffe p-value
LL - lower limit of the Scheffe confidence interval
UL - upper limit of the Scheffe confidence interval
Price RM, Bonett DG (2004). “An improved confidence interval for a linear function of binomial proportions.” Computational Statistics & Data Analysis, 45(3), 449–456. ISSN 01679473. doi:10.1016/S0167-9473(03)00007-0.
Marascuilo LA, McSweeney M (1977). Nonparametric and Distribution-Free Methods for the Social Sciences. Brooks/Cole.
Bonett DG (2021). Statistical Methods for Psychologists https://dgbonett.sites.ucsc.edu/.
f <- c(26, 24, 38) n <- c(60, 60, 60) v <- c(-.5, -.5, 1) ci.lc.prop.scheffe(.05, f, n, v) # Should return: # Estimate SE z p LL UL # 0.2119565 0.07602892 2.7878 0.02053 0.02585698 0.3980561f <- c(26, 24, 38) n <- c(60, 60, 60) v <- c(-.5, -.5, 1) ci.lc.prop.scheffe(.05, f, n, v) # Should return: # Estimate SE z p LL UL # 0.2119565 0.07602892 2.7878 0.02053 0.02585698 0.3980561
Computes a confidence interval and test statistic for a linear contrast of population regression coefficients (e.g., a y-intercept or a slope coefficient) across groups in a multiple group regression model. Equality of error variances across groups is not assumed. A Satterthwaite adjustment to the degrees of freedom is used to improve the accuracy of the confidence interval.
For more details, see Section 2.20 of Bonett (2021, Volume 2)
ci.lc.reg(alpha, est, se, n, s, v)ci.lc.reg(alpha, est, se, n, s, v)
alpha |
alpha level for 1-alpha confidence |
est |
vector of parameter estimates |
se |
vector of standard errors |
n |
vector of group sample sizes |
s |
number of predictor variables for each within-group model |
v |
vector of contrast coefficients |
Returns a 1-row matrix. The columns are:
Estimate - estimated linear contrast
SE - standard error
t - t test statistic
df - degrees of freedom
p - two-sided p-value
LL - lower limit of the confidence interval
UL - upper limit of the confidence interval
Bonett DG (2021). Statistical Methods for Psychologists https://dgbonett.sites.ucsc.edu/.
est <- c(1.74, 1.83, 0.482) se <- c(.483, .421, .395) n <- c(40, 40, 40) v <- c(.5, .5, -1) ci.lc.reg(.05, est, se, n, 4, v) # Should return: # Estimate SE t df p LL UL # 1.303 0.5085838 2.5620 78.8197 0.01231 0.2906532 2.315347est <- c(1.74, 1.83, 0.482) se <- c(.483, .421, .395) n <- c(40, 40, 40) v <- c(.5, .5, -1) ci.lc.reg(.05, est, se, n, 4, v) # Should return: # Estimate SE t df p LL UL # 1.303 0.5085838 2.5620 78.8197 0.01231 0.2906532 2.315347
Computes confidence intervals for a population standardized linear contrast of means in a between-subjects design. The unweighted standardizer is recommended in experimental designs. The weighted standardizer is recommended in nonexperimental designs with simple random sampling. The group 1 standardizer is useful in both experimental and nonexperimental designs. Equality of variances is not assumed.
For more details, see Section 3.4 of Bonett (2021, Volume 1)
ci.lc.stdmean.bs(alpha, m, sd, n, v)ci.lc.stdmean.bs(alpha, m, sd, n, v)
alpha |
alpha level for 1-alpha confidence |
m |
vector of estimated group means |
sd |
vector of estimated group standard deviation |
n |
vector of sample sizes |
v |
vector of between-subjects contrast coefficients |
Returns a 3-row matrix. The columns are:
Estimate - estimated standardized linear contrast
adj Estimate - bias adjusted standardized linear contrast estimate
SE - standard error
LL - lower limit of the confidence interval
UL - upper limit of the confidence interval
Bonett DG (2008). “Confidence intervals for standardized linear contrasts of means.” Psychological Methods, 13(2), 99–109. ISSN 1939-1463. doi:10.1037/1082-989X.13.2.99.
Bonett DG (2021). Statistical Methods for Psychologists https://dgbonett.sites.ucsc.edu/.
m <- c(6.94, 7.15, 4.60, 3.68) sd <- c(2.21, 2.83, 2.29, 1.90) n <- c(40, 40, 40, 40) v <- c(.5, .5, -.5, -.5) ci.lc.stdmean.bs(.05, m, sd, n, v) # Should return: # Estimate adj Estimate SE LL UL # Unweighted standardizer: 1.2459 1.2399 0.17621 0.9005 1.5912 # Weighted standardizer: 1.2459 1.2399 0.17313 0.9065 1.5852 # Group 1 standardizer: 1.3145 1.2890 0.22515 0.8732 1.7558m <- c(6.94, 7.15, 4.60, 3.68) sd <- c(2.21, 2.83, 2.29, 1.90) n <- c(40, 40, 40, 40) v <- c(.5, .5, -.5, -.5) ci.lc.stdmean.bs(.05, m, sd, n, v) # Should return: # Estimate adj Estimate SE LL UL # Unweighted standardizer: 1.2459 1.2399 0.17621 0.9005 1.5912 # Weighted standardizer: 1.2459 1.2399 0.17313 0.9065 1.5852 # Group 1 standardizer: 1.3145 1.2890 0.22515 0.8732 1.7558
Computes confidence intervals for two types of population standardized linear contrast of means (unweighted standardizer and level 1 standardizer) in a within-subjects design. Equality of variances is not assumed, but the correlations among the repeated measures are assumed to be approximately equal.
For more details, see Section 4.7 of Bonett (2021, Volume 1)
ci.lc.stdmean.ws(alpha, m, sd, cor, n, q)ci.lc.stdmean.ws(alpha, m, sd, cor, n, q)
alpha |
alpha level for 1-alpha confidence |
m |
vector of estimated means for levels of within-subjects factor |
sd |
vector of estimated standard deviations for levels of within-subjects factor |
cor |
average estimated correlation of all measurement pairs |
n |
sample size |
q |
vector of within-subjects contrast coefficients |
Returns a 2-row matrix. The columns are:
Estimate - estimated standardized linear contrast
adj Estimate - bias adjusted standardized linear contrast estimate
SE - standard error
LL - lower limit of the confidence interval
UL - upper limit of the confidence interval
Bonett DG (2008). “Confidence intervals for standardized linear contrasts of means.” Psychological Methods, 13(2), 99–109. ISSN 1939-1463. doi:10.1037/1082-989X.13.2.99.
Bonett DG (2021). Statistical Methods for Psychologists https://dgbonett.sites.ucsc.edu/.
m <- c(33.5, 37.9, 38.0, 44.1) sd <- c(3.84, 3.84, 3.65, 4.98) q <- c(.5, .5, -.5, -.5) ci.lc.stdmean.ws(.05, m, sd, .672, 20, q) # Should return: # Estimate adj Estimate SE LL UL # Unweighted standardizer: -1.3013 -1.2666 0.31479 -1.9182 -0.6843 # Level 1 standardizer: -1.3932 -1.3375 0.36618 -2.1109 -0.6755m <- c(33.5, 37.9, 38.0, 44.1) sd <- c(3.84, 3.84, 3.65, 4.98) q <- c(.5, .5, -.5, -.5) ci.lc.stdmean.ws(.05, m, sd, .672, 20, q) # Should return: # Estimate adj Estimate SE LL UL # Unweighted standardizer: -1.3013 -1.2666 0.31479 -1.9182 -0.6843 # Level 1 standardizer: -1.3932 -1.3375 0.36618 -2.1109 -0.6755
Computes a confidence interval for a population mean absolute deviation from the median (MAD). The MAD is a robust alternative to the standard deviation.
For more details, see Section 1.26 of Bonett (2021, Volume 1)
ci.mad(alpha, y)ci.mad(alpha, y)
alpha |
alpha level for 1-alpha confidence |
y |
vector of scores |
Returns a 1-row matrix. The columns are:
Estimate - estimated mean absolute deviation
SE - standard error
LL - lower limit of the confidence interval
UL - upper limit of the confidence interval
Bonett DG, Seier E (2003). “Confidence intervals for mean absolute deviations.” The American Statistician, 57(4), 233–236. ISSN 0003-1305. doi:10.1198/0003130032323.
Bonett DG (2021). Statistical Methods for Psychologists https://dgbonett.sites.ucsc.edu/.
y <- c(30, 20, 15, 10, 10, 60, 20, 25, 20, 30, 10, 5, 50, 40, 20, 10, 0, 20, 50) ci.mad(.05, y) # Should return: # Estimate SE LL UL # 12.5 2.876103 7.962667 19.62282y <- c(30, 20, 15, 10, 10, 60, 20, 25, 20, 30, 10, 5, 50, 40, 20, 10, 0, 20, 50) ci.mad(.05, y) # Should return: # Estimate SE LL UL # 12.5 2.876103 7.962667 19.62282
Computes a distribution-free confidence interval for the Mann-Whitney parameter (a "common language effect size"). In a 2-group experiment, this parameter is the proportion of members in the population with scores that would be higher under treatment 1 than treatment 2. In a 2-group nonexperiment where participants are sampled from two subpopulations of sizes N1 and N2, the parameter is the proportion of all N1 x N2 pairs in which a member from subpopulation 1 has a larger score than a member from subpopulation 2.
For more details, see Section 2.12 of Bonett (2021, Volume 1)
ci.mann(alpha, y1, y2)ci.mann(alpha, y1, y2)
alpha |
alpha level for 1-alpha confidence |
y1 |
vector of scores for group 1 |
y2 |
vector of scores for group 2 |
Returns a 1-row matrix. The columns are:
Estimate - estimated proportion
SE - standard error
LL - lower limit of the confidence interval
UL - upper limit of the confidence interval
Sen PK (1967). “A note on asymptotically distribution-free confidence bounds for P(X < Y), based on two independent samples.” The Indian Journal of Statistics, Series A, 29(1), 95–102.
Bonett DG (2021). Statistical Methods for Psychologists https://dgbonett.sites.ucsc.edu/.
y1 <- c(9.4, 10.3, 58.3, 106.0, 31.0, 46.2, 12.0, 19.0, 135.0, 159.0) y2 <- c(14.6, 5.1, 8.1, 22.7, 6.4, 4.4, 19.0, 3.2) ci.mann(.05, y1, y2) # Should return: # Estimate SE LL UL # 0.86875 0.1222202 0.6292028 1y1 <- c(9.4, 10.3, 58.3, 106.0, 31.0, 46.2, 12.0, 19.0, 135.0, 159.0) y2 <- c(14.6, 5.1, 8.1, 22.7, 6.4, 4.4, 19.0, 3.2) ci.mann(.05, y1, y2) # Should return: # Estimate SE LL UL # 0.86875 0.1222202 0.6292028 1
Computes a confidence interval for a population mean absolute prediction error (MAPE) in a general linear model. The MAPE is a more robust alternative to the residual standard deviation. This function requires a vector of estimated residuals from a general linear model. This confidence interval does not assume zero excess kurtosis but does assume symmetry of the population prediction errors.
For more details, see Section 1.16 of Bonett (2021, Volume 2)
ci.mape(alpha, res, s)ci.mape(alpha, res, s)
alpha |
alpha level for 1-alpha confidence |
res |
vector of residuals |
s |
number of predictor variables in model |
Returns a 1-row matrix. The columns are:
Estimate - estimated mean absolute prediction error
SE - standard error
LL - lower limit of the confidence interval
UL - upper limit of the confidence interval
Bonett DG (2021). Statistical Methods for Psychologists https://dgbonett.sites.ucsc.edu/.
res <- c(-2.70, -2.69, -1.32, 1.02, 1.23, -1.46, 2.21, -2.10, 2.56, -3.02, -1.55, 1.46, 4.02, 2.34) ci.mape(.05, res, 1) # Should return: # Estimate SE LL UL # 2.3744 0.3314752 1.751678 3.218499res <- c(-2.70, -2.69, -1.32, 1.02, 1.23, -1.46, 2.21, -2.10, 2.56, -3.02, -1.55, 1.46, 4.02, 2.34) ci.mape(.05, res, 1) # Should return: # Estimate SE LL UL # 2.3744 0.3314752 1.751678 3.218499
Computes a confidence interval for a population mean using the estimated mean, estimated standard deviation, and sample size. Use the t.test function for raw data input.
For more details, see Section 1.7 of Bonett (2021, Volume 1)
ci.mean(alpha, m, sd, n)ci.mean(alpha, m, sd, n)
alpha |
alpha level for 1-alpha confidence |
m |
estimated mean |
sd |
estimated standard deviation |
n |
sample size |
Returns a 1-row matrix. The columns are:
Estimate - estimated mean
SE - standard error
LL - lower limit of the confidence interval
UL - upper limit of the confidence interval
Snedecor GW, Cochran WG (1989). Statistical Methods, 8th edition. ISU University Pres, Ames, Iowa.
Bonett DG (2021). Statistical Methods for Psychologists https://dgbonett.sites.ucsc.edu/.
ci.mean(.05, 38.3, 8.14, 10) # Should return: # Estimate SE LL UL # 38.3 2.574094 32.47699 44.12301ci.mean(.05, 38.3, 8.14, 10) # Should return: # Estimate SE LL UL # 38.3 2.574094 32.47699 44.12301
Computes a confidence interval for a population mean with a finite population correction (fpc) using the estimated mean, estimated standard deviation, sample size, and population size. This function is useful when the sample size is not a small fraction of the population size.
For more details, see Section 1.33 of Bonett (2021, Volume 1)
ci.mean.fpc(alpha, m, sd, n, N)ci.mean.fpc(alpha, m, sd, n, N)
alpha |
alpha level for 1-alpha confidence |
m |
estimated mean |
sd |
estimated standard deviation |
n |
sample size |
N |
population size |
Returns a 1-row matrix. The columns are:
Estimate - estimated mean
SE - standard error with fpc
LL - lower limit of the confidence interval with fpc
UL - upper limit of the confidence interval with fpc
Bonett DG (2021). Statistical Methods for Psychologists https://dgbonett.sites.ucsc.edu/.
ci.mean.fpc(.05, 24.5, 3.65, 40, 300) # Should return: # Estimate SE LL UL # 24.5 0.5381631 23.41146 25.58854ci.mean.fpc(.05, 24.5, 3.65, 40, 300) # Should return: # Estimate SE LL UL # 24.5 0.5381631 23.41146 25.58854
Computes confidence intervals for three population generalized means (square-root, geometric, and harmonic) using a vector of response scores as input. The square-root mean requires non-negative scores. The geometric and harmonic means require positive scores. The standard errors are recovered from the confidence intervals.
ci.mean.gen(alpha, y)ci.mean.gen(alpha, y)
alpha |
alpha level for 1-alpha confidence |
y |
vector of scores |
Returns a 1-row matrix. The columns are:
Estimate - estimated mean
SE - recovered standard error
LL - lower limit of the confidence interval
UL - upper limit of the confidence interval
y <- c(32, 47, 28, 15, 20, 41, 87) ci.mean.gen(.05, y) # Should return: # Estimate SE LL UL # Square-root 35.79395 8.141122 18.64498 58.48619 # Geometric 33.26410 7.633328 19.47124 56.82741 # Harmonic 29.07073 7.978149 19.35236 58.39602y <- c(32, 47, 28, 15, 20, 41, 87) ci.mean.gen(.05, y) # Should return: # Estimate SE LL UL # Square-root 35.79395 8.141122 18.64498 58.48619 # Geometric 33.26410 7.633328 19.47124 56.82741 # Harmonic 29.07073 7.978149 19.35236 58.39602
Computes a confidence interval for a population paired-samples mean difference using the estimated means, estimated standard deviations, estimated correlation, and sample size. Also computes a paired-samples t-test. Use the t.test function for raw data input.
For more details, see Section 4.2 of Bonett (2021, Volume 1)
ci.mean.ps(alpha, m1, m2, sd1, sd2, cor, n)ci.mean.ps(alpha, m1, m2, sd1, sd2, cor, n)
alpha |
alpha level for 1-alpha confidence |
m1 |
estimated mean for measurement 1 |
m2 |
estimated mean for measurement 2 |
sd1 |
estimated standard deviation for measurement 1 |
sd2 |
estimated standard deviation for measurement 2 |
cor |
estimated correlation between measurements |
n |
sample size |
Returns a 1-row matrix. The columns are:
Estimate - estimated mean difference
SE - standard error
t - t test statistic
df - degrees of freedom
p - two-sided p-value
LL - lower limit of the confidence interval
UL - upper limit of the confidence interval
Snedecor GW, Cochran WG (1989). Statistical Methods, 8th edition. ISU University Pres, Ames, Iowa.
Bonett DG (2021). Statistical Methods for Psychologists https://dgbonett.sites.ucsc.edu/.
ci.mean.ps(.05, 58.2, 51.4, 7.43, 8.92, .537, 30) # Should return: # Estimate SE t df p LL UL # 6.8 1.455922 4.6706 29 6e-05 3.822304 9.777696ci.mean.ps(.05, 58.2, 51.4, 7.43, 8.92, .537, 30) # Should return: # Estimate SE t df p LL UL # 6.8 1.455922 4.6706 29 6e-05 3.822304 9.777696
Computes equal variance and unequal variance confidence intervals for a population 2-group mean difference using the estimated means, estimated standard deviations, and sample sizes. Also computes equal variance and unequal variance independent-samples t-tests. Use the t.test function for raw data input.
For more details, see Section 2.3 of Bonett (2021, Volume 1)
ci.mean2(alpha, m1, m2, sd1, sd2, n1, n2)ci.mean2(alpha, m1, m2, sd1, sd2, n1, n2)
alpha |
alpha level for 1-alpha confidence |
m1 |
estimated mean for group 1 |
m2 |
estimated mean for group 2 |
sd1 |
estimated standard deviation for group 1 |
sd2 |
estimated standard deviation for group 2 |
n1 |
sample size for group 1 |
n2 |
sample size for group 2 |
Returns a 2-row matrix. The columns are:
Estimate - estimated mean difference
SE - standard error
t - t test statistic
df - degrees of freedom
p - two-sided p-value
LL - lower limit of the confidence interval
UL - upper limit of the confidence interval
Snedecor GW, Cochran WG (1989). Statistical Methods, 8th edition. ISU University Pres, Ames, Iowa.
Bonett DG (2021). Statistical Methods for Psychologists https://dgbonett.sites.ucsc.edu/.
ci.mean2(.05, 19.4, 11.3, 2.70, 2.10, 40, 40) # Should return: # Estimate SE t df p # Equal Variances Assumed: 8.1 0.5408327 14.9769 78.00 0 # Equal Variances Not Assumed: 8.1 0.5408327 14.9769 73.54 0 # LL UL # Equal Variances Assumed: 7.023285 9.176715 # Equal Variances Not Assumed: 7.022256 9.177744ci.mean2(.05, 19.4, 11.3, 2.70, 2.10, 40, 40) # Should return: # Estimate SE t df p # Equal Variances Assumed: 8.1 0.5408327 14.9769 78.00 0 # Equal Variances Not Assumed: 8.1 0.5408327 14.9769 73.54 0 # LL UL # Equal Variances Assumed: 7.023285 9.176715 # Equal Variances Not Assumed: 7.022256 9.177744
Computes a distribution-free confidence interval for a population median. Tied scores are assumed to be rare.
For more details, see Section 1.25 of Bonett (2021, Volume 1)
ci.median(alpha, y)ci.median(alpha, y)
alpha |
alpha level for 1-alpha confidence |
y |
vector of scores |
Returns a 1-row matrix. The columns are:
Estimate - estimated median
SE - standard error
LL - lower limit of the confidence interval
UL - upper limit of the confidence interval
Snedecor GW, Cochran WG (1989). Statistical Methods, 8th edition. ISU University Pres, Ames, Iowa.
Bonett DG (2021). Statistical Methods for Psychologists https://dgbonett.sites.ucsc.edu/.
y <- c(25, 29, 35, 36, 36, 40, 41, 43, 44, 54) ci.median(.05, y) # Should return: # Estimate SE LL UL # 38 3.261774 29 44y <- c(25, 29, 35, 36, 36, 40, 41, 43, 44, 54) ci.median(.05, y) # Should return: # Estimate SE LL UL # 38 3.261774 29 44
Computes a distribution-free confidence interval for a difference of population medians in a paired-samples design. This function also computes the standard error of each median and the covariance between the two estimated medians. Tied scores within each measurement are assumed to be rare.
For more details, see Section 4.23 of Bonett (2021, Volume 1)
ci.median.ps(alpha, y1, y2)ci.median.ps(alpha, y1, y2)
alpha |
alpha level for 1-alpha confidence |
y1 |
vector of scores for measurement 1 |
y2 |
vector of scores for measurement 2 (paired with y1) |
Returns a 1-row matrix. The columns are:
Median1 - estimated median for measurement 1
Median2 - estimated median for measurement 2
Median1-Median2 - estimated difference of medians
SE1 - standard error of median 1
SE2 - standard error of median 2
COV - covariance of the two estimated medians
LL - lower limit of the confidence interval
UL - upper limit of the confidence interval
Bonett DG, Price RM (2020). “Interval estimation for linear functions of medians in within-subjects and mixed designs.” British Journal of Mathematical and Statistical Psychology, 73(2), 333–346. ISSN 0007-1102. doi:10.1111/bmsp.12171.
Bonett DG (2021). Statistical Methods for Psychologists https://dgbonett.sites.ucsc.edu/.
y1 <- c(21.1, 4.9, 9.2, 12.4, 35.8, 18.1, 10.7, 22.9, 24.0, 1.2, 6.1, 8.3, 13.1, 16.2) y2 <- c(67.0, 28.1, 30.9, 28.6, 52.0, 40.8, 25.8, 37.4, 44.9, 10.3, 14.9, 20.2, 28.8, 40.6) ci.median.ps(.05, y1, y2) # Should return: # Median1 Median2 Median1-Median2 SE LL UL # 12.75 29.85 -17.1 3.704248 -24.36019 -9.839807 # SE1 SE2 COV # 3.379695 4.968956 11.1957y1 <- c(21.1, 4.9, 9.2, 12.4, 35.8, 18.1, 10.7, 22.9, 24.0, 1.2, 6.1, 8.3, 13.1, 16.2) y2 <- c(67.0, 28.1, 30.9, 28.6, 52.0, 40.8, 25.8, 37.4, 44.9, 10.3, 14.9, 20.2, 28.8, 40.6) ci.median.ps(.05, y1, y2) # Should return: # Median1 Median2 Median1-Median2 SE LL UL # 12.75 29.85 -17.1 3.704248 -24.36019 -9.839807 # SE1 SE2 COV # 3.379695 4.968956 11.1957
Computes a distribution-free confidence interval for a difference of population medians in a 2-group design. Tied scores within each group are assumed to be rare.
For more details, see Section 2.12 of Bonett (2021, Volume 1)
ci.median2(alpha, y1, y2)ci.median2(alpha, y1, y2)
alpha |
alpha level for 1-alpha confidence |
y1 |
vector of scores for group 1 |
y2 |
vector of scores for group 2 |
Returns a 1-row matrix. The columns are:
Median1 - estimated median for group 1
Median2 - estimated median for group 2
Median1-Median2 - estimated difference of medians
SE - standard error
LL - lower limit of the confidence interval
UL - upper limit of the confidence interval
Bonett DG, Price RM (2002). “Statistical inference for a linear function of medians: Confidence intervals, hypothesis testing, and sample size requirements.” Psychological Methods, 7(3), 370–383. ISSN 1939-1463. doi:10.1037/1082-989X.7.3.370.
Bonett DG (2021). Statistical Methods for Psychologists https://dgbonett.sites.ucsc.edu/.
y1 = c(70, 394, 43, 95, 62, 128, 2, 203, 81, 436, 85, 35, 156, 1, 3, 27, 63, 181, 184, 18) y2 = c(102, 120, 78, 78, 417, 124, 86, 171, 176, 129, 230, 194, 100, 157, 306, 411, 164, 103, 193, 312) ci.median2(.05, y1, y2) # Should return: # Median1 Median2 Median1-Median2 SE LL UL # 75.5 160.5 -85 37.11502 -157.7441 -12.25589y1 = c(70, 394, 43, 95, 62, 128, 2, 203, 81, 436, 85, 35, 156, 1, 3, 27, 63, 181, 184, 18) y2 = c(102, 120, 78, 78, 417, 124, 86, 171, 176, 129, 230, 194, 100, 157, 306, 411, 164, 103, 193, 312) ci.median2(.05, y1, y2) # Should return: # Median1 Median2 Median1-Median2 SE LL UL # 75.5 160.5 -85 37.11502 -157.7441 -12.25589
Computes a confidence interval for an odds ratio with .5 added to each cell frequency. This function requires the frequency counts from a 2 x 2 contingency table for two dichotomous variables.
For more details, see Section 3.4 of Bonett (2021, Volume 3)
ci.oddsratio(alpha, f00, f01, f10, f11)ci.oddsratio(alpha, f00, f01, f10, f11)
alpha |
alpha level for 1-alpha confidence |
f00 |
number of participants with y = 0 and x = 0 |
f01 |
number of participants with y = 0 and x = 1 |
f10 |
number of participants with y = 1 and x = 0 |
f11 |
number of participants with y = 1 and x = 1 |
Returns a 1-row matrix. The columns are:
Estimate - estimate of odds ratio
SE - standard error
LL - lower limit of the confidence interval
UL - upper limit of the confidence interval
Fleiss JL, Paik MC (2003). Statistical Methods for Rates and Proportions, 3rd edition. Wiley.
Bonett DG (2021). Statistical Methods for Psychologists https://dgbonett.sites.ucsc.edu/.
ci.oddsratio(.05, 229, 28, 96, 24) # Should return: # Estimate SE LL UL # 2.044451 0.6154578 1.133267 3.688254ci.oddsratio(.05, 229, 28, 96, 24) # Should return: # Estimate SE LL UL # 2.044451 0.6154578 1.133267 3.688254
Computes adjusted Wald confidence intervals for pairwise proportion differences of a multinomial variable in a single sample. These adjusted Wald confidence intervals use the same method that is used to compare the two proportions in a paired-samples design.
For more details, see Section 1.12 of Bonett (2021, Volume 3)
ci.pairs.mult(alpha, f)ci.pairs.mult(alpha, f)
alpha |
alpha level for 1-alpha confidence |
f |
vector of multinomial frequency counts |
Returns a matrix with the number of rows equal to the number of pairwise comparisons. The columns are:
Estimate - adjusted estimate of proportion difference
SE - adjusted standard error
LL - lower limit of the adjusted Wald confidence interval
UL - upper limit of the adjusted Wald confidence interval
Bonett DG, Price RM (2012). “Adjusted wald confidence interval for a difference of binomial proportions based on paired data.” Journal of Educational and Behavioral Statistics, 37(4), 479–488. ISSN 1076-9986. doi:10.3102/1076998611411915.
Bonett DG (2021). Statistical Methods for Psychologists https://dgbonett.sites.ucsc.edu/.
f <- c(87, 49, 31, 133) ci.pairs.mult(.05, f) # Should return: # Estimate SE LL UL # 1 2 0.12582781 0.03821865 0.050920628 0.20073500 # 1 3 0.18543046 0.03466808 0.117482270 0.25337866 # 1 4 -0.15231788 0.04855183 -0.247477718 -0.05715804 # 2 3 0.05960265 0.02978792 0.001219398 0.11798590 # 2 4 -0.27814570 0.04196760 -0.360400688 -0.19589070 # 3 4 -0.33774834 0.03797851 -0.412184859 -0.26331183f <- c(87, 49, 31, 133) ci.pairs.mult(.05, f) # Should return: # Estimate SE LL UL # 1 2 0.12582781 0.03821865 0.050920628 0.20073500 # 1 3 0.18543046 0.03466808 0.117482270 0.25337866 # 1 4 -0.15231788 0.04855183 -0.247477718 -0.05715804 # 2 3 0.05960265 0.02978792 0.001219398 0.11798590 # 2 4 -0.27814570 0.04196760 -0.360400688 -0.19589070 # 3 4 -0.33774834 0.03797851 -0.412184859 -0.26331183
Computes adjusted Wald confidence intervals for all pairwise differences of population proportions in a between-subjects design using a Bonferroni adjusted alpha level.
For more details, see Section 2.7 of Bonett (2021, Volume 3)
ci.pairs.prop.bs(alpha, f, n)ci.pairs.prop.bs(alpha, f, n)
alpha |
alpha level for simultaneous 1-alpha confidence |
f |
vector of frequency counts of participants who have the attribute |
n |
vector of sample sizes |
Returns a matrix with the number of rows equal to the number of pairwise comparisons. The columns are:
Estimate - adjusted estimate of proportion difference
SE - adjusted standard error
z - z test statistic
p - two-sided p-value
LL - lower limit of the adjusted Wald confidence interval
UL - upper limit of the adjusted Wald confidence interval
Agresti A, Caffo B (2000). “Simple and effective confidence intervals for proportions and differences of proportions result from adding two successes and two failures.” The American Statistician, 54(4), 280-288. ISSN 00031305. doi:10.2307/2685779.
Bonett DG (2021). Statistical Methods for Psychologists https://dgbonett.sites.ucsc.edu/.
f <- c(111, 161, 132) n <- c(200, 200, 200) ci.pairs.prop.bs(.05, f, n) # Should return: # Estimate SE z p LL UL # 1 2 -0.2475248 0.04482323 -5.5222 0.00000 -0.35483065 -0.14021885 # 1 3 -0.1039604 0.04833562 -2.1508 0.03149 -0.21967489 0.01175409 # 2 3 0.1435644 0.04358401 3.2940 0.00099 0.03922511 0.24790360f <- c(111, 161, 132) n <- c(200, 200, 200) ci.pairs.prop.bs(.05, f, n) # Should return: # Estimate SE z p LL UL # 1 2 -0.2475248 0.04482323 -5.5222 0.00000 -0.35483065 -0.14021885 # 1 3 -0.1039604 0.04833562 -2.1508 0.03149 -0.21967489 0.01175409 # 2 3 0.1435644 0.04358401 3.2940 0.00099 0.03922511 0.24790360
Computes confidence intervals for two types of population point-biserial correlations. One type uses a weighted average of the group variances and is appropriate for nonexperimental designs with simple random sampling (but not stratified random sampling). The other type uses an unweighted average of the group variances and is appropriate for experimental designs. Equality of variances is not assumed for either type.
For more details, see Section 1.18 of Bonett (2021, Volume 2)
ci.pbcor(alpha, m1, m2, sd1, sd2, n1, n2)ci.pbcor(alpha, m1, m2, sd1, sd2, n1, n2)
alpha |
alpha level for 1-alpha confidence |
m1 |
estimated mean for group 1 |
m2 |
estimated mean for group 2 |
sd1 |
estimated standard deviation for group 1 |
sd2 |
estimated standard deviation for group 2 |
n1 |
sample size for group 1 |
n2 |
sample size for group 2 |
Returns a 2-row matrix. The columns are:
Estimate - estimated point-biserial correlation
SE - standard error
LL - lower limit of the confidence interval
UL - upper limit of the confidence interval
Bonett DG (2020). “Point-biserial correlation: Interval estimation, hypothesis testing, meta-analysis, and sample size determination.” British Journal of Mathematical and Statistical Psychology, 73(S1), 113–144. ISSN 0007-1102. doi:10.1111/bmsp.12189.
Bonett DG (2021). Statistical Methods for Psychologists https://dgbonett.sites.ucsc.edu/.
ci.pbcor(.05, 28.32, 21.48, 3.81, 3.09, 40, 40) # Should return: # Estimate SE LL UL # Weighted: 0.7066 0.04891 0.5885 0.7854 # Unweighted: 0.7021 0.05019 0.5808 0.7829ci.pbcor(.05, 28.32, 21.48, 3.81, 3.09, 40, 40) # Should return: # Estimate SE LL UL # Weighted: 0.7066 0.04891 0.5885 0.7854 # Unweighted: 0.7021 0.05019 0.5808 0.7829
Computes a Fisher confidence interval for a population phi correlation. This function requires the frequency counts from a 2 x 2 contingency table for two dichotomous variables. This measure of association is usually most appropriate when both dichotomous variables are naturally dichotomous.
For more details, see Section 3.4 of Bonett (2021, Volume 3)
ci.phi(alpha, f00, f01, f10, f11)ci.phi(alpha, f00, f01, f10, f11)
alpha |
alpha level for 1-alpha confidence |
f00 |
number of participants with y = 0 and x = 0 |
f01 |
number of participants with y = 0 and x = 1 |
f10 |
number of participants with y = 1 and x = 0 |
f11 |
number of participants with y = 1 and x = 1 |
Returns a 1-row matrix. The columns are:
Estimate - estimate of phi correlation
SE - standard error
LL - lower limit of the confidence interval
UL - upper limit of the confidence interval
Bishop YMM, Fienberg SE, Holland PW (1975). Discrete Multivariate Analysis. MIT Press.
Bonett DG (2021). Statistical Methods for Psychologists https://dgbonett.sites.ucsc.edu/.
ci.phi(.05, 229, 28, 96, 24) # Should return: # Estimate SE LL UL # 0.123 0.0548 0.015 0.229ci.phi(.05, 229, 28, 96, 24) # Should return: # Estimate SE LL UL # 0.123 0.0548 0.015 0.229
Computes a confidence interval for a population Poisson rate. This function requires the number of occurrences (f) of a specific event that were observed over a specific period of time (t).
ci.poisson(alpha, f, t)ci.poisson(alpha, f, t)
alpha |
alpha value for 1-alpha confidence |
f |
number of event occurrences |
t |
time period |
The time period (t) does not need to be an integer and can be expressed in any unit of time such as seconds, hours, or months. The occurances are assumed to be independent of one another and the unknown occurance rate is assumed to be constant over time.
Returns a 1-row matrix. The columns are:
Estimate - estimated Poisson rate
SE - recovered standard error
LL - lower limit of the confidence interval
UL - upper limit of the confidence interval
Hahn GJ, Meeker WQ (1991). Statistical Intervals: A Guide for Practitioners. Wiley. ISBN 9780470316771. doi:10.1002/9780470316771.
ci.poisson(.05, 23, 5.25) # Should return: # Estimate SE LL UL # 4.380952 0.9684952 2.777148 6.57358ci.poisson(.05, 23, 5.25) # Should return: # Estimate SE LL UL # 4.380952 0.9684952 2.777148 6.57358
Computes a Wald confidence interval for an unknown population size using mark-recapture sampling. This method assumes independence of the two samples. This function requires the frequency counts from an incomplete 2 x 2 contingency table for the two samples (f11 is the unknown number of people who were not observed in either sample). This method sets the estimated odds ratio (with .5 added to each cell) to 1 and solves for unobserved cell frequency. An approximate standard error is recovered from the confidence interval.
For more details, see Section 3.7 of Bonett (2021, Volume 3)
ci.popsize(alpha, f00, f01, f10)ci.popsize(alpha, f00, f01, f10)
alpha |
alpha level for 1-alpha confidence |
f00 |
number of people observed in both samples |
f01 |
number of people observed in first sample but not second sample |
f10 |
number of people observed in second sample but not first sample |
Returns a 1-row matrix. The columns are:
Estimate - estimate of the unknown population size
SE - recovered standard error
LL - lower limit of the confidence interval
UL - upper limit of the confidence interval
Bonett DG (2021). Statistical Methods for Psychologists https://dgbonett.sites.ucsc.edu/.
ci.popsize(.05, 85, 196, 184) # Should return: # Estimate SE LL UL # 889 67.35 777 1041ci.popsize(.05, 85, 196, 184) # Should return: # Estimate SE LL UL # 889 67.35 777 1041
Computes adjusted Wald (Agresi-Coull), Wilson, and exact confidence intervals for a population proportion. The Wilson confidence interval uses a continuity correction.
For more details, see Section 1.5 of Bonett (2021, Volume 3)
ci.prop(alpha, f, n)ci.prop(alpha, f, n)
alpha |
alpha level for 1-alpha confidence |
f |
number of participants who have the attribute |
n |
sample size |
Returns a 2-row matrix. The columns of row 1 are:
Estimate - adjusted estimate of proportion
SE - standard error of adjusted estimate
LL - lower limit of the adjusted Wald confidence interval
UL - upper limit of the adjusted Wald confidence interval
The columns of row 2 are:
Estimate - ML estimate of proportion
SE - standard error of ML estimate
LL - lower limit of the Wilson confidence interval
UL - upper limit of the Wilson confidence interval
The columns of row 3 are:
Estimate - ML estimate of proportion
SE - standard error of ML estimate
LL - lower limit of the exact confidence interval
UL - upper limit of the exact confidence interval
Bonett DG (2021). Statistical Methods for Psychologists https://dgbonett.sites.ucsc.edu/.
Agresti A, Coull BA (1998). “Approximate is better than 'exact' for interval estimation of binomial proportions.” The American Statistician, 52(2), 119–126. ISSN 0003-1305. doi:10.1080/00031305.1998.10480550.
ci.prop(.05, 120, 300) # Should return: # Estimate SE LL UL # Adjusted Wald 0.4013158 0.02811287 0.3462156 0.4564160 # Wilson with cc 0.4000000 0.02828427 0.3445577 0.4580464 # Exact 0.4000000 0.02828427 0.3441290 0.4578664ci.prop(.05, 120, 300) # Should return: # Estimate SE LL UL # Adjusted Wald 0.4013158 0.02811287 0.3462156 0.4564160 # Wilson with cc 0.4000000 0.02828427 0.3445577 0.4580464 # Exact 0.4000000 0.02828427 0.3441290 0.4578664
Computes an adjusted Wald interval for a population proportion with a finite population correction (fpc). This confidence interval is useful when the sample size is not a small fraction of the population size.
For more details, see Section 1.20 of Bonett (2021, Volume 3)
ci.prop.fpc(alpha, f, n, N)ci.prop.fpc(alpha, f, n, N)
alpha |
alpha level for 1-alpha confidence |
f |
number of participants who have the attribute |
n |
sample size |
N |
population size |
Returns a 1-row matrix. The columns are:
Estimate - adjusted estimate of proportion
SE - adjusted standard error with fpc
LL - lower limit of the confidence interval with fpc
UL - upper limit of the confidence interval with fpc
Bonett DG (2021). Statistical Methods for Psychologists https://dgbonett.sites.ucsc.edu/.
ci.prop.fpc(.05, 61, 75, 415) # Should return: # Estimate SE LL UL # 0.7974684 0.04097594 0.717157 0.8777797ci.prop.fpc(.05, 61, 75, 415) # Should return: # Estimate SE LL UL # 0.7974684 0.04097594 0.717157 0.8777797
Computes an exact confidence interval for a population proportion when inverse sampling has been used. An approximate standard error is recovered from the confidence interval. With inverse sampling, the number of participants who have the attribute (f) is predetermined and sampling continues until f attains its prespecified value. With inverse sampling, the sample size (n) will not be known in advance.
For more details, see Section 1.19 of Bonett (2021, Volume 3)
ci.prop.inv(alpha, f, n)ci.prop.inv(alpha, f, n)
alpha |
alpha level for 1-alpha confidence |
f |
number of participants who have the attribute (fixed) |
n |
sample size (random) |
Returns a 1-row matrix. The columns are:
Estimate - estimate of proportion
SE - recovered standard error
LL - lower limit of confidence interval
UL - upper limit of confidence interval
Zou GY (2010). “Confidence interval estimation under inverse sampling.” Computational Statistics & Data Analysis, 54(1), 55–64. ISSN 0167-9473. doi:10.1016/j.csda.2005.05.007.
Bonett DG (2021). Statistical Methods for Psychologists https://dgbonett.sites.ucsc.edu/.
ci.prop.inv(.05, 10, 87) # Should return: # Estimate SE LL UL # 0.1149425 0.03389574 0.05651668 0.1893855ci.prop.inv(.05, 10, 87) # Should return: # Estimate SE LL UL # 0.1149425 0.03389574 0.05651668 0.1893855
Computes an adjusted Wald confidence interval for a difference of population proportions in a paired-samples design. This function requires the frequency counts from a 2 x 2 contingency table for two repeated dichotomous measurements.
For more details, see Section 3.2 of Bonett (2021, Volume 3)
ci.prop.ps(alpha, f00, f01, f10, f11)ci.prop.ps(alpha, f00, f01, f10, f11)
alpha |
alpha level for 1-alpha confidence |
f00 |
number of participants with y = 0 and x = 0 |
f01 |
number of participants with y = 0 and x = 1 |
f10 |
number of participants with y = 1 and x = 0 |
f11 |
number of participants with y = 1 and x = 1 |
Returns a 1-row matrix. The columns are:
Estimate - adjusted estimate of proportion difference
SE - adjusted standard error
LL - lower limit of the adjusted Wald confidence interval
UL - upper limit of the adjusted Wald confidence interval
Bonett DG, Price RM (2012). “Adjusted wald confidence interval for a difference of binomial proportions based on paired data.” Journal of Educational and Behavioral Statistics, 37(4), 479–488. ISSN 1076-9986. doi:10.3102/1076998611411915.
Bonett DG (2021). Statistical Methods for Psychologists https://dgbonett.sites.ucsc.edu/.
ci.prop.ps(.05, 12, 4, 26, 6) # Should return: # Estimate SE LL UL # 0.44 0.09448809 0.2548067 0.6251933ci.prop.ps(.05, 12, 4, 26, 6) # Should return: # Estimate SE LL UL # 0.44 0.09448809 0.2548067 0.6251933
Computes an adjusted Wald confidence interval for a population proportion difference in a 2-group design.
For more details, see Section 2.2 of Bonett (2021, Volume 3)
ci.prop2(alpha, f1, f2, n1, n2)ci.prop2(alpha, f1, f2, n1, n2)
alpha |
alpha level for 1-alpha confidence |
f1 |
number of participants in group 1 who have the attribute |
f2 |
number of participants in group 2 who have the attribute |
n1 |
sample size for group 1 |
n2 |
sample size for group 2 |
Returns a 1-row matrix. The columns are:
Estimate - adjusted estimate of proportion difference
SE - adjusted standard error
LL - lower limit of the adjusted Wald confidence interval
UL - upper limit of the adjusted Wald confidence interval
Agresti A, Caffo B (2000). “Simple and effective confidence intervals for proportions and differences of proportions result from adding two successes and two failures.” The American Statistician, 54(4), 280-288. ISSN 00031305. doi:10.2307/2685779.
Bonett DG (2021). Statistical Methods for Psychologists https://dgbonett.sites.ucsc.edu/.
ci.prop2(.05, 57, 15, 100, 100) # Should return: # Estimate SE LL UL # 0.4117647 0.06083948 0.2925215 0.5310079ci.prop2(.05, 57, 15, 100, 100) # Should return: # Estimate SE LL UL # 0.4117647 0.06083948 0.2925215 0.5310079
Computes an approximate confidence interval for a population proportion difference when inverse sampling has been used. An approximate standard error is recovered from the confidence interval. With inverse sampling, the number of participants who have the attribute within group 1 (f1) and group 2 (f2) are predetermined, and sampling continues within each group until f1 and f2 attain their prespecified values. With inverse sampling, the sample sizes (n1 and n2) will not be known in advance.
ci.prop2.inv(alpha, f1, f2, n1, n2)ci.prop2.inv(alpha, f1, f2, n1, n2)
alpha |
alpha level for 1-alpha confidence |
f1 |
number of participants in group 1 who have the attribute (fixed) |
f2 |
number of participants in group 2 who have the attribute (fixed) |
n1 |
sample size for group 1 (random) |
n2 |
sample size for group 2 (random) |
Returns a 1-row matrix. The columns are:
Estimate - estimate of proportion difference
SE - recovered standard error
LL - lower limit of confidence interval
UL - upper limit of confidence interval
Zou GY (2010). “Confidence interval estimation under inverse sampling.” Computational Statistics & Data Analysis, 54(1), 55–64. ISSN 0167-9473. doi:10.1016/j.csda.2005.05.007.
ci.prop2.inv(.05, 10, 10, 48, 213) # Should return: # Estimate SE LL UL # 0.161385 0.05997618 0.05288277 0.2879851ci.prop2.inv(.05, 10, 10, 48, 213) # Should return: # Estimate SE LL UL # 0.161385 0.05997618 0.05288277 0.2879851
Computes adjusted Wald confidence intervals for positive and negative predictive values (PPV and NPV) of a diagnostic test with retrospective sampling where the population prevalence rate is assumed to be known. With retrospective sampling, one random sample is obtained from a subpopulation that is known to have a "positive" outcome, a second random sample is obtained from a subpopulation that is known to have a "negative" outcome, and then the diagnostic test (scored "pass" or "fail") is given in each sample. PPV and NPV can be expressed as a function of proportion ratios and the known population prevalence rate (the population proportion who would "pass"). The confidence intervals for PPV and NPV are based on the Price-Bonett adjusted Wald confidence interval for a proportion ratio.
For more details, see Section 3.6 of Bonett (2021, Volume 3)
ci.pv(alpha, f1, f2, n1, n2, prev)ci.pv(alpha, f1, f2, n1, n2, prev)
alpha |
alpha level for 1-alpha confidence |
f1 |
number of participants with a positive outcome who pass the test |
f2 |
number of participants with a negative outcome who fail the test |
n1 |
sample size for the positive outcome group |
n2 |
sample size for the negative outcome group |
prev |
known population proportion with a positive outcome |
Returns a 2-row matrix. The columns are:
Estimate - adjusted estimate of the predictive value
LL - lower limit of the adjusted Wald confidence interval
UL - upper limit of the adjusted Wald confidence interval
Price RM, Bonett DG (2008). “Confidence intervals for a ratio of two independent binomial proportions.” Statistics in Medicine, 27(26), 5497–5508. ISSN 02776715. doi:10.1002/sim.3376.
Bonett DG (2021). Statistical Methods for Psychologists https://dgbonett.sites.ucsc.edu/.
ci.pv(.05, 89, 5, 100, 100, .16) # Should return: # Estimate LL UL # PPV: 0.7640449 0.5838940 0.8819671 # NPV: 0.9779978 0.9623406 0.9872318ci.pv(.05, 89, 5, 100, 100, .16) # Should return: # Estimate LL UL # PPV: 0.7640449 0.5838940 0.8819671 # NPV: 0.9779978 0.9623406 0.9872318
Computes estimates and confidence intervals for four parameters of the one-way random effects ANOVA: 1) the superpopulation grand mean, 2) the square-root within-group variance component, 3) the square-root between-group variance component, and 4) the omega-squared coefficient. This function assumes equal sample sizes.
For more details, see Section 3.18 of Bonett (2021, Volume 1)
ci.random.anova(alpha, m, sd, n)ci.random.anova(alpha, m, sd, n)
alpha |
1 - alpha confidence |
m |
vector of estimated group means |
sd |
vector of estimated group standard deviations |
n |
common sample size in each group |
Returns a 4-row matrix. The rows are:
Grand mean - the mean of the superpopulation of means
Within SD - the square-root within-group variance component
Between SD - the square-root between-group variance component
Omega-squared - the omega-squared coefficient
The columns are:
Estimate - estimate of parameter
LL - lower limit of the confidence interval
UL - upper limit of the confidence interval
Bonett DG (2021). Statistical Methods for Psychologists https://dgbonett.sites.ucsc.edu/.
m <- c(56.1, 51.2, 60.3, 68.2, 48.9, 70.5) sd <- c(9.45, 8.79, 9.71, 8.90, 8.31, 9.75) ci.random.anova(.05, m, sd, 20) # Should return: # Estimate LL UL # Grand mean 59.200000 49.9363896 68.4636104 # Within SD: 9.166782 8.0509046 10.4373219 # Between SD: 8.585948 8.3239359 8.8562078 # Omega-squared: 0.467317 0.2284142 0.8480383m <- c(56.1, 51.2, 60.3, 68.2, 48.9, 70.5) sd <- c(9.45, 8.79, 9.71, 8.90, 8.31, 9.75) ci.random.anova(.05, m, sd, 20) # Should return: # Estimate LL UL # Grand mean 59.200000 49.9363896 68.4636104 # Within SD: 9.166782 8.0509046 10.4373219 # Between SD: 8.585948 8.3239359 8.8562078 # Omega-squared: 0.467317 0.2284142 0.8480383
Computes a confidence interval for a ratio of population dispersion coefficients (mean absolute deviation from median divided by median) in a 2-group design. Ratio-scale scores are assumed.
ci.ratio.cod2(alpha, y1, y2)ci.ratio.cod2(alpha, y1, y2)
alpha |
alpha level for 1-alpha confidence |
y1 |
vector of scores in group 1 |
y2 |
vector of scores in group 2 |
Returns a 1-row matrix. The columns are:
COD1 - estimated coefficient of dispersion in group 1
COD2 - estimated coefficient of dispersion in group 2
COD1/COD2 - estimated ratio of dispersion coefficients
LL - lower limit of the confidence interval
UL - upper limit of the confidence interval
y1 <- c(32, 39, 26, 35, 43, 27, 40, 37, 34, 29) y2 <- c(36, 44, 47, 42, 49, 39, 46, 31, 33, 48) ci.ratio.cod2(.05, y1, y2) # Should return: # COD1 COD2 COD1/COD2 LL UL # 0.1333333 0.1232558 1.081761 0.494964 2.282254y1 <- c(32, 39, 26, 35, 43, 27, 40, 37, 34, 29) y2 <- c(36, 44, 47, 42, 49, 39, 46, 31, 33, 48) ci.ratio.cod2(.05, y1, y2) # Should return: # COD1 COD2 COD1/COD2 LL UL # 0.1333333 0.1232558 1.081761 0.494964 2.282254
Computes a confidence interval for a ratio of population coefficients of variation (CV) in a 2-group design. This confidence interval uses the confidence interval for each CV and then uses the MOVER-DL method (see Newcombe, page 138) to obtain a confidence interval for CV1/CV2. The CV assumes ratio-scale scores.
ci.ratio.cv2(alpha, m1, m2, sd1, sd2, n1, n2)ci.ratio.cv2(alpha, m1, m2, sd1, sd2, n1, n2)
alpha |
alpha level for 1-alpha confidence |
m1 |
estimated mean for group 1 |
m2 |
estimated mean for group 2 |
sd1 |
estimated standard deviation for group 1 |
sd2 |
estimated standard deviation for group 2 |
n1 |
sample size for group 1 |
n2 |
sample size for group 2 |
Returns a 1-row matrix. The columns are:
Estimate - estimated ratio of coefficients of variation
LL - lower limit of the confidence interval
UL - upper limit of the confidence interval
Newcombe RG (2013). Confidence Interval for Proportions and Related Measures of Effect Size. CRC Press.
ci.ratio.cv2(.05, 34.5, 26.1, 4.15, 2.26, 50, 50) # Should return: # Estimate LL UL # 1.389188 1.041478 1.854101ci.ratio.cv2(.05, 34.5, 26.1, 4.15, 2.26, 50, 50) # Should return: # Estimate LL UL # 1.389188 1.041478 1.854101
Computes a confidence interval for a ratio of population MADs (mean absolute deviation from median) in a paired-samples design.
For more details, see Section 4.24 of Bonett (2021, Volume 1)
ci.ratio.mad.ps(alpha, y1, y2)ci.ratio.mad.ps(alpha, y1, y2)
alpha |
alpha level for 1-alpha confidence |
y1 |
vector of measurement 1 scores |
y2 |
vector of measurement 2 scores (paired with y1) |
Returns a 1-row matrix. The columns are:
MAD1 - estimated MAD for measurement 1
MAD2 - estimated MAD for measurement 2
MAD1/MAD2 - estimate of MAD ratio
LL - lower limit of the confidence interval
UL - upper limit of the confidence interval
Bonett DG, Seier E (2003). “Statistical inference for a ratio of dispersions using paired samples.” Journal of Educational and Behavioral Statistics, 28(1), 21–30. ISSN 1076-9986. doi:10.3102/10769986028001021.
Bonett DG (2021). Statistical Methods for Psychologists https://dgbonett.sites.ucsc.edu/.
y2 <- c(21, 4, 9, 12, 35, 18, 10, 22, 24, 1, 6, 8, 13, 16, 19) y1 <- c(67, 28, 30, 28, 52, 40, 25, 37, 44, 10, 14, 20, 28, 40, 51) ci.ratio.mad.ps(.05, y1, y2) # Should return: # MAD1 MAD2 MAD1/MAD2 LL UL # 12.71429 7.5 1.695238 1.109176 2.590961y2 <- c(21, 4, 9, 12, 35, 18, 10, 22, 24, 1, 6, 8, 13, 16, 19) y1 <- c(67, 28, 30, 28, 52, 40, 25, 37, 44, 10, 14, 20, 28, 40, 51) ci.ratio.mad.ps(.05, y1, y2) # Should return: # MAD1 MAD2 MAD1/MAD2 LL UL # 12.71429 7.5 1.695238 1.109176 2.590961
Computes a confidence interval for a ratio of population MADs (mean absolute deviation from median) in a 2-group design.
For more details, see Section 2.10 of Bonett (2021, Volume 1)
ci.ratio.mad2(alpha, y1, y2)ci.ratio.mad2(alpha, y1, y2)
alpha |
alpha level for 1-alpha confidence |
y1 |
vector of scores for group 1 |
y2 |
vector of scores for group 2 |
Returns a 1-row matrix. The columns are:
MAD1 - estimated MAD for group 1
MAD2 - estimated MAD for group 2
MAD1/MAD2 - estimate of MAD ratio
LL - lower limit of the confidence interval
UL - upper limit of the confidence interval
Bonett DG, Seier E (2003). “Confidence intervals for mean absolute deviations.” The American Statistician, 57(4), 233–236. ISSN 0003-1305. doi:10.1198/0003130032323.
Bonett DG (2021). Statistical Methods for Psychologists https://dgbonett.sites.ucsc.edu/.
y1 <- c(32, 39, 26, 35, 43, 27, 40, 37, 34, 29) y2 <- c(36, 44, 47, 42, 49, 39, 46, 31, 33, 48) ci.ratio.mad2(.05, y1, y2) # Should return: # MAD1 MAD2 MAD1/MAD2 LL UL # 5.111111 5.888889 0.8679245 0.4520879 1.666253y1 <- c(32, 39, 26, 35, 43, 27, 40, 37, 34, 29) y2 <- c(36, 44, 47, 42, 49, 39, 46, 31, 33, 48) ci.ratio.mad2(.05, y1, y2) # Should return: # MAD1 MAD2 MAD1/MAD2 LL UL # 5.111111 5.888889 0.8679245 0.4520879 1.666253
Computes a confidence interval for a ratio of population mean absolute prediction errors from a general linear model in two independent groups. The number of predictor variables can differ across groups and the two models can be non-nested. This function requires a vector of estimated residuals from each group. This function does not assume zero excess kurtosis but does assume symmetry in the population prediction errors for the two models.
ci.ratio.mape2(alpha, res1, res2, s1, s2)ci.ratio.mape2(alpha, res1, res2, s1, s2)
alpha |
alpha level for 1-alpha confidence |
res1 |
vector of residuals from group 1 |
res2 |
vector of residuals from group 2 |
s1 |
number of predictor variables used in group 1 |
s2 |
number of predictor variables used in group 2 |
Returns a 1-row matrix. The columns are:
MAPE1 - bias adjusted mean absolute prediction error for group 1
MAPE2 - bias adjusted mean absolute prediction error for group 2
MAPE1/MAPE2 - ratio of bias adjusted mean absolute prediction errors
LL - lower limit of the confidence interval
UL - upper limit of the confidence interval
res1 <- c(-2.70, -2.69, -1.32, 1.02, 1.23, -1.46, 2.21, -2.10, 2.56, -3.02 -1.55, 1.46, 4.02, 2.34) res2 <- c(-0.71, -0.89, 0.72, -0.35, 0.33 -0.92, 2.37, 0.51, 0.68, -0.85, -0.15, 0.77, -1.52, 0.89, -0.29, -0.23, -0.94, 0.93, -0.31 -0.04) ci.ratio.mape2(.05, res1, res2, 1, 1) # Should return: # MAPE1 MAPE2 MAPE1/MAPE2 LL UL # 2.58087 0.8327273 3.099298 1.917003 5.010761res1 <- c(-2.70, -2.69, -1.32, 1.02, 1.23, -1.46, 2.21, -2.10, 2.56, -3.02 -1.55, 1.46, 4.02, 2.34) res2 <- c(-0.71, -0.89, 0.72, -0.35, 0.33 -0.92, 2.37, 0.51, 0.68, -0.85, -0.15, 0.77, -1.52, 0.89, -0.29, -0.23, -0.94, 0.93, -0.31 -0.04) ci.ratio.mape2(.05, res1, res2, 1, 1) # Should return: # MAPE1 MAPE2 MAPE1/MAPE2 LL UL # 2.58087 0.8327273 3.099298 1.917003 5.010761
Compute a confidence interval for a ratio of population means of ratio-scale measurements in a paired-samples design. Equality of variances is not assumed.
For more details, see Section 4.4 of Bonett (2021, Volume 1)
ci.ratio.mean.ps(alpha, y1, y2)ci.ratio.mean.ps(alpha, y1, y2)
alpha |
alpha level for 1-alpha confidence |
y1 |
vector of measurement 1 scores |
y2 |
vector of measurement 2 scores (paired with y1) |
Returns a 1-row matrix. The columns are:
Mean1 - estimated mean for measurement 1
Mean2 - estimated mean for measurement 2
Mean1/Mean2 - estimate of mean ratio
LL - lower limit of the confidence interval
UL - upper limit of the confidence interval
Bonett DG, Price RM (2020). “Confidence intervals for ratios of means and medians.” Journal of Educational and Behavioral Statistics, 45(6), 750–770. doi:10.3102/1076998620934125.
Bonett DG (2021). Statistical Methods for Psychologists https://dgbonett.sites.ucsc.edu/.
y1 = c(76.41, 66.91, 81.06, 74.78, 83.76, 89.31, 78.78, 87.06, 82.61, 76.74, 88.33, 86.18) y2 = c(59.85, 60.64, 84.86, 68.16, 71.53, 86.18, 67.30, 65.46, 83.50, 66.76, 88.37, 65.02) ci.ratio.mean.ps(.05, y1, y2) # Should return: # Mean1 Mean2 Mean1/Mean2 LL UL # 80.99417 72.3025 1.120213 1.040747 1.205745y1 = c(76.41, 66.91, 81.06, 74.78, 83.76, 89.31, 78.78, 87.06, 82.61, 76.74, 88.33, 86.18) y2 = c(59.85, 60.64, 84.86, 68.16, 71.53, 86.18, 67.30, 65.46, 83.50, 66.76, 88.37, 65.02) ci.ratio.mean.ps(.05, y1, y2) # Should return: # Mean1 Mean2 Mean1/Mean2 LL UL # 80.99417 72.3025 1.120213 1.040747 1.205745
Computes a confidence interval for a ratio of population means of ratio-scale measurements in a 2-group design. Equality of variances is not assumed.
ci.ratio.mean2(alpha, y1, y2)ci.ratio.mean2(alpha, y1, y2)
alpha |
alpha level for 1-alpha confidence |
y1 |
vector of scores for group 1 |
y2 |
vector of scores for group 2 |
For more details, see Section 2.5 of Bonett (2021, Volume 1)
Returns a 1-row matrix. The columns are:
Mean1 - estimated mean for group 1
Mean2 - estimated mean for group 2
Mean1/Mean2- estimated mean ratio
LL - lower limit of the confidence interval
UL - upper limit of the confidence interval
Bonett DG, Price RM (2020). “Confidence intervals for ratios of means and medians.” Journal of Educational and Behavioral Statistics, 45(6), 750–770. doi:10.3102/1076998620934125.
Bonett DG (2021). Statistical Methods for Psychologists https://dgbonett.sites.ucsc.edu/.
y2 <- c(32, 39, 26, 35, 43, 27, 40, 37, 34, 29, 49, 42, 40) y1 <- c(36, 44, 47, 42, 49, 39, 46, 31, 33, 48) ci.ratio.mean2(.05, y1, y2) # Should return: # # Mean1 Mean2 Mean1/Mean2 LL UL # 41.5 36.38462 1.140592 0.9897482 1.314425y2 <- c(32, 39, 26, 35, 43, 27, 40, 37, 34, 29, 49, 42, 40) y1 <- c(36, 44, 47, 42, 49, 39, 46, 31, 33, 48) ci.ratio.mean2(.05, y1, y2) # Should return: # # Mean1 Mean2 Mean1/Mean2 LL UL # 41.5 36.38462 1.140592 0.9897482 1.314425
Computes a distribution-free confidence interval for a ratio of population medians in a paired-samples design. Ratio-scale measurements are assumed. Tied scores within each measurement are assumed to be rare.
For more details, see Section 4.23 of Bonett (2021, Volume 1)
ci.ratio.median.ps(alpha, y1, y2)ci.ratio.median.ps(alpha, y1, y2)
alpha |
alpha level for 1-alpha confidence |
y1 |
vector of scores for measurement 1 |
y2 |
vector of scores for measurement 2 (paired with y1) |
Returns a 1-row matrix. The columns are:
Median1 - estimated median for measurement 1
Median2 - estimated median for measurement 2
Median1/Median2 - estimated ratio of medians
LL - lower limit of the confidence interval
UL - upper limit of the confidence interval
Bonett DG, Price RM (2020). “Confidence intervals for ratios of means and medians.” Journal of Educational and Behavioral Statistics, 45(6), 750–770. doi:10.3102/1076998620934125.
Bonett DG (2021). Statistical Methods for Psychologists https://dgbonett.sites.ucsc.edu/.
y1 = c(76.41, 66.91, 81.06, 74.78, 83.76, 89.31, 78.78, 87.06, 82.61, 76.74, 88.33, 86.18) y2 = c(59.85, 60.64, 84.86, 68.16, 71.53, 86.18, 67.30, 65.46, 83.50, 66.76, 88.37, 65.02) ci.ratio.median.ps(.05, y1, y2) # Should return: # Median1 Median2 Median1/Median2 LL UL # 81.835 67.73 1.208253 1.069251 1.365326y1 = c(76.41, 66.91, 81.06, 74.78, 83.76, 89.31, 78.78, 87.06, 82.61, 76.74, 88.33, 86.18) y2 = c(59.85, 60.64, 84.86, 68.16, 71.53, 86.18, 67.30, 65.46, 83.50, 66.76, 88.37, 65.02) ci.ratio.median.ps(.05, y1, y2) # Should return: # Median1 Median2 Median1/Median2 LL UL # 81.835 67.73 1.208253 1.069251 1.365326
Computes a distribution-free confidence interval for a ratio of population medians of ratio-scale measurements in a 2-group design. Tied scores within each group are assumed to be rare.
For more details, see Section 2.12 of Bonett (2021, Volume 1)
ci.ratio.median2(alpha, y1, y2)ci.ratio.median2(alpha, y1, y2)
alpha |
alpha level for 1-alpha confidence |
y1 |
vector of scores for group 1 |
y2 |
vector of scores for group 2 |
Returns a 1-row matrix. The columns are:
Median1 - estimated median for group 1
Median2 - estimated median for group 2
Median1/Median2 - estimated ratio of medians
LL - lower limit of the confidence interval
UL - upper limit of the confidence interval
Bonett DG, Price RM (2020). “Confidence intervals for ratios of means and medians.” Journal of Educational and Behavioral Statistics, 45(6), 750–770. doi:10.3102/1076998620934125.
Bonett DG (2021). Statistical Methods for Psychologists https://dgbonett.sites.ucsc.edu/.
y2 <- c(32, 39, 26, 35, 43, 27, 40, 37, 34, 29, 49, 42, 40) y1 <- c(36, 44, 47, 42, 49, 39, 46, 31, 33, 48) ci.ratio.median2(.05, y1, y2) # Should return: # Median1 Median2 Median1/Median2 LL UL # 43 37 1.162162 0.927667 1.455933y2 <- c(32, 39, 26, 35, 43, 27, 40, 37, 34, 29, 49, 42, 40) y1 <- c(36, 44, 47, 42, 49, 39, 46, 31, 33, 48) ci.ratio.median2(.05, y1, y2) # Should return: # Median1 Median2 Median1/Median2 LL UL # 43 37 1.162162 0.927667 1.455933
Computes a confidence interval for a ratio of population Poisson rates in a 2-group design. The confidence interval is based on the binomial method with an Agresti-Coull confidence interval. This function requires the number of occurrences of a specific event (f) that were observed over a specific period of time (t) within each group.
ci.ratio.poisson2(alpha, f1, f2, t1, t2)ci.ratio.poisson2(alpha, f1, f2, t1, t2)
alpha |
alpha value for 1-alpha confidence |
f1 |
number of event occurrences for group 1 |
f2 |
number of event occurrences for group 2 |
t1 |
time period for group 1 |
t2 |
time period for group 2 |
The time periods do not need to be integers and can be expressed in any unit of time such as seconds, hours, or months. The occurances are assumed to be independent of one another and the unknown occurrence rate is assumed to be constant over time within each group condition.
Returns a 1-row matrix. The columns are:
Estimate - estimated ratio of Poisson rates
LL - lower limit of the confidence interval
UL - upper limit of the confidence interval
Price RM, Bonett DG (2000). “Estimating the ratio of two Poisson rates.” Computational Statistics & Data Analysis, 34(3), 345–356. doi:10.1016/S0167-9473(99)00100-0.
ci.ratio.poisson2(.05, 19, 5, 30, 40.5) # Should return: # Estimate LL UL # 5.13 1.939576 13.71481ci.ratio.poisson2(.05, 19, 5, 30, 40.5) # Should return: # Estimate LL UL # 5.13 1.939576 13.71481
Computes a confidence interval for a ratio of population proportions in a paired-samples design. This function requires the frequency counts from a 2 x 2 contingency table for two repeated dichotomous measurements.
For more details, see Section 3.2 of Bonett (2021, Volume 3)
ci.ratio.prop.ps(alpha, f00, f01, f10, f11)ci.ratio.prop.ps(alpha, f00, f01, f10, f11)
alpha |
alpha level for 1-alpha confidence |
f00 |
number of participants with y = 0 and x = 0 |
f01 |
number of participants with y = 0 and x = 1 |
f10 |
number of participants with y = 1 and x = 0 |
f11 |
number of participants with y = 1 and x = 1 |
Returns a 1-row matrix. The columns are:
Estimate - estimate of proportion ratio
LL - lower limit of the confidence interval
UL - upper limit of the confidence interval
Bonett DG, Price RM (2006). “Confidence intervals for a ratio of binomial proportions based on paired data.” Statistics in Medicine, 25(17), 3039–3047. ISSN 0277-6715. doi:10.1002/sim.2440.
Bonett DG (2021). Statistical Methods for Psychologists https://dgbonett.sites.ucsc.edu/.
ci.ratio.prop.ps(.05, 12, 4, 26, 6) # Should return: # Estimate LL UL # 3.2 1.766544 5.796628ci.ratio.prop.ps(.05, 12, 4, 26, 6) # Should return: # Estimate LL UL # 3.2 1.766544 5.796628
Computes an adjusted Wald confidence interval for a population proportion ratio in a 2-group design.
For more details, see Section 2.3 of Bonett (2021, Volume 3)
ci.ratio.prop2(alpha, f1, f2, n1, n2)ci.ratio.prop2(alpha, f1, f2, n1, n2)
alpha |
alpha level for 1-alpha confidence |
f1 |
number of participants in group 1 who have the attribute |
f2 |
number of participants in group 2 who have the attribute |
n1 |
sample size for group 1 |
n2 |
sample size for group 2 |
Returns a 1-row matrix. The columns are:
Estimate - adjusted estimate of proportion ratio
LL - lower limit of the adjusted Wald confidence interval
UL - upper limit of the adjusted Wald confidence interval
Price RM, Bonett DG (2008). “Confidence intervals for a ratio of two independent binomial proportions.” Statistics in Medicine, 27(26), 5497–5508. ISSN 02776715. doi:10.1002/sim.3376.
Bonett DG (2021). Statistical Methods for Psychologists https://dgbonett.sites.ucsc.edu/.
ci.ratio.prop2(.05, 62, 35, 100, 100) # Should return: # Estimate LL UL # 1.765957 1.297164 2.404172ci.ratio.prop2(.05, 62, 35, 100, 100) # Should return: # Estimate LL UL # 1.765957 1.297164 2.404172
Computes a robust confidence interval for a ratio of population standard deviations in a 2-group design. This function is a modification of the confidence interval proposed by Bonett (2006). The original Bonett method used a pooled kurtosis estimate in the standard error that assumed equal variances, which limited the confidence interval's use to tests of equal population variances and equivalence tests. This function uses a pooled kurtosis estimate that does not assume equal variances and provides a useful confidence interval for a ratio of standard deviations under general conditions. This function requires of minimum sample size of four per group but sample sizes of at least 10 per group are recommended.
ci.ratio.sd2(alpha, y1, y2)ci.ratio.sd2(alpha, y1, y2)
alpha |
alpha level for 1-alpha confidence |
y1 |
vector of scores for group 1 |
y2 |
vector of scores for group 2 |
Returns a 1-row matrix. The columns are:
SD1 - estimated SD for group 1
SD2 - estimated SD for group 2
SD1/SD2 - estimate of SD ratio
LL - lower limit of the confidence interval
UL - upper limit of the confidence interval
Bonett DG (2006). “Robust confidence interval for a ratio of standard deviations.” Applied Psychological Measurement, 30(5), 432–439. ISSN 0146-6216. doi:10.1177/0146621605279551.
y1 <- c(32, 39, 26, 35, 43, 27, 40, 37, 34, 29) y2 <- c(36, 44, 47, 42, 49, 39, 46, 31, 33, 48) ci.ratio.sd2(.05, y1, y2) # Should return: # SD1 SD2 SD1/SD2 LL UL # 5.711587 6.450667 0.8854257 0.486279 1.728396y1 <- c(32, 39, 26, 35, 43, 27, 40, 37, 34, 29) y2 <- c(36, 44, 47, 42, 49, 39, 46, 31, 33, 48) ci.ratio.sd2(.05, y1, y2) # Should return: # SD1 SD2 SD1/SD2 LL UL # 5.711587 6.450667 0.8854257 0.486279 1.728396
Computes a 100(1 - alpha)% confidence interval for a difference in population reliabilities in a 2-group design. This function can be used with any type of reliability coefficient (e.g., Cronbach alpha, McDonald omega, intraclass reliability). The function requires a point estimate and a 100(1 - alpha)% confidence interval for each reliability as input.
For more details, see Section 2.15 of Bonett (2021, Volume 4)
ci.rel2(rel1, ll1, ul1, rel2, ll2, ul2)ci.rel2(rel1, ll1, ul1, rel2, ll2, ul2)
rel1 |
estimated reliability for group 1 |
ll1 |
lower limit for group 1 reliability |
ul1 |
upper limit for group 1 reliability |
rel2 |
estimated reliability for group 2 |
ll2 |
lower limit for group 2 reliability |
ul2 |
upper limit for group 2 reliability |
Returns a 1-row matrix. The columns are:
Estimate - estimated reliability difference
LL - lower limit of the confidence interval
UL - upper limit of the confidence interval
Bonett DG (2021). Statistical Methods for Psychologists https://dgbonett.sites.ucsc.edu/.
Bonett DG, Wright TA (2015). “Cronbach's alpha reliability: Interval estimation, hypothesis testing, and sample size planning.” Journal of Organizational Behavior, 36(1), 3–15. ISSN 08943796. doi:10.1002/job.1960.
ci.rel2(.4, .35, .47, .2, .1, .32) # Should return: # Estimate LL UL # 0.2 0.07 0.3221ci.rel2(.4, .35, .47, .2, .1, .32) # Should return: # Estimate LL UL # 0.2 0.07 0.3221
Computes a confidence interval for a population reliability coefficient such as Cronbach's alpha or McDonald's omega using an estimate of the reliability and its standard error. The standard error can be a robust standard error or bootstrap standard error obtained from an SEM program. Use ci.cronbach for Cronbach's alpha if parallel measurements can be assumed.
For more details, see Section 2.8 of Bonett (2021, Volume 4)
ci.reliability(alpha, rel, se, n)ci.reliability(alpha, rel, se, n)
alpha |
alpha level for 1-alpha confidence |
rel |
estimated reliability |
se |
standard error of reliability |
n |
sample size |
Returns a 1-row matrix. The columns are:
Estimate - estimated reliability (from input)
LL - lower limit of the confidence interval
UL - upper limit of the confidence interval
Bonett DG (2021). Statistical Methods for Psychologists https://dgbonett.sites.ucsc.edu/.
ci.reliability(.05, .88, .0147, 100) # Should return: # Estimate LL UL # 0.88 0.849 0.9066ci.reliability(.05, .88, .0147, 100) # Should return: # Estimate LL UL # 0.88 0.849 0.9066
Computes an approximate confidence interval for a population squared multiple correlation in a linear model with random predictor variables. This function uses the scaled central F approximation method. An approximate standard error is recovered from the confidence interval.
For more details, see Section 2.4 of Bonett (2021, Volume 2)
ci.rsqr(alpha, r2, s, n)ci.rsqr(alpha, r2, s, n)
alpha |
alpha value for 1-alpha confidence |
r2 |
estimated unadjusted squared multiple correlation |
s |
number of predictor variables |
n |
sample size |
Returns a 1-row matrix. The columns are:
R-squared - estimate of unadjusted R-squared (from input)
adj R-squared - bias adjusted R-squared estimate
SE - recovered standard error
LL - lower limit of the confidence interval
UL - upper limit of the confidence interval
Helland IS (1987). “On the interpretation and use of R2 in regression analysis.” Biometrics, 43(1), 61–69. doi:10.2307/2531949.
Bonett DG (2021). Statistical Methods for Psychologists https://dgbonett.sites.ucsc.edu/.
ci.rsqr(.05, .247, 4, 150) # Should return: # R-squared adj R-squared SE LL UL # 0.247 0.2262 0.06024 0.1152 0.3514ci.rsqr(.05, .247, 4, 150) # Should return: # R-squared adj R-squared SE LL UL # 0.247 0.2262 0.06024 0.1152 0.3514
Computes the traditional confidence interval for a population standard deviation using a sample estimate of the standard deviation. The traditional confidence interval assumes normality and is hypersensitive to minor violations of this assumption. This function should be used only if the data appear to come from an approximate normal or mildly platykurtic distribution.
ci.sd(alpha, sd, n)ci.sd(alpha, sd, n)
alpha |
alpha value for 1-alpha confidence |
sd |
estimated standard deviation |
n |
sample size |
Returns a 1-row matrix. The columns are:
Estimate - estimated standard deviation (from input)
LL - lower limit of the confidence interval
UL - upper limit of the confidence interval
ci.sd(.05, 4.65, 50) # Should return: # Estimate LL UL # 4.65 3.884303 5.79452ci.sd(.05, 4.65, 50) # Should return: # Estimate LL UL # 4.65 3.884303 5.79452
Computes an adjusted Wald interval for the population proportion of quantitative scores that are greater than the null hypothesis value of the population median in a one-sample sign test. This proportion is a measure of effect size that can be reported along with the sign test.
For more details, see Section 1.25 of Bonett (2021, Volume 1)
ci.sign(alpha, y, h)ci.sign(alpha, y, h)
alpha |
alpha level for 1-alpha confidence |
y |
vector of y scores |
h |
null hypothesis value for population median |
Returns a 1-row matrix. The columns are:
Estimate - adjusted estimate of proportion
SE - adjusted standard error
LL - lower limit of adjusted Wald confidence interval
UL - upper limit of adjusted Wald confidence interval
Agresti A, Coull BA (1998). “Approximate is better than 'exact' for interval estimation of binomial proportions.” The American Statistician, 52(2), 119–126. ISSN 0003-1305. doi:10.1080/00031305.1998.10480550.
Bonett DG (2021). Statistical Methods for Psychologists https://dgbonett.sites.ucsc.edu/.
y <- c(30, 20, 15, 10, 10, 60, 20, 25, 20, 30, 10, 5, 50, 40, 20, 10, 0, 20, 50) ci.sign(.05, y, 9) # Should return: # Estimate SE LL UL # 0.826087 0.0790342 0.6711828 0.9809911y <- c(30, 20, 15, 10, 10, 60, 20, 25, 20, 30, 10, 5, 50, 40, 20, 10, 0, 20, 50) ci.sign(.05, y, 9) # Should return: # Estimate SE LL UL # 0.826087 0.0790342 0.6711828 0.9809911
Computes a confidence interval for a population slope coefficient in a simple linear model using the sample correlation, sample standard deviation of the y scores (response variable), sample standard deviation of the x scores (predictor variable), and sample size as input.
For more details, see Section 1.11 of Bonett (2021, Volume 2)
ci.slope(alpha, cor, sdy, sdx, n)ci.slope(alpha, cor, sdy, sdx, n)
alpha |
alpha level for 1-alpha confidence |
cor |
estimated Pearson correlation |
sdy |
estimated standard deviation of response variable |
sdx |
estimated standard deviation of predictor variable |
n |
sample size |
Returns a 1-row matrix. The columns are:
Estimate - estimated slope
SE - standard error
t - t test statistic
df - degrees of freedom
p - two-sided p-value
LL - lower limit of the confidence interval
UL - upper limit of the confidence interval
Bonett DG (2021). Statistical Methods for Psychologists https://dgbonett.sites.ucsc.edu/.
ci.slope(.05, .362, 25.1, 6.25, 85) # Should return: # Estimate SE t df p LL UL # 1.453792 0.4109165 3.5379 83 0.00066 0.6364957 2.271088ci.slope(.05, .362, 25.1, 6.25, 85) # Should return: # Estimate SE t df p LL UL # 1.453792 0.4109165 3.5379 83 0.00066 0.6364957 2.271088
Computes a test statistic and confidence interval for the slope of means in a one-factor experimental design with a quantitative between-subjects factor. This function computes both the unequal variance and equal variance confidence intervals and test statistics. A Satterthwaite adjustment to the degrees of freedom is used with the unequal variance method.
For more details, see Section 1.11 of Bonett (2021, Volume 2)
ci.slope.mean.bs(alpha, m, sd, n, x)ci.slope.mean.bs(alpha, m, sd, n, x)
alpha |
alpha level for 1-alpha confidence |
m |
vector of sample means |
sd |
vector of sample standard deviations |
n |
vector of sample sizes |
x |
vector of quantiative factor values |
Returns a 2-row matrix. The columns are:
Estimate - estimated slope
SE - standard error
t - t test statistic
df - degrees of freedom
p - two-sided p-value
LL - lower limit of the confidence interval
UL - upper limit of the confidence interval
Bonett DG (2021). Statistical Methods for Psychologists https://dgbonett.sites.ucsc.edu/.
m <- c(33.5, 37.9, 38.0, 44.1) sd <- c(3.84, 3.84, 3.65, 4.98) n <- c(10,10,10,10) x <- c(5, 10, 20, 30) ci.slope.mean.bs(.05, m, sd, n, x) # Should return: # Estimate SE t df # Equal Variances Assumed: 0.3664407 0.06770529 5.4123 36.00 # Equal Variances Not Assumed: 0.3664407 0.07336289 4.9949 18.66 # p LL UL # Equal Variances Assumed: 4e-06 0.2291280 0.5037534 # Equal Variances Not Assumed: 8e-05 0.2126998 0.5201815m <- c(33.5, 37.9, 38.0, 44.1) sd <- c(3.84, 3.84, 3.65, 4.98) n <- c(10,10,10,10) x <- c(5, 10, 20, 30) ci.slope.mean.bs(.05, m, sd, n, x) # Should return: # Estimate SE t df # Equal Variances Assumed: 0.3664407 0.06770529 5.4123 36.00 # Equal Variances Not Assumed: 0.3664407 0.07336289 4.9949 18.66 # p LL UL # Equal Variances Assumed: 4e-06 0.2291280 0.5037534 # Equal Variances Not Assumed: 8e-05 0.2126998 0.5201815
Computes a distribution-free test and confidence interval for the slope of medians in a one-factor experimental design with a quantitative between-subjects factor using sample group medians and standard errors as input. The sample median and standard error for each group can be computed using the ci.median function.
ci.slope.median.bs(alpha, m, se, x)ci.slope.median.bs(alpha, m, se, x)
alpha |
alpha level for 1-alpha confidence |
m |
vector of sample median |
se |
vector of standard errors |
x |
vector of quantitative factor values |
Returns a 1-row matrix. The columns are:
Estimate - estimated slope
SE - standard error
z - z test statistic
p - two-sided p-value
LL - lower limit of the confidence interval
UL - upper limit of the confidence interval
m <- c(33.5, 37.9, 38.0, 44.1) se <- c(0.84, 0.94, 1.65, 2.98) x <- c(5, 10, 20, 30) ci.slope.median.bs(.05, m, se, x) # Should return: # Estimate SE z p LL UL # 0.3664407 0.1163593 3.1492 0.00164 0.1383806 0.5945008m <- c(33.5, 37.9, 38.0, 44.1) se <- c(0.84, 0.94, 1.65, 2.98) x <- c(5, 10, 20, 30) ci.slope.median.bs(.05, m, se, x) # Should return: # Estimate SE z p LL UL # 0.3664407 0.1163593 3.1492 0.00164 0.1383806 0.5945008
Computes a test statistic and an adjusted Wald confidence interval for the population slope of proportions in a one-factor experimental design with a quantitative between-subjects factor.
For more details, see Section 4.4 of Bonett (2021, Volume 3)
ci.slope.prop.bs(alpha, f, n, x)ci.slope.prop.bs(alpha, f, n, x)
alpha |
alpha level for 1-alpha confidence |
f |
vector of frequency counts of participants who have the attribute |
n |
vector of sample sizes |
x |
vector of quantitative factor values |
Returns a 1-row matrix. The columns are:
Estimate - adjusted slope estimate
SE - adjusted standard error
z - z test statistic
p - two-sided p-value
LL - lower limit of the adjusted Wald confidence interval
UL - upper limit of the adjusted Wald confidence interval
Price RM, Bonett DG (2004). “An improved confidence interval for a linear function of binomial proportions.” Computational Statistics & Data Analysis, 45(3), 449–456. ISSN 01679473. doi:10.1016/S0167-9473(03)00007-0.
Bonett DG (2021). Statistical Methods for Psychologists https://dgbonett.sites.ucsc.edu/.
f <- c(11, 15, 20, 27) n <- c(60, 60, 60, 60) x <- c(10, 20, 30, 40) ci.slope.prop.bs(.05, f, n, x) # Should return: # Estimate SE z p LL UL # 0.008688525 0.002566409 3.3855 0.00071 0.003658456 0.01371859f <- c(11, 15, 20, 27) n <- c(60, 60, 60, 60) x <- c(10, 20, 30, 40) ci.slope.prop.bs(.05, f, n, x) # Should return: # Estimate SE z p LL UL # 0.008688525 0.002566409 3.3855 0.00071 0.003658456 0.01371859
Computes a Fisher confidence interval for a population semipartial correlation. This function requires an (unadjusted) estimate of the squared multiple correlation in the full model that contains the predictor variable of interest plus all control variables. This function computes a modified Aloe-Becker confidence interval that uses n - 3 rather than n in the standard error and also uses a Fisher transformation of the semipartial correlation.
For more details, see Section 2.7 of Bonett (2021, Volume 2)
ci.spcor(alpha, cor, r2, n)ci.spcor(alpha, cor, r2, n)
alpha |
alpha level for 1-alpha confidence |
cor |
estimated semipartial correlation |
r2 |
estimated squared multiple correlation in full model |
n |
sample size |
Returns a 1-row matrix. The columns are:
Estimate - estimated semipartial correlation (from input)
SE - standard error
LL - lower limit of the confidence interval
UL - upper limit of the confidence interval
Bonett DG (2021). Statistical Methods for Psychologists https://dgbonett.sites.ucsc.edu/.
Aloe AM, Becker BJ (2012). “An effect size for regression predictors in meta-analysis.” Journal of Educational and Behavioral Statistics, 37(2), 278–297. ISSN 1076-9986. doi:10.3102/1076998610396901.
ci.spcor(.05, -.355, .230, 236) # Should return: # Estimate SE LL UL # -0.355 0.05426 -0.4565 -0.2444ci.spcor(.05, -.355, .230, 236) # Should return: # Estimate SE LL UL # -0.355 0.05426 -0.4565 -0.2444
Computes a Fisher confidence interval for a population Spearman correlation. Unlike the confidence interval for a Pearson correlation, this function does not assume bivariate normality. Unlike the Pearson correlation which describes a linear bivariate relation, the Spearman correlation describes a monotonic bivariate relation. This function is not appropriate for ordered categorical variables.
For more details, see Section 1.32 of Bonett (2021, Volume 2)
ci.spear(alpha, y, x)ci.spear(alpha, y, x)
alpha |
alpha level for 1-alpha confidence |
y |
vector of y scores |
x |
vector of x scores (paired with y) |
Returns a 1-row matrix. The columns are:
Estimate - estimated Spearman correlation
SE - standard error
LL - lower limit of the confidence interval
UL - upper limit of the confidence interval
Bonett DG, Wright TA (2000). “Sample size requirements for estimating Pearson, Kendall and Spearman correlations.” Psychometrika, 65(1), 23–28. ISSN 0033-3123. doi:10.1007/BF02294183.
Bonett DG (2021). Statistical Methods for Psychologists https://dgbonett.sites.ucsc.edu/.
y <- c(21, 4, 9, 12, 35, 18, 10, 22, 24, 1, 6, 8, 13, 16, 19) x <- c(67, 28, 30, 28, 52, 40, 25, 37, 44, 10, 14, 20, 28, 40, 51) ci.spear(.05, y, x) # Should return: # Estimate SE LL UL # 0.87 0.08241 0.5841 0.9638y <- c(21, 4, 9, 12, 35, 18, 10, 22, 24, 1, 6, 8, 13, 16, 19) x <- c(67, 28, 30, 28, 52, 40, 25, 37, 44, 10, 14, 20, 28, 40, 51) ci.spear(.05, y, x) # Should return: # Estimate SE LL UL # 0.87 0.08241 0.5841 0.9638
Computes a confidence interval for a difference of population Spearman correlations in a 2-group design. This function is not appropriate for ordered categorical variables.
ci.spear2(alpha, cor1, cor2, n1, n2)ci.spear2(alpha, cor1, cor2, n1, n2)
alpha |
alpha level for 1-alpha confidence |
cor1 |
estimated Spearman correlation for group 1 |
cor2 |
estimated Spearman correlation for group 2 |
n1 |
sample size for group 1 |
n2 |
sample size for group 2 |
Returns a 1-row matrix. The columns are:
Estimate - estimated correlation difference
SE - standard error
LL - lower limit of the confidence interval
UL - upper limit of the confidence interval
Bonett DG, Wright TA (2000). “Sample size requirements for estimating Pearson, Kendall and Spearman correlations.” Psychometrika, 65(1), 23–28. ISSN 0033-3123. doi:10.1007/BF02294183.
Zou GY (2007). “Toward using confidence intervals to compare correlations.” Psychological Methods, 12(4), 399–413. ISSN 1939-1463. doi:10.1037/1082-989X.12.4.399.
ci.spear2(.05, .54, .48, 180, 200) # Should return: # Estimate SE LL UL # 0.06 0.08125 -0.1004 0.2185ci.spear2(.05, .54, .48, 180, 200) # Should return: # Estimate SE LL UL # 0.06 0.08125 -0.1004 0.2185
Computes a confidence interval for a population standardized mean difference from a hypothesized value. If the hypothesized value is set to 0, the reciprocals of the confidence interval endpoints gives a confidence interval for the coefficient of variation (see ci.cv).
ci.stdmean(alpha, m, sd, n, h)ci.stdmean(alpha, m, sd, n, h)
alpha |
alpha level for 1-alpha confidence |
m |
estimated mean |
sd |
estimated standard deviation |
n |
sample size |
h |
hypothesized value of mean |
Returns a 1-row matrix. The columns are:
Estimate - estimated standardized mean difference
adj Estimate - bias adjusted standardized mean difference estimate
SE - standard error
LL - lower limit of the confidence interval
UL - upper limit of the confidence interval
Bonett DG (2008). “Confidence intervals for standardized linear contrasts of means.” Psychological Methods, 13(2), 99–109. ISSN 1939-1463. doi:10.1037/1082-989X.13.2.99.
ci.stdmean(.05, 24.5, 3.65, 40, 20) # Should return: # Estimate adj Estimate SE LL UL # 1.2329 1.209 0.21244 0.8165 1.6493ci.stdmean(.05, 24.5, 3.65, 40, 20) # Should return: # Estimate adj Estimate SE LL UL # 1.2329 1.209 0.21244 0.8165 1.6493
Computes confidence intervals for a population standardized mean difference in a paired-samples design. A square root unweighted variance standardizer and single measurement standard deviation standardizers are used. Equality of variances is not assumed.
For more details, see Section 4.3 of Bonett (2021, Volume 1)
ci.stdmean.ps(alpha, m1, m2, sd1, sd2, cor, n)ci.stdmean.ps(alpha, m1, m2, sd1, sd2, cor, n)
alpha |
alpha level for 1-alpha confidence |
m1 |
estimated mean for measurement 1 |
m2 |
estimated mean for measurement 2 |
sd1 |
estimated standard deviation for measurement 1 |
sd2 |
estimated standard deviation for measurement 2 |
cor |
estimated correlation between measurements |
n |
sample size |
Returns a 3-row matrix. The columns are:
Estimate - estimated standardized mean difference
adj Estimate - bias adjusted standardized mean difference estimate
SE - standard error
LL - lower limit of the confidence interval
UL - upper limit of the confidence interval
Bonett DG (2008). “Confidence intervals for standardized linear contrasts of means.” Psychological Methods, 13(2), 99–109. ISSN 1939-1463. doi:10.1037/1082-989X.13.2.99.
Bonett DG (2021). Statistical Methods for Psychologists https://dgbonett.sites.ucsc.edu/.
ci.stdmean.ps(.05, 602.4, 705.6, 33.17, 51.08, .769, 8) # Should return: # Estimate adj Estimate SE LL UL # Unweighted standardizer: -2.3963 -2.2185 0.65209 -3.6744 -1.1182 # Measurement 1 standardizer: -3.1112 -2.7656 0.91362 -4.9019 -1.3206 # Measurement 2 standardizer: -2.0204 -1.7959 0.59328 -3.1832 -0.8576ci.stdmean.ps(.05, 602.4, 705.6, 33.17, 51.08, .769, 8) # Should return: # Estimate adj Estimate SE LL UL # Unweighted standardizer: -2.3963 -2.2185 0.65209 -3.6744 -1.1182 # Measurement 1 standardizer: -3.1112 -2.7656 0.91362 -4.9019 -1.3206 # Measurement 2 standardizer: -2.0204 -1.7959 0.59328 -3.1832 -0.8576
Computes confidence intervals for a population standardized mean difference in a 2-group nonexperimental design with stratified random sampling (a random sample of a specified size from each subpopulation) using a square root weighted variance standardizer or single group standard deviation standardizer. Equality of variances is not assumed.
ci.stdmean.strat(alpha, m1, m2, sd1, sd2, n1, n2, p1)ci.stdmean.strat(alpha, m1, m2, sd1, sd2, n1, n2, p1)
alpha |
alpha level for 1-alpha confidence |
m1 |
estimated mean for group 1 |
m2 |
estimated mean for group 2 |
sd1 |
estimated standard deviation for group 1 |
sd2 |
estimated standard deviation for group 2 |
n1 |
sample size for group 1 |
n2 |
sample size for group 2 |
p1 |
proportion of total population in subpopulation 1 |
Returns a 3-row matrix. The columns are:
Estimate - estimated standardized mean difference
adj Estimate - bias adjusted standardized mean difference estimate
SE - standard error
LL - lower limit of the confidence interval
UL - upper limit of the confidence interval
Bonett DG (2020). “Point-biserial correlation: Interval estimation, hypothesis testing, meta-analysis, and sample size determination.” British Journal of Mathematical and Statistical Psychology, 73(S1), 113–144. ISSN 0007-1102. doi:10.1111/bmsp.12189.
ci.stdmean.strat(.05, 33.2, 30.8, 10.5, 11.2, 200, 200, .533) # Should return: # Estimate adj Estimate SE LL UL # Weighted standardizer: 0.2216 0.2211 0.10052 0.0245 0.4186 # Group 1 standardizer: 0.2286 0.2277 0.10428 0.0242 0.4330 # Group 2 standardizer: 0.2143 0.2277 0.09776 0.0227 0.4059ci.stdmean.strat(.05, 33.2, 30.8, 10.5, 11.2, 200, 200, .533) # Should return: # Estimate adj Estimate SE LL UL # Weighted standardizer: 0.2216 0.2211 0.10052 0.0245 0.4186 # Group 1 standardizer: 0.2286 0.2277 0.10428 0.0242 0.4330 # Group 2 standardizer: 0.2143 0.2277 0.09776 0.0227 0.4059
Computes confidence intervals for a population standardized mean difference. Unweighted, weighted, and single group variance standardizers are used. The square root weighted variance standardizer is recommended in 2-group nonexperimental designs with simple random sampling. The square root unweighted variance standardizer is recommended in 2-group experimental designs. The single group standard deviation standardizer can be used with experimental or nonexperimental designs. Equality of variances is not assumed.
For more details, see Section 2.4 of Bonett (2021, Volume 1)
ci.stdmean2(alpha, m1, m2, sd1, sd2, n1, n2)ci.stdmean2(alpha, m1, m2, sd1, sd2, n1, n2)
alpha |
alpha level for 1-alpha confidence |
m1 |
estimated mean for group 1 |
m2 |
estimated mean for group 2 |
sd1 |
estimated standard deviation for group 1 |
sd2 |
estimated standard deviation for group 2 |
n1 |
sample size for group 1 |
n2 |
sample size for group 2 |
Returns a 4-row matrix. The columns are:
Estimate - estimated standardized mean difference
adj Estimate - bias adjusted standardized mean difference estimate
SE - standard error
LL - lower limit of the confidence interval
UL - upper limit of the confidence interval
Bonett DG (2008). “Confidence intervals for standardized linear contrasts of means.” Psychological Methods, 13(2), 99–109. ISSN 1939-1463. doi:10.1037/1082-989X.13.2.99.
Bonett DG (2021). Statistical Methods for Psychologists https://dgbonett.sites.ucsc.edu/.
ci.stdmean2(.05, 20.9, 19.1, 3.85, 3.19, 50, 50) # Should return: # Estimate adj Estimate SE LL UL # Unweighted standardizer: 0.5091 0.5052 0.20539 0.1066 0.9117 # Weighted standardizer: 0.5091 0.5052 0.20328 0.1107 0.9076 # Group 1 standardizer: 0.4675 0.4603 0.19144 0.0923 0.8427 # Group 2 standardizer: 0.5643 0.5556 0.23105 0.1114 1.0171ci.stdmean2(.05, 20.9, 19.1, 3.85, 3.19, 50, 50) # Should return: # Estimate adj Estimate SE LL UL # Unweighted standardizer: 0.5091 0.5052 0.20539 0.1066 0.9117 # Weighted standardizer: 0.5091 0.5052 0.20328 0.1107 0.9076 # Group 1 standardizer: 0.4675 0.4603 0.19144 0.0923 0.8427 # Group 2 standardizer: 0.5643 0.5556 0.23105 0.1114 1.0171
Computes a confidence interval for an approximation to the tetrachoric correlation. This function requires the frequency counts from a 2 x 2 contingency table for two dichotomous variables. This measure of association assumes both of the dichotomous variables are artificially dichotomous. An approximate standard error is recovered from the confidence interval.
For more details, see Section 3.4 of Bonett (2021, Volume 3)
ci.tetra(alpha, f00, f01, f10, f11)ci.tetra(alpha, f00, f01, f10, f11)
alpha |
alpha level for 1-alpha confidence |
f00 |
number of participants with y = 0 and x = 0 |
f01 |
number of participants with y = 0 and x = 1 |
f10 |
number of participants with y = 1 and x = 0 |
f11 |
number of participants with y = 1 and x = 1 |
Returns a 1-row matrix. The columns are:
Estimate - estimate of tetrachoric approximation
SE - recovered standard error
LL - lower limit of the confidence interval
UL - upper limit of the confidence interval
Bonett DG (2021). Statistical Methods for Psychologists https://dgbonett.sites.ucsc.edu/.
Bonett DG, Price RM (2005). “Inferential methods for the tetrachoric correlation coefficient.” Journal of Educational and Behavioral Statistics, 30(2), 213–225. ISSN 1076-9986. doi:10.3102/10769986030002213.
ci.tetra(.05, 86, 16, 7, 93) # Should return: # Estimate SE LL UL # 0.938 0.0268 0.868 0.973ci.tetra(.05, 86, 16, 7, 93) # Should return: # Estimate SE LL UL # 0.938 0.0268 0.868 0.973
Computes a Theil-Sen estimate and distribution-free confidence interval for the population slope in a simple linear regression model. An approximate standard error is recovered from the confidence interval.
For more details, see Section 1.32 of Bonett (2021, Volume 2)
ci.theil(alpha, y, x)ci.theil(alpha, y, x)
alpha |
alpha level for 1-alpha confidence |
y |
vector of response variable scores |
x |
vector of predictor variable scores (paired with y) |
Returns a 1-row matrix. The columns are:
Estimate - Theil-Sen estimate of population slope
SE - recovered standard error
LL - lower limit of confidence interval
UL - upper limit of confidence interval
Hollander M, Wolf DA (1999). Nonparametric Statistical Methods. Wiley.
Bonett DG (2021). Statistical Methods for Psychologists https://dgbonett.sites.ucsc.edu/.
y <- c(21, 4, 9, 12, 35, 18, 10, 22, 24, 1, 6, 8, 13, 16, 19) x <- c(67, 28, 30, 28, 52, 40, 25, 37, 44, 10, 14, 20, 28, 40, 51) ci.theil(.05, y, x) # Should return: # Estimate SE LL UL # 0.5 0.1085927 0.3243243 0.75y <- c(21, 4, 9, 12, 35, 18, 10, 22, 24, 1, 6, 8, 13, 16, 19) x <- c(67, 28, 30, 28, 52, 40, 25, 37, 44, 10, 14, 20, 28, 40, 51) ci.theil(.05, y, x) # Should return: # Estimate SE LL UL # 0.5 0.1085927 0.3243243 0.75
Computes heteroscedastic Tukey-Kramer (also known as Games-Howell) confidence intervals for all pairwise comparisons of population means using estimated means, estimated standard deviations, and samples sizes as input. A Satterthwaite adjustment to the degrees of freedom is used to improve the accuracy of the confidence intervals.
For more details, see Section 3.1 of Bonett (2021, Volume 1)
ci.tukey(alpha, m, sd, n)ci.tukey(alpha, m, sd, n)
alpha |
alpha level for simultaneous 1-alpha confidence |
m |
vector of estimated group means |
sd |
vector of estimated group standard deviations |
n |
vector of sample sizes |
Returns a matrix with the number of rows equal to the number of pairwise comparisons. The columns are:
Estimate - estimated mean difference
SE - standard error
t - t test statistic
df - degrees of freedom
p - two-sided Tukey p-value
LL - lower limit of the confidence interval
UL - upper limit of the confidence interval
Games PA, Howell JF (1976). “Pairwise multiple comparison procedures with unequal N's and/or variances: A Monte Carlo study.” Journal of Educational Statistics, 1(2), 113. ISSN 03629791. doi:10.2307/1164979.
Bonett DG (2021). Statistical Methods for Psychologists https://dgbonett.sites.ucsc.edu/.
m <- c(12.86, 17.57, 26.29, 30.21) sd <- c(13.185, 12.995, 14.773, 15.145) n <- c(20, 20, 20, 20) ci.tukey(.05, m, sd, n) # Should return: # Estimate SE t df p LL UL # 1 2 -4.71 4.139530 -1.1378 37.99 0.66881 -15.83085 6.4108517 # 1 3 -13.43 4.427673 -3.0332 37.52 0.02177 -25.33172 -1.5282764 # 1 4 -17.35 4.490074 -3.8641 37.29 0.00233 -29.42281 -5.2771918 # 2 3 -8.72 4.399497 -1.9820 37.39 0.21291 -20.54783 3.1078269 # 2 4 -12.64 4.462292 -2.8326 37.14 0.03572 -24.64034 -0.6396589 # 3 4 -3.92 4.730817 -0.8286 37.98 0.84055 -16.62958 8.7895768m <- c(12.86, 17.57, 26.29, 30.21) sd <- c(13.185, 12.995, 14.773, 15.145) n <- c(20, 20, 20, 20) ci.tukey(.05, m, sd, n) # Should return: # Estimate SE t df p LL UL # 1 2 -4.71 4.139530 -1.1378 37.99 0.66881 -15.83085 6.4108517 # 1 3 -13.43 4.427673 -3.0332 37.52 0.02177 -25.33172 -1.5282764 # 1 4 -17.35 4.490074 -3.8641 37.29 0.00233 -29.42281 -5.2771918 # 2 3 -8.72 4.399497 -1.9820 37.39 0.21291 -20.54783 3.1078269 # 2 4 -12.64 4.462292 -2.8326 37.14 0.03572 -24.64034 -0.6396589 # 3 4 -3.92 4.730817 -0.8286 37.98 0.84055 -16.62958 8.7895768
Computes an upper confidence limit for a population variance using an estimated variance from a sample of size n in a prior study. The upper limit can be used as a variance planning value in sample size functions for desired power that require a planning value of the population variance.
For more details, see Section 1.31 of Bonett (2021, Volume 1)
ci.var.upper(alpha, var, n)ci.var.upper(alpha, var, n)
alpha |
alpha value for 1-alpha confidence (one-sided) |
var |
estimated variance |
n |
sample size |
Returns an upper limit (UL) variance planning value
Bonett DG (2021). Statistical Methods for Psychologists https://dgbonett.sites.ucsc.edu/.
ci.var.upper(.10, 1.45, 100) # Should return: # UL # 1.762447ci.var.upper(.10, 1.45, 100) # Should return: # UL # 1.762447
Computes confidence intervals for four generalized Yule measures of association (Yule Q, Yule Y, Digby H, and Bonett-Price Y*) using a transformation of a confidence interval for an odds ratio with .5 added to each cell frequency. This function requires the frequency counts from a 2 x 2 contingency table for two dichotomous variables. Digby H is sometimes used as a crude approximation to the tetrachoric correlation. Yule Y is equal to the phi coefficient only when all marginal frequencies are equal. Bonett-Price Y* is a better approximation to the phi coefficient when the marginal frequencies are not equal.
For more details, see Section 3.4 of Bonett (2021, Volume 3)
ci.yule(alpha, f00, f01, f10, f11)ci.yule(alpha, f00, f01, f10, f11)
alpha |
alpha level for 1-alpha confidence |
f00 |
number of participants with y = 0 and x = 0 |
f01 |
number of participants with y = 0 and x = 1 |
f10 |
number of participants with y = 1 and x = 0 |
f11 |
number of participants with y = 1 and x = 1 |
Returns a 1-row matrix. The columns are:
Estimate - estimate of generalized Yule coefficient
SE - standard error
LL - lower limit of the confidence interval
UL - upper limit of the confidence interval
Bonett DG (2021). Statistical Methods for Psychologists https://dgbonett.sites.ucsc.edu/. Bonett DG, Price RM (2007). “Statistical inference for generalized Yule coefficients in 2x2 contingency tables.” Sociological Methods & Research, 35(3), 429–446. ISSN 0049-1241. doi:10.1177/0049124106292358.
ci.yule(.05, 229, 28, 96, 24) # Should return: # Estimate SE LL UL # Q: 0.343 0.1328 0.062 0.573 # Y: 0.177 0.0729 0.031 0.315 # H: 0.262 0.1051 0.047 0.454 # Y*: 0.131 0.0546 0.023 0.236ci.yule(.05, 229, 28, 96, 24) # Should return: # Estimate SE LL UL # Q: 0.343 0.1328 0.062 0.573 # Y: 0.177 0.0729 0.031 0.315 # H: 0.262 0.1051 0.047 0.454 # Y*: 0.131 0.0546 0.023 0.236
Computes an approximate bias adjustment for eta-squared. This adjustment can be applied to eta-squared, partial-eta squared, and generalized eta-squared estimates.
For more details, see Section 3.7 of Bonett (2021, Volume 1)
etasqr.adj(etasqr, dfeffect, dferror)etasqr.adj(etasqr, dfeffect, dferror)
etasqr |
unadjusted eta-square estimate |
dfeffect |
degrees of freedom for the effect |
dferror |
error degrees of freedom |
Returns a bias adjusted eta-squared estimate
Bonett DG (2021). Statistical Methods for Psychologists https://dgbonett.sites.ucsc.edu/.
etasqr.adj(.315, 2, 42) # Should return: # adj Eta-squared # 0.2824etasqr.adj(.315, 2, 42) # Should return: # adj Eta-squared # 0.2824
Computes generalized eta-square estimates in a two-factor design where one or both factors are classification factors. If both factors are treatment factors, then partial eta-square estimates are typically recommended. The eta-squared estimates from this function can be used in the etasqr.adj function to obtain bias adjusted estimates.
For more details, see Section 3.12 of Bonett (2021, Volume 1)
etasqr.gen.2way(SSa, SSb, SSab, SSe)etasqr.gen.2way(SSa, SSb, SSab, SSe)
SSa |
sum of squares for factor A |
SSb |
sum of squares for factor B |
SSab |
sum of squares for A x B interaction |
SSe |
error (within) sum of squares |
Returns a 3-row matrix. The columns are:
A - estimate of eta-squared for factor A
B - estimate of eta-squared for factor B
AB - estimate of eta-squared for A x B interaction
Bonett DG (2021). Statistical Methods for Psychologists https://dgbonett.sites.ucsc.edu/.
etasqr.gen.2way(12.3, 15.6, 5.2, 7.9) # Should return: # A B AB # A treatment, B classification: 0.300000 0.5435540 0.1811847 # A classification, B treatment: 0.484252 0.3804878 0.2047244 # A classification, B classification: 0.300000 0.3804878 0.1268293etasqr.gen.2way(12.3, 15.6, 5.2, 7.9) # Should return: # A B AB # A treatment, B classification: 0.300000 0.5435540 0.1811847 # A classification, B treatment: 0.484252 0.3804878 0.2047244 # A classification, B classification: 0.300000 0.3804878 0.1268293
Computes confidence intervals for exp(B) - 1 (as a percent) and exp(B) where B is a population slope coefficient in a binary logit, ordinal logit, or log-Poisson model. This function is useful with software that does not have an option to compute exp(B) and exp(B) - 1.
For more details, see Section 4.1 of Bonett (2021, Volume 3)
expon.slope(alpha, b, se)expon.slope(alpha, b, se)
alpha |
alpha level for 1-alpha confidence |
b |
estimated slope coefficient |
se |
slope standard error |
Returns a 2-row matrix. The first row gives the results for exp(B), and the the second row gives the results for exp(B) - 1 (as a percent). The columns are:
Estimate - estimate of exp(B) or exp(B) - 1
LL - lower limit of the confidence interval
UL - upper limit of the confidence interval
Bonett DG (2021). Statistical Methods for Psychologists https://dgbonett.sites.ucsc.edu/.
expon.slope(.05, .502, .0396) # Should return: # Estimate LL UL # exp(B) 1.652022 1.528651 1.78535 # 100[exp(B) - 1]% 65.202201 52.865066 78.53502expon.slope(.05, .502, .0396) # Should return: # Estimate LL UL # exp(B) 1.652022 1.528651 1.78535 # 100[exp(B) - 1]% 65.202201 52.865066 78.53502
Computes the normed fit index (NFI), adjusted normed fit index (adj NFI), comparative fit index (CFI), Tucker-Lewis fit index (TLI), and root mean square error of approximation index (RMSEA). Of the first four indices, the adj NFI index is recommended because it has smaller sampling variability than CFI and TLI and less negative bias than NFI.
For more details, see Section 2.14 of Bonett (2021, Volume 4)
fitindices(chi1, df1, chi2, df2, n)fitindices(chi1, df1, chi2, df2, n)
chi1 |
chi-square test statistic for full model |
df1 |
degrees of freedom for full model |
chi2 |
chi-square test statistic for reduced model |
df2 |
degrees of freedom for reduced model |
n |
sample size |
Returns NFI, adj NFI, CFI, TLI, and RMSEA
Bonett DG (2021). Statistical Methods for Psychologists https://dgbonett.sites.ucsc.edu/.
fitindices(14.21, 10, 258.43, 20, 300) # Should return: # NFI adj NFI CFI TLI RMSEA # 0.945 0.9837 0.98 0.9647 0.0375fitindices(14.21, 10, 258.43, 20, 300) # Should return: # NFI adj NFI CFI TLI RMSEA # 0.945 0.9837 0.98 0.9647 0.0375
Computes the Shannon, Berger, and Simpson indices of qualitative variation. Will be replaced soon with ci.diversity.
iqv(f)iqv(f)
f |
vector of multinomial frequency counts |
Returns estimates of the Shannon, Berger, and Simpson indices
f <- c(10, 46, 15, 3) iqv(f) # Should return: # Simpson Berger Shannon # 0.7367908 0.5045045 0.7f <- c(10, 46, 15, 3) iqv(f) # Should return: # Simpson Berger Shannon # 0.7367908 0.5045045 0.7
Computes approximate one-sided or two-sided prediction limits for the estimated Pearson correlation in a future study with a planned sample size of n. The prediction interval uses a correlation estimate from a prior study that had a sample size of n0.
Several confidence interval sample size functions in this package require a planning value of the expected sample value of a Pearson correlation in the planned study. A one-sided lower correlation prediction limit is useful as a correlation planning value for a conservatively large sample size required to obtain a confidence interval with desired width. This strategy for specifying a correlation planning value is useful in applications where the population correlation in the prior study is assumed to be very similar to the population correlation in the planned study.
For more details, see Section 1.26 of Bonett (2021, Volume 2)
pi.cor(alpha, cor, n0, n, type)pi.cor(alpha, cor, n0, n, type)
alpha |
alpha value for 1-alpha confidence |
cor |
estimated Pearson correlation from prior study |
n0 |
sample size used to estimate the correlation in prior study |
n |
planned sample size of future study |
type |
|
Returns one-sided or two-sided prediction limit(s) of an estimated Pearson correlation in a future study
Bonett DG (2021). Statistical Methods for Psychologists https://dgbonett.sites.ucsc.edu/.
pi.cor(.1, .761, 50, 100, 1) # Should return: # LL UL # 0.6034 0.8573 pi.cor(.1, .761, 50, 100, 3) # Should return: # LL # 0.6429pi.cor(.1, .761, 50, 100, 1) # Should return: # LL UL # 0.6034 0.8573 pi.cor(.1, .761, 50, 100, 3) # Should return: # LL # 0.6429
Computes approximate one-sided or two-sided prediction limits for the estimated Cronbach reliability in a future study with a planned sample size of n. The prediction interval uses a Cronbach reliability estimate from a prior study.
The size.ci.cronbach and size.ci.cronbach2 functions require a planning value of the expected sample value of Cronbach's reliability in the planned study. A one-sided lower prediction limit for the sample value of Cronbach's reliability in the planned study can be used in the size.ci.cronbach and size.ci.cronbach2 functions to obtain conservatively large sample size requirements. This strategy for specifying a reliability planning value is useful in applications where the population Cronbach reliability in the prior study is assumed to be very similar to the population Cronbach reliability in the planned study.
pi.cronbach(alpha, rel, r, n0, n, type)pi.cronbach(alpha, rel, r, n0, n, type)
alpha |
alpha value for 1-alpha confidence |
rel |
estimated Cronbach reliability from prior study |
r |
number of measurements (e.g., items, raters, etc.) |
n0 |
sample size used to estimate reliability in prior study |
n |
planned sample size of future study |
type |
|
Returns one-sided or two-sided prediction limit(s) of an estimated Cronbach reliability in a future study
pi.cronbach(.1, .852, 5, 100, 150, 1) # Should return: # LL UL # 0.7944 0.8956 pi.cronbach(.1, .852, 5, 100, 150, 3) # Should return: # LL # 0.8092pi.cronbach(.1, .852, 5, 100, 150, 1) # Should return: # LL UL # 0.7944 0.8956 pi.cronbach(.1, .852, 5, 100, 150, 3) # Should return: # LL # 0.8092
Computes an approximate one-sided or two-sided prediction interval for the estimated proportion in a future study with a planned sample size of n. The prediction interval uses a proportion estimate from a prior study that had a sample size of n0.
Several confidence interval sample size functions in this package require a planning value of the expected sample value of a proportion in the planned study. A one-sided proportion prediction limit is useful as a proportion planning value for a conservatively large sample size required to obtain a confidence interval with desired width. This strategy for specifying a proportion planning value is useful in applications where the population proportion in the prior study is assumed to be very similar to the population proportion in the planned study.
For sample size planning, use an upper prediction limit if the population proportion is assumed to be less than .5; and if the upper prediction limit is greater than .5, set the proportion planning value to .5. Use a lower prediction limit if the population proportion is asumed to be greater than .5; and if the lower prediction limit is less than .5, set the proportion planning value to .5.
For more details, see Section 1.16 of Bonett (2021, Volume 3)
pi.prop(alpha, prop, n0, n, type)pi.prop(alpha, prop, n0, n, type)
alpha |
alpha value for 1-alpha confidence |
prop |
estimated proportion from prior study |
n0 |
sample size used to estimate proportion in prior study |
n |
planned sample size of future study |
type |
|
Returns one-sided or two-sided prediction limit(s) for an estimated proportion in a future study
Bonett DG (2021). Statistical Methods for Psychologists https://dgbonett.sites.ucsc.edu/.
pi.prop(.1, .225, 80, 120, 1) # Should return: # LL UL # 0.1390955 0.337095pi.prop(.1, .225, 80, 120, 1) # Should return: # LL UL # 0.1390955 0.337095
Computes a prediction interval for the response variable score of one randomly selected member from the study population.
For more details, see Section 1.9 of Bonett (2021, Volume 1)
pi.score(alpha, m, sd, n)pi.score(alpha, m, sd, n)
alpha |
alpha level for 1-alpha confidence |
m |
estimated mean |
sd |
estimated standard deviation |
n |
sample size |
Returns a 1-row matrix. The columns are:
Predicted - predicted score
df - degrees of freedom
LL - lower limit of the prediction interval
UL - upper limit of the prediction interval
Bonett DG (2021). Statistical Methods for Psychologists https://dgbonett.sites.ucsc.edu/.
pi.score(.05, 24.5, 3.65, 40) # Should return: # Predicted df LL UL # 24.5 39 17.02546 31.97454pi.score(.05, 24.5, 3.65, 40) # Should return: # Predicted df LL UL # 24.5 39 17.02546 31.97454
For a 2-level within-subjects experiment, this function computes a prediction interval for how the response variable score for one randomly selected person from the study population would differ under the two treatment conditions.
For more details, see Section 4.5 of Bonett (2021, Volume 1)
pi.score.ps(alpha, m1, m2, sd1, sd2, cor, n)pi.score.ps(alpha, m1, m2, sd1, sd2, cor, n)
alpha |
alpha level for 1-alpha confidence |
m1 |
estimated mean for measurement 1 |
m2 |
estimated mean for measurement 2 |
sd1 |
estimated standard deviation for measurement 1 |
sd2 |
estimated standard deviation for measurement 2 |
cor |
estimated correlation of paired scores |
n |
sample size |
Returns a 1-row matrix. The columns are:
Predicted - predicted difference in scores
df - degrees of freedom
LL - lower limit of the prediction interval
UL - upper limit of the prediction interval
Bonett DG (2021). Statistical Methods for Psychologists https://dgbonett.sites.ucsc.edu/.
pi.score.ps(.05, 265.1, 208.6, 23.51, 19.94, .814, 30) # Should return: # Predicted df LL UL # 56.5 29 28.05936 84.94064pi.score.ps(.05, 265.1, 208.6, 23.51, 19.94, .814, 30) # Should return: # Predicted df LL UL # 56.5 29 28.05936 84.94064
For a 2-group experimental design, this function computes a prediction interval for how the response variable score for one randomly selected person from the study population would differ under the two treatment conditions. Both equal variance and unequal variance prediction intervals are computed.
For more details, see Section 2.6 of Bonett (2021, Volume 1)
pi.score2(alpha, m1, m2, sd1, sd2, n1, n2)pi.score2(alpha, m1, m2, sd1, sd2, n1, n2)
alpha |
alpha level for 1-alpha confidence |
m1 |
estamated mean for group 1 |
m2 |
estimated mean for group 1 |
sd1 |
estimated standard deviation for group 1 |
sd2 |
estimated standard deviation for group 2 |
n1 |
sample size for group 1 |
n2 |
sample size for group 2 |
Returns a 2-row matrix. The columns are:
Predicted - predicted difference in scores
df - degrees of freedom
LL - lower limit of the prediction interval
UL - upper limit of the prediction interval
Hahn GJ (1977). “A prediction interval on the difference between two future sample means and its application to a claim of product superiority.” Technometrics, 19(2), 131–134. ISSN 0040-1706. doi:10.1080/00401706.1977.10489520.
Bonett DG (2021). Statistical Methods for Psychologists https://dgbonett.sites.ucsc.edu/.
pi.score2(.05, 19.4, 11.3, 2.70, 2.10, 40, 40) # Should return: # Predicted df LL UL # Equal Variances Assumed: 8.1 78.00 1.205659 14.99434 # Equal Variances Not Assumed: 8.1 73.54 1.199073 15.00093pi.score2(.05, 19.4, 11.3, 2.70, 2.10, 40, 40) # Should return: # Predicted df LL UL # Equal Variances Assumed: 8.1 78.00 1.205659 14.99434 # Equal Variances Not Assumed: 8.1 73.54 1.199073 15.00093
Computes a two-sided or one-sided prediction limit for the estimated variance in a future study for a planned sample size of n. The prediction limit uses a variance estimate from a prior study of size n0.
Several confidence interval sample size functions in this package require a planning value of the expected sample variance in the planned study. A one-sided upper variance prediction limit is useful as a variance planning value for a conservatively large sample size required to obtain a confidence interval with desired width. This strategy for specifying a variance planning value is useful in applications where the population variance in the prior study is assumed to be very similar to the population variance in the planned study.
For more details, see Section 1.31 of Bonett (2021, Volume 1)
pi.var(alpha, var, n0, n, type)pi.var(alpha, var, n0, n, type)
alpha |
alpha value for upper 1-alpha confidence |
var |
estimated variance from prior study |
n0 |
sample size used to estimate the variance |
n |
planned sample size of future study |
type |
|
Returns two-sided or one-sided prediction limit(s) of an estimate variance in a future study
Hahn GJ (1972). “Simultaneous prediction intervals to contain the standard deviations or ranges of future samples from a normal population.” Journal of the American Statistical Association, 67(340), 938–942. doi:10.1080/01621459.1972.10481322.
Bonett DG (2021). Statistical Methods for Psychologists https://dgbonett.sites.ucsc.edu/.
pi.var(.05, 15, 40, 100, 2) # Should return: # UL # 23.9724pi.var(.05, 15, 40, 100, 2) # Should return: # UL # 23.9724
Computes the approximate power of a test for a population Pearson or partial correlation test for a planned sample size. Set s = 0 for a Pearson correlation.
power.cor(alpha, n, cor, h, s)power.cor(alpha, n, cor, h, s)
alpha |
alpha level for hypothesis test |
n |
planned sample size |
cor |
planning value of correlation |
h |
null hypothesis value of correlation |
s |
number of control variables |
Returns the approximate power of the test
power.cor(.05, 80, .3, 0, 0) # Should return: # Power # 0.7751947power.cor(.05, 80, .3, 0, 0) # Should return: # Power # 0.7751947
Computes the approximate power of a test for equal population Pearson or partial correlations in a 2-group design for planned sample sizes. Set s = 0 for Pearson correlations.
power.cor2(alpha, n1, n2, cor1, cor2, s)power.cor2(alpha, n1, n2, cor1, cor2, s)
alpha |
alpha level for hypothesis test |
n1 |
planned sample size for group 1 |
n2 |
planned sample size for group 2 |
cor1 |
correlation planning value for group 1 |
cor2 |
correlation planning value for group 2 |
s |
number of control variables |
Returns the approximate power of the test
power.cor2(.05, 200, 200, .4, .2, 0) # Should return: # Power # 0.5919682power.cor2(.05, 200, 200, .4, .2, 0) # Should return: # Power # 0.5919682
Computes the approximate power of a test for a linear contrast of population means for planned sample sizes in a between-subject design. The groups can be the factor levels of a single factor design or the combinations of factors in a factorial design. For a conservatively low power approximation, set the variance planning values to the largest values within their plausible ranges, and set the effect size to a minimally interesting value. The within-group variances can be unequal across groups and a Satterthwaite degree of freedom adjustment is used to improve the accuracy of the power approximation.
power.lc.mean.bs(alpha, n, var, es, v)power.lc.mean.bs(alpha, n, var, es, v)
alpha |
alpha level for hypothesis test |
n |
vector of planned sample sizes |
var |
vector of within-group variance planning values |
es |
planning value of linear contrast of means |
v |
vector of contrast coefficients |
Returns the approximate power of the test
n <- c(20, 20, 20, 20) var <- c(70, 70, 80, 80) v <- c(.5, .5, -.5, -.5) power.lc.mean.bs(.05, n, var, 5, v) # Should return: # Power # 0.7221171n <- c(20, 20, 20, 20) var <- c(70, 70, 80, 80) v <- c(.5, .5, -.5, -.5) power.lc.mean.bs(.05, n, var, 5, v) # Should return: # Power # 0.7221171
Computes the approximate power of a one-sample t-test for a planned sample size. For a conservatively low power approximation, set the variance planning value to the largest value within its plausible range, and set the effect size to a minimally interesting value.
power.mean(alpha, n, var, es)power.mean(alpha, n, var, es)
alpha |
alpha level for hypothesis test |
n |
planned sample size |
var |
planning value of response variable variance |
es |
planning value of mean minus null hypothesis value |
Returns the approximate power of the test
power.mean(.05, 15, 80.5, 7) # Should return: # Power # 0.8021669power.mean(.05, 15, 80.5, 7) # Should return: # Power # 0.8021669
Computes the approximate power of a paired-samples t-test for a planned sample size. For a conservatively low power approximation, set the variance planning values to the largest values within their plausible ranges, set the correlation planning value to the smallest value within its plausible range, and set the effect size to a minimally interesting value. The variances of the two measurements can be unequal.
power.mean.ps(alpha, n, var1, var2, es, cor)power.mean.ps(alpha, n, var1, var2, es, cor)
alpha |
alpha level for hypothesis test |
n |
planned sample size |
var1 |
planning value of measurement 1 variance |
var2 |
planning value of measurement 2 variance |
es |
planning value of mean difference |
cor |
planning value of correlation between measurements |
Returns the approximate power of the test
power.mean.ps(.05, 20, 10.0, 12.0, 2, .7) # Should return: # Power # 0.9074354power.mean.ps(.05, 20, 10.0, 12.0, 2, .7) # Should return: # Power # 0.9074354
Computes the approximate power of a two-sample t-test for planned sample sizes. For a conservatively low power approximation, set the variance planning values to the largest values within their plausible ranges, and set the effect size to a minimally interesting value. The within-group variances can be unequal across groups and a Satterthwaite degree of freedom adjustment is used to improve the accuracy of the power approximation.
power.mean2(alpha, n1, n2, var1, var2, es)power.mean2(alpha, n1, n2, var1, var2, es)
alpha |
alpha level for hypothesis test |
n1 |
planned sample size for group 1 |
n2 |
planned sample size for group 2 |
var1 |
planning value of within-group variance for group 1 |
var2 |
planning value of within-group variance for group 2 |
es |
planning value of mean difference |
Returns the approximate power of the test
power.mean2(.05, 25, 25, 5.0, 6.0, 2) # Should return: # Power # 0.8398417power.mean2(.05, 25, 25, 5.0, 6.0, 2) # Should return: # Power # 0.8398417
Computes the approximate power of a one-sample proportion test for a planned sample size. Set the proportion planning value to .5 for a conservatively low power estimate. The value of the effect size need not be based on the proportion planning value.
power.prop(alpha, n, p, es)power.prop(alpha, n, p, es)
alpha |
alpha level for hypothesis test |
n |
planned sample size |
p |
planning value of proportion |
es |
planning value of proportion minus null hypothesis value |
Returns the approximate power of the test
power.prop(.05, 40, .5, .2) # Should return: # Power # 0.7156044power.prop(.05, 40, .5, .2) # Should return: # Power # 0.7156044
Computes the approximate power of a test for equal population proportions in a paired-samples design (the McNemar test). This function requires planning values for both proportions and a phi coefficient that describes the correlation between the two dichotomous measurements. The proportion planning values can set to .5 for a conservatively low power estimate. The planning value for the proportion difference (effect size) could be set to the difference of the two proportion planning values or it could be set to a minimally interesting effect size. Set the phi correlation planning value to the smallest value within a plausible range for a conservatively low power estimate.
power.prop.ps(alpha, n, p1, p2, phi, es)power.prop.ps(alpha, n, p1, p2, phi, es)
alpha |
alpha level for hypothesis test |
n |
planned sample size |
p1 |
planning value of proportion for measurement 1 |
p2 |
planning value of proportion for measurement 2 |
phi |
planning value of phi correlation |
es |
planning value of proportion difference |
Returns the approximate power of the test
power.prop.ps(.05, 45, .5, .5, .4, .2) # Should return: # Power # 0.6877704power.prop.ps(.05, 45, .5, .5, .4, .2) # Should return: # Power # 0.6877704
Computes the approximate power for a test of equal population proportions in a 2-group design for the planned sample sizes. This function requires planning values for both proportions. Set the proportion planning values to .5 for a conservatively low power estimate. The planning value for the proportion difference could be set to the difference of the two proportion planning values or it could be set to a minimally interesting effect size.
power.prop2(alpha, n1, n2, p1, p2, es)power.prop2(alpha, n1, n2, p1, p2, es)
alpha |
alpha level for hypothesis test |
n1 |
planned sample size for group 1 |
n2 |
planned sample size for group 2 |
p1 |
planning value of proportion for group 1 |
p2 |
planning value of proportion for group 2 |
es |
planning value of proportion difference |
Returns the approximate power of the test
power.prop2(.05, 60, 40, .5, .5, .2) # Should return: # Power # 0.4998959power.prop2(.05, 60, 40, .5, .5, .2) # Should return: # Power # 0.4998959
Generates a random sample of participant IDs without replacement.
random.sample(popsize, samsize)random.sample(popsize, samsize)
popsize |
study population size |
samsize |
sample size |
Returns a vector of randomly generated participant IDs
random.sample(3000, 25) # Should return random numbers such as: # [1] 37 94 134 186 212 408 485 697 722 781 998 1055 # [13] 1182 1224 1273 1335 1452 1552 1783 1817 2149 2188 2437 2850 2936random.sample(3000, 25) # Should return random numbers such as: # [1] 37 94 134 186 212 408 485 697 722 781 998 1055 # [13] 1182 1224 1273 1335 1452 1552 1783 1817 2149 2188 2437 2850 2936
Generates a random sample of scores from a normal distribution with a specified population mean and standard deviation. This function is useful for generating hypothetical data for classroom demonstrations.
random.y(n, m, sd, min, max, dec)random.y(n, m, sd, min, max, dec)
n |
sample size |
m |
population mean of scores |
sd |
population standard deviation of scores |
min |
minimum allowable value |
max |
maximum allowable value |
dec |
number of decimal points |
Returns a vector of randomly generated scores.
random.y(10, 3.6, 2.8, 1, 7, 0) # Should return random numbers such as: # [1] 2 7 7 1 6 3 1 3 2 1random.y(10, 3.6, 2.8, 1, 7, 0) # Should return random numbers such as: # [1] 2 7 7 1 6 3 1 3 2 1
Generates a random sample of y scores and x scores from a bivariate normal distributions with specified population means, standard deviations, and correlation. This function is useful for generating hypothetical data for classroom demonstrations.
random.yx(n, my, mx, sdy, sdx, cor, dec)random.yx(n, my, mx, sdy, sdx, cor, dec)
n |
sample size |
my |
population mean of y scores |
mx |
population mean of x scores |
sdy |
population standard deviation of y scores |
sdx |
population standard deviation of x scores |
cor |
population correlation between x and y |
dec |
number of decimal points |
Returns n pairs of y and x scores
random.yx(10, 50, 20, 4, 2, .5, 1) # Should return: # y x # 1 50.3 21.6 # 2 52.0 21.6 # 3 53.0 22.7 # 4 46.9 21.3 # 5 56.3 23.8 # 6 50.4 20.3 # 7 44.6 19.9 # 8 49.9 18.3 # 9 49.4 18.5 # 10 42.3 20.2random.yx(10, 50, 20, 4, 2, .5, 1) # Should return: # y x # 1 50.3 21.6 # 2 52.0 21.6 # 3 53.0 22.7 # 4 46.9 21.3 # 5 56.3 23.8 # 6 50.4 20.3 # 7 44.6 19.9 # 8 49.9 18.3 # 9 49.4 18.5 # 10 42.3 20.2
Randomly assigns a sample of participants into k groups.
randomize(n)randomize(n)
n |
k x 1 vector of sample sizes |
Returns a vector of randomly generated group assignments
n <- c(10, 10, 5) randomize(n) # Should return random numbers such as: # [1] 2 3 2 1 1 2 3 3 2 1 2 1 3 1 1 2 3 1 1 2 2 1 1 2 2n <- c(10, 10, 5) randomize(n) # Should return random numbers such as: # [1] 2 3 2 1 1 2 3 3 2 1 2 1 3 1 1 2 3 1 1 2 2 1 1 2 2
Computes the hit rate, false alarm rate, d-prime, threshold, and bias for one participant (observer) in a Yes/No signal detection study. An equal-variance Gaussian model is assumed. The parameter estimates are computed after adding .5 to the number of "Yes" responses in each condition (the signal and noise conditions) and adding 1 to the number of signal trials and to the number of noise trails. In memory recognition studies, the observer is first presented with set of words or images to study, and is later presented with another set of words or images where some items are from the first list (old items) and some items are new items.
For more details, see Section 3.8 of Bonett (2021, Volume 3)
signal(f1, f2, n1, n2)signal(f1, f2, n1, n2)
f1 |
number of "Yes" responses in the stimulus (old item) trials |
f2 |
number of "Yes" responses in the noise (new item) trials |
n1 |
number of stimulus (or old item) trials |
n2 |
number of noise (or new item) trials |
Returns a 1-row matrix. The columns are:
HR - estimate of hit rate
FAR - estimate of false alarm rate
d-prime - estimate of d-prime
Threshold - estimate of threshold (criterion)
Bias - estimate of threshold minus d-prime/2
Wickens TD (2002). Elementary Signal Detection Theory. Oxford.
Bonett DG (2021). Statistical Methods for Psychologists https://dgbonett.sites.ucsc.edu/.
signal(82, 46, 100, 100) # Should return: # HR FAR d-prime Threshold Bias # 0.8168317 0.460396 1.002793 0.09943603 -0.4019603signal(82, 46, 100, 100) # Should return: # HR FAR d-prime Threshold Bias # 0.8168317 0.460396 1.002793 0.09943603 -0.4019603
Performs a computer simulation of confidence interval performance for a Pearson correlation. A bias adjustment is used to reduce the bias of the Fisher transformed Pearson correlation. Sample data can be generated from bivariate population distributions with five different marginal distributions. All distributions are scaled to have standard deviations of 1.0. Bivariate random data with specified marginal skewness and kurtosis are generated using the unonr function in the mnonr package.
sim.ci.cor(alpha, n, cor, dist1, dist2, rep)sim.ci.cor(alpha, n, cor, dist1, dist2, rep)
alpha |
alpha level for 1-alpha confidence |
n |
sample size |
cor |
population Pearson correlation |
dist1 |
type of distribution for variable 1 (1, 2, 3, 4, or 5) |
dist2 |
type of distribution for variable 2 (1, 2, 3, 4, or 5)
|
rep |
number of Monte Carlo samples |
Returns a 1-row matrix. The columns are:
Coverage - probability of confidence interval including population correlation
Lower Error - probability of lower limit greater than population correlation
Upper Error - probability of upper limit less than population correlation
Ave CI Width - average confidence interval width
sim.ci.cor(.05, 30, .7, 4, 5, 1000) # Should return (within sampling error): # Coverage Lower Error Upper Error Ave CI Width # [1,] 0.93815 0.05125 0.0106 0.7778518sim.ci.cor(.05, 30, .7, 4, 5, 1000) # Should return (within sampling error): # Coverage Lower Error Upper Error Ave CI Width # [1,] 0.93815 0.05125 0.0106 0.7778518
Performs a computer simulation of the confidence interval performance for a population mean. Sample data can be generated from five different population distributions. All distributions are scaled to have a standard deviation of 1.0.
sim.ci.mean(alpha, n, dist, rep)sim.ci.mean(alpha, n, dist, rep)
alpha |
alpha level for 1-alpha confidence |
n |
sample size |
dist |
type of distribution (1, 2, 3, 4,or 5)
|
rep |
number of Monte Carlo samples |
Returns a 1-row matrix. The columns are:
Coverage - probability of confidence interval including population mean
Lower Error - probability of lower limit greater than population mean
Upper Error - probability of upper limit less than population mean
Ave CI Width - average confidence interval width
sim.ci.mean(.05, 10, 1, 5000) # Should return (within sampling error): # Coverage Lower Error Upper Error Ave CI Width # 0.9484 0.0264 0.0252 1.392041 sim.ci.mean(.05, 40, 4, 1000) # Should return (within sampling error): # Coverage Lower Error Upper Error Ave CI Width # 0.94722 0.01738 0.0354 0.6333067sim.ci.mean(.05, 10, 1, 5000) # Should return (within sampling error): # Coverage Lower Error Upper Error Ave CI Width # 0.9484 0.0264 0.0252 1.392041 sim.ci.mean(.05, 40, 4, 1000) # Should return (within sampling error): # Coverage Lower Error Upper Error Ave CI Width # 0.94722 0.01738 0.0354 0.6333067
Performs a computer simulation of confidence interval performance for a population mean difference in a paired-samples design. Sample data for the two levels of the within-subjects factor can be generated from bivariate population distributions with five different marginal distributions. All distributions are scaled to have a standard deviation of 1.0 at level 1. Bivariate random data with specified marginal skewness and kurtosis are generated using the unonr function in the mnonr package.
sim.ci.mean.ps(alpha, n, sd2, cor, dist1, dist2, rep)sim.ci.mean.ps(alpha, n, sd2, cor, dist1, dist2, rep)
alpha |
alpha level for 1-alpha confidence |
n |
sample size |
sd2 |
population standard deviation at level 2 |
cor |
population correlation of paired observations |
dist1 |
type of distribution at level 1 (1, 2, 3, 4, or 5) |
dist2 |
type of distribution at level 2 (1, 2, 3, 4, or 5)
|
rep |
number of Monte Carlo samples |
Returns a 1-row matrix. The columns are:
Coverage - probability of confidence interval including population mean difference
Lower Error - probability of lower limit greater than population mean difference
Upper Error - probability of upper limit less than population mean difference
Ave CI Width - average confidence interval width
sim.ci.mean.ps(.05, 30, 1.5, .7, 4, 5, 1000) # Should return (within sampling error): # Coverage Lower Error Upper Error Ave CI Width # 0.94415 0.04525 0.0106 0.7818518sim.ci.mean.ps(.05, 30, 1.5, .7, 4, 5, 1000) # Should return (within sampling error): # Coverage Lower Error Upper Error Ave CI Width # 0.94415 0.04525 0.0106 0.7818518
Performs a computer simulation of separate variance and pooled variance confidence interval performance for a population mean difference in a 2-group design. Sample data within each group can be generated from five different population distributions. All distributions are scaled to have a standard deviation of 1.0 for group 1.
sim.ci.mean2(alpha, n1, n2, sd2, dist1, dist2, rep)sim.ci.mean2(alpha, n1, n2, sd2, dist1, dist2, rep)
alpha |
alpha level for 1-alpha confidence |
n1 |
sample size in group 1 |
n2 |
sample size in group 2 |
sd2 |
population standard deviation for group 2 |
dist1 |
type of distribution for group 1 (1, 2, 3, 4, or 5) |
dist2 |
type of distribution for group 2 (1, 2, 3, 4, or 5)
|
rep |
number of Monte Carlo samples |
Returns a 1-row matrix. The columns are:
Coverage - probability of confidence interval including population mean difference
Lower Error - probability of lower limit greater than population mean difference
Upper Error - probability of upper limit less than population mean difference
Ave CI Width - average confidence interval width
sim.ci.mean2(.05, 30, 25, 1.5, 1, 1, 1000) # Should return (within sampling error): # Coverage Lower Error Upper Error Ave CI Width # Equal Variances Assumed: 0.93988 0.0322 0.02792 1.354437 # Equal Variances Not Assumed: 0.94904 0.0262 0.02476 1.411305 sim.ci.mean2(.05, 30, 25, 1.5, 4, 5, 1000) # Should return (within sampling error): # Coverage Lower Error Upper Error Ave CI Width # Equal Variances Assumed: 0.93986 0.04022 0.01992 1.344437 # Equal Variances Not Assumed: 0.94762 0.03862 0.01376 1.401305sim.ci.mean2(.05, 30, 25, 1.5, 1, 1, 1000) # Should return (within sampling error): # Coverage Lower Error Upper Error Ave CI Width # Equal Variances Assumed: 0.93988 0.0322 0.02792 1.354437 # Equal Variances Not Assumed: 0.94904 0.0262 0.02476 1.411305 sim.ci.mean2(.05, 30, 25, 1.5, 4, 5, 1000) # Should return (within sampling error): # Coverage Lower Error Upper Error Ave CI Width # Equal Variances Assumed: 0.93986 0.04022 0.01992 1.344437 # Equal Variances Not Assumed: 0.94762 0.03862 0.01376 1.401305
Performs a computer simulation of the confidence interval performance for a population median. Sample data can be generated from five different population distributions. All distributions are scaled to have a standard deviation of 1.0.
sim.ci.median(alpha, n, dist, rep)sim.ci.median(alpha, n, dist, rep)
alpha |
alpha level for 1-alpha confidence |
n |
sample size |
dist |
type of distribution (1, 2, 3, 4, or 5)
|
rep |
number of Monte Carlo samples |
Returns a 1-row matrix. The columns are:
Coverage - probability of confidence interval including population median
Lower Error - probability of lower limit greater than population median
Upper Error - probability of upper limit less than population median
Ave CI Width - average confidence interval width
sim.ci.median(.05, 20, 5, 1000) # Should return (within sampling error): # Coverage Lower Error Upper Error Ave CI Width # 0.9589 0.0216 0.0195 0.9735528sim.ci.median(.05, 20, 5, 1000) # Should return (within sampling error): # Coverage Lower Error Upper Error Ave CI Width # 0.9589 0.0216 0.0195 0.9735528
Performs a computer simulation of confidence interval performance for a population median difference in a paired-samples design. Sample data for the two levels of the within-subjects factor can be generated from bivariate population distributions with five different marginal distributions. All distributions are scaled to have a standard deviation of 1.0 at level 1. Bivariate random data with specified marginal skewness and kurtosis are generated using the unonr function in the mnonr package.
sim.ci.median.ps(alpha, n, sd2, cor, dist1, dist2, rep)sim.ci.median.ps(alpha, n, sd2, cor, dist1, dist2, rep)
alpha |
alpha level for 1-alpha confidence |
n |
sample size |
sd2 |
population standard deviation at level 2 |
cor |
population correlation of paired observations |
dist1 |
type of distribution at level 1 (1, 2, 3, 4, or 5) |
dist2 |
type of distribution at level 2 (1, 2, 3, 4, or 5)
|
rep |
number of Monte Carlo samples |
Returns a 1-row matrix. The columns are:
Coverage - probability of confidence interval including population median difference
Lower Error - probability of lower limit greater than population median difference
Upper Error - probability of upper limit less than population median difference
Ave CI Width - average confidence interval width
sim.ci.median.ps(.05, 30, 1.5, .7, 4, 3, 1000) # Should return (within sampling error): # Coverage Lower Error Upper Error Ave CI Width # 0.961 0.026 0.013 0.9435462sim.ci.median.ps(.05, 30, 1.5, .7, 4, 3, 1000) # Should return (within sampling error): # Coverage Lower Error Upper Error Ave CI Width # 0.961 0.026 0.013 0.9435462
Performs a computer simulation of the confidence interval performance for a difference of population medians in a 2-group design. Sample data for each group can be generated from five different population distributions. All distributions are scaled to have a standard deviation of 1.0 for group 1.
sim.ci.median2(alpha, n1, n2, sd2, dist1, dist2, rep)sim.ci.median2(alpha, n1, n2, sd2, dist1, dist2, rep)
alpha |
alpha level for 1-alpha confidence |
n1 |
sample size for group 1 |
n2 |
sample size for group 2 |
sd2 |
population standard deviation for group 2 |
dist1 |
type of distribution for group 1 (1, 2, 3, 4, or 5) |
dist2 |
type of distribution for group 2 (1, 2, 3, 4, or 5)
|
rep |
number of Monte Carlo samples |
Returns a 1-row matrix. The columns are:
Coverage - Probability of confidence interval including population median difference
Lower Error - Probability of lower limit greater than population median difference
Upper Error - Probability of upper limit less than population median difference
Ave CI Width - Average confidence interval width
sim.ci.median2(.05, 20, 20, 2, 5, 4, 5000) # Should return (within sampling error): # Coverage Lower Error Upper Error Ave CI Width # 0.952 0.027 0.021 2.368914sim.ci.median2(.05, 20, 20, 2, 5, 4, 5000) # Should return (within sampling error): # Coverage Lower Error Upper Error Ave CI Width # 0.952 0.027 0.021 2.368914
Performs a computer simulation of confidence interval performance for a Spearman correlation. Sample data can be generated from bivariate population distributions with five different marginal distributions. All distributions are scaled to have standard deviations of 1.0. Bivariate random data with specified marginal skewness and kurtosis are generated using the unonr function in the mnonr package.
sim.ci.spear(alpha, n, cor, dist1, dist2, rep)sim.ci.spear(alpha, n, cor, dist1, dist2, rep)
alpha |
alpha level for 1-alpha confidence |
n |
sample size |
cor |
population Spearman correlation |
dist1 |
type of distribution for variable 1 (1, 2, 3, 4, or 5) |
dist2 |
type of distribution for variable 2 (1, 2, 3, 4, or 5)
|
rep |
number of Monte Carlo samples |
Returns a 1-row matrix. The columns are:
Coverage - probability of confidence interval including population correlation
Lower Error - probability of lower limit greater than population correlation
Upper Error - probability of upper limit less than population correlation
Ave CI Width - average confidence interval width
sim.ci.spear(.05, 30, .7, 4, 5, 1000) # Should return (within sampling error): # Coverage Lower Error Upper Error Ave CI Width # [1,] 0.96235 0.01255 0.0251 0.4257299sim.ci.spear(.05, 30, .7, 4, 5, 1000) # Should return (within sampling error): # Coverage Lower Error Upper Error Ave CI Width # [1,] 0.96235 0.01255 0.0251 0.4257299
Performs a computer simulation of confidence interval performance for two types of standardized mean differences in a paired-samples design (see ci.stdmean.ps). Sample data for the two levels of the within-subjects factor can be generated from five different population distributions. All distributions are scaled to have a standard deviation of 1.0 at level 1. Bivariate random data with specified marginal skewness and kurtosis are generated using the unonr function in the mnonr package.
sim.ci.stdmean.ps(alpha, n, sd2, cor, dist1, dist2, d, rep)sim.ci.stdmean.ps(alpha, n, sd2, cor, dist1, dist2, d, rep)
alpha |
alpha level for 1-alpha confidence |
n |
sample size |
sd2 |
population standard deviation at level 2 |
cor |
correlation between paired measurements |
dist1 |
type of distribution at level 1 (1, 2, 3, 4, or 5) |
dist2 |
type of distribution at level 2 (1, 2, 3, 4, or 5)
|
d |
population standardized mean difference |
rep |
number of Monte Carlo samples |
Returns a 1-row matrix. The columns are:
Coverage - Probability of confidence interval including population std mean difference
Lower Error - Probability of lower limit greater than population std mean difference
Upper Error - Probability of upper limit less than population std mean difference
Ave CI Width - Average confidence interval width
sim.ci.stdmean.ps(.05, 20, 1.5, .8, 4, 4, .5, 2000) # Should return (within sampling error): # Coverage Lower Error Upper Error Ave CI Width Ave Est # Unweighted Standardizer 0.9095 0.0555 0.035 0.7354865 0.5186796 # Level 1 Standardizer 0.9525 0.0255 0.022 0.9330036 0.5058198sim.ci.stdmean.ps(.05, 20, 1.5, .8, 4, 4, .5, 2000) # Should return (within sampling error): # Coverage Lower Error Upper Error Ave CI Width Ave Est # Unweighted Standardizer 0.9095 0.0555 0.035 0.7354865 0.5186796 # Level 1 Standardizer 0.9525 0.0255 0.022 0.9330036 0.5058198
Performs a computer simulation of confidence interval performance for two types of standardized mean differences in a 2-group design (see ci.stdmean2). Sample data for each group can be generated from five different population distributions. All distributions are scaled to have a standard deviation of 1.0 for group 1.
sim.ci.stdmean2(alpha, n1, n2, sd2, dist1, dist2, d, rep)sim.ci.stdmean2(alpha, n1, n2, sd2, dist1, dist2, d, rep)
alpha |
alpha level for 1-alpha confidence |
n1 |
sample size for group 1 |
n2 |
sample size for group 2 |
sd2 |
population standard deviation for group 2 |
dist1 |
type of distribution for group 1 (1, 2, 3, 4, or 5) |
dist2 |
type of distribution for group 2 (1, 2, 3, 4, or 5)
|
d |
population standardized mean difference |
rep |
number of Monte Carlo samples |
Returns a 1-row matrix. The columns are:
Coverage - Probability of confidence interval including population std mean difference
Lower Error - Probability of lower limit greater than population std mean difference
Upper Error - Probability of upper limit less than population std mean difference
Ave CI Width - Average confidence interval width
sim.ci.stdmean2(.05, 20, 20, 1.5, 3, 4, .75, 5000) # Should return (within sampling error): # Coverage Lower Error Upper Error Ave CI Width Ave Est # Unweighted Standardizer 0.9058 0.0610 0.0332 1.342560 0.7838679 # Group 1 Standardizer 0.9450 0.0322 0.0228 1.827583 0.7862640sim.ci.stdmean2(.05, 20, 20, 1.5, 3, 4, .75, 5000) # Should return (within sampling error): # Coverage Lower Error Upper Error Ave CI Width Ave Est # Unweighted Standardizer 0.9058 0.0610 0.0332 1.342560 0.7838679 # Group 1 Standardizer 0.9450 0.0322 0.0228 1.827583 0.7862640
Computes the sample size required to estimate a population G-index of agreement for two dichotomous ratings with desired confidence interval precision. Set the G-index planning value to the smallest value within a plausible range for a conservatively large sample size.
For more details, see Section 3.12 of Bonett (2021, Volume 3)
size.ci.agree(alpha, G, w)size.ci.agree(alpha, G, w)
alpha |
alpha level for 1-alpha confidence |
G |
planning value of G-index |
w |
desired confidence interval width |
Returns the required sample size
Bonett DG (2021). Statistical Methods for Psychologists https://dgbonett.sites.ucsc.edu/.
size.ci.agree(.05, .8, .2) # Should return: # Sample size # 139size.ci.agree(.05, .8, .2) # Should return: # Sample size # 139
Computes the sample size for each group required to estimate a mean difference in a 2-group ANCOVA model with desired confidence interval precision. In a nonexperimental design, the sample size is affected by the magnitude of covariate mean differences across groups. The covariate mean differences can be approximated by specifying the largest standardized covariate mean difference of all covariates. In an experiment, this standardized mean difference should be set to 0. Set the error variance planning value to the largest value within a plausible range for a conservatively large sample size.
For more details, see Section 2.28 of Bonett (2021, Volume 2)
size.ci.ancova2(alpha, evar, s, d, w, R)size.ci.ancova2(alpha, evar, s, d, w, R)
alpha |
alpha level for 1-alpha confidence |
evar |
planning value of within group (error) variance |
s |
number of covariates |
d |
largest standardized mean difference of all covariates |
w |
desired confidence interval width |
R |
ratio of n2/n1 |
Returns the required sample size for each group
Bonett DG (2021). Statistical Methods for Psychologists https://dgbonett.sites.ucsc.edu/.
size.ci.ancova2(.05, 1.37, 1, 0, 1.5, 1) # Should return: # n1 n2 # 21 21 size.ci.ancova2(.05, 1.37, 1, 0, 1.5, 2) # Should return: # n1 n2 # 16 32 size.ci.ancova2(.05, 1.37, 1, .75, 1.5, 1) # Should return: # n1 n2 # 24 24size.ci.ancova2(.05, 1.37, 1, 0, 1.5, 1) # Should return: # n1 n2 # 21 21 size.ci.ancova2(.05, 1.37, 1, 0, 1.5, 2) # Should return: # n1 n2 # 16 32 size.ci.ancova2(.05, 1.37, 1, .75, 1.5, 1) # Should return: # n1 n2 # 24 24
Computes the sample size required to estimate a biserial-phi correlation with desired confidence interval precision. Set the biserial-phi planning value to the smallest absolute value within a plausible range for a conservatively large sample size. The column variable is assumed to be naturally dichotomous and the row variable is assumed to be artificially dichotomous.
size.ci.biphi(alpha, p1, p2, cor, w)size.ci.biphi(alpha, p1, p2, cor, w)
alpha |
alpha level for 1 - alpha confidence |
p1 |
planning value for row 1 marginal proportion |
p2 |
planning value for column 1 marginal proportion |
cor |
planning value for biserial-phi correlation |
w |
desired confidence interval width |
Returns the required sample size
size.ci.biphi(.05, .2, .5, .3, .4) # Should return: # Sample size # 195size.ci.biphi(.05, .2, .5, .3, .4) # Should return: # Sample size # 195
Computes the total sample size required to estimate a population conditional mean of y at x = x* in a fixed-x linear regression model with desired confidence interval precision. The total sample size would be allocated to the levels of the quantitative factor, and it might be necessary to increase the total sample size to give the desired sample size at each level of the fixed factor. Set the error variance planning value to the largest value within a plausible range for a conservatively large sample size.
For more details, see Section 1.24 of Bonett (2021, Volume 2)
size.ci.condmean(alpha, evar, xvar, diff, w)size.ci.condmean(alpha, evar, xvar, diff, w)
alpha |
alpha level for 1-alpha confidence |
evar |
planning value of within group (error) variance |
xvar |
variance of fixed predictor variable |
diff |
difference between x* and mean of x |
w |
desired confidence interval width |
Returns the required total sample size
Bonett DG (2021). Statistical Methods for Psychologists https://dgbonett.sites.ucsc.edu/.
size.ci.condmean(.05, 120, 125, 15, 5) # Should return: # Total sample size # 210size.ci.condmean(.05, 120, 125, 15, 5) # Should return: # Total sample size # 210
Computes the sample size required to estimate a population Pearson or partial correlation with desired confidence interval precision. Set s = 0 for a Pearson correlation. Set the correlation planning value to the smallest absolute value within a plausible range for a conservatively large sample size.
For more details, see Section 1.24 of Bonett (2021, Volume 2)
size.ci.cor(alpha, cor, s, w)size.ci.cor(alpha, cor, s, w)
alpha |
alpha level for 1-alpha confidence |
cor |
planning value of correlation |
s |
number of control variables |
w |
desired confidence interval width |
Returns the required sample size
Bonett DG, Wright TA (2000). “Sample size requirements for estimating Pearson, Kendall and Spearman correlations.” Psychometrika, 65(1), 23–28. ISSN 0033-3123. doi:10.1007/BF02294183.
Bonett DG (2021). Statistical Methods for Psychologists https://dgbonett.sites.ucsc.edu/.
size.ci.cor(.05, .3, 0, .2) # Should return: # Sample size # 320size.ci.cor(.05, .3, 0, .2) # Should return: # Sample size # 320
Computes the sample size required to estimate a Pearson correlation with desired confidence interval precision in applications where an estimated Pearson correlation from a prior study is available. The actual confidence interval width in the planned study will depend on the value of the estimated correlation in the planned study. An estimated correlation from a prior study can be used to compute a prediction interval for the value of the estimated correlation in the planned study, which is then used as a planning value in the sample size analysis. If the prediction interval includes 0, then the correlation planning value is set to 0; otherwise, the correlation planning value is set to the lower prediction limit (if the prior correlation is positive) or the upper prediction limit (if the prior correlation is negative). The probability that the prediction interval will have a width that is less than the desired width in the planned study is approximately 1 - alpha2.
This sample size approach assumes that the population Pearson correlation that was estimated in the prior study is very similar to the population Pearson correlation that will be estimated in the planned study. If an estimated Pearson correlation from a prior study is not available the researcher must use expert opinion to guess the value of the Pearson correlation that will be observed in the planned study. The size.ci.cor function uses a correlation planning value that is based on expert opinion regarding the likely value of the correlation estimate that will be observed in the planned study.
For more details, see Section 1.26 of Bonett (2021, Volume 2)
size.ci.cor.prior(alpha1, alpha2, cor0, n0, w)size.ci.cor.prior(alpha1, alpha2, cor0, n0, w)
alpha1 |
alpha level for 1-alpha1 confidence in the planned study |
alpha2 |
alpha level for the 1-alpha2 prediction interval |
cor0 |
estimated correlation in prior study |
n0 |
sample size in prior study |
w |
desired confidence interval width |
Returns the required sample size
Bonett DG (2021). Statistical Methods for Psychologists https://dgbonett.sites.ucsc.edu/.
size.ci.cor.prior(.05, .10, -.56, 120, .2) # Should return: # Sample size # 246size.ci.cor.prior(.05, .10, -.56, 120, .2) # Should return: # Sample size # 246
Computes the sample size required to estimate a difference in population Pearson or partial correlations with desired confidence interval precision in a 2-group design. Set the correlation planning values to the smallest absolute values within their plausible ranges for a conservatively large sample size.
size.ci.cor2(alpha, cor1, cor2, w)size.ci.cor2(alpha, cor1, cor2, w)
alpha |
alpha level for 1-alpha confidence |
cor1 |
correlation planning value for group 1 |
cor2 |
correlation planning value for group 2 |
w |
desired confidence interval width |
Returns the required sample size
Bonett DG, Wright TA (2000). “Sample size requirements for estimating Pearson, Kendall and Spearman correlations.” Psychometrika, 65(1), 23–28. ISSN 0033-3123. doi:10.1007/BF02294183.
size.ci.cor2(.05, .8, .5, .2) # Should return: # Sample size per group # 271size.ci.cor2(.05, .8, .5, .2) # Should return: # Sample size per group # 271
Computes the sample size required to estimate a Cronbach reliability with desired confidence interval precision. Set the reliability planning value to the smallest value within a plausible range for a conservatively large sample size.
size.ci.cronbach(alpha, rel, r, w)size.ci.cronbach(alpha, rel, r, w)
alpha |
alpha value for 1-alpha confidence |
rel |
reliability planning value |
r |
number of measurements (items, raters, forms) |
w |
desired confidence interval width |
For more details, see Section 4.26 of Bonett (2021, Volume 1)
Returns the required sample size
Bonett DG, Wright TA (2015). “Cronbach's alpha reliability: Interval estimation, hypothesis testing, and sample size planning.” Journal of Organizational Behavior, 36(1), 3–15. ISSN 08943796. doi:10.1002/job.1960.
Bonett DG (2021). Statistical Methods for Psychologists https://dgbonett.sites.ucsc.edu/.
size.ci.cronbach(.05, .75, 5, .15) # Should return: # Sample size # 109size.ci.cronbach(.05, .75, 5, .15) # Should return: # Sample size # 109
Computes the sample size required to estimate a Cronbach reliability with desired confidence interval precision in applications where an estimated Cronbach reliability from a prior study is available. The actual confidence interval width in the planned study will depend on the value of the estimated reliability in the planned study. An estimated Cronbach reliability from a prior study can be used to compute a lower prediction limit for the estimated reliability in the planned study, which is then used as a planning value in the sample size analysis. The probability that the prediction interval will have a width that is less than the desired width in the planned study is approximately 1 - alpha2.
This sample size approach assumes that the population Cronbach reliability that was estimated in the prior study is very similar to the population Cronbach reliability that will be estimated in the planned study. If an estimated Cronbach reliability from a prior study is not available, the researcher must use expert opinion to guess the value of the Cronbach reliability that will be observed in the planned study. The size.ci.cronbach function uses a reliability planning value that is based on expert opinion regarding the likely value of the reliability estimate that will be observed in the planned study.
size.ci.cronbach.prior(alpha1, alpha2, rel0, n0, r, w)size.ci.cronbach.prior(alpha1, alpha2, rel0, n0, r, w)
alpha1 |
alpha level for 1-alpha1 confidence in the planned study |
alpha2 |
alpha level for the 1-alpha2 prediction interval |
rel0 |
estimated reliability in prior study |
n0 |
sample size in prior study |
r |
number of measurements (items, raters, forms) |
w |
desired confidence interval width |
Returns the required sample size
size.ci.cronbach.prior(.05, .10, .86, 50, 5, .15) # Should return: # Sample size # 71size.ci.cronbach.prior(.05, .10, .86, 50, 5, .15) # Should return: # Sample size # 71
Computes the sample size per group (assuming equal sample sizes) required to estimate a difference in population Cronbach reliability coefficients with desired precision in a 2-group design.
size.ci.cronbach2(alpha, rel1, rel2, r, w)size.ci.cronbach2(alpha, rel1, rel2, r, w)
alpha |
alpha level for hypothesis test |
rel1 |
reliability planning value for group 1 |
rel2 |
reliability planning value for group 2 |
r |
number of measurements (items, raters, forms) |
w |
desired confidence interval width |
For more details, see Section 2.19 of Bonett (2021, Volume 4)
Returns the required sample size for each group
Bonett DG, Wright TA (2015). “Cronbach's alpha reliability: Interval estimation, hypothesis testing, and sample size planning.” Journal of Organizational Behavior, 36(1), 3–15. ISSN 08943796. doi:10.1002/job.1960.
Bonett DG (2021). Statistical Methods for Psychologists https://dgbonett.sites.ucsc.edu/.
size.ci.cronbach2(.05, .85, .70, 8, .15) # Should return: # Sample size per group # 180size.ci.cronbach2(.05, .85, .70, 8, .15) # Should return: # Sample size per group # 180
Computes an approximate sample size required to estimate a population coefficient of variation (CV) with desired confidence interval precision. Set the CV planning value to the largest value within a plausible range for a conservatively large sample size.
size.ci.cv(alpha, CV, w)size.ci.cv(alpha, CV, w)
alpha |
alpha level for 1-alpha confidence |
CV |
planning value of coefficient of variation |
w |
desired confidence interval width |
Returns the required sample size
size.ci.cv(.05, .25, .10) # Should return: # Sample size # 60size.ci.cv(.05, .25, .10) # Should return: # Sample size # 60
Computes the sample size required to estimate an eta-squared coefficient in a one-way ANOVA with desired confidence interval precision. Set the planning value of eta-squared to about 1/3 for a conservatively large sample size.
For more details, see Section 3.24 of Bonett (2021, Volume 1)
size.ci.etasqr(alpha, etasqr, groups, w)size.ci.etasqr(alpha, etasqr, groups, w)
alpha |
alpha level for 1-alpha confidence |
etasqr |
planning value of eta-squared |
groups |
number of groups |
w |
desired confidence interval width |
Returns the required sample size for each group
Bonett DG (2021). Statistical Methods for Psychologists https://dgbonett.sites.ucsc.edu/.
size.ci.etasqr(.05, .2, 3, .15) # Should return: # Sample size per group # 103size.ci.etasqr(.05, .2, 3, .15) # Should return: # Sample size per group # 103
Computes the sample size required to estimate a single population parameter with desired precision using a standard error for the parameter estimate from a prior or pilot study. This function can be used with any type of parameter where the standard error of the parameter estimate is a function of the square root of the sample size (most parameter estimates have this property). This function also assumes that the sampling distribution of the parameter estimate is approximately normal in large samples.
size.ci.gen(alpha, se, n0, w)size.ci.gen(alpha, se, n0, w)
alpha |
alpha level for hypothesis test |
se |
standard error of parameter estimate from prior/pilot study |
n0 |
sample size of prior/pilot study |
w |
desired confidence interval width |
Returns the required sample size
size.ci.gen(.05, 2.89, 30, 8) # Should return: # Sample size # 61size.ci.gen(.05, 2.89, 30, 8) # Should return: # Sample size # 61
Computes the sample size required to estimate a difference in population parameters with desired precision in a 2-group design using a standard error for a parameter estimate from a prior or pilot study. This function can be used with any type of parameter where the standard error of the parameter estimate is a function of the square root of the sample size (most parameter estimates have this property). This function also assumes that the sampling distribution of the parameter estimate is approximately normal in large samples. Set R = 1 for equal sample sizes.
size.ci.gen2(alpha, se, n0, w, R)size.ci.gen2(alpha, se, n0, w, R)
alpha |
alpha level for hypothesis test |
se |
standard error of parameter estimate from prior/pilot study |
n0 |
sample size of prior/pilot study |
w |
desired confidence interval width |
R |
n2/n1 ratio |
Returns the required sample size for each group
size.ci.gen2(.05, .175, 30, .8, 1) # Should return: # n1 n2 # 45 45size.ci.gen2(.05, .175, 30, .8, 1) # Should return: # n1 n2 # 45 45
Computes the sample size required to estimate an intraclass correlation with desired confidence interval precision. This type of intraclass correlation can be used to describe the reliability of a single measurement (e.g., a single rater or a single form of a test). This intraclass correlation assumes a two-factor (subject x measurement) model. Use the size.ci.cronbach function to determine the sample size required to estimate the reliability of a sum or average of r measurements (e.g., items) with desired confidence interval precision.
size.ci.icc(alpha, icc, r, w)size.ci.icc(alpha, icc, r, w)
alpha |
alpha value for 1-alpha confidence |
icc |
intraclass correlation planning value |
r |
number of measurements (raters, forms, occasions) |
w |
desired confidence interval width |
Specifying an intraclass correlation planning value for a conservatively large sample size requirement is not straightforward with an intraclass correlation. For r = 2, the sample size requirement is largest for an intraclass correlation of zero. But for r = 3, 4, 5, 10, 20, and 40 an intraclass correlation planning value of about .26, .33, .38, .43, .44, and .45, respectively, maximizes the sample size requirement.
Returns the required sample size
Bonett DG (2002). “Sample size requirements for estimating intraclass correlations with desired precision.” Statistics in Medicine, 21, 1331–1335. doi:10.1002/sim.1108.
size.ci.icc(.05, .70, 3, .2) # Should return: # Sample size # 68size.ci.icc(.05, .70, 3, .2) # Should return: # Sample size # 68
Computes the sample size required to estimate an intraclass correlation with desired confidence interval precision in applications where an estimated intraclass correlation from a prior study is available. The actual confidence interval width in the planned study will depend on the value of the estimated intraclas correlation in the planned study. An estimated intraclass correlation from a prior study can be used to compute a lower prediction limit for the estimated intraclass correlation in the planned study, which is then used as a planning value in the sample size analysis. The probability that the prediction interval will have a width that is less than the desired width in the planned study is approximately 1 - alpha2.
This sample size approach assumes that the population intraclass correlation that was estimated in the prior study is very similar to the population intraclass correlation that will be estimated in the planned study. If an estimated intraclas correlation from a prior study is not available, the researcher must use expert opinion to guess the value of the intraclass correlation that will be observed in the planned study. The size.ci.icc function uses an intraclass correlation planning value that is based on expert opinion regarding the likely value of the intraclass correlation estimate that will be observed in the planned study.
size.ci.icc.prior(alpha1, alpha2, cor0, n0, r, w)size.ci.icc.prior(alpha1, alpha2, cor0, n0, r, w)
alpha1 |
alpha level for 1-alpha1 confidence in the planned study |
alpha2 |
alpha level for the 1-alpha2 prediction interval |
cor0 |
estimated correlation in prior study |
n0 |
sample size in prior study |
r |
number of measurements (raters, forms) |
w |
desired confidence interval width |
Returns the required sample size
size.ci.icc.prior(.05, .10, .674, 50, 3, .2) # Should return: # Sample size # 114size.ci.icc.prior(.05, .10, .674, 50, 3, .2) # Should return: # Sample size # 114
Computes the approximate sample size required to estimate a population standardized indirect effect in a simple mediation model. The direct effect of the independent (exogenous) variable on the response variable, controlling for the mediator variable, is assumed to be negligible.
For more details, see Section 1.19 of Bonett (2021, Volume 4)
size.ci.indirect(alpha, cor1, cor2, w)size.ci.indirect(alpha, cor1, cor2, w)
alpha |
alpha level for 1-alpha confidence |
cor1 |
planning value of correlation between the independent and mediator variables |
cor2 |
planning value of correlation between the mediator and response variables |
w |
desired confidence interval width |
Returns the required sample size
Bonett DG (2021). Statistical Methods for Psychologists https://dgbonett.sites.ucsc.edu/.
size.ci.indirect(.05, .4, .5, .2) # Should return: # Sample size # 106size.ci.indirect(.05, .4, .5, .2) # Should return: # Sample size # 106
Computes the sample size for each group (assuming equal sample sizes) required to estimate a population linear contrast of means in an ANCOVA model with desired confidence interval precision. In a nonexperimental design, the sample size is affected by the magnitude of covariate mean differences across groups. The covariate mean differences can be approximated by specifying the largest standardized covariate mean difference across all pairwise group differences and for all covariates. In an experiment, this standardized mean difference should be set to 0. Set the error variance planning value to the largest value within a plausible range for a conservatively large sample size.
For more details, see Section 2.28 of Bonett (2021, Volume 2)
size.ci.lc.ancova(alpha, evar, s, d, w, v)size.ci.lc.ancova(alpha, evar, s, d, w, v)
alpha |
alpha level for 1-alpha confidence |
evar |
planning value of within group (error) variance |
s |
number of covariates |
d |
largest standardized mean difference for all covariates |
w |
desired confidence interval width |
v |
vector of between-subjects contrast coefficients |
Returns the required sample size for each group
Bonett DG (2021). Statistical Methods for Psychologists https://dgbonett.sites.ucsc.edu/.
v <- c(.5, .5, -.5, -.5) size.ci.lc.ancova(.05, 6.4, 1, 0, 3.0, v) # Should return: # Sample size per group # 13v <- c(.5, .5, -.5, -.5) size.ci.lc.ancova(.05, 6.4, 1, 0, 3.0, v) # Should return: # Sample size per group # 13
Computes the sample size in each group (assuming equal sample sizes) required to estimate a linear contrast of population means with desired confidence interval precision in a between-subjects design. Set the variance planning value to the largest value within a plausible range for a conservatively large sample size.
For more details, see Section 3.24 of Bonett (2021, Volume 1)
size.ci.lc.mean.bs(alpha, var, w, v)size.ci.lc.mean.bs(alpha, var, w, v)
alpha |
alpha level for 1-alpha confidence |
var |
planning value of average within-group variance |
w |
desired confidence interval width |
v |
vector of between-subjects contrast coefficients |
Returns the required sample size for each group
Bonett DG (2021). Statistical Methods for Psychologists https://dgbonett.sites.ucsc.edu/.
v <- c(.5, .5, -.5, -.5) size.ci.lc.mean.bs(.05, 8.0, 3.0, v) # Should return: # Sample size per group # 15v <- c(.5, .5, -.5, -.5) size.ci.lc.mean.bs(.05, 8.0, 3.0, v) # Should return: # Sample size per group # 15
Computes the sample size required to estimate a linear contrast of population means with desired confidence interval precision in a within-subjects design. Set the variance planning value to the largest value within a plausible range for a conservatively large sample size. Set the Pearson correlation planning value to the smallest value within a plausible range for a conservatively large sample size.
For more details, see Section 4.26 of Bonett (2021, Volume 1)
size.ci.lc.mean.ws(alpha, var, cor, w, q)size.ci.lc.mean.ws(alpha, var, cor, w, q)
alpha |
alpha level for 1-alpha confidence |
var |
planning value of average variance of the measurements |
cor |
planning value of average correlation between measurements |
w |
desired confidence interval width |
q |
vector of within-subjects contrast coefficients |
Returns the required sample size
Bonett DG (2021). Statistical Methods for Psychologists https://dgbonett.sites.ucsc.edu/.
q <- c(.5, .5, -.5, -.5) size.ci.lc.mean.ws(.05, 161.9, .77, 4, q) # Should return: # Sample size # 38q <- c(.5, .5, -.5, -.5) size.ci.lc.mean.ws(.05, 161.9, .77, 4, q) # Should return: # Sample size # 38
Computes the sample size in each group (assuming equal sample sizes) required to estimate a linear contrast of population medians with desired confidence interval precision in a between-subjects design. Set the variance planning value to the largest value within a plausible range for a conservatively large sample size. The sample size requirement depends on the shape of the distribution. Select one of the four distribution options (Normal, Logistic, Laplace, Exponential) that approximates the most likely distribution shape in the planned study. Select the Normal distribution for a conservatively large sample size requirement.
For more details, see Sections 1.28 and 3.24 of Bonett (2021, Volume 1)
size.ci.lc.median.bs(alpha, var, w, v, dist)size.ci.lc.median.bs(alpha, var, w, v, dist)
alpha |
alpha level for 1-alpha confidence |
var |
planning value of average within-group variance |
w |
desired confidence interval width |
v |
vector of between-subjects contrast coefficients |
dist |
|
Returns the required sample size for each group
Bonett DG, Price RM (2002). “Statistical inference for a linear function of medians: Confidence intervals, hypothesis testing, and sample size requirements.” Psychological Methods, 7(3), 370–383. ISSN 1939-1463. doi:10.1037/1082-989X.7.3.370.
Bonett DG (2021). Statistical Methods for Psychologists https://dgbonett.sites.ucsc.edu/.
v <- c(.5, .5, -1) size.ci.lc.median.bs(.05, 5.62, 2.0, v, 1) # Should return: # Sample size per group # 51 size.ci.lc.median.bs(.05, 5.62, 2.0, v, 4) # Should return: # Sample size per group # 33v <- c(.5, .5, -1) size.ci.lc.median.bs(.05, 5.62, 2.0, v, 1) # Should return: # Sample size per group # 51 size.ci.lc.median.bs(.05, 5.62, 2.0, v, 4) # Should return: # Sample size per group # 33
Computes the sample size in each group (assuming equal sample sizes) required to estimate a linear contrast of population proportions with desired confidence interval precision in a between-subjects design. Set the proportion planning values to .5 for a conservatively large sample size.
For more details, see Section 2.22 of Bonett (2021, Volume 3)
size.ci.lc.prop.bs(alpha, p, w, v)size.ci.lc.prop.bs(alpha, p, w, v)
alpha |
alpha level for 1-alpha confidence |
p |
vector of proportion planning values |
w |
desired confidence interval width |
v |
vector of between-subjects contrast coefficients |
Returns the required sample size for each group
Bonett DG (2021). Statistical Methods for Psychologists https://dgbonett.sites.ucsc.edu/.
p <- c(.1, .2, .2, .3) v <- c(.5, -.5, .5, -.5) size.ci.lc.prop.bs(.05, p, .2, v) # Should return: # Sample size per group # 60p <- c(.1, .2, .2, .3) v <- c(.5, -.5, .5, -.5) size.ci.lc.prop.bs(.05, p, .2, v) # Should return: # Sample size per group # 60
Computes the sample size per group (assuming equal sample sizes) required to estimate two types of standardized linear contrasts of population means (unweighted average standardizer and single group standardizer) with desired confidence interval precision in a between-subjects design. Set the standardized linear contrast of means to the largest value within a plausible range for a conservatively large sample size.
For more details, see Section 3.24 of Bonett (2021, Volume 1)
size.ci.lc.stdmean.bs(alpha, d, w, v)size.ci.lc.stdmean.bs(alpha, d, w, v)
alpha |
alpha level for 1-alpha confidence |
d |
planning value of standardized linear contrast of means |
w |
desired confidence interval width |
v |
vector of between-subjects contrast coefficients |
Returns the required sample size per group for each standardizer
Bonett DG (2009). “Estimating standardized linear contrasts of means with desired precision.” Psychological Methods, 14(1), 1–5. ISSN 1939-1463. doi:10.1037/a0014270.
Bonett DG (2021). Statistical Methods for Psychologists https://dgbonett.sites.ucsc.edu/.
v <- c(.5, .5, -1) size.ci.lc.stdmean.bs(.05, .8, .6, v) # Should return: # Sample size per group # Unweighted standardizer: 69 # Single group standardizer: 78v <- c(.5, .5, -1) size.ci.lc.stdmean.bs(.05, .8, .6, v) # Should return: # Sample size per group # Unweighted standardizer: 69 # Single group standardizer: 78
Computes the sample size required to estimate two types of standardized linear contrasts of population means (unweighted standardizer and single level standardizer) with desired confidence interval precision in a within-subjects design. For a conservatively large sample size, set the standardized linear contrast of means planning value to the largest value within a plausible range, and set the Pearson correlation planning value to the smallest value within a plausible range.
For more details, see Section 4.26 of Bonett (2021, Volume 1)
size.ci.lc.stdmean.ws(alpha, d, cor, w, q)size.ci.lc.stdmean.ws(alpha, d, cor, w, q)
alpha |
alpha level for 1-alpha confidence |
d |
planning value of standardized linear contrast |
cor |
planning value of average correlation between measurements |
w |
desired confidence interval width |
q |
vector of within-subjects contrast coefficients |
Returns the required sample size for each standardizer
Bonett DG (2009). “Estimating standardized linear contrasts of means with desired precision.” Psychological Methods, 14(1), 1–5. ISSN 1939-1463. doi:10.1037/a0014270.
Bonett DG (2021). Statistical Methods for Psychologists https://dgbonett.sites.ucsc.edu/.
q <- c(1/3, 1/3, 1/3, -1) size.ci.lc.stdmean.ws(.05, .5, .7, .4, q) # Should return: # Sample size # Unweighted standardizer: 46 # Single level standardizer: 51q <- c(1/3, 1/3, 1/3, -1) size.ci.lc.stdmean.ws(.05, .5, .7, .4, q) # Should return: # Sample size # Unweighted standardizer: 46 # Single level standardizer: 51
Computes the sample size required to estimate a population mean absolute prediction error for a general linear model with desired confidence interval precision. Setting s = 0 gives the sample size requirement for a mean absolute deviation in a one-group design. This function assumes that the prediction errors have an approximate normal distribution.
size.ci.mape(alpha, mape, s, w)size.ci.mape(alpha, mape, s, w)
alpha |
alpha value for 1-alpha confidence |
mape |
mean absolute prediction error planning value |
s |
number of predictor variables |
w |
desired confidence interval width |
Returns the required sample size
size.ci.mape(.05, 4.5, 5, 2) # Should return: # Sample size # 57size.ci.mape(.05, 4.5, 5, 2) # Should return: # Sample size # 57
Computes the sample size required to estimate a population mean with desired confidence interval precision. Set the variance planning value to the largest value within a plausible range for a conservatively large sample size.
For more details, see Section 1.28 of Bonett (2021, Volume 1)
size.ci.mean(alpha, var, w)size.ci.mean(alpha, var, w)
alpha |
alpha level for 1-alpha confidence |
var |
planning value of response variable variance |
w |
desired confidence interval width |
Returns the required sample size
Bonett DG (2021). Statistical Methods for Psychologists https://dgbonett.sites.ucsc.edu/.
size.ci.mean(.05, 6.0, 1.5) # Should return: # Sample size # 43size.ci.mean(.05, 6.0, 1.5) # Should return: # Sample size # 43
Computes the sample size required to estimate a population mean with desired confidence interval precision in applications where an estimated variance from a prior study is available. The actual confidence interval width in the planned study will depend on the value of the estimated variance in the planned study. An estimated variance from a prior study can be used to compute an upper prediction limit for the estimated variance in the planned study. The upper prediction limit is then used as the variance planning value. The probability that the prediction interval in the planned study will have a width that is less than the desired width is approximately 1 - alpha2.
This sample size approach assumes that the population variance in the prior study is very similar to the population variance in the planned study. If an estimated variance from a prior study is not available, the researcher must use expert opinion to guess the value of the variance that will be observed in the planned study. The size.ci.mean function uses a variance planning value that is based on expert opinion regarding the likely value of the variance estimate that will be observed in the planned study.
For more details, see Section 1.31 of Bonett (2021, Volume 1)
size.ci.mean.prior(alpha1, alpha2, var0, n0, w)size.ci.mean.prior(alpha1, alpha2, var0, n0, w)
alpha1 |
alpha level for 1-alpha1 confidence in the planned study |
alpha2 |
alpha level for the 1-alpha2 prediction interval |
var0 |
estimated variance in prior study |
n0 |
sample size in prior study |
w |
desired confidence interval width |
Returns the required sample size
Bonett DG (2021). Statistical Methods for Psychologists https://dgbonett.sites.ucsc.edu/.
size.ci.mean.prior(.05, .10, 0.71, 204, .4) # Should return: # Sample size # 88size.ci.mean.prior(.05, .10, 0.71, 204, .4) # Should return: # Sample size # 88
Computes the sample size required to estimate a difference in population means with desired confidence interval precision in a paired-samples design. Set the Pearson correlation planning value to the smallest value within a plausible range for a conservatively large sample size. Set the variance planning value to the largest value within a plausible range for a conservatively large sample size.
For more details, see Section 4.26 of Bonett (2021, Volume 1)
size.ci.mean.ps(alpha, var, cor, w)size.ci.mean.ps(alpha, var, cor, w)
alpha |
alpha level for 1-alpha confidence |
var |
planning value of average variance of the two measurements |
cor |
planning value of correlation between measurements |
w |
desired confidence interval width |
Returns the required sample size
Bonett DG (2021). Statistical Methods for Psychologists https://dgbonett.sites.ucsc.edu/.
size.ci.mean.ps(.05, 5.0, .5, 2.0) # Should return: # Sample size # 22size.ci.mean.ps(.05, 5.0, .5, 2.0) # Should return: # Sample size # 22
Computes the sample size for each group required to estimate a population mean difference with desired confidence interval precision in a 2-group design. Set the variance planning value to the largest value within a plausible range for a conservatively large sample size. Set R = 1 for equal sample sizes. For unequal sample sizes, this function assumes approximately equal population variances.
For more details, see Section 2.13 of Bonett (2021, Volume 1)
size.ci.mean2(alpha, var, w, R)size.ci.mean2(alpha, var, w, R)
alpha |
alpha level for 1-alpha confidence |
var |
planning value of average within-group variance |
w |
desired confidence interval width |
R |
n2/n1 ratio |
Returns the required sample size for each group
Bonett DG (2021). Statistical Methods for Psychologists https://dgbonett.sites.ucsc.edu/.
size.ci.mean2(.01, 81, 12, 1) # Should return: # n1 n2 # 32 32 size.ci.mean2(.05, 4.0, 2.5, 2) # Should return: # n1 n2 # 16 32size.ci.mean2(.01, 81, 12, 1) # Should return: # n1 n2 # 32 32 size.ci.mean2(.05, 4.0, 2.5, 2) # Should return: # n1 n2 # 16 32
Computes the sample size required to estimate a population median with desired confidence interval precision. Set the variance planning value to the largest value within a plausible range for a conservatively large sample size. The sample size requirement depends on the shape of the distribution. Select one of the four distribution options (Normal, Logistic, Laplace, Exponential) that approximates the most likely distribution shape in the planned study. Select the Normal distribution for a conservatively large sample size requirement.
For more details, see Section 1.28 of Bonett (2021, Volume 1)
size.ci.median(alpha, var, w, dist)size.ci.median(alpha, var, w, dist)
alpha |
alpha level for 1-alpha confidence |
var |
planning value of response variable variance |
w |
desired confidence interval width |
dist |
|
Returns the required sample size
Bonett DG, Price RM (2002). “Statistical inference for a linear function of medians: Confidence intervals, hypothesis testing, and sample size requirements.” Psychological Methods, 7(3), 370–383. ISSN 1939-1463. doi:10.1037/1082-989X.7.3.370.
Bonett DG (2021). Statistical Methods for Psychologists https://dgbonett.sites.ucsc.edu/.
size.ci.median(.05, 264.4, 10, 1) # Should return: # Sample size # 64 size.ci.median(.05, 264.4, 10, 3) # Should return: # Sample size # 21size.ci.median(.05, 264.4, 10, 1) # Should return: # Sample size # 64 size.ci.median(.05, 264.4, 10, 3) # Should return: # Sample size # 21
Computes the sample size for each group required to estimate a population median difference with desired confidence interval precision in a 2-group design. Set the variance planning value to the largest value within a plausible range for a conservatively large sample size. The sample size requirement depends on the shape of the distribution. Select one of the four distribution options (Normal, Logistic, Laplace, Exponential) that approximates the most likely distribution shape in the planned study. Select the Normal distribution for a conservatively large sample size requirement. Set R = 1 for equal sample sizes.
For more details, see Sections 1.28 and 2.13 of Bonett (2021, Volume 1)
size.ci.median2(alpha, var, w, R, dist)size.ci.median2(alpha, var, w, R, dist)
alpha |
alpha level for 1-alpha confidence |
var |
planning value of average within-group variance |
w |
desired confidence interval width |
R |
n2/n1 ratio |
dist |
|
Returns the required sample size for each group
Bonett DG, Price RM (2002). “Statistical inference for a linear function of medians: Confidence intervals, hypothesis testing, and sample size requirements.” Psychological Methods, 7(3), 370–383. ISSN 1939-1463. doi:10.1037/1082-989X.7.3.370.
Bonett DG (2021). Statistical Methods for Psychologists https://dgbonett.sites.ucsc.edu/.
size.ci.median2(.05, 37.1, 5, 1, 1) # Should return: # n1 n2 # 72 72 size.ci.median2(.05, 37.1, 5, 2, 4) # Should return: # n1 n2 # 51 102size.ci.median2(.05, 37.1, 5, 1, 1) # Should return: # n1 n2 # 72 72 size.ci.median2(.05, 37.1, 5, 2, 4) # Should return: # n1 n2 # 51 102
Computes the sample size required to estimate an odds ratio with desired confidence interval precision.
size.ci.oddsratio(alpha, p1, p2, or, r)size.ci.oddsratio(alpha, p1, p2, or, r)
alpha |
alpha level for 1 - alpha confidence |
p1 |
planning value for row 1 marginal proportion |
p2 |
planning value for column 1 marginal proportion |
or |
planning value of odds ratio |
r |
desired upper to lower confidence interval endpoint ratio |
Returns the required sample size
size.ci.oddsratio(.05, .3, .2, 5.5, 3.0) # Should return: # Sample size # 356size.ci.oddsratio(.05, .3, .2, 5.5, 3.0) # Should return: # Sample size # 356
Computes the sample size required to estimate a population point-biserial correlation with desired confidence interval precision in a two-group nonexperimental design with simple random sampling. A two-group nonexperimental design implies two subpopulations (e.g., all boys and all girls in a school district). This function requires a planning value for the proportion of population members who belong to one of the two subpopulations. Set the correlation planning value to the smallest absolute value within a plausible range for a conservatively large sample size.
For more details, see Section 1.24 of Bonett (2021, Volume 2)
size.ci.pbcor(alpha, cor, w, p)size.ci.pbcor(alpha, cor, w, p)
alpha |
alpha level for 1-alpha confidence |
cor |
planning value of point-biserial correlation |
w |
desired confidence interval width |
p |
proportion of members in one of the two subpopulations |
Returns the required sample size
Bonett DG (2020). “Point-biserial correlation: Interval estimation, hypothesis testing, meta-analysis, and sample size determination.” British Journal of Mathematical and Statistical Psychology, 73(S1), 113–144. ISSN 0007-1102. doi:10.1111/bmsp.12189.
Bonett DG (2021). Statistical Methods for Psychologists https://dgbonett.sites.ucsc.edu/.
size.ci.pbcor(.05, .40, .25, .73) # Should return: # Sample size # 168size.ci.pbcor(.05, .40, .25, .73) # Should return: # Sample size # 168
Computes the sample size required to estimate a phi correlation with desired confidence interval precision. Set the phi correlation planning value to the smallest absolute value within a plausible range for a conservatively large sample size.
size.ci.phi(alpha, p1, p2, phi, w)size.ci.phi(alpha, p1, p2, phi, w)
alpha |
alpha level for 1 - alpha confidence |
p1 |
planning value for row 1 marginal proportion |
p2 |
planning value for column 1 marginal proportion |
phi |
planning value for phi correlation |
w |
desired confidence interval width |
Returns the required sample size
size.ci.phi(.05, .7, .8, .35, .2) # Should return: # Sample size # 416size.ci.phi(.05, .7, .8, .35, .2) # Should return: # Sample size # 416
Computes the sample size required to estimate a population proportion with desired confidence interval precision. Set the proportion planning value to .5 for a conservatively large sample size.
For more details, see Section 1.14 of Bonett (2021, Volume 3)
size.ci.prop(alpha, p, w)size.ci.prop(alpha, p, w)
alpha |
alpha level for 1-alpha confidence |
p |
planning value of proportion |
w |
desired confidence interval width |
Returns the required sample size
Bonett DG (2021). Statistical Methods for Psychologists https://dgbonett.sites.ucsc.edu/.
size.ci.prop(.05, .5, .1) # Should return: # Sample size # 385size.ci.prop(.05, .5, .1) # Should return: # Sample size # 385
Computes the sample size required to estimate a population proportion with desired confidence interval precision in applications where an estimated proportion from a prior study is available. The actual confidence interval width in the planned study will depend on the value of the estimated proportion in the planned study. An estimated proportion from a prior study is used to predict the value of the estimated proportion in the planned study, and the predicted proportion estimate is then used as a planning value in the sample size computation. The probability that the prediction interval in the planned study will have a width that is less than the desired width is approximately 1 - alpha2.
This sample size approach assumes that the population proportion in the prior study is very similar to the population proportion in the planned study. If an estimated proportion from a prior study is not available the researcher must use expert opinion to guess the value of the proportion that will be observed in the planned study. The size.ci.prop function uses a proportion planning value that is based on expert opinion regarding the likely value of the proportion estimate that will be observed in the planned study.
For more details, see Section 1.16 of Bonett (2021, Volume 3)
size.ci.prop.prior(alpha1, alpha2, p0, n0, w)size.ci.prop.prior(alpha1, alpha2, p0, n0, w)
alpha1 |
alpha level for 1-alpha1 confidence in the planned study |
alpha2 |
alpha level for the 1-alpha2 prediction interval |
p0 |
estimated proportion in prior study |
n0 |
sample size in prior study |
w |
desired confidence interval width |
Returns the required sample size
Bonett DG (2021). Statistical Methods for Psychologists https://dgbonett.sites.ucsc.edu/.
size.ci.prop.prior(.05, .10, .78, 50, .1) # Should return: # Sample size # 384size.ci.prop.prior(.05, .10, .78, 50, .1) # Should return: # Sample size # 384
Computes the sample size required to estimate a population proportion difference with desired confidence interval precision in a paired-samples design. Set the proportion planning values to .5 for a conservatively large sample size. Set the phi correlation planning value to the smallest value within a plausible range for a conservatively large sample size.
For more details, see Section 3.12 of Bonett (2021, Volume 3)
size.ci.prop.ps(alpha, p1, p2, phi, w)size.ci.prop.ps(alpha, p1, p2, phi, w)
alpha |
alpha level for 1-alpha confidence |
p1 |
planning value of proportion for measurement 1 |
p2 |
planning value of proportion for measurement 2 |
phi |
planning value of phi correlation |
w |
desired confidence interval width |
Returns the required sample size
Bonett DG (2021). Statistical Methods for Psychologists https://dgbonett.sites.ucsc.edu/.
size.ci.prop.ps(.05, .25, .35, .6, .1) # Should return: # Sample size # 257size.ci.prop.ps(.05, .25, .35, .6, .1) # Should return: # Sample size # 257
Computes the sample size in each group required to estimate a difference of proportions with desired confidence interval precision in a 2-group design. Set the proportion planning values to .5 for a conservatively large sample size. Set R = 1 for equal sample sizes.
For more details, see Section 2.22 of Bonett (2021, Volume 3)
size.ci.prop2(alpha, p1, p2, w, R)size.ci.prop2(alpha, p1, p2, w, R)
alpha |
alpha level for 1-alpha confidence |
p1 |
planning value of proportion for group 1 |
p2 |
planning value of proportion for group 2 |
w |
desired confidence interval width |
R |
n2/n1 ratio |
Returns the required sample size for each group
Bonett DG (2021). Statistical Methods for Psychologists https://dgbonett.sites.ucsc.edu/.
size.ci.prop2(.05, .05, .15, .1, 1) # Should return: # n1 n2 # 269 269 size.ci.prop2(.05, .4, .2, .15, .5) # Should return: # n1 n2 # 383 192size.ci.prop2(.05, .05, .15, .1, 1) # Should return: # n1 n2 # 269 269 size.ci.prop2(.05, .4, .2, .15, .5) # Should return: # n1 n2 # 383 192
Computes the sample size required to estimate a ratio of population means with desired confidence interval precision in a paired-samples design. Set the correlation planning value to the smallest value within a plausible range for a conservatively large sample size. This function requires planning values for each mean and the sample size requirement is very sensitive to these planning values. Set the variance planning value to the largest value within a plausible range for a conservatively large sample size.
For more details, see Section 4.26 of Bonett (2021, Volume 1)
size.ci.ratio.mean.ps(alpha, var, m1, m2, cor, r)size.ci.ratio.mean.ps(alpha, var, m1, m2, cor, r)
alpha |
alpha level for 1-alpha confidence |
var |
planning value of average variance of the two measurements |
m1 |
planning value of mean for measurement 1 |
m2 |
planning value of mean for measurement 2 |
cor |
planning value for correlation between measurements |
r |
desired upper to lower confidence interval endpoint ratio |
Returns the required sample size
Bonett DG (2021). Statistical Methods for Psychologists https://dgbonett.sites.ucsc.edu/.
size.ci.ratio.mean.ps(.05, 400, 150, 100, .7, 1.2) # Should return: # Sample size # 21size.ci.ratio.mean.ps(.05, 400, 150, 100, .7, 1.2) # Should return: # Sample size # 21
Computes the sample size in each group required to estimate a ratio of population means with desired confidence interval precision in a 2-group design. This function requires planning values for each mean and the sample size requirement is very sensitive to these planning values. Set the variance planning value to the largest value within a plausible range for a conservatively large sample size. Set R = 1 for equal sample sizes. For unequal sample sizes, this function assumes approximately equal population variances.
For more details, see Section 2.13 of Bonett (2021, Volume 1)
size.ci.ratio.mean2(alpha, var, m1, m2, r, R)size.ci.ratio.mean2(alpha, var, m1, m2, r, R)
alpha |
alpha level for 1-alpha confidence |
var |
planning value of average within-group variance |
m1 |
planning value of mean for group 1 |
m2 |
planning value of mean for group 2 |
r |
desired upper to lower confidence interval endpoint ratio |
R |
n2/n1 ratio |
Returns the required sample size for each group
Bonett DG (2021). Statistical Methods for Psychologists https://dgbonett.sites.ucsc.edu/.
size.ci.ratio.mean2(.05, .4, 3.5, 3.1, 1.2, 1) # Should return: # n1 n2 # 70 70 size.ci.ratio.mean2(.05, .4, 3.5, 3.1, 1.2, 2) # Should return: # n1 n2 # 53 106size.ci.ratio.mean2(.05, .4, 3.5, 3.1, 1.2, 1) # Should return: # n1 n2 # 70 70 size.ci.ratio.mean2(.05, .4, 3.5, 3.1, 1.2, 2) # Should return: # n1 n2 # 53 106
Computes the sample size required to estimate a ratio of population proportions with desired confidence interval precision in a paired-samples design. Set the phi correlation planning value to the smallest value within a plausible range for a conservatively large sample size.
For more details, see Section 3.12 of Bonett (2021, Volume 3)
size.ci.ratio.prop.ps(alpha, p1, p2, phi, r)size.ci.ratio.prop.ps(alpha, p1, p2, phi, r)
alpha |
alpha level for 1-alpha confidence |
p1 |
planning value of proportion for measurement 1 |
p2 |
planning value of proportion for measurement 2 |
phi |
planning value of phi correlation |
r |
desired upper to lower confidence interval endpoint ratio |
Returns the required sample size
Bonett DG (2021). Statistical Methods for Psychologists https://dgbonett.sites.ucsc.edu/.
size.ci.ratio.prop.ps(.05, .4, .2, .7, 2) # Should return: # Sample size # 67size.ci.ratio.prop.ps(.05, .4, .2, .7, 2) # Should return: # Sample size # 67
Computes the sample size in each group required to estimate a ratio of proportions with desired confidence interval precision in a 2-group design. Set R = 1 for equal sample sizes.
For more details, see Section 2.22 of Bonett (2021, Volume 3)
size.ci.ratio.prop2(alpha, p1, p2, r, R)size.ci.ratio.prop2(alpha, p1, p2, r, R)
alpha |
alpha level for 1-alpha confidence |
p1 |
planning value of proportion for group 1 |
p2 |
planning value of proportion for group 2 |
r |
desired upper to lower confidence interval endpoint ratio |
R |
n2/n1 ratio |
Returns the required sample size for each group
Bonett DG (2021). Statistical Methods for Psychologists https://dgbonett.sites.ucsc.edu/.
size.ci.ratio.prop2(.05, .9, .7, 1.5, 1) # Should return: # n1 n2 # 51 51 size.ci.ratio.prop2(.05, .9, .7, 1.5, .5) # Should return: # n1 n2 # 91 46size.ci.ratio.prop2(.05, .9, .7, 1.5, 1) # Should return: # n1 n2 # 51 51 size.ci.ratio.prop2(.05, .9, .7, 1.5, .5) # Should return: # n1 n2 # 91 46
Computes the sample size required to estimate a population squared multiple correlation in a random-x regression model with desired confidence interval precision. Set the planning value of the squared multiple correlation to 1/3 for a conservatively large sample size.
For more details, see Section 2.28 of Bonett (2021, Volume 2)
size.ci.rsqr(alpha, r2, s, w)size.ci.rsqr(alpha, r2, s, w)
alpha |
alpha level for 1-alpha confidence |
r2 |
planning value of squared multiple correlation |
s |
number of predictor variables in model |
w |
desired confidence interval width |
Returns the required sample size
Bonett DG (2021). Statistical Methods for Psychologists https://dgbonett.sites.ucsc.edu/.
size.ci.rsqr(.05, .3, 5, .2) # Should return: # Sample size # 227size.ci.rsqr(.05, .3, 5, .2) # Should return: # Sample size # 227
Computes the sample size required to estimate a population standard deviation with desired confidence interval precision. This function assumes that the traditional confidence interval for a population standard deviation will be used. The traditional confidence interval assumes that the response variable has an approximate normal distribution and can be highly innacurate when this assumption is not satisfied.
size.ci.sd(alpha, r)size.ci.sd(alpha, r)
alpha |
alpha level for 1-alpha confidence |
r |
desired upper to lower confidence interval endpoint ratio |
Returns the required sample size
size.ci.sd(.05, 1.5) # Should return: # Sample size # 49size.ci.sd(.05, 1.5) # Should return: # Sample size # 49
Computes the second-stage sample size required to obtain desired confidence interval precision. This function can use either the total sample size for all groups in the first stage sample or a single group sample size in the first stage sample. If the total first-stage sample size is given, then the function computes the total sample size required in the second-stage sample. If a single group first-stage sample size is given, then the function computes the single-group sample size required in the second-stage sample. The second-stage sample is combined with the first-stage sample to obtain the desired confidence interval width.
For more details, see Section 1.30 of Bonett (2021, Volume 1)
size.ci.second(n0, w0, w)size.ci.second(n0, w0, w)
n0 |
first-stage sample size |
w0 |
confidence interval width in first-stage sample |
w |
desired confidence interval width |
Returns the required sample size for the second-stage sample
Bonett DG (2021). Statistical Methods for Psychologists https://dgbonett.sites.ucsc.edu/.
size.ci.second(25, 4.38, 2.0) # Should return: # Second-stage sample size # 95size.ci.second(25, 4.38, 2.0) # Should return: # Second-stage sample size # 95
Computes the total sample size required to estimate a population slope with desired confidence interval precision in a between-subjects design with a quantitative factor. In an experimental design, the total sample size would be allocated to the levels of the quantitative factor and it might be necessary to increase the total sample size to achieve equal sample sizes. Set the error variance planning value to the largest value within a plausible range for a conservatively large sample size.
For more details, see Section 1.24 of Bonett (2021, Volume 2)
size.ci.slope(alpha, evar, x, w)size.ci.slope(alpha, evar, x, w)
alpha |
alpha level for 1-alpha confidence |
evar |
planning value of within-group (error) variance |
x |
vector of x values of the quantitative factor |
w |
desired confidence interval width |
Returns the required total sample size
Bonett DG (2021). Statistical Methods for Psychologists https://dgbonett.sites.ucsc.edu/.
x <- c(5, 7, 9) size.ci.slope(.05, 300, x, 5) # Should return: # Total sample size # 73x <- c(5, 7, 9) size.ci.slope(.05, 300, x, 5) # Should return: # Total sample size # 73
Computes the sample size required to estimate a slope coefficient with desired confidence interval precision in any type of statistical model. This function requires a standard error estimate for the slope of interest from a prior or pilot study and the sample size that was used in the prior or pilot study. This function can be used for both unstandardized and standardized slopes. This function also can be used for both unstandardized and standardized factor loadings in a confirmatory factor analysis model. This function will soon be replaced with size.ci.gen.
For more details, see Section 2.28 of Bonett (2021, Volume 2)
size.ci.slope.gen(alpha, se, n0, w)size.ci.slope.gen(alpha, se, n0, w)
alpha |
alpha level for 1-alpha confidence |
se |
standard error of slope from prior/pilot study |
n0 |
sample size used in prior/pilot study |
w |
desired confidence interval width |
Returns the required sample size
Bonett DG (2021). Statistical Methods for Psychologists https://dgbonett.sites.ucsc.edu/.
size.ci.slope.gen(.05, 3.15, 50, 5) # Should return: # Sample size # 305size.ci.slope.gen(.05, 3.15, 50, 5) # Should return: # Sample size # 305
Computes the sample size required to estimate a population Spearman correlation with desired confidence interval precision. Set the correlation planning value to the smallest absolute value within a plausible range for a conservatively large sample size.
size.ci.spear(alpha, cor, w)size.ci.spear(alpha, cor, w)
alpha |
alpha level for 1-alpha confidence |
cor |
planning value of Spearman correlation |
w |
desired confidence interval width |
Returns the required sample size
Bonett DG, Wright TA (2000). “Sample size requirements for estimating Pearson, Kendall and Spearman correlations.” Psychometrika, 65(1), 23–28. ISSN 0033-3123. doi:10.1007/BF02294183.
size.ci.spear(.05, .362, .25) # Should return: # Sample size # 200size.ci.spear(.05, .362, .25) # Should return: # Sample size # 200
Computes the sample size required to estimate a difference in population Spearman correlations with desired confidence interval precision in a 2-group design. Set the correlation planning values to the smallest absolute values within their plausible ranges for a conservatively large sample size.
size.ci.spear2(alpha, cor1, cor2, w)size.ci.spear2(alpha, cor1, cor2, w)
alpha |
alpha level for 1-alpha confidence |
cor1 |
Spearman correlation planning value for group 1 |
cor2 |
Spearman correlation planning value for group 2 |
w |
desired confidence interval width |
Returns the required sample size
Bonett DG, Wright TA (2000). “Sample size requirements for estimating Pearson, Kendall and Spearman correlations.” Psychometrika, 65(1), 23–28. ISSN 0033-3123. doi:10.1007/BF02294183.
size.ci.spear2(.05, .8, .5, .2) # Should return: # Sample size per group # 314size.ci.spear2(.05, .8, .5, .2) # Should return: # Sample size per group # 314
Computes the sample size required to estimate two types of population standardized mean differences (unweighted standardizer and single group standardizer) with desired confidence interval precision in a paired-samples design. Set the standardized mean difference planning value to the largest value within a plausible range, and set the Pearson correlation planning value to the smallest value within a plausible range for a conservatively large sample size.
For more details, see Section 4.26 of Bonett (2021, Volume 1)
size.ci.stdmean.ps(alpha, d, cor, w)size.ci.stdmean.ps(alpha, d, cor, w)
alpha |
alpha level for 1-alpha confidence |
d |
planning value of standardized mean difference |
cor |
planning value of correlation between measurements |
w |
desired confidence interval width |
Returns the required sample size for each standardizer
Bonett DG (2009). “Estimating standardized linear contrasts of means with desired precision.” Psychological Methods, 14(1), 1–5. ISSN 1939-1463. doi:10.1037/a0014270.
Bonett DG (2021). Statistical Methods for Psychologists https://dgbonett.sites.ucsc.edu/.
size.ci.stdmean.ps(.05, 1, .65, .6) # Should return: # Sample Size # Unweighted standardizer: 46 # Single group standardizer: 52size.ci.stdmean.ps(.05, 1, .65, .6) # Should return: # Sample Size # Unweighted standardizer: 46 # Single group standardizer: 52
Computes the sample size per group required to estimate two types of population standardized mean differences (unweighted standardizer and single group standardizer) with desired confidence interval precision in a 2-group design. Set the standardized mean difference planning value to the largest value within a plausible range for a conservatively large sample size. Set R = 1 for equal sample sizes. For unequal sample sizes, this function assumes approximately equal population variances.
For more details, see Section 2.13 of Bonett (2021, Volume 1)
size.ci.stdmean2(alpha, d, w, R)size.ci.stdmean2(alpha, d, w, R)
alpha |
alpha level for 1-alpha confidence |
d |
planning value of standardized mean difference |
w |
desired confidence interval width |
R |
n2/n1 ratio |
Returns the required sample size per group for each standardizer
Bonett DG (2009). “Estimating standardized linear contrasts of means with desired precision.” Psychological Methods, 14(1), 1–5. ISSN 1939-1463. doi:10.1037/a0014270.
Bonett DG (2021). Statistical Methods for Psychologists https://dgbonett.sites.ucsc.edu/.
size.ci.stdmean2(.05, 1.0, .5, 1) # Should return: # n1 n2 # Unweighted standardizer: 139 139 # Single group standardizer: 154 154 size.ci.stdmean2(.05, 1.0, .5, 2) # Should return: # n1 n2 # Unweighted standardizer: 104 208 # Single group standardizer: 116 232size.ci.stdmean2(.05, 1.0, .5, 1) # Should return: # n1 n2 # Unweighted standardizer: 139 139 # Single group standardizer: 154 154 size.ci.stdmean2(.05, 1.0, .5, 2) # Should return: # n1 n2 # Unweighted standardizer: 104 208 # Single group standardizer: 116 232
Computes the sample size required to estimate a tetrachoric correlation with desired confidence interval precision. Set the tetrachoric planning value to the smallest absolute value within a plausible range for a conservatively large sample size.
size.ci.tetra(alpha, p1, p2, cor, w)size.ci.tetra(alpha, p1, p2, cor, w)
alpha |
alpha level for 1 - alpha confidence |
p1 |
planning value for row 1 marginal proportion |
p2 |
planning value for column 1 marginal proportion |
cor |
tetrachoric planning value |
w |
desired confidence interval width |
Returns the required sample size
Bonett DG, Price RM (2005). “Inferential methods for the tetrachoric correlation coefficient.” Journal of Educational and Behavioral Statistics, 30(2), 213–225. ISSN 1076-9986. doi:10.3102/10769986030002213.
size.ci.tetra(.05, .5, .3, .7, .25) # Should return: # Sample size # 304size.ci.tetra(.05, .5, .3, .7, .25) # Should return: # Sample size # 304
Computes the sample size required to estimate Yule's Q with desired confidence interval precision. Set the Yule's Q planning value to the smallest absolute value within a plausible range for a conservatively large sample size.
size.ci.yule(alpha, p1, p2, Q, w)size.ci.yule(alpha, p1, p2, Q, w)
alpha |
alpha level for 1 - alpha confidence |
p1 |
planning value for row 1 marginal proportion |
p2 |
planning value for column 1 marginal proportion |
Q |
planning value of Yule's Q |
w |
desired confidence interval width |
Returns the required sample size
size.ci.yule(.05, .3, .2, .5, .4) # Should return: # Sample size # 354size.ci.yule(.05, .3, .2, .5, .4) # Should return: # Sample size # 354
Computes the sample size required to perform an equivalence test for the difference in population means with desired power in a paired-samples design. The value of h specifies a range of practical equivalence, -h to h, for the difference in population means. The planning value for the absolute mean difference must be less than h. Equivalence tests often require a very large sample size. Equivalence tests usually use 2 x alpha rather than alpha (e.g., use alpha = .10 rather alpha = .05). Set the Pearson correlation value to the smallest value within a plausible range, and set the variance planning value to the largest value within a plausible range for a conservatively large sample size.
For more details, see Section 4.27 of Bonett (2021, Volume 1)
size.equiv.mean.ps(alpha, pow, var, es, cor, h)size.equiv.mean.ps(alpha, pow, var, es, cor, h)
alpha |
alpha level for hypothesis test |
pow |
desired power |
var |
planning value of average variance of the two measurements |
es |
planning value of mean difference |
cor |
planning value of the correlation between measurements |
h |
upper limit for range of practical equivalence |
Returns the required sample size
Bonett DG (2021). Statistical Methods for Psychologists https://dgbonett.sites.ucsc.edu/.
size.equiv.mean.ps(.10, .90, 25, .5, .75, 2) # Should return: # Sample size # 49size.equiv.mean.ps(.10, .90, 25, .5, .75, 2) # Should return: # Sample size # 49
Computes the sample size in each group (assuming equal sample sizes) required to perform an equivalence test for the difference in population means with desired power in a 2-group design. The value of h specifies a range of practical equivalence, -h to h, for the difference in population means. The planning value for the absolute mean difference must be less than h. Equivalence tests often require a very large sample size. Equivalence tests usually use 2 x alpha rather than alpha (e.g., use alpha = .10 rather alpha = .05). Set the variance planning value to the largest value within a plausible range for a conservatively large sample size.
For more details, see Section 2.14 of Bonett (2021, Volume 1)
size.equiv.mean2(alpha, pow, var, es, h)size.equiv.mean2(alpha, pow, var, es, h)
alpha |
alpha level for hypothesis test |
pow |
desired power |
var |
planning value of average within-group variance |
es |
planning value of mean difference |
h |
upper limit for range of practical equivalence |
Returns the required sample size for each group
Bonett DG (2021). Statistical Methods for Psychologists https://dgbonett.sites.ucsc.edu/.
size.equiv.mean2(.10, .80, 15, 2, 4) # Should return: # Sample size per group # 50size.equiv.mean2(.10, .80, 15, 2, 4) # Should return: # Sample size per group # 50
Computes the sample size required to perform an equivalence test for the difference in population proportions with desired power in a paired-samples design. The value of h specifies a range of practical equivalence, -h to h, for the difference in population proportions. The absolute difference in the proportion planning values must be less than h. Equivalence tests often require a very large sample size. Equivalence tests usually use 2 x alpha rather than alpha (e.g., use alpha = .10 rather alpha = .05). This function sets the effect size equal to the difference in proportion planning values. Set the phi correlation planning value to the smallest absolute value within a plausible range for a conservatively large sample size.
For more details, see Section 3.13 of Bonett (2021, Volume 3)
size.equiv.prop.ps(alpha, pow, p1, p2, phi, h)size.equiv.prop.ps(alpha, pow, p1, p2, phi, h)
alpha |
alpha level for hypothesis test |
pow |
desired power |
p1 |
planning value of proportion for measurement 1 |
p2 |
planning value of proportion for measurement 2 |
phi |
planning value of phi correlation |
h |
upper limit for range of practical equivalence |
Returns the required sample size
Bonett DG (2021). Statistical Methods for Psychologists https://dgbonett.sites.ucsc.edu/.
size.equiv.prop.ps(.1, .8, .30, .35, .40, .15) # Should return: # Sample size # 173size.equiv.prop.ps(.1, .8, .30, .35, .40, .15) # Should return: # Sample size # 173
Computes the sample size in each group (assuming equal sample sizes) required to perform an equivalence test for the difference in population proportions with desired power in a 2-group design. The value of h specifies a range of practical equivalence, -h to h, for the difference in population proportions. The absolute difference in the proportion planning values must be less than h. Equivalence tests often require a very large sample size. Equivalence tests usually use 2 x alpha rather than alpha (e.g., use alpha = .10 rather than alpha = .05). This function sets the effect size equal to the difference in proportion planning values.
For more details, see Section 2.23 of Bonett (2021, Volume 3)
size.equiv.prop2(alpha, pow, p1, p2, h)size.equiv.prop2(alpha, pow, p1, p2, h)
alpha |
alpha level for hypothesis test |
pow |
desired power |
p1 |
planning value of proportion for group 1 |
p2 |
planning value of proportion for group 2 |
h |
upper limit for range of practical equivalence |
Returns the required sample size for each group
Bonett DG (2021). Statistical Methods for Psychologists https://dgbonett.sites.ucsc.edu/.
size.equiv.prop2(.1, .9, .8, .8, .075) # Should return: # Sample size per group # 488size.equiv.prop2(.1, .9, .8, .8, .075) # Should return: # Sample size per group # 488
Computes the sample size required to perform an interval test for a population Pearson or a partial correlation with desired power where the interval midpoint is equal to zero. This function can be used to plan a study where the goal is to show that the population correlation is small. Set s = 0 for a Pearson correlation. The correlation planning value must be a value within the hypothesized interval.
For more details, see Section 1.25 of Bonett (2021, Volume 2)
size.interval.cor(alpha, pow, cor, s, h)size.interval.cor(alpha, pow, cor, s, h)
alpha |
alpha level for hypothesis test |
pow |
desired power |
cor |
planning value of correlation |
s |
number of control variables |
h |
upper limit of hypothesized interval |
Returns the required sample size
Bonett DG (2021). Statistical Methods for Psychologists https://dgbonett.sites.ucsc.edu/.
size.interval.cor(.05, .9, .1, 0, .3) # Should return: # Sample size # 251size.interval.cor(.05, .9, .1, 0, .3) # Should return: # Sample size # 251
Computes the sample size required to perform a superiority or noninferiority test for the difference in population means with desired power in a paired-samples design. For a superiority test, specify the upper limit (h) for the range of practical equivalence and specify an effect size (es) such that es > h. For a noninferiority test, specify the lower limit (-h) for the range of practical equivalence and specify an effect size such that es > -h. Set the Pearson correlation planning value to the smallest value within a plausible range, and set the variance planning value to the largest value within a plausible range for a conservatively large sample size.
For more details, see Section 4.27 of Bonett (2021, Volume 1)
size.supinf.mean.ps(alpha, pow, var, es, cor, h)size.supinf.mean.ps(alpha, pow, var, es, cor, h)
alpha |
alpha level for hypothesis test |
pow |
desired power |
var |
planning value of average variance of the two measurements |
es |
planning value of mean difference |
cor |
planning value of the correlation between measurements |
h |
upper or lower limit for range of practical equivalence |
Returns the required sample size
Bonett DG (2021). Statistical Methods for Psychologists https://dgbonett.sites.ucsc.edu/.
size.supinf.mean.ps(.05, .80, 225, 9, .75, 4) # Should return: # Sample size # 38size.supinf.mean.ps(.05, .80, 225, 9, .75, 4) # Should return: # Sample size # 38
Computes the sample size in each group (assuming equal sample sizes) required to perform a superiority or noninferiority test for the difference in population means with desired power in a 2-group design. For a superiority test, specify the upper limit (h) for the range of practical equivalence and specify an effect size (es) such that es > h. For a noninferiority test, specify the lower limit (-h) for the range of practical equivalence and specify an effect size such that es > -h. Set the variance planning value to the largest value within a plausible range for a conservatively large sample size.
For more details, see Section 2.14 of Bonett (2021, Volume 1)
size.supinf.mean2(alpha, pow, var, es, h)size.supinf.mean2(alpha, pow, var, es, h)
alpha |
alpha level for hypothesis test |
pow |
desired power |
var |
planning value of average within-group variance |
es |
planning value of mean difference |
h |
upper or lower limit for range of practical equivalence |
Returns the required sample size for each group
Bonett DG (2021). Statistical Methods for Psychologists https://dgbonett.sites.ucsc.edu/.
size.supinf.mean2(.05, .80, 225, 9, 4) # Should return: # Sample size per group # 143size.supinf.mean2(.05, .80, 225, 9, 4) # Should return: # Sample size per group # 143
Computes the sample size required to perform a superiority or inferiority test for the difference in population proportions with desired power in a paired-samples design. For a superiority test, specify the upper limit (h) for the range of practical equivalence and specify values of p1 and p2 such that p1 - p2 > h. For an inferiority test, specify the lower limit (-h) for the range of practical equivalence and specify values of p1 and p2 such that p1 - p2 > -h. This function sets the effect size equal to p1 - p2. Set the phi correlation planning value to the smallest absolute value within a plausible range for a conservatively large sample size.
For more details, see Section 3.13 of Bonett (2021, Volume 3)
size.supinf.prop.ps(alpha, pow, p1, p2, phi, h)size.supinf.prop.ps(alpha, pow, p1, p2, phi, h)
alpha |
alpha level for hypothesis test |
pow |
desired power |
p1 |
planning value of proportion for measurement 1 |
p2 |
planning value of proportion for measurement 2 |
phi |
planning value of phi correlation |
h |
lower or upper limit for range of practical equivalence |
Returns the required sample size
Bonett DG (2021). Statistical Methods for Psychologists https://dgbonett.sites.ucsc.edu/.
size.supinf.prop.ps(.05, .9, .35, .20, .45, .05) # Should return: # Sample size # 227size.supinf.prop.ps(.05, .9, .35, .20, .45, .05) # Should return: # Sample size # 227
Computes the sample size in each group (assuming equal sample sizes) required to perform a superiority or inferiority test for the difference in population proportions with desired power in a 2-group design. For a superiority test, specify the upper limit (h) for the range of practical equivalence and specify values of p1 and p2 such that p1 - p2 > h. For an inferiority test, specify the lower limit (-h) for the range of practical equivalence and specify values of p1 and p2 such that p1 - p2 > -h. This function sets the effect size equal to p1 - p2.
For more details, see Section 2.23 of Bonett (2021, Volume 3)
size.supinf.prop2(alpha, pow, p1, p2, h)size.supinf.prop2(alpha, pow, p1, p2, h)
alpha |
alpha level for hypothesis test |
pow |
desired power |
p1 |
planning value of proportion for group 1 |
p2 |
planning value of proportion for group 2 |
h |
lower or upper limit for range of practical equivalence |
Returns the required sample size for each group
Bonett DG (2021). Statistical Methods for Psychologists https://dgbonett.sites.ucsc.edu/.
size.supinf.prop2(.05, .9, .35, .20, .05) # Should return: # Sample size per group # 408size.supinf.prop2(.05, .9, .35, .20, .05) # Should return: # Sample size per group # 408
Computes the sample size for each group required to test a mean difference in an ANCOVA model with desired power in a 2-group design. In a nonexperimental design, the sample size is affected by the magnitude of covariate mean differences across groups. The covariate mean differences can be approximated by specifying the largest standardized covariate mean difference across of all covariates. In an experiment, this standardized mean difference is set to 0. Set the error variance planning value to the largest value within a plausible range for a conservatively large sample size.
For more details, see Section 2.29 of Bonett (2021, Volume 2)
size.test.ancova2(alpha, pow, evar, es, s, d, R)size.test.ancova2(alpha, pow, evar, es, s, d, R)
alpha |
alpha level for hypothesis test |
pow |
desired power |
evar |
planning value of within-group (error) variance |
es |
planning value of mean difference |
s |
number of covariates |
d |
largest standardized mean difference of all covariates |
R |
n2/n1 ratio |
Returns the required sample size for each group
Bonett DG (2021). Statistical Methods for Psychologists https://dgbonett.sites.ucsc.edu/.
size.test.ancova2(.05, .9, 1.37, .7, 1, 0, 1) # Should return: # n1 n2 # 61 61 size.test.ancova2(.05, .9, 1.37, .7, 1, 0, 2) # Should return: # n1 n2 # 47 94 size.test.ancova2(.05, .9, 1.37, .7, 1, .5, 1) # Should return: # n1 n2 # 65 65size.test.ancova2(.05, .9, 1.37, .7, 1, 0, 1) # Should return: # n1 n2 # 61 61 size.test.ancova2(.05, .9, 1.37, .7, 1, 0, 2) # Should return: # n1 n2 # 47 94 size.test.ancova2(.05, .9, 1.37, .7, 1, .5, 1) # Should return: # n1 n2 # 65 65
Computes the sample size required to test a population Pearson or a partial correlation with desired power. Set s = 0 for a Pearson correlation.
For more details, see Section 1.25 of Bonett (2021, Volume 2)
size.test.cor(alpha, pow, cor, s, h)size.test.cor(alpha, pow, cor, s, h)
alpha |
alpha level for hypothesis test |
pow |
desired power |
cor |
planning value of correlation |
s |
number of control variables |
h |
null hypothesis value of correlation |
Returns the required sample size
Bonett DG (2021). Statistical Methods for Psychologists https://dgbonett.sites.ucsc.edu/.
size.test.cor(.05, .95, -.50, 0, 0) # Should return: # Sample size # 47 size.test.cor(.05, .90, .4, 2, 0) # Should return: # Sample size # 64size.test.cor(.05, .95, -.50, 0, 0) # Should return: # Sample size # 47 size.test.cor(.05, .90, .4, 2, 0) # Should return: # Sample size # 64
Computes the sample size required to test equality of two Pearson or partial correlation with desired power in a 2-group design. Set s = 0 for a Pearson correlation. Set R = 1 for equal sample sizes.
size.test.cor2(alpha, pow, cor1, cor2, s, R)size.test.cor2(alpha, pow, cor1, cor2, s, R)
alpha |
alpha level for hypothesis test |
pow |
desired power |
cor1 |
correlation planning value for group 1 |
cor2 |
correlation planning value for group 2 |
s |
number of control variables |
R |
n2/n1 ratio |
Returns the required sample size for each group
size.test.cor2(.05, .8, .4, .2, 0, 1) # Should return: # n1 n2 # 325 325 size.test.cor2(.05, .8, .4, .2, 0, 2) # Should return: # n1 n2 # 245 490size.test.cor2(.05, .8, .4, .2, 0, 1) # Should return: # n1 n2 # 325 325 size.test.cor2(.05, .8, .4, .2, 0, 2) # Should return: # n1 n2 # 245 490
Computes the sample size required to test a Cronbach reliability with desired power.
size.test.cronbach(alpha, pow, rel, r, h)size.test.cronbach(alpha, pow, rel, r, h)
alpha |
alpha level for hypothesis test |
pow |
desired power |
rel |
reliability planning value |
r |
number of measurements (items, raters, forms) |
h |
null hypothesis value of reliability |
Returns the required sample size
Bonett DG, Wright TA (2015). “Cronbach's alpha reliability: Interval estimation, hypothesis testing, and sample size planning.” Journal of Organizational Behavior, 36(1), 3–15. ISSN 08943796. doi:10.1002/job.1960.
size.test.cronbach(.05, .85, .80, 5, .7) # Should return: # Sample size # 139size.test.cronbach(.05, .85, .80, 5, .7) # Should return: # Sample size # 139
Computes the sample size required to test a difference in population Cronbach reliability coefficients with desired power in a 2-group design.
size.test.cronbach2(alpha, pow, rel1, rel2, r)size.test.cronbach2(alpha, pow, rel1, rel2, r)
alpha |
alpha level for hypothesis test |
pow |
desired power |
rel1 |
reliability planning value for group 1 |
rel2 |
reliability planning value for group 2 |
r |
number of measurements (items, raters, forms) |
Returns the required sample size for each group
Bonett DG, Wright TA (2015). “Cronbach's alpha reliability: Interval estimation, hypothesis testing, and sample size planning.” Journal of Organizational Behavior, 36(1), 3–15. ISSN 08943796. doi:10.1002/job.1960.
size.test.cronbach2(.05, .80, .85, .70, 8) # Should return: # Sample size per group # 77size.test.cronbach2(.05, .80, .85, .70, 8) # Should return: # Sample size per group # 77
Computes the sample size required to test a single population parameter with desired power using a standard error for the parameter estimate from a prior or pilot study. This function can be used with any type of parameter where the standard error of the parameter estimate is a function of the square root of the sample size (most parameter estimates have this property). This function also assumes that the sampling distribution of the parameter estimate is approximately normal in large samples.
For more details, see Section 2.29 of Bonett (2021, Volume 2)
size.test.gen(alpha, pow, se, n0, es)size.test.gen(alpha, pow, se, n0, es)
alpha |
alpha level for hypothesis test |
pow |
desired power |
se |
standard error of parameter estimate from prior/pilot study |
n0 |
sample size of prior/pilot study |
es |
planning value of parameter minus null hypothesis value |
Returns the required sample size
Bonett DG (2021). Statistical Methods for Psychologists https://dgbonett.sites.ucsc.edu/.
size.test.gen(.05, .8, 2.89, 30, 5) # Should return: # Sample size # 79size.test.gen(.05, .8, 2.89, 30, 5) # Should return: # Sample size # 79
Computes the sample size per group required to test a difference in two population parameters with desired power using a standard error for a single parameter estimate from a prior or pilot study. This function can be used with any type of parameter where the standard error of the parameter estimate is a function of the square root of the sample size (most parameter estimates have this property). This function also assumes that the sampling distribution of the parameter estimate is approximately normal in large samples. Set R = 1 for equal sample sizes.
size.test.gen2(alpha, pow, se, n0, es, R)size.test.gen2(alpha, pow, se, n0, es, R)
alpha |
alpha level for hypothesis test |
pow |
desired power |
se |
standard error of parameter estimate from prior/pilot study |
n0 |
sample size of prior/pilot study |
es |
planning value of parameter difference |
R |
n2/n1 ratio |
Returns the required sample size for each group
size.test.gen2(.05, .85, .175, 30, .5, 1) # Should return: # n1 n2 # 66 66size.test.gen2(.05, .85, .175, 30, .5, 1) # Should return: # n1 n2 # 66 66
Computes the sample size for each group (assuming equal sample sizes) required to test a linear contrast of population means in an ANCOVA model with desired power. In a nonexperimental design, the sample size is affected by the magnitude of covariate mean differences across groups. The covariate mean differences can be approximated by specifying the largest standardized covariate mean difference across all pairwise comparisons and for all covariates. In an experiment, this standardized mean difference is set to 0. Set the error variance planning value to the largest value within a plausible range for a conservatively large sample size.
For more details, see Section 2.29 of Bonett (2021, Volume 2)
size.test.lc.ancova(alpha, pow, evar, es, s, d, v)size.test.lc.ancova(alpha, pow, evar, es, s, d, v)
alpha |
alpha level for hypothesis test |
pow |
desired power |
evar |
planning value of within-group (error) variance |
es |
planning value of linear contrast |
s |
number of covariates |
d |
largest standardized mean difference for all covariates |
v |
vector of between-subjects contrast coefficients |
Returns the required sample size for each group
Bonett DG (2021). Statistical Methods for Psychologists https://dgbonett.sites.ucsc.edu/.
v <- c(.25, .25, .25, .25, -1) size.test.lc.ancova(.05, .9, 17.5, 4.0, 2, 0, v) # Should return: # Sample size per group # 17v <- c(.25, .25, .25, .25, -1) size.test.lc.ancova(.05, .9, 17.5, 4.0, 2, 0, v) # Should return: # Sample size per group # 17
Computes the sample size in each group (assuming equal sample sizes) required to test a linear contrast of population means with desired power in a between-subjects design. Set the variance planning value to the largest value within a plausible range for a conservatively large sample size.
For more details, see Section 3.25 of Bonett (2021, Volume 1)
size.test.lc.mean.bs(alpha, pow, var, es, v)size.test.lc.mean.bs(alpha, pow, var, es, v)
alpha |
alpha level for hypothesis test |
pow |
desired power |
var |
planning value of average within-group variance |
es |
planning value of linear contrast of means |
v |
vector of between-subjects contrast coefficients |
Returns the required sample size for each group
Bonett DG (2021). Statistical Methods for Psychologists https://dgbonett.sites.ucsc.edu/.
v <- c(1/4, 1/4, 1/4, 1/4, -1) size.test.lc.mean.bs(.05, .90, 1, .5, v) # Should return: # Sample size per group # 53 v <- c(1, -1, -1, 1) size.test.lc.mean.bs(.05, .90, 27.5, 5, v) # Should return: # Sample size per group # 47v <- c(1/4, 1/4, 1/4, 1/4, -1) size.test.lc.mean.bs(.05, .90, 1, .5, v) # Should return: # Sample size per group # 53 v <- c(1, -1, -1, 1) size.test.lc.mean.bs(.05, .90, 27.5, 5, v) # Should return: # Sample size per group # 47
Computes the sample size required to test a linear contrast of population means with desired power in a within-subjects design. Set the average variance planning value to the largest value within a plausible range for a conservatively large sample size. Set the average correlation planning value to the smallest value within a plausible range for a conservatively large sample size.
For more details, see Section 4.27 of Bonett (2021, Volume 1)
size.test.lc.mean.ws(alpha, pow, var, es, cor, q)size.test.lc.mean.ws(alpha, pow, var, es, cor, q)
alpha |
alpha level for hypothesis test |
pow |
desired power |
var |
planning value of average variance of measurements |
es |
planning value of linear contrast of means |
cor |
planning value of average correlation between measurements |
q |
vector of with-subjects contrast coefficients |
Returns the required sample size
Bonett DG (2021). Statistical Methods for Psychologists https://dgbonett.sites.ucsc.edu/.
q <- c(1, -1, -1, 1) size.test.lc.mean.ws(.05, .95, 15.0, 3, .8, q) # Should return: # Sample size # 20q <- c(1, -1, -1, 1) size.test.lc.mean.ws(.05, .95, 15.0, 3, .8, q) # Should return: # Sample size # 20
Computes the sample size in each group (assuming equal sample sizes) required to test a linear contrast of population proportions with desired power in a between-subjects design. The planning value for the effect size (linear contrast of proportions) could be set equal to the linear contrast of proportion planning values or it could be set equal to a minimally interesting effect size. For a conservatively large sample size, set the proportion planning values to .5 and set the effect size to a minimally interesting value.
For more details, see Section 2.23 of Bonett (2021, Volume 3)
size.test.lc.prop.bs(alpha, pow, p, es, v)size.test.lc.prop.bs(alpha, pow, p, es, v)
alpha |
alpha level for hypothesis test |
pow |
desired power |
p |
vector of proportion planning values |
es |
planning value of proportion linear contrast |
v |
vector of between-subjects contrast coefficients |
Returns the required sample size for each group
Bonett DG (2021). Statistical Methods for Psychologists https://dgbonett.sites.ucsc.edu/.
p <- c(.35, .35, .20) v <- c(.5, .5, -1) size.test.lc.prop.bs(.05, .9, p, .15, v) # Should return: # Sample size per group # 128p <- c(.35, .35, .20) v <- c(.5, .5, -1) size.test.lc.prop.bs(.05, .9, p, .15, v) # Should return: # Sample size per group # 128
Computes the sample size in each group (assuming equal sample sizes) required for the Mann-Whitney test with desired power. A planning value of the Mann-Whitney parameter is required. In a 2-group experiment, this parameter is the proportion of members in the population with scores that would be larger under treatment 1 than treatment 2. In a 2-group nonexperiment where participants are sampled from two subpopulations of sizes N1 and N2, the parameter is the proportion of all N1 x N2 pairs in which a member from subpopulation 1 has a larger score than a member from subpopulation 2.
For more details, see Section 2.14 of Bonett (2021, Volume 1)
size.test.mann(alpha, pow, p)size.test.mann(alpha, pow, p)
alpha |
alpha level for hypothesis test |
pow |
desired power |
p |
planning value of Mann-Whitney parameter |
Returns the required sample size for each group
Noether GE (1987). “Sample size determination for some common nonparametric tests.” Journal of the American Statistical Association, 82(398), 645–647. ISSN 0162-1459. doi:10.1080/01621459.1987.10478478.
Bonett DG (2021). Statistical Methods for Psychologists https://dgbonett.sites.ucsc.edu/.
size.test.mann(.05, .90, .3) # Should return: # Sample size per group # 44size.test.mann(.05, .90, .3) # Should return: # Sample size per group # 44
Computes the sample size required to test a single population mean with desired power in a 1-group design. Set the variance planning value to the largest value within a plausible range for a conservatively large sample size.
For more details, see Section 1.29 of Bonett (2021, Volume 1)
size.test.mean(alpha, pow, var, es)size.test.mean(alpha, pow, var, es)
alpha |
alpha level for hypothesis test |
pow |
desired power |
var |
planning value of response variable variance |
es |
planning value of mean minus null hypothesis value |
Returns the required sample size
Bonett DG (2021). Statistical Methods for Psychologists https://dgbonett.sites.ucsc.edu/.
size.test.mean(.05, .9, 8.2, 1.5) # Should return: # Sample size # 41size.test.mean(.05, .9, 8.2, 1.5) # Should return: # Sample size # 41
Computes the sample size required to test a difference in population means with desired power in a paired-samples design. Set the Pearson correlation planning value to the smallest value within a plausible range, and set the variance planning value to the largest value within a plausible range for a conservatively large sample size.
For more details, see Section 4.27 of Bonett (2021, Volume 1)
size.test.mean.ps(alpha, pow, var, es, cor)size.test.mean.ps(alpha, pow, var, es, cor)
alpha |
alpha level for hypothesis test |
pow |
desired power |
var |
planning value of average variance of the two measurements |
es |
planning value of mean difference |
cor |
planning value of correlation |
Returns the required sample size
Bonett DG (2021). Statistical Methods for Psychologists https://dgbonett.sites.ucsc.edu/.
size.test.mean.ps(.05, .80, 1.25, .5, .75) # Should return: # Sample size # 22size.test.mean.ps(.05, .80, 1.25, .5, .75) # Should return: # Sample size # 22
Computes the sample size in each group required to test a difference in population means with desired power in a 2-group design. Set the variance planning value to the largest value within a plausible range for a conservatively large sample size. Set R = 1 for equal sample sizes. For unequal sample sizes, this function assumes approximately equal population variances.
For more details, see Section 2.14 of Bonett (2021, Volume 1)
size.test.mean2(alpha, pow, var, es, R)size.test.mean2(alpha, pow, var, es, R)
alpha |
alpha level for hypothesis test |
pow |
desired power |
var |
planning value of average within-group variance |
es |
planning value of mean difference |
R |
n2/n1 ratio |
Returns the required sample size for each group
Bonett DG (2021). Statistical Methods for Psychologists https://dgbonett.sites.ucsc.edu/.
size.test.mean2(.05, .95, 100, 10, 1) # Should return: # n1 n2 # 27 27 size.test.mean2(.05, .95, 100, 10, 3) # Should return: # n1 n2 # 19 57 size.test.mean2(.05, .95, 100, 10, .5) # Should return: # n1 n2 # 40 20size.test.mean2(.05, .95, 100, 10, 1) # Should return: # n1 n2 # 27 27 size.test.mean2(.05, .95, 100, 10, 3) # Should return: # n1 n2 # 19 57 size.test.mean2(.05, .95, 100, 10, .5) # Should return: # n1 n2 # 40 20
Computes the sample size required to test a population proportion with desired power (using a correction for continuity) in a 1-group design.
For more details, see Section 1.15 of Bonett (2021, Volume 3)
size.test.prop(alpha, pow, p, h)size.test.prop(alpha, pow, p, h)
alpha |
alpha level for hypothesis test |
pow |
desired power |
p |
planning value of proportion |
h |
null hypothesis value of proportion |
Returns the required sample size
Fleiss JL, Paik MC (2003). Statistical Methods for Rates and Proportions, 3rd edition. Wiley.
Bonett DG (2021). Statistical Methods for Psychologists https://dgbonett.sites.ucsc.edu/.
size.test.prop(.05, .9, .5, .3) # Should return: # Sample size # 65size.test.prop(.05, .9, .5, .3) # Should return: # Sample size # 65
Computes the sample size required to test a difference in population proportions with desired power in a paired-samples design. This function requires planning values for both proportions and a phi coefficient that describes the correlation between the two dichotomous measurements. The proportion planning values can be set to .5 for a conservatively large sample size. The planning value for the effect size (proportion difference) could be set equal to the difference of the two proportion planning values or it could be set equal to a minimally interesting effect size. Set the phi correlation planning value to the smallest absolute value within a plausible range for a conservatively large sample size.
For more details, see Section 3.13 of Bonett (2021, Volume 3)
size.test.prop.ps(alpha, pow, p1, p2, phi, es)size.test.prop.ps(alpha, pow, p1, p2, phi, es)
alpha |
alpha level for hypothesis test |
pow |
desired power |
p1 |
planning value of proportion for measurement 1 |
p2 |
planning value of proportion for measurement 2 |
phi |
planning value of phi correlation |
es |
planning value of proportion difference |
Returns the required sample size
Bonett DG (2021). Statistical Methods for Psychologists https://dgbonett.sites.ucsc.edu/.
size.test.prop.ps(.05, .90, .6, .7, .5, .1) # Should return: # Sample size # 237size.test.prop.ps(.05, .90, .6, .7, .5, .1) # Should return: # Sample size # 237
Computes the sample size in each group required to test a difference in population proportions with desired power (using a continuity correction) in a 2-group design. This function requires planning values for both proportions. Set each proportion planning value to .5 for a conservatively large sample size requirement. This function does not require the planning value for the proportion difference (effect size) to equal the difference of the two proportion planning values; for example, the planning value of the proportion difference could be set equal to a minimally interesting effect size.
For more details, see Section 2.23 of Bonett (2021, Volume 3)
size.test.prop2(alpha, pow, p1, p2, es)size.test.prop2(alpha, pow, p1, p2, es)
alpha |
alpha level for hypothesis test |
pow |
desired power |
p1 |
planning value of proportion for group 1 |
p2 |
planning value of proportion for group 2 |
es |
planning value of proportion difference (effect size) |
Returns the required sample size for each group
Bonett DG (2021). Statistical Methods for Psychologists https://dgbonett.sites.ucsc.edu/.
size.test.prop2(.05, .8, .6, .4, .2) # Should return: # Sample size per group # 106 size.test.prop2(.05, .8, .5, .5, .2) # Should return: # Sample size per group # 109size.test.prop2(.05, .8, .6, .4, .2) # Should return: # Sample size per group # 106 size.test.prop2(.05, .8, .5, .5, .2) # Should return: # Sample size per group # 109
Computes the sample size required for a 1-group sign test with desired power (see size.test.sign.ps for a paired-samples sign test). The Sign test is a test of the null hypothesis that the population median is equal to some specified value. This null hypothesis can also be expressed in terms of the proportion of scores in the population that are greater than the hypothesized population median value. Under the null hypothesis, the population proportion is equal to .5. This function requires a planning value of the population proportion.
For more details, see Section 1.29 of Bonett (2021, Volume 1)
size.test.sign(alpha, pow, p)size.test.sign(alpha, pow, p)
alpha |
alpha level for hypothesis test |
pow |
desired power |
p |
planning value of proportion |
Returns the required sample size
Bonett DG (2021). Statistical Methods for Psychologists https://dgbonett.sites.ucsc.edu/.
size.test.sign(.05, .90, .3) # Should return: # Sample size # 67size.test.sign(.05, .90, .3) # Should return: # Sample size # 67
Computes sample size required for a paired-samples sign test with desired power. The null hypothesis can be expressed in terms of a population proportion. In a paired-samples experiment, the proportion is defined as the proportion of members in the population with scores that would be larger under treatment 1 than treatment 2. In a paired-samples nonexperiment, the proportion is the proportion of members in the population with measurement 1 scores that are larger than their measurement 2 scores. Under the null hypothesis, the population proportion is equal to to .5. This function requires a planning value of the population proportion.
size.test.sign.ps(alpha, pow, p)size.test.sign.ps(alpha, pow, p)
alpha |
alpha level for hypothesis test |
pow |
desired power |
p |
planning value of proportion |
Returns the required sample size
size.test.sign.ps(.05, .90, .75) # Should return: # Sample size # 42size.test.sign.ps(.05, .90, .75) # Should return: # Sample size # 42
Computes the total sample size required to test a population slope with desired power in a between-subjects design with a quantitative factor. In an experimental design, the total sample size would be allocated to the levels of the quantitative factor and it might be necessary to use a larger total sample size to achieve equal sample sizes. Set the error variance planning value to the largest value within a plausible range for a conservatively large sample size.
For more details, see Section 1.25 of Bonett (2021, Volume 2)
size.test.slope(alpha, pow, evar, x, slope, h)size.test.slope(alpha, pow, evar, x, slope, h)
alpha |
alpha level for hypothesis test |
pow |
desired power |
evar |
planning value of within-group (error) variance |
x |
vector of x values of the quantitative factor |
slope |
planning value of slope |
h |
null hypothesis value of slope |
Returns the required total sample size
Bonett DG (2021). Statistical Methods for Psychologists https://dgbonett.sites.ucsc.edu/.
x <- c(2, 5, 8) size.test.slope(.05, .9, 31.1, x, .75, 0) # Should return: # Total sample size # 100x <- c(2, 5, 8) size.test.slope(.05, .9, 31.1, x, .75, 0) # Should return: # Total sample size # 100
Computes the contrast coefficients that are needed to estimate the slope of a line in a one-factor design with a quantitative factor.
For more details, see Section 1.11 of Bonett (2021, Volume 2)
slope.contrast(x)slope.contrast(x)
x |
vector of numeric factor levels |
Returns the vector of contrast coefficients
Bonett DG (2021). Statistical Methods for Psychologists https://dgbonett.sites.ucsc.edu/.
x <- c(25, 50, 75, 100) slope.contrast(x) # Should return: # Coefficient # [1,] -0.012 # [2,] -0.004 # [3,] 0.004 # [4,] 0.012x <- c(25, 50, 75, 100) slope.contrast(x) # Should return: # Coefficient # [1,] -0.012 # [2,] -0.004 # [3,] 0.004 # [4,] 0.012
Computes the reliability of a scale that is the sum or average of r2 parallel measurements given the reliability of a scale that is the sum or average of r1 parallel measurements. The "measurements" can be items, forms, raters, or occasions.
For more details, see Section 4.19 of Bonett (2021, Volume 1)
spearmanbrown(rel, r1, r2)spearmanbrown(rel, r1, r2)
rel |
reliability of the sum or average of r1 measurements |
r1 |
number of measurements in the original scale |
r2 |
number of measurements in the new scale |
Returns the reliability of the sum or average of r2 measurements
Bonett DG (2021). Statistical Methods for Psychologists https://dgbonett.sites.ucsc.edu/.
spearmanbrown(.6, 10, 20) # Should return: # Reliability of r2 measurements # .75spearmanbrown(.6, 10, 20) # Should return: # Reliability of r2 measurements # .75
Computes the F statistic, p-value, eta-squared, and adjusted eta-squared for the main effect in a one-way between-subjects ANOVA using the estimated group means, estimated group standard deviations, and group sample sizes.
For more details, see Section 3.7 of Bonett (2021, Volume 1)
test.anova.bs(m, sd, n)test.anova.bs(m, sd, n)
m |
vector of estimated group means |
sd |
vector of estimated group standard deviations |
n |
vector of group sample sizes |
Returns a 1-row matrix. The columns are:
F - F statistic for test of null hypothesis
dfA - degrees of freedom for between-subjects factor
dfE - error degrees of freedom
p - p-value
Eta-squared - estimate of eta-squared
adj Eta-squared - a bias adjusted estimate of eta-squared
Bonett DG (2021). Statistical Methods for Psychologists https://dgbonett.sites.ucsc.edu/.
m <- c(12.4, 8.6, 10.5) sd <- c(3.84, 3.12, 3.48) n <- c(20, 20, 20) test.anova.bs(m, sd, n) # Should return: # F dfA dfE p Eta-squared adj Eta-squared # 5.9196 2 57 0.00461 0.172 0.1429m <- c(12.4, 8.6, 10.5) sd <- c(3.84, 3.12, 3.48) n <- c(20, 20, 20) test.anova.bs(m, sd, n) # Should return: # F dfA dfE p Eta-squared adj Eta-squared # 5.9196 2 57 0.00461 0.172 0.1429
Computes a t test for a test of the null hypothesis that a population Pearson or partial correlations is equal to 0, or a z test using a Fisher transformation for a test of the null hypothesis that a Pearson or partial correlation is equal to some specified nonzero value. Set s = 0 for a Pearson correlation. The hypothesis testing results should be accompanied with a confidence interval for the population Pearson or partial correlation value (see ci.cor).
For more details, see Section 1.19 of Bonett (2021, Volume 2)
test.cor(cor, n, s, h)test.cor(cor, n, s, h)
cor |
estimated correlation |
n |
sample size |
s |
number of control variables |
h |
null hypothesis value of correlation |
Returns a 1-row matrix. The columns are:
Estimate - estimate of correlation
t or z - t test statistic (for h = 0) or z test statistic (for nonzero h)
p - two-sided p-value
Bonett DG (2021). Statistical Methods for Psychologists https://dgbonett.sites.ucsc.edu/.
test.cor(.484, 100, 0, .2) # Should return: # Estimate z p # 0.484 3.2054 0.00135 test.cor(.372, 100, 0, 0) # Should return: # Estimate t df p # 0.372 3.9673 98 0.00014test.cor(.484, 100, 0, .2) # Should return: # Estimate z p # 0.484 3.2054 0.00135 test.cor(.372, 100, 0, 0) # Should return: # Estimate t df p # 0.372 3.9673 98 0.00014
Computes a z test for a difference of population Pearson or partial correlations in a 2-group design. Set s = 0 for a Pearson correlation. The hypothesis testing results should be accompanied with a confidence interval for the difference in population correlation values (see ci.cor2).
test.cor2(cor1, cor2, n1, n2, s)test.cor2(cor1, cor2, n1, n2, s)
cor1 |
estimated correlation for group 1 |
cor2 |
estimated correlation for group 2 |
n1 |
sample size for group 1 |
n2 |
sample size for group 2 |
s |
number of control variables |
Returns a 1-row matrix. The columns are:
Estimate - estimate of correlation difference
z - z test statistic
p - two-sided p-value
test.cor2(.684, .437, 100, 125, 0) # Should return: # Estimate z p # 0.247 2.7057 0.00682test.cor2(.684, .437, 100, 125, 0) # Should return: # Estimate z p # 0.247 2.7057 0.00682
Computes a Monte Carlo p-value (250,000 replications) for the null hypothesis that the sample data come from a normal distribution. If the p-value is small (e.g., less than .05) and excess kurtosis is positive, then the normality assumption can be rejected due to leptokurtosis. If the p-value is small (e.g., less than .05) and excess kurtosis is negative, then the normality assumption can be rejected due to platykurtosis.
For more details, see Section 1.23 of Bonett (2021, Volume 1)
test.kurtosis(y)test.kurtosis(y)
y |
vector of quantitative scores |
Returns a 1-row matrix. The columns are:
Kurtosis - estimate of kurtosis coefficient
Excess - estimate of excess kurtosis (kurtosis - 3)
p - Monte Carlo two-sided p-value
Bonett DG (2021). Statistical Methods for Psychologists https://dgbonett.sites.ucsc.edu/.
y <- c(30, 20, 15, 10, 10, 60, 20, 25, 20, 30, 10, 5, 50, 40, 95) test.kurtosis(y) # Should return: # Kurtosis Excess p # 4.8149 1.8149 0.038y <- c(30, 20, 15, 10, 10, 60, 20, 25, 20, 30, 10, 5, 50, 40, 95) test.kurtosis(y) # Should return: # Kurtosis Excess p # 4.8149 1.8149 0.038
Computes a one-sample t-test for a population mean using the estimated mean, estimated standard deviation, sample size, and null hypothesis value. Use the t.test function for raw data input. A confidence interval for a population mean is a recommended supplement to the t-test (see ci.mean).
For more details, see Section 1.11 of Bonett (2021, Volume 1)
test.mean(m, sd, n, h)test.mean(m, sd, n, h)
m |
estimated mean |
sd |
estimated standard deviation |
n |
sample size |
h |
null hypothesis value of mean |
Returns a 1-row matrix. The columns are:
t - t test statistic
df - degrees of freedom
p - two-sided p-value
Snedecor GW, Cochran WG (1989). Statistical Methods, 8th edition. ISU University Pres, Ames, Iowa.
Bonett DG (2021). Statistical Methods for Psychologists https://dgbonett.sites.ucsc.edu/.
test.mean(7.9, 3.05, 100, 7) # Should return: # t df p # 2.9508 99 0.00396test.mean(7.9, 3.05, 100, 7) # Should return: # t df p # 2.9508 99 0.00396
Computes simultaneous confidence intervals for all adjacent pairwise comparisons of population means using estimated group means, estimated group standard deviations, and samples sizes as input. Equal variances are not assumed. A Satterthwaite adjustment to the degrees of freedom is used to improve the accuracy of the confidence intervals. If one or more lower limits are greater than 0 and no upper limit is less than 0, then conclude that the population means are monotonic decreasing. If one or more upper limits are less than 0 and no lower limits are greater than 0, then conclude that the population means are monotonic increasing. Reject the hypothesis of a monotonic trend if any lower limit is greater than 0 and any upper limit is less than 0.
For more details, see Section 1.21 of Bonett (2021, Volume 2)
test.mono.mean.bs(alpha, m, sd, n)test.mono.mean.bs(alpha, m, sd, n)
alpha |
alpha level for simultaneous 1-alpha confidence |
m |
vector of estimated group means |
sd |
vector of estimated group standard deviations |
n |
vector of sample sizes |
Returns a matrix with the number of rows equal to the number of adjacent pairwise comparisons. The columns are:
Estimate - estimated mean difference
SE - standard error
LL - one-sided lower limit of the confidence interval
UL - one-sided upper limit of the confidence interval
Bonett DG (2021). Statistical Methods for Psychologists https://dgbonett.sites.ucsc.edu/.
m <- c(12.86, 24.57, 36.29, 53.21) sd <- c(13.185, 12.995, 14.773, 15.145) n <- c(20, 20, 20, 20) test.mono.mean.bs(.05, m, sd, n) # Should return: # Estimate SE LL UL # 1 2 -11.71 4.139530 -22.07803 -1.3419744 # 2 3 -11.72 4.399497 -22.74731 -0.6926939 # 3 4 -16.92 4.730817 -28.76921 -5.0707936m <- c(12.86, 24.57, 36.29, 53.21) sd <- c(13.185, 12.995, 14.773, 15.145) n <- c(20, 20, 20, 20) test.mono.mean.bs(.05, m, sd, n) # Should return: # Estimate SE LL UL # 1 2 -11.71 4.139530 -22.07803 -1.3419744 # 2 3 -11.72 4.399497 -22.74731 -0.6926939 # 3 4 -16.92 4.730817 -28.76921 -5.0707936
Computes simultaneous confidence intervals for all adjacent pairwise comparisons of population medians using sample group medians and standard errors as input. If one or more lower limits are greater than 0 and no upper limit is less than 0, then conclude that the population medians are monotonic decreasing. If one or more upper limits are less than 0 and no lower limits are greater than 0, then conclude that the population medians are monotonic increasing. Reject the hypothesis of a monotonic trend if any lower limit is greater than 0 and any upper limit is less than 0. The sample median and standard error for each group can be computed using the ci.median function.
For more details, see Section 1.21 of Bonett (2021, Volume 2)
test.mono.median.bs(alpha, m, se)test.mono.median.bs(alpha, m, se)
alpha |
alpha level for simultaneous 1-alpha confidence |
m |
vector of estimated group medians |
se |
vector of estimated group standard errors |
Returns a matrix with the number of rows equal to the number of adjacent pairwise comparisons. The columns are:
Estimate - estimated median difference
SE - standard error
LL - one-sided lower limit of the confidence interval
UL - one-sided upper limit of the confidence interval
Bonett DG (2021). Statistical Methods for Psychologists https://dgbonett.sites.ucsc.edu/.
m <- c(12.86, 24.57, 36.29, 53.21) se <- c(2.85, 2.99, 3.73, 3.88) test.mono.median.bs(.05, m, se) # Should return: # Estimate SE LL UL # 1 2 -11.71 4.130690 -21.59879 -1.8212115 # 2 3 -11.72 4.780481 -23.16438 -0.2756247 # 3 4 -16.92 5.382128 -29.80471 -4.0352947m <- c(12.86, 24.57, 36.29, 53.21) se <- c(2.85, 2.99, 3.73, 3.88) test.mono.median.bs(.05, m, se) # Should return: # Estimate SE LL UL # 1 2 -11.71 4.130690 -21.59879 -1.8212115 # 2 3 -11.72 4.780481 -23.16438 -0.2756247 # 3 4 -16.92 5.382128 -29.80471 -4.0352947
Computes simultaneous confidence intervals for all adjacent pairwise comparisons of population proportions using group frequency counts and samples sizes as input. If one or more lower limits are greater than 0 and no upper limit is less than 0, then conclude that the population proportions are monotonic decreasing. If one or more upper limits are less than 0 and no lower limits are greater than 0, then conclude that the population proportions are monotonic increasing. Reject the hypothesis of a monotonic trend if any lower limit is greater than 0 and any upper limit is less than 0.
For more details, see Section 2.12 of Bonett (2021, Volume 3)
test.mono.prop.bs(alpha, f, n)test.mono.prop.bs(alpha, f, n)
alpha |
alpha level for simultaneous 1-alpha confidence |
f |
vector of frequency counts of participants who have the attribute |
n |
vector of sample sizes |
Returns a matrix with the number of rows equal to the number of adjacent pairwise comparisons. The columns are:
Estimate - estimated proportion difference
SE - standard error
LL - one-sided lower limit of the confidence interval
UL - one-sided upper limit of the confidence interval
Bonett DG (2021). Statistical Methods for Psychologists https://dgbonett.sites.ucsc.edu/.
f <- c(67, 49, 30, 10) n <- c(100, 100, 100, 100) test.mono.prop.bs(.05, f, n) # Should return: # Estimate SE LL UL # 1 2 0.1764706 0.06803446 0.01359747 0.3393437 # 2 3 0.1862745 0.06726135 0.02525219 0.3472968 # 3 4 0.1960784 0.05493010 0.06457688 0.3275800f <- c(67, 49, 30, 10) n <- c(100, 100, 100, 100) test.mono.prop.bs(.05, f, n) # Should return: # Estimate SE LL UL # 1 2 0.1764706 0.06803446 0.01359747 0.3393437 # 2 3 0.1862745 0.06726135 0.02525219 0.3472968 # 3 4 0.1960784 0.05493010 0.06457688 0.3275800
Computes a continuity-corrected z-test for a population proportion in a 1-group design. A confidence interval for a population proportion is a recommended supplement to the z-test (see ci.prop).
For more details, see Section 1.7 of Bonett (2021, Volume 3)
test.prop(f, n, h)test.prop(f, n, h)
f |
number of participants who have the attribute |
n |
sample size |
h |
null hypothesis value of proportion |
Returns a 1-row matrix. The columns are:
Estimate - ML estimate of proportion
z - z test statistic
p - two-sided p-value
Snedecor GW, Cochran WG (1989). Statistical Methods, 8th edition. ISU University Pres, Ames, Iowa.
Bonett DG (2021). Statistical Methods for Psychologists https://dgbonett.sites.ucsc.edu/.
test.prop(76, 100, .6) # Should return: # Estimate z p # 0.76 3.1639 0.00156test.prop(76, 100, .6) # Should return: # Estimate z p # 0.76 3.1639 0.00156
Computes a Pearson chi-square test for equal population proportions for a dichotomous response variable in a one-factor between-subjects design.
For more details, see Section 2.13 of Bonett (2021, Volume 3)
test.prop.bs(f, n)test.prop.bs(f, n)
f |
vector of frequency counts of participants who have the attribute |
n |
vector of sample sizes |
Returns a 1-row matrix. The columns are:
Chi-square - chi-square test statistic
df - degrees of freedom
p - p-value
Fleiss JL, Paik MC (2003). Statistical Methods for Rates and Proportions, 3rd edition. Wiley.
Bonett DG (2021). Statistical Methods for Psychologists https://dgbonett.sites.ucsc.edu/.
f <- c(111, 118, 132) n <- c(200, 200, 200) test.prop.bs (f, n) # Should return: # Chi-square df p # 4.7706 2 0.09206f <- c(111, 118, 132) n <- c(200, 200, 200) test.prop.bs (f, n) # Should return: # Chi-square df p # 4.7706 2 0.09206
Computes a continuity-corrected McNemar test for equality of population proportions in a paired-samples design. This function requires the frequency counts from a 2 x 2 contingency table for two paired dichotomous measurements. A confidence interval for a difference in population proportions (see ci.prop.ps) is a recommended supplement to the McNemar test.
For more details, see Section 3.2 of Bonett (2021, Volume 3)
test.prop.ps(f00, f01, f10, f11)test.prop.ps(f00, f01, f10, f11)
f00 |
number participants with y = 0 and x = 0 |
f01 |
number participants with y = 0 and x = 1 |
f10 |
number participants with y = 1 and x = 0 |
f11 |
number participants with y = 1 and x = 1 |
Returns a 1-row matrix. The columns are:
Estimate - ML estimate of proportion difference
z - z test statistic
p - two-sided p-value
Snedecor GW, Cochran WG (1989). Statistical Methods, 8th edition. ISU University Pres, Ames, Iowa.
Bonett DG (2021). Statistical Methods for Psychologists https://dgbonett.sites.ucsc.edu/.
test.prop.ps(12, 4, 26, 6) # Should return: # Estimate z p # -0.4583333 3.8341 0.00013test.prop.ps(12, 4, 26, 6) # Should return: # Estimate z p # -0.4583333 3.8341 0.00013
Computes a continuity-corrected z-test for a difference of population proportions in a 2-group design. A confidence interval for a difference in population proportions is a recommended supplement to the z-test (see ci.prop2).
For more details, see Section 2.4 of Bonett (2021, Volume 3)
test.prop2(f1, f2, n1, n2)test.prop2(f1, f2, n1, n2)
f1 |
number of group 1 participants who have the attribute |
f2 |
number of group 2 participants who have the attribute |
n1 |
sample size for group 1 |
n2 |
sample size for group 2 |
Returns a 1-row matrix. The columns are:
Estimate - ML estimate of proportion difference
z - z test statistic
p - two-sided p-value
Snedecor GW, Cochran WG (1989). Statistical Methods, 8th edition. ISU University Pres, Ames, Iowa.
Bonett DG (2021). Statistical Methods for Psychologists https://dgbonett.sites.ucsc.edu/.
test.prop2(39, 24, 50, 50) # Should return: # Estimate z p # 0.3 2.8997 0.00373test.prop2(39, 24, 50, 50) # Should return: # Estimate z p # 0.3 2.8997 0.00373
Computes a Monte Carlo p-value (250,000 replications) for the null hypothesis that the sample data come from a normal distribution. If the p-value is small (e.g., less than .05) and the skewness estimate is positive, then the normality assumption can be rejected due to positive skewness. If the p-value is small (e.g., less than .05) and the skewness estimate is negative, then the normality assumption can be rejected due to negative skewness.
For more details, see Section 1.23 of Bonett (2021, Volume 1)
test.skew(y)test.skew(y)
y |
vector of quantitative scores |
Returns a 1-row matrix. The columns are:
Skewness - estimate of skewness coefficient
p - Monte Carlo two-sided p-value
Bonett DG (2021). Statistical Methods for Psychologists https://dgbonett.sites.ucsc.edu/.
y <- c(30, 20, 15, 10, 10, 60, 20, 25, 20, 30, 10, 5, 50, 40, 95) test.skew(y) # Should return: # Skewness p # 1.5201 0.007y <- c(30, 20, 15, 10, 10, 60, 20, 25, 20, 30, 10, 5, 50, 40, 95) test.skew(y) # Should return: # Skewness p # 1.5201 0.007
Computes a t test for a test of the null hypothesis that a population Spearman correlation is equal to 0, or a z test using a Fisher transformation for a test of the null hypothesis that a Spearman correlation is equal to some specified nonzero value. The hypothesis testing results should be accompanied with a confidence interval for the population Spearman correlation value (see ci.spear).
test.spear(cor, h, n)test.spear(cor, h, n)
cor |
estimated correlation |
h |
null hypothesis value of correlation |
n |
sample size |
Returns a 1-row matrix. The columns are:
Estimate - estimate of correlation
t or z - t test statistic (for h = 0) or z test statistic (for nonzero h)
p - two-sided p-value
test.spear(.471, .2, 100) # Should return: # Estimate z p # 0.471 3.0096 0.00262 test.spear(.341, 0, 100) # Should return: # Estimate t df p # 0.341 3.591 98 0.00052test.spear(.471, .2, 100) # Should return: # Estimate z p # 0.471 3.0096 0.00262 test.spear(.341, 0, 100) # Should return: # Estimate t df p # 0.341 3.591 98 0.00052
Computes a z test for a difference of population Spearman correlations in a 2-group design. The test statistic uses a Bonett-Wright standard error for each Spearman correlation. The hypothesis testing results should be accompanied with a confidence interval for a difference in population Spearman correlation values (see ci.spear2).
test.spear2(cor1, cor2, n1, n2)test.spear2(cor1, cor2, n1, n2)
cor1 |
estimated Spearman correlation for group 1 |
cor2 |
estimated Spearman correlation for group 2 |
n1 |
sample size for group 1 |
n2 |
sample size for group 2 |
Returns a 1-row matrix. The columns are:
Estimate - estimate of correlation difference
z - z test statistic
p - two-sided p-value
Bonett DG, Wright TA (2000). “Sample size requirements for estimating Pearson, Kendall and Spearman correlations.” Psychometrika, 65(1), 23–28. ISSN 0033-3123. doi:10.1007/BF02294183.
test.spear2(.684, .437, 100, 125) # Should return: # Estimate z p # 0.247 2.4986 0.01247test.spear2(.684, .437, 100, 125) # Should return: # Estimate z p # 0.247 2.4986 0.01247