l_fitDens {mgcViz} | R Documentation |
Adding density strip of fitted effect
Description
This layer adds a conditional posterior density strip to 1D smooth effects plots. With the default colour scale, the opacity is proportional to the conditional density of the fitted effects, under the usual Gaussian approximation the posterior.
Usage
l_fitDens(n = 50, level = 0.95, trans = identity, ...)
Arguments
n |
sqrt of the number of grid points used to compute the effect plot. |
level |
confidence level. By default the conditional density of the fit will be plotted
between the Gaussian quantiles 0.025 and 0.975, hence the |
trans |
monotonic function to be applied to the density of the fit, which determines colour of the plot. Monotonicity is not checked. |
... |
further arguments to be passed to |
Details
See Bowman (2018) for explanations about the advantages of density strips, relative to plots including the mean fit + confidence intervals.
Value
An object of class gamLayer.
References
Bowman, D. W (2018). Graphics for uncertainty. Journal of the Royal Statistical Society: Series A.
Examples
library(mgcViz)
set.seed(44)
dat <- gamSim(1,n=400,dist="normal",scale=2)
b <- gamV(y~s(x0)+x1+s(x2)+s(x3),data=dat)
plot(sm(b, 1)) + l_fitDens() + l_fitLine()
plot(pterm(b, 1)) + l_fitDens(trans = function(x) x^0.25) + l_fitLine()