[R] R.squared in summary.lm with weights

David Winsemius dwinsemius at comcast.net
Sun Apr 10 19:31:05 CEST 2016


> On Apr 10, 2016, at 9:38 AM, David Winsemius <dwinsemius at comcast.net> wrote:
> 
>> 
>> On Apr 10, 2016, at 3:11 AM, Murray Efford <murray.efford at otago.ac.nz> wrote:
>> 
>> Martin -
>> Thanks, but although hatvalues() is useful for calculating PRESS, I can't find anything directly relevant to my question in the influence help pages. After some burrowing in the literature I'm doubting there is an answer out there (PRESS R^2 is always presented in a fairly ad hoc way).
>> This is a new topic, as you say, and perhaps better handled on a statistics list.
>> Murray Efford
>> 
>> [BTW
>> stats ::: influence.lm
>> just gets me
>> function (model, do.coef = TRUE, ...) 
>> lm.influence(model, do.coef = do.coef, ...)
>> <bytecode: 0x00000000081023b8>
>> <environment: namespace:stats>
>> which is not very helpful]
> 
> influence.lm is just saying you should be looking at lm.influence
> 
> #Try typing:
> lm.influence    
> 
> Admittedly the meat of that function is probably encapsulated in C with the results delivered by:
> 
>      res <- .Call(C_influence, mqr, do.coef, e, tol)
> 
> Perhaps looking at:
> 
> https://svn.r-project.org/R/trunk/src/library/stats/src/influence.c
> 
> 
> I haven't been following the rest of the thread so this is just commenting on your difficulties reading R code.

When I do attempt filling in blanks in my knowledge regarding PRESS, I am reminded by MarkMail that this question came up 5-6 years ago and I went looking for an answer:

http://markmail.org/search/?q=list%3Aorg.r-project.r-help+PRESS#query:list%3Aorg.r-project.r-help%20PRESS+page:1+mid:k2mbz5sov5eo5ejw+state:results

I also see that other packages have implemented PRESS at least as reported by others:

Subject: [R] I need help computing PRESS statistics (qpcR package) of...:
From:	Francisco Goes (xico... at hotmail.com)
Date:	Jun 4, 2014 4:05:03 pm

I tried a current search, although I admit that the fact that "press" is an acronym shared by other topics does seem to complicate that process. I counted 9 packages with PRESS functions even after excluding the ones related to "the Press" and "protein residues" when I did a search with:

sos::findFn("PRESS")

-- 
David.



> 
> -- 
> 
> David.
> 
> 
>> 
>> ________________________________________
>> From: Martin Maechler <maechler at stat.math.ethz.ch>
>> Sent: Sunday, 10 April 2016 4:07 a.m.
>> To: Murray Efford
>> Cc: peter dalgaard; Duncan Murdoch; r-help at r-project.org
>> Subject: Re: [R] R.squared in summary.lm with weights
>> 
>>>>>>> Murray Efford <murray.efford at otago.ac.nz>
>>>>>>>   on Fri, 8 Apr 2016 18:45:33 +0000 writes:
>> 
>>> Thanks for these perfectly consistent replies - I didn't
>>> understand the purpose of m = sum(w * f/sum(w)) and saw it
>>> merely as a weighted average of the fitted values.  My
>>> ultimate concern is how to compute an appropriate weighted
>>> TSS (or equivalently, MSS) for PRESS-R^2 = 1 - PRESS/TSS =
>>> 1 - PRESS/ (MSS + PRESS). Do you think it then makes sense
>>> to substitute the vector of leave-one-out fitted values
>>> for f here?
>> 
>> --> A new topic really.
>> 
>> I think you should find the answer on the help pages (and in the
>> source) of
>> 
>>    ? influence.measures  (which documents a host of such functions)
>>   and
>>    ? influence
>> 
>> Note that influence is S3 generic and
>> 
>>  methods(influence)
>> 
>> indicates that the 'lm' and 'glm' methods are hidden.
>> Of course I do recommend reading the real R source code (which
>>  also contains the comments and has some logical order in all the
>>  function definitions),
>> but you can use   stats ::: influence.lm
>> to show a version of the function that looks not too different
>> from the source.
>> 
>> Martin Maechler, ETH Zurich
>> 
>> 
>> ______________________________________________
>> R-help at r-project.org mailing list -- To UNSUBSCRIBE and more, see
>> https://stat.ethz.ch/mailman/listinfo/r-help
>> PLEASE do read the posting guide http://www.R-project.org/posting-guide.html
>> and provide commented, minimal, self-contained, reproducible code.
> 
> David Winsemius
> Alameda, CA, USA
> 
> ______________________________________________
> R-help at r-project.org mailing list -- To UNSUBSCRIBE and more, see
> https://stat.ethz.ch/mailman/listinfo/r-help
> PLEASE do read the posting guide http://www.R-project.org/posting-guide.html
> and provide commented, minimal, self-contained, reproducible code.

David Winsemius
Alameda, CA, USA



More information about the R-help mailing list