0
votes

Hi I'd like to do a logistical regression by adjusting on the propensity score. But first I'd like to match treaty and non-treaty according to propensity scores. Here's my first script:

mod_match<-matchit(Treatment~Prop.score, method = "nearest", data = Epidemio.prop,caliper = 0.05)

Here are the error messages

Error in matchit(Treatment~Prop.score, method = "nearest", data = Epidemio.prop, : Missing values exist in the data

I have therefore removed from the model all other variables except the two variables of interest that have no missing data.

mod_match<-matchit(Treatment~Prop.score, 
method = "nearest",  data = Epidemio.prop[c("Treatment","Prop.score")],
caliper = 0.1)

I still have error messages.

Error in weights.matrix(match.matrix, treat, discarded) : No units were matched In addition: Warning messages:

1: In max(pscore[treat == 0]) : no non-missing arguments to max; returning -Inf

2: In max(pscore[treat == 1]) : no non-missing arguments to max; returning -Inf

3: In min(pscore[treat == 0]) : no non-missing arguments to min; returning Inf

4: In min(pscore[treat == 1]) : no non-missing arguments to min; returning Inf

1
Always explicitly state from what packages any non-base R functions are coming. I've added a reference to package MatchIt (which I assume is what you've been using) in the title. Also please note that using all-caps is considered shouting. - Maurits Evers
@MauritsEvers thanks for your suggestion. But I also tried what you propose it didn't solve the problem. But when I changed my variable "Treatment" in 0,1 it worked. - Seydou GORO
I didn’t suggest anything. Your question/issue is not reproducible on account of missing sample data. Always include minimal sample data that allows us to reproduce the issue you’re having. - Maurits Evers

1 Answers

2
votes

The problem is that you are not giving any variables to be used in the propensity score calculation (i.e., you are only giving Treatment and Prop.score, whose meaning is not clear to me). You need to pass a set of auxiliary variables that are going to be used to fit the model predicting propensity scores.

Also, from my experience using MatchIt, it will throw an error related to missing values no matter the missingness is not related to the variables included in the model.

I recommend you create an auxiliary data frame with the variables you want to use in the model, and delete (or impute) any of the observations with missing values in any of those variables.

Something like this:

vars_to_keep <- c("Treatment", "x1", "x2", "x3", ... )
aux_df <- df[vars_to_keep]

# Select only complete cases (i.e. drop observations with at least one missing)
aux_df <- aux_df[complete.cases(aux_df), ]

mod_match <- matchit(Treatment ~ x1 + x2 + x3 + ..., method = "nearest", data = aux_df) 

Nevertheless, this tutorial is a much more comprehensive help. I recommend having a look at it.

Good luck!