kkawato / rdlearn

Safe Policy Learning under Regression Discontinuity Designs with Multiple Cutoffs
Other
0 stars 0 forks source link

Control NAMESPCE by roxygen tags, instead of manually expose functions. #2

Closed sou412 closed 7 months ago

sou412 commented 7 months ago

Apply minor edits, creating a PR to add comments on 1_1crossfit.R.

The followings are my comments:

Then, instead, you could do something like

if (length(eval.dat0.all) == 0) {
   mu.fit0 <- 0
} else {
  # actually fit the local linear regression
} 
data %>% 
  filter(X >= c.vec[g], X < c.vec[min(g + 1, q)])

Probably, it's better to write a function is_in_range and call it instead.

is_in_range <- function(X, cutoff_lb, cutoff_ub) {
  return(X >= cutoff_lb & X <= cutoff_ub)
}

data[is_in_range(X, c.vec[g], c.vec[min(g+1, q)], ]