I use class in proc glm to run a one-way fixed-effect model as follows.
data have;
do i=1 to 3;
do j=1 to 3;
do k=1 to 10;
x=rannor(1);
y=x+rannor(1);
output;
end;
end;
end;
run;
proc glm data=have;
class i;
model y=x i/noint solution;
ods output parameterestimates=oneway_class;
quit;Or sometimes I use absorb because it is faster than class.
proc glm data=have;
absorb i;
model y=x/noint solution;
ods output parameterestimates=oneway_absorb;
quit;And I found that absorb, unlike class, cannot estimate a two-way fixed-effect model in this way.
/*THE FOLLOWING ESTIMATES TWO-WAY FIXED-EFFECT MODELS CORRECTLY*/
proc glm data=have;
class i j;
model y=x i j/noint solution;
ods output parameterestimates=twoway_class;
quit;
/*THE FOLLOWING DOES NOT ESTIMATE TWO-WAY FIXED-EFFECT MODELS*/
proc glm data=have;
absorb i j;
model y=x/noint solution;
ods output parameterestimates=twoway_absorb;
quit;Though the first glm with class is correct, it becomes too slow because the real data have so many observations. How can I estimate a two-way fixed-effect model with absorb in glm instead?
Correct.
If you use the ABSORB statement with two variables, ABSORB assumes that the second variable in the list is nested within the first, and this is not the design you have.
Correct.
If you use the ABSORB statement with two variables, ABSORB assumes that the second variable in the list is nested within the first, and this is not the design you have.
Thanks. Then should I give up the absorb approach for two-way fixed effects?
@Junyong wrote:
Thanks. Then should I give up the
absorbapproach for two-way fixed effects?
I would replace the word "should" with "must"
Sad news since LSDV-estimating multi-way fixed-effect models is computationally costly, but thanks anyway.
April 27 – 30 | Gaylord Texan | Grapevine, Texas
Walk in ready to learn. Walk out ready to deliver. This is the data and AI conference you can't afford to miss.
Register now and lock in 2025 pricing—just $495!
Learn how use the CAT functions in SAS to join values from multiple variables into a single value.
Find more tutorials on the SAS Users YouTube channel.
Ready to level-up your skills? Choose your own adventure.