VapoData <- VapoData |>
mutate(
arm = factor(arm, levels = c("Placebo", "Active", "SF")))
Previous model used the number of visits instead of Days in BAART
model <- glm(wound ~
days_since_healed +
arm +
dm_duration +
pet_owner +
contra +
bmi +
arm_exposure_days +
hgba1c +
smoking +
charlson_comorbidity +
reulceration,
family = gaussian,
data = VapoData)
summary(model)
##
## Call:
## glm(formula = wound ~ days_since_healed + arm + dm_duration +
## pet_owner + contra + bmi + arm_exposure_days + hgba1c + smoking +
## charlson_comorbidity + reulceration, family = gaussian, data = VapoData)
##
## Coefficients:
## Estimate Std. Error t value Pr(>|t|)
## (Intercept) -8.676076 6.920027 -1.254 0.210753
## days_since_healed -0.024316 0.007564 -3.215 0.001425 **
## armActive 3.261067 1.523697 2.140 0.033017 *
## armSF 14.908091 3.914403 3.809 0.000165 ***
## dm_duration -0.301410 0.055168 -5.463 8.80e-08 ***
## pet_ownerY 1.881406 1.167880 1.611 0.108077
## contra 0.726757 0.073115 9.940 < 2e-16 ***
## bmi 0.039362 0.070442 0.559 0.576659
## arm_exposure_days 0.046059 0.020068 2.295 0.022309 *
## hgba1c 0.687646 0.352510 1.951 0.051877 .
## smoking1 2.488923 1.190944 2.090 0.037340 *
## smoking2 5.627323 1.328128 4.237 2.89e-05 ***
## charlson_comorbidity 1.110037 0.422518 2.627 0.008983 **
## reulcerationY 3.878797 1.247740 3.109 0.002031 **
## ---
## Signif. codes: 0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1
##
## (Dispersion parameter for gaussian family taken to be 57.77718)
##
## Null deviance: 37982 on 368 degrees of freedom
## Residual deviance: 20511 on 355 degrees of freedom
## (16 observations deleted due to missingness)
## AIC: 2559.8
##
## Number of Fisher Scoring iterations: 2
Previous model used the number of visits instead of day exposed to BAART
VapoDataR <- VapoData |>
mutate(reulceration = dplyr::recode(reulceration,
"Y" = 1,
"N" = 0))
model2 <- glm(reulceration ~
days_since_healed +
arm +
dm_duration +
pet_owner +
contra +
bmi +
hgba1c +
smoking +
arm_exposure_days +
charlson_comorbidity +
wound,
family = gaussian,
data = VapoDataR)
summary(model2)
##
## Call:
## glm(formula = reulceration ~ days_since_healed + arm + dm_duration +
## pet_owner + contra + bmi + hgba1c + smoking + arm_exposure_days +
## charlson_comorbidity + wound, family = gaussian, data = VapoDataR)
##
## Coefficients:
## Estimate Std. Error t value Pr(>|t|)
## (Intercept) 1.2213125 0.2837602 4.304 2.17e-05 ***
## days_since_healed 0.0016669 0.0003097 5.383 1.33e-07 ***
## armActive 0.0708875 0.0642494 1.103 0.270637
## armSF 0.3235249 0.1667247 1.940 0.053114 .
## dm_duration 0.0153371 0.0022692 6.759 5.72e-11 ***
## pet_ownerY 0.2009800 0.0480233 4.185 3.60e-05 ***
## contra -0.0017835 0.0034681 -0.514 0.607387
## bmi -0.0179023 0.0028009 -6.392 5.16e-10 ***
## hgba1c -0.0824197 0.0142158 -5.798 1.49e-08 ***
## smoking1 0.2426182 0.0486129 4.991 9.44e-07 ***
## smoking2 0.0513531 0.0570673 0.900 0.368800
## arm_exposure_days 0.0028479 0.0008349 3.411 0.000722 ***
## charlson_comorbidity -0.1524790 0.0159709 -9.547 < 2e-16 ***
## wound 0.0068321 0.0021978 3.109 0.002031 **
## ---
## Signif. codes: 0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1
##
## (Dispersion parameter for gaussian family taken to be 0.1017691)
##
## Null deviance: 70.542 on 368 degrees of freedom
## Residual deviance: 36.128 on 355 degrees of freedom
## (16 observations deleted due to missingness)
## AIC: 219.72
##
## Number of Fisher Scoring iterations: 2
Now we run an ANOVA to analyze the table of deviance We want the difference between the difference between Df Deviance and Resid. Dev (better if larger).
## Analysis of Deviance Table
##
## Model: gaussian, link: identity
##
## Response: wound
##
## Terms added sequentially (first to last)
##
##
## Df Deviance Resid. Df Resid. Dev Pr(>Chi)
## NULL 368 37982
## days_since_healed 1 5.0 367 37977 0.768961
## arm 2 1901.7 365 36075 7.122e-08 ***
## dm_duration 1 5445.8 364 30629 < 2.2e-16 ***
## pet_owner 1 0.3 363 30629 0.940000
## contra 1 7662.7 362 22966 < 2.2e-16 ***
## bmi 1 294.3 361 22672 0.024013 *
## arm_exposure_days 1 226.4 360 22446 0.047775 *
## hgba1c 1 4.6 359 22441 0.777912
## smoking 2 1257.9 357 21183 1.873e-05 ***
## charlson_comorbidity 1 113.8 356 21069 0.160414
## reulceration 1 558.3 355 20511 0.001879 **
## ---
## Signif. codes: 0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1
Now we want to assess model fit with McFadden R^2 index
## fitting null model for pseudo-r2
## llh llhNull G2 McFadden r2ML
## -1.264894e+03 -1.378574e+03 2.273601e+02 8.246208e-02 4.599816e-01
## r2CU
## 4.602434e-01
Check for multicollinearity Remember that a VIF that exceeds 5-10 shows too much collinearity.
## GVIF Df GVIF^(1/(2*Df))
## days_since_healed 1.328965 1 1.152807
## arm 20.690614 2 2.132767
## dm_duration 2.261653 1 1.503879
## pet_owner 2.101594 1 1.449688
## contra 1.487460 1 1.219615
## bmi 2.750649 1 1.658508
## arm_exposure_days 14.603709 1 3.821480
## hgba1c 1.907173 1 1.381004
## smoking 2.721221 2 1.284372
## charlson_comorbidity 2.692338 1 1.640835
## reulceration 1.900813 1 1.378700
model3 <- glm(reulceration ~
days_since_healed +
dm_duration +
pet_owner +
contra +
bmi +
arm_exposure_days +
hgba1c +
smoking +
charlson_comorbidity +
wound,
family = gaussian,
data = VapoDataR)
summary(model3)
##
## Call:
## glm(formula = reulceration ~ days_since_healed + dm_duration +
## pet_owner + contra + bmi + arm_exposure_days + hgba1c + smoking +
## charlson_comorbidity + wound, family = gaussian, data = VapoDataR)
##
## Coefficients:
## Estimate Std. Error t value Pr(>|t|)
## (Intercept) 1.6119132 0.2014426 8.002 1.73e-14 ***
## days_since_healed 0.0017497 0.0003053 5.731 2.13e-08 ***
## dm_duration 0.0156142 0.0022714 6.874 2.79e-11 ***
## pet_ownerY 0.2208865 0.0470518 4.695 3.82e-06 ***
## contra -0.0016676 0.0034671 -0.481 0.630829
## bmi -0.0198755 0.0025733 -7.724 1.15e-13 ***
## arm_exposure_days 0.0012831 0.0002642 4.856 1.80e-06 ***
## hgba1c -0.0945713 0.0129193 -7.320 1.65e-12 ***
## smoking1 0.2229568 0.0424293 5.255 2.55e-07 ***
## smoking2 0.0144640 0.0515165 0.281 0.779054
## charlson_comorbidity -0.1452119 0.0149416 -9.719 < 2e-16 ***
## wound 0.0078496 0.0021459 3.658 0.000293 ***
## ---
## Signif. codes: 0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1
##
## (Dispersion parameter for gaussian family taken to be 0.1023686)
##
## Null deviance: 70.542 on 368 degrees of freedom
## Residual deviance: 36.546 on 357 degrees of freedom
## (16 observations deleted due to missingness)
## AIC: 219.96
##
## Number of Fisher Scoring iterations: 2
## GVIF Df GVIF^(1/(2*Df))
## days_since_healed 1.328965 1 1.152807
## arm 20.690614 2 2.132767
## dm_duration 2.261653 1 1.503879
## pet_owner 2.101594 1 1.449688
## contra 1.487460 1 1.219615
## bmi 2.750649 1 1.658508
## arm_exposure_days 14.603709 1 3.821480
## hgba1c 1.907173 1 1.381004
## smoking 2.721221 2 1.284372
## charlson_comorbidity 2.692338 1 1.640835
## reulceration 1.900813 1 1.378700
VapoData_NoSF <- VapoDataR |>
filter(!arm == "SF")
model4 <- glm(wound ~
days_since_healed +
arm +
dm_duration +
pet_owner +
contra +
bmi +
arm_exposure_days +
hgba1c +
smoking +
charlson_comorbidity +
reulceration,
family = gaussian,
data = VapoData_NoSF)
summary(model4)
##
## Call:
## glm(formula = wound ~ days_since_healed + arm + dm_duration +
## pet_owner + contra + bmi + arm_exposure_days + hgba1c + smoking +
## charlson_comorbidity + reulceration, family = gaussian, data = VapoData_NoSF)
##
## Coefficients:
## Estimate Std. Error t value Pr(>|t|)
## (Intercept) -7.103343 6.380221 -1.113 0.2665
## days_since_healed -0.010277 0.007869 -1.306 0.1927
## armActive 2.462468 1.426097 1.727 0.0854 .
## dm_duration -0.244815 0.054888 -4.460 1.2e-05 ***
## pet_ownerY 3.739681 1.672388 2.236 0.0262 *
## contra 0.906332 0.076798 11.802 < 2e-16 ***
## bmi -0.094349 0.080206 -1.176 0.2405
## arm_exposure_days 0.037568 0.020028 1.876 0.0618 .
## hgba1c 0.804387 0.404374 1.989 0.0477 *
## smoking1 1.077007 1.315162 0.819 0.4136
## smoking2 4.309903 2.181748 1.975 0.0492 *
## charlson_comorbidity 0.838440 0.605032 1.386 0.1670
## reulceration 3.599714 1.453878 2.476 0.0139 *
## ---
## Signif. codes: 0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1
##
## (Dispersion parameter for gaussian family taken to be 45.57283)
##
## Null deviance: 26515 on 283 degrees of freedom
## Residual deviance: 12350 on 271 degrees of freedom
## (1 observation deleted due to missingness)
## AIC: 1905.3
##
## Number of Fisher Scoring iterations: 2
library(ggplot2)
# Boxplot Wound TEWL by Arm
ggplot(VapoData) +
aes(x = "", y = wound, fill = arm) +
geom_boxplot() +
scale_fill_hue(direction = 1) +
theme_minimal() +
facet_wrap(vars(arm))
# Violin Wound TEWL by Arm
ggplot(VapoData) +
aes(x = "", y = wound, fill = arm) +
geom_violin(adjust = 1L, scale = "area") +
scale_fill_hue(direction = 1) +
theme_minimal() +
facet_wrap(vars(arm))