|
1 | | -#' @title Funnel plot |
2 | | -#' @description |
3 | | -#' Using metafor package to create a funnel plot. |
4 | | -#' @param yi |
5 | | -#' 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) |
6 | | -#' @param vi |
7 | | -#' A \code{string} of the variable which holds the vector of length k with the corresponding sampling variances in the selected dataset (d) |
8 | | -#' @param d |
9 | | -#' A \code{string} representing the dataset name that should be used for fitting. |
10 | | -#' @param effectName |
11 | | -#' A \code{string} representing the effect name that should be printed as label. defaults to "Effect" |
12 | | -#' @param measure |
13 | | -#' A character string indicating underlying summary measure. |
14 | | -#' @return |
15 | | -#' returns a Funnel plot for the given dataset |
16 | | -#' @author Robert Studtrucker |
17 | | -#' @export |
18 | | -funnelPLot <- function(yi,vi,measure,d,peer="no", effectName="Effect") { |
19 | | - |
20 | | - requireNamespace("metafor") |
21 | | - |
22 | | - #load the in variable d defined dataset from the package |
23 | | - dat <- checkData(d) |
24 | | - checkParameter(dat,c(yi,vi,"r_peer")) |
25 | | - |
26 | | - # Filtern nach veröffentlichten Studien wenn in der Anwendung ausgewählt (peer reviewed yes/no) |
27 | | - # Per default werden alle Studien mit einbezogen |
28 | | - if(peer == "yes"){ |
29 | | - filtered_dat <- subset(dat,r_peer=="yes") |
30 | | - }else{ |
31 | | - filtered_dat<-dat |
32 | | - } |
33 | | - |
34 | | - if(measure == "COR") { |
35 | | - # z-standardisierte Daten erstellen |
36 | | - temp_dat <- metafor::escalc(measure="ZCOR", ri=filtered_dat[,yi], vi=filtered_dat[,vi], ni=filtered_dat[,"o_ni"], data=filtered_dat, var.names=c("o_zcor","o_zcor_var")) |
37 | | - |
38 | | - # Modell berechnen |
39 | | - rma_model <- metafor::rma.uni(temp_dat[,"o_zcor"],temp_dat[,"o_zcor_var"], measure="ZCOR") |
40 | | - |
41 | | - RTest <-metafor::regtest(x=rma_model) |
42 | | - metafor::funnel(rma_model, yaxis="sei") # 'label' |
43 | | - metafor::funnel(rma_model, level=c(90, 95, 99), shade=c("white", "orange", "red"), refline=0, legend=TRUE) |
44 | | - gc() # Force R to release memory it is no longer using |
45 | | - |
46 | | - return(RTest) |
47 | | - |
48 | | - }else{ |
49 | | - rma_model <- metafor::rma.uni(yi=filtered_dat[,yi],vi=filtered_dat[,vi],measure=measure) |
50 | | - RTest <-metafor::regtest(x=rma_model) |
51 | | - |
52 | | - metafor::funnel(rma_model, yaxis="sei") # 'label' |
53 | | - metafor::funnel(rma_model, level=c(90, 95, 99), shade=c("white", "orange", "red"), refline=0, legend=TRUE) |
54 | | - gc() # Force R to release memory it is no longer using |
55 | | - |
56 | | - return(RTest) |
57 | | - } |
58 | | - |
59 | | - |
60 | | -} |
| 1 | +#' @title Funnel plot |
| 2 | +#' @description |
| 3 | +#' Using metafor package to create a funnel plot. |
| 4 | +#' @param yi |
| 5 | +#' 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) |
| 6 | +#' @param vi |
| 7 | +#' A \code{string} of the variable which holds the vector of length k with the corresponding sampling variances in the selected dataset (d) |
| 8 | +#' @param d |
| 9 | +#' A \code{string} representing the dataset name that should be used for fitting. |
| 10 | +#' @param effectName |
| 11 | +#' A \code{string} representing the effect name that should be printed as label. defaults to "Effect" |
| 12 | +#' @param measure |
| 13 | +#' A character string indicating underlying summary measure. |
| 14 | +#' @return |
| 15 | +#' returns a Funnel plot for the given dataset |
| 16 | +#' @author Robert Studtrucker |
| 17 | +#' @export |
| 18 | +funnelPlot <- function(yi,vi,measure,d,peer="no", effectName="Effect") { |
| 19 | + |
| 20 | + requireNamespace("metafor") |
| 21 | + |
| 22 | + #load the in variable d defined dataset from the package |
| 23 | + dat <- d |
| 24 | + checkParameter(dat,c(yi,vi,"r_peer")) |
| 25 | + |
| 26 | + # Filtern nach veröffentlichten Studien wenn in der Anwendung ausgewählt (peer reviewed yes/no) |
| 27 | + # Per default werden alle Studien mit einbezogen |
| 28 | + if(peer == "yes"){ |
| 29 | + filtered_dat <- subset(dat,r_peer=="yes") |
| 30 | + }else{ |
| 31 | + filtered_dat<-dat |
| 32 | + } |
| 33 | + |
| 34 | + if(measure == "COR") { |
| 35 | + # z-standardisierte Daten erstellen |
| 36 | + temp_dat <- metafor::escalc(measure="ZCOR", ri=filtered_dat[,yi], vi=filtered_dat[,vi], ni=filtered_dat[,"o_ni"], data=filtered_dat, var.names=c("o_zcor","o_zcor_var")) |
| 37 | + |
| 38 | + # Modell berechnen |
| 39 | + rma_model <- metafor::rma.uni(temp_dat[,"o_zcor"],temp_dat[,"o_zcor_var"], measure="ZCOR") |
| 40 | + |
| 41 | + RTest <-metafor::regtest(x=rma_model) |
| 42 | + metafor::funnel(rma_model, yaxis="sei") # 'label' |
| 43 | + metafor::funnel(rma_model, level=c(90, 95, 99), shade=c("white", "orange", "red"), refline=0, legend=TRUE) |
| 44 | + gc() # Force R to release memory it is no longer using |
| 45 | + |
| 46 | + return(RTest) |
| 47 | + |
| 48 | + }else{ |
| 49 | + rma_model <- metafor::rma.uni(yi=filtered_dat[,yi],vi=filtered_dat[,vi],measure=measure) |
| 50 | + RTest <-metafor::regtest(x=rma_model) |
| 51 | + |
| 52 | + metafor::funnel(rma_model, yaxis="sei") # 'label' |
| 53 | + metafor::funnel(rma_model, level=c(90, 95, 99), shade=c("white", "orange", "red"), refline=0, legend=TRUE) |
| 54 | + gc() # Force R to release memory it is no longer using |
| 55 | + |
| 56 | + return(RTest) |
| 57 | + } |
| 58 | + |
| 59 | + |
| 60 | +} |
0 commit comments