tag:blogger.com,1999:blog-2198942534740642384.post2809266709481290462..comments2023-10-24T03:16:41.009-07:00Comments on Econometrics Beat: Dave Giles' Blog: Illustrating Asymptotic Behaviour - Part IDave Gileshttp://www.blogger.com/profile/05389606956062019445noreply@blogger.comBlogger2125tag:blogger.com,1999:blog-2198942534740642384.post-36262725795459393162016-07-23T05:16:49.752-07:002016-07-23T05:16:49.752-07:00very useful to understand the concept of consisten...very useful to understand the concept of consistencyDr.K.Dhanasekaranhttps://www.blogger.com/profile/15038889931233353679noreply@blogger.comtag:blogger.com,1999:blog-2198942534740642384.post-61791819386217638972014-10-18T13:52:46.584-07:002014-10-18T13:52:46.584-07:00Hi,
Thanks for this very helpful entry. In my cl...Hi, <br /><br />Thanks for this very helpful entry. In my class I also use a similar MC experiment to demonstrate the consistency of the OLS estimator of the AR(1) process. I use STATA and I thought it may be helpful for those are interested in STATA programming. So here is the code with the same DGP and parameter values. (PS: I admit that there may be more elegant ways of coding this :))<br /><br />// Consistency of OLS estimator of AR(1) model<br /><br />clear<br />capt prog drop arols<br />program arols, rclass<br /> version 12<br /> syntax [, N(int 50), burnin(int 100)]<br /> drop _all<br /> set obs `n'<br /> gen double u = -1 + 2*runiform() // random error, from U(-1,1) <br /> gen y = 0<br /> replace y = 1 + 0.5*y[_n-1] + u in 2/`n'<br /> drop in 1/`burnin'<br /> gen t = _n<br /> tsset t <br /> reg y l.y<br /> ret sca b1 =_b[_cons]<br /> ret sca b2 =_b[l.y]<br />end<br /><br />graph drop _all<br />glo numsim = 5000<br />local burnin = 200<br />foreach T of numlist 20 100 250 1000 5000 {<br />local n = `burnin' + `T'<br />simulate ARpar`T'=r(b2), ///<br /> reps($numsim) saving(OLSMC`T', replace) nolegend nodots: ///<br /> arols, n(`n') burnin(`burnin') <br /> hist ARpar`T', normal name(n`T') title("AR(1) Parameter: n=`T'")<br />}<br />clear<br />use OLSMC20<br />foreach T of numlist 100 250 1000 5000{<br />merge using OLSMC`T'<br />drop _merge<br />}<br />sum<br />tw (kdensity ARpar20) (kdensity ARpar100) (kdensity ARpar250) (kdensity ARpar1000) (kdensity ARpar5000)<br /><br /><br />The code above draws the kernel density estimates similar to the last graph in your post. Also here are the summary statistics: <br /><br /><br /> Variable | Obs Mean Std. Dev. Min Max<br />-------------+--------------------------------------------------------<br /> ARpar20 | 5000 .371518 .2144403 -.5469691 .9904804<br /> ARpar100 | 5000 .4751635 .0893891 .0822227 .7326534<br /> ARpar250 | 5000 .4906103 .0546967 .2765988 .6818358<br /> ARpar1000 | 5000 .4973098 .0272844 .3987602 .5796224<br /> ARpar5000 | 5000 .4998611 .0121114 .4362852 .5412318<br />Anonymoushttps://www.blogger.com/profile/15251712552217454351noreply@blogger.com