Guest User

Untitled

a guest
Jan 16th, 2018
74
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.76 KB | None | 0 0
  1. test = matchit(treat ~ age + educ + married, method = "nearest",
  2. exact = c(married), data = lalonde)
  3.  
  4. ## Now for exact matching within nearest neighbor
  5. ## exact should not equal T for this type of matching--that would get sent to matchit2exact
  6. if (!is.null(exact)){
  7. if(!sum(exact%in%names(data))==length(exact)) {
  8. warning("Exact variables not contained in data. Exact matching not done.",call.=FALSE)
  9. exact=NULL
  10. }
  11. else {
  12. ww <- exact%in%dimnames(X)[[2]]
  13. nw <- length(exact)
  14. exact <- data[,exact,drop=F]
  15. if(sum(ww)!=nw){
  16. X <- cbind(X,exact[!ww])
  17. }
  18. }
  19. }
  20.  
  21. test = matchit(treat ~ age + educ + married, method = "nearest",
  22. exact = "married", data = lalonde)
Add Comment
Please, Sign In to add comment