-
Notifications
You must be signed in to change notification settings - Fork 0
/
.Rhistory
512 lines (512 loc) · 34.9 KB
/
.Rhistory
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
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
z <- mc_setoguchi(10, 100)
z
?stop
x
compute_asam(x, treatment = "exposure", outcome = "y", exclude = "exposure_prob", formula = exposure ~ . - y - exposure_prob)
library(data.table)
x
z
z[,]
compute_asam(x, treatment = "exposure", outcome = "y", exclude = "exposure_prob", formula = exposure ~ . - y - exposure_prob)
z[,lapply(.SD, compute_asam, treatment = "exposure", outcome = "y", exclude = "exposure_prob", formula = exposure ~ . - y - exposure_prob), by = mcname]
z[,lapply(.SD, function(x) {.SD %>% compute_asam(treatment = "exposure", outcome = "y", exclude = "exposure_prob", formula = exposure ~ . - y - exposure_prob)}), by = mcname]
z[,lapply(.SD, function(x) {x %>% compute_asam(treatment = "exposure", outcome = "y", exclude = "exposure_prob", formula = exposure ~ . - y - exposure_prob)}), by = mcname]
z[,lapply(.SD, function(i) {i %>% compute_asam(treatment = "exposure", outcome = "y", exclude = "exposure_prob", formula = exposure ~ . - y - exposure_prob)}), by = mcname]
x[,lapply(.SD, function(i) {i %>% compute_asam(treatment = "exposure", outcome = "y", exclude = "exposure_prob", formula = exposure ~ . - y - exposure_prob)})]
x %>% compute_asam(treatment = "exposure", outcome = "y", exclude = "exposure_prob", formula = exposure ~ . - y - exposure_prob)
z[,lapply(.SD, function(i) {i %>% compute_asam(treatment = "exposure", outcome = "y", exclude = "exposure_prob", formula = exposure ~ . - y - exposure_prob) %>% as.numeric()}), by = mcname]
z
z[,lapply(.SD, function(i) {i %>% compute_asam(treatment = "exposure", outcome = "y", exclude = "exposure_prob", formula = get(exposure) ~ . - get(y) - get(exposure_prob)) %>% as.numeric()}), by = mcname]
compute_asam(x, treatment = "exposure", outcome = "y", exclude = "exposure_prob", formula = exposure ~ . - y - exposure_prob)
z[,lapply(.SD, compute_asam, treatment = "exposure", outcome = "y", exclude = "exposure_prob", formula = exposure ~ . - y - exposure_prob), by = mcname]
library(propensityml)
z[,lapply(.SD, compute_asam, treatment = "exposure", outcome = "y", exclude = "exposure_prob", formula = exposure ~ . - y - exposure_prob), by = mcname]
compute_asam(x, treatment = "exposure", outcome = "y", exclude = "exposure_prob", formula = exposure ~ . - y - exposure_prob)
z[,lapply(.SD, function(i) {i %>% compute_asam(treatment = "exposure", outcome = "y", exclude = "exposure_prob", formula = exposure ~ . - y - exposure_prob)}), by = mcname]
library(propensityml)
x <- sim_outcome(1000)
z <- mc_setoguchi(10, 100)
z
z[,lapply(.SD, function(i) {i %>% compute_asam(treatment = "exposure", outcome = "y", exclude = "exposure_prob", formula = exposure ~ . - y - exposure_prob)}), by = mcname]
compute_asam(x, treatment = "exposure", outcome = "y", exclude = "exposure_prob", formula = exposure ~ . - y - exposure_prob)
?compute_asam
library(propensityml)
compute_asam(x, treatment = "exposure", outcome = "y", exclude = "exposure_prob", formula = exposure ~ . - y - exposure_prob)
mc_asam(z, treatment = "exposure", outcome = "y", exclude = "exposure_prob", formula = exposure ~ . - y - exposure_prob, mc_col = "mcname")
mc_asam(z, treatment = "exposure", outcome = "y", exclude = "exposure_prob", formula = exposure ~ . - y - exposure_prob)
library(propensityml)
mc_asam(z, treatment = "exposure", outcome = "y", exclude = "exposure_prob", formula = exposure ~ . - y - exposure_prob, mc_col = "mcname")
z
z[scenario == ]
z[scenario == 1]
z[mcname == 1]
z
compute_asam(x, treatment = "exposure", outcome = "y", exclude = "exposure_prob", formula = exposure ~ . - y - exposure_prob)
library(propensityml)
compute_asam(x, treatment = "exposure", outcome = "y", exclude = "exposure_prob", formula = exposure ~ . - y - exposure_prob)
lapply(1:10, function(mc) {compute_asam(x[mcname == mc], treatment = "exposure", outcome = "y", exclude = "exposure_prob", formula = exposure ~ . - y - exposure_prob)})
lapply(1:10, function(mc) {compute_asam(z[mcname == mc], treatment = "exposure", outcome = "y", exclude = "exposure_prob", formula = exposure ~ . - y - exposure_prob)})
compute_asam(z[mcname == 1], treatment = "exposure", outcome = "y", exclude = "exposure_prob", formula = exposure ~ . - y - exposure_prob)
z[mcname == 1]
compute_asam(z[mcname == 1], treatment = "exposure", outcome = "y", exclude = c("exposure_prob", "mcname"), formula = exposure ~ . - y - exposure_prob)
compute_asam(z[mcname == 1, -"mcname"], treatment = "exposure", outcome = "y", exclude = "exposure_prob", formula = exposure ~ . - y - exposure_prob)
lapply(1:10, function(mc) {compute_asam(z[mcname == mc, - "mcname"], treatment = "exposure", outcome = "y", exclude = "exposure_prob", formula = exposure ~ . - y - exposure_prob)})
lapply(1:10, function(mc) {compute_asam(z[mcname == mc, - "mcname"], treatment = "exposure", outcome = "y", exclude = "exposure_prob", formula = exposure ~ . - y - exposure_prob)}) %>% data.table::rbindlist()
lapply(1:10, function(mc) {compute_asam(z[mcname == mc, - "mcname"], treatment = "exposure", outcome = "y", exclude = "exposure_prob", formula = exposure ~ . - y - exposure_prob)}) %>% data.table::rbindlist() %>% mean()
lapply(1:10, function(mc) {compute_asam(z[mcname == mc, - "mcname"], treatment = "exposure", outcome = "y", exclude = "exposure_prob", formula = exposure ~ . - y - exposure_prob)}) %>% data.table::rbindlist() %>% colMeans()
lapply(1:10, function(mc) {compute_asam(z[mcname == mc, - "mcname"], treatment = "exposure", outcome = "y", exclude = "exposure_prob", formula = exposure ~ . - y - exposure_prob)}) %>% mean()
lapply(1:10, function(mc) {compute_asam(z[mcname == mc, - "mcname"], treatment = "exposure", outcome = "y", exclude = "exposure_prob", formula = exposure ~ . - y - exposure_prob)}) %>% unlist()
lapply(1:10, function(mc) {compute_asam(z[mcname == mc, - "mcname"], treatment = "exposure", outcome = "y", exclude = "exposure_prob", formula = exposure ~ . - y - exposure_prob)}) %>% unlist() %>% mean()
?parallel::mclapply
dt
library(propensityml)
library(propensityml)
mc_asam(z, treatment = "exposure", outcome = "y", exclude = "exposure_prob", formula = exposure ~ . - y - exposure_prob, mc_col = "mcname")
library(propensityml)
mc_asam(z, treatment = "exposure", outcome = "y", exclude = "exposure_prob", formula = exposure ~ . - y - exposure_prob, mc_col = "mcname")
mc_asam(z, treatment = "exposure", outcome = "y", exclude = "exposure_prob", formula = exposure ~ . - y - exposure_prob, mc_col = "mcname") %>% .[]
library(propensityml)
mc_asam(z, treatment = "exposure", outcome = "y", exclude = "exposure_prob", formula = exposure ~ . - y - exposure_prob, mc_col = "mcname") %>% .[]
mc_asam(z, treatment = "exposure", outcome = "y", exclude = "exposure_prob", formula = exposure ~ . - y - exposure_prob, mc_col = "mcname")
usethis::use_package("parallel")
library(propensityml)
library(propensityml)
doMC::registerDoMC(4)
small_list <- foreach(scenario = c("A", "B", "F", "G"), .combine = rbind) %dopar% {
mc_setoguchi(N = 10, n_dat = 100, scenario = scenario, parallel = TRUE)[,
scenario := scenario]
}
small_list <- foreach::foreach(scenario = c("A", "B", "F", "G"), .combine = rbind) foreach::`%dopar%` {
mc_setoguchi(N = 10, n_dat = 100, scenario = scenario, parallel = TRUE)[,
scenario := scenario]
}
?foreach::`%dopar%`
library(foreach)
doMC::registerDoMC(4)
small_list <- foreach(scenario = c("A", "B", "F", "G"), .combine = rbind) %dopar% {
mc_setoguchi(N = 10, n_dat = 100, scenario = scenario, parallel = TRUE)[,
scenario := scenario]
}
small_list
mc_asam(small_list, treatment = "exposure", outcome = "y", exclude = "exposure_prob", formula = exposure ~ . - y - exposure_prob, mc_col = "mcname", sc_col = "scenario")
library(propensityml)
library(propensityml)
mc_asam(small_list, treatment = "exposure", outcome = "y", exclude = "exposure_prob", formula = exposure ~ . - y - exposure_prob, mc_col = "mcname", sc_col = "scenario")
library(propensityml)
mc_asam(small_list, treatment = "exposure", outcome = "y", exclude = "exposure_prob", formula = exposure ~ . - y - exposure_prob, mc_col = "mcname", sc_col = "scenario")
library(propensityml)
mc_asam(small_list, treatment = "exposure", outcome = "y", exclude = "exposure_prob", formula = exposure ~ . - y - exposure_prob, mc_col = "mcname", sc_col = "scenario")
library(propensityml)
mc_asam(small_list, treatment = "exposure", outcome = "y", exclude = "exposure_prob", formula = exposure ~ . - y - exposure_prob, mc_col = "mcname", sc_col = "scenario")
z[,mcname] %>% unique()
small_list[,mcname] %>% unique()
library(propensityml)
mc_asam(small_list, treatment = "exposure", outcome = "y", exclude = "exposure_prob", formula = exposure ~ . - y - exposure_prob, mc_col = "mcname", sc_col = "scenario")
small_list
small_list[scenario == "A"]
small_list[scenario == "A"][mcname == 1]
small_list[scenario == "A"]
small_list[scenario == "A", .SD, .SDcols = -"scenario"]
small_list[scenario == "A", .SD, .SDcols = -"scenario"][mcname == 1]
small_list[scenario == "A", .SD, .SDcols = -"scenario"][mcname == 1] %>% nrow()
small_list[scenario == "A"][mcname == 1] %>% nrow()
library(propensityml)
mc_asam(small_list, treatment = "exposure", outcome = "y", exclude = "exposure_prob", formula = exposure ~ . - y - exposure_prob, mc_col = "mcname", sc_col = "scenario")
mc_asam(small_list, treatment = "exposure", outcome = "y", exclude = "exposure_prob", formula = exposure ~ . - y - exposure_prob, mc_col = "mcname", sc_col = "scenario") %>% .[,.(mean(asam)), by = SC]
x
library(propensityml)
mc_asam(small_list, treatment = "exposure", outcome = "y", exclude = "exposure_prob", formula = exposure ~ . - y - exposure_prob, mc_col = "mcname", sc_col = "scenario")
library(propensityml)
small_list[,-"scenario"]
mc_asam(small_list[,-"scenario"], treatment = "exposure", outcome = "y", exclude = "exposure_prob", formula = exposure ~ . - y - exposure_prob, mc_col = "mcname")
library(propensityml)
mc_asam(small_list[,-"scenario"], treatment = "exposure", outcome = "y", exclude = "exposure_prob", formula = exposure ~ . - y - exposure_prob, mc_col = "mcname")
library(propensityml)
x <- sim_outcome(1000)
x
x %>% add_propensity(formula = exposure ~ . - y - exposure_prob)
x %>% add_ipw_wt(treatment = "exposure", formula = exposure ~ . - y - exposure_prob)
x %>% add_ipw_wt(treatment = "exposure", formula = exposure ~ . - y - exposure_prob) %>% dplyr::mutate(ipw = ipw_wt * y)
x %>% add_ipw_wt(treatment = "exposure", formula = exposure ~ . - y - exposure_prob) %>% dplyr::summarise(ipw = mean(ipw_wt * y))
x %>% add_iptw(treatment = "exposure", outcome = "y", formula = exposure ~ . - y - exposure_prob)
x %>% add_iptw(treatment = "exposure", outcome = "y", formula = exposure ~ . - y - exposure_prob) %>% dplyr::summarise(ipw = mean(iptw))
x %>% add_iptw(treatment = "exposure", outcome = "y", formula = exposure ~ . - y - exposure_prob) %>% dplyr::summarise(ipw = mean(iptw * y))
x %>% add_iptw(treatment = "exposure", outcome = "y", formula = exposure ~ . - y - exposure_prob)
library(propensityml)
x %>% add_iptw(treatment = "exposure", outcome = "y", formula = exposure ~ . - y - exposure_prob)
x %>% compute_ipw(treatment = "exposure", outcome = "y", formula = exposure ~ . - y - exposure_prob)
library(propensityml)
x %>% add_iptw(treatment = "exposure", outcome = "y", formula = exposure ~ . - y - exposure_prob)
x %>% add_iptw(treatment = "exposure", formula = exposure ~ . - y - exposure_prob)
x %>% compute_ipw(treatment = "exposure", outcome = "y", formula = exposure ~ . - y - exposure_prob)
library(propensityml)
x %>% compute_ipw(treatment = "exposure", outcome = "y", formula = exposure ~ . - y - exposure_prob)
x %>% add_iptw(treatment = "exposure", formula = exposure ~ . - y - exposure_prob)
x %>% add_iptw(treatment = "exposure", formula = exposure ~ . - y - exposure_prob) %>% dplyr::summarise(sd(iptw))
x %>% add_iptw(treatment = "exposure", formula = exposure ~ . - y - exposure_prob) %>% dplyr::summarise(mean(iptw + .4))
x %>% add_iptw(treatment = "exposure", formula = exposure ~ . - y - exposure_prob) %>% dplyr::summarise(mean(iptw / .4))
x %>% add_iptw(treatment = "exposure", formula = exposure ~ . - y - exposure_prob) %>% dplyr::summarise(.4 / iptw)
x %>% add_iptw(treatment = "exposure", formula = exposure ~ . - y - exposure_prob) %>% dplyr::summarise(mean(.4 / iptw))
x %>% compute_asam(treatment = "exposure", outcome = "y", formula = exposure ~ . - y - exposure_prob)
library(propensityml)
library(propensityml)
?as.formula
library(propensityml)
library(propensityml)
x <- mc_setoguchi(10, 100)
x
x %>% add_propensity(formula = exposure ~ . - y - exposure_prob, mc = "mcname")
?data.table::setkey
add_propensity
?randomForest::randomForest
x
x <- sim_outcome(1000)
x %>% add_propensity(formula = exposure ~ . - y - exposure_prob)
x %>% add_propensity(formula = exposure ~ . - y - exposure_prob, method = "rf")
sim_outcome(1000)
set.seed(1)
sim_outcome(1000)
set.seed(1)
mc_setoguchi(10, 100)
set.seed(1)
mc_setoguchi(100, 10)
sim_outcome(100)
sim_outcome(1000)
?parallel::mclapply
library(propensityml)
mc_setoguchi(100, 10)
library(propensityml)
mc_setoguchi(100, 10)
x <- mc_setoguchi(10, 100)
x[, .N, by = .(mcname, scenario)]
x[, .N, by = scenario]
x[, .N, by = mcname]
x
x[, .N, by = .(mcname, scenario)]
x %>% add_propensity(formula = exposure ~ . - y - exposure_prob, mc = c("mcname", "scenario"))
x <- mc_setoguchi(10, 100, scenario = c("A", "B", "F", "G"))
x
x %>% add_propensity(formula = exposure ~ . - y - exposure_prob, mc = c("mcname", "scenario"))
x %>% add_propensity(formula = exposure ~ . - y - exposure_prob, method = "rf", mc = c("mcname", "scenario"))
x <- mc_setoguchi(10, 1000, scenario = c("A", "B", "F", "G"))
x
x %>% add_propensity(formula = exposure ~ . - y - exposure_prob, method = "rf", mc = c("mcname", "scenario"))
x <- mc_setoguchi(10, 100, scenario = c("A", "B", "F", "G"))
x %>% add_propensity(formula = exposure ~ . - y - exposure_prob, method = "rf", mc = c("mcname", "scenario"))
?switch
switch(1, x[1:5], x[2:6])
switch(2, x[1:5], x[2:6])
switch(3, x[1:5], x[2:6])
switch(3, {x[1:5]}, {x[2:6]})
switch(1, {x[1:5]}, {x[2:6]})
c("logit", "rf", "cart", "SVM")
c("logit", "rf", "cart", "SVM") %in% "logit"
c("logit", "rf", "cart", "SVM") == "logit"
which(c("logit", "rf", "cart", "SVM") == "logit")
switch("logit", "logit" = {x[1:5]}, "rf" = {x[2:6]})
switch("rf", "logit" = {x[1:5]}, "rf" = {x[2:6]})
library(propensityml)
x %>% add_propensity(formula = exposure ~ . - y - exposure_prob, mc = c("mcname", "scenario"))
x %>% add_propensity(formula = exposure ~ . - y - exposure_prob, method = "rf", mc = c("mcname", "scenario"))
x %>% add_propensity(formula = exposure ~ . - y - exposure_prob, method = "rf", mc = c("mcname", "scenario"))
?data.table::copy
library(propensityml)
x %>% add_propensity(formula = exposure ~ . - y - exposure_prob, mc = c("mcname", "scenario"))
x %>% tibble::tibble() %>% add_propensity(formula = exposure ~ . - y - exposure_prob, mc = c("mcname", "scenario"))
x
x %>% tibble::tibble()
is.data.table(x %>% tibble::tibble())
data.table::is.data.table(x %>% tibble::tibble())
x %>% tibble::tibble() %>% add_propensity(formula = exposure ~ . - y - exposure_prob, mc = c("mcname", "scenario"))
x %>% add_propensity(formula = exposure ~ . - y - exposure_prob, mc = c("mcname", "scenario"))
x[,.N,by = .(mcname, scenario)]
?data.table::setkey
unique(x[[c("mcname", "scenario")]])
unique(x[[c("mcname")]])
?foreach::`%:%`
x
library(propensityml)
set.seed(1)
doMC::registerDoMC(4)
x %>% tibble::tibble() %>% add_propensity(formula = exposure ~ . - y - exposure_prob, method = "rf", mc_col = "mcname", sc_col = "scenario")
unique(x[["scenario"]])
unique(x[[sc_col]])
library(propensityml)
doMC::registerDoMC(4)
x %>% tibble::tibble() %>% add_propensity(formula = exposure ~ . - y - exposure_prob, method = "rf", mc_col = "mcname", sc_col = "scenario")
doMC::registerDoMC(4)
x %>% add_propensity(formula = exposure ~ . - y - exposure_prob, method = "rf", mc_col = "mcname", sc_col = "scenario")
x
library(propensityml)
x %>% add_propensity(formula = exposure ~ . - y - exposure_prob, method = "rf", mc = c("mcname", "scenario"))
library(propensityml)
doMC::registerDoMC(8)
x %>% add_propensity(formula = exposure ~ . - y - exposure_prob, method = "rf", mc_col = "mcname", sc_col = "scenario")
z <- mc_setoguchi(10, 1000, scenario = c("A", "B", "F", "G"))
z
nrow(x)
nrow(z)
doMC::registerDoMC(8)
z %>% add_propensity(formula = exposure ~ . - y - exposure_prob, method = "rf", mc_col = "mcname", sc_col = "scenario")
doMC::registerDoMC(8)
system.time(z %>% add_propensity(formula = exposure ~ . - y - exposure_prob, method = "rf", mc_col = "mcname", sc_col = "scenario"))
library(propensityml)
system.time(z %>% add_propensity(formula = exposure ~ . - y - exposure_prob, method = "rf", mc = c("mcname", "scenario")))
z
library(propensityml)
doMC::registerDoMC(8)
z %>% add_propensity(formula = exposure ~ . - y - exposure_prob, method = "rf", mc_col = "mcname", sc_col = "scenario")
z
doMC::registerDoMC(8)
system.time(z %>% add_propensity(formula = exposure ~ . - y - exposure_prob, method = "rf", mc_col = "mcname", sc_col = "scenario"))
library(propensityml)
doMC::registerDoMC(8)
z %>% add_propensity(formula = exposure ~ . - y - exposure_prob, method = "rf", mc_col = "mcname", sc_col = "scenario")
library(propensityml)
doMC::registerDoMC(8)
z %>% add_propensity(formula = exposure ~ . - y - exposure_prob, method = "rf", mc_col = "mcname", sc_col = "scenario")
z
x
x
z
x
xx <- sim_outcome(1000)
doMC::registerDoMC(8)
xx %>% add_propensity(formula = exposure ~ . - y - exposure_prob, method = "rf")
library(propensityml)
doMC::registerDoMC(8)
z %>% add_propensity(formula = exposure ~ . - y - exposure_prob, method = "rf", mc_col = "mcname", sc_col = "scenario")
library(propensityml)
doMC::registerDoMC(8)
z %>% add_propensity(formula = exposure ~ . - y - exposure_prob, method = "rf", mc_col = "mcname", sc_col = "scenario")
z %>% add_propensity(formula = exposure ~ . - y - exposure_prob - mcname - scenario, method = "rf", mc_col = "mcname", sc_col = "scenario")
doMC::registerDoMC(8)
z %>% add_propensity(formula = exposure ~ . - y - exposure_prob - mcname - scenario, method = "rf", mc_col = "mcname", sc_col = "scenario", parallel = TRUE)
library(propensityml)
doMC::registerDoMC(8)
z %>% add_propensity(formula = exposure ~ . - y - exposure_prob - mcname - scenario, method = "rf", mc_col = "mcname", sc_col = "scenario", parallel = TRUE)
doMC::registerDoMC(8)
z %>% add_propensity(formula = exposure ~ . - y - exposure_prob, method = "rf", mc_col = "mcname", sc_col = "scenario", parallel = TRUE)
library(propensityml)
doMC::registerDoMC(8)
z %>% add_propensity(formula = exposure ~ . - y - exposure_prob, method = "rf", mc_col = "mcname", sc_col = "scenario", parallel = TRUE)
z
library(propensityml)
doMC::registerDoMC(8)
z %>% add_propensity(formula = exposure ~ . - y - exposure_prob, method = "rf", mc_col = "mcname", sc_col = "scenario", parallel = TRUE)
library(propensityml)
doMC::registerDoMC(8)
z %>% add_propensity(formula = exposure ~ . - y - exposure_prob, method = "rf", mc_col = "mcname", sc_col = "scenario", parallel = TRUE)
doMC::registerDoMC(4)
system.time(z %>% add_propensity(formula = exposure ~ . - y - exposure_prob, method = "rf", mc_col = "mcname", sc_col = "scenario", parallel = TRUE))
doMC::registerDoMC(8)
system.time(z %>% add_propensity(formula = exposure ~ . - y - exposure_prob, method = "rf", mc_col = "mcname", sc_col = "scenario", parallel = TRUE))
doMC::registerDoMC(16)
system.time(z %>% add_propensity(formula = exposure ~ . - y - exposure_prob, method = "rf", mc_col = "mcname", sc_col = "scenario", parallel = TRUE))
z[scenario == "A"]
z[scenario == "A", mcname]
library(propensityml)
library(propensityml)
doMC::registerDoMC(8)
z %>% add_propensity(formula = exposure ~ . - y - exposure_prob, method = "rf", mc_col = "mcname", sc_col = "scenario", parallel = TRUE)
doMC::registerDoMC(8)
system.time(z %>% add_propensity(formula = exposure ~ . - y - exposure_prob, method = "rf", mc_col = "mcname", sc_col = "scenario", parallel = TRUE))
library(propensityml)
doMC::registerDoMC(8)
system.time(z %>% add_propensity(formula = exposure ~ . - y - exposure_prob, method = "rf", mc_col = "mcname", sc_col = "scenario", parallel = TRUE))
library(propensityml)
library(propensityml)
z
z %>% compute_ipw(treatment = "exposure", outcome = "y", formula = exposure ~ . - y - exposure_prob, mc_col = "mcname", sc_col = "scenario")
library(propensityml)
z %>% compute_ipw(treatment = "exposure", outcome = "y", formula = exposure ~ . - y - exposure_prob, mc_col = "mcname", sc_col = "scenario")
z %>% compute_sipw(treatment = "exposure", outcome = "y", formula = exposure ~ . - y - exposure_prob, mc_col = "mcname", sc_col = "scenario")
library(propensityml)
z %>% compute_sipw(treatment = "exposure", outcome = "y", formula = exposure ~ . - y - exposure_prob, mc_col = "mcname", sc_col = "scenario")
z %>% compute_ipw(treatment = "exposure", outcome = "y", formula = exposure ~ . - y - exposure_prob, mc_col = "mcname", sc_col = "scenario")
doMC::registerDoMC(8)
z %>% add_iptw(treatment = "exposure", formula = exposure ~ . - y - exposure_prob, mc_col = "mcname", sc_col = "scenario", parallel = TRUE)
xx
z %>% compute_ipw(treatment = "exposure", outcome = "y", formula = exposure ~ . - y - exposure_prob, mc_col = "mcname", sc_col = "scenario")
xx
xx %>% compute_ipw(treatment = "exposure", outcome = "y", formula = exposure ~ . - y - exposure_prob)
library(propensityml)
xx %>% compute_ipw(treatment = "exposure", outcome = "y", formula = exposure ~ . - y - exposure_prob)
z %>% compute_ipw(treatment = "exposure", outcome = "y", formula = exposure ~ . - y - exposure_prob, mc_col = "mcname", sc_col = "scenario")
library(propensityml)
z %>% compute_ipw(treatment = "exposure", outcome = "y", formula = exposure ~ . - y - exposure_prob, mc_col = "mcname", sc_col = "scenario")
z
z %>% add_propensity(formula = exposure ~ . - y - exposure_prob, mc_col = "mcname", sc_col = "scenario")
library(propensityml)
z %>% add_propensity(formula = exposure ~ . - y - exposure_prob, mc_col = "mcname", sc_col = "scenario")
doMC::registerDoMC(8)
z %>% add_propensity(formula = exposure ~ . - y - exposure_prob, mc_col = "mcname", sc_col = "scenario", parallel = T)
xx %>% add_propensity(formula = exposure ~ . - y - exposure_prob)
z
doMC::registerDoMC(8)
z %>% add_propensity(formula = exposure ~ . - y - exposure_prob, mc_col = "mcname", sc_col = "scenario", parallel = T)
z %>% add_propensity(formula = exposure ~ . - y - exposure_prob, mc_col = "mcname", sc_col = "scenario", parallel = F)
xx %>% add_propensity(formula = exposure ~ . - y - exposure_prob)
library(propensityml)
z %>% add_propensity(formula = exposure ~ . - y - exposure_prob, mc_col = "mcname", sc_col = "scenario", parallel = F)
z %>% add_propensity(formula = exposure ~ . - y - exposure_prob, mc_col = "mcname", sc_col = "scenario")
xx %>% add_propensity(formula = exposure ~ . - y - exposure_prob)
xx
z %>% add_propensity(formula = exposure ~ . - y - exposure_prob, mc_col = "mcname", sc_col = "scenario")
doMC::registerDoMC(8)
z %>% add_propensity(formula = exposure ~ . - y - exposure_prob, mc_col = "mcname", sc_col = "scenario", parallel = T)
z[mcname == 1 & scenario == "A"]
library(propensityml)
z %>% add_propensity(formula = exposure ~ . - y - exposure_prob, mc_col = "mcname", sc_col = "scenario")
library(propensityml)
z %>% add_propensity(formula = exposure ~ . - y - exposure_prob, mc_col = "mcname", sc_col = "scenario")
z %>% add_propensity(formula = exposure ~ . - y - exposure_prob, mc_col = "mcname", sc_col = "scenario")
xx %>% add_propensity(formula = exposure ~ . - y - exposure_prob)
library(propensityml)
z %>% add_propensity(formula = exposure ~ . - y - exposure_prob, mc_col = "mcname", sc_col = "scenario")
z %>% compute_ipw(treatment = "exposure", outcome = "y", formula = exposure ~ . - y - exposure_prob, mc_col = "mcname", sc_col = "scenario")
xx %>% compute_ipw(treatment = "exposure", outcome = "y", formula = exposure ~ . - y - exposure_prob)
source('~/Documents/GitHub/propensityml/R/weighting.R', echo=TRUE)
xx %>% add_ipw_wt(treatment = "exposure", formula = exposure ~ . - y - exposure_prob)
library(data.table)
xx %>% add_ipw_wt(treatment = "exposure", formula = exposure ~ . - y - exposure_prob)
xx %>% add_ipw_wt(treatment = "exposure", formula = exposure ~ . - y - exposure_prob) %>% .[, .(IPW = mean(ipw_wt * y))]
xx %>% add_ipw_wt(treatment = "exposure", formula = exposure ~ . - y - exposure_prob) %>% .[, .(IPW = mean(ipw_wt * y)), by = c(NULL, NULL)]
xx %>% add_ipw_wt(treatment = "exposure", formula = exposure ~ . - y - exposure_prob) %>% .[, .(IPW = mean(ipw_wt * y)), by = NULL]
xx %>% add_ipw_wt(treatment = "exposure", formula = exposure ~ . - y - exposure_prob) %>% .[, .(IPW = mean(ipw_wt * y)), by = list(NULL, NULL)]
library(propensityml)
xx %>% add_ipw_wt(treatment = "exposure", formula = exposure ~ . - y - exposure_prob) %>% .[, .(IPW = mean(ipw_wt * y)), by = list(NULL, NULL)]
library(propensityml)
library(propensityml)
xx %>% compute_ipw(treatment = "exposure", outcome = "y", formula = exposure ~ . - y - exposure_prob)
library(propensityml)
xx %>% compute_ipw(treatment = "exposure", outcome = "y", formula = exposure ~ . - y - exposure_prob)
z %>% compute_ipw(treatment = "exposure", outcome = "y", formula = exposure ~ . - y - exposure_prob, mc_col = "mcname", sc_col = "scenario")
library(propensityml)
library(propensityml)
x <- mc_setoguchi(10, 1000, scenario = c("A", "B", "F", "G"))
x
z <- sim_outcome(1000)
z %>% compute_ipw(treatment = 1000, outcome = "y", formula = exposure ~ . - y - exposure_prob, mc_col = "mcname", sc_col = "scenario")
x %>% compute_ipw(treatment = 1000, outcome = "y", formula = exposure ~ . - y - exposure_prob, mc_col = "mcname", sc_col = "scenario")
x %>% compute_ipw(treatment = "exposure", outcome = "y", formula = exposure ~ . - y - exposure_prob, mc_col = "mcname", sc_col = "scenario")
z %>% compute_ipw(treatment = "exposure", outcome = "y", formula = exposure ~ . - y - exposure_prob)
library(propensityml)
z %>% compute_sipw(treatment = "exposure", outcome = "y", formula = exposure ~ . - y - exposure_prob)
x %>% compute_sipw(treatment = "exposure", outcome = "y", formula = exposure ~ . - y - exposure_prob, mc_col = "mcname", sc_col = "scenario")
z %>% add_iptw(treatment = "exposure", formula = exposure ~ . - y - exposure_prob, mc_col = "mcname", sc_col = "scenario")
x %>% add_iptw(treatment = "exposure", formula = exposure ~ . - y - exposure_prob, mc_col = "mcname", sc_col = "scenario")
z %>% compute_asam(treatment = "exposure", outcome = "y", formula = exposure ~ . - y - exposure_prob, weighting = "IPW")
x %>% compute_ipw(treatment = "exposure", outcome = "y", formula = exposure ~ . - y - exposure_prob, mc_col = "mcname", sc_col = "scenario")
x
merge(x, x %>% compute_ipw(treatment = "exposure", outcome = "y", formula = exposure ~ . - y - exposure_prob, mc_col = "mcname", sc_col = "scenario"), by = c("mcname", "scenario"))
?compute_ipw
?compute_sipw
library(propensityml)
x %>% compute_asam(treatment = "exposure", outcome = "y", formula = exposure ~ . - y - exposure_prob, weighting = "IPW", mc_col = "mcname", sc_col = "scenario")
x
library(propensityml)
x <- mc_setoguchi(10, 100, scenario = c("A", "B", "F", "G"))
x
z <- sim_outcome(1000)
x
doMC::registerDoMC(8)
x %>% compute_asam(treatment = "exposure", outcome = "y", exclude = "exposure_prob", formula = exposure ~ . - y - exposure_prob, mc_col = "mcname", sc_col = "scenario")
library(propensityml)
x
x %>% compute_asam(treatment = "exposure", outcome = "y", exclude = "exposure_prob", formula = exposure ~ . - y - exposure_prob, mc_col = "mcname", sc_col = "scenario")
library(propensityml)
x %>% compute_asam(treatment = "exposure", outcome = "y", exclude = "exposure_prob", formula = exposure ~ . - y - exposure_prob, mc_col = "mcname", sc_col = "scenario")
library(propensityml)
x %>% compute_asam(treatment = "exposure", outcome = "y", exclude = "exposure_prob", formula = exposure ~ . - y - exposure_prob, mc_col = "mcname", sc_col = "scenario")
x
x %>% compute_asam(treatment = "exposure", outcome = "y", exclude = "exposure_prob", formula = exposure ~ . - y - exposure_prob, mc_col = "mcname", sc_col = "scenario") %>% tibble::tibble()
library(propensityml)
x %>% compute_asam(treatment = "exposure", outcome = "y", exclude = "exposure_prob", formula = exposure ~ . - y - exposure_prob, mc_col = "mcname", sc_col = "scenario")
library(propensityml)
x %>% compute_asam(treatment = "exposure", outcome = "y", exclude = "exposure_prob", formula = exposure ~ . - y - exposure_prob, mc_col = "mcname", sc_col = "scenario")
library(propensityml)
x %>% compute_asam(treatment = "exposure", outcome = "y", exclude = "exposure_prob", formula = exposure ~ . - y - exposure_prob, mc_col = "mcname", sc_col = "scenario")
library(propensityml)
x %>% compute_asam(treatment = "exposure", outcome = "y", exclude = "exposure_prob", formula = exposure ~ . - y - exposure_prob, mc_col = "mcname", sc_col = "scenario")
library(propensityml)
x %>% compute_asam(treatment = "exposure", outcome = "y", exclude = "exposure_prob", formula = exposure ~ . - y - exposure_prob, mc_col = "mcname", sc_col = "scenario")
library(propensityml)
x %>% compute_asam(treatment = "exposure", outcome = "y", exclude = "exposure_prob", formula = exposure ~ . - y - exposure_prob, mc_col = "mcname", sc_col = "scenario")
library(propensityml)
x %>% compute_asam(treatment = "exposure", outcome = "y", exclude = "exposure_prob", formula = exposure ~ . - y - exposure_prob, mc_col = "mcname", sc_col = "scenario")
x %>% compute_asam(treatment = "exposure", outcome = "y", exclude = "exposure_prob", formula = exposure ~ . - y - exposure_prob, method = "rf", mc_col = "mcname", sc_col = "scenario")
library(propensityml)
library(propensityml)
library(propensityml)
z
z %>% compute_asam(treatment = "exposure", outcome = "y", exclude = "exposure_prob", formula = exposure ~ . - y - exposure_prob)
library(propensityml)
x %>% compute_asam(treatment = "exposure", outcome = "y", exclude = "exposure_prob", formula = exposure ~ . - y - exposure_prob, mc_col = "mcname", sc_col = "scenario")
z %>% compute_asam(treatment = "exposure", outcome = "y", exclude = "exposure_prob", formula = exposure ~ . - y - exposure_prob)
is.null(c(NULL, NULL))
all(is.null(c(NULL, NULL)))
any(is.null(c(NULL, NULL)))
is.null(c(NULL, 1))
is.null(c(NULL, "1"))
library(propensityml)
x %>% compute_asam(treatment = "exposure", outcome = "y", exclude = "exposure_prob", formula = exposure ~ . - y - exposure_prob, mc_col = "mcname", sc_col = "scenario")
library(propensityml)
x %>% compute_asam(treatment = "exposure", outcome = "y", exclude = "exposure_prob", formula = exposure ~ . - y - exposure_prob, mc_col = "mcname", sc_col = "scenario")
z %>% compute_asam(treatment = "exposure", outcome = "y", exclude = "exposure_prob", formula = exposure ~ . - y - exposure_prob)
library(propensityml)
library(propensityml)
library(propensityml)
library(propensityml)
x <- mc_setoguchi(10, 100, scenario = c("A", "B", "F", "G"))
x
x %>% compute_ipw(treatment = "exposure", outcome = "y", formula = exposure ~ . - y - exposure_prob, mc_col = "mcname", sc_col = "scenario")
x %>% add_iptw(treatment = "exposure", formula = exposure ~ . - y - exposure_prob, mc_col = "mcname", sc_col = "scenario")
x %>% add_propensity(treatment = "exposure", formula = exposure ~ . - y - exposure_prob, mc_col = "mcname", sc_col = "scenario")
x %>% add_propensity(formula = exposure ~ . - y - exposure_prob, mc_col = "mcname", sc_col = "scenario")
library(propensityml)
x %>% add_iptw(treatment = "exposure", formula = exposure ~ . - y - exposure_prob, mc_col = "mcname", sc_col = "scenario")
x %>% compute_ipw(treatment = "exposure", outcome = "y", formula = exposure ~ . - y - exposure_prob, mc_col = "mcname", sc_col = "scenario")
x %>% compute_asam(treatment = "exposure", outcome = "y", exclude = "exposure_prob", formula = exposure ~ . - y - exposure_prob, mc_col = "mcname", sc_col = "scenario")
library(propensityml)
library(propensityml)
x <- mc_setoguchi(10, 100, scenario = c("A", "B", "F", "G"))
x %>% add_iptw(treatment = "exposure", formula = exposure ~ . - y - exposure_prob, mc_col = "mcname", sc_col = "scenario")
library(propensityml)
x %>% add_iptw(treatment = "exposure", formula = exposure ~ . - y - exposure_prob, mc_col = "mcname", sc_col = "scenario")
library(propensityml)
x %>% add_iptw(treatment = "exposure", formula = exposure ~ . - y - exposure_prob, mc_col = "mcname", sc_col = "scenario")
library(propensityml)
library(propensityml)
library(propensityml)
x <- mc_setoguchi(10, 100, scenario = c("A", "B", "F", "G"))
x
x %>% add_weighting(treatment = "exposure", formula = exposure ~ . - y - exposure_prob, mc_col = "mcname", sc_col = "scenario")
library(propensityml)
x %>% compute_ipw(ttreatment = "exposure", outcome = "y", formula = exposure ~ . - y - exposure_prob, mc_col = "mcname", sc_col = "scenario")
x %>% compute_ipw(treatment = "exposure", outcome = "y", formula = exposure ~ . - y - exposure_prob, mc_col = "mcname", sc_col = "scenario")
wt <- x %>% add_weighting(treatment = "exposure", formula = exposure ~ . - y - exposure_prob, mc_col = "mcname", sc_col = "scenario")
wt
wt %>% compute_ipw(treatment = "exposure", outcome = "y", iptw = "iptw", formula = exposure ~ . - y - exposure_prob, mc_col = "mcname", sc_col = "scenario")
weight
library(propensityml)
wt %>% compute_ipw(treatment = "exposure", outcome = "y", weight = "iptw", formula = exposure ~ . - y - exposure_prob, mc_col = "mcname", sc_col = "scenario")
wt[,.(IPW = iptw * y), by = .(mcname, scenario)]
x %>% compute_ipw(treatment = "exposure", outcome = "y", formula = exposure ~ . - y - exposure_prob, mc_col = "mcname", sc_col = "scenario")
library(propensityml)
x %>% compute_ipw(treatment = "exposure", outcome = "y", formula = exposure ~ . - y - exposure_prob, mc_col = "mcname", sc_col = "scenario")
wt[,.(IPW = iptw * y), by = .(mcname, scenario)]
wt %>% compute_ipw(treatment = "exposure", outcome = "y", weight = "iptw", formula = exposure ~ . - y - exposure_prob, mc_col = "mcname", sc_col = "scenario")
wt[,.(IPW = mean(iptw * y)), by = .(mcname, scenario)]
x %>% add_weighting(treatment = "exposure", formula = exposure ~ . - y - exposure_prob, mc_col = "mcname", sc_col = "scenario")
library(propensityml)
wt %>% compute_sipw(treatment = "exposure", outcome = "y", weight = "iptw", formula = exposure ~ . - y - exposure_prob, mc_col = "mcname", sc_col = "scenario")
x %>% compute_sipw(treatment = "exposure", outcome = "y", formula = exposure ~ . - y - exposure_prob, mc_col = "mcname", sc_col = "scenario")
wt %>% compute_sipw(treatment = "exposure", outcome = "y", weight = "iptw", formula = exposure ~ . - y - exposure_prob, mc_col = "mcname", sc_col = "scenario")
library(propensityml)
x %>% compute_sipw(treatment = "exposure", outcome = "y", formula = exposure ~ . - y - exposure_prob, mc_col = "mcname", sc_col = "scenario")
library(propensityml)
x %>% compute_sipw(treatment = "exposure", outcome = "y", formula = exposure ~ . - y - exposure_prob, mc_col = "mcname", sc_col = "scenario")
wt %>% compute_sipw(treatment = "exposure", outcome = "y", weight = "iptw", formula = exposure ~ . - y - exposure_prob, mc_col = "mcname", sc_col = "scenario")
wt %>% compute_ipw(treatment = "exposure", outcome = "y", weight = "iptw", formula = exposure ~ . - y - exposure_prob, mc_col = "mcname", sc_col = "scenario")
wt %>% compute_ipw(treatment = "exposure", outcome = "y", weight = "iptw", formula = exposure ~ . - y - exposure_prob, mc_col = "mcname", sc_col = "scenario") %>% .[,.(mean(IPW)), by = scenario]