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

Hello everyone, 

 

I need your urgent help. 

 

I have 16 plants treated with 16 different fertilizers and a control plant (untreated), for a total of 17 units. The pots were randomly arranged without replication. However, these plants were fertilized for 27 weeks. What would be the repeated measure code for this? I want to see the effects of these fertilizers on plant height for 27 weeks. This is the coding I came up with. Thanks for your valuable time. 

 

frt= fertilizers 

ph= plant height 

 

Proc glimmix Data =first;
class frt ph week;
model ph = fert week fert*week;
random week/subject=frt*rep type=ar(1) residual;
lsmeans fert*week / pdiff Adjust = Tukey lines slicediff= day;
output out=second predicted=pred residual=resid residual(noblup)=mresid student=studentresid student(noblup)=smresid;
Run;

 

 

 

 

 

 

1 ACCEPTED SOLUTION

Accepted Solutions
SteveDenham
Jade | Level 19

Because you have no replication of your fertilizer treatments, other than in time, this looks like a classic growth curve comparison. I think your code might have some redundant parts, so consider the following:

 

Proc glimmix Data =first;
class frt ph week;
model ph = fert week fert*week;
random week/subject=frt type=ar(1) residual; /* Removed rep as it is confounded with tertilizer */
lsmeans fert*week / Adjust = Tukey lines slicediff= week; /* changed the slicediff to reflect the terms in the lsmeans, deleted the pdiff as the slicediff handles all differences of interest */
output out=second predicted=pred residual=resid residual(noblup)=mresid student=studentresid student(noblup)=smresid;
run;

I hope this helps. I have been pretty busy with my real world work and haven't been able to answer here as soon as folks need.

 

SteveDenham

 

View solution in original post

9 REPLIES 9
SteveDenham
Jade | Level 19

Because you have no replication of your fertilizer treatments, other than in time, this looks like a classic growth curve comparison. I think your code might have some redundant parts, so consider the following:

 

Proc glimmix Data =first;
class frt ph week;
model ph = fert week fert*week;
random week/subject=frt type=ar(1) residual; /* Removed rep as it is confounded with tertilizer */
lsmeans fert*week / Adjust = Tukey lines slicediff= week; /* changed the slicediff to reflect the terms in the lsmeans, deleted the pdiff as the slicediff handles all differences of interest */
output out=second predicted=pred residual=resid residual(noblup)=mresid student=studentresid student(noblup)=smresid;
run;

I hope this helps. I have been pretty busy with my real world work and haven't been able to answer here as soon as folks need.

 

SteveDenham

 

Zynep93
Obsidian | Level 7
Thanks so much Steve. Highly appreciated.
Zynep93
Obsidian | Level 7
The code gave an error. Here is the log;

532 ;
533 run;
534 Proc glimmix Data =Waterford;
535 class frt ph week;
536 model ph = frt week frt*week;
537 random week/subject=frt type=ar(1) residual;
538 lsmeans frt*week / Adjust = Tukey lines slicediff= week;
539 output out=second predicted=pred residual=resid residual(noblup)=mresid student=studentresid student(noblup)=smresid;
540 run;

ERROR: Least-squares means are not available for the multinomial distribution.
NOTE: The SAS System stopped processing this step because of errors.
WARNING: The data set WORK.SECOND may be incomplete. When this step was stopped there were 0 observations and 0 variables.
NOTE: PROCEDURE GLIMMIX used (Total process time)

Does that mean the data is not normally distributed?
SteveDenham
Jade | Level 19

It doesn't mean that - what it does mean is that you have included it in the CLASS statement. If a dependent variable is given in the CLASS statement, GLIMMIX defaults to a multinomial.  So, remove "ph" from the CLASS statement.

 

SteveDenham

Zynep93
Obsidian | Level 7
log: NOTE: Some observations are not used in the analysis because of: missing response values (n=4), missing fixed effects (n=4).
WARNING: Mixed model has saturated mean and profiled variance. Fit does not proceed.

It the data being interpolated? It seems like I have high-variance data, and it's not a good fit... ?





SteveDenham
Jade | Level 19

This is what I feared when you described the experimental design. I would first try removing the main effects of frt and week from the MODEL statement leaving 

 

model ph =frt*week;

This one-way model would test whether any plant at any time point differed from any other plant at any time point. It should get away from the saturated mean/profiled variance.

 

If that does not work, consider analyzing the data with a generalized estimating equation approach (PROC GEE). Something like this may be possible:

 

Proc gee Data =first;
class frt  week;
model ph = week;
repeated subject=frt/type=ar(1) covb corrb;
run;

If this runs, we can work on getting marginal means and pairwise comparisons out later.  Additionally, look at Example 49.3 (SAS/STAT 15.2) Weighted GEE for Longitudinal Data That Have Missing Values.

 

SteveDenham

 

 

Zynep93
Obsidian | Level 7

Yes, the experimental design is not ideal, unfortunately.
When I run the proc gee, I do not see whether treatments differ from each other. I only see the week differences.

 

there are 27 weeks but somehow the data mixed up with plant height data ( pls see the ss below) 

 

log: 

1 OPTIONS NONOTES NOSTIMER NOSOURCE NOSYNTAXCHECK;
68
69 data Waterford;
70 infile datalines expandtabs truncover;
71 input frt$ ph Week;
72 datalines;
 
NOTE: Invalid data for ph in line 218 4-4.
RULE: ----+----1----+----2----+----3----+----4----+----5----+----6----+----7----+----8----+----9----+----0
218 FF H 71.12 9
frt=FF ph=. Week=71.12 _ERROR_=1 _N_=146
NOTE: Invalid data for ph in line 235 4-4.
235 FF H 76.20 10
frt=FF ph=. Week=76.2 _ERROR_=1 _N_=163
NOTE: Invalid data for ph in line 320 4-4.
320 FF H 142.24 15
frt=FF ph=. Week=142.24 _ERROR_=1 _N_=248
NOTE: Invalid data for ph in line 507 4-4.
507 FF H 193.04 26
frt=FF ph=. Week=193.04 _ERROR_=1 _N_=435
 
 
 
Screenshot 2024-10-10 at 11.58.41 AM.png
SteveDenham
Jade | Level 19

What does the "H" designate for the variable ph? Has the plant been harvested? If so, then it should be replaced with a period if it no longer exists, or perhaps with the last observation carried forward (LOCF method). Mixed modeling is robust to missing data when there is adequate replication. You will have to make a scientific decision as to how to proceed, based on what your research question is.

 

SteveDenham

Zynep93
Obsidian | Level 7

I've corrected that one in SAS. It is a letter from a treatment name with a space in between. I would like to have a pairwise comparison of treatments ( fertilizers) with letters. The hypothesis is that the fertilizers will increase the plant height. 

 

I tried adding; 

 

Proc gee Data =Waterford;
class frt week;
model ph=frt;
repeated subject=frt/type=ar(1) covb corrb;
lsmeans frt/ pdiff=all adjust=tukey LINES;
run;

 

Error: Only CLASS variables allowed in this effect.

Is it because we added cov, which is already LS means of covariances? 

 

 

Thanks Steve! 

 

 

 

SAS Innovate 2025: Register Now

Registration is now open for SAS Innovate 2025 , our biggest and most exciting global event of the year! Join us in Orlando, FL, May 6-9.
Sign up by Dec. 31 to get the 2024 rate of just $495.
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
  • 9 replies
  • 1538 views
  • 6 likes
  • 2 in conversation