Wednesday, May 30, 2012

Estimating Random Coefficients on x

* Stata code version 11.

* In Econometrics terms this is what we are thinking about:

* y=xb + e    e is a random variable
* b = B + u   u is a random variable

* Ie. there is an average effect B of x but there is also a individual effect, u.
* We want to know how much does the the effect of the policy vary accoss individuals.

* Therefore:
* Y=X(B+u) + e
* Y=XB + Xu + e
* Y=XB + v ;  v=(Xu + e)

set seed 111
set obs 1000

gen u = rnormal()*3

* We cannot hope to estimate every individual u.
* However, we can get an estimate on the stanadard deviation of u.
* Which is >>>> 3 <<<<

gen b=u + 4

gen x=rnormal()

gen e=rnormal()*5

gen y= b*x + e

* We will attempt to use xtmixed to recover the variance on u and e.
* The standard deviation on u should be estimated by sd(x) since u is the random coefficient on x.
* And sd(_cons) is an estimate of the standard deviation of e.
* This might seem fishy but having a random coefficient on a constant is the same as having the standard addative error in the model.

xtmixed y x || x: x , iterate(2)
* xtmixed is tested with several specifications of iterate because it tends to bog down.
* Waiting for the algorithm to converge seemed far too time consuming.
* Epeciatally when one exams almost non-existant difference between 5 and 10.

xtmixed y x || x: x , iterate(5)

xtmixed y x || x: x , iterate(10)

xtmixed y x || x: x , iterate(20)

xtmixed y x || x: x

No comments:

Post a Comment