Bookmark and Share

Notice: On April 23, 2014, Statalist moved from an email list to a forum, based at statalist.org.


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

st: nlsuraids returned 199, please help


From   "ABDULFATAH S, ADAM" <[email protected]>
To   [email protected]
Subject   st: nlsuraids returned 199, please help
Date   Fri, 6 May 2011 05:12:20 -0700 (PDT)

Dear Statalist,
I will be very grateful if someone can assist me with this. 
I am having a difficult time estimating AIDS model with 11 expenditure equations using stata's nlsur. 
Stata is returning this error:

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

I have checked my code again and again and it seems to me there is no error, or may be I am missing something.
Any assistance is highly appreciated. 

Here is my code:

program nlsuraids
	version 10.0
	syntax varlist (min=24 max=24) if, at(name)
	tokenize `varlist'
	args w1 w2 w3 w4 w5 w6 w7 w8 w9 w10 w11 lnp1 lnp2 lnp3 
	lnp4 lnp5 lnp6 lnp7 lnp8 lnp9 lnp10 lnp11 lnp12 lnexp 
	tempname a1 a2 a3 a4 a5 a6 a7 a8 a9 a10 a11 a12
	scalar `a1'=`at'[1,1]
	scalar `a2'=`at'[1,2]
	scalar `a3'=`at'[1,3]
	scalar `a4'=`at'[1,4]
	scalar `a5'=`at'[1,5]
	scalar `a6'=`at'[1,6]
	scalar `a7'=`at'[1,7]
	scalar `a8'=`at'[1,8]
	scalar `a9'=`at'[1,9]
	scalar `a10'=`at'[1,10]
	scalar `a11'=`at'[1,11]
	scalar `a12'= 1-`a1'-`a2'-`a3'-`a4'-`a5'-`a6'-`a7'-`a8'-`a9'-`a10'-`a11'
	tempname b1 b2 b3 b4 b5 b6 b7 b8 b9 b10 b11
	scalar `b1'=`at'[1,12]
	scalar `b2'=`at'[1,13]
	scalar `b3'=`at'[1,14] 
	scalar `b4'=`at'[1,15] 
	scalar `b5'=`at'[1,16] 
	scalar `b6'=`at'[1,17] 
	scalar `b7'=`at'[1,18]
	scalar `b8'=`at'[1,19]
	scalar `b9'=`at'[1,20]
	scalar `b10'=`at'[1,21]
	scalar `b11'=`at'[1,22]
	tempname g11 g12 g13 g14 g15 g16 g17 g18 g19 g110 g111 g112
	tempname g21 g22 g23 g24 g25 g26 g27 g28 g29 g210 g211 g212 
	tempname g31 g32 g33 g34 g35 g36 g37 g38 g39 g310 g311 g312
	tempname g41 g42 g43 g44 g45 g46 g47 g48 g49 g410 g411 g412
	tempname g51 g52 g53 g54 g55 g56 g57 g58 g59 g510 g511 g512
	tempname g61 g62 g63 g64 g65 g66 g67 g68 g69 g610 g611 g612
	tempname g71 g72 g73 g74 g75 g76 g77 g78 g79 g710 g711 g612
	tempname g81 g82 g83 g84 g85 g86 g87 g88 g89 g810 g811 g812
	tempname g91 g92 g93 g94 g95 g96 g97 g98 g99 g910 g911 g912
	tempname g101 g102 g103 g104 g105 g106 g107 g108 g109 g1010 g1011 g1012
	tempname g111 g112 g113 g114 g115 g116 g117 g118 g119 g1110 g1111 g1112
	tempname g121 g122 g123 g124 g125 g126 g127 g128 g129 g1210 g1211 g1212
	scalar `g11' = `at'[1,23]
	scalar `g12' = `at'[1,24]
	scalar `g13' = `at'[1,25]
	scalar `g14' = `at'[1,26]
	scalar `g15' = `at'[1,27]
	scalar `g16' = `at'[1,28]
	scalar `g17' = `at'[1,29]
	scalar `g18' = `at'[1,30]
	scalar `g19' = `at'[1,31]
	scalar `g110' = `at'[1,32]
	scalar `g111' = `at'[1,33]
	scalar `g112' = -`g11'-`g12'-`g13'-`g14'-`g15'-`g16'-`g17'-`g18'-`g19'-`g110'-`g111'
	scalar `g21' = `g12'
	scalar `g22' = `at'[1,34]
	scalar `g23' = `at'[1,35]
	scalar `g24' = `at'[1,36]
	scalar `g25' = `at'[1,37]
	scalar `g26' = `at'[1,38]
	scalar `g27' = `at'[1,39]
	scalar `g28' = `at'[1,40]
	scalar `g29' = `at'[1,41]
	scalar `g210' = `at'[1,42]
	scalar `g211' = `at'[1,43]
	scalar `g212' = -`g21'-`g22'-`g23'-`g24'-`g25'-`g26'-`g27'-`g28'-`g29'-`g210'-`g211'
	scalar `g31' = `g13'
	scalar `g32' = `g23' 
	scalar `g33' = `at'[1,44]
	scalar `g34' = `at'[1,45]
	scalar `g35' = `at'[1,46]
	scalar `g36' = `at'[1,47]
	scalar `g37' = `at'[1,48]
	scalar `g38' = `at'[1,49]
	scalar `g39' = `at'[1,50]
	scalar `g310' = `at'[1,51]
	scalar `g311' = `at'[1,52]
	scalar `g312' = -`g31'-`g32'-`g33'-`g34'-`g35'-`g36'-`g37'-`g38'-`g39'-`g310'-`g311'
	scalar `g41' = `g14'
	scalar `g42' = `g24' 
	scalar `g43' = `g34'
	scalar `g44' = `at'[1,53]
	scalar `g45' = `at'[1,54]
	scalar `g46' = `at'[1,55]
	scalar `g47' = `at'[1,56]
	scalar `g48' = `at'[1,57]
	scalar `g49' = `at'[1,58]
	scalar `g410' = `at'[1,59]
	scalar `g411' = `at'[1,60]
	scalar `g412' = -`g41'-`g42'-`g43'-`g44'-`g45'-`g46'-`g47'-`g48'-`g49'-`g410'-`g411'
	scalar `g51' = `g15'
	scalar `g52' = `g25' 
	scalar `g53' = `g35'
	scalar `g54' = `g45'
	scalar `g55' = `at'[1,61]
	scalar `g56' = `at'[1,62]
	scalar `g57' = `at'[1,63]
	scalar `g58' = `at'[1,64]
	scalar `g59' = `at'[1,65]
	scalar `g510' = `at'[1,66]
	scalar `g511' = `at'[1,67]
	scalar `g512' = -`g51'-`g52'-`g53'-`g54'-`g55'-`g56'-`g57'-`g58'-`g59'-`g510'-`g511'
	scalar `g61' = `g16'
	scalar `g62' = `g26' 
	scalar `g63' = `g36'
	scalar `g64' = `g46'
	scalar `g65' = `g56'
	scalar `g66' = `at'[1,68]
	scalar `g67' = `at'[1,69]
	scalar `g68' = `at'[1,70]
	scalar `g69' = `at'[1,71]
	scalar `g610' = `at'[1,72]
	scalar `g611' = `at'[1,73]
	scalar `g612' = -`g61'-`g62'-`g63'-`g64'-`g65'-`g66'-`g67'-`g68'-`g69'-`g610'-`g611'
	scalar `g71' = `g17'
	scalar `g72' = `g27' 
	scalar `g73' = `g37'
	scalar `g74' = `g47'
	scalar `g75' = `g57'
	scalar `g76' = `g67'
	scalar `g77' = `at'[1,74]
	scalar `g78' = `at'[1,75]
	scalar `g79' = `at'[1,76]
	scalar `g710' = `at'[1,77]
	scalar `g711' = `at'[1,78]
	scalar `g712' = -`g71'-`g72'-`g73'-`g74'-`g75'-`g76'-`g77'-`g78'-`g79'-`g710'-`g711'
	scalar `g81' = `g18'
	scalar `g82' = `g28' 
	scalar `g83' = `g38'
	scalar `g84' = `g48'
	scalar `g85' = `g58'
	scalar `g86' = `g68'
	scalar `g87' = `g78'
	scalar `g88' = `at'[1,79]
	scalar `g89' = `at'[1,80]
	scalar `g810' = `at'[1,81]
	scalar `g811' = `at'[1,82]
	scalar `g812' = -`g81'-`g82'-`g83'-`g84'-`g85'-`g86'-`g87'-`g88'-`g89'-`g810'-`g811'
	scalar `g91' = `g19'
	scalar `g92' = `g29' 
	scalar `g93' = `g39'
	scalar `g94' = `g49'
	scalar `g95' = `g59'
	scalar `g96' = `g69'
	scalar `g97' = `g79'
	scalar `g98' = `g89'
	scalar `g99' = `at'[1,83]
	scalar `g910' = `at'[1,84]
	scalar `g911' = `at'[1,85]
	scalar `g912' = -`g91'-`g92'-`g93'-`g94'-`g95'-`g96'-`g97'-`g98'-`g99'-`g910'-`g911'
	scalar `g101' = `g110'
	scalar `g102' = `g210' 
	scalar `g103' = `g310'
	scalar `g104' = `g410'
	scalar `g105' = `g510'
	scalar `g106' = `g610'
	scalar `g107' = `g710'
	scalar `g108' = `g810'
	scalar `g109' = `g910'
	scalar `g1010' = `at'[1,86]
	scalar `g1011' = `at'[1,87]
	scalar `g1012' = -`g101'-`g102'-`g103'-`g104'-`g105'-`g106'-`g107'-`g108'-`g109'-`g1010'-`g1011'
	scalar `g111' = `g111'
	scalar `g112' = `g211' 
	scalar `g113' = `g311'
	scalar `g114' = `g411'
	scalar `g115' = `g511'
	scalar `g116' = `g611'
	scalar `g117' = `g711'
	scalar `g118' = `g811'
	scalar `g119' = `g911'
	scalar `g1110' = `g1011'
	scalar `g1111' = `at'[1,88]
	scalar `g1112' = -`g111'-`g112'-`g113'-`g114'-`g115'-`g116'-`g117'-`g118'-`g119'-`g1110'-`g1111'
	scalar `g121' = `g112'
	scalar `g122' = `g212' 
	scalar `g123' = `g312'
	scalar `g124' = `g412'
	scalar `g125' = `g512'
	scalar `g126' = `g612'
	scalar `g127' = `g712'
	scalar `g128' = `g812'
	scalar `g129' = `g912'
	scalar `g1210' = `g1012'
	scalar `g1211' = `g1112'
	scalar `g1212' = -`g121'-`g122'-`g123'-`g124'-`g125'-`g126'-`g127'-`g128'-`g129'-`g1210'-`g1211'
	quietly {
		tempvar lnpindex
			gen double `lnpindex' = 5 + `a1'*`lnp1'+`a2'*`lnp2'+`a3'*`lnp3'+`a4'*`lnp4'+`a5'*`lnp5'+ ///
		`a6'*`lnp6'+`a7'*`lnp7'+`a8'*`lnp8'+`a9'*`lnp9'+`a10'*`lnp10'+`a11'*`lnp11'+`a12'*`lnp12'

		forvalues i = 1/12 {
			forvalues j = 1/12 {
				replace `lpindex' = `lpindex'+ ///
					0.5*`g`i'`j''*`lnp`i''*`lnp`j''
			}
		  }
		  replace `w1' = `a1' + `g11'*`lnp1' + `g12'*`lnp2' + `g13'*`lnp3' +   ///
		  		`g14'*`lnp4' + `g15'*`lnp5'+ `g16'*`lnp6'+ `g17'*`lnp7' + ///
		  		`g18'*`lnp8' + `g19'*`lnp9'+ `g110'*`lnp10'+ `g111'*`lnp11' ///
		  		`g112'*`lnp12'+ `b1'*(`lnexp'-`lnpindex')
		  replace `w2' = `a2' + `g21'*`lnp1' + `g22'*`lnp2' + `g23'*`lnp3' +   ///
	        		`g24'*`lnp4' + `g25'*`lnp5'+ `g26'*`lnp6'+ `g27'*`lnp7' + ///
		 		 `g28'*`lnp8' + `g29'*`lnp9'+ `g210'*`lnp10'+ `g211'*`lnp11' ///
		 		 `g212'*`lnp12'+ `b2'*(`lnexp'-`lnpindex')
		  replace `w3' = `a3' + `g31'*`lnp1' + `g32'*`lnp2' + `g33'*`lnp3' +   ///
				`g34'*`lnp4' + `g35'*`lnp5'+ `g36'*`lnp6'+ `g37'*`lnp7' + ///
				`g38'*`lnp8' + `g39'*`lnp9'+ `g310'*`lnp10'+ `g311'*`lnp11' ///
				`g312'*`lnp12'+ `b3'*(`lnexp'-`lnpindex')
 		  replace `w4' = `a4' + `g41'*`lnp1' + `g42'*`lnp2' + `g43'*`lnp3' +   ///
				`g44'*`lnp4' + `g45'*`lnp5'+ `g46'*`lnp6'+ `g47'*`lnp7' + ///
				`g48'*`lnp8' + `g49'*`lnp9'+ `g410'*`lnp10'+ `g411'*`lnp11' ///
				`g412'*`lnp12'+ `b4'*(`lnexp'-`lnpindex')
		  replace `w5' = `a5' + `g51'*`lnp1' + `g52'*`lnp2' + `g53'*`lnp3' +   ///
				`g54'*`lnp4' + `g55'*`lnp5'+ `g56'*`lnp6'+ `g57'*`lnp7' + ///
				`g58'*`lnp8' + `g59'*`lnp9'+ `g510'*`lnp10'+ `g511'*`lnp11' ///
				`g512'*`lnp12'+ `b5'*(`lnexp'-`lnpindex')
		  replace `w6' = `a6' + `g61'*`lnp1' + `g62'*`lnp2' + `g63'*`lnp3' +   ///
				`g64'*`lnp4' + `g65'*`lnp5'+ `g66'*`lnp6'+ `g67'*`lnp7' + ///
				`g68'*`lnp8' + `g69'*`lnp9'+ `g610'*`lnp10'+ `g611'*`lnp11' ///
				`g612'*`lnp12'+ `b6'*(`lnexp'-`lnpindex')
		  replace `w7' = `a7' + `g71'*`lnp1' + `g72'*`lnp2' + `g73'*`lnp3' +   ///
				`g74'*`lnp4' + `g75'*`lnp5'+ `g76'*`lnp6'+ `g77'*`lnp7' + ///
				`g78'*`lnp8' + `g79'*`lnp9'+ `g710'*`lnp10'+ `g711'*`lnp11' ///
				`g712'*`lnp12'+ `b7'*(`lnexp'-`lnpindex')
		  replace `w8' = `a8' + `g81'*`lnp1' + `g82'*`lnp2' + `g83'*`lnp3' +   ///
				`g84'*`lnp4' + `g85'*`lnp5'+ `g86'*`lnp6'+ `g87'*`lnp7' + ///
				`g88'*`lnp8' + `g89'*`lnp9'+ `g810'*`lnp10'+ `g811'*`lnp11' ///
				`g812'*`lnp12'+ `b8'*(`lnexp'-`lnpindex')
		  replace `w9' = `a9' + `g91'*`lnp1' + `g92'*`lnp2' + `g93'*`lnp3' +   ///
				`g94'*`lnp4' + `g95'*`lnp5'+ `g96'*`lnp6'+ `g97'*`lnp7' + ///
				`g98'*`lnp8' + `g99'*`lnp9'+ `g910'*`lnp10'+ `g911'*`lnp11' ///
				`g912'*`lnp12'+ `b9'*(`lnexp'-`lnpindex')
		  replace `w10' = `a10' + `g101'*`lnp1' + `g102'*`lnp2' + `g103'*`lnp3' +   ///
				`g104'*`lnp4' + `g105'*`lnp5'+ `g106'*`lnp6'+ `g107'*`lnp7' + ///
				`g108'*`lnp8' + `g109'*`lnp9'+ `g1010'*`lnp10'+ `g1011'*`lnp11' ///
				`g1012'*`lnp12'+ `b10'*(`lnexp'-`lnpindex')
		  replace `w11' = `a11' + `g111'*`lnp1' + `g112'*`lnp2' + `g113'*`lnp3' +   ///
				`g114'*`lnp4' + `g115'*`lnp5'+ `g116'*`lnp6'+ `g117'*`lnp7' + ///
				`g118'*`lnp8' + `g119'*`lnp9'+ `g1110'*`lnp10'+ `g1111'*`lnp11' ///
				`g1112'*`lnp12'+ `b11'*(`lnexp'-`lnpindex')
  	 }

end

nlsur aids @ w1 w2 w3 w4 w5 w6 w7 w8 w9 w10 w11 lnp1 lnp2 lnp3 lnp4 lnp5 lnp6 ///
		lnp7 lnp8 lnp9 lnp10 lnp11 lnp12 lnexp, parameters(a1 a2 a3 a4 a5 ///
		a6 a7 a8 a9 a10 a11 b1 b2 b3 b4 b5 b6 b7 b8 b9 b10 b11 g11 g12 g13 ///
		g14 g15 g16 g17 g18 g19 g110 g111 g22 g23 g24 g25 g26 g27 g28 g29 ///
		g210 g211 g33 g34 g35 g36 g37 g38 g39 g310 g311 g44 g45 g46 g47 g48 ///
		g49 g410 g411 g55 g56 g57 g58 g59 g510 g511 g66 g67 g68 g69 g610 ///
		g611 g77 g78 g79 g710 g711 g88 g89 g810 g811 g99 g910 g911 g1010 ///
		g1011 g1111)nequations(11)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/


© Copyright 1996–2018 StataCorp LLC   |   Terms of use   |   Privacy   |   Contact us   |   Site index