slope_fun: Compute the linear slope of a numeric sequence
Description
Computes the slope of a simple linear regression of a numeric vector
against its index (seq_along(x)). Non-finite (NA, NaN, Inf) values
are removed prior to computation. If fewer than two finite values remain,
the function returns 0.
Usage
slope_fun(x)
Value
A numeric scalar giving the slope of the fitted linear trend.
Arguments
x
Numeric vector.
Details
The slope is estimated from the model
\(x_i = \beta_0 + \beta_1 i + \varepsilon_i\),
where \(i = 1, \dots, n\). The function returns the estimated slope
\(\beta_1\).
This summary is useful for characterizing monotonic trends in ordered
risk values along a path.