Programming the statistical procedures from SAS

how to approach this glimmix?counts

New Contributor
Posts: 4

how to approach this glimmix?counts

Hello all,

I am busy on a study to compare different types of sowing type for field margins to attract bumble bees.

I have three blocks, and within those blocks there are the four different treatements (fixed effects). There are 4 different moments in which i counted the bees,

I would like to know if the sowing types have a significant effect on the counts of the bees and wether they differ pairwise from each other

This presents me with a lot of problem solving to do in stating my model, i cannot find any examples which are similar.

This is my data

data hommel;

input loc $ meng count;


a    g    29

b    g    43

c    g    10

a     i    24

b    i    66

c    i    23

a     k    83

b    k    73

c    k    60

a     t    45

b    t    75

c    t    48


I came up with the following code:

proc glimmix data=hommels;

class mengsel loc;

model count=mengsel/dist=poisson link=log solution;

random loc;

random _residual_;

lsmeans mengsel/cl ilink;,


i did a dist=poisson because it are counts, log link for the same reason

random component is the block of the location and then i try to correct for overdispersion because it looked the right way to do...

the cl ilink for giving me the real estimates, but this does not seem to work either..

I am not sure if this is the right way to go with this, so i do not want to jump in conclusions and not i am not even sure what the conclusions would be fro this, i do not get a t value for fixed factor t?

I would really like to know how i could solve this...also an output of this does not render me pairwise comparison as the output of a proc mixed can give



New Contributor
Posts: 4

Re: how to approach this glimmix?counts

These actually are the counts added up for the whole season...i figured that i cannot do any statistical analyses on a dataset like this, nor on the one where i split the dates as i should to take into account the random variation on the dates because my fixed factors are not fixed either... the different sowing types in the different block have different abundances in flowers, some flowers present and shared with one block, some not but very abundant in the one block  and this al in different combinations, also there is a random component of the different popolutions of bees at the different blocks.Different species composition with all different numbers of total bees... 

So i cannot perform any statistics on it, is it... i think the design should have been that i have more blocks, the field margins should not be adjecent and that the fixed factors should have been randomised...?

can somebody please confirm this?



Respected Advisor
Posts: 2,655

Re: how to approach this glimmix?counts

Well, I got an analysis, but given your second post, it may not be quite what you need.

First, there are some typos to clear up.  The dataset has a different name than what is called in the PROC GLIMMIX statement.  Also, the data step has the variable meng, while in GLIMMIX it is mengsel, and it probably needs to be identified as character.  To get the pairwise comparisons, I added the diff option to the LSMEANS statement.  My code follows:

data hommel;
input loc $ meng $ count;
a g 29
b g 43
c g 10
a i 24
b i 66
c i 23
a k 83
b k 73
c k 60
a t 45
b t 75
c t 48

proc glimmix data=hommel;
class meng loc;
model count=meng/dist=poisson link=log solution;
random loc;
random _residual_;
lsmeans meng/cl ilink diff;

As far as your concerns about things over time, you could look at a repeated measures analysis, and if you could come up with a suitable set of covariates for species of flowers and their abundance, that could also be introduced (although you would probably have a time varying covariate for this, as I suspect the abundance changes over time).  So, given that, it makes sense to me that the block effect, as you have presented it, is probably the best approach to addressing these issues.

The part that I worry about is that you say that the fixed effects were not randomized.  Within each block, all four sowing types are represented.  I assumed that the types were not systematically applied to come up with this analysis.  More information would be nice to see if all is OK.

Steve Denham

New Contributor
Posts: 4

Re: how to approach this glimmix?counts

Posted in reply to SteveDenham


thanks! i couldn't come up with what to do with it, it got rather frustrating out here

Now i could run this analysis on every sample date apart in the blocks then...? So i have an idea on each sampling date how things are...

the blocks are indeed not randomized, like you say, all four sowing types present in one block.

also within these blocks the sowing types are adjecent in a fixed order with for example a and d on the outsides...

the setup of the experiment was thought up by a predecessor, i do not like it, but do have to come up with an answer to the question which one is better



New Contributor
Posts: 4

Re: how to approach this glimmix?counts

the next question pops do i interpret this?

i have a type III test for my fixed effects...i guess that is pretty straightforward...that there is an  effect of the fixed factors...can i then state that all the fixed effects have an effect?

and the solution for fixed  the intercept the estimate (e^estimate) of the t type(dummy) and then the other estimates are e^(estimateT+the estimate of intrest)?  my p-values representing wether the fixed factors differ from t? i shouldn't really report on this? i have the pairwise comparisons in the lsmeansdiff output...

but then the lsmeans diff gives me the lsmeans compared to each other, they differ if the p-value is less then 0,05? can i derive from such an estimate how much they differ or can i just say they differ? it cannot be as simple as G-I ==> G differs e^(estimate)*I ,is it?



Ask a Question
Discussion stats
  • 4 replies
  • 2 in conversation