I'm trying to perform a sensitivity power analysis in R with clmm2.
I'm building off the code from this post (Trying to use tidy for a power analysis and using clmm2) but am running into issues with inputting desired beta estimates into the model.
Here's the two functions to run the power analysis in tidy format
# Tidy function
tidy_output_clmm = function(fit){
results = as.data.frame(coefficients(summary(fit)))
colnames(results) = c("estimate","std.error","statistic","p.value")
results %>% tibble::rownames_to_column("term")
}
# Simulate function
sim_experiment_power <- function(rep) {
idx = sample(nrow(wine),replace=TRUE)
model <- clmm2(rating ~ temp, random=judge, data=wine[idx,], nAGQ=10,Hess=TRUE)
tidy_output_clmm(model) %>% mutate(rep=rep)
}
# Run simulation
my_power <- map_df(1:100, sim_experiment_power)
# Examine proportion of significant models
my_power %>% group_by(term) %>% summarise(power = mean(p.value < 0.05))
However, I want to input beta estimates into my model before I simulate power so that I can understand how sensitive the data is to detect this effect.
# Add something like this to the above sim_experiment_power function
model$beta["temp"] <- 0.05
Does anyone have suggestions on how to add this to the function?