Announcement

Collapse
No announcement yet.
X
  • Filter
  • Time
  • Show
Clear All
new posts

  • Monte carlo simulation to test RE model

    Hi folks,

    I run a random effect model and would like to make a robustness test with monte carlo. I am pretty new in this field, and am unsure about the results.


    my model

    -----------
    use "C:\STATA\20190118 fbdata.dta", replace
    xtset ID year
    xtreg MATH football age sex parentaleducation parentalincome, re
    -----------


    my monte carlo simulation:

    -----------
    capture program drop regprog
    program regprog, rclass
    drop _all
    set obs 100
    use "C:\STATA\20190118 fbdata.dta", replace
    gen u=invnorm(uniform())
    xtset ID year
    xtreg MATH football+u age sex parentaleducation year
    return scalar b0 = _coef[_cons]
    return scalar b1 = _coef[football]
    return scalar b2 = _coef[age]
    return scalar b3 = _coef[sex]
    return scalar b4 = _coef[parentaleducation]
    return scalar b5 = _coef[year]
    return scalar b6 = u
    end

    simulate b0 = r(b0) b1 = r(b1) b2 = r(b2) b3 = r(b3) b4 = r(b4) b5 = r(b5) b6 = r(b6), reps(100): regprog
    sum
    histogram b1, kdensity plot(function stdnorm = normalden(x,0,1), lpattern(dash))

    ----------------

    the results seems to look weird.

    for the random effect model I get
    MATH
    football 0.838
    age 4.935
    sex -0.586
    parentaleducation 0.882
    year 0.183
    for the monte carlo simulation I get
    b0 -173
    b1 -0.041
    b2 4.986
    b3 -0.543
    b4 0.878
    b5 0.181
    b6 0.164

    On my interpretation, the values look all very good. also u is with 0.164 close to 0. but why is b1 so different from the coefficient of football? When I change the random variable to i.e. sex, I have the same phenomenon. All coefficients are almost identical to the monte carlo simulation but not sex, even if the error term has a standard deviation.

    can somebody help me to get the point? thank you very much for your appreciate help!





  • #2
    Code:
    xtreg MATH football+u age sex parentaleducation year
    is a syntax error and would have stopped your program cold. So why don't you show the code you actually ran to get those results? A sample of your data (use -dataex- for that) would be crucial here as well.

    If you are running version 15.1 or a fully updated version 14.2, -dataex- is already part of your official Stata installation. If not, run -ssc install dataex- to get it. Either way, run -help dataex- to read the simple instructions for using it. -dataex- will save you time; it is easier and quicker than typing out tables. It includes complete information about aspects of the data that are often critical to answering your question but cannot be seen from tabular displays or screenshots. It also makes it possible for those who want to help you to create a faithful representation of your example to try out their code, which in turn makes it more likely that their answer will actually work in your data.

    When asking for help with code, always show example data. When showing example data, always use -dataex-.

    Comment

    Working...
    X