Stata The Stata listserver
[Date Prev][Date Next][Thread Prev][Thread Next][Date index][Thread index]

RE: st: fweights + ml d0


From   "Nick Cox" <[email protected]>
To   <[email protected]>
Subject   RE: st: fweights + ml d0
Date   Mon, 14 Jun 2004 19:19:40 +0100

Sorry, no. I lost track of what you are doing here, 
and wouldn't understand it anyway. But 
I note that as you just -sort- on identifier, 
you are jumbling observations within each panel. 
Which is tagged as last will then be arbitrary. 
Any reason not to use -tsset-? 

Nick 
[email protected] 

> -----Original Message-----
> From: [email protected]
> [mailto:[email protected]]On Behalf Of Alfonso
> Miranda Caso Luengo
> Sent: 14 June 2004 19:11
> To: [email protected]
> Subject: RE: st: fweights + ml d0
> 
> 
> Dear Nick,
> 
> Many thanks for your point. I did the correction but still 
> have the problem with mlsum. Any other ideas?
> 
> Best,
> 
> Alfonso.
> 
> =====================================
> Alfonso Miranda
> PhD Student
> 
> Economics Department
> University of Warwick
> Coventry CV4 7AL
> E-mail:[email protected]
> WebPage: http://www.warwick.ac.uk/go/amiranda
> =====================================
> >>> [email protected] 06/14/04 18:47 PM >>>
> In your first program you refer to a local macro ivar which 
> you never define. I think you meant to have earlier 
> 
> local ivar "`s(ivar)'"
> 
> Nick 
> [email protected] 
> 
> > -----Original Message-----
> > From: [email protected]
> > [mailto:[email protected]]On Behalf Of Alfonso
> > Miranda Caso Luengo
> > Sent: 14 June 2004 16:48
> > To: [email protected]
> > Subject: Re: st: fweights + ml d0
> > 
> > 
> > Dear all,
> > 
> > Here is an example of the problems I found with fw and ml d0. 
> > This code estimates a sequential probit. A dummy dependent 
> > variable is observed for each individual in various periods. 
> > The model predicts the probability of observing a given 
> > sequence. For each individual draws are iid. However, 
> > observations in the data set are not independent as each 
> > individual contributes a group of observations. Hence, the ml 
> > linear-form restriction is not met in this case.
> > 
> > Here is the example. Can anyone see the error?
> > 
> > Many thanks in advance,
> > 
> > Alfonso.
> > 
> > 
> > --------------------------------------------------------------
> > -----------------
> >        log:  C:\temp\mycode.smcl
> >   log type:  smcl
> >  opened on:  14 Jun 2004, 16:44:28
> > 
> > . do "C:\temp\mycode.do"
> > 
> > . 
> > . capture program drop mycode2
> > 
> > . program define mycode2, eclass
> >   1.         syntax [varlist] [if] [in] [fw] [,  I(string) ]
> >   2. 
> > .         /* Obtaining dependent variable and explanatory 
> > variables */    
> > . 
> > .         gettoken endgv exogv : varlist, parse("") 
> >   3. 
> > .         /* Selecting sample */  
> > . 
> > .         marksample touse
> >   4.         xt_iis `i'
> >   5.         local i "`s(ivar)'"
> >   6.         global S_ivar   "`i'"
> >   7.         markout `touse' `ivar' `varlist', strok
> >   8. 
> > .         /* Sorting data */
> > .         
> > .         sort `i'
> >   9. 
> > .         /* Etimate */
> > .         
> > .         ml model d0 mycode2_ll ("`endgv'": `endgv' = `exogv') /*
> > >         */ [`weight'`exp'] if `touse'
> >  10. 
> > .         ml check
> >  11. end
> > 
> > . 
> > . capture program drop mycode2_ll
> > 
> > . program define mycode2_ll
> >   1. args todo b lnf
> >   2. 
> > .  local y "$ML_y1"
> >   3.  local i "$S_ivar"
> >   4. 
> > .  tempvar xb F  last
> >   5. 
> > .  mleval `xb' = `b'
> >   6.  
> > .  qui { 
> >   7.         by `i' : gen `last' = cond(_n==_N,1,0)
> >   8. 
> > .         gen double `F' = . in 1  if  $ML_samp
> >   9.                        
> > .      #delimit ;
> > delimiter now ;
> > .      by `i': replace `F' = 
> > >      cond(_n==1,
> > >      cond(`y',normprob(`xb'),normprob(-`xb')),
> > >      cond(`y', 
> > >      normprob(`xb'),normprob(-`xb'))*`F'[_n-1] ) if $ML_samp;
> >  10.      #delimit cr
> > delimiter now cr
> > . 
> > .      mlsum `lnf' = log(`F')  if `last' 
> >  11. 
> > .    }
> >  12. end
> > 
> > . 
> > . mycode  depv d4-d30  catholic indspker edu12 c6372 c7382  
> > agu-chih  durango-z
> > > a [fw=wt], i(id)
> > 
> > Test 1:  Calling mycode_ll to check if it computes log 
> likelihood and
> >          does not alter coefficient vector...
> >          FAILED; mycode_ll returned error 499.
> > 
> > Here is a trace of its execution:
> > --------------------------------------------------------------
> > ----------------
> > -> mycode_ll 0 ML_b ML_f __0000QH __0000QI __0000QA
> > - `begin'
> > - args todo b lnf
> > - local y "$ML_y1"
> > - local i "$S_ivar"
> > - tempvar xb F last
> > - mleval `xb' = `b'
> > - qui {
> > - by `i' : gen `last' = cond(_n==_N,1,0)
> > - gen double `F' = . in 1 if $ML_samp
> > - by `i': replace `F' = cond(_n==1, 
> > cond(`y',normprob(`xb'),normprob(-`xb')), c
> > > ond(`y', normprob(`xb'),normprob(-`xb'))*`F'[_n-1] ) if $ML_samp
> > - mlsum `lnf' = log(`F') if `last'
> > mlsum must be over entire estimation sample when weights
> > are specified
> >   }
> > - `end'
> > --------------------------------------------------------------
> > ----------------
> > Fix mycode_ll.
> > r(499);
> > 
> > end of do-file
> > r(499);
> > 
> > . log close
> >        log:  C:\temp\mycode.smcl
> >   log type:  smcl
> >  closed on:  14 Jun 2004, 16:46:01
> > --------------------------------------------------------------
> > -----------------
> > 
> > =====================================
> > Alfonso Miranda
> > PhD Student
> > 
> > Economics Department
> > University of Warwick
> > Coventry CV4 7AL
> > E-mail:[email protected]
> > WebPage: http://www.warwick.ac.uk/go/amiranda
> > =====================================
> > 
> > *
> > *   For searches and help try:
> > *   http://www.stata.com/support/faqs/res/findit.html
> > *   http://www.stata.com/support/statalist/faq
> > *   http://www.ats.ucla.edu/stat/stata/
> > 
> 
> *
> *   For searches and help try:
> *   http://www.stata.com/support/faqs/res/findit.html
> *   http://www.stata.com/support/statalist/faq
> *   http://www.ats.ucla.edu/stat/stata/
> 
> 
> *
> *   For searches and help try:
> *   http://www.stata.com/support/faqs/res/findit.html
> *   http://www.stata.com/support/statalist/faq
> *   http://www.ats.ucla.edu/stat/stata/
> 

*
*   For searches and help try:
*   http://www.stata.com/support/faqs/res/findit.html
*   http://www.stata.com/support/statalist/faq
*   http://www.ats.ucla.edu/stat/stata/



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