As I am finishing up my thesis I have recently been plotting effects from many models. An important aspect of this is to show the uncertainty surrounding different estimates and effects. Following a paper by Gary King, Michael Tomz and Jason Wittenberg it has become very popular among quants in political science to simulate the uncertainty rather than relying on the delta method. They take advantage of the fact that the central limit theorem show that with a large enough sample and bounded variance it is possible to simulate parameter values by drawing from a multivariate normal distribution. The means are set equal to the estimated parameters and variance equal to the variance-covariance matrix from the model.

Stata users have access to the excellent Clarify module from Gary King and colleagues which implements their approrach, however since I am doing most of my work in R this is not an option. King and friends have implemented much of the same functionality in the Zelig package for R, but I find extracting exactly what I want from objects created by Zelig to be a chore. Luckily it is very easy to implement this on your own in R. The approach advocated by King and colleagues follows a 5 step process:

- Simulate the parameters
- define the values at which the variables are held constant
- Calculate the systematic component of model for each round of simulated parameters
- Use the systematic component to calculate your quantity of interest
- repeat step 1-4 a 1000 times, or until you have the desired degree of accuracy

Here I will show how to do this for a logit model. I first generate some fake data, and then go through the above steps. Finally I plot the effects with uncertainty using ggplot2.

Based on the above R script, we get the following plot of the effect and uncertainty surrounding the effect of the variable V3:

*Related*

To

**leave a comment** for the author, please follow the link and comment on their blog:

** The PolStat Feed**.

R-bloggers.com offers

**daily e-mail updates** about

R news and

tutorials on topics such as:

Data science,

Big Data, R jobs, visualization (

ggplot2,

Boxplots,

maps,

animation), programming (

RStudio,

Sweave,

LaTeX,

SQL,

Eclipse,

git,

hadoop,

Web Scraping) statistics (

regression,

PCA,

time series,

trading) and more...

If you got this far, why not

__subscribe for updates__ from the site? Choose your flavor:

e-mail,

twitter,

RSS, or

facebook...