Skip to content

Commit

Permalink
updated pcurve function to work with data session key instead of data…
Browse files Browse the repository at this point in the history
… name
  • Loading branch information
Rostu committed Nov 26, 2024
1 parent ccfae89 commit 195b55e
Showing 1 changed file with 37 additions and 36 deletions.
73 changes: 37 additions & 36 deletions R/pcurves.R
Original file line number Diff line number Diff line change
@@ -1,36 +1,37 @@
#' @title Plot pcurve
#' @description
#' Using the R package meta to calculate a random effects meta-analysis based on estimates (e.g. log hazard ratios) and their standard errors. Afterwards using dmetar package to create a pcurve plot.
#' @param yi
#' A \code{string} of the variable which holds the vector of length k with the observed effect sizes or outcomes in the selected dataset (d)
#' @param vi
#' A \code{string} of the variable which holds the vector of length k with the corresponding sampling variances in the selected dataset (d)
#' @param d
#' A \code{string} representing the dataset name that should be used for fitting.
#' @param measure
#' A character string indicating underlying summary measure
#' @return returns a pcurve plot
#' @author Robert Studtrucker
#' @export
pcurves<-function(yi,vi,measure,d) {

requireNamespace("dmetar")
requireNamespace("meta")


#load the in variable d defined dataset from the package
dat <- checkData(d)
checkParameter(dat,c(yi,vi))

#Filtern auf nur peer reviewed arcticles
dat<-dat[dat$r_peer=="yes",]

# meta-Model
overall.meta <- meta::metagen(TE=dat[,yi], seTE=sqrt(dat[,vi]),data = dat, studlab = paste(r_author),
comb.fixed = FALSE,comb.random = TRUE,method.tau = "SJ",
hakn = TRUE,prediction = TRUE,sm = measure)

# p-curve
dmetar::pcurve(overall.meta)

}
#' @title Plot pcurve
#' @description
#' Using the R package meta to calculate a random effects meta-analysis based on estimates (e.g. log hazard ratios) and their standard errors. Afterwards using dmetar package to create a pcurve plot.
#' @param yi
#' A \code{string} of the variable which holds the vector of length k with the observed effect sizes or outcomes in the selected dataset (d)
#' @param vi
#' A \code{string} of the variable which holds the vector of length k with the corresponding sampling variances in the selected dataset (d)
#' @param d
#' A \code{string} representing the dataset name that should be used for fitting.
#' @param measure
#' A character string indicating underlying summary measure
#' @return returns a pcurve plot
#' @author Robert Studtrucker
#' @export
pcurves<-function(yi,vi,measure,d) {

requireNamespace("dmetar")
requireNamespace("meta")


#load the in variable d defined dataset from the package
#dat <- checkData(d)
dat <- d
checkParameter(dat,c(yi,vi))

#Filter peer reviewed articles
dat<-dat[dat$r_peer=="yes",]

# meta-Model
overall.meta <- meta::metagen(TE=dat[,yi], seTE=sqrt(dat[,vi]),data = dat, studlab = paste(r_author),
comb.fixed = FALSE,comb.random = TRUE,method.tau = "SJ",
hakn = TRUE,prediction = TRUE,sm = measure)

# p-curve
dmetar::pcurve(overall.meta)

}

0 comments on commit 195b55e

Please sign in to comment.