On 06/04/2026 19:07, Ramki S wrote:
Hi
Is there any option to create grand mean centering of a varibale x_mc, (x_i - x_bar),
group mean (x_barj), centering within clustered variable x_cwc (x_i - x_barj). These are
necesary functions to teach mixed models. If there are not, i request you to provide.
The aggregate() function is probably your best friend here:
<hansl>
open mroz87.gdt
matrix m = aggregate(WA, KL6, mean)
series grpmeans = replace(KL6, m[,1], m[,3])
series WA_demeaned = WA - grpmeans
boxplot WAdemeaned KL6 --fact --output=display
</hansl>
-------------------------------------------------------
Riccardo (Jack) Lucchetti
Dipartimento di Scienze Economiche e Sociali (DiSES)
Università Politecnica delle Marche
(formerly known as Università di Ancona)
r.lucchetti(a)univpm.it
http://www2.econ.univpm.it/servizi/hpp/lucchetti
-------------------------------------------------------