You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
std_resids=resids/np.sqrt(pi_weighted_sigma2) ## Using stationary distribution to weight regime variances. This is only an approximation (true weights should come from filtered probabilties), but we don't have these available at this stage
723
729
724
730
# 2. Construct constraint matrices from all models and distribution
725
-
constraints= (
731
+
constraints= (
726
732
self.constraints(),
727
733
self.volatility.constraints(),
728
734
self.distribution.constraints(),
@@ -790,12 +796,16 @@ def fit(
790
796
_callback_info["display"] =update_freq
791
797
disp_flag=Trueifdisp=="final"elseFalse
792
798
793
-
func=self._loglikelihood
794
-
args= (sigma2, backcast, var_bounds)
795
-
ineq_constraints=constraint(a, b)
799
+
ifisinstance(self.volatility, MSGARCH):
800
+
func=self.volatility.msgarch_loglikelihood# MS GARCH
801
+
args= (resids, sigma2, backcast, var_bounds)
796
802
797
-
fromscipy.optimizeimportminimize
803
+
else:
804
+
func=self._loglikelihood# standard GARCH
805
+
args= (sigma2, backcast, var_bounds)
798
806
807
+
ineq_constraints=constraint(a, b)
808
+
fromscipy.optimizeimportminimize
799
809
options= {} ifoptionsisNoneelseoptions
800
810
options.setdefault("disp", disp_flag)
801
811
withwarnings.catch_warnings():
@@ -835,7 +845,10 @@ def fit(
835
845
mp, vp, dp=self._parse_parameters(params)
836
846
837
847
resids=self.resids(mp)
838
-
vol=np.zeros(resids.shape[0], dtype=float)
848
+
ifisinstance(self.volatility, MSGARCH):
849
+
vol=np.zeros((resids.shape[0], n_regimes), dtype=float) # MS GARCH
850
+
else:
851
+
vol=np.zeros(resids.shape[0], dtype=float) # standard GARCH
0 commit comments