turn on suggestions

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

Showing results for

Find a Community

- Home
- /
- Analytics
- /
- Stat Procs
- /
- Likelihood ratio tests for mean structures in proc...

Topic Options

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

- Mark as New
- Bookmark
- Subscribe
- Subscribe to RSS Feed
- Permalink
- Email to a Friend
- Report Inappropriate Content

02-23-2013 04:07 PM

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.

- Mark as New
- Bookmark
- Subscribe
- Subscribe to RSS Feed
- Permalink
- Email to a Friend
- Report Inappropriate Content

Posted in reply to davidGOLIATH

02-24-2013 12:39 PM

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.

- Mark as New
- Bookmark
- Subscribe
- Subscribe to RSS Feed
- Permalink
- Email to a Friend
- Report Inappropriate Content

Posted in reply to 1zmm

02-24-2013 04:09 PM

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
- Subscribe to RSS Feed
- Permalink
- Email to a Friend
- Report Inappropriate Content

Posted in reply to davidGOLIATH

03-08-2013 05:39 PM

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
- Subscribe to RSS Feed
- Permalink
- Email to a Friend
- Report Inappropriate Content

Posted in reply to davidGOLIATH

03-09-2013 11:38 AM

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.

- Mark as New
- Bookmark
- Subscribe
- Subscribe to RSS Feed
- Permalink
- Email to a Friend
- Report Inappropriate Content

03-13-2013 04:33 PM

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.