@@ -60,8 +60,11 @@ FilePsInput <- function(id, label = "Upload data (csv/xlsx/sav/sas7bdat/dta)") {
60
60
uiOutput(ns(" group_ps" )),
61
61
uiOutput(ns(" indep_ps" )),
62
62
uiOutput(ns(" pcut" )),
63
- uiOutput(ns(" caliperps" ))
63
+ uiOutput(ns(" caliperps" )),
64
+ uiOutput(ns(" ratio" ))
64
65
)
66
+
67
+
65
68
}
66
69
67
70
@@ -191,7 +194,8 @@ FilePs <- function(input, output, session, nfactor.limit = 20) {
191
194
nclass <- unlist(out [, lapply(.SD , function (x ){length(unique(x ))}), .SDcols = conti_vars ])
192
195
factor_adds_list = mklist(data_varStruct , names(nclass )[(nclass < = nfactor.limit ) & (nclass < nrow(out ))])
193
196
194
- except_vars <- names(nclass )[ nclass == 1 | nclass > = nfactor.limit ]
197
+ # except_vars <- names(nclass)[ nclass== 1 | nclass >= nfactor.limit]
198
+ except_vars <- names(nclass )[ nclass == 1 ]
195
199
add_vars <- names(nclass )[nclass > = 1 & nclass < = 5 ]
196
200
# factor_vars_ini <- union(factor_vars, add_vars)
197
201
naomit <- ifelse(length(naCol ) == 0 , " Data has <B>no</B> missing values." , paste(" Column <B>" , paste(naCol , collapse = " , " ), " </B> are(is) excluded due to missing value." , sep = " " ))
@@ -219,6 +223,13 @@ FilePs <- function(input, output, session, nfactor.limit = 20) {
219
223
selected = 0.1 , inline = T )
220
224
})
221
225
226
+ output $ ratio <- renderUI({
227
+ if (is.null(input $ file )){return (NULL )}
228
+ radioButtons(session $ ns(" ratio_ps" ), label = " Case:control ratio" ,
229
+ choices = c(" 1:1" = 1 , " 1:2" = 2 , " 1:3" = 3 , " 1:4" = 4 ),
230
+ selected = 1 , inline = T )
231
+ })
232
+
222
233
223
234
observeEvent(data.info(), {
224
235
output $ factor <- renderUI({
@@ -513,15 +524,15 @@ FilePs <- function(input, output, session, nfactor.limit = 20) {
513
524
514
525
515
526
516
- mat.info <- eventReactive(c(input $ indep_pscal , input $ group_pscal , input $ caliper , data()), {
527
+ mat.info <- eventReactive(c(input $ indep_pscal , input $ group_pscal , input $ caliper , input $ ratio_ps , data()), {
517
528
req(input $ indep_pscal )
518
529
if (is.null(input $ group_pscal ) | is.null(input $ indep_pscal )){
519
530
return (NULL )
520
531
}
521
532
data <- data.table(data()$ data )
522
533
523
534
forms <- as.formula(paste(input $ group_pscal , " ~ " , paste(input $ indep_pscal , collapse = " +" ), sep = " " ))
524
- m.out <- MatchIt :: matchit(forms , data = data , caliper = input $ caliper )
535
+ m.out <- MatchIt :: matchit(forms , data = data , caliper = input $ caliper , ratio = as.integer( input $ ratio_ps ) )
525
536
pscore <- m.out $ distance
526
537
iptw <- ifelse(m.out $ treat == levels(m.out $ treat )[2 ], 1 / pscore , 1 / (1 - pscore ))
527
538
wdata <- cbind(data , pscore , iptw )
0 commit comments