BookmarkSubscribeRSS Feed
laurenengelking
Calcite | Level 5

Hi all, 

 

I keep getting the following error messages when I run my code:

"R-side random effects are not supported for the multinomial distribution." and

"Least square means are not supported for the multinomial distribution"

 

My data set has milk yield from from 32 cows over 21 days (DIM = days in milk i.e. the number of days they have been lactating). Treatment is if cows were given hay or no hay. Cows were blocked by parity and expected calving date. My code is:

 

PROC GLIMMIX DATA = haytrial;

CLASS treatment DIM treatment block;

MODEL milkyield=treatment*DIM/DDFM=kr2;

RANDOM block;

RANDOM intercept/ SUBJECT=cow(block);

RANDOM DIM/RESIDUAL SUBJECT=cow(block) TYPE=ar(1);

LSMEANS treatment*DIM;

RUN;

 

I am completely new to SAS so any help is much appreciated!

2 REPLIES 2
jiltao
SAS Super FREQ

I am curious - I do not see anywhere in your code that you are fitting a multinomial model. Can you send us the complete log?

SteveDenham
Jade | Level 19

Following up on @jiltao 's comment - the code you present looks quite good for analyzing milk yield, but you may want to consider the following:

 

Parity is likely a fixed effect in this case, as the lactation curve is known to be different for heifers as compared to cows. Consider dichotomizing to two parity groups based on lactation number (primiparous = 1, multiparous  >1) .  Also, your code treats 'cow' as a subject, but is not included in the CLASS statement, so be sure that this variable is numeric and that the data are sorted by 'cow' and 'DIM'. Thus, you may wish to consider the following:

 

PROC GLIMMIX DATA = haytrial;
CLASS treatment DIM block parity;
MODEL milkyield=treatment*DIM*parity/DDFM=kr2;
RANDOM block;
RANDOM intercept/ SUBJECT=cow(block) group=parity;
RANDOM DIM/RESIDUAL SUBJECT=cow(block) TYPE=ar(1) group=parity;
LSMEANS parity*treatment*DIM;

RUN;

This enables you to fit different curves for the primiparous and multiparous animals, with different intercepts by parity and correlations in time by parity.

I don't see a reason to expect the use of a multinomial distribution unless you change to a different response variable, which would be categorical.

 

SteveDenham

 

 

 

 

 

hackathon24-white-horiz.png

The 2025 SAS Hackathon has begun!

It's finally time to hack! Remember to visit the SAS Hacker's Hub regularly for news and updates.

Latest Updates

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
  • 2 replies
  • 1077 views
  • 0 likes
  • 3 in conversation