KURT: In case you have time to look briefly at the 'garch' code, you might be interested in this example. This email includes a self-contained example that generates a warning that seems to me unnecessary: "Warning in sqrt(pred$e) : NaNs produced". This occurs because pred$e[1] = -0.121. This NaN is immediately replaced by NA in the line after this 'sqrt(pred$e)'. If the user should be concerned about this, I suggest you provide a more informative warning. Otherwise, I suggest you modify the code to eliminate this warning; see below.
ARUN KUMAR SAHA: Thanks for the reproducible example. In addition to the warning you mention, I also got "FALSE CONVERGENCE". To explore this issue, I looked at the trace output; the following shows the first and the last two rows: IT NF F RELDF PRELDF RELDX STPPAR D*STEP NPRELDF 0 1 -0.284E+04 1 7 -0.284E+04 0.16E-02 0.23E-02 0.3E-03 0.9E+10 0.3E-04 0.98E+07 ... 54 131 -0.293E+04 0.39E-14 0.40E-14 0.5E-13 0.2E+01 0.1E-12 -0.97E-02 55 133 -0.293E+04 -0.34E+07 0.81E-15 0.1E-13 0.2E+01 0.2E-13 -0.97E-02 ***** FALSE CONVERGENCE ***** The huge negative final value for "RELDF" caught my eye. I don't know what it means, but it seems strange to me, and could relate in some way to the "FALSE CONVERGENCE". To investigate this, I tried, "str(garch1)". This told me that 'garch1' is a list with 10 components, which I also saw on the "garch" help page. I didn't see anything unusual in summary(garch1) and plot(garch1). Moreover, garch1$residuals has an NA for the first observation and no other NAs, which I confirmed using sum(is.na(garch1$residuals)). However, I am NOT an expert on 'garch'; others might see things that I missed. To explore this further, I set 'options(warn=2)'; this converts warnings to errors. I got all the same printed output as before, except that 'garch' stopped on the 'warning' and failed to return anything. This told me that the warning is generated in the post-processing of the fit, preparing the list of 10 components that it normally returns. Then I listed "garch", set "debug(garch)" and repeated the call to call to "garch" [after resetting options(warn=1)]. The .C calls to "fit_garch", "pred_garch", and "ophess_garch" all seemed to work normally. I then found the following line: rank <- qr(com.hess$hess, ...)$rank The proclaimed rank was 3, as it should be. However, to explore this more, I tried the following: eigen(com.hess$hess, symmetric=TRUE) $values [1] 4.804906e+11 9.671882e+03 5.837768e+02 $vectors [,1] [,2] [,3] [1,] 1.000000e+00 0.0001342715 -4.869677e-06 [2,] 6.262745e-06 -0.0827853262 -9.965674e-01 [3,] 1.342137e-04 -0.9965673945 8.278533e-02 The ratio of the first to the last eigenevalues is almost 1e9. Conclusion: This matrix is ill conditioned, consistent with the "FALSE CONVERGENCE" report. When we round the near-singular eigenvector to 2 significant digits, we get (0, -1, 0.08). This suggests to me that the second parameter is poorly estimated. However, when I look at summary(garch1), I see that the third, not the second parameter seems unnecessary: Estimate Std. Error t value Pr(>|t|) a0 1.196e-04 1.996e-06 59.88 <2e-16 *** a1 1.001e+00 4.125e-02 24.26 <2e-16 *** b1 1.113e-14 1.070e-02 1.04e-12 1 The next step generated the warning: > sigt <- sqrt(pred$e) Warning in sqrt(pred$e) : NaNs produced This seems to be more or less anticipated, as the next line replaces the NaN produced by NA: sigt[1:max(order[1], order[2])] <- rep(NA, max(order[1], order[2])) I'm suggesting to the maintainer that he consider replacing these two steps by the following: e. <- pred$e e.[1:max(order[1], order[2])] <- rep(NA, max(order[1], order[2])) sigt <- sqrt(e.) This looks to me like it does the same thing without generating this strange warning message. If the warning is needed for some other purpose, then the code should be modified to more explicitly advice the user of the concern. Next, I tried to refit the model without the third, allegedly insignificant parameter: garch10 <- garch(dat, 1:0) <snip> Warning: singular information Maybe the eigenvector analysis was correct, and I misunderstood the "summary". This led me to try the following: garch01 <- garch(dat, 0:1) This did NOT produce a warning. Next, I tried 'anova': anova(garch1, garch01) Error in anova(garch1, garch01) : no applicable method for "anova" This didn't work, but perhaps I can get the log(likelihoods): > logLik(garch1) 'log Lik.' 2222.459 (df=3) > logLik(garch01) 'log Lik.' 2222.481 (df=2) Note that logLik for the second model is larger than the first; this is a reflection of the "singular convergence". Hope this helps. Spencer Graves Arun Kumar Saha wrote: > Dear all R-users, > > Previously I posted the same query in R-Help. But I haven't got the > solution. So I am posting the same query again. It is my strong hope that I > will get my solution this time. > > I wanted to fit a Garch(1,1) model to the following data set by: > >> garch1 = garch(dat) > But I got a warning message while executing, which is: > >> Warning message: >> NaNs produced in: sqrt(pred$e) > > dat > 0.018078 -0.0017 0.019082 0.000448 0.006055 -0.02908 -0.0171 0.136383 - > 0.01098 0.014523 -0.02504 -0.01261 -0.01301 -0.01937 0.031302 0.001924 > 0.016204 -0.01743 -0.00676 0.016391 0.037661 0.009682 -0.00311 0.034842 > 0.007326 0.004407 0.025833 0.013588 0.014807 0.030997 -0.02917 -0.01277 - > 0.02489 0.003631 0.020853 0.001613 0.016834 0.144082 -0.01198 0.009475 - > 0.00944 -0.00731 0.00854 -0.0211 -0.00037 -0.01354 -0.009 -0.00294 0.03639 > 0.005408 0.001024 -0.01789 -0.00682 -0.02709 0.015037 0.014098 -0.02083 - > 0.00259 0.003773 -0.01239 0.002841 0.006787 -0.0069 -0.00729 0.003035 > 0.001797 0.000785 0.001065 0 -0.00062 -0.00022 0.000673 0.001064 0.000168 - > 0.0019 0.000224 0.000224 0 -0.00022 0.000616 0 0.000448 0.000224 -0.00106 > 0.137144 0.00453 -0.00234 0.009654 0.017495 0.043445 0.036829 0.12604 - > 0.06833 0.075942 -0.0157 0.012691 0.0006 0.011262 -0.01698 0.001169 0.035891 > 0.026974 -0.01448 -0.01285 0.010269 -0.00944 -0.00627 -0.02959 -0.00226 - > 0.00658 -0.01566 0.002465 -0.00595 -0.00071 -0.02837 0.011752 0.000191 - > 0.01585 0.003368 0.017396 -0.01288 -0.01559 -0.00301 0.009209 -0.00362 - > 0.00477 -0.00588 0.011478 0.002748 0.01776 0.025986 -0.01573 -0.00452 - > 0.01353 -0.01166 -0.01138 -0.00419 0.020279 -0.00736 -0.0178 0.017386 - > 0.04783 -0.00973 -0.01211 -0.01552 0.020297 -0.00268 0.020165 -0.03628 > 0.004313 0.002682 0.009511 -0.0543 0.016064 0.020505 0.005516 0.02107 > 0.00809 0.021399 0.104238 -0.10466 0.025576 -0.00577 -0.01866 -0.00736 - > 0.00443 0.004892 0.012944 0.015257 -0.00633 -0.01304 -0.0065 -0.00791 - > 0.00226 0.033313 0.011476 -0.0111 -0.00365 0.033186 0.02298 -0.0037 0.002046 > -0.01238 0.008637 -0.00032 -0.00685 -0.01352 -0.00169 0.011631 0.00227 > 0.003654 0.007346 0.001533 0.005212 0.009414 0.0202 0.011882 -0.00218 - > 0.00316 7.54E-05 -0.02038 0.011471 -0.00396 -0.00658 0.006229 0.002735 - > 0.00633 0.001307 -0.00802 -0.0007 -0.01103 0.008764 -0.00781 0.01373 - > 0.00125 -0.01414 0.008101 0.001142 -0.011 0.010643 0.003889 0.006915 - > 0.00304 -0.00221 0.003028 -0.00171 -0.00144 -0.00396 0.001579 -0.00854 - > 0.00202 0.00621 0.01185 -0.01605 -0.0063 0.003573 0.001958 0.004974 -0.00326 > 0.005464 0.003653 -0.00027 0.00781 -0.00609 0.007569 -0.00209 0.001707 > 0.007578 0.008708 -0.00078 0.070744 -0.08202 -0.00271 0.018286 0.003212 > 0.00232 0.000183 0.034699 0.011807 -0.00204 0.000616 3.42E-05 0.014975 - > 0.00183 0.010891 0.010186 -0.00403 0.01614 0.002654 -0.0057 0.005801 > 0.034555 0.00405 0.010423 -0.00521 -0.00558 -0.00762 -0.00405 0.001195 > 0.002731 -0.01309 -0.00283 0.004433 -0.0118 -0.01089 0.004808 -0.00773 > 0.006685 -0.00064 0.004273 0.038674 -0.02693 -0.02044 0.021999 0.007472 > 0.011074 -0.01286 0.00217 -0.00481 0.000436 0.000871 0.003755 0.003 0.00697 > 0.006982 -0.00576 -0.00119 -0.00242 -0.00257 -0.00242 0 -0.00808 0.001454 > 0.000958 0.000124 -0.01118 0.000406 -0.00976 -0.00117 -0.01069 -0.0011 - > 0.00156 0.004814 -0.00563 0.004265 0.009255 -0.01358 -0.00346 0.003791 - > 0.00395 -0.00068 0.005023 -0.00586 -0.00207 0.00035 0.0073 0.00158 0.006326 > 0.004164 0.011432 -0.0017 -0.00139 -0.00372 0.01356 0.014993 -0.00602 > 0.011983 -0.00898 -0.00183 0.008998 -0.00252 -0.00448 0.006338 0.002094 - > 0.00744 0.000873 0.029343 -0.00155 0.005344 0.007062 0.004139 2.85E-05 > 0.00325 -0.00445 0.005597 0.004748 0.003125 0.002022 0.003193 0.002039 - > 0.00017 0.005511 -0.00264 0.001279 8.34E-05 -0.00636 0 -2.83E-05 0.002344 > 0.005121 0.009747 0.001056 -0.0049 -0.00137 -0.00029 -0.00249 0.002091 > 0.010335 -0.00105 0.001502 -0.00051 -0.00113 0 -0.00023 -0.00098 0 0.008371 > -0.01234 0.00058 0.002855 0.000115 0.007058 -0.00513 0.002124 -0.00169 - > 0.00242 0.0021 -0.00164 -0.00154 -0.00889 -0.0047 -0.00306 -0.00979 -0.0031 > 0.001016 -0.00467 -0.00952 -0.00147 -0.00335 -0.00361 -0.02078 -0.00466 > 0.007358 0.012572 0.011018 -0.00369 0.004359 0.002006 -0.00955 0.002938 - > 0.00314 0.001294 -0.00912 0.000123 -0.01086 9.36E-05 0.006065 -0.00311 > 0.004562 -0.0004 -0.00276 -0.01364 -0.0005 0.007126 0.004463 0.005373 > 0.000836 0.005802 0.001599 -0.01348 -0.01842 -0.0056 -0.00329 -0.00526 > 0.001253 -0.00813 0.004265 0.00694 0.005237 -0.00771 9.63E-05 -0.00019 > 0.005506 -0.00026 -0.00195 0.003003 0.001944 0.000699 0.000508 0.00073 > 0.000222 0.005727 0.001041 -0.00404 -0.01018 -0.00307 -0.00865 0.001065 - > 0.00686 0.002142 0.000907 0.000162 0.003807 -0.00177 -0.00398 -0.00399 - > 0.00117 0.002893 -0.00081 -0.00068 0.002409 -0.00639 -0.0062 -0.00617 > 0.005078 -0.00292 0.00226 -0.04239 0.003596 -0.00117 -0.00131 0.003765 > 0.000793 0.006592 -0.00123 0.001917 0.003005 0.001876 -0.0016 -0.00229 - > 0.00347 0.002996 -0.00203 -0.00273 0.002313 -0.00431 0.000187 0.002663 - > 0.0008 -0.00227 -0.00227 0.002352 -0.00614 -0.00791 0.003025 -0.00174 > 0.004621 0.004621 0.001327 -0.00105 -0.00344 0.003162 -0.00364 0.001658 - > 0.00161 -0.00086 -0.00179 -0.00061 0.00453 -0.0006 -0.00529 -0.00458 -0.0019 > 0.001411 -0.00148 -0.00888 -0.00045 0.001676 -0.00194 0.002029 0.001394 > 0.001812 0.002699 -0.00207 0.005783 -0.00469 -0.00156 0.008546 -0.00837 - > 0.01456 -0.02116 0.004523 -0.00673 -0.00626 -0.0145 -0.00313 -0.03585 - > 0.02317 0.01289 -0.00122 -0.01519 -0.03454 0.008239 -0.00756 -0.00419 > 0.00629 -0.00236 -0.00498 0.004631 0.008615 0.01143 0.016818 -0.00412 - > 0.00034 0.001046 -0.00774 -0.00239 -0.01782 -0.00428 0.005898 0.004978 - > 0.00457 -0.00544 0.00923 -0.00402 -0.0076 0 0.003472 -0.00344 0.006295 > 0.006864 -0.00096 0.001192 -0.00498 0.001576 0.006863 0.004808 0.000976 > 0.00086 0.002033 0.002714 0.004112 0.008735 -0.00377 -0.0002 -0.01089 - > 0.00402 0.003514 0.00171 -0.00351 -0.05464 0.003282 -0.00508 -0.00342 - > 0.00253 0.006963 -0.00322 -0.00157 -0.00454 -0.00054 0.002806 -0.00057 > 0.002048 -0.00731 -0.0055 0.000986 -0.00087 -0.04326 0.04659 0.005094 > 0.004819 0.002076 -0.00465 -0.00352 -0.00294 -0.00307 0.00022 0.008688 > 0.001182 0.00087 0.00065 -0.00989 0.005141 -0.00655 -0.00632 -0.00965 - > 0.00497 0.00045 0.004568 0.004253 0.016834 -0.01762 -0.00521 0.000328 - > 0.00801 -0.00676 -0.00363 -0.00152 -0.00411 0.002059 -0.00764 -0.00746 > 0.001618 0.001951 0.004091 -0.00159 -0.00164 -0.0014 0.0044 -0.00114 > 0.002384 -0.00119 -0.00602 0.031675 0.006157 -0.00487 0.00327 0.006087 > 0.004132 0.001138 0.000126 0.013054 0.000779 -0.00075 -0.00842 -0.00612 - > 0.0018 0.002125 -0.00157 0.003201 0.001785 -0.00291 -0.00028 -0.00676 > 0.000185 0.003607 0.001109 0.005279 0.000459 -0.0022 -0.00249 0.003486 - > 0.00841 -0.00529 0.00237 0.003607 0.001737 0.004438 0.001153 -0.00184 - > 0.00338 0.001567 -9.39E-05 0.002127 0.007596 -0.00028 -6.20E-05 -0.00165 - > 0.00495 -0.00012 -0.00471 -0.00498 -0.00713 0.008507 0.001599 -9.40E-05 > 0.003224 0.002466 0.012423 -0.00262 0.001542 -0.00126 0.001264 -0.00361 - > 0.00509 0.003538 -0.00419 -0.00022 0.002021 0.005543 -0.00649 0.004877 - > 0.00034 0.000155 -0.00292 -0.00022 -0.00134 0.000249 -0.00193 0.000125 - > 0.00225 -0.00718 -0.00949 0.01128 0.002425 -0.00035 -0.00397 -0.00662 > 0.003302 -0.00096 -0.00447 0.009146 0.0044 > Can anyone tell me where the problem is? > > Thanks and regards > > [[alternative HTML version deleted]] > > ______________________________________________ > R-help@stat.math.ethz.ch mailing list > https://stat.ethz.ch/mailman/listinfo/r-help > PLEASE do read the posting guide! http://www.R-project.org/posting-guide.html ______________________________________________ R-help@stat.math.ethz.ch mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide! http://www.R-project.org/posting-guide.html