Created
September 14, 2012 12:52
-
-
Save aaronberdanier/3721746 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
t <- 10 # number of times | |
n <- 100 # number of individuals 'n' | |
x <- rnorm(t,0,1) # environmental variable 'x' | |
mu <- 4 # average survival response to 'x' | |
s <- 2 # variation among individuals in survival response to 'x' | |
b0 <- 1.5 | |
beta <- rnorm(n,mu,s) # survival response for individual to 'x' | |
# deterministic survival probabilty for each individual at each time | |
theta <- exp(b0+x%*%t(beta))/(1+exp(b0+x%*%t(beta))) | |
# simulated data for the population | |
y <- matrix(rbinom(n*t,1,theta),nrow=t) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment