BookmarkSubscribeRSS Feed
🔒 This topic is solved and locked. Need further help from the community? Please sign in and ask a new question.
Naviava1973
Fluorite | Level 6

Hi All,

I am running a treatment effect longitudinal analysis with the outcome being a log transformed value collected over 5 days.

My covariates are time and treatment group (intervention vs. control) and their interaction (treatment*time).

The aim of the analysis is to determine if there is a treatment effect in favour of the intervention but expressed as a percentage change.

I have fitted my model assuming a fixed effect for time, treatment group and their interaction with a random intercept.

proc mixed; class treatment; model outcome= time time*treatment / s; random intercept/subject=ID; run;

Could someone point me to literature or example that illustrates how the treatment effect is determined as a percentage? Or an example if any?

 

Regards

Kennedy 

 

1 ACCEPTED SOLUTION

Accepted Solutions
jiltao
SAS Super FREQ

It looks to me that your response variable is a log-transformed variable. The percent difference in lsmeans that you want would be on the logged scale, correct?

Like @SteveDenham pointed out, you can save the LSMEANS results (using an ODS OUTPUT statement) and use SAS data steps to compute the percent difference in lsmeans. However, this will not give you standard errors / p-values / confidence intervals. If you also wanted to make inferences on the percentage, you might consider using PROC NLMIXED to fit your model, and use the ESTIMATE statement in PROC NLMIXED to compute the percent difference. The ESTIMATE statement would produce the p-value and 95% confidence interval for you on the estimate (which is the percent difference).

For method 2 suggested by @SteveDenham, I assume he wanted you to use the Log link on your log-transformed variable? I just wanted to point out that these two methods will not give you the same model. Also, Steve might mean pct_change = 100* (exp(diff in lsmeans) -1) rather than pct_change = 100* (diff in lsmeans -1). Please correct me if I am wrong @SteveDenham.

 

Jill

View solution in original post

21 REPLIES 21
SteveDenham
Jade | Level 19

I can think of two ways, but neither is done entirely within PROC MIXED.  I'll list them in order of probable appropriateness.

Method 1: Get the lsmeans and differences into datasets, merge them and post process it, dividing the difference from pretreatment for each post treatment time lsmean by the pretreatment time lsmean and multiply by 100.

Method 2: Shift to PROC GLIMMIX, use a log link.  The differences will be ratios which are "fold" changes.  From there convert to percentage changes by calculating pct_change = 100* (diff in lsmeans -1).

 

What you should NOT do is divide the values by each pretreatment value and analyze the ratios as if they were normal.  This ignores all covariance within subject, plus ratios of variables with normal errors generally do not have normal errors.

 

SteveDenham

Naviava1973
Fluorite | Level 6
Thank you very much Steve.
I will work to implement this approach and see what I get.
jiltao
SAS Super FREQ

It looks to me that your response variable is a log-transformed variable. The percent difference in lsmeans that you want would be on the logged scale, correct?

Like @SteveDenham pointed out, you can save the LSMEANS results (using an ODS OUTPUT statement) and use SAS data steps to compute the percent difference in lsmeans. However, this will not give you standard errors / p-values / confidence intervals. If you also wanted to make inferences on the percentage, you might consider using PROC NLMIXED to fit your model, and use the ESTIMATE statement in PROC NLMIXED to compute the percent difference. The ESTIMATE statement would produce the p-value and 95% confidence interval for you on the estimate (which is the percent difference).

For method 2 suggested by @SteveDenham, I assume he wanted you to use the Log link on your log-transformed variable? I just wanted to point out that these two methods will not give you the same model. Also, Steve might mean pct_change = 100* (exp(diff in lsmeans) -1) rather than pct_change = 100* (diff in lsmeans -1). Please correct me if I am wrong @SteveDenham.

 

Jill

Naviava1973
Fluorite | Level 6
Thank you Jiltao.
I will look for PROC NLMIXED references that specifically address the percentage change.
This is definitely helpful.
I really thank you both.
Naviava1973
Fluorite | Level 6
Yes my response variable is log transformed.
SteveDenham
Jade | Level 19

@Naviava1973 , I missed that your response was already log transformed.  That means that for the first method I mentioned, the lsmeans need to be preprocessed by exponentiating.  The same would apply to any confidence bounds.  The second method could be applied directly to the lsmeans you currently obtain as well as any confidence bounds.  As @jiltao said, you would have to use NLMIXED to get valid standard errors for the means on the original scale.

 

SteveDenham

Naviava1973
Fluorite | Level 6
Hi Steve,
Thanks for the advise.
I really appreciate.

Regards

KO
Naviava1973
Fluorite | Level 6
Hi Jil,
I have run the approach proposed by Steve Denham. I was wondering if you could point me to a reference for NLMIXED that has done something similar so I can compare findings from both methods.
Naviava
jiltao
SAS Super FREQ

Here is the documentation for PROC NLMIXED, where you can find syntax and example code --

https://go.documentation.sas.com/?cdcId=pgmsascdc&cdcVersion=v_009&docsetId=statug&docsetTarget=stat...

 

Suppose your treatment contains levels A and P, and your data is already sorted by ID. Then if this is your PROC MIXED statement --

proc mixed; 
class treatment; 
model outcome= time treatment time*treatment / s; 
random intercept/subject=ID; 
lsmeans treatment / e;
run;

You might write the following PROC NLMIXED program to fit the same model. Please note that the LSMEANS statement in PROC MIXED above was computed at mean value for TIME, which would be displayed in the E option output. For illustration purpose, I used 5 as the mean value for time for my sample code below. You would need to replace that with whatever mean value was used in PROC MIXED.

proc nlmixed;
  parms b0=2 b1=1.2 b2=0.5 b3=1.2 sb=2 se=1; ** you might want to specify more reasonable starting values;
  mu = b0 + b1*time + b2*(treatment="A") + b3*time*(treatment="A") + u;
  model outcome ~ normal(mu, se);
  random u ~ normal(0, sb) subject=ID;
  estimate 'percent difference in the A and P at the mean time of 5' 100*(b2+b3*5)/(b0+b1*5);
  run;

Please let me know if this does not work out.

Jill

 

Naviava1973
Fluorite | Level 6
Dear Jill,
Thank you very much.
This has worked out perfectly and I can now see the outcome I was looking for though I noticed wide 95% CIs.
Once more, I really appreciate the support from you and the SAS users group.
Regards

KO
Rhea1234
Fluorite | Level 6

@jiltao How do we compare changes in a metric for two groups across two points T0 and T+2 in time using a similar approach ? Can you please help me arrive at the % change in the metric for the two groups ? I am using proc glm with a response variable as the value of the metric at  T+2.

SteveDenham
Jade | Level 19

Here is how I would approach this.  There are two levels of group (say A and B) and two levels of time (t0 and t+2). I would use PROC MIXED as you have correlated responses. Follow this up with a post-analysis processing to get the percent change.  Something like this:

 

proc mixed data=have;
class group time subject; /* subject is a member of one of the levels of group */
model response = group time group*time;
repeated time/type=un subject=subject;
lsmestimate group*time 'Baseline Group A' 1 0 0 0;
lsmestimate group*time 'Baseline Group B' 0 0 1 0;
lsmestimate group*time 'Difference over time for Group A' 1 -1 0 0;
lsmestimate group*time 'Difference over time for Group B' 0 0 1 -1;
lsmestimate group*time 'Difference between groups over time (B - A)' -1 1 1 -1; ods output lsmestimates=lsmestimates; run;

Then you can calculate the percent change in each group by dividing the difference over time by the baseline for that group.  The p value from the last lsmestimate would apply to the difference in group changes. No place along here would there be an analysis of percent change.

 

I strongly recommend against analyzing the percent changes as a response variable.  See Harrell's Applied Regression Strategies or the website run by the Vanderbilt University biostats department https://discourse.datamethods.org/t/author-checklist/3407 .  In particular, see this webpage:  http://hbiostat.org/bbr/md/change.html#sec:changegen  for the many caveats on analyzing change scores.

 

SteveDenham

SteveDenham
Jade | Level 19
proc glm data=have;
class group covA covB; 
model response = covA covB covC baseline group  group*baseline;
lsmeans group/pdiff;
run;

@Rhea1234, this code should help you accommodate the things brought up in your private message.  At this point, I would recommend responding here rather than be a private message - there are other folks who can help.

 

The code above will give the difference between groups, averaged over the categorical effects covA and covB,, and estimated at the mean values of the continuous effects covC and baseline.  The F test for group*baseline will tell you whether the adjustment is the same in both groups.  Now I'll recommend getting a good text on analysis of covariance to see how to proceed.  If you have access to SAS for Mixed Models, there is a great chapter that goes through this step by step, and how to get the comparisons needed if the adjustments for baseline are not equal.

 

SteveDenham

Rhea1234
Fluorite | Level 6

Thank you Steve. I will try to get a copy of the book. I ultimately need to arrive at the % change (response - baseline) for the two groups and assess the impact other covariates have on the response. Hope it makes sense?

SAS Innovate 2025: Save the Date

 SAS Innovate 2025 is scheduled for May 6-9 in Orlando, FL. Sign up to be first to learn about the agenda and registration!

Save the date!

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
  • 21 replies
  • 3745 views
  • 5 likes
  • 4 in conversation