Created
June 1, 2018 16:04
-
-
Save timcdlucas/9d8d29d7f9761dfcc7b139ca7c021609 to your computer and use it in GitHub Desktop.
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
# Assume just the first 16 parameters vary, but can do the same thing. | |
df <- | |
data.frame( | |
ad.surv.intercept=rep(0.0002516054, 16 * 2), | |
ad.surv.temp=0.1702, | |
ad.surv.pack=-0.1654, | |
disp.intercept=0.0064262, | |
disp.pack.size=0.10594, | |
#IBI.average=10.81 | |
#IBI.temp=1.02 | |
pup.intercept=0.87515, | |
pup.pack.size=0.04574, | |
juv.surv.intercept=18.61131, | |
juv.surv.temp=-0.70572, | |
juv.surv.litter=0.5482, | |
IBI.intercept=-17.25578, | |
IBI.tempcoef=0.91565, | |
IBI.pups=0.51976, | |
#sets my mean temperature (change temp) | |
meantemp=28.22864, | |
#the actual mean temperature at present | |
actual.meantemp=28.22864, | |
number.of.packs=9 | |
) | |
for(i in 1:(nrow(df) / 2)){ | |
df[i, i] <- 0.99 * df[i, i] | |
} | |
for(i in ((nrow(df) / 2) + 1) : nrow(df)){ | |
df[i, i - nrow(df) / 2] <- 0.99 * df[i, i - nrow(df) / 2] | |
} | |
#for 2 iterations (guessing you want 1000 because it's stochastic) | |
its <- 2 | |
df_big <- do.call(rbind, replicate(its, df, simplify = FALSE)) | |
tic() | |
results <- | |
lapply(1:nrow(df_big), function(x) | |
results = run_simulation(df_big[x, 1], | |
df_big[x, 2], | |
ad.surv.pack,disp.intercept,disp.pack.size,IBI.intercept,IBI.tempcoef,IBI.pups, | |
pup.intercept,pup.pack.size,juv.surv.intercept,juv.surv.temp,juv.surv.litter, | |
meantemp,actual.meantemp,number.of.packs,n.steps,repeats, burntime) | |
) | |
toc() | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment