plot_diff | R Documentation |
Plot difference curve based on model predictions.
plot_diff( model, view, comp, cond = NULL, se = 1.96, sim.ci = FALSE, n.grid = 100, add = FALSE, rm.ranef = TRUE, mark.diff = TRUE, col.diff = "red", col = "black", eegAxis = FALSE, transform.view = NULL, print.summary = getOption("itsadug_print"), plot = TRUE, main = NULL, ylab = NULL, xlab = NULL, xlim = NULL, ylim = NULL, hide.label = FALSE, ... )
model |
A GAMM model, resulting from the functions
|
view |
Name of continuous predictor that should be plotted on the x- axis. |
comp |
Named list with the grouping predictor (categorical variable) and the 2 levels to calculate the difference for. |
cond |
A named list of the values to use for the predictor terms. Variables omitted from this list will have the closest observed value to the median for continuous variables, or the reference level for factors. |
se |
If less than or equal to zero then only the predicted smooth is
plotted, but if greater than zero, then the predicted values plus
confidence intervals are plotted.
The value of |
sim.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., |
n.grid |
Number of data points sampled as predictions. Defaults to 100. |
add |
Logical: whether or not to add the line to an existing plot.
Default is FALSE.
When no plot window is available and |
rm.ranef |
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. |
mark.diff |
Logical: whether or not marking where the difference is significantly different from 0. |
col.diff |
Color to mark differences (red by default). |
col |
Line color. Shading color is derived from line color. |
eegAxis |
Logical: whether or not to reverse the y-axis, plotting negative values upwards. Default is FALSE. |
transform.view |
Function for transforming
the values on the x-axis. Defaults to NULL (no transformation).
(See |
print.summary |
Logical: whether or not to print the summary.
Default set to the print info messages option
(see |
plot |
Logical: whether or not to plot the difference. If FALSE, then
the output is returned as a list, with the estimated difference
( |
main |
Text string, alternative title for plot. |
ylab |
Text string, alternative label for y-axis. |
xlab |
Text string, alternative label for x-axis. |
xlim |
Range of x-axis. If not specified, the function automatically generates an appropriate x-axis. |
ylim |
Range of y-axis. If not specified, the function automatically generates an appropriate y-axis. |
hide.label |
Logical: whether or not to hide the label (i.e., 'difference'). Default is FALSE. |
... |
Optional arguments for |
If the result is not being plotted, a list is
returned with the estimated difference (est
) and the standard error
over the estimate (se
) and the x-values (x
) is returned.
Martijn Wieling, Jacolien van Rij
Other Testing for significance:
compareML()
,
plot_diff2()
,
report_stats()
,
wald_gam()
data(simdat) ## Not run: m1 <- bam(Y ~ Group + te(Time, Trial, by=Group) + s(Time, Subject, bs='fs', m=1), data=simdat, discrete=TRUE) plot_diff(m1, view='Time', comp=list(Group=c('Children', 'Adults'))) # in this model, excluding random effects does not change the difference: plot_diff(m1, view='Time', comp=list(Group=c('Children', 'Adults')), rm.ranef=TRUE) # simultaneous CI: plot_diff(m1, view='Time', comp=list(Group=c('Children', 'Adults')), rm.ranef=TRUE, sim.ci=TRUE) # Reversed y-axis (for EEG data) and no shading: plot_diff(m1, view='Time', comp=list(Group=c('Children', 'Adults')), eegAxis=TRUE, shade=FALSE) plot_diff(m1, view='Time', comp=list(Group=c('Children', 'Adults')), density=15, angle=90, ci.lwd=3) # Retrieving plot values... out <- plot_diff(m1, view='Time', comp=list(Group=c('Children', 'Adults')), plot=FALSE) #... which might be used for indicating differences: x <- find_difference(out$est, out$se, f=1.96, xVals=out$xVals) # add lines: arrows(x0=x$start, x1=x$end, y0=0, y1=0,code=3, length=.1, col='red') ## End(Not run)
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.