View source: R/stdDiffDotPlot.r
stdDiffDotPlot | R Documentation |
Plot (dotchart) the absolute standardised differences of variables used to generate the propensity score. Standardised differences are calculated using stddiff package. Standardized differences are used to compare the balance in measured baseline covariates. Standardized difference in excess of 10
stdDiffDotPlot(
dataSMD,
data,
treat = "treat",
showRes = TRUE,
plotGraph = TRUE,
lateX = FALSE,
inset = 0.02,
xlim = c(0, 0.5),
col,
...
)
dataSMD |
dataframe of SMD results |
data |
dataframe |
treat |
name of the treatment variable |
showRes |
boolean if true print result table |
plotGraph |
boolean if true show graph in the output |
lateX |
boolean if true print result table in lateX format |
inset |
inset for legend position relative to the bottom right |
xlim |
xlim see ?par |
col |
colors |
data.frame
JuG
#synthetic data
set.seed(2020)
treat<-round(abs(rnorm(100)+1)*10,0) %% 2
numeric1<-round((rnorm(100)+1)*10,0)
numeric2 <- round(abs(rnorm(100)+1)*10,0)
binary<-factor(round(abs(rnorm(100)+1)*10,0) %% 2)
binary2<-factor(round(abs(rnorm(100)+1)*10,0) %% 2)
category<-factor(round(abs(rnorm(100)+1)*10,0) %% 3)
category2<-factor(round(abs(rnorm(100)+1)*10,0) %% 5)
data<-data.frame(treat,numeric1, numeric2,binary, binary2,category, category2)
stdDiffDotPlot(data = data, treat = "treat", showRes = TRUE, plotGraph = FALSE)
stdDiffDotPlot(data = data, treat = "treat", showRes = FALSE, plotGraph = TRUE, xlim=c(-.5,1), pch=21, bg="lightgrey", col=c("blue","black"))
#res <- stdDiffDotPlot(data = data, treat = "treat", showRes = TRUE, plotGraph = FALSE)
#segments(x0=res$stddiff.l, x1=res$stddiff.u, y0=1:6)
data2 <- data.frame(age=c(rnorm(2929, 69.6, 13.5), rnorm(6178, 65, 13.3)), ttt=c(rep("NobetaBlock",2929), rep("betaBlock", 6178)))
stdDiffDotPlot(data = data2, treat = "ttt", showRes = TRUE, plotGraph = FALSE)
example 2 : with dataSMD
dataSMD = data.frame(unmatched = c(.4,.2,.25,.3),
matched = c(.1,.1,.05,.02),
weighted = c(.02,.05,.08,.03))
rownames(dataSMD) <- c("Age", "Height", "Weight", "ParamX")
stdDiffDotPlot(dataSMD=dataSMD,col=c("black", "blue", "purple") )
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.