Hello there, i want to model probabilitys for piglets being outside.
I am using SAS 9.4.
My dependent variable "haeufigkeitskategorie" has three values 0= no piglets outside 1= 1-50% of the piglets outside and 2= more than 50% outside. The variable "jahreszeit" means season an has four classes. So i run the code below, but i am not sure if my estimate statements are correct.
proc glimmix data=final_f;
class jahreszeit bucht;
model haeufigkeitskategorie = jahreszeit
/ dist=multi link = clogit oddsratio(diff=all) solution;
random intercept/ subject = bucht;
estimate "kat 0: frühling" intercept 1 0 0 jahreszeit 1 0 0 0/ ilink;
estimate "kat 0,1: frühling" intercept 0 1 0 jahreszeit 1 0 0 0/ ilink;
estimate "kat 0: herbst" intercept 1 0 0 jahreszeit 0 1 0 0/ ilink;
estimate "kat 0,1: herbst" intercept 0 1 0 jahreszeit 0 1 0 0/ ilink;
estimate "kat 0: sommer" intercept 1 0 0 jahreszeit 0 0 1 0/ ilink;
estimate "kat 0,1: sommer" intercept 0 1 0 jahreszeit 0 0 1 0 / ilink;
estimate "kat 0: winter" intercept 1 0 0 jahreszeit 0 0 0 1/ ilink;
estimate "kat 0,1: winter" intercept 0 1 0 jahreszeit 0 0 0 1/ ilink;
title 'glimmix haeufigkeitskategorie ferkel';
run;
The output seems logical:
My problem is that actually my model contains more class variables like daytime (day or night), age of the piglets (1-10days) and continious variables like rainfall (liter/m²) and temperature.
So if i try the code below (no more season but temperature, it is highly correlated) i don't get estimates for kat 0,1. And i really don't kow how to get estimates for temperature and rainfall.
Is there anyone who could help, please?
Best regards and thank you,
Julika
proc glimmix data=final_f;
class tageszeit alter_tag bucht;
model haeufigkeitskategorie = tageszeit alter_tag lufttemp niederschlag_stuendlich
/ dist=multi link = clogit oddsratio solution;
random intercept/ subject = bucht;
estimate "kat 0: nacht" intercept 1 0 tageszeit 1 0 / ilink;
estimate "kat 0,1: nacht" intercept 0 1 tageszeit 1 0/ ilink;
estimate "kat 0: tag" intercept 1 0 0 tageszeit 0 1 / ilink;
estimate "kat 0,1: tag" intercept 0 1 0 tageszeit 0 1 / ilink;
estimate "kat 0: alter_1" intercept 1 0 0 alter_tag 1 0 0 0 0 0 0 0 0 0;
estimate "kat 0,1 alter_1" intercept 0 1 0 alter_tag 1 0 0 0 0 0 0 0 0 0;
estimate "kat 0: alter_5" intercept 1 0 0 alter_tag 0 0 0 0 1 0 0 0 0 0;
estimate "kat 0,1 alter_5" intercept 0 1 0 alter_tag 0 0 0 0 1 0 0 0 0 0;
estimate "kat 0: alter_10" intercept 1 0 0 alter_tag 0 0 0 0 0 0 0 0 0 1;
estimate "kat 0,1 alter_10" intercept 0 1 0 alter_tag 0 0 0 0 0 0 0 0 0 1;
title 'glimmix haeufigkeitskategorie ferkel mit lufttemp';
run;
Okay. Well, it is always best to avoid using the ESTIMATE or CONTRAST statement whenever other statements that don't require specifying coefficients can do what you want. Most goals can be accomplished with the LSMEANS, SLICE, or LSMESTIMATE statement. So, I suggest you drop all of your ESTIMATE statements and add a STORE statement in your GLIMMIX step. Then use the LSMEANS statement in PROC PLM. For example:
proc glimmix data=final_f;
class tageszeit alter_tag bucht;
model haeufigkeitskategorie = tageszeit alter_tag lufttemp niederschlag_stuendlich
/ dist=multi link = clogit oddsratio solution;
random intercept/ subject = bucht;
store mod;
run;
proc plm restore=mod;
lsmeans tageszeit alter_tag / ilink cl;
run;
If "bucht" indicates a group of animals and, for each group, if you know the total number of animals as well as the number of those animals outside, then this can be modeled using a logistic model without the need for a RANDOM statement. For example:
proc logistic data=final_f;
class tageszeit alter_tag / param=glm;
model NumOut/NumInBucht = tageszeit alter_tag lufttemp niederschlag_stuendlich;
lsmeans tageszeit alter_tag / ilink;
run;
Hello Dave,
thank you for your reply!
I'm sorry, i wasn't clear enough. "bucht" means not group but stable, so it is really a random variable.
I know the exact number of animals in each group, but i wasn't able to count the ones outside every time, so often i just know if few (categorie 1) or many (categorie 2) animals outside.
So yes, it would be much easier if i could model NumOut/ NumInBucht but i would lose all observations where i don't know the exact number of animals outside. And that would be more often the observations with lots of piglets outside because it is easy to count 2 animals but not more than ten in a huddle.
Greetings,
Julika
Okay. Well, it is always best to avoid using the ESTIMATE or CONTRAST statement whenever other statements that don't require specifying coefficients can do what you want. Most goals can be accomplished with the LSMEANS, SLICE, or LSMESTIMATE statement. So, I suggest you drop all of your ESTIMATE statements and add a STORE statement in your GLIMMIX step. Then use the LSMEANS statement in PROC PLM. For example:
proc glimmix data=final_f;
class tageszeit alter_tag bucht;
model haeufigkeitskategorie = tageszeit alter_tag lufttemp niederschlag_stuendlich
/ dist=multi link = clogit oddsratio solution;
random intercept/ subject = bucht;
store mod;
run;
proc plm restore=mod;
lsmeans tageszeit alter_tag / ilink cl;
run;
SAS Innovate 2025 is scheduled for May 6-9 in Orlando, FL. Sign up to be first to learn about the agenda and registration!
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.