sim_ordbeta | R Documentation |
This function allows you to calculate power curves (or anything else) via simulating the ordered beta regression model.
sim_ordbeta(
N = 1000,
k = 5,
iter = 1000,
cores = 1,
phi = 1,
cutpoints = c(-1, 1),
beta_coef = NULL,
beta_type = "continuous",
treat_assign = 0.5,
return_data = FALSE,
seed = as.numeric(Sys.time()),
...
)
N |
The sample size for the simulation. Include a vector of integers to examine power/results for multiple sample sizes. |
k |
The number of covariates/predictors. |
iter |
The number of simulations to run. For power calculation, should be at least 500 (yes, this will take some time). |
cores |
The number of cores to use to parallelize the simulation. |
phi |
Value of the dispersion parameter in the beta distribution. |
cutpoints |
Value of the two cutpoints for the ordered model. By default are the values -1 and +1 (these are interpreted in the logit scale and so should not be too large). The farther apart, the fewer degenerate (0 or 1) responses there will be in the distribution. |
beta_coef |
If not null, a vector of length |
beta_type |
Can be either |
treat_assign |
If |
return_data |
Whether to return the simulated dqta as a list
in the |
seed |
The seed to use to make the results reproducible. Set automatically to a date-time stamp. |
... |
Any other arguments are passed on to the brms::brm function to control modeling options. |
This function implements the simulation found in Kubinec (2022). This
simulation allows you to vary the sample size, number & type of predictors,
values of the predictors (or treatment values), and the power to target.
The function returns a data frame
with one row per simulation draw and covariate k
.
a tibble data frame with columns of simulated and estimated values and
rows for each simulation iteration X coefficient combination. I.e.,
if there are five predictors, and 1,000 iterations, the resulting data frame
will have 1,000 rows. If there are multiple values for N
,
then each value
of N
will have its own set of iterations, making the final size of the
data a multiple of the number of sample sizes to iterate over. The
data frame will have the following columns:
1.
# This function takes a while to run as it has
# to fit an ordered beta regression to each
# draw. The package comes with a saved
# simulation dataset you can inspect to see what the
# result looks like
data("sim_data")
library(dplyr)
# will take a while to run this
if(.Platform$OS.type!="windows") {
sim_data <- sim_ordbeta(N=c(250,750),
k=1,
beta_coef = .5,
iter=5,cores=2,
beta_type="binary",
treat_assign=0.3)
}
# to get the power values by N, simply summarize/group
# by N with functions from the R package dplyr
sim_data %>%
group_by(N) %>%
summarize(mean_power=mean(power))
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.