This file contains hidden or 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
######### These are my attempts to incorporate McCann's models into R to help me interpret these food web models ###################### | |
library(deSolve) | |
### Section 2.2.5 | |
# parameters and state variables for the R-M model | |
r <- 1.0 # per capita rate of increase in resource | |
K <- 2.0 | |
e <- 0.7 | |
Ro <- 0.5 |
This file contains hidden or 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
## simulation of experiment | |
## to test patterns of randomization | |
## first set up the relationships | |
## volume is a uniform variable | |
n.mathoms <- 30 |
This file contains hidden or 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
## a simulation of detecting effect size on gall parasitisim rates | |
## and occupancy. | |
## basically ask: how many larvae are in each gall (poisson) | |
## how many samples do you need to see the difference? | |
## | |
#first, a homemade function for the Zero-Inflated Negative Binomial distribution | |
rzinbinom <- function(n,mu,size,zprob){ | |
ifelse(runif(n)<zprob,0,rnbinom(n,mu=mu,size=size)) | |
} |
This file contains hidden or 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
# by Andrew MacDonald Nov 2011 | |
## please add your own tips and tricks! | |
## the idea here is to demonstrate how for loops are used | |
## and then immediately demonstrate how they can be avoided. | |
## we'll begin by creating a fake dataset. | |
## This experiment is a 3x3 factorial with 2 replicates of each treatment combination. | |
## The scientist applied nitrogen and phosphorous to the soil | |
## then she measured two responses: plant growth and seed production. |
NewerOlder