Code: Select all
wfopen 1.csv
scalar length = @obsrange
series logr = dlog(abs(prc)/cfacpr)
series forecasted_garch
scalar estimation_window = 100
for !i=estimation_window to length-2
smpl @first+!i-estimation_window @first+!i
equation kamo.ARCH(1,1) logr
smpl @first+!i+1 @first+!i+1
kamo.forecast r se var
forecasted_garch(!i+2)=var(!i+2)
next
smpl @all
genr problem = @recode(forecasted_garch<0,1,0)
scalar nr_of_neg_vol_forecasts = @sum(problem)
Could you please incorporate coefficient restrictions in the GARCH estimations? Preferably not just for GARCH(p,q) models where all the estimated coefficients should be nonnegative, but for any other models where these restrictions should apply.