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

Hi,

I have the following question. I've carried out a study in which 96 animals were involved. They were spread over four rounds, so in each round 24 animals were followed up. In each round, animals were spread over 4 treatments, so in each round I had 6 animals per treatment. Treatments in the four rounds were the same.

Each round lasted for two weeks and animals were observed on day 2, 4, 6, 8, 10  and 12.

I want to use proc glimmix to verify differences between the four treatments. However, I have repeated measures for each animals (6 different days) and I'm not sure how to include this.

At first I used the following procedure:

Proc glimmix data=dataset;

class animal treatment day;

model y = treatment day/dist=binary;

random animal;

lsmeans treatment/pdiff;

run;

However, in this way I'm not taking into account the repeated measures per animal. I feel like I need to change the random statement but I'm not sure how.

Do you have any suggestions?

1 ACCEPTED SOLUTION

Accepted Solutions
SteveDenham
Jade | Level 19

Sorry to be so late in replying but vacay got in the way.

When you say that time is nested, do you mean that the time points differ from one region_id to another?  Also, are the time points equally spaced?  Unless both of these hold, autoregressive structures as implemented in MIXED or GLIMMIX aren't appropriate.  Until we address that point, you might try the following untested code.  It assumes that immigration, GDP, density and trend are all continuous variables:

PROC GLIMMIX DATA=WORK.SAS NOLCPRINT;

CLASS REGION_ID timepoint;

MODEL RACIST_CRIME= IMMIGRATION GDP DENSITY TREND timepoint /SOLUTION DIST=POI LINK=LOG OFFSET=POPUL_LOG DDFM=BW;

RANDOM timepoint/SUB=REGION_ID TYPE =AR(1) RESIDUAL;

RUN;

Now if the timepoints are unequally spaced, and not truly the same across region_id, you may have to address this through the use of a spline.

Steve Denham

View solution in original post

6 REPLIES 6
SteveDenham
Jade | Level 19

You might try:

proc glimmix data=dataset method=laplace;

class animal treatment data;

model y=treatment day treatment*day/dist=binary;

random intercept/subject=animal;

random day/type=ar(1) subject=animal;

lsmeans treatment/diff ilink;

lsmeans treatment*day/slicediff=day ilink;

run;

This will give a conditional estimate of the effects.

The following will be somewhat biased, due to regression to the mean, but is a marginal approach:

proc glimmix data=dataset;

class animal treatment data;

model y=treatment day treatment*day/dist=binary;

random intercept/subject=animal;

random day/residual type=ar(1) subject=animal;

lsmeans treatment/diff ilink;

lsmeans treatment*day/slicediff=day ilink;

I would recommend Walter Stroup's text: Generalized Linear Mixed Models if you are going to work in SAS on this analysis.

Steve Denham

run;

spiatkowska
Calcite | Level 5

Dear Steve,

I do have a problem with AR(1) while using Glimmix procedure. I have seen that you are very familiar with that command, so I decided to contact you directly. Your help would be more than important and valuable for me at this point. My problem is related to the Glimmix warning: obtaining minimum variance quadratic unbiased estimated as starting values for the covariance parameters failed. I have seen that you have addressed this question in the past  with the following command:

random studyday /residual  type=&covtype subject= anml_nbr ;*group=grp_no;

%if "&covtype" = "AR(1)" OR "&covtype" = "ARH(1)" %then %do;

random intercept/subject=anml_nbr;

%end;

I have panel data with racially motivated crimes are my dependent variable. The data are structured as pooled cross-national time series, where time is nested . In other words, my dependent and independent variables were collected over time at the regional level. I have detected significant autocorrelation in my dependent variable. There is also an issue of heteroskedasticity.

Here is the command I use:

PROC GLIMMIX DATA=WORK.SAS NOLCPRINT;

CLASS REGION_ID;

MODEL=RACIST_CRIME IMMIGRATION GDP DENSITY TREND /SOLUTION DIST=POI LINK=LOG OFFSET=POPUL_LOG DDFM=BW;

RANDOM INTERCEPT/SUB=REGION_ID TYPE =AR(1) RESIDUAL;

RUN;

I was told to use REPEATED instead of RANDOM, but the former seems to be appropriate only for proc mixed. Here instead I should use RANDOM ... RESIDUAL.

I do not receive the  warning when I exclude RESIDUAL, but then I get 0 for the estimate for AR(1)  and missing value for its standard error. Thus, I do not think I control for autocorrletation in my data.

When I include RANDOM  RESIDUAL, I get the warning: obtaining minimum variance...I

have read that I should use AR(1) plus random effects.

I have read that I should use AR(1) plus random effects. Could you please tell me how to incorporate that? Or perhaps I should use different TYPE. I would be extremely thankful for any help.

Sincerely,

Sylwia

SteveDenham
Jade | Level 19

Sorry to be so late in replying but vacay got in the way.

When you say that time is nested, do you mean that the time points differ from one region_id to another?  Also, are the time points equally spaced?  Unless both of these hold, autoregressive structures as implemented in MIXED or GLIMMIX aren't appropriate.  Until we address that point, you might try the following untested code.  It assumes that immigration, GDP, density and trend are all continuous variables:

PROC GLIMMIX DATA=WORK.SAS NOLCPRINT;

CLASS REGION_ID timepoint;

MODEL RACIST_CRIME= IMMIGRATION GDP DENSITY TREND timepoint /SOLUTION DIST=POI LINK=LOG OFFSET=POPUL_LOG DDFM=BW;

RANDOM timepoint/SUB=REGION_ID TYPE =AR(1) RESIDUAL;

RUN;

Now if the timepoints are unequally spaced, and not truly the same across region_id, you may have to address this through the use of a spline.

Steve Denham

rivina
Calcite | Level 5

I have been reading quit a bit on the topic but I'm still somewhat confused...

 

In my case I have an experiment with animals that was replicated 3 years.
Ten animals are used in each year for each of two treatments;  at the end of the year  they are replaced with new but similar animals.

The variable of interest is the animal's weight. Weights were recorded for animals in two Treatments, at irregularly spaced (Time) intervals (intervals vary between years, but not within years) . My main interest is the weights evolution over time, i.e. the regression of weight on time and treatment, but I also should lke to determine if Year had an effect.

 

My model then should be  (?)     Weight= Treatment  Time  Treatment*Time;

I suspect that the random statement should be something like:

 

random intercept AnimalNumber Time / subject Year;

 

I have read that the covariance structure in the random statement above should be specified by type=sp(pow) given the  irregular time intervals

 

covtest 'random slope coeff=0' ...0;

 

I would certainly appreciate feedback on the above.

 

Thanks

SteveDenham
Jade | Level 19

In the GLIMMIX documentation for SAS/STAT 14.1 there is an example where bodyweights of cows at unequally spaced time points is analyzed.  See:

 

http://support.sas.com/documentation/cdl/en/statug/68162/HTML/default/viewer.htm#statug_glimmix_exam...

 

This may help you get started.

 

Steve Denham

rivina
Calcite | Level 5
Thanks Steve. After posting my inquire I found the example, quite useful.

##- Please type your reply above this line. Simple formatting, no
attachments. -##

sas-innovate-2024.png

Join us for SAS Innovate April 16-19 at the Aria in Las Vegas. Bring the team and save big with our group pricing for a limited time only.

Pre-conference courses and tutorials are filling up fast and are always a sellout. Register today to reserve your seat.

 

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
  • 6 replies
  • 23099 views
  • 2 likes
  • 4 in conversation