### Install development version from GitHub Source: https://smartdata-analysis-and-statistics.github.io/metamisc/index.html Installation method for the latest development version using the devtools package. ```R # install.packages("devtools") devtools::install_github("smartdata-analysis-and-statistics/metamisc") ``` -------------------------------- ### Install metamisc from CRAN Source: https://smartdata-analysis-and-statistics.github.io/metamisc/index.html Standard installation method for the stable version of the package from the CRAN repository. ```R install.packages("metamisc") ``` -------------------------------- ### Build Generalizable Models Source: https://smartdata-analysis-and-statistics.github.io/metamisc/reference/metapred.html Examples for building generalizable models using the metapred function with various parameters. ```R metapred(DVTipd, strata = "study", formula = dvt ~ 1, scope = f, family = binomial) # Forwards metapred(DVTipd, strata = "study", formula = f, scope = f, family = binomial) # no selection metapred(DVTipd, strata = "study", formula = f, max.steps = 0, family = binomial) # no selection metapred(DVTipd, strata = "study", formula = f, recal.int = TRUE, family = binomial) metapred(DVTipd, strata = "study", formula = f, meta.method = "REML", family = binomial) ``` -------------------------------- ### Generating Forest Plots for Performance Estimates Source: https://smartdata-analysis-and-statistics.github.io/metamisc/reference/plot.mm_perf.html Examples demonstrating how to calculate performance metrics and visualize them using forest plots. ```R data(EuroSCORE) # Calculate the c-statistic and its standard error est1 <- ccalc(cstat = c.index, cstat.se = se.c.index, cstat.cilb = c.index.95CIl, cstat.ciub = c.index.95CIu, N = n, O = n.events, data = EuroSCORE, slab = Study) plot(est1) # Calculate the total O:E ratio and its standard error est2 <- oecalc(O = n.events, E = e.events, N = n, data = EuroSCORE, slab = Study) plot(est2) ``` -------------------------------- ### Recalibrating a metapred model Source: https://smartdata-analysis-and-statistics.github.io/metamisc/reference/recalibrate.html Example demonstrating how to recalibrate a metapred model using a subset of data. ```R data(DVTipd) DVTipd$cluster <- 1:4 # Add a fictional clustering to the data set. # Suppose we estimated the model in three studies: DVTipd123 <- DVTipd[DVTipd$cluster <= 3, ] mp <- metamisc:::metapred(DVTipd123, strata = "cluster", f = dvt ~ vein + malign, family = binomial) # and now want to recalibrate it for the fourth: DVTipd4 <- DVTipd[DVTipd$cluster == 4, ] metamisc:::recalibrate(mp, newdata = DVTipd4) ``` -------------------------------- ### Display meta-analysis summary output Source: https://smartdata-analysis-and-statistics.github.io/metamisc/articles/ma-pm.html Example output showing the summary c-statistic with confidence and prediction intervals. ```text Summary c-statistic with 95% confidence and (approximate) 95% prediction interval: Estimate CIl CIu PIl PIu 0.7888603 0.7648784 0.8110005 0.6792568 0.8682736 Number of studies included: 23 ``` -------------------------------- ### Generate funnel plots Source: https://smartdata-analysis-and-statistics.github.io/metamisc/reference/plot.fat.html Examples demonstrating the creation of basic funnel plots and plots using alternative test methods. ```R data(Fibrinogen) b <- log(Fibrinogen$HR) b.se <- ((log(Fibrinogen$HR.975) - log(Fibrinogen$HR.025))/(2*qnorm(0.975))) n.total <- Fibrinogen$N.total # A very simple funnel plot plot(fat(b=b, b.se=b.se), xlab = "Log hazard ratio") # Plot the funnel for an alternative test plot(fat(b=b, b.se=b.se, n.total=n.total, method="M-FIV"), xlab = "Log hazard ratio") ``` -------------------------------- ### Generate meta-analysis distribution plots Source: https://smartdata-analysis-and-statistics.github.io/metamisc/reference/dplot.uvmeta.html Examples demonstrating how to visualize prior and posterior distributions for model parameters using the dplot function. ```R if (FALSE) { # \dontrun{ data(Roberts) fit <- with(Roberts, uvmeta(r=SDM, r.se=SE, method="BAYES")) dplot(fit) dplot(fit, distr_type = "posterior") dplot(fit, par = "tau", distr_type = "prior") dplot(fit, plot_type = "hist") } # } ``` -------------------------------- ### Example: Plotting a Frequentist Meta-analysis Source: https://smartdata-analysis-and-statistics.github.io/metamisc/reference/plot.uvmeta.html Demonstrates creating a forest plot from a frequentist random-effects meta-analysis using the Roberts dataset. ```R data(Roberts) # Frequentist random-effects meta-analysis fit <- with(Roberts, uvmeta(r=SDM, r.se=SE, labels=rownames(Roberts))) plot(fit) ``` -------------------------------- ### Generating a forest plot for a metapred fit Source: https://smartdata-analysis-and-statistics.github.io/metamisc/reference/forest.metapred.html Example demonstrating the creation of a metapred fit and the subsequent attempt to generate a forest plot. ```R data(DVTipd) # Internal-external cross-validation of a pre-specified model 'f' f <- dvt ~ histdvt + ddimdich + sex + notraum fit <- metapred(DVTipd, strata = "study", formula = f, scope = f, family = binomial) # Display the model's external performance (expressed as mean squared error by default) # for each study forest(fit) #> Error in forest.default(fit): Must specify either 'vi', 'sei', or ('ci.lb','ci.ub'). ``` -------------------------------- ### Example: Plotting autocorrelation for a fitted model Source: https://smartdata-analysis-and-statistics.github.io/metamisc/reference/acplot.valmeta.html Demonstrates fitting a Bayesian meta-analysis model using valmeta and visualizing the autocorrelation of the results. ```R if (FALSE) { # \dontrun{ data(EuroSCORE) fit <- valmeta(cstat=c.index, cstat.se=se.c.index, cstat.cilb=c.index.95CIl, cstat.ciub=c.index.95CIu, N=n, O=n.events, data=EuroSCORE, method="BAYES", slab=Study) acplot(fit) } # } ``` -------------------------------- ### Example: Imputing missing values Source: https://smartdata-analysis-and-statistics.github.io/metamisc/reference/impute_conditional_mean.html Demonstrates defining population parameters and imputing missing values in a partially observed sample. ```R # Define the population means mu <- c(0, 1, 2) # Define the covariance of the population Sigma <- diag(1,3) Sigma[1,2] <- Sigma[2,1] <- 0.3 Sigma[2,3] <- Sigma[3,2] <- 0.1 Sigma[1,3] <- Sigma[3,1] <- -0.2 # Generate a 'random' sample from the population that is partially observed x <- c(NA, 2, 4) # Impute the missing values impute_conditional_mean (x=x, mu=mu, Sigma=Sigma) #> [1] -0.1414141 2.0000000 4.0000000 ``` -------------------------------- ### Example: Plotting running means from a Bayesian meta-analysis Source: https://smartdata-analysis-and-statistics.github.io/metamisc/reference/rmplot.uvmeta.html Demonstrates fitting a Bayesian meta-analysis model using the Roberts dataset and visualizing the results with rmplot. ```R if (FALSE) { # \dontrun{ data(Roberts) fit <- with(Roberts, uvmeta(r=SDM, r.se=SE, labels=rownames(Roberts), method="BAYES")) rmplot(fit) } # } ``` -------------------------------- ### Example usage of gelmanplot Source: https://smartdata-analysis-and-statistics.github.io/metamisc/reference/gelmanplot.valmeta.html Demonstrates how to generate a plot after performing a Bayesian meta-analysis of the concordance statistic. ```R if (FALSE) { # \dontrun{ data(EuroSCORE) # Meta-analysis of the concordance statistic fit <- valmeta(cstat=c.index, cstat.se=se.c.index, cstat.cilb=c.index.95CIl, cstat.ciub=c.index.95CIu, N=n, O=n.events, data=EuroSCORE, method="BAYES", slab=Study) gelmanplot(fit) } # } ``` -------------------------------- ### Display Bayesian meta-analysis summary output Source: https://smartdata-analysis-and-statistics.github.io/metamisc/articles/ma-pm.html Example output showing the summary c-statistic with credibility and prediction intervals from the Bayesian model. ```text Summary c-statistic with 95% credibility and 95% prediction interval: Estimate CIl CIu PIl PIu 0.7885098 0.7648367 0.8123593 0.6800665 0.8775017 ``` -------------------------------- ### Example: Plotting autocorrelation for a Bayesian meta-analysis Source: https://smartdata-analysis-and-statistics.github.io/metamisc/reference/acplot.uvmeta.html Demonstrates fitting a Bayesian meta-analysis model using the Roberts dataset and visualizing the autocorrelation of the results. ```R if (FALSE) { # \dontrun{ data(Roberts) fit <- with(Roberts, uvmeta(r=SDM, r.se=SE, labels=rownames(Roberts), method="BAYES")) acplot(fit) } # } ``` -------------------------------- ### Load metafor package Source: https://smartdata-analysis-and-statistics.github.io/metamisc/reference/fat.html Initializes the metafor package to access statistical testing functions. ```R require(metafor) ``` -------------------------------- ### Calculate O:E ratio for binary outcome prediction models Source: https://smartdata-analysis-and-statistics.github.io/metamisc/reference/oecalc.html Example usage of the oecalc function with the EuroSCORE dataset. ```R ######### Validation of prediction models with a binary outcome ######### data(EuroSCORE) ``` -------------------------------- ### Extracting Models from Metapred Objects Source: https://smartdata-analysis-and-statistics.github.io/metamisc/reference/subset.metapred.html Demonstrates how to initialize a metapred object and use the subset function to extract various model configurations. ```R data(DVTipd) DVTipd$cluster <- letters[1:4] # Add a fictional clustering to the data. mp <- metapred(DVTipd, strata = "cluster", formula = dvt ~ histdvt + ddimdich, family = binomial) subset(mp) # best cross-validated model ``` ```R subset(mp, select = "global") # Final model fitted on all strata. ``` ```R subset(mp, step = 1) # The best model of step 1 ``` ```R subset(mp, step = 1, model = "histdvt") # The model in which histdvt was removed, in step 1. ``` -------------------------------- ### Load DVTipd dataset Source: https://smartdata-analysis-and-statistics.github.io/metamisc/reference/DVTipd.html Load the hypothetical dataset into the R environment. ```R data(DVTipd) ``` -------------------------------- ### Load and inspect DVTipd dataset Source: https://smartdata-analysis-and-statistics.github.io/metamisc/reference/DVTipd.html Load the dataset into the R environment and display its structure and summary statistics. ```R data(DVTipd) str(DVTipd) #> 'data.frame': 500 obs. of 16 variables: #> $ sex : num 0 1 0 1 0 0 1 0 1 0 ... #> $ malign : num 0 0 0 0 0 0 0 0 0 0 ... #> $ par : num 0 0 1 0 0 0 0 0 0 0 ... #> $ surg : num 0 0 0 0 0 0 0 0 1 0 ... #> $ tend : num 1 1 0 1 1 0 0 1 1 1 ... #> $ oachst : num 0 0 0 0 0 0 0 0 0 0 ... #> $ leg : num 1 0 0 0 0 1 1 0 0 0 ... #> $ notraum : num 1 1 1 1 1 0 0 1 0 1 ... #> $ calfdif3: num 0 0 0 0 0 0 0 0 0 0 ... #> $ pit : num 0 0 0 0 0 1 0 1 1 1 ... #> $ vein : num 0 0 0 0 1 0 0 0 0 1 ... #> $ altdiagn: num 1 0 1 1 1 0 1 1 1 1 ... #> $ histdvt : num 0 1 0 0 0 0 1 0 0 0 ... #> $ ddimdich: num 1 0 0 0 0 1 1 0 1 1 ... #> $ dvt : num 0 0 0 0 0 0 0 0 0 0 ... #> $ study : Factor w/ 4 levels "a","b","c","d": 1 4 1 4 1 4 4 4 4 2 ... summary(apply(DVTipd,2,as.factor)) #> sex malign par surg #> Length:500 Length:500 Length:500 Length:500 #> Class :character Class :character Class :character Class :character #> Mode :character Mode :character Mode :character Mode :character #> tend oachst leg notraum #> Length:500 Length:500 Length:500 Length:500 #> Class :character Class :character Class :character Class :character #> Mode :character Mode :character Mode :character Mode :character #> calfdif3 pit vein altdiagn #> Length:500 Length:500 Length:500 Length:500 #> Class :character Class :character Class :character Class :character #> Mode :character Mode :character Mode :character Mode :character #> histdvt ddimdich dvt study #> Length:500 Length:500 Length:500 Length:500 #> Class :character Class :character Class :character Class :character #> Mode :character Mode :character Mode :character Mode :character ``` -------------------------------- ### Perform univariate meta-analysis with uvmeta Source: https://smartdata-analysis-and-statistics.github.io/metamisc/reference/uvmeta-class.html Demonstrates creating a uvmeta object using effect sizes and variances from the Collins dataset. ```R data(Collins) #Extract effect size and error variance r <- Collins$logOR vars <- Collins$SE**2 #Frequentist random-effects meta-analysis fit1 <- uvmeta(r,vars) #Extract results fit1$results #> NULL ``` -------------------------------- ### Load Zhang Dataset Source: https://smartdata-analysis-and-statistics.github.io/metamisc/reference/Zhang.html Load the dataset into the R environment. ```R data("Zhang") ``` -------------------------------- ### Load required R packages Source: https://smartdata-analysis-and-statistics.github.io/metamisc/articles/ma-pf.html Load the metafor and metamisc packages to access functions for meta-analysis of prognosis studies. ```R library(metafor) library(metamisc) ``` -------------------------------- ### plot(x, ...) Source: https://smartdata-analysis-and-statistics.github.io/metamisc/reference/plot.valmeta.html Creates a forest plot for objects of class 'valmeta'. ```APIDOC ## plot(x, ...) ### Description Generates a forest plot showing performance estimates of each validation with corresponding confidence intervals. A summary estimate polygon is included, and a 95% prediction interval is added for random-effects models. ### Arguments - **x** (valmeta) - Required - An object of class "valmeta". - **...** (dots) - Optional - Additional arguments passed to forest. ### Value Returns an object of class ggplot. ### Examples ```r data(EuroSCORE) fit <- valmeta(cstat=c.index, cstat.se=se.c.index, cstat.cilb=c.index.95CIl, cstat.ciub=c.index.95CIu, N=n, O=n.events, data=EuroSCORE) plot(fit) library(ggplot2) plot(fit, theme=theme_grey()) ``` ``` -------------------------------- ### View the Zhang dataset structure Source: https://smartdata-analysis-and-statistics.github.io/metamisc/articles/ma-pf.html A tabular representation of the Zhang dataset showing study metadata and statistical estimates. ```text Study PrimaryAuthor year Country Disease N HR 1 Gonzalez-Rodilla 2013 Gonzalez-Rodilla 2013 Spain EC 126 1.14 2 Togami 2012 Togami 2012 Japan UPSC 71 3.00 3 Mori 2010 Mori 2010 Japan EEC 63 2.58 4 Jongen 2009-2 Jongen 2009 Netherlands EEC 315 0.66 5 Konecny 2009 Konecny 2009 USA EC 273 2.13 6 Odicino 2008 Odicino 2008 Italy UPSC 10 1.60 7 Santin 2005-2 Santin 2005 USA UPSC 30 5.19 8 Santin 2005-1 Santin 2005 USA UPSC 27 12.43 9 Backe 1997 Backe 1997 Germany EC 222 1.17 10 Kohlberger 1996 Kohlberger 1996 Australia EC 100 3.95 11 Saffari 2995 Saffari 1995 USA EC 75 5.25 12 Peiro 2004 Peiro 2004 Germany EC 10 1.64 13 Cianciulli 2003 Cianciulli 2003 Italy EC 73 1.90 14 Gates 2006 Gates 2006 USA EC 99 4.00 15 Togami 2012 Togami 2012 Japan UPSC 71 3.43 16 Mori 2010 Mori 2010 Japan EEC 63 3.80 17 Jongen 2009-2 Jongen 2009 Netherlands EEC 315 1.75 18 Coronado 2001 Coronado 2001 Spain EC 114 2.69 19 Backe 1997 Backe 1997 Germany EC 222 1.36 20 Voss 2011 Vos 2011 England EC 156 1.41 HR.025 HR.975 outcome 1 0.52 2.52 OS 2 1.15 7.01 OS 3 1.03 7.92 OS 4 0.10 4.28 OS 5 1.65 2.73 OS 6 0.89 2.89 OS 7 1.52 17.64 OS 8 1.57 98.28 OS 9 0.93 1.49 OS 10 1.07 14.69 OS 11 1.33 20.74 OS 12 1.04 2.57 OS 13 0.83 4.36 OS 14 0.77 20.80 OS 15 1.50 7.23 PFS 16 1.29 12.35 PFS 17 0.23 13.08 PFS 18 1.35 5.37 PFS 19 0.65 2.85 PFS 20 0.51 3.88 PFS ``` -------------------------------- ### Alternative Meta-Analysis Syntax Source: https://smartdata-analysis-and-statistics.github.io/metamisc/articles/ma-pf.html Demonstrates the default rma function call which yields the same results as the explicit REML method. ```R # The following approach yields the same results # rma(yi=logHR, sei=se.logHR, subset=(outcome=="OS"), data=Zhang) ``` -------------------------------- ### plot(x, sort = "asc", ...) Source: https://smartdata-analysis-and-statistics.github.io/metamisc/reference/plot.uvmeta.html Generates a forest plot for a 'uvmeta' object, displaying performance estimates, confidence intervals, and summary estimates. ```APIDOC ## plot(x, sort = "asc", ...) ### Description Creates a forest plot for objects of class "uvmeta". The plot displays performance estimates of each validation with corresponding confidence intervals and a summary estimate polygon. ### Arguments - **x** (uvmeta) - Required - An object of class "uvmeta". - **sort** (string) - Optional - Determines study ordering. Use "asc" for ascending effect size, "desc" for descending, or any other value to ignore ordering. Defaults to "asc". - **...** (dots) - Optional - Additional arguments passed to forest. ### Example ```R data(Roberts) fit <- with(Roberts, uvmeta(r=SDM, r.se=SE, labels=rownames(Roberts))) plot(fit) ``` ``` -------------------------------- ### Usage of summary method for riley objects Source: https://smartdata-analysis-and-statistics.github.io/metamisc/reference/summary.riley.html Standard S3 method signature for generating parameter summaries from a riley object. ```R # S3 method for class 'riley' summary(object, ...) ``` -------------------------------- ### Load Roberts dataset Source: https://smartdata-analysis-and-statistics.github.io/metamisc/reference/Roberts.html Load the Roberts dataset into the R environment for analysis. ```R data("Roberts") ``` -------------------------------- ### Load Kertai dataset Source: https://smartdata-analysis-and-statistics.github.io/metamisc/reference/Kertai.html Load the Kertai dataset into the R environment for analysis. ```R data("Kertai") ``` -------------------------------- ### Perform Meta-Analysis with Riley Source: https://smartdata-analysis-and-statistics.github.io/metamisc/reference/riley.html Demonstrates fitting meta-analysis models to various datasets including Daniels, Kertai, and Scheidler. ```R data(Scheidler) data(Daniels) data(Kertai) # Meta-analysis of potential surrogate markers data # The results obtained by Riley (2008) were as follows: # beta1 = -0.042 (SE = 0.063), # beta2 = 14.072 (SE = 4.871) # rho = -0.759 if (FALSE) { # \dontrun{ fit1 <- riley(Daniels) #maxit reached, try again with more iterations } # } fit1 <- riley(Daniels, control=list(maxit=10000)) summary(fit1) #> Call: #> riley.default(X = Daniels, control = list(maxit = 10000)) #> #> Estimate SE 2.5 % 97.5 % #> beta1 0.005298983 0.06479973 -0.12170616 0.1323041 #> beta2 13.505678310 4.99256719 3.72042644 23.2909302 #> psi1 0.134785102 0.09190903 -0.04535329 0.3149235 #> psi2 18.076027226 4.00992798 10.21671280 25.9353417 #> rho -0.748689375 0.15266774 -0.89430728 -0.4596724 # Meta-analysis of prognostic test studies fit2 <- riley(Kertai) fit2 #> Call: #> riley.default(X = Kertai) #> #> Coefficients #> beta1 beta2 psi1 psi2 rho #> 0.8164679 -0.9715821 0.3499043 0.7692122 0.1537878 #> #> Degrees of Freedom: 9 Residual # Meta-analysis of computed tomography data ds <- Scheidler[which(Scheidler$modality==1),] fit3 <- riley(ds) fit3 #> Call: #> riley.default(X = ds) #> #> Coefficients #> beta1 beta2 psi1 psi2 rho #> -0.01731291 -2.32166611 0.71181410 0.38103153 0.70119871 #> #> Degrees of Freedom: 29 Residual ``` -------------------------------- ### Perform two-stage meta-analysis of O:E ratios Source: https://smartdata-analysis-and-statistics.github.io/metamisc/reference/valmeta.html Conducts a two-stage meta-analysis of O:E ratios using different input configurations. ```R valmeta(measure="OE", O=n.events, E=e.events, N=n, slab=Study, data=EuroSCORE) ``` ```R valmeta(measure="OE", O=n.events, E=e.events, data=EuroSCORE) ``` ```R valmeta(measure="OE", Po=Po, Pe=Pe, N=n, data=EuroSCORE) ``` -------------------------------- ### Explore Fibrinogen Dataset Source: https://smartdata-analysis-and-statistics.github.io/metamisc/reference/Fibrinogen.html Basic commands to inspect the structure or visualize the loaded dataset. ```R data(Fibrinogen) ## maybe str(Fibrinogen) ; plot(Fibrinogen) ... ``` -------------------------------- ### Estimate Generalizability Source: https://smartdata-analysis-and-statistics.github.io/metamisc/reference/metapred.html Use gen() to retrieve generalizability estimates. Setting genFUN to 0 returns all available estimates. ```R gen(fit2, genFUN = 0) ``` -------------------------------- ### Load EuroSCORE data Source: https://smartdata-analysis-and-statistics.github.io/metamisc/articles/ma-pm.html Load the metamisc library and the EuroSCORE dataset for analysis. ```R library(metamisc) data(EuroSCORE) ``` -------------------------------- ### Load EuroSCORE dataset Source: https://smartdata-analysis-and-statistics.github.io/metamisc/reference/EuroSCORE.html Load the EuroSCORE dataset into the R environment for analysis. ```R data("EuroSCORE") ``` ```R data(EuroSCORE) ``` -------------------------------- ### data("impact") Source: https://smartdata-analysis-and-statistics.github.io/metamisc/reference/impact.html Loads the IMPACT dataset into the R environment. ```APIDOC ## Load Dataset ### Description Loads the IMPACT dataset, which consists of 11,022 observations from 15 studies regarding traumatic brain injury. ### Usage ```r data("impact") ``` ### Variables - **name** (string) - Name of the study - **type** (string) - Type of study (RCT or OBS) - **age** (numeric) - Age of the patient - **motor_score** (numeric) - Glasgow Coma Scale motor score - **pupil** (numeric) - Pupillary reactivity - **ct** (numeric) - Marshall Computerized Tomography classification - **hypox** (numeric) - Hypoxia (0=no, 1=yes) - **hypots** (numeric) - Hypotension (0=no, 1=yes) - **tsah** (numeric) - Traumatic subarachnoid hemorrhage (0=no, 1=yes) - **edh** (numeric) - Epidural hematoma (0=no, 1=yes) - **mort** (numeric) - 6-month mortality (0=alive, 1=dead) ``` -------------------------------- ### uvmeta() Source: https://smartdata-analysis-and-statistics.github.io/metamisc/reference/index.html Performs a univariate meta-analysis. ```APIDOC ## uvmeta() ### Description Performs a univariate meta-analysis. Returns an object of class 'uvmeta'. ``` -------------------------------- ### Usage of stackedglm Source: https://smartdata-analysis-and-statistics.github.io/metamisc/reference/stackedglm.html Basic syntax for calling the stackedglm function to create a meta-model. ```R stackedglm(models, family = binomial, data) ``` -------------------------------- ### Summarize uvmeta model Source: https://smartdata-analysis-and-statistics.github.io/metamisc/reference/summary.uvmeta.html Use this S3 method to generate summary statistics for a fitted univariate meta-analysis model object. ```R # S3 method for class 'uvmeta' summary(object, ...) ``` -------------------------------- ### Load DVTmodels dataset Source: https://smartdata-analysis-and-statistics.github.io/metamisc/reference/DVTmodels.html Loads the DVTmodels dataset into the R environment for analysis. ```R data(DVTmodels) ``` -------------------------------- ### Load Tzoulaki dataset Source: https://smartdata-analysis-and-statistics.github.io/metamisc/reference/Tzoulaki.html Load the dataset into the R environment for analysis. ```R data("Tzoulaki") ``` -------------------------------- ### Load Collins dataset Source: https://smartdata-analysis-and-statistics.github.io/metamisc/reference/Collins.html Loads the Collins dataset into the R environment for analysis. ```R data(Collins) ``` -------------------------------- ### Perform Bayesian one-stage random effects meta-analysis of the total O:E ratio Source: https://smartdata-analysis-and-statistics.github.io/metamisc/reference/valmeta.html Configures a Bayesian model with specific priors and handles missing N values by switching between Poisson and Binomial distributions. ```R EuroSCORE.new <- EuroSCORE EuroSCORE.new$n[c(1, 2, 5, 10, 20)] <- NA pars <- list(hp.tau.dist="dhalft", # Prior for the between-study standard deviation hp.tau.sigma=1.5, # Standard deviation for 'hp.tau.dist' hp.tau.df=3, # Degrees of freedom for 'hp.tau.dist' hp.tau.max=10, # Maximum value for the between-study standard deviation seed=5) # Set random seed for the simulations fit3 <- valmeta(measure="OE", O=n.events, E=e.events, N=n, data=EuroSCORE.new, method="BAYES", slab=Study, pars=pars) plot(fit3) print(fit3$fit$model) # Inspect the JAGS model print(fit3$fit$data) # Inspect the JAGS data ``` -------------------------------- ### Perform frequentist random-effects meta-analysis with uvmeta Source: https://smartdata-analysis-and-statistics.github.io/metamisc/reference/uvmeta.html Executes a random-effects meta-analysis using the Roberts dataset and displays the summary and forest plot. ```R data(Roberts) # Frequentist random-effects meta-analysis fit1 <- with(Roberts, uvmeta(r=SDM, r.se=SE, labels=rownames(Roberts))) summary(fit1) #> Call: #> uvmeta.default(r = SDM, r.se = SE, labels = rownames(Roberts)) #> #> Random effects summary: 0.36195 (SE: 0.0859) #> Tau squared: 0.01322 (SE: 0.03431) plot(fit1) #show a forest plot fit1 #> Summary estimate with 95% confidence and (approximate) 95% prediction interval: #> #> Estimate CIl CIu PIl PIu #> 0.36194806 0.17636909 0.54752703 0.04923206 0.67466405 ``` -------------------------------- ### summary.riley(object, ...) Source: https://smartdata-analysis-and-statistics.github.io/metamisc/reference/summary.riley.html Computes summary estimates and confidence intervals for a riley object, assuming asymptotic normality for confidence intervals. ```APIDOC ## summary.riley(object, ...) ### Description Provides the summary estimates of the alternative model for bivariate random-effects meta-analysis by Riley et al. (2008) with their corresponding standard errors. For confidence intervals, asymptotic normality is assumed. ### Usage summary(object, ...) ### Arguments - **object** (riley) - Required - A riley object. - **...** (dots) - Optional - Arguments to be passed on to other functions (currently ignored). ### Value Returns an array with confidence intervals for the estimated model parameters. For diagnostic test accuracy data, the resulting summary sensitivity and false positive rate are included. ``` -------------------------------- ### Explore Tzoulaki dataset Source: https://smartdata-analysis-and-statistics.github.io/metamisc/reference/Tzoulaki.html Basic commands to inspect the structure or visualize the dataset. ```R data(Tzoulaki) ## maybe str(Tzoulaki) ; plot(Tzoulaki) ... ``` -------------------------------- ### Load Fibrinogen Dataset Source: https://smartdata-analysis-and-statistics.github.io/metamisc/reference/Fibrinogen.html Load the dataset into the R environment for analysis. ```R data("Fibrinogen") ``` -------------------------------- ### Generate Forest Plot using Metafor Source: https://smartdata-analysis-and-statistics.github.io/metamisc/articles/ma-pf.html Creates a forest plot for overall survival using the metafor package. ```r metafor::forest(x = Zhang$HR, ci.lb = Zhang$HR.025, ci.ub = Zhang$HR.975, slab = Zhang$Study, subset = (Zhang$outcome=="OS"), xlab = "Hazard ratio of HER2 versus OS", refline = 1) ``` -------------------------------- ### Display Bayesian model object Source: https://smartdata-analysis-and-statistics.github.io/metamisc/articles/ma-pm.html Command to inspect the fitted Bayesian model object. ```R fit ``` -------------------------------- ### Load Framingham dataset Source: https://smartdata-analysis-and-statistics.github.io/metamisc/reference/Framingham.html Load the Framingham dataset into the R environment. ```R data("Framingham") ``` ```R data(Framingham) ``` -------------------------------- ### oecalc(OE, OE.se, OE.cilb, OE.ciub, OE.cilv, EO, EO.se, citl, citl.se, N, O, E, Po, Po.se, Pe, data, slab, add, g, level, ...) Source: https://smartdata-analysis-and-statistics.github.io/metamisc/reference/oecalc.html Calculates the ratio of total observed versus expected events with the corresponding sampling variance. ```APIDOC ## oecalc ### Description This function calculates (transformed versions of) the ratio of total number of observed versus expected events with the corresponding sampling variance. ### Arguments - **OE** (vector) - Optional - Estimated ratio of total observed versus total expected events. - **OE.se** (vector) - Optional - Standard errors of the estimated O:E ratios. - **OE.cilb** (vector) - Optional - Lower limits of the confidence interval for OE. - **OE.ciub** (vector) - Optional - Upper limits of the confidence interval for OE. - **OE.cilv** (vector) - Optional - Levels of confidence interval limits (default: 0.95). - **EO** (vector) - Optional - Estimated ratio of total expected versus total observed events. - **EO.se** (vector) - Optional - Standard errors of the estimated E:O ratios. - **citl** (vector) - Optional - Estimated calibration-in-the-large statistics. - **citl.se** (vector) - Optional - Standard error of the calibration-in-the-large statistics. - **N** (vector) - Optional - Sample/group sizes. - **O** (vector) - Optional - Total number of observed events. - **E** (vector) - Optional - Total number of expected events. - **Po** (vector) - Optional - (Cumulative) observed event probabilities. - **Po.se** (vector) - Optional - Standard errors of Po. - **Pe** (vector) - Optional - (Cumulative) expected event probabilities. - **data** (data.frame) - Optional - Data frame containing the variables. - **slab** (vector) - Optional - Labels for the studies. - **add** (numeric) - Optional - Amount to add to zero counts (default: 1/2). - **g** (string) - Optional - Function to transform estimates of the total O:E ratio. - **level** (numeric) - Optional - Level for confidence interval (default: 0.95). ### Value Returns an object of class c("mm_perf","data.frame") with columns: - **theta**: The (transformed) O:E ratio. - **theta.se**: Standard errors of the (transformed) O:E ratio. - **theta.cilb**: Lower confidence interval of the (transformed) O:E ratios. - **theta.ciub**: Upper confidence interval of the (transformed) O:E ratios. - **theta.source**: Method used for calculating the (transformed) O:E ratio. - **theta.se.source**: Method used for calculating the standard error of the (transformed) O:E ratio. ``` -------------------------------- ### riley(X, control) Source: https://smartdata-analysis-and-statistics.github.io/metamisc/reference/riley.html Performs a meta-analysis on the provided dataset X. The control parameter allows for configuration of optimization settings such as maximum iterations. ```APIDOC ## riley(X, control) ### Description Performs meta-analysis on a given dataset. This function is used to estimate parameters for surrogate markers, prognostic test studies, or other statistical data. ### Parameters - **X** (data.frame) - Required - The dataset containing the study information to be analyzed. - **control** (list) - Optional - A list of control parameters for the optimization process, such as 'maxit' for maximum iterations. ### Returns - **fit** (object) - An object containing the estimated coefficients (beta1, beta2, psi1, psi2, rho) and model summary information. ``` -------------------------------- ### Calculate O:E ratio using oecalc Source: https://smartdata-analysis-and-statistics.github.io/metamisc/reference/oecalc.html Computes the O:E ratio and associated statistics from observed events, expected events, and total sample size. ```R est1 <- oecalc(O = n.events, E = e.events, N = n, data = EuroSCORE, slab = Study) est1 ``` -------------------------------- ### Load Scheidler dataset Source: https://smartdata-analysis-and-statistics.github.io/metamisc/reference/Scheidler.html Load the Scheidler dataset into the R environment. ```R data("Scheidler") ``` -------------------------------- ### Generate a Forest Plot for valmeta Source: https://smartdata-analysis-and-statistics.github.io/metamisc/reference/plot.valmeta.html Basic usage of the plot function on a valmeta object to visualize performance estimates. ```R data(EuroSCORE) fit <- valmeta(cstat=c.index, cstat.se=se.c.index, cstat.cilb=c.index.95CIl, cstat.ciub=c.index.95CIu, N=n, O=n.events, data=EuroSCORE) plot(fit) ``` ```R library(ggplot2) plot(fit, theme=theme_grey()) ``` -------------------------------- ### metapred(...) Source: https://smartdata-analysis-and-statistics.github.io/metamisc/reference/metapred.html Builds a generalizable model from data. ```APIDOC ## metapred(data, strata, formula, scope, family, ...) ### Description Constructs a generalizable model from the provided dataset. ### Parameters - **data** (data.frame) - Required - The dataset to use. - **strata** (string) - Required - The variable name used for stratification. - **formula** (formula) - Required - The model formula. - **scope** (formula) - Optional - The scope for model selection. - **family** (family) - Required - The error distribution and link function (e.g., binomial). ``` -------------------------------- ### Generate a forest plot with forest.default Source: https://smartdata-analysis-and-statistics.github.io/metamisc/reference/forest.default.html Use this S3 method to visualize meta-analysis results including study-specific effect sizes and summary estimates. ```R # Default S3 method forest( theta, theta.ci.lb, theta.ci.ub, theta.slab, theta.summary, theta.summary.ci.lb, theta.summary.ci.ub, theta.summary.pi.lb, theta.summary.pi.ub, title, sort = "asc", theme = theme_bw(), predint.linetype = 1, xlim, xlab = "", refline = 0, label.summary = "Summary Estimate", label.predint = "Prediction Interval", nrows.before.summary = 1, study.digits = 2, study.shape = 15, col.diamond = "white", col.predint = "black", size.study = 0.5, size.predint = 1, lty.ref = "dotted", ... ) ``` -------------------------------- ### Transform O:E ratio to log scale Source: https://smartdata-analysis-and-statistics.github.io/metamisc/articles/ma-pm.html Applies a natural logarithm transformation to the O:E ratio for meta-analysis preparation. ```R EuroSCORE <- EuroSCORE %>% mutate(logoe = log(oe)) ``` -------------------------------- ### uvmeta(r, r.se, r.vi, method, test, labels, na.action, n.chains, pars, verbose, ...) Source: https://smartdata-analysis-and-statistics.github.io/metamisc/reference/uvmeta.html Summarizes multiple estimates for a single parameter by assuming a fixed or random effects model across studies. ```APIDOC ## uvmeta(r, r.se, r.vi, method = "REML", test = "knha", labels, na.action, n.chains = 4, pars, verbose = FALSE, ...) ### Description This function summarizes multiple estimates for a single parameter by assuming a fixed or random effects model across studies. It calculates a weighted mean accounting for sample size and between-study heterogeneity. ### Parameters - **r** (numeric vector) - Required - Effect size of each study. - **r.se** (numeric vector) - Optional - Standard error of the effect sizes. - **r.vi** (numeric vector) - Optional - Sampling variance of the effect sizes. - **method** (string) - Optional - Model type: "FE" for fixed-effect, or random-effects methods: "REML" (default), "DL", "HE", "SJ", "ML", "EB", "HS", "GENQ", "BAYES". - **test** (string) - Optional - Method for test statistics and confidence intervals (default "knha"). - **labels** (character vector) - Optional - Labels for the studies. - **na.action** (function) - Optional - Handling of NAs (default "na.fail"). - **n.chains** (numeric) - Optional - Number of chains for Gibbs sampler when method is "BAYES" (default 4). - **pars** (list) - Optional - Additional configuration parameters for MCMC sampling and interval levels. - **verbose** (boolean) - Optional - Display messages during fitting (default FALSE). - **...** - Optional - Additional arguments passed to rma or runjags. ``` -------------------------------- ### Usage of dplot for mcmc.list Source: https://smartdata-analysis-and-statistics.github.io/metamisc/reference/dplot.mcmc.list.html Displays the S3 method signature for plotting posterior distributions from mcmc.list objects. ```R # S3 method for class 'mcmc.list' dplot(x, P, plot_type = "dens", ...) ``` -------------------------------- ### Obtain generalizability estimates Source: https://smartdata-analysis-and-statistics.github.io/metamisc/reference/gen.html Use these functions to retrieve generalizability estimates from a metapred model object. The ellipsis parameter allows passing arguments to subset.metapred for specific model selection. ```R gen(object, ...) generalizability(object, ...) ``` -------------------------------- ### Load Daniels dataset Source: https://smartdata-analysis-and-statistics.github.io/metamisc/reference/Daniels.html Load the Daniels dataset into the R environment. ```R data("Daniels") ``` -------------------------------- ### Obtain performance estimates using perf and performance Source: https://smartdata-analysis-and-statistics.github.io/metamisc/reference/perf.html Use these functions to retrieve performance metrics from a metapred object. By default, the final model is selected, but additional arguments can be passed to subset.metapred to target specific models. ```R perf(object, ...) performance(object, ...) ``` -------------------------------- ### Define oecalc function parameters Source: https://smartdata-analysis-and-statistics.github.io/metamisc/reference/oecalc.html Function signature for oecalc showing available arguments for calculating O:E ratios. ```R oecalc( OE, OE.se, OE.cilb, OE.ciub, OE.cilv, EO, EO.se, citl, citl.se, N, O, E, Po, Po.se, Pe, data, slab, add = 1/2, g = NULL, level = 0.95, ... ) ``` -------------------------------- ### Calculate log of O:E ratio in R Source: https://smartdata-analysis-and-statistics.github.io/metamisc/reference/oecalc.html Computes the log of the O:E ratio using observed events, expected events, and total sample size. ```R est2 <- oecalc(O = n.events, E = e.events, N = n, data = EuroSCORE, slab = Study, g = "log(OE)") est2 ``` -------------------------------- ### Perform one-stage meta-analysis of O:E ratios Source: https://smartdata-analysis-and-statistics.github.io/metamisc/reference/valmeta.html Conducts a one-stage meta-analysis using maximum likelihood estimation. ```R valmeta(measure="OE", O=n.events, E=e.events, data=EuroSCORE, method="ML", pars=list(model.oe="poisson/log")) ``` -------------------------------- ### inv.logit(x) Source: https://smartdata-analysis-and-statistics.github.io/metamisc/reference/inv.logit.html Transforms a linear predictor into a probability. ```APIDOC ## inv.logit(x) ### Description Transforms a linear predictor into a probability. ### Usage inv.logit(x) ### Arguments - **x** (numeric vector) - Required - A vector of numerics (between -Inf and Inf). ### Value A vector of numerics between 0 and 1. ``` -------------------------------- ### Load IMPACT dataset Source: https://smartdata-analysis-and-statistics.github.io/metamisc/reference/impact.html Loads the IMPACT dataset into the R environment. ```R data("impact") ``` -------------------------------- ### Inspect the Zhang dataset Source: https://smartdata-analysis-and-statistics.github.io/metamisc/articles/ma-pf.html Displays the contents of the Zhang object, which includes study details, hazard ratios, and survival outcomes. ```R Zhang ``` -------------------------------- ### plot(x, title, sort = "asc", xlim, refline, ...) Source: https://smartdata-analysis-and-statistics.github.io/metamisc/reference/plot.riley.html Generates a forest plot for each outcome of the bivariate meta-analysis. ```APIDOC ## plot(x, title, sort = "asc", xlim, refline, ...) ### Description Generates a forest plot for each outcome of the bivariate meta-analysis based on the Riley et al. (2008) model. ### Arguments - **x** (riley) - Required - An object of class 'riley'. - **title** (string) - Optional - Title of the forest plot. - **sort** (string) - Optional - Determines study ordering. Use "asc" for ascending effect size, "desc" for descending, or any other value to ignore ordering. Defaults to "asc". - **xlim** (numeric) - Optional - The x limits (x1, x2) of the forest plot. - **refline** (numeric) - Optional - A numeric value specifying a reference line. - **...** (dots) - Optional - Additional parameters for generating forest plots. ### Example ```r data(Scheidler) fit <- riley(Scheidler[which(Scheidler$modality==1),]) plot(fit) ``` ``` -------------------------------- ### Usage of dplot for valmeta objects Source: https://smartdata-analysis-and-statistics.github.io/metamisc/reference/dplot.valmeta.html Standard signature for the dplot S3 method. ```R # S3 method for class 'valmeta' dplot(x, par, distr_type, plot_type = "dens", ...) ``` -------------------------------- ### Load and Summarize IMPACT Data Source: https://smartdata-analysis-and-statistics.github.io/metamisc/reference/impact.html Load the dataset and generate summary statistics grouped by study name. ```R data(impact) by(impact, impact$name, summary) ``` -------------------------------- ### Usage of gelmanplot Source: https://smartdata-analysis-and-statistics.github.io/metamisc/reference/gelmanplot.html Basic syntax for calling the gelmanplot function. ```R gelmanplot(...) ``` -------------------------------- ### Usage of rmplot for valmeta objects Source: https://smartdata-analysis-and-statistics.github.io/metamisc/reference/rmplot.valmeta.html Standard S3 method signature for plotting running means from a valmeta object. ```R # S3 method for class 'valmeta' rmplot(x, ...) ``` -------------------------------- ### Perform frequentist meta-analysis of c-statistics Source: https://smartdata-analysis-and-statistics.github.io/metamisc/articles/ma-pm.html Uses the valmeta function with REML estimation and Hartung-Knapp-Sidik-Jonkman adjustments to summarize c-statistics. ```R valmeta(cstat = c.index, cstat.se = se.c.index, cstat.cilb = c.index.95CIl, cstat.ciub = c.index.95CIu, N = n, O = n.events, method = "REML", test = "knha", slab = Study, data = EuroSCORE) ``` -------------------------------- ### Usage of acplot for Bayesian meta-analysis Source: https://smartdata-analysis-and-statistics.github.io/metamisc/reference/acplot.valmeta.html Displays the syntax for the S3 method acplot applied to a valmeta object. ```R # S3 method for class 'valmeta' acplot(x, ...) ``` -------------------------------- ### Usage of rmplot for uvmeta objects Source: https://smartdata-analysis-and-statistics.github.io/metamisc/reference/rmplot.uvmeta.html Standard S3 method signature for plotting running means from a uvmeta object. ```R # S3 method for class 'uvmeta' rmplot(x, ...) ```