parameterise_smooth | R Documentation |
This function helps the user to define reasonable functions for the effect of a covariate on a linear predictor/response for simulations. Then, model-based inferences of the effect of that covariate can be plotted on top of simulated effects to examine the performance of a model in terms of its ability to correctly estimate the simulated function under different scenarios. This function is intended for use primarily in GAMS4DTS
.
parameterise_smooth( x, f, param = list(), parameterise_smooth_ls = NULL, plot = TRUE, add_sim_args = list(type = "l", lwd = 2), xlab = "", ylab = "", plot_gam = FALSE, dat, model, term, plot_gam_ls, add_error_envelope_args = list(), residuals = FALSE, add_residuals_args = list(), shift_truth = 0, shift_predictions = 0, add_rug = FALSE, add_rug_args = list(), add_moons = FALSE, add_moons_args = list(), pretty_axis_args = list(side = 1:2, pretty = list(n = 10), control_axis = list(las = TRUE)), mtext_args = list(), ... )
x |
A numeric sequence of values for which to evaluate the shape of a user-defined function (see below). |
f |
A function which relates a covariate to a linear predictor/response. |
param |
A named list of parameters and parameter values required to evaluate the function. |
parameterise_smooth_ls |
A list from a previous implementation of |
plot |
A logical input which defines whether or not to create a plot. |
add_sim_args |
A named list of arguments to customise the visualisation of the simulated effect of a covariate on the plot. |
xlab |
A character input which defines the label for the x axis. By default, this is |
ylab |
A character input which defines the label for the y axis. By default, this is |
plot_gam |
A logical input which defines whether or not to plot the output of a GAM on top of the simulated effect. |
dat |
The dataframe used to fit the GAM. |
model |
The model used to fit the GAM. |
term |
A character specifying the term of interest. |
plot_gam_ls |
The output of |
add_error_envelope_args |
A named list of arguments passed to |
residuals |
A logical input which defines whether or not to add partial residuals to the plot. |
add_residuals_args |
A named list of arguments to customise the partial residuals on the plot. |
shift_truth |
A number which defines a value by which to shift f(x) vertically. |
shift_predictions |
A number which defines a value by which to shift model predictions/partial residuals vertically. |
add_rug |
A logical input which defines whether or not to plot a rug. If so, |
add_rug_args |
A named list of arguments passed to |
add_moons |
A logical input which defines whether or not to add moons to a plot. This is useful for visualising the effects of lunar phase in models of animal movement time series. |
add_moons_args |
A named list of arguments passed to |
pretty_axis_args |
A named list of arguments, passed to |
mtext_args |
A named list of arguments, passed to |
... |
Additional plotting parameters passed to |
Edward Lavender
#### Example 1: Simulate a quadratic effect of variable (e.g. Julian day) on a response (e.g. depth) # The function creates a plot, so we can 'play' with the parameters # .... until we're happy with the shape: smooth_julian_day <- parameterise_smooth(x = 0:365, f = quadratic, param = list(a = -0.001, b = 1, h = 183, k = 15), plot = TRUE) # The function returns a list containing x, f, the parameters we chose and y values: utils::str(smooth_julian_day) # We could then use these parameters to simulate a response, model the response using a GAM # ... and then compare the simulated and modelled relationship using parameterise_smooth() again # ... (see the vignette or GAMS4DTS() for further examples).
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.