Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
24 changes: 24 additions & 0 deletions docs/src/ss.md
Original file line number Diff line number Diff line change
Expand Up @@ -51,6 +51,26 @@ The subspace-based estimation algorithms have a number of parameters that can be
- `zeroD` allows you to force the estimated ``D`` matrix to be zero (a strictly proper model).
- It is possible to select the weight type `W`, choose between `:MOESP, :CVA, :N4SID, :IVM`. The default is `:MOESP`.

### Uncertainty estimates
With the keyword argument `uncertainty = Val(:jackknife)`, [`subspaceid`](@ref) additionally returns a [`SubspaceJackknife`](@ref) object. The data is partitioned into `nblocks` contiguous blocks, and the model is estimated once for each block with that block left out. The resulting models are transformed to the state basis of the full-data model, and [`jackknife_std`](@ref) computes the jackknife standard deviation of any quantity computed from a model. The example below computes the standard deviation of the magnitude of the frequency response and of the poles.
```@example ss
using LinearAlgebra
u2 = randn(1, 10000)
y2 = lsim(G, u2).y .+ 0.5 .* randn.()
d2 = iddata(y2, u2, Ts)
sysu, unc = subspaceid(d2, G.nx; zeroD = true, uncertainty = Val(:jackknife), nblocks = 10)
w = exp10.(range(-1, log10(pi/Ts), length = 300))
mag = vec(abs.(freqresp(sysu, w)))
σmag = jackknife_std(s -> vec(abs.(freqresp(s, w))), unc)
plot(w, vec(abs.(freqresp(G, w))), lab = "True", xscale = :log10, yscale = :log10, xlabel = "Frequency [rad/s]", ylabel = "Magnitude")
plot!(w, mag, ribbon = (min.(2σmag, 0.99mag), 2σmag), lab = "subspace ± 2σ")
```
```@example ss
[poles(sysu) pole_std(sysu, unc)]
```
The jackknife covariance of the model parameters `[vec(A); vec(B); vec(C); vec(D); vec(K)]` is obtained with [`jackknife_cov`](@ref).

The variance estimate assumes that the blocks are approximately independent. The blocks must therefore be long compared with the horizons `r`, `s1`, `s2` and with the time constants of the system and the noise model. The accuracy of the jackknife variance is not guaranteed. In Monte Carlo experiments with a third-order system, a fixed white-noise input and independent white measurement noise, the root-mean-square jackknife standard deviation of the frequency response and of the poles was 0.9–1.25 times the standard deviation over noise realizations with 8000 samples. With 2000 samples and a lower signal-to-noise ratio, the distribution of the estimate had heavier tails than a Gaussian distribution, and the jackknife standard deviation of the frequency response was up to 1.9 times, and that of a weakly determined real pole up to 4 times, the standard deviation over noise realizations.

See the docstrings of [`subspaceid`](@ref) and [`n4sid`](@ref) for additional arguments and more details.

Expand Down Expand Up @@ -196,6 +216,10 @@ Pages = ["ss.md"]
ControlSystemIdentification.newpem
ControlSystemIdentification.structured_pem
ControlSystemIdentification.subspaceid
ControlSystemIdentification.SubspaceJackknife
ControlSystemIdentification.jackknife_std
ControlSystemIdentification.jackknife_cov
ControlSystemIdentification.pole_std
ControlSystemIdentification.n4sid
ControlSystemIdentification.era
ControlSystemIdentification.okid
Expand Down
1 change: 1 addition & 0 deletions src/ControlSystemIdentification.jl
Original file line number Diff line number Diff line change
Expand Up @@ -49,6 +49,7 @@ export AbstractPredictionStateSpace, PredictionStateSpace, N4SIDStateSpace,
pem, newpem, structured_pem, prediction_error, prediction_error_filter, predictiondata, predict, simulate, noise_model, estimate_x0
export LPVStateSpace, lpv_pem, lpv_warmstart
export n4sid, subspaceid, era, okid, find_similarity_transform, schur_stab
export SubspaceJackknife, jackknife_std, jackknife_cov, pole_std
export getARXregressor,
getARregressor,
find_na,
Expand Down
Loading
Loading