Bookmark and Share

Notice: On March 31, it was announced that Statalist is moving from an email list to a forum. The old list will shut down at the end of May, and its replacement, statalist.org is already up and running.


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

Re: st: Has anyone successfully run the nlsur AIDS example: [R] I-P (pages 472-473)?


From   Jorge Eduardo Pérez Pérez <perez.jorge@ur.edu.co>
To   "statalist@hsphsun2.harvard.edu" <statalist@hsphsun2.harvard.edu>
Subject   Re: st: Has anyone successfully run the nlsur AIDS example: [R] I-P (pages 472-473)?
Date   Tue, 10 Apr 2012 14:11:48 -0400

This line in your code is wrong. :

 - replace `lnpindex' = `lnpindex' = `lnpindex' +
0.5*`g`i'`j''*`lnp`i''*`lnp`j''

should be

replace `lnpindex' = `lnpindex' + 0.5*`g`i'`j''*`lnp`i''*`lnp`j''

I don't have a copy of the Stata 10 manual with me, so I don't know if
the mistake is yours or if it is a typo in the Stata 10 manual. It is
written correctly in the Stata 11 pdf manual.

Hope this helps,
_______________________
Jorge Eduardo Pérez Pérez




On Tue, Apr 10, 2012 at 1:27 PM, Anthony Murray <agmurr@yahoo.com> wrote:
>
> Good afternoon,
>
> Has anyone ever gotten the AIDS function evaluator program example to work?  It is on page 472 in the Stata 10 physical manuals and page 1253 in the Stata 11 pdf manual.  The code looks exactly the same between the two manuals, with only the version number changing between them.
>
> I have tried it on Stata 10.1 and 11.2 and when I type the code in _exactly_ (unless I am missing something simple when I retype it) as it is in the book.  In both instances, I either get a r198 error stating that I need to verify that nlsuraids is a function evaluator program.
>
> This same problem has come up before without resolve.  See this thread:
>
> http://www.stata.com/statalist/archive/2009-03/msg00670.html
>
> (There is still at least one typo in the final post in the share equation w3 of that code, but otherwise it looks equivalent to the example in the book)
>
> To ensure that there were as few typing errors as possible, I copy/pasted the code from the pdf into a file and still received the same error.  I also typed the code directly.  Here is the code I typed:
>
> program nlsuraids
>        version 10
>        syntax varlist(min=8 max=8) if, at(name)
>        tokenize `varlist'
>        args w1 w2 w3 lnp1 lnp2 lnp3 lnp4 lnm
>        tempname a1 a2 a3 a4
>        scalar `a1' = `at'[1,1]
>        scalar `a2' = `at'[1,2]
>        scalar `a3' = `at'[1,3]
>        scalar `a4' = 1 - `a1' - `a2' - `a3'
>        tempname b1 b2 b3
>        scalar `b1' = `at'[1,4]
>        scalar `b2' = `at'[1,5]
>        scalar `b3' = `at'[1,6]
>        tempname g11 g12 g13 g14
>        tempname g21 g22 g23 g24
>        tempname g31 g32 g33 g34
>        tempname g41 g42 g43 g44
>        scalar `g11' = `at'[1,7]
>        scalar `g12' = `at'[1,8]
>        scalar `g13' = `at'[1,9]
>        scalar `g14' = -`g11' - `g12' -`g13'
>        scalar `g21' = `g12'
>        scalar `g22' = `at'[1,10]
>        scalar `g23' = `at'[1,11]
>        scalar `g24' = -`g21' - `g22' -`g23'
>        scalar `g31' = `g13'
>        scalar `g32' = `g23'
>        scalar `g33' = `at'[1,12]
>        scalar `g34' = -`g31' - `g32' -`g33'
>        scalar `g41' = `g14'
>        scalar `g42' = `g24'
>        scalar `g43' = `g34'
>        scalar `g44' = -`g41' - `g42' -`g43'
>
>        quietly {
>                tempvar lnpindex
>                gen double `lnpindex' = 5 + `a1'*`lnp1' + `a2'*`lnp2' + `a3'*`lnp3' + `a4'*`lnp4'
>                forvalues i = 1/4 {
>                        forvalues j = 1/4 {
>                                replace `lnpindex' = `lnpindex' = `lnpindex' + 0.5*`g`i'`j''*`lnp`i''*`lnp`j''
>                        }
>                }
>                replace `w1' = `a1' + `g11'*`lnp1' + `g12'*`lnp2' + `g13'*`lnp3' + `g14'*`lnp4' + `b1'*(`lnm' - `lnpindex')
>                replace `w2' = `a2' + `g21'*`lnp1' + `g22'*`lnp2' + `g23'*`lnp3' + `g24'*`lnp4' + `b2'*(`lnm' - `lnpindex')
>                replace `w3' = `a3' + `g31'*`lnp1' + `g32'*`lnp2' + `g33'*`lnp3' + `g34'*`lnp4' + `b3'*(`lnm' - `lnpindex')
>        }
> end
>
> use http://www.stata-press.com/data/r10/food, clear
> nlsur aids @ w1 w2 w3 lnp1 lnp2 lnp3 lnp4 lnexp, parameters(a1 a2 a3 b1 b2 b3 g11 g12 g13 g22 g32 g33) neq(3) ifgnls
>
> **Comments from the past thread that I have tried and not changed the error:
>
> replacing "if" with "[if]" in the syntax line of the program
> changing the order of the actual -nlsur- command to match the exact -help nlsur- file within Stata:
>  nlsur FEP @ depvars [varlist], nequations(#), {parameters(namelist)|nparameters(#)}
>
>
> Finally, I have attached the last bit of code when I -set trace on-, but I am not a fluent enough programmer in Stata to understand how to debug it.
>
> Thanks for your help!
>
> Results from trace:
>
>
>  capture nlsur`eqn' `alljunk' `t23rhs' `wtexp' if `touse', at(`parmvec')
>  = capture nlsuraids __000012 __000013 __000014 lnp1 lnp2 lnp3 lnp4 lnexp  if __00000R, at(__00000S)
>    ---------------------------------------------------------------------------------------- begin nlsuraids ---
>    - version 10
>    - syntax varlist(min=8 max=8) if, at(name)
>    - tokenize `varlist'
>    = tokenize __000012 __000013 __000014 lnp1 lnp2 lnp3 lnp4 lnexp
>    - args w1 w2 w3 lnp1 lnp2 lnp3 lnp4 lnm
>    - tempname a1 a2 a3 a4
>    - scalar `a1' = `at'[1,1]
>    = scalar __000015 = __00000S[1,1]
>    - scalar `a2' = `at'[1,2]
>    = scalar __000016 = __00000S[1,2]
>    - scalar `a3' = `at'[1,3]
>    = scalar __000017 = __00000S[1,3]
>    - scalar `a4' = 1 - `a1' - `a2' - `a3'
>    = scalar __000018 = 1 - __000015 - __000016 - __000017
>    - tempname b1 b2 b3
>    - scalar `b1' = `at'[1,4]
>    = scalar __000019 = __00000S[1,4]
>    - scalar `b2' = `at'[1,5]
>    = scalar __00001A = __00000S[1,5]
>    - scalar `b3' = `at'[1,6]
>    = scalar __00001B = __00000S[1,6]
>    - tempname g11 g12 g13 g14
>    - tempname g21 g22 g23 g24
>    - tempname g31 g32 g33 g34
>    - tempname g41 g42 g43 g44
>    - scalar `g11' = `at'[1,7]
>    = scalar __00001C = __00000S[1,7]
>    - scalar `g12' = `at'[1,8]
>    = scalar __00001D = __00000S[1,8]
>    - scalar `g13' = `at'[1,9]
>    = scalar __00001E = __00000S[1,9]
>    - scalar `g14' = -`g11' - `g12' -`g13'
>    = scalar __00001F = -__00001C - __00001D -__00001E
>    - scalar `g21' = `g12'
>    = scalar __00001G = __00001D
>    - scalar `g22' = `at'[1,10]
>    = scalar __00001H = __00000S[1,10]
>    - scalar `g23' = `at'[1,11]
>    = scalar __00001I = __00000S[1,11]
>    - scalar `g24' = -`g21' - `g22' -`g23'
>    = scalar __00001J = -__00001G - __00001H -__00001I
>    - scalar `g31' = `g13'
>    = scalar __00001K = __00001E
>    - scalar `g32' = `g23'
>    = scalar __00001L = __00001I
>    - scalar `g33' = `at'[1,12]
>    = scalar __00001M = __00000S[1,12]
>    - scalar `g34' = -`g31' - `g32' -`g33'
>    = scalar __00001N = -__00001K - __00001L -__00001M
>    - scalar `g41' = `g14'
>    = scalar __00001O = __00001F
>    - scalar `g42' = `g24'
>    = scalar __00001P = __00001J
>    - scalar `g43' = `g34'
>    = scalar __00001Q = __00001N
>    - scalar `g44' = -`g41' - `g42' -`g43'
>    = scalar __00001R = -__00001O - __00001P -__00001Q
>    - quietly {
>    - tempvar lnpindex
>    - gen double `lnpindex' = 5 + `a1'*`lnp1' + `a2'*`lnp2' + `a3'*`lnp3' + `a4'*`lnp4'
>    = gen double __00001S = 5 + __000015*lnp1 + __000016*lnp2 + __000017*lnp3 + __000018*lnp4
>    - forvalues i = 1/4 {
>    - forvalues j = 1/4 {
>    - replace `lnpindex' = `lnpindex' = `lnpindex' + 0.5*`g`i'`j''*`lnp`i''*`lnp`j''
>    = replace __00001S = __00001S = __00001S + 0.5*__00001C*lnp1*lnp1
>      }
>      }
>      replace `w1' = `a1' + `g11'*`lnp1' + `g12'*`lnp2' + `g13'*`lnp3' + `g14'*`lnp4' + `b1'*(`lnm' - `lnpindex'
> > )
>      replace `w2' = `a2' + `g21'*`lnp1' + `g22'*`lnp2' + `g23'*`lnp3' + `g24'*`lnp4' + `b2'*(`lnm' - `lnpindex'
> > )
>      replace `w3' = `a3' + `g31'*`lnp1' + `g32'*`lnp2' + `g33'*`lnp3' + `g34'*`lnp4' + `b3'*(`lnm' - `lnpindex'
> > )
>      }
>    ------------------------------------------------------------------------------------------ end nlsuraids ---
>  - }
>  - if _rc {
>  - di as error "nlsur`eqn' returned " _rc
>  = di as error "nlsuraids returned " _rc
> nlsuraids returned 198
>  - di as error "verify that nlsur`eqn' is a function evaluator program"
>  = di as error "verify that nlsuraids is a function evaluator program"
> verify that nlsuraids is a function evaluator program
>  - exit _rc
>    }
>    }
>  --------------------------------------------------------------------------------------- end nlsur.Estimate ---
> -------------------------------------------------------------------------------------------------- end nlsur ---
>
> *
> *   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/
>
>


*
*   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   |   Site index