squidgroup / squidSim

squidSim in tool for simulating data from multi-level/hierarchical models, including genetic, phylogenetic, temporal and spatial effects
Other
8 stars 0 forks source link

Sampling from population #21

Closed hallegue closed 2 years ago

hallegue commented 2 years ago

I'm trying to sample 25 individuals from simulated data of 100 individuals. However, the number of individuals sampled is different in each simulation.

library(squidSim)

sim_res <- simulate_population(

  data_structure = make_structure("individual(100)", repeat_obs=1),
  response_name = "Female",

  parameters = list(

    intercept = 0.19360,

    observation = list(
        names = c("Elo_score"),
        beta  = c(-0.11368)
      ),

    residual = list(
            vcov = 6.95e-10
          )
  ),

  family = "binomial", 
  link   = "logit",

  n_pop = 1,

  sample_type  = "nested",
  sample_param = cbind(individual=25, observation=1)
)

sample_data <- get_sample_data(sim_res, sample_set=1)
joelpick commented 2 years ago

I'm trying to work out the bug, but it seems to be whenrepeat_obs=1, so a quick fix is to have repeat_obs=2 and then observation=1 in sample_param

joelpick commented 2 years ago

fixed with 45b5c67