Library

Library

Auxiliar Functions

NarmaxLasso.simulateFunction.
simulate(u, f, yterms, uterms[, vterms][; σv=0.0, σw=0.0, seed=1] ) -> y

Be u the input vector applied to a discrete system and y the correspondent output vector for a system described by the difference equations:

\[y^*[k] = f([ y^*[k-\text{yterms}[1]], y^*[k-\text{yterms}[2]],..., y^*[k-\text{yterms}[\text{end}]] ],\\ [ u[k-\text{uterms}[1]], u[k-\text{uterms}[2]],..., u[k-\text{uterms}[\text{end}]] ],\\ [ v[k-\text{vterms}[1]], v[k-\text{vterms}[2]],..., v[k-\text{vterms}[\text{end}]] ]) + v[k]\\\]

and

\[y[k] = y^*[k] + w[k]\]

where yterms , uterms and vterms are vector containing dependencies on previous terms of $y$, $u$ and $v$; $v[k]$ and $w[k]$ are random variables with zero mean and standard deviation σv and σw, respectively. The random number generator is initialized with seed, during the generation. Furthermore, f is the function that describe the system dynamics: f(yvec, uvec, vvec) -> y.

source
simulate(u, mdl::NarmaxRegressors, β) -> y

Be u the input vector applied to a discrete system and y the correspondent output vector for a system described by a basis expansion model mdl and the parameter vector β.

source
generate_random_input(n [, nrep=5][; σ=1, seed=1]) -> u

Generate a vector $u$ containing a random signal. The values are draw from a zero-mean Gaussian distribution with standard deviation σ and held for nrep samples. The random number generator is initialized with seed, during the generation.

source

Basis Expansion

Basis

A basis function is an element of a particular basis for a function space. Every continuous function in the function space can be represented as a linear combination of basis functions:

\[f(x_1, \cdots, x_n) = \sum_i \beta_i\text{basis}_i(x_1, \cdots, x_n)\]

So far the only implemented basis is Monomial.

source
Monomial(exponents)

A Monomial function is a product of powers of variables with nonnegative integer exponents.

\[x_1^{p_1} * x_2^{p_2} *\cdots * x_n^{p_n}\]

The Monomial is defined using a vector of integers exponents. This vector contains the correspondent exponents $p$ for all the inputs from 1 to n.

source

Regressors

NarmaxRegressors{T<:Basis}(basis::Vector{T}, yterms, uterms[, vterms])

Describe regressors to be used on a NARMAX estimation problem.

source
generate_all(::Type{NarmaxRegressors}, ::Type{Monomials}, ny, nu, nv, order)

Generate a set of regressors containing all monomials:

\[\left(y[k-q_i] \right)^{l_i} \left(u[k-t_i] \right)^{r_i} \left(e[k-w_i] \right)^{s_i}\]

for which: $1\le q_i \le n_y$; $1 \le t_i \le n_u$; $1 \le w_i \le n_e$; and, $l_i + r_i + s_i = \text{order}[i]$.

source

LassoEstimation

narmax_lasso(y, u, mdl::NarmaxRegressors[; use_glmnet]) -> r::LassoResult

Given input and output signals u and y, and a structure mdl specifying the regressors through a structure NarmaxRegressors. Find the solution of the lasso problem:

\[\min_\beta ||\mathbf{e}||^2 + \lambda * \sum_{i} |\beta_i|\]

for a grid of values of the regularization parameter $\lambda$. Return a LassoResult structure containing the obtained values. The option use_glmnet=true changes the internal solver to GLMNet (only available when no noise term is present).

source
LassoResult

Result of lasso estimation for a grid of values of regularization parameter. Contains:

AtributesTypeBrief Description
mdlNarmaxRegressorsRegressors
λMatrix{Float64}Sequence of regularization parameters λ
βMatrix{Float64}Parameter vectors arranged columnwise, for the sequence of λ
dfMatrix{Int}Number of nonzero terms for the sequence of λ
timeFloat64Execution time
total_iterIntTotal number of internal iterations
source