[R] How to use lm() output for systemfit() 'Seemingly unrelated regression'

Arne Henningsen arne.henningsen at googlemail.com
Fri Sep 3 16:01:26 CEST 2010


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



More information about the R-help mailing list