Stata The Stata listserver
[Date Prev][Date Next][Thread Prev][Thread Next][Date index][Thread index]

Re: st: Loop for Shapley Decomposition sub-routine


From   Ramani Gunatilaka <[email protected]>
To   [email protected]
Subject   Re: st: Loop for Shapley Decomposition sub-routine
Date   Mon, 26 Jan 2004 07:37:40 +0000

Thank you, Stas. Will follow up.
Regards,
Ramani

Stas Kolenikov <[email protected]> wrote:
> --- In [email protected], Ramani Gunatilaka
> > 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.
> 
> I have -shapley- ado-file available from my web-page (the server is down
> sometimes; there should be a copy at SSC although it might be quite old).
> 
> The best way to proceed within the context of that program is to generate
> 
> foreach x of varlist <<your variables here>> {
>   gen VVV`x' = `x'
> }
> 
> then
> 
> regress depvar VVV*
> 
> which would give you the coefficients to use later, and then run my
> -shapley- with a subroutine that would do something like
> 
> cap prog drop MyShapley
> prog define MyShapley
> 
>   syntax varlist
> 
>   foreach x of varlist <<your variables here again>> {
>     replace VVV`x' = `x'
>   }
>   foreach x of varlist `varlist' {
>     sum `x'
>     replace VVV`x' = r(mean)
>   }
>   cap drop predicted
>   predict predicted
> 
>   * do whatever you need with that predicted variable
> 
> end
> 
>  ---                                    Stas Kolenikov
>  --       Ph.D. student in Statistics at UNC-Chapel Hill
>
*
*   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/



© Copyright 1996–2024 StataCorp LLC   |   Terms of use   |   Privacy   |   Contact us   |   What's new   |   Site index