Generate BEKK latex PDF and diagnoseBEKK of the 'mgarchBEKK' package

Asked

Viewed 47 times

-2

I want to generate in PDF latex the functions BEKK and diagnoseBEKK of the mgarchBEKK package, only that it comes out all disfigured. It follows from the data:

> head(LOG1)
     [,1]     [,2]
[1,] 3.129256 3.288402
[2,] 3.148093 3.292126
[3,] 3.151220 3.284664
[4,] 3.145901 3.280911
[5,] 3.140324 3.295837
[6,] 3.143793 3.295837 

> dput(head(LOG1, 20))
structure(c(3.12925604926495, 3.14809347817882, 3.15122000536595, 
3.14590053886684, 3.14032413879594, 3.14379279514427, 3.15001885787015, 
3.15575581137615, 3.1871339647665, 3.17698029293942, 3.1650185553098, 
3.15712199430691, 3.15808523968012, 3.1424437880591, 3.11208598177176, 
3.12253114789199, 3.15877485557127, 3.16054905970894, 3.17276954280673, 
3.18961151256573, 3.28840188751681, 3.29212628660779, 3.2846635654062, 
3.28091121578765, 3.29583686600433, 3.29583686600433, 3.29620716780452, 
3.30688670219091, 3.32143241319329, 3.31418600467253, 3.29953372788566, 
3.31600253559892, 3.31418600467253, 3.30027146307219, 3.2846635654062, 
3.28840188751681, 3.30431930668567, 3.30431930668567, 3.34215484102837, 
3.33932197794407), .Dim = c(20L, 2L))

When I Gero the BEKK function:

> estimated1 <- BEKK(as.matrix(LOG1),c(1, 1))
H IS SINGULAR!...
H IS SINGULAR!...
H IS SINGULAR!...
H IS SINGULAR!...
H IS SINGULAR!...

and the diagnoseBEKK function, I would like to generate in table "C estimates", "ARCH estimates" and "GARCH estimates"

> diagnoseBEKK(estimated1)
Number of estimated series :  5282 
Length of estimated series :  2641 
Estimation Time            :  6.374574 
Total Time                 :  7.716886 
BEKK order                 :  1 1 
Eigenvalues                :  13.62364 1.016955 0.7921524 0.09844105 
aic                        :  -206.238 
unconditional cov. matrix  :  677.4441 -669.5645 -669.5645 661.1839 
var(resid 1 )                :  0.5140241 
mean(resid 1 )               :  0.6797914 
var(resid 2 )                :  0.4907388 
mean(resid 2 )               :  0.6919167 
Estimated parameters       :

C estimates:
          [,1]        [,2]
[1,] -0.06893851 -0.07384558
[2,]  0.00000000  0.01378535

ARCH estimates:
         [,1]      [,2]
[1,]  0.3166768  1.250476
[2,] -1.2402237 -2.175200

GARCH estimates:
        [,1]       [,2]
[1,] -1.726880 -1.3451395
[2,]  1.316612  0.9358533

asy.se.coef                : 

C estimates, standard errors:
       [,1]         [,2]
[1,] 0.03257374 0.0331921785
[2,] 0.00000000 0.0004459779

ARCH estimates, standard errors:
        [,1]      [,2]
[1,] 0.1476386 0.1501182
[2,] 0.1460898 0.1473559

GARCH estimates, standard errors:
        [,1]      [,2]
[1,] 0.5575840 0.5634912
[2,] 0.5514318 0.5570802

And also asks to click on "continue", which I would also like to take to avoid disturbing the time to generate the PDF

Called from: diagnoseBEKK(estimated1)
Browse[1]> c
Called from: diagnoseBEKK(estimated1)
Browse[1]> c
  • Instead of posting the functions of a package we can get, please edit the question with the instructions you tried, how you called these functions and with the output of dput(dados) or, if the base is too large, dput(head(dados, 20))? Note: dados is the base name, for example a data frame..

  • Okay Rui, I’ve made the right changes.

  • Much better. But the code is missing, as it is using the functions that are causing problems, as you are calling them.

  • I think put the information you requested, if I understand correctly. Thank you Rui

1 answer

2


You can create a latex table for each array of estimates with the following function. I will not use the package stargazer but yes the package xtable, that is simpler and that for this problem arrives well.

Function output is a list of latex tables, one for each member of the list.

library(mgarchBEKK)
library(xtable)


mgarchBEKKlatex <- function(x, digits = 4, ...){
  out <- vector("list", length = sum(c(1, x$order)))
  out[[1]] <- xtable(x$est.params[[1]],
                     caption = "C estimates:",
                     digits = digits, ...)
  if (x$order[2] > 0) {
    caption <- "ARCH estimates:"
    for (count in seq_len(x$order[2])) {
      out[[count + 1]] <- xtable(x$est.params[[count + 1]],
                                 caption = caption,
                                 label = paste("order:", count),
                                 digits = digits, ...)
    }
  }
  if (x$order[1] > 0) {
    caption <- "ARCH estimates:"
    for (count2 in seq_len(x$order[1])) {
      out[[count2 + count + 1]] <- xtable(x$est.params[[count2 + count + 1]],
                                 caption = caption,
                                 label = paste("order:", count),
                                 digits = digits, ...)
    }
  }
  out
}

estimated1 <- BEKK(LOG1, c(1, 1))

tabelas <- mgarchBEKKlatex(estimated1)

tabelas[[1]]
#% latex table generated in R 3.6.1 by xtable 1.8-4 package
#% Mon Aug 12 20:28:18 2019
#\begin{table}[ht]
#\centering
#\begin{tabular}{rrr}
#  \hline
# & 1 & 2 \\ 
#  \hline
#1 & 6.1491 & 6.4497 \\ 
#  2 & 0.0000 & 0.0040 \\ 
#   \hline
#\end{tabular}
#\caption{C estimates:} 
#\end{table}

Browser other questions tagged

You are not signed in. Login or sign up in order to post.