Hi I was trying to estimate simultaneous equation system in R using systemfit. I used the following commands>library(systemfit) > data(Kmenta) > attach(Kmenta)>eqDemand<-consump~price+income> eqSupply<-consump~price+farmprice+trend > fitsur<-systemfit("SUR",list(demand=eqDemand, supply=eqSupply))and got the following error messege Error in systemfit("SUR", list(demand = eqDemand, supply = eqSupply)) : argument 'formula' must be an object of class 'formula' or a list of objects of class 'formula' Can anyone tell me how to overcome this problem? regards Anwesha [[alternative HTML version deleted]]
You got the order of the arguments wrong: ################################## library(systemfit) eqDemand <- consump ~ price + income eqSupply <- consump ~ price + farmPrice + trend fitsur <- systemfit(list(demand=eqDemand, supply=eqSupply), "SUR", data=Kmenta) summary(fitsur) ################################## On Tue, Aug 18, 2009 at 9:48 AM, Anwesha Chakrabarti<c.anwesha at gmail.com> wrote:> Hi > I was trying to estimate simultaneous equation system in R using systemfit. > I used the following commands >>library(systemfit) >> data(Kmenta) >> attach(Kmenta) > ?>eqDemand<-consump~price+income >> eqSupply<-consump~price+farmprice+trend >> fitsur<-systemfit("SUR",list(demand=eqDemand, supply=eqSupply)) > and got the following error messege > > Error in systemfit("SUR", list(demand = eqDemand, supply = eqSupply)) : > argument 'formula' must be an object of class 'formula' or a list of objects > of class 'formula' > > Can anyone tell me how to overcome this problem? > > regards > Anwesha > > ? ? ? ?[[alternative HTML version deleted]] > > ______________________________________________ > R-help at r-project.org mailing list > https://stat.ethz.ch/mailman/listinfo/r-help > PLEASE do read the posting guide http://www.R-project.org/posting-guide.html > and provide commented, minimal, self-contained, reproducible code. >
Anwesha Chakrabarti wrote:> >> fitsur<-systemfit("SUR",list(demand=eqDemand, supply=eqSupply)) > and got the following error messege > > Error in systemfit("SUR", list(demand = eqDemand, supply = eqSupply)) : > argument 'formula' must be an object of class 'formula' or a list of > objects > of class 'formula' > > Can anyone tell me how to overcome this problem? >Read the manual for systemfit. You have supplied the arguments in the wrong order. The formula is the first argument and the method is the second. Berend -- View this message in context: http://www.nabble.com/R-formula-tp25021359p25022361.html Sent from the R help mailing list archive at Nabble.com.
Hi Anwesha On Tue, Aug 18, 2009 at 10:48 AM, Anwesha Chakrabarti<c.anwesha at gmail.com> wrote:> I was trying to estimate simultaneous equation system in R using systemfit. > I used the following commands >> library(systemfit) >> data(Kmenta) >> attach(Kmenta) >> eqDemand<-consump~price+income >> eqSupply<-consump~price+farmprice+trendPlease replace "farmprice" by "farmPrice">> fitsur<-systemfit("SUR",list(demand=eqDemand, supply=eqSupply)) > and got the following error messege > > Error in systemfit("SUR", list(demand = eqDemand, supply = eqSupply)) : > argument 'formula' must be an object of class 'formula' or a list of objects > of class 'formula'The error message is correct. If you do not name the arguments, the first argument must be the formula or the list of formulas. You could estimate the system either by R> fitsur <- systemfit( list( demand=eqDemand, supply=eqSupply ), "SUR" ) or by R> fitsur <- systemfit( method="SUR", formula=list( demand=eqDemand, supply=eqSupply ) ) Please read the documentation/manual of systemfit and the paper about systemfit published in the JSS: http://www.jstatsoft.org/v23/i04/ Best wishes, Arne -- Arne Henningsen http://www.arne-henningsen.name