-
Notifications
You must be signed in to change notification settings - Fork 1
/
ui.R
327 lines (305 loc) · 12.8 KB
/
ui.R
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
library(shiny)
library(markdown)
library(shinydashboard)
library(DynTxRegime)
library(DT)
library(rgenoud)
source("./modules/uploadDat.R")
header <-
dashboardHeader(title = "Dynamic Treatment Regimes",titleWidth = 350, disable = FALSE)
sidebar <- dashboardSidebar(
width = 350,
tags$head(
tags$link(rel = "stylesheet", type = "text/css", href = "custom.css"),
tags$script(src = "custom.js")
),
sidebarMenu(
menuItem(
text = "Causal Inference Background",
menuItem(text = "Motivation", tabName = "mot"),
menuItem(
text = "Causal Effect",
menuSubItem(text = "Individual Causal Effect", tabName = "ice"),
menuSubItem(text = "Average Causal Effect", tabName = "ace"),
menuSubItem(text = "Summary", tabName = "sce")
),
menuItem(
text = "Point Exposure Studies",
menuSubItem(text = "Randomized Studies", tabName = "rs"),
menuSubItem(text = "Observational studies", tabName = "os"),
menuSubItem(text = "Notation", tabName = "not")
),
menuItem(
text = "Three Necessary Assumptions",
menuSubItem(text = "Necessary Assumptions", tabName = "na1"),
menuSubItem(text = "Assumption 1 : SUTVA", tabName = "sutva"),
menuSubItem(text = "Assumption 2 : NUC", tabName = "nuc"),
menuSubItem(text = "Assumption 3 : Positivity", tabName = "pos"),
menuSubItem(text = "Necessary Assumptions (Cont'd)", tabName = "na2")
),
menuItem(text = "Optimal Treatment Regimes", tabName = "otr")
),
menuItem(text = "Dataset", tabName = "dataone"),
menuItem(
text = "Single Stage Methods",
menuItem(
text = "Outcome Regression",
menuSubItem(text = "Outcome Regression", tabName = "or"),
menuSubItem(text = "Case Study", tabName = "orc")
),
menuItem(
text = "Augmented Inverse Probability Weighted Estimator",
menuSubItem(text = "AIPWE", tabName = "aipwe"),
menuSubItem(text = "Case study", tabName = "ac")
),
menuItem(
text = "Classification Method",
menuSubItem(text = "Classification Method", tabName = "class"),
menuSubItem(text = "Case Study", tabName = "cc")
),
menuItem(text = "Hands-on", tabName = "handson")
),
menuItem(text = "Reference", tabName = "ref")
)
)
body <- dashboardBody(
tabItems(
tabItem(tabName = "mot",
withMathJax(
includeMarkdown("./www/background/begin.Rmd")
)),
tabItem(tabName = "ice",
withMathJax(
includeMarkdown("./www/background/effect_1.Rmd")
)),
tabItem(tabName = "ace",
withMathJax(
includeMarkdown("./www/background/effect_2.Rmd")
)),
tabItem(tabName = "sce",
withMathJax(includeMarkdown("./www/background/effect_3.Rmd")
)),
tabItem(tabName = "rs",
withMathJax(includeMarkdown("./www/background/point_1.Rmd")
)),
tabItem(tabName = "os",
withMathJax(includeMarkdown("./www/background/point_2.Rmd")
)),
tabItem(tabName = "not",
withMathJax(includeMarkdown("./www/background/notation.Rmd")
)),
tabItem(tabName = "na1",
withMathJax(includeMarkdown("./www/background/assumption1.Rmd")
)),
tabItem(tabName = "sutva",
withMathJax(
includeMarkdown("./www/background/sutva.Rmd")
)),
tabItem(tabName = 'nuc',
withMathJax(
includeMarkdown("./www/background/nuc.Rmd")
)),
tabItem(tabName = 'pos',
withMathJax(
includeMarkdown("./www/background/positivity.Rmd")
)),
tabItem(tabName = "na2",
withMathJax(
includeMarkdown("./www/background/assumption2.Rmd")
)),
tabItem(tabName = "otr",
withMathJax(
includeMarkdown("./www/background/optimal.Rmd")
)),
tabItem(tabName = "dataone",
uiOutput("dataone")),
tabItem(tabName = "or",
withMathJax(includeMarkdown("./www/outcome_regress.Rmd"))),
tabItem(tabName = "orc",
uiOutput("orc")),
tabItem(tabName = "aipwe",
withMathJax(includeMarkdown("./www/aipwe.Rmd"))),
tabItem(tabName = "ac",
uiOutput("ac")),
tabItem(tabName = "class",
withMathJax(includeMarkdown("./www/class.Rmd"))),
tabItem(tabName = "cc",
uiOutput("cc")),
tabItem(tabName = "ref",
withMathJax(includeMarkdown("./www/background/reference.Rmd"))),
tabItem(
tabName = "handson",
tabsetPanel(
type = "tabs",
tabPanel("Upload Data",
sidebarLayout(
sidebarPanel(
h3("Upload Your Data:"),
p("You may load a small sized csv/text file (less
that 5Mb) to interactiely learn about the outcome regression
method."),
csvFileInput("datafile", "User data (.csv format)")),
mainPanel(dataTableOutput("table"))
)
),
tabPanel(
"Data Explore",
fluidPage(
h4("Data Explore with Scatter Plots"),
p("You may use scatter plots to visualize your uploaded dataset.")
),
actionButton("getplot", "Go"),
plotOutput("plot0")
),
tabPanel("Methods",
fluidPage(
fluidRow(wellPanel( # radio buttons for conditionalPanel, allow user to choose methods
radioButtons("radio", label = h4("Choose a method"),
choices = list("Outcome Regression" = 1, "AIPWE" = 2,
"Classification Method" = 3),
selected = 1, inline=TRUE))),
# Only show this panel if the plot type is a histogram
conditionalPanel(
condition = "input.radio == '1'",
fluidPage(
sidebarLayout(
sidebarPanel(# let user choose variable and models
uiOutput("varTrtR"),
uiOutput("varResponseR"),
uiOutput("varMainR"),
uiOutput("solverMainR"),
uiOutput("varContR"),
uiOutput("solverContR"),
width =4
),
mainPanel(
fluidPage(
h2("Outcome Regression"),
h4("Build your model objects for main effect and contrast and fit"),
p("To build model objects for main effect (moMain) and
contrast (moCont). You may specify your treatment variable and response
varible below. You may also choose the covariates to include in and
solver for each model. Here, we choose the solver to be 'lm'. Yet,
other methods, such as glm, can be used for each model independently.
This step can be achieved using the function buildModelObj(), followed by
call the qLearn() function to fit the models together."),
h4("Fit the model specified"),
actionButton("getmodelR", "GO"),
# h4("The corresponding code:"),
# textOutput("myMainR"),
# textOutput("myContR"),
# textOutput("myFitQ1"),
h4("Extract the estimated coefficients"),
p("We may extract the estimated coefficients by function coeff()"),
#code("coef(fitQ1)"),
tableOutput("coeffTbl"),
h4("Diagnostic plots"),
p("We may use the function plot() to obtain the diagnostic plots for fitted model"),
# code("plot(fitQ1)"),
fluidRow(
column(6, plotOutput("plot1")),
column(6, plotOutput("plot2"))
),
fluidRow(
column(6, plotOutput("plot3")),
column(6, plotOutput("plot4"))
)
)
)
)
)
),
conditionalPanel(
condition = "input.radio == '2'",
fluidPage(
#interaction not included yet
sidebarLayout(
sidebarPanel(
uiOutput("varTrtA"),
uiOutput("varResponseA"),
uiOutput("varPropA"),
# uiOutput("solverProp"),
uiOutput("varMainA"),
# uiOutput("solverMain"),
uiOutput("varContA"),
# uiOutput("solverCont"),
uiOutput("varRuleA")
#uiOutput("solverCont")
),
mainPanel(
fluidPage(
h2("Augmented Inverse Probility Weighted Estimator"),
h4("Specify treatment variable and build your modeling objects."),
p("Before running the optimalSeq function, we need to for the
treatment variable. This tells optimalSeq 'optimalSeq' which
columns of data correspond to treatments, and build the modeling
objects for propensity score (moPropen) and conditional expectations
of the main and contrast effect (expec.main and expec.cont).
You may specify your treatment variable and response varible below.
You may also choose the covariates to include in and solver for each model.
Here, we choose the solver to be glm for modeling propensity score and
gl for conditional expectations."),
h4("Estimate the optimal regime"),
actionButton("getmodelA", "GO"),
uiOutput("aipwe")
# uiOutput("ipwe")
# p("The corresponding code for build models:"),
# textOutput("myPropA"),
# textOutput("myMainA"),
# textOutput("myContA")
)
)
)
)
),
# Only show this panel if Custom is selected
conditionalPanel(
condition = "input.radio == '3'",
fluidPage(
sidebarLayout(
sidebarPanel(
uiOutput("varTrtC"),
uiOutput("varResponseC"),
uiOutput("varPropC"),
uiOutput("varMainC"),
uiOutput("varContC"),
uiOutput("varClass")
),
mainPanel(
fluidPage(
h2("Classification"),
h4("Specify treatment variable and build your modeling objects."),
p("Before running the optimalClass function, we need to for the
treatment variable. This tells optimalClass 'optimalClass' which
columns of data correspond to treatments, and build the modeling
objects for propensity score (moPropen) and conditional expectations
(moMain and moCont), You may specify your treatment variable
and response varible You may also choose the covariates to include
in and solver for each model. You may also choose variables to specify
the class of regimes. The class of regime is restricted to be linear
decision rule"),
h6("Estimate the optimal regime"),
actionButton("getmodelC", "GO"),
uiOutput("optClass")
)
)
)
)
)
)
)
)
)
))
dashboardPage(header, sidebar, body, tags$head(tags$style(
HTML(
'
.skin-blue .main-sidebar {
background-color: #666666;
}
.skin-blue .sidebar-menu>li.active>a, .skin-blue .sidebar-menu>li:hover>a {
background-color: #444444;
}
'
)
)))