问:
How to use & interpret bivariate GARCH GJR model using mGJR()
I am using a bivariate GJR model using mGJR() command from R.

The instruction from the package "mgarchBEKK" says I input first time series, second time series, and so on. I am trying to use the unexpected returns as my input and need coefficients from these.

I thought I needed to input my pre-calculated unexpected returns as my first time series, second time series and so on into my model.

However, when I run mGJR(), it gives out the output saying "$resid1" and "$resid2" which look like the residuals (i.e. unexpected returns) which I've been looking for.

If so, do I need to input the returns not the unexpected returns into the model to derive the unexpected returns automatically?

Besides, how does my bivariate GJR GARCH model looks like if I try to describe it using the coefficients derived from my output below?
How can I get the coefficients for the model that I need for my analysis from the long output I have below?
Specifically, I find that I have a total of 17 coefficients where one of them is zero. I find that these coefficients are grouped by 4 where the last one is only one left.

For instance, I find $est.params$1, $est.params$2, $est.params$3, $est.params$4, $est.params$5 where there is a total of 17 parameters.
However, I am not sure how mathematically these are expressed explicitly within the formal bivariate GJR GARCH formula.

Please note that this is "bivariate" GJR GARCH not just GJR GARCH. Thus, I have 17 parameters where I have 4 blocks each with 4 coefficients plus one parameter making it a total of 17. However, I don't know which parameter corresponds to which variable coefficient. I tried to provide as much information as possible but if any clarification needed please let me know.

The output I get using the expected return is the following:

mGJR(eps1, eps2, order = c(1, 1, 1))

```    Warning: initial values for the parameters are set at:
             2 0 2 0.4 0.1 0.1 0.4 0.4 0.1 0.1 0.4 0.1 0.1 0.1 0.1 0.5
    Starting estimation process via loglikelihood function implemented in C.
    Optimization Method is ' BFGS '
    H IS SINGULAR!...
    H IS SINGULAR!...
    H IS SINGULAR!...
    H IS SINGULAR!...
    H IS SINGULAR!...
    H IS SINGULAR!...
    H IS SINGULAR!...
    H IS SINGULAR!...
    H IS SINGULAR!...
    H IS SINGULAR!...
    H IS SINGULAR!...
    H IS SINGULAR!...
    H IS SINGULAR!...
    H IS SINGULAR!...
    H IS SINGULAR!...
    H IS SINGULAR!...
    H IS SINGULAR!...
    H IS SINGULAR!...
    H IS SINGULAR!...
    H IS SINGULAR!...
    H IS SINGULAR!...
    H IS SINGULAR!...
    H IS SINGULAR!...
    H IS SINGULAR!...
    H IS SINGULAR!...
    H IS SINGULAR!...
    H IS SINGULAR!...
    H IS SINGULAR!...
    H IS SINGULAR!...
    H IS SINGULAR!...
    H IS SINGULAR!...
    H IS SINGULAR!...
    H IS SINGULAR!...
    H IS SINGULAR!...
    H IS SINGULAR!...
    H IS SINGULAR!...
    H IS SINGULAR!...
    H IS SINGULAR!...
    H IS SINGULAR!...
    H IS SINGULAR!...
    H IS SINGULAR!...
    H IS SINGULAR!...
    H IS SINGULAR!...
    H IS SINGULAR!...
    H IS SINGULAR!...
    H IS SINGULAR!...
    H IS SINGULAR!...
    H IS SINGULAR!...
    H IS SINGULAR!...
    H IS SINGULAR!...
    H IS SINGULAR!...
    H IS SINGULAR!...
    H IS SINGULAR!...
    H IS SINGULAR!...
    H IS SINGULAR!...
    H IS SINGULAR!...
    H IS SINGULAR!...
    H IS SINGULAR!...
    H IS SINGULAR!...
    H IS SINGULAR!...
    H IS SINGULAR!...
    H IS SINGULAR!...
    H IS SINGULAR!...
    H IS SINGULAR!...
    H IS SINGULAR!...
    H IS SINGULAR!...
    H IS SINGULAR!...
    H IS SINGULAR!...
    H IS SINGULAR!...
    H IS SINGULAR!...
    H IS SINGULAR!...
    H IS SINGULAR!...
    H IS SINGULAR!...
    H IS SINGULAR!...
    H IS SINGULAR!...
    H IS SINGULAR!...
    H IS SINGULAR!...
    H IS SINGULAR!...
    H IS SINGULAR!...
    H IS SINGULAR!...
    H IS SINGULAR!...
    H IS SINGULAR!...
    H IS SINGULAR!...
    H IS SINGULAR!...
    H IS SINGULAR!...
    H IS SINGULAR!...
    H IS SINGULAR!...
    H IS SINGULAR!...
    H IS SINGULAR!...
    H IS SINGULAR!...
    Estimation process completed.
    Starting diagnostics...
    Calculating estimated:
     1. residuals,
     2. correlations,
     3. standard deviations,
     4. eigenvalues.
    Diagnostics ended...
    Class attributes are ready via following names:
    eps1 eps2 series.length estimation.time total.time order estimation aic asy.se.coef est.params cor sd1 sd2 H.estimated eigenvalues uncond.cov.matrix resid1 resid2
    $eps1
     [1] -0.002605971  0.110882333 -0.148960989 -0.068514869 -0.003755887
     [6]  0.010796054 -0.147830267  0.047830346  0.028587561  0.003945359
    [11]  0.082094667 -0.027768830 -0.006713995  0.024364330 -0.012109627
    [16] -0.018345875  0.025668553  0.004490535  0.017510124  0.027143473
    [21]  0.011606530  0.010522457  0.026053738  0.009380949 -0.070996648
    [26]  0.020755072 -0.005830603  0.014289265 -0.000418889  0.022697292
    [31]  0.023063329  0.005635615  0.049926161  0.013989454  0.019870327
    [36]  0.018279627  0.014478743 -0.002177036  0.024635614  0.050726032
    [41] -0.004392337  0.001234857 -0.018066777 -0.054437778  0.010428982
    [46] -0.082777078  0.127812102  0.008940764 -0.001295593  0.060328122
    [51] -0.009104799 -0.007204478  0.045631975  0.023096514  0.010598574
    [56]  0.016541977 -0.011387952 -0.038157908  0.010327360  0.044342365
    [61]  0.035077460  0.017492338  0.038596692  0.137205423 -0.004735584
    [66]  0.104792896  0.036139814 -0.096482047 -0.000561027 -0.002632458
    [71]  0.016177144  0.025230196  0.031753168  0.068971843  0.054021759
    [76]  0.027263191 -0.025345373  0.033643409 -0.060322431  0.030377924
    [81] -0.069716766 -0.089266804

    $eps2
     [1] -0.002889166  0.003033355 -0.002152031  0.003236581  0.003236581
     [6] -0.001602802  0.004961099 -0.003176289 -0.000264979 -0.000264979
    [11] -0.000264979 -0.001112752  0.004795299  0.004795299  0.005683859
    [16]  0.007793699  0.001613168 -0.000354773  0.001350773 -0.000303199
    [21]  0.009337753  0.009337753  0.001886769 -0.001791025  0.005869744
    [26]  0.004795546  0.004795546  0.004509183  0.005226653  0.000383686
    [31]  0.000207546  0.000207546  0.000207546  0.001570381  0.001669796
    [36]  0.000549576  0.000549576 -0.001210093  0.014468461 -0.005345880
    [41]  0.000130449  0.000130449 -0.001412638 -0.003304416  0.000117946
    [46]  0.002145056  0.002145056 -0.002114632  0.005395410 -0.003153774
    [51]  0.001888270 -0.001988031  0.000716514 -0.000331566 -0.000331566
    [56] -0.000325350 -0.002882419 -0.006754058 -0.006754058 -0.001131800
    [61] -0.017930260  0.002718202  0.006840023  0.006840023  0.002059632
    [66]  0.003552300  0.003350965 -0.000126651 -0.000126651 -0.000126651
    [71] -0.000990530  0.006430433  0.002933145  0.002933145 -0.002259438
    [76]  0.001770744  0.000417412  0.004213458  0.004213458  0.004360485
    [81]  0.002158630 -0.000686097

    $series.length
    [1] 82

    $estimation.time
    Time difference of 0.109386 secs

    $total.time
    Time difference of 0.1562669 secs

    $order
    GARCH component  ARCH component   HJR component
                  1               1               1

    $estimation
    $estimation$par
     [1] -3.902944e-02 -2.045331e-05 -4.296356e-03  2.268312e-01  2.111034e+00
     [6]  1.350601e-04  1.252329e-01 -3.143425e-01 -1.538355e-02 -5.587068e-03
    [11] -1.628474e-04  4.224089e-01  1.025256e-01 -7.414033e-03 -4.869328e-01
    [16] -1.102507e+00

    $estimation$value
    [1] -459.6969

    $estimation$counts
    function gradient
         278       53

    $estimation$convergence
    [1] 0

    $estimation$message
    NULL

    $estimation$hessian
                   [,1]          [,2]          [,3]          [,4]          [,5]
     [1,]  77991.191735  -27033.70607 -1.895287e+03 -655.73521140 -6.727215e+01
     [2,] -27033.706072 3337349.78552 -3.369295e+05 -371.07738150 -1.447052e+02
     [3,]  -1895.286899 -336929.51987  1.109169e+07 -122.26145691 -5.595868e+00
     [4,]   -655.735211    -371.07738 -1.222615e+02   18.61522485 -1.311354e-02
     [5,]    -67.272152    -144.70520 -5.595868e+00   -0.01311354  3.109780e-01
     [6,]     20.487872  -18111.17773  3.525887e+03   -5.52437237 -8.751496e-02
     [7,]    -26.898108   -2073.43486 -2.975629e+03   -0.26691407 -3.916406e-01
     [8,]   1477.726124     320.50607 -4.807709e+02   -9.98402142 -9.782072e-01
     [9,]      9.388141     -27.62368 -5.331019e+01   -0.16106385 -1.537450e-02
    [10,]   -179.429796   49000.01743  2.023153e+04    7.66772695  1.378254e+00
    [11,]     16.757240     -87.91362  2.360375e+03    0.23119576  7.084715e-02
    [12,]   -317.440585     -56.15303  3.710999e+01    6.57357184 -1.785094e-01
    [13,]      3.793978      98.71583 -1.142264e+01   -0.22870343  1.543862e-02
    [14,]   -146.123961   -9829.15416 -5.196531e+02  -29.62565159  4.260863e-01
    [15,]     18.082524     131.52060  3.398486e+03    0.33823287  3.212786e-02
    [16,]     11.460530    -240.54059  6.706526e+02    0.32655416 -4.680544e-03
                   [,6]          [,7]         [,8]          [,9]        [,10]
     [1,]  2.048787e+01   -26.8981081 1477.7261235    9.38814077  -179.429796
     [2,] -1.811118e+04 -2073.4348620  320.5060742  -27.62367781 49000.017430
     [3,]  3.525887e+03 -2975.6287124 -480.7709387  -53.31018730 20231.529905
     [4,] -5.524372e+00    -0.2669141   -9.9840214   -0.16106385     7.667727
     [5,] -8.751496e-02    -0.3916406   -0.9782072   -0.01537450     1.378254
     [6,]  4.340038e+03    72.0221887   23.7403796    4.74321851  -479.279271
     [7,]  7.202219e+01    22.5064989   -0.6280896    0.21674046   -44.382358
     [8,]  2.374038e+01    -0.6280896  123.3928335    2.05555317   -53.354577
     [9,]  4.743219e+00     0.2167405    2.0555532   20.53760214    53.165201
    [10,] -4.792793e+02   -44.3823578  -53.3545766   53.16520102 17583.612011
    [11,] -2.045612e+00     1.0454365   38.9154805 -823.29002882 -1763.407498
    [12,] -1.488681e+01    -0.5717977   -6.3888226   -0.05658090   -21.965231
    [13,] -4.554201e-01    -0.2556849    0.1795778    0.01041940     1.602574
    [14,]  2.372186e+02   -13.7297349   13.5989185   -1.51829772  -127.664692
    [15,] -1.372792e+01    -1.3537030    0.4896836    0.05291901    12.398407
    [16,] -2.586931e+00    -0.1781386    0.1308570    0.05498165    -7.648387
                  [,11]        [,12]        [,13]         [,14]         [,15]
     [1,]  1.675724e+01 -317.4405852   3.79397825  -146.1239612   18.08252377
     [2,] -8.791362e+01  -56.1530304  98.71583141 -9829.1541554  131.52059520
     [3,]  2.360375e+03   37.1099898 -11.42263544  -519.6531079 3398.48583556
     [4,]  2.311958e-01    6.5735718  -0.22870343   -29.6256516    0.33823287
     [5,]  7.084715e-02   -0.1785094   0.01543862     0.4260863    0.03212786
     [6,] -2.045612e+00  -14.8868094  -0.45542005   237.2185632  -13.72791768
     [7,]  1.045436e+00   -0.5717977  -0.25568491   -13.7297349   -1.35370300
     [8,]  3.891548e+01   -6.3888226   0.17957777    13.5989185    0.48968359
     [9,] -8.232900e+02   -0.0565809   0.01041940    -1.5182977    0.05291901
    [10,] -1.763407e+03  -21.9652313   1.60257372  -127.6646916   12.39840658
    [11,]  4.214986e+04   -0.0719787   0.06153061   -11.5769904    1.70462536
    [12,] -7.197870e-02   18.7268970  -0.46324902   -16.1849665    1.23612627
    [13,]  6.153061e-02   -0.4632490   0.12685032     1.2327783   -0.20692983
    [14,] -1.157699e+01  -16.1849665   1.23277827  3180.7362850  -40.24439774
    [15,]  1.704625e+00    1.2361263  -0.20692983   -40.2443977    9.65359055
    [16,] -1.608423e-01   -0.4136609   0.07688678    13.4226923    0.70015741
                  [,16]
     [1,]  1.146053e+01
     [2,] -2.405406e+02
     [3,]  6.706526e+02
     [4,]  3.265542e-01
     [5,] -4.680544e-03
     [6,] -2.586931e+00
     [7,] -1.781386e-01
     [8,]  1.308570e-01
     [9,]  5.498165e-02
    [10,] -7.648387e+00
    [11,] -1.608423e-01
    [12,] -4.136609e-01
    [13,]  7.688678e-02
    [14,]  1.342269e+01
    [15,]  7.001574e-01
    [16,]  2.609256e+00

    $aic
    [1] -443.6969

    $asy.se.coef
    $asy.se.coef[[1]]
                [,1]         [,2]
    [1,] 0.005951115 0.0006300630
    [2,] 0.000000000 0.0003293308

    $asy.se.coef[[2]]
              [,1]       [,2]
    [1,] 0.3150396 0.01581263
    [2,] 2.3065406 0.24110204

    $asy.se.coef[[3]]
              [,1]        [,2]
    [1,] 0.1049158 0.007811719
    [2,] 0.4800751 0.010559776

    $asy.se.coef[[4]]
              [,1]       [,2]
    [1,] 0.2626887 0.01915952
    [2,] 3.1255330 0.36661918

    $asy.se.coef[[5]]
    [1] 0.6559587

    $est.params
    $est.params$`1`
                [,1]          [,2]
    [1,] -0.03902944 -2.045331e-05
    [2,]  0.00000000 -4.296356e-03

    $est.params$`2`
              [,1]         [,2]
    [1,] 0.2268312 0.0001350601
    [2,] 2.1110340 0.1252329455

    $est.params$`3`
                [,1]          [,2]
    [1,] -0.31434246 -0.0055870676
    [2,] -0.01538355 -0.0001628474

    $est.params$`4`
              [,1]         [,2]
    [1,] 0.4224089 -0.007414033
    [2,] 0.1025256 -0.486932758

    $est.params$`5`
    [1] -1.102507

    $cor
     [1]           NA  0.031402656  0.058089044 -0.283965989  0.160141195
     [6]  0.053237600  0.024081209  0.199587984  0.050169828  0.024045688
    [11]  0.022017308  0.015292008 -0.015322752  0.070343728  0.060106129
    [16]  0.104828553  0.165459125  0.030923632  0.022277698  0.026315363
    [21]  0.020411283  0.102018250  0.102516847  0.035770620  0.024838651
    [26]  0.274964544  0.063922572  0.067181338  0.051522997  0.051263760
    [31]  0.023492076  0.022088161  0.021845645  0.021179838  0.028180317
    [36]  0.028967267  0.023372747  0.022865880  0.020896186  0.180173786
    [41]  0.034766653  0.022790880  0.021499773 -0.005938808 -0.137011386
    [46]  0.029587448  0.062026969  0.053761176  0.036707465  0.054668898
    [51]  0.009740057  0.040966003  0.012100219  0.024982728  0.021599599
    [56]  0.021286712  0.020662963 -0.000403477 -0.118423344  0.080086394
    [61]  0.017643159  0.287047099  0.043052577  0.095924672  0.129103089
    [66]  0.052969944  0.066284046  0.055521350 -0.095508217  0.040009553
    [71]  0.022822525  0.020620174  0.080723033  0.044702009  0.051760071
    [76]  0.015962034  0.031439947  0.021103665  0.057557712  0.184430145
    [81]  0.061929502  0.074235107

    $sd1
     [1]         NA 0.04250885 0.05256355 0.08452372 0.05574627 0.04322082
     [7] 0.04134005 0.07735273 0.04624463 0.04210977 0.04121545 0.04524121
    [13] 0.04400240 0.04235476 0.04419338 0.04269033 0.04362228 0.04244062
    [19] 0.04124873 0.04171567 0.04157849 0.04691775 0.04729332 0.04297800
    [25] 0.04133609 0.05057450 0.04475342 0.04245633 0.04322428 0.04275222
    [31] 0.04173813 0.04159489 0.04119978 0.04290491 0.04182107 0.04199520
    [37] 0.04156416 0.04141240 0.04126752 0.05496396 0.04274670 0.04132509
    [43] 0.04113889 0.04241273 0.05098749 0.04227554 0.05554117 0.05507267
    [49] 0.04276771 0.04274602 0.04200447 0.04140829 0.04167090 0.04296412
    [55] 0.04157519 0.04119998 0.04124952 0.04231602 0.04991076 0.04371888
    [61] 0.04217155 0.05092909 0.04333244 0.04758239 0.06275051 0.04389357
    [67] 0.05246204 0.04515198 0.06193409 0.04361523 0.04139218 0.04118088
    [73] 0.04553376 0.04376651 0.04708736 0.04252185 0.04248968 0.04285559
    [79] 0.04458945 0.04858689 0.04500212 0.05183762

    $sd2
     [1]          NA 0.004482407 0.004338972 0.004809936 0.004467527 0.004585295
     [7] 0.004308208 0.004536616 0.004338359 0.004304288 0.004302985 0.004303282
    [13] 0.004368628 0.004897167 0.004391425 0.005115556 0.005729580 0.004312162
    [19] 0.004303200 0.004308760 0.004302868 0.004976847 0.005020608 0.004316566
    [25] 0.004309195 0.004939797 0.004398925 0.004894407 0.004397014 0.004840029
    [31] 0.004303750 0.004303055 0.004302843 0.004303352 0.004311628 0.004312208
    [37] 0.004303962 0.004303769 0.004340892 0.005536457 0.004364419 0.004303177
    [43] 0.004302664 0.004381032 0.004754002 0.004305919 0.004331610 0.004329750
    [49] 0.004315664 0.004919065 0.004322781 0.004392385 0.004419426 0.004305283
    [55] 0.004303278 0.004302883 0.004302743 0.004548148 0.005589150 0.004407496
    [61] 0.004305608 0.004895706 0.004332758 0.004476358 0.004463722 0.004425254
    [67] 0.004349885 0.004344478 0.004371742 0.004310808 0.004304083 0.004304599
    [73] 0.004475105 0.004333152 0.004333715 0.004314340 0.004313605 0.004303264
    [79] 0.004365063 0.004618021 0.004372850 0.004343962

    $H.estimated
    , , 1

                 [,1]         [,2]
    [1,] 2.398788e-03 6.043323e-06
    [2,] 6.043323e-06 1.742282e-05

    , , 2

                 [,1]         [,2]
    [1,] 1.807002e-03 5.983524e-06
    [2,] 5.983524e-06 2.009197e-05

    , , 3

                 [,1]         [,2]
    [1,] 2.762927e-03 1.324847e-05
    [2,] 1.324847e-05 1.882667e-05

    , , 4

                  [,1]          [,2]
    [1,]  0.0071442584 -1.154474e-04
    [2,] -0.0001154474  2.313548e-05

    , , 5

                 [,1]         [,2]
    [1,] 3.107646e-03 3.988284e-05
    [2,] 3.988284e-05 1.995880e-05

    , , 6

                 [,1]         [,2]
    [1,] 1.868039e-03 1.055064e-05
    [2,] 1.055064e-05 2.102493e-05

    , , 7

                 [,1]         [,2]
    [1,] 1.709000e-03 4.288901e-06
    [2,] 4.288901e-06 1.856066e-05

    , , 8

                 [,1]         [,2]
    [1,] 5.983444e-03 7.003934e-05
    [2,] 7.003934e-05 2.058089e-05

    , , 9

                 [,1]         [,2]
    [1,] 2.138566e-03 1.006536e-05
    [2,] 1.006536e-05 1.882135e-05

    , , 10

                 [,1]         [,2]
    [1,] 1.773233e-03 4.358343e-06
    [2,] 4.358343e-06 1.852689e-05

    , , 11

                 [,1]         [,2]
    [1,] 1.698713e-03 3.904758e-06
    [2,] 3.904758e-06 1.851568e-05

    , , 12

                 [,1]         [,2]
    [1,] 2.046767e-03 2.977135e-06
    [2,] 2.977135e-06 1.851824e-05

    , , 13

                  [,1]          [,2]
    [1,]  1.936211e-03 -2.945494e-06
    [2,] -2.945494e-06  1.908491e-05

    , , 14

                 [,1]         [,2]
    [1,] 1.793925e-03 1.459058e-05
    [2,] 1.459058e-05 2.398224e-05

    , , 15

                 [,1]         [,2]
    [1,] 1.953055e-03 1.166491e-05
    [2,] 1.166491e-05 1.928461e-05

    , , 16

                 [,1]         [,2]
    [1,] 1.822465e-03 2.289296e-05
    [2,] 2.289296e-05 2.616891e-05

    , , 17

                 [,1]         [,2]
    [1,] 1.902904e-03 4.135442e-05
    [2,] 4.135442e-05 3.282809e-05

    , , 18

                 [,1]         [,2]
    [1,] 1.801206e-03 5.659359e-06
    [2,] 5.659359e-06 1.859474e-05

    , , 19

                 [,1]         [,2]
    [1,] 1.701457e-03 3.954325e-06
    [2,] 3.954325e-06 1.851753e-05

    , , 20

                 [,1]         [,2]
    [1,] 1.740197e-03 4.729997e-06
    [2,] 4.729997e-06 1.856541e-05

    , , 21

                 [,1]         [,2]
    [1,] 1.728771e-03 3.651716e-06
    [2,] 3.651716e-06 1.851467e-05

    , , 22

                 [,1]         [,2]
    [1,] 2.201275e-03 2.382151e-05
    [2,] 2.382151e-05 2.476901e-05

    , , 23

                 [,1]         [,2]
    [1,] 2.236658e-03 2.434172e-05
    [2,] 2.434172e-05 2.520650e-05

    , , 24

                 [,1]         [,2]
    [1,] 1.847108e-03 6.636071e-06
    [2,] 6.636071e-06 1.863274e-05

    , , 25

                 [,1]         [,2]
    [1,] 1.708672e-03 4.424391e-06
    [2,] 4.424391e-06 1.856916e-05

    , , 26

                 [,1]         [,2]
    [1,] 2.557780e-03 6.869377e-05
    [2,] 6.869377e-05 2.440159e-05

    , , 27

                 [,1]         [,2]
    [1,] 2.002868e-03 1.258424e-05
    [2,] 1.258424e-05 1.935054e-05

    , , 28

                 [,1]         [,2]
    [1,] 1.802540e-03 1.396019e-05
    [2,] 1.396019e-05 2.395522e-05

    , , 29

                 [,1]         [,2]
    [1,] 1.868338e-03 9.792344e-06
    [2,] 9.792344e-06 1.933373e-05

    , , 30

                 [,1]         [,2]
    [1,] 0.0018277521 1.060760e-05
    [2,] 0.0000106076 2.342588e-05

    , , 31

                 [,1]         [,2]
    [1,] 1.742072e-03 4.219893e-06
    [2,] 4.219893e-06 1.852227e-05

    , , 32

                 [,1]         [,2]
    [1,] 1.730135e-03 3.953452e-06
    [2,] 3.953452e-06 1.851628e-05

    , , 33

                 [,1]         [,2]
    [1,] 1.697422e-03 3.872712e-06
    [2,] 3.872712e-06 1.851446e-05

    , , 34

                 [,1]         [,2]
    [1,] 1.840831e-03 3.910538e-06
    [2,] 3.910538e-06 1.851884e-05

    , , 35

                 [,1]         [,2]
    [1,] 1.749002e-03 5.081388e-06
    [2,] 5.081388e-06 1.859014e-05

    , , 36

                 [,1]         [,2]
    [1,] 1.763597e-03 5.245741e-06
    [2,] 5.245741e-06 1.859513e-05

    , , 37

                 [,1]         [,2]
    [1,] 1.727580e-03 4.181164e-06
    [2,] 4.181164e-06 1.852409e-05

    , , 38

                 [,1]         [,2]
    [1,] 1.714987e-03 4.075372e-06
    [2,] 4.075372e-06 1.852243e-05

    , , 39

                 [,1]         [,2]
    [1,] 1.703008e-03 3.743298e-06
    [2,] 3.743298e-06 1.884335e-05

    , , 40

                 [,1]         [,2]
    [1,] 3.021037e-03 5.482789e-05
    [2,] 5.482789e-05 3.065235e-05

    , , 41

                 [,1]         [,2]
    [1,] 1.827281e-03 6.486224e-06
    [2,] 6.486224e-06 1.904815e-05

    , , 42

                 [,1]         [,2]
    [1,] 1.707763e-03 4.052884e-06
    [2,] 4.052884e-06 1.851733e-05

    , , 43

                 [,1]         [,2]
    [1,] 1.692408e-03 3.805606e-06
    [2,] 3.805606e-06 1.851292e-05

    , , 44

                  [,1]          [,2]
    [1,]  1.798840e-03 -1.103499e-06
    [2,] -1.103499e-06  1.919344e-05

    , , 45

                  [,1]          [,2]
    [1,]  2.599725e-03 -3.321083e-05
    [2,] -3.321083e-05  2.260054e-05

    , , 46

                 [,1]         [,2]
    [1,] 1.787221e-03 5.385952e-06
    [2,] 5.385952e-06 1.854093e-05

    , , 47

                 [,1]         [,2]
    [1,] 3.084822e-03 1.492262e-05
    [2,] 1.492262e-05 1.876285e-05

    , , 48

                 [,1]         [,2]
    [1,] 0.0030329985 1.281940e-05
    [2,] 0.0000128194 1.874673e-05

    , , 49

                 [,1]         [,2]
    [1,] 1.829077e-03 6.775136e-06
    [2,] 6.775136e-06 1.862496e-05

    , , 50

                 [,1]         [,2]
    [1,] 1.827222e-03 1.149525e-05
    [2,] 1.149525e-05 2.419720e-05

    , , 51

                 [,1]         [,2]
    [1,] 1.764375e-03 1.768562e-06
    [2,] 1.768562e-06 1.868643e-05

    , , 52

                 [,1]         [,2]
    [1,] 1.714646e-03 7.450944e-06
    [2,] 7.450944e-06 1.929305e-05

    , , 53

                 [,1]         [,2]
    [1,] 1.736464e-03 2.228394e-06
    [2,] 2.228394e-06 1.953133e-05

    , , 54

                 [,1]         [,2]
    [1,] 1.845916e-03 4.621122e-06
    [2,] 4.621122e-06 1.853546e-05

    , , 55

                 [,1]         [,2]
    [1,] 1.728496e-03 3.864375e-06
    [2,] 3.864375e-06 1.851820e-05

    , , 56

                 [,1]         [,2]
    [1,] 1.697438e-03 3.773681e-06
    [2,] 3.773681e-06 1.851481e-05

    , , 57

                 [,1]         [,2]
    [1,] 1.701523e-03 3.667388e-06
    [2,] 3.667388e-06 1.851360e-05

    , , 58

                  [,1]          [,2]
    [1,]  1.790646e-03 -7.765298e-08
    [2,] -7.765298e-08  2.068565e-05

    , , 59

                  [,1]          [,2]
    [1,]  2.491084e-03 -3.303522e-05
    [2,] -3.303522e-05  3.123859e-05

    , , 60

                 [,1]         [,2]
    [1,] 1.911341e-03 1.543191e-05
    [2,] 1.543191e-05 1.942602e-05

    , , 61

                 [,1]         [,2]
    [1,] 1.778439e-03 3.203542e-06
    [2,] 3.203542e-06 1.853826e-05

    , , 62

                 [,1]         [,2]
    [1,] 2.593772e-03 7.157055e-05
    [2,] 7.157055e-05 2.396793e-05

    , , 63

                 [,1]         [,2]
    [1,] 1.877700e-03 8.083078e-06
    [2,] 8.083078e-06 1.877280e-05

    , , 64

                 [,1]         [,2]
    [1,] 2.264084e-03 2.043155e-05
    [2,] 2.043155e-05 2.003778e-05

    , , 65

                 [,1]         [,2]
    [1,] 3.937627e-03 3.616188e-05
    [2,] 3.616188e-05 1.992481e-05

    , , 66

                 [,1]         [,2]
    [1,] 1.926645e-03 1.028889e-05
    [2,] 1.028889e-05 1.958287e-05

    , , 67

                 [,1]         [,2]
    [1,] 2.752265e-03 1.512627e-05
    [2,] 1.512627e-05 1.892150e-05

    , , 68

                 [,1]         [,2]
    [1,] 2.038701e-03 1.089117e-05
    [2,] 1.089117e-05 1.887449e-05

    , , 69

                  [,1]          [,2]
    [1,]  3.835832e-03 -2.585979e-05
    [2,] -2.585979e-05  1.911213e-05

    , , 70

                 [,1]         [,2]
    [1,] 1.902289e-03 7.522472e-06
    [2,] 7.522472e-06 1.858307e-05

    , , 71

                 [,1]         [,2]
    [1,] 1.713313e-03 4.065956e-06
    [2,] 4.065956e-06 1.852513e-05

    , , 72

                 [,1]         [,2]
    [1,] 1.695865e-03 3.655281e-06
    [2,] 3.655281e-06 1.852958e-05

    , , 73

                 [,1]         [,2]
    [1,] 0.0020733237 1.644880e-05
    [2,] 0.0000164488 2.002657e-05

    , , 74

                 [,1]         [,2]
    [1,] 0.0019155075 8.477600e-06
    [2,] 0.0000084776 1.877621e-05

    , , 75

                 [,1]         [,2]
    [1,] 2.217220e-03 1.056233e-05
    [2,] 1.056233e-05 1.878109e-05

    , , 76

                 [,1]         [,2]
    [1,] 1.808108e-03 2.928295e-06
    [2,] 2.928295e-06 1.861353e-05

    , , 77

                 [,1]         [,2]
    [1,] 1.805373e-03 5.762429e-06
    [2,] 5.762429e-06 1.860719e-05

    , , 78

                 [,1]         [,2]
    [1,] 1.836602e-03 3.891915e-06
    [2,] 3.891915e-06 1.851808e-05

    , , 79

                 [,1]         [,2]
    [1,] 1.988219e-03 1.120279e-05
    [2,] 1.120279e-05 1.905377e-05

    , , 80

                 [,1]         [,2]
    [1,] 2.360685e-03 4.138156e-05
    [2,] 4.138156e-05 2.132612e-05

    , , 81

                 [,1]         [,2]
    [1,] 2.025191e-03 1.218695e-05
    [2,] 1.218695e-05 1.912182e-05

    , , 82

                 [,1]         [,2]
    [1,] 2.687139e-03 1.671631e-05
    [2,] 1.671631e-05 1.887001e-05

    $eigenvalues
    [1] 4.55569683 0.22879456 0.17683774 0.01426322

    $uncond.cov.matrix
                [,1]        [,2]
    [1,] 0.002266730 0.001058754
    [2,] 0.001058754 0.014184073

    $resid1
     [1]  0.000000000  2.606658633 -2.832423405 -0.803429943 -0.076228015
     [6]  0.251640690 -3.578761931  0.627605808  0.618572249  0.093834350
    [11]  1.992057160 -0.613463505 -0.151066326  0.568366658 -0.281145635
    [16] -0.447418119  0.584725959  0.106051164  0.423859148  0.650891694
    [21]  0.275002848  0.206027474  0.547710301  0.219653206 -1.720836929
    [26]  0.388360723 -0.136578900  0.330299607 -0.015356362  0.530624264
    [31]  0.552493411  0.135394145  1.211759017  0.325365217  0.474140365
    [36]  0.434967460  0.348083690 -0.051966703  0.590366618  0.941768811
    [41] -0.102859959  0.029817748 -0.438515201 -1.283947967  0.205149728
    [46] -1.959551678  2.299605523  0.164294634 -0.034506773  1.415352264
    [51] -0.217156708 -0.172233261  1.094882761  0.537781247  0.255092253
    [56]  0.401673126 -0.274777615 -0.901794851  0.192673354  1.016721711
    [61]  0.838610788  0.331314439  0.884670384  2.873061672 -0.079539903
    [66]  2.384117962  0.685180049 -2.137240072 -0.009247067 -0.060258875
    [71]  0.391339172  0.609775354  0.692992830  1.573446856  1.149792694
    [76]  0.640567944 -0.596838960  0.783185773 -1.358186376  0.611629203
    [81] -1.552405453 -1.721844943

    $resid2
     [1]  0.00000000  0.60291683 -0.34446882  0.47408464  0.74401685 -0.36208567
     [7]  1.22988753 -0.83357295 -0.08954723 -0.06362390 -0.10131479 -0.25004018
    [13]  1.09566787  0.94523475  1.31164457  1.57234641  0.19804905 -0.08528340
    [19]  0.30541107 -0.08591785  2.16540690  1.86518502  0.32642704 -0.42228251
    [25]  1.40120757  0.90215659  1.09997892  0.90303309  1.19070375  0.05489337
    [31]  0.03646646  0.04553108  0.02427045  0.35872374  0.37528677  0.11605970
    [37]  0.12034527 -0.28015423  3.32249290 -1.13529670  0.03315067  0.02970541
    [43] -0.31984221 -0.76117735  0.05094163  0.55098391  0.36347692 -0.49720367
    [49]  1.25203911 -0.71138871  0.43875324 -0.44653544  0.15015921 -0.08924866
    [55] -0.08205853 -0.08336948 -0.66487750 -1.48534156 -1.19469384 -0.33165737
    [61] -4.17835758  0.48521539  1.54523260  1.28097851  0.47447031  0.68879762
    [67]  0.72978029  0.07920992 -0.02991489 -0.02720370 -0.23827852  1.48272617
    [73]  0.60612812  0.61341050 -0.57651419  0.40119127  0.11384865  0.96428797
    [79]  1.03790954  0.85330306  0.58221097 -0.04007542

    attr(,"class")
    [1] "mGJR"
```

I am trying to replicate the following situation:

Then I am trying to get the output as below:

答:
The mGJR command is used to estimate a GARCH (Generalized autoregressive conditional heteroscedasticity) model. GARCH models are used to model volatility of time-series (most commonly asset returns). That (and lots of parameters) is what you can access from the fitted GJR object.

If you want to know more about GARCH models paired with examples in R, I can recommend the following books by R. Tsay:

Analysis of Financial Time Series and

Multivariate Time Series Analysis: With R and Financial Applications

do I need to input the returns not the unexpected returns into the model to derive the unexpected returns automatically?

Usually the input for GARCH models are in the past observed returns. (see e.g. the above quoted books or this article by R. Engle, the person who initially proposed the ARCH model)

There are some tests to determine if there are any linear dependencies in the time series. If there are, they need to be removed with a mean-model (such as VARIMA models). Examples and different cases are also in Tsays Analysis of Financial Time Series. The full process for volatility model building is nicely explained on page 133.

Short: Your eps1 and eps2 need to be these (mean-model corrected) return series.

Besides, how does my bivariate GJR GARCH model looks like if I try to
  describe it using the coefficients derived from my output below? How can I get the coefficients for the model that I need for my analysis from the long output I have below?

It takes a bit of digging but when looking at a publication from Schmidbauer & Roesch (2008) and the code of the mgarchBEKK it looks like the mGJR specification is what the authors Schmidbauer & Roesch call a bivariate asymmetric quadratic GARCH (baqGARCH), which on page 5 of linked publication is defined as:

The parameters from the fitted GJR object represent in descending order: C, A, B, Gamma, w. as on page 7 of the publication (the values in smaller font in the parenthesis are t-values):

Here a reproducible example for fitting mGJR and accessing the parameters:

```<code># packages
library(mgarchBEKK)

# generate heteroscedastic data

dat <- simulateBEKK(series.count = 2, T = 200, c(1,1))

returns1 <- dat$eps[[1]]
returns2 <- dat$eps[[2]]

# fit GJR to data

my_mGJR <- mGJR(eps1 = returns1, eps2 = returns2, order = c(1, 1, 1))

# extract parameters from GJR object
my_param <- my_mGJR$est.params

# assign names
names(my_param) = c('C', 'A', 'B', 'Gamma', 'w')

# access parameters
my_param
</code>```

Take e.g. the coefficient-matrix B, [1,] and [2,] tell you which row, [,1] and [,2] which column of the matrix you are looking at. Here an oversimplified explanation: Since you have a bivariate model the diagonal elements [1,][,1] and [2,][,2] are the coefficients that tell you something about the respective series on its own variance. The off-diagonal elements are more about the conditional covariance or volatility spillover of the two series.

Short: You have the equation from (2) -> You input the coefficients as shown above -> You can solve for H_T (conditional covariance matrix at time T) for the time dependant variables (returnseries_T-1, H_T-1).

Specifically, I find that I have a total of 17 coefficients where one
  of them is zero.

If a coefficient is fixed to zero it doesn't count as a parameter. The off-diagonal lower coefficient C is always fixed to zero. Thus you have a total of 16 parameters (if you don't restrict the model, such as the authors have done in their paper).

However, when I run mGJR(), it gives out the output saying "$resid1"
  and "$resid2" which look like the residuals

That is correct, they are the residuals that are not explained by the coefficients, but for the conditional volatility (not sure what you are on about "unexpected returns"). They are so to speak what cannot be explained by the model, random white noise (see e.g. here or wikipedia). Residuals in GARCH models are mostly used to perform some model adequacy tests to answer the question: "Does my fitted model adequately explain the conditional variance equation?"

Here a plot of the conditional volatility, conditional correlation and the residuals. There seem to be some volatility clustering in the conditional standarddeviation of the series (first two plots). There doesn't seem to be quite as much structure in the residual series (last two plots).

And the code for the plot:

```<code>library(ggplot2)
library(reshape2)

my_results <- data.frame(index       = 1:200,
                         sd_returns1 = my_mGJR$sd1,
                         sd_returns2 = my_mGJR$sd2,
                         cor_returns = my_mGJR$cor,
                         res_returns1 = my_mGJR$resid1,
                         res_returns2 = my_mGJR$resid2)

# melt data to long format for plotting

p_results = melt(my_results, id = 'index')

# plot the results

my_p = ggplot(p_results, aes(x = index, y = value)) +
  geom_line() +
  facet_grid(variable ~ ., scales = "free_y") +
  theme_bw()

ggsave('example_cor_sd_res.png', plot = my_p, device = 'png', units = 'cm',
       width = 12, height = 15)
</code>```

I am trying to replicate the following situation:

Basically you have everything you need. Significance of the parameters (either p-values or t-values) can be calculated from the standard errors of the parameters. For the t-values e.g. you need to divide the parameters by the standard errors. The standard errors can be taken from the GJR object like:

```<code>my_param_se = my_mGJR$asy.se.coef

names(my_param_se) = paste0(rep("tvals_", 5), c('C', 'A', 'B', 'Gamma', 'w'))

my_param_se
</code>```

Since the mGJR commands model (or baqGARCH) is similarly constructed as e.g. the BEKK-GARCH you probably won't be able to interpret it the same way as in your example. As I've elaborated above the diagonal elements of the different coefficients will tell you about significant conditional volatility of series 1 from innovations in series 1. The off-diagonal elements will tell you something about volatility-spillover from one series to the other. If you want to account for that you will need to include these results in your table.

Then I am trying to get the output as below:

Most of this I explained above, just one note to the residuals. It looks like the model adequacy was gauged by the LjungBox-Test (=LB?). See e.g. here.

I hope this answers your questions.

Edit: updated answer to include the additional questions.

Body:
I am using a bivariate GJR model using mGJR() command from R.

The instruction from the package "mgarchBEKK" says I input first time series, second time series, and so on. I am trying to use the unexpected returns as my input and need coefficients from these.

I thought I needed to input my pre-calculated unexpected returns as my first time series, second time series and so on into my model.

However, when I run mGJR(), it gives out the output saying "$resid1" and "$resid2" which look like the residuals (i.e. unexpected returns) which I've been looking for.

If so, do I need to input the returns not the unexpected returns into the model to derive the unexpected returns automatically?

Besides, how does my bivariate GJR GARCH model looks like if I try to describe it using the coefficients derived from my output below?
How can I get the coefficients for the model that I need for my analysis from the long output I have below?
Specifically, I find that I have a total of 17 coefficients where one of them is zero. I find that these coefficients are grouped by 4 where the last one is only one left.

For instance, I find $est.params$1, $est.params$2, $est.params$3, $est.params$4, $est.params$5 where there is a total of 17 parameters.
However, I am not sure how mathematically these are expressed explicitly within the formal bivariate GJR GARCH formula.

Please note that this is "bivariate" GJR GARCH not just GJR GARCH. Thus, I have 17 parameters where I have 4 blocks each with 4 coefficients plus one parameter making it a total of 17. However, I don't know which parameter corresponds to which variable coefficient. I tried to provide as much information as possible but if any clarification needed please let me know.

The output I get using the expected return is the following:

mGJR(eps1, eps2, order = c(1, 1, 1))

    Warning: initial values for the parameters are set at:
             2 0 2 0.4 0.1 0.1 0.4 0.4 0.1 0.1 0.4 0.1 0.1 0.1 0.1 0.5
    Starting estimation process via loglikelihood function implemented in C.
    Optimization Method is ' BFGS '
    H IS SINGULAR!...
    H IS SINGULAR!...
    H IS SINGULAR!...
    H IS SINGULAR!...
    H IS SINGULAR!...
    H IS SINGULAR!...
    H IS SINGULAR!...
    H IS SINGULAR!...
    H IS SINGULAR!...
    H IS SINGULAR!...
    H IS SINGULAR!...
    H IS SINGULAR!...
    H IS SINGULAR!...
    H IS SINGULAR!...
    H IS SINGULAR!...
    H IS SINGULAR!...
    H IS SINGULAR!...
    H IS SINGULAR!...
    H IS SINGULAR!...
    H IS SINGULAR!...
    H IS SINGULAR!...
    H IS SINGULAR!...
    H IS SINGULAR!...
    H IS SINGULAR!...
    H IS SINGULAR!...
    H IS SINGULAR!...
    H IS SINGULAR!...
    H IS SINGULAR!...
    H IS SINGULAR!...
    H IS SINGULAR!...
    H IS SINGULAR!...
    H IS SINGULAR!...
    H IS SINGULAR!...
    H IS SINGULAR!...
    H IS SINGULAR!...
    H IS SINGULAR!...
    H IS SINGULAR!...
    H IS SINGULAR!...
    H IS SINGULAR!...
    H IS SINGULAR!...
    H IS SINGULAR!...
    H IS SINGULAR!...
    H IS SINGULAR!...
    H IS SINGULAR!...
    H IS SINGULAR!...
    H IS SINGULAR!...
    H IS SINGULAR!...
    H IS SINGULAR!...
    H IS SINGULAR!...
    H IS SINGULAR!...
    H IS SINGULAR!...
    H IS SINGULAR!...
    H IS SINGULAR!...
    H IS SINGULAR!...
    H IS SINGULAR!...
    H IS SINGULAR!...
    H IS SINGULAR!...
    H IS SINGULAR!...
    H IS SINGULAR!...
    H IS SINGULAR!...
    H IS SINGULAR!...
    H IS SINGULAR!...
    H IS SINGULAR!...
    H IS SINGULAR!...
    H IS SINGULAR!...
    H IS SINGULAR!...
    H IS SINGULAR!...
    H IS SINGULAR!...
    H IS SINGULAR!...
    H IS SINGULAR!...
    H IS SINGULAR!...
    H IS SINGULAR!...
    H IS SINGULAR!...
    H IS SINGULAR!...
    H IS SINGULAR!...
    H IS SINGULAR!...
    H IS SINGULAR!...
    H IS SINGULAR!...
    H IS SINGULAR!...
    H IS SINGULAR!...
    H IS SINGULAR!...
    H IS SINGULAR!...
    H IS SINGULAR!...
    H IS SINGULAR!...
    H IS SINGULAR!...
    H IS SINGULAR!...
    H IS SINGULAR!...
    H IS SINGULAR!...
    H IS SINGULAR!...
    H IS SINGULAR!...
    Estimation process completed.
    Starting diagnostics...
    Calculating estimated:
     1. residuals,
     2. correlations,
     3. standard deviations,
     4. eigenvalues.
    Diagnostics ended...
    Class attributes are ready via following names:
    eps1 eps2 series.length estimation.time total.time order estimation aic asy.se.coef est.params cor sd1 sd2 H.estimated eigenvalues uncond.cov.matrix resid1 resid2
    $eps1
     [1] -0.002605971  0.110882333 -0.148960989 -0.068514869 -0.003755887
     [6]  0.010796054 -0.147830267  0.047830346  0.028587561  0.003945359
    [11]  0.082094667 -0.027768830 -0.006713995  0.024364330 -0.012109627
    [16] -0.018345875  0.025668553  0.004490535  0.017510124  0.027143473
    [21]  0.011606530  0.010522457  0.026053738  0.009380949 -0.070996648
    [26]  0.020755072 -0.005830603  0.014289265 -0.000418889  0.022697292
    [31]  0.023063329  0.005635615  0.049926161  0.013989454  0.019870327
    [36]  0.018279627  0.014478743 -0.002177036  0.024635614  0.050726032
    [41] -0.004392337  0.001234857 -0.018066777 -0.054437778  0.010428982
    [46] -0.082777078  0.127812102  0.008940764 -0.001295593  0.060328122
    [51] -0.009104799 -0.007204478  0.045631975  0.023096514  0.010598574
    [56]  0.016541977 -0.011387952 -0.038157908  0.010327360  0.044342365
    [61]  0.035077460  0.017492338  0.038596692  0.137205423 -0.004735584
    [66]  0.104792896  0.036139814 -0.096482047 -0.000561027 -0.002632458
    [71]  0.016177144  0.025230196  0.031753168  0.068971843  0.054021759
    [76]  0.027263191 -0.025345373  0.033643409 -0.060322431  0.030377924
    [81] -0.069716766 -0.089266804

    $eps2
     [1] -0.002889166  0.003033355 -0.002152031  0.003236581  0.003236581
     [6] -0.001602802  0.004961099 -0.003176289 -0.000264979 -0.000264979
    [11] -0.000264979 -0.001112752  0.004795299  0.004795299  0.005683859
    [16]  0.007793699  0.001613168 -0.000354773  0.001350773 -0.000303199
    [21]  0.009337753  0.009337753  0.001886769 -0.001791025  0.005869744
    [26]  0.004795546  0.004795546  0.004509183  0.005226653  0.000383686
    [31]  0.000207546  0.000207546  0.000207546  0.001570381  0.001669796
    [36]  0.000549576  0.000549576 -0.001210093  0.014468461 -0.005345880
    [41]  0.000130449  0.000130449 -0.001412638 -0.003304416  0.000117946
    [46]  0.002145056  0.002145056 -0.002114632  0.005395410 -0.003153774
    [51]  0.001888270 -0.001988031  0.000716514 -0.000331566 -0.000331566
    [56] -0.000325350 -0.002882419 -0.006754058 -0.006754058 -0.001131800
    [61] -0.017930260  0.002718202  0.006840023  0.006840023  0.002059632
    [66]  0.003552300  0.003350965 -0.000126651 -0.000126651 -0.000126651
    [71] -0.000990530  0.006430433  0.002933145  0.002933145 -0.002259438
    [76]  0.001770744  0.000417412  0.004213458  0.004213458  0.004360485
    [81]  0.002158630 -0.000686097

    $series.length
    [1] 82

    $estimation.time
    Time difference of 0.109386 secs

    $total.time
    Time difference of 0.1562669 secs

    $order
    GARCH component  ARCH component   HJR component
                  1               1               1

    $estimation
    $estimation$par
     [1] -3.902944e-02 -2.045331e-05 -4.296356e-03  2.268312e-01  2.111034e+00
     [6]  1.350601e-04  1.252329e-01 -3.143425e-01 -1.538355e-02 -5.587068e-03
    [11] -1.628474e-04  4.224089e-01  1.025256e-01 -7.414033e-03 -4.869328e-01
    [16] -1.102507e+00

    $estimation$value
    [1] -459.6969

    $estimation$counts
    function gradient
         278       53

    $estimation$convergence
    [1] 0

    $estimation$message
    NULL

    $estimation$hessian
                   [,1]          [,2]          [,3]          [,4]          [,5]
     [1,]  77991.191735  -27033.70607 -1.895287e+03 -655.73521140 -6.727215e+01
     [2,] -27033.706072 3337349.78552 -3.369295e+05 -371.07738150 -1.447052e+02
     [3,]  -1895.286899 -336929.51987  1.109169e+07 -122.26145691 -5.595868e+00
     [4,]   -655.735211    -371.07738 -1.222615e+02   18.61522485 -1.311354e-02
     [5,]    -67.272152    -144.70520 -5.595868e+00   -0.01311354  3.109780e-01
     [6,]     20.487872  -18111.17773  3.525887e+03   -5.52437237 -8.751496e-02
     [7,]    -26.898108   -2073.43486 -2.975629e+03   -0.26691407 -3.916406e-01
     [8,]   1477.726124     320.50607 -4.807709e+02   -9.98402142 -9.782072e-01
     [9,]      9.388141     -27.62368 -5.331019e+01   -0.16106385 -1.537450e-02
    [10,]   -179.429796   49000.01743  2.023153e+04    7.66772695  1.378254e+00
    [11,]     16.757240     -87.91362  2.360375e+03    0.23119576  7.084715e-02
    [12,]   -317.440585     -56.15303  3.710999e+01    6.57357184 -1.785094e-01
    [13,]      3.793978      98.71583 -1.142264e+01   -0.22870343  1.543862e-02
    [14,]   -146.123961   -9829.15416 -5.196531e+02  -29.62565159  4.260863e-01
    [15,]     18.082524     131.52060  3.398486e+03    0.33823287  3.212786e-02
    [16,]     11.460530    -240.54059  6.706526e+02    0.32655416 -4.680544e-03
                   [,6]          [,7]         [,8]          [,9]        [,10]
     [1,]  2.048787e+01   -26.8981081 1477.7261235    9.38814077  -179.429796
     [2,] -1.811118e+04 -2073.4348620  320.5060742  -27.62367781 49000.017430
     [3,]  3.525887e+03 -2975.6287124 -480.7709387  -53.31018730 20231.529905
     [4,] -5.524372e+00    -0.2669141   -9.9840214   -0.16106385     7.667727
     [5,] -8.751496e-02    -0.3916406   -0.9782072   -0.01537450     1.378254
     [6,]  4.340038e+03    72.0221887   23.7403796    4.74321851  -479.279271
     [7,]  7.202219e+01    22.5064989   -0.6280896    0.21674046   -44.382358
     [8,]  2.374038e+01    -0.6280896  123.3928335    2.05555317   -53.354577
     [9,]  4.743219e+00     0.2167405    2.0555532   20.53760214    53.165201
    [10,] -4.792793e+02   -44.3823578  -53.3545766   53.16520102 17583.612011
    [11,] -2.045612e+00     1.0454365   38.9154805 -823.29002882 -1763.407498
    [12,] -1.488681e+01    -0.5717977   -6.3888226   -0.05658090   -21.965231
    [13,] -4.554201e-01    -0.2556849    0.1795778    0.01041940     1.602574
    [14,]  2.372186e+02   -13.7297349   13.5989185   -1.51829772  -127.664692
    [15,] -1.372792e+01    -1.3537030    0.4896836    0.05291901    12.398407
    [16,] -2.586931e+00    -0.1781386    0.1308570    0.05498165    -7.648387
                  [,11]        [,12]        [,13]         [,14]         [,15]
     [1,]  1.675724e+01 -317.4405852   3.79397825  -146.1239612   18.08252377
     [2,] -8.791362e+01  -56.1530304  98.71583141 -9829.1541554  131.52059520
     [3,]  2.360375e+03   37.1099898 -11.42263544  -519.6531079 3398.48583556
     [4,]  2.311958e-01    6.5735718  -0.22870343   -29.6256516    0.33823287
     [5,]  7.084715e-02   -0.1785094   0.01543862     0.4260863    0.03212786
     [6,] -2.045612e+00  -14.8868094  -0.45542005   237.2185632  -13.72791768
     [7,]  1.045436e+00   -0.5717977  -0.25568491   -13.7297349   -1.35370300
     [8,]  3.891548e+01   -6.3888226   0.17957777    13.5989185    0.48968359
     [9,] -8.232900e+02   -0.0565809   0.01041940    -1.5182977    0.05291901
    [10,] -1.763407e+03  -21.9652313   1.60257372  -127.6646916   12.39840658
    [11,]  4.214986e+04   -0.0719787   0.06153061   -11.5769904    1.70462536
    [12,] -7.197870e-02   18.7268970  -0.46324902   -16.1849665    1.23612627
    [13,]  6.153061e-02   -0.4632490   0.12685032     1.2327783   -0.20692983
    [14,] -1.157699e+01  -16.1849665   1.23277827  3180.7362850  -40.24439774
    [15,]  1.704625e+00    1.2361263  -0.20692983   -40.2443977    9.65359055
    [16,] -1.608423e-01   -0.4136609   0.07688678    13.4226923    0.70015741
                  [,16]
     [1,]  1.146053e+01
     [2,] -2.405406e+02
     [3,]  6.706526e+02
     [4,]  3.265542e-01
     [5,] -4.680544e-03
     [6,] -2.586931e+00
     [7,] -1.781386e-01
     [8,]  1.308570e-01
     [9,]  5.498165e-02
    [10,] -7.648387e+00
    [11,] -1.608423e-01
    [12,] -4.136609e-01
    [13,]  7.688678e-02
    [14,]  1.342269e+01
    [15,]  7.001574e-01
    [16,]  2.609256e+00

    $aic
    [1] -443.6969

    $asy.se.coef
    $asy.se.coef[[1]]
                [,1]         [,2]
    [1,] 0.005951115 0.0006300630
    [2,] 0.000000000 0.0003293308

    $asy.se.coef[[2]]
              [,1]       [,2]
    [1,] 0.3150396 0.01581263
    [2,] 2.3065406 0.24110204

    $asy.se.coef[[3]]
              [,1]        [,2]
    [1,] 0.1049158 0.007811719
    [2,] 0.4800751 0.010559776

    $asy.se.coef[[4]]
              [,1]       [,2]
    [1,] 0.2626887 0.01915952
    [2,] 3.1255330 0.36661918

    $asy.se.coef[[5]]
    [1] 0.6559587

    $est.params
    $est.params$`1`
                [,1]          [,2]
    [1,] -0.03902944 -2.045331e-05
    [2,]  0.00000000 -4.296356e-03

    $est.params$`2`
              [,1]         [,2]
    [1,] 0.2268312 0.0001350601
    [2,] 2.1110340 0.1252329455

    $est.params$`3`
                [,1]          [,2]
    [1,] -0.31434246 -0.0055870676
    [2,] -0.01538355 -0.0001628474

    $est.params$`4`
              [,1]         [,2]
    [1,] 0.4224089 -0.007414033
    [2,] 0.1025256 -0.486932758

    $est.params$`5`
    [1] -1.102507

    $cor
     [1]           NA  0.031402656  0.058089044 -0.283965989  0.160141195
     [6]  0.053237600  0.024081209  0.199587984  0.050169828  0.024045688
    [11]  0.022017308  0.015292008 -0.015322752  0.070343728  0.060106129
    [16]  0.104828553  0.165459125  0.030923632  0.022277698  0.026315363
    [21]  0.020411283  0.102018250  0.102516847  0.035770620  0.024838651
    [26]  0.274964544  0.063922572  0.067181338  0.051522997  0.051263760
    [31]  0.023492076  0.022088161  0.021845645  0.021179838  0.028180317
    [36]  0.028967267  0.023372747  0.022865880  0.020896186  0.180173786
    [41]  0.034766653  0.022790880  0.021499773 -0.005938808 -0.137011386
    [46]  0.029587448  0.062026969  0.053761176  0.036707465  0.054668898
    [51]  0.009740057  0.040966003  0.012100219  0.024982728  0.021599599
    [56]  0.021286712  0.020662963 -0.000403477 -0.118423344  0.080086394
    [61]  0.017643159  0.287047099  0.043052577  0.095924672  0.129103089
    [66]  0.052969944  0.066284046  0.055521350 -0.095508217  0.040009553
    [71]  0.022822525  0.020620174  0.080723033  0.044702009  0.051760071
    [76]  0.015962034  0.031439947  0.021103665  0.057557712  0.184430145
    [81]  0.061929502  0.074235107

    $sd1
     [1]         NA 0.04250885 0.05256355 0.08452372 0.05574627 0.04322082
     [7] 0.04134005 0.07735273 0.04624463 0.04210977 0.04121545 0.04524121
    [13] 0.04400240 0.04235476 0.04419338 0.04269033 0.04362228 0.04244062
    [19] 0.04124873 0.04171567 0.04157849 0.04691775 0.04729332 0.04297800
    [25] 0.04133609 0.05057450 0.04475342 0.04245633 0.04322428 0.04275222
    [31] 0.04173813 0.04159489 0.04119978 0.04290491 0.04182107 0.04199520
    [37] 0.04156416 0.04141240 0.04126752 0.05496396 0.04274670 0.04132509
    [43] 0.04113889 0.04241273 0.05098749 0.04227554 0.05554117 0.05507267
    [49] 0.04276771 0.04274602 0.04200447 0.04140829 0.04167090 0.04296412
    [55] 0.04157519 0.04119998 0.04124952 0.04231602 0.04991076 0.04371888
    [61] 0.04217155 0.05092909 0.04333244 0.04758239 0.06275051 0.04389357
    [67] 0.05246204 0.04515198 0.06193409 0.04361523 0.04139218 0.04118088
    [73] 0.04553376 0.04376651 0.04708736 0.04252185 0.04248968 0.04285559
    [79] 0.04458945 0.04858689 0.04500212 0.05183762

    $sd2
     [1]          NA 0.004482407 0.004338972 0.004809936 0.004467527 0.004585295
     [7] 0.004308208 0.004536616 0.004338359 0.004304288 0.004302985 0.004303282
    [13] 0.004368628 0.004897167 0.004391425 0.005115556 0.005729580 0.004312162
    [19] 0.004303200 0.004308760 0.004302868 0.004976847 0.005020608 0.004316566
    [25] 0.004309195 0.004939797 0.004398925 0.004894407 0.004397014 0.004840029
    [31] 0.004303750 0.004303055 0.004302843 0.004303352 0.004311628 0.004312208
    [37] 0.004303962 0.004303769 0.004340892 0.005536457 0.004364419 0.004303177
    [43] 0.004302664 0.004381032 0.004754002 0.004305919 0.004331610 0.004329750
    [49] 0.004315664 0.004919065 0.004322781 0.004392385 0.004419426 0.004305283
    [55] 0.004303278 0.004302883 0.004302743 0.004548148 0.005589150 0.004407496
    [61] 0.004305608 0.004895706 0.004332758 0.004476358 0.004463722 0.004425254
    [67] 0.004349885 0.004344478 0.004371742 0.004310808 0.004304083 0.004304599
    [73] 0.004475105 0.004333152 0.004333715 0.004314340 0.004313605 0.004303264
    [79] 0.004365063 0.004618021 0.004372850 0.004343962

    $H.estimated
    , , 1

                 [,1]         [,2]
    [1,] 2.398788e-03 6.043323e-06
    [2,] 6.043323e-06 1.742282e-05

    , , 2

                 [,1]         [,2]
    [1,] 1.807002e-03 5.983524e-06
    [2,] 5.983524e-06 2.009197e-05

    , , 3

                 [,1]         [,2]
    [1,] 2.762927e-03 1.324847e-05
    [2,] 1.324847e-05 1.882667e-05

    , , 4

                  [,1]          [,2]
    [1,]  0.0071442584 -1.154474e-04
    [2,] -0.0001154474  2.313548e-05

    , , 5

                 [,1]         [,2]
    [1,] 3.107646e-03 3.988284e-05
    [2,] 3.988284e-05 1.995880e-05

    , , 6

                 [,1]         [,2]
    [1,] 1.868039e-03 1.055064e-05
    [2,] 1.055064e-05 2.102493e-05

    , , 7

                 [,1]         [,2]
    [1,] 1.709000e-03 4.288901e-06
    [2,] 4.288901e-06 1.856066e-05

    , , 8

                 [,1]         [,2]
    [1,] 5.983444e-03 7.003934e-05
    [2,] 7.003934e-05 2.058089e-05

    , , 9

                 [,1]         [,2]
    [1,] 2.138566e-03 1.006536e-05
    [2,] 1.006536e-05 1.882135e-05

    , , 10

                 [,1]         [,2]
    [1,] 1.773233e-03 4.358343e-06
    [2,] 4.358343e-06 1.852689e-05

    , , 11

                 [,1]         [,2]
    [1,] 1.698713e-03 3.904758e-06
    [2,] 3.904758e-06 1.851568e-05

    , , 12

                 [,1]         [,2]
    [1,] 2.046767e-03 2.977135e-06
    [2,] 2.977135e-06 1.851824e-05

    , , 13

                  [,1]          [,2]
    [1,]  1.936211e-03 -2.945494e-06
    [2,] -2.945494e-06  1.908491e-05

    , , 14

                 [,1]         [,2]
    [1,] 1.793925e-03 1.459058e-05
    [2,] 1.459058e-05 2.398224e-05

    , , 15

                 [,1]         [,2]
    [1,] 1.953055e-03 1.166491e-05
    [2,] 1.166491e-05 1.928461e-05

    , , 16

                 [,1]         [,2]
    [1,] 1.822465e-03 2.289296e-05
    [2,] 2.289296e-05 2.616891e-05

    , , 17

                 [,1]         [,2]
    [1,] 1.902904e-03 4.135442e-05
    [2,] 4.135442e-05 3.282809e-05

    , , 18

                 [,1]         [,2]
    [1,] 1.801206e-03 5.659359e-06
    [2,] 5.659359e-06 1.859474e-05

    , , 19

                 [,1]         [,2]
    [1,] 1.701457e-03 3.954325e-06
    [2,] 3.954325e-06 1.851753e-05

    , , 20

                 [,1]         [,2]
    [1,] 1.740197e-03 4.729997e-06
    [2,] 4.729997e-06 1.856541e-05

    , , 21

                 [,1]         [,2]
    [1,] 1.728771e-03 3.651716e-06
    [2,] 3.651716e-06 1.851467e-05

    , , 22

                 [,1]         [,2]
    [1,] 2.201275e-03 2.382151e-05
    [2,] 2.382151e-05 2.476901e-05

    , , 23

                 [,1]         [,2]
    [1,] 2.236658e-03 2.434172e-05
    [2,] 2.434172e-05 2.520650e-05

    , , 24

                 [,1]         [,2]
    [1,] 1.847108e-03 6.636071e-06
    [2,] 6.636071e-06 1.863274e-05

    , , 25

                 [,1]         [,2]
    [1,] 1.708672e-03 4.424391e-06
    [2,] 4.424391e-06 1.856916e-05

    , , 26

                 [,1]         [,2]
    [1,] 2.557780e-03 6.869377e-05
    [2,] 6.869377e-05 2.440159e-05

    , , 27

                 [,1]         [,2]
    [1,] 2.002868e-03 1.258424e-05
    [2,] 1.258424e-05 1.935054e-05

    , , 28

                 [,1]         [,2]
    [1,] 1.802540e-03 1.396019e-05
    [2,] 1.396019e-05 2.395522e-05

    , , 29

                 [,1]         [,2]
    [1,] 1.868338e-03 9.792344e-06
    [2,] 9.792344e-06 1.933373e-05

    , , 30

                 [,1]         [,2]
    [1,] 0.0018277521 1.060760e-05
    [2,] 0.0000106076 2.342588e-05

    , , 31

                 [,1]         [,2]
    [1,] 1.742072e-03 4.219893e-06
    [2,] 4.219893e-06 1.852227e-05

    , , 32

                 [,1]         [,2]
    [1,] 1.730135e-03 3.953452e-06
    [2,] 3.953452e-06 1.851628e-05

    , , 33

                 [,1]         [,2]
    [1,] 1.697422e-03 3.872712e-06
    [2,] 3.872712e-06 1.851446e-05

    , , 34

                 [,1]         [,2]
    [1,] 1.840831e-03 3.910538e-06
    [2,] 3.910538e-06 1.851884e-05

    , , 35

                 [,1]         [,2]
    [1,] 1.749002e-03 5.081388e-06
    [2,] 5.081388e-06 1.859014e-05

    , , 36

                 [,1]         [,2]
    [1,] 1.763597e-03 5.245741e-06
    [2,] 5.245741e-06 1.859513e-05

    , , 37

                 [,1]         [,2]
    [1,] 1.727580e-03 4.181164e-06
    [2,] 4.181164e-06 1.852409e-05

    , , 38

                 [,1]         [,2]
    [1,] 1.714987e-03 4.075372e-06
    [2,] 4.075372e-06 1.852243e-05

    , , 39

                 [,1]         [,2]
    [1,] 1.703008e-03 3.743298e-06
    [2,] 3.743298e-06 1.884335e-05

    , , 40

                 [,1]         [,2]
    [1,] 3.021037e-03 5.482789e-05
    [2,] 5.482789e-05 3.065235e-05

    , , 41

                 [,1]         [,2]
    [1,] 1.827281e-03 6.486224e-06
    [2,] 6.486224e-06 1.904815e-05

    , , 42

                 [,1]         [,2]
    [1,] 1.707763e-03 4.052884e-06
    [2,] 4.052884e-06 1.851733e-05

    , , 43

                 [,1]         [,2]
    [1,] 1.692408e-03 3.805606e-06
    [2,] 3.805606e-06 1.851292e-05

    , , 44

                  [,1]          [,2]
    [1,]  1.798840e-03 -1.103499e-06
    [2,] -1.103499e-06  1.919344e-05

    , , 45

                  [,1]          [,2]
    [1,]  2.599725e-03 -3.321083e-05
    [2,] -3.321083e-05  2.260054e-05

    , , 46

                 [,1]         [,2]
    [1,] 1.787221e-03 5.385952e-06
    [2,] 5.385952e-06 1.854093e-05

    , , 47

                 [,1]         [,2]
    [1,] 3.084822e-03 1.492262e-05
    [2,] 1.492262e-05 1.876285e-05

    , , 48

                 [,1]         [,2]
    [1,] 0.0030329985 1.281940e-05
    [2,] 0.0000128194 1.874673e-05

    , , 49

                 [,1]         [,2]
    [1,] 1.829077e-03 6.775136e-06
    [2,] 6.775136e-06 1.862496e-05

    , , 50

                 [,1]         [,2]
    [1,] 1.827222e-03 1.149525e-05
    [2,] 1.149525e-05 2.419720e-05

    , , 51

                 [,1]         [,2]
    [1,] 1.764375e-03 1.768562e-06
    [2,] 1.768562e-06 1.868643e-05

    , , 52

                 [,1]         [,2]
    [1,] 1.714646e-03 7.450944e-06
    [2,] 7.450944e-06 1.929305e-05

    , , 53

                 [,1]         [,2]
    [1,] 1.736464e-03 2.228394e-06
    [2,] 2.228394e-06 1.953133e-05

    , , 54

                 [,1]         [,2]
    [1,] 1.845916e-03 4.621122e-06
    [2,] 4.621122e-06 1.853546e-05

    , , 55

                 [,1]         [,2]
    [1,] 1.728496e-03 3.864375e-06
    [2,] 3.864375e-06 1.851820e-05

    , , 56

                 [,1]         [,2]
    [1,] 1.697438e-03 3.773681e-06
    [2,] 3.773681e-06 1.851481e-05

    , , 57

                 [,1]         [,2]
    [1,] 1.701523e-03 3.667388e-06
    [2,] 3.667388e-06 1.851360e-05

    , , 58

                  [,1]          [,2]
    [1,]  1.790646e-03 -7.765298e-08
    [2,] -7.765298e-08  2.068565e-05

    , , 59

                  [,1]          [,2]
    [1,]  2.491084e-03 -3.303522e-05
    [2,] -3.303522e-05  3.123859e-05

    , , 60

                 [,1]         [,2]
    [1,] 1.911341e-03 1.543191e-05
    [2,] 1.543191e-05 1.942602e-05

    , , 61

                 [,1]         [,2]
    [1,] 1.778439e-03 3.203542e-06
    [2,] 3.203542e-06 1.853826e-05

    , , 62

                 [,1]         [,2]
    [1,] 2.593772e-03 7.157055e-05
    [2,] 7.157055e-05 2.396793e-05

    , , 63

                 [,1]         [,2]
    [1,] 1.877700e-03 8.083078e-06
    [2,] 8.083078e-06 1.877280e-05

    , , 64

                 [,1]         [,2]
    [1,] 2.264084e-03 2.043155e-05
    [2,] 2.043155e-05 2.003778e-05

    , , 65

                 [,1]         [,2]
    [1,] 3.937627e-03 3.616188e-05
    [2,] 3.616188e-05 1.992481e-05

    , , 66

                 [,1]         [,2]
    [1,] 1.926645e-03 1.028889e-05
    [2,] 1.028889e-05 1.958287e-05

    , , 67

                 [,1]         [,2]
    [1,] 2.752265e-03 1.512627e-05
    [2,] 1.512627e-05 1.892150e-05

    , , 68

                 [,1]         [,2]
    [1,] 2.038701e-03 1.089117e-05
    [2,] 1.089117e-05 1.887449e-05

    , , 69

                  [,1]          [,2]
    [1,]  3.835832e-03 -2.585979e-05
    [2,] -2.585979e-05  1.911213e-05

    , , 70

                 [,1]         [,2]
    [1,] 1.902289e-03 7.522472e-06
    [2,] 7.522472e-06 1.858307e-05

    , , 71

                 [,1]         [,2]
    [1,] 1.713313e-03 4.065956e-06
    [2,] 4.065956e-06 1.852513e-05

    , , 72

                 [,1]         [,2]
    [1,] 1.695865e-03 3.655281e-06
    [2,] 3.655281e-06 1.852958e-05

    , , 73

                 [,1]         [,2]
    [1,] 0.0020733237 1.644880e-05
    [2,] 0.0000164488 2.002657e-05

    , , 74

                 [,1]         [,2]
    [1,] 0.0019155075 8.477600e-06
    [2,] 0.0000084776 1.877621e-05

    , , 75

                 [,1]         [,2]
    [1,] 2.217220e-03 1.056233e-05
    [2,] 1.056233e-05 1.878109e-05

    , , 76

                 [,1]         [,2]
    [1,] 1.808108e-03 2.928295e-06
    [2,] 2.928295e-06 1.861353e-05

    , , 77

                 [,1]         [,2]
    [1,] 1.805373e-03 5.762429e-06
    [2,] 5.762429e-06 1.860719e-05

    , , 78

                 [,1]         [,2]
    [1,] 1.836602e-03 3.891915e-06
    [2,] 3.891915e-06 1.851808e-05

    , , 79

                 [,1]         [,2]
    [1,] 1.988219e-03 1.120279e-05
    [2,] 1.120279e-05 1.905377e-05

    , , 80

                 [,1]         [,2]
    [1,] 2.360685e-03 4.138156e-05
    [2,] 4.138156e-05 2.132612e-05

    , , 81

                 [,1]         [,2]
    [1,] 2.025191e-03 1.218695e-05
    [2,] 1.218695e-05 1.912182e-05

    , , 82

                 [,1]         [,2]
    [1,] 2.687139e-03 1.671631e-05
    [2,] 1.671631e-05 1.887001e-05

    $eigenvalues
    [1] 4.55569683 0.22879456 0.17683774 0.01426322

    $uncond.cov.matrix
                [,1]        [,2]
    [1,] 0.002266730 0.001058754
    [2,] 0.001058754 0.014184073

    $resid1
     [1]  0.000000000  2.606658633 -2.832423405 -0.803429943 -0.076228015
     [6]  0.251640690 -3.578761931  0.627605808  0.618572249  0.093834350
    [11]  1.992057160 -0.613463505 -0.151066326  0.568366658 -0.281145635
    [16] -0.447418119  0.584725959  0.106051164  0.423859148  0.650891694
    [21]  0.275002848  0.206027474  0.547710301  0.219653206 -1.720836929
    [26]  0.388360723 -0.136578900  0.330299607 -0.015356362  0.530624264
    [31]  0.552493411  0.135394145  1.211759017  0.325365217  0.474140365
    [36]  0.434967460  0.348083690 -0.051966703  0.590366618  0.941768811
    [41] -0.102859959  0.029817748 -0.438515201 -1.283947967  0.205149728
    [46] -1.959551678  2.299605523  0.164294634 -0.034506773  1.415352264
    [51] -0.217156708 -0.172233261  1.094882761  0.537781247  0.255092253
    [56]  0.401673126 -0.274777615 -0.901794851  0.192673354  1.016721711
    [61]  0.838610788  0.331314439  0.884670384  2.873061672 -0.079539903
    [66]  2.384117962  0.685180049 -2.137240072 -0.009247067 -0.060258875
    [71]  0.391339172  0.609775354  0.692992830  1.573446856  1.149792694
    [76]  0.640567944 -0.596838960  0.783185773 -1.358186376  0.611629203
    [81] -1.552405453 -1.721844943

    $resid2
     [1]  0.00000000  0.60291683 -0.34446882  0.47408464  0.74401685 -0.36208567
     [7]  1.22988753 -0.83357295 -0.08954723 -0.06362390 -0.10131479 -0.25004018
    [13]  1.09566787  0.94523475  1.31164457  1.57234641  0.19804905 -0.08528340
    [19]  0.30541107 -0.08591785  2.16540690  1.86518502  0.32642704 -0.42228251
    [25]  1.40120757  0.90215659  1.09997892  0.90303309  1.19070375  0.05489337
    [31]  0.03646646  0.04553108  0.02427045  0.35872374  0.37528677  0.11605970
    [37]  0.12034527 -0.28015423  3.32249290 -1.13529670  0.03315067  0.02970541
    [43] -0.31984221 -0.76117735  0.05094163  0.55098391  0.36347692 -0.49720367
    [49]  1.25203911 -0.71138871  0.43875324 -0.44653544  0.15015921 -0.08924866
    [55] -0.08205853 -0.08336948 -0.66487750 -1.48534156 -1.19469384 -0.33165737
    [61] -4.17835758  0.48521539  1.54523260  1.28097851  0.47447031  0.68879762
    [67]  0.72978029  0.07920992 -0.02991489 -0.02720370 -0.23827852  1.48272617
    [73]  0.60612812  0.61341050 -0.57651419  0.40119127  0.11384865  0.96428797
    [79]  1.03790954  0.85330306  0.58221097 -0.04007542

    attr(,"class")
    [1] "mGJR"

I am trying to replicate the following situation:

Then I am trying to get the output as below:

Body:
The mGJR command is used to estimate a GARCH (Generalized autoregressive conditional heteroscedasticity) model. GARCH models are used to model volatility of time-series (most commonly asset returns). That (and lots of parameters) is what you can access from the fitted GJR object.

If you want to know more about GARCH models paired with examples in R, I can recommend the following books by R. Tsay:

Analysis of Financial Time Series and

Multivariate Time Series Analysis: With R and Financial Applications

do I need to input the returns not the unexpected returns into the model to derive the unexpected returns automatically?

Usually the input for GARCH models are in the past observed returns. (see e.g. the above quoted books or this article by R. Engle, the person who initially proposed the ARCH model)

There are some tests to determine if there are any linear dependencies in the time series. If there are, they need to be removed with a mean-model (such as VARIMA models). Examples and different cases are also in Tsays Analysis of Financial Time Series. The full process for volatility model building is nicely explained on page 133.

Short: Your eps1 and eps2 need to be these (mean-model corrected) return series.

Besides, how does my bivariate GJR GARCH model looks like if I try to
  describe it using the coefficients derived from my output below? How can I get the coefficients for the model that I need for my analysis from the long output I have below?

It takes a bit of digging but when looking at a publication from Schmidbauer & Roesch (2008) and the code of the mgarchBEKK it looks like the mGJR specification is what the authors Schmidbauer & Roesch call a bivariate asymmetric quadratic GARCH (baqGARCH), which on page 5 of linked publication is defined as:

The parameters from the fitted GJR object represent in descending order: C, A, B, Gamma, w. as on page 7 of the publication (the values in smaller font in the parenthesis are t-values):

Here a reproducible example for fitting mGJR and accessing the parameters:

# packages
library(mgarchBEKK)

# generate heteroscedastic data

dat <- simulateBEKK(series.count = 2, T = 200, c(1,1))

returns1 <- dat$eps[[1]]
returns2 <- dat$eps[[2]]

# fit GJR to data

my_mGJR <- mGJR(eps1 = returns1, eps2 = returns2, order = c(1, 1, 1))

# extract parameters from GJR object
my_param <- my_mGJR$est.params

# assign names
names(my_param) = c('C', 'A', 'B', 'Gamma', 'w')

# access parameters
my_param

Take e.g. the coefficient-matrix B, [1,] and [2,] tell you which row, [,1] and [,2] which column of the matrix you are looking at. Here an oversimplified explanation: Since you have a bivariate model the diagonal elements [1,][,1] and [2,][,2] are the coefficients that tell you something about the respective series on its own variance. The off-diagonal elements are more about the conditional covariance or volatility spillover of the two series.

Short: You have the equation from (2) -> You input the coefficients as shown above -> You can solve for H_T (conditional covariance matrix at time T) for the time dependant variables (returnseries_T-1, H_T-1).

Specifically, I find that I have a total of 17 coefficients where one
  of them is zero.

If a coefficient is fixed to zero it doesn't count as a parameter. The off-diagonal lower coefficient C is always fixed to zero. Thus you have a total of 16 parameters (if you don't restrict the model, such as the authors have done in their paper).

However, when I run mGJR(), it gives out the output saying "$resid1"
  and "$resid2" which look like the residuals

That is correct, they are the residuals that are not explained by the coefficients, but for the conditional volatility (not sure what you are on about "unexpected returns"). They are so to speak what cannot be explained by the model, random white noise (see e.g. here or wikipedia). Residuals in GARCH models are mostly used to perform some model adequacy tests to answer the question: "Does my fitted model adequately explain the conditional variance equation?"

Here a plot of the conditional volatility, conditional correlation and the residuals. There seem to be some volatility clustering in the conditional standarddeviation of the series (first two plots). There doesn't seem to be quite as much structure in the residual series (last two plots).

And the code for the plot:

library(ggplot2)
library(reshape2)

my_results <- data.frame(index       = 1:200,
                         sd_returns1 = my_mGJR$sd1,
                         sd_returns2 = my_mGJR$sd2,
                         cor_returns = my_mGJR$cor,
                         res_returns1 = my_mGJR$resid1,
                         res_returns2 = my_mGJR$resid2)

# melt data to long format for plotting

p_results = melt(my_results, id = 'index')

# plot the results

my_p = ggplot(p_results, aes(x = index, y = value)) +
  geom_line() +
  facet_grid(variable ~ ., scales = "free_y") +
  theme_bw()

ggsave('example_cor_sd_res.png', plot = my_p, device = 'png', units = 'cm',
       width = 12, height = 15)

I am trying to replicate the following situation:

Basically you have everything you need. Significance of the parameters (either p-values or t-values) can be calculated from the standard errors of the parameters. For the t-values e.g. you need to divide the parameters by the standard errors. The standard errors can be taken from the GJR object like:

my_param_se = my_mGJR$asy.se.coef

names(my_param_se) = paste0(rep("tvals_", 5), c('C', 'A', 'B', 'Gamma', 'w'))

my_param_se

Since the mGJR commands model (or baqGARCH) is similarly constructed as e.g. the BEKK-GARCH you probably won't be able to interpret it the same way as in your example. As I've elaborated above the diagonal elements of the different coefficients will tell you about significant conditional volatility of series 1 from innovations in series 1. The off-diagonal elements will tell you something about volatility-spillover from one series to the other. If you want to account for that you will need to include these results in your table.

Then I am trying to get the output as below:

Most of this I explained above, just one note to the residuals. It looks like the model adequacy was gauged by the LjungBox-Test (=LB?). See e.g. here.

I hope this answers your questions.

Edit: updated answer to include the additional questions.


来源: stackexchange

问:
Cocoa Autolayout: content hugging vs content compression resistance priority
I can't find a clear answer on Apple documentation regarding Cocoa Autolayout about the difference between content hugging and compression resistance. </p>

<p>Can somebody explain their usages and difference ? </p>

答:
contentCompressionResistancePriority – The view with the lowest value gets truncated when there is not enough space to fit everything’s intrinsicContentSize

contentHuggingPriority – The view with the lowest value gets expanded beyond its intrinsicContentSize when there is leftover space to fill

ContentLicense: CC BY-SA 3.0

Body:
I can't find a clear answer on Apple documentation regarding Cocoa Autolayout about the difference between content hugging and compression resistance.

Can somebody explain their usages and difference ?


问:
Html / Javascript - Div Showing & Hiding
Little Layout
MDIV
ADIV = BDIV

I'm trying to hide and show divs with onclicks and failing miserably.

When function MA() button is clicked = ADIV to show and BDIV to hide

When function MB() button is clicked = BDIV to show and ADIV to hide

function MA() {

  document.getElementById("ADIV").style.display = "";
  document.getElementById("BDIV").style.display = "none";

}

function MB() {

  document.getElementById("ADIV").style.display = "none";
  document.getElementById("BDIV").style.display = "";

}```
<pre class="snippet-code-html lang-html prettyprint-override"><code><div id="MDIV">
  <button onclick="MA()">MA</button>
  <button onclick="MB()">MB</button>
</div>

<div id="ADIV">
  <button onclick="A()">ADIV</button>
</div>
<div id="BDIV">
  <button onclick="B()">BDIV</button>
</div></code>```

Sidenote
Also if anyone can explain how to load with just MDIV - ADIV on page load.

Cheers in advance.

答:
Your code already toggles the visibility of the two elements on click of the respective buttons. However, you'll probably want to turn your elements to style.display = block when they're visible, rather than just removing the display style entirely.

In order to have #BDIV hidden by default, simply run
document.getElementById("BDIV").style.display = "none"; outside of your two functions.

This can be seen in the following example:

document.getElementById("BDIV").style.display = "none";

function MA() {
  document.getElementById("ADIV").style.display = "block";
  document.getElementById("BDIV").style.display = "none";
}

function MB() {
  document.getElementById("ADIV").style.display = "none";
  document.getElementById("BDIV").style.display = "block";
}```
<pre class="snippet-code-html lang-html prettyprint-override"><code><body>
  <div id="MDIV">
    <button onclick="MA()">MA</button>
    <button onclick="MB()">MB</button>
  </div>
  <div id="ADIV">
    <button onclick="A()">ADIV</button>
  </div>
  <div id="BDIV">
    <button onclick="B()">BDIV</button>
  </div>
</body></code>```

Hope this helps! :)

Body:
Little Layout
MDIV
ADIV = BDIV

I'm trying to hide and show divs with onclicks and failing miserably.

When function MA() button is clicked = ADIV to show and BDIV to hide

When function MB() button is clicked = BDIV to show and ADIV to hide

function MA() {

  document.getElementById("ADIV").style.display = "";
  document.getElementById("BDIV").style.display = "none";

}

function MB() {

  document.getElementById("ADIV").style.display = "none";
  document.getElementById("BDIV").style.display = "";

}

  <button onclick="MA()">MA</button>
  <button onclick="MB()">MB</button>

  <button onclick="A()">ADIV</button>

  <button onclick="B()">BDIV</button>

Sidenote
Also if anyone can explain how to load with just MDIV - ADIV on page load.

Cheers in advance.

Body:
Your code already toggles the visibility of the two elements on click of the respective buttons. However, you'll probably want to turn your elements to style.display = block when they're visible, rather than just removing the display style entirely.

In order to have #BDIV hidden by default, simply run
document.getElementById("BDIV").style.display = "none"; outside of your two functions.

This can be seen in the following example:

document.getElementById("BDIV").style.display = "none";

function MA() {
  document.getElementById("ADIV").style.display = "block";
  document.getElementById("BDIV").style.display = "none";
}

function MB() {
  document.getElementById("ADIV").style.display = "none";
  document.getElementById("BDIV").style.display = "block";
}

<body>
  <div id="MDIV">
    <button onclick="MA()">MA</button>
    <button onclick="MB()">MB</button>
  </div>
  <div id="ADIV">
    <button onclick="A()">ADIV</button>
  </div>
  <div id="BDIV">
    <button onclick="B()">BDIV</button>
  </div>
</body>

Hope this helps! :)


问:
gcc mingw compiler does not recognize CancelIOEx
I am trying to build some windows specific code that makes calls to CancelIOEx; however, the gcc linker keeps complaining that it can't find an implementation of CancelIOEx to link.

I tried specifying the kernel32 library file as a link library but that didn't work.

I am using the code blocks IDE.

Does anyone know how I can get around this problem?

答:
Per msdn and mingw, you must define the version of windows you are using to be greater than Vista before including windows.h:

```<code># define NTDDI_VERSION NTDDI_VISTA
# undef _WIN32_WINNT
# define _WIN32_WINNT _WIN32_WINNT_VISTA
</code>```

This may also be better done on the gcc command line:

```<code>CPPFLAGS += -DNTDDI_VERSION=NTDDI_VISTA -D_WIN32_WINNT=_WIN32_WINNT_VISTA
</code>```

Body:
Per msdn and mingw, you must define the version of windows you are using to be greater than Vista before including windows.h:

# define NTDDI_VERSION NTDDI_VISTA
# undef _WIN32_WINNT
# define _WIN32_WINNT _WIN32_WINNT_VISTA

This may also be better done on the gcc command line:

CPPFLAGS += -DNTDDI_VERSION=NTDDI_VISTA -D_WIN32_WINNT=_WIN32_WINNT_VISTA


问:
'git checkout' is not creating local branch to match remote tracking branch
On one machine, calling git checkout will not create a local branch.

For example, if I have a remote tracking branch origin/master, I can call git checkout origin/master, and it will work fine, putting me in a headless state.

But if I try to call git checkout master, I get the error error: pathspec 'master' did not match any file(s) known to git.

I tried this on another machine, and it worked just fine.

They have the exact same version of git installed (2.15.0.windows.1).  git config --list shows one difference.  The machine where it worked properly had the following line in its configuration:

```<code>remote.origin.fetch=+refs/heads/*:refs/remotes/origin/*
</code>```

What would put that in the local configuration, why might it be missing from one of the systems, and what is the proper thing to do to fix the problem?

答:
Before checkout branch you should run fetch:</p>

```<code>git fetch
git checkout master
</code>```

Body:
On one machine, calling git checkout will not create a local branch.

For example, if I have a remote tracking branch origin/master, I can call git checkout origin/master, and it will work fine, putting me in a headless state.

But if I try to call git checkout master, I get the error error: pathspec 'master' did not match any file(s) known to git.

I tried this on another machine, and it worked just fine.

They have the exact same version of git installed (2.15.0.windows.1).  git config --list shows one difference.  The machine where it worked properly had the following line in its configuration:

remote.origin.fetch=+refs/heads/*:refs/remotes/origin/*

What would put that in the local configuration, why might it be missing from one of the systems, and what is the proper thing to do to fix the problem?

Body:
Before checkout branch you should run fetch:

git fetch
git checkout master


问:
Changing image back to original after it is changed on hover?
I am attempting to use jQuery to hover over an image while it changes the other. I have that part done, the part I don't understand is when I hover over the image and then move the mouse off of it, how do I get the original image to come back? Any help would be greatly appreciated.

Here is what I have so far:

```<code>$(document).ready(function(){
     $("#04").hover(function(){
        $("#imgBig").attr("src", "imgLab10/04.jpg");
     });
});
</code>```

答:
I'm not a fan of changing the img source because you can have lag or disconnect issues then your alternative image may now show.  This can also be done without jQuery altogether.

.img-swap{
 width: 100px;
 height: 100px;
}

.img-swap .img-swap-alt{
  display: none;
}

.img-swap:hover .img-swap-alt{
  display: block;
}

.img-swap:hover .img-swap-def{
  display: none;
}```
<pre class="snippet-code-html lang-html prettyprint-override"><code><div class="img-swap">
<img class="img-swap-def" src="http://lorempixel.com/output/abstract-q-c-300-300-10.jpg"/>
<img class="img-swap-alt" src="http://lorempixel.com/output/food-q-c-300-300-1.jpg" />
</div</code>```

Body:
I am attempting to use jQuery to hover over an image while it changes the other. I have that part done, the part I don't understand is when I hover over the image and then move the mouse off of it, how do I get the original image to come back? Any help would be greatly appreciated.

Here is what I have so far:

$(document).ready(function(){
     $("#04").hover(function(){
        $("#imgBig").attr("src", "imgLab10/04.jpg");
     });
});

Body:
I'm not a fan of changing the img source because you can have lag or disconnect issues then your alternative image may now show.  This can also be done without jQuery altogether.

.img-swap{
 width: 100px;
 height: 100px;
}

.img-swap .img-swap-alt{
  display: none;
}

.img-swap:hover .img-swap-alt{
  display: block;
}

.img-swap:hover .img-swap-def{
  display: none;
}

<div class="img-swap">
<img class="img-swap-def" src="http://lorempixel.com/output/abstract-q-c-300-300-10.jpg"/>
<img class="img-swap-alt" src="http://lorempixel.com/output/food-q-c-300-300-1.jpg" />
</div


问:
How do you properly include a resource folder in a JAR artifact in IntelliJ IDEA?
I have a project that reads graphics and sound effects from a folder labeled res. This folder is at the same directory level as the src folder. I have res marked as Resources Root.

I configured my artifact to include res as a Content Directory by way of
Project Structure -> Artifacts -> Add (Alt + Insert) -> JAR

Then, in the output layout tab, I pressed the Add dropdown box -> Directory Content -> res

When I run the project in Intellij, it finds the resources just fine. Here is a code snippet showing how I access the resources:

```<code>public static final Sfx VOID_SOUND = new Sfx(TinySound.loadSound(new File("res/audio/sfx/void_sound.wav")));
</code>```

However, when I build the standalone artifact, then run the jar, it looks for the resource by prepending the parent directory of my machine to the file path, all the way to root. Here is how the terminal output looks:

```<code>/home/user/Demo/res/audio/sfx/void_sound.wav (No such file or directory)
Error getting resource stream!
</code>```

Is there a way to configure the artifact build to where it looks in the proper place? I want the resources included inside the jar file so it acts as a standalone jar with no external dependencies.

答: Now I understand why it doesn't work. It's because resources included within the JAR artifact must be included in the classpath and are accessible using getResource(). Resources outside the classpath must be accessed using a filepath. If you use a relative path, it will resolve to where the pwd where the JAR is launched form, not to inside the JAR, hence the reason it resolves back to root. The solution is to put the resources in the classpath and access them using getClass().getResource() or getClass().getLoader().getResource().

Body:
I have a project that reads graphics and sound effects from a folder labeled res. This folder is at the same directory level as the src folder. I have res marked as Resources Root.

I configured my artifact to include res as a Content Directory by way of
Project Structure -> Artifacts -> Add (Alt + Insert) -> JAR

Then, in the output layout tab, I pressed the Add dropdown box -> Directory Content -> res

When I run the project in Intellij, it finds the resources just fine. Here is a code snippet showing how I access the resources:

public static final Sfx VOID_SOUND = new Sfx(TinySound.loadSound(new File("res/audio/sfx/void_sound.wav")));

However, when I build the standalone artifact, then run the jar, it looks for the resource by prepending the parent directory of my machine to the file path, all the way to root. Here is how the terminal output looks:

/home/user/Demo/res/audio/sfx/void_sound.wav (No such file or directory)
Error getting resource stream!

Is there a way to configure the artifact build to where it looks in the proper place? I want the resources included inside the jar file so it acts as a standalone jar with no external dependencies.


问:
Making Column Records as Column Names
I have a table :

```<code> A | B
---+---
 a | 1qw
 b | 2q
 c | 3s
 a | 4sd
 b | 5
 c | 6
</code>```

Output Table:

```<code> a | b | c
---+---+---
1qw| 2q| 3s
4sd| 5 | 6
</code>```

How can i get the output table in sql server. This is an example and there could be more than 3 distinct records in the first column.

I used :

```<code>select a,b,c from
(select A,B from TABLE) as P
Pivot (max(B) for A in (a,b,c)
</code>```

This only gives me 1 of the rows (which is not even correct).

答:
It is quickest for you and easiest for us to answer these types of questions, when you provide a fully working valid SQL code example (even if does not get what you want) with DDL scripts like below:

```<code>CREATE TABLE #Data( ID INT IDENTITY, A1 CHAR( 1 ), B1 VARCHAR( 5 ))
INSERT INTO #Data
VALUES
( 'a', '1qw' ), ( 'b', '2q ' ), ( 'c', '3s ' ),
( 'a', '4sd' ), ( 'b', '5  ' ), ( 'c', '6  ' )
</code>```

The trick is to have a "Group ID" column that identifies groups ("buckets") of a, b, c records:

```<code>SELECT *, ROW_NUMBER() OVER( PARTITION BY A1 ORDER BY ID ) AS GroupID
FROM #Data
ORDER BY GroupID
</code>```

I assumed that you have "positional dependency" on ID column and that your groups are derived from the value of ID column i.e. b record with ID = 2 is in the same group as preceding a record with ID = 1. If your initial data setup is different then you need to come up with your own logic of how to assign "Group ID"s.

The final PIVOT query:

```<code>SELECT *
FROM
( SELECT A1, B1, ROW_NUMBER() OVER( PARTITION BY A1 ORDER BY ID ) AS GroupID
FROM #Data ) AS data
PIVOT(
    MAX( B1 ) FOR A1 IN( [a], [b], [c] )
) AS P
</code>```

Output:

```<code>GroupID              a     b     c
-------------------- ----- ----- -----
1                    1qw   2q    3s
2                    4sd   5     6
</code>```

References: https://learn.microsoft.com/en-us/sql/t-sql/queries/from-using-pivot-and-unpivot

Title: Making Column Records as Column Names

Body:
I have a table :

 A | B
---+---
 a | 1qw
 b | 2q
 c | 3s
 a | 4sd
 b | 5
 c | 6

Output Table:

 a | b | c
---+---+---
1qw| 2q| 3s
4sd| 5 | 6

How can i get the output table in sql server. This is an example and there could be more than 3 distinct records in the first column.

I used :

select a,b,c from
(select A,B from TABLE) as P
Pivot (max(B) for A in (a,b,c)

This only gives me 1 of the rows (which is not even correct).

Body:
It is quickest for you and easiest for us to answer these types of questions, when you provide a fully working valid SQL code example (even if does not get what you want) with DDL scripts like below:

CREATE TABLE #Data( ID INT IDENTITY, A1 CHAR( 1 ), B1 VARCHAR( 5 ))
INSERT INTO #Data
VALUES
( 'a', '1qw' ), ( 'b', '2q ' ), ( 'c', '3s ' ),
( 'a', '4sd' ), ( 'b', '5  ' ), ( 'c', '6  ' )

The trick is to have a "Group ID" column that identifies groups ("buckets") of a, b, c records:

SELECT *, ROW_NUMBER() OVER( PARTITION BY A1 ORDER BY ID ) AS GroupID
FROM #Data
ORDER BY GroupID

I assumed that you have "positional dependency" on ID column and that your groups are derived from the value of ID column i.e. b record with ID = 2 is in the same group as preceding a record with ID = 1. If your initial data setup is different then you need to come up with your own logic of how to assign "Group ID"s.

The final PIVOT query:

SELECT *
FROM
( SELECT A1, B1, ROW_NUMBER() OVER( PARTITION BY A1 ORDER BY ID ) AS GroupID
FROM #Data ) AS data
PIVOT(
    MAX( B1 ) FOR A1 IN( [a], [b], [c] )
) AS P

Output:

GroupID              a     b     c
-------------------- ----- ----- -----
1                    1qw   2q    3s
2                    4sd   5     6

References: https://learn.microsoft.com/en-us/sql/t-sql/queries/from-using-pivot-and-unpivot


答:
Regarding the sidenote: you should provide a default style of display: none for that BDIV:

function MA() {

  document.getElementById("ADIV").style.display = "block";
  document.getElementById("BDIV").style.display = "none";

}

function MB() {

  document.getElementById("ADIV").style.display = "none";
  document.getElementById("BDIV").style.display = "block";

}```
<pre class="snippet-code-html lang-html prettyprint-override"><code><div id="MDIV">
  <button onclick="MA()">MA</button>
  <button onclick="MB()">MB</button>
</div>

<div id="ADIV">
  <button onclick="A()">ADIV</button>
</div>
<div id="BDIV" style="display: none;">
  <button onclick="B()">BDIV</button>
</div></code>```

Edit: I would recommend explicitly setting a value for the display-property. Either use inline, block, or inline-block, depending on what you need.

Title: Html / Javascript - Div Showing & Hiding

Body:
Regarding the sidenote: you should provide a default style of display: none for that BDIV:

function MA() {

  document.getElementById("ADIV").style.display = "block";
  document.getElementById("BDIV").style.display = "none";

}

function MB() {

  document.getElementById("ADIV").style.display = "none";
  document.getElementById("BDIV").style.display = "block";

}

<div id="MDIV">
  <button onclick="MA()">MA</button>
  <button onclick="MB()">MB</button>
</div>

<div id="ADIV">
  <button onclick="A()">ADIV</button>
</div>
<div id="BDIV" style="display: none;">
  <button onclick="B()">BDIV</button>
</div>

Edit: I would recommend explicitly setting a value for the display-property. Either use inline, block, or inline-block, depending on what you need.


问:
convert matlab code to c code
is there s a way to convert simulink blocks or a matlab ".m" code to C code automatically ?</p>

答:
To convert Simulink models or MATLAB m-code to C you need Real-Time Workshop.
It supports only subset of MATLAB language and oriented for embedded systems.

Look also at other MatWorks products for code generation and application deployment:
http://www.mathworks.com/products

With MATLAB Compiler you will not get a C code, but a binary code, executable or library (dll), which will run on machines without MATLAB installed, but with MATLAB Compiler Runtime (MCR) library. It quite large in size, and platform specific and I believe it has to match the MATLAB version of compiled code.

For the new coming release 2011a The MathWorks developed new code generation products: MATLAB Coder, Simulink Coder and Embedded Coder.

ContentLicense: CC BY-SA 2.5

Title: convert matlab code to c code


问:
In Xamarin.Forms, how to allow for autocompletion for bindings in XAML code in the case you can't instantiate the BindingContext from XAML?
Given the following project:

MainPage.xaml

```<code><?xml version="1.0" encoding="utf-8" ?>
<ContentPage
    x:Class="A.MainPage"
    xmlns="http://xamarin.com/schemas/2014/forms"
    xmlns:x="http://schemas.microsoft.com/winfx/2009/xaml"
    xmlns:local="clr-namespace:A">
    <ContentPage.Content>
        <StackLayout>
            <StackLayout>
                <Button Clicked="Greet" Text="Greet" />
            </StackLayout>
        </StackLayout>
    </ContentPage.Content>
</ContentPage>
</code>```

MainPage.xaml.cs

```<code>using System;
using Xamarin.Forms;

namespace A
{
    public partial class MainPage : ContentPage
    {
        public MainPage()
        {
            InitializeComponent();
        }

        private void Greet(object sender, EventArgs e)
        {
            Navigation.PushModalAsync(new SubPage
            {
                BindingContext = new SubPageViewModel("World")
            });
        }
    }
}
</code>```

SubPage.xaml

```<code><?xml version="1.0" encoding="utf-8" ?>
<ContentPage
    x:Class="A.SubPage"
    xmlns="http://xamarin.com/schemas/2014/forms"
    xmlns:x="http://schemas.microsoft.com/winfx/2009/xaml">
    <ContentPage.Content>
        <StackLayout>
            <Label
                HorizontalOptions="CenterAndExpand"
                Text="{Binding Greeting}"
                VerticalOptions="CenterAndExpand" />
        </StackLayout>
    </ContentPage.Content>
</ContentPage>
</code>```

SubPage.xaml.cs

```<code>using Xamarin.Forms;

namespace A
{
    public partial class SubPage : ContentPage
    {
        public SubPage ()
        {
            InitializeComponent ();
        }
    }
}
</code>```

SubPageViewModel.cs

```<code>using System.ComponentModel;
using System.Runtime.CompilerServices;

namespace A
{
    public class SubPageViewModel : INotifyPropertyChanged
    {
        private string place;

        public string Place
        {
            get => place;
            set
            {
                if(place != value)
                    return;
                place = value;
                OnPropertyChanged();
                OnPropertyChanged(nameof(Greeting));
            }
        }

        public SubPageViewModel(string place)
        {
            this.place = place;
        }

        public string Greeting => $"Hello, {place}";

        public event PropertyChangedEventHandler PropertyChanged;

        protected virtual void OnPropertyChanged([CallerMemberName] string propertyName = null)
        {
            PropertyChanged?.Invoke(this, new PropertyChangedEventArgs(propertyName));
        }
    }
}
</code>```

Visual Studio won't autocomplete bindings in SubPage.xaml and will be complaining that it "Cannot resolve symbol 'Greeting' due to unknown DataContext", because the syntax highlighter doesn't know the type at the compile time. Typically, I'd use the following syntax:

```<code><ContentPage.BindingContext>
    <a:SubPageViewModel />
</ContentPage.BindingContext>
</code>```

however, this isn't applicable here, since the ViewModel is not default constructible.

If this was WPF, I'd be using mc:Ignorable="d" together with d:DesignInstance, however, DesignInstance doesn't seem to be implemented in XF.

How do I make autocompletion work?

答:
You can declare a dummy static property which will be used in a binding.

SubPage.xaml

```<code><?xml version="1.0" encoding="utf-8" ?>
<ContentPage
    x:Class="A.SubPage"
    xmlns="http://xamarin.com/schemas/2014/forms"
    xmlns:x="http://schemas.microsoft.com/winfx/2009/xaml"
    xmlns:a="clr-namespace:A;assembly=A.Android"
    xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
    BindingContext="{x:Static a:SubPage.BindingContextDummyInstance}"> <!-- <------ added -->
    <ContentPage.Content>
        <StackLayout>
            <Label
                HorizontalOptions="CenterAndExpand"
                Text="{Binding Greeting}"
                VerticalOptions="CenterAndExpand" />
        </StackLayout>
    </ContentPage.Content>
</ContentPage>
</code>```

SubPage.xaml.cs

```<code>using Xamarin.Forms;

namespace A
{
    public partial class SubPage : ContentPage
    {
        public static SubPageViewModel BindingContextDummyInstance => null; // <------ added

        public SubPage ()
        {
            InitializeComponent ();
        }
    }
}
</code>```

This changes nothing with regards to code semantics since the default BindingContext is still null, but now autocompletion is working, because the BindingContext is known at compile time.

Body:
Given the following project:

MainPage.xaml

<?xml version="1.0" encoding="utf-8" ?>
<ContentPage
    x:Class="A.MainPage"
    xmlns="http://xamarin.com/schemas/2014/forms"
    xmlns:x="http://schemas.microsoft.com/winfx/2009/xaml"
    xmlns:local="clr-namespace:A">
    <ContentPage.Content>
        <StackLayout>
            <StackLayout>
                <Button Clicked="Greet" Text="Greet" />
            </StackLayout>
        </StackLayout>
    </ContentPage.Content>
</ContentPage>

MainPage.xaml.cs

using System;
using Xamarin.Forms;

namespace A
{
    public partial class MainPage : ContentPage
    {
        public MainPage()
        {
            InitializeComponent();
        }

        private void Greet(object sender, EventArgs e)
        {
            Navigation.PushModalAsync(new SubPage
            {
                BindingContext = new SubPageViewModel("World")
            });
        }
    }
}

SubPage.xaml

<?xml version="1.0" encoding="utf-8" ?>
<ContentPage
    x:Class="A.SubPage"
    xmlns="http://xamarin.com/schemas/2014/forms"
    xmlns:x="http://schemas.microsoft.com/winfx/2009/xaml">
    <ContentPage.Content>
        <StackLayout>

        </StackLayout>
    </ContentPage.Content>
</ContentPage>

SubPage.xaml.cs

using Xamarin.Forms;

namespace A
{
    public partial class SubPage : ContentPage
    {
        public SubPage ()
        {
            InitializeComponent ();
        }
    }
}

SubPageViewModel.cs

using System.ComponentModel;
using System.Runtime.CompilerServices;

namespace A
{
    public class SubPageViewModel : INotifyPropertyChanged
    {
        private string place;

        public string Place
        {
            get => place;
            set
            {
                if(place != value)
                    return;
                place = value;
                OnPropertyChanged();
                OnPropertyChanged(nameof(Greeting));
            }
        }

        public SubPageViewModel(string place)
        {
            this.place = place;
        }

        public string Greeting => $"Hello, {place}";

        public event PropertyChangedEventHandler PropertyChanged;

        protected virtual void OnPropertyChanged([CallerMemberName] string propertyName = null)
        {
            PropertyChanged?.Invoke(this, new PropertyChangedEventArgs(propertyName));
        }
    }
}

Visual Studio won't autocomplete bindings in SubPage.xaml and will be complaining that it "Cannot resolve symbol 'Greeting' due to unknown DataContext", because the syntax highlighter doesn't know the type at the compile time. Typically, I'd use the following syntax:

<ContentPage.BindingContext>

</ContentPage.BindingContext>

however, this isn't applicable here, since the ViewModel is not default constructible.

If this was WPF, I'd be using mc:Ignorable="d" together with d:DesignInstance, however, DesignInstance doesn't seem to be implemented in XF.

How do I make autocompletion work?

Body:
You can declare a dummy static property which will be used in a binding.

SubPage.xaml

<?xml version="1.0" encoding="utf-8" ?>
<ContentPage
    x:Class="A.SubPage"
    xmlns="http://xamarin.com/schemas/2014/forms"
    xmlns:x="http://schemas.microsoft.com/winfx/2009/xaml"
    xmlns:a="clr-namespace:A;assembly=A.Android"
    xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
    BindingContext="{x:Static a:SubPage.BindingContextDummyInstance}"> <!-- <------ added -->
    <ContentPage.Content>
        <StackLayout>
            <Label
                HorizontalOptions="CenterAndExpand"
                Text="{Binding Greeting}"
                VerticalOptions="CenterAndExpand" />
        </StackLayout>
    </ContentPage.Content>
</ContentPage>

SubPage.xaml.cs

using Xamarin.Forms;

namespace A
{
    public partial class SubPage : ContentPage
    {
        public static SubPageViewModel BindingContextDummyInstance => null; // <------ added

        public SubPage ()
        {
            InitializeComponent ();
        }
    }
}

This changes nothing with regards to code semantics since the default BindingContext is still null, but now autocompletion is working, because the BindingContext is known at compile time.