Open joelpick opened 2 years ago
in internal_sim_func.R
## if factor make design matrix
x<-stats::model.matrix(stats::formula(paste("~ factor(",p$group,")-1")),as.data.frame(str_index))
should this be with data_structure
?
Example of problem
squid_dat <- simulate_population(
data_structure=make_structure("sex(2)",repeat_obs=100, level_names=list(sex=c("Male","Female"))),
parameters = list(
sex =list(
fixed=TRUE,
names = c("Male","Female"),
beta = c(0.5,0.3)
),
residual = list(
vcov = 0.3
)
)
)
dat <- get_population_data(squid_dat)
head(dat)
boxplot(y~sex,dat)
potential bug - if something is input as a fixed factor (fixed =TRUE in parameter list), the user can give names. If these were the same names as in the data_structure, there is no reference back to them in the code, so it would be easy for a user to put them in the wrong way round and the function wouldn't detect this, so the effects would be the wrong way in the generated data.
Also the default naming should be better. At the moment, it comes out as e.g. sex_effect1, sex_effect2. It would be much better if it linked back the names in the data_structure, so was sex_male and sex_female for example