Turn on suggestions

Auto-suggest helps you quickly narrow down your search results by suggesting possible matches as you type.

Showing results for

- Home
- /
- Analytics
- /
- Stat Procs
- /
- Likelihood ratio tests for mean structures in proc mixed: can it be d...

Options

- RSS Feed
- Mark Topic as New
- Mark Topic as Read
- Float this Topic for Current User
- Bookmark
- Subscribe
- Mute
- Printer Friendly Page

- Mark as New
- Bookmark
- Subscribe
- Mute
- RSS Feed
- Permalink
- Report Inappropriate Content

Posted 02-23-2013 04:07 PM
(3635 views)

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.

6 REPLIES 6

- Mark as New
- Bookmark
- Subscribe
- Mute
- RSS Feed
- Permalink
- Report Inappropriate Content

- Mark as New
- Bookmark
- Subscribe
- Mute
- RSS Feed
- Permalink
- Report Inappropriate Content

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;

- Mark as New
- Bookmark
- Subscribe
- Mute
- RSS Feed
- Permalink
- Report Inappropriate Content

Thanks for this response. My worry with the likelihood ratio tests for mean structures in proc mixed is that the difference of the -2 loglikelihood will have chi distribution with zero degree of freedom. From the example you gave, there is one covariance parameter in each of the fitted model which implies different of zero degree of freedom. This is the problem I am having with the analysis I am doing.

Please clarification.

- Mark as New
- Bookmark
- Subscribe
- Mute
- RSS Feed
- Permalink
- Report Inappropriate Content

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 let a message-board brother know.

Thanks,

David Goliath

- Mark as New
- Bookmark
- Subscribe
- Mute
- RSS Feed
- Permalink
- Report Inappropriate Content

- Mark as New
- Bookmark
- Subscribe
- Mute
- RSS Feed
- Permalink
- Report Inappropriate Content

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.

**Available on demand!**

Missed SAS Innovate Las Vegas? Watch all the action for free! View the keynotes, general sessions and 22 breakouts on demand.

What is ANOVA?

ANOVA, or Analysis Of Variance, is used to compare the averages or means of two or more populations to better understand how they differ. Watch this tutorial for more.

Find more tutorials on the SAS Users YouTube channel.