dlm-js
    Preparing search index...

    Function dlmFit

    • Fit a Dynamic Linear Model (DLM).

      Implements a two-pass estimation procedure:

      1. Initial pass with diffuse prior to estimate starting values
      2. Final pass with refined initial state from smoothed estimates

      Model components are determined by the options parameter:

      • Polynomial trend (order 0/1/2)
      • Full or trigonometric seasonal
      • AR(p) components

      When X is provided (n×q covariate matrix), the observation equation becomes: y(t) = F_base·x(t) + X[t,:]·β + v

      The β coefficients are appended to the state vector as static states (identity evolution, zero process noise), matching the MATLAB DLM convention.

      System matrices G and F are generated by dlmGenSys(). State noise covariance W = diag(w[0]², w[1]², ...) with zeros for states beyond w.length.

      Parameters

      • y: ArrayLike<number>

        Observations (n×1 array)

      • s: number | ArrayLike<number>

        Observation noise standard deviation: scalar (same for all timesteps) or array of length n (per-observation sigma, e.g. satellite uncertainty)

      • w: number[]

        State noise standard deviations (diagonal of sqrt(W))

      • dtype: DType = DType.Float64

        Computation precision (default: Float64)

      • options: DlmOptions = {}

        Model specification (default: order=1, no seasonal)

      • OptionalX: ArrayLike<number>[]

        Optional covariate matrix (n rows × q cols); each row is X[t,:]

      • OptionalforceAssocScan: boolean

      Returns Promise<DlmFitResult>

      Complete model fit with smoothed estimates and diagnostics