Bookmark and Share

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


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

st: QUAIDS with demographic translation


From   Khalida Akhtar Choudhury <310543@soas.ac.uk>
To   statalist@hsphsun2.harvard.edu
Subject   st: QUAIDS with demographic translation
Date   Wed, 29 Aug 2012 12:40:56 +0100

Hello,

I have tried to code my own do file for QUAIDS with demographic
translation. I am using the approach of Gould & Dong (2004). There are
two differences between my approach and that of Banks et al. (1997).
There is a scalar term representing demographic variables(ti(d)) in
the welfare share equation(wi) and the expenditure m* is now dependent
on demographic variables.

I get error 198, "nlsurquaids returned 198 verify that nlsurquaids is
a function evaluator program an error occurred when bootstrap executed
estimate."

set seed 1

global ngoods =3D 4 // no. of goods

global nbootstraps =3D 3 // no. of bootstrap replications

global anot =3D 6 // alpha_0 parameter




global nminus1 =3D $ngoods - 1



capture program drop nlsurquaids

program nlsurquaids, rclass



version 10



local nv =3D $ngoods + $nminus1 + 1

syntax varlist(min=3D`=3D`nv'' max=3D`=3D`nv'') if, at(name)



local j 1

forvalues i =3D 1/$nminus1 {

local w`i' `:word `j' of `varlist''

local `++j'

}

forvalues i =3D 1/$ngoods {

local lnp`i' `:word `j' of `varlist''

local `++j'

}

local lnm `:word `j' of `varlist''

local col 1

local d1 :word count `demographics'

// alpha

forvalues i =3D 1/$nminus1 {

tempname a`i'

scalar `a`i'' =3D `at'[1,`col']

local `++col'

}

tempname a${ngoods}

scalar `a${ngoods}' =3D 1

forvalues i =3D 1/$nminus1 {

scalar `a${ngoods}' =3D `a${ngoods}' - `a`i''

}

// beta

forvalues i =3D 1/$nminus1 {

tempname b`i'

scalar `b`i'' =3D `at'[1,`col']

local `++col'

}

tempname b${ngoods}

scalar `b${ngoods}' =3D 0

forvalues i =3D 1/$nminus1 {

scalar `b${ngoods}' =3D `b${ngoods}' - `b`i''

}

// gamma

forvalues i =3D 1/$nminus1 {

forvalues j =3D 1/$nminus1 {

tempname g`i'`j'

if `i' > `j' {

scalar `g`i'`j'' =3D `g`j'`i''

}

else {

scalar `g`i'`j'' =3D `at'[1, `col']

local `++col'

}

}

tempname g`i'${ngoods}

scalar `g`i'${ngoods}' =3D 0

forvalues j =3D 1/$nminus1 {

scalar `g`i'${ngoods}' =3D  `g`i'${ngoods}' - `g`i'`j''

}

}

forvalues j =3D 1/$nminus1 {

tempname g${ngoods}`j'

scalar `g${ngoods}`j'' =3D `g`j'${ngoods}'

}

tempname g${ngoods}${ngoods}

scalar `g${ngoods}${ngoods}' =3D 0

forvalues j =3D 1/${ngoods} {

scalar `g${ngoods}${ngoods}' =3D `g${ngoods}${ngoods}' -  ///

`g${ngoods}`j''

}

// lambda

forvalues i =3D 1/$nminus1 {

tempname l`i'

scalar `l`i'' =3D `at'[1,`col']

local `++col'

}

tempname l${ngoods}

scalar `l${ngoods}' =3D 0

forvalues i =3D 1/$nminus1 {

scalar `l${ngoods}' =3D `l${ngoods}' - `l`i''

}

//omega

forvalues i =3D 1/$nminus1 {

tempname o`i'

scalar `o`i'' =3D `at'[1,`col']

local `++col'

}



quietly {

tempvar lnpindex

gen double `lnpindex' =3D $anot

forvalues i =3D 1/$ngoods {

replace `lnpindex' =3D `lnpindex' + `a`i''*`lnp`i''

}

forvalues i =3D 1/$ngoods {

forvalues j =3D 1/$ngoods {

replace `lnpindex' =3D `lnpindex' +  ///

0.5*`g`i'`j''*`lnp`i''*`lnp`j''

}

}

tempvar bp

gen double `bp' =3D 0

forvalues i =3D 1/$ngoods {

replace `bp' =3D `bp' + `lnp`i''*`b`i''

}

replace `bp' =3D exp(`bp')

forvalues i =3D 1/$nminus1 {

replace `w`i'' =3D `a`i'' + `o`i''*`demographics'

forvalues j =3D 1/$ngoods {

replace `w`i'' =3D `w`i'' + `g`i'`j''*`lnp`j''

}

replace `w`i'' =3D `w`i'' +  ///

`o`i''*`demographics'+ ///

`b`i''*(`lnm' - `lnpindex') + ///

`l`i''/`bp'*(`lnm' - `lnpindex')^2

}

}



end



// This program fits the QUAIDS model, then it calculates the elasticities

// at the sample means.



capture program drop estimate

program estimate, rclass



// Build up nlsur command

forvalues i =3D 1/$nminus1 {

local vlist `vlist' w`i'

local alist `alist' a`i'

local blist `blist' b`i'

local llist `llist' l`i'

local tlist `olist' o`i'

}

forvalues i =3D 1/$ngoods {

local vlist `vlist' lnp`i'

}

local vlist `vlist' lnexp

forvalues i =3D 1/$nminus1 {

forvalues j =3D `i'/$nminus1 {

local glist `glist' g`i'`j'

}

}

nlsur quaids @ `vlist', ifgnls nequations($nminus1) ///

param(`alist' `blist' `glist' `llist'`olist')
*
*   For searches and help try:
*   http://www.stata.com/help.cgi?search
*   http://www.stata.com/support/statalist/faq
*   http://www.ats.ucla.edu/stat/stata/


© Copyright 1996–2014 StataCorp LP   |   Terms of use   |   Privacy   |   Contact us   |   Site index