I noticed that the summary command does show the within and between
variation for a series but not for lists.
Hence, I wanted to calculate the variation components with a UDF.
On page 33 of this presentation
the stata output for the series mdu of the data set 'mus18data.dta'
) is shown.
The only difference to the gretl output is the calculated within variation:
When trying to calculate it myself I came up with totally different
How is it correct? Is there 'a' correct method?
series x_bar_i= pmean(mdu)
series x_bar = mean(mdu)
## between variation
eval sd(pmean(mdu)) # OK
eval sqrt(sum(((x_bar_i-x_bar)^2))/5908/5) # OK, Baltagi (2003) p.76f
*## within variation*
eval mean(psd(mdu)) # *wrong*
eval sqrt(sum((mdu-x_bar_i)^2)/5908/5) # *wrong*, Baltagi (2003) p.76