# Define a function to fit a new spline-based model using standard errors
<- function(fun_dt, center=TRUE,
new_spline_based_on_se_old formula="logrr ~ rcs(exp_rr, 3)") {
# fun_dt<- stroke_list() %>% left_join(data, by = c("Study", "subtype"))
<- fun_dt %>% mutate(
fun_dt case=NA,
n=NA)
# Define the covariance matrices for each study
# (based on https://alecri.github.io/downloads/codes/missing%20cases%20n.txt)
<- lapply(unique(fun_dt$id), function(i) {
Slist with(subset(fun_dt, id == i),
if (any(is.na(case) | is.na(n))) {
diag(logse[logse != 0 & !is.na(logse)]^2, nrow = sum(logse != 0 & !is.na(logse)))
else {
} covar.logrr(case = case, n = n, y = logrr, v = I(logse^2), type = type, covariance = "gl")
}
)
})
# Fit the model using dosresmeta with custom covariance matrices
<- dosresmeta(
spline_model formula = as.formula(formula),
id = fun_dt$id,
se = fun_dt$logse,
data = fun_dt,
covariance = "user",
method="ml",
Slist = Slist,
center = center,
intercept = F,
proc="1stage",
)
return(spline_model)
}
# Define a function to fit a new spline-based model using standard errors
<- function(fun_dt, center=TRUE,
new_spline_based_on_se formula="logrr ~ rcs(exp_rr, 3)") {
# fun_dt<- stroke_list() %>% left_join(data, by = c("Study", "subtype"))
<- dosresmeta(
spline_model formula = as.formula(formula),
id = fun_dt$id,
se = fun_dt$logse,
data = fun_dt,
proc = "1stage",
method="ml",
center = TRUE,
intercept = FALSE,
covariance="indep",
)
return(spline_model)
}
Corrected dosresmeta
Materials and methods
The ERFs were evaluated using the dosresmeta
package in R, which fits dose-response meta-analysis models using standard errors. The dosresmeta
package allows for the fitting of both linear and non-linear models, including restricted cubic splines with multiple knots. The models were evaluated for linearity using likelihood ratio tests and Wald tests for overall dose-response association and deviation from linearity.
Here is a function to define dosresmeta
models
With this new and old function specification we could test the output on results of IHD, Restricted Cubic splines with three knots.
Slist = Slist
,covariance="indep"
IHD: Spline-based models with three knots
According to our agreement Wald test for overall dose-response association and Wald test for deviation from linearity are added to the plot displayed on the plot.
IHD results (all warinings are ON)
Warning in optim(par = par, fn = fn, gr = gr, Xlist = Xlist, Zlist = Zlist, : one-dimensional optimization by Nelder-Mead is unreliable:
use "Brent" or optimize() directly
Warning in optim(par = par, fn = fn, gr = gr, Xlist = Xlist, Zlist = Zlist, : one-dimensional optimization by Nelder-Mead is unreliable:
use "Brent" or optimize() directly
MI results
Warning in optim(par = par, fn = fn, gr = gr, Xlist = Xlist, Zlist = Zlist, : one-dimensional optimization by Nelder-Mead is unreliable:
use "Brent" or optimize() directly
Warning in optim(par = par, fn = fn, gr = gr, Xlist = Xlist, Zlist = Zlist, : one-dimensional optimization by Nelder-Mead is unreliable:
use "Brent" or optimize() directly
Stroke results (all warinings are ON)
Warning in optim(par = par, fn = fn, gr = gr, Xlist = Xlist, Zlist = Zlist, : one-dimensional optimization by Nelder-Mead is unreliable:
use "Brent" or optimize() directly
Warning in optim(par = par, fn = fn, gr = gr, Xlist = Xlist, Zlist = Zlist, : one-dimensional optimization by Nelder-Mead is unreliable:
use "Brent" or optimize() directly