Skip to content

Commit

Permalink
Commit.
Browse files Browse the repository at this point in the history
  • Loading branch information
FerreiraAS committed Jun 4, 2024
1 parent aef8384 commit 31cea17
Show file tree
Hide file tree
Showing 57 changed files with 780 additions and 696 deletions.
Binary file modified Ciencia-com-R.docx
Binary file not shown.
236 changes: 122 additions & 114 deletions Ciencia-com-R.log

Large diffs are not rendered by default.

Binary file modified Ciencia-com-R_files/figure-html/evento-dado-1.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file modified Ciencia-com-R_files/figure-html/regressao-media-plot-1.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
14 changes: 7 additions & 7 deletions R/Descricao/extracolumn-N.R
Original file line number Diff line number Diff line change
Expand Up @@ -11,11 +11,11 @@ N <- function(x, ...) {
if (nlevels(g) > 2) {
# For numeric variables with 3 or more groups
model <- aov(g ~ y)
eta2 <- eta_squared(model, partial = TRUE)
eta2 <- rstatix::eta_squared(model, partial = TRUE)
if (!is.na(eta2)) {
es <- eta2_to_f(eta2)
N <- pwr.anova.test(k = nlevels(g), f = eta2_to_f(es), sig.level = 0.05,
power = 0.8)
es <- effectsize::eta2_to_f(eta2)
N <- pwr::pwr.anova.test(k = nlevels(g), f = effectsize::eta2_to_f(es),
sig.level = 0.05, power = 0.8)
}
} else {
# For numeric variables with 2 groups
Expand All @@ -27,15 +27,15 @@ N <- function(x, ...) {
d <- (mu.1 - mu.2)/pool.sd
if (!is.na(d)) {
es <- d
N <- ceiling(pwr.t.test(d = es, sig.level = 0.05, power = 1 - 0.2,
type = "two.sample")$n)
N <- ceiling(pwr::pwr.t.test(d = es, sig.level = 0.05, power = 1 -
0.2, type = "two.sample")$n)
}
}
} else {
# For categorical variables
w <- chisq.test(table(y, g), correct = TRUE)
es <- w$statistic
N <- pwr.chisq.test(w = w$statistic, df = w$parameter, sig.level = 0.05,
N <- pwr::pwr.chisq.test(w = w$statistic, df = w$parameter, sig.level = 0.05,
power = 0.8)
}
# Format the ES value, using an HTML entity. The initial empty string
Expand Down
14 changes: 7 additions & 7 deletions R/Descricao/extracolumn-es.R
Original file line number Diff line number Diff line change
Expand Up @@ -11,11 +11,11 @@ es <- function(x, ...) {
if (nlevels(g) > 2) {
# For numeric variables with 3 or more groups
model <- aov(as.character(g) ~ y)
eta2 <- eta_squared(model, partial = TRUE)$Eta2
eta2 <- effectsize::eta_squared(model, partial = TRUE)$Eta2
if (!is.na(eta2)) {
es <- eta2_to_f(eta2)
N <- ceiling(pwr.anova.test(k = nlevels(g), f = eta2_to_f(es), sig.level = 0.05,
power = 0.8)$n)
es <- effectsize::eta2_to_f(eta2)
N <- ceiling(pwr::pwr.anova.test(k = nlevels(g), f = effectsize::eta2_to_f(es),
sig.level = 0.05, power = 0.8)$n)
}
} else {
# For numeric variables with 2 groups
Expand All @@ -27,15 +27,15 @@ es <- function(x, ...) {
d <- (mu.1 - mu.2)/pool.sd
if (!is.na(d)) {
es <- d
N <- ceiling(pwr.t.test(d = es, sig.level = 0.05, power = 1 - 0.2,
type = "two.sample")$n)
N <- ceiling(pwr::pwr.t.test(d = es, sig.level = 0.05, power = 1 -
0.2, type = "two.sample")$n)
}
}
} else {
# For categorical variables
w <- chisq.test(table(y, g), correct = TRUE)
es <- sqrt(as.numeric(w$statistic)/as.numeric(sum(w$observed)) * as.numeric(w$parameter))
N <- ceiling(pwr.chisq.test(w = es, N = NULL, df = w$parameter, sig.level = 0.05,
N <- ceiling(pwr::pwr.chisq.test(w = es, N = NULL, df = w$parameter, sig.level = 0.05,
power = 0.8)$N)
}
# Format the ES value, using an HTML entity. The initial empty string
Expand Down
11 changes: 6 additions & 5 deletions R/Descricao/pilotdata_gopal.R
Original file line number Diff line number Diff line change
Expand Up @@ -23,25 +23,26 @@ source("extracolumn-N.R")
dataset <- data.frame(read_excel("pilotdata_gopal.xlsx", sheet = 1))

# COMPARATIVE ANALYSIS
table1(~Sex + Age + Height_cm + Weight_kg + BMI_kg.m. + Smoker + FVC + FEV1 + FEV1.FVC +
MIP + MEP | Group, data = dataset, extra.col = list(`P-value` = pvalue, `Effect size (d, f, V)` = es))
table1::table1(~Sex + Age + Height_cm + Weight_kg + BMI_kg.m. + Smoker + FVC + FEV1 +
FEV1.FVC + MIP + MEP | Group, data = dataset, extra.col = list(`P-value` = pvalue,
`Effect size (d, f, V)` = es))

# COMPARATIVE ANALYSIS
table1(~Both.Leg...Eyes.Opened..Overall.balance.index...Two.Leg.. + Both.Leg...Eyes.Opened..Overall.balance.index...SD.. +
table1::table1(~Both.Leg...Eyes.Opened..Overall.balance.index...Two.Leg.. + Both.Leg...Eyes.Opened..Overall.balance.index...SD.. +
Both.Leg...Eyes.Opened..ANT.POST.balance.index...Two.Leg. + Both.Leg...Eyes.Opened..ANT.POST.balance.index...SD. +
Both.Leg...Eyes.Opened..MED.LAT..balance.index..Two.Leg. + Both.Leg...Eyes.Opened..MED.LAT..balance.index..SD. |
Group, data = dataset, extra.col = list(`P-value` = pvalue, `Effect size<br>(d, f, X)` = es,
`Sample size<br>(per group)` = N))

# COMPARATIVE ANALYSIS
table1(~Both.Leg...Eyes.closed..Overall.balance.index..Two.leg. + Both.Leg...Eyes.closed..Overall.balance.index..SD. +
table1::table1(~Both.Leg...Eyes.closed..Overall.balance.index..Two.leg. + Both.Leg...Eyes.closed..Overall.balance.index..SD. +
Both.Leg...Eyes.Closed..ANT.POST.balance.index..two.leg. + Both.Leg...Eyes.Closed..ANT.POST.balance.index..SD. +
Both.Leg...Eyes.Closed..MED.LAT..balance.index...two.Leg. + Both.Leg...Eyes.Closed..MED.LAT..balance.index...SD. |
Group, data = dataset, extra.col = list(`P-value` = pvalue, `Effect size<br>(d, f, X)` = es,
`Sample size<br>(per group)` = N))

# COMPARATIVE ANALYSIS
table1(~Sagittal.Imbalance.VP.DM.R. + Sagittal.Imbalance.VP.DM.L. + Coronal.Imbalance.VP.DM.mm.R +
table1::table1(~Sagittal.Imbalance.VP.DM.R. + Sagittal.Imbalance.VP.DM.L. + Coronal.Imbalance.VP.DM.mm.R +
Coronal.Imbalance.VP.DM.mm.L + Pelvic.Obliquity.mm.R + Pelvic.Obliquity.mm.L +
Pelvic.Obliquity.mm + Pelvic.Torsion.DL.DR..R. + Pelvic.Torsion.DL.DR.L. + Pelvic.Torsion.DL.DR.. +
Pelvic.Rotation.. + Pelvic.Rotation.R. + Pelvic.Rotation.L. + Kyphotic.Angle.ICT.ITL..MAX.... +
Expand Down
18 changes: 9 additions & 9 deletions R/Desempenho diagnostico/diag-stats.R
Original file line number Diff line number Diff line change
Expand Up @@ -67,16 +67,16 @@ diag.stats <- function(new.test, reference.test, new.lab, ref.lab, adjustment, c
youden <- sen + spe - 1

# Clopper-Pearson exact confidence intervals
sen.ci <- exactci(TP, (TP + FN), conf.level)
spe.ci <- exactci(TN, (FP + TN), conf.level)
ppv.ci <- exactci(TP, (TP + FP), conf.level)
npv.ci <- exactci(TN, (FN + TN), conf.level)
acc.ci <- exactci((TP + TN), (TP + FN + FP + TN), conf.level)
plr.ci <- riskscoreci(TP, (TP + FN), FP, (FP + TN), conf.level)
nlr.ci <- riskscoreci(FN, (TP + FN), TN, (FP + TN), conf.level)
dor.ci <- oddsratioci.mp((FP * FN), (TP * TN), conf.level)
sen.ci <- PropCIs::exactci(TP, (TP + FN), conf.level)
spe.ci <- PropCIs::exactci(TN, (FP + TN), conf.level)
ppv.ci <- PropCIs::exactci(TP, (TP + FP), conf.level)
npv.ci <- PropCIs::exactci(TN, (FN + TN), conf.level)
acc.ci <- PropCIs::exactci((TP + TN), (TP + FN + FP + TN), conf.level)
plr.ci <- PropCIs::riskscoreci(TP, (TP + FN), FP, (FP + TN), conf.level)
nlr.ci <- PropCIs::riskscoreci(FN, (TP + FN), TN, (FP + TN), conf.level)
dor.ci <- PropCIs::oddsratioci.mp((FP * FN), (TP * TN), conf.level)
# DeLong confidence interval
auc.ci <- ci.auc(new.test, reference.test, conf.level = conf.level)
auc.ci <- pROC::ci.auc(new.test, reference.test, conf.level = conf.level)
# Wallis confidence interval
p1 <- sen
p2 <- spe
Expand Down
28 changes: 14 additions & 14 deletions R/Ensaio experimental aleatorizado/RCT-Figure1.R
100755 → 100644
Original file line number Diff line number Diff line change
Expand Up @@ -87,27 +87,27 @@ FIGURE.1 <- function(dataset, variables, covariate, bw.factor, wt.labels, missin
# fit linear mixed model
if (missing != "multiple.imputation") {
if (!is.null(covariate)) {
mod1 <- lme(fixed = OUTCOME_M ~ TIME_M * GROUP_M + COVARIATE_M, random = ~1 |
ID_M/TIME_M, data = data_M)
mod1 <- lme4::lme(fixed = OUTCOME_M ~ TIME_M * GROUP_M + COVARIATE_M,
random = ~1 | ID_M/TIME_M, data = data_M)
} else {
mod1 <- lme(fixed = OUTCOME_M ~ TIME_M * GROUP_M, random = ~1 | ID_M/TIME_M,
data = data_M)
mod1 <- lme4::lme(fixed = OUTCOME_M ~ TIME_M * GROUP_M, random = ~1 |
ID_M/TIME_M, data = data_M)
}
mod1.aov <- anova(mod1)
} else {
ini <- mice(data = data_M, maxit = 0)
ini <- mice::mice(data = data_M, maxit = 0)
pred <- ini$pred
pred["OUTCOME_M", "ID_M"] <- -2
imp <- mice(data_M, pred = pred, method = "2l.pan", m = m.imputations, seed = 0,
print = FALSE)
imp <- mice::mice(data_M, pred = pred, method = "2l.pan", m = m.imputations,
seed = 0, print = FALSE)
if (!is.null(covariate)) {
mod1 <- with(data = imp, lme(fixed = OUTCOME_M ~ TIME_M * GROUP_M + COVARIATE_M,
random = ~1 | ID_M/TIME_M))
mod1.aov <- quiet(mi.anova(imp, formula = "OUTCOME_M ~ TIME_M * GROUP_M + COVARIATE_M"))
mod1 <- with(data = imp, lme4::lme(fixed = OUTCOME_M ~ TIME_M * GROUP_M +
COVARIATE_M, random = ~1 | ID_M/TIME_M))
mod1.aov <- quiet(miceadds::mi.anova(imp, formula = "OUTCOME_M ~ TIME_M * GROUP_M + COVARIATE_M"))
} else {
mod1 <- with(data = imp, lme(fixed = OUTCOME_M ~ TIME_M * GROUP_M, random = ~1 |
ID_M/TIME_M))
mod1.aov <- quiet(mi.anova(imp, formula = "OUTCOME_M ~ TIME_M * GROUP_M"))
mod1 <- with(data = imp, lme4::lme(fixed = OUTCOME_M ~ TIME_M * GROUP_M,
random = ~1 | ID_M/TIME_M))
mod1.aov <- quiet(miceadds::mi.anova(imp, formula = "OUTCOME_M ~ TIME_M * GROUP_M"))
}
mod1.aov <- mod1.aov$anova.table[1:3, 2:5]
mod1.aov <- rbind(rep(NA, 4), mod1.aov)
Expand All @@ -133,7 +133,7 @@ FIGURE.1 <- function(dataset, variables, covariate, bw.factor, wt.labels, missin
"*\",\"*", " ~ p", p.value))

# calculate CI
myCI <- group.CI(OUTCOME_M ~ GROUP_M * as.factor(TIME_M), data = cbind(GROUP_M,
myCI <- Rmisc::group.CI(OUTCOME_M ~ GROUP_M * as.factor(TIME_M), data = cbind(GROUP_M,
as.factor(TIME_M), OUTCOME_M), ci = 1 - alpha)
myCI[, 2] <- rep(wt.labels, each = nlevels(bw.factor))

Expand Down
2 changes: 1 addition & 1 deletion R/Ensaio experimental aleatorizado/RCT-Missingness.R
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ missing.data <- function(dataset, variables, covariate, digits = 3, p.digits = 3
dataset <- cbind(dataset, covariate)
}

test.res <- na.test(dataset, digits = digits, p.digits = p.digits, as.na = as.na,
test.res <- misty::na.test(dataset, digits = digits, p.digits = p.digits, as.na = as.na,
check = check, output = output)

# output results
Expand Down
47 changes: 24 additions & 23 deletions R/Ensaio experimental aleatorizado/RCT-Table2a.R
100755 → 100644
Original file line number Diff line number Diff line change
Expand Up @@ -124,27 +124,27 @@ TABLE.2a <- function(dataset, variables, covariate, bw.factor, control.g, wt.lab
# fit linear mixed model
if (missing != "multiple.imputation") {
if (!is.null(covariate)) {
mod1 <- lme(fixed = OUTCOME_M ~ TIME_M * GROUP_M + COVARIATE_M, random = ~1 |
ID_M/TIME_M, data = data_M)
mod1 <- lme4::lme(fixed = OUTCOME_M ~ TIME_M * GROUP_M + COVARIATE_M,
random = ~1 | ID_M/TIME_M, data = data_M)
} else {
mod1 <- lme(fixed = OUTCOME_M ~ TIME_M * GROUP_M, random = ~1 | ID_M/TIME_M,
data = data_M)
mod1 <- lme4::lme(fixed = OUTCOME_M ~ TIME_M * GROUP_M, random = ~1 |
ID_M/TIME_M, data = data_M)
}
mod1.aov <- anova(mod1)
} else {
ini <- mice(data = data_M, maxit = 0)
ini <- mice::mice(data = data_M, maxit = 0)
pred <- ini$pred
pred["OUTCOME_M", "ID_M"] <- -2
imp <- mice(data_M, pred = pred, method = "2l.pan", m = m.imputations, seed = 0,
print = FALSE)
imp <- mice::mice(data_M, pred = pred, method = "2l.pan", m = m.imputations,
seed = 0, print = FALSE)
if (!is.null(covariate)) {
mod1 <- with(data = imp, lme(fixed = OUTCOME_M ~ TIME_M * GROUP_M + COVARIATE_M,
random = ~1 | ID_M/TIME_M))
mod1.aov <- quiet(mi.anova(imp, formula = "OUTCOME_M ~ TIME_M * GROUP_M + COVARIATE_M"))
mod1 <- with(data = imp, lme4::lme(fixed = OUTCOME_M ~ TIME_M * GROUP_M +
COVARIATE_M, random = ~1 | ID_M/TIME_M))
mod1.aov <- quiet(miceadds::mi.anova(imp, formula = "OUTCOME_M ~ TIME_M * GROUP_M + COVARIATE_M"))
} else {
mod1 <- with(data = imp, lme(fixed = OUTCOME_M ~ TIME_M * GROUP_M, random = ~1 |
ID_M/TIME_M))
mod1.aov <- quiet(mi.anova(imp, formula = "OUTCOME_M ~ TIME_M * GROUP_M"))
mod1 <- with(data = imp, lme4::lme(fixed = OUTCOME_M ~ TIME_M * GROUP_M,
random = ~1 | ID_M/TIME_M))
mod1.aov <- quiet(miceadds::mi.anova(imp, formula = "OUTCOME_M ~ TIME_M * GROUP_M"))
}
mod1.aov <- mod1.aov$anova.table[1:3, 2:5]
mod1.aov <- rbind(rep(NA, 4), mod1.aov)
Expand Down Expand Up @@ -212,8 +212,8 @@ TABLE.2a <- function(dataset, variables, covariate, bw.factor, control.g, wt.lab
model.res[3, 1] <- interaction

# calcula e preenche a subtabela WITHIN-GROUP (SAME LINEAR MIXED MODEL)
mult.within <- summary(pairs(emmeans(mod1, ~TIME_M | GROUP_M), reverse = FALSE),
infer = c(TRUE, TRUE))
mult.within <- multcomp::summary(emmGrid::pairs(emmeans::emmeans(mod1, ~TIME_M |
GROUP_M), reverse = FALSE), infer = c(TRUE, TRUE))
wt <- c()
wt.pvalues <- c()
for (i in 1:nlevels(bw.factor)) {
Expand Down Expand Up @@ -255,22 +255,23 @@ TABLE.2a <- function(dataset, variables, covariate, bw.factor, control.g, wt.lab
if (!is.null(covariate)) {
df <- data.frame(ID, bw.factor, BASELINE_M, FOLLOWUP_M, CHANGE_M,
COVARIATE_M)
mod2 <- lme(CHANGE_M ~ bw.factor + BASELINE_M + COVARIATE_M, random = ~1 |
ID, data = df)
mod2 <- lme4::lme(CHANGE_M ~ bw.factor + BASELINE_M + COVARIATE_M,
random = ~1 | ID, data = df)
} else {
df <- data.frame(ID, bw.factor, BASELINE_M, FOLLOWUP_M, CHANGE_M)
mod2 <- lme(CHANGE_M ~ bw.factor + BASELINE_M, random = ~1 | ID,
data = df)
mod2 <- lme4::lme(CHANGE_M ~ bw.factor + BASELINE_M, random = ~1 |
ID, data = df)
}
mod2.sum <- summary(glht(mod2, linfct = mcp(bw.factor = "Tukey")), test = adjusted("holm"))
mod2.sum <- multcomp::summary(multcomp::glht(mod2, linfct = mcp::mcp(bw.factor = "Tukey")),
test = adjusted("holm"))
names <- names(coef(mod2.sum))
estimate <- round(confint(mod2.sum, level = 1 - alpha)$confint[, "Estimate"],
digits = n.digits)
low.ci <- round(confint(mod2.sum, level = 1 - alpha)$confint[, "lwr"],
digits = n.digits)
upp.ci <- round(confint(mod2.sum, level = 1 - alpha)$confint[, "upr"],
digits = n.digits)
p.value <- summary(mod2)$tTable[, "p-value"][2]
p.value <- multcomp::summary(mod2)$tTable[, "p-value"][2]
} else {
if (!is.null(covariate)) {
df <- data.frame(ID, bw.factor, BASELINE_M, FOLLOWUP_M, CHANGE_M,
Expand All @@ -282,7 +283,7 @@ TABLE.2a <- function(dataset, variables, covariate, bw.factor, control.g, wt.lab
pred <- ini$pred
pred["FOLLOWUP_M", "ID"] <- -2
pred["CHANGE_M", "ID"] <- -2
imp <- mice(data = df, pred = pred, method = "2l.pan", m = m.imputations,
imp <- mice::mice(data = df, pred = pred, method = "2l.pan", m = m.imputations,
seed = 0, print = FALSE)
implist <- mids2mitml.list(imp)
mod2 <- with(data = implist, lm(CHANGE_M ~ bw.factor + BASELINE_M, random = ~1 |
Expand Down Expand Up @@ -315,7 +316,7 @@ TABLE.2a <- function(dataset, variables, covariate, bw.factor, control.g, wt.lab
group_data[bw.factor == bw.factor] <- 0
group_data[bw.factor != control.g] <- 1
data <- data.frame(group_data, CHANGE_M)
smd <- stddiff.numeric(data = data, gcol = 1, vcol = 2)
smd <- stddiff::stddiff.numeric(data = data, gcol = 1, vcol = 2)
estimate <- round(smd[7], digits = n.digits)
lower <- round(smd[8], digits = n.digits)
upper <- round(smd[9], digits = n.digits)
Expand Down
32 changes: 16 additions & 16 deletions R/Ensaio experimental aleatorizado/RCT-Table2b.R
100755 → 100644
Original file line number Diff line number Diff line change
Expand Up @@ -122,27 +122,27 @@ TABLE.2b <- function(dataset, variables, covariate, bw.factor, control.g, wt.lab
# fit linear mixed model
if (missing != "multiple.imputation") {
if (!is.null(covariate)) {
mod1 <- lme(fixed = OUTCOME_M ~ TIME_M * GROUP_M + COVARIATE_M, random = ~1 |
ID_M/TIME_M, data = data_M)
mod1 <- lme4::lme(fixed = OUTCOME_M ~ TIME_M * GROUP_M + COVARIATE_M,
random = ~1 | ID_M/TIME_M, data = data_M)
} else {
mod1 <- lme(fixed = OUTCOME_M ~ TIME_M * GROUP_M, random = ~1 | ID_M/TIME_M,
data = data_M)
mod1 <- lme4::lme(fixed = OUTCOME_M ~ TIME_M * GROUP_M, random = ~1 |
ID_M/TIME_M, data = data_M)
}
mod1.aov <- anova(mod1)
} else {
ini <- mice(data = data_M, maxit = 0)
ini <- mice::mice(data = data_M, maxit = 0)
pred <- ini$pred
pred["OUTCOME_M", "ID_M"] <- -2
imp <- mice(data_M, pred = pred, method = "2l.pan", m = m.imputations, seed = 0,
print = FALSE)
imp <- mice::mice(data_M, pred = pred, method = "2l.pan", m = m.imputations,
seed = 0, print = FALSE)
if (!is.null(covariate)) {
mod1 <- with(data = imp, lme(fixed = OUTCOME_M ~ TIME_M * GROUP_M + COVARIATE_M,
random = ~1 | ID_M/TIME_M))
mod1.aov <- quiet(mi.anova(imp, formula = "OUTCOME_M ~ TIME_M * GROUP_M + COVARIATE_M"))
mod1.aov <- quiet(miceadds::mi.anova(imp, formula = "OUTCOME_M ~ TIME_M * GROUP_M + COVARIATE_M"))
} else {
mod1 <- with(data = imp, lme(fixed = OUTCOME_M ~ TIME_M * GROUP_M, random = ~1 |
ID_M/TIME_M))
mod1.aov <- quiet(mi.anova(imp, formula = "OUTCOME_M ~ TIME_M * GROUP_M"))
mod1 <- with(data = imp, lme4::lme(fixed = OUTCOME_M ~ TIME_M * GROUP_M,
random = ~1 | ID_M/TIME_M))
mod1.aov <- quiet(miceadds::mi.anova(imp, formula = "OUTCOME_M ~ TIME_M * GROUP_M"))
}
mod1.aov <- mod1.aov$anova.table[1:3, 2:5]
mod1.aov <- rbind(rep(NA, 4), mod1.aov)
Expand Down Expand Up @@ -208,8 +208,8 @@ TABLE.2b <- function(dataset, variables, covariate, bw.factor, control.g, wt.lab
}

# calcula e preenche a subtabela WITHIN-GROUP (SAME LINEAR MIXED MODEL)
mult.within <- summary(pairs(emmeans(mod1, ~TIME_M | GROUP_M), reverse = FALSE),
infer = c(TRUE, TRUE))
mult.within <- multcomp::summary(emmGrid::pairs(emmeans::emmeans(mod1, ~TIME_M |
GROUP_M), reverse = FALSE), infer = c(TRUE, TRUE))
wt <- c()
wt.pvalues <- c()
for (i in 1:nlevels(bw.factor)) {
Expand Down Expand Up @@ -239,8 +239,8 @@ TABLE.2b <- function(dataset, variables, covariate, bw.factor, control.g, wt.lab
bw <- c()
bw.pvalues <- c()
smd.values <- c()
mult.between <- summary(pairs(emmeans(mod1, ~GROUP_M | TIME_M), reverse = FALSE),
infer = c(TRUE, TRUE))
mult.between <- multcomp::summary(emmGrid::pairs(emmeans::emmeans(mod1, ~GROUP_M |
TIME_M), reverse = FALSE), infer = c(TRUE, TRUE))
for (i in 1:(length(wt.labels))) {
group.data <- mult.between[i, ]
# reverse signs due to mult.within order
Expand All @@ -259,7 +259,7 @@ TABLE.2b <- function(dataset, variables, covariate, bw.factor, control.g, wt.lab
group_data[bw.factor == bw.factor] <- 0
group_data[bw.factor != control.g] <- 1
data <- data.frame(group_data, OUTCOME_M[TIME_M == i])
smd <- stddiff.numeric(data = data, gcol = 1, vcol = 2)
smd <- stddiff::stddiff.numeric(data = data, gcol = 1, vcol = 2)
estimate <- round(smd[7], digits = n.digits)
lower <- round(smd[8], digits = n.digits)
upper <- round(smd[9], digits = n.digits)
Expand Down
Loading

0 comments on commit 31cea17

Please sign in to comment.