[R] getting the response (dependent) from formula?

About this list Date view Thread view Subject view Author view Attachment view

From: Jeff D. Hamann (jeff_hamann@hamanndonald.com)
Date: Wed 16 Jan 2002 - 16:55:41 EST


Message-id: <000701c19e52$6eb1d6a0$01000001@godzilla>

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@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@stat.math.ethz.ch
_._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._


About this list Date view Thread view Subject view Author view Attachment view

This archive was generated by hypermail 2.1.3 : Thu 17 Jan 2002 - 11:10:11 EST