Skip to content

How to have N0 be a parameter in the input data frame? #14

@atyre2

Description

@atyre2

If I want to run scenarios where N0 varies, right now I have to run iterate separately for each, because N0 is passed to iterate as a parameter, not inside the dataframe.

inputs <- crossing(
  r = 0.205,
  sigma = 0.06,
  K = c(20, 30, 40),
  lambda = c(1, 2),
  rep = 1:2,
  t = 1:3
) %>% 
  mutate(
    N = case_when(t == 1 ~ K,
                  TRUE ~ NA_real_),
    H = rpois(n(), lambda),
    r = r + rnorm(n(), 0, sigma)
  )

discrete_theta_logistic <- function(N0, r, K, theta, H){
  N1 <- N0 * exp(r*(1-(N0/K)^theta)) - H
}
iterate(inputs) # this won't work
iterate(inputs, N0 = K) # this is what I want, but won't work

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions