Displaying 20 results from an estimated 20000 matches similar to: "R.squared in summary.lm with weights"
2016 Apr 07
0
R.squared in summary.lm with weights
Do you mean w <- z$residuals ?
Type names(z) to see the list of item in your model.
I ran your code on a lm and it work fine.
You don't need the brackets around mss <-
Michael Long
On 04/07/2016 02:21 PM, Murray Efford wrote:
> Following some old advice on this list, I have been reading the code for summary.lm to understand the computation of R-squared from a weighted
2016 Apr 08
2
R.squared in summary.lm with weights
On 08 Apr 2016, at 12:57 , Duncan Murdoch <murdoch.duncan at gmail.com> wrote:
> On 07/04/2016 5:21 PM, Murray Efford wrote:
>> Following some old advice on this list, I have been reading the code for summary.lm to understand the computation of R-squared from a weighted regression. Usually weights in lm are applied to squared residuals, but I see that the weighted mean of the
2016 Apr 08
0
R.squared in summary.lm with weights
On 07/04/2016 5:21 PM, Murray Efford wrote:
> Following some old advice on this list, I have been reading the code for summary.lm to understand the computation of R-squared from a weighted regression. Usually weights in lm are applied to squared residuals, but I see that the weighted mean of the observations is calculated as if the weights are on the original scale:
>
> [...]
> f
2016 Apr 09
2
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
2016 Apr 10
0
R.squared in summary.lm with weights
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
2016 Apr 10
2
R.squared in summary.lm with weights
> 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
2016 Apr 10
0
R.squared in summary.lm with weights
> 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
2016 Apr 08
0
R.squared in summary.lm with weights
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
2006 Aug 25
1
R.squared in Weighted Least Square using the Lm Function
Hello all,
I am using the function lm to do my weighted least
square regression.
model<-lm(Y~X1+X2, weight=w)
What I am confused is the r.squared.
It does not seem that the r.squared for the weighted
case is an ordinary 1-RSS/TSS.
What is that precisely?
Is the r.squared measure comparable to that obtained
by the ordinary least square?
<I also notice that
model$res is the unweighted
2011 Mar 30
1
wrong calculation of R-squared in summary.lm
Dear all,
I just stumbled upon the fact, that when I perform a regression on
multivariate responses, that are not centred, I get a ricilulously high
R-squared value. After reading the code of summary.lm, I found a bug in
the function summary.lm:
mss is calculated by:
mss <-sum((f - mean(f))^2) - where f are the fitted values.
This works only for a single response variable, because
2005 Dec 07
1
summary[["r.squared"]] gives strange results
I am simulating an ANOVA model and get a strange behavior from the
summary function. To be more specific: please run the following code
and see for yourself: the summary()[["r.squared"]] values of two
identical models are quite different!!
## 3 x 3 ANOVA of two factors x and z on outcome y
s.size <- 300 # the sample size
p.z <- c(0.25, 0.5, 0.25) # the probabilities of factor z
##
2009 Sep 26
1
Compatibility of external C code across platforms
A package I have written makes considerable use of external C code. There appear to be no problems building a Windows binary with the GNU C compiler, but now I would like to make the package available for other platforms. A stringent check of the code with the gcc options '-Wall -pedantic' flags many nested functions and variable-length arrays that are not allowed in ISO C. Is it
2013 Jan 28
2
Adjusted R-squared formula in lm()
What is the exact formula used in R lm() for the Adjusted R-squared? How can I interpret it?
There seem to exist several formula's to calculate Adjusted R-squared.
Wherry’s formula [1-(1-R2)·(n-1)/(n-v)]
McNemar’s formula [1-(1-R2)·(n-1)/(n-v-1)]
Lord’s formula [1-(1-R2)(n+v-1)/(n-v-1)]
Stein 1-(n-1/n-k-1)(n-2)/n-k-2) (n+1/n)
Theil's formula (found here:
2001 Sep 18
2
Error mean square
If rb.lm is an lm-object, I can access the error mean square as
s2 <- sum(rb.lm$residuals^2)/rb.lm$df.residual
This seems a bit like hard work for such a commonly wanted quantity. Is
there a better way to do this?
Murray Jorgensen
Dr Murray Jorgensen http://www.stats.waikato.ac.nz/Staff/maj.html
Department of Statistics, University of Waikato, Hamilton, New Zealand
Email: maj at
2005 Jun 28
1
Possible bug in summary of residuals with lm and weights
I sent this to r-devel the other day but didn't get any takers. This
may not be a bug but rather an inconsistency.
I'm not sure if this is intentional. summary.lm stores weighted
residuals whereas I think most users will want print.summary.lm to
summarize unweighted ones as if saying summary(resid(fit)).
> set.seed(1)
> dat <- data.frame(y = rnorm(15), x = rnorm(15), w = 1:15)
2010 Jan 22
4
Extract R-squared from summary of lm
Dear all,
I cannot find to explicitly get the R-squared or adjusted R-squared from
summary(lm())
Thanks a lot!
[[alternative HTML version deleted]]
2006 May 20
1
(PR#8877) predict.lm does not have a weights argument for newdata
Dear R developers,
I am a little disappointed that my bug report only made it to the
wishlist, with the argument:
Well, it does not say it has.
Only relevant to prediction intervals.
predict.lm does calculate prediction intervals for linear models from
weighted regression, so they should be correct, right?
As far as I can see they are bound to be wrong in almost all cases, if
no weights
2010 Apr 28
1
Rd2dvi pagination of index in pdf manual
I construct a pdf package manual in Windows 7 using
R CMD Rd2dvi --pdf --no-preview [packagename]
Page numbers are listed correctly under 'R topics documented' at the front, but incorrectly (offset by -2 pages) in the Index at the back. Following the hyperlinked page numbers in the Index takes you to the wrong page. 2 pages happens to be the length of the package overview man page inserted
2005 Apr 18
1
R-squared in summary(lm...)
What is the difference between the two R-squareds returned for a linear
regression by summary(lm...)? When might one report multiple vs. adjusted
R-squared?
Thank you,
Ben Osborne
--
Botany Department
University of Vermont
109 Carrigan Drive
Burlington, VT 05405
benjamin.osborne at uvm.edu
phone: 802-656-0297
fax: 802-656-0440
2007 May 08
5
Weighted least squares
Dear all,
I'm struggling with weighted least squares, where something that I had
assumed to be true appears not to be the case. Take the following
data set as an example:
df <- data.frame(x = runif(100, 0, 100))
df$y <- df$x + 1 + rnorm(100, sd=15)
I had expected that:
summary(lm(y ~ x, data=df, weights=rep(2, 100)))
summary(lm(y ~ x, data=rbind(df,df)))
would be equivalent, but