Announcement

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

  • Random Coefficient Model

    Hi statalists,

    I need your help.
    I am currently trying to estimate the model (3) by plugging (2) into (1)
    (1) yi = b0 + b1i * xi + b2i * zi + ei
    (2) b1i = g0 + g1 * pi + g2 * zi + ui

    (3) yi = b0 + (g0 + g1 * pi + g2 * zi + ui)* xi + b2i * zi + ei
    = b0 + g0*xi + g1*pi*xii + g2*zi*xi+ ui*xi + b2i* zi + ei

    This is the random coefficient model.
    What kind of command I have to use to estimate?

    For xi, I have edu( years of schooling ) and for zi, I have age, age (age squared), and urban.
    For pi, I have pre (precipitaion)

    Thank you in advance.
    Last edited by Shisho Jakas; 23 Mar 2018, 05:19.

  • #2
    help mixed
    ---------------------------------
    Maarten L. Buis
    University of Konstanz
    Department of history and sociology
    box 40
    78457 Konstanz
    Germany
    http://www.maartenbuis.nl
    ---------------------------------

    Comment


    • #3
      Thank you Maarten for replying!
      I looked up the helped mixed and I am still confusing.
      I think that I do not get the concept about the variables.
      Could you give me a hint on my code based on the model and variable I have?

      So in my case, what is the level variable?

      I tried
      Code:
      mixed ttlwages || edu age age_squ urban:

      but it did not go well. It says level edu age age_squ urban incorrectly specified


      and plus,
      after estimating this model, where or how can I find the distribution estimated?
      Here is my data from dataex

      Code:
      * Example generated by -dataex-. To install: ssc install dataex
      clear
      input long(persid ttlwages) float edu byte age float age_squ byte urban double preci
       10150302     0  4 35 1225 1 70.3422
       30790104     0  4 32 1024 0 5.87504
       10150301     0  . 36 1296 1 70.3422
       40140102     0  . 40 1600 0 121.639
       80670701     0  5 49 2401 0 5.87504
       40140101     0  6 41 1681 0 121.639
       10240702  9000  . 29  841 0 12.6427
       10241002 10000  . 49 2401 0 12.6427
       10240402 12000  . 39 1521 0 12.6427
       40240902 14000  6 32 1024 0 27.8573
      220040502 14000  9 26  676 1 70.3422
      150161201 15000  6 73 5329 0 5.87504
       20641002 15000  5 25  625 0 213.632
      170240201 15000  . 42 1764 0 12.6427
       30390202 18000  7 19  361 0 27.8573
      121510201 20000  8 71 5041 1 70.3422
       30080402 20000  5 37 1369 1 5.87504
       70081001 20000 12 24  576 0 341.446
       20260902 20000  8 28  784 0 293.869
       20260901 20000  8 30  900 0 293.869
      200180201 20000  7 32 1024 0 341.446
      121320901 20000  7 76 5776 1 293.869
       20370802 23000  . 19  361 0 12.6427
       10050705 25000 18 21  441 1 121.639
       10230102 25000  4 33 1089 0 12.6427
      170411201 25300  3 40 1600 0 5.87504
      160031102 30000  6 59 3481 1 5.87504
       10240302 30000  . 54 2916 0 12.6427
       10310802 30000  . 66 4356 0 5.87504
       31060303 30000  . 70 4900 0 5.87504
       30980903 30000  7 27  729 0 341.446
       10261203 30000  8 18  324 0 334.451
      150101101 30000  5 46 2116 0 334.451
      210401201 30000  7 52 2704 0 102.575
       10311102 30000  . 48 2304 0 5.87504
       90100902 30000  4 22  484 0 27.8573
       80440202 30000  4 31  961 0 5.87504
       50530102 30000  2 55 3025 0 5.87504
      210010902 30000  2 31  961 1 315.577
       80511101 30000  4 63 3969 0 27.8573
      150201101 30000  5 60 3600 0 334.451
       31060206 30000  4 51 2601 0 5.87504
       30370101 30000  7 42 1764 0 293.869
       20010801 30000  . 33 1089 1 70.3422
      220100401 35000  8 40 1600 0 121.639
       30321004 37500  3 23  529 0 5.87504
       30321001 37500  4 53 2809 0 5.87504
       30921101 37500  . 48 2304 0 85.5155
       30321003 37500  6 25  625 0 5.87504
       30881102 40000  5 24  576 0 27.8573
       10241102 40000  . 40 1600 0 12.6427
       10260101 40000  3 37 1369 0 334.451
       40050503 40000  7 30  900 1 85.5155
      121030501 40000  8 69 4761 1 5.87504
       10240202 40000  . 46 2116 0 12.6427
      100170501 40000  6 45 2025 0 12.6427
       10240501 40000  8 26  676 0 12.6427
       50191001 40000  3 44 1936 0 213.632
       40150806 40000  8 18  324 0 121.639
       10030701 40000  8 55 3025 1 315.577
      140480703 40000 13 32 1024 0 12.6427
      140221201 40000  . 51 2601 0 213.632
       30881002 40000  . 58 3364 0 27.8573
      140221201 40000  . 51 2601 0 213.632
      100131203 40000 10 37 1369 0 213.632
      240220901 40000  4 55 3025 1 341.446
       30250903 40000  8 24  576 0 334.451
       30250904 40000 13 32 1024 0 334.451
       50601101 40000 13 27  729 0 293.869
       90101102 40000  7 27  729 0 27.8573
       31060501 40000  5 53 2809 0 5.87504
       40050501 40000  9 58 3364 1 85.5155
       50580503 40000  . 29  841 0 341.446
      130080101 40000  6 24  576 0 341.446
      150201204 42000 10 23  529 0 334.451
       30340501 42500  5 29  841 0 70.3422
      200081003 44000 11 25  625 0 85.5155
       10241202 45000  2 49 2401 0 12.6427
       30370304 45000  7 22  484 0 293.869
       10241201 45000  . 49 2401 0 12.6427
       30380602 45000  . 50 2500 0 293.869
       20231203 45000 15 21  441 0 293.869
       30380601 45000  . 45 2025 0 293.869
       10241101 45000  . 30  900 0 12.6427
       10260102 46000  . 44 1936 0 334.451
      140331201 48000  5 25  625 0 70.3422
       30021104 48000  8 27  729 1 334.451
      121661004 48000  7 24  576 0 12.6427
       30610903 48000  0 30  900 0 293.869
       30450403 48000  9 27  729 0 213.632
       80571204 48000 10 31  961 0 315.577
       80571203 48000  4 34 1156 0 315.577
       50700401 48000  6 30  900 0 12.6427
       80370903 48000 10 44 1936 0 334.451
      200131104 48000  . 21  441 0 12.6427
      120281005 50000 13 31  961 1 121.639
      170230703 50000  4 20  400 0 12.6427
      121670401 50000  5 59 3481 0 12.6427
      220041202 50000  . 49 2401 1 70.3422
      160190201 50000  2 50 2500 0 5.87504
      end
      Last edited by Shisho Jakas; 23 Mar 2018, 07:37.

      Comment


      • #4
        Can anyone help?

        Comment


        • #5
          Shisho:
          you should read (at least) -mixed- entry carefully again (examples on pigs growth are really interesting) before trying to sketch any mixed model code: they're really demanding to conceive, decipher and disseminate.
          You might also be interested in the very well written and (pretty) easy to grasp: http://uk.sagepub.com/en-gb/eur/mult...age/book235963.
          That said:
          1) it is not clear from your code if you're actualy interested in a random intercept or in a random coefficient mixed model. If the latter were the case, please note that you have to select the variable that allows for a random slope;
          2) why creating -age-squ- by hand when -fvvarlist- can create that for you?
          3) your model(s) are not expected to converge (that is, you should revise your dataset and/or your model specification), as you can see form the following example:
          Code:
          *Random intercept model*
          . mixed ttlwages c.age##c.age urban edu || persid:
          
          Performing EM optimization:
          
          Performing gradient-based optimization:
          
          could not calculate numerical derivatives -- discontinuous region with missing values encountered
          could not calculate numerical derivatives -- discontinuous region with missing values encountered
          r(430);
          
          *Random coefficient model (also known as (aka): random slope model); random slope on urban*
          
          . mixed ttlwages c.age##c.age edu || persid: urban
          
          Performing EM optimization:
          
          Performing gradient-based optimization:
          
          Iteration 0:   log likelihood = -804.60138  (not concave)
          Iteration 1:   log likelihood = -804.38868  (not concave)
          Iteration 2:   log likelihood = -804.31495  (not concave)
          Iteration 3:   log likelihood = -804.30858  (not concave)
          Iteration 4:   log likelihood = -804.30857  (not concave)
          Iteration 5:   log likelihood = -804.30857  (not concave)
          Iteration 6:   log likelihood = -804.30857  (not concave)
          Iteration 7:   log likelihood = -804.30857  (not concave)
          Iteration 8:   log likelihood = -804.30857  (not concave)
          Iteration 9:   log likelihood = -804.30857  (not concave)
          Iteration 10:  log likelihood = -804.30857  (not concave)
          Iteration 11:  log likelihood = -804.30857  (not concave)
          Iteration 12:  log likelihood = -804.30857  (not concave)
          Iteration 13:  log likelihood = -804.30857  (not concave)
          Iteration 14:  log likelihood = -804.30857  (not concave)
          Iteration 15:  log likelihood = -804.30857  (not concave)
          Iteration 16:  log likelihood = -804.30857  (not concave)
          Iteration 17:  log likelihood = -804.30857  (not concave)
          Iteration 18:  log likelihood = -804.30857  (not concave)
          Iteration 19:  log likelihood = -804.30857  (not concave)
          Iteration 20:  log likelihood = -804.30857  (not concave)
          Iteration 21:  log likelihood = -804.30857  (not concave)
          Iteration 22:  log likelihood = -804.30857  (not concave)
          Iteration 23:  log likelihood = -804.30857  (not concave)
          Iteration 24:  log likelihood = -804.30857  (not concave)
          Iteration 25:  log likelihood = -804.30857  (not concave)
          Iteration 26:  log likelihood = -804.30857  (not concave)
          Iteration 27:  log likelihood = -804.30857  (not concave)
          Iteration 28:  log likelihood = -804.30857  (not concave)
          Iteration 29:  log likelihood = -804.30857  (not concave)
          Iteration 30:  log likelihood = -804.30857  (not concave)
          Iteration 31:  log likelihood = -804.30857  (not concave)
          --Break--
          r(1);
          Kind regards,
          Carlo
          (Stata 19.0)

          Comment

          Working...
          X