2
votes

So I am trying to do propensity score matching and then utilize Zelig to perform a logistic regression on the matched data.

Here is an example of what my data looks like: DATA

So I am trying to match the patients based on Dementia, Stroke, and Age. I am then trying to see whether or not Drug X is associated with an increased risk of falling once the patients have been matched. I would then like to go through the same process for Drug Y and Drug Z to see if each individual drug has an association.

Here is the code I have used so far to perform the matching and the logistic regression analysis:

data <- read_csv("Desktop/data.csv")
View(data)
attach(data)
data[1:10,]

m.out = matchit(Fall ~ Dementia + Stroke + Age, method = "exact", data = data)

m.data = match.data(m.out)
library(Zelig)
z.out = zelig(Fall ~ Drug X + Dementia + Stroke + Age, model = "logit", data = m.data)

x.out0 <- setx(z.out, Drug X = 0)
x1.out0 <- setx(z.out, Drug X = 1)

s.out0 <- sim(z.out, x = x.out0, x1 = x1.out0)

Everything seems to be going smoothly until this last line. Here is the error message I keep getting.

Error in eigen(Sigma, symmetric = TRUE) : 
  infinite or missing values in 'x'

Any ideas what I'm doing wrong? I've been stuck here for a while now and decided to reach out for help.

Thanks in advance.

1

1 Answers

0
votes

At this time, Zelig has not been updated in a few years and appears to have some bugs that are unaddressed. One issue is that the sim command seems to be very sensitive to variable names and data types. For anyone getting this error, try the following:

  • the variable Drug X has a space which Zelig probably can't handle. Try renaming it to something like Drug_X

  • If there's a variable that's dropping from the regression model due to collinearity, it needs to be dropped from the model entirely before going to sim()

  • Before running the model, also check that any character variables are converted to factors or you might get the following error:

    Error in contrasts<-(tmp, value = contr.funs[1 + isOF[nn]]) : contrasts can be applied only to factors with 2 or more levels