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]

Re: st: loop


From   Nick Cox <njcoxstata@gmail.com>
To   statalist@hsphsun2.harvard.edu
Subject   Re: st: loop
Date   Thu, 29 Mar 2012 15:59:25 +0100

Commenting only on

> reg lwage $x if fem==0
> predict pip if fem==0, xb
> forvalues k = 1 2 to 7 {
>        predict pip`k' if fem==0 & occ`k'==1, xb
> }

Note that these are exactly the same predictions. You are just
selecting different subsets of observations. So
no obvious purpose is served by -predict-ing the same variable over
and over again.

Nick

On Thu, Mar 29, 2012 at 3:32 PM, Chiara Mussida <cmussida@gmail.com> wrote:
> Dear All,
> I wrote a loop for wage regressions to obtain the predicted wages if
> men are paid as men at each occupation:
>
> reg lwage $x if fem==0
> predict pip if fem==0, xb
> forvalues k = 1 2 to 7 {
>        predict pip`k' if fem==0 & occ`k'==1, xb
> }
> summarize pip, meanonly
> scalar xMbM=r(mean) /*Predicted wages if men are paid as men*/
> forvalues k = 1 2 to 7 {
>        summarize pip`k', meanonly
>        scalar xMbM`k'=r(mean) /*Predicted wages if men are paid as men at
> each occupation*/
> }
>
> I now want to get the xMbM (and also xFbF for females) by occupation.
> For each occupation I want the product between ythe mean individual
> charachteristics (xM) and the coefficients (bM). I tried with this
> loop, but i'm not sure it's the correct one:
>
> reg lwage $x if fem==0
> predict pip if occupation==1, xb
> forvalues k = 1  {
>        predict pip`k' if fem==0 & occ`k'==1, xb
> }
> summarize pip, meanonly
> scalar xMbM=r(mean) /*Predicted wages if men are paid as men*/
> forvalues k = 1 {
>        summarize pip`k', meanonly
>        scalar xMbM`k'=r(mean) /*Predicted wages if men are paid as men at
> each occupation*/
> }
>
> More precisely, i'm not sure this wille give me each product between
> mean values of characteristics (x, for M or F) and estomated wage
> equation coefficients (b, for M or F) at each 1...7 occupation.
>

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