Nothing
#' Plot estimated smooths from a fitted \code{smimodel}
#'
#' Plots the graphs of fitted spline(s). If a set of multiple models are fitted,
#' plots graphs of fitted spline(s) of a specified model (in argument
#' \code{model}) out of the set of multiple models fitted.
#'
#' @param object A \code{smimodel} object.
#' @param model An \code{integer} to indicate the smooths of which model (out of
#' the set of multiple models fitted) to be plotted.
#' @param ... Other arguments not currently used.
#'
#' @return Plot(s) of fitted spline(s).
#'
#' @method autoplot smimodel
#'
#' @examples
#' if(requireNamespace("gurobi", quietly = TRUE)){
#' library(dplyr)
#' library(ROI)
#' library(tibble)
#' library(tidyr)
#' library(tsibble)
#'
#' # Simulate data
#' n = 1005
#' set.seed(123)
#' sim_data <- tibble(x_lag_000 = runif(n)) |>
#' mutate(
#' # Add x_lags
#' x_lag = lag_matrix(x_lag_000, 5)) |>
#' unpack(x_lag, names_sep = "_") |>
#' mutate(
#' # Response variable
#' y = (0.9*x_lag_000 + 0.6*x_lag_001 + 0.45*x_lag_003)^3 + rnorm(n, sd = 0.1),
#' # Add an index to the data set
#' inddd = seq(1, n)) |>
#' drop_na() |>
#' select(inddd, y, starts_with("x_lag")) |>
#' # Make the data set a `tsibble`
#' as_tsibble(index = inddd)
#'
#' # Index variables
#' index.vars <- colnames(sim_data)[3:8]
#'
#' # Model fitting
#' smimodel_ppr <- model_smimodel(data = sim_data,
#' yvar = "y",
#' index.vars = index.vars,
#' initialise = "ppr")
#'
#' autoplot(smimodel_ppr)
#' }
#'
#' @export
autoplot.smimodel <- function(object, model = 1, ...){
draw(object$fit[[model]]$best$gam)
}
Any scripts or data that you put into this service are public.
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.