Publications by Tony Cookson
How to Bootstrap in R: The Case of R-squared
I recorded a new video tutorial whose original intent was to demonstrate how to write a for loop. As I wanted to make the for loop count for something, I decided that my application would be to write some code that computes the bootstrap approximation to the sampling distribution. This is a common econometric application. Here is the ...
1172 sym 8 img
How to Shade Under a Normal Density in R
The easiest-to-find method for shading under a normal density is to use the polygon() command. That link is to the first hit on Google for “Shading Under a Normal Curve in R.” It works (like a charm), but it is not the most intuitive way to let users produce plots of normal densities. In response to the standard polygon() approach...
1307 sym 8 img
How did I make this plot?
To make this plot, I used R’s plot(), points() and lines() commands. If you have been wanting to learn how to plot in R, watch it unfold in this video tutorial:Also, here’s the code I used: Related To leave a comment for the author, please follow the link and comment on their blog: Coffee and Econometrics in the Morning. R-bloggers.com o...
613 sym 10 img
Video Tutorial on IV Regression
Update: [1 May 2011] I am working on a better augmentation of the current IV regression functions (specifically ivreg() in AER) in R. I will post a link here to my new method/function for IV regression when I finish debugging the code.Update 2: [15 May 2011] The function I wrote here does not work with factors due to the way in which I construct...
2046 sym 2 img
Video Tutorial on Robust Standard Errors
Update: I have included a modified version of this summaryR() command as part of my package tonymisc, which extends mtable() to report robust standard errors. The tonymisc package is available on CRAN through the install.packages() command.If you have the right R commands at your disposal, it is simple to correct for heteroskedasticity using the...
1577 sym 2 img
Computing Statistical Power
Today’s task is to compute a statistical power function in R. For a good definition of power, go here. Thinking about the power of a testing procedure is an often-overlooked aspect of hypothesis testing.I also explain what power (in a statistical sense) is in the video, as well as use my shadenorm() function to show what power look...
1240 sym 2 img
A Creative Use of R
Update (5/18/2011): Looks like Freakonomics approves as well. Let the record show that I approved first 🙂I approve: “I use the open-source program R to create the patterns.”But, I’m not sure I approve of calling these distributions “evil.”In case you were wondering, here are the commands to create the density plots for these “evil...
953 sym 4 img
A Population Regression
Here’s a video on some of the theory behind simple linear regression.There’s no R involved with this video, but the video provides some theory behind what it is that R’s lm() command estimates. Related To leave a comment for the author, please follow the link and comment on their blog: Coffee and Econometrics in the Morning. ...
626 sym 2 img
Common Data Creation Commands
Here is a video tutorial where I go through some of the most commonly used commands in creating and manipulating data. As soon as I want to do more than just running a single regression, I use these commands more than any other set of commands (in some of the other videos, you may have seen these).Here is the code I use in the video ...
826 sym 2 img
Good Looking Maps in R
I haven’t yet tried this, but it looks like a nice package.In one recent project I needed to draw several maps and visualize different kinds of geographical data on it. I found the combination of R/ggplot/maps package extremely flexible and powerful, and produce nice looking map based visualizations. Here is a short tutorial, mo...
905 sym 2 img