Simulation metamodeling with GNU R
Want to share your content on R-bloggers? click here if you have a blog, or here if you don't.
I am one of the organizers of ESSA2013 conference that will take place in September 2013 in Warsaw, Poland. The conference scope is social simulation and in particular methods of statistical analysis of simulation output (metamodeling). As we have just issued Call for Papers for the conference so I decided to post a simple example of a metamodel.
Recently I had to calculate variance of a random variable given as:
where p and N are model parameters and q is a random variable that has binomial distribution with N Bernoulli trials and probability of success 2-p. After some lengthily calculations I came up with the following formula for the variance:
However the result is so long that I was not sure that it was correct, so I decided to verify it using metamodeling.
First I have generated the data for the simulation with the following code and visualized it. The data covers a grid where p is from interval [1;2] and N spans from 1 to 10. In each grid point 100000 simulations are performed and variance of q(p-2+q/N) is calculated:
Here is the resulting plot:
Next I have estimated the linear regression model with parameters reflecting analytical specification given above:
The output looks as follows:
As we can see the model fit is almost perfect and the estimates are very close to analytical results. This reassured me that my calculation was correct.
In this way you could use simulation to verify analytical results. Of course simulation metamodeling has much broader applications – especially when we do not have analytical results.
I hope to organize a special session during ESSA2013 dedicated to simulation metamodeling using GNU R. So if you are interested in such topics and willing to promote GNU R in simulation society you are welcome to come to Warsaw.
R-bloggers.com offers daily e-mail updates about R news and tutorials about learning R and many other topics. Click here if you're looking to post or find an R/data-science job.
Want to share your content on R-bloggers? click here if you have a blog, or here if you don't.