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

I'm running an experiment where I'm interested in climate, time of year, and parasitism levels on population densities of an insect.

I sample 3 climate types 26 times over the course of a year. Climate A has 5 sites, and Climates B and C each have 2 sites for 9 sites total.

 

My code looks like this:

 

proc glimmix data=final ;

class site climate interval;

model totalfin = interval climate previous_para / dist=poi link=log solution;

random interval / subject= site(climate) residual;

run;

 

Model suggests there is a highly significant effects of sample interval, parasitism, but not climate (p=0.11). Looking at the raw data it appears that climate effects exists, but they vary by season and this is washing out the effects. I want to compare climate effects within each season so I assign each interval to a season. I want to use contrasts rather than grouping 26 intervals into 4 groups to maintain my df. I can look at seasonal differences on densities via these contrasts, but I'm having trouble finding a way to code the contrasts so that I can look at site(climate) differences on densities within these seasons.

 

contrast "Spring vs. Summer" interval -1 -1 -1 -1 -1 0 0 0 0 0 0 0 0 0 0 0 0 0 1 1 1 1 1 1 -1 -1 ;

contrast "Spring vs. Fall" interval  0 0 0 0 0 -1 -1 -1 -1 -1 -1 0 0 0 0 0 0 0 1 1 1 1 1 1 0 0 ;

contrast "Spring vs. Winter" interval 0 0 0 0 0 0 0 0 0 0 0 -1 -1 -1 -1 -1 -1 1 1 1 1 1 1 0 0 ;

contrast "Summer vs. Fall" interval  1 1 1 1 1 -1 -1 -1 -1 -1 -1 0 0 0 0 0 0 0 0 0 0 0 0 0 1 1 ;

contrast "Summer vs. Winter" interval 1 1 1 1 1 0 0 0 0 0 0 0 -1 -1 -1 -1 -1 -1 -1 0 0 0 0 0 0 1 1;

contrast "Fall vs. Winter" interval 0 0 0 0 0 1 1 1 1 1 1 -1 -1 -1 -1 -1 -1 -1 0 0 0 0 0 0 0 0;

 

If it comes down to it I can just assign each interval to a categorical season, but I would like to avoid this if possible.

 

Thanks!

1 ACCEPTED SOLUTION

Accepted Solutions
PaigeMiller
Diamond | Level 26

The model should be

 

model totalfin = season interval(season) climate season*climate previous_para ... ;

 

Then you can compute lsmeans for season*climate

--
Paige Miller

View solution in original post

5 REPLIES 5
PaigeMiller
Diamond | Level 26

You might want to put season into your model, and have interval nested within season.

 

Then you can compute least squares means (LSMEANS) for site and season, instead of writing out all possible contrasts of site and season.

 

--
Paige Miller
PaigeMiller
Diamond | Level 26

Adding: It seems to me that creating contrasts are useful in the case where the coefficients in the contrast are irregular in the sense that you are not just comparing level X to level Y; for example if you want to test if summer is equal to the average of spring and fall, you'd need a contrast for that. If you're just comparing summer to fall, the LSMEANS ought to do that with minimal effort on your part.

--
Paige Miller
Nebulus
Calcite | Level 5

I agree with your point about the use of contrasts.

Regarding including season in the model,I can do that but all it does again is just compare differences in densities between intervals(season). I need to look at the lsmeans of climate within a specific season (e.g. coastal vs. inland within spring, summer, fall and winter).

 

proc glimmix data=final;

class site climate interval season;

model totalfin = interval(season) climate  previous_para / dist=poi link=log solution;

random interval(season) / subject= site(climate) residual;

lsmeans climate / cl pdiff plot=meanplot;

lsmeans interval(season) / cl pdiff plot=meanplot;

 

This model doesn't let me do interval(season)*climate in the model statement. I might have to just end up getting rid of interval after all and do lmeans of season*climate

PaigeMiller
Diamond | Level 26

The model should be

 

model totalfin = season interval(season) climate season*climate previous_para ... ;

 

Then you can compute lsmeans for season*climate

--
Paige Miller
Nebulus
Calcite | Level 5

Thank you!

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!

How to Concatenate Values

Learn how use the CAT functions in SAS to join values from multiple variables into a single value.

Find more tutorials on the SAS Users YouTube channel.

SAS Training: Just a Click Away

 Ready to level-up your skills? Choose your own adventure.

Browse our catalog!

Discussion stats
  • 5 replies
  • 1318 views
  • 0 likes
  • 2 in conversation