Data Preparation

Check for Multicollinearity

Data Analysis

GLM - Generalized Linear Model - Reulceration Risk

Previous model used the number of visits instead of day exposed to BAART

VapoDataR <- VapoData |> 
  mutate(
    arm = factor(arm, levels = c("Placebo", "Active", "SF")),
    arm = recode(arm, "SF" = "Placebo"),
    smoking = recode(smoking, "1" = "2"),
    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.6381029  0.2049866   7.991 1.87e-14 ***
## days_since_healed     0.0014175  0.0003034   4.671 4.25e-06 ***
## armActive            -0.0439821  0.0420998  -1.045  0.29686    
## dm_duration           0.0138129  0.0022618   6.107 2.65e-09 ***
## pet_ownerY            0.2323082  0.0478039   4.860 1.76e-06 ***
## contra               -0.0000838  0.0035164  -0.024  0.98100    
## bmi                  -0.0201784  0.0026329  -7.664 1.72e-13 ***
## hgba1c               -0.1004648  0.0131839  -7.620 2.30e-13 ***
## smoking2              0.1313916  0.0413037   3.181  0.00160 ** 
## arm_exposure_days     0.0016668  0.0002564   6.500 2.70e-10 ***
## charlson_comorbidity -0.1362093  0.0154536  -8.814  < 2e-16 ***
## wound                 0.0071919  0.0021842   3.293  0.00109 ** 
## ---
## Signif. codes:  0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1
## 
## (Dispersion parameter for gaussian family taken to be 0.1061313)
## 
##     Null deviance: 70.542  on 368  degrees of freedom
## Residual deviance: 37.889  on 357  degrees of freedom
##   (16 observations deleted due to missingness)
## AIC: 233.28
## 
## Number of Fisher Scoring iterations: 2

Effect Size Plot - Rulceration GLM

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: reulceration
## 
## Terms added sequentially (first to last)
## 
## 
##                      Df Deviance Resid. Df Resid. Dev  Pr(>Chi)    
## NULL                                   368     70.542              
## days_since_healed     1   4.7141       367     65.828 2.653e-11 ***
## arm                   1   3.1328       366     62.695 5.541e-08 ***
## dm_duration           1   0.5580       365     62.137 0.0218465 *  
## pet_owner             1   2.4817       364     59.655 1.327e-06 ***
## contra                1   0.0053       363     59.650 0.8238841    
## bmi                   1   3.9537       362     55.696 1.038e-09 ***
## hgba1c                1   3.6728       361     52.024 4.036e-09 ***
## smoking               1   1.9816       360     50.042 1.553e-05 ***
## arm_exposure_days     1   3.4510       359     46.591 1.182e-08 ***
## charlson_comorbidity  1   7.5515       358     39.040 < 2.2e-16 ***
## wound                 1   1.1507       357     37.889 0.0009921 ***
## ---
## 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         r2CU 
## -103.6405933 -218.3167792  229.3523718    0.5252743    0.4628893    0.6672470

Check for multicollinearity Remember that a VIF that exceeds 5-10 shows too much collinearity.

##    days_since_healed                  arm          dm_duration 
##             1.164391             1.501192             2.069541 
##            pet_owner               contra                  bmi 
##             1.916868             1.872977             2.091925 
##               hgba1c              smoking    arm_exposure_days 
##             1.452281             1.472395             1.297965 
## charlson_comorbidity                wound 
##             1.960693             1.707295

Graphs

Reulceration Plots

library(dplyr)
library(tidyr)
library(knitr)
library(kableExtra)
## 
## Attaching package: 'kableExtra'
## The following object is masked from 'package:dplyr':
## 
##     group_rows
# Define categorical and continuous variables
categorical_vars <- c("pet_owner", "smoking", "arm", "reulceration", "id", "site")
continuous_vars <- c("dm_duration", "wound", "arm_exposure_days", "days_since_healed", 
                     "contra", "bmi", "hgba1c", "charlson_comorbidity", "age", "five_cm", "contra_five_cm", "dif")

# Process categorical variables
cat_data <- VapoDataR %>%
  select(all_of(categorical_vars)) %>%
  pivot_longer(cols = -id, names_to = "variable", values_to = "level") %>%
  distinct(id, variable, level, .keep_all = TRUE) %>%
  group_by(variable, level) %>%
  summarise(count = n(), .groups = "drop") %>%
  mutate(percent = count / sum(count) * 100)

# Process continuous variables
cont_data <- VapoDataR %>%
  select(all_of(continuous_vars)) %>%
  pivot_longer(cols = everything(), names_to = "variable", values_to = "value") %>%
  group_by(variable) %>%
  summarise(mean = mean(value, na.rm = TRUE), 
            sd = sd(value, na.rm = TRUE),
            median = median(value, na.rm = TRUE),
            IQR = IQR(value, na.rm = TRUE), .groups = "drop")

# Combine categorical and continuous data
table1 <- bind_rows(cat_data, cont_data)

# Format Table 1 using kable
kable_table <- kable(table1, format = "html", 
                     caption = "Summary Statistics for Study Variables",
                     col.names = c("Variable", "Level/Statistic", "Count/Frequency", "Percentage", "Mean", "Standard Deviation", "Median", "IQR"),
                     align = 'c') %>%
  kable_styling(bootstrap_options = c("striped", "hover", "condensed", "responsive"))

# Print the formatted table
kable_table
Summary Statistics for Study Variables
Variable Level/Statistic Count/Frequency Percentage Mean Standard Deviation Median IQR
arm Active 8 8 NA NA NA NA
arm Placebo 12 12 NA NA NA NA
pet_owner N 11 11 NA NA NA NA
pet_owner Y 9 9 NA NA NA NA
reulceration No 15 15 NA NA NA NA
reulceration Yes 5 5 NA NA NA NA
site first mt 2 2 NA NA NA NA
site hallux 7 7 NA NA NA NA
site heel 3 3 NA NA NA NA
site lateral 1 1 NA NA NA NA
site medial 2 2 NA NA NA NA
site second mt 3 3 NA NA NA NA
site second toe 1 1 NA NA NA NA
site third mt 1 1 NA NA NA NA
smoking 0 10 10 NA NA NA NA
smoking 2 10 10 NA NA NA NA
age NA NA NA 69.727273 6.415793 71.00 10.000
arm_exposure_days NA NA NA 119.168831 76.298721 146.00 148.000
bmi NA NA NA 36.550000 9.227933 33.67 11.700
charlson_comorbidity NA NA NA 5.701299 1.514384 5.00 2.000
contra NA NA NA 19.117838 6.601795 17.85 9.700
contra_five_cm NA NA NA 17.878487 5.880068 16.95 8.500
days_since_healed NA NA NA 84.545455 65.110392 70.00 76.000
dif NA NA NA 5.271595 8.684772 3.70 10.975
dm_duration NA NA NA 21.012987 10.626830 21.00 8.000
five_cm NA NA NA 19.623644 6.740541 19.20 9.300
hgba1c NA NA NA 7.996615 1.522079 7.70 1.800
wound NA NA NA 23.881532 10.287148 23.50 13.500