Skip to content

survey_sim(): manually specifying new survey designs results in errors #2

@luccoffeng

Description

@luccoffeng

If a user-defined survey design is created, survey_sim() will complain that it does not know the name (e.g., "NS_51") and terminate. Likewise, simulating an arbitrary number of pre-treatment days of sampling will result in an error. I'm not sure whether or why this level of error control is necessary.

Minimal working example:

# Prep session ----
rm(list = ls())

library(eggSim)
library(data.table)


# Set basic simulation parameters ----
species <- "hookworm"  # just a placeholder
T_E <- 0.98   # expected treatment efficacy
delta <- .05  # non-inferiority margin

scen <- as.data.table(survey_scenario(parasite = species)[1, ])
scen[, true_efficacy := T_E]

pars <- as.data.table(survey_parameters(design = c("NS_11"),
                                        parasite = species,
                                        method = "kk"))
pars <- pars[1]
pars[, min_positive_pre := 0]
pars[, min_positive_screen := 0]
pars[, efficacy_expected := T_E]
pars[, efficacy_lower_target := delta]
pars[, n_day_pre := 5]  # will trigger error about Invalid N_day_pre (does not match template)
# pars[, design := "NS_51"]  # uncomment to trigger error about unrecognised design


# Run simulations for non-inferiority trial----
test <- survey_sim(
  scenario = scen,
  parameters = pars,
  n_individ = 1e3,
  iterations = 100,
  cl = 10,
  output = "full",
  analysis = "delta",
  check_memory = TRUE
)

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions