Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

add continuous traits #36

Open
goldingn opened this issue Jun 7, 2016 · 2 comments
Open

add continuous traits #36

goldingn opened this issue Jun 7, 2016 · 2 comments

Comments

@goldingn
Copy link
Owner

goldingn commented Jun 7, 2016

This will enable age- or size-structured models, like IPMs.

This requires:

  • clean, unambiguous transition formula syntax
  • a trait transition function (based around a probability density function)
  • construction of expanded matrices (deterministic) and population dataframes (stochastic) with bins within the state
  • tidy representation of the trait-bins in plotting

Initially this can just be a single trait, but possible to allow multiples (representing all combinations of bins for each trait as separate bins)

@goldingn
Copy link
Owner Author

goldingn commented Jun 7, 2016

This is the preferred formula syntax, for:

  1. moving to a new stage with a trait
(size | juvenile) ~ adult
  1. changing trait within a stage
(size | juvenile) ~ (size | juvenile)
  1. moving from a stage with a trait to one without
adult ~ (size | larvae)
  1. moving between two stages with traits
(size | adult) ~ (size | larvae)

will need to parse these cleanly, and use trait density (need a better name than that) transfuns for 1, 2, and 4. I.e. anything with a trait on the LHS (can just use the population vector for the RHS)

@goldingn
Copy link
Owner Author

goldingn commented Jun 7, 2016

Code to parse these, with or without braces:

stripBraces <- function (x) {
  if (as.character(x[[1]]) == '(') {
    x <- x[[2]]
    x <- stripBraces(x)
  }
  return (x)
}
getStage <- function (f, which = c('to', 'from')) {
  which <- match.arg(which)
  x <- switch(which,
              to = f[[2]],
              from = f[[3]])
  if (length(x) == 1) {
    stage <- as.character(x)
  } else {
    x <- stripBraces(x)
    if (length(x) == 3 &
               as.character(x[[1]]) == '|') {
      stage <- as.character(x[[3]])
      attr(stage, 'trait') <- as.character(x[[2]])
    } else {
      stop ('cannot parse transition formula')
    }
  }
  return (stage)
}

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant