Fits a smooth surface to x, y, z data using generalised additive models
Source:R/fit_gam_surface.R
fit_gam_surface.Rd
This is based on mgcv::gam()
and derived from openair::polarPlot()
Usage
fit_gam_surface(
data,
x,
y,
z,
weights = NULL,
k = 100,
extrapolate = FALSE,
force_positive = TRUE,
dist = 0.05
)
Arguments
- data
a data.frame or tibble containing the data (wide format)
- x
string giving the u (wind) component or x coordinate, respectively
- y
string giving the v (wind) component or y coordinate, respectively
- z
string giving the response variable
- weights
vector of weights for fitting x, y value pair; can be NULL
- k
numeric, smoothing degree in gam model mgcv::gam(z ~ s(x, y, k = k)
- extrapolate
TRUE/FALSE, result of fit extends over NA values in z, thus providing a way of extrapolation. If FALSE, only u, v pairs with !is.na(z) are returned, if TRUE, also fitted z values within a certain distance (dist) from x, y are returned based on mgcv::exclude.too.far()
- force_positive
TRUE/FALSE, shall fitted values forced to be positive?
- dist
input for
mgcv::exclude.too.far()
: how far away counts as too far. Grid and data are first scaled so that the grid lies exactly in the unit square, and dist is a distance within this unit square