Description Usage Arguments Details Value Notes Author(s) References Examples
Perform a safeguard power analysis starting from a Cohen's d effect size (assuming a two samples t-test) or from a Pearson correlation coefficient. It is also possible to perform the analysis by starting from the data, if these are available.
1 2 3 4 5 | safeguard.d(d, n.1, n.2, sig.level = .05, power = .8, conf = .80)
safeguard.d2(m.1, m.2, sd.1, sd.2, n.1, n.2, sig.level = .05, power = .8, conf = .80)
safeguard.d.data(x, y, sig.level = .05, power = .8, conf = .80)
safeguard.r(r, n, sig.level = .05, power = .8, conf = .80)
safeguard.r.data(x, y, sig.level = .05, power = .8, conf = .80)
|
x |
A vector of data |
y |
A vector of data |
d |
Standardized mean difference (Cohen's d) |
m.1 |
The mean value of the group 1 |
m.2 |
The mean value of the group 2 |
sd.1 |
The standard deviation of the group 1 |
sd.2 |
The standard deviation of the group 2 |
r |
Pearson's correlation coefficient |
n |
Sample size of the original study |
n.1 |
Sample size for group 1 of the original study |
n.2 |
Sample size for group 2 of the original study |
sig.level |
Significance level (Type I error probability or alpha) |
power |
Power of the test (1 minus Type II error probability or 1 minus beta) |
conf |
Power of the test (1 minus Type II error probability or 1 minus beta)One-tailed confidence interval for computing the safeguard effect size, defaults to .80. It is required that .5 < conf < 1. |
Function safeguard.d
computes the safeguard effect size (ds) as the lower limit of the specified confidence interval of d
, subsequently a power analysis is performed using ds as input, as well as sig.level
and power
, to get the safeguard sample size. Function safeguard.d2
is a wrapper for safeguard.d
that allows to specify the means and the standard deviations of the two groups instead of the Cohen's d. Function safeguard.r
takes as input the Pearson's correlation coefficient instead of the Cohen's d. Functions safeguard.d.data
and safeguard.r.data
are wrappers for safeguard.d2
and safeguard.r
respectively. They accept the data as input and are especially useful for post-hoc safeguard power analysis, when the original data are available.
A vector of three elements is returned.
Lower_d |
The safeguard effect size. ( |
N_required |
The safeguard sample size (ns) required for the replication study (in |
.
SSR |
The safeguard sample ratio of the original study, namely the ratio of the safeguard sample size over the original sample size, |
If the safeguard effect size has the opposite sign of the original effect size the functions return a warning (this happens if the original effect size is significant at a certain p-level, one tailed, but conf
is higher than one minus that p-level): should this happen, we suggest to lower the value of conf
. Moreover in some situations it may happen that the value of the safeguard effect size is too high or too low to compute the exact value of the safeguard sample size. When the safeguard effect size is close to zero the N_required
is set to Inf
, while when it is much higher than zero the N_required
is set to 2 (i.e., the minimum possible value for a sample size). In these situations, warning messages are returned.
Giulio Costantini (giulio.costantini@unimib.it)
Perugini, M., Gallucci, M., Costantini, G. (in preparation) Safeguard Power as a Protection Against Imprecise Power Estimates
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 | # Most of the examples are taken from the main paper.
# Notice that all of the functions presented here require the one-tailed
# confidence interval as input (parameter conf). For the examples that consider
# the effect size of the differences of two means in two independent groups
# (safeguard.d and safeguard.d2), the total sample size is split in two equal
# groups, n.1 and n.2.
library(pwr)
library(MBESS)
# Safeguard power analysis for Cohen's d = .80 and n = 50.
# To mirror the example in the main text, that considers a CI 95% two-tailed,
# we specify as input the corresponding one-tailed CI, conf = .975.
safeguard.d(d = .8, n.1 = 25, n.2 = 25, sig.level = .05, power = .8,
conf = 0.975)
# the same analysis using safeguard.d2, i.e., specifying a value for the means
# and for the pooled SD. We used means of 1.8 and 1, with a pooled SD of 1 to
# get an effect size of d = .8
safeguard.d2(m.1 = 1.8, m.2 = 1, sd.1 = 1, sd.2 = 1, n.1 = 25, n.2 = 25,
conf = .975)
# The safeguard sample sizes the Table 1 of the paper can be reproduced with
# function safeguard.d by varying the values of d, n and conf. Here an example
# with a sample of 20 (two groups of 10), effect size .5 and one-tailed
# confidence inteval of .80
safeguard.d(d=.5, n.1=10, n.2=10, conf=.80)
#The examples discussed in the text, about evaluating empirical evidence.
safeguard.d(d = .5, n.1 = 30, n.2 = 30)
safeguard.d(d = .5, n.1 = 90, n.2 = 90)
# Some cases considered in the paper in which the SSR is one.
safeguard.d(d = .5, n.1 = 91, n.2 = 91)
safeguard.d(d = .8, n.1 = 37, n.2 = 37)
safeguard.d(d = 1, n.1 = 24, n.2 = 24)
safeguard.d(d = 1.5, n.1 = 12, n.2 = 12)
#The examples in Table 3
safeguard.d(d = .7, n.1 = 25, n.2 = 25)
safeguard.d(d = .7, n.1 = 100, n.2 = 100)
safeguard.d(d = 1, n.1 = 15, n.2 = 15)
safeguard.d(d = 1.5, n.1 = 10, n.2 = 10)
safeguard.d(d = .4, n.1 = 40, n.2 = 40)
# an example of usage of the function safeguard.r
safeguard.r(r = .4, n = 100, sig.level = .05, power = .8, conf = .80)
# an example of the usage of safeguard.d.data
set.seed(100)
x <- rnorm(n = 50, mean = 1, sd = 1)
y <- rnorm(n = 50, mean = 2, sd = 1)
safeguard.d.data(x,y)
# an example of the usage of safeguard.r.data
set.seed(100)
x <- rnorm(n = 100, mean = 1, sd = 1)
y <- x + rnorm(n = 100, mean = 1, sd = 1)
safeguard.r.data(x,y)
|
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.