BookmarkSubscribeRSS Feed
ehines
Fluorite | Level 6

Hello! I was presented with this model statement today, and am confused why you would nest an individual within a treatment?

example

 

data hotties;

input ID trt day time rtemp; 

datalines;

1 1 3 1 103.6

1 1 3 2 103.6

1 1 4 1 104.2

1 1 4 2 104.6

 

2 2 3 1 102.1

2 2 3 2 102.6

2 2 4 1 102.2

2 2 4 2 103.6

3 1 3 1 103.1

3 1 3 2 103.5

3 1 4 1 102.9

3 1 4 2 103.2

etc. 

 

class ID trt day time;

model rtemp = trt|day|time/ ddfm=satterw;

repeat day/ sub = ID(trt);    <<<<<<<< the sub = ID(trt), this is the part I do not understand what it does or why you would use it in this senario. Any thoughts? The SAS description of sub is to create a block, which is great. But my interpretation of this is that individual is then blocked by treatment, which does not make a whole lot of sense to me. Why would you block by treatment? Or am I interpretting this incorrectly?

 

2 REPLIES 2
Ksharp
Super User

if your ID is unique ,then you can use 

repeat day/ sub = ID

 

But if not ,then you have to use 

repeat day/ sub = ID(trt)

or

repeat day/ sub = ID*trt

to make subject id(strata) is unique.

 

E.X.

id trt

1 1

2 1

1 2

2 2

for this kind of data you have to use sub=id(trt) .

sld
Rhodochrosite | Level 12 sld
Rhodochrosite | Level 12

The syntax

repeated day / subject=id(trt);

corresponds to an experimental design in which each subject (id) is randomly assigned to one level of trt, and multiple observations are made on each id at each level of day. As such, ids are nested within levels of trt: each id belongs to only one level of trt

 

id(trt) identifies a random effects factor that has one level for each unique combination of id and trt. It does not mean that trt is random; it's just a syntax shortcut.

 

Alternatively, you could assign each subject a unique id value and use

repeated day / subject=unique_id;

which is the point that @Ksharp is making.

 

Even with unique values for subjects, I still use the nested syntax because it does a better job of giving me the denominator df that I think are appropriate.

 

I note that you have time in the MODEL statement. I bet this is a repeated measures factor as well, probably multiple times within each day. If so, your model is wrong, along with your understanding of the MIXED syntax. But that's another topic.

 

I highly recommend 

https://www.sas.com/store/books/categories/usage-and-reference/sas-for-mixed-models-second-edition/p...

It will tell you most of what you need to know.

 

sas-innovate-2024.png

Don't miss out on SAS Innovate - Register now for the FREE Livestream!

Can't make it to Vegas? No problem! Watch our general sessions LIVE or on-demand starting April 17th. Hear from SAS execs, best-selling author Adam Grant, Hot Ones host Sean Evans, top tech journalist Kara Swisher, AI expert Cassie Kozyrkov, and the mind-blowing dance crew iLuminate! Plus, get access to over 20 breakout sessions.

 

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