[R] getting the response (dependent) from formula?
Jeff D. Hamann
jeff_hamann at hamanndonald.com
Wed Jan 16 06:55:41 CET 2002
I'm trying to build a vector (fitting systems of equations) and I'm having a
little trouble getting the response variables from a list of formulas...
bdgmodel <- lbdg ~ d1sqr + ld1 + lhg
hgmodel <- lhg ~ ht2 + lht + whc
inst <- ~ d1sqr + ld1 + ht2 + lht + whc
systemeq <- list( bdgmodel, hgmodel )
# manually generate the y matrix...
y <- cbind( matrix( lbdg ),
matrix( log(hg) ) )
I would like to replace the previous line with something like...
# do the three stage least squares here...
for(i in 1:length( systemeq ) )
{
bigy <- rbind( bigy, attr(terms(systemeq[[i]]),"variables")[2] )
}
... then go on to fit the system of equations, etc, etc, etc...
attr(terms(systemeq[[i]]),"variables")[2]
this statement returns
"lbdg()" - without the quotes, which I can't figure out how to use....
is there an equivalent to model.matrix( systemeq[[1]] )?
Thanks,
Jeff.
Jeff D. Hamann
Hamann, Donald & Associates, Inc.
PO Box 1421
Corvallis, Oregon USA 97339-1421
Bus. 541-753-7333
Cell. 541-740-5988
jeff_hamann at hamanndonald.com
www.hamanndonald.com
-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-
r-help mailing list -- Read http://www.ci.tuwien.ac.at/~hornik/R/R-FAQ.html
Send "info", "help", or "[un]subscribe"
(in the "body", not the subject !) To: r-help-request at stat.math.ethz.ch
_._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._
More information about the R-help
mailing list