Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Error when including a numeric variable in formula using cem #160

Closed
jfhelmer opened this issue Apr 8, 2023 · 9 comments
Closed

Error when including a numeric variable in formula using cem #160

jfhelmer opened this issue Apr 8, 2023 · 9 comments

Comments

@jfhelmer
Copy link

jfhelmer commented Apr 8, 2023

When I try to include a numeric variable with a range of 18 to 96 (ages in years) in my matchit formula (on the righthand side), I get this error: Error in seq.default(min(X[[i]]), max(X[[i]]), length = bins + 1) :
'from' must be a finite number

I've checked the data to make sure there aren't any NAs. Any ideas? If I omit the variable, matchit runs without errors. If I only include that one variable, it throws the same error. I've tried different cutpoints (sturges, q5, and 5). All give the same error.

@ngreifer
Copy link
Collaborator

ngreifer commented Apr 8, 2023

Can you show me the output of the call summary() when used on that variable? Are you able to sue that variable in other forms of matching?

@jfhelmer
Copy link
Author

jfhelmer commented Apr 10, 2023 via email

@ngreifer
Copy link
Collaborator

You said the variable was age in years with a range from 18 to 96, but you showed me the summary of a binary factor variable. Is that an mistake?

@jfhelmer
Copy link
Author

jfhelmer commented Apr 10, 2023 via email

@ngreifer
Copy link
Collaborator

Hi Jesse, I'm not sure what the problem is. It would be helpful if you could send me your dataset with just the treatment variable and the problematic variable. If you can't do that, would you mind installing the development version of MatchIt using remotes::install_github("ngreifer/MatchIt"), restarting R, and seeing if the bug has been fixed? Thanks.

@jfhelmer
Copy link
Author

jfhelmer commented Apr 11, 2023 via email

@ngreifer
Copy link
Collaborator

Interesting. Unfortunately that doesn't help me solve the problem because the error occurs in a part of the code where each variable is considered separately from the others. I'm still wondering if you could send me a reproducible example to help me debug it.

@jfhelmer
Copy link
Author

jfhelmer commented Apr 12, 2023 via email

@ngreifer
Copy link
Collaborator

Hi Jesse, unfortunately email attachments don't work on GitHub issues, so I can't see the dataset. But actually, it's okay; I'm pretty sure I solved the problem.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants