开发者

using update() with objects of class 'tsls'

Is there a way to use update() on objects that are created through tsls() in the sem package? For example, I would like to do something like this:

library(sem)
data(Kmenta)
mod1 <- tsls(Q ~ P, ~ D, data=Kmenta)
mod2 <- update(mod1, . ~ ., ~ D + F)

The first three lines of this example work. They create a tsls object in which D is an instrument for P.

I would like the last line of the example to create another tsls object in which both D and F are instruments for P. 开发者_StackOverflow But when I try to execute the last line, R tells me

Error in update.default(mod1, . ~ ., ~D + F) : 
  need an object with call component

Should I be calling update() in a different way, or do I need to find another way of making the mod2 object?

I'm using R 2.11.1 and sem 0.9-21.


The tsls does not save the call in the object and thus you cannot use the update function to refit models using the old fit. You can fit mod2 in the same way you fit mod1, which will unfortunately require some recalculations.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜