Run a power analysis
powr.Rd
This is a wrapper function for running a power analysis on iterative simulation and reconstruction methods process.
Arguments
- output
the resulting data frame from the iterative methods process
- sig.level
numeric. the desired level of significance to achieve
- power
numeric. the desired level of power to achieve
- delta
numeric. the desired effect size to achieve
- n
integer. the number of replicates/sample size. should be assigned
NULL
if desiring sample size
Examples
# Use powr wrapper function on example results
library(sporeg)
library(dplyr)
library(data.table)
load(system.file("extdata", "results.Rda", package = "sporeg"))
results <- lapply(results, data.table::rbindlist, idcol = 'resolution')
results <- data.table::rbindlist(results, idcol = 'iteration') %>%
left_join(tibble(resolution = 1:4,
res_name = c("100km", "50km", "25km", "10km")),
by = "resolution")
df_var <- zero_var(results)
pow_stat <- df_var %>%
dplyr::group_by(res_name, gid) %>%
dplyr::summarise(sd = sd(dif)) %>%
dplyr::ungroup() %>%
dplyr::group_by(res_name)
#> `summarise()` has grouped output by 'res_name'. You can override using the
#> `.groups` argument.
res <- pow_stat %>% dplyr::filter(res_name == "100km")
anims <- 30
power <- 0.8
delta <- anims*0.01 # a delta within 1% of the total number of animals
sig.level <- 0.95
n <- NULL
pwr_100km <- powr(res, sig.level, power, delta)
print("Grid cell resolution: 100 km x 100 km")
#> [1] "Grid cell resolution: 100 km x 100 km"
pwr_100km
#>
#> Paired t test power calculation
#>
#> n = 118.3773
#> delta = 0.3
#> sd = 3.609324
#> sig.level = 0.95
#> power = 0.8
#> alternative = two.sided
#>
#> NOTE: n is number of *pairs*, sd is std.dev. of *differences* within pairs
#>