focal.focal_linear_regression
- focal.focal_linear_regression(x: Array, y: Array, *, window: int | tuple[int, ...] | list[int] | ndarray[tuple[int, ...], bool] | Window, fraction_accepted: float = 0.7, verbose: bool = False, reduce: bool = False, error: Literal['bootstrap', 'parametric'] | None = 'parametric', bootstrap_config: BootstrapConfig | None = None, chunks: int | tuple[int, int] | None = None, out: RegressionResult | None = None) RegressionResult
Focal linear regression.
- Parameters:
y (Array) – Dependent variable. Must be two-dimensional.
x (Array) – Independent variables. Must be two or three-dimensional. If two-dimensional, it is interpreted as a single feature, internally transformed to three dimensions by adding a singleton dimension.
window (int, array-like, or Window) –
Window applied over the input arrays. It can be:
An integer (interpreted as a square window),
A sequence of integers (interpreted as a rectangular window),
A boolean array,
Or a
pyspatialstats.windows.Windowobject.
fraction_accepted (float, optional) –
Fraction of valid (non-NaN) cells per window required for regression to be performed.
0: use windows with at least 1 valid value1: use only fully valid windowsBetween
0and1: minimum acceptable fraction
Default is 0.7.
verbose (bool, optional) – If True, print progress message with timing. Default is False.
reduce (bool, optional) – If True, each pixel is used exactly once without overlapping windows. The resulting array will have shape
a_shape / window_shape. Default is False.error ({'bootstrap', 'parametric'}, optional) – Compute the uncertainty of the linear regression parameters using either a bootstrap or parametric method. If not set, the function does not return the uncertainty.
bootstrap_config (BootstrapConfig, optional) – Configuration for the bootstrap if error is ‘bootstrap’
chunks (int or tuple of int, optional) – Shape of chunks to split the array into. If None, the array is not split into chunks, which is the default.
out (LinearRegressionResult, optional) – LinearRegressionResult to write results to.
- Returns:
StatResult containing regression coefficients, standard error values, t-statistics, and optionally p-values.
- Return type:
RegressionResult