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

NA rows in df will cause uninformative error for brsmatch() #16

Closed
skent259 opened this issue Feb 3, 2024 · 1 comment · Fixed by #17
Closed

NA rows in df will cause uninformative error for brsmatch() #16

skent259 opened this issue Feb 3, 2024 · 1 comment · Fixed by #17

Comments

@skent259
Copy link
Owner

skent259 commented Feb 3, 2024

Simple test case. Problem is that the data frame output in .compute_distances() will have different number of rows since model.matrix() will automatically remove NAs.

library(rsmatch)

df <- data.frame(
  id = rep(1:3, each = 3),
  time = rep(1:3, 3),
  trt_time = rep(c(2, 3, NA), each = 3),
  X1 = c(2, 2, 2, 3, 3, 3, 9, 9, 9),
  X2 = rep(c("a", "a", "b"), each = 3),
  X3 = c(9, 4, 5, 6, NA, NA, 3, 4, 8),
  X4 = c(8, 9, 4, 5, 6, 7, 2, 3, 4)
)

brsmatch(n_pairs = 1, data = df)
#> Error in data.frame(trt_id = i, all_id = df_at_trt[[id]], trt_time = trt_time_i, : arguments imply differing number of rows: 1, 3, 2

Created on 2024-02-03 with reprex v2.0.2

@skent259
Copy link
Owner Author

skent259 commented Feb 3, 2024

Confirmed that similar problem will happen with coxpsmatch() function

@skent259 skent259 linked a pull request Feb 3, 2024 that will close this issue
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

Successfully merging a pull request may close this issue.

1 participant