[R] Extract r.squared using cbind in lm

Johannes Radinger JRadinger at gmx.at
Thu Sep 8 14:53:12 CEST 2011


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)

model_a <-lm(b~a,data=data)
model_b <-lm(cbind(b,c)~a,data=data)


How can I access r.squared in my case? Is there any option?
In the end, I want a dataframe containing the the intercept,
slope, p-value and r.squared for all Y's of my regression.

thank you

More information about the R-help mailing list