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

Hey everybody!

I apologize in advance for my noob-ness.

 

I am having a very hard time trying to figure out how to write SAS code that will properly analyze a multilevel data structure which has both:

a dichotomous level 1 predictor

a dichotomous level 2 predictor

 

We had people track a moving target on the screen with the mouse. At random times we blasted them with 200ms of loud white noise. This dysregulated mouse control accuracy right after the noise. Each person did 60 trials of tracking.. half of which had a noise, half of which were silent. Before doing the tracking task, we had people learn about non-attachment to aversive experience (non-attach condition) or learn about trees (control condition). Random assignment by subject number.

 

So, for the MLM, I have trials (60) of the tracking task nested within individuals (115). The DV is mouse tracking error or "target miss" just after blasted by noise. 

The trial-level (level 1) variables are:

sound (noise vs. silent, coded as 1,0, or even left as words. that seems to work too)

PC_Baseline_miss (tracking right before sound event or silent/nothing "event", person centered)

 

Person-level 2 variables:

experiment condition (1,0, or words)

 

Does anybody know what I'm talking about and how to adjust SAS code for this? Here is the code I am using now....

It doesn't work and I don't know why....

A primary question really is why is there are two “random” lines in the code I was given 🙂 I think they correspond to each level of analysis, but not sure about this.


PROC MIXED COVTEST NOCLPRINT IC NAMELEN=100 METHOD=ML;
CLASS subject trail sound condition;
MODEL Avds_recover = PCAVDS_base sound condition sound*condition / SOLUTION DDFM=Satterthwaite;
RANDOM INTERCEPT pcAVDS_base sound / SUBJECT=trial Group= sound TYPE=UN;
RANDOM INTERCEPT pcAVDS_base sound / SUBJECT=subject TYPE=UN GROUP=condition;
REPEATED / SUBJECT=subject TYPE=VC group = sound GROUP=condition ; run;

1 ACCEPTED SOLUTION

Accepted Solutions
sld
Rhodochrosite | Level 12 sld
Rhodochrosite | Level 12

The statistical model for this experiment is known, in some quarters, as a random coefficients model (essentially, regression in a mixed model).

 

The current model assumes that the relationship between Avds_recover and PCAVDS_base is linear, and that the slope is the same regardless of sound or condition (because the model does not include interactions of sound and/or condition with PCAVDS_base). Are these assumptions valid?

 

IF I understand your study design correctly, then I would consider

proc mixed;
  class subject sound condition;
  model Avds_recover = PCAVDS_base | sound | condition;
  random subject(condition);
  random intercept PCAVDS_base / subject=sound*subject(condition);
  lsmeans sound | condition;
  run;

Generally, REML is preferable to ML. Assumptions include normality, homogeneity of variance, and linearity. Also that order of sound presentation doesn't matter--that a subsequent trial is not affected by previous trials. You don't say how sound level was assigned to trials.

 

Trial would never be a SUBJECT in a RANDOM statement (if I'm interpreting trial correctly). Sound probably should not be in a RANDOM statement with TYPE=UN; it would be better dealt with in a separate RANDOM statement as appropriate.

 

There are a variety of ways to specify the random structure for the model. Differences in the specification of SUBJECT= and optionally GROUP= produce different covariance structures. Theoretically, one will fit the data best. You definitely want to know what you're doing with different specifications. It's complicated (no surprise there).

 

Personally, I don't see the need for a REPEATED statement in a model like this, but some people include one to deal with the temporal autocorrelation among trials. If you include REPEATED, I doubt you can have two "group=" (although I've never tried), and you would need to either have the data set sorted appropriately by trial (which is the repeated measure) or, better yet, include trial (as REPEATED trial / ...).

 

I'll make my usual recommendation: read

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

This is a challenging model and you really don't want to go about it blindly.

 

 If you haven't already done so, plot your data.

 

 

View solution in original post

1 REPLY 1
sld
Rhodochrosite | Level 12 sld
Rhodochrosite | Level 12

The statistical model for this experiment is known, in some quarters, as a random coefficients model (essentially, regression in a mixed model).

 

The current model assumes that the relationship between Avds_recover and PCAVDS_base is linear, and that the slope is the same regardless of sound or condition (because the model does not include interactions of sound and/or condition with PCAVDS_base). Are these assumptions valid?

 

IF I understand your study design correctly, then I would consider

proc mixed;
  class subject sound condition;
  model Avds_recover = PCAVDS_base | sound | condition;
  random subject(condition);
  random intercept PCAVDS_base / subject=sound*subject(condition);
  lsmeans sound | condition;
  run;

Generally, REML is preferable to ML. Assumptions include normality, homogeneity of variance, and linearity. Also that order of sound presentation doesn't matter--that a subsequent trial is not affected by previous trials. You don't say how sound level was assigned to trials.

 

Trial would never be a SUBJECT in a RANDOM statement (if I'm interpreting trial correctly). Sound probably should not be in a RANDOM statement with TYPE=UN; it would be better dealt with in a separate RANDOM statement as appropriate.

 

There are a variety of ways to specify the random structure for the model. Differences in the specification of SUBJECT= and optionally GROUP= produce different covariance structures. Theoretically, one will fit the data best. You definitely want to know what you're doing with different specifications. It's complicated (no surprise there).

 

Personally, I don't see the need for a REPEATED statement in a model like this, but some people include one to deal with the temporal autocorrelation among trials. If you include REPEATED, I doubt you can have two "group=" (although I've never tried), and you would need to either have the data set sorted appropriately by trial (which is the repeated measure) or, better yet, include trial (as REPEATED trial / ...).

 

I'll make my usual recommendation: read

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

This is a challenging model and you really don't want to go about it blindly.

 

 If you haven't already done so, plot your data.

 

 

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
  • 1 reply
  • 1163 views
  • 0 likes
  • 2 in conversation