2017-04-11 56 views
0

使用R,當我運行下面的代碼,我收到錯誤消息繼承的方法。無法找到函數「SIM」的簽名「‘澤裏格柯-LS’」

代碼:

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"’   

除行所有其他線路工作: s.out <- sim(z.out0, x = x.out0, x1= x1.out0)

有人能解釋錯誤信息給我?謝謝!

回答

0

它可能鏈接到一個事實,即「卡」功能已裝入另一個包存在。如果是這種情況,則該功能被「屏蔽」。

使用要使用兩次,然後將包名「:」那你想使用的特定函數的名稱。在你的情況下,它變成: s.out0 <- Zelig::sim(z.out0, x = x.out0, x1= x1.out0)

最好