sim_pow_glm_single: Function to simulate power.

Description Usage Arguments Details See Also

View source: R/pow_sim_glm.r

Description

Input simulation conditions and which term to compute power for, export reported power.

Usage

1
2
3
4
5
6
sim_pow_glm_single(fixed, fixed_param, cov_param, n, data_str,
  cor_vars = NULL, fact_vars = list(NULL), contrasts = NULL,
  outcome_type, knot_args = list(NULL), missing = FALSE,
  missing_args = list(NULL), pow_param = NULL, alpha,
  pow_dist = c("z", "t"), pow_tail = c(1, 2), glm_fit_mod = NULL,
  glm_fit_family, general_mod = NULL, general_extract = NULL, ...)

Arguments

fixed

One sided formula for fixed effects in the simulation. To suppress intercept add -1 to formula.

fixed_param

Fixed effect parameter values (i.e. beta weights). Must be same length as fixed.

cov_param

List of arguments to pass to the continuous generating function, must be the same order as the variables specified in fixed. This list does not include intercept, time, factors, or interactions. Required arguments include:

  • dist_fun: This is a quoted R distribution function.

  • var_type: This is the level of variable to generate. Must be 'single'. Must be same order as fixed formula above.

Optional arguments to the distribution functions are in a nested list, see the examples or vignettes for example code.

n

Cluster sample size.

data_str

Type of data. Must be "cross", "long", or "single".

cor_vars

A vector of correlations between variables.

fact_vars

A nested list of factor, categorical, or ordinal variable specification, each list must include:

  • numlevels: Number of levels for ordinal or factor variables.

  • var_type: Must be 'single'.

Optional arguments include:

  • replace

  • prob

  • value.labels

See also sample for use of these optional arguments.

contrasts

An optional list that specifies the contrasts to be used for factor variables (i.e. those variables with .f or .c). See contrasts for more detail.

outcome_type

A vector specifying the type of outcome, must be either logistic or poisson. Logitstic outcome will be 0/1 and poisson outcome will be counts.

knot_args

A nested list of named knot arguments. See sim_knot for more details. Arguments must include:

  • var

  • knot_locations

missing

TRUE/FALSE flag indicating whether missing data should be simulated.

missing_args

Additional missing arguments to pass to the missing_data function. See missing_data for examples.

pow_param

Name of variable to calculate power for, must be a name from fixed.

alpha

What should the per test alpha rate be used for the hypothesis testing.

pow_dist

Which distribution should be used when testing hypothesis test, z or t?

pow_tail

One-tailed or two-tailed test?

glm_fit_mod

Valid glm syntax to be used for model fitting.

glm_fit_family

Valid family syntax to pass to the glm function.

general_mod

Valid model syntax. This syntax can be from any R package. By default, broom is used to extract model result information. Note, package must be defined or loaded prior to running the sim_pow function.

general_extract

A valid function to extract model results if general_mod argument is used. This argument is primarily used if extracting model results is not possibly using the broom package. If this is left NULL (default), broom is used to collect model results.

...

Additional specification needed to pass to the random generating function defined by with_err_gen.

Details

Power function to compute power for a regression term for simple generalized regression models. This function would need to be replicated to make any statement about power. Use sim_pow_glm as a convenient wrapper for this.

See Also

sim_pow_glm for a wrapper to replicate.


simglm documentation built on Jan. 24, 2019, 1:04 a.m.