You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Dear author,
I am writing to report a potential issue I encountered while using the MatchIt package (version 4.6.0) with the method = "nearest" option. Below are the details:
Description of the Issue:
When using the nearest method with ratio > 2, I noticed that each treated case is only matched to a single control instead of the expected ratio number of controls. And the last case will match all rest unmatched controls,like 1:2000. This occurs even when there are enough controls to meet the specified ratio.
R version: 4.2.2
MatchIt version: 4.6.0
Operating system: macOS(15.1.1)
I have included a minimal reproducible example below for your reference:
Could you please confirm if this is an intended behavior or a potential bug? If it is the latter, I would be happy to provide additional details or assist in testing any fixes.
I attempted to revert to an earlier version of MatchIt to resolve this problem, but unfortunately, the error persists.
This issue is impacting my current research, and as I am on a tight schedule to finalize an article for publication, I would greatly appreciate any guidance or a quick resolution.
Thank you for your time and for all your efforts in maintaining this fantastic tool for the community.
The text was updated successfully, but these errors were encountered:
Dear author,
I am writing to report a potential issue I encountered while using the MatchIt package (version 4.6.0) with the method = "nearest" option. Below are the details:
Description of the Issue:
When using the nearest method with ratio > 2, I noticed that each treated case is only matched to a single control instead of the expected ratio number of controls. And the last case will match all rest unmatched controls,like 1:2000. This occurs even when there are enough controls to meet the specified ratio.
R version: 4.2.2
MatchIt version: 4.6.0
Operating system: macOS(15.1.1)
I have included a minimal reproducible example below for your reference:
set.seed(123)
扩展到上千的病例和对照数据
n_cases <- 1000 # 病例数量
n_controls <- 5000 # 对照数量
生成模拟数据
test_data <- data.frame(
case_control = c(rep(1, n_cases), rep(0, n_controls)), # 病例与对照分组
age = c(rnorm(n_cases, 60, 5), rnorm(n_controls, 60, 5)), # 年龄分布
sex = c(
sample(0:1, n_cases, replace = TRUE), # 病例性别分布
sample(0:1, n_controls, replace = TRUE) # 对照性别分布
),
ID = 1:(n_cases + n_controls) # 唯一标识符
)
使用 MatchIt 进行匹配
library(MatchIt)
m.out <- matchit(case_control ~ age + sex,
data = test_data,
method = "nearest", # 使用最近邻匹配
ratio = 10, # 每个病例匹配5个对照
distance = "mahalanobis", # 使用 Mahalanobis 距离
caliper = c(age = 0.32), # 对年龄限制在 ±1 岁内
exact = "sex") # 确保性别完全一致匹配
matched_data <- match.data(m.out)
Could you please confirm if this is an intended behavior or a potential bug? If it is the latter, I would be happy to provide additional details or assist in testing any fixes.
I attempted to revert to an earlier version of MatchIt to resolve this problem, but unfortunately, the error persists.
This issue is impacting my current research, and as I am on a tight schedule to finalize an article for publication, I would greatly appreciate any guidance or a quick resolution.
Thank you for your time and for all your efforts in maintaining this fantastic tool for the community.
The text was updated successfully, but these errors were encountered: