Plot difference surface based on model predictions.
plot_diff2(
model,
view,
comp,
cond = NULL,
color = "terrain",
nCol = 100,
col = NULL,
add.color.legend = TRUE,
se = 1.96,
sim.ci = FALSE,
show.diff = FALSE,
col.diff = 1,
alpha.diff = 0.5,
n.grid = 30,
nlevels = 10,
zlim = NULL,
xlim = NULL,
ylim = NULL,
main = NULL,
xlab = NULL,
ylab = NULL,
rm.ranef = TRUE,
transform.view = NULL,
hide.label = FALSE,
dec = NULL,
f = 1.96,
print.summary = getOption("itsadug_print"),
...
)
Name of continuous predictors that should be plotted on the x- and y-axes. Vector of two values.
Named list with the grouping predictor (categorical variable) and the 2 levels to calculate the difference for.
Named list of the values to use for the other predictor terms (not in view).
The color scheme to use for plots. One of 'topo', 'heat', 'cm', 'terrain', 'gray' or 'bw'. Alternatively a vector with some colors can be provided for a custom color palette.
Range of colors of background of contour plot.
Line color.
Logical: whether or not to add a color legend.
Default is TRUE. If FALSE (omitted), one could use the function
gradientLegend
to add a legend manually at any position.
If less than or equal to zero then only the predicted surface is
plotted, but if greater than zero, then the predicted values plus
confidence intervals are plotted.
The value of se
will be multiplied with
the standard error (i.e., 1.96 results in 95%CI and 2.58).
Default is set to 1.96 (95%CI).
Logical: Using simultaneous confidence intervals or not
(default set to FALSE). The implementation of simultaneous CIs follows
Gavin Simpson's blog of December 15, 2016:
https://fromthebottomoftheheap.net/2016/12/15/simultaneous-interval-revisited/.
This interval is calculated from simulations based.
Please specify a seed (e.g., set.seed(123)
) for reproducable results.
Note: in contrast with Gavin Simpson's code, here the Bayesian posterior
covariance matrix of the parameters is uncertainty corrected
(unconditional=TRUE
) to reflect the uncertainty on the estimation of
smoothness parameters.
Logical: whether or not to indicate the regions that
are significantly different from zero. Note that these regions are just
an indication and dependent on the value of n.grid
.
Defaults to FALSE.
Color to shade the nonsignificant areas.
Level of transparency to mark the nonsignificant areas.
Resolution.
Levels of contour lines.
A two item array giving the lower and upper limits for the z- axis scale. NULL to choose automatically.
A two item array giving the lower and upper limits for the x- axis scale. NULL to choose automatically.
A two item array giving the lower and upper limits for the y- axis scale. NULL to choose automatically.
Title of plot.
Label x-axis.
Label y-axis.
Logical: whether or not to remove random effects. Default is TRUE. Alternatively a string (or vector of strings) with the name of the random effect(s) to remove.
List with two functions for transforming
the values on the x- and y-axis respectively. If one of the axes
need to be transformed, set the other to NULL (no transformation).
(See fvisgam
for more info.)
Logical: whether or not to hide the label (i.e., 'difference'). Default is FALSE.
Numeric: number of decimals for rounding the color legend.
When NULL (default), no rounding. If -1 (default), automatically determined.
Note: if value = -1 (default), rounding will be applied also when
zlim
is provided.
Scaling factor to determine the CI from the se, for marking the
difference with 0. Only applies when se
is smaller or equal to zero
and show.diff
is set to TRUE.
Logical: whether or not to print a summary.
Default set to the print info messages option
(see infoMessages
).
Optional arguments for plotsurface
.
If the result is not being plotted, a list is
returned with the estimated difference (est
) and the standard error
over the estimate (se.est
) and the x-values (x
) is returned.
When the argument show.diff
is set to TRUE a shading area indicates
where the confidence intervals include zero. Or, in other words, the areas
that are not significantly different from zero. Be careful with the
interpretation, however, as the precise shape of the surface is dependent
on model constraints such as the value of choose.k
and the
smooth function used, and the size of the confidence intervals are
dependent on the model fit and model characteristics
(see vignette('acf', package='itsadug')
). In addition, the value of
n.grid
determines the precision of the plot.
Other Testing for significance:
compareML()
,
plot_diff()
,
report_stats()
,
wald_gam()
# NOT RUN {
data(simdat)
# }
# NOT RUN {
m1 <- bam(Y ~ Group + te(Time, Trial, by=Group),
data=simdat)
plot_diff2(m1, view=c('Time', 'Trial'),
comp=list(Group=c('Children', 'Adults')))
# }
Run the code above in your browser using DataLab