[R] correlation coefficient

Benedikt Niesterok KleinerHaifisch at gmx.net
Tue Apr 28 15:33:02 CEST 2009


Hello,
I would like to get a correlation coefficient (R-squared) for my model.
I don't know how to calculate it in R.
What I've done so far:

x<-8.5:32.5   #Vektor x
y<-c(NA ,5.88 , 6.95  , 7.2 , 7.66 , 8.02 , 8.44 , 9.06,  9.65, 10.22 ,
10.63 ,11.06, 11.37, 11.91 ,12.28, 12.69 ,13.07 , 13.5 , 13.3 ,14.14  ,  NA  ,  NA ,   NA  ,  NA  ,  NA) #Vektor y
plot(y~x,col="green",pch=16,ylim=c(0,20),xlim=c(0,50))

(mod1<-nls(y~a+b*log(x,base=exp(1)),start=list(a=1,b=1),trace=TRUE))
xx<-seq(min(x),max(x),length=100)
yy<-6.2456*log(xx)-7.7822
lines(xx,yy,col="blue1")
summary(mod1)

This way I don't get R-squared like I do using the command "lm" for linear
models.
Would appreciate your help,

Benedikt N.
--




More information about the R-help mailing list