forked from eyra/fertility-prediction-challenge
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy path.Rhistory
512 lines (512 loc) · 26.2 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
model <- spikeSlabGAM(new_child ~(partner_2020+birthyear_bg)^2+mig_by_generation+
having_children_future+years_next_children+desired_nr_add_children+
civil_status + type_dwelling+urban_type+religious_participation+long_disease+oplcat_2020,
data = model_est, family = "binomial")
summary(model)
summary(model)
model <- spikeSlabGAM(new_child ~(partner_2020+birthyear_bg+oplcat_2020)^2+mig_by_generation+
having_children_future+years_next_children+desired_nr_add_children+
civil_status + type_dwelling+urban_type+religious_participation+long_disease,
data = model_est, family = "binomial")
summary(model)
model <- spikeSlabGAM(new_child ~(partner_2020+birthyear_bg)^2+mig_by_generation+oplcat_2020+
having_children_future+years_next_children+desired_nr_add_children+
(civil_status + type_dwelling)^2+urban_type+religious_participation+long_disease,
data = model_est, family = "binomial")
summary(model)
model <- spikeSlabGAM(new_child ~(partner_2020+birthyear_bg)^2+mig_by_generation+oplcat_2020+
having_children_future+years_next_children+desired_nr_add_children+
(civil_status + religious_participation)^2+urban_type+religious_participation+long_disease,
data = model_est, family = "binomial")
summary(model)
model <- spikeSlabGAM(new_child ~(partner_2020+birthyear_bg)^2+oplcat_2020+
having_children_future+years_next_children+desired_nr_add_children+type_dwelling+
(civil_status + mig_by_generation)^2+urban_type+religious_participation+long_disease,
data = model_est, family = "binomial")
summary(model)
aantalki
data_red$aantalki
table(data_red$aantalki)
data_red$aantalki[data_red$aantalki>2]
data_red$aantalki[data_red$aantalki>2]<-"3+"
data_red$aantalki
model_est <- model_df[, c("new_child","having_children_future","years_next_children",
"desired_nr_add_children","birthyear_bg","partner_2020","gender_bg",
"urban_type", "civil_status","religious_participation",
"employment_status", "type_dwelling","mig_by_generation", "long_disease",
"oplcat_2020","aantalki")]
model <- spikeSlabGAM(new_child ~(partner_2020+birthyear_bg)^2+oplcat_2020+mig_by_generation+
having_children_future+years_next_children+desired_nr_add_children+type_dwelling+
(civil_status + aantalki)^2+urban_type+religious_participation+long_disease,
data = model_est, family = "binomial")
model_df <- merge(data_red, out, by = "nomem_encr")
model_est <- model_df[, c("new_child","having_children_future","years_next_children",
"desired_nr_add_children","birthyear_bg","partner_2020","gender_bg",
"urban_type", "civil_status","religious_participation",
"employment_status", "type_dwelling","mig_by_generation", "long_disease",
"oplcat_2020","aantalki")]
model_est<-model_est[complete.cases(model_est),]
model <- spikeSlabGAM(new_child ~(partner_2020+birthyear_bg)^2+oplcat_2020+mig_by_generation+
having_children_future+years_next_children+desired_nr_add_children+type_dwelling+
(civil_status + aantalki)^2+urban_type+religious_participation+long_disease,
data = model_est, family = "binomial")
summary(model)
plot(model)
model_est <- model_df[, c("new_child","having_children_future","years_next_children",
"desired_nr_add_children","birthyear_bg","partner_2020","gender_bg",
"urban_type", "civil_status","religious_participation",
"employment_status", "type_dwelling","mig_by_generation", "long_disease",
"oplcat_2020","aantalki", "anxiety","presence_debt")]
model <- spikeSlabGAM(new_child ~(partner_2020+birthyear_bg)^2+oplcat_2020+mig_by_generation+presence_debt
having_children_future+years_next_children+desired_nr_add_children+type_dwelling+
model_est<-model_est[complete.cases(model_est),]
model <- spikeSlabGAM(new_child ~(partner_2020+birthyear_bg)^2+oplcat_2020+mig_by_generation+presence_debt+
having_children_future+years_next_children+desired_nr_add_children+type_dwelling+
(civil_status + aantalki)^2+urban_type+religious_participation+long_disease+anxiety,
data = model_est, family = "binomial")
data_red$cp20l019
data_red$cp20l010
data_red$presence_debt
model_est <- model_df[, c("new_child","having_children_future","years_next_children",
"desired_nr_add_children","birthyear_bg","partner_2020","gender_bg",
"urban_type", "civil_status","religious_participation",
"employment_status", "type_dwelling","mig_by_generation", "long_disease",
"oplcat_2020","aantalki", "anxiety")]
model_est<-model_est[complete.cases(model_est),]
model <- spikeSlabGAM(new_child ~(partner_2020+birthyear_bg)^2+oplcat_2020+mig_by_generation+
having_children_future+years_next_children+desired_nr_add_children+type_dwelling+
(civil_status + aantalki)^2+urban_type+religious_participation+long_disease+anxiety,
data = model_est, family = "binomial")
summary(model)
model <- spikeSlabGAM(new_child ~(religious_participation+birthyear_bg)^2+oplcat_2020+mig_by_generation+partner_2020+
having_children_future+years_next_children+desired_nr_add_children+type_dwelling+
(civil_status + aantalki)^2+urban_type+long_disease+anxiety,
data = model_est, family = "binomial")
summary(model)
plot(model)
model <- spikeSlabGAM(new_child ~(religious_participation+mig_by_generation)^2+birthyear_bg+oplcat_2020+mig_by_generation+partner_2020+
having_children_future+years_next_children+desired_nr_add_children+type_dwelling+
(civil_status + aantalki)^2+urban_type+long_disease+anxiety,
data = model_est, family = "binomial")
summary(model)
plot(model)
data_red$urban_type2<-data_red$urban_type
data_red$urban_type2
data_red$urban_type2[data_red$urban_type2!="Not urban"]
data_red$urban_type2[data_red$urban_type2!="Not urban"]<-"Urban"
data_red$urban_type2<-as.character(data_red$urban_type)
data_red$urban_type2[data_red$urban_type2!="Not urban"]<-"Urban"
data_red$urban_type2
model_est <- model_df[, c("new_child","having_children_future","years_next_children",
"desired_nr_add_children","birthyear_bg","partner_2020","gender_bg",
"urban_type", "civil_status","religious_participation",
"employment_status", "type_dwelling","mig_by_generation", "long_disease",
"oplcat_2020","aantalki", "anxiety","log_net_household_income")]
model_est<-model_est[complete.cases(model_est),]
model <- spikeSlabGAM(new_child ~(religious_participation+mig_by_generation)^2+birthyear_bg+oplcat_2020+mig_by_generation+partner_2020+
having_children_future+years_next_children+desired_nr_add_children+type_dwelling+
(civil_status + aantalki)^2+urban_type2+long_disease+anxiety,
data = model_est, family = "binomial")
model_est <- model_df[, c("new_child","having_children_future","years_next_children",
"desired_nr_add_children","birthyear_bg","partner_2020","gender_bg",
"urban_type2", "civil_status","religious_participation",
"employment_status", "type_dwelling","mig_by_generation", "long_disease",
"oplcat_2020","aantalki", "anxiety","log_net_household_income")]
model_est<-model_est[complete.cases(model_est),]
model <- spikeSlabGAM(new_child ~(religious_participation+mig_by_generation)^2+birthyear_bg+oplcat_2020+mig_by_generation+partner_2020+
having_children_future+years_next_children+desired_nr_add_children+type_dwelling+
(civil_status + aantalki)^2+urban_type2+long_disease+anxiety+log_net_household_income,
data = model_est, family = "binomial")
model_est <- model_df[, c("new_child","having_children_future","years_next_children",
"desired_nr_add_children","birthyear_bg","partner_2020","gender_bg",
"urban_type2", "civil_status","religious_participation",
"employment_status", "type_dwelling","mig_by_generation", "long_disease",
"oplcat_2020","aantalki", "anxiety","log_net_household_income")]
model_est<-model_est[complete.cases(model_est),]
model_df <- merge(data_red, out, by = "nomem_encr")
model_est <- model_df[, c("new_child","having_children_future","years_next_children",
"desired_nr_add_children","birthyear_bg","partner_2020","gender_bg",
"urban_type2", "civil_status","religious_participation",
"employment_status", "type_dwelling","mig_by_generation", "long_disease",
"oplcat_2020","aantalki", "anxiety","log_net_household_income")]
model_est<-model_est[complete.cases(model_est),]
model <- spikeSlabGAM(new_child ~(religious_participation+mig_by_generation)^2+birthyear_bg+oplcat_2020+mig_by_generation+partner_2020+
having_children_future+years_next_children+desired_nr_add_children+type_dwelling+
(civil_status + aantalki)^2+urban_type2+long_disease+anxiety+log_net_household_income,
data = model_est, family = "binomial")
summary(model)
summary(model)
model_est <- model_df[, c("new_child","having_children_future","years_next_children",
"desired_nr_add_children","birthyear_bg","partner_2020","gender_bg",
"urban_type2", "civil_status","religious_participation",
"employment_status", "type_dwelling","mig_by_generation", "long_disease",
"oplcat_2020","aantalki", "anxiety")]
model_est<-model_est[complete.cases(model_est),]
model <- spikeSlabGAM(new_child ~(religious_participation+mig_by_generation)^2+birthyear_bg+oplcat_2020+mig_by_generation+partner_2020+
having_children_future+years_next_children+desired_nr_add_children+type_dwelling+
(civil_status + aantalki)^2+urban_type2+long_disease+anxiety,
data = model_est, family = "binomial")
summary(model)
model <- spikeSlabGAM(new_child ~(religious_participation+mig_by_generation)^2+birthyear_bg+oplcat_2020+mig_by_generation+
having_children_future+years_next_children+desired_nr_add_children+
(civil_status + aantalki)^2+urban_type2+long_disease+anxiety+(partner_2020+type_dwelling)^2,
data = model_est, family = "binomial")
summary(model)
summary(model)
str(model$mcmc)
model$samples$beta
plot(model$samples$beta)
plot(model$samples$beta)
plot(model$samples$beta)
?spikeSlabGAM
mcmc <- list(nChains = 3, burnin = 1000, chainLength = 4000,
thin = 3, reduceRet = TRUE)
model <- spikeSlabGAM(new_child ~(religious_participation+mig_by_generation)^2+birthyear_bg+oplcat_2020+mig_by_generation+
having_children_future+years_next_children+desired_nr_add_children+
(civil_status + aantalki)^2+urban_type2+long_disease+anxiety+(partner_2020+type_dwelling),
data = model_est, family = "binomial", mcmc = mcmc)
plot(model$samples$beta)
summary(model)
plot(model)
model$fitted
model$fitted[,2]
plot(model$fitted[,2])
plot(model$fitted[,2])
plot(model$fitted[,2])
boxplot(model$fitted[,2]model_est$new_child)
boxplot(model$fitted[,2]~model_est$new_child)
library(ROCit)
obj <- rocit(class = model_est$new_child, score = model$fitted[,2])
plot(obj)
summary(obj)
model <- readRDS("~/GitHub/fertility-prediction-challenge/model.rds")
obj <- rocit(class = model$y, score = model$fitted.values)
model$fitted.values
model <- readRDS("~/GitHub/fertility-prediction-challenge/model.rds")
model
model$y
ksplot(obj)
obj$neg_D
table(model$y, ifelse(model$fitted.values>0.25,1,0))
table(model$y, ifelse(model$fitted[,2]>0.25,1,0))
table(model$y, ifelse(model$fitted[,2]>0.15,1,0))
table(model$y, ifelse(model$fitted[,2]>0.2,1,0))
obj <- rocit(class = model_est$new_child, score = model$fitted[,2])
plot(obj)
model$fitted[,2]
model_est$new_child
model <- spikeSlabGAM(new_child ~(religious_participation+mig_by_generation)^2+birthyear_bg+oplcat_2020+mig_by_generation+
having_children_future+years_next_children+desired_nr_add_children+
(civil_status + aantalki)^2+urban_type2+long_disease+anxiety+(partner_2020+type_dwelling),
data = model_est, family = "binomial", mcmc = mcmc)
obj <- rocit(class = model_est$new_child, score = model$fitted[,2])
plot(obj)
class <- model_est$new_child
score <- model$fitted[,2]
# -------------------------------------------------------------
measure <- measureit(score = score, class = class,
measure = c("ACC", "SENS", "FSCR"))
names(measure)
#> [1] "Cutoff" "Depth" "TP" "FP" "TN" "FN" "ACC" "SENS"
#> [9] "FSCR"
plot(measure$ACC~measure$Cutoff, type = "l")
table(model$y, ifelse(model$fitted[,2]>0.2,1,0))
table(model$y, ifelse(model$fitted[,2]>0.4,1,0))
table(model$y, ifelse(model$fitted[,2]>0.45,1,0))
measure
measure$Cutoff[which.max(measure$ACC)]
table(model$y, ifelse(model$fitted[,2]>0.4711597,1,0))
model <- spikeSlabGAM(new_child ~(religious_participation+mig_by_generation)^2+(gender_bg+birthyear_bg)^2+oplcat_2020+mig_by_generation+
having_children_future+years_next_children+desired_nr_add_children+
(civil_status + aantalki)^2+urban_type2+long_disease+anxiety+(partner_2020+type_dwelling),
data = model_est, family = "binomial", mcmc = mcmc)
summary(model)
class <- model_est$new_child
score <- model$fitted[,2]
# -------------------------------------------------------------
measure <- measureit(score = score, class = class,
measure = c("ACC", "SENS", "FSCR"))
measure$Cutoff[which.max(measure$ACC)]
max(measure$ACC)
plot(model)
summary(model)
#> [1] "Cutoff" "Depth" "TP" "FP" "TN" "FN" "ACC" "SENS"
#> [9] "FSCR"
plot(measure$ACC~measure$Cutoff, type = "l")
install.packages("BoomSpikeSlab")
model2 <- spikeSlabGAM(new_child ~(religious_participation+mig_by_generation)^2+(gender_bg+birthyear_bg)^2+oplcat_2020+mig_by_generation+
#having_children_future+years_next_children+desired_nr_add_children+
(civil_status + aantalki)+urban_type2+long_disease+anxiety+(partner_2020+type_dwelling),
data = model_est, family = "binomial", mcmc = mcmc)
summary(model)
summary(model2)
summary(model2)
class <- model_est$new_child
score <- model2$fitted[,2]
# -------------------------------------------------------------
measure <- measureit(score = score, class = class,
measure = c("ACC", "SENS", "FSCR"))
names(measure)
#> [1] "Cutoff" "Depth" "TP" "FP" "TN" "FN" "ACC" "SENS"
#> [9] "FSCR"
plot(measure$ACC~measure$Cutoff, type = "l")
measure$Cutoff[which.max(measure$ACC)]
max(measure$ACC)
plot(model2)
model <- spikeSlabGAM(new_child ~(religious_participation+mig_by_generation)^2+(gender_bg+birthyear_bg)^2+oplcat_2020+mig_by_generation+
having_children_future+years_next_children+desired_nr_add_children+employment_status+
(civil_status + aantalki)+urban_type2+long_disease+anxiety+(partner_2020+type_dwelling),
data = model_est, family = "binomial", mcmc = mcmc)
summary(model)
class <- model_est$new_child
score <- model$fitted[,2]
# -------------------------------------------------------------
measure <- measureit(score = score, class = class,
measure = c("ACC", "SENS", "FSCR"))
names(measure)
#> [1] "Cutoff" "Depth" "TP" "FP" "TN" "FN" "ACC" "SENS"
#> [9] "FSCR"
plot(measure$ACC~measure$Cutoff, type = "l")
measure$Cutoff[which.max(measure$ACC)]
max(measure$ACC)
model2 <- spikeSlabGAM(new_child ~(religious_participation+mig_by_generation)+(gender_bg+birthyear_bg)^2+oplcat_2020+employment_status+
#having_children_future+years_next_children+desired_nr_add_children+
(civil_status + aantalki)+urban_type2+long_disease+anxiety+(partner_2020+type_dwelling),
data = model_est, family = "binomial", mcmc = mcmc)
summary(model2)
plot(model$samples$beta)
boxplot(model$fitted[,2]~model_est$new_child)
library(ROCit)
obj <- rocit(class = model_est$new_child, score = model$fitted[,2])
plot(obj)
summary(obj)
ksplot(obj)
obj$neg_D
table(model$y, ifelse(model$fitted[,2]>0.4711597,1,0))
class <- model_est$new_child
score <- model2$fitted[,2]
# -------------------------------------------------------------
measure <- measureit(score = score, class = class,
measure = c("ACC", "SENS", "FSCR"))
names(measure)
#> [1] "Cutoff" "Depth" "TP" "FP" "TN" "FN" "ACC" "SENS"
#> [9] "FSCR"
plot(measure$ACC~measure$Cutoff, type = "l")
max(measure$ACC)
model2 <- spikeSlabGAM(new_child ~(religious_participation+mig_by_generation)+(partner_2020+gender_bg+birthyear_bg)^2+oplcat_2020+employment_status+
#having_children_future+years_next_children+desired_nr_add_children+
(civil_status + aantalki)^2+urban_type2+long_disease+anxiety+(partner_2020+type_dwelling)^2,
data = model_est, family = "binomial", mcmc = mcmc)
summary(model2)
plot(model2)
class <- model_est$new_child
score <- model2$fitted[,2]
# -------------------------------------------------------------
measure <- measureit(score = score, class = class,
measure = c("ACC", "SENS", "FSCR"))
names(measure)
#> [1] "Cutoff" "Depth" "TP" "FP" "TN" "FN" "ACC" "SENS"
#> [9] "FSCR"
plot(measure$ACC~measure$Cutoff, type = "l")
max(measure$ACC)
class <- model_est$new_child
score <- model2$fitted[,2]
# -------------------------------------------------------------
measure <- measureit(score = score, class = class,
measure = c("ACC", "SENS", "FSCR"))
#> [1] "Cutoff" "Depth" "TP" "FP" "TN" "FN" "ACC" "SENS"
#> [9] "FSCR"
plot(measure$ACC~measure$Cutoff, type = "l")
summary(model2)
model2 <- spikeSlabGAM(new_child ~(religious_participation)+(partner_2020+gender_bg+birthyear_bg)^2+oplcat_2020+employment_status+
#having_children_future+years_next_children+desired_nr_add_children+
(civil_status + aantalki+religious_participation)^2+long_disease+anxiety+(urban_type2+type_dwelling),
data = model_est, family = "binomial", mcmc = mcmc)
summary(model2)
plot(model2)
model2 <- spikeSlabGAM(new_child ~(religious_participation)+partner_2020+ (gender_bg+birthyear_bg)^2+oplcat_2020+employment_status+
#having_children_future+years_next_children+desired_nr_add_children+
(civil_status + aantalki+religious_participation)^2+long_disease+anxiety+(urban_type2+type_dwelling)^2,
data = model_est, family = "binomial", mcmc = mcmc)
summary(model2)
model_est <- model_df[, c("new_child","having_children_future","years_next_children",
"desired_nr_add_children","birthyear_bg","partner_2020","gender_bg",
"urban_type2", "civil_status","religious_participation",
"employment_status", "type_dwelling","mig_by_generation", "long_disease",
"oplcat_2020","aantalki", "anxiety","cp20l010")]
model_est<-model_est[complete.cases(model_est),]
model2 <- spikeSlabGAM(new_child ~(religious_participation)+partner_2020+ (gender_bg+birthyear_bg)^2+oplcat_2020+employment_status+
#having_children_future+years_next_children+desired_nr_add_children+
(civil_status + aantalki)^2+long_disease+anxiety+(urban_type2+type_dwelling)+cp20l010,
data = model_est, family = "binomial", mcmc = mcmc)
summary(model2)
plot(model2)
class <- model_est$new_child
score <- model2$fitted[,2]
# -------------------------------------------------------------
measure <- measureit(score = score, class = class,
measure = c("ACC", "SENS", "FSCR"))
names(measure)
#> [1] "Cutoff" "Depth" "TP" "FP" "TN" "FN" "ACC" "SENS"
#> [9] "FSCR"
plot(measure$ACC~measure$Cutoff, type = "l")
max(measure$ACC)
data_red$cr20m089
table(data_red$cr20m089)
table(data_red$cs20m063)
table(data_red$cs20m283)
table(data_red$cs20m285)
table(data_red$cs20m286)
table(data_red$cs20m287)
data_red$rely <- factor(data_red$cs20m286)
table(data_red$cs20m001)
model_est <- model_df[, c("new_child","having_children_future","years_next_children",
"desired_nr_add_children","birthyear_bg","partner_2020","gender_bg",
"urban_type2", "civil_status","religious_participation",
"employment_status", "type_dwelling","mig_by_generation", "long_disease",
"oplcat_2020","rely", "anxiety")]
data_red$rely <- factor(data_red$cs20m286)
model_df <- merge(data_red, out, by = "nomem_encr")
model_est <- model_df[, c("new_child","having_children_future","years_next_children",
"desired_nr_add_children","birthyear_bg","partner_2020","gender_bg",
"urban_type2", "civil_status","religious_participation",
"employment_status", "type_dwelling","mig_by_generation", "long_disease",
"oplcat_2020","rely", "anxiety")]
model <- spikeSlabGAM(new_child ~(religious_participation+mig_by_generation)^2+(gender_bg+birthyear_bg)^2+oplcat_2020+mig_by_generation+
having_children_future+years_next_children+desired_nr_add_children+employment_status+
(civil_status + aantalki)+urban_type2+long_disease+anxiety+(partner_2020+type_dwelling)+rely,
data = model_est, family = "binomial", mcmc = mcmc)
model_est <- model_df[, c("new_child","having_children_future","years_next_children",
"desired_nr_add_children","birthyear_bg","partner_2020","gender_bg",
"urban_type2", "civil_status","religious_participation",
"employment_status", "type_dwelling","mig_by_generation", "long_disease",
"oplcat_2020","rely", "anxiety")]
model_est<-model_est[complete.cases(model_est),]
mcmc <- list(nChains = 3, burnin = 1000, chainLength = 4000,
thin = 3, reduceRet = TRUE)
model2 <- spikeSlabGAM(new_child ~(religious_participation)+partner_2020+ (gender_bg+birthyear_bg)^2+oplcat_2020+employment_status+
#having_children_future+years_next_children+desired_nr_add_children+
(civil_status + aantalki)^2+long_disease+anxiety+(urban_type2+type_dwelling)+rely,
data = model_est, family = "binomial", mcmc = mcmc)
names(model_est)
model_est <- model_df[, c("new_child","having_children_future","years_next_children",
"desired_nr_add_children","birthyear_bg","partner_2020","gender_bg",
"urban_type2", "civil_status","religious_participation",
"employment_status", "type_dwelling","mig_by_generation", "long_disease",
"oplcat_2020","rely", "anxiety","model_est")]
model_est <- model_df[, c("new_child","having_children_future","years_next_children",
"desired_nr_add_children","birthyear_bg","partner_2020","gender_bg",
"urban_type2", "civil_status","religious_participation",
"employment_status", "type_dwelling","mig_by_generation", "long_disease",
"oplcat_2020","rely", "anxiety","aantalki")]
model_est<-model_est[complete.cases(model_est),]
mcmc <- list(nChains = 3, burnin = 1000, chainLength = 4000,
thin = 3, reduceRet = TRUE)
model <- spikeSlabGAM(new_child ~(religious_participation+mig_by_generation)^2+(gender_bg+birthyear_bg)^2+oplcat_2020+mig_by_generation+
having_children_future+years_next_children+desired_nr_add_children+employment_status+
(civil_status + aantalki)+urban_type2+long_disease+anxiety+(partner_2020+type_dwelling)+rely,
data = model_est, family = "binomial", mcmc = mcmc)
model2 <- spikeSlabGAM(new_child ~(religious_participation)+partner_2020+ (gender_bg+birthyear_bg)^2+oplcat_2020+employment_status+
#having_children_future+years_next_children+desired_nr_add_children+
(civil_status + aantalki)^2+long_disease+anxiety+(urban_type2+type_dwelling)+rely,
data = model_est, family = "binomial", mcmc = mcmc)
summary(model2)
model_est <- model_df[, c("new_child","having_children_future","years_next_children",
"desired_nr_add_children","birthyear_bg","partner_2020","gender_bg",
"urban_type2", "civil_status","religious_participation",
"employment_status", "type_dwelling","mig_by_generation", "long_disease",
"oplcat_2020","rely", "anxiety","aantalki","log_net_household_income")]
model_est<-model_est[complete.cases(model_est),]
class <- model_est$new_child
score <- model2$fitted[,2]
# -------------------------------------------------------------
measure <- measureit(score = score, class = class,
measure = c("ACC", "SENS", "FSCR"))
names(measure)
#> [1] "Cutoff" "Depth" "TP" "FP" "TN" "FN" "ACC" "SENS"
#> [9] "FSCR"
plot(measure$ACC~measure$Cutoff, type = "l")
measure$Cutoff[which.max(measure$ACC)]
max(measure$ACC)
model2 <- spikeSlabGAM(new_child ~(religious_participation)+partner_2020+ (gender_bg+birthyear_bg)^2+oplcat_2020+employment_status+
#having_children_future+years_next_children+desired_nr_add_children+
(civil_status + aantalki)^2+long_disease+anxiety+(urban_type2+type_dwelling)+rely+log_net_household_income,
data = model_est, family = "binomial", mcmc = mcmc)
summary(model2)
class <- model_est$new_child
score <- model2$fitted[,2]
# -------------------------------------------------------------
measure <- measureit(score = score, class = class,
measure = c("ACC", "SENS", "FSCR"))
names(measure)
#> [1] "Cutoff" "Depth" "TP" "FP" "TN" "FN" "ACC" "SENS"
#> [9] "FSCR"
plot(measure$ACC~measure$Cutoff, type = "l")
max(measure$ACC)
plot(model2)
model_est <- model_df[, c("new_child","having_children_future","years_next_children",
"desired_nr_add_children","birthyear_bg","partner_2020","gender_bg",
"urban_type2", "civil_status","religious_participation",
"employment_status", "type_dwelling","mig_by_generation", "long_disease",
"oplcat_2020","rely", "anxiety","aantalki")]
model_est<-model_est[complete.cases(model_est),]
model2 <- spikeSlabGAM(new_child ~(religious_participation)+partner_2020+ (gender_bg+birthyear_bg)^2+oplcat_2020+employment_status+
#having_children_future+years_next_children+desired_nr_add_children+
(civil_status + aantalki)^2+long_disease+anxiety+(urban_type2+type_dwelling)+rely,
data = model_est, family = "binomial", mcmc = mcmc)
summary(model2)
summary(model2)
plot(model2)
class <- model_est$new_child
score <- model2$fitted[,2]
# -------------------------------------------------------------
measure <- measureit(score = score, class = class,
measure = c("ACC", "SENS", "FSCR"))
names(measure)
#> [1] "Cutoff" "Depth" "TP" "FP" "TN" "FN" "ACC" "SENS"
#> [9] "FSCR"
plot(measure$ACC~measure$Cutoff, type = "l")
max(measure$ACC)
plot(model2$samples$beta)
plot(model2$samples$beta)
plot(model2$samples$gamma)
model2 <- spikeSlabGAM(new_child ~(religious_participation)+partner_2020+ (gender_bg+birthyear_bg)^2+oplcat_2020+employment_status+
#having_children_future+years_next_children+desired_nr_add_children+
(civil_status + aantalki)+long_disease+anxiety+(urban_type2+type_dwelling)+rely,
data = model_est, family = "binomial", mcmc = mcmc)
summary(model2)
class <- model_est$new_child
score <- model2$fitted[,2]
# -------------------------------------------------------------
measure <- measureit(score = score, class = class,
measure = c("ACC", "SENS", "FSCR"))
names(measure)
#> [1] "Cutoff" "Depth" "TP" "FP" "TN" "FN" "ACC" "SENS"
#> [9] "FSCR"
plot(measure$ACC~measure$Cutoff, type = "l")
measure$Cutoff[which.max(measure$ACC)]
max(measure$ACC)
plot(model2)
plot(model2$samples$beta)
model <- spikeSlabGAM(new_child ~(religious_participation+mig_by_generation)^2+(gender_bg+birthyear_bg)^2+oplcat_2020+mig_by_generation+
having_children_future+years_next_children+desired_nr_add_children+employment_status+
(civil_status + aantalki)+urban_type2+long_disease+anxiety+(partner_2020+type_dwelling)+rely,
data = model_est, family = "binomial", mcmc = mcmc, hyperparameters = list(tau2=c(1,0.0005)))
model2 <- spikeSlabGAM(new_child ~(religious_participation)+partner_2020+ (gender_bg+birthyear_bg)^2+oplcat_2020+employment_status+
#having_children_future+years_next_children+desired_nr_add_children+
(civil_status + aantalki)+long_disease+anxiety+(urban_type2+type_dwelling)+rely,
data = model_est, family = "binomial", mcmc = mcmc, hyperparameters = list(tau2=c(1,0.0005)))
plot(model2$samples$beta)
summary(model2)
plot(model2)
class <- model_est$new_child
score <- model2$fitted[,2]
# -------------------------------------------------------------
measure <- measureit(score = score, class = class,
measure = c("ACC", "SENS", "FSCR"))
names(measure)
#> [1] "Cutoff" "Depth" "TP" "FP" "TN" "FN" "ACC" "SENS"
#> [9] "FSCR"
plot(measure$ACC~measure$Cutoff, type = "l")
measure$Cutoff[which.max(measure$ACC)]
max(measure$ACC)