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   Stas Kolenikov <[email protected]>
To   [email protected]
Subject   Re: st: Loop for Shapley Decomposition sub-routine
Date   Sun, 25 Jan 2004 14:24:44 -0500 (EST)

--- 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
 - http://www.komkon.org/~tacik/  -- [email protected]

* This e-mail and all attachments to it are not intended to provide any
* reasonable point of view and was transmitted to you in error. It
* should be immediately deleted by all recepients unless they really
* enjoy communicating with the author :). Other restrictions apply.

*
*   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