Statalist


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

st: RE: Re: Emailing: st RE Cappellari and Jenkins code for MSL estimation of a probit model


From   "Nick Cox" <n.j.cox@durham.ac.uk>
To   <statalist@hsphsun2.harvard.edu>
Subject   st: RE: Re: Emailing: st RE Cappellari and Jenkins code for MSL estimation of a probit model
Date   Tue, 8 Sep 2009 14:03:27 +0100

I am implying that you need to define a global macro called -id- for this code to work. 

It may be that you changed the code and didn't change it consistently. I don't know. 

Nick 
n.j.cox@durham.ac.uk 

Ousmane FAYE

Hi Nick,
Thank you so much for your help. However, I am still having the same
problem. Please can you clarify a bit what you are suggesting?


"Nick Cox" <n.j.cox@durham.ac.uk>

> The code you run expects a global macro called -id- to be defined, but
> evidently it is empty.

Ousmane FAYE

> 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