Leeds, Mark (IED)
2007-May-23 21:05 UTC
[R] Changing sequential regression code to call systemfit
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. #xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx eqDemand <- consump ~ -1 + price + income eqSupply <- consump ~ -1 + price + farmPrice + trend system<-list( demand = eqDemand, supply = eqSupply) #xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx 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}}