zbynek.janoska@gmail.com
2010-Sep-03 10:03 UTC
[R] How to use lm() output for systemfit() 'Seemingly unrelated regression'
I am having problem using output of lm() function for further analysing using systemfit package. Basicaly, the problem s following - I generate several formulas using lm()> fo1 <- lm(r98[,2] ~ f98[,1] + f98[,2] + ... + f98[,43]) > fo2 <- lm(r98[,1] ~ f98[,1] + f98[,2] + ... + f98[,43])and than I want to estimate a general model using package systemfit.> fitsur <- systemfit("SUR",list(as.formula(fo),as.formula(foo)))and I get following error: Error in systemfit("SUR", list(as.formula(fo), as.formula(foo))) : argument 'formula' must be an object of class 'formula' or a list of objects of class 'formula' and I am not able to find where the problem is. The problem remains even when I try:> fo1 <- r98[,2] ~ f98[,1] + f98[,2] + ... + f98[,43] > fo2 <- r98[,1] ~ f98[,1] + f98[,2] + ... + f98[,43]instead of using lm() Could someone give me a hand? I am quite new to R, so possibly the solutions is simple:) Thanks Zbynek Janoska -- View this message in context: http://r.789695.n4.nabble.com/How-to-use-lm-output-for-systemfit-Seemingly-unrelated-regression-tp2525418p2525418.html Sent from the R help mailing list archive at Nabble.com.
Arne Henningsen
2010-Sep-03 14:01 UTC
[R] How to use lm() output for systemfit() 'Seemingly unrelated regression'
On 3 September 2010 12:03, zbynek.janoska at gmail.com <zbynek.janoska at centrum.cz> wrote:> > I am having problem using output of lm() function for further analysing using > systemfit package. > > Basicaly, the problem s following - I generate several formulas using lm() >> fo1 <- lm(r98[,2] ~ f98[,1] + f98[,2] + ... + f98[,43]) >> fo2 <- lm(r98[,1] ~ f98[,1] + f98[,2] + ... + f98[,43]) > > and than I want to estimate a general model using package systemfit. > >> fitsur <- systemfit("SUR",list(as.formula(fo),as.formula(foo))) > > and I get following error: > Error in systemfit("SUR", list(as.formula(fo), as.formula(foo))) : > ?argument 'formula' must be an object of class 'formula' or a list of > objects of class 'formula' > > and I am not able to find where the problem is. > The problem remains even when I try: >> fo1 <- r98[,2] ~ f98[,1] + f98[,2] + ... + f98[,43] >> fo2 <- r98[,1] ~ f98[,1] + f98[,2] + ... + f98[,43] > instead of using lm() > Could someone give me a hand? I am quite new to R, so possibly the solutions > is simple:)Yes, the formula(s) must be the *first* argument of the systemfit() command, e.g.: R> fitsur <- systemfit( list(as.formula(fo),as.formula(foo)), method = "SUR" ) /Arne -- Arne Henningsen http://www.arne-henningsen.name