markmfredrickson / optmatch

Functions for optimal matching in R
https://markmfredrickson.github.io/optmatch
Other
47 stars 14 forks source link

discretize distances for solver in 1 way not 2 #163

Closed benthestatistician closed 5 years ago

benthestatistician commented 5 years ago

SubDivStrat() has

    .matcher <- function(toIntFunction) {
      tmp <- dm
      tmp$distance <- toIntFunction(dm$distance * reso)
      fmatch(tmp,
             max.row.units = ceiling(1/min.cpt),
             max.col.units = ceiling(max.cpt),
             min.col.units = max(1, floor(min.cpt)), f=f.ctls)

    }

    temp <- .matcher(floor)

and then later, if maximum "error" associated w/ temp was too large,

      temp1 <- temp
      temp2 <- .matcher(round)

      if  (sum(temp1$solution * dm$distance, na.rm = TRUE) <= sum(temp2$solution * dm$distance, na.rm = TRUE)) {
        temp <- temp1
      } else {
        temp <- temp2
      }

I propose to get rid of this alternation in the course of enabling warm starts, using one of floor and round but not both. That will make it easier to record/convey what was done. If the solution has too large a maxerr, the user should start it again w/ lower tolerance.

As to which of the two discretization functions to use, probably round()?

benthestatistician commented 5 years ago

Probably a major version sort of change; cf . #134.