Hi Scott,
Thanks - I had already looked at that programme. Unfortunately I am not Stata literate enough to understand how it works. So I thought I'd programme it myself with the basic Stata that I know.
But thanks for the suggestion, anyway,
Cheers,
Ramani
Scott Merryman <[email protected]> wrote:
> Ramani,
>
> Stas Kolenikov has written a Shapley value decomposition program (-findit
> shapley-), which you may find helpful.
>
> Scott
>
> ----- Original Message -----
> From: "Ramani Gunatilaka" <[email protected]>
> To: <[email protected]>
> Sent: Sunday, January 25, 2004 2:56 AM
> Subject: st: Loop for Shapley Decomposition sub-routine
>
>
> > Hi all,
> > I am trying to apply the Shapley decomposition method to household consumption
> data.
> > I am wondering if there is a short cut to do the following subroutine.
> >
> > Consumption data is x, and assume there are 4 explanatory variables,
> var1-var4.
> >
> > I have performed the following:
> >
> > regress x var1 var2 var3 var4
> >
> > saved the betas as B1, B2 etc. upto B5 (coeff on the constant) and generated
> them as variables alongside var1 var2 etc.
> >
> > I next need to generate means of variables, vbar1, vbar2, and generate new
> consumption variables x1 x2 x3 x4 as follows.
> >
> > Using a loop,
> >
> > local i=$j/*where $j is total no of vars, that is 4*/
> > while `i'>=1{
> > qui sum var`i'
> > qui gen vbar`i'=r(mean)
> > qui gen XXXXXX/*see below*/
> > local i =`i'-1
> > }
> >
> > The XXXXXX part has to read as follows if i=4
> >
> > x4=exp((B1*var1)+(B2*var2)+(B3*var3)+(B4*vbar4) +(B($j+1))/*constant*/
> >
> > if i=3, then XXXX must read,
> >
> > x3=exp((B1*var1)+(B2*var2)+(B3*vbar3)+(B4*var4) +(B($j+1))/*constant*/
> >
> > if i=2, then XXXXX goes,
> > x2=exp((B1*var1)+(B2*vbar2)+(B3*var3)+(B4*var4) +(B($j+1))/*constant*/
> >
> > etc.
> >
> > Can anyone please suggest how I may write an expression for XXXXX which
> includes all the above possibilities, depending on the value that `i'
> takes and
> even if I have 25 variables?
> >
> > Thanks so much,
> > Ramani
>
> *
> * For searches and help try:
> * http://www.stata.com/support/faqs/res/findit.html
> * http://www.stata.com/support/statalist/faq
> * http://www.ats.ucla.edu/stat/stata/
*
* For searches and help try:
* http://www.stata.com/support/faqs/res/findit.html
* http://www.stata.com/support/statalist/faq
* http://www.ats.ucla.edu/stat/stata/