[R] Changing sequential regression code to call systemfit

From: Leeds, Mark (IED) <Mark.Leeds_at_morganstanley.com>
Date: Wed, 23 May 2007 17:05:56 -0400

I use code ( actually its code from vars package and its directly below ) to do a sequence of lm calls and the data I use from the matrix depends on restrictions.

 for(i in 1:K){

      datares <- datasub[, which(x$restrictions[i, ] == 1),drop=FALSE]
      y <- yendog[, i]
      lmres <- lm(y ~ -1 + ., data=datares)

# x$varresult[[i]] <- lmres
# x$resid[, i] <- resid(x$varresult[[i]])


I would like to modify the code to make one call to systemfit because I really should be using SUR rather than a sequence of lms.

But, systemfit needs the following type of setup.


eqDemand <- consump ~ -1 + price + income eqSupply <- consump ~ -1 + price + farmPrice + trend system<-list( demand = eqDemand, supply = eqSupply)


Then, the call to systemfit is

fitsur<- systemfit( "SUR", system)

Does anyone know how to change the code in the for loop ( I can deal with the two lines with x$ ) to mimic the 3 lines between

The xxxxxxxxxxxxxxxxxxxx lines ?

I'm not good enough in R to do this but my guess is that it is possible because datares and y both have column names. Thanks.

This is not an offer (or solicitation of an offer) to buy/se...{{dropped}}

R-help_at_stat.math.ethz.ch 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. Received on Wed 23 May 2007 - 21:15:54 GMT

Archive maintained by Robert King, hosted by the discipline of statistics at the University of Newcastle, Australia.
Archive generated by hypermail 2.2.0, at Wed 23 May 2007 - 21:31:53 GMT.

Mailing list information is available at https://stat.ethz.ch/mailman/listinfo/r-help. Please read the posting guide before posting to the list.