Skip to content

How to use arrays when constructing an age-structured model #213

Answered by kingaa
Chaofan13 asked this question in Q&A
Discussion options

You must be logged in to vote

@Chaofan13, your example very well demonstrates the inconvenience of having to treat every state variable, parameter, observable, and covariate by name when you supply basic model components to pomp as R functions. This illustrates one more advantage of the C snippet interface.

You've given us a lot to work with here, but it's a bit too much really. I'll illustrate how to write a C snippet to accomplish something similar, but simpler. Let's suppose we want to translate the following basic model components—which are written as R functions—into C snippets.

rinit_fn <- function (s1, s2, s3, e1, e2, e3, ...) {
  population <- 1e4
  S <- round(c(s1,s2,s3)*population)
  E <- round(c(e1,e2,e3)*p…

Replies: 1 comment 1 reply

Comment options

You must be logged in to vote
1 reply
@Chaofan13
Comment options

Answer selected by Chaofan13
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Category
Q&A
Labels
None yet
2 participants