Programming the statistical procedures from SAS

Proc Mianalyze with mixed models

Reply
Contributor
Posts: 20

Proc Mianalyze with mixed models

Hello,

I have a dataset with missing data (17/722=2.35%).  I have run multiple imputations on this dataset.  I want to run a mixed model with repeated option on the imputations.  In addition to overall effects I would like to test contrasts.

1.  How do I get Mianalyze to give me the results of the ESTIMATE from PROC MIXED?

Here is the code:

*multiple imputation;

proc mi data=XX seed=23456 nimpute=3 out=miout1;

mcmc;

var change baseline;

run;

*MMRM model;

proc mixed data=miout1 method=ml;

by _imputation_;

class trt visit usubjid country sex;

model change=trt visit trt*visit baseline country /ddfm=kr solution covb;;

repeated visit/ subject=usubjid type=vc;

lsmeans trt*visit/cl pdiff;

estimate 'Trt A vs Trt B at visit 2'  trt 1 -1 trt*visit 1 0 -1 0/cl;

estimate 'Trt A vs Trt B at visit 3'  trt 1 -1 trt*visit 0 1 0 -1/cl;

ods output solutionf=mixparms covb=mixcovb diffs=mixdiff estimates=mixestimates;

run;

quit;

*Mianalyze procedure;

proc mianalyze parms(classvar=full)=mixparms covb (effectvar=rowcol)=mixcovb edf=663;

class trt visit usubjid country;

2.  I am getting this in the log of the proc mianalyze.

WARNING:  The within-imputation covariance matrix is singular.  The total covariance matrix and related statistics in multivariate inference will be set to missing.

I am not sure why.

Thank you in advance for your help.

ns


Respected Advisor
Posts: 2,655

Re: Proc Mianalyze with mixed models

MIANALYZE and MIXED don't always play well with one another.  My first instinct would be to trust in the results obtained from PROC MIXED with the data treated as missing.  Unless the data are MNAR, the likelihood methods of mixed models are at least as good as any imputational method available in PROC MI (opinion only), as none of the imputational methods deal well with random effects, and especially nested random effects. Note that the PROC MIXED examples in the MIANALYZE documentation have neither a RANDOM or a REPEATED statement, so that strikes me as unusual.

Still, I believe that there was a paper presented at one of the last two SGF meetings that addressed how to get the necessary matrixes into MIANALYZE.  This was not straightforward, and I have yet to get it right (though I haven't tried in almost a year).  And, to get the equivalent of the ESTIMATE statements, you will have to specify a TEST statement in MIANALYZE. It will give an estimate and a standard error.

Steve Denham

Contributor
Posts: 20

Re: Proc Mianalyze with mixed models

Thank you for your response.

I have noticed that there is not much information on MIANALYZE together with repeated statements.  I have also been researching this and have found pretty consistently that using the MMRM model without imputation is just as good as trying to impute the data.  In order to strengthen this idea, I wanted to show the results of the ESTIMATES in both ways.  I wanted to show that the pvalues are similar in the MMRM and then in the MIANALYZE.  I am just not having success with this in the mianalyze procedure (TEST statement).  Can you perhaps help with the syntax?

Also, until I resolve the WARNING, I cannot rely on the results. I am not sure why I am getting that warning.

Thanks for the reference to the SGF papers.  I will look them up and see how they can help.

Thanks,

ns 

Respected Advisor
Posts: 2,655

Re: Proc Mianalyze with mixed models

To get TEST to work, you need the names of the variables from the mixparms dataset.  You can then plug them in to get an equivalent to the ESTIMATE statement.  The output will include the L matrix, so you could check to see that it is doing what you ask.

It may be that your G or R matrix is singular for one of the imputations.  I would suggest doing more imputations and selecting only those that avoid this.  If it keeps throwing this error, then I might think about opening a ticket with Tech Support.

Steve Denham

Contributor
Posts: 20

Re: Proc Mianalyze with mixed models

Thank you again for your help.  I was not able to get the TEST statement to work the way I wanted. Instead I used this code:

proc mianalyze data=estimates;

     by label;

     modeleffects estimate;

     stderr stderr;

run;

Does this look correct?

I am still not able to fix the warning in the log of the MIANALYZE procedure regardng the within imputation covariance matrix being singular. I cannot figure out what is causing this.  Running more imputations and trying to choose a subset of these did not help.

ns

Respected Advisor
Posts: 2,655

Re: Proc Mianalyze with mixed models

We are definitely beyond my abilities with that error.  Open up a ticket with Tech Support.  I know the last time we got stuck on this that Tech Support was the way to go.  When they give their feedback, please share it here.  I could really stand to learn how to fix this.

BTW, that looks like a good workaround over the estimates.

Steve Denham

New User
Posts: 1

Re: Proc Mianalyze with mixed models

Hi all, I just figured out a fix for the MIANALYZE issue... You will need to recode the "Label" variable name in your "mixestimates" dataset to one of the suggested names that is listed in the error statement. I recoded "LABEL" as "ROWNAME" in the mixestimates2 dataset. From there you can run the MIANALYZE script below on the mixestimates2 dataset. Also, you will need to label your ESTIMATE statements in PROC MIXED using a one word variable name in between the quotes (see below). I hope this helps!

 

-Robert

 

*********************************************************

Recoding variables

*********************************************************;

DATA mixestimates2(RENAME = (LABEL=ROWNAME));

SET mixestimates;

PROC PRINT DATA= est2 (firstobs= 1 obs= 25);

VAR _IMPUTATION_ ROWNAME;

RUN;

 

PROC MIANALYZE parms=mixestimates2;

MODELEFFECTS Var1 Var2 Var3 Var4;

run;

 

 

*********************************************************

Estimate statements

*********************************************************;

ESTIMATE 'VAR1' EMOT 1 TK*EMOT -3;

ESTIMATE 'VAR2' EMOT 1 TK*EMOT -2;

ESTIMATE 'VAR3' EMOT 1 TK*EMOT -1;

ESTIMATE 'VAR4' EMOT 1 TK*EMOT  0;

N/A
Posts: 1

Re: Proc Mianalyze with mixed models

I think the warning about the singularity has to do with the fact that there is a 0 row in the COVB matrix for the reference level of class variables.  One possibility is to create dummy codes instead of using class variables and see if that helps.

Carole.

Ask a Question
Discussion stats
  • 7 replies
  • 1752 views
  • 0 likes
  • 4 in conversation