Skip to content

Instantly share code, notes, and snippets.

@aaronberdanier
Created September 14, 2012 12:52
Show Gist options
  • Save aaronberdanier/3721746 to your computer and use it in GitHub Desktop.
Save aaronberdanier/3721746 to your computer and use it in GitHub Desktop.
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