Programming the statistical procedures from SAS

Likelihood ratio tests for mean structures in proc mixed: can it be done through simple-ish syntax?

Reply
New Contributor
Posts: 3

Likelihood ratio tests for mean structures in proc mixed: can it be done through simple-ish syntax?

Howdy.

Does anyone know of a way to script to compare mixed effects model mean structures with a likelihood ratio test in SAS?

I know SAS spits out -2 Log Likelihoods in proc mixed (with method=ml), and I can run two models (a simple example with linear models:  one with two main effects [random intercept, let's say]; and one with the two main effects and an interaction term [random slope + intercept]) then use each -2 Log Likelihood to construct a likelihood ratio statistic and test against chi-squared, but I would think there has to be some not-too-difficult way to script such a test rather than scrolling back through the outputs and constructing the test statistic "by hand."

I searched about a bit already, but didn't find anything helpful, except a fairly convoluted macro.

Any assistance will be much appreciated.

Thanks kindly -

d.G.

Regular Contributor
Posts: 152

Re: Likelihood ratio tests for mean structures in proc mixed: can it be done through simple-ish syntax?

PROC MIXED can create an Output Delivery System (ODS) tables of the fit statistics for a model, one of which is the -2*log likelihood statistic.  Run PROC MIXED twice to generate these SAS data sets of fit statistics, once with your more limited model and the other time with your more expansive model.  In a DATA step, select the -2*log likelihood statistic from the two ODS tables, merge these two tables together, subtract one statistic from the (renamed) other statistic, and calculate the probability under a chi-squared distribution that this difference is statistically significant.

Valued Guide
Valued Guide
Posts: 673

Re: Likelihood ratio tests for mean structures in proc mixed: can it be done through simple-ish syntax?

Just to expand on the answer from 1zmm. The ODS output file is called FitStatistics. Here is a sample program for doing the likelihood ratio test for a fixed effect (treatment) based on two runs of MIXED. This is a different model from the one you describe, but it shows how to store the -2 log likelihoods, and then get their difference in a DATA step. You will have to keep track of the approriate number of degrees of freedom. One could get more sophisticated and store df for each run in other ODS files, combine all of these, and then get the chi-square p value in a data step, but this should get you in the right direction. For others reading this, it is very important that method=ml is used to do the likelihood ratio test for fixed effects.

data a;     *-generate some data for the demonstration;

do block = 1 to 6;

    blk = rannor(1)*sqrt(2);

    do trt = 1 to 4;

        error = rannor(1);

        y = 10 + blk + trt/2 + error;

        output;

        end;

    end;

;

proc mixed data = a method=ml;

ods output fitstatistics=fits1;

class block trt;

model y = trt / s;

random block;

run;

proc print data=fits1;

run;

proc mixed data = a method=ml;

ods output fitstatistics=fits2;

class block trt;

model y =  / s;

random block;

run;

proc print data=fits2;

run;

data combine;

    merge    fits1(obs=1 rename=(Value=one))

            fits2(obs=1 rename=(Value=two));

    statistic = two - one;

proc print data=combine;run;

New Contributor
Posts: 3

Re: Likelihood ratio tests for mean structures in proc mixed: can it be done through simple-ish syntax?

Thanks for the posts, 1zmm and lvm:  both helpful responses.

I was really hoping there was a way in SAS to put two (or more!) different models in a single procedure and have SAS calculate and output LR tests:  either ML-based for fixed-effect, mean-structure testing or REML-based for testing random-effects / covariance patterns.  If anyone out there knows of such a dangerous weapon  Smiley Wink  let a message-board brother know.

Thanks,

David Goliath

Valued Guide
Valued Guide
Posts: 673

Re: Likelihood ratio tests for mean structures in proc mixed: can it be done through simple-ish syntax?

You were only asking about fixed effects in your original posts. In general, MIXED or GLIMMIX are designed to fit only one model at a time. So, you have to run the procedure twice. But for random effects, it is a different story. With GLIMMIX (not MIXED), you can use the COVTEST statement (don't confuse this with the covtest option in MIXED). Check out the documentation. This is a powerful tool for testing random effects using likelihood ratios.

New Contributor
Posts: 3

Re: Likelihood ratio tests for mean structures in proc mixed: can it be done through simple-ish syntax?

Thanks again for the reply, lvm.

True, I only asked about fixed effects in my first post, but I'm also wondering about REML-based LR tests for testing random effects / covariance patterns.

I see that covtest option in proc mixed produces standard errors and Wald Z-tests for covariance parameter estimates whereas covtest statement in proc glimmix appears to be testing any specified covariance pattern against an assumed-independent pattern.  Very kewl.

Much obliged.

Ask a Question
Discussion stats
  • 5 replies
  • 375 views
  • 6 likes
  • 3 in conversation