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

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

Your help would be appreciated,

Thank you,

Marcio

1 ACCEPTED SOLUTION

Accepted Solutions
marcioadg
Calcite | Level 5

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;

View solution in original post

11 REPLIES 11
SteveDenham
Jade | Level 19

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

marcioadg
Calcite | Level 5

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;

SteveDenham
Jade | Level 19

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

Steve Denham

lvm
Rhodochrosite | Level 12 lvm
Rhodochrosite | Level 12

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.

marcioadg
Calcite | Level 5

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;

lvm
Rhodochrosite | Level 12 lvm
Rhodochrosite | Level 12

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).

SteveDenham
Jade | Level 19

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

marcioadg
Calcite | Level 5

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

SteveDenham
Jade | Level 19

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

marcioadg
Calcite | Level 5

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

SteveDenham
Jade | Level 19

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

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
  • 11 replies
  • 4553 views
  • 7 likes
  • 3 in conversation