PRESS Calculation After Linreg

If you are seeking RATS code for implementing a particular technique or replicating results from a paper, post your request here. Be sure to include complete citations for any papers or books.
Ken-Cogger
Posts: 13
Joined: Wed Feb 15, 2012 7:58 pm

PRESS Calculation After Linreg

Unread post by Ken-Cogger »

Is there a simple procedure for validating a linear regression with the predicted regression error sum of squares (PRESS) statistic other than writing code like
make x
# x1 x2
compute h =x*inv(tr(x)*x)*tr(x)
compute press =0.0
do i=1,N
compute press =press+(%resids(i)/(1-h(i,i)))^2
end do i
display press

The PRESS statistic is based on the leave-one-out validation approach and was published by
Allen, D. M. (1974), "The Relationship Between Variable Selection and Data Augmentation and a Method for Prediction," Technometrics, 16, 125–127

Thanks,
Ken Cogger.
TomDoan
Posts: 7814
Joined: Wed Nov 01, 2006 4:36 pm

Re: PRESS Calculation After Linreg

Unread post by TomDoan »

The diagonals of the H matrix can be produced using PRJ with the XVX option. So the calculation can be done with (using the data set from the ROBUST.RPF example):

Code: Select all

linreg logy
# constant logk logl
prj(xvx=px)
sstats %regstart() %regend() %resids^2/(1-px)>>press
(Do you mean to have the denominator squared in your formula?)
Ken-Cogger
Posts: 13
Joined: Wed Feb 15, 2012 7:58 pm

Re: PRESS Calculation After Linreg

Unread post by Ken-Cogger »

Thanks, Tom.
I was not aware of prj or sstats. They simplify my code a lot.
And, yes, the denominator should be squared in the calculation of PRESS.
Best wishes,
Ken.
Post Reply