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

David Winsemius dwinsemius at comcast.net
Sun Apr 10 18:38:34 CEST 2016


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

-- 

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



More information about the R-help mailing list