0

Using R, when I run the code below, I am getting an error message.

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)

Can someone explain the error message to me? Thanks!

rbm
  • 3,243
  • 2
  • 17
  • 28
A.N.
  • 1
  • 2

1 Answers1

0

It's probably linked to the fact that 'sim' function exists in another package you have loaded. 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).

Best

Conrad
  • 1