getcov
Parameter covariance of identified model
Description
returns the raw covariance
of the parameters of an identified model.cov_data =
getcov(sys)
If
sysis a single model, thencov_datais an np-by-np matrix. np is the number of parameters ofsys.If
sysis a model array, thencov_datais a cell array of size equal to the array size ofsys.cov_data(i,j,k,...)contains the covariance data forsys(:,:,i,j,k,...).
Examples
Obtain the identified model.
load iddata1 z1 sys = tfest(z1,2);
Get the raw parameter covariance for the model.
cov_data = getcov(sys)
cov_data = 5×5
1.2131 -4.3949 -0.0309 -0.5531 0
-4.3949 115.0838 1.8598 10.6660 0
-0.0309 1.8598 0.0636 0.1672 0
-0.5531 10.6660 0.1672 1.2433 0
0 0 0 0 0
cov_data contains the covariance matrix for the parameter vector [sys.Numerator,sys.Denominator(2:end),sys.IODelay].
sys.Denominator(1) is fixed to 1 and not treated as a parameter. The covariance matrix entries corresponding to the delay parameter (fifth row and column) are zero because the delay was not estimated.
Obtain the identified model array.
load iddata1 z1; sys1 = tfest(z1,2); sys2 = tfest(z1,3); sysarr = stack(1,sys1,sys2);
sysarr is a 2-by-1 array of continuous-time, identified transfer functions.
Get the raw parameter covariance for the models in the array.
cov_data = getcov(sysarr)
cov_data=2×1 cell array
{5×5 double}
{7×7 double}
cov_data is a 2-by-1 cell array. cov_data{1} and cov_data{2} are the raw parameter covariance matrices for sys1 and sys2.
Load the estimation data.
load iddata1 z1 z1.y = cumsum(z1.y);
Estimate the model.
init_sys = idtf([100 1500],[1 10 10 0]); init_sys.Structure.Numerator.Minimum = eps; init_sys.Structure.Denominator.Minimum = eps; init_sys.Structure.Denominator.Free(end) = false; opt = tfestOptions('SearchMethod','lm'); sys = tfest(z1,init_sys,opt);
sys is an idtf model with six parameters, four of which are estimated.
Get the covariance matrix for the estimated parameters.
cov_type = 'value'; cov_data = getcov(sys,cov_type,'free')
cov_data = 4×4
105 ×
0.0269 -0.1237 -0.0001 -0.0017
-0.1237 1.0221 0.0016 0.0133
-0.0001 0.0016 0.0000 0.0000
-0.0017 0.0133 0.0000 0.0002
cov_data is a 4x4 covariance matrix, with entries corresponding to the four estimated parameters.
Obtain the identified model.
load iddata1 z1 sys = tfest(z1,2);
Get the factored parameter covariance for the model.
cov_type = 'factors';
cov_data = getcov(sys,cov_type);Obtain the identified model array.
load iddata1 z1 sys1 = tfest(z1,2); sys2 = tfest(z1,3); sysarr = stack(1,sys1,sys2);
sysarr is a 2-by-1 array of continuous-time, identified transfer functions.
Get the factored parameter covariance for the models in the array.
cov_type = 'factors';
cov_data = getcov(sysarr,cov_type)cov_data=2×1 struct array with fields:
R
T
Free
cov_data is a 2-by-1 structure array. cov_data(1) and cov_data(2) are the factored covariance structures for sys1 and sys2.
Load the estimation data.
load iddata1 z1 z1.y = cumsum(z1.y);
Estimate the model.
init_sys = idtf([100 1500],[1 10 10 0]); init_sys.Structure.Numerator.Minimum = eps; init_sys.Structure.Denominator.Minimum = eps; init_sys.Structure.Denominator.Free(end) = false; opt = tfestOptions('SearchMethod','lm'); sys = tfest(z1,init_sys,opt);
sys, an idtf model, has six parameters, four of which are estimated.
Get the factored covariance for the estimated parameters.
cov_type = 'factors'; cov_data = getcov(sys,cov_type,'free');
Input Arguments
Covariance return type, specified as either 'value' or 'factors'.
If
cov_typeis'value', thencov_datais returned as a matrix (raw covariance).If
cov_typeis'factors', thencov_datais returned as a structure containing the factors of the covariance matrix.Use this option for fetching the covariance data if the covariance matrix contains nonfinite values, is not positive definite, or is ill conditioned. You can calculate the response uncertainty using the covariance factors instead of the numerically disadvantageous covariance matrix.
This option does not offer a numerical advantage in the following cases:
Data Types: char
Output Arguments
Parameter covariance of sys, returned as
a matrix, cell array of matrices, structure, or cell array of structures. cov_data is [] for idnlarx and idnlhw models.
If
sysis a single model andcov_typeis'value', thencov_datais an np-by-np matrix. np is the number of parameters ofsys.The value of the nonzero elements of this matrix is equal to
sys.Report.Parameters.FreeParCovariancewhensysis obtained via estimation. The row and column entries that correspond to fixed parameters are zero.If
sysis a single model andcov_typeis'factors', thencov_datais a structure with fields:R— Usually an upper triangular matrix.T— Transformation matrix.Free— Logical vector of length np, indicating if a model parameter is free (estimated) or not. np is the number of parameters ofsys.
To obtain the covariance matrix using the factored form, enter:
Free = cov_factored.Free; T = cov_factored.T; R = cov_factored.R; np = nparams(sys); cov_matrix = zeros(np); cov_matrix(Free, Free) = T*inv(R'*R)*T';
For numerical accuracy, calculate
T*inv(R'*R)*T'asX*X', whereX = T/R.If
sysis a model array, thencov_datais a cell array of size equal to the array size ofsys.cov_data(i,j,k,...)contains the covariance data forsys(:,:,i,j,k,...).
Version History
Introduced in R2012a
See Also
MATLAB Command
You clicked a link that corresponds to this MATLAB command:
Run the command by entering it in the MATLAB Command Window. Web browsers do not support MATLAB commands.
Sélectionner un site web
Choisissez un site web pour accéder au contenu traduit dans votre langue (lorsqu'il est disponible) et voir les événements et les offres locales. D’après votre position, nous vous recommandons de sélectionner la région suivante : .
Vous pouvez également sélectionner un site web dans la liste suivante :
Comment optimiser les performances du site
Pour optimiser les performances du site, sélectionnez la région Chine (en chinois ou en anglais). Les sites de MathWorks pour les autres pays ne sont pas optimisés pour les visites provenant de votre région.
Amériques
- América Latina (Español)
- Canada (English)
- United States (English)
Europe
- Belgium (English)
- Denmark (English)
- Deutschland (Deutsch)
- España (Español)
- Finland (English)
- France (Français)
- Ireland (English)
- Italia (Italiano)
- Luxembourg (English)
- Netherlands (English)
- Norway (English)
- Österreich (Deutsch)
- Portugal (English)
- Sweden (English)
- Switzerland
- United Kingdom (English)