loess_plot | R Documentation |
Loess plot with density distributions for propensity scores and outcomes on top and right, respectively.
loess_plot(
ps,
outcome,
treatment,
outcomeTitle = "",
treatmentTitle = "Treatment",
percentPoints.treat = 0.1,
percentPoints.control = 0.01,
points.treat.alpha = 0.1,
points.control.alpha = 0.1,
plot.strata,
plot.strata.alpha = 0.2,
level = 0.68,
...
)
ps |
vector of propensity scores. |
outcome |
the outcome variable. |
treatment |
the treatment varaible as a logical type. |
outcomeTitle |
the label to use for the y-axis (i.e. the name of the outcome variable) |
treatmentTitle |
the label to use for the treatment legend. |
percentPoints.treat |
the percentage of treatment points to randomly plot. |
percentPoints.control |
the percentage of control points to randomly plot. |
points.treat.alpha |
the transparency level for treatment points. |
points.control.alpha |
the transparency level for control points. |
plot.strata |
an integer value greater than 2 indicating the number of vertical lines to plot corresponding to quantiles. |
plot.strata.alpha |
the alpha level for the vertical lines. |
level |
Level of confidence interval to use. The default is 0.68 (for 1 standard error) since the primary purpose is to compare overlap between the two lines. See this article for more details: https://towardsdatascience.com/why-overlapping-confidence-intervals-mean-nothing-about-statistical-significance-48360559900a |
... |
other parameters passed to |
a ggplot2 figure
plot.mlpsa
## Not run:
require(multilevelPSA)
require(party)
data(pisana)
data(pisa.psa.cols)
cnt <- 'USA' # Can change this to USA, MEX, or CAN
pisana2 <- pisana[pisana$CNT == cnt,]
pisana2$treat <- as.integer(pisana2$PUBPRIV) %% 2
lr.results <- glm(treat ~ ., data=pisana2[,c('treat',pisa.psa.cols)], family='binomial')
st <- data.frame(ps=fitted(lr.results),
math=apply(pisana2[,paste('PV', 1:5, 'MATH', sep='')], 1, mean),
pubpriv=pisana2$treat)
st$treat = as.logical(st$pubpriv)
loess_plot(st$ps, outcome=st$math, treatment=st$treat, percentPoints.control = 0.4,
percentPoints.treat=0.4)
## End(Not run)
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.