I am doing emmeans analysis for my bachelors thesis. I am analysing households incomes based on different variables like education, number of children, job sector, area ect.
The question is: Is there a way to merge eg. multiple living areas into one, as they have basically the same mmean and then construct the GLM again?
In SAS I would use this code to merge 3 areas into one: ESTIMATE "BB-KE-ZA" intercept 3 REGION 1 1 0 0 0 0 1 /divisor=3;
and I wish to do the same in R.
I wish to create new value of the variable Region where will be merged 3 values of the variable Region that have same least square means.
Sure. If you have something like
and
group
has levels A, B, C, D, E, and you want to average (B, D, and E) as well as (A and C), you could useWhile
contrast()
is primarily intended to compute contrasts, it can compute any linear function -- similar to your SASESTIMATE
statement except it works with the EMMs rather than the regression coefficients.