st: Re: retruned r(198) in nlsur

classic Classic list List threaded Threaded
72 messages Options
1234
Reply | Threaded
Open this post in threaded view
|

st: Re: retruned r(198) in nlsur

Christopher F Baum
<>
According to help nlsur what you have typed below is not the proper  
format of the command.


         nlsur func_prog @ depvar_1 depvar_2 ...  [varlist] [if] [in]  
[weight] , nequations(#)
                        {parameters(namelist)|nparameters(#)} [options]

so you should list the depvars for the several (4?) equations, then  
give a varlist of variables to be passed to the routine, then comma,  
nequations() option. In what you have written below you have a ) where  
you should not and are missing the comma. Also, either parameters() or  
nparameters() MUST be given.

Look at the examples at the foot of the help file for the simpler  
example of a function evaluator program, and make sure your command  
follows the appropriate syntax.

Kit Baum   |   Boston College Economics and DIW Berlin   |   http://ideas.repec.org/e/pba1.html
An Introduction to Stata Programming   |   http://www.stata-press.com/books/isp.html
An Introduction to Modern Econometrics Using Stata   |   http://www.stata-press.com/books/imeus.html



On Mar 14, 2009, at 02:33 ,Jingling wrote:

>
> nlsur wellll @ lnc sl sk sm lnpl lnpk lnpm lnpe lnq halflnqlnq lnpllnq
> lnpklnq lnpmlnq lnpelnq lnqt lnqd1 lnqd2 lnqd3 lnqd4 lnqd5 lnqd6 t
> halftt lnplt lnpkt lnpmt lnpet d1 d2 d3 d4 d5 d6 td1 td2 td3 td4 td5
> td6 lnpld1 lnpld2 lnpld3 lnpld4 lnpld5 lnpld6 lnpkd1 lnpkd2 lnpkd3
> lnpkd4 lnpkd5 lnpkd6 lnpmd1 lnpmd2 lnpmd3 lnpmd4 lnpmd5 lnpmd6 lnped1
> lnped2 lnped3 lnped4 lnped5 lnped6, parameters(al ak am aq aqq blq bkq
> bmq bqt bq1 bq2 bq3 bq4 bq5 bq6 at att blt bkt bmt d1 d2 d3 d4 d5 d6
> bt1 bt2 bt3 bt4 bt5 bt6 bl1 bl2 bl3 bl4 bl5 bl6 bk1 bk2 bk3 bk4 bk5
> bk6  bm1 bm2 bm3 bm4 bm5 bm6 be1 be2 be3 be4 be5 dkl dkk dml dmk dmm)
> neq(4) ifgnls

*
*   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/
Reply | Threaded
Open this post in threaded view
|

st: CASE-CONTROL STUDY

Ishay Barat
HELLO



I've got a data set containing about 2500 patients, of which 300 have my
interest (Group A).

I would like to extract a sample of 900 patients (Group B) out of the data
set that match Group A in age, sex and some other parameters. A Classical
Case-Control study with 3 controllers for each case.



Is anybody have a clue how the syntax look like??






*¸..· ´¨)) -:¦:-        *
    ¸.·´ .
  (( -:¦:- * Ishay *  -:¦:-
    ´·..          ..·´
               ((¸¸.·´* -:¦:-

*
*   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/
Reply | Threaded
Open this post in threaded view
|

Re: st: CASE-CONTROL STUDY

Airey, David C
.

This looks relevant:

http://personalpages.manchester.ac.uk/staff/mark.lunt/optmatch.html


On Mar 14, 2009, at 11:28 AM, Ishay Barat wrote:

> HELLO
>
>
>
> I've got a data set containing about 2500 patients, of which 300  
> have my interest (Group A).
>
> I would like to extract a sample of 900 patients (Group B) out of  
> the data set that match Group A in age, sex and some other  
> parameters. A Classical Case-Control study with 3 controllers for  
> each case.
>
>
>
> Is anybody have a clue how the syntax look like??
>
>
>
>
>
>
> *¸..· ´¨)) -:¦:-        *
>   ¸.·´ .
> (( -:¦:- * Ishay *  -:¦:-
>   ´·..          ..·´
>              ((¸¸.·´* -:¦:-
> *
> *   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/
Reply | Threaded
Open this post in threaded view
|

Re: st: CASE-CONTROL STUDY

Airey, David C
In reply to this post by Ishay Barat
.

PS... what is your signature text figure supposed to be? A dragon?


On Mar 14, 2009, at 11:28 AM, Ishay Barat wrote:

> HELLO
>
>
>
> I've got a data set containing about 2500 patients, of which 300  
> have my interest (Group A).
>
> I would like to extract a sample of 900 patients (Group B) out of  
> the data set that match Group A in age, sex and some other  
> parameters. A Classical Case-Control study with 3 controllers for  
> each case.
>
>
>
> Is anybody have a clue how the syntax look like??
>
>
>
>
>
>
> *¸..· ´¨)) -:¦:-        *
>   ¸.·´ .
> (( -:¦:- * Ishay *  -:¦:-
>   ´·..          ..·´
>              ((¸¸.·´* -:¦:-
> *
> *   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/
Reply | Threaded
Open this post in threaded view
|

st: RE: CASE-CONTROL STUDY

Kieran McCaul
In reply to this post by Ishay Barat
Matching is an element of the design of a study, planned before the data is collected, and should be done for efficiency, not control.
If you already have the data, you gain nothing by matching.  You have a sample size of 2,500.  If you match these data in the way you have indicated, you will end up with a matched sample size of 1,200.  Why would you want to discard over half of your data?  

You should analyse the data as they are and control for age, sex, etc in the analysis.


______________________________________________
Kieran McCaul MPH PhD
WA Centre for Health & Ageing (M573)
University of Western Australia
Level 6, Ainslie House
48 Murray St
Perth 6000
Phone: (08) 9224-2140
Fax: (08) 9224 8009
email: [hidden email]
http://myprofile.cos.com/mccaul 
http://www.researcherid.com/rid/B-8751-2008
______________________________________________
Epidemiology is so beautiful and provides such an important perspective on human life and death,
but an incredible amount of rubbish is published.  Richard Peto (2007)

-----Original Message-----
From: [hidden email] [mailto:[hidden email]] On Behalf Of Ishay Barat
Sent: Sunday, 15 March 2009 1:28 AM
To: [hidden email]
Subject: st: CASE-CONTROL STUDY

HELLO



I've got a data set containing about 2500 patients, of which 300 have my
interest (Group A).

I would like to extract a sample of 900 patients (Group B) out of the data
set that match Group A in age, sex and some other parameters. A Classical
Case-Control study with 3 controllers for each case.



Is anybody have a clue how the syntax look like??






*¸..· ´¨)) -:¦:-        *
    ¸.·´ .
  (( -:¦:- * Ishay *  -:¦:-
    ´·..          ..·´
               ((¸¸.·´* -:¦:-

*
*   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/
Reply | Threaded
Open this post in threaded view
|

st: Return code 199 after redoing the example in stata reference

Crystal Li
In reply to this post by Christopher F Baum
Hi,

Since my own codes don't work, I copyed the codes from Stata reference  
I-p, page471, example 5.

I use the same codes, same data set. I only modified two things.  
First, I changed -version 10- to -version 10.1-, which is the version  
I am using. Second, I rename lnexp to lnm in the data set, because the  
variable is named lnm in their program codes. I am quite sure the  
other codes are exactly the same as the one in the book.

However, when I typed the conmand in the last line, -nlsur- bla bla,  
there the error:

nlsuraids returned 199
verify that nlsuraidss is a function evaluator program
r(199);


That's so wireld! I list my code following:



program nlsuraids

         version 10.1

         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
         sca1ar `a1'=`at'[1,1]
         sca1ar `a2'=`at'[1,2]
         sca1ar `a3'=`at'[1,3]
         sca1ar `a4'= 1-`a1'-`a2'-`a3'

         tempname b1 b2 b3
         sca1ar `b1'=`at'[1,4]
         sca1ar `b2'=`at'[1,5]
         sca1ar `b3'=`at'[1,6]


         tempname g11 g12 g13 g14
         tempname g21 g22 g23 g24
         tempname g31 g32 g33 g34
         tempname g41 g42 g43 g44
         sca1ar `g11'=`at'[1,7]
         sca1ar `g12'=`at'[1,8]
         sca1ar `g13'=`at'[1,9]
         sca1ar `g14'=-`g11'-`g12'-`g13'

         sca1ar `g21'=`g12'
         sca1ar `g22'=`at'[1,10]
         sca1ar `g23'=`at'[1,11]
         sca1ar `g24'=-`g21'-`g22'-`g23'

         sca1ar `g31'=`g13'
         sca1ar `g32'=`g23'
         sca1ar `g33'=`at'[1,12]
         sca1ar `g34'=-`g31'-`g32'-`g33'

         sca1ar `gel'=`g14'
         sca1ar `g42'=`g24'
         sca1ar `g43'=`g34'
         sca1ar `g44'=-`g41'-`g42'-`g43'


         quietly {
                 tempvar lnpindex
                 gen double `lnpindex' =
5+`a1'*`lnp1'+`a2'*`lnp2'+`a3'*`lnp3'+`a4'*`lnp4'
                 forva1ues i=1/4 {
                         forva1ues j = 1/4 {
                                 replace  
`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

nlsur aids @ w1 w2 w3 lnp1 lnp2 lnp3 lnp4 lnm, parameters (a1 a2 a3 b1  
b2 b3 g11 g12 g13 g22 g32 g33) neq(3) ifgnls



Jingjing


引用 Kit Baum <[hidden email]>:

> <>
> According to help nlsur what you have typed below is not the proper
> format of the command.
>
>
>         nlsur func_prog @ depvar_1 depvar_2 ...  [varlist] [if] [in]
> [weight] , nequations(#)
>                        {parameters(namelist)|nparameters(#)} [options]
>
> so you should list the depvars for the several (4?) equations, then
> give a varlist of variables to be passed to the routine, then comma,
> nequations() option. In what you have written below you have a ) where
> you should not and are missing the comma. Also, either parameters() or
> nparameters() MUST be given.
>
> Look at the examples at the foot of the help file for the simpler
> example of a function evaluator program, and make sure your command
> follows the appropriate syntax.
>
> Kit Baum   |   Boston College Economics and DIW Berlin   |
> http://ideas.repec.org/e/pba1.html
> An Introduction to Stata Programming   |
> http://www.stata-press.com/books/isp.html
> An Introduction to Modern Econometrics Using Stata   |
> http://www.stata-press.com/books/imeus.html
>
>
>
> On Mar 14, 2009, at 02:33 ,Jingling wrote:
>
>>
>> nlsur wellll @ lnc sl sk sm lnpl lnpk lnpm lnpe lnq halflnqlnq lnpllnq
>> lnpklnq lnpmlnq lnpelnq lnqt lnqd1 lnqd2 lnqd3 lnqd4 lnqd5 lnqd6 t
>> halftt lnplt lnpkt lnpmt lnpet d1 d2 d3 d4 d5 d6 td1 td2 td3 td4 td5
>> td6 lnpld1 lnpld2 lnpld3 lnpld4 lnpld5 lnpld6 lnpkd1 lnpkd2 lnpkd3
>> lnpkd4 lnpkd5 lnpkd6 lnpmd1 lnpmd2 lnpmd3 lnpmd4 lnpmd5 lnpmd6 lnped1
>> lnped2 lnped3 lnped4 lnped5 lnped6, parameters(al ak am aq aqq blq bkq
>> bmq bqt bq1 bq2 bq3 bq4 bq5 bq6 at att blt bkt bmt d1 d2 d3 d4 d5 d6
>> bt1 bt2 bt3 bt4 bt5 bt6 bl1 bl2 bl3 bl4 bl5 bl6 bk1 bk2 bk3 bk4 bk5
>> bk6  bm1 bm2 bm3 bm4 bm5 bm6 be1 be2 be3 be4 be5 dkl dkk dml dmk dmm)
>> neq(4) ifgnls
>
> *
> *   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/
Reply | Threaded
Open this post in threaded view
|

Re: st: Return code 199 after redoing the example in stata reference

Eva Poen
Jingjing,

your program is fine, apart from some typos.

>        syntax varlist(min=8 max=8) if, at(name)

should read

syntax varlist(min=8 max=8) [if], at(name)

>        sca1ar `a1'=`at'[1,1]

should read

scalar `a1'=`at'[1,1]

(and the same in all lines with sca1ar instead of scalar)

>        sca1ar `gel'=`g14'

should read

scalar `g41'=`g14'

(or so I guess).


>                forva1ues i=1/4 {
>                        forva1ues j = 1/4 {

should read

                forvalues i=1/4 {
                        forvalues j = 1/4 {


In here:

>                replace `w1' = ///
> `a1'+`g11'*`lnp1'+`g12*`lnp2'+`g13'*`lnp3'+`g14'*`lnp4'+`b1'*(`lnm'-`lnpindex')

it should read `g12'*`lnp2' (note the closing single quote after 2).
The same is true for the three lines after this one.

With these corrections, the -nlsur- command ought to run as intended.
By the way, the names that you give to temporary variables in a
program (e.g. lnm, to which you refer to with `lnm' in the program)
have nothing to do with the variable names in the data set. You can
name your temporary variables anything you want (within Stata's rules
for tempvars), but make sure you know which one is which when you call
your program with -nlsur-.

Hope this helps,
Eva





2009/3/14  <[hidden email]>:

> Hi,
>
> Since my own codes don't work, I copyed the codes from Stata reference I-p,
> page471, example 5.
>
> I use the same codes, same data set. I only modified two things. First, I
> changed -version 10- to -version 10.1-, which is the version I am using.
> Second, I rename lnexp to lnm in the data set, because the variable is named
> lnm in their program codes. I am quite sure the other codes are exactly the
> same as the one in the book.
>
> However, when I typed the conmand in the last line, -nlsur- bla bla, there
> the error:
>
> nlsuraids returned 199
> verify that nlsuraidss is a function evaluator program
> r(199);
>
>
> That's so wireld! I list my code following:
>
>
>
> program nlsuraids
>
>        version 10.1
>
>        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
>        sca1ar `a1'=`at'[1,1]
>        sca1ar `a2'=`at'[1,2]
>        sca1ar `a3'=`at'[1,3]
>        sca1ar `a4'= 1-`a1'-`a2'-`a3'
>
>        tempname b1 b2 b3
>        sca1ar `b1'=`at'[1,4]
>        sca1ar `b2'=`at'[1,5]
>        sca1ar `b3'=`at'[1,6]
>
>
>        tempname g11 g12 g13 g14
>        tempname g21 g22 g23 g24
>        tempname g31 g32 g33 g34
>        tempname g41 g42 g43 g44
>        sca1ar `g11'=`at'[1,7]
>        sca1ar `g12'=`at'[1,8]
>        sca1ar `g13'=`at'[1,9]
>        sca1ar `g14'=-`g11'-`g12'-`g13'
>
>        sca1ar `g21'=`g12'
>        sca1ar `g22'=`at'[1,10]
>        sca1ar `g23'=`at'[1,11]
>        sca1ar `g24'=-`g21'-`g22'-`g23'
>
>        sca1ar `g31'=`g13'
>        sca1ar `g32'=`g23'
>        sca1ar `g33'=`at'[1,12]
>        sca1ar `g34'=-`g31'-`g32'-`g33'
>
>        sca1ar `gel'=`g14'
>        sca1ar `g42'=`g24'
>        sca1ar `g43'=`g34'
>        sca1ar `g44'=-`g41'-`g42'-`g43'
>
>
>        quietly {
>                tempvar lnpindex
>                gen double `lnpindex' =
> 5+`a1'*`lnp1'+`a2'*`lnp2'+`a3'*`lnp3'+`a4'*`lnp4'
>                forva1ues i=1/4 {
>                        forva1ues j = 1/4 {
>                                replace
> `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
>
> nlsur aids @ w1 w2 w3 lnp1 lnp2 lnp3 lnp4 lnm, parameters (a1 a2 a3 b1 b2 b3
> g11 g12 g13 g22 g32 g33) neq(3) ifgnls
>
>
>
> Jingjing
>
>
> 引用 Kit Baum <[hidden email]>:
>
>> <>
>> According to help nlsur what you have typed below is not the proper
>> format of the command.
>>
>>
>>        nlsur func_prog @ depvar_1 depvar_2 ...  [varlist] [if] [in]
>> [weight] , nequations(#)
>>                       {parameters(namelist)|nparameters(#)} [options]
>>
>> so you should list the depvars for the several (4?) equations, then
>> give a varlist of variables to be passed to the routine, then comma,
>> nequations() option. In what you have written below you have a ) where
>> you should not and are missing the comma. Also, either parameters() or
>> nparameters() MUST be given.
>>
>> Look at the examples at the foot of the help file for the simpler
>> example of a function evaluator program, and make sure your command
>> follows the appropriate syntax.
>>
>> Kit Baum   |   Boston College Economics and DIW Berlin   |
>> http://ideas.repec.org/e/pba1.html
>> An Introduction to Stata Programming   |
>> http://www.stata-press.com/books/isp.html
>> An Introduction to Modern Econometrics Using Stata   |
>> http://www.stata-press.com/books/imeus.html
>>
>>
>>
>> On Mar 14, 2009, at 02:33 ,Jingling wrote:
>>
>>>
>>> nlsur wellll @ lnc sl sk sm lnpl lnpk lnpm lnpe lnq halflnqlnq lnpllnq
>>> lnpklnq lnpmlnq lnpelnq lnqt lnqd1 lnqd2 lnqd3 lnqd4 lnqd5 lnqd6 t
>>> halftt lnplt lnpkt lnpmt lnpet d1 d2 d3 d4 d5 d6 td1 td2 td3 td4 td5
>>> td6 lnpld1 lnpld2 lnpld3 lnpld4 lnpld5 lnpld6 lnpkd1 lnpkd2 lnpkd3
>>> lnpkd4 lnpkd5 lnpkd6 lnpmd1 lnpmd2 lnpmd3 lnpmd4 lnpmd5 lnpmd6 lnped1
>>> lnped2 lnped3 lnped4 lnped5 lnped6, parameters(al ak am aq aqq blq bkq
>>> bmq bqt bq1 bq2 bq3 bq4 bq5 bq6 at att blt bkt bmt d1 d2 d3 d4 d5 d6
>>> bt1 bt2 bt3 bt4 bt5 bt6 bl1 bl2 bl3 bl4 bl5 bl6 bk1 bk2 bk3 bk4 bk5
>>> bk6  bm1 bm2 bm3 bm4 bm5 bm6 be1 be2 be3 be4 be5 dkl dkk dml dmk dmm)
>>> neq(4) ifgnls

*
*   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/
Reply | Threaded
Open this post in threaded view
|

Re: st: Return code 199 after redoing the example in stata reference

Crystal Li
Hi eva,

Thank you so much!

I corrected the first, third and fifth errors as you mentioned. But I  
am afraid I can not see any difference between your command and mine  
in the second and fouth points. My corrected codes are as following:

program nlsuraids

         version 10.1

         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]
         sca1ar `a2'=`at'[1,2]
         sca1ar `a3'=`at'[1,3]
         sca1ar `a4'= 1-`a1'-`a2'-`a3'

         tempname b1 b2 b3
         sca1ar `b1'=`at'[1,4]
         sca1ar `b2'=`at'[1,5]
         sca1ar `b3'=`at'[1,6]


         tempname g11 g12 g13 g14
         tempname g21 g22 g23 g24
         tempname g31 g32 g33 g34
         tempname g41 g42 g43 g44
         sca1ar `g11'=`at'[1,7]
         sca1ar `g12'=`at'[1,8]
         sca1ar `g13'=`at'[1,9]
         sca1ar `g14'=-`g11'-`g12'-`g13'

         sca1ar `g21'=`g12'
         sca1ar `g22'=`at'[1,10]
         sca1ar `g23'=`at'[1,11]
         sca1ar `g24'=-`g21'-`g22'-`g23'

         sca1ar `g31'=`g13'
         sca1ar `g32'=`g23'
         sca1ar `g33'=`at'[1,12]
         sca1ar `g34'=-`g31'-`g32'-`g33'

         sca1ar `g4l'=`g14'
         sca1ar `g42'=`g24'
         sca1ar `g43'=`g34'
         sca1ar `g44'=-`g41'-`g42'-`g43'


         quietly {
                 tempvar lnpindex
                 gen double `lnpindex' =  
5+`a1'*`lnp1'+`a2'*`lnp2'+`a3'*`lnp3'+`a4'*`lnp4'
                 forva1ues i=1/4 {
                         forva1ues j = 1/4 {
                                 replace  
`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

rename lnexp lnpm

nlsur aids @ w1 w2 w3 lnp1 lnp2 lnp3 lnp4 lnm, parameters (a1 a2 a3 b1  
b2 b3 g11 g12








Quoting Eva Poen <[hidden email]>:

> Jingjing,
>
> your program is fine, apart from some typos.
>
>>        syntax varlist(min=8 max=8) if, at(name)
>
> should read
>
> syntax varlist(min=8 max=8) [if], at(name)
>
>>        sca1ar `a1'=`at'[1,1]
>
> should read
>
> scalar `a1'=`at'[1,1]
>
> (and the same in all lines with sca1ar instead of scalar)
>
>>        sca1ar `gel'=`g14'
>
> should read
>
> scalar `g41'=`g14'
>
> (or so I guess).
>
>
>>                forva1ues i=1/4 {
>>                        forva1ues j = 1/4 {
>
> should read
>
>                 forvalues i=1/4 {
>                         forvalues j = 1/4 {
>
>
> In here:
>
>>                replace `w1' = ///
>> `a1'+`g11'*`lnp1'+`g12*`lnp2'+`g13'*`lnp3'+`g14'*`lnp4'+`b1'*(`lnm'-`lnpindex')
>
> it should read `g12'*`lnp2' (note the closing single quote after 2).
> The same is true for the three lines after this one.
>
> With these corrections, the -nlsur- command ought to run as intended.
> By the way, the names that you give to temporary variables in a
> program (e.g. lnm, to which you refer to with `lnm' in the program)
> have nothing to do with the variable names in the data set. You can
> name your temporary variables anything you want (within Stata's rules
> for tempvars), but make sure you know which one is which when you call
> your program with -nlsur-.
>
> Hope this helps,
> Eva
>
>
>
>
>
> 2009/3/14  <[hidden email]>:
>> Hi,
>>
>> Since my own codes don't work, I copyed the codes from Stata reference I-p,
>> page471, example 5.
>>
>> I use the same codes, same data set. I only modified two things. First, I
>> changed -version 10- to -version 10.1-, which is the version I am using.
>> Second, I rename lnexp to lnm in the data set, because the variable is named
>> lnm in their program codes. I am quite sure the other codes are exactly the
>> same as the one in the book.
>>
>> However, when I typed the conmand in the last line, -nlsur- bla bla, there
>> the error:
>>
>> nlsuraids returned 199
>> verify that nlsuraidss is a function evaluator program
>> r(199);
>>
>>
>> That's so wireld! I list my code following:
>>
>>
>>
>> program nlsuraids
>>
>>        version 10.1
>>
>>        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
>>        sca1ar `a1'=`at'[1,1]
>>        sca1ar `a2'=`at'[1,2]
>>        sca1ar `a3'=`at'[1,3]
>>        sca1ar `a4'= 1-`a1'-`a2'-`a3'
>>
>>        tempname b1 b2 b3
>>        sca1ar `b1'=`at'[1,4]
>>        sca1ar `b2'=`at'[1,5]
>>        sca1ar `b3'=`at'[1,6]
>>
>>
>>        tempname g11 g12 g13 g14
>>        tempname g21 g22 g23 g24
>>        tempname g31 g32 g33 g34
>>        tempname g41 g42 g43 g44
>>        sca1ar `g11'=`at'[1,7]
>>        sca1ar `g12'=`at'[1,8]
>>        sca1ar `g13'=`at'[1,9]
>>        sca1ar `g14'=-`g11'-`g12'-`g13'
>>
>>        sca1ar `g21'=`g12'
>>        sca1ar `g22'=`at'[1,10]
>>        sca1ar `g23'=`at'[1,11]
>>        sca1ar `g24'=-`g21'-`g22'-`g23'
>>
>>        sca1ar `g31'=`g13'
>>        sca1ar `g32'=`g23'
>>        sca1ar `g33'=`at'[1,12]
>>        sca1ar `g34'=-`g31'-`g32'-`g33'
>>
>>        sca1ar `gel'=`g14'
>>        sca1ar `g42'=`g24'
>>        sca1ar `g43'=`g34'
>>        sca1ar `g44'=-`g41'-`g42'-`g43'
>>
>>
>>        quietly {
>>                tempvar lnpindex
>>                gen double `lnpindex' =
>> 5+`a1'*`lnp1'+`a2'*`lnp2'+`a3'*`lnp3'+`a4'*`lnp4'
>>                forva1ues i=1/4 {
>>                        forva1ues j = 1/4 {
>>                                replace
>> `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
>>
>> nlsur aids @ w1 w2 w3 lnp1 lnp2 lnp3 lnp4 lnm, parameters (a1 a2 a3 b1 b2 b3
>> g11 g12 g13 g22 g32 g33) neq(3) ifgnls
>>
>>
>>
>> Jingjing
>>
>>
>> 引用 Kit Baum <[hidden email]>:
>>
>>> <>
>>> According to help nlsur what you have typed below is not the proper
>>> format of the command.
>>>
>>>
>>>        nlsur func_prog @ depvar_1 depvar_2 ...  [varlist] [if] [in]
>>> [weight] , nequations(#)
>>>                       {parameters(namelist)|nparameters(#)} [options]
>>>
>>> so you should list the depvars for the several (4?) equations, then
>>> give a varlist of variables to be passed to the routine, then comma,
>>> nequations() option. In what you have written below you have a ) where
>>> you should not and are missing the comma. Also, either parameters() or
>>> nparameters() MUST be given.
>>>
>>> Look at the examples at the foot of the help file for the simpler
>>> example of a function evaluator program, and make sure your command
>>> follows the appropriate syntax.
>>>
>>> Kit Baum   |   Boston College Economics and DIW Berlin   |
>>> http://ideas.repec.org/e/pba1.html
>>> An Introduction to Stata Programming   |
>>> http://www.stata-press.com/books/isp.html
>>> An Introduction to Modern Econometrics Using Stata   |
>>> http://www.stata-press.com/books/imeus.html
>>>
>>>
>>>
>>> On Mar 14, 2009, at 02:33 ,Jingling wrote:
>>>
>>>>
>>>> nlsur wellll @ lnc sl sk sm lnpl lnpk lnpm lnpe lnq halflnqlnq lnpllnq
>>>> lnpklnq lnpmlnq lnpelnq lnqt lnqd1 lnqd2 lnqd3 lnqd4 lnqd5 lnqd6 t
>>>> halftt lnplt lnpkt lnpmt lnpet d1 d2 d3 d4 d5 d6 td1 td2 td3 td4 td5
>>>> td6 lnpld1 lnpld2 lnpld3 lnpld4 lnpld5 lnpld6 lnpkd1 lnpkd2 lnpkd3
>>>> lnpkd4 lnpkd5 lnpkd6 lnpmd1 lnpmd2 lnpmd3 lnpmd4 lnpmd5 lnpmd6 lnped1
>>>> lnped2 lnped3 lnped4 lnped5 lnped6, parameters(al ak am aq aqq blq bkq
>>>> bmq bqt bq1 bq2 bq3 bq4 bq5 bq6 at att blt bkt bmt d1 d2 d3 d4 d5 d6
>>>> bt1 bt2 bt3 bt4 bt5 bt6 bl1 bl2 bl3 bl4 bl5 bl6 bk1 bk2 bk3 bk4 bk5
>>>> bk6  bm1 bm2 bm3 bm4 bm5 bm6 be1 be2 be3 be4 be5 dkl dkk dml dmk dmm)
>>>> neq(4) ifgnls
>
> *
> *   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/
Reply | Threaded
Open this post in threaded view
|

Re: st: Return code 199 after redoing the example in stata reference

Christopher F Baum
In reply to this post by Crystal Li
<>
The word is s c a L a r.  Eva pointed that out quite clearly.


Kit Baum   |   Boston College Economics and DIW Berlin   |   http://ideas.repec.org/e/pba1.html
An Introduction to Stata Programming   |   http://www.stata-press.com/books/isp.html
An Introduction to Modern Econometrics Using Stata   |   http://www.stata-press.com/books/imeus.html



On Mar 15, 2009, at 02:33 , Jingjing wrote:

>         sca1ar `a2'=`at'[1,2]
>         sca1ar `a3'=`at'[1,3]
>         sca1ar `a4'= 1-`a1'-`a2'-`a3'
>
>         tempname b1 b2 b3
>         sca1ar `b1'=`at'[1,4]
>         sca1ar `b2'=`at'[1,5]
>         sca1ar `b3'=`at'[1,6]

etc.
*
*   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/
Reply | Threaded
Open this post in threaded view
|

RE: Re: st: Return code 199 after redoing the example in stata reference

Glenn Goldsmith
In reply to this post by Crystal Li
I wouldn't be too harsh here, Kit; they're very difficult to distinguish in
some fonts...

...which leads to the generic advice: make sure you work in a font that
clearly distinguishes between 1 (one) and l (lowercase el).

So for example: Lucida Console good; but Times New Roman and Courier New
(especially 8 point or below) not so much.

I learned this lesson the hard way. ;)

Best,

Glenn.


Kit Baum <[hidden email]> wrote:
<>
The word is s c a L a r.  Eva pointed that out quite clearly.


Kit Baum   |   Boston College Economics and DIW Berlin   |
http://ideas.repec.org/e/pba1.html
An Introduction to Stata Programming   |
http://www.stata-press.com/books/isp.html
An Introduction to Modern Econometrics Using Stata   |
http://www.stata-press.com/books/imeus.html



On Mar 15, 2009, at 02:33 , Jingjing wrote:

        sca1ar `a2'=`at'[1,2]
        sca1ar `a3'=`at'[1,3]
        sca1ar `a4'= 1-`a1'-`a2'-`a3'

        tempname b1 b2 b3
        sca1ar `b1'=`at'[1,4]
        sca1ar `b2'=`at'[1,5]
        sca1ar `b3'=`at'[1,6]

etc.

       


*
*   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/
Reply | Threaded
Open this post in threaded view
|

Re: st: Return code 199 after redoing the example in stata reference

Eva Poen
In reply to this post by Christopher F Baum
This message that I sent earlier has not made it through to the list;
I therefore re-send it. My apologies, should it appear twice.

Eva
***************************

 Jingjing,

 Also, take a look at the following line:

 > sca1ar `g4l'=`g14'

 You want `g41' here, not `g4l' (i.e. the number 1 instead of the
 letter l, as in life). With the commands  -scalar- and -forvalues- it's the
 other way round (you have the number 1 in those commands where
 you should have the letter l). See also -help scalar-
 and -help forvalues-.

 Oh, and I just noticed that your line

 > replace `w3' =
`a3'+`g31'*`lnp1'+`g32*`lnp2'+`g33'*`lnp3'+`g34'*`lnp4'+`b3'*(`lnm'-`lnpindex')

 still lacks a closing single quote after `g32. You want:

 replace `w3' =
`a3'+`g31'*`lnp1'+`g32'*`lnp2'+`g33'*`lnp3'+`g34'*`lnp4'+`b3'*(`lnm'-`lnpindex')


 Eva

>
>
>
> 2009/3/15 Kit Baum <[hidden email]>:
>> <>
>> The word is s c a L a r.  Eva pointed that out quite clearly.
>>
>>
>> Kit Baum   |   Boston College Economics and DIW Berlin   |
>> http://ideas.repec.org/e/pba1.html
>> An Introduction to Stata Programming   |
>> http://www.stata-press.com/books/isp.html
>> An Introduction to Modern Econometrics Using Stata   |
>> http://www.stata-press.com/books/imeus.html
>>
>>
>>
>> On Mar 15, 2009, at 02:33 , Jingjing wrote:
>>
>>>        sca1ar `a2'=`at'[1,2]
>>>        sca1ar `a3'=`at'[1,3]
>>>        sca1ar `a4'= 1-`a1'-`a2'-`a3'
>>>
>>>        tempname b1 b2 b3
>>>        sca1ar `b1'=`at'[1,4]
>>>        sca1ar `b2'=`at'[1,5]
>>>        sca1ar `b3'=`at'[1,6]
>>
>> etc.
>> *
>

*
*   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/
Reply | Threaded
Open this post in threaded view
|

st: Re: RE: CASE-CONTROL STUDY

Ishay Barat
In reply to this post by Kieran McCaul
Dear Kieran and David



There can be lots of arguments why one designs backwards study and not
forward one. In my case, I am responsible for a lot of patients, going
through my department, and need form time to time to have quality control of
our patients management. It would have been nice to have a quarter of a
million $ and 3 years time to carry on a study, but that's not reality.



Sorry.



And now for your question.



As my objective is geriatric patients, and my data includes general inter
medicine ward cliental I like to reduce the noise younger and far healthier
patients introduces into my data.

By matching some crucial parameters like age, sex, medication and disease, I
may get answers to my questions.



As to my anagram. It is just for fun and nothing else.



As to the reference to
http://personalpages.manchester.ac.uk/staff/mark.lunt/optmatch.html

I installed the files, but can not find the command in the menus.




*¸..· ´¨)) -:¦:-        *
    ¸.·´ .
  (( -:¦:- * Ishay *  -:¦:-
    ´·..          ..·´
               ((¸¸.·´* -:¦:-

_________________________________________________________-


> Matching is an element of the design of a study, planned before the data
> is collected, and should be done for efficiency, not control.
> If you already have the data, you gain nothing by matching.  You have a
> sample size of 2,500.  If you match these data in the way you have
> indicated, you will end up with a matched sample size of 1,200.  Why would
> you want to discard over half of your data?
>
> You should analyse the data as they are and control for age, sex, etc in
> the analysis.
>
>
> ______________________________________________
> Kieran McCaul MPH PhD
> WA Centre for Health & Ageing (M573)
> University of Western Australia
> Level 6, Ainslie House
> 48 Murray St
> Perth 6000
> Phone: (08) 9224-2140
> Fax: (08) 9224 8009
> email: [hidden email]
> http://myprofile.cos.com/mccaul
> http://www.researcherid.com/rid/B-8751-2008
> ______________________________________________
> Epidemiology is so beautiful and provides such an important perspective on
> human life and death,
> but an incredible amount of rubbish is published.  Richard Peto (2007)
>
> -----Original Message-----
> From: [hidden email]
> [mailto:[hidden email]] On Behalf Of Ishay Barat
> Sent: Sunday, 15 March 2009 1:28 AM
> To: [hidden email]
> Subject: st: CASE-CONTROL STUDY
>
> HELLO
>
>
>
> I've got a data set containing about 2500 patients, of which 300 have my
> interest (Group A).
>
> I would like to extract a sample of 900 patients (Group B) out of the data
> set that match Group A in age, sex and some other parameters. A Classical
> Case-Control study with 3 controllers for each case.
>
>
>
> Is anybody have a clue how the syntax look like??
>
>
>
>
>
>
> *¸..· ´¨)) -:¦:-        *
>    ¸.·´ .
>  (( -:¦:- * Ishay *  -:¦:-
>    ´·..          ..·´
>               ((¸¸.·´* -:¦:-
>
> *
> *   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/
>
>
> --
> No virus found in this incoming message.
> Checked by AVG.
> Version: 7.5.557 / Virus Database: 270.11.13 - Release Date: 13-03-2009
> 00:00
>
>

*
*   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/
Reply | Threaded
Open this post in threaded view
|

Re: st: Re: RE: CASE-CONTROL STUDY

Airey, David C
.

There is at that URL, optmatch2.ado and optmatch2.hlp.

You can save these files where Stata wants them, and then they will be  
available to you at the Stata command line. There won't be any menus.

You might also track don't the author. He has offered email assistance  
using this program.

-Dave

----------------------------------------------------------------------------------------
help for optmatch2
----------------------------------------------------------------------------------------

Optimal Matching

Syntax

         optmatch2 casecontrol varlist [if] [in] [, options ]

     options               description
     
----------------------------------------------------------------------------------
     Main
       minc(#)              Minimum control:case ratio.
       maxc(#)              Maximum number of controls per set.
       nc(#)                Total number of controls to include in  
match.
       gen(newvar)          A new variable to contain the number of  
the case-control
                             set each subject belongs to.
       caliper(#)           Limit on acceptable matching.
       measure(string)      Type of dissimilarity measure to use.
       epsilon(#)           Stability constant.
       repeat               If requested number of controls cannot be  
matched, produce
                             match with as many controls as possible.
     
----------------------------------------------------------------------------------

Description

     The command optmatch2 performs optimal matching using the network  
flow methodology
     outlined in Rosenbaum(1989).  The variable casecontrol contains 1  
for cases and 0
     for controls. The variable(s) on which matching is to be  
performed are given by
     varlist. If there is more than one variable in varlist, there are  
a number of ways
     of calculating a distance between a case and a control: see the  
option measure
     below for more information.

Options        +------+
            ----+ Main  
+---------------------------------------------------------------

     minc(#) Minimum control:case ratio. May be less than 1:  e.g. 0.5  
means the same
         control can be mapped to 2 cases. Default value is 1.
     maxc(#) Maximum number of controls per case-control set. Must be  
an integer >= 1:
         default value is 1
     nc(#) Total number of controls to be used in the match. Defaults  
to the all
         controls in the dataset. Can be set to any integer less than  
or equal to this:
         requesting more controls than exist in the dataset will cause  
optmatch2 to
         fail with an error message.
     gen(newvar) If given, this will create a new variable containing  
an identifier for
         the case-control set this individual belongs to. If it is not  
given, a
         variable called set is created, unless it already exists in  
which case
         optmatch2 will fail with an error message.
     caliper(#) This sets the maximum allowable discrepancy between a  
case and a
         control within a matched set. By default, no caliper is set  
and every control
         can, in theory, be matched to any case.
     measure(string) This is only of importance if there are more than  
one variable in
         varlist. In this case, it determines the metric to use when  
converting
         differences in several variables to one overall dissimilarity  
measure. The
         standard measures that stata can use are outline in  
measure_option. Of these,
         optmatch2 can use L(#), Lpower(#) and Linfinity and their  
various aliases,
         with the default being L2. In addition, it can accept a value  
mahal to use the
         Mahalonobis distance.
     epsilon(#) Default value is 0.000001. Technically, the optimal  
matching method
         only works if all discrepancies between cases and controls  
are greater than
         zero. This value is added to all discrepancies to ensure that  
this is the
         case. The value of epsilon can affect the matching if (opt  
minc} < 1: see
         Hansen and Klopfer (2006) for a discussion of this.
     repeat It may be impossible for optmatch2 to find a matching that  
matches the
         requested number of controls (nc). This may be a logical  
impossibility (there
         are not that many controls in the data) or an empirical one  
(if you use
         caliper to define the maximum allowable discrepancy in a  
match, it may not be
         possible to match all controls to a case). If you give the  
repeat option, it
         will report how many controls it can match, then perform the  
matching with
         that number of controls. Otherwise, it will simply report the  
maximum number
         of controls it could match.

Remarks

     The command optmatch2 produces matched sets, that is groups  
consisting of one or
     more cases and one or more controls, with the dissimilarities  
between subjects in
     a set being as small as possible. By default, it produces matched  
pairs (1 case
     and 1 control), but this can be changed using the options minc,  
maxc and nc. For
     example, minc(1) maxc(1) will produce the default 1 to 1  
matching, whilst minc(3)
     maxc(3) will produce sets which all consist of 1 case and 3  
controls.

     More complex matchings can be achieved by using values of minc  
less than 1. For
     example, minc(0.5) maxc(2) will produce sets consisting of either  
1 control and 2
     cases, 1 control and 1 case or 2 controls and 1 case.

References

     Ben B. Hansen and Stephanie Olsen Klopfer:  "Optimal Full  
Matching and Related
         Designs via Network Flows" (2006) Journal of Computational  
and Graphical
         Statistics 15(3):  609-627.

     Paul R. Rosenbaum "Optimal Matching for Observational  
Studies" (1989) JASA
         84(408): 1024-1302.

Author

     Mark Lunt, ARC Epidemiology Unit

     The University of Manchester

     Please email [hidden email] if you encounter problems  
with this
     program


On Mar 15, 2009, at 11:52 AM, Ishay Barat wrote:

> Dear Kieran and David
>
>
>
> There can be lots of arguments why one designs backwards study and  
> not forward one. In my case, I am responsible for a lot of patients,  
> going through my department, and need form time to time to have  
> quality control of our patients management. It would have been nice  
> to have a quarter of a million $ and 3 years time to carry on a  
> study, but that's not reality.
>
>
>
> Sorry.
>
>
>
> And now for your question.
>
>
>
> As my objective is geriatric patients, and my data includes general  
> inter medicine ward cliental I like to reduce the noise younger and  
> far healthier patients introduces into my data.
>
> By matching some crucial parameters like age, sex, medication and  
> disease, I may get answers to my questions.
>
>
>
> As to my anagram. It is just for fun and nothing else.
>
>
>
> As to the reference to http://personalpages.manchester.ac.uk/staff/mark.lunt/optmatch.html
>
> I installed the files, but can not find the command in the menus.
>
>
>
>
> *¸..· ´¨)) -:¦:-        *
>   ¸.·´ .
> (( -:¦:- * Ishay *  -:¦:-
>   ´·..          ..·´
>              ((¸¸.·´* -:¦:-
>
> _________________________________________________________-
>
>
>> Matching is an element of the design of a study, planned before the  
>> data is collected, and should be done for efficiency, not control.
>> If you already have the data, you gain nothing by matching.  You  
>> have a sample size of 2,500.  If you match these data in the way  
>> you have indicated, you will end up with a matched sample size of  
>> 1,200.  Why would you want to discard over half of your data?
>>
>> You should analyse the data as they are and control for age, sex,  
>> etc in the analysis.
>>
>>
>> ______________________________________________
>> Kieran McCaul MPH PhD
>> WA Centre for Health & Ageing (M573)
>> University of Western Australia
>> Level 6, Ainslie House
>> 48 Murray St
>> Perth 6000
>> Phone: (08) 9224-2140
>> Fax: (08) 9224 8009
>> email: [hidden email]
>> http://myprofile.cos.com/mccaul
>> http://www.researcherid.com/rid/B-8751-2008
>> ______________________________________________
>> Epidemiology is so beautiful and provides such an important  
>> perspective on human life and death,
>> but an incredible amount of rubbish is published.  Richard Peto  
>> (2007)
>>
>> -----Original Message-----
>> From: [hidden email] [mailto:[hidden email]
>> ] On Behalf Of Ishay Barat
>> Sent: Sunday, 15 March 2009 1:28 AM
>> To: [hidden email]
>> Subject: st: CASE-CONTROL STUDY
>>
>> HELLO
>>
>>
>>
>> I've got a data set containing about 2500 patients, of which 300  
>> have my
>> interest (Group A).
>>
>> I would like to extract a sample of 900 patients (Group B) out of  
>> the data
>> set that match Group A in age, sex and some other parameters. A  
>> Classical
>> Case-Control study with 3 controllers for each case.
>>
>>
>>
>> Is anybody have a clue how the syntax look like??
>>
>>
>>
>>
>>
>>
>> *¸..· ´¨)) -:¦:-        *
>>   ¸.·´ .
>> (( -:¦:- * Ishay *  -:¦:-
>>   ´·..          ..·´
>>              ((¸¸.·´* -:¦:-
>>
>> *
>> *   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/
>>
>>
>> --
>> No virus found in this incoming message.
>> Checked by AVG.
>> Version: 7.5.557 / Virus Database: 270.11.13 - Release Date:  
>> 13-03-2009 00:00
>>
>
> *
> *   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/
Reply | Threaded
Open this post in threaded view
|

st: Return r(111) this time

Crystal Li
In reply to this post by Eva Poen
Thanks Eva! You are so nice and patient.

After correcting all the typo you mentioned, the codes for the example works.

However, in my own program, there's r(111) even correcting all the  
similar typo. I am not sure if r(11) is still a kind of error that  
caused by typo or other big errors. If it's caused by typo, I will  
check it again and agian until it works. What I am worried about is  
that it's the codes designing errors.

My codes is:

program nlsurweb

         version 10.1

         syntax varlist(min=16 max=16) [if], at(name)

         tokenize `varlist'
         args lnc sl sk sm lnpl lnpk lnpm lnpe lnq t d1 d2 d3 d4 d5 d6

         tempname al ak am ae
         scalar `al'=`at'[1,1]
         scalar `ak'=`at'[1,2]
         scalar `am'=`at'[1,3]
         scalar `ae'=1-`al'-`ak'-`am'

         tempname aq aqq
         scalar `aq'=`at'[1,4]
         scalar `aqq'=at'[1,5]

         tempname blq bkq bmq beq
         scalar `blq'=`at'[1,6]
         scalar `bkq'=`at'[1,7]
         scalar `bmq'=`at'[1,8]
         scalar `beq'=-`blq'-`bkq'-`bmq'

         tempname bqt bq1 bq2 bq3 bq4 bq5 bq6
         scalar `bqt'=`at'[1,9]
         scalar `bq1'=`at'[1,10]
         scalar `bq2'=`at'[1,11]
         scalar `bq3'=`at'[1,12]
         scalar `bq4'=`at'[1,13]
         scalar `bq5'=`at'[1,14]
         scalar `bq6'=`at'[1,15]

         tempname at att blt bkt bmt bet
         scalar `ai'=`at'[1,16]
         scalar `aii'=`at'[1,17]
         scalar `blt'=`at'[1,18]
         scalar `bkt'=`at'[1,19]
         scalar `bmt'=`at'[1,20]
         scalar `bet'=-`blt'-`bkt'-`bmt'

         tempname ad1 ad2 ad3 ad4 ad5 ad6 bt1 bt2 bt3 bt4 bt5 bt6
         scalar `ad1'=`at'[1,21]
         scalar `ad2'=`at'[1,22]
         scalar `ad3'=`at'[1,23]
         scalar `ad4'=`at'[1,24]
         scalar `ad5'=`at'[1,25]
         scalar `ad6'=`at'[1,26]
         scalar `bt1'=`at'[1,27]
         scalar `bt2'=`at'[1,28]
         scalar `bt3'=`at'[1,29]
         scalar `bt4'=`at'[1,30]
         scalar `bt5'=`at'[1,31]
         scalar `bt6'=`at'[1,32]

         tempname bl1 bl2 bl3 bl4 bl5 bl6 bk1 bk2 bk3 bk4 bk5 bk6  bm1  
bm2 bm3 bm4 bm5 bm6  be1 be2 be3 be4 be5 be6
         scalar `bl1'=`at'[1,33]
         scalar `bl2'=`at'[1,34]
         scalar `bl3'=`at'[1,35]
         scalar `bl4'=`at'[1,36]
         scalar `bl5'=`at'[1,37]
         scalar `bl6'=`at'[1,38]
         scalar `bk1'=`at'[1,39]
         scalar `bk2'=`at'[1,40]
         scalar `bk3'=`at'[1,41]
         scalar `bk4'=`at'[1,42]
         scalar `bk5'=`at'[1,43]
         scalar `bk6'=`at'[1,44]
         scalar `bm1'=`at'[1,45]
         scalar `bm2'=`at'[1,46]
         scalar `bm3'=`at'[1,47]
         scalar `bm4'=`at'[1,48]
         scalar `bm5'=`at'[1,49]
         scalar `bm6'=`at'[1,50]
         scalar `be1'=`at'[1,51]
         scalar `be2'=`at'[1,52]
         scalar `be3'=`at'[1,53]
         scalar `be4'=`at'[1,54]
         scalar `be5'=`at'[1,55]
         scalar  
`be6'=-`bl1'-`bl2'-`bl3'-`bl4'-`bl5'-`bl6'-`bm1'-`bm2'-`bm3'-`bm4'-`bm5'-`bm6'-`bk1'-`bk2'-`bk3'-`bk4'-`bk5'-`bk6'-`be1'-`be2'-`be3'-`be4'-`be5'

         tempname dll dkl dkk dml dmk dmm
         scalar `dll'=`at'[1,56]
         scalar `dkl'=`at'[1,57]
         scalar `dkk'=`at'[1,58]
         scalar `dml'=`at'[1,59]
         scalar `dmk'=`at'[1,60]
         scalar `dmm'=`at'[1,61]


         quietly {

replace lnc =  
5+`aq'*`lnq'+`al'*`lnpl'+`ak'*`lnpk'+`am'*`lnpm'+(1-`al'-`ak'-`am')*`lnpe'+`blq'*`lnpl'*`lnq'+`bkq'*`lnpk'*`lnq'+`bmq'*`lnpm'*`lnq'+(-`blq'-`bkq'-`bmq')*`lnpe'*`lnq'+`aqq'*0.5*`lnq'*`lnq'+`ay'*`t'+`att'*0.5*`t'*`t'+`blt'*`lnpl'*`t'+`bkt'*`lnpk'*`t'+`bmt'*`lnpm'*`t'+(-`blt'-`bkt'-`bmt')*`lnpe'*`t'+`bqt'*`lnq'*`t'+`ad1'*`d1'+`ad2'*`d2'+`ad3'*`d3'+`ad4'*`d4'+`ad5'*`d5'+`ad6'*`d6'+`bl1'*`lnpl'*`d1'+`bl2'*`lnpl'*`d2'+`bl3'*`lnpl'*`d3'+`bl4'*`lnpl'*`d4'+`bl5'*`lnpl'*`d5'+`bl6'*`lnpl'*`d6'+`bk1'*`lnpk'*`d1'+`bk2'*`lnpk'*`d2'+`bk3'*`lnpk'*`d3'+`bk4'*`lnpk'*`d4'+`bk5'*`lnpk'*`d5'+`bk6'*`lnpk'*`d6'+`bm1'*`lnpm'*`d1'+`bm2'*`lnpm'*`d2'+`bm3'*`lnpm'*`d3'+`bm4'*`lnpm'*`d4'+`bm5'*`lnpm'*`d5'+`bm6'*`lnpm'*`d6'+`be1'*`lnpe'*`d1'+`be2'*`lnpe'*`d2'+`be3'*`lnpe'*`d3'+`be4'*`lnpe'*`d4'+`be5'*`lnpe'*`d5'+(-`bl1'-`bl2'-`bl3'-`bl4'-`bl5'-`bl6'-`bm1'-`bm2'-`bm3'-`bm4'-`bm5'-`bm6'-`bk1'-`bk2'-`bk3'-`bk4'-`bk5'-`bk6'-`be1'-`be2'-`be3'-`be4'-`be5')*`lnpe'*`d6'+`bq1'*`lnq'*`d1'+`bq2'*`lnq'*`d2'+`bq3'*`lnq'*`d3'+
`bq4'*`lnq'*`d4'+`bq5'*`lnq'*`d5'+`bq6'*`lnq'*`d6'+`bt1'*`t'*`d1'+`bt2'*`t'*`d2'+`bt3'*`t'*`d3'+`bt4'*`t'*`d4'+`bt5'*`t'*`d5'+`bt6'*`t'*`d6'+(-`dll'*`dll'+`al'-`al'*`al')*0.5*`lnpl'*`lnpl'+(-`dll'*`dkl'-`al'*`ak')*`lnpl'*`lnpk'+(-`dll'*`dml'-`al'*`am')*`lnpl'*`lnpm'+(`dll'*`dll'-`al'+`al'*`al'+`dll'*`dkl'+`al'*`ak'+`dll'*`dml'+`al'*`am')*`lnpl'*`lnpe'+(-`dkl'*`dkl'-`dkk'*`dkk'+`ak'-`ak'*`ak')*0.5*`lnpk'*`lnpk'+(-`dkl'*`dml'-`dkk'*`dmk'-`ak'*`am')*`lnpk'*`lnpm'+(`dll'*`dkl'+`al'*`ak'+`dkl'*`dkl'+`dkk'*`dkk'-`ak'+`ak'*`ak'+`dkl'*`dml'+`dkk'*`dmk'+`ak'*`am')*`lnpk'*`lnpe'+(-`dml'*`dml'-`dmk'*`dmk'-`dmm'*`dmm'+`am'-`am'*`am')*0.5*`lnpm'*`lnpm'+(`dll'*`dml'+`al'*`am'+`dkl'*`dml'+`dkk'*`dmk'+`ak'*`am'+`dml'*`dml'+`dmk'*`dmk'+`dmm'*`dmm'-`am'+`am'*`am')*`lnpm'*`lnpe'+(-`dll'*`dll'+`al'-`al'*`al'-`dll'*`dkl'-`al'*`ak'-`dll'*`dml'-`al'*`am'-`dll'*`dml'-`al'*`am'-`dkl'*`dml'-`dkk'*`dmk'-`ak'*`am'-`dml'*`dml'-`dmk'*`dmk'-`dmm'*`dmm'+`am'-`am'*`am'-`dll'*`dkl'-`al'*`ak'-`dkl'*`dkl'-`dkk'*`dkk'+`
ak'-`ak'*`ak'-`dkl'*`dml'-`dkk'*`dmk'-`ak'*`am')*0.5*`lnpe'*`lnpe'



                 replace sl =  
`al'+`blq'*`lnq'+(-`dll'+`al'-`al'*`al')*`lnpl'+(-`dll'*`dkl'-`al'*`ak')*`lnpk'+(-`dll'*`dml'-`al'*`am')*`lnpm'+(`dll'-`al'+`al'*`al'+`dll'*`dkl'+`al'*`ak'+`dll'*`dml'+`al'*`am')*`lnpe'+`blt'*`t'+`bl1'*`d1'+`bl2'*`d2'+`bl3'*`d3'+`bl4'*`d4'+`bl5'*`d5'+`bl6'*`d6'


                 replace sk =  
`ak'+`bkq'*`lnq'+(-`dll'*`dkl'-`al'*`ak')*`lnpl'+(-`dkl'*`dkl'-`dkk'*`dkk'+`ak'-`ak'*`ak')*`lnpk'+(-`dkl'*`dml'-`dkk'*`dmk'-`ak'*`am')*`lnpm'+(`dll'*`dkl'+`al'*`ak'+`dkl'*`dkl'+`dkk'*`dkk'-`ak'+`ak'*`ak'+`dkl'*`dml'+`dkk'*`dmk'+`ak'*`am')*`lnpe'+`bkt'*`t'+`bk1'*`d1'+`bk2'*`d2'+`bk3'*`d3'+`bk4'*`d4'+`bk5'*`d5'+`bk6'*`d6'


                 replace sm =  
`am'+`bmq'*`lnq'+(-`dll'*`dml'-`al'*`am')*`lnpl'+(-`dkl'*`dml'-`dkk'*`dmk'-`ak'*`am')*`lnpk'+(-`dml'*`dml'-`dmk'*`dmk'-`dmm'*`dmm'+`am'-`am'*`am')*`lnpm'+(`dll'*`dml'+`al'*`am'+`dkl'*`dml'+`dkk'*`dmk'+`ak'*`am'+`dml'*`dml'+`dmk'*`dmk'+`dmm'*`dmm'-`am'+`am'*`am')*`lnpe'+`bmt'*`t'+`bm1'*`d1'+`bm2'*`d2'+`bm3'*`d3'+`bm4'*`d4'+`bm5'*`d5'+`bm6'*`d6'




         }

end

nlsur web @ lnc sl sk sm lnpl lnpk lnpm lnpe lnq t d1 d2 d3 d4 d5 d6,  
parameters(al ak am aq aqq blq bkq bmq bqt bq1 bq2 bq3 bq4 bq5 bq6 ai  
aii blt bkt bmt ad1 ad2 ad3 ad4 ad5 ad6 bt1 bt2 bt3 bt4 bt5 bt6 bl1  
bl2 bl3 bl4 bl5 bl6 bk1 bk2 bk3 bk4 bk5 bk6  bm1 bm2 bm3 bm4 bm5 bm6  
be1 be2 be3 be4 be5 dll dkl dkk dml dmk dmm) neq(4) ifgnls






Quoting Eva Poen <[hidden email]>:

> This message that I sent earlier has not made it through to the list;
> I therefore re-send it. My apologies, should it appear twice.
>
> Eva
> ***************************
>
>  Jingjing,
>
>  Also, take a look at the following line:
>
>  > sca1ar `g4l'=`g14'
>
>  You want `g41' here, not `g4l' (i.e. the number 1 instead of the
>  letter l, as in life). With the commands  -scalar- and -forvalues- it's the
>  other way round (you have the number 1 in those commands where
>  you should have the letter l). See also -help scalar-
>  and -help forvalues-.
>
>  Oh, and I just noticed that your line
>
>  > replace `w3' =
> `a3'+`g31'*`lnp1'+`g32*`lnp2'+`g33'*`lnp3'+`g34'*`lnp4'+`b3'*(`lnm'-`lnpindex')
>
>  still lacks a closing single quote after `g32. You want:
>
>  replace `w3' =
> `a3'+`g31'*`lnp1'+`g32'*`lnp2'+`g33'*`lnp3'+`g34'*`lnp4'+`b3'*(`lnm'-`lnpindex')
>
>
>  Eva
>
>>
>>
>>
>> 2009/3/15 Kit Baum <[hidden email]>:
>>> <>
>>> The word is s c a L a r.  Eva pointed that out quite clearly.
>>>
>>>
>>> Kit Baum   |   Boston College Economics and DIW Berlin   |
>>> http://ideas.repec.org/e/pba1.html
>>> An Introduction to Stata Programming   |
>>> http://www.stata-press.com/books/isp.html
>>> An Introduction to Modern Econometrics Using Stata   |
>>> http://www.stata-press.com/books/imeus.html
>>>
>>>
>>>
>>> On Mar 15, 2009, at 02:33 , Jingjing wrote:
>>>
>>>>        sca1ar `a2'=`at'[1,2]
>>>>        sca1ar `a3'=`at'[1,3]
>>>>        sca1ar `a4'= 1-`a1'-`a2'-`a3'
>>>>
>>>>        tempname b1 b2 b3
>>>>        sca1ar `b1'=`at'[1,4]
>>>>        sca1ar `b2'=`at'[1,5]
>>>>        sca1ar `b3'=`at'[1,6]
>>>
>>> etc.
>>> *
>>
>
> *
> *   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/
Reply | Threaded
Open this post in threaded view
|

st: RE: Return r(111) this time

Nick Cox
scalar `aqq'=at'[1,5]

is another typo. I didn't try finding any others.

Do please find out about -set trace-, today!

P.S. A bug here is that your program allows -if- but ignores it.

Nick
[hidden email]

[hidden email]

Thanks Eva! You are so nice and patient.

After correcting all the typo you mentioned, the codes for the example works.

However, in my own program, there's r(111) even correcting all the  
similar typo. I am not sure if r(11) is still a kind of error that  
caused by typo or other big errors. If it's caused by typo, I will  
check it again and agian until it works. What I am worried about is  
that it's the codes designing errors.

My codes is:

program nlsurweb

         version 10.1

         syntax varlist(min=16 max=16) [if], at(name)

         tokenize `varlist'
         args lnc sl sk sm lnpl lnpk lnpm lnpe lnq t d1 d2 d3 d4 d5 d6

         tempname al ak am ae
         scalar `al'=`at'[1,1]
         scalar `ak'=`at'[1,2]
         scalar `am'=`at'[1,3]
         scalar `ae'=1-`al'-`ak'-`am'

         tempname aq aqq
         scalar `aq'=`at'[1,4]
         scalar `aqq'=at'[1,5]

         tempname blq bkq bmq beq
         scalar `blq'=`at'[1,6]
         scalar `bkq'=`at'[1,7]
         scalar `bmq'=`at'[1,8]
         scalar `beq'=-`blq'-`bkq'-`bmq'

         tempname bqt bq1 bq2 bq3 bq4 bq5 bq6
         scalar `bqt'=`at'[1,9]
         scalar `bq1'=`at'[1,10]
         scalar `bq2'=`at'[1,11]
         scalar `bq3'=`at'[1,12]
         scalar `bq4'=`at'[1,13]
         scalar `bq5'=`at'[1,14]
         scalar `bq6'=`at'[1,15]

         tempname at att blt bkt bmt bet
         scalar `ai'=`at'[1,16]
         scalar `aii'=`at'[1,17]
         scalar `blt'=`at'[1,18]
         scalar `bkt'=`at'[1,19]
         scalar `bmt'=`at'[1,20]
         scalar `bet'=-`blt'-`bkt'-`bmt'

         tempname ad1 ad2 ad3 ad4 ad5 ad6 bt1 bt2 bt3 bt4 bt5 bt6
         scalar `ad1'=`at'[1,21]
         scalar `ad2'=`at'[1,22]
         scalar `ad3'=`at'[1,23]
         scalar `ad4'=`at'[1,24]
         scalar `ad5'=`at'[1,25]
         scalar `ad6'=`at'[1,26]
         scalar `bt1'=`at'[1,27]
         scalar `bt2'=`at'[1,28]
         scalar `bt3'=`at'[1,29]
         scalar `bt4'=`at'[1,30]
         scalar `bt5'=`at'[1,31]
         scalar `bt6'=`at'[1,32]

         tempname bl1 bl2 bl3 bl4 bl5 bl6 bk1 bk2 bk3 bk4 bk5 bk6  bm1  
bm2 bm3 bm4 bm5 bm6  be1 be2 be3 be4 be5 be6
         scalar `bl1'=`at'[1,33]
         scalar `bl2'=`at'[1,34]
         scalar `bl3'=`at'[1,35]
         scalar `bl4'=`at'[1,36]
         scalar `bl5'=`at'[1,37]
         scalar `bl6'=`at'[1,38]
         scalar `bk1'=`at'[1,39]
         scalar `bk2'=`at'[1,40]
         scalar `bk3'=`at'[1,41]
         scalar `bk4'=`at'[1,42]
         scalar `bk5'=`at'[1,43]
         scalar `bk6'=`at'[1,44]
         scalar `bm1'=`at'[1,45]
         scalar `bm2'=`at'[1,46]
         scalar `bm3'=`at'[1,47]
         scalar `bm4'=`at'[1,48]
         scalar `bm5'=`at'[1,49]
         scalar `bm6'=`at'[1,50]
         scalar `be1'=`at'[1,51]
         scalar `be2'=`at'[1,52]
         scalar `be3'=`at'[1,53]
         scalar `be4'=`at'[1,54]
         scalar `be5'=`at'[1,55]
         scalar  
`be6'=-`bl1'-`bl2'-`bl3'-`bl4'-`bl5'-`bl6'-`bm1'-`bm2'-`bm3'-`bm4'-`bm5'-`bm6'-`bk1'-`bk2'-`bk3'-`bk4'-`bk5'-`bk6'-`be1'-`be2'-`be3'-`be4'-`be5'

         tempname dll dkl dkk dml dmk dmm
         scalar `dll'=`at'[1,56]
         scalar `dkl'=`at'[1,57]
         scalar `dkk'=`at'[1,58]
         scalar `dml'=`at'[1,59]
         scalar `dmk'=`at'[1,60]
         scalar `dmm'=`at'[1,61]


         quietly {

replace lnc =  
5+`aq'*`lnq'+`al'*`lnpl'+`ak'*`lnpk'+`am'*`lnpm'+(1-`al'-`ak'-`am')*`lnpe'+`blq'*`lnpl'*`lnq'+`bkq'*`lnpk'*`lnq'+`bmq'*`lnpm'*`lnq'+(-`blq'-`bkq'-`bmq')*`lnpe'*`lnq'+`aqq'*0.5*`lnq'*`lnq'+`ay'*`t'+`att'*0.5*`t'*`t'+`blt'*`lnpl'*`t'+`bkt'*`lnpk'*`t'+`bmt'*`lnpm'*`t'+(-`blt'-`bkt'-`bmt')*`lnpe'*`t'+`bqt'*`lnq'*`t'+`ad1'*`d1'+`ad2'*`d2'+`ad3'*`d3'+`ad4'*`d4'+`ad5'*`d5'+`ad6'*`d6'+`bl1'*`lnpl'*`d1'+`bl2'*`lnpl'*`d2'+`bl3'*`lnpl'*`d3'+`bl4'*`lnpl'*`d4'+`bl5'*`lnpl'*`d5'+`bl6'*`lnpl'*`d6'+`bk1'*`lnpk'*`d1'+`bk2'*`lnpk'*`d2'+`bk3'*`lnpk'*`d3'+`bk4'*`lnpk'*`d4'+`bk5'*`lnpk'*`d5'+`bk6'*`lnpk'*`d6'+`bm1'*`lnpm'*`d1'+`bm2'*`lnpm'*`d2'+`bm3'*`lnpm'*`d3'+`bm4'*`lnpm'*`d4'+`bm5'*`lnpm'*`d5'+`bm6'*`lnpm'*`d6'+`be1'*`lnpe'*`d1'+`be2'*`lnpe'*`d2'+`be3'*`lnpe'*`d3'+`be4'*`lnpe'*`d4'+`be5'*`lnpe'*`d5'+(-`bl1'-`bl2'-`bl3'-`bl4'-`bl5'-`bl6'-`bm1'-`bm2'-`bm3'-`bm4'-`bm5'-`bm6'-`bk1'-`bk2'-`bk3'-`bk4'-`bk5'-`bk6'-`be1'-`be2'-`be3'-`be4'-`be5')*`lnpe'*`d6'+`bq1'*`lnq'*`d1'+`bq2'*`lnq'*`d2'+`bq3'*`l!
 nq'*`d3'+
`bq4'*`lnq'*`d4'+`bq5'*`lnq'*`d5'+`bq6'*`lnq'*`d6'+`bt1'*`t'*`d1'+`bt2'*`t'*`d2'+`bt3'*`t'*`d3'+`bt4'*`t'*`d4'+`bt5'*`t'*`d5'+`bt6'*`t'*`d6'+(-`dll'*`dll'+`al'-`al'*`al')*0.5*`lnpl'*`lnpl'+(-`dll'*`dkl'-`al'*`ak')*`lnpl'*`lnpk'+(-`dll'*`dml'-`al'*`am')*`lnpl'*`lnpm'+(`dll'*`dll'-`al'+`al'*`al'+`dll'*`dkl'+`al'*`ak'+`dll'*`dml'+`al'*`am')*`lnpl'*`lnpe'+(-`dkl'*`dkl'-`dkk'*`dkk'+`ak'-`ak'*`ak')*0.5*`lnpk'*`lnpk'+(-`dkl'*`dml'-`dkk'*`dmk'-`ak'*`am')*`lnpk'*`lnpm'+(`dll'*`dkl'+`al'*`ak'+`dkl'*`dkl'+`dkk'*`dkk'-`ak'+`ak'*`ak'+`dkl'*`dml'+`dkk'*`dmk'+`ak'*`am')*`lnpk'*`lnpe'+(-`dml'*`dml'-`dmk'*`dmk'-`dmm'*`dmm'+`am'-`am'*`am')*0.5*`lnpm'*`lnpm'+(`dll'*`dml'+`al'*`am'+`dkl'*`dml'+`dkk'*`dmk'+`ak'*`am'+`dml'*`dml'+`dmk'*`dmk'+`dmm'*`dmm'-`am'+`am'*`am')*`lnpm'*`lnpe'+(-`dll'*`dll'+`al'-`al'*`al'-`dll'*`dkl'-`al'*`ak'-`dll'*`dml'-`al'*`am'-`dll'*`dml'-`al'*`am'-`dkl'*`dml'-`dkk'*`dmk'-`ak'*`am'-`dml'*`dml'-`dmk'*`dmk'-`dmm'*`dmm'+`am'-`am'*`am'-`dll'*`dkl'-`al'*`ak'-`dkl'*`dkl'-`dkk!
 '*`dkk'+`
ak'-`ak'*`ak'-`dkl'*`dml'-`dkk'*`dmk'-`ak'*`am')*0.5*`lnpe'*`lnpe'



                 replace sl =  
`al'+`blq'*`lnq'+(-`dll'+`al'-`al'*`al')*`lnpl'+(-`dll'*`dkl'-`al'*`ak')*`lnpk'+(-`dll'*`dml'-`al'*`am')*`lnpm'+(`dll'-`al'+`al'*`al'+`dll'*`dkl'+`al'*`ak'+`dll'*`dml'+`al'*`am')*`lnpe'+`blt'*`t'+`bl1'*`d1'+`bl2'*`d2'+`bl3'*`d3'+`bl4'*`d4'+`bl5'*`d5'+`bl6'*`d6'


                 replace sk =  
`ak'+`bkq'*`lnq'+(-`dll'*`dkl'-`al'*`ak')*`lnpl'+(-`dkl'*`dkl'-`dkk'*`dkk'+`ak'-`ak'*`ak')*`lnpk'+(-`dkl'*`dml'-`dkk'*`dmk'-`ak'*`am')*`lnpm'+(`dll'*`dkl'+`al'*`ak'+`dkl'*`dkl'+`dkk'*`dkk'-`ak'+`ak'*`ak'+`dkl'*`dml'+`dkk'*`dmk'+`ak'*`am')*`lnpe'+`bkt'*`t'+`bk1'*`d1'+`bk2'*`d2'+`bk3'*`d3'+`bk4'*`d4'+`bk5'*`d5'+`bk6'*`d6'


                 replace sm =  
`am'+`bmq'*`lnq'+(-`dll'*`dml'-`al'*`am')*`lnpl'+(-`dkl'*`dml'-`dkk'*`dmk'-`ak'*`am')*`lnpk'+(-`dml'*`dml'-`dmk'*`dmk'-`dmm'*`dmm'+`am'-`am'*`am')*`lnpm'+(`dll'*`dml'+`al'*`am'+`dkl'*`dml'+`dkk'*`dmk'+`ak'*`am'+`dml'*`dml'+`dmk'*`dmk'+`dmm'*`dmm'-`am'+`am'*`am')*`lnpe'+`bmt'*`t'+`bm1'*`d1'+`bm2'*`d2'+`bm3'*`d3'+`bm4'*`d4'+`bm5'*`d5'+`bm6'*`d6'




         }

end

nlsur web @ lnc sl sk sm lnpl lnpk lnpm lnpe lnq t d1 d2 d3 d4 d5 d6,  
parameters(al ak am aq aqq blq bkq bmq bqt bq1 bq2 bq3 bq4 bq5 bq6 ai  
aii blt bkt bmt ad1 ad2 ad3 ad4 ad5 ad6 bt1 bt2 bt3 bt4 bt5 bt6 bl1  
bl2 bl3 bl4 bl5 bl6 bk1 bk2 bk3 bk4 bk5 bk6  bm1 bm2 bm3 bm4 bm5 bm6  
be1 be2 be3 be4 be5 dll dkl dkk dml dmk dmm) neq(4) ifgnls


*
*   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/
Reply | Threaded
Open this post in threaded view
|

Re: st: Return r(111) this time

Eva Poen
In reply to this post by Crystal Li
Jingjing,

good to hear that the example now works for you. Without having gone
through all of your code, there are a few problems that I spotted. I
will first point those out, and then show you how you can debug your
program in Stata.

>        tempname at att blt bkt bmt bet
>        scalar `ai'=`at'[1,16]
>        scalar `aii'=`at'[1,17]

Here, you declare tempnames at and att, and then use ai and aii for
your scalars. Later on, you appear to use t and att. Therefore, this
is not going to work (the names have to be the same). In addition, you
already have an option called at in your program. I advise to use ai
and aii for your scalars to avoid confusion. Therefore, change it to

tempname ai aii blt bkt bmt bet
scalar `ai'=`at'[1,16]
scalar `aii'=`at'[1,17]

and also replace all instances of `t' with `ai', and all instances of
`att' with `aii'. Please note that I haven't checked any of the other
scalars for consistency.

The next problem comes at the end of your program, within the -quietly
{ }- part. There, you need to change

 >                replace lnc =

to

replace `lnc' =

(note the single quotes). The same holds for the following two lines,
where you have to change sl to `sl', sk to `sk' and sm to `sm'.


Maybe we have found all mistakes, and the program will run. If not,
here is how you can figure out what's going wrong. First, create
copies of your four dependent variables lnc, sl, sk, and sm :

****
foreach x of varlist lnc sl sk sm {
  gen c_`x' = `x'
}
****

Next, call your program directly (without -nlsur-):

****
matrix a = J(1,61,0)
set trace on
nlsurweb c_lnc c_sl c_sk c_sm lnpl lnpk lnpm lnpe lnq t d1 d2 d3 d4 d5 d6, at(a)
****

The -trace- output will show you where exactly the problem is.


Good luck,
Eva



2009/3/15  <[hidden email]>:

> Thanks Eva! You are so nice and patient.
>
> After correcting all the typo you mentioned, the codes for the example
> works.
>
> However, in my own program, there's r(111) even correcting all the similar
> typo. I am not sure if r(11) is still a kind of error that caused by typo or
> other big errors. If it's caused by typo, I will check it again and agian
> until it works. What I am worried about is that it's the codes designing
> errors.
>
> My codes is:
>
> program nlsurweb
>
>        version 10.1
>
>        syntax varlist(min=16 max=16) [if], at(name)
>
>        tokenize `varlist'
>        args lnc sl sk sm lnpl lnpk lnpm lnpe lnq t d1 d2 d3 d4 d5 d6
>
>        tempname al ak am ae
>        scalar `al'=`at'[1,1]
>        scalar `ak'=`at'[1,2]
>        scalar `am'=`at'[1,3]
>        scalar `ae'=1-`al'-`ak'-`am'
>
>        tempname aq aqq
>        scalar `aq'=`at'[1,4]
>        scalar `aqq'=at'[1,5]
>
>        tempname blq bkq bmq beq
>        scalar `blq'=`at'[1,6]
>        scalar `bkq'=`at'[1,7]
>        scalar `bmq'=`at'[1,8]
>        scalar `beq'=-`blq'-`bkq'-`bmq'
>
>        tempname bqt bq1 bq2 bq3 bq4 bq5 bq6
>        scalar `bqt'=`at'[1,9]
>        scalar `bq1'=`at'[1,10]
>        scalar `bq2'=`at'[1,11]
>        scalar `bq3'=`at'[1,12]
>        scalar `bq4'=`at'[1,13]
>        scalar `bq5'=`at'[1,14]
>        scalar `bq6'=`at'[1,15]
>
>        tempname at att blt bkt bmt bet
>        scalar `ai'=`at'[1,16]
>        scalar `aii'=`at'[1,17]
>        scalar `blt'=`at'[1,18]
>        scalar `bkt'=`at'[1,19]
>        scalar `bmt'=`at'[1,20]
>        scalar `bet'=-`blt'-`bkt'-`bmt'
>
>        tempname ad1 ad2 ad3 ad4 ad5 ad6 bt1 bt2 bt3 bt4 bt5 bt6
>        scalar `ad1'=`at'[1,21]
>        scalar `ad2'=`at'[1,22]
>        scalar `ad3'=`at'[1,23]
>        scalar `ad4'=`at'[1,24]
>        scalar `ad5'=`at'[1,25]
>        scalar `ad6'=`at'[1,26]
>        scalar `bt1'=`at'[1,27]
>        scalar `bt2'=`at'[1,28]
>        scalar `bt3'=`at'[1,29]
>        scalar `bt4'=`at'[1,30]
>        scalar `bt5'=`at'[1,31]
>        scalar `bt6'=`at'[1,32]
>
>        tempname bl1 bl2 bl3 bl4 bl5 bl6 bk1 bk2 bk3 bk4 bk5 bk6  bm1 bm2 bm3
> bm4 bm5 bm6  be1 be2 be3 be4 be5 be6
>        scalar `bl1'=`at'[1,33]
>        scalar `bl2'=`at'[1,34]
>        scalar `bl3'=`at'[1,35]
>        scalar `bl4'=`at'[1,36]
>        scalar `bl5'=`at'[1,37]
>        scalar `bl6'=`at'[1,38]
>        scalar `bk1'=`at'[1,39]
>        scalar `bk2'=`at'[1,40]
>        scalar `bk3'=`at'[1,41]
>        scalar `bk4'=`at'[1,42]
>        scalar `bk5'=`at'[1,43]
>        scalar `bk6'=`at'[1,44]
>        scalar `bm1'=`at'[1,45]
>        scalar `bm2'=`at'[1,46]
>        scalar `bm3'=`at'[1,47]
>        scalar `bm4'=`at'[1,48]
>        scalar `bm5'=`at'[1,49]
>        scalar `bm6'=`at'[1,50]
>        scalar `be1'=`at'[1,51]
>        scalar `be2'=`at'[1,52]
>        scalar `be3'=`at'[1,53]
>        scalar `be4'=`at'[1,54]
>        scalar `be5'=`at'[1,55]
>        scalar
> `be6'=-`bl1'-`bl2'-`bl3'-`bl4'-`bl5'-`bl6'-`bm1'-`bm2'-`bm3'-`bm4'-`bm5'-`bm6'-`bk1'-`bk2'-`bk3'-`bk4'-`bk5'-`bk6'-`be1'-`be2'-`be3'-`be4'-`be5'
>
>        tempname dll dkl dkk dml dmk dmm
>        scalar `dll'=`at'[1,56]
>        scalar `dkl'=`at'[1,57]
>        scalar `dkk'=`at'[1,58]
>        scalar `dml'=`at'[1,59]
>        scalar `dmk'=`at'[1,60]
>        scalar `dmm'=`at'[1,61]
>
>
>        quietly {
>
> replace lnc =
> 5+`aq'*`lnq'+`al'*`lnpl'+`ak'*`lnpk'+`am'*`lnpm'+(1-`al'-`ak'-`am')*`lnpe'+`blq'*`lnpl'*`lnq'+`bkq'*`lnpk'*`lnq'+`bmq'*`lnpm'*`lnq'+(-`blq'-`bkq'-`bmq')*`lnpe'*`lnq'+`aqq'*0.5*`lnq'*`lnq'+`ay'*`t'+`att'*0.5*`t'*`t'+`blt'*`lnpl'*`t'+`bkt'*`lnpk'*`t'+`bmt'*`lnpm'*`t'+(-`blt'-`bkt'-`bmt')*`lnpe'*`t'+`bqt'*`lnq'*`t'+`ad1'*`d1'+`ad2'*`d2'+`ad3'*`d3'+`ad4'*`d4'+`ad5'*`d5'+`ad6'*`d6'+`bl1'*`lnpl'*`d1'+`bl2'*`lnpl'*`d2'+`bl3'*`lnpl'*`d3'+`bl4'*`lnpl'*`d4'+`bl5'*`lnpl'*`d5'+`bl6'*`lnpl'*`d6'+`bk1'*`lnpk'*`d1'+`bk2'*`lnpk'*`d2'+`bk3'*`lnpk'*`d3'+`bk4'*`lnpk'*`d4'+`bk5'*`lnpk'*`d5'+`bk6'*`lnpk'*`d6'+`bm1'*`lnpm'*`d1'+`bm2'*`lnpm'*`d2'+`bm3'*`lnpm'*`d3'+`bm4'*`lnpm'*`d4'+`bm5'*`lnpm'*`d5'+`bm6'*`lnpm'*`d6'+`be1'*`lnpe'*`d1'+`be2'*`lnpe'*`d2'+`be3'*`lnpe'*`d3'+`be4'*`lnpe'*`d4'+`be5'*`lnpe'*`d5'+(-`bl1'-`bl2'-`bl3'-`bl4'-`bl5'-`bl6'-`bm1'-`bm2'-`bm3'-`bm4'-`bm5'-`bm6'-`bk1'-`bk2'-`bk3'-`bk4'-`bk5'-`bk6'-`be1'-`be2'-`be3'-`be4'-`be5')*`lnpe'*`d6'+`bq1'*`lnq'*`d1'+`bq2'*`lnq'*`d2'+`bq3'*`l!
> nq'*`d3'+
> `bq4'*`lnq'*`d4'+`bq5'*`lnq'*`d5'+`bq6'*`lnq'*`d6'+`bt1'*`t'*`d1'+`bt2'*`t'*`d2'+`bt3'*`t'*`d3'+`bt4'*`t'*`d4'+`bt5'*`t'*`d5'+`bt6'*`t'*`d6'+(-`dll'*`dll'+`al'-`al'*`al')*0.5*`lnpl'*`lnpl'+(-`dll'*`dkl'-`al'*`ak')*`lnpl'*`lnpk'+(-`dll'*`dml'-`al'*`am')*`lnpl'*`lnpm'+(`dll'*`dll'-`al'+`al'*`al'+`dll'*`dkl'+`al'*`ak'+`dll'*`dml'+`al'*`am')*`lnpl'*`lnpe'+(-`dkl'*`dkl'-`dkk'*`dkk'+`ak'-`ak'*`ak')*0.5*`lnpk'*`lnpk'+(-`dkl'*`dml'-`dkk'*`dmk'-`ak'*`am')*`lnpk'*`lnpm'+(`dll'*`dkl'+`al'*`ak'+`dkl'*`dkl'+`dkk'*`dkk'-`ak'+`ak'*`ak'+`dkl'*`dml'+`dkk'*`dmk'+`ak'*`am')*`lnpk'*`lnpe'+(-`dml'*`dml'-`dmk'*`dmk'-`dmm'*`dmm'+`am'-`am'*`am')*0.5*`lnpm'*`lnpm'+(`dll'*`dml'+`al'*`am'+`dkl'*`dml'+`dkk'*`dmk'+`ak'*`am'+`dml'*`dml'+`dmk'*`dmk'+`dmm'*`dmm'-`am'+`am'*`am')*`lnpm'*`lnpe'+(-`dll'*`dll'+`al'-`al'*`al'-`dll'*`dkl'-`al'*`ak'-`dll'*`dml'-`al'*`am'-`dll'*`dml'-`al'*`am'-`dkl'*`dml'-`dkk'*`dmk'-`ak'*`am'-`dml'*`dml'-`dmk'*`dmk'-`dmm'*`dmm'+`am'-`am'*`am'-`dll'*`dkl'-`al'*`ak'-`dkl'*`dkl'-`dkk!
> '*`dkk'+`
> ak'-`ak'*`ak'-`dkl'*`dml'-`dkk'*`dmk'-`ak'*`am')*0.5*`lnpe'*`lnpe'
>
>
>
>                replace sl =
> `al'+`blq'*`lnq'+(-`dll'+`al'-`al'*`al')*`lnpl'+(-`dll'*`dkl'-`al'*`ak')*`lnpk'+(-`dll'*`dml'-`al'*`am')*`lnpm'+(`dll'-`al'+`al'*`al'+`dll'*`dkl'+`al'*`ak'+`dll'*`dml'+`al'*`am')*`lnpe'+`blt'*`t'+`bl1'*`d1'+`bl2'*`d2'+`bl3'*`d3'+`bl4'*`d4'+`bl5'*`d5'+`bl6'*`d6'
>
>
>                replace sk =
> `ak'+`bkq'*`lnq'+(-`dll'*`dkl'-`al'*`ak')*`lnpl'+(-`dkl'*`dkl'-`dkk'*`dkk'+`ak'-`ak'*`ak')*`lnpk'+(-`dkl'*`dml'-`dkk'*`dmk'-`ak'*`am')*`lnpm'+(`dll'*`dkl'+`al'*`ak'+`dkl'*`dkl'+`dkk'*`dkk'-`ak'+`ak'*`ak'+`dkl'*`dml'+`dkk'*`dmk'+`ak'*`am')*`lnpe'+`bkt'*`t'+`bk1'*`d1'+`bk2'*`d2'+`bk3'*`d3'+`bk4'*`d4'+`bk5'*`d5'+`bk6'*`d6'
>
>
>                replace sm =
> `am'+`bmq'*`lnq'+(-`dll'*`dml'-`al'*`am')*`lnpl'+(-`dkl'*`dml'-`dkk'*`dmk'-`ak'*`am')*`lnpk'+(-`dml'*`dml'-`dmk'*`dmk'-`dmm'*`dmm'+`am'-`am'*`am')*`lnpm'+(`dll'*`dml'+`al'*`am'+`dkl'*`dml'+`dkk'*`dmk'+`ak'*`am'+`dml'*`dml'+`dmk'*`dmk'+`dmm'*`dmm'-`am'+`am'*`am')*`lnpe'+`bmt'*`t'+`bm1'*`d1'+`bm2'*`d2'+`bm3'*`d3'+`bm4'*`d4'+`bm5'*`d5'+`bm6'*`d6'
>
>
>
>
>        }
>
> end
>
> nlsur web @ lnc sl sk sm lnpl lnpk lnpm lnpe lnq t d1 d2 d3 d4 d5 d6,
> parameters(al ak am aq aqq blq bkq bmq bqt bq1 bq2 bq3 bq4 bq5 bq6 ai aii
> blt bkt bmt ad1 ad2 ad3 ad4 ad5 ad6 bt1 bt2 bt3 bt4 bt5 bt6 bl1 bl2 bl3 bl4
> bl5 bl6 bk1 bk2 bk3 bk4 bk5 bk6  bm1 bm2 bm3 bm4 bm5 bm6 be1 be2 be3 be4 be5
> dll dkl dkk dml dmk dmm) neq(4) ifgnls
>
>
>
>
>
>
> Quoting Eva Poen <[hidden email]>:
>
>> This message that I sent earlier has not made it through to the list;
>> I therefore re-send it. My apologies, should it appear twice.
>>
>> Eva
>> ***************************
>>
>>  Jingjing,
>>
>>  Also, take a look at the following line:
>>
>>  > sca1ar `g4l'=`g14'
>>
>>  You want `g41' here, not `g4l' (i.e. the number 1 instead of the
>>  letter l, as in life). With the commands  -scalar- and -forvalues- it's
>> the
>>  other way round (you have the number 1 in those commands where
>>  you should have the letter l). See also -help scalar-
>>  and -help forvalues-.
>>
>>  Oh, and I just noticed that your line
>>
>>  > replace `w3' =
>>
>> `a3'+`g31'*`lnp1'+`g32*`lnp2'+`g33'*`lnp3'+`g34'*`lnp4'+`b3'*(`lnm'-`lnpindex')
>>
>>  still lacks a closing single quote after `g32. You want:
>>
>>  replace `w3' =
>>
>> `a3'+`g31'*`lnp1'+`g32'*`lnp2'+`g33'*`lnp3'+`g34'*`lnp4'+`b3'*(`lnm'-`lnpindex')
>>
>>
>>  Eva
>>
>>>
>>>
>>>
>>> 2009/3/15 Kit Baum <[hidden email]>:
>>>>
>>>> <>
>>>> The word is s c a L a r.  Eva pointed that out quite clearly.
>>>>
>>>>
>>>> Kit Baum   |   Boston College Economics and DIW Berlin   |
>>>> http://ideas.repec.org/e/pba1.html
>>>> An Introduction to Stata Programming   |
>>>> http://www.stata-press.com/books/isp.html
>>>> An Introduction to Modern Econometrics Using Stata   |
>>>> http://www.stata-press.com/books/imeus.html
>>>>
>>>>
>>>>
>>>> On Mar 15, 2009, at 02:33 , Jingjing wrote:
>>>>
>>>>>        sca1ar `a2'=`at'[1,2]
>>>>>        sca1ar `a3'=`at'[1,3]
>>>>>        sca1ar `a4'= 1-`a1'-`a2'-`a3'
>>>>>
>>>>>        tempname b1 b2 b3
>>>>>        sca1ar `b1'=`at'[1,4]
>>>>>        sca1ar `b2'=`at'[1,5]
>>>>>        sca1ar `b3'=`at'[1,6]
>>>>
>>>> etc.

*
*   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/
Reply | Threaded
Open this post in threaded view
|

Re: st: RE: Return r(111) this time

Eva Poen
In reply to this post by Nick Cox
Nick spotted two important points which I overlooked:

> scalar `aqq'=at'[1,5]

should be

scalar `aqq'=`at'[1,5]

Also, the if condition has to be added at the end of the program:

replace `lnc' = .... `if'
replace `sl'  = .... `if'
replace `sk'  = .... `if'
replace `sm' = .... `if'

where ... stands for the very long expressions in Jingjing's code.

Concerning -trace- and -nlsur-: From my (quick) experiments it
appeared that -trace- will only show details of the program if it is
invoked directly (i.e. without -nlsur-). In order to to that, one has
to be careful to use copies of the dependent variables, since the
program will change those variables if running successfully.

Eva



2009/3/15 Nick Cox <[hidden email]>:

> scalar `aqq'=at'[1,5]
>
> is another typo. I didn't try finding any others.
>
> Do please find out about -set trace-, today!
>
> P.S. A bug here is that your program allows -if- but ignores it.
>
> Nick
> [hidden email]
>
*
*   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/
Reply | Threaded
Open this post in threaded view
|

RE: st: RE: Return r(111) this time

Nick Cox
I've not tried it with -nlsur- but in general it is true that you may
need to -set tracedepth- too. Alternatively, and probably better here,
insert  -set trace on- at the beginning of your own program.

Nick
[hidden email]

Eva Poen

Nick spotted two important points which I overlooked:

> scalar `aqq'=at'[1,5]

should be

scalar `aqq'=`at'[1,5]

Also, the if condition has to be added at the end of the program:

replace `lnc' = .... `if'
replace `sl'  = .... `if'
replace `sk'  = .... `if'
replace `sm' = .... `if'

where ... stands for the very long expressions in Jingjing's code.

Concerning -trace- and -nlsur-: From my (quick) experiments it
appeared that -trace- will only show details of the program if it is
invoked directly (i.e. without -nlsur-). In order to to that, one has
to be careful to use copies of the dependent variables, since the
program will change those variables if running successfully.


2009/3/15 Nick Cox <[hidden email]>:
> scalar `aqq'=at'[1,5]
>
> is another typo. I didn't try finding any others.
>
> Do please find out about -set trace-, today!
>
> P.S. A bug here is that your program allows -if- but ignores it.

*
*   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/
Reply | Threaded
Open this post in threaded view
|

Re: st: RE: Return r(111) this time

Eva Poen
I have to correct myself in the sense that -trace- will show, with
-nlsur-, details of the program used. It will not, however, pass on
the error message, or the return code, of the program. That makes it
more difficult to pinpoint the error. The same happens if -set trace
on- is used inside the program, irrespective of -tracedepth-.

When the program is invoked directly (without -nlsur-), the error
messages will relate to actual problem inside the program. The program
will, however, change the data if it runs successfully; therefore,
copies of the dependent variables should be used.

Eva



2009/3/15 Nick Cox <[hidden email]>:
> I've not tried it with -nlsur- but in general it is true that you may
> need to -set tracedepth- too. Alternatively, and probably better here,
> insert  -set trace on- at the beginning of your own program.
>
> Nick
> [hidden email]

*
*   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/
Reply | Threaded
Open this post in threaded view
|

Re: st: RE: Return r(111) this time

Crystal Li
Hi,

First, I corrected all the typo.

Then I changed constant item 5 to a0 in the first equation. I setted  
constant item a0 as a strating value 5 in my previous codes, because  
they did so in the example. Now I decide to scalar a new coef. a0. Is  
that ok? Or I need to set the constant item at other starting value?

Second, I typed -set trace on- before running the stuff. Here's the  
error record:


}
-------------------------------------------------------------- end  
nlsurwellbehav ---
- }
- if _rc {
- di as error "nlsur`eqn' returned " _rc
= di as error "nlsurwellbehav returned " _rc
nlsurwellbehav returned 111
- di as error "verify that nlsur`eqn' is a function evaluator program"
= di as error "verify that nlsurwellbehav is a function evaluator program"
verify that nlsurwellbehav is a function evaluator program
- exit _rc
}
}
---------------------------------------------------------------- end  
nlsur.Estimate ---
end nlsur ---
r(111);

I am thinking there maybe another kind of errors in my codes. Say  
there's two items in my equation:   a*lne   and   b*lne*lne. I think I  
should define them as:

replace `lnc'=`a'*`lne'+`b'*``lnpe'*`lne''

In my previous codes I defined them as:

`lnc'=`a'*`lne'+`b'*`lnpe'*`lne'

Does it cause the r(111)?

Jingjing







Quoting Eva Poen <[hidden email]>:

> I have to correct myself in the sense that -trace- will show, with
> -nlsur-, details of the program used. It will not, however, pass on
> the error message, or the return code, of the program. That makes it
> more difficult to pinpoint the error. The same happens if -set trace
> on- is used inside the program, irrespective of -tracedepth-.
>
> When the program is invoked directly (without -nlsur-), the error
> messages will relate to actual problem inside the program. The program
> will, however, change the data if it runs successfully; therefore,
> copies of the dependent variables should be used.
>
> Eva
>
>
>
> 2009/3/15 Nick Cox <[hidden email]>:
>> I've not tried it with -nlsur- but in general it is true that you may
>> need to -set tracedepth- too. Alternatively, and probably better here,
>> insert  -set trace on- at the beginning of your own program.
>>
>> Nick
>> [hidden email]
>
> *
> *   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/
1234