BookmarkSubscribeRSS Feed
☑ This topic is solved. Need further help from the community? Please sign in and ask a new question.
Lucai_sister
Obsidian | Level 7

Hi, guys. I would like to study the mean difference in the number of relapse among the three treatment groups. Because the data set was partially missing, after using multiple imputation, 100  imputation sets were obtained.

After using pro genmod analysis, I want to use the nlmeans macro to compare the comparison results of each imputation set.  But the following result is prompted. Do you know why?

 

here is my data

imputation      id      relapse_count    lntime   group

1                          1             0                        -1             1

1                          2             2                       -3             2

.....

100                    33            3                       -4             3

 

here is my SAS code:

stype1:
proc genmod data=relapse;
class group(ref="1") id/param=glm;
model relapse_count=group/link=log dist=negbin offset=lntime;
repeated subject=id;
lsmeans group/ilink cl e;
estimate 'group2 vs 1 of RR' group -1 1 0/e;
estimate 'group1 vs 3 of RR' group 1 0 -1/e;
estimate 'group2 vs 3 of RR' group 0 1 -1/e;
ods output coef=coeffs;
store out=insmodel;
by _Imputation_;
run;

stype2:
%include 'path\nlest.sas';
%include 'path\nlmeans.sas';
%NLMeans(instore=insmodel, coef=coeffs, link=log, title=Difference of relapse Rates)



Here is the error:
Lucai_sister_0-1685453700392.png
here is my coeffs:
Lucai_sister_1-1685453850889.png

Am I missing a procedure? I really want researchers to help me.


 

1 ACCEPTED SOLUTION

Accepted Solutions
StatDave
SAS Super FREQ

As Rob suggests, to get a final combined rate estimate you need to run NLMeans on each imputation data set and then combine the results. BY processing can be done by using the NLMeans macro in the RunBY macro. This is discussed in the Details section of the NLMeans macro documentation and is illustrated in the last example in the Results tab. In your case, you should drop the ESTIMATE statements since only the LSMEANS statement is needed. Then, after downloading the RunBY macro and defining it in your session using a %INC statement, you should just need to add the following after your GENMOD step. I also suggest you make sure you are using the latest versions of the NLMeans and NLEST macro (which NLMeans calls). You can download the latest versions from support.sas.com.

%macro code;
  %nlmeans(instore=insmodel, coef=coeffs, link=log, where=&_BY1=&_LVL1, 
           options=nonames noprint, title=rate diffs)
  proc append base=alldiff data=est; run;
%mend;
%runby(data=relapse, by=_imputation_)

data alldiff; 
  set alldiff;  
  _imputation_=_n_;
  run;
proc mianalyze data=alldiff;
   modeleffects estimate;
   stderr standarderror;
   run;

 

View solution in original post

6 REPLIES 6
sbxkoenk
SAS Super FREQ

Hello,

 

Here's how you should use multiple imputation.

 

Multiple imputation inference involves three distinct phases:
  1. The missing data are filled in m times to generate m complete data sets or by-groups. (PROC MI)
  2. Perform regression or any other analysis on each of the m complete data sets or by-groups. (PROC GENMOD)
  3. Average the values of the parameter estimates across the M samples to produce a single point estimate. (PROC MIANALYZE)

After 3. you can run the macro's you need!

 

See also here:

Multiple Imputation for Missing Data: Concepts and New Development (Version 9.0)
Yang C. Yuan, SAS Institute Inc., Rockville, MD
https://support.sas.com/rnd/app/stat/papers/multipleimputation.pdf

https://support.sas.com/rnd/app/stat/topics/multiple-imputation.html

 

[EDIT] @Lucai_sister 
My answer is not entirely correct, I believe.
I am sure my colleagues @SAS_Rob and @StatDave know better, so please follow their advice.
See below for their replies!

 

Koen

 
Lucai_sister
Obsidian | Level 7
I really appreciate your advice!
SAS_Rob
SAS Employee

The %NLMEANS macro does not have a BY statement which is what you would need to make this work.  My suggestion would be to run the macro for each _imputation_ independently and then combine the estimates and standard errors into a single data set.  Once you do that you should be able to use Proc MIANALYZE to get the final combined estimates.

Lucai_sister
Obsidian | Level 7
Thank you so much!
StatDave
SAS Super FREQ

As Rob suggests, to get a final combined rate estimate you need to run NLMeans on each imputation data set and then combine the results. BY processing can be done by using the NLMeans macro in the RunBY macro. This is discussed in the Details section of the NLMeans macro documentation and is illustrated in the last example in the Results tab. In your case, you should drop the ESTIMATE statements since only the LSMEANS statement is needed. Then, after downloading the RunBY macro and defining it in your session using a %INC statement, you should just need to add the following after your GENMOD step. I also suggest you make sure you are using the latest versions of the NLMeans and NLEST macro (which NLMeans calls). You can download the latest versions from support.sas.com.

%macro code;
  %nlmeans(instore=insmodel, coef=coeffs, link=log, where=&_BY1=&_LVL1, 
           options=nonames noprint, title=rate diffs)
  proc append base=alldiff data=est; run;
%mend;
%runby(data=relapse, by=_imputation_)

data alldiff; 
  set alldiff;  
  _imputation_=_n_;
  run;
proc mianalyze data=alldiff;
   modeleffects estimate;
   stderr standarderror;
   run;

 

Lucai_sister
Obsidian | Level 7
The code works fine. Thank you so much!

sas-innovate-2024.png

Available on demand!

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

 

Register now!

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.

Discussion stats
  • 6 replies
  • 879 views
  • 9 likes
  • 4 in conversation