This is an R Markdown Notebook. When you execute code within the notebook, the results appear beneath the code.
Try executing this chunk by clicking the Run button within the chunk or by placing your cursor inside it and pressing Cmd+Shift+Enter.
#print out the results Model 1
fit.weib
Call:
idm(formula01 = formula1 ~ prediabetes + diabetes + sex + smoke +
drink, formula02 = formula2 ~ prediabetes + diabetes + sex +
smoke + drink, data = feb)
Illness-death regression model using Weibull parametrization
to estimate the baseline transition intensities.
number of subjects: 1788
number of events '0 -> 1': 374
number of events '0 -> 2' or '0 -> 1 -> 2': 479
number of covariates: 5 5 5
----
Model converged.
number of iterations: 14
convergence criteria: parameters= 1e-09
: likelihood= 1e-08
: second derivatives= 1e-12
Without covariates With covariates
log-likelihood -3847.996 -3767.299
Parameters of the Weibull distributions: 'S(t) = exp(-(b*t)^a)'
transition 0 -> 1 transition 0 -> 2 transition 1 -> 2
shape (a) 9.25627265 12.71828442 6.91867827
scale (b) 0.01139174 0.01168751 0.01402317
Regression coefficients:
$`transition 0 -> 1`
Factor coef SE coef exp(coef) CI p-value
1 prediabetes 0.3400 0.1128 1.4050 [1.13;1.75] 0.0025750
2 diabetes 0.5055 0.1510 1.6579 [1.23;2.23] 0.0008149
3 sex 0.1969 0.1477 1.2176 [0.91;1.63] 0.1826221
4 smoke -0.5032 0.1282 0.6046 [0.47;0.78] < 1e-04
5 drink -0.2868 0.1495 0.7507 [0.56;1.01] 0.0550085
$`transition 0 -> 2`
Factor coef SE coef exp(coef) CI p-value
6 prediabetes 0.1741 0.1272 1.1902 [0.93;1.53] 0.1711681
7 diabetes 0.3820 0.1679 1.4652 [1.05;2.04] 0.0228810
8 sex -0.1856 0.1586 0.8306 [0.61;1.13] 0.2417547
9 smoke -0.6636 0.1383 0.5150 [0.39;0.68] < 1e-04
10 drink -0.1121 0.1566 0.8939 [0.66;1.21] 0.4738512
$`transition 1 -> 2`
Factor coef SE coef exp(coef) CI p-value
11 prediabetes 0.1472 0.1711 1.1586 [0.83;1.62] 0.3895990
12 diabetes 0.1905 0.2151 1.2099 [0.79;1.84] 0.3757779
13 sex -0.7135 0.2105 0.4899 [0.32;0.74] 0.0007024
14 smoke -0.7572 0.1827 0.4690 [0.33;0.67] < 1e-04
15 drink 0.4168 0.2065 1.5172 [1.01;2.27] 0.0435466
print(summary(fit.weib,digits = 4))
Method: Weibull parametrization
number of subjects: 1788
number of events '0-->1': 374
number of events '0-->2 or 0-->1-->2': 479
number of covariates: 5 5 5
observation deleted due to missing: 1
#print out the results Model 2
fit.weib2
Call:
idm(formula01 = formula1 ~ prediabetes + diabetes + sex + underweight +
obese + smoke + drink, formula02 = formula2 ~ prediabetes +
diabetes + sex + underweight + obese + smoke + drink, data = feb)
Illness-death regression model using Weibull parametrization
to estimate the baseline transition intensities.
number of subjects: 1787
number of events '0 -> 1': 374
number of events '0 -> 2' or '0 -> 1 -> 2': 479
number of covariates: 7 7 7
----
Model converged.
number of iterations: 20
convergence criteria: parameters= 1.1e-08
: likelihood= 2.7e-08
: second derivatives= 9.4e-14
Without covariates With covariates
log-likelihood -3847.886 -3762.253
Parameters of the Weibull distributions: 'S(t) = exp(-(b*t)^a)'
transition 0 -> 1 transition 0 -> 2 transition 1 -> 2
shape (a) 9.29214530 12.73193017 6.90660077
scale (b) 0.01154579 0.01171112 0.01395997
Regression coefficients:
$`transition 0 -> 1`
Factor coef SE coef exp(coef) CI p-value
1 prediabetes 0.3260 0.1128 1.3854 [1.11;1.73] 0.0038573
2 diabetes 0.5054 0.1509 1.6576 [1.23;2.23] 0.0008088
3 sex 0.1828 0.1484 1.2006 [0.90;1.61] 0.2179094
4 underweight 0.2155 0.2493 1.2405 [0.76;2.02] 0.3873206
5 obese -0.2506 0.1099 0.7783 [0.63;0.97] 0.0225435
6 smoke -0.5050 0.1285 0.6035 [0.47;0.78] < 1e-04
7 drink -0.2922 0.1495 0.7466 [0.56;1.00] 0.0506860
$`transition 0 -> 2`
Factor coef SE coef exp(coef) CI p-value
8 prediabetes 0.1615 0.1290 1.1753 [0.91;1.51] 0.2104449
9 diabetes 0.3714 0.1703 1.4498 [1.04;2.02] 0.0291502
10 sex -0.1795 0.1614 0.8357 [0.61;1.15] 0.2662359
11 underweight -0.1379 0.3993 0.8712 [0.40;1.91] 0.7298915
12 obese -0.0851 0.1190 0.9184 [0.73;1.16] 0.4743116
13 smoke -0.6509 0.1404 0.5216 [0.40;0.69] < 1e-04
14 drink -0.1236 0.1609 0.8838 [0.64;1.21] 0.4425781
$`transition 1 -> 2`
Factor coef SE coef exp(coef) CI p-value
15 prediabetes 0.1712 0.1716 1.1867 [0.85;1.66] 0.3183304
16 diabetes 0.2387 0.2169 1.2695 [0.83;1.94] 0.2712914
17 sex -0.7306 0.2133 0.4816 [0.32;0.73] 0.0006142
18 underweight 0.5806 0.3190 1.7871 [0.96;3.34] 0.0687775
19 obese 0.0374 0.1789 1.0382 [0.73;1.47] 0.8342068
20 smoke -0.7677 0.1831 0.4641 [0.32;0.66] < 1e-04
21 drink 0.4322 0.2133 1.5407 [1.01;2.34] 0.0426893
print(summary(fit.weib2,digits = 4))
Method: Weibull parametrization
number of subjects: 1787
number of events '0-->1': 374
number of events '0-->2 or 0-->1-->2': 479
number of covariates: 7 7 7
observation deleted due to missing: 1
#print out the results Model 3
fit.weib3
Call:
idm(formula01 = formula1 ~ prediabetes + diabetes + sex + underweight +
obese + smoke + drink + base_hyp + base_tch + base_hdl +
base_tg, formula02 = formula2 ~ prediabetes + diabetes +
sex + underweight + obese + smoke + drink + base_hyp + base_tch +
base_hdl + base_tg, data = feb)
Illness-death regression model using Weibull parametrization
to estimate the baseline transition intensities.
number of subjects: 1787
number of events '0 -> 1': 374
number of events '0 -> 2' or '0 -> 1 -> 2': 479
number of covariates: 11 11 11
----
Model converged.
number of iterations: 27
convergence criteria: parameters= 1.7e-10
: likelihood= 2.7e-07
: second derivatives= 1.2e-06
Without covariates With covariates
log-likelihood -3847.886 -3751.507
Parameters of the Weibull distributions: 'S(t) = exp(-(b*t)^a)'
transition 0 -> 1 transition 0 -> 2 transition 1 -> 2
shape (a) 9.26895557 12.8117972 7.08733291
scale (b) 0.01128546 0.0117958 0.01341032
Regression coefficients:
$`transition 0 -> 1`
Factor coef SE coef exp(coef) CI p-value
1 prediabetes 0.3013 0.1133 1.3516 [1.08;1.69] 0.0078489
2 diabetes 0.5091 0.1516 1.6638 [1.24;2.24] 0.0007835
3 sex 0.2264 0.1520 1.2540 [0.93;1.69] 0.1364213
4 underweight 0.1983 0.2516 1.2193 [0.74;2.00] 0.4305390
5 obese -0.2470 0.1098 0.7812 [0.63;0.97] 0.0244871
6 smoke -0.4940 0.1314 0.6102 [0.47;0.79] 0.0001704
7 drink -0.2826 0.1513 0.7538 [0.56;1.01] 0.0617227
8 base_hyp 0.2915 0.1041 1.3384 [1.09;1.64] 0.0051190
9 base_tch -0.0910 0.1321 0.9130 [0.70;1.18] 0.4909232
10 base_hdl -0.0788 0.1595 0.9242 [0.68;1.26] 0.6212870
11 base_tg 0.1025 0.1156 1.1079 [0.88;1.39] 0.3753372
$`transition 0 -> 2`
Factor coef SE coef exp(coef) CI p-value
12 prediabetes 0.1746 0.1277 1.1907 [0.93;1.53] 0.1716223
13 diabetes 0.3499 0.1704 1.4189 [1.02;1.98] 0.0400081
14 sex -0.2725 0.1639 0.7615 [0.55;1.05] 0.0964527
15 underweight -0.0427 0.3628 0.9582 [0.47;1.95] 0.9063967
16 obese -0.0924 0.1178 0.9118 [0.72;1.15] 0.4327868
17 smoke -0.6956 0.1400 0.4988 [0.38;0.66] < 1e-04
18 drink -0.0542 0.1579 0.9473 [0.70;1.29] 0.7315440
19 base_hyp 0.0091 0.1036 1.0091 [0.82;1.24] 0.9301192
20 base_tch 0.0866 0.1417 1.0904 [0.83;1.44] 0.5410335
21 base_hdl -0.3726 0.1847 0.6889 [0.48;0.99] 0.0437044
22 base_tg 0.1881 0.1267 1.2070 [0.94;1.55] 0.1376511
$`transition 1 -> 2`
Factor coef SE coef exp(coef) CI p-value
23 prediabetes 0.1399 0.1712 1.1502 [0.82;1.61] 0.4135854
24 diabetes 0.1860 0.2165 1.2044 [0.79;1.84] 0.3902579
25 sex -0.6265 0.2227 0.5345 [0.35;0.83] 0.0048984
26 underweight 0.6217 0.3236 1.8620 [0.99;3.51] 0.0547457
27 obese -0.0013 0.1012 0.9987 [0.82;1.22] 0.9894045
28 smoke -0.7184 0.1858 0.4875 [0.34;0.70] 0.0001103
29 drink 0.3015 0.2120 1.3518 [0.89;2.05] 0.1550309
30 base_hyp 0.0602 0.1598 1.0621 [0.78;1.45] 0.7063391
31 base_tch 0.0087 0.2754 1.0088 [0.59;1.73] 0.9746970
32 base_hdl 0.4069 0.2115 1.5021 [0.99;2.27] 0.0543499
33 base_tg 0.2185 0.1724 1.2441 [0.89;1.74] 0.2050491
print(summary(fit.weib3,digits = 4))
Method: Weibull parametrization
number of subjects: 1787
number of events '0-->1': 374
number of events '0-->2 or 0-->1-->2': 479
number of covariates: 11 11 11
observation deleted due to missing: 1
#plot transition intensities
par(mgp=c(4,1,0),mar=c(5,5,5,5))
plot(fit.weib,conf.int = TRUE,lwd = 3,citype = "shadow",xlim = c(65,100),axis2.las=2,axis1.at=seq(65,100,5),xlab = "Age(years)")
plot(fit.weib2,conf.int = TRUE,lwd = 3,citype = "shadow",xlim = c(65,100),axis2.las=2,axis1.at=seq(65,100,5),xlab = "Age(years)")
plot(fit.weib3,conf.int = TRUE,lwd = 3,citype = "shadow",xlim = c(65,100),axis2.las=2,axis1.at=seq(65,100,5),xlab = "Age(years)")
#Predictive probabilities
# Women age 65 with diabetes in obese grps, no smoking and no alc drinking
pred_w10yr<-predict(fit.weib2,s=65,t=75,newdata=data.frame(diabetes=1,prediabetes=0,sex=2,smoke=0, drink=0, underweight=0, obese=1))
pred_prob_w10yr<-as.data.frame(pred_w10yr$transprob)
pred_prob_w10yr
# Men age 65 with diabetes in obese grps, no smoking and no alc drinking
pred_m10yr<-predict(fit.weib2,s=65,t=75,newdata=data.frame(diabetes=1,prediabetes=0,sex=1,smoke=0, drink=0, underweight=0, obese=1))
pred_prob_m10yr<-as.data.frame(pred_m10yr$transprob)
pred_prob_m10yr
#Figure of predictive probabilities
# create sequence of x values from 0 to 10 representing 10 years
x <- seq(0, 10, length.out = 100)
# set the estimate values
estimate <- probsubset$Estimate
# calculate corresponding y values for each estimate
y <- matrix(0, nrow = length(x), ncol = length(estimate))
for (i in 1:length(estimate)) {
y[,i] <- estimate[i] * (1 - exp(-0.1 * x))
}
# calculate the space between y[i+1] and y[i] as the difference between y[i+1] and the sum of y[i] and y[i+1]
space <- matrix(0, nrow = length(x), ncol = length(estimate))
for (i in 2:length(estimate)) {
space[,i] <- y[,i] - (y[,1]+y[,i])
}
# plot curves for each estimate
plot(x, y[,1], type = "l", col = "blue", ylim = c(0,1), lwd = 2, main = "Curves for Estimates")
for (i in 2:length(estimate)) {
lines(x, y[,i], type = "l", col = i, lwd = 2)
}
# add labels and axis
xlabel <- "Years"
ylabel <- "Predictive probabilities"
title <- "Curves for prediction over 10 Years"
axis(1, at = seq(0, 10, by = 2), labels = seq(0, 10, by = 2))
axis(2, at = seq(0, 1, by = 0.2), labels = seq(0, 1, by = 0.2))
title(xlab = xlabel, ylab = ylabel, main = title)
legend("topright", legend = paste0("Estimate ", 1:length(estimate)), col = 1:length(estimate), lwd = 2)
Add a new chunk by clicking the Insert Chunk button on the toolbar or by pressing Cmd+Option+I.
When you save the notebook, an HTML file containing the code and output will be saved alongside it (click the Preview button or press Cmd+Shift+K to preview the HTML file).
The preview shows you a rendered HTML copy of the contents of the editor. Consequently, unlike Knit, Preview does not run any R code chunks. Instead, the output of the chunk when it was last run in the editor is displayed.