Monte-Carlo Methods
Introduction
Monte-Carlo methods refer to running portions or all of the modeling process over and over again using random variation to help understand the nature and robustness of our models.
Monte-Carlo is often reduce to "MC" and sometimes, incorrlectly, to MCMC. MCMC stands for Monte-Carlo Marcov Chains and since we do not use Marcov Chains in the models on this web site, we'll just use MC.
Check out our section on loops if you are not familiary with loops in R.
MC in R
A simple example would be to take one of our GAM models and try different values for gAMM
Gammas=seq(1,20,by=1) # setup a sequence of values for gamma AICs=vector() # setup a vector to contain the AIC values Count=1 while (Count<=length(Gammas)) # go through all the gamma values { # the family is gaussian by default but the gamma should be changed from 1 to smooth TheModel=gam(MaxHt~s(MaxTemp)+s(MinTemp)+s(Precip),data=TheData,gamma=Gammas[Count]) # get the AIC value and add it to the vector for all AIC values TheAIC=AIC(TheModel) AICs=c(AICs,TheAIC) Count=Count+1 # move to the next gamma value }