title: Extract coefficients and variance-covariance matrix from var output (estimated with vars package)
body: <p>I want to extract the coefficients and variance-covariance matrix from the output of my estimated var model (estimated with vars package). Is there a way to save the coefficients into an array, and the var-cov matrix into a matrix so that I can later extract certain numbers out of these and use as input for a later function (which is my ultimate goal).  </p>
  
  <p>This a mock estimation and results. </p>
  
  <pre><code>sale1_ts &lt;- ts(sale1, frequency=12, start=c(2012,1))
  sale2_ts &lt;- ts(sale2, frequency=12, start=c(2012,1))
  
  #VARMODEL
  varendo&lt;-data.frame(sale1_ts,sale2_ts)
  names(varendo)&lt;-c("sale1_ts","sale2_ts")
  attach(varendo)
  
  library(vars)
  fitvar&lt;- VAR(varendo, type = c("both"), season = NULL, lag.max = 12,ic = c("AIC"))
  summary(fitvar)
  </code></pre>
  
  <p>This leads to following output</p>
  
  <pre><code>Endogenous variables: sale1_ts, sale2_ts 
  Deterministic variables: both 
  Sample size: 21 
  Log Likelihood: -43.463 
  Roots of the characteristic polynomial:
  1.19 1.06 1.06 0.961 0.961 0.96 0.96 0.914 0.914 0.883 0.883 0.84 0.84 0.75
  Call:
  VAR(y = varendo, type = c("both"), lag.max = 12, ic = c("AIC"))
  
  
  Estimation results for equation sale1_ts: 
  ========================================= 
  sale1_ts = sale1_ts.l1 + sale2_ts.l1 + sale1_ts.l2 + sale2_ts.l2 + sale1_ts.l3 + sale2_ts.l3 + sale1_ts.l4 + sale2_ts.l4 + sale1_ts.l5 + sale2_ts.l5 + sale1_ts.l6 + sale2_ts.l6 + sale1_ts.l7 + sale2_ts.l7 + const + trend 
  
              Estimate Std. Error t value Pr(&gt;|t|)
  sale1_ts.l1  -0.0576     0.3603   -0.16     0.88
  sale2_ts.l1  -0.0384     0.3538   -0.11     0.92
  sale1_ts.l2  -0.4768     0.3933   -1.21     0.28
  sale2_ts.l2   0.1963     0.3137    0.63     0.56
  sale1_ts.l3  -0.0837     0.3245   -0.26     0.81
  sale2_ts.l3  -0.2097     0.6108   -0.34     0.75
  sale1_ts.l4  -0.5665     0.3653   -1.55     0.18
  sale2_ts.l4  -0.3511     0.5174   -0.68     0.53
  sale1_ts.l5  -0.1479     0.4199   -0.35     0.74
  sale2_ts.l5   0.1263     0.4640    0.27     0.80
  sale1_ts.l6  -0.3143     0.3684   -0.85     0.43
  sale2_ts.l6   0.1174     0.2700    0.43     0.68
  sale1_ts.l7  -0.4727     0.4810   -0.98     0.37
  sale2_ts.l7   0.3255     0.3071    1.06     0.34
  const        12.5453    13.4200    0.93     0.39
  trend         0.1062     0.0759    1.40     0.22
  
  Residual standard error: 1.5 on 5 degrees of freedom
  Multiple R-Squared: 0.741,  Adjusted R-squared: -0.0376 
  F-statistic: 0.952 on 15 and 5 DF,  p-value: 0.575 
  
  Estimation results for equation sale2_ts: 
  ========================================= 
  sale2_ts = sale1_ts.l1 + sale2_ts.l1 + sale1_ts.l2 + sale2_ts.l2 + sale1_ts.l3 + sale2_ts.l3 + sale1_ts.l4 + sale2_ts.l4 + sale1_ts.l5 + sale2_ts.l5 + sale1_ts.l6 + sale2_ts.l6 + sale1_ts.l7 + sale2_ts.l7 + const + trend 
  
              Estimate Std. Error t value Pr(&gt;|t|)  
  sale1_ts.l1  -0.7135     0.3899   -1.83    0.127  
  sale2_ts.l1  -0.0598     0.3829   -0.16    0.882  
  sale1_ts.l2  -0.4054     0.4257   -0.95    0.385  
  sale2_ts.l2  -0.0300     0.3395   -0.09    0.933  
  sale1_ts.l3  -0.7129     0.3512   -2.03    0.098 .
  sale2_ts.l3   0.6945     0.6611    1.05    0.342  
  sale1_ts.l4  -0.7165     0.3954   -1.81    0.130  
  sale2_ts.l4   0.4709     0.5600    0.84    0.439  
  sale1_ts.l5   0.1324     0.4545    0.29    0.783  
  sale2_ts.l5   0.7127     0.5022    1.42    0.215  
  sale1_ts.l6   0.2318     0.3987    0.58    0.586  
  sale2_ts.l6  -0.0859     0.2922   -0.29    0.781  
  sale1_ts.l7   0.4826     0.5206    0.93    0.397  
  sale2_ts.l7   0.5011     0.3324    1.51    0.192  
  const        -0.6180    14.5252   -0.04    0.968  
  trend         0.1744     0.0822    2.12    0.087 .
  ---
  Signif. codes:  0 ‘***’ 0.001 ‘**’ 0.01 ‘*’ 0.05 ‘.’ 0.1 ‘ ’ 1
  
  Residual standard error: 1.6 on 5 degrees of freedom
  Multiple R-Squared: 0.819,  Adjusted R-squared: 0.276 
  F-statistic: 1.51 on 15 and 5 DF,  p-value: 0.343 
  
  
  Covariance matrix of residuals:
           sale1_ts sale2_ts
  sale1_ts     2.14    -1.25
  sale2_ts    -1.25     2.51
  
  Correlation matrix of residuals:
           sale1_ts sale2_ts
  sale1_ts    1.000   -0.541
  sale2_ts   -0.541    1.000
  </code></pre>
  
  <p>I have tried print() and coefficients() but this gets me strange results. E.g.    </p>
  
  <pre><code>test&lt;-array(coefficients(fitvar), c(16,4,2))
  
  &gt; test
  , , 1
  
        [,1]       [,2]       [,3]       [,4]      
   [1,] Numeric,64 Numeric,64 Numeric,64 Numeric,64
   [2,] Numeric,64 Numeric,64 Numeric,64 Numeric,64
   [3,] Numeric,64 Numeric,64 Numeric,64 Numeric,64
   [4,] Numeric,64 Numeric,64 Numeric,64 Numeric,64
   [5,] Numeric,64 Numeric,64 Numeric,64 Numeric,64
   [6,] Numeric,64 Numeric,64 Numeric,64 Numeric,64
   [7,] Numeric,64 Numeric,64 Numeric,64 Numeric,64
   [8,] Numeric,64 Numeric,64 Numeric,64 Numeric,64
   [9,] Numeric,64 Numeric,64 Numeric,64 Numeric,64
   [10,] Numeric,64 Numeric,64 Numeric,64 Numeric,64
   [11,] Numeric,64 Numeric,64 Numeric,64 Numeric,64
   [12,] Numeric,64 Numeric,64 Numeric,64 Numeric,64
   [13,] Numeric,64 Numeric,64 Numeric,64 Numeric,64
   [14,] Numeric,64 Numeric,64 Numeric,64 Numeric,64
   [15,] Numeric,64 Numeric,64 Numeric,64 Numeric,64
   [16,] Numeric,64 Numeric,64 Numeric,64 Numeric,64
  
  , , 2
  
        [,1]       [,2]       [,3]       [,4]      
   [1,] Numeric,64 Numeric,64 Numeric,64 Numeric,64
   [2,] Numeric,64 Numeric,64 Numeric,64 Numeric,64
   [3,] Numeric,64 Numeric,64 Numeric,64 Numeric,64
   [4,] Numeric,64 Numeric,64 Numeric,64 Numeric,64
   [5,] Numeric,64 Numeric,64 Numeric,64 Numeric,64
   [6,] Numeric,64 Numeric,64 Numeric,64 Numeric,64
   [7,] Numeric,64 Numeric,64 Numeric,64 Numeric,64
   [8,] Numeric,64 Numeric,64 Numeric,64 Numeric,64
   [9,] Numeric,64 Numeric,64 Numeric,64 Numeric,64
   [10,] Numeric,64 Numeric,64 Numeric,64 Numeric,64   
   [11,] Numeric,64 Numeric,64 Numeric,64 Numeric,64
   [12,] Numeric,64 Numeric,64 Numeric,64 Numeric,64
   [13,] Numeric,64 Numeric,64 Numeric,64 Numeric,64
   [14,] Numeric,64 Numeric,64 Numeric,64 Numeric,64
   [15,] Numeric,64 Numeric,64 Numeric,64 Numeric,64
   [16,] Numeric,64 Numeric,64 Numeric,64 Numeric,64
  </code></pre>