Statalist


[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

st: Cappellari and Jenkins code for MSL estimation of a probit model for panel data


From   Ousmane FAYE <xalebifaye@yahoo.co.uk>
To   statalist-owner@hsphsun2.harvard.edu
Subject   st: Cappellari and Jenkins code for MSL estimation of a probit model for panel data
Date   Sat, 5 Sep 2009 14:51:52 +0000 (GMT)

Dear all,
I have a probit model using a panel data with 6 waves of observations. I am trying to run  the code suggested by Cappellari and Jenkins Stata Journal (2006) (Paragraph 3.6: Illustration 4: MSL estimation of a probit model for panel data) See below. 
However I have the following error message after 'ml maximize' : "varlist required."
I use 'ml check' and here is where the error likely happens:
      ......
           - quietly {
              - forvalues i = 1/6 {
              - by $id: gen double `k`i'' = ( 2*$ML_y1[`i'] ) - 1
              = by : gen double __00001J = ( 2*Diarrhea[1] ) - 1
varlist required
                by $id: gen double `xb`i'' = `theta1'[`i']
                }
                
I have exactly replicate the Cappellari and Jenkins' code. I don't why this occurs then. Can someone advise on this issue?
Thanks in advance,

The program i use is what follows:


sort  ChildID update
global cs " "
global csbar " "
forvalues i = 2/6 {
        forvalues j = 1/`i' {
                global cs "$cs c`i'`j'"
                global csbar "$csbar  /c`i'`j'"
        }
}
program drop myll
program define myll
     args todo b lnf
     tempvar theta1 T fi xb1 xb2 xb3 xb4 xb5 xb6 k1 k2 k3 k4 k5 k6
     tempname $cs
     mleval `theta1' = `b' , eq(1)
     local c = 1
     forvalues i = 2/6 {
           forvalues j = 1/`i' {
                  local c = `c' + 1
                  mleval `c`i'`j'' = `b' , eq(`c') scalar
           }
     }
     quietly {
             forvalues i = 1/6 {
                   by $ChildID: gen double `k`i'' = ( 2*$ML_y1[`i'] ) - 1
                   by $ChildID: gen double `xb`i'' = `theta1'[`i']
             }
             by $ChildID: gen double `T' = (_n == 6)
             tempname C
             mat `C' = I(6)
             forvalues i = 2/6 {
                    forvalues j = 1/`i' {
                           local c`i'`j' = `c`i'`j''
                           mat `C'[`i',`j'] = (`c`i'`j'')
                    }
             }
             egen `fi' = mvnp(`xb1' `xb2' `xb3' `xb4' `xb5' `xb6') , ///
                 chol(`C') dr($dr) prefix(z) ///
                 signs(`k1' `k2' `k3' `k4' `k5' `k6')
             mlsum `lnf' = ln(`fi') if `T'
       }
end

di "$cs"
di "$csbar"
probit Diarrhea LDiarrhea LWAZ ChildAge ChildAge2 MotherAge female prim_sch sec_sch high_sch 
mat b0 = e(b)
mdraws, dr(10) neq(6) prefix(z) antithetics
global dr = r(n_draws)
ml init b0
ml model d0 myll (Diarrhea: Diarrhea = LDiarrhea LWAZ ChildAge ChildAge2 MotherAge female prim_sch sec_sch high_sch) $csbar
ml maximize


      

*
*   For searches and help try:
*   http://www.stata.com/help.cgi?search
*   http://www.stata.com/support/statalist/faq
*   http://www.ats.ucla.edu/stat/stata/



© Copyright 1996–2014 StataCorp LP   |   Terms of use   |   Privacy   |   Contact us   |   What's new   |   Site index