Help Calculating Skewness of Residuals in Proc Mixed!!

Occasional Contributor
Posts: 12

Help Calculating Skewness of Residuals in Proc Mixed!!

Hello everyone,

I am running a growth model with longitudinal person data and have been reading the following article:

http://www.statcan.gc.ca/pub/82-003-x/2011004/article/11598-eng.htm

I would like to calculate the skewness of both level 1 and level 2 for my model like they do in this article but currently using ods graphics and outp i only get one measure of skewness. I am working at the RDC so cannot input my exact syntax.

Can anyone help? It would be much appreciated.

Sincerely,

Naomi

PhD Candidate

University of Toronto

Views: 6

Posts: 5,057

Re: Help Calculating Skewness of Residuals in Proc Mixed!!

Unless I am missing something, it should be enough to add option OUTP=myL1Resid to your MODEL statement in PROC MIXED and then do:

proc univariate data=myL1Resid normal ;

var Resid;

run;

to get the skewness of residuals and a whole lot of other distribution measures.

Same thing for L2.

PG

PG
Occasional Contributor
Posts: 12

Re: Help Calculating Skewness of Residuals in Proc Mixed!!

Hi PG,

However, the article I am referencing provides different calculations of skewness at each level - which is what I would assume.

However, when I do as you say above I get identical output when I put L1 versus L2 - I assume I am just changing the name of the dataset, right? Am I supposed to put the OUTP statement somewhere different in the proc mixed statement to get the residual output for level2?

Thanks again,

Naomi

Posts: 5,057

Re: Help Calculating Skewness of Residuals in Proc Mixed!!

You're right, Level-2 will probably be a bit more complicated. It would help us a lot if you posted a (simplified or disguised if necessary) version of your SAS code.

PG
Occasional Contributor
Posts: 12

Re: Help Calculating Skewness of Residuals in Proc Mixed!!

OK sure, it's something like this:

proc mixed noclprint poitprint data = work.slid;

class personid;

model index = vismin vismin*t cborn cborn*t (etc.) / residual solution ddfm = btw notest cl;

random intercept t/sub=personid;

run;

Thanks!

Posts: 5,057

Re: Help Calculating Skewness of Residuals in Proc Mixed!!

I would try something like this (also hoping to get 's opinion on this):

...

random intercept t/sub=personid s;

ods output SolutionR=Level_2R;

...

proc univariate data=Level_2R(where=(lowcase(Effect)="t")) normal;

var Estimate;

run;

Not sure about the part in blue. Check the Level_2R dataset to select the proper rows.

PG

PG
Occasional Contributor
Posts: 12

Re: Help Calculating Skewness of Residuals in Proc Mixed!!

Thank you - this did work but I'm not exactly sure I understand what it's doing. what is "s"?

It is now calculating a new skewness measure which I can take to be the Level 2 measure?

Posts: 5,057

Re: Help Calculating Skewness of Residuals in Proc Mixed!!

Option s is for requesting the printing of random effect estimates (solutions). It is required to get the SolutionR output dataset.

What I understand in the referenced article is that Level-2 residuals are the estimated random effects associated with individuals, i.e. the variation between individuals. Level-1 residuals are the random variation of measurements within individuals.

I hope somebody better versed in MIXED modelling than I am will be able to help you further.

Good luck!

PG

PG
Posts: 2,655

Re: Help Calculating Skewness of Residuals in Proc Mixed!!

Hi everybody (for those of you who are Simpsons fans, that's Dr Nick's entering line),

Go with the answers that PG offered.  The OUTP= dataset will have the level 1 residuals, the ODS output statement for the solution of the random effects will give the level 2 residuals.  NOTE WELL: The level 2 residuals are meaningful only if you are working with a normal distribution in PROC MIXED.  If you were fitting a generalized linear mixed model using PROC GLIMMIX, the values are not really residuals in the traditional sense.  They are deviations, but unless an overdispersion effect is added, the model does not include residual error.

Steve Denham

Occasional Contributor
Posts: 12