Hi,
first if your script does what you want, why try to "change a winning team"?

Apart from that, for a weighted mean maybe the wmean() function in
combination with clever sample restrictions could do the job for you,
too. But what exactly do you mean with "time series means" -- I would
have thought the per-unit means of pmean() are just that.

cheers,
sven

MICHAEL BOLDIN schrieb:
> I would like to calculate time series means in a panel data set as
> easily as pmean()  and  wonder if there is a built in function or
> easier way than my script below. I am computing stock market returns
> for a portfolio where px=1 was set to select the included
> cross-sectional identifiers, and note I also need to weight (by market
> value in this case).
> 
> smpl --full
> series retp= NA
> ## Loop over dates
> loop foreach dx  38748 38776 38807
>     smpl --full
>     ## Set sample dates and selected ids
>     smpl DATE= $dx --restrict
>     smpl px=1 --restrict
>     ##  Compute weighted average returns as wls intercept coefficient
>     wls mktval_lag ret const  --quiet
>     series retp=$coeff(0)
> endloop
> 
> Second and third thing:  I imported the data from EXCEL and the dates
> are numbers (1/1/1900=0), hence my loop over 38748 38776 38807 that
> are month end days.  Is there a easy way to get all date ids to loop
> over and format as dates.
> _______________________________________________
> Gretl-users mailing list
> Gretl-users(a)lists.wfu.edu
> http://lists.wfu.edu/mailman/listinfo/gretl-users
> 

Reply via email to