# Using-metapower

library(metapower)

## Computing Meta-analytic Power

Suppose that we plan to meta-analyze all published findings to compute a summary effect size estimate for the group difference between typically developing individuals and individuals with autism on a measure of face recognition ability. In order to plan the study accordingly, we must choose plausible values for the following:

1. Expected effect size
2. Expected sample size per group
3. Expected number of studies

for our meta-analysis of face recognition deficits in autism

1. We expect that face recognition deficits in ASD are small (Cohen’s d = 0.2)
2. Sample sizes in autism research are generally small. We expect the average group size to be 20.
3. Face recognition is frequently studied in autism; therefore, we expect to find 10 studies.

To do this with metapower, we use the core function mpower()

my_power <- mpower(effect_size = .2, sample_size = 20, k = 10, es_type = "d")
print(my_power)
#>
#>  Power Analysis for Meta-analysis
#>
#>  Expected Effect Size:              0.2
#>  Expected Sample Size (per group):  10
#>  Expected Number of Studies:        10
#>
#>  Estimated Power: Mean Effect Size
#>
#>  Fixed-Effects Model                0.2917841
#>  Random-Effects Model (i2 =  0% ):  0.2478379
#>  Random-Effects Model (i2 = 25% ):  0.2328637
#>  Random-Effects Model (i2 = 50% ):  0.1982394
#>  Random-Effects Model (i2 = 75% ):  0.1446749

The first part of the output shows the expected input values, where the main results are shown in the bottom portion, mainly, Estimated Power. Under this set of values, our power to detect a mean difference under a Fixed-Effects model is 29.18%. Furthermore, we can look at the power under a Random-Effects model under various heterogeneity levels (e.g., Low, Moderate, Large). For the output regarding Estimated Power: Test of Homogeneity, please see below

Given that power analysis require a lot of assumptions, it is generally advisable to look at power across a range of input values. To visualize the power curve for these set of input parameters, use plot_mpower() to generate a ggobject that is modifiable and by default, shows 5x as many studies as the user inputs.

plot_mpower(my_power)

For fixed-effects model, power curves are shown for a range of effect sizes, whereas random-effects model shows power across a range of heterogeneity values, $$\tau^2$$

For users wanting more flexibility in visualization, the mpower object contains a data frame $power_range containing all data populating the ggobject, str(my_power$power_range)
#> 'data.frame':    147 obs. of  12 variables:
#>  $k_v : int 2 3 4 5 6 7 8 9 10 11 ... #>$ es_v           : num  0.1 0.1 0.1 0.1 0.1 0.1 0.1 0.1 0.1 0.1 ...
#>  $effect_size : num 0.2 0.2 0.2 0.2 0.2 0.2 0.2 0.2 0.2 0.2 ... #>$ n_v            : num  10 10 10 10 10 10 10 10 10 10 ...
#>  $c_alpha : num 1.96 1.96 1.96 1.96 1.96 ... #>$ test_type      : chr  "two-tailed" "two-tailed" "two-tailed" "two-tailed" ...
#>  $variance : num 0.2 0.2 0.2 0.2 0.2 ... #>$ fixed_power    : num  0.0615 0.0673 0.0732 0.0791 0.085 ...
#>  $random_power_0 : num 0.047 0.0508 0.0556 0.0607 0.066 ... #>$ random_power_25: num  0.0726 0.0732 0.076 0.0795 0.0833 ...
#>  $random_power_50: num 0.114 0.105 0.102 0.101 0.1 ... #>$ random_power_75: num  0.183 0.149 0.131 0.119 0.111 ...

## Power for the Test of Homogeneity

For Fixed-Effects Model, the test of homogeneity examines whether the amount of variation among effect sizes is greater than that of sampling error alone. To compute this, simply wrap the same arguments used in mpower with homogen_power. Since it is hard to justify selecting the standard deviation between a set of studies, homogen_power() automatically computes power across a range of different standard deviation values (i.e., SD = 1, SD = 2.)

(homogen_test_power <- homogen_power(effect_size = .25, sample_size = 20, k = 30, es_type = "d"))
#>
#>  Power Analysis for Test of Homogeneity in Meta-analysis
#>
#>  Expected Effect Size:              0.25
#>  Expected Sample Size (per group):  10
#>  Expected Number of Studies:        30
#>
#>  Estimated Power: Test of Homogeneity
#>
#>  Fixed-Effects Model (SD = 1)        0.06687224
#>  Fixed-Effects Model (SD = 2)        0.1348743
#>  Fixed-Effects Model (SD = 3)        0.2966788
#>  Fixed-Effects Model (SD = 4)        0.55878
#>  Fixed-Effects Model (SD = 5)        0.8167712
#>
#>  Random-Effects Model (i2 =   0% ):  0.05
#>  Random-Effects Model (i2 =  25% ):  0.2941892
#>  Random-Effects Model (i2 =  50% ):  0.9670784
#>  Random-Effects Model (i2 =  75% ):  0.999998

For Random-Effects models, homogen_power() computes power across a range of possible heterogeneity values (i.e., $$I^2$$)

1. $$I^2$$ = 0% (No Heterogeneity)
2. $$I^2$$ = 25% (Low Heterogeneity)
3. $$I^2$$ = 50% (Moderate Heterogeneity)
4. $$I^2$$ = 75% (Large Heterogeneity)

We can visualize this across a range with plot_homogen_power

plot_homogen_power(homogen_test_power)

## Example 2: Power analysis for moderation analysis (categorical variables)

Although researchers are primarily interested in conducting meta-analysis to quantify the main effect of a specific phenomenon, It is very common to evaluate the moderation of this overall effect based on a number of study- and/or sample-related characteristics such as task paradigm or age group (e.g., children, adolescents, adults). To compute the statistical power for the detection of categorical moderators, we use the function subgroup_power() with a few additional arguments, mainly:

1. Expected number of groups (n_groups):
2. Expected effect size of each group(effect_sizes):

for our meta-analysis of face recognition deficits in autism

We may expect that face recognition tasks have larger effect sizes then face perception tasks; therefore, we specify 2 groups and their respective expected effect sizes:

1. n_groups = 2
2. effect_sizes = c(.2,.5)
my_mod <- subgroup_power(n_groups = 2,
effect_sizes = c(.2,.5),
sample_size = 20,
k = 30,
es_type = "d")
print(my_mod)
#>
#>  Power Analysis for Subgroup analysis:
#>
#>  Number of Groups:                  2
#>  Groups:
#>  Expected Effect Sizes:             0.2 0.5
#>  Expected Sample Size (per group):  10
#>  Expected Number of Studies:        30
#>
#>  Esimated Power to detect subgroup differences
#>
#>  Fixed-Effects Model:                  0.4456862
#>  Random-Effects Model (i2 = 0%):       0.4456862
#>  Random-Effects Model (i2 = 25%):      0.3517928
#>  Random-Effects Model (i2 = 50%):      0.2517633
#>  Random-Effects Model (i2 = 75%):      0.1492777

Given, this set of expected values, we have 44.57% to detect between-group differences under a Fixed-Effects model. As expected, moderator effects are much harder to detect and more studies are required, especially when heterogeneity is high.