Geostatex.RegressionKriging (Geostatex v0.6.0)

Copy Markdown View Source

Regression kriging, after pykrige.rk.RegressionKriging (PyKrige).

fit/4 fits a regression of the values on predictors observed at the same points, then krige the regression's residuals over the points (Geostatex.Kriging). predict/3 adds the kriged residual to the regression at new points: the regression captures what the predictors explain and kriging the spatial pattern they leave.

Options of fit/4

  • :regression - :linear (default: ordinary least squares with an intercept, as scikit-learn's LinearRegression) or {fit, predict}, two functions: fit.(predictors, values) returns a model and predict.(model, predictors) its predictions (a list), for any regression (Scholar, Axon, ...).
  • :method - :ordinary (default) or :universal kriging of the residuals.
  • :n_closest_points - the moving window of ordinary kriging at prediction (default 10, as PyKrige; nil uses every point); universal kriging uses every point, as PyKrige ignores it.
  • Any option of Geostatex.Kriging.ordinary/3 (or universal/3), with PyKrige's RegressionKriging defaults: variogram_model: :linear, nlags: 6.

Predictors are a list of rows (a list or tuple of numbers each, or a number for a single predictor), one per point; points as for Geostatex.Kriging.

iex> points = for x <- 0..4, y <- 0..4, do: {x * 1.0, y * 1.0}
iex> predictors = for {x, y} <- points, do: [x + 2 * y]
iex> values = for {x, y} <- points, do: 1 + 3 * (x + 2 * y) + :math.sin(x)
iex> rk = Geostatex.RegressionKriging.fit(predictors, points, values)
iex> Float.round(rk.intercept, 6) > 0
true

Summary

Functions

Fits the regression and krige its residuals. See the module documentation.

The regression residual kriged at points.

The regression at predictors plus the residual kriged at points.

The coefficient of determination R² of predict/3 against values (scikit-learn's r2_score).

Types

t()

@type t() :: %Geostatex.RegressionKriging{
  coef: term(),
  intercept: term(),
  kriging: term(),
  method: term(),
  model: term(),
  n_closest_points: term(),
  regression: term()
}

Functions

fit(predictors, points, values, opts \\ [])

@spec fit(term(), term(), term(), keyword()) :: t()

Fits the regression and krige its residuals. See the module documentation.

krige_residual(rk, points)

@spec krige_residual(t(), term()) :: [float()]

The regression residual kriged at points.

predict(rk, predictors, points)

@spec predict(t(), term(), term()) :: [float()]

The regression at predictors plus the residual kriged at points.

score(rk, predictors, points, values)

@spec score(t(), term(), term(), [number()]) :: float()

The coefficient of determination R² of predict/3 against values (scikit-learn's r2_score).