Solved
Contributor
Posts: 45

# How to output or calculate Studentized Residuals in Proc NLMIXED?

I am struggling to output or calculate Studentized Residuals in Proc NLMIXED.

Thank you,

Marcio

Accepted Solutions
Solution
‎07-03-2014 03:03 PM
Contributor
Posts: 45

## Re: How to output or calculate Studentized Residuals in Proc NLMIXED?

Thank you Steve, I ended up get this working and here is how.

As always thanks for your input,

Marcio

predict L + U*(z1) out=ppp;

run;

data ppp; set ppp;

resid=y-pred;

resid_t=resid;  run;

proc standard data=ppp std =1 out =pred_std;

var resid_t;

run;

title;

proc print data=ppp; run;

proc print data=pred_std;

run;

symbol1 value=dot color=blue i=none;

proc gplot data=pred_std;

plot resid_t*x resid_t*pred/vref=(0);

run;

All Replies
Posts: 2,655

## Re: How to output or calculate Studentized Residuals in Proc NLMIXED?

I don't know, and the person who I think does is seldom found around here anymore.  However, take a look at Dale McLerran's post:

https://communities.sas.com/message/55521#55521

where he calculates individual deviances for a Poisson.  I believe you could take the square root of the individual deviance and use it as a denominator in calculating the studentized residual.  to me, the key statement is the PREDICT statement with the OUT= option.

Steve Denham

Solution
‎07-03-2014 03:03 PM
Contributor
Posts: 45

## Re: How to output or calculate Studentized Residuals in Proc NLMIXED?

Thank you Steve, I ended up get this working and here is how.

As always thanks for your input,

Marcio

predict L + U*(z1) out=ppp;

run;

data ppp; set ppp;

resid=y-pred;

resid_t=resid;  run;

proc standard data=ppp std =1 out =pred_std;

var resid_t;

run;

title;

proc print data=ppp; run;

proc print data=pred_std;

run;

symbol1 value=dot color=blue i=none;

proc gplot data=pred_std;

plot resid_t*x resid_t*pred/vref=(0);

run;

Posts: 2,655

## Re: How to output or calculate Studentized Residuals in Proc NLMIXED?

You should give yourself a "Correct answer".  The use of STANDARD is something I overlook way too often.

Steve Denham

Valued Guide
Posts: 684

## Re: How to output or calculate Studentized Residuals in Proc NLMIXED?

proc standard would not be giving you the standardized or studentized residual. You need to obtain the estimated standard error for EACH residual, which is not directly given by NLMIXED.The standard procedure is just scaling by the the variation in the raw residuals (not the same thing). I think getting standardized residuals from NLMIXED will require some coding (post-model-fitting) which would depend on the chosen conditional distribution. It would require the "hat" matrix.

Contributor
Posts: 45

## Re: How to output or calculate Studentized Residuals in Proc NLMIXED?

lvm, thanks. This is what I have used.

data ppp; set ppp;

resid=y-pred;

resid_t=resid;  run;

proc standard data=ppp std =1 out =pred_std;

var resid_t;

run;

Valued Guide
Posts: 684

## Re: How to output or calculate Studentized Residuals in Proc NLMIXED?

proc standard will not give you a standardized or studentized residual. Each residual has a unique variance, var(r_i), and you cannot recover this from proc standard (even though I saw a website that says that you can).

Posts: 2,655

## Re: How to output or calculate Studentized Residuals in Proc NLMIXED?

I think I saw the same thing, hence my excitementat using PROC STANDARD.  I think an IML solution may be the only way out now.

Steve Denham

Contributor
Posts: 45

## Re: How to output or calculate Studentized Residuals in Proc NLMIXED?

Hi Steve, do you have any directions on how I could get that?

Posts: 2,655

## Re: How to output or calculate Studentized Residuals in Proc NLMIXED?

Search 's blog: The DO Loop.  You are going to need the entire X'VX matrix from NLMIXED, and the Y vector, to calculate the residual, and the variance for that residual.  The last step is the only easy one for me--residual/sqrt(var(r_i)).  I need to learn how to do more things "long hand".

Steve Denham

Contributor
Posts: 45

## Re: How to output or calculate Studentized Residuals in Proc NLMIXED?

Hi Steve, thanks!!! I was not able to find nothing related to NLMIXED or 'studentized' in his blog, any idea what I should look at?

Thanks,

Marcio

Posts: 2,655

## Re: How to output or calculate Studentized Residuals in Proc NLMIXED?

It wouldn't be specific, but more as background on how to use IML to calculate what you need from the various matrixes, following 's note regarding the individual variances of the residual.

Now it seems to me that a residual is a sum of two non-independent random variables, and the estimate and the Y value are correlated, so the key is getting the covariance between the two to estimate the variance of the residual.  Surely someplace on the web has a matrix representation.  Then it is just a matter of of following the right examples in the documentation and Rick's blog.

Steve Denham

🔒 This topic is solved and locked.