stat_QQVPC | R Documentation |
Add Visual predictive check confidence interval for Quantile-Quantile Plots with ggplot2.
stat_QQVPC(mapping = NULL, data = NULL, geom = "ribbon", position = "identity", na.rm = FALSE, show.legend = NA, inherit.aes = TRUE, confidence.level = 0.95, ...)
mapping |
Set of aesthetic mappings created by aes or aes_. |
data |
The data to be displayed in this layer. |
geom |
Use to override the default geom |
position |
Position adjustment, either as a string, or the result of a call to a position adjustment function. |
na.rm |
If FALSE, the default, missing values are removed with a warning. If TRUE, missing values are silently removed. |
show.legend |
logical. Should this layer be included in the legends? NA, the default, includes if any aesthetics are mapped. FALSE never includes, and TRUE always includes. |
inherit.aes |
If FALSE, overrides the default aesthetics, rather than combining with them. |
confidence.level |
Confidence level for confidence intervals, default=0.95 |
... |
other arguments passed on to layer. |
Provide Visual predictive check confidence interval for normal QQplot under the assumption of normal distribution. With confidence.level=0.95, by chance one 1 of 20 data points may fall outside the confidence interval when data truly are normal distributed. Confidence intervals are based on repeated simulation of normal distributed data with mean and sd equal to the mean and sd of input data and confidence limits are defined by the quantiles of simulated data.
geom_smooth understands the following aesthetics (required aesthetics are in bold):
x, alpha, colour, fill, group, shape, size, stroke
dd<-data.frame(gr=c(rep("A",20),rep("B",40))) dd$dv<-2*(dd$gr=="B")+rnorm(nrow(dd))/(1+2*(dd$gr=="A")) dd<-dd[order(dd$gr,dd$dv),] dd$px<-NA for(gri in levels(dd$gr)){ dd$px[dd$gr==gri]<-qqnorm(dd$dv[dd$gr==gri],plot=FALSE)$x } ggplot(dd, aes(dv)) + stat_QQVPC(alpha=0.25)+ stat_QQnorm()+ facet_wrap(~gr) ## Not run: ggplot(dd, aes(dv,color=factor(gr))) + stat_QQVPC(alpha=0.25) + stat_QQnorm() ## End(Not run)
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.