Displaying 20 results from an estimated 20000 matches similar to: "R.squared in Weighted Least Square using the Lm Function"
2016 Apr 07
4
R.squared in summary.lm with weights
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 <- z$fitted.values
w <- z$weights
[...]
m
2008 Jun 25
1
weighted inverse chi-square method for combining p-values
Hi,
This is more of a general question than a pure R one, but I hope that is OK.
I want to combine one-tailed independent p-values using the weighted version
of fisher's inverse chi-square method. The unweighted version is pretty
straightforward to implement. If x is a vector with p-values, then I guess
that this will do for the unweighted version:
statistic <- -2*sum(log(x))
comb.p <-
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
2006 Mar 01
1
Drop1 and weights
Hi,
If I used drop1 in a weighted lm fit, it seems to ignore the weights
in the AIC calculation of the dropped terms, see the example below.
Can this be right?
Yan
--------------------
library(car)
> unweighted.model <- lm(trSex ~ (river+length +depth)^2-
length:depth, dno2)
> Anova(unweighted.model)
Anova Table (Type II tests)
Response: trSex
Sum Sq Df F value
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 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
2012 Sep 19
0
Discrepancies in weighted nonlinear least squares
Dear all,
I encounter some discrepancies when comparing the deviance of a weighted and
unweigthed model with the AIC values.
A general example (from 'nls'):
DNase1 <- subset(DNase, Run == 1)
fm1DNase1 <- nls(density ~ SSlogis(log(conc), Asym, xmid, scal), DNase1)
This is the unweighted fit, in the code of 'nls' one can see that 'nls'
generates a vector
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
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:
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
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
##
2000 Sep 17
1
Weighted Histogram
Greetings,
I'm having trouble finding a simple way to calculate a weighted
histogram where there may be zero raw counts in a given interval.
Given equal-length vectors of data 'data' and weights 'w', and breaks
(intervals) for the histogram, I calculate a weighted histogram as
follows (see MASS's 'truehist' for an unweighted histogram):
bin <- cut(data,
2007 Dec 11
1
postResample R² and lm() R²
Hello,
I'm with a conceptual doubt regarding Rsquared of both lm() and
postResample(library caret).
I've got a multiple regression linear model (lets say mlr) with anR² value
of 67.52%.
Then I use this model pro make predictions with predict() function using the
same data as input , that is, use the generated model to predict the value
associated with data that I used as input.
Next, if
2011 Feb 23
1
Weighted Mean By Factor Using "BY"
Hello R folks,
Reproducible code below - I'm trying to do a weighted mean by a factor and
can't figure it out. Thanks in advance for your assistance.
Mike
data<-data.frame(c(5,5,1,1,1),
c(10,8,9,5,3),
c("A","A","A","B","B"))
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)
2006 Mar 01
2
Weighted networks and multigraphs
I would like to apply network measures (such as betweenness centrality,
upper boundedness, etc.) to a weighted graph with non-integer weights,
defined by a euclidean distance matrix. The package sna provides the
measures that I want to use, but seems only to operate on binary graphs.
I have read work by Mark Newman
(http://aps.arxiv.org/abs/cond-mat/0407503/), who suggests that a
weighted graph