# AssertionError: isfinite(phi\_c) && isfinite(dphi\_c) when estimating EGARCH

**URL:** <https://discourse.julialang.org/t/assertionerror-isfinite-phi-c-isfinite-dphi-c-when-estimating-egarch/89841>\
**Category:** Statistics\
**Created:** [November 6, 2022, 3:40pm UTC](https://discourse.julialang.org/t/assertionerror-isfinite-phi-c-isfinite-dphi-c-when-estimating-egarch/89841 "2022-11-06T15:40:50Z")\
**Posts on this page:** 1\
**Page:** 1

<div class="post-metadata">

**Author:** ![ultratrader](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/ultratrader/32/42836_2.png) [@ultratrader](https://discourse.julialang.org/u/ultratrader)\
**Post date:** [November 6, 2022, 3:40pm UTC](https://discourse.julialang.org/t/assertionerror-isfinite-phi-c-isfinite-dphi-c-when-estimating-egarch/89841/1 "2022-11-06T15:40:50Z")

</div>

I tried to forecast VaR(Value at Risk) based on GARCH model using ARCHModels.jl. I found no problem for standard GARCH and TGARCH.

```julia
using TimeSeries, MarketData, ARCHModels
using Plots, Dates, Missings
startdate = DateTime(2015, 1, 1)
enddate = DateTime(2020, 12, 31)
ihsg_ta = yahoo("^JKSE", YahooOpt(period1 = startdate,
                                period2 = enddate,
                                interval = "1d"))
rt = diff(log.(ihsg_ta[:Close]))
y = collect(skipmissing(values(rt)))

```

There is no problem to fit below models!

```julia
am = fit(EGARCH{3, 1, 2}, y; dist=StdNormal, meanspec=NoIntercept);
vars = VaRs(am, 0.01)

```

but problem occurs when I try to forecast one-step ahead VaR value using below codes (even it worked for standard GARCH and TGARCH)

```julia
T = length(y);
windowsize = 1000;
vars = similar(y);
for t = windowsize+1:T-1
    m = fit(EGARCH{3, 1, 2}, y[t-windowsize:t]; dist=StdNormal, meanspec=NoIntercept)
    vars[t+1] = predict(m, :VaR; level=0.01)
end

```

I know that there were problems as discussed [here](https://discourse.julialang.org/t/optimization-error/77358) and  
[here](https://discourse.julialang.org/t/optim-with-occasionally-non-finite-values/10174)

Is there an error with the second code? I just curious why the first code works,  
but the second error. I replicate the code from this [manual](https://s-broda.github.io/ARCHModels.jl/stable/usage/#Forecasting)
