Skip to contents

When a power or compromise analysis was performed in Spower this function can be used to update the compromise or power criteria without the need for re-simulating the experiment. For compromise analyses a beta_alpha criteria must be supplied, while for prospective/post-hoc power analyses the sig.level must be supplied.

Usage

# S3 method for class 'Spower'
update(object, sig.level = 0.05, beta_alpha = NULL, predCI = 0.95, ...)

Arguments

object

object returned from Spower where power was estimated or the bete_alpha criteria were supplied

sig.level

Type I error rate (alpha)

beta_alpha

Type II/Type I error ratio

predCI

confidence interval precision (see Spower for similar input)

...

arguments to be passed

Value

object of class Spower with updated information

Author

Phil Chalmers rphilip.chalmers@gmail.com

Examples

# \donttest{

########
## Prospective power analysis update

# Estimate power using sig.level = .05 (default)
out <- p_t.test(n = 50, d = .5) |> Spower()

# update power estimate given sig.level=.01 and .20
update(out, sig.level=.01)
#> 
#> Execution time (H:M:S): 00:00:02
#> Design conditions: 
#> 
#> # A tibble: 1 × 4
#>       n     d sig.level power
#>   <dbl> <dbl>     <dbl> <lgl>
#> 1    50   0.5      0.01 NA   
#> 
#> Estimate of power: 0.451
#> 95% Confidence Interval: [0.438, 0.459]
update(out, sig.level=.20)
#> 
#> Execution time (H:M:S): 00:00:02
#> Design conditions: 
#> 
#> # A tibble: 1 × 4
#>       n     d sig.level power
#>   <dbl> <dbl>     <dbl> <lgl>
#> 1    50   0.5       0.2 NA   
#> 
#> Estimate of power: 0.889
#> 95% Confidence Interval: [0.885, 1.000]


########
## Compromise analysis update

# Solve beta/alpha ratio to specific error trade-off constant
out <- p_t.test(n = 50, d = .5) |> Spower(beta_alpha = 2)

# update beta_alpha criteria without re-simulating
update(out, beta_alpha=4)
#> 
#> Execution time (H:M:S): 00:00:02
#> Design conditions: 
#> 
#> # A tibble: 1 × 5
#>       n     d sig.level power beta_alpha
#>   <dbl> <dbl>     <dbl> <lgl>      <dbl>
#> 1    50   0.5        NA NA             4
#> 
#> Estimate of Type I error rate (alpha/sig.level): 0.067
#> 95% Confidence Interval: [0.062, 0.072]
#> 
#> Estimate of power (1-beta): 0.732
#> 95% Confidence Interval: [0.723, 0.740]

# also works if compromise not initially run but prospective/post-hoc power was
out <- p_t.test(n = 50, d = .5) |> Spower()
update(out, beta_alpha=4)
#> 
#> Execution time (H:M:S): 00:00:02
#> Design conditions: 
#> 
#> # A tibble: 1 × 5
#>       n     d sig.level power beta_alpha
#>   <dbl> <dbl>     <dbl> <lgl>      <dbl>
#> 1    50   0.5        NA NA             4
#> 
#> Estimate of Type I error rate (alpha/sig.level): 0.065
#> 95% Confidence Interval: [0.061, 0.070]
#> 
#> Estimate of power (1-beta): 0.738
#> 95% Confidence Interval: [0.730, 0.747]

# }