sdmTMB icon indicating copy to clipboard operation
sdmTMB copied to clipboard

Append threshold covariates to simulated data

Open ericward-noaa opened this issue 1 year ago • 0 comments

In this example, sim_dat includes 'a1' -- but not 'a2'


  predictor_dat <- data.frame(
    X = runif(300), Y = runif(300),
    a1 = rnorm(300), a2 = rnorm(300), year = rep(1:6, each = 50)
  )
  mesh <- make_mesh(predictor_dat, xy_cols = c("X", "Y"), cutoff = 0.1)

  sim_dat <- sdmTMB_simulate(
    formula = ~ 1 + a1 + I(a1^2) + breakpt(a2),
    data = predictor_dat,
    time = "year",
    mesh = mesh,
    family = gaussian(),
    range = 0.5,
    sigma_E = 0.1,
    phi = 0.01,
    sigma_O = 0.2,
    seed = 42,
    threshold_coefs = c(0.4, 0),
    B = c(0.2, -0.4,-0.03) # B0 = intercept, B1 = a1 slope
  )
  sim_dat$a2 <- predictor_dat$a2

ericward-noaa avatar Aug 01 '22 21:08 ericward-noaa