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]

Re: st: nlsur quaids for 11 items


From   Nick Cox <[email protected]>
To   "[email protected]" <[email protected]>
Subject   Re: st: nlsur quaids for 11 items
Date   Fri, 2 Dec 2011 06:58:23 +0000

g_79 is a typo

Nick

On 1 Dec 2011, at 23:44, Kompal Sinha <[email protected]> wrote:

Dear All,
I am trying to estimate a demand system for 11 commodities using Brian Poi's nlsur code with Stone's price approximation. The nlsur for 10 equation system gives me theerror:
verify that nlsuraidselv is a function evaluator program

I was wondering if someone could suggest where I am going wrong? Any help will be highly appreciated.

nlsur qaidsel @ w1 w2 w3 w4 w5 w6 w7 w8 w9 w10 lnp1-lnp11 lnexp,ifgnls
nequations(10) param(a1 a2 a3 a4 a5 a6 a7 a8 a9 a10 b1 b2 b3 b4 b5 b6 b7 b8 b9 b10 g1_1 g1_2 g1_3 g1_4 g1_5 g1_6 g1_7 g1_8 g1_9 g1_10 g2_2 g2_3 g2_4 g2_5 g2_6 g2_7 g2_8 g2_9 g2_10 g3_3 g3_4 g3_5 g3_6 g3_7 g3_8 g3_9 g3_10 g4_4 g4_5 g4_6 g4_7 g4_8 g4_9 g4_10 g5_5 g5_6 g5_7 g5_8 g5_9 g5_10 g6_6 g6_7 g6_8 g6_9 g6_10 g7_7 g7_8 g7_9 g7_10 g8_8 g8_9 g8_10 g9_9
g9_10 g10_10 l1 l2 l3 l4 l5 l6 l7 l8 l9 l10) nolog

program nlsurquaidselv

version 10

syntax varlist(min=22 max=22) if, at(name)

tokenize `varlist'

args w1 w2 w3 w4 w5 w6 w7 w8 w9 w10 lnp1 lnp2 lnp3 lnp4 lnp5 lnp6 lnp7 lnp8 lnp9 lnp10 lnp11 lnm


tempname a1 a2 a3 a4 a5 a6 a7 a8 a9 a10 a11

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'= 1 - `a1' - `a2' - `a3' - `a4' -`a5'-`a6' - `a7' - `a8' - `a9' -`a10'

tempname b1 b2 b3 b4 b5 b6 b7 b8 b9 b10 b11

scalar `b1' = `at'[1,11]

scalar `b2' = `at'[1,12]

scalar `b3' = `at'[1,13]

scalar `b4' = `at'[1,14]

scalar `b5' = `at'[1,15]

scalar `b6' = `at'[1,16]

scalar `b7' = `at'[1,17]

scalar `b8' = `at'[1,18]

scalar `b9' = `at'[1,19]

scalar `b10' = `at'[1,20]

scalar `b11' = -`b1' - `b2' - `b3' - `b4' - `b5'-`b6' - `b7' - `b8' - `b9' - `b10'

tempname g1_1 g1_2 g1_3 g1_4 g1_5 g1_6 g1_7 g1_8 g1_9 g1_10 g1_11

tempname g2_1 g2_2 g2_3 g2_4 g2_5 g2_6 g2_7 g2_8 g2_9 g2_10 g2_11

tempname g3_1 g3_2 g3_3 g3_4 g3_5 g3_6 g3_7 g3_8 g3_9 g3_10 g3_11

tempname g4_1 g4_2 g4_3 g4_4 g4_5 g4_6 g4_7 g4_8 g4_9 g4_10 g4_11

tempname g5_1 g5_2 g5_3 g5_4 g5_5 g5_6 g5_7 g5_8 g5_9 g5_10 g5_11

tempname g6_1 g6_2 g6_3 g6_4 g6_5 g6_6 g6_7 g6_8 g6_9 g6_10 g6_11

tempname g7_1 g7_2 g7_3 g7_4 g7_5 g7_6 g7_7 g7_8 g7_9 g7_10 g7_11

tempname g8_1 g8_2 g8_3 g8_4 g8_5 g8_6 g8_7 g8_8 g8_9 g8_10 g8_11

tempname g9_1 g9_2 g9_3 g9_4 g9_5 g9_6 g9_7 g9_8 g9_9 g9_10 g9_11

tempname g10_1 g10_2 g10_3 g10_4 g10_5 g10_6 g10_7 g10_8 g10_9 g10_10 g10_11

tempname g11_1 g11_2 g11_3 g11_4 g11_5 g11_6 g11_7 g11_8 g11_9 g11_10 g11_11

scalar `g1_1' = `at'[1,21]

scalar `g1_2' = `at'[1,22]

scalar `g1_3' = `at'[1,23]

scalar `g1_4' = `at'[1,24]

scalar `g1_5' = `at'[1,25]

scalar `g1_6 '= `at'[1,26]

scalar `g1_7' = `at'[1,27]

scalar `g1_8' = `at'[1,28]

scalar `g1_9' = `at'[1,29]

scalar `g1_10' = `at'[1,30]

scalar `g1_11' = -`g1_1' - `g1_2' - `g1_3' - `g1_4' - `g1_5' -`g1_6' - `g1_7' - `g1_8' - `g1_9' - `g1_10'


scalar `g2_1' = `g1_2'

scalar `g2_2' = `at'[1,31]

scalar `g2_3' = `at'[1,32]

scalar `g2_4' = `at'[1,33]

scalar `g2_5' = `at'[1,34]

scalar `g2_6' = `at'[1,35]

scalar `g2_7' = `at'[1,36]

scalar `g2_8' = `at'[1,37]

scalar `g2_9' = `at'[1,38]

scalar `g2_10' = `at'[1,39]

scalar `g2_11' = -`g2_1' - `g2_2' - `g2_3' - `g2_4' - `g2_5'-`g2_6' - `g2_7' - `g2_8' - `g2_9' - `g2_10'

scalar `g3_1' = `g1_3'

scalar `g3_2' = `g2_3'

scalar `g3_3' = `at'[1,40]

scalar `g3_4' = `at'[1,41]

scalar `g3_5' = `at'[1,42]

scalar `g3_6' = `at'[1,43]

scalar `g3_7' = `at'[1,44]

scalar `g3_8' = `at'[1,45]

scalar `g3_9' = `at'[1,46]

scalar `g3_10' = `at'[1,47]

scalar `g3_11' = -`g3_1' - `g3_2' - `g3_3' - `g3_4' - `g3_5'-`g3_6' - `g3_7' - `g3_8' - `g3_9' - `g3_10'


scalar `g4_1' = `g1_4'

scalar `g4_2' = `g2_4'

scalar `g4_3' = `g3_4'

scalar `g4_4' = `at'[1,48]

scalar `g4_5' = `at'[1,49]

scalar `g4_6' = `at'[1,50]

scalar `g4_7' = `at'[1,51]

scalar `g4_8' = `at'[1,52]

scalar `g4_9' = `at'[1,53]

scalar `g4_10' = `at'[1,54]

scalar `g4_11' = -`g4_1' - `g4_2' - `g4_3' - `g4_4' -`g4_5'-`g4_6' - `g4_7' - `g4_8' - `g4_9' -`g4_10'

scalar `g5_1' = `g1_5'

scalar `g5_2' = `g2_5'

scalar `g5_3' = `g3_5'

scalar `g5_4' = `g4_5'

scalar `g5_5' = `at'[1,55]

scalar `g5_6' = `at'[1,56]

scalar `g5_7' = `at'[1,57]

scalar `g5_8' = `at'[1,58]

scalar `g5_9' = `at'[1,59]

scalar `g5_10' = `at'[1,60]

scalar `g5_11' = -`g5_1' - `g5_2' - `g5_3' - `g5_4' - `g5_5'-`g5_6' - `g5_7' - `g5_8' - `g5_9' - `g5_10'

scalar `g6_1' = `g1_6'

scalar `g6_2' = `g2_6'

scalar `g6_3' = `g3_6'

scalar `g6_4' = `g4_6'

scalar `g6_5' = `g5_6'

scalar `g6_6' = `at'[1,61]

scalar `g6_7' = `at'[1,62]

scalar `g6_8' = `at'[1,63]

scalar `g6_9' = `at'[1,64]

scalar `g6_10' =`at'[1,65]

scalar `g6_11' = -`g6_1' - `g6_2' - `g6_3' - `g6_4' - `g6_5'-`g6_6' - `g6_7' - `g6_8' - `g6_9' - `g6_10'


scalar `g7_1' = `g1_7'

scalar `g7_2' = `g2_7'

scalar `g7_3' = `g3_7'

scalar `g7_4' = `g4_7'

scalar `g7_5' = `g5_7'

scalar `g7_6' = `g6_7'

scalar `g7_7' = `at'[1,66]

scalar `g7_8' = `at'[1,67]

scalar `g7_9' = `at'[1,68]

scalar `g7_10' = `at'[1,69]

scalar `g7_11' = -`g7_1' - `g7_2' - `g7_3' - `g7_4' - `g7_5'-`g7_6' - `g7_7' - `g7_8' - `g7_9' - `g7_10'


scalar `g8_1' = `g1_8'

scalar `g8_2' = `g2_8'

scalar `g8_3' = `g3_8'

scalar `g8_4' = `g4_8'

scalar `g8_5' = `g5_8'

scalar `g8_6' = `g6_8'

scalar `g8_7' = `g7_8'

scalar `g8_8' = `at'[1,70]

scalar `g8_9' = `at'[1,71]

scalar `g8_10' = `at'[1,72]

scalar `g8_11' = -`g8_1' - `g8_2' - `g8_3' - `g8_4' - `g8_5'-`g8_6' - `g8_7' - `g8_8' - `g8_9' - `g8_10'

scalar `g9_1' = `g1_9'

scalar `g9_2' = `g2_9'

scalar `g9_3' = `g3_9'

scalar `g9_4' = `g4_9'

scalar `g9_5' = `g5_9'

scalar `g9_6' = `g6_9'

scalar `g9_7' = `g_79'

scalar `g9_8' = `g8_9'

scalar `g9_9' = `at'[1,73]

scalar `g9_10' = `at'[1,74]

scalar `g9_11' = -`g9_1' - `g9_2' - `g9_3' - `g9_4' - `g9_5'-`g9_6' - `g9_7' - `g9_8' - `g9_9' - `g9_10'

scalar `g10_1' = `g1_10'

scalar `g10_2' = `g2_10'

scalar `g10_3' = `g3_10'

scalar `g10_4' = `g4_10'

scalar `g10_5' = `g5_10'

scalar `g10_6' = `g6_10'

scalar `g10_7' = `g7_10'

scalar `g10_8' = `g8_10'

scalar `g10_9' = `g9_10'

scalar `g10_10' = `at'[1,75]

scalar `g10_11' = -`g10_1' - `g10_2' - `g10_3' - `g10_4' - `g10_5'- `g10_6' - `g10_7' - `g10_8' - `g10_9' - `g10_10'

scalar `g11_1' = `g1_11'

scalar `g11_2' = `g2_11'

scalar `g11_3' = `g3_11'

scalar `g11_4' = `g4_11'

scalar `g11_5' = `g5_11'

scalar `g11_6' = `g6_11'

scalar `g11_7' = `g7_11'

scalar `g11_8' = `g8_11'

scalar `g11_9' = `g9_11'

scalar `g11_10' = `g10_11'

scalar `g11_11' = -`g11_1' - `g11_2' - `g11_3' - `g11_4' - `g11_5'- `g11_6' - `g11_7' - `g11_8' - `g11_9' - `g11_10'

tempname l1 l2 l3 l4 l5 l6 l7 l8 l9 l10 l11

scalar `l1' = `at'[1,76]

scalar `l2' = `at'[1,77]

scalar `l3' = `at'[1,78]

scalar `l4' = `at'[1,79]

scalar `l5' = `at'[1,80]

scalar `l6' = `at'[1,81]

scalar `l7' = `at'[1,82]

scalar `l8' = `at'[1,83]

scalar `l9' = `at'[1,84]

scalar `l10' = `at'[1,85]

scalar `l11' = -`l1' - `l2' - `l3' - `l4' - `l5'-`l6' - `l7' - `l8' - `l9' - `l10'

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'


// The b(p) term in the QUAIDS model:

tempvar bofp

gen double `bofp' = 0

forvalues i = 1/11{

replace `bofp' = `bofp' + `lnp`i''*`b`i''

}

replace `bofp' = exp(`bofp')


// Finally, the expenditure shares

replace `w1' = `a1' + `g11'*`lnp1' + `g1_2'*`lnp2' +///

    `g1_3'*`lnp3' + `g1_4'*`lnp4' +`g1_5'*`lnp5' + `g1_6'*`lnp6' + ///

`g1_7'*`lnp7' + `g1_8'*`lnp8' +`g1_9'*`lnp9' + `g1_10'*`lnp10' +`g1_11'*`lnp11' + ///

    `b1'*(`lnm' - `lnpindex') + `l1'/`bofp'*(`lnm' - `lnpindex')^2

replace `w2' = `a2' + `g2_1'*`lnp1' + `g2_2'*`lnp2' +///

    `g2_3'*`lnp3' + `g2_4'*`lnp4' +`g2_5'*`lnp5' + `g2_6'*`lnp6' + ///

`g2_7'*`lnp7' + `g2_8'*`lnp8' +`g2_9'*`lnp9' + `g2_10'*`lnp10' +`g2_11'*`lnp11' + ///

    `b2'*(`lnm' - `lnpindex') + `l2'/`bofp'*(`lnm' - `lnpindex')^2

replace `w3' = `a3' + `g3_1'*`lnp1' + `g3_2'*`lnp2' +///

    `g3_3'*`lnp3' + `g3_4'*`lnp4' +`g3_5'*`lnp5' + `g3_6'*`lnp6' + ///

`g3_7'*`lnp7' + `g3_8'*`lnp8' +`g3_9'*`lnp9' + `g3_10'*`lnp10' + `g3_11'*`lnp11' +///

    `b3'*(`lnm' - `lnpindex') + `l3'/`bofp'*(`lnm' - `lnpindex')^2

replace `w4' = `a4' + `g4_1'*`lnp1' + `g4_2'*`lnp2' +///

    `g4_3'*`lnp3' + `g4_4'*`lnp4' +`g4_5'*`lnp5' + `g4_6'*`lnp6' + ///

`g4_7'*`lnp7' + `g4_8'*`lnp8' +`g4_9'*`lnp9' + `g4_10'*`lnp10' + `g4_11'*`lnp11' + ///

    `b4'*(`lnm' - `lnpindex') + `l4'/`bofp'*(`lnm' - `lnpindex')^2

replace `w5' = `a5' + `g5_1'*`lnp1' + `g5_2'*`lnp2' +///

    `g5_3'*`lnp3' + `g5_4'*`lnp4' +`g5_5'*`lnp5' + `g5_6'*`lnp6' + ///

`g5_7'*`lnp7' + `g5_8'*`lnp8' +`g5_9'*`lnp9' + `g5_10'*`lnp10' + `g5_11'*`lnp11' + ///

    `b5'*(`lnm' - `lnpindex') + `l5'/`bofp'*(`lnm' - `lnpindex')^2

replace `w6' = `a6' + `g6_1'*`lnp1' + `g6_2'*`lnp2' +///

    `g6_3'*`lnp3' + `g6_4'*`lnp4' +`g6_5'*`lnp5' + `g6_6'*`lnp6' + ///

`g6_7'*`lnp7' + `g6_8'*`lnp8' +`g6_9'*`lnp9' + `g6_10'*`lnp10' + `g6_11'*`lnp11' + ///

    `b6'*(`lnm' - `lnpindex') + `l6'/`bofp'*(`lnm' - `lnpindex')^2

  replace `w7' = `a7' + `g7_1'*`lnp1' + `g7_2'*`lnp2' +///

    `g7_3'*`lnp3' + `g7_4'*`lnp4' +`g7_5'*`lnp5' + `g7_6'*`lnp6' + ///

`g77'*`lnp7' + `g7_8'*`lnp8' +`g7_9'*`lnp9' + `g7_10'*`lnp10' + `g7_11'*`lnp11' + ///

    `b7'*(`lnm' - `lnpindex') + `l7'/`bofp'*(`lnm' - `lnpindex')^2

  replace `w8' = `a8' + `g8_1'*`lnp1' + `g8_2'*`lnp2' +///

    `g8_3'*`lnp3' + `g8_4'*`lnp4' +`g8_5'*`lnp5' + `g8_6'*`lnp6' + ///

`g8_7'*`lnp7' + `g8_8'*`lnp8' +`g8_9'*`lnp9' + `g8_10'*`lnp10' + `g8_11'*`lnp11' + ///

    `b8'*(`lnm' - `lnpindex') + `l8'/`bofp'*(`lnm' - `lnpindex')^2

  replace `w9' = `a9' + `g9_1'*`lnp1' + `g9_2'*`lnp2' +///

    `g9_3'*`lnp3' + `g9_4'*`lnp4' +`g9_5'*`lnp5' + `g9_6'*`lnp6' + ///

`g9_7'*`lnp7' + `g9_8'*`lnp8' +`g9_9'*`lnp9' + `g9_10'*`lnp10' + `g9_11'*`lnp11' + ///

    `b9'*(`lnm' - `lnpindex') + `l9'/`bofp'*(`lnm' - `lnpindex')^2

  replace `w10' = `a10' + `g10_1'*`lnp1' + `g10_2'*`lnp2' +///

`g10_3'*`lnp3' + `g10_4'*`lnp4' +`g10_5'*`lnp5' + `g10_6'*`lnp6' + ///

`g10_7'*`lnp7' + `g10_8'*`lnp8' +`g10_9'*`lnp9' + `g10_10'*`lnp10' + `g10_11'*`lnp11' + ///

    `b10'*(`lnm' - `lnpindex') + `l10'/`bofp'*(`lnm' - `lnpindex')^2

}

end



Many Thanks,

Kompal


--

Dr. Kompal Sinha

Department of Econometrics and Business Statistics,

Monash University, Australia



*
*   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–2018 StataCorp LLC   |   Terms of use   |   Privacy   |   Contact us   |   Site index