Learn R Programming

mgwrsar (version 1.3.1)

plot,mgwrsar,missing-method: Plot method for mgwrsar model

Description

Maps the results of an mgwrsar model using an interactive Plotly map. Supports plotting coefficients, t-statistics, residuals, and fitted values. Automatically switches between a geographic map (if CRS is present) and a scatter plot.

Visualizes the results of an MGWRSAR model (coefficients, t-statistics, residuals, or fitted values) using interactive plots via the plotly package.

If a Coordinate Reference System (CRS) is provided (either via the crs argument or stored in the model object), the function generates an interactive map. Otherwise, it generates a standard scatter plot of the values against the coordinates.

Usage

# S4 method for mgwrsar,missing
plot(
  x,
  y,
  type = "coef",
  var = NULL,
  crs = NULL,
  mypalette = "RdYlGn",
  opacity = 0.8,
  size = 5,
  title = NULL,
  show_legend = TRUE,
  n_time_steps = 10,
  ...
)

# S3 method for mgwrsar plot( x, type = "coef", var = NULL, crs = NULL, mypalette = "RdYlGn", size = 5, opacity = 0.8, title = NULL, show_legend = TRUE, n_time_steps = 10, ... )

Value

An interactive Plotly object (Mapbox or Scatter).

A plotly object representing the interactive plot (or map).

Arguments

x

An object of class mgwrsar.

y

missing (not used).

type

Character. The type of output to plot. Options are:

  • 'coef': Spatially varying coefficients (default).

  • 't_coef': t-statistics of the coefficients (visualized with a significance threshold of 1.96).

  • 'residuals': Model residuals.

  • 'fitted': Fitted values.

var

Character. The name of the variable (covariate) to plot. Required if type is 'coef' or 't_coef'.

crs

Numeric or character. The Coordinate Reference System (e.g., EPSG code) of the coordinates. If NULL, the function attempts to retrieve the CRS from x@my_crs.

mypalette

Character. The color palette to use for the points (e.g., "RdYlGn", "Viridis"). Default is "RdYlGn".

opacity

Numeric. The opacity of the markers, between 0 and 1. Default is 0.8.

size

Numeric. The size of the markers. Default is 5.

title

Character. A custom title for the plot. If NULL, a default title is automatically generated.

show_legend

Logical. Whether to display the legend. Default is TRUE.

n_time_steps

time step for spatio-temporal model (default 10).

...

Additional arguments passed to the internal plot function.

See Also

MGWRSAR