Closed benthestatistician closed 5 years ago
This is occurring because of this line inside compute_mahalanobis
evaluating to NA due to sum(z) = 1
.
sum(z)==1
, we could just do mt <- 0
. Similarly if sum(!z)==1
, do mc <- 0
. cov(data[z, ,drop=FALSE])
that's evaluating to NA
, with sum(z)-1
evaluating to 0.)match_on()
. Given how we've got things set up, the Mahalanobis distances will have to be standardized against covariance matrix A and covariance matrix B, whereas one would have wanted to use a common covariance matrix for either calculation.
I.e., one would have wanted to be able to provide an optional cov
argument to match_on()
, to be passed down to makedist()
and then to compute_mahalanobis()
. Alternatively, users expecting to be able to rbind()
/cbind()
together different match_on()
results might be expected to provide common data=
arguments in each of the calls to match_on()
, specifying his different data "slices" using a subset=
argument to match_on()
(which does not currently exist). In this alternative the covariance would have to be calculated prior to filtering based on subset=
, so I suppose the makedist()
and compute_mahalanobis()
function signatures would still have to be changed. I propose to have that bigger issue be its own issue, one that we don't take on as a part of this maintenance release project. (I sense a connection to the broader topic of whether match_on()
should be more insistent about receiving a data
argument; cf. #134 .)
Example:
This problem seems not to arise for
match_on.numeric()
, nor formatch_on.formula()
in cases with multiple treatment group members.