Skip to content
Prev 2365 / 29559 Next

Adding R-square to linear regression

except for the R^2 symbol...I found that problem else where too, but have
no solution yet.




__

Thomas Szegvary
Institute of Environmental Geosciences
Department of Geosciences
University of Basel
Bernoullistrasse 30
CH - 4056 Basel

Tel.  41-61-267 04 82
Fax. 41-61-267 04 79
Email: t.szegvary at unibas.ch
www.radon.unibas.ch
www.unibas.ch/environment


 
-----Urspr?ngliche Nachricht-----
Von: Andrew Niccolai [mailto:andrew.niccolai at yale.edu] 
Gesendet: Freitag, 20. Juli 2007 14:30
An: rob.robinson at bto.org; 'Thomas Szegvary'; r-sig-geo at stat.math.ethz.ch
Betreff: RE: [R-sig-Geo] Adding R-square to linear regression

I would merely add to Rob's reply that the text line can be modified to the
following:

text(x=2,y=2, paste("R squared = ", summary(c)$r.squared, sep="")) 


Does anyone know the expression function that would produce an R squared
symbol?  I tried expression(R^2) and that seems to only works correctly if
you have a follow on formula such as expression(x^2 == sum(over(x[i], n),
i==1, n).  Any ideas? 


Andrew Niccolai
Doctoral Candidate
Yale School of Forestry


 
-----Original Message-----
From: r-sig-geo-bounces at stat.math.ethz.ch
[mailto:r-sig-geo-bounces at stat.math.ethz.ch] On Behalf Of Rob Robinson
Sent: Friday, July 20, 2007 8:02 AM
To: 'Thomas Szegvary'; r-sig-geo at stat.math.ethz.ch
Subject: Re: [R-sig-Geo] Adding R-square to linear regression

Thomas,
 Can you not use text() to add a label? If you are using lm() to generate
the regression you can get at the R.sq by calling summary:
summary(c)$r.squared [there's also an adj.r.squared, have a look at
summary.lm] So something along the lines of
text(x=xpos,y=ypos,summary(obj)$r.squared)
ought to work, see code below
Hth
rob


a=c(1,2,3,4,5)
b=c(1,3,2,5,4)
c=lm(a~b)
summary(c)$r.squared
plot(a~b)
text(x=2,y=2,summary(c)$r.squared)

*** Want to know about Britain's birds? Try  www.bto.org/birdfacts ***

Dr Rob Robinson, Senior Population Biologist British Trust for Ornithology,
The Nunnery, Thetford, Norfolk, IP24 2PU
Ph: +44 (0)1842 750050         E: rob.robinson at bto.org
Fx: +44 (0)1842 750030         W: http://www.bto.org
eSafe scanned this email for viruses, vandals and malicious content (!)

==== "How can anyone be enlightened, when truth is so poorly lit" =====
_______________________________________________
R-sig-Geo mailing list
R-sig-Geo at stat.math.ethz.ch
https://stat.ethz.ch/mailman/listinfo/r-sig-geo