IPW.ASYM.boxplot {IPWboxplot} | R Documentation |
Boxplot adapted to skewness and missing values
Description
The function draws a modified boxplot adapted to missing data and skewness. The drop-out probabilities can be given by the practitioner or fitted through a logistic model using auxiliary covariates. The plots are adapted to asymmetric distributions by correcting the whiskers through a measure of the skewness.
Usage
IPW.ASYM.boxplot(y,px=NULL,x=NULL,graph=c("IPW","both"),names=c("IPW Asymmetric Boxplot",
"NAIVE Asymmetric Boxplot"), size.letter=1.2,
method=c("quartile","octile"), ctea=-4, cteb=3, lim.inf=NULL,lim.sup=NULL,
main=" ",xlab = " ", ylab =" ",color="black")
Arguments
y |
Numerical vector of length n with possible missing values codified by NA or NAN. |
px |
Optional. Numerical vector of drop-out probabilities. If not provided a logistic fit is performed using |
x |
Optional. The matrix of fully observed variables used to estimate the missing model with dimension nrows=n and ncol=p. Missing values are not admitted. One of the vectors px or x must be supplied. |
graph |
Optional. Character string indicating if the plot contains two boxplots ("both") or only the boxplot computed with the inverse probability weighted quantiles ("IPW"). The default is "IPW". |
names |
Optional. Character string to name the boxplots. The default is "IPW Asymmetric Boxplot", when |
size.letter |
Optional. The font size of names. Default value is 1.2 |
method |
Optional. Character string indicating if the skewness measure is based on the quartiles ("quartile") or the octiles ("octile"). The default is "quartile". |
ctea |
Optional. Scaling factors to compute the outlier boundary. The default is -4. |
cteb |
Optional. Scaling factors to compute the outlier boundary. The default is 3. When ctea=cteb=0 the IPW boxplot for symmetric data is obtained. |
lim.inf |
Optional. The lower limit of the plot if supplied by the user. |
lim.sup |
Optional. The upper limit of the plot if supplied by the user. |
main |
Optional. Character string to title the plot. By default no main title is given. |
xlab |
Optional. Character string to indicate the label of the horizontal axis. |
ylab |
Optional. Character string to indicate the label of the vertical axis. |
color |
Optional. Color for the IPW Boxplot. |
Details
The function draws boxplots designed to adjust both for skewness and missingness. The drop-out probabilities can be supplied by the user or estimated through a logistic model from given covariates.
The function plots as default a modified boxplot based on the inverse probability weighted (IPW) quantiles adapting for missing observations as in Zhang et al.(2012), but using a correction factor to adjust for skewness. For that purpose, the function incorporates a skewness measure to compute the whiskers and the outlier cut–off values in a similar way to that considered in Hubert and Vandervieren (2008).
The argument method
selects quartiles (method="quartile"
) or octiles (method="octile"
) to calculate the skewness measure SKEW, respectively, as
SKEW=\frac{(Q_{0.75}-Q_{0.5})-(Q_{0.5}-Q_{25})}{(Q_{0.75}-Q_{0.25})},
SKEW=\frac{(Q_{0.875}-Q_{0.5})-(Q_{0.5}-Q_{0.125})}{(Q_{0.875}-Q_{0.125})},
where Q\alpha
denotes the \alpha-
quantile.
The whiskers and the outlier cut–off values are computed by means of an exponential model in the fashion of Hubert and Vandervieren (2008) taking into account the interval:
(Q_{0.25}-1.5*\exp{(c_i*SKEW)}*IQR,Q_{0.75}+1.5*\exp{(c_s*SKEW)}*IQR),
where IQR=Q_{0.75}-Q_{0.25}
and c_i
=ctea
and c_s
=cteb
if SKEW is positive, otherwise, c_i
=-cteb
and c_s
=-ctea
.
The default values for ctea
and cteb
are -4
and 3
, however, the user may choose other values for these constants.
By specifying graph = "both"
, the function displays two parallel modified boxplots. The boxplot on the left corresponds to the IPW boxplot adapted for missingness and skewness, while that on the right, to its naive counterpart which is simply based on the observations y
at hand without any correction for missingness.
The user can supply a vector of drop-out probabilities px
or a set of covariates x
to estimate the propensity.
When both px
and x
are supplied, the IPW.ASYM.boxplot is executed using px
. When px
is not given, it is estimated assuming a logistic model depending on the covariates x
.
For more details, see Bianco et al. (2018).
Value
The output of the function is a list with components:
px |
Numerical vector of drop-out probabilities. |
IPW.Quartiles |
Numerical vector of inverse probability weighted quartiles. |
IPW.whisker |
Numerical vector of lower and upper whiskers calculated from IPW quantiles. |
out.IPW |
Numerical vector of data points detected as atypical by the IPW boxplot adapted to skewness. |
SKEW.IPW |
Skewness measure based on the IPW quartiles (method="quartile") or IPW octiles (method="octile"). |
NAIVE.Quartiles |
Numerical vector of naive quartiles computed from the subset of non-missing values of |
NAIVE.whisker |
Numerical vector of lower and upper whiskers obtained from the naive quantiles. Returned only when graph="both". |
out.NAIVE |
Numerical vector of data points detected as atypical by the naive boxplot. Returned only when graph="both". |
SKEW.NAIVE |
Skewness measure based on the naive quartiles (method="quartile") or Naive octiles (method="octile"), computed from the subset of non-missing values of |
Note
The missing values of y
must be codified as NA or NAN.
The numerical vector px
and the matrix of covariates x
must be fully observed. px
or x
must be supplied by the user.
The lengths of y
, px
, and nrow(x)
must be equal.
Author(s)
Ana Maria Bianco <abianco@dm.uba.ar>, Graciela Boente <gboente@dm.uba.ar> and Ana Perez-Gonzalez <anapg@uvigo.es>.
References
Bianco, A. M., Boente, G., and Perez-Gonzalez, A. (2018). A boxplot adapted to missing values: an R function when predictive covariates are available. Submitted.
Hubert, M. and Vandervieren, E. (2008). An adjusted boxplot for skewed distributions. Computational Statistics & Data Analysis, 52, 5186-5201.
Zhang, Z., Chen, Z., Troendle, J. F. and Zhang, J. (2012). Causal inference on quantiles with an obstetric application. Biometrics, 68, 697-706.
See Also
IPW.quantile, IPW.Boxplot
Examples
## A real data example
library(mice)
data(boys)
attach(boys)
# The function plots the IPW boxplot adapted to skewness.
# Some statistical summaries computed using the inverse probability weighting approach
# are also returned.
res1=IPW.ASYM.boxplot(hc,x=age,main="IPW boxplot adjusted for skewness of the head circumference")
# We can compare the naive and IPW approaches. We also can consider the skewness measure computed
# using the quartiles (as default).
res2=IPW.ASYM.boxplot(hc,x=age,method="quartile",graph="both",main=" ")
# The results obtained if the skewness measure is computed with the octiles (method="octile") are:
res3=IPW.ASYM.boxplot(hc,x=age,method="octile",graph="both",main=" ")