Skip to menu

matching을 하려고 합니다.

권혜미 2016.12.02 17:45 Views : 445

Rstudio을 사용하여 matching을 진행하려고 했습니다..



## Propensity score estimation (pscore object returned)
dat.nonrandom <- pscore(formula     = Alc ~ Age + Sex_F0M1 + R_BMI 
                        data        = dat,
                        family      = "binomial",
                        name.pscore = "ps")



## Actual Propensity score matching
res.ps.match <- ps.match(object             = dat.nonrandom,
                         control.matched.by = matched.by,
                         who.treated        = 1,                # value 1 is treated
                         name.match.index   = "match.index",
                         ratio              = 1,              
                         caliper            = "logit",
                         x                  = 0.2,
                         givenTmatchingC    = TRUE,
                         bestmatch.first    = TRUE,
                         setseed            = FALSE,
                         combine.output     = TRUE)
res.ps.match





res.ps.match를 시행하여보면

Matching data:
                                        
Number of treated obs.:              260
Number of matched treated obs.:      260
Number of untreated obs.:           1061
Number of matched untreated obs.:    260
Number of total matched obs.:        520
Number of not matched obs.:          801
Number of matching sets:             260
Number of incomplete matching sets:    0

이러한 결과가 나오는데

## Extract matched data
defMatched <-dat[unlist(res.ps.match[c("match.index","control.index")]), ]
## Construct a table
tabMatched <- CreateTableOne(vars = vars, factorVars = catvars, strata = "Alc", data = defMatched, test = TRUE)
## Show table with SMD
print(tabMatched, smd = TRUE, test=TRUE)

하면

                                       0                1                p      test SMD   
  n                                          434               86                            


로 treated 군이 86명으로 나옵니다ㅠ


저는 어디서 잘못된건지 모르겠습니다.ㅠ

위에 결과보면 260씩 매칭이된거 같은데- matched set을 만들때 잘못된건지 모르겠습니다....


저의 작은 지식으로는 이해가 안됩니다.ㅠ

조언부탁드립니다ㅜㅜ 감사합니다.