Conversion to logical from struct is not possible.

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:
Does anyone know how to fix this?
Thank you!

 채택된 답변

Tushar
Tushar 2023년 6월 17일
Hello Alya,
Here is the Link to the question with the similar issue.
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

Alya
Alya 2023년 6월 17일
Thank you for the answer!
However, I tried running the command given but now it says "too many output arguments".
Can you give an exact description of MS_VAR_Fit_tvtp() function?
You are mssing the px parameter in your call to MS_VAR_Fit_tvtp
Alya
Alya 2023년 6월 19일
Oh! I thought it was unnecessary as the older function didn't require it. Thank you for the help.

댓글을 달려면 로그인하십시오.

추가 답변 (0개)

카테고리

도움말 센터File Exchange에서 Historical Contests에 대해 자세히 알아보기

질문:

2023년 6월 17일

댓글:

2023년 6월 19일

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!

Translated by