[英]Unable to find an inherited method for function ‘sim’ for signature ‘“Zelig-ls”’
Using R, when I run the code below, I am getting an error message. 使用R,当我运行下面的代码时,我收到一条错误消息。
Code: 码:
library(MatchIt)
library(Zelig)
lw.y2loswt<-newcombined
matchIt.y2loswt <- matchit(y2_LOSWT ~ y0_HLTHTH + y0_THINIMP + y0_DRELAT
+ y0_DPARENT + y0_DFRIEND + y0_AGE910 + y0_RACE + y0_CATINC + y0_CATEDUC
+ y0_SOCCP + y0_PARENTS + y0_SELWT + y0_ATHCP, data = lw.y2loswt, method="full")
matchIt.y2loswt
summary(matchIt.y2loswt)
data.y2loswt.matchIt<-match.data(matchIt.y2loswt)
z.out0 <- zelig(y10_SUMSKIN ~ y2_LOSWT +y0_HLTHTH + y0_THINIMP +
y0_DRELAT + y0_DPARENT + y0_DFRIEND + y0_AGE910 + y0_RACE + y0_CATINC +
y0_CATEDUC + y0_SOCCP + y0_PARENTS + y0_SELWT + y0_ATHCP, data =
data.y2loswt.matchIt, model = "ls")
x.out0 <- setx(z.out0, y2_LOSWT = 0)
x1.out0 <- setx(z.out0, y2_LOSWT = 1)
s.out0 <- sim(z.out0, x = x.out0, x1= x1.out0)
#Error message:
#s.out0 <- sim(z.out0, x = x.out0, x1= x1.out0)
#Error in (function (classes, fdef, mtable) :
# unable to find an inherited method for function ‘sim’ for signature ‘"Zelig-#ls"’
All the other lines work except for the line: s.out <- sim(z.out0, x = x.out0, x1= x1.out0)
除该行外,其他所有行均有效: s.out <- sim(z.out0, x = x.out0, x1= x1.out0)
Can someone explain the error message to me? 有人可以向我解释错误消息吗? Thanks! 谢谢!
It's probably linked to the fact that 'sim' function exists in another package you have loaded. 这可能与“ sim”函数存在于您已加载的另一个软件包中这一事实有关。 If this is the case, the function is "masked". 在这种情况下,该功能被“屏蔽”。
Use the name of the package you want to use then twice ":" then the name of the particular function you want to use. 使用您要使用的程序包的名称,然后输入两次“:”,然后输入您要使用的特定功能的名称。 In your case, it becomes: s.out0 <- Zelig::sim(z.out0, x = x.out0, x1= x1.out0)
. 在您的情况下,它变为: s.out0 <- Zelig::sim(z.out0, x = x.out0, x1= x1.out0)
。
Best 最好
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.