Conversion to logical from struct is not possible.
4 vues (au cours des 30 derniers jours)
Afficher commentaires plus anciens
Hi! I am currently working on a Markov Switching DCC-GARCH model using Matlab and got stuck. I believe someone has asked this question before but as I am very new to Matlab, I still can't figure out how to fix mine. Here's the code I use:
addpath('MS_Regress-Matlab-master');
addpath('m_Files');
addpath('data_Files');
[filename,pathname]=uigetfile('*.xlsx');
[data,textdata,raw] = xlsread(filename,1);
date=datenum(textdata(2:397,1),'dd/mm/yyyy');
s_start = '01/01/1989';
s_end = '01/12/2021';
date_find=datenum([s_start; s_end],'dd/mm/yyyy');
ss=datefind(date_find(1,1),date);
se=datefind(date_find(2,1),date);
cant=data(1:396,1:2);
R_eq=diff(log(cant));
dep=R_eq; % Defifines the dependent variables in system
nLag=3; % Number of vector autoregressive lags in 2x1 system (p)
k=2; % Number of states/regimes (K)
doIntercept=1; % Add intercept to equations (1= Yes; 0= No) (whether ? is MS)
advOpt.distrib='Normal';
advOpt.std_method = 1; % Defifining the method for calculation of standard errors.
advOpt.diagCovMat = 0; % Whether we will estimate by MLE also MS covariances (H feature)
advOpt.doPlots = 1; % Does not produce automatic plots (you are in charge of that!)
advOpt.printIter = 0; % When set to 0, does not print iterations to the screeen
[Spec_Out]=MS_VAR_Fit_tvtp(dep,nLag,k,doIntercept,advOpt);
Screenshot:
Here is the data: https://docs.google.com/spreadsheets/d/1WGPw54y6ctJYG1HQ6L97jlTpDPmeo6Gd/edit?usp=sharing&ouid=101920988099355662450&rtpof=true&sd=true
Does anyone know how to fix this?
Thank you!
0 commentaires
Réponse acceptée
Tushar
le 17 Juin 2023
Hello Alya,
But with your code it appears like the MS_VAR_Fit_tvtp() function is returning a structure. So you must be familiar with the properties of the structure being returned. Therefore, a possible solution could be to modify the function MS_VAR_Fit_tvtp to return the specific fields of the structure that you are interested in, or you can assign the structure to multiple output variables that correspond to its fields. For example:
[Parameters, LogLikelihood, Residuals] = MS_VAR_Fit_tvtp(dep, nLag, k, doIntercept, advOpt);
Replace Parameters, LogLikelihood, and Residuals with the actual field names of the Spec_Out structure that you want to extract and use in your further analysis.
5 commentaires
Plus de réponses (0)
Voir également
Produits
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!