[R] How do I output all the R-squares of an SUR? summary(fitSUR$eq[[1:4]])$r.squared does not work

StellathePug ritacarreira at hotmail.com
Tue Jun 28 17:05:56 CEST 2011


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 way of making this automatic, for example, something more
along the way of 

summary(fitSUR$eq[[1:4]])$r.squared ?

The above does not work, by the way.

I have attached below my sample program. Thanks!
Rita


############ SAMPLE PROGRAM ################

YX<-as.data.frame(matrix(rnorm(280),ncol=14, nrow=20))               ##
generate variables
names(YX) <-c(paste("Y", 1:4, sep=""), paste("X", 1:10, sep=""))     ##
assign variables' names

library(systemfit)

## EQUATIONS:
EQ1 <- Y1 ~ X1 + X2 + X4 + X7 + X10      ## equation 1 formula
EQ2 <- Y2 ~ X2 + X3 + X5 + X8 + X10      ## equation 2 formula
EQ3 <- Y3 ~ X5 + X6 + X7 + X9            ## equation 3 formula
EQ4 <- Y4 ~ X1 + X3 + X4 + X6 + X9       ## equation 4 formula

eqSystem <-list(form1 = EQ1, form2 = EQ2, form3 = EQ3, form4 = EQ4)

fitSUR <- systemfit(eqSystem, method ="SUR", data=YX)


## How do I out put all the R-squares of the system without having to type a
single line for each?

summary(fitSUR$eq[[1]])$r.squared
summary(fitSUR$eq[[2]])$r.squared
summary(fitSUR$eq[[3]])$r.squared
summary(fitSUR$eq[[4]])$r.squared

summary(fitSUR$eq[[1]])$adj.r.squared
summary(fitSUR$eq[[2]])$adj.r.squared
summary(fitSUR$eq[[3]])$adj.r.squared
summary(fitSUR$eq[[4]])$adj.r.squared

--
View this message in context: http://r.789695.n4.nabble.com/How-do-I-output-all-the-R-squares-of-an-SUR-summary-fitSUR-eq-1-4-r-squared-does-not-work-tp3630601p3630601.html
Sent from the R help mailing list archive at Nabble.com.



More information about the R-help mailing list