Displaying 20 results from an estimated 12000 matches similar to: "loop issues (r.squared)"
2007 Feb 12
3
processing a large matrix
I would like to compare every column in my matrix with every other column and
get the r-squared.
I tried using the following formula and looping through every column:
> summary(lm(matrix[,x]~matrix[,y]))$r.squared
If I have 10,000 columns, the loops (10,000 * 10,000) take forever even if
there is no formula inside.
Then, I attempted to vectorize my code:
> cor(matrix)^2
With 10,000
2007 Feb 27
1
read.csv size limits
I have been using the read.csv function for a while now without any problems.
My files are usually 20-50 MBs and they take up to a minute to import. They
have all been under 50,000 rows and under 100 columns.
Recently, I tried importing a file of a similar size (which means about the
same amount of data), but with ~500,000 columns and ~20 rows. The process is
taking forever (~1 hour so far). In
2013 Jan 07
2
Have problem to do loop to generate transformed chi-squared variates
Hello R-helpers,
I need to generate standard variates normal to 'create' chi-squared variates. To make you more understand,
(1) a<-rnorm(3,0,1)
*after do (1), I need to squared and summed the three values. My problem is, how am I going to continue the programming if I had to repeat the process for 15 times, which in the end I will get 15 values from the whole programme.Hope you can
2011 Aug 24
3
Efficient way to Calculate the squared distances for a set of vectors to a fixed vector
I am pretty new to R. So this may be an easy question for most of you.
?
I would like to calculate the squared distances of a large set (let's say 20000) of vectors (let's say dimension of 5) to a fixed vector.
?
Say I have a data frame MY_VECTORS with 20000 rows and 5 columns, and one 5x1 vector y. I would like to efficiently calculate the squared distances?between each of the 20000
2011 Jun 28
2
How do I output all the R-squares of an SUR? summary(fitSUR$eq[[1:4]])$r.squared does not work
Greetings R Users,
I have a system of equations for which I would like to output all the
R-squares. Assume there are four equations in my system, the only way I
found to output all the R-squares is by calling them out one by one as this:
summary(fitSUR$eq[[1]])$r.squared
summary(fitSUR$eq[[2]])$r.squared
summary(fitSUR$eq[[3]])$r.squared
summary(fitSUR$eq[[4]])$r.squared
But isn't there a
2004 Jul 22
1
Bug: wrong R-squared in lm formula w/o intercept (PR#7127)
Full_Name: Adriano Azevedo Filho
Version: 1.9.1
OS: Windows, Linux
Submission from: (NULL) (200.171.246.212)
R-squared and Adjusted R-squared appear to be wrong when
the formula in lm() is specified without intercept. Problem
present in both Windows and Linux 1.9.1 version. Also
in the 1.8.1 version for Windows (other versions not
checked).
Possible example which reproduces the problem:
2011 Sep 08
2
Extract r.squared using cbind in lm
Hello,
I am using cbind in a lm-model. For standard lm-models
the r.squared can be easily extracted with summary(model)$r.squared,
but that is not working in in the case with cbind.
Here an example to illustrate the problem:
a <- c(1,3,5,2,5,3,1,6,7,2,3,2,6)
b <- c(12,15,18,10,18,22,9,7,9,23,12,17,13)
c <- c(22,26,32,33,32,28,29,37,34,29,30,32,29)
data <- data.frame(a,b,c)
2013 Feb 16
2
Interpret R-squared and cor in R
Hi I am trying to find the relationship between two variables.
First I fitted a linear model between two variables and I found the
following results:
Residual standard error: 0.03253 on 2498 degrees of freedom
Multiple R-squared: 0.5551, Adjusted R-squared: 0.5549
F-statistic: 3116 on 1 and 2498 DF, p-value: < 2.2e-16
Then I used the cor function to see the correlation between two variable
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
2006 Nov 21
1
R-squared with and without constant
Greetings Listers!
the R-squared value reported by summary of lm is calculated as
1 - RSS/RSS_m
where RSS_m is the residual sum of squares of a minimal model. In
most cases, the minimal model is simply y = mean(y), but when a
constant is left out of the model, the minimal model is y = 0.
However, if you manually add a constant, R still considers y = 0 the
minimal model. This also causes
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:
2004 Oct 06
1
odd behavior of summary()$r.squared
I may be missing something obvious here, but consider the following simple
dataset simulating repeated measures on 5 individuals with pretty strong
between-individual variance.
set.seed(1003)
n<-5
v<-rep(1:n,each=2)
d<-data.frame(factor(v),v+rnorm(2*n))
names(d)<-c("id","y")
Now consider the following two linear models that provide identical fitted
values,
2004 Jun 06
3
Average R-squared of model1 to model n
Hi,
We got a question about interpretating R-suqared.
The actual outputs for a test dataset is X=(x1,x2, ..., xn).
model 1 predicted the outputs as Y1=(y11,y12,..., y1n)
model n predicted the outputs as Y2=(y21,y22,..., y2n)
...
model m predicted the outputs as Ym=(ym1,ym2,..., ymn)
Now we have two ways to calculate R squared to evaluate the average performance of committee model.
(a)
2003 Apr 11
1
Pearson's Chi-squared Test
How i can perform a Pearson's Chi-squared Test in this data set:
| Outcome
-----------------+-----------+----------------------------------+
Treatment | Sex | None |Some | Marked | Total
-----------------+------------+--------+--------+-------------+
Active | Female | 6 | 5 | 16 | 27
2010 Jan 29
3
extract R-squared and P-value from lm results
Hi, R Users
I find a problem in extracting the R-squared and P-value from the lm results
described below (in Italic),
*Residual standard error: 2.25 on 17 degrees of freedom*
*Multiple R-squared: 0.001069, Adjusted R-squared: -0.05769 *
*F-statistic: 0.01819 on 1 and 17 DF, p-value: 0.8943 *
*
*
Any suggestions will be appreciated. Thanks.
Wenjun
[[alternative HTML version deleted]]
2003 Nov 03
2
Odd r-squared
Hi,
I would consider the calculation of r-squared in the following to be a
bug, but then, I've been wrong before. It seems that R looks to see if the
model contains an intercept term, and if it does not, computes r-squared in
a way I don't understand. To my mind, the following are two alternative
parametrizations of the same model, and should yield the same r-squared.
Any insight much
2011 Mar 04
1
linear model - lm (Adjusted R-squared)?
Hi,
Sorry for the naive question, but what exactly does the 'Adjusted R-squared'
coefficient in the summary of linear model adjust for?
Sample code:
> x <- rnorm(15)
> y <- rnorm(15)
> lmr <- lm(y~x)
> summary(lmr)
Call:
lm(formula = y ~ x)
Residuals:
Min 1Q Median 3Q Max
-1.7828 -0.7379 -0.4485 0.7563 2.1570
Coefficients:
2012 Dec 03
4
Chi-squared test when observed near expected
Dear UseRs,
I'm running a chi-squared test where the expected matrix is the same as the
observed, after rounding. R reports a X-squared of zero with a p value of
one. I can justify this because any other result will deviate at least as
much from the expected because what we observe is the expected, after
rounding. But the formula for X-squared, sum (O-E)^2/E gives a positive
value. What
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
##
2010 Jun 11
3
Calculation of r squared from a linear regression
Hi,
I'm trying to verify the calculation of coefficient of determination (r squared) for linear regression. I've done the calculation manually with a simple test case and using the definition of r squared outlined in summary(lm) help. There seems to be a discrepancy between the what R produced and the manual calculation. Does anyone know why this is so? What does the multiple r squared