lebebr01 / simglm

Simulate regression models
https://simglm.brandonlebeau.org/
Other
43 stars 12 forks source link

Interactions with Factors, more than 2 levels #72

Closed lebebr01 closed 4 years ago

lebebr01 commented 4 years ago

The following code throws an error due to incorrect number of factor variable interactions.

sim_arguments <- list(
  formula = y ~ 1 + sex + type + sex:type,
  fixed = list(sex = list(var_type = 'factor', levels=c('fem','male')),
               type = list(var_type = 'factor', levels = c('type1', 'type2', 'type3'))),
  error = list(variance = 0.2),
  sample_size = 150,
  reg_weights = c(0,0,1,2,0)    ## less parameters than previous example!
 # outcome_type = 'count'
)

simulate_fixed(data = NULL, sim_arguments)

Need to adapt factor_names() internally or add a new function for modification of variable names for factor variables of more than 2 levels.