Skip to contents

When newdata is NULL, returns the in-sample fitted values. Otherwise estimates the local coefficients at each new location with GWmodel::gwr.basic(regression.points = ), with the fit's kernel and bandwidth (an adaptive bandwidth counts neighbours among the training points), and returns \(x^\top\hat\beta(u)\). These are the values GWmodel::gwr.predict() returns, without its prediction variance, which this method never returned and which costs time cubic in the number of training points. Each location stands alone: one that cannot be estimated does not affect the others. newdata is first transformed to the CRS used during fitting (via ensure_projected()), so predictions are computed in a single coordinate system regardless of the CRS newdata arrives in.

Usage

# S3 method for class 'gwr_fit'
predict(object, newdata = NULL, ...)

Arguments

object

A gwr_fit object.

newdata

An sf object with the same predictors. The response variable need not be present (true out-of-sample prediction is supported). NULL = fitted values.

...

Ignored.

Value

Numeric vector aligned to nrow(newdata), with NA for rows dropped as missing or non-finite, and for locations whose local regression cannot be estimated (too few training points within a fixed bandwidth, or a singular local design); a warning counts those. If the design matrix for newdata cannot be built, every value is NA and a warning says why. CRS-less newdata first receives the interpretation the training data got, so the same rows land where they did at fit time.