-
Notifications
You must be signed in to change notification settings - Fork 0
/
Differences-in-Variance.qmd
258 lines (180 loc) · 8.67 KB
/
Differences-in-Variance.qmd
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
# Differences in Variability
Occasionally researchers would like to compare the variations between two conditions or groups rather than the mean. Two commonly used are the natural logarithms of variability ratio ($lnVR$) and the coefficient of variance ratio ($lnCVR$). The latter of these can be useful when there may be a mean-variance relationship present (i.e., variances tend to increase with mean values) in order to account for this. An lnVR or lnCVR of zero therefore would indicate no difference in variation between the two groups, an lnVR or lnCVR of \>0 would indicate larger variance in group 1, and an lnVR or lnCVR of \<0 would indicate larger variance in group 2. There are both independent and dependent versions of these effect sizes [see @senior2020]. To obtain confidence intervals of a the lnVR or lnCVR then we, for example 95% confidence intervals, we merely multiply the standard error for the parameter by 1.96 similarly to other effect size statistics,
$$
CI_{lnVR/lnCVR}=lnVR \pm 1.96\cdot SE_{lnVR/lnCVR}
$$
#### **Here is a table for every effect size discussed in this chapter:** {.unnumbered}
| Type | Description | Section|
|:------|:---------|:----:|
| **Variability Ratios (VR)** | | @sec-vr|
| $lnVR_\text{ind}$ - Natural Logarithm of variability ratio for independent groups | Used to compare the standard deviations (i.e., the variability) between two groups. | @sec-vr-ind|
| $lnVR_\text{dep}$ - Natural Logarithm of variability ratio for dependent groups | Used to compare the standard deviations (i.e., the variability) between paired groups (i.e., repeated measures designs). | @sec-vr-dep|
| **Coefficient of Variation Ratios (CVR)** | | @sec-cvr |
| $lnCVR_\text{ind}$ - Natural Logarithm of coefficient variation ratio for independent groups | Used to compare the variation between two groups. More useful than a variability ratio ($lnVR_\text{ind}$) when there is a relationship between the mean and variance. | @sec-cvr-ind |
| $lnCVR_\text{dep}$ - Natural Logarithm of coefficient variation ratio for dependent groups | Used to compare the variation between paired groups (i.e., repeated measures). More useful than a variability ratio ($lnVR_\text{dep}$) when there is a relationship between the mean and variance. | @sec-cvr-ind |
## Variability Ratios {#sec-vr}
### Natural Logarithm of Variability Ratio for Independent Groups ($lnVR_\text{ind}$) {#sec-vr-ind}
The variability ratio for independent groups can be calculated by taking the natural logarithm of the *standard deviation* within one group divided by the standard deviation in another group,
$$
lnVR_\text{ind}=\ln\left(\frac{S_T}{S_C}\right) + CF
$$
Where $CF$ is a small sample correction factor calculated as,
$$
CF=\frac{1}{2(n_T-1)}-\frac{1}{2(n_C-1)}
$$
A $lnVR$ of zero therefore would indicate no difference in variation between the two groups, a $lnVR$ of \>0 would indicate larger variance in group 1, and $lnVR$ of \<0 would indicate larger variance in group 2. The standard error of the VR can be calculated as,
$$
SE_{lnVR_\text{ind}}=\sqrt{\frac{n_T}{2(n_T-1)^2}+\frac{n_C}{2(n_C-1)^2}}
$$
In R, we can simply use the metafor packages `escalc()` function from the `metafor` package [@metafor] as follows:
```{r, echo=TRUE, message=FALSE}
# Example:
# Group 1: standard deviation = 4.5, sample size = 50
# Group 2: standard deviation = 3.5, sample size = 50
library(metafor)
# prepare the data
SD1 <- 4.5
SD2 <- 3.5
n1 <- n2 <- 50
lnVRind <- escalc(
measure = "VR",
sd1i = SD1,
sd2i = SD2,
n1i = n1,
n2i = n2
)
lnVRind$SE <- sqrt(lnVRind$vi)
# calculate confidence interval
lnVRind_low <- lnVRind$yi - 1.96*lnVRind$SE
lnVRind_high <- lnVRind$yi + 1.96*lnVRind$SE
# print the VR value and confidence intervals
data.frame(lnVRind = MOTE::apa(lnVRind$yi),
lnVRind_low = MOTE::apa(lnVRind_low),
lnVRind_high = MOTE::apa(lnVRind_high))
```
From the example, we obtain a natural log variability ratio of $lnVR_\text{ind}$ = 0.25 \[-0.03, 0.53\].
### Natural Logarithm of Variability Ratio for Dependent Groups ($lnVR_\text{dep}$) {#sec-vr-dep}
The variability ratio for dependent groups can similarly be calculated by taking the natural logarithm of the *standard deviation* within one group divided by the *standard deviation* in another group,
$$
lnVR_\text{dep}=\ln\left(\frac{S_T}{S_C}\right)
$$
Note, the correction factor for small sample size bias is not relevant here as due to its calculation its value is zero.
$$
SE_{lnVR_\text{dep}}=\sqrt{\frac{n}{n-1} - \frac{r^2}{n-1} + \frac{r^4\left(S^8_T+S^8_C\right)}{2(n-1)^2 S^4_T+S^4_C}}
$$
In R, we can simply use the metafor packages `escalc()` function as follows:
```{r,echo=TRUE, message=FALSE}
# Example:
# Group 1: standard deviation = 4.5
# Group 2: standard deviation = 3.5
# Sample size = 50
# Correlation = 0.4
library(metafor)
# prepare the data
SD1 <- 4.5
SD2 <- 3.5
n <- 50
r <- 0.4
# use escalc to compute lnVRdep
lnVRdep <- escalc(
measure = "VRC",
sd1i = SD1,
sd2i = SD2,
ni = n1,
ri = r
)
lnVRdep$SE <- sqrt(lnVRdep$vi)
# calculate confidence interval
lnVRdep_low <- lnVRdep$yi - 1.96*lnVRdep$SE
lnVRdep_high <- lnVRdep$yi + 1.96*lnVRdep$SE
# print the VR value and confidence intervals
data.frame(lnVRdep = MOTE::apa(lnVRdep$yi),
lnVRdep_low = MOTE::apa(lnVRdep_low),
v_high = MOTE::apa(lnVRdep_high))
```
## Coefficient of Variation Ratios {#sec-cvr}
### Natural Logarithm of Coefficient of Variation Ratio for independent groups (lnCVR_\text{ind}) {#sec-cvr-ind}
The coefficient of variation ratio for independent groups can be calculated by taking the natural logarithm of the coefficient of variation within one group divided by the coefficient of variation in another group,
$$
lnCVR_\text{ind}=\ln\left(\frac{CV_T}{CV_C}\right) + CF
$$
Where $CV_T =S_T / M_T$, $CV_C =S_C / M_C$, and $M$ indicates the mean of the respective group. The correction factor, $CF$, is a small sample size bias correction factor that combines that from the lnRR (presented earlier) and the lnVR calculated as,
$$
CF=\frac{1}{2(n_T-1)}-\frac{1}{2(n_C-1)} + \frac{S_T^2}{2(n_TM_T^2)} + \frac{S_C^2}{2(n_CM_C^2)}
$$
In R, we can simply use the `escalc()` function from the `metafor` package as follows:
```{r,message=FALSE}
# Example:
# Group 1: mean = 22.4, standard deviation = 4.5, sample size = 50
# Group 2: mean = 20.1, standard deviation = 3.5, sample size = 50
library(metafor)
# prepare the data
M1 <- 22.4
M2 <- 20.1
SD1 <- 4.5
SD2 <- 3.5
n1 <- n2 <- 50
lnCVRind <- escalc(
measure = "CVR",
m1i = M1,
m2i = M2,
sd1i = SD1,
sd2i = SD2,
n1i = n1,
n2i = n2
)
lnCVRind$SE <- sqrt(lnCVRind$vi)
# calculate confidence interval
lnCVRind_low <- lnCVRind$yi - 1.96*lnCVRind$SE
lnCVRind_high <- lnCVRind$yi + 1.96*lnCVRind$SE
# print the VR value and confidence intervals
data.frame(lnCVRind = MOTE::apa(lnCVRind$yi),
lnCVRind_low = MOTE::apa(lnCVRind_low),
lnCVRind_high = MOTE::apa(lnCVRind_high))
```
### Natural Logarithm of Coefficient of Variation Ratio for independent groups ($lnCVR_\text{dep}$) {#sec-cvr-dep}
The coefficient of variation ratio for dependent groups can be similarly calculated by taking the natural logarithm of the coefficient of variation within one group divided by the coefficient of variation in another group,
$$
lnCVR_\text{dep}=\ln\left(\frac{CV_T}{CV_C}\right) + CF
$$
Where $CV_T =S_T / M_T$, $CV_C =S_C / M_C$ and CF is a small sample size bias correction factor that combines that from the $lnVR$ (presented earlier) and the $lnVR$ (note again for dependent cases this is zero and so omitted) calculated as,
$$
CF = \frac{S^2_T}{2n M_T^2} - \frac{S^2_C}{2nM_C^2}
$$
The standard error of the $lnCVR_\text{dep}$ can be calculated as,
$$
\small{SE_{lnCVR_\text{dep}} = \sqrt{\frac{S^2_T}{n M_T^2} + \frac{S^2_T}{nM_T^2} + \frac{S^4_T}{2n^2 M_T^4} + \frac{S^4_T}{2n^2 M_T^4} + \frac{2rS_CS_T}{n M_C M_T} + \frac{r^2S^2_T S^2_C (M^4_T + M^4_C)}{2n^2M_T^4M^4_C}}}
$$
In R, we can simply use the metafor packages escalc() function as follows:
```{r}
# Example:
# Group 1: standard deviation = 4.5
# Group 2: standard deviation = 3.5
# Sample size = 50
# Correlation = 0.4
library(metafor)
# prepare the data
M1 <- 22.4
M2 <- 20.1
SD1 <- 4.5
SD2 <- 3.5
n <- 50
r <- 0.4
lnCVRdep <- escalc(
measure = "CVRC",
m1i = M1,
m2i = M2,
sd1i = SD1,
sd2i = SD2,
ni = n1,
ri = r
)
lnCVRdep$SE <- sqrt(lnCVRdep$vi)
# calculate confidence interval
lnCVRdep_low <- lnCVRdep$yi - 1.96*lnCVRdep$SE
lnCVRdep_high <- lnCVRdep$yi + 1.96*lnCVRdep$SE
# print the CVR value and confidence intervals
data.frame(lnCVRdep = MOTE::apa(lnCVRdep$yi),
lnCVRdep_low = MOTE::apa(lnCVRdep_low),
lnCVRdep_high = MOTE::apa(lnCVRdep_high))
```