If an answer is illustrated with R
code, it would be even more gratefully accepted.
Asked
Active
Viewed 2,777 times
2

whuber
- 281,159
- 54
- 637
- 1,101

AkiyamaYukari
- 39
- 1
- 5
-
What is the statistical question? – utobi Nov 29 '16 at 14:34
-
1@utobi the question is "how to calculate PRESS". In my opinion this is a perfectly valid question. – Tim Nov 29 '16 at 15:15
-
3@Tim as far as I understood the question is "how to calculate PRESS using R", which sounds like performing routine operations within a statistical computing platform, hence off-topic. – utobi Nov 29 '16 at 15:45
-
1@utobi In its current state, this question seems on-topic to me. I don't think the question is demanding only the R code but the details of computation. It is quite common for "how to compute" questions to express a language preference, but answerers are not obliged to respect it. That is, an answer without R code - using pseudo-code or Python or no code altogether - would still be a valid answer to the question as written. I think the line gets crossed when we see a question that asks how to *implement in R*. – Silverfish Nov 29 '16 at 19:45
-
@Tim Thanks for your great answer and I sorry about the way me asking this question.New to the neighbourhood, and still learning. – AkiyamaYukari Nov 30 '16 at 09:51
-
@AkiyamaYukari no problem. You can check http://stats.stackexchange.com/help/on-topic to learn what's on-topic on this site. There was some confusion because questions solely on how to use some software are off-topic, while question of statistical manner are on-topic. Btw, if you find my answer helpful you can mark it as "accepted" (the `v` button on the left of the answer) or upvote it (the upper arrow button) so it is clear that you received an answer and are satisfied with it, see http://stats.stackexchange.com/tour to learn more. – Tim Nov 30 '16 at 09:55
-
@Tim Much Thanks! I have accepted it but can ont upvote due to my low reputation. Sorry. – AkiyamaYukari Nov 30 '16 at 13:36
-
@AkiyamaYukari I know, this was just for your information. – Tim Nov 30 '16 at 13:40
1 Answers
6
For linear regression model, given the hat matrix
$$ H = X (X'X)^{-1} X' $$
and residuals $e_i$, PRESS can be calculated as (see also here):
$$ \mathrm{PRESS} = \sum_i \left( \frac{e_i}{1-h_{ii}}\right)^2$$
This can be easily translated to the simple function:
PRESS <- function(linear.model) {
pr <- residuals(linear.model)/(1 - lm.influence(linear.model)$hat)
sum(pr^2)
}
-
May I ask you to please take a look at https://stats.stackexchange.com/questions/476935/the-best-way-to-compute-the-press-statistic and at https://stats.stackexchange.com/questions/476913/what-assumptions-must-be-satisfied-to-use-r2-to-compute-the-f-statistic – BillB Jul 13 '20 at 23:04