#mean
mean(master_matched$Magnesium_Baseline,na.rm=T)
## [1] 1.963158
sd(master_matched$Magnesium_Baseline,na.rm=T)
## [1] 0.3157326
mean(master_matched$BaselinePpi,na.rm=T)
## [1] 857.8932
sd(master_matched$BaselinePpi,na.rm=T)
## [1] 596.4267
#matched numbers
master_matched %>% group_by(matched) %>% summarize(mean_mg=mean(Magnesium_Baseline,na.rm=T),sd_mg=sd(Magnesium_Baseline,na.rm=T),
mean_ppi=mean(BaselinePpi,na.rm=T),sd_ppi=sd(BaselinePpi,na.rm=T),
median_ppi=median(BaselinePpi,na.rm = T),
Q1_ppi = quantile(BaselinePpi, 0.25, na.rm = TRUE),
Q3_ppi = quantile(BaselinePpi, 0.75, na.rm = TRUE),
death=sum(Outcome_at_6Wks_death == "dead"),
total_count = n(),
missing_ppi = sum(is.na(BaselinePpi)),
missing_mg = sum(is.na(Magnesium_Baseline)))
## # A tibble: 2 × 12
## matched mean_mg sd_mg mean_ppi sd_ppi median_ppi Q1_ppi Q3_ppi death
## <dbl> <dbl> <dbl> <dbl> <dbl> <dbl> <dbl> <dbl> <int>
## 1 0 2.06 0.302 591. 342. 590. 361. 689. 27
## 2 1 1.9 0.315 1116. 677. 1090. 645. 1490. 28
## # ℹ 3 more variables: total_count <int>, missing_ppi <int>, missing_mg <int>
#models cases
master_cases <- master %>% filter(Group==1)
master_cases %>%
select("Magnesium_Baseline","BaselinePpi","Amputation_at_6week"
) %>%
tbl_uvregression(
method = glm,
y = Amputation_at_6week,
method.args = list(family = binomial),
exponentiate = TRUE,
label = list(male = "Female"),
pvalue_fun = ~style_pvalue(.x, digits = 3)
) %>%
add_global_p() %>%
bold_p() %>% # bold p-values under a given threshold (default 0.05)
bold_labels() %>%
modify_spanning_header(
c(estimate, ci, p.value) ~
"**Amputation_at_6week Univariate logistic regression **")
Characteristic | N | **Amputation_at_6week Univariate logistic regression ** | ||
---|---|---|---|---|
OR1 | 95% CI1 | p-value | ||
Magnesium_Baseline | 53 | 1.63 | 0.14, 19.9 | 0.694 |
BaselinePpi | 68 | 1.00 | 1.00, 1.00 | 0.494 |
1 OR = Odds Ratio, CI = Confidence Interval |
master_cases %>%
select("Magnesium_Baseline","BaselinePpi","Outcome_at_6Wks_death"
) %>%
tbl_uvregression(
method = glm,
y = Outcome_at_6Wks_death,
method.args = list(family = binomial),
exponentiate = TRUE,
label = list(male = "Female"),
pvalue_fun = ~style_pvalue(.x, digits = 3)
) %>%
add_global_p() %>%
bold_p() %>% # bold p-values under a given threshold (default 0.05)
bold_labels() %>%
modify_spanning_header(
c(estimate, ci, p.value) ~
"**Outcome_at_6Wks_death Univariate logistic regression **")
Characteristic | N | **Outcome_at_6Wks_death Univariate logistic regression ** | ||
---|---|---|---|---|
OR1 | 95% CI1 | p-value | ||
Magnesium_Baseline | 53 | 0.11 | 0.01, 0.81 | 0.030 |
BaselinePpi | 69 | 1.00 | 1.00, 1.00 | 0.005 |
1 OR = Odds Ratio, CI = Confidence Interval |
master_cases %>%
select("Magnesium_Baseline","BaselinePpi","Hospitalizations_6wk"
) %>%
tbl_uvregression(
method = glm,
y = Hospitalizations_6wk,
method.args = list(family = binomial),
exponentiate = TRUE,
label = list(male = "Female"),
pvalue_fun = ~style_pvalue(.x, digits = 3)
) %>%
add_global_p() %>%
bold_p() %>% # bold p-values under a given threshold (default 0.05)
bold_labels() %>%
modify_spanning_header(
c(estimate, ci, p.value) ~
"**Hospitalizations_6wk Univariate logistic regression **")
Characteristic | N | **Hospitalizations_6wk Univariate logistic regression ** | ||
---|---|---|---|---|
OR1 | 95% CI1 | p-value | ||
Magnesium_Baseline | 23 | 0.32 | 0.01, 4.79 | 0.413 |
BaselinePpi | 29 | 1.00 | 1.00, 1.00 | 0.419 |
1 OR = Odds Ratio, CI = Confidence Interval |
#Correlation
shapiro.test(master_matched$Magnesium_Baseline) # => p = 0.1229
##
## Shapiro-Wilk normality test
##
## data: master_matched$Magnesium_Baseline
## W = 0.9691, p-value = 0.368
# Shapiro-Wilk normality test for wt
shapiro.test(master_matched$Magnesium_Baseline)
##
## Shapiro-Wilk normality test
##
## data: master_matched$Magnesium_Baseline
## W = 0.9691, p-value = 0.368
cor.test(master_matched$BaselinePpi, master_matched$Magnesium_Baseline, method = "pearson", use = "complete.obs")
##
## Pearson's product-moment correlation
##
## data: master_matched$BaselinePpi and master_matched$Magnesium_Baseline
## t = -1.982, df = 36, p-value = 0.05515
## alternative hypothesis: true correlation is not equal to 0
## 95 percent confidence interval:
## -0.57562570 0.00669272
## sample estimates:
## cor
## -0.3136617
library("ggpubr")
ggscatter(master_matched, x = "Magnesium_Baseline", y = "BaselinePpi",
add = "reg.line", conf.int = TRUE,
cor.coef = TRUE, cor.method = "pearson",
xlab = "BaselinePpi", ylab = "BaselinePpi")
## Warning: Removed 21 rows containing non-finite values (`stat_smooth()`).
## Warning: Removed 21 rows containing non-finite values (`stat_cor()`).
## Warning: Removed 21 rows containing missing values (`geom_point()`).