cedalion.models.glm.solve

Solve the GLM model.

Functions

fit(ts, design_matrix[, noise_model, ...])

Fit design matrix to data.

predict(ts, thetas, design_matrix)

Predict time series from design matrix and thetas.

cedalion.models.glm.solve.fit(
ts: cdt.NDTimeSeries,
design_matrix: DesignMatrix,
noise_model: str = 'ols',
ar_order: int = 30,
max_jobs: int = -1,
verbose: bool = False,
)[source]

Fit design matrix to data.

Parameters:
  • ts – the time series to be modeled

  • design_matrix – DataArray with dims time, regressor, chromo

  • noise_model

    specifies the linear regression model

    • ols: ordinary least squares

    • rls: recursive least squares

    • wls: weighted least squares

    • ar_irls: autoregressive iteratively reweighted least squares (Barker et al. [BAH13])

    • gls: generalized least squares

    • glsar: generalized least squares with autoregressive covariance structure

  • ar_order – order of the autoregressive model

  • max_jobs – controls the number of jobs in parallel execution. Set to -1 for all available cores. Set it to 1 to disable parallel execution.

  • verbose – display progress information if True.

Returns:

thetas as a DataArray

cedalion.models.glm.solve.predict(
ts: cdt.NDTimeSeries,
thetas: DataArray,
design_matrix: DesignMatrix,
) cdt.NDTimeSeries[source]

Predict time series from design matrix and thetas.

Parameters:
  • ts (cdt.NDTimeSeries) – The time series to be modeled.

  • thetas (xr.DataArray) – The estimated parameters.

  • design_matrix (xr.DataArray) – DataArray with dims time, regressor, chromo

  • channel_wise_regressors (list[xr.DataArray]) – Optional list of design matrices,

  • dimension. (with additional channel)

Returns:

The predicted time series.

Return type:

prediction (xr.DataArray)