## PROC NESTED VS. PROC VARCOMP / MIXED

Regular Contributor
Posts: 180

# PROC NESTED VS. PROC VARCOMP / MIXED

Hello all,

I have lab results and I want to do variance analysis as a part of an R&R analysis. My main interest is the variance components, i.e., what is the variance associated with each factor and what is the percentage of each factor out of the total variability. I have a continuous variable Y and 4 factors: X1, X2, X3 and X4.

I tried 3 different PROC's for this analysis: MIXED, VARCOMP and NESTED. MIXED and VARCOMP gave me identical results, while NESTED was different. In the results of NESTED, I got for the total variance, the exact observed variance of the entire dataset, while in MIXED or VARCOMP, the total variance was higher by 10 (65 instead of 55) from the observed variance.

One of my factors is responsible for most of the variance, I know it as a fact (can be seen graphically). In NESTED is had 99.9% of the total variability, while in MIXED or VARCOMP less (still over 90%). On the surface, it looks like NESTED is better, since it actually gives me the observed variance. Anyone who will look at the output of MIXED or VARCOMP will wonder where the total variability came from. I tried this also in JMP (which is automatic), and it ran the variance component using a Bayesian estimation, and then the total variance was almost as the observed (2 units less).

Does anyone here known why I see such big differences between NESTED and VARCOMP (or MIXED) ? Which one should I go with ?

My code is:

``````proc varcomp method=reml data=RR;
class X1 X2 X3 X4;
model Y=X1 X2(X1) X3(X1 X2) X4(X1 X2 X3) / fixed=0;
run;

proc nested data=RR;
class X1 X2 X3 X4;
var Y;
run;``````

Posts: 2,048

## Re: PROC NESTED VS. PROC VARCOMP / MIXED

You should not expect these two methods to produce identical results.

PROC NESTED uses the ANOVA sums of squares breakdown of variance, PROC VARCOMP uses REML (Restricted Maximum Likelihood), and these will not give the same answers.

The ANOVA sums of squares method can produce negative variance estimates, while (Restricted) Maximum Likelihood will not produce negative variance estimates.

If you have fixed factors in your design, REML will probably be better, but its really not as simple as that.

--
Paige Miller
Discussion stats