<rss version="2.0" xmlns:atom="http://www.w3.org/2005/Atom">
  <channel>
    <title>Time Series on R Views</title>
    <link>https://rviews.rstudio.com/categories/time-series/</link>
    <description>Recent content in Time Series on R Views</description>
    <generator>Hugo -- gohugo.io</generator>
    <language>en-us</language>
    <lastBuildDate>Fri, 22 Jan 2021 00:00:00 +0000</lastBuildDate>
    <atom:link href="https://rviews.rstudio.com/categories/time-series/" rel="self" type="application/rss+xml" />
    
    
    
    
    <item>
      <title>SEM Time Series Modeling</title>
      <link>https://rviews.rstudio.com/2021/01/22/sem-time-series-modeling/</link>
      <pubDate>Fri, 22 Jan 2021 00:00:00 +0000</pubDate>
      
      <guid>https://rviews.rstudio.com/2021/01/22/sem-time-series-modeling/</guid>
      <description>
        
&lt;script src=&#34;/2021/01/22/sem-time-series-modeling/index_files/header-attrs/header-attrs.js&#34;&gt;&lt;/script&gt;


&lt;!--
tested on Win10:    R-4.0.3, rstudio-1.3.911, bimets-1.5.2
tested on Redhat7:  R-3.5.3, rstudio-1.1.463, bimets-1.5.2
--&gt;
&lt;p&gt;&lt;em&gt;Andrea Luciani is a Technical Advisor for the Directorate General for Economics, Statistics and Research at the Bank of Italy, and co-author of the bimets package.&lt;/em&gt;&lt;/p&gt;
&lt;p&gt;Structural Equation Models &lt;a href=&#34;https://en.wikipedia.org/wiki/Structural_equation_modeling&#34;&gt;(SEM)&lt;/a&gt;, which are common in many economic modeling efforts, require fitting and simulating whole system of equations where each equation may depend on the results of other equations. Moreover, they often require combining time series and regression equations in ways that are well beyond what the &lt;code&gt;ts()&lt;/code&gt; and &lt;code&gt;lm()&lt;/code&gt; functions were designed to do. For example, one might want to account for an error auto-correlation of some degree in the regression, or force linear restrictions modeling coefficients.&lt;/p&gt;
&lt;p&gt;In this post, we will show how to do structural equation modeling in R by working through the &lt;a href=&#34;http://www.ipe.ro/rjef/rjef1_14/rjef1_2014p5-14.pdf&#34;&gt;Klein Model&lt;/a&gt; of the United States economy, one of the oldest and most elementary models of its kind.&lt;/p&gt;
&lt;p&gt;These equations define the model:&lt;/p&gt;
&lt;p&gt;&lt;span class=&#34;math inline&#34;&gt;\(CN_t = \alpha_1 + \alpha_2 * P_t + \alpha_3 * P_{t-1} + \alpha_4 * ( WP_t + WG_t )\)&lt;/span&gt;&lt;/p&gt;
&lt;p&gt;&lt;span class=&#34;math inline&#34;&gt;\(I_t = \beta_1 + \beta_2 * P_t + \beta_3 * P_{t-1} - \beta_4 * K_{t-1}\)&lt;/span&gt;&lt;/p&gt;
&lt;p&gt;&lt;span class=&#34;math inline&#34;&gt;\(WP_t = \gamma_1 + \gamma_2 * ( Y_t + T_t - WG_t ) + \gamma_3 * ( Y_{t-1} + T_{t-1} - WG_{t-1} ) + \gamma_4 * Time\)&lt;/span&gt;&lt;/p&gt;
&lt;p&gt;&lt;span class=&#34;math inline&#34;&gt;\(P_t = Y_t - ( WP_t + WG_t )\)&lt;/span&gt;&lt;/p&gt;
&lt;p&gt;&lt;span class=&#34;math inline&#34;&gt;\(K_t = K_{t-1} + I_t\)&lt;/span&gt;&lt;/p&gt;
&lt;p&gt;&lt;span class=&#34;math inline&#34;&gt;\(Y_t = CN_t + I_t + G_t - T_t\)&lt;/span&gt;&lt;/p&gt;
&lt;p&gt;Given:&lt;/p&gt;
&lt;p&gt;&lt;span class=&#34;math inline&#34;&gt;\(CN\)&lt;/span&gt; as private consumption expenditure;&lt;br /&gt;
&lt;span class=&#34;math inline&#34;&gt;\(I\)&lt;/span&gt; as investment;&lt;br /&gt;
&lt;span class=&#34;math inline&#34;&gt;\(WP\)&lt;/span&gt; as wage bill of the private sector (demand for labor);&lt;br /&gt;
&lt;span class=&#34;math inline&#34;&gt;\(P\)&lt;/span&gt; as profits;&lt;br /&gt;
&lt;span class=&#34;math inline&#34;&gt;\(K\)&lt;/span&gt; as stock of capital goods;&lt;br /&gt;
&lt;span class=&#34;math inline&#34;&gt;\(Y\)&lt;/span&gt; as gross national product;&lt;br /&gt;
&lt;span class=&#34;math inline&#34;&gt;\(WG\)&lt;/span&gt; as wage bill of the government sector;&lt;br /&gt;
&lt;span class=&#34;math inline&#34;&gt;\(Time\)&lt;/span&gt; as an index of the passage of time, e.g. 1931 = zero;&lt;br /&gt;
&lt;span class=&#34;math inline&#34;&gt;\(G\)&lt;/span&gt; as government expenditure plus net exports;&lt;br /&gt;
&lt;span class=&#34;math inline&#34;&gt;\(T\)&lt;/span&gt; as business taxes.&lt;/p&gt;
&lt;p&gt;&lt;span class=&#34;math inline&#34;&gt;\(\alpha_i, \beta_j, \gamma_k\)&lt;/span&gt; are coefficient to be estimated.&lt;/p&gt;
&lt;p&gt;This system has only 6 equations, three of which must be fitted in order to assess the coefficients. It may not seem so difficult to solve this system, but the real complexity emerges if you look at the incidence graph in the following figure, wherein endogenous variables are plotted in blue and exogenous variables are plotted in pink.&lt;/p&gt;
&lt;p&gt;&lt;img src=&#34;/2021/01/22/sem-time-series-modeling/index_files/figure-html/incidence_graph-1.png&#34; width=&#34;672&#34; /&gt;&lt;/p&gt;
&lt;p&gt;Each edge states a simultaneous dependence from a variable to another, e.g. the &lt;code&gt;WP&lt;/code&gt; equation depends on the current value of the &lt;code&gt;TIME&lt;/code&gt; time series; complexity arises because in this model there are several circular dependencies, one of which is plotted in dark blue.&lt;/p&gt;
&lt;p&gt;A circular dependency in the incidence graph of a model implies that the model is a “simultaneous” equations model and that it must be estimated by using ad-hoc procedures; moreover it can be simulated, i.e. performing a forecast, only by using an iterative algorithm.&lt;/p&gt;
&lt;p&gt;If we search for “simultaneous equations” inside the &lt;a href=&#34;https://cran.r-project.org/web/views/Econometrics.html&#34;&gt;Econometrics Task View&lt;/a&gt; web page we can find two results: the &lt;a href=&#34;https://cran.r-project.org/web/packages/systemfit/index.html&#34;&gt;systemfit&lt;/a&gt; and the &lt;a href=&#34;https://cran.r-project.org/web/packages/bimets/index.html&#34;&gt;bimets&lt;/a&gt; packages.&lt;/p&gt;
&lt;p&gt;The &lt;a href=&#34;https://cran.r-project.org/web/packages/systemfit/index.html&#34;&gt;systemfit&lt;/a&gt; package is a powerful tool for econometric estimation of simultaneous systems of linear and nonlinear equations, but it only provides fitting procedures, thus it cannot be used in our example in order to work out a forecast.&lt;/p&gt;
&lt;p&gt;On the other hand, the &lt;a href=&#34;https://cran.r-project.org/web/packages/bimets/index.html&#34;&gt;bimets&lt;/a&gt; package implements, among others, simulation and forecasting procedures; as stated into the &lt;a href=&#34;https://cran.r-project.org/web/packages/bimets/vignettes/bimets.pdf&#34;&gt;vignette&lt;/a&gt; it allows users to write down the model in a natural way, to test several strategies and to focus on the econometric analysis, without overly dealing with coding.&lt;/p&gt;
&lt;p&gt;Time series projection, linear restrictions and error auto-correlation can be triggered directly in the model definition, so let us try to define a similar but more complex Klein model by using a &lt;a href=&#34;https://cran.r-project.org/web/packages/bimets/index.html&#34;&gt;bimets&lt;/a&gt; compliant syntax:&lt;/p&gt;
&lt;pre class=&#34;r&#34;&gt;&lt;code&gt;#load library
library(bimets)

#define the Klein model
kleinModelDef &amp;lt;- &amp;quot;
MODEL

COMMENT&amp;gt; Modified Klein Model 1 of the U.S. Economy with PDL, 
COMMENT&amp;gt; autocorrelation on errors, restrictions and conditional equation evaluations

COMMENT&amp;gt; Consumption with autocorrelation on errors
BEHAVIORAL&amp;gt; cn
TSRANGE 1923 1 1940 1
EQ&amp;gt; cn =  a1 + a2*p + a3*TSLAG(p,1) + a4*(wp+wg) 
COEFF&amp;gt; a1 a2 a3 a4
ERROR&amp;gt; AUTO(2)

COMMENT&amp;gt; Investment with restrictions
BEHAVIORAL&amp;gt; i
TSRANGE 1923 1 1940 1
EQ&amp;gt; i = b1 + b2*p + b3*TSLAG(p,1) + b4*TSLAG(k,1)
COEFF&amp;gt; b1 b2 b3 b4
RESTRICT&amp;gt; b2 + b3 = 1

COMMENT&amp;gt; Demand for Labor with PDL
BEHAVIORAL&amp;gt; wp 
TSRANGE 1923 1 1940 1
EQ&amp;gt; wp = c1 + c2*(y+t-wg) + c3*TSLAG(y+t-wg,1) + c4*time
COEFF&amp;gt; c1 c2 c3 c4
PDL&amp;gt; c3 1 2

COMMENT&amp;gt; Gross National Product
IDENTITY&amp;gt; y
EQ&amp;gt; y = cn + i + g - t

COMMENT&amp;gt; Profits
IDENTITY&amp;gt; p
EQ&amp;gt; p = y - (wp+wg)

COMMENT&amp;gt; Capital Stock with IF switches
IDENTITY&amp;gt; k
EQ&amp;gt; k = TSLAG(k,1) + i
IF&amp;gt; i &amp;gt; 0
IDENTITY&amp;gt; k
EQ&amp;gt; k = TSLAG(k,1) 
IF&amp;gt; i &amp;lt;= 0

END
&amp;quot;

#load the model
kleinModel &amp;lt;- LOAD_MODEL(modelText = kleinModelDef)&lt;/code&gt;&lt;/pre&gt;
&lt;pre&gt;&lt;code&gt;## Analyzing behaviorals...
## Analyzing identities...
## Optimizing...
## Loaded model &amp;quot;kleinModelDef&amp;quot;:
##     3 behaviorals
##     3 identities
##    12 coefficients
## ...LOAD MODEL OK&lt;/code&gt;&lt;/pre&gt;
&lt;p&gt;The code is quite intuitive and uses explicit keywords in order to define equations, coefficients, parameters, etc. Users can easily:&lt;/p&gt;
&lt;ul&gt;
&lt;li&gt;&lt;p&gt;change the &lt;code&gt;TSRANGE&lt;/code&gt; in order to fit the model in a custom time range per equation;&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;modify an equation &lt;code&gt;EQ&lt;/code&gt; without changing any user procedure or code;&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;add or remove one or more linear restriction on the coefficients by using the keyword &lt;code&gt;RESTRICT&lt;/code&gt;, e.g.&lt;br /&gt;
&lt;code&gt;RESTRICT&amp;gt; -1.23*b2 + 8.9*b3 = 0.34&lt;/code&gt;&lt;br /&gt;
&lt;code&gt;RESRTICT&amp;gt; b4 – 1.2*b1 = 5&lt;/code&gt;&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;add or remove an error auto-correlation structure with an arbitrary order by using the keyword:&lt;br /&gt;
&lt;code&gt;ERROR&amp;gt;&lt;/code&gt;&lt;/p&gt;&lt;/li&gt;
&lt;/ul&gt;
&lt;p&gt;Equations can contain advanced expressions, e.g.:&lt;/p&gt;
&lt;p&gt;&lt;code&gt;EQ&amp;gt; TSDELTA(i) = b1 + b2*EXP(p/1000) + b3*TSDELTALOG(TSLAG(p,1)) + b4*MOVAVG(TSLAG(k,1),5)&lt;/code&gt;&lt;/p&gt;
&lt;div id=&#34;model-estimation&#34; class=&#34;section level3&#34;&gt;
&lt;h3&gt;Model estimation&lt;/h3&gt;
&lt;p&gt;Now, we define time series to be used in our example, and then we perform an estimation of the whole &lt;code&gt;kleinModel&lt;/code&gt; by using the command &lt;code&gt;ESTIMATE()&lt;/code&gt;:&lt;/p&gt;
&lt;pre class=&#34;r&#34;&gt;&lt;code&gt;#define data
kleinModelData &amp;lt;- list(  
  cn  =TIMESERIES(39.8,41.9,45,49.2,50.6,52.6,55.1,56.2,57.3,57.8,
                  55,50.9,45.6,46.5,48.7,51.3,57.7,58.7,57.5,61.6,65,69.7,  
                  START=c(1920,1),FREQ=1),
  g   =TIMESERIES(4.6,6.6,6.1,5.7,6.6,6.5,6.6,7.6,7.9,8.1,9.4,10.7,
                  10.2,9.3,10,10.5,10.3,11,13,14.4,15.4,22.3,   
                  START=c(1920,1),FREQ=1),
  i   =TIMESERIES(2.7,-.2,1.9,5.2,3,5.1,5.6,4.2,3,5.1,1,-3.4,-6.2,
                  -5.1,-3,-1.3,2.1,2,-1.9,1.3,3.3,4.9,  
                  START=c(1920,1),FREQ=1),
  k   =TIMESERIES(182.8,182.6,184.5,189.7,192.7,197.8,203.4,207.6,
                  210.6,215.7,216.7,213.3,207.1,202,199,197.7,199.8,
                  201.8,199.9,201.2,204.5,209.4,    
                  START=c(1920,1),FREQ=1),
  p   =TIMESERIES(12.7,12.4,16.9,18.4,19.4,20.1,19.6,19.8,21.1,21.7,
                  15.6,11.4,7,11.2,12.3,14,17.6,17.3,15.3,19,21.1,23.5, 
                  START=c(1920,1),FREQ=1),
  wp  =TIMESERIES(28.8,25.5,29.3,34.1,33.9,35.4,37.4,37.9,39.2,41.3,
                  37.9,34.5,29,28.5,30.6,33.2,36.8,41,38.2,41.6,45,53.3,    
                  START=c(1920,1),FREQ=1),
  y   =TIMESERIES(43.7,40.6,49.1,55.4,56.4,58.7,60.3,61.3,64,67,57.7,
                  50.7,41.3,45.3,48.9,53.3,61.8,65,61.2,68.4,74.1,85.3, 
                  START=c(1920,1),FREQ=1),
  t   =TIMESERIES(3.4,7.7,3.9,4.7,3.8,5.5,7,6.7,4.2,4,7.7,7.5,8.3,5.4,
                  6.8,7.2,8.3,6.7,7.4,8.9,9.6,11.6, 
                  START=c(1920,1),FREQ=1),
  time=TIMESERIES(NA,-10,-9,-8,-7,-6,-5,-4,-3,-2,-1,0,
                  1,2,3,4,5,6,7,8,9,10, 
                  START=c(1920,1),FREQ=1),
  wg  =TIMESERIES(2.2,2.7,2.9,2.9,3.1,3.2,3.3,3.6,3.7,4,4.2,4.8,
                  5.3,5.6,6,6.1,7.4,6.7,7.7,7.8,8,8.5,  
                  START=c(1920,1),FREQ=1)
);

#load time series into the model object
kleinModel &amp;lt;- LOAD_MODEL_DATA(kleinModel,kleinModelData)&lt;/code&gt;&lt;/pre&gt;
&lt;pre&gt;&lt;code&gt;## Load model data &amp;quot;kleinModelData&amp;quot; into model &amp;quot;kleinModelDef&amp;quot;...
## ...LOAD MODEL DATA OK&lt;/code&gt;&lt;/pre&gt;
&lt;pre class=&#34;r&#34;&gt;&lt;code&gt;#estimate the model
kleinModel &amp;lt;- ESTIMATE(kleinModel, quietly=TRUE)&lt;/code&gt;&lt;/pre&gt;
&lt;p&gt;In order to reduce this blog post length we only show the output for a single estimation; anyhow, for each estimated equation the output is similar to the following:&lt;/p&gt;
&lt;pre class=&#34;r&#34;&gt;&lt;code&gt;kleinModel &amp;lt;- ESTIMATE(kleinModel, eqList=&amp;#39;cn&amp;#39;)&lt;/code&gt;&lt;/pre&gt;
&lt;pre&gt;&lt;code&gt;## 
## Estimate the Model kleinModelDef:
## the number of behavioral equations to be estimated is 1.
## The total number of coefficients is 4.
## 
## _________________________________________
## 
## BEHAVIORAL EQUATION: cn
## Estimation Technique: OLS
## Autoregression of Order  2  (Cochrane-Orcutt procedure)
## 
## Convergence was reached in  6  /  20  iterations.
## 
## 
## cn                  =   14.83    
##                         T-stat. 7.608    ***
## 
##                     +   0.2589   p
##                         T-stat. 2.96     *
## 
##                     +   0.01424  TSLAG(p,1)
##                         T-stat. 0.1735   
## 
##                     +   0.839    (wp+wg)
##                         T-stat. 14.68    ***
## 
## ERROR STRUCTURE:  AUTO(2) 
## 
## AUTOREGRESSIVE PARAMETERS:
## Rho          Std. Error   T-stat.      
##  0.2542       0.2589       0.9817       
## -0.05251      0.2594      -0.2024       
## 
## 
## STATs:
## R-Squared                      : 0.9827   
## Adjusted R-Squared             : 0.9755   
## Durbin-Watson Statistic        : 2.256    
## Sum of squares of residuals    : 8.072    
## Standard Error of Regression   : 0.8201   
## Log of the Likelihood Function : -18.32   
## F-statistic                    : 136.2    
## F-probability                  : 3.874e-10
## Akaike&amp;#39;s IC                    : 50.65    
## Schwarz&amp;#39;s IC                   : 56.88    
## Mean of Dependent Variable     : 54.29    
## Number of Observations         : 18
## Number of Degrees of Freedom   : 12
## Current Sample (year-period)   : 1923-1 / 1940-1
## 
## 
## Signif. codes:   *** 0.001  ** 0.01  * 0.05  
## 
## 
## ...ESTIMATE OK&lt;/code&gt;&lt;/pre&gt;
&lt;p&gt;The &lt;code&gt;ESTIMATE()&lt;/code&gt; function can fit also non-simultaneous system and a single equation. Several predefined time series transformations are available in &lt;a href=&#34;https://cran.r-project.org/web/packages/bimets/index.html&#34;&gt;bimets&lt;/a&gt;:&lt;/p&gt;
&lt;p&gt;– Time series extension &lt;code&gt;TSEXTEND()&lt;/code&gt;&lt;br /&gt;
– Time series merging &lt;code&gt;TSMERGE()&lt;/code&gt;&lt;br /&gt;
– Time series projection &lt;code&gt;TSPROJECT()&lt;/code&gt;&lt;br /&gt;
– Lag &lt;code&gt;TSLAG()&lt;/code&gt;&lt;br /&gt;
– Lag differences: standard, percentage and logarithmic, i.e. &lt;code&gt;TSDELTA()&lt;/code&gt;, &lt;code&gt;TSDELTAP()&lt;/code&gt;, &lt;code&gt;TSDELTALOG()&lt;/code&gt;&lt;br /&gt;
– Cumulative product &lt;code&gt;CUMPROD()&lt;/code&gt;&lt;br /&gt;
– Cumulative sum &lt;code&gt;CUMSUM()&lt;/code&gt;&lt;br /&gt;
– Moving average &lt;code&gt;MOVAVG()&lt;/code&gt;&lt;br /&gt;
– Moving sum &lt;code&gt;MOVSUM()&lt;/code&gt;&lt;br /&gt;
– Parametric (Dis)Aggregation &lt;code&gt;YEARLY()&lt;/code&gt;, &lt;code&gt;QUARTERLY()&lt;/code&gt;, &lt;code&gt;MONTHLY()&lt;/code&gt;, &lt;code&gt;DAILY()&lt;/code&gt;&lt;br /&gt;
– Time series data presentation &lt;code&gt;TABIT()&lt;/code&gt;&lt;/p&gt;
&lt;/div&gt;
&lt;div id=&#34;forecasting&#34; class=&#34;section level3&#34;&gt;
&lt;h3&gt;Forecasting&lt;/h3&gt;
&lt;p&gt;The &lt;code&gt;predict()&lt;/code&gt; function of the &lt;code&gt;lm()&lt;/code&gt; or &lt;code&gt;dyn$lm&lt;/code&gt; linear model framework produces predicted values, obtained by evaluating the regression function with new data: it is a popular function among the R users.&lt;/p&gt;
&lt;p&gt;Unfortunately, it does not help in our example: as we said before, in order to forecast a simultaneous model that presents circular dependencies in the incidence graph, we cannot merely assess the right-hand side of the equations, as the &lt;code&gt;predict.lm&lt;/code&gt; function does; in our case we need an iterative algorithm.&lt;/p&gt;
&lt;p&gt;The &lt;code&gt;predict.lm&lt;/code&gt; equivalent function that allows to forecast our simultaneous model is the &lt;code&gt;SIMULATE()&lt;/code&gt; function. On the other hand the &lt;code&gt;SIMULATE()&lt;/code&gt; function can also solve non-simultaneous models and gives the same results as the &lt;code&gt;predict.lm&lt;/code&gt; function.&lt;/p&gt;
&lt;p&gt;In addition, as in the Capital Stock &lt;code&gt;k&lt;/code&gt; equation in our example, the &lt;code&gt;SIMULATE()&lt;/code&gt; function can conditionally evaluate an identity during a simulation, depending on the value of a logical expression (e.g. for each simulation period the &lt;code&gt;k&lt;/code&gt; equation changes depending on the &lt;code&gt;i&lt;/code&gt; current value). Thus, it is possible to have a model alternating between two or more equation specifications for each simulation period, depending upon results from other equations.&lt;/p&gt;
&lt;p&gt;Structural stability, multiplier analysis and endogenous targeting are additional capabilities coded in &lt;a href=&#34;https://cran.r-project.org/web/packages/bimets/index.html&#34;&gt;bimets&lt;/a&gt; but not described in this post.&lt;/p&gt;
&lt;p&gt;In order to forecast the model up to 1944, we need to extend exogenous time series by using the &lt;code&gt;TSEXTEND()&lt;/code&gt; function. In this example, we perform simple extensions:&lt;/p&gt;
&lt;pre class=&#34;r&#34;&gt;&lt;code&gt;#we need to extend exogenous variables up to 1944
kleinModel$modelData &amp;lt;- within(kleinModel$modelData,{
    wg    = TSEXTEND(wg,  UPTO=c(1944,1),EXTMODE=&amp;#39;CONSTANT&amp;#39;)
    t     = TSEXTEND(t,   UPTO=c(1944,1),EXTMODE=&amp;#39;LINEAR&amp;#39;)
    g     = TSEXTEND(g,   UPTO=c(1944,1),EXTMODE=&amp;#39;CONSTANT&amp;#39;)
    k     = TSEXTEND(k,   UPTO=c(1944,1),EXTMODE=&amp;#39;LINEAR&amp;#39;)
    time  = TSEXTEND(time,UPTO=c(1944,1),EXTMODE=&amp;#39;LINEAR&amp;#39;)
  })&lt;/code&gt;&lt;/pre&gt;
&lt;p&gt;A call to the &lt;code&gt;SIMULATE()&lt;/code&gt; function will solve our simultaneous system of equations:&lt;/p&gt;
&lt;pre class=&#34;r&#34;&gt;&lt;code&gt;#forecast model
kleinModel &amp;lt;- SIMULATE(kleinModel
                      ,simType=&amp;#39;FORECAST&amp;#39;
                      ,TSRANGE=c(1941,1,1944,1)
                      ,simConvergence=0.00001
                      ,simIterLimit=100
                      ,quietly=TRUE
  )&lt;/code&gt;&lt;/pre&gt;
&lt;p&gt;The historical GNP (original referred as “Net national income, measured in billions of 1934 dollars” , pg. 141 in “&lt;a href=&#34;https://cowles.yale.edu/sites/default/files/files/pub/mon/m11-all.pdf&#34;&gt;Economic Fluctuations in the United States 1921-1941&lt;/a&gt;” by L. R. Klein, Wiley and Sons Inc., New York, 1950) is shown in figure, along with the simulation and the forecast.&lt;/p&gt;
&lt;pre class=&#34;r&#34;&gt;&lt;code&gt;#get forecasted GNP
TABIT(kleinModel$simulation$y)&lt;/code&gt;&lt;/pre&gt;
&lt;pre&gt;&lt;code&gt;## 
##       DATE, PER, kleinModel$simulation$y
## 
##       1941, 1  ,  125.3      
##       1942, 1  ,  172.5      
##       1943, 1  ,  185.6      
##       1944, 1  ,  141.1&lt;/code&gt;&lt;/pre&gt;
&lt;p&gt;&lt;img src=&#34;/2021/01/22/sem-time-series-modeling/index_files/figure-html/plot_ts-1.png&#34; width=&#34;672&#34; /&gt;&lt;/p&gt;
&lt;p&gt;Disclaimer: &lt;em&gt;The views and opinions expressed in this page are those of the author and do not necessarily reflect the official policy or position of the Bank of Italy. Examples of analysis performed within these pages are only examples. They should not be utilized in real-world analytic products as they are based only on very limited and dated open source information. Assumptions made within the analysis are not reflective of the position of the Bank of Italy.&lt;/em&gt;&lt;/p&gt;
&lt;/div&gt;

        &lt;script&gt;window.location.href=&#39;https://rviews.rstudio.com/2021/01/22/sem-time-series-modeling/&#39;;&lt;/script&gt;
      </description>
    </item>
    
    <item>
      <title>Learning things we already know about stocks</title>
      <link>https://rviews.rstudio.com/2017/08/22/stocks/</link>
      <pubDate>Tue, 22 Aug 2017 00:00:00 +0000</pubDate>
      
      <guid>https://rviews.rstudio.com/2017/08/22/stocks/</guid>
      <description>
         

&lt;script src=&#34;/rmarkdown-libs/htmlwidgets/htmlwidgets.js&#34;&gt;&lt;/script&gt;
&lt;script src=&#34;/rmarkdown-libs/jquery/jquery.min.js&#34;&gt;&lt;/script&gt;
&lt;script src=&#34;/rmarkdown-libs/threejs/three.min.js&#34;&gt;&lt;/script&gt;
&lt;script src=&#34;/rmarkdown-libs/threejs/Detector.js&#34;&gt;&lt;/script&gt;
&lt;script src=&#34;/rmarkdown-libs/threejs/Projector.js&#34;&gt;&lt;/script&gt;
&lt;script src=&#34;/rmarkdown-libs/threejs/CanvasRenderer.js&#34;&gt;&lt;/script&gt;
&lt;script src=&#34;/rmarkdown-libs/threejs/TrackballControls.js&#34;&gt;&lt;/script&gt;
&lt;script src=&#34;/rmarkdown-libs/threejs/StateOrbitControls.js&#34;&gt;&lt;/script&gt;
&lt;script src=&#34;/rmarkdown-libs/scatterplotThree-binding/scatterplotThree.js&#34;&gt;&lt;/script&gt;
&lt;link href=&#34;/rmarkdown-libs/crosstalk/css/crosstalk.css&#34; rel=&#34;stylesheet&#34; /&gt;
&lt;script src=&#34;/rmarkdown-libs/crosstalk/js/crosstalk.min.js&#34;&gt;&lt;/script&gt;
&lt;script src=&#34;/rmarkdown-libs/transmitter-binding/transmitter.js&#34;&gt;&lt;/script&gt;


&lt;p&gt;This example groups stocks together in a network that highlights associations within and between the groups using only historical price data. The result is far from ground-breaking: you can already guess the output. For the most part, the stocks get grouped together into pretty obvious business sectors.&lt;/p&gt;
&lt;p&gt;Despite the obvious result, the process of teasing out latent groupings from historic price data is interesting. That’s the focus of this example. A central idea of the approach taken here comes from the great paper of Ledoit and Wolf, “Honey, I Shrunk the Sample Covariance Matrix” (&lt;a href=&#34;http://www.ledoit.net/honey.pdf&#34; class=&#34;uri&#34;&gt;http://www.ledoit.net/honey.pdf&lt;/a&gt;). This example employs an alternative approach based on a matrix eigenvalue decomposition, but it’s the same general idea.&lt;/p&gt;
&lt;p&gt;This note follows an informal, how-to format. Rather than focus on mathematical analysis, which is well-detailed in the references, I try to spell out the how’s and why’s: how to do things step by step (using R) and a somewhat non-rigorous rationale for each step that’s hopefully at least convincing and intuitive.&lt;/p&gt;
&lt;p&gt;For emphasis, allow me to restate the first sentence as an objective:&lt;/p&gt;
&lt;ul&gt;
&lt;li&gt;Group stocks together in a network that highlights associations within and between the groups using only historical price data.&lt;/li&gt;
&lt;/ul&gt;
&lt;p&gt;That’s what the rest of this example will do, hopefully illuminating some key ideas about regularization along the way.&lt;/p&gt;
&lt;div id=&#34;software-used-in-the-example&#34; class=&#34;section level1&#34;&gt;
&lt;h1&gt;Software used in the example&lt;/h1&gt;
&lt;p&gt;The example uses R of course, and the following R packages, all available on CRAN (some of the packages themselves have dependencies):&lt;/p&gt;
&lt;ul&gt;
&lt;li&gt;quantmod (at least version 0.4-10)&lt;/li&gt;
&lt;li&gt;igraph (at least version 1.1.2)&lt;/li&gt;
&lt;li&gt;threejs (at least version 0.3.1)&lt;/li&gt;
&lt;/ul&gt;
&lt;/div&gt;
&lt;div id=&#34;getting-data&#34; class=&#34;section level1&#34;&gt;
&lt;h1&gt;Getting data&lt;/h1&gt;
&lt;p&gt;NOTE: You can skip ahead to the &lt;a href=&#34;#correlation&#34;&gt;Sample correlation&lt;/a&gt; section by simply downloading a sample copy of processed log(return) data as follows:&lt;/p&gt;
&lt;pre class=&#34;r&#34;&gt;&lt;code&gt;library(quantmod)
load(url(&amp;quot;http://illposed.net/logreturns.rdata&amp;quot;))&lt;/code&gt;&lt;/pre&gt;
&lt;p&gt;Otherwise, follow the next two sections to download the raw stock daily price data and process those data into log(returns).&lt;/p&gt;
&lt;div id=&#34;download-daily-closing-price-data-from-google-finance&#34; class=&#34;section level2&#34;&gt;
&lt;h2&gt;Download daily closing price data from Google Finance&lt;/h2&gt;
&lt;p&gt;The quantmod package (Ulrich and Ryan, &lt;a href=&#34;http://www.quantmod.com/&#34; class=&#34;uri&#34;&gt;http://www.quantmod.com/&lt;/a&gt;) makes it ridiculously easy to download (and visualize) financial time series data. The following code uses quantmod to download daily stock price data for about 100 companies with the largest market capitalizations listed on the Standard &amp;amp; Poor’s 500 index at the time of this writing. The code downloads daily closing prices from 2012 until the present. Modify the code to experiment with different time periods or stocks as desired!&lt;/p&gt;
&lt;p&gt;Because stock symbol names may change and companies my come and go, it’s possible that some of the data for some time periods are not available. The &lt;code&gt;tryCatch()&lt;/code&gt; block in the code checks for a download error and flags problems by returning &lt;code&gt;NA&lt;/code&gt;, later removed from the result. The upshot is that the output number of columns of stock price time series may be smaller than the input list of stock symbols.&lt;/p&gt;
&lt;p&gt;The output of the following code is an xts time series matrix of stock prices called &lt;code&gt;prices&lt;/code&gt; whose rows correspond to days and columns to stock symbols.&lt;/p&gt;
&lt;pre class=&#34;r&#34;&gt;&lt;code&gt;library(quantmod)
from=&amp;quot;2012-05-17&amp;quot;
sym = c(&amp;quot;AAPL&amp;quot;, &amp;quot;ABBV&amp;quot;, &amp;quot;ABT&amp;quot;, &amp;quot;ACN&amp;quot;, &amp;quot;AGN&amp;quot;, &amp;quot;AIG&amp;quot;, &amp;quot;ALL&amp;quot;, &amp;quot;AMGN&amp;quot;, &amp;quot;AMZN&amp;quot;, &amp;quot;AXP&amp;quot;,
        &amp;quot;BA&amp;quot;, &amp;quot;BAC&amp;quot;, &amp;quot;BIIB&amp;quot;, &amp;quot;BK&amp;quot;, &amp;quot;BLK&amp;quot;, &amp;quot;BMY&amp;quot;, &amp;quot;BRK.B&amp;quot;, &amp;quot;C&amp;quot;, &amp;quot;CAT&amp;quot;, &amp;quot;CELG&amp;quot;, &amp;quot;CL&amp;quot;,
        &amp;quot;CMCSA&amp;quot;, &amp;quot;COF&amp;quot;, &amp;quot;COP&amp;quot;, &amp;quot;COST&amp;quot;, &amp;quot;CSCO&amp;quot;, &amp;quot;CVS&amp;quot;, &amp;quot;CVX&amp;quot;, &amp;quot;DD&amp;quot;, &amp;quot;DHR&amp;quot;, &amp;quot;DIS&amp;quot;, &amp;quot;DOW&amp;quot;,
        &amp;quot;DUK&amp;quot;, &amp;quot;EMR&amp;quot;, &amp;quot;EXC&amp;quot;, &amp;quot;F&amp;quot;, &amp;quot;FB&amp;quot;, &amp;quot;FDX&amp;quot;, &amp;quot;FOX&amp;quot;, &amp;quot;FOXA&amp;quot;, &amp;quot;GD&amp;quot;, &amp;quot;GE&amp;quot;, &amp;quot;GILD&amp;quot;, &amp;quot;GM&amp;quot;,
        &amp;quot;GOOG&amp;quot;, &amp;quot;GOOGL&amp;quot;, &amp;quot;GS&amp;quot;, &amp;quot;HAL&amp;quot;, &amp;quot;HD&amp;quot;, &amp;quot;HON&amp;quot;, &amp;quot;IBM&amp;quot;, &amp;quot;INTC&amp;quot;, &amp;quot;JNJ&amp;quot;, &amp;quot;JPM&amp;quot;, &amp;quot;KHC&amp;quot;,
        &amp;quot;KMI&amp;quot;, &amp;quot;KO&amp;quot;, &amp;quot;LLY&amp;quot;, &amp;quot;LMT&amp;quot;, &amp;quot;LOW&amp;quot;, &amp;quot;MA&amp;quot;, &amp;quot;MCD&amp;quot;, &amp;quot;MDLZ&amp;quot;, &amp;quot;MDT&amp;quot;, &amp;quot;MET&amp;quot;, &amp;quot;MMM&amp;quot;,
        &amp;quot;MO&amp;quot;, &amp;quot;MON&amp;quot;, &amp;quot;MRK&amp;quot;, &amp;quot;MS&amp;quot;, &amp;quot;MSFT&amp;quot;, &amp;quot;NEE&amp;quot;, &amp;quot;NKE&amp;quot;, &amp;quot;ORCL&amp;quot;, &amp;quot;OXY&amp;quot;, &amp;quot;PCLN&amp;quot;, &amp;quot;PEP&amp;quot;,
        &amp;quot;PFE&amp;quot;, &amp;quot;PG&amp;quot;, &amp;quot;PM&amp;quot;, &amp;quot;PYPL&amp;quot;, &amp;quot;QCOM&amp;quot;, &amp;quot;RTN&amp;quot;, &amp;quot;SBUX&amp;quot;, &amp;quot;SLB&amp;quot;, &amp;quot;SO&amp;quot;, &amp;quot;SPG&amp;quot;, &amp;quot;T&amp;quot;,
        &amp;quot;TGT&amp;quot;, &amp;quot;TWX&amp;quot;, &amp;quot;TXN&amp;quot;, &amp;quot;UNH&amp;quot;, &amp;quot;UNP&amp;quot;, &amp;quot;UPS&amp;quot;, &amp;quot;USB&amp;quot;, &amp;quot;UTX&amp;quot;, &amp;quot;V&amp;quot;, &amp;quot;VZ&amp;quot;, &amp;quot;WBA&amp;quot;,
        &amp;quot;WFC&amp;quot;, &amp;quot;WMT&amp;quot;, &amp;quot;XOM&amp;quot;)

prices = Map(function(n)
             {
               print(n)
               tryCatch(getSymbols(n, src=&amp;quot;google&amp;quot;, env=NULL, from=from)[, 4], error = function(e) NA)
             }, sym)
N = length(prices)
# identify symbols returning valid data
i = ! unlist(Map(function(i) is.na(prices[i]), seq(N)))
# combine returned prices list into a matrix, one column for each symbol with valid data
prices = Reduce(cbind, prices[i])
colnames(prices) = sym[i]&lt;/code&gt;&lt;/pre&gt;
&lt;/div&gt;
&lt;div id=&#34;clean-up-and-transform-data&#34; class=&#34;section level2&#34;&gt;
&lt;h2&gt;Clean up and transform data&lt;/h2&gt;
&lt;p&gt;Not every stock symbol may have prices available for every day. Trading can be suspended for some reason, companies get acquired or go private, new companies form, etc.&lt;/p&gt;
&lt;p&gt;Let’s fill in missing values going forward in time using the last reported price (piecewise constant interpolation)–a reasonable approach for stock price time series. After that, if there are still missing values, just remove those symbols that contain them, possibly further reducing the universe of stock symbols we’re working with.&lt;/p&gt;
&lt;pre class=&#34;r&#34;&gt;&lt;code&gt;for(j in 1:ncol(prices)) prices[, j] = na.locf(prices[, j])       # fill in
prices = prices[, apply(prices, 2, function(x) ! any(is.na(x)))]  # omit stocks with missing data&lt;/code&gt;&lt;/pre&gt;
&lt;p&gt;Now that we have a universe of stocks with valid price data, convert those prices to log(returns) for the remaining analysis (by returns I mean simply the ratio of prices relative to the first price).&lt;/p&gt;
&lt;p&gt;Why log(returns) instead of prices?&lt;/p&gt;
&lt;p&gt;The log(returns) are closer to normally distributed than prices especially in the long run. Pat Burns wrote a note about this (with a Tom Waits soundrack): &lt;a href=&#34;http://www.portfolioprobe.com/2012/01/23/the-distribution-of-financial-returns-made-simple/&#34; class=&#34;uri&#34;&gt;http://www.portfolioprobe.com/2012/01/23/the-distribution-of-financial-returns-made-simple/&lt;/a&gt;.&lt;/p&gt;
&lt;p&gt;But why care about getting data closer to normally distributed?&lt;/p&gt;
&lt;p&gt;That turns out to be important to us because later we’ll use a technique called partial correlation. That technique generally works better for normally distributed data than otherwise, see for example a nice technical discussion about this by Baba, Shibata, and Sibuya here: &lt;a href=&#34;https://doi.org/10.1111%2Fj.1467-842X.2004.00360.x&#34;&gt;https://doi.org/10.1111%2Fj.1467-842X.2004.00360.x&lt;/a&gt;&lt;/p&gt;
&lt;p&gt;The following simple code converts our &lt;code&gt;prices&lt;/code&gt; matrix into a matrix of log(returns):&lt;/p&gt;
&lt;pre class=&#34;r&#34;&gt;&lt;code&gt;log_returns = apply(prices, 2, function(x) diff(log(x)))&lt;/code&gt;&lt;/pre&gt;
&lt;/div&gt;
&lt;/div&gt;
&lt;div id=&#34;sample-correlation-matrix&#34; class=&#34;section level1&#34;&gt;
&lt;h1&gt;Sample correlation &lt;a name=&#34;correlation&#34;/&gt; matrix&lt;/h1&gt;
&lt;p&gt;It’s easy to convert the downloaded log(returns) data into a Pearson’s sample correlation matrix &lt;code&gt;X&lt;/code&gt;:&lt;/p&gt;
&lt;pre class=&#34;r&#34;&gt;&lt;code&gt;X = cor(log_returns)&lt;/code&gt;&lt;/pre&gt;
&lt;p&gt;The (i, j)th entry of the sample correlation matrix &lt;code&gt;X&lt;/code&gt; above is a measurement of the degree of linear dependence between the log(return) series for the stocks in columns i and j.&lt;/p&gt;
&lt;p&gt;There exist at least two issues that can lead to serious problems with the interpretation of the sample correlation values:&lt;/p&gt;
&lt;ol style=&#34;list-style-type: decimal&#34;&gt;
&lt;li&gt;As Ledoit and Wolf point out, it’s well-known that empirical correlation estimates may contain lots of error.&lt;/li&gt;
&lt;li&gt;Correlation estimates between two stock log(return) series can be misleading for many reasons, including spurious correlation or existence of confounding variables related to both series (&lt;a href=&#34;http://www.tylervigen.com/spurious-correlations&#34; class=&#34;uri&#34;&gt;http://www.tylervigen.com/spurious-correlations&lt;/a&gt;).&lt;/li&gt;
&lt;/ol&gt;
&lt;p&gt;A &lt;a href=&#34;http://www.nobelprize.org/nobel_prizes/economic-sciences/laureates/2003/&#34;&gt;Nobel-prize winning&lt;/a&gt; approach to dealing with the second problem considers cointegration between series instead of correlation, see for example notes by Eric Zivot (&lt;a href=&#34;https://faculty.washington.edu/ezivot/econ584/notes/cointegrationslides.pdf&#34; class=&#34;uri&#34;&gt;https://faculty.washington.edu/ezivot/econ584/notes/cointegrationslides.pdf&lt;/a&gt;), or Bernhard Pfaff’s lovely book “Analysis of Integrated and Cointegrated Time Series with R” (&lt;a href=&#34;http://www.springer.com/us/book/9780387759661&#34; class=&#34;uri&#34;&gt;http://www.springer.com/us/book/9780387759661&lt;/a&gt;), or Wikipedia (&lt;a href=&#34;https://en.wikipedia.org/wiki/Cointegration&#34; class=&#34;uri&#34;&gt;https://en.wikipedia.org/wiki/Cointegration&lt;/a&gt;). (I also have some weird technical notes on the numerics of cointegration at &lt;a href=&#34;http://illposed.net/cointegration.html&#34; class=&#34;uri&#34;&gt;http://illposed.net/cointegration.html&lt;/a&gt;.)&lt;/p&gt;
&lt;p&gt;Cointegration is a wonderful but fairly technical topic. Instead, let’s try a simpler approach.&lt;/p&gt;
&lt;p&gt;We can try to address issue 2 above by controlling for confounding variables, at least partially. One approach considers &lt;em&gt;partial correlation&lt;/em&gt; instead of correlation (see for example the nice description in Wikipedia &lt;a href=&#34;https://en.wikipedia.org/wiki/Partial_correlation&#34; class=&#34;uri&#34;&gt;https://en.wikipedia.org/wiki/Partial_correlation&lt;/a&gt;). That approach works best in practice with approximately normal data–one reason for the switch to log(returns) instead of prices. We will treat the entries of the precision matrix as measures of association in a network of stocks below.&lt;/p&gt;
&lt;p&gt;It’s worth stating that our simple approach basically treats the log(returns) series as a bunch of vectors and not so much bona fide time series, and can’t handle as many pathologies that might occur as well as cointegration can. But as we will see, this simple technique is still pretty effective at finding structure in our data. (And indeed related methods as discussed by Ledoit and Wolf and elsewhere are widely used in portfolio and risk analyses in practice.)&lt;/p&gt;
&lt;p&gt;The partial correlation coefficients between all stock log(returns) series are the entries of the inverse of the sample correlation matrix (&lt;a href=&#34;https://www.statlect.com/glossary/precision-matrix&#34; class=&#34;uri&#34;&gt;https://www.statlect.com/glossary/precision-matrix&lt;/a&gt;).&lt;/p&gt;
&lt;p&gt;Market trading of our universe of companies, with myriad known and unknown associations between them and the larger economy, produced the stock prices we downloaded. Our objective is a kind of inverse problem: given a bunch of historical stock prices, produce a network of associations.&lt;/p&gt;
&lt;p&gt;You may recall from some long ago class that, numerically speaking, inverting matrices is generally a bad idea. Even worse, issue 1 above says that our estimated correlation coefficients contain error (noise). Even a tiny amount noise can be hugely amplified if we invert the matrix. That’s because, as we will soon see, the sample correlation matrix contains tiny eigenvalues and matrix inversion effectively divides the noise by those tiny values. Simply stated, dividing by a tiny number returns a big number–that is, matrix inversion tends to blow the noise up. This is a fundamental issue (in a sense, &lt;em&gt;the&lt;/em&gt; fundamental issue) common to many inverse problems.&lt;/p&gt;
&lt;p&gt;Ledoit and Wolf’s sensible answer to reducing the influence of noise is &lt;em&gt;regularization&lt;/em&gt;. Regularization replaces models with &lt;em&gt;different, but related&lt;/em&gt;, models designed to reduce the influence of noise on their output. LW use a form of regularization related to ridge regression (a. k. a. Tikhonov regularization) with a peculiar regularization operator based on a highly structured estimate of the covariance. We will use a simpler kind of regularization based on an eigenvalue decomposition of the sample correlation matrix &lt;code&gt;X&lt;/code&gt;.&lt;/p&gt;
&lt;/div&gt;
&lt;div id=&#34;regularization&#34; class=&#34;section level1&#34;&gt;
&lt;h1&gt;Regularization&lt;/h1&gt;
&lt;p&gt;Here is an eigenvalue decomposition of the sample correlation matrix:&lt;/p&gt;
&lt;pre class=&#34;r&#34;&gt;&lt;code&gt;L = eigen(X, symmetric=TRUE)&lt;/code&gt;&lt;/pre&gt;
&lt;p&gt;Note that R’s &lt;code&gt;eigen()&lt;/code&gt; function takes care to return the (real-valued) eigenvalues of a symmetric matrix in decreasing order for us. (Technically, the correlation matrix is symmetric positive semi-definite, and will have only nonnegative real eigenvalues.)&lt;/p&gt;
&lt;p&gt;Each eigenvector represents an orthogonal projection of the sample correlation matrix into a line (a 1-d shadow of the data); The first two eigenvectors define a projection of the sample correlation matrix into a plane (2-d), and so on. The eigenvalues estimate the proportion of information (or variability if you prefer) from the original sample correlation matrix contained in each eigenvector. Because the eigenvectors are orthogonal, these measurements of projected information are additive.&lt;/p&gt;
&lt;p&gt;Here is a plot of all the sample correlation matrix eigenvalues (along with a vertical line that will be explained in a moment):&lt;/p&gt;
&lt;pre class=&#34;r&#34;&gt;&lt;code&gt;plot(L$values, ylab=&amp;quot;eigenvalues&amp;quot;)
abline(v=10)&lt;/code&gt;&lt;/pre&gt;
&lt;p&gt;&lt;img src=&#34;/post/2017-08-21-stocks_files/figure-html/unnamed-chunk-8-1.png&#34; width=&#34;672&#34; /&gt;&lt;/p&gt;
&lt;p&gt;The eigenvalues fall off rather quickly in our example! That means that a lot of the information in the sample correlation matrix is contained in the first few eigenvectors.&lt;/p&gt;
&lt;p&gt;Let’s assume, perhaps unreasonably, that the errors in our estimate of the correlation matrix are equally likely to occur in any direction (that the errors are white noise, basically). As we can see above, most of the information is concentrated in the subspace corresponding to the first few eigenvectors. But white noise will have information content in all the dimensions more or less equally.&lt;/p&gt;
&lt;p&gt;One regularization technique replaces the sample correlation matrix with an approximation defined by only its first few eigenvectors. Because they represent a large amount of the information content, the approximation can be pretty good. More importantly, because we assumed noise to be more or less equally represented across the eigenvector directions and we’re cutting most of those off, this approximation tends to damp the noise more than the underlying information. Most importantly, we’re cutting off the subspace associated with tiny eigenvalues, avoiding the problem of division by tiny values and significantly reducing amplified noise in the inverse of the sample correlation matrix (the precision matrix).&lt;/p&gt;
&lt;p&gt;The upshot is, we regularize the sample correlation matrix by approximating it by a low-rank matrix that substantially reduces the influence of noise on the precision matrix. See Per Christian Hansen’s classic paperback “Rank-Deficient and Discrete Ill-Posed Problems” (&lt;a href=&#34;http://epubs.siam.org/doi/book/10.1137/1.9780898719697&#34; class=&#34;uri&#34;&gt;http://epubs.siam.org/doi/book/10.1137/1.9780898719697&lt;/a&gt;) for insight into related topics.&lt;/p&gt;
&lt;div id=&#34;but-how-to-choose-a-cut-off-rank&#34; class=&#34;section level2&#34;&gt;
&lt;h2&gt;But how to choose a cut-off rank?&lt;/h2&gt;
&lt;p&gt;There is a substantial mathematical literature for just this topic (regularization parameter choice selection), complete with deep theory as well as lots of heuristics. Let’s keep things simple for this example and form our approximation by cutting off eigenvectors beyond where the eigenvalue plot starts to flatten out – close to the vertical line in the above plot.&lt;/p&gt;
&lt;p&gt;Alternatively consider the lovely short 2004 paper by Chris Ding and Xiaofeng He (&lt;a href=&#34;http://dl.acm.org/citation.cfm?id=1015408&#34; class=&#34;uri&#34;&gt;http://dl.acm.org/citation.cfm?id=1015408&lt;/a&gt;) that illuminates connections (that I happen to find fascinating) between k-means clustering and projections like truncated eigenvalue expansions. Although we aren’t interested in k-means clustering per se, our objective &lt;em&gt;is&lt;/em&gt; connected to clustering. Ding and He show that we can find at least k (k-means) clusters using the first k - 1 eigenvectors above. This gives us another heuristic way to choose a projection dimension, at least if we have an idea about the number of clusters to look for.&lt;/p&gt;
&lt;/div&gt;
&lt;div id=&#34;a-precision-matrix-finally&#34; class=&#34;section level2&#34;&gt;
&lt;h2&gt;A precision matrix, finally&lt;/h2&gt;
&lt;p&gt;Finally, we form the precision matrix &lt;code&gt;P&lt;/code&gt; from the regularized sample correlation matrix. The inversion is less numerically-problematic now because of regularization. Feel free to experiment with the projected rank &lt;code&gt;N&lt;/code&gt; below!&lt;/p&gt;
&lt;pre class=&#34;r&#34;&gt;&lt;code&gt;N = 10  # (use 1st 10 eigenvectors, set N larger to reduce regularization)
P = L$vectors[, 1:N] %*% ((1 / L$values[1:N]) * t(L$vectors[, 1:N]))
P = P / tcrossprod(sqrt(diag(P)))&lt;/code&gt;&lt;/pre&gt;
&lt;/div&gt;
&lt;div id=&#34;other-approaches&#34; class=&#34;section level2&#34;&gt;
&lt;h2&gt;Other approaches&lt;/h2&gt;
&lt;p&gt;I’m not qualified to write about them, but you should be aware that Bayesian approaches to solving problems like this are also effectively (and effective!) regularization methods. I hope to someday better understand the connections between classical inverse problem solution methods that I know a little bit about, and Bayesian methods that I know substantially less about.&lt;/p&gt;
&lt;/div&gt;
&lt;/div&gt;
&lt;div id=&#34;put-a-package-on-it&#34; class=&#34;section level1&#34;&gt;
&lt;h1&gt;Put a package on it&lt;/h1&gt;
&lt;p&gt;There is a carefully written R package to construct regularized correlation and precision matrices: the corpcor package (&lt;a href=&#34;https://cran.r-project.org/package=corpcor&#34; class=&#34;uri&#34;&gt;https://cran.r-project.org/package=corpcor&lt;/a&gt;, and also see &lt;a href=&#34;http://strimmerlab.org/software/corpcor/&#34; class=&#34;uri&#34;&gt;http://strimmerlab.org/software/corpcor/&lt;/a&gt;) by Juliane Schafer, Rainer Opgen-Rhein, Verena Zuber, Miika Ahdesmaki, A. Pedro Duarte Silva, and Korbinian Strimmer. Their package includes the original Ledoit Wolf-like regularization method, as well as refinements to it and many other methods. The corpcor package, like Ledoit Wolf, includes ways to use sophisticated regularization operators and can apply more broadly than the simple approach taken in this note.&lt;/p&gt;
&lt;p&gt;You can use the corpcor package to form a Ledoit-Wolf-like regularized precision matrix P, and you should try it! The result is pretty similar to what we get from our simple truncated eigenvalue decomposition regularization in this example.&lt;/p&gt;
&lt;/div&gt;
&lt;div id=&#34;networks-and-clustering&#34; class=&#34;section level1&#34;&gt;
&lt;h1&gt;Networks and clustering&lt;/h1&gt;
&lt;p&gt;The (i, j)th entry of the precision matrix &lt;code&gt;P&lt;/code&gt; is a measure of association between the log(return) time series for the stocks in columns i and j, with larger values corresponding to more association.&lt;/p&gt;
&lt;p&gt;An interesting way to group related stocks together is to think of the precision matrix as an adjacency matrix defining a weighted, undirected network of stock associations. Thresholding entries of the precision matrix to include, say, only the top ten per cent results in a network of only the most strongly associated stocks.&lt;/p&gt;
&lt;p&gt;Thinking in terms of networks opens up a huge and useful toolbox: graph theory. We gain access to all kinds of nifty ways to analyze and visualize data, including methods for clustering and community detection.&lt;/p&gt;
&lt;p&gt;R’s comprehensive igraph package by Gábor Csárdi (&lt;a href=&#34;https://cran.r-project.org/package=igraph&#34; class=&#34;uri&#34;&gt;https://cran.r-project.org/package=igraph&lt;/a&gt;) includes many network cluster detection algorithms. The example below uses Blondel and co-authors’ fast community detection algorithm implemented by igraph’s &lt;code&gt;cluster_louvain()&lt;/code&gt; function to segment the thresholded precision matrix of stocks into groups. The code produces an igraph graph object &lt;code&gt;g&lt;/code&gt;, with vertices colored by group membership.&lt;/p&gt;
&lt;pre class=&#34;r&#34;&gt;&lt;code&gt;suppressMessages(library(igraph))

threshold = 0.90
Q = P * (P &amp;gt; quantile(P, probs=threshold))                           # thresholded precision matrix
g = graph.adjacency(Q, mode=&amp;quot;undirected&amp;quot;, weighted=TRUE, diag=FALSE) # ...expressed as a graph

# The rest of the code lumps any singletons lacking edges into a single &amp;#39;unassociated&amp;#39; group shown in gray
# (also assigning distinct colors to the other groups).
x = groups(cluster_louvain(g))
i = unlist(lapply(x, length))
d = order(i, decreasing=TRUE)
x = x[d]
i = i[d]
j = i &amp;gt; 1
s = sum(j)
names(x)[j] = seq(1, s)
names(x)[! j] = s + 1
grp = as.integer(rep(names(x), i))
clrs = c(rainbow(s), &amp;quot;gray&amp;quot;)[grp[order(unlist(x))]]
g = set_vertex_attr(g, &amp;quot;color&amp;quot;, value=clrs)&lt;/code&gt;&lt;/pre&gt;
&lt;p&gt;Use the latest threejs package to make a nice interactive visualization of the network (you can use your mouse/trackpad to rotate, zoom and pan the visualization).&lt;/p&gt;
&lt;pre class=&#34;r&#34;&gt;&lt;code&gt;library(threejs)
graphjs(g, vertex.size=0.2, vertex.shape=colnames(X), edge.alpha=0.5)&lt;/code&gt;&lt;/pre&gt;
&lt;div id=&#34;htmlwidget-1&#34; style=&#34;width:816px;height:672px;&#34; class=&#34;scatterplotThree html-widget&#34;&gt;&lt;/div&gt;
&lt;script type=&#34;application/json&#34; data-for=&#34;htmlwidget-1&#34;&gt;{&#34;x&#34;:{&#34;NROW&#34;:94,&#34;height&#34;:null,&#34;width&#34;:null,&#34;axis&#34;:false,&#34;numticks&#34;:[6,6,6],&#34;xticklabs&#34;:null,&#34;yticklabs&#34;:null,&#34;zticklabs&#34;:null,&#34;color&#34;:[[&#34;#00FFFF&#34;,&#34;#0040FF&#34;,&#34;#00FFFF&#34;,&#34;#80FF00&#34;,&#34;#80FF00&#34;,&#34;#0040FF&#34;,&#34;#00FF40&#34;,&#34;#80FF00&#34;,&#34;#FF0000&#34;,&#34;#80FF00&#34;,&#34;#0040FF&#34;,&#34;#80FF00&#34;,&#34;#80FF00&#34;,&#34;#0040FF&#34;,&#34;#80FF00&#34;,&#34;#80FF00&#34;,&#34;#FF0000&#34;,&#34;#0040FF&#34;,&#34;#00FF40&#34;,&#34;#FF00BF&#34;,&#34;#80FF00&#34;,&#34;#8000FF&#34;,&#34;#FFBF00&#34;,&#34;#00FFFF&#34;,&#34;#FFBF00&#34;,&#34;#8000FF&#34;,&#34;#FF0000&#34;,&#34;#FF0000&#34;,&#34;#FF00BF&#34;,&#34;#FF0000&#34;,&#34;#FFBF00&#34;,&#34;#FF0000&#34;,&#34;#FFBF00&#34;,&#34;#FFBF00&#34;,&#34;#00FF40&#34;,&#34;#FF0000&#34;,&#34;#FF00BF&#34;,&#34;#FF00BF&#34;,&#34;#FF0000&#34;,&#34;#FF0000&#34;,&#34;#0040FF&#34;,&#34;#FFBF00&#34;,&#34;#00FF40&#34;,&#34;#00FF40&#34;,&#34;#80FF00&#34;,&#34;#8000FF&#34;,&#34;#FFBF00&#34;,&#34;#FF0000&#34;,&#34;#00FFFF&#34;,&#34;#00FFFF&#34;,&#34;#0040FF&#34;,&#34;#80FF00&#34;,&#34;#8000FF&#34;,&#34;#00FF40&#34;,&#34;#0040FF&#34;,&#34;#FFBF00&#34;,&#34;#00FF40&#34;,&#34;#00FF40&#34;,&#34;#80FF00&#34;,&#34;#FF0000&#34;,&#34;#00FF40&#34;,&#34;#FF0000&#34;,&#34;#0040FF&#34;,&#34;#80FF00&#34;,&#34;#00FFFF&#34;,&#34;#FFBF00&#34;,&#34;#FFBF00&#34;,&#34;#00FFFF&#34;,&#34;#8000FF&#34;,&#34;#00FF40&#34;,&#34;#00FF40&#34;,&#34;#0040FF&#34;,&#34;#00FF40&#34;,&#34;#00FF40&#34;,&#34;#00FFFF&#34;,&#34;#FF0000&#34;,&#34;#FFBF00&#34;,&#34;#8000FF&#34;,&#34;#FFBF00&#34;,&#34;#FFBF00&#34;,&#34;#00FFFF&#34;,&#34;#FFBF00&#34;,&#34;#FF00BF&#34;,&#34;#00FFFF&#34;,&#34;#FFBF00&#34;,&#34;#FF0000&#34;,&#34;#FF0000&#34;,&#34;#80FF00&#34;,&#34;#FF0000&#34;,&#34;#00FF40&#34;,&#34;#00FFFF&#34;,&#34;#80FF00&#34;,&#34;#FFBF00&#34;,&#34;#8000FF&#34;]],&#34;size&#34;:0.2,&#34;stroke&#34;:&#34;black&#34;,&#34;flipy&#34;:true,&#34;grid&#34;:false,&#34;renderer&#34;:&#34;auto&#34;,&#34;signif&#34;:8,&#34;bg&#34;:&#34;white&#34;,&#34;cexsymbols&#34;:1,&#34;xlim&#34;:[-1,1],&#34;ylim&#34;:[-1,1],&#34;zlim&#34;:[-1,1],&#34;pch&#34;:[&#34;AAPL&#34;,&#34;ABT&#34;,&#34;ACN&#34;,&#34;AIG&#34;,&#34;ALL&#34;,&#34;AMGN&#34;,&#34;AMZN&#34;,&#34;AXP&#34;,&#34;BA&#34;,&#34;BAC&#34;,&#34;BIIB&#34;,&#34;BK&#34;,&#34;BLK&#34;,&#34;BMY&#34;,&#34;BRK.B&#34;,&#34;C&#34;,&#34;CAT&#34;,&#34;CELG&#34;,&#34;CL&#34;,&#34;CMCSA&#34;,&#34;COF&#34;,&#34;COP&#34;,&#34;COST&#34;,&#34;CSCO&#34;,&#34;CVS&#34;,&#34;CVX&#34;,&#34;DD&#34;,&#34;DHR&#34;,&#34;DIS&#34;,&#34;DOW&#34;,&#34;DUK&#34;,&#34;EMR&#34;,&#34;EXC&#34;,&#34;F&#34;,&#34;FB&#34;,&#34;FDX&#34;,&#34;FOX&#34;,&#34;FOXA&#34;,&#34;GD&#34;,&#34;GE&#34;,&#34;GILD&#34;,&#34;GM&#34;,&#34;GOOG&#34;,&#34;GOOGL&#34;,&#34;GS&#34;,&#34;HAL&#34;,&#34;HD&#34;,&#34;HON&#34;,&#34;IBM&#34;,&#34;INTC&#34;,&#34;JNJ&#34;,&#34;JPM&#34;,&#34;KMI&#34;,&#34;KO&#34;,&#34;LLY&#34;,&#34;LOW&#34;,&#34;MA&#34;,&#34;MCD&#34;,&#34;MET&#34;,&#34;MMM&#34;,&#34;MO&#34;,&#34;MON&#34;,&#34;MRK&#34;,&#34;MS&#34;,&#34;MSFT&#34;,&#34;NEE&#34;,&#34;NKE&#34;,&#34;ORCL&#34;,&#34;OXY&#34;,&#34;PCLN&#34;,&#34;PEP&#34;,&#34;PFE&#34;,&#34;PG&#34;,&#34;PM&#34;,&#34;QCOM&#34;,&#34;RTN&#34;,&#34;SBUX&#34;,&#34;SLB&#34;,&#34;SO&#34;,&#34;SPG&#34;,&#34;T&#34;,&#34;TGT&#34;,&#34;TWX&#34;,&#34;TXN&#34;,&#34;UNH&#34;,&#34;UNP&#34;,&#34;UPS&#34;,&#34;USB&#34;,&#34;UTX&#34;,&#34;V&#34;,&#34;VZ&#34;,&#34;WFC&#34;,&#34;WMT&#34;,&#34;XOM&#34;],&#34;from&#34;:[[0,0,0,0,0,0,0,0,1,1,1,1,1,1,1,1,1,2,2,2,2,2,2,2,3,3,3,3,3,3,3,3,3,3,3,3,3,3,4,4,4,4,4,4,4,4,4,5,5,5,5,5,5,5,5,6,6,6,6,6,6,6,7,7,7,7,7,7,7,7,7,7,7,8,8,8,8,8,8,8,8,8,8,8,8,8,9,9,9,9,9,9,9,9,9,9,9,10,10,10,10,10,10,11,11,11,11,11,11,11,11,11,11,12,12,12,12,12,12,12,12,12,13,13,13,13,13,14,14,14,14,14,14,14,14,14,14,14,15,15,15,15,15,15,15,16,16,17,17,17,17,18,18,18,18,18,18,18,19,19,19,19,20,20,20,20,20,20,21,21,21,21,21,21,22,22,22,22,22,23,23,23,23,23,23,23,24,24,24,24,24,24,25,25,25,25,25,26,26,26,26,26,26,26,26,26,26,26,27,27,27,27,27,27,27,27,27,27,28,28,28,29,29,29,29,29,30,30,30,30,30,30,31,31,31,31,31,31,31,31,31,32,32,32,33,33,33,33,33,33,34,34,34,34,34,35,35,35,35,35,35,36,36,37,38,38,38,38,38,38,39,39,40,40,40,41,41,42,42,43,44,44,44,44,44,45,45,45,45,46,46,46,46,46,47,47,47,47,47,48,48,48,48,48,48,48,49,49,49,49,49,49,50,50,50,50,51,51,51,51,52,52,52,53,53,53,53,53,54,54,55,55,55,55,56,56,56,56,57,57,57,57,58,58,58,59,59,59,59,60,60,60,60,61,62,62,62,62,63,63,64,64,64,64,64,65,65,66,66,67,67,67,67,68,68,69,69,70,70,72,73,74,74,74,75,75,75,77,78,80,81,85,85,86,87]],&#34;to&#34;:[[2,23,48,49,64,67,74,83,5,10,13,17,40,50,54,62,71,23,48,49,59,64,67,83,4,7,9,11,12,14,15,20,44,51,58,63,87,91,7,11,12,14,18,53,70,87,91,10,13,17,40,50,54,62,71,34,42,43,56,69,76,89,9,11,12,15,20,44,51,58,63,87,91,26,27,29,31,35,38,47,59,61,75,85,86,88,11,12,14,15,20,44,51,58,63,87,91,13,17,40,54,71,84,12,14,15,20,44,51,58,63,87,91,14,15,20,44,51,58,63,87,91,17,40,50,71,84,15,18,44,51,53,58,63,70,72,87,91,20,44,51,58,63,87,91,31,83,40,54,62,71,53,57,60,70,72,73,89,28,36,37,82,44,51,58,63,87,91,25,45,52,68,77,93,24,46,55,81,92,48,49,64,67,74,80,83,46,55,66,81,84,92,45,52,68,77,93,27,29,31,38,39,47,59,61,75,85,86,29,31,35,38,47,59,75,85,86,88,36,37,82,31,38,47,61,85,32,33,41,65,78,79,35,38,39,47,59,75,85,86,88,65,78,79,41,46,55,79,81,92,42,43,56,69,89,38,47,75,85,86,88,37,82,82,47,59,75,85,86,88,59,86,54,62,71,79,81,43,69,69,51,58,63,87,91,52,68,77,93,55,66,76,81,92,59,75,85,86,88,49,64,67,74,80,83,90,64,67,74,80,83,90,54,62,71,72,58,63,87,91,68,77,93,57,60,70,72,73,62,71,66,76,81,92,57,69,76,89,60,70,72,73,63,87,91,75,85,86,88,70,72,73,89,89,71,74,80,90,87,91,67,74,80,83,90,78,79,76,84,74,80,83,90,77,93,76,89,72,73,73,89,80,83,90,85,86,88,93,79,90,92,86,88,88,91]],&#34;lwd&#34;:1,&#34;linealpha&#34;:0.5,&#34;center&#34;:true,&#34;main&#34;:[&#34;&#34;],&#34;options&#34;:true,&#34;alpha&#34;:[[1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1]],&#34;vertices&#34;:[[0.99435826,-0.18517922,0.27016006,0.46310306,-0.6845987,0.92797536,0.75298048,0.019898935,0.25485259,0.17296863,-0.48576149,0.37713592,0.31635867,-0.39382867,0.20195847,0.39357401,-0.70224116,0.92521416,0.15618082,-0.29979211,-0.49132011,0.14799075,-0.52003878,0.42759141,-0.047326101,0.855766,-0.018309461,0.23787088,-0.52634344,0.44263582,0.27072708,-0.73901044,0.92066817,0.24939707,-0.44805402,0.3885148,0.28547091,-0.4582017,0.44776476,0.22771722,-0.74618952,0.89503219,0.33184386,-0.3974979,0.26441651,0.10146587,-0.47988207,0.47418627,0.47920665,0.48172673,0.098332213,0.46682555,-0.73666797,0.8716736,0.44591884,-0.2435929,-0.083724264,-0.32834071,0.24872013,-0.75703723,0.11649181,-0.54903517,0.49069722,0.033614675,-0.88120323,-1,-0.58911005,-0.65719304,0.11553562,0.93098793,-0.21248371,0.29722672,-0.4568082,-0.67078647,0.35404278,0.032283929,-0.91790968,-0.83037476,-0.040018615,0.7930879,0.078475013,-0.11563657,0.89878401,-0.031182212,-0.43967858,0.27976747,-0.67444814,-0.064729336,0.78922016,-0.12909993,-0.88300096,-0.59494548,0.39682545,0.034793553,0.83241268,0.070586601,-0.96193802,-0.52958259,0.31409861,-0.70978399,-0.62782263,0.29401669,0.31656398,-0.24743532,-0.58084584,-0.19239341,0.96554072,-0.0061389222,-0.3994254,0.36769528,-0.7857988,-0.49965905,0.23945035,-0.73470881,-0.14985577,0.85891474,0.071671587,0.011409109,0.87870328,0.29579214,0.48277378,-0.75529751,1,-0.82379511,-0.64498419,0.2549568,0.27044719,-0.30440136,-0.68449783,0.31410635,-0.39990667,-0.61817165,0.17608954,-0.48023468,0.5401067,-0.089924603,-0.90886065,-0.94260113,-0.43009607,-0.61622572,0.1479685,-0.12505817,0.93695276,0.043978762,0.97277485,-0.19251592,0.40544854,1,-0.23114637,0.36674268,0.4792984,-0.59294701,0.7079636,0.19719787,-0.58851532,0.46903548,-0.090520908,-1,-0.8967193,0.55004151,-0.28814195,-0.012940899,0.53605226,-0.59584496,0.9036283,-0.46821967,-0.63821157,0.11291664,0.23488173,-0.26842928,-0.35313458,0.52876423,-0.25584505,-0.18584821,0.27011225,-0.5636189,0.51751115,0.098756115,0.71127219,0.13061134,0.61112413,-0.15775248,-0.17084602,0.077302842,0.57973828,-0.21243846,0.69409011,-0.58040032,0.76466432,0.2036897,-0.37950144,0.47109146,0.96059803,-0.32544398,0.37130888,-1,-0.61625086,0.40060929,-0.28151607,-0.67264632,0.22857152,0.92971023,-0.12554655,0.4154447,0.057413422,-0.96027397,-0.89062801,0.19178498,-0.35501392,-0.4618808,0.47900151,-0.30209176,0.0012528252,0.45667885,-0.83127889,0.868696,0.55045092,-0.31867252,0.099941103,0.55264929,-0.10723572,-0.12864382,0.90367356,-0.37207164,0.48815237,-0.030850668,0.99007015,0.035684545,-0.11764282,-0.48439,-0.14617896,-0.027951798,-0.94151224,-0.84732979,-0.9413136,-0.63878196,0.53304791,-0.85021553,-0.5489049,0.46772456,0.92404712,-0.36594974,0.55478319,-0.64770157,-0.63916066,0.18994941,-0.44471347,0.22155795,-0.848248,0.87859166,-0.014521476,0.30073867,-0.13828589,-0.77190768,0.67428421,-0.10623841,0.89079742,0.14207471,-0.046086419,0.99517338,0.10773409,0.18273265,-0.37085274,0.36167704,-0.14001989,1,0.14884917,0.33036303,-0.042606931,-0.34845295,0.99864786,-0.42016859,0.57269573,0.12937751,-0.48833,0.3387481,-0.57765168,-0.82602171,0.19780566,0.11230442,-0.86699388,-0.91950212]],&#34;xticklab&#34;:[&#34;-1.00&#34;,&#34;-0.60&#34;,&#34;-0.20&#34;,&#34;0.20&#34;,&#34;0.60&#34;,&#34;1.00&#34;],&#34;yticklab&#34;:[&#34;-1.00&#34;,&#34;-0.60&#34;,&#34;-0.20&#34;,&#34;0.20&#34;,&#34;0.60&#34;,&#34;1.00&#34;],&#34;zticklab&#34;:[&#34;1.00&#34;,&#34;0.60&#34;,&#34;0.20&#34;,&#34;-0.20&#34;,&#34;-0.60&#34;,&#34;-1.00&#34;],&#34;xtick&#34;:[0,0.2,0.4,0.6,0.8,1],&#34;ytick&#34;:[0,0.2,0.4,0.6,0.8,1],&#34;ztick&#34;:[0,0.2,0.4,0.6,0.8,1]},&#34;evals&#34;:[],&#34;jsHooks&#34;:[]}&lt;/script&gt;
&lt;p&gt;The stock groups identified by this method are uncanny, but hardly all that surprising really. Look closely and you will see clusters made up of bank-like companies (AIG, BAC, BK, C, COF, GS, JPM, MET, MS, USB, WFC), pharmaceutical companies (ABT, AMGN, BIIB, BMY, CELG, GILD, JNJ, LLY, MRK, PFE), computer/technology-driven companies (AAPL, ACN, CSCO, IBM, INTC, MSFT, ORCL, QCOM, T, TXN, VZ, and so on. With the threshold value of 0.9 above, a few stocks aren’t connected to any others – they appear in gray.&lt;/p&gt;
&lt;p&gt;The groups more or less correspond to what we already know!&lt;/p&gt;
&lt;p&gt;The FB, GOOG, AMZN, PCLN (Facebook, Alphabet/Google, Amazon, Priceline) group is interesting–it includes credit card companies V (Visa), MA (Mastercard). Perhaps the returns of FB, GOOG and AMZN are more closely connected to consumer spending than technology!&lt;/p&gt;
&lt;p&gt;This way of looking at things also nicely highlights connections between groups. For instance, the pharma group is connected to consumer products group through JNJ and PG (Johnson and Johnson and Proctor and Gamble). See the appendix below for a visualization that explores different precision matrix threshold values, including lower values with far greater network connectivity.&lt;/p&gt;
&lt;/div&gt;
&lt;div id=&#34;review&#34; class=&#34;section level1&#34;&gt;
&lt;h1&gt;Review&lt;/h1&gt;
&lt;p&gt;We downloaded daily closing stock prices for 100 stocks from the S&amp;amp;P 500, and, using basic tools of statistics and analysis like correlation and regularization, we grouped the stocks together in a network that highlights associations within and between the groups. The structure teased out of the stock price data is reasonably intuitive.&lt;/p&gt;
&lt;hr/&gt;
&lt;/div&gt;
&lt;div id=&#34;appendix-threejs-tricks&#34; class=&#34;section level1&#34;&gt;
&lt;h1&gt;Appendix: threejs tricks&lt;/h1&gt;
&lt;p&gt;The following self-contained example shows how the network changes with threshold value. It performs the same steps as we did above, but uses some tricks in threejs and an experimental extension to the crosstalk package and a few additional R packages to present an interactive animation. Enjoy!&lt;/p&gt;
&lt;pre class=&#34;r&#34;&gt;&lt;code&gt;suppressMessages({
library(quantmod)
library(igraph)
library(threejs)
library(crosstalk)
library(htmltools)
# using an experimental extension to crosstalk:
library(crosstool) # devtools::install_github(&amp;#39;bwlewis/crosstool&amp;#39;)
})

# Download the processed log(returns) data:
suppressMessages(load(url(&amp;quot;http://illposed.net/logreturns.rdata&amp;quot;)))

X = cor(log_returns)
L = eigen(X, symmetric=TRUE)
N = 10  # (use 1st 10 eigenvectors, set N larger to reduce regularization)
P = L$vectors[, 1:N] %*% ((1 / L$values[1:N]) * t(L$vectors[, 1:N]))
P = P / tcrossprod(sqrt(diag(P)))
colnames(P) = colnames(X)

# A function that creates a network for a given threshold and precision matrix
f = function(threshold, P)
{
  Q = P * (P &amp;gt; quantile(P, probs=threshold))                           # thresholded precision matrix
  g = graph.adjacency(Q, mode=&amp;quot;undirected&amp;quot;, weighted=TRUE, diag=FALSE) # ...expressed as a graph

  x = groups(cluster_louvain(g))
  i = unlist(lapply(x, length))
  d = order(i, decreasing=TRUE)
  x = x[d]
  i = i[d]
  j = i &amp;gt; 1
  s = sum(j)
  names(x)[j] = seq(1, s)
  names(x)[! j] = s + 1
  grp = as.integer(rep(names(x), i))
  clrs = c(rainbow(s), &amp;quot;gray&amp;quot;)[grp[order(unlist(x))]]
  g = set_vertex_attr(g, &amp;quot;color&amp;quot;, value=clrs)
  set_vertex_attr(g, &amp;quot;shape&amp;quot;, value=colnames(P))
}

threshold = c(0.97, 0.95, 0.90, 0.85, 0.8)
g = Map(f, threshold, MoreArgs=list(P=P)) # list of graphs, one for each threshold

# Compute force-directed network layouts for each threshold value
# A bit expensive to compute, so run in parallel!
library(parallel)
l = mcMap(function(x) layout_with_fr(x, dim=3, niter=150), g, mc.cores=detectCores())

sdf = SharedData$new(data.frame(key=paste(seq(0, length(threshold) - 1))), key=~key)
slider = crosstool(sdf, &amp;quot;transmitter&amp;quot;,
                sprintf(&amp;quot;&amp;lt;input type=&amp;#39;range&amp;#39; min=&amp;#39;0&amp;#39; max=&amp;#39;%d&amp;#39; value=&amp;#39;0&amp;#39;/&amp;gt;&amp;quot;,
                length(threshold) - 1), width=&amp;quot;100%&amp;quot;, height=20, channel=&amp;quot;filter&amp;quot;)
vis = graphjs(g, l, vertex.size=0.2, main=as.list(threshold), defer=TRUE, edge.alpha=0.5, deferfps=30,
        crosstalk=sdf, width=&amp;quot;100%&amp;quot;, height=900)

browsable(div(list(HTML(&amp;quot;&amp;lt;center&amp;gt;&amp;quot;), tags$h3(&amp;quot;Precision matrix quantile threshold (adjust slider to change)&amp;quot;), slider, vis)))&lt;/code&gt;&lt;/pre&gt;
&lt;p&gt;&lt;div&gt;
&lt;center&gt;
&lt;h3&gt;Precision matrix quantile threshold (adjust slider to change)&lt;/h3&gt;
&lt;div id=&#34;htmlwidget-2&#34; style=&#34;width:100%;height:20px;&#34; class=&#34;transmitter html-widget&#34;&gt;&lt;/div&gt;
&lt;script type=&#34;application/json&#34; data-for=&#34;htmlwidget-2&#34;&gt;{&#34;x&#34;:{&#34;innerHTML&#34;:&#34;&lt;input type=&#39;range&#39; min=&#39;0&#39; max=&#39;4&#39; value=&#39;0&#39;/&gt;&#34;,&#34;value&#34;:&#34;value&#34;,&#34;channel&#34;:&#34;filter&#34;,&#34;crosstalk_key&#34;:[&#34;0&#34;,&#34;1&#34;,&#34;2&#34;,&#34;3&#34;,&#34;4&#34;],&#34;crosstalk_group&#34;:&#34;SharedDatafe99d0a2&#34;,&#34;crosstalk_group2&#34;:&#34;SharedDatafe99d0a2&#34;},&#34;evals&#34;:[],&#34;jsHooks&#34;:[]}&lt;/script&gt;
&lt;div id=&#34;htmlwidget-3&#34; style=&#34;width:100%;height:900px;&#34; class=&#34;scatterplotThree html-widget&#34;&gt;&lt;/div&gt;
&lt;script type=&#34;application/json&#34; data-for=&#34;htmlwidget-3&#34;&gt;{&#34;x&#34;:{&#34;NROW&#34;:94,&#34;height&#34;:null,&#34;width&#34;:null,&#34;axis&#34;:false,&#34;numticks&#34;:[6,6,6],&#34;xticklabs&#34;:null,&#34;yticklabs&#34;:null,&#34;zticklabs&#34;:null,&#34;color&#34;:[[&#34;#BEBEBE&#34;,&#34;#00FFFF&#34;,&#34;#BEBEBE&#34;,&#34;#BEBEBE&#34;,&#34;#BEBEBE&#34;,&#34;#00FF24&#34;,&#34;#BEBEBE&#34;,&#34;#BEBEBE&#34;,&#34;#FF6D00&#34;,&#34;#FF0000&#34;,&#34;#00FF24&#34;,&#34;#FF0000&#34;,&#34;#BEBEBE&#34;,&#34;#BEBEBE&#34;,&#34;#BEBEBE&#34;,&#34;#FF0000&#34;,&#34;#BEBEBE&#34;,&#34;#00FF24&#34;,&#34;#49FF00&#34;,&#34;#BEBEBE&#34;,&#34;#BEBEBE&#34;,&#34;#FFDB00&#34;,&#34;#0024FF&#34;,&#34;#B6FF00&#34;,&#34;#BEBEBE&#34;,&#34;#FFDB00&#34;,&#34;#BEBEBE&#34;,&#34;#FF6D00&#34;,&#34;#00FF92&#34;,&#34;#BEBEBE&#34;,&#34;#BEBEBE&#34;,&#34;#BEBEBE&#34;,&#34;#0092FF&#34;,&#34;#BEBEBE&#34;,&#34;#BEBEBE&#34;,&#34;#BEBEBE&#34;,&#34;#00FF92&#34;,&#34;#00FF92&#34;,&#34;#FF6D00&#34;,&#34;#BEBEBE&#34;,&#34;#00FF24&#34;,&#34;#BEBEBE&#34;,&#34;#4900FF&#34;,&#34;#4900FF&#34;,&#34;#FF0000&#34;,&#34;#FFDB00&#34;,&#34;#B600FF&#34;,&#34;#FF6D00&#34;,&#34;#B6FF00&#34;,&#34;#B6FF00&#34;,&#34;#BEBEBE&#34;,&#34;#FF0000&#34;,&#34;#BEBEBE&#34;,&#34;#49FF00&#34;,&#34;#00FFFF&#34;,&#34;#B600FF&#34;,&#34;#FF00DB&#34;,&#34;#BEBEBE&#34;,&#34;#FF0000&#34;,&#34;#BEBEBE&#34;,&#34;#49FF00&#34;,&#34;#BEBEBE&#34;,&#34;#BEBEBE&#34;,&#34;#FF0000&#34;,&#34;#BEBEBE&#34;,&#34;#0092FF&#34;,&#34;#BEBEBE&#34;,&#34;#B6FF00&#34;,&#34;#FFDB00&#34;,&#34;#BEBEBE&#34;,&#34;#49FF00&#34;,&#34;#00FFFF&#34;,&#34;#BEBEBE&#34;,&#34;#49FF00&#34;,&#34;#BEBEBE&#34;,&#34;#FF6D00&#34;,&#34;#BEBEBE&#34;,&#34;#FFDB00&#34;,&#34;#0092FF&#34;,&#34;#BEBEBE&#34;,&#34;#FF006D&#34;,&#34;#0024FF&#34;,&#34;#00FF92&#34;,&#34;#B6FF00&#34;,&#34;#BEBEBE&#34;,&#34;#FF6D00&#34;,&#34;#FF6D00&#34;,&#34;#FF0000&#34;,&#34;#FF6D00&#34;,&#34;#FF00DB&#34;,&#34;#FF006D&#34;,&#34;#FF0000&#34;,&#34;#0024FF&#34;,&#34;#FFDB00&#34;]],&#34;size&#34;:0.2,&#34;stroke&#34;:&#34;black&#34;,&#34;flipy&#34;:true,&#34;grid&#34;:false,&#34;renderer&#34;:&#34;auto&#34;,&#34;signif&#34;:8,&#34;bg&#34;:&#34;white&#34;,&#34;cexsymbols&#34;:1,&#34;xlim&#34;:[-1,1],&#34;ylim&#34;:[-1,1],&#34;zlim&#34;:[-1,1],&#34;pch&#34;:[&#34;AAPL&#34;,&#34;ABT&#34;,&#34;ACN&#34;,&#34;AIG&#34;,&#34;ALL&#34;,&#34;AMGN&#34;,&#34;AMZN&#34;,&#34;AXP&#34;,&#34;BA&#34;,&#34;BAC&#34;,&#34;BIIB&#34;,&#34;BK&#34;,&#34;BLK&#34;,&#34;BMY&#34;,&#34;BRK.B&#34;,&#34;C&#34;,&#34;CAT&#34;,&#34;CELG&#34;,&#34;CL&#34;,&#34;CMCSA&#34;,&#34;COF&#34;,&#34;COP&#34;,&#34;COST&#34;,&#34;CSCO&#34;,&#34;CVS&#34;,&#34;CVX&#34;,&#34;DD&#34;,&#34;DHR&#34;,&#34;DIS&#34;,&#34;DOW&#34;,&#34;DUK&#34;,&#34;EMR&#34;,&#34;EXC&#34;,&#34;F&#34;,&#34;FB&#34;,&#34;FDX&#34;,&#34;FOX&#34;,&#34;FOXA&#34;,&#34;GD&#34;,&#34;GE&#34;,&#34;GILD&#34;,&#34;GM&#34;,&#34;GOOG&#34;,&#34;GOOGL&#34;,&#34;GS&#34;,&#34;HAL&#34;,&#34;HD&#34;,&#34;HON&#34;,&#34;IBM&#34;,&#34;INTC&#34;,&#34;JNJ&#34;,&#34;JPM&#34;,&#34;KMI&#34;,&#34;KO&#34;,&#34;LLY&#34;,&#34;LOW&#34;,&#34;MA&#34;,&#34;MCD&#34;,&#34;MET&#34;,&#34;MMM&#34;,&#34;MO&#34;,&#34;MON&#34;,&#34;MRK&#34;,&#34;MS&#34;,&#34;MSFT&#34;,&#34;NEE&#34;,&#34;NKE&#34;,&#34;ORCL&#34;,&#34;OXY&#34;,&#34;PCLN&#34;,&#34;PEP&#34;,&#34;PFE&#34;,&#34;PG&#34;,&#34;PM&#34;,&#34;QCOM&#34;,&#34;RTN&#34;,&#34;SBUX&#34;,&#34;SLB&#34;,&#34;SO&#34;,&#34;SPG&#34;,&#34;T&#34;,&#34;TGT&#34;,&#34;TWX&#34;,&#34;TXN&#34;,&#34;UNH&#34;,&#34;UNP&#34;,&#34;UPS&#34;,&#34;USB&#34;,&#34;UTX&#34;,&#34;V&#34;,&#34;VZ&#34;,&#34;WFC&#34;,&#34;WMT&#34;,&#34;XOM&#34;],&#34;from&#34;:[[1,5,5,5,8,8,9,9,9,9,9,9,9,9,10,10,11,11,15,15,15,15,15,17,18,18,18,21,21,21,21,21,22,22,23,23,23,25,27,27,28,28,32,32,36,36,37,38,38,38,38,42,44,44,44,44,45,45,46,47,47,47,48,48,49,51,51,51,53,53,53,54,56,60,60,63,63,65,67,68,70,75,80,81,86,87]],&#34;to&#34;:[[71,10,17,40,38,47,11,15,44,51,58,63,87,91,17,40,51,87,44,51,63,87,91,40,53,60,70,25,45,68,77,93,81,92,48,67,83,93,38,47,36,37,65,78,37,82,82,47,75,86,88,43,51,63,87,91,68,77,55,75,85,88,49,67,67,63,87,91,60,70,73,71,89,70,73,87,91,78,83,77,73,86,90,92,88,91]],&#34;lwd&#34;:1,&#34;linealpha&#34;:0.5,&#34;center&#34;:true,&#34;main&#34;:[0.97,0.95,0.9,0.85,0.8],&#34;defer&#34;:{&#34;vertices&#34;:[[-0.083756874,-1,-1,-0.33193237,0.65896192,-0.33462375,0.0096707596,-0.96759652,-0.84339247,-0.39491718,-0.41929575,-0.49189299,0.50987879,-0.46153034,0.25408287,-0.48342594,-0.031117573,0.067823284,0.52322845,-0.0097745858,-0.44432355,0.5172261,0.36887232,-0.33947207,-0.26453272,-0.49680054,0.41740054,-0.59137677,0.1426698,0.93899703,-0.45717261,-0.037827692,-0.038347319,-0.56771021,0.15991127,0.78530781,0.40135361,-0.30204938,-0.46331872,0.81395512,0.28902531,-0.19023344,-0.00013346484,-0.51813993,-0.47397787,-0.78854768,0.16241969,0.88765227,-0.28875332,0.10665586,-0.3669419,-0.60974348,-0.03431126,-0.0045589152,0.65555212,-0.15966689,0.83816434,0.47689396,0.58696671,0.22606262,0.67968406,-0.051663567,-0.21914243,-0.81564367,0.3268111,-0.19217847,-0.9372025,-0.27764425,0.18271458,0.12266908,0.32554487,0.87621059,-0.055723204,-0.16165957,-0.48401914,-0.66168606,0.34186115,-0.28298988,0.70999933,0.7252045,0.11241263,-0.214983,-0.50962755,0.65602303,-0.95097409,0.50381866,0.46347676,0.90494463,0.22874719,0.15583371,0.89089658,-0.0015200295,0.14189409,0.36082772,0.58315832,0.60306553,0.84680781,-0.24688717,0.13290201,0.84404613,0.33039334,0.56892104,0.79293173,-0.29607883,0.48196394,0.54329474,0.70497988,0.73633538,-0.98766591,0.49951256,0.33953809,-0.85575316,0.51079779,0.36702661,-0.10547412,-0.51073799,0.52551814,0.719118,0.69562464,0.49594976,-0.53221647,-0.11847456,0.024336579,-0.52922962,0.82740432,0.27252236,-0.24690065,-0.60124972,-0.12863172,-0.36481925,-0.58287999,-0.19633625,-0.76559397,0.1637044,0.97106114,-0.87865218,0.34500031,-0.07634441,-0.27505681,0.87630528,0.016039001,-0.22343293,-0.4939272,0.53764224,-0.019561316,0.34179128,0.79566277,-0.075037083,0.37582269,0.68033287,0.90324636,0.51838321,0.1224127,-0.68420191,0.16139919,0.88267825,0.71865992,0.081063093,0.49566018,0.57064316,-0.19992546,0.81235123,-0.58480953,0.70082009,-0.19043758,-0.18630364,0.87474672,-0.07598433,0.37616422,-0.42805688,-0.15187929,0.38819008,0.87377858,0.029032726,-0.37815971,0.033229865,0.9513037,0.36155228,0.90100371,0.37480731,0.47353227,-0.17203459,0.86558091,0.18212402,0.70833847,-0.26524121,0.082196942,0.84610805,0.58372459,-0.66720407,0.17588241,1,1,0.074628513,-0.098637032,0.79765763,-0.23155687,0.23807418,-0.2965246,0.77939115,0.65168405,0.093634887,0.34223716,0.74164117,-0.99246744,0.30497849,-0.095777432,0.087655791,0.48475836,-0.52009561,0.54105337,-0.12231407,0.76980373,-0.46956202,0.67006717,-0.27255805,0.42526566,0.62421597,-0.33613309,0.43148749,-0.20862259,0.75056717,0.10246196,1,0.14877759,-0.0095979434,-0.52395947,0.59613473,-0.15176462,0.9368179,0.38740995,-0.95259418,0.29037993,-0.17559448,0.92958003,-0.18166612,0.21690782,-0.031431568,0.28093375,-0.69300415,0.043424645,0.15189207,-0.53721695,-1,-0.24216711,0.27407577,-0.8797843,0.51064178,0.24448582,0.25054541,0.31845891,0.81199533,0.72214751,0.54497611,-0.22160546,-0.45029238,-0.45899454,0.55437481,0.07809239,-0.53704013,0.49219656,-0.65278471,0.2232103,0.87309214,-0.065016291,-0.53628966,0.42558831,0.28163512,-0.47975048,-0.073220636,0.1756893,0.15383767,-0.48871923,-0.73039227,0.24517354,0.93223765,-0.8619314,-0.27752725,0.2844637,-0.73710826,0.25955476,-0.32797016],[0.73919769,-0.30596899,0.59834348,-0.70678838,0.19659466,-0.64313837,0.26534468,-0.24149075,1,-0.65130218,-0.47902757,0.64332343,0.50949762,-0.19064893,-0.74953059,-0.85786915,0.02406967,-0.40553526,0.67110947,0.18122774,-0.29257523,-0.11171521,-0.84566246,-1,-0.34905863,0.085477451,0.13740591,-0.7820176,-0.45813377,0.5352464,-1,-0.064726381,-0.35056446,-0.67369753,-0.43230329,0.59915373,-0.48372482,-0.46286841,0.65330047,0.25412436,-0.62700489,-0.91759974,-0.43721116,-0.42466279,0.79581844,-0.71365125,-0.4668363,0.46463085,0.90353266,-0.36309681,0.02492799,-0.93732872,-0.042416201,-0.25516789,0.55249918,-0.98974174,-0.13492361,0.088585912,0.17359704,-0.88517069,-0.85783275,-0.46325542,0.38641513,0.0082816113,-0.94941398,-0.49483781,0.088926592,0.6682804,0.7200672,0.3307044,-0.22054968,0.87910335,1,0.34319883,0.29923785,-0.13216963,-0.95245955,-0.39309138,0.082195174,0.94233053,0.015137239,-0.17632862,0.099481169,0.21699646,-0.012213514,0.17165303,-0.79881106,0.2000125,0.9452973,-0.049258047,-0.24290279,0.98821517,-0.26156315,-0.50049626,0.12024956,0.37885328,-0.54604176,0.86811718,-0.33489173,0.67299188,-0.34113964,-0.40294521,0.72536362,0.22101533,-0.4210859,-0.19857932,0.097893242,0.3614796,-0.10196563,0.14908343,-0.88386483,-0.0072176265,0.16054664,-0.93831649,-0.23815903,0.084407012,0.26593743,0.47517914,0.96450139,-0.20178385,-0.8919706,-0.14458301,-0.31618497,0.79278813,-0.35359064,-0.47039809,0.72785287,0.35367415,0.64288024,0.78359111,0.37610246,0.52943424,-0.84085633,-0.48055818,0.57974833,0.013903647,-0.98351681,-0.60752221,0.19629684,0.58850719,0.84268815,-0.34610181,0.10737543,0.21327681,0.44006497,-0.26181113,0.88661124,0.52212591,-0.23848896,0.80332959,0.41357112,0.93875296,0.38111072,-0.87385323,-0.42372178,0.49350352,0.65907469,0.72546939,0.10611872,0.39231105,-0.97907269,-0.14162412,-0.70995807,0.17585318,-0.50282133,0.26013634,0.62184758,0.73073578,0.7599042,0.17294995,0.16697956,0.66560914,0.71549334,-0.31578685,-0.77378758,-0.48819779,0.62993234,-0.17645243,0.11325855,-0.14370994,0.37933971,-0.97882386,-0.038592486,0.95474747,0.42059767,-0.094588102,-0.56658662,0.22275796,-0.61216449,-0.69854048,-0.42910675,0.52092588,0.57721435,-0.32394156,0.71514054,-0.59777952,0.87095197,-0.43787749,-0.012113965,0.93869665,-0.53004986,0.41936431,-0.25543179,0.7537221,-0.10417944,-0.92019468,-0.54450173,0.64932002,0.096879443,-0.41937197,0.48364639,-0.95862299,-0.12932588,-0.82563428,0.18457221,-0.52569326,0.47737795,-0.99018172,0.0047683114,0.49912661,-0.88757633,-0.053602641,0.82757523,0.55353315,-0.44467326,-0.24050917,0.085845037,0.078079753,0.061460648,0.94796535,-0.42063035,-0.060503013,-1,-0.44342054,-0.4575855,0.85925486,-0.4549039,0.38958576,0.60783665,-0.71096254,-0.60858395,0.94964685,0.20877471,-0.030251023,0.76018323,0.61034488,0.0077857639,0.052830287,-0.85314965,0.41803393,-0.12018081,0.81708845,0.36002599,0.94533,-0.52240058,-0.33780572,0.12208383,0.31887938,-0.26128337,0.15448296,0.19539403,-0.79980938,-0.39477175,0.45133674,-0.32181128,0.017604248,0.25960878,0.879686,0.099006088,0.13843197,-0.51179911,1,0.2971215,-0.77194506,-0.55415923,0.48043833,-0.053954356,0.76552024,0.72945885,-0.14786358,-0.85249512,-0.45444209],[0.32238601,0.74845331,0.68164812,0.31690224,0.67047337,-0.27217508,0.1006646,0.6769327,0.66115629,0.1364207,-0.88294148,-0.094025425,-0.012006868,-0.6921301,-0.19196444,0.42209944,0.6719605,-0.29519442,-0.7743261,-0.036177852,-0.34985437,0.20847671,-0.89082979,-0.026698948,-0.46150079,0.22439841,0.85596128,-0.0034623602,-0.89592457,0.067785636,0.33729048,0.67943563,-0.51729829,-0.0039878934,-0.88823896,-0.056255804,0.085058944,-0.88063118,-0.059009851,0.25948522,0.61096104,-0.47209558,-0.033607058,-0.70159312,-0.079456739,0.11313488,-0.92572885,0.041609998,-0.09148819,0.41368687,0.67887697,0.45028102,0.72605835,-0.37962859,-0.23357055,-0.35862452,-0.11658074,1,-0.31139209,0.33934443,0.13780344,-0.93955975,0.11000514,0.81578995,-0.024358514,-0.7342156,-0.38697548,0.45037438,-1,0.20787929,0.75873822,0.54284435,-0.27007254,0.45321986,-0.90730758,0.94197114,-0.018594303,-0.79709528,-0.57052347,0.22395549,0.73681533,-0.57580404,0.26165293,0.91073548,0.97511437,-0.3178364,0.23519102,-0.6191415,0.1324015,0.83751692,-0.73123188,0.83166834,-0.51936655,-0.4168933,0.29770511,0.77761963,-0.85835445,0.89722805,-0.38193684,-0.61681826,0.63229037,-0.7728453,-0.84493622,-0.083286415,-0.18073959,-0.50936917,0.2955393,1,0.84421526,-0.2923455,0.35648037,0.87491399,-0.35205466,0.2726977,-0.42564888,0.2629897,0.94340495,-0.58021546,0.346357,0.57550548,0.3763265,0.76768312,-0.41765657,-0.69720119,0.75352375,-0.76206222,-1,-0.067218404,-0.30618978,-0.9580744,-0.15426325,-0.29054662,0.083505858,-0.85778176,0.063313044,0.81594914,-0.049210637,-0.80468826,-0.49821794,0.39083012,-0.80795963,-0.52318644,0.32602561,0.89111265,0.19762965,0.81988549,0.54636536,0.31339995,0.77960991,0.56125159,0.2351816,0.45591481,-0.26271694,-0.01853538,-0.96200536,-0.0025860172,0.84862423,-0.054258067,-0.63508932,-0.13582489,-0.38952456,-0.18061388,0.3927306,0.76456305,-0.28215652,-0.42626965,0.41407336,-0.81377868,-0.60072022,-0.076188291,-0.33101816,-0.28115753,-0.27797172,-0.32792068,0.036823972,-0.99735722,0.04556002,-0.35209253,0.35918252,0.76529431,-0.32181323,-0.28884434,-0.22752857,-0.60370904,0.037572108,0.50888367,0.36683695,0.75327992,-0.055817241,0.13138184,-1,-0.00011181188,0.37731299,0.76311398,0.57872383,-0.72887581,0.96435107,-0.38672813,-0.29909169,0.3361939,-0.73988045,0.27825777,0.85410355,0.54729124,0.87345246,0.065507372,-0.816642,-0.79433578,-0.00060735828,-0.28393815,-0.18232154,-0.44222288,-0.23197076,0.28377372,0.7408029,-0.32641138,-0.080394287,-0.20532533,-0.21031787,-0.31461256,-0.28509189,-0.14805029,0.36327452,0.77733309,0.42704856,-0.48762325,0.32137448,0.81821241,-0.57028298,0.18328348,-0.57449878,0.96906673,-0.080286668,-0.72944206,-0.80513941,1,-0.46604914,-0.75761788,0.8859979,-0.59115496,0.29968584,0.84205498,0.33506512,-0.50115236,0.55178241,-0.92544808,0.91430518,-0.37750785,0.41627824,0.22432333,0.643879,0.61786382,0.035966311,0.53747,-0.73881543,-0.47877913,0.16603984,0.90987607,-0.56683665,0.34467416,0.80489907,0.10239332,-0.80639258,-0.031130916,-0.41029435,0.37837333,0.91532357,-0.58495175,-0.13099499,-0.083833298,0.39994687,0.8647988,0.34219904,0.036318178,-0.95843763,-0.10861079,-0.50730571,0.43948098,-0.96446143,0.9279595,0.03588929,-0.65327385],[0.078585607,-0.3951495,-0.4608002,0.072547668,0.86794811,-0.44652788,-0.029305853,-0.064566378,-0.2386658,0.33448664,-0.18240112,0.93358008,0.1676283,0.041668477,0.63408778,-0.1505072,0.96735024,-0.35485161,0.57116808,-0.68377057,0.049557722,0.22180233,-0.13558043,0.67367416,-0.65991769,0.06672198,-0.012828537,0.44972619,-0.096835326,0.93810166,-0.1718223,0.82491466,-0.28614894,0.34653645,0.11500294,0.92248214,0.27853962,-0.12469611,0.86200071,-0.16139382,0.59219696,-0.16729654,0.23317243,0.093929536,0.71933994,0.20376453,-0.14371569,0.96403507,-0.28167723,-0.12087459,-0.22714931,-0.019033996,1,-0.3660045,0.023146225,0.25254454,0.25605691,0.45891787,-0.64901636,-0.92769444,0.37141296,-0.11370413,0.99727458,-0.95024216,0.81423737,0.33105609,1,0.044734476,-0.069496049,-0.11592648,-0.24485072,-0.48060421,0.62341333,0.24911581,-0.10082843,-0.79431925,0.80670946,0.41012757,-0.34883584,0.093865128,0.0728508,-0.56282789,0.18697909,-0.069026179,0.60494509,-0.89587547,-1,-0.57025564,0.18955231,0.088463139,0.010520718,-0.32719998,0.15045487,-0.57218584,-0.14178111,-0.14044708,0.10283526,-0.36095048,0.39180408,0.46523265,-0.059376028,-0.021167711,0.49027951,-0.6998677,0.15381754,-0.41033858,-0.11662568,0.11716855,0.52782161,-1,-0.97277381,0.35036947,-0.79002077,-0.76154192,-0.61396355,0.074874226,-0.10277375,-0.3613248,0.081136059,-0.13328771,-0.026527983,0.99842597,-0.29856673,0.19331869,-0.25472658,-0.015795804,0.53759471,-0.76267718,-0.14890969,0.44182734,-0.69344113,-0.10762606,0.24223058,-0.065199336,0.98670691,-0.85584072,0.57435992,0.20861008,0.91787576,-0.11841292,-0.039864506,-0.68565578,-0.085351498,-0.018013448,-0.15826176,-0.17136211,-0.51931376,0.0094754529,-0.11718082,-0.56102469,0.044347209,0.74622092,-0.14654683,0.30319089,0.067981049,1,-0.45433154,0.36203712,0.29337021,0.10519209,0.13201228,0.39031922,-0.076916685,0.84674864,-0.44874782,0.87368629,-0.0058863276,-0.027121365,0.22766335,-0.21800139,0.12453618,0.36080625,0.11897835,0.13222356,0.43223526,0.027201952,0.98870076,-0.50318145,-0.056425383,-0.20706031,0.11373123,0.16241735,0.24303787,-0.21747744,-0.046178114,0.033033747,0.040936084,0.54799976,-0.50072203,0.22747938,0.072097021,0.93353074,0.1851732,-0.38194204,-0.46966076,0.10593473,-0.56603733,0.32668797,0.64364232,-0.15594735,0.031911686,-0.090729809,-0.056110856,-0.54133268,-1,0.67014239,0.34616528,0.66682177,-0.68335961,0.078537543,0.15419981,0.22255966,0.28378416,0.13973244,0.89839548,-0.35254879,-0.0023535484,0.40663687,0.30366069,0.056529421,0.059170188,0.32545795,0.096499508,-0.087053829,-0.45091402,-0.67221206,0.12264762,-0.065840108,0.73792789,-0.3492803,0.030048273,-0.89585721,0.56381305,0.32366498,0.29797632,-0.57898191,0.35676441,0.32528176,-0.3530778,0.12145888,0.10978685,-0.18460001,-0.67945125,0.79234374,-0.16419127,-0.15590848,0.50819082,-0.70299705,-0.72535907,-0.21210941,-0.19956551,-0.43701712,-0.056140026,0.31188049,0.03234417,-0.50662725,-0.09590651,-0.023522591,-0.76669137,-0.080522158,-0.079762308,0.16026645,0.015082066,0.97281821,-0.57647921,-0.14947725,-0.086949597,0.24130996,-0.16116492,0.19294444,0.27188755,-0.04284173,-0.57568829,0.43159463,0.03679493,0.91213508,0.79473689,-0.056132643,-0.19744252,-0.71005396,0.75421617,0.27854037],[-0.30128812,-0.54648562,-0.38714672,-0.7196483,-0.94230857,-0.14488305,-0.57195509,-0.20777012,-0.11478971,0.78324655,0.36798825,0.76298994,0.38257931,0.40942572,0.59258707,-1,-0.92400222,0.10804194,0.62394904,-0.11930524,0.10015699,0.7375987,0.45082234,0.55560505,-0.65179078,0.45818007,0.070316174,0.90355548,0.60401819,0.93077216,-0.73393845,-0.76844962,0.15783796,0.55958938,0.50069385,0.8527866,0.69846595,0.63746192,0.6928328,-0.58389262,-0.2953185,0.10914283,0.39510725,0.38655294,0.74950153,1,0.6285711,0.8240784,-0.3330836,0.20122371,-0.30733417,-0.73543717,-1,0.099855778,-0.12518949,0.038964205,0.39090548,0.29730962,-0.62453495,-0.93102548,0.89518618,0.56058969,0.67799203,0.15448312,0.99469621,-0.46221651,0.54555723,-0.47335508,-0.33766298,-0.74038429,-0.25245835,-0.47942591,0.073970529,-0.60107875,-0.078527242,0.13796533,1,-0.24445152,-0.29341271,0.36993747,0.10424959,-0.50467701,0.20539653,0.05147214,0.73585687,-0.45032703,-0.79499585,-0.13699304,0.43869131,-0.062596103,0.3766088,0.29946155,0.04999459,-0.55994431,0.4954068,-0.18496457,0.74200065,0.3990086,0.27495131,0.63250317,0.03280726,-0.19037162,0.45811857,-0.30017405,0.22090224,-0.066451665,0.4943412,0.11514911,0.41500945,-0.39840016,-0.88502002,0.62930175,-0.39478986,-1,-0.53225359,0.3541277,-0.055379973,-0.33630175,0.17233308,-0.16313523,-0.55799413,-0.825795,0.062209963,0.27654364,0.17121365,-0.098792341,0.36880599,-0.74399679,-0.0073688772,0.50655544,-0.69962754,0.044468266,0.89856661,0.74907861,0.81938517,0.27543682,0.65493489,-0.39132423,0.53496599,-0.43646796,-0.21041648,-0.43093638,0.43721115,-0.10234649,-0.7455698,-0.36683122,-0.54051192,-0.76576577,-0.55441556,-0.4671077,-0.57584793,-0.43444933,0.18314533,0.64564272,0.7005277,0.88809481,0.46327689,0.42803172,-0.2321776,-0.054168081,0.15980526,0.53940983,-0.95429649,-0.93566879,-0.11002238,0.65919758,-0.34630749,-0.23985728,0.086226793,-0.14356966,0.24013416,0.073301598,0.018940682,0.12958333,0.92536911,0.61764149,1,-0.71291544,0.17528908,-0.11909145,-0.33198732,0.054187895,0.4032049,-0.070153759,0.082467906,-0.051148347,-0.75870285,-0.7807821,-0.24862122,0.96632167,0.48618408,0.848165,-0.41531467,-0.6790726,-0.36955391,0.81935278,0.43833107,0.16338318,0.32518368,-0.13831758,-0.11632353,-0.84570622,-0.43221116,-0.42931499,0.40433737,0.82766703,-0.27737611,0.39693145,-0.54549121,0.10067164,-0.22530052,0.16521669,0.43262567,-0.80823084,-0.77463406,-0.039104089,-0.061261178,0.31297044,0.38161289,-0.034913121,-0.0096200508,0.48925781,-0.27439415,-0.37072733,-0.35260859,-0.70812758,0.33481753,0.011329196,0.57089999,-0.27805528,-0.090322052,0.13771068,0.8621698,-0.33768347,0.81865687,0.25367422,0.26261128,0.81752006,0.072351271,-0.10046567,-0.46172784,-0.68214037,-0.59570179,0.45907,-0.30668755,-0.42617234,0.41930976,-0.30197767,-0.73113443,-0.72735422,-0.1095893,-0.39388308,-0.11417964,-0.076330267,0.17075409,-0.37728707,0.54192457,-0.0096309923,-0.55458223,0.55036312,0.022340055,0.71312407,0.5421562,0.96044922,-0.53374899,0.58202437,-0.089619921,0.23572786,-0.11170781,0.30801991,-0.3479599,-0.57501191,-0.573863,0.79982525,0.7439444,0.93134533,0.25742058,-0.59266294,-0.34119844,-0.068953801,0.49928767,-0.33281803]],&#34;color&#34;:[[&#34;#BEBEBE&#34;,&#34;#00FFFF&#34;,&#34;#BEBEBE&#34;,&#34;#BEBEBE&#34;,&#34;#BEBEBE&#34;,&#34;#00FF24&#34;,&#34;#BEBEBE&#34;,&#34;#BEBEBE&#34;,&#34;#FF6D00&#34;,&#34;#FF0000&#34;,&#34;#00FF24&#34;,&#34;#FF0000&#34;,&#34;#BEBEBE&#34;,&#34;#BEBEBE&#34;,&#34;#BEBEBE&#34;,&#34;#FF0000&#34;,&#34;#BEBEBE&#34;,&#34;#00FF24&#34;,&#34;#49FF00&#34;,&#34;#BEBEBE&#34;,&#34;#BEBEBE&#34;,&#34;#FFDB00&#34;,&#34;#0024FF&#34;,&#34;#B6FF00&#34;,&#34;#BEBEBE&#34;,&#34;#FFDB00&#34;,&#34;#BEBEBE&#34;,&#34;#FF6D00&#34;,&#34;#00FF92&#34;,&#34;#BEBEBE&#34;,&#34;#BEBEBE&#34;,&#34;#BEBEBE&#34;,&#34;#0092FF&#34;,&#34;#BEBEBE&#34;,&#34;#BEBEBE&#34;,&#34;#BEBEBE&#34;,&#34;#00FF92&#34;,&#34;#00FF92&#34;,&#34;#FF6D00&#34;,&#34;#BEBEBE&#34;,&#34;#00FF24&#34;,&#34;#BEBEBE&#34;,&#34;#4900FF&#34;,&#34;#4900FF&#34;,&#34;#FF0000&#34;,&#34;#FFDB00&#34;,&#34;#B600FF&#34;,&#34;#FF6D00&#34;,&#34;#B6FF00&#34;,&#34;#B6FF00&#34;,&#34;#BEBEBE&#34;,&#34;#FF0000&#34;,&#34;#BEBEBE&#34;,&#34;#49FF00&#34;,&#34;#00FFFF&#34;,&#34;#B600FF&#34;,&#34;#FF00DB&#34;,&#34;#BEBEBE&#34;,&#34;#FF0000&#34;,&#34;#BEBEBE&#34;,&#34;#49FF00&#34;,&#34;#BEBEBE&#34;,&#34;#BEBEBE&#34;,&#34;#FF0000&#34;,&#34;#BEBEBE&#34;,&#34;#0092FF&#34;,&#34;#BEBEBE&#34;,&#34;#B6FF00&#34;,&#34;#FFDB00&#34;,&#34;#BEBEBE&#34;,&#34;#49FF00&#34;,&#34;#00FFFF&#34;,&#34;#BEBEBE&#34;,&#34;#49FF00&#34;,&#34;#BEBEBE&#34;,&#34;#FF6D00&#34;,&#34;#BEBEBE&#34;,&#34;#FFDB00&#34;,&#34;#0092FF&#34;,&#34;#BEBEBE&#34;,&#34;#FF006D&#34;,&#34;#0024FF&#34;,&#34;#00FF92&#34;,&#34;#B6FF00&#34;,&#34;#BEBEBE&#34;,&#34;#FF6D00&#34;,&#34;#FF6D00&#34;,&#34;#FF0000&#34;,&#34;#FF6D00&#34;,&#34;#FF00DB&#34;,&#34;#FF006D&#34;,&#34;#FF0000&#34;,&#34;#0024FF&#34;,&#34;#FFDB00&#34;],[&#34;#FFBF00&#34;,&#34;#DFFF00&#34;,&#34;#FFBF00&#34;,&#34;#FF0000&#34;,&#34;#BEBEBE&#34;,&#34;#DFFF00&#34;,&#34;#00FFFF&#34;,&#34;#BEBEBE&#34;,&#34;#FF6000&#34;,&#34;#FF0000&#34;,&#34;#DFFF00&#34;,&#34;#FF0000&#34;,&#34;#FF0000&#34;,&#34;#BEBEBE&#34;,&#34;#FF0000&#34;,&#34;#FF0000&#34;,&#34;#BEBEBE&#34;,&#34;#DFFF00&#34;,&#34;#80FF00&#34;,&#34;#00FF40&#34;,&#34;#FF0000&#34;,&#34;#20FF00&#34;,&#34;#00FF9F&#34;,&#34;#FFBF00&#34;,&#34;#BEBEBE&#34;,&#34;#20FF00&#34;,&#34;#0040FF&#34;,&#34;#FF6000&#34;,&#34;#00FF40&#34;,&#34;#0040FF&#34;,&#34;#BEBEBE&#34;,&#34;#FF6000&#34;,&#34;#009FFF&#34;,&#34;#2000FF&#34;,&#34;#00FFFF&#34;,&#34;#FF6000&#34;,&#34;#00FF40&#34;,&#34;#00FF40&#34;,&#34;#FF6000&#34;,&#34;#BEBEBE&#34;,&#34;#DFFF00&#34;,&#34;#2000FF&#34;,&#34;#8000FF&#34;,&#34;#8000FF&#34;,&#34;#FF0000&#34;,&#34;#20FF00&#34;,&#34;#00FF9F&#34;,&#34;#FF6000&#34;,&#34;#FFBF00&#34;,&#34;#FFBF00&#34;,&#34;#BEBEBE&#34;,&#34;#FF0000&#34;,&#34;#BEBEBE&#34;,&#34;#80FF00&#34;,&#34;#DFFF00&#34;,&#34;#00FF9F&#34;,&#34;#FF00BF&#34;,&#34;#BEBEBE&#34;,&#34;#FF0000&#34;,&#34;#FF6000&#34;,&#34;#80FF00&#34;,&#34;#BEBEBE&#34;,&#34;#DFFF00&#34;,&#34;#FF0000&#34;,&#34;#FFBF00&#34;,&#34;#009FFF&#34;,&#34;#DF00FF&#34;,&#34;#FFBF00&#34;,&#34;#20FF00&#34;,&#34;#00FFFF&#34;,&#34;#80FF00&#34;,&#34;#DFFF00&#34;,&#34;#80FF00&#34;,&#34;#80FF00&#34;,&#34;#BEBEBE&#34;,&#34;#FF6000&#34;,&#34;#DF00FF&#34;,&#34;#20FF00&#34;,&#34;#009FFF&#34;,&#34;#BEBEBE&#34;,&#34;#FF0060&#34;,&#34;#00FF9F&#34;,&#34;#00FF40&#34;,&#34;#FFBF00&#34;,&#34;#BEBEBE&#34;,&#34;#FF6000&#34;,&#34;#FF6000&#34;,&#34;#FF0000&#34;,&#34;#FF6000&#34;,&#34;#FF00BF&#34;,&#34;#FF0060&#34;,&#34;#FF0000&#34;,&#34;#00FF9F&#34;,&#34;#20FF00&#34;],[&#34;#00FFFF&#34;,&#34;#0040FF&#34;,&#34;#00FFFF&#34;,&#34;#80FF00&#34;,&#34;#80FF00&#34;,&#34;#0040FF&#34;,&#34;#00FF40&#34;,&#34;#80FF00&#34;,&#34;#FF0000&#34;,&#34;#80FF00&#34;,&#34;#0040FF&#34;,&#34;#80FF00&#34;,&#34;#80FF00&#34;,&#34;#0040FF&#34;,&#34;#80FF00&#34;,&#34;#80FF00&#34;,&#34;#FF0000&#34;,&#34;#0040FF&#34;,&#34;#00FF40&#34;,&#34;#FF00BF&#34;,&#34;#80FF00&#34;,&#34;#8000FF&#34;,&#34;#FFBF00&#34;,&#34;#00FFFF&#34;,&#34;#FFBF00&#34;,&#34;#8000FF&#34;,&#34;#FF0000&#34;,&#34;#FF0000&#34;,&#34;#FF00BF&#34;,&#34;#FF0000&#34;,&#34;#FFBF00&#34;,&#34;#FF0000&#34;,&#34;#FFBF00&#34;,&#34;#FFBF00&#34;,&#34;#00FF40&#34;,&#34;#FF0000&#34;,&#34;#FF00BF&#34;,&#34;#FF00BF&#34;,&#34;#FF0000&#34;,&#34;#FF0000&#34;,&#34;#0040FF&#34;,&#34;#FFBF00&#34;,&#34;#00FF40&#34;,&#34;#00FF40&#34;,&#34;#80FF00&#34;,&#34;#8000FF&#34;,&#34;#FFBF00&#34;,&#34;#FF0000&#34;,&#34;#00FFFF&#34;,&#34;#00FFFF&#34;,&#34;#0040FF&#34;,&#34;#80FF00&#34;,&#34;#8000FF&#34;,&#34;#00FF40&#34;,&#34;#0040FF&#34;,&#34;#FFBF00&#34;,&#34;#00FF40&#34;,&#34;#00FF40&#34;,&#34;#80FF00&#34;,&#34;#FF0000&#34;,&#34;#00FF40&#34;,&#34;#FF0000&#34;,&#34;#0040FF&#34;,&#34;#80FF00&#34;,&#34;#00FFFF&#34;,&#34;#FFBF00&#34;,&#34;#FFBF00&#34;,&#34;#00FFFF&#34;,&#34;#8000FF&#34;,&#34;#00FF40&#34;,&#34;#00FF40&#34;,&#34;#0040FF&#34;,&#34;#00FF40&#34;,&#34;#00FF40&#34;,&#34;#00FFFF&#34;,&#34;#FF0000&#34;,&#34;#FFBF00&#34;,&#34;#8000FF&#34;,&#34;#FFBF00&#34;,&#34;#FFBF00&#34;,&#34;#00FFFF&#34;,&#34;#FFBF00&#34;,&#34;#FF00BF&#34;,&#34;#00FFFF&#34;,&#34;#FFBF00&#34;,&#34;#FF0000&#34;,&#34;#FF0000&#34;,&#34;#80FF00&#34;,&#34;#FF0000&#34;,&#34;#00FF40&#34;,&#34;#00FFFF&#34;,&#34;#80FF00&#34;,&#34;#FFBF00&#34;,&#34;#8000FF&#34;],[&#34;#00FFFF&#34;,&#34;#0040FF&#34;,&#34;#00FFFF&#34;,&#34;#FF0000&#34;,&#34;#FF0000&#34;,&#34;#0040FF&#34;,&#34;#80FF00&#34;,&#34;#FF0000&#34;,&#34;#FFBF00&#34;,&#34;#FF0000&#34;,&#34;#0040FF&#34;,&#34;#FF0000&#34;,&#34;#FF0000&#34;,&#34;#0040FF&#34;,&#34;#FF0000&#34;,&#34;#FF0000&#34;,&#34;#00FFFF&#34;,&#34;#0040FF&#34;,&#34;#80FF00&#34;,&#34;#FF00BF&#34;,&#34;#FF0000&#34;,&#34;#8000FF&#34;,&#34;#00FF40&#34;,&#34;#00FFFF&#34;,&#34;#00FF40&#34;,&#34;#8000FF&#34;,&#34;#FFBF00&#34;,&#34;#FFBF00&#34;,&#34;#FF00BF&#34;,&#34;#FFBF00&#34;,&#34;#00FF40&#34;,&#34;#FFBF00&#34;,&#34;#00FF40&#34;,&#34;#00FF40&#34;,&#34;#80FF00&#34;,&#34;#FFBF00&#34;,&#34;#FF00BF&#34;,&#34;#FF00BF&#34;,&#34;#FFBF00&#34;,&#34;#FFBF00&#34;,&#34;#0040FF&#34;,&#34;#00FF40&#34;,&#34;#80FF00&#34;,&#34;#80FF00&#34;,&#34;#FF0000&#34;,&#34;#8000FF&#34;,&#34;#00FF40&#34;,&#34;#FFBF00&#34;,&#34;#00FFFF&#34;,&#34;#00FFFF&#34;,&#34;#0040FF&#34;,&#34;#FF0000&#34;,&#34;#8000FF&#34;,&#34;#80FF00&#34;,&#34;#0040FF&#34;,&#34;#00FF40&#34;,&#34;#80FF00&#34;,&#34;#80FF00&#34;,&#34;#FF0000&#34;,&#34;#FFBF00&#34;,&#34;#80FF00&#34;,&#34;#FFBF00&#34;,&#34;#0040FF&#34;,&#34;#FF0000&#34;,&#34;#00FFFF&#34;,&#34;#00FF40&#34;,&#34;#00FF40&#34;,&#34;#00FFFF&#34;,&#34;#8000FF&#34;,&#34;#80FF00&#34;,&#34;#80FF00&#34;,&#34;#0040FF&#34;,&#34;#80FF00&#34;,&#34;#80FF00&#34;,&#34;#00FFFF&#34;,&#34;#FFBF00&#34;,&#34;#80FF00&#34;,&#34;#8000FF&#34;,&#34;#00FF40&#34;,&#34;#00FF40&#34;,&#34;#00FFFF&#34;,&#34;#00FF40&#34;,&#34;#FF00BF&#34;,&#34;#00FFFF&#34;,&#34;#0040FF&#34;,&#34;#FFBF00&#34;,&#34;#FFBF00&#34;,&#34;#FF0000&#34;,&#34;#FFBF00&#34;,&#34;#80FF00&#34;,&#34;#00FFFF&#34;,&#34;#FF0000&#34;,&#34;#00FF40&#34;,&#34;#8000FF&#34;],[&#34;#00FFFF&#34;,&#34;#0040FF&#34;,&#34;#00FFFF&#34;,&#34;#FF0000&#34;,&#34;#FF0000&#34;,&#34;#0040FF&#34;,&#34;#80FF00&#34;,&#34;#FF0000&#34;,&#34;#FFBF00&#34;,&#34;#FF0000&#34;,&#34;#0040FF&#34;,&#34;#FF0000&#34;,&#34;#FF0000&#34;,&#34;#0040FF&#34;,&#34;#FF0000&#34;,&#34;#FF0000&#34;,&#34;#FFBF00&#34;,&#34;#0040FF&#34;,&#34;#80FF00&#34;,&#34;#FF00BF&#34;,&#34;#FF0000&#34;,&#34;#8000FF&#34;,&#34;#00FF40&#34;,&#34;#00FFFF&#34;,&#34;#00FF40&#34;,&#34;#8000FF&#34;,&#34;#FFBF00&#34;,&#34;#FFBF00&#34;,&#34;#FF00BF&#34;,&#34;#FFBF00&#34;,&#34;#00FF40&#34;,&#34;#FFBF00&#34;,&#34;#FF0000&#34;,&#34;#00FF40&#34;,&#34;#80FF00&#34;,&#34;#FFBF00&#34;,&#34;#FF00BF&#34;,&#34;#FF00BF&#34;,&#34;#FFBF00&#34;,&#34;#FFBF00&#34;,&#34;#0040FF&#34;,&#34;#00FF40&#34;,&#34;#80FF00&#34;,&#34;#80FF00&#34;,&#34;#FF0000&#34;,&#34;#8000FF&#34;,&#34;#00FF40&#34;,&#34;#FFBF00&#34;,&#34;#00FFFF&#34;,&#34;#00FFFF&#34;,&#34;#0040FF&#34;,&#34;#FF0000&#34;,&#34;#8000FF&#34;,&#34;#80FF00&#34;,&#34;#0040FF&#34;,&#34;#00FF40&#34;,&#34;#80FF00&#34;,&#34;#80FF00&#34;,&#34;#FF0000&#34;,&#34;#FFBF00&#34;,&#34;#80FF00&#34;,&#34;#FFBF00&#34;,&#34;#0040FF&#34;,&#34;#FF0000&#34;,&#34;#00FFFF&#34;,&#34;#FF0000&#34;,&#34;#00FF40&#34;,&#34;#00FFFF&#34;,&#34;#8000FF&#34;,&#34;#80FF00&#34;,&#34;#80FF00&#34;,&#34;#0040FF&#34;,&#34;#80FF00&#34;,&#34;#80FF00&#34;,&#34;#00FFFF&#34;,&#34;#FFBF00&#34;,&#34;#00FF40&#34;,&#34;#8000FF&#34;,&#34;#FF0000&#34;,&#34;#00FF40&#34;,&#34;#00FFFF&#34;,&#34;#00FF40&#34;,&#34;#FF00BF&#34;,&#34;#00FFFF&#34;,&#34;#0040FF&#34;,&#34;#FFBF00&#34;,&#34;#FFBF00&#34;,&#34;#FF0000&#34;,&#34;#FFBF00&#34;,&#34;#80FF00&#34;,&#34;#00FFFF&#34;,&#34;#FF0000&#34;,&#34;#00FF40&#34;,&#34;#8000FF&#34;]],&#34;alpha&#34;:[[1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1],[1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1],[1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1],[1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1],[1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1]],&#34;from&#34;:[[1,5,5,5,8,8,9,9,9,9,9,9,9,9,10,10,11,11,15,15,15,15,15,17,18,18,18,21,21,21,21,21,22,22,23,23,23,25,27,27,28,28,32,32,36,36,37,38,38,38,38,42,44,44,44,44,45,45,46,47,47,47,48,48,49,51,51,51,53,53,53,54,56,60,60,63,63,65,67,68,70,75,80,81,86,87],[0,1,1,1,2,2,3,3,3,3,3,3,3,5,5,5,5,5,6,6,8,8,8,8,8,8,8,9,9,9,9,9,9,9,9,9,10,10,11,11,11,11,11,11,11,11,11,12,15,15,15,15,15,15,15,17,18,18,18,18,18,19,19,19,19,20,20,20,20,20,21,21,21,21,21,22,22,22,22,23,23,23,23,25,25,25,26,27,27,27,27,27,27,27,28,28,28,31,31,32,32,33,34,35,35,35,35,35,36,36,37,38,38,38,38,38,42,44,44,44,44,44,45,45,46,47,47,47,47,48,48,48,48,49,49,49,51,51,51,51,53,53,53,53,54,54,56,58,58,58,59,60,60,60,63,63,64,65,66,67,68,68,70,70,72,75,75,77,80,81,85,85,86,87],[0,0,0,0,0,0,0,0,1,1,1,1,1,1,1,1,1,2,2,2,2,2,2,2,3,3,3,3,3,3,3,3,3,3,3,3,3,3,4,4,4,4,4,4,4,4,4,5,5,5,5,5,5,5,5,6,6,6,6,6,6,6,7,7,7,7,7,7,7,7,7,7,7,8,8,8,8,8,8,8,8,8,8,8,8,8,9,9,9,9,9,9,9,9,9,9,9,10,10,10,10,10,10,11,11,11,11,11,11,11,11,11,11,12,12,12,12,12,12,12,12,12,13,13,13,13,13,14,14,14,14,14,14,14,14,14,14,14,15,15,15,15,15,15,15,16,16,17,17,17,17,18,18,18,18,18,18,18,19,19,19,19,20,20,20,20,20,20,21,21,21,21,21,21,22,22,22,22,22,23,23,23,23,23,23,23,24,24,24,24,24,24,25,25,25,25,25,26,26,26,26,26,26,26,26,26,26,26,27,27,27,27,27,27,27,27,27,27,28,28,28,29,29,29,29,29,30,30,30,30,30,30,31,31,31,31,31,31,31,31,31,32,32,32,33,33,33,33,33,33,34,34,34,34,34,35,35,35,35,35,35,36,36,37,38,38,38,38,38,38,39,39,40,40,40,41,41,42,42,43,44,44,44,44,44,45,45,45,45,46,46,46,46,46,47,47,47,47,47,48,48,48,48,48,48,48,49,49,49,49,49,49,50,50,50,50,51,51,51,51,52,52,52,53,53,53,53,53,54,54,55,55,55,55,56,56,56,56,57,57,57,57,58,58,58,59,59,59,59,60,60,60,60,61,62,62,62,62,63,63,64,64,64,64,64,65,65,66,66,67,67,67,67,68,68,69,69,70,70,72,73,74,74,74,75,75,75,77,78,80,81,85,85,86,87],[0,0,0,0,0,0,0,0,0,0,0,0,0,1,1,1,1,1,1,1,1,1,1,2,2,2,2,2,2,2,2,2,2,2,2,3,3,3,3,3,3,3,3,3,3,3,3,3,3,4,4,4,4,4,4,4,4,4,4,4,4,4,4,4,4,4,4,4,4,4,4,4,5,5,5,5,5,5,5,5,5,6,6,6,6,6,6,6,6,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,9,9,9,9,9,9,9,9,9,9,9,10,10,10,10,10,10,10,10,10,11,11,11,11,11,11,11,11,11,11,12,12,12,12,12,12,12,12,12,12,13,13,13,13,13,13,13,13,13,13,13,13,13,13,14,14,14,14,14,14,14,14,14,14,14,14,14,14,15,15,15,15,15,15,15,16,16,16,16,16,16,16,16,16,16,16,16,16,16,16,16,16,16,17,17,17,17,17,17,18,18,18,18,18,18,18,18,18,18,18,18,19,19,19,19,19,19,20,20,20,20,20,20,21,21,21,21,21,21,21,22,22,22,22,22,22,22,22,22,23,23,23,23,23,23,23,23,23,23,24,24,24,24,24,24,24,24,24,25,25,25,25,25,25,26,26,26,26,26,26,26,26,26,26,26,26,26,26,26,26,26,26,26,26,26,27,27,27,27,27,27,27,27,27,27,27,27,28,28,28,29,29,29,29,29,29,29,29,29,29,29,29,29,29,29,29,30,30,30,30,30,30,30,30,30,30,31,31,31,31,31,31,31,31,31,31,31,32,32,32,32,32,32,32,33,33,33,33,33,33,33,33,34,34,34,34,34,34,34,34,34,35,35,35,35,35,35,35,35,35,35,35,36,36,37,37,38,38,38,38,38,38,38,38,38,39,39,39,39,39,39,39,39,39,39,40,40,40,40,40,41,41,41,41,41,41,41,41,41,41,41,42,42,42,42,42,43,43,43,43,43,44,44,44,44,44,45,45,45,45,46,46,46,46,46,46,47,47,47,47,47,47,47,48,48,48,48,48,48,48,48,49,49,49,49,49,49,49,50,50,50,50,50,50,51,51,51,51,52,52,52,52,53,53,53,53,53,53,53,53,54,54,54,55,55,55,55,55,56,56,56,56,56,56,56,56,56,56,57,57,57,57,57,57,57,58,58,58,59,59,59,59,59,59,59,60,60,60,60,60,61,61,61,61,61,61,61,62,62,62,62,62,63,63,64,64,64,64,64,65,65,66,66,66,66,66,66,66,67,67,67,67,68,68,69,69,70,70,70,72,72,72,73,74,74,74,74,75,75,75,75,76,76,77,78,79,79,79,80,80,80,81,81,83,83,84,84,85,85,86,87,90],[0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,3,3,3,3,3,3,3,3,3,3,3,3,3,3,3,3,3,3,3,4,4,4,4,4,4,4,4,4,4,4,4,4,4,4,4,4,4,4,4,4,4,4,4,4,4,4,4,4,5,5,5,5,5,5,5,5,5,6,6,6,6,6,6,6,6,6,6,6,6,6,6,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,9,9,9,9,9,9,9,9,9,9,9,10,10,10,10,10,10,10,10,10,10,10,11,11,11,11,11,11,11,11,11,11,11,11,11,11,11,12,12,12,12,12,12,12,12,12,12,12,12,12,12,13,13,13,13,13,13,13,13,13,13,13,13,13,13,13,13,13,13,13,13,13,13,13,14,14,14,14,14,14,14,14,14,14,14,14,14,14,14,14,15,15,15,15,15,15,15,15,15,16,16,16,16,16,16,16,16,16,16,16,16,16,16,16,16,16,16,16,16,16,16,16,16,16,16,16,17,17,17,17,17,17,17,17,18,18,18,18,18,18,18,18,18,18,18,18,18,18,19,19,19,19,19,19,19,19,20,20,20,20,20,20,20,20,20,20,20,21,21,21,21,21,21,21,21,22,22,22,22,22,22,22,22,22,22,22,22,22,23,23,23,23,23,23,23,23,23,23,23,23,24,24,24,24,24,24,24,24,24,24,25,25,25,25,25,25,25,25,25,26,26,26,26,26,26,26,26,26,26,26,26,26,26,26,26,26,26,26,26,26,26,26,26,27,27,27,27,27,27,27,27,27,27,27,27,27,27,27,27,27,28,28,28,28,28,28,29,29,29,29,29,29,29,29,29,29,29,29,29,29,29,29,29,29,29,29,30,30,30,30,30,30,30,30,30,30,30,30,30,30,30,30,30,31,31,31,31,31,31,31,31,31,31,31,31,32,32,32,32,32,32,32,32,32,32,32,33,33,33,33,33,33,33,33,33,33,33,33,33,33,34,34,34,34,34,34,34,34,34,34,34,34,34,34,35,35,35,35,35,35,35,35,35,35,35,35,35,36,36,36,36,36,36,37,37,38,38,38,38,38,38,38,38,38,38,38,38,39,39,39,39,39,39,39,39,39,39,39,39,39,39,39,39,39,39,39,39,40,40,40,40,40,40,41,41,41,41,41,41,41,41,41,41,41,41,41,41,42,42,42,42,42,42,43,43,43,43,43,43,44,44,44,44,44,44,45,45,45,45,45,45,46,46,46,46,46,46,46,46,47,47,47,47,47,47,47,47,47,48,48,48,48,48,48,48,48,48,49,49,49,49,49,49,49,49,49,50,50,50,50,50,50,50,50,50,50,50,50,50,51,51,51,51,51,51,52,52,52,52,52,52,52,52,52,52,53,53,53,53,53,53,53,53,54,54,54,54,54,55,55,55,55,55,55,55,56,56,56,56,56,56,56,56,56,56,56,57,57,57,57,57,57,57,57,57,57,58,58,58,59,59,59,59,59,59,59,59,59,60,60,60,60,60,61,61,61,61,61,61,61,61,61,61,62,62,62,62,62,62,62,62,63,63,63,64,64,64,64,64,64,65,65,65,66,66,66,66,66,66,66,66,67,67,67,67,68,68,68,69,69,70,70,70,71,71,72,72,72,72,73,74,74,74,74,74,75,75,75,75,75,76,76,76,76,77,78,79,79,79,79,80,80,80,80,80,81,81,82,83,83,83,84,84,84,84,85,85,86,87,90,90]],&#34;to&#34;:[[71,10,17,40,38,47,11,15,44,51,58,63,87,91,17,40,51,87,44,51,63,87,91,40,53,60,70,25,45,68,77,93,81,92,48,67,83,93,38,47,36,37,65,78,37,82,82,47,75,86,88,43,51,63,87,91,68,77,55,75,85,88,49,67,67,63,87,91,60,70,73,71,89,70,73,87,91,78,83,77,73,86,90,92,88,91],[64,54,62,71,23,48,9,11,15,44,58,63,91,10,17,40,54,71,34,69,27,38,47,75,85,86,88,11,15,20,44,51,58,63,87,91,17,40,12,14,15,44,51,58,63,87,91,63,20,44,51,58,63,87,91,40,53,60,70,72,73,28,36,37,82,44,51,63,87,91,25,45,68,77,93,46,55,81,92,48,49,67,83,68,77,93,29,35,38,47,75,85,86,88,36,37,82,85,88,65,78,41,69,38,47,85,86,88,37,82,82,47,75,85,86,88,43,51,58,63,87,91,68,77,55,75,85,86,88,49,64,67,83,64,67,83,58,63,87,91,60,70,72,73,62,71,89,63,87,91,75,70,72,73,87,91,67,78,76,83,77,93,72,73,73,86,88,93,90,92,86,88,88,91],[2,23,48,49,64,67,74,83,5,10,13,17,40,50,54,62,71,23,48,49,59,64,67,83,4,7,9,11,12,14,15,20,44,51,58,63,87,91,7,11,12,14,18,53,70,87,91,10,13,17,40,50,54,62,71,34,42,43,56,69,76,89,9,11,12,15,20,44,51,58,63,87,91,26,27,29,31,35,38,47,59,61,75,85,86,88,11,12,14,15,20,44,51,58,63,87,91,13,17,40,54,71,84,12,14,15,20,44,51,58,63,87,91,14,15,20,44,51,58,63,87,91,17,40,50,71,84,15,18,44,51,53,58,63,70,72,87,91,20,44,51,58,63,87,91,31,83,40,54,62,71,53,57,60,70,72,73,89,28,36,37,82,44,51,58,63,87,91,25,45,52,68,77,93,24,46,55,81,92,48,49,64,67,74,80,83,46,55,66,81,84,92,45,52,68,77,93,27,29,31,38,39,47,59,61,75,85,86,29,31,35,38,47,59,75,85,86,88,36,37,82,31,38,47,61,85,32,33,41,65,78,79,35,38,39,47,59,75,85,86,88,65,78,79,41,46,55,79,81,92,42,43,56,69,89,38,47,75,85,86,88,37,82,82,47,59,75,85,86,88,59,86,54,62,71,79,81,43,69,69,51,58,63,87,91,52,68,77,93,55,66,76,81,92,59,75,85,86,88,49,64,67,74,80,83,90,64,67,74,80,83,90,54,62,71,72,58,63,87,91,68,77,93,57,60,70,72,73,62,71,66,76,81,92,57,69,76,89,60,70,72,73,63,87,91,75,85,86,88,70,72,73,89,89,71,74,80,90,87,91,67,74,80,83,90,78,79,76,84,74,80,83,90,77,93,76,89,72,73,73,89,80,83,90,85,86,88,93,79,90,92,86,88,88,91],[2,16,23,42,43,48,49,64,67,74,80,83,90,5,10,13,17,40,50,54,62,71,90,23,39,48,49,59,60,64,67,70,72,73,83,4,7,9,11,12,14,15,20,44,51,58,63,87,91,7,9,11,12,14,15,18,20,35,44,51,53,58,60,61,63,70,72,73,84,87,89,91,10,13,17,40,50,54,62,71,84,34,42,43,56,66,69,76,89,9,11,12,14,15,20,30,32,35,44,51,58,63,65,78,79,84,87,91,13,26,27,29,31,35,38,39,47,59,61,75,84,85,86,88,11,12,14,15,20,44,51,58,63,87,91,13,17,27,40,50,54,62,71,84,12,14,15,20,44,51,58,63,87,91,14,15,20,32,44,51,58,63,87,91,17,18,24,26,27,29,38,40,50,54,61,71,75,84,15,18,20,44,51,53,58,60,63,70,72,73,87,91,20,44,51,58,63,87,91,23,30,31,33,38,39,41,45,47,48,49,59,67,74,83,85,86,88,40,50,54,62,71,84,26,39,50,53,56,57,60,61,70,72,73,89,28,36,37,80,82,90,44,51,58,63,87,91,25,29,45,52,68,77,93,24,33,46,55,57,66,76,81,92,39,48,49,59,64,67,74,80,83,90,46,55,57,66,71,76,81,84,92,45,52,68,72,77,93,27,29,31,35,38,39,47,53,56,57,59,60,61,70,73,75,77,85,86,88,89,29,31,35,38,47,59,61,75,84,85,86,88,36,37,82,31,35,38,39,45,47,56,59,61,68,75,77,85,86,88,89,32,33,35,41,52,65,74,78,79,85,35,38,39,41,47,59,75,83,85,86,88,34,35,41,52,65,78,79,41,46,52,55,66,79,81,92,42,43,56,65,66,69,76,78,89,38,41,47,59,61,65,75,84,85,86,88,37,82,61,82,39,47,59,61,75,84,85,86,88,47,48,57,59,75,83,85,86,88,93,50,54,62,71,84,46,55,65,66,74,78,79,81,85,88,92,43,56,64,69,76,56,64,69,76,89,51,58,63,87,91,52,68,77,93,55,57,66,76,81,92,59,61,75,84,85,86,88,49,59,64,67,74,80,83,90,62,64,67,74,80,83,90,54,60,62,70,71,72,58,63,87,91,68,77,79,93,56,57,60,61,70,72,73,89,62,71,74,57,66,76,81,92,57,60,61,66,69,70,73,76,84,89,60,66,70,72,73,76,89,63,87,91,61,67,75,83,85,86,88,61,70,72,73,89,70,73,75,85,86,88,89,67,71,74,80,90,87,91,67,74,80,83,90,78,79,69,76,79,81,84,89,92,74,80,83,90,77,93,76,89,72,73,89,73,89,93,89,80,82,83,90,84,85,86,88,81,89,93,79,81,82,92,82,83,90,90,92,88,90,85,89,86,88,88,91,92],[2,16,23,41,42,43,48,49,62,64,67,69,74,80,81,83,90,92,5,10,13,17,24,40,49,50,54,62,67,71,74,80,90,92,18,23,26,39,48,49,53,57,59,60,64,67,70,72,73,74,75,80,83,86,90,4,6,7,9,11,12,14,15,20,32,34,44,51,58,63,84,87,89,91,7,9,11,12,14,15,18,20,26,32,35,44,51,53,56,58,60,61,63,65,70,72,73,78,84,86,87,89,91,10,13,17,40,50,54,62,71,84,34,42,43,45,52,56,57,66,68,69,73,76,77,89,9,11,12,14,15,20,30,32,33,34,35,41,44,51,58,63,65,78,79,84,87,91,13,16,26,27,29,31,35,38,39,47,56,59,61,75,84,85,86,88,11,12,14,15,20,44,51,58,63,87,91,13,17,24,27,34,40,50,54,62,71,84,12,14,15,18,20,44,51,53,58,63,70,72,73,87,91,14,15,20,32,35,44,51,58,63,65,78,84,87,91,17,18,24,26,27,29,38,40,47,50,54,56,57,59,60,61,70,71,72,75,84,85,89,15,18,20,44,50,51,53,57,58,60,63,70,72,73,87,91,20,32,44,51,58,63,78,87,91,21,23,26,27,29,30,31,33,35,38,39,41,45,47,48,49,52,59,64,67,74,75,77,83,85,86,88,34,40,50,54,62,71,74,84,24,26,29,39,50,53,56,57,60,61,70,72,73,89,28,33,36,37,74,80,82,90,30,32,33,41,44,51,58,63,78,87,91,25,29,39,45,52,68,77,93,24,33,39,41,46,55,57,66,76,79,81,90,92,31,39,48,49,59,62,64,67,74,80,83,90,46,50,55,57,66,71,76,81,84,92,29,39,45,52,57,68,72,77,93,27,29,31,35,38,39,45,47,53,56,57,59,60,61,68,70,72,73,75,77,85,86,88,89,29,30,31,35,38,39,41,47,56,59,61,66,75,84,85,86,88,36,37,61,66,76,82,31,35,38,39,45,47,56,57,59,61,66,68,69,75,77,84,85,86,88,89,31,32,33,34,35,38,41,42,43,47,52,65,74,78,79,85,88,35,38,39,41,47,59,61,75,83,85,86,88,33,34,35,41,44,52,63,65,74,78,79,35,41,46,52,55,65,66,74,76,78,79,81,82,92,40,42,43,52,56,61,65,66,69,76,78,79,84,89,38,41,47,59,61,65,66,75,78,84,85,86,88,37,61,79,80,82,90,61,82,39,41,47,59,61,66,75,83,84,85,86,88,45,46,47,48,49,50,55,57,59,60,67,70,72,75,77,83,85,86,88,93,50,52,54,62,71,84,46,47,52,55,65,66,74,78,79,81,85,86,88,92,43,56,64,69,76,89,56,64,69,76,78,89,51,58,63,78,87,91,52,68,76,77,81,93,55,57,66,76,79,81,84,92,59,61,66,75,83,84,85,86,88,49,59,62,64,67,74,80,83,90,54,59,62,64,67,74,80,83,90,53,54,57,59,60,62,70,71,72,73,75,84,93,53,58,63,72,87,91,65,66,68,76,77,78,79,81,82,93,56,57,60,61,70,72,73,89,62,71,74,80,90,57,66,76,79,81,84,92,57,60,61,66,69,70,72,73,76,84,89,60,66,68,70,72,73,75,76,89,93,63,87,91,60,61,67,70,75,83,85,86,88,61,70,72,73,89,69,70,73,75,82,84,85,86,88,89,64,67,71,74,80,90,92,93,78,87,91,67,69,74,80,83,90,78,79,84,69,76,79,81,84,85,89,92,74,80,83,90,76,77,93,76,89,72,73,89,92,93,73,87,89,93,89,78,80,82,83,90,83,84,85,86,88,81,84,89,92,93,79,81,82,84,92,81,82,83,90,92,90,92,90,86,88,90,85,86,88,89,86,88,88,91,92,93]],&#34;main&#34;:[0.97,0.95,0.9,0.85,0.8]},&#34;deferfps&#34;:30,&#34;options&#34;:true,&#34;alpha&#34;:[[1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1]],&#34;vertices&#34;:[[-0.083756874,-1,-1,-0.33193237,0.65896192,-0.33462375,0.0096707596,-0.96759652,-0.84339247,-0.39491718,-0.41929575,-0.49189299,0.50987879,-0.46153034,0.25408287,-0.48342594,-0.031117573,0.067823284,0.52322845,-0.0097745858,-0.44432355,0.5172261,0.36887232,-0.33947207,-0.26453272,-0.49680054,0.41740054,-0.59137677,0.1426698,0.93899703,-0.45717261,-0.037827692,-0.038347319,-0.56771021,0.15991127,0.78530781,0.40135361,-0.30204938,-0.46331872,0.81395512,0.28902531,-0.19023344,-0.00013346484,-0.51813993,-0.47397787,-0.78854768,0.16241969,0.88765227,-0.28875332,0.10665586,-0.3669419,-0.60974348,-0.03431126,-0.0045589152,0.65555212,-0.15966689,0.83816434,0.47689396,0.58696671,0.22606262,0.67968406,-0.051663567,-0.21914243,-0.81564367,0.3268111,-0.19217847,-0.9372025,-0.27764425,0.18271458,0.12266908,0.32554487,0.87621059,-0.055723204,-0.16165957,-0.48401914,-0.66168606,0.34186115,-0.28298988,0.70999933,0.7252045,0.11241263,-0.214983,-0.50962755,0.65602303,-0.95097409,0.50381866,0.46347676,0.90494463,0.22874719,0.15583371,0.89089658,-0.0015200295,0.14189409,0.36082772,0.58315832,0.60306553,0.84680781,-0.24688717,0.13290201,0.84404613,0.33039334,0.56892104,0.79293173,-0.29607883,0.48196394,0.54329474,0.70497988,0.73633538,-0.98766591,0.49951256,0.33953809,-0.85575316,0.51079779,0.36702661,-0.10547412,-0.51073799,0.52551814,0.719118,0.69562464,0.49594976,-0.53221647,-0.11847456,0.024336579,-0.52922962,0.82740432,0.27252236,-0.24690065,-0.60124972,-0.12863172,-0.36481925,-0.58287999,-0.19633625,-0.76559397,0.1637044,0.97106114,-0.87865218,0.34500031,-0.07634441,-0.27505681,0.87630528,0.016039001,-0.22343293,-0.4939272,0.53764224,-0.019561316,0.34179128,0.79566277,-0.075037083,0.37582269,0.68033287,0.90324636,0.51838321,0.1224127,-0.68420191,0.16139919,0.88267825,0.71865992,0.081063093,0.49566018,0.57064316,-0.19992546,0.81235123,-0.58480953,0.70082009,-0.19043758,-0.18630364,0.87474672,-0.07598433,0.37616422,-0.42805688,-0.15187929,0.38819008,0.87377858,0.029032726,-0.37815971,0.033229865,0.9513037,0.36155228,0.90100371,0.37480731,0.47353227,-0.17203459,0.86558091,0.18212402,0.70833847,-0.26524121,0.082196942,0.84610805,0.58372459,-0.66720407,0.17588241,1,1,0.074628513,-0.098637032,0.79765763,-0.23155687,0.23807418,-0.2965246,0.77939115,0.65168405,0.093634887,0.34223716,0.74164117,-0.99246744,0.30497849,-0.095777432,0.087655791,0.48475836,-0.52009561,0.54105337,-0.12231407,0.76980373,-0.46956202,0.67006717,-0.27255805,0.42526566,0.62421597,-0.33613309,0.43148749,-0.20862259,0.75056717,0.10246196,1,0.14877759,-0.0095979434,-0.52395947,0.59613473,-0.15176462,0.9368179,0.38740995,-0.95259418,0.29037993,-0.17559448,0.92958003,-0.18166612,0.21690782,-0.031431568,0.28093375,-0.69300415,0.043424645,0.15189207,-0.53721695,-1,-0.24216711,0.27407577,-0.8797843,0.51064178,0.24448582,0.25054541,0.31845891,0.81199533,0.72214751,0.54497611,-0.22160546,-0.45029238,-0.45899454,0.55437481,0.07809239,-0.53704013,0.49219656,-0.65278471,0.2232103,0.87309214,-0.065016291,-0.53628966,0.42558831,0.28163512,-0.47975048,-0.073220636,0.1756893,0.15383767,-0.48871923,-0.73039227,0.24517354,0.93223765,-0.8619314,-0.27752725,0.2844637,-0.73710826,0.25955476,-0.32797016]],&#34;xticklab&#34;:[&#34;-1.00&#34;,&#34;-0.60&#34;,&#34;-0.20&#34;,&#34;0.20&#34;,&#34;0.60&#34;,&#34;1.00&#34;],&#34;yticklab&#34;:[&#34;-1.00&#34;,&#34;-0.60&#34;,&#34;-0.20&#34;,&#34;0.20&#34;,&#34;0.60&#34;,&#34;1.00&#34;],&#34;zticklab&#34;:[&#34;1.00&#34;,&#34;0.60&#34;,&#34;0.20&#34;,&#34;-0.20&#34;,&#34;-0.60&#34;,&#34;-1.00&#34;],&#34;xtick&#34;:[0,0.2,0.4,0.6,0.8,1],&#34;ytick&#34;:[0,0.2,0.4,0.6,0.8,1],&#34;ztick&#34;:[0,0.2,0.4,0.6,0.8,1],&#34;crosstalk_key&#34;:[&#34;0&#34;,&#34;1&#34;,&#34;2&#34;,&#34;3&#34;,&#34;4&#34;],&#34;crosstalk_group&#34;:&#34;SharedDatafe99d0a2&#34;,&#34;fpl&#34;:-1},&#34;evals&#34;:[],&#34;jsHooks&#34;:[]}&lt;/script&gt;
&lt;/div&gt; &lt;em&gt;Editors Note: This post was revised on 8/28/17 to include a correction by the author that rescales the precision matrix.&lt;/em&gt;&lt;/p&gt;
&lt;/div&gt;

        &lt;script&gt;window.location.href=&#39;https://rviews.rstudio.com/2017/08/22/stocks/&#39;;&lt;/script&gt;
      </description>
    </item>
    
    <item>
      <title>Mapping Quandl Data with Shiny</title>
      <link>https://rviews.rstudio.com/2017/06/14/mapping-quandl-data-with-shiny/</link>
      <pubDate>Wed, 14 Jun 2017 00:00:00 +0000</pubDate>
      
      <guid>https://rviews.rstudio.com/2017/06/14/mapping-quandl-data-with-shiny/</guid>
      <description>
        
&lt;!-- BLOGDOWN-HEAD --&gt;
&lt;!-- /BLOGDOWN-HEAD --&gt;

&lt;!-- BLOGDOWN-BODY-BEFORE --&gt;
&lt;!-- /BLOGDOWN-BODY-BEFORE --&gt;
&lt;p&gt;Today, we are going to wrap our previously built &lt;a href=&#34;https://rviews.rstudio.com/2017/05/10/mapping-quandl-macroeconomic-data/&#34;&gt;Quandl/world map Notebook&lt;/a&gt; into an interactive Shiny app that lets users choose both a country and a data set for display. As usual, we did a lot of the heavy lifting in the Notebook to make our work more reproducible and our app more performant. The final app is available &lt;a href=&#34;http://colorado.rstudio.com:3939/worldmap-quandl-shiny/&#34;&gt;here&lt;/a&gt;.&lt;/p&gt;
&lt;p&gt;Devotees of this Reproducible Finance blog series will note similarities to this &lt;a href=&#34;http://colorado.rstudio.com:3939/Global-ETF-Map/&#34;&gt;Shiny app&lt;/a&gt;, but today’s app will have different and richer functionality.&lt;/p&gt;
&lt;p&gt;First, we are going to be pulling in data from Quandl, so we won’t be using ticker symbols, but rather will be using country codes plus data set codes. That would allow us to open this app to the vast number of data sets available via Quandl.&lt;/p&gt;
&lt;p&gt;Second, the user will be able to use the sidebar to select different data sets, rather than being restricted to a country ETF. For example, the user might want to select GDP-per-capita, or the exchange rate, or any data set that we wish to make available. Our app today will include 6 economic indicators.&lt;/p&gt;
&lt;p&gt;Third, we will display a chart using &lt;code&gt;highcharter&lt;/code&gt; instead of &lt;code&gt;dygraphs&lt;/code&gt;. There’s not a substantive reason to be doing this, beyond that it’s a good chance to start exploring &lt;code&gt;highcharter&lt;/code&gt;, which is a popular tool in the financial world.&lt;/p&gt;
&lt;p&gt;Lastly, we’ll port raw data to a &lt;code&gt;data.table&lt;/code&gt; and include a few buttons for easy download, in case our end users want to reproduce our charts or import data for their own work. We are going to use the &lt;code&gt;as_tibble&lt;/code&gt; function from the fantastically useful new &lt;a href=&#34;https://cran.r-project.org/web/packages/tidyquant/index.html&#34;&gt;tidyquant&lt;/a&gt; package to facilitate our &lt;code&gt;data.table&lt;/code&gt;. We won’t have space to cover the data download section in this post, but all the code is available in the live app.&lt;/p&gt;
&lt;p&gt;Without further ado, let’s get to it.&lt;/p&gt;
&lt;p&gt;The first line of substance in this app loads in the &lt;code&gt;leaflet&lt;/code&gt; map we constructed in our Notebook. We named the object &lt;code&gt;leaf_world&lt;/code&gt; and saved it in a file called &lt;code&gt;wdiMapData.RDat&lt;/code&gt;. If you want to refresh your memory on how we did that, have a look back at the &lt;a href=&#34;https://rviews.rstudio.com/2017/05/10/mapping-quandl-macroeconomic-data/&#34;&gt;previous post&lt;/a&gt;. Apologies if that sounds tedious, but hopefully it emphasizes the workflow of doing the heavy map-building in the Notebook when possible. If you or your team ever want to use that map as the basis for another Shiny app, that Notebook will be convenient to reuse.&lt;/p&gt;
&lt;p&gt;To load our map, we run the following:&lt;/p&gt;
&lt;pre class=&#34;r&#34;&gt;&lt;code&gt;# Load the .RDat file where the leaflet map is saved.
load(&amp;#39;wdiMapData.RDat&amp;#39;)&lt;/code&gt;&lt;/pre&gt;
&lt;p&gt;Now we can access whatever R objects were saved in that file and, in this case, that means one R object called &lt;code&gt;leaf_world&lt;/code&gt;. That might not be a great name, but it’s the leaflet map of the world we built in the Notebook. When we are ready to build the map in our Shiny app, we’ll simply render that object.&lt;/p&gt;
&lt;p&gt;Before we get to the map, though, let’s construct a sidebar where the user can choose which data set to display. We are going to be working with a macroeconomic data source from the World Bank called World Development Indicators &lt;a href=&#34;http://data.worldbank.org/products/wdi&#34;&gt;WDI&lt;/a&gt;. The Quandl code for WDI is &lt;code&gt;WWDI&lt;/code&gt; and thus we’ll append &lt;code&gt;WWDI/&lt;/code&gt; to each data set call - but note that this will not appear in the sidebar because we won’t actually pass any data to Quandl there. We have to wait for the user to click on a county, and thus will handle the data passing in a future code chunk. This sidebar has one purpose: for the user to select the code for the economic indicator.&lt;/p&gt;
&lt;p&gt;We want to give the user a drop-down of choices, but we don’t want the choices to be the Quandl codes. We want the choices to be the familiar names of the data sets. In other words, the user will see as a choice ‘GDP Per Capita’, instead of the Quandl code &lt;code&gt;_NY_GDP_PCAP_KN&lt;/code&gt;. For that reason, we’ll first create an object called &lt;code&gt;dataChoices&lt;/code&gt; that holds our name-value pairs. The name is the familiar title of the time series - for example, ’GDP Per Capita` - and the value is the Quandl code.&lt;/p&gt;
&lt;pre class=&#34;r&#34;&gt;&lt;code&gt;dataChoices &amp;lt;- c(&amp;quot;GDP Per Capita&amp;quot; = &amp;quot;_NY_GDP_PCAP_KN&amp;quot;,
                  &amp;quot;GDP Per Capita Growth&amp;quot; = &amp;quot;_NY_GDP_PCAP_KD_ZG&amp;quot;,
                  &amp;quot;Real Interest Rate&amp;quot; = &amp;quot;_FR_INR_RINR&amp;quot;,
                  &amp;quot;Exchange Rate&amp;quot; = &amp;quot;_PX_REX_REER&amp;quot;,
                  &amp;quot;CPI&amp;quot; = &amp;quot;_FP_CPI_TOTL_ZG&amp;quot;,
                  &amp;quot;Labor Force Part. Rate&amp;quot; = &amp;quot;_SL_TLF_ACTI_ZS&amp;quot;)&lt;/code&gt;&lt;/pre&gt;
&lt;p&gt;Next, in our &lt;code&gt;selectInput&lt;/code&gt; statement, we will set choices equal to &lt;code&gt;dataChoices&lt;/code&gt;, which will allow the user to see intuitive names but choose the Quandl codes.&lt;/p&gt;
&lt;pre class=&#34;r&#34;&gt;&lt;code&gt;selectInput(&amp;quot;indicatorSelect&amp;quot;, 
            &amp;quot;Choose an economic indicator&amp;quot;,
            # Give the user a choice from the object we created above.
            choices = dataChoices,
            selected = &amp;quot;GDP Per Capita&amp;quot;)&lt;/code&gt;&lt;/pre&gt;
&lt;p&gt;Our simple sidebar is finished, and the end result is that when a user makes a choice, we have an input reactive with the value of the data set code. Let’s put that code aside for a minute and turn our attention to the map.&lt;/p&gt;
&lt;p&gt;Remember, we did the map-building work on this in our &lt;a href=&#34;https://rviews.rstudio.com/2017/05/10/mapping-quandl-macroeconomic-data/&#34;&gt;Notebook&lt;/a&gt;, then loaded the object in the &lt;code&gt;setup&lt;/code&gt; code chunk. That leaves us with a simple call to &lt;code&gt;renderLeaflet()&lt;/code&gt; to pass it &lt;code&gt;leaf_world&lt;/code&gt;.&lt;/p&gt;
&lt;pre class=&#34;r&#34;&gt;&lt;code&gt;leafletOutput(&amp;quot;map1&amp;quot;)

output$map1 &amp;lt;- renderLeaflet({
  leaf_world
  })&lt;/code&gt;&lt;/pre&gt;
&lt;p&gt;Alright, that wasn’t too cumbersome, and perhaps the simplicity of that step makes the hard work in the previous Notebook a bit more tolerable.&lt;/p&gt;
&lt;p&gt;And now the fun part, wherein we build the machinery to let a user click the map and grab data from Quandl. We will proceed in four steps:&lt;/p&gt;
&lt;ul&gt;
&lt;li&gt;capture the country code of the country that gets clicked&lt;/li&gt;
&lt;li&gt;call the economic time series that the user selected in the sidebar&lt;/li&gt;
&lt;li&gt;paste the country code and the time series together to create one data set code&lt;/li&gt;
&lt;li&gt;pass that one data set code to Quandl and import the time series&lt;/li&gt;
&lt;/ul&gt;
&lt;p&gt;On to step 1, capturing the clicked country.&lt;/p&gt;
&lt;pre class=&#34;r&#34;&gt;&lt;code&gt;clickedCountry &amp;lt;- eventReactive(input$map1_shape_click, {
  return(input$map1_shape_click$id)
})&lt;/code&gt;&lt;/pre&gt;
&lt;p&gt;It’s same process we used in &lt;a href=&#34;https://rviews.rstudio.com/2016/12/16/reproducible-finance-with-r-a-shiny-etf-map/&#34;&gt;this post&lt;/a&gt;, but there is one difference. Let’s review what happened here.&lt;/p&gt;
&lt;p&gt;Recall that we set &lt;code&gt;layerID = ~iso_a3&lt;/code&gt; when we built the map in our Notebook. That’s because Quandl appends the iso_a3 country codes to the data set code. In other words, if we want GDP-per-capita for Brazil, we need the Brazil country code ‘BRA’ so we can later append it to the GDP-per-capita code ’_NY_GDP_PCAP_KN’.&lt;/p&gt;
&lt;p&gt;In the code chunk above, we used an &lt;code&gt;observeEvent&lt;/code&gt; function to capture the &lt;code&gt;layerID&lt;/code&gt; of whatever shape a user clicks, and in the Notebook, we had set that ID to be the &lt;code&gt;~isa_a3&lt;/code&gt; code. When a user clicks Brazil, our reactive captures the country code ‘BRA’.&lt;/p&gt;
&lt;p&gt;Next, we need to append that country code to the data set code. Recall that the user chose this code in our sidebar. We just need to grab his selection via another &lt;code&gt;reactive&lt;/code&gt;.&lt;/p&gt;
&lt;pre class=&#34;r&#34;&gt;&lt;code&gt;# Nothing fancy here, a reactive value from our sidebar input.
indicatorValue &amp;lt;- reactive({input$indicatorSelect})&lt;/code&gt;&lt;/pre&gt;
&lt;p&gt;Let’s pause and take inventory of what we have captured thus far: the country code from the click on the map is stored as &lt;code&gt;clickedCountry()&lt;/code&gt;, and the data set code from the sidebar is stored as &lt;code&gt;indicatorValue()&lt;/code&gt;. Now we want to paste those together and pass them to Quandl. We’ll do that via another &lt;code&gt;reactive&lt;/code&gt;, but we are also going to pass that pasted chain to Quandl in the reactive. Thus, the chunk below has one &lt;code&gt;reactive&lt;/code&gt; that does two things.&lt;/p&gt;
&lt;p&gt;First, it pastes together our inputs to form one data set code. Second, it passes that code to Quandl and returns the desired time series.&lt;/p&gt;
&lt;p&gt;Notice that when we paste the codes together, we start with &lt;code&gt;WWDI/&lt;/code&gt;. That’s because all of our data comes from the WWDI data source on Quandl. We are not letting the user choose a different data source. We could have done so in the sidebar, but consider how that would have complicated our data set code &lt;code&gt;reactive&lt;/code&gt; input in the sidebar.&lt;/p&gt;
&lt;p&gt;Back to our data import chunk wherein we create our data set code by pasting inputs together and then pass them to Quandl:&lt;/p&gt;
&lt;pre class=&#34;r&#34;&gt;&lt;code&gt;countryData &amp;lt;- reactive({
  
  # WWDI is the World Bank data set. 
  # We aren&amp;#39;t giving the user a choice of data sources, but we could.
  dataSet &amp;lt;- paste(&amp;quot;WWDI/&amp;quot;,
                   # The country that was clicked.
                   as.character(clickedCountry()),
                   # The time series that was chosen in the sidebar.
                   as.character(indicatorValue()), 
                   sep = &amp;quot;&amp;quot;)
  # Now pass that pasted data set code object to Quandl.
  Quandl(dataSet, type = &amp;quot;xts&amp;quot;)
})  &lt;/code&gt;&lt;/pre&gt;
&lt;p&gt;We now have an object called &lt;code&gt;countryData&lt;/code&gt; that is an &lt;code&gt;xts&lt;/code&gt; object imported from Quandl. It holds the time series (1) from the WWDI data source, (2) for the country that was clicked, (3) for the economic indicator that was chosen in the sidebar&lt;/p&gt;
&lt;p&gt;From a data import perspective, we’re done. We could fit a model to this data, run forecasts, etc., but I am going to head straight to visualization using &lt;code&gt;highcharter&lt;/code&gt;.&lt;/p&gt;
&lt;p&gt;As mentioned at the outset, &lt;code&gt;dygraph&lt;/code&gt; would have done a fine job here, but &lt;code&gt;highcharter&lt;/code&gt; seems to be a more popular visualization tool in the financial industry, and that’s a good reason to start exploring its capabilities.&lt;/p&gt;
&lt;p&gt;The code chunk below might look heavy, but most of the lines are for aesthetics, creating a nice title and removing scroll bars that seem clunky to me. The key substantive statements below are &lt;code&gt;highchart(type = &amp;quot;stock&amp;quot;)&lt;/code&gt; and &lt;code&gt;hc_add_series(countryData())&lt;/code&gt;.&lt;/p&gt;
&lt;p&gt;The first statement tells &lt;code&gt;highcharter&lt;/code&gt; to use its built-in stock format (this is good for graphing all sorts of economic time series, not just stocks), and the second passes our data object to the graphing function &lt;code&gt;hc_add_series&lt;/code&gt;. It’s a well-named function because it adds a series to the chart. If we wanted to include another series, we would use that same function and pass in another &lt;code&gt;xts&lt;/code&gt; object.&lt;/p&gt;
&lt;pre class=&#34;r&#34;&gt;&lt;code&gt;output$highchart &amp;lt;- renderHighchart({
  
  # Make a nice title for the chart.
  # The next three linese are purely aesthetic to that our graph has an intuitive
  # title. 
  indicatorName1 &amp;lt;- names(dataChoices[dataChoices == input$indicatorSelect])
  countryName1 &amp;lt;- countrycode(as.character(clickedCountry()), &amp;quot;iso3c&amp;quot;, &amp;quot;country.name&amp;quot;)
  title &amp;lt;- paste(countryName1, indicatorName1, sep = &amp;quot; &amp;quot;)
  
  # Call highchart and ask nicely for it to use the built-in &amp;#39;stock&amp;#39; format.
  highchart(type = &amp;quot;stock&amp;quot;) %&amp;gt;% 
    hc_title(text = title) %&amp;gt;%
    # Pass our time series object countryData to highcharter function hc_add_series.
    hc_add_series(countryData(), name = title) %&amp;gt;%
    # I don&amp;#39;t like the look of the navigator/scrollbar in a small space, but others might. 
    # Change these to enabled = TRUE and check out the results.
    hc_navigator(enabled = FALSE) %&amp;gt;% 
    hc_scrollbar(enabled = FALSE)
})&lt;/code&gt;&lt;/pre&gt;
&lt;p&gt;That’s all for today. This post completes what we can retrospectively consider our 3-part series of Quandl Shiny apps. The other two posts are &lt;a href=&#34;https://rviews.rstudio.com/2017/04/21/a-shiny-app-for-importing-and-forecasting-commodities-prices-from-quandl/&#34;&gt;here&lt;/a&gt; and &lt;a href=&#34;https://rviews.rstudio.com/2017/06/02/a-shiny-app-for-exploring-commodities-prices-and-economic-indicators-via-quandl/&#34;&gt;here&lt;/a&gt;. There are definitely interesting ways to combine the functionalities in these apps, but I’ll leave that to the awesome community of Shiny developers.&lt;/p&gt;
&lt;p&gt;See you next time, when we visit the wonderful world of portfolio theory and volatility!&lt;/p&gt;

        &lt;script&gt;window.location.href=&#39;https://rviews.rstudio.com/2017/06/14/mapping-quandl-data-with-shiny/&#39;;&lt;/script&gt;
      </description>
    </item>
    
    <item>
      <title>Sector Correlations</title>
      <link>https://rviews.rstudio.com/2017/01/18/reproducible-finance-with-r-sector-correlations/</link>
      <pubDate>Wed, 18 Jan 2017 00:00:00 +0000</pubDate>
      
      <guid>https://rviews.rstudio.com/2017/01/18/reproducible-finance-with-r-sector-correlations/</guid>
      <description>
        
&lt;script src=&#34;/rmarkdown-libs/htmlwidgets/htmlwidgets.js&#34;&gt;&lt;/script&gt;
&lt;script src=&#34;/rmarkdown-libs/jquery/jquery.min.js&#34;&gt;&lt;/script&gt;
&lt;link href=&#34;/rmarkdown-libs/dygraphs/dygraph.css&#34; rel=&#34;stylesheet&#34; /&gt;
&lt;script src=&#34;/rmarkdown-libs/dygraphs/dygraph-combined.js&#34;&gt;&lt;/script&gt;
&lt;script src=&#34;/rmarkdown-libs/moment/moment.js&#34;&gt;&lt;/script&gt;
&lt;script src=&#34;/rmarkdown-libs/moment-timezone/moment-timezone-with-data.js&#34;&gt;&lt;/script&gt;
&lt;script src=&#34;/rmarkdown-libs/moment-fquarter/moment-fquarter.min.js&#34;&gt;&lt;/script&gt;
&lt;script src=&#34;/rmarkdown-libs/dygraphs-binding/dygraphs.js&#34;&gt;&lt;/script&gt;

&lt;p&gt;Welcome to the first installation of reproducible finance for 2017. It’s a new year, a new President takes office soon, and we could be entering a new political-economic environment. What better time to think about a popular topic over the last few years: equity correlations. Elevated correlations are important for several reasons - life is hard for active managers and diversification gains are vanishing - but I personally enjoy thinking about them more from an inference or data exploration perspective. Are changning correlations telling us something about the world? Are sectors diverging? How much can be attributed to the Central Bank regime at hand? So many questions, so many hypotheses to be explored. Let’s get started.&lt;/p&gt;
&lt;p&gt;Today, we will build a Notebook and start exploring the historical rolling correlations between sector ETFs and the S&amp;amp;P 500. That is, we want to explore how equity returns in different sectors have been correlated with the returns of the broader index. Perhaps they are all moving in lockstep, perhaps they have been diverging. Either way, this Notebook will be the first step toward an flexdashboard that lets us do more interactive exploration - choosing different sector ETFs and rolling windows.&lt;/p&gt;
&lt;p&gt;We are going to accomplish a few things today. We will load up the sector ETF tickers, then build a function to download their price history and calculate weekly returns. We will save this to one xts object. Next we will build a function to calculate the rolling correlations between a chosen sector ETF and the S&amp;amp;P 500. Finally, dygraphs will make its usual appearance to help visualize the rolling correlation time series.&lt;/p&gt;
&lt;p&gt;As usual, we will be living in the Rmarkdown world and, by way of disclaimer, the data import and return calculation functions here should be familiar from previous posts. That is by design and hopefully, it won’t be too boring for devotees of this series (I know you’re out there somewhere!). More importantly, I hope the usefulness of reproducible, reusable code is emerging. Some of the code chunks in previous posts might have seemed trivially simple, containing just a simple function and little else. But, the simplicity of those code chunks made it very easy to return to those previous scripts, understand the functions, and use them in this post.&lt;/p&gt;
&lt;p&gt;Let’s load up a few packages.&lt;/p&gt;
&lt;pre class=&#34;r&#34;&gt;&lt;code&gt;library(dplyr)
library(quantmod)
library(dygraphs)&lt;/code&gt;&lt;/pre&gt;
&lt;p&gt;Now, we need the tickers and sectors for the sector ETFs. They are copied below and available &lt;a href=&#34;http://www.sectorspdr.com/sectorspdr/&#34;&gt;here&lt;/a&gt;. I deleted the XLRE real estate ETF because it’s only been around since 2015 and I want look back several years in this Notebook.&lt;/p&gt;
&lt;pre class=&#34;r&#34;&gt;&lt;code&gt;# List of tickers for sector etfs. 
# Omit XLRE because its inception is 2015. Not really enough to check out long term monthly correlations. 

ticker &amp;lt;- c(&amp;quot;XLY&amp;quot;, &amp;quot;XLP&amp;quot;, &amp;quot;XLE&amp;quot;,    &amp;quot;XLF&amp;quot;, &amp;quot;XLV&amp;quot;,   
            &amp;quot;XLI&amp;quot;, &amp;quot;XLB&amp;quot;, &amp;quot;XLK&amp;quot;, &amp;quot;XLU&amp;quot;, &amp;quot;SPY&amp;quot;)  

# And the accompanying sector names for those ETFs.

sector &amp;lt;- c(&amp;quot;Consumer Discretionary&amp;quot;, &amp;quot;Consumer Staples&amp;quot;, 
            &amp;quot;Energy&amp;quot;, &amp;quot;Financials&amp;quot;, &amp;quot;Health Care&amp;quot;, &amp;quot;Industrials&amp;quot;, 
            &amp;quot;Materials&amp;quot;, &amp;quot;Information Technology&amp;quot;, &amp;quot;Utilities&amp;quot;, &amp;quot;Index&amp;quot;)

etf_ticker_sector &amp;lt;- data_frame(ticker, sector)

etf_ticker_sector&lt;/code&gt;&lt;/pre&gt;
&lt;pre&gt;&lt;code&gt;## # A tibble: 10 × 2
##    ticker                 sector
##     &amp;lt;chr&amp;gt;                  &amp;lt;chr&amp;gt;
## 1     XLY Consumer Discretionary
## 2     XLP       Consumer Staples
## 3     XLE                 Energy
## 4     XLF             Financials
## 5     XLV            Health Care
## 6     XLI            Industrials
## 7     XLB              Materials
## 8     XLK Information Technology
## 9     XLU              Utilities
## 10    SPY                  Index&lt;/code&gt;&lt;/pre&gt;
&lt;p&gt;We’ve got our dataframe of tickers and sectors. Let’s build a function to download price history and then convert those price histories to weekly returns. We’ll use a combination of getSymbols() and periodReturn() to accomplish that. If you want to change this script to use daily returns, change the argument below to period = ‘daily’, but be prepared to import quite a bit more data.&lt;/p&gt;
&lt;pre class=&#34;r&#34;&gt;&lt;code&gt;# A function to build an xts object of etf returns.

etf_weekly_returns &amp;lt;- function(ticker) {
    
symbols &amp;lt;- getSymbols(ticker, auto.assign = TRUE, warnings = FALSE)

etf_prices &amp;lt;- do.call(merge, lapply(symbols, function(x) Cl(get(x))))
    
etf_returns &amp;lt;- do.call(merge, lapply(etf_prices, 
                                     function(x) periodReturn(x, period = &amp;#39;weekly&amp;#39;, type = &amp;#39;log&amp;#39;)))

#Change the column names to the sector names from our dataframe above.

colnames(etf_returns) &amp;lt;- etf_ticker_sector$sector
    
etf_returns

}

# Let&amp;#39;s pass in our ticker symbols and build an xts object of etf returns
etf_returns &amp;lt;- etf_weekly_returns(etf_ticker_sector$ticker)&lt;/code&gt;&lt;/pre&gt;
&lt;pre&gt;&lt;code&gt;##     As of 0.4-0, &amp;#39;getSymbols&amp;#39; uses env=parent.frame() and
##  auto.assign=TRUE by default.
## 
##  This  behavior  will be  phased out in 0.5-0  when the call  will
##  default to use auto.assign=FALSE. getOption(&amp;quot;getSymbols.env&amp;quot;) and 
##  getOptions(&amp;quot;getSymbols.auto.assign&amp;quot;) are now checked for alternate defaults
## 
##  This message is shown once per session and may be disabled by setting 
##  options(&amp;quot;getSymbols.warning4.0&amp;quot;=FALSE). See ?getSymbols for more details.&lt;/code&gt;&lt;/pre&gt;
&lt;pre&gt;&lt;code&gt;## pausing 1 second between requests for more than 5 symbols
## pausing 1 second between requests for more than 5 symbols
## pausing 1 second between requests for more than 5 symbols
## pausing 1 second between requests for more than 5 symbols
## pausing 1 second between requests for more than 5 symbols
## pausing 1 second between requests for more than 5 symbols&lt;/code&gt;&lt;/pre&gt;
&lt;pre class=&#34;r&#34;&gt;&lt;code&gt;head(etf_returns)&lt;/code&gt;&lt;/pre&gt;
&lt;pre&gt;&lt;code&gt;##            Consumer Discretionary Consumer Staples       Energy
## 2007-01-05           -0.007034027     -0.005722007 -0.011733539
## 2007-01-12            0.026062578      0.014055350 -0.008620725
## 2007-01-19            0.008875499      0.003765102  0.020354264
## 2007-01-26           -0.019888442     -0.004519819  0.004760584
## 2007-02-02            0.022409825      0.011634547  0.030830343
## 2007-02-09           -0.006315545     -0.010502685 -0.004101903
##              Financials  Health Care  Industrials     Materials
## 2007-01-05 -0.011167160  0.005655589 -0.007693470 -0.0113323889
## 2007-01-12  0.013331718  0.017361037  0.017579216  0.0290876947
## 2007-01-19 -0.001081666  0.011312637  0.001123511  0.0152115609
## 2007-01-26 -0.003795098 -0.012772249 -0.011577145  0.0086291974
## 2007-02-02  0.015362168  0.014501414  0.027452705  0.0151288535
## 2007-02-09 -0.005901386 -0.005485765 -0.009439299 -0.0008194183
##            Information Technology    Utilities        Index
## 2007-01-05            0.007260335 -0.019471313 -0.005888436
## 2007-01-12            0.021886396 -0.006668599  0.019029484
## 2007-01-19           -0.027005903  0.005005572 -0.002936435
## 2007-01-26           -0.001283929  0.005532545 -0.004842978
## 2007-02-02            0.016985546  0.023177534  0.018680358
## 2007-02-09           -0.008881386  0.025021348 -0.006025965&lt;/code&gt;&lt;/pre&gt;
&lt;p&gt;This function has done some good work for us and it was refreshingly comfortable to put in place because we used very similar functionality in this &lt;a href=&#34;https://www.rstudio.com/rviews/2016/11/09/reproducible-finance-with-r-the-sharpe-ratio/&#34;&gt;post&lt;/a&gt; and this &lt;a href=&#34;https://www.rstudio.com/rviews/2016/12/14/reproducible-finance-with-r-pulling-and-displaying-etf-data/&#34;&gt;post&lt;/a&gt;.&lt;/p&gt;
&lt;p&gt;A pattern seems to be emerging in these Notebooks: grab tickers, get price history, convert to returns and save new xts object. In an ideal world, that pattern of data import and conversion is getting so familiar as to be commonplace.&lt;/p&gt;
&lt;p&gt;That said, enough with the commonplace stuff - let’s get on to something a little more dangerous: rolling correlations amongst etf returns. Correlations are important because high correlations make it hard to find diversification opportunities and they make it hard to deliver alpha - though I suppose it’s always hard to deliver alpha. Fortunately, we don’t have to worry about generating alpha today so let’s get to our function.&lt;/p&gt;
&lt;p&gt;Calculating rolling correlations in R is pretty straightforward. We use the rollapply() function, along with the cor() function, pass in our data and a time window, and it’s off to the races. We’ll create our own function below to handle these jobs and return an xts object.&lt;/p&gt;
&lt;pre class=&#34;r&#34;&gt;&lt;code&gt;# A function that calculates the rolling correlation between a sector ETF and the SPY SP500 ETF. 

sector_index_correlation &amp;lt;- function(x, window) {
  
    merged_xts &amp;lt;- merge(x, etf_returns$&amp;#39;Index&amp;#39;)

    merged_xts$rolling_test &amp;lt;- rollapply(merged_xts, window, 
                                         function(x) cor(x[,1], x[,2], use = &amp;quot;pairwise.complete.obs&amp;quot;), 
                                         by.column = FALSE)
    
    names(merged_xts) &amp;lt;- c(&amp;quot;Sector Returns&amp;quot;, &amp;quot;SPY Returns&amp;quot;, &amp;quot;Sector/SPY Correlation&amp;quot;)
    
    merged_xts
}&lt;/code&gt;&lt;/pre&gt;
&lt;p&gt;Notice that this function does something that seems unnecessary: it creates a new xts object that holds the sector returns, SPY returns and the rolling correlation. We don’t have much use for that separate object and could probably have just added columns to our original xts object. Indeed, if this were our final product we might spend more time eliminating its present. I choose not to do that here for two reasons. First, this Notebook is built to underlie a flexdashboard that could go into production. I want to get the logic right here, then focus more on efficiency in the final app.&lt;/p&gt;
&lt;p&gt;Second, and relatedly, we are prioritizing clarity of workflow in this Notebook. It should be crystal clear how we are moving from an xts object of ETF returns to creating a new XTS object of two returns plus one correlation. The goal is for any collaborators, including my future self, to open this Notebook and see the workflow. If that collaboarator finds this step to be unnecessary and has a more clever solution - that’s fantastic because it means this document is intellegible enough to serve as the basis for more sophisticated work.&lt;/p&gt;
&lt;p&gt;Let’s go ahead and use this function. We will pass in a time series of Information Technology ETF returns and a window of size 20 for the rolling correlation.&lt;/p&gt;
&lt;pre class=&#34;r&#34;&gt;&lt;code&gt;# Choose a sector ETF and a rolling window and pass them to the function we just build. 
# Let&amp;#39;s go with a 5 month window and the Information Technology sector.
# We will now have a new xts object with 3 time series: sector returns, SPY returns
# and the rolling correlation between those return series.

IT_SPY_correlation &amp;lt;- sector_index_correlation(etf_returns$&amp;#39;Information Technology&amp;#39;, 20)

# Have a peek. The first 20 rows in the correlation column should be 
# NAs. 

head(IT_SPY_correlation, n = 25)&lt;/code&gt;&lt;/pre&gt;
&lt;pre&gt;&lt;code&gt;##            Sector Returns   SPY Returns Sector/SPY Correlation
## 2007-01-05    0.007260335 -0.0058884356                     NA
## 2007-01-12    0.021886396  0.0190294841                     NA
## 2007-01-19   -0.027005903 -0.0029364349                     NA
## 2007-01-26   -0.001283929 -0.0048429782                     NA
## 2007-02-02    0.016985546  0.0186803576                     NA
## 2007-02-09   -0.008881386 -0.0060259646                     NA
## 2007-02-16    0.015177315  0.0123590071                     NA
## 2007-02-23    0.003341691 -0.0029549759                     NA
## 2007-03-02   -0.057501940 -0.0467035959                     NA
## 2007-03-09    0.015776007  0.0151013857                     NA
## 2007-03-16   -0.002176236 -0.0161114796                     NA
## 2007-03-23    0.026656737  0.0344812823                     NA
## 2007-03-30   -0.010663355 -0.0097411262                     NA
## 2007-04-05    0.022892097  0.0156515560                     NA
## 2007-04-13    0.001256461  0.0074596420                     NA
## 2007-04-20    0.014131615  0.0224544236                     NA
## 2007-04-27    0.015561370  0.0061043558                     NA
## 2007-05-04    0.016122840  0.0092528469                     NA
## 2007-05-11    0.007171385 -0.0003976208                     NA
## 2007-05-18    0.004752405  0.0115988780              0.8820099
## 2007-05-25   -0.004752405 -0.0061121613              0.8963962
## 2007-06-01    0.018096442  0.0156329832              0.8946237
## 2007-06-08   -0.012159397 -0.0199273050              0.9301269
## 2007-06-15    0.017214861  0.0133507228              0.9311254
## 2007-06-22   -0.009744766 -0.0166001040              0.9302817&lt;/code&gt;&lt;/pre&gt;
&lt;p&gt;Alright, the function seems to have succeeded in building that new xts object and storing the rolling correlation. Now we will use dygraphs to visualize this rolling correlation over time and see if anything jumps out as interesting or puzzling.&lt;/p&gt;
&lt;pre class=&#34;r&#34;&gt;&lt;code&gt;# Let&amp;#39;s graph the sector/index rolling correlation using our old friend dygraphs. 
# I&amp;#39;ll add an event for the financial crisis and shade the recession of 2007-2009 with 
# an unimposing pink hue.

dygraph(IT_SPY_correlation$&amp;#39;Sector/SPY Correlation&amp;#39;, main = &amp;quot;Correlation between SP500 and Tech ETF&amp;quot;) %&amp;gt;% 
    dyAxis(&amp;quot;y&amp;quot;, label = &amp;quot;Correlation&amp;quot;) %&amp;gt;% 
    dyRangeSelector(height = 20) %&amp;gt;%
    dyShading(from = &amp;quot;2007-12-01&amp;quot;, to = &amp;quot;2009-06-01&amp;quot;, color = &amp;quot;#FFE6E6&amp;quot;) %&amp;gt;% 
    dyEvent(x = &amp;quot;2008-09-15&amp;quot;, label = &amp;quot;Fin Crisis&amp;quot;, labelLoc = &amp;quot;top&amp;quot;, color = &amp;quot;red&amp;quot;)&lt;/code&gt;&lt;/pre&gt;
&lt;div id=&#34;htmlwidget-3bef70aed8f61b38658e&#34; style=&#34;width:672px;height:480px;&#34; class=&#34;dygraphs html-widget&#34;&gt;&lt;/div&gt;
&lt;script type=&#34;application/json&#34; data-for=&#34;htmlwidget-3bef70aed8f61b38658e&#34;&gt;{&#34;x&#34;:{&#34;attrs&#34;:{&#34;axes&#34;:{&#34;x&#34;:{&#34;pixelsPerLabel&#34;:60},&#34;y&#34;:[]},&#34;title&#34;:&#34;Correlation between SP500 and Tech ETF&#34;,&#34;labels&#34;:[&#34;week&#34;,&#34;Sector/SPY Correlation&#34;],&#34;legend&#34;:&#34;auto&#34;,&#34;retainDateWindow&#34;:false,&#34;ylabel&#34;:&#34;Correlation&#34;,&#34;showRangeSelector&#34;:true,&#34;rangeSelectorHeight&#34;:20,&#34;rangeSelectorPlotFillColor&#34;:&#34; #A7B1C4&#34;,&#34;rangeSelectorPlotStrokeColor&#34;:&#34;#808FAB&#34;,&#34;interactionModel&#34;:&#34;Dygraph.Interaction.defaultModel&#34;},&#34;scale&#34;:&#34;weekly&#34;,&#34;annotations&#34;:[],&#34;shadings&#34;:[{&#34;from&#34;:&#34;2007-12-01T00:00:00.000Z&#34;,&#34;to&#34;:&#34;2009-06-01T00:00:00.000Z&#34;,&#34;color&#34;:&#34;#FFE6E6&#34;,&#34;axis&#34;:&#34;x&#34;}],&#34;events&#34;:[{&#34;pos&#34;:&#34;2008-09-15T00:00:00.000Z&#34;,&#34;label&#34;:&#34;Fin Crisis&#34;,&#34;labelLoc&#34;:&#34;top&#34;,&#34;color&#34;:&#34;red&#34;,&#34;strokePattern&#34;:[7,3],&#34;axis&#34;:&#34;x&#34;}],&#34;format&#34;:&#34;date&#34;,&#34;data&#34;:[[&#34;2007-01-05T00:00:00.000Z&#34;,&#34;2007-01-12T00:00:00.000Z&#34;,&#34;2007-01-19T00:00:00.000Z&#34;,&#34;2007-01-26T00:00:00.000Z&#34;,&#34;2007-02-02T00:00:00.000Z&#34;,&#34;2007-02-09T00:00:00.000Z&#34;,&#34;2007-02-16T00:00:00.000Z&#34;,&#34;2007-02-23T00:00:00.000Z&#34;,&#34;2007-03-02T00:00:00.000Z&#34;,&#34;2007-03-09T00:00:00.000Z&#34;,&#34;2007-03-16T00:00:00.000Z&#34;,&#34;2007-03-23T00:00:00.000Z&#34;,&#34;2007-03-30T00:00:00.000Z&#34;,&#34;2007-04-05T00:00:00.000Z&#34;,&#34;2007-04-13T00:00:00.000Z&#34;,&#34;2007-04-20T00:00:00.000Z&#34;,&#34;2007-04-27T00:00:00.000Z&#34;,&#34;2007-05-04T00:00:00.000Z&#34;,&#34;2007-05-11T00:00:00.000Z&#34;,&#34;2007-05-18T00:00:00.000Z&#34;,&#34;2007-05-25T00:00:00.000Z&#34;,&#34;2007-06-01T00:00:00.000Z&#34;,&#34;2007-06-08T00:00:00.000Z&#34;,&#34;2007-06-15T00:00:00.000Z&#34;,&#34;2007-06-22T00:00:00.000Z&#34;,&#34;2007-06-29T00:00:00.000Z&#34;,&#34;2007-07-06T00:00:00.000Z&#34;,&#34;2007-07-13T00:00:00.000Z&#34;,&#34;2007-07-20T00:00:00.000Z&#34;,&#34;2007-07-27T00:00:00.000Z&#34;,&#34;2007-08-03T00:00:00.000Z&#34;,&#34;2007-08-10T00:00:00.000Z&#34;,&#34;2007-08-17T00:00:00.000Z&#34;,&#34;2007-08-24T00:00:00.000Z&#34;,&#34;2007-08-31T00:00:00.000Z&#34;,&#34;2007-09-07T00:00:00.000Z&#34;,&#34;2007-09-14T00:00:00.000Z&#34;,&#34;2007-09-21T00:00:00.000Z&#34;,&#34;2007-09-28T00:00:00.000Z&#34;,&#34;2007-10-05T00:00:00.000Z&#34;,&#34;2007-10-12T00:00:00.000Z&#34;,&#34;2007-10-19T00:00:00.000Z&#34;,&#34;2007-10-26T00:00:00.000Z&#34;,&#34;2007-11-02T00:00:00.000Z&#34;,&#34;2007-11-09T00:00:00.000Z&#34;,&#34;2007-11-16T00:00:00.000Z&#34;,&#34;2007-11-23T00:00:00.000Z&#34;,&#34;2007-11-30T00:00:00.000Z&#34;,&#34;2007-12-07T00:00:00.000Z&#34;,&#34;2007-12-14T00:00:00.000Z&#34;,&#34;2007-12-21T00:00:00.000Z&#34;,&#34;2007-12-28T00:00:00.000Z&#34;,&#34;2008-01-04T00:00:00.000Z&#34;,&#34;2008-01-11T00:00:00.000Z&#34;,&#34;2008-01-18T00:00:00.000Z&#34;,&#34;2008-01-25T00:00:00.000Z&#34;,&#34;2008-02-01T00:00:00.000Z&#34;,&#34;2008-02-08T00:00:00.000Z&#34;,&#34;2008-02-15T00:00:00.000Z&#34;,&#34;2008-02-22T00:00:00.000Z&#34;,&#34;2008-02-29T00:00:00.000Z&#34;,&#34;2008-03-07T00:00:00.000Z&#34;,&#34;2008-03-14T00:00:00.000Z&#34;,&#34;2008-03-20T00:00:00.000Z&#34;,&#34;2008-03-28T00:00:00.000Z&#34;,&#34;2008-04-04T00:00:00.000Z&#34;,&#34;2008-04-11T00:00:00.000Z&#34;,&#34;2008-04-18T00:00:00.000Z&#34;,&#34;2008-04-25T00:00:00.000Z&#34;,&#34;2008-05-02T00:00:00.000Z&#34;,&#34;2008-05-09T00:00:00.000Z&#34;,&#34;2008-05-16T00:00:00.000Z&#34;,&#34;2008-05-23T00:00:00.000Z&#34;,&#34;2008-05-30T00:00:00.000Z&#34;,&#34;2008-06-06T00:00:00.000Z&#34;,&#34;2008-06-13T00:00:00.000Z&#34;,&#34;2008-06-20T00:00:00.000Z&#34;,&#34;2008-06-27T00:00:00.000Z&#34;,&#34;2008-07-03T00:00:00.000Z&#34;,&#34;2008-07-11T00:00:00.000Z&#34;,&#34;2008-07-18T00:00:00.000Z&#34;,&#34;2008-07-25T00:00:00.000Z&#34;,&#34;2008-08-01T00:00:00.000Z&#34;,&#34;2008-08-08T00:00:00.000Z&#34;,&#34;2008-08-15T00:00:00.000Z&#34;,&#34;2008-08-22T00:00:00.000Z&#34;,&#34;2008-08-29T00:00:00.000Z&#34;,&#34;2008-09-05T00:00:00.000Z&#34;,&#34;2008-09-12T00:00:00.000Z&#34;,&#34;2008-09-19T00:00:00.000Z&#34;,&#34;2008-09-26T00:00:00.000Z&#34;,&#34;2008-10-03T00:00:00.000Z&#34;,&#34;2008-10-10T00:00:00.000Z&#34;,&#34;2008-10-17T00:00:00.000Z&#34;,&#34;2008-10-24T00:00:00.000Z&#34;,&#34;2008-10-31T00:00:00.000Z&#34;,&#34;2008-11-07T00:00:00.000Z&#34;,&#34;2008-11-14T00:00:00.000Z&#34;,&#34;2008-11-21T00:00:00.000Z&#34;,&#34;2008-11-28T00:00:00.000Z&#34;,&#34;2008-12-05T00:00:00.000Z&#34;,&#34;2008-12-12T00:00:00.000Z&#34;,&#34;2008-12-19T00:00:00.000Z&#34;,&#34;2008-12-26T00:00:00.000Z&#34;,&#34;2009-01-02T00:00:00.000Z&#34;,&#34;2009-01-09T00:00:00.000Z&#34;,&#34;2009-01-16T00:00:00.000Z&#34;,&#34;2009-01-23T00:00:00.000Z&#34;,&#34;2009-01-30T00:00:00.000Z&#34;,&#34;2009-02-06T00:00:00.000Z&#34;,&#34;2009-02-13T00:00:00.000Z&#34;,&#34;2009-02-20T00:00:00.000Z&#34;,&#34;2009-02-27T00:00:00.000Z&#34;,&#34;2009-03-06T00:00:00.000Z&#34;,&#34;2009-03-13T00:00:00.000Z&#34;,&#34;2009-03-20T00:00:00.000Z&#34;,&#34;2009-03-27T00:00:00.000Z&#34;,&#34;2009-04-03T00:00:00.000Z&#34;,&#34;2009-04-09T00:00:00.000Z&#34;,&#34;2009-04-17T00:00:00.000Z&#34;,&#34;2009-04-24T00:00:00.000Z&#34;,&#34;2009-05-01T00:00:00.000Z&#34;,&#34;2009-05-08T00:00:00.000Z&#34;,&#34;2009-05-15T00:00:00.000Z&#34;,&#34;2009-05-22T00:00:00.000Z&#34;,&#34;2009-05-29T00:00:00.000Z&#34;,&#34;2009-06-05T00:00:00.000Z&#34;,&#34;2009-06-12T00:00:00.000Z&#34;,&#34;2009-06-19T00:00:00.000Z&#34;,&#34;2009-06-26T00:00:00.000Z&#34;,&#34;2009-07-02T00:00:00.000Z&#34;,&#34;2009-07-10T00:00:00.000Z&#34;,&#34;2009-07-17T00:00:00.000Z&#34;,&#34;2009-07-24T00:00:00.000Z&#34;,&#34;2009-07-31T00:00:00.000Z&#34;,&#34;2009-08-07T00:00:00.000Z&#34;,&#34;2009-08-14T00:00:00.000Z&#34;,&#34;2009-08-21T00:00:00.000Z&#34;,&#34;2009-08-28T00:00:00.000Z&#34;,&#34;2009-09-04T00:00:00.000Z&#34;,&#34;2009-09-11T00:00:00.000Z&#34;,&#34;2009-09-18T00:00:00.000Z&#34;,&#34;2009-09-25T00:00:00.000Z&#34;,&#34;2009-10-02T00:00:00.000Z&#34;,&#34;2009-10-09T00:00:00.000Z&#34;,&#34;2009-10-16T00:00:00.000Z&#34;,&#34;2009-10-23T00:00:00.000Z&#34;,&#34;2009-10-30T00:00:00.000Z&#34;,&#34;2009-11-06T00:00:00.000Z&#34;,&#34;2009-11-13T00:00:00.000Z&#34;,&#34;2009-11-20T00:00:00.000Z&#34;,&#34;2009-11-27T00:00:00.000Z&#34;,&#34;2009-12-04T00:00:00.000Z&#34;,&#34;2009-12-11T00:00:00.000Z&#34;,&#34;2009-12-18T00:00:00.000Z&#34;,&#34;2009-12-24T00:00:00.000Z&#34;,&#34;2009-12-31T00:00:00.000Z&#34;,&#34;2010-01-08T00:00:00.000Z&#34;,&#34;2010-01-15T00:00:00.000Z&#34;,&#34;2010-01-22T00:00:00.000Z&#34;,&#34;2010-01-29T00:00:00.000Z&#34;,&#34;2010-02-05T00:00:00.000Z&#34;,&#34;2010-02-12T00:00:00.000Z&#34;,&#34;2010-02-19T00:00:00.000Z&#34;,&#34;2010-02-26T00:00:00.000Z&#34;,&#34;2010-03-05T00:00:00.000Z&#34;,&#34;2010-03-12T00:00:00.000Z&#34;,&#34;2010-03-19T00:00:00.000Z&#34;,&#34;2010-03-26T00:00:00.000Z&#34;,&#34;2010-04-01T00:00:00.000Z&#34;,&#34;2010-04-09T00:00:00.000Z&#34;,&#34;2010-04-16T00:00:00.000Z&#34;,&#34;2010-04-23T00:00:00.000Z&#34;,&#34;2010-04-30T00:00:00.000Z&#34;,&#34;2010-05-07T00:00:00.000Z&#34;,&#34;2010-05-14T00:00:00.000Z&#34;,&#34;2010-05-21T00:00:00.000Z&#34;,&#34;2010-05-28T00:00:00.000Z&#34;,&#34;2010-06-04T00:00:00.000Z&#34;,&#34;2010-06-11T00:00:00.000Z&#34;,&#34;2010-06-18T00:00:00.000Z&#34;,&#34;2010-06-25T00:00:00.000Z&#34;,&#34;2010-07-02T00:00:00.000Z&#34;,&#34;2010-07-09T00:00:00.000Z&#34;,&#34;2010-07-16T00:00:00.000Z&#34;,&#34;2010-07-23T00:00:00.000Z&#34;,&#34;2010-07-30T00:00:00.000Z&#34;,&#34;2010-08-06T00:00:00.000Z&#34;,&#34;2010-08-13T00:00:00.000Z&#34;,&#34;2010-08-20T00:00:00.000Z&#34;,&#34;2010-08-27T00:00:00.000Z&#34;,&#34;2010-09-03T00:00:00.000Z&#34;,&#34;2010-09-10T00:00:00.000Z&#34;,&#34;2010-09-17T00:00:00.000Z&#34;,&#34;2010-09-24T00:00:00.000Z&#34;,&#34;2010-10-01T00:00:00.000Z&#34;,&#34;2010-10-08T00:00:00.000Z&#34;,&#34;2010-10-15T00:00:00.000Z&#34;,&#34;2010-10-22T00:00:00.000Z&#34;,&#34;2010-10-29T00:00:00.000Z&#34;,&#34;2010-11-05T00:00:00.000Z&#34;,&#34;2010-11-12T00:00:00.000Z&#34;,&#34;2010-11-19T00:00:00.000Z&#34;,&#34;2010-11-26T00:00:00.000Z&#34;,&#34;2010-12-03T00:00:00.000Z&#34;,&#34;2010-12-10T00:00:00.000Z&#34;,&#34;2010-12-17T00:00:00.000Z&#34;,&#34;2010-12-23T00:00:00.000Z&#34;,&#34;2010-12-31T00:00:00.000Z&#34;,&#34;2011-01-07T00:00:00.000Z&#34;,&#34;2011-01-14T00:00:00.000Z&#34;,&#34;2011-01-21T00:00:00.000Z&#34;,&#34;2011-01-28T00:00:00.000Z&#34;,&#34;2011-02-04T00:00:00.000Z&#34;,&#34;2011-02-11T00:00:00.000Z&#34;,&#34;2011-02-18T00:00:00.000Z&#34;,&#34;2011-02-25T00:00:00.000Z&#34;,&#34;2011-03-04T00:00:00.000Z&#34;,&#34;2011-03-11T00:00:00.000Z&#34;,&#34;2011-03-18T00:00:00.000Z&#34;,&#34;2011-03-25T00:00:00.000Z&#34;,&#34;2011-04-01T00:00:00.000Z&#34;,&#34;2011-04-08T00:00:00.000Z&#34;,&#34;2011-04-15T00:00:00.000Z&#34;,&#34;2011-04-21T00:00:00.000Z&#34;,&#34;2011-04-29T00:00:00.000Z&#34;,&#34;2011-05-06T00:00:00.000Z&#34;,&#34;2011-05-13T00:00:00.000Z&#34;,&#34;2011-05-20T00:00:00.000Z&#34;,&#34;2011-05-27T00:00:00.000Z&#34;,&#34;2011-06-03T00:00:00.000Z&#34;,&#34;2011-06-10T00:00:00.000Z&#34;,&#34;2011-06-17T00:00:00.000Z&#34;,&#34;2011-06-24T00:00:00.000Z&#34;,&#34;2011-07-01T00:00:00.000Z&#34;,&#34;2011-07-08T00:00:00.000Z&#34;,&#34;2011-07-15T00:00:00.000Z&#34;,&#34;2011-07-22T00:00:00.000Z&#34;,&#34;2011-07-29T00:00:00.000Z&#34;,&#34;2011-08-05T00:00:00.000Z&#34;,&#34;2011-08-12T00:00:00.000Z&#34;,&#34;2011-08-19T00:00:00.000Z&#34;,&#34;2011-08-26T00:00:00.000Z&#34;,&#34;2011-09-02T00:00:00.000Z&#34;,&#34;2011-09-09T00:00:00.000Z&#34;,&#34;2011-09-16T00:00:00.000Z&#34;,&#34;2011-09-23T00:00:00.000Z&#34;,&#34;2011-09-30T00:00:00.000Z&#34;,&#34;2011-10-07T00:00:00.000Z&#34;,&#34;2011-10-14T00:00:00.000Z&#34;,&#34;2011-10-21T00:00:00.000Z&#34;,&#34;2011-10-28T00:00:00.000Z&#34;,&#34;2011-11-04T00:00:00.000Z&#34;,&#34;2011-11-11T00:00:00.000Z&#34;,&#34;2011-11-18T00:00:00.000Z&#34;,&#34;2011-11-25T00:00:00.000Z&#34;,&#34;2011-12-02T00:00:00.000Z&#34;,&#34;2011-12-09T00:00:00.000Z&#34;,&#34;2011-12-16T00:00:00.000Z&#34;,&#34;2011-12-23T00:00:00.000Z&#34;,&#34;2011-12-30T00:00:00.000Z&#34;,&#34;2012-01-06T00:00:00.000Z&#34;,&#34;2012-01-13T00:00:00.000Z&#34;,&#34;2012-01-20T00:00:00.000Z&#34;,&#34;2012-01-27T00:00:00.000Z&#34;,&#34;2012-02-03T00:00:00.000Z&#34;,&#34;2012-02-10T00:00:00.000Z&#34;,&#34;2012-02-17T00:00:00.000Z&#34;,&#34;2012-02-24T00:00:00.000Z&#34;,&#34;2012-03-02T00:00:00.000Z&#34;,&#34;2012-03-09T00:00:00.000Z&#34;,&#34;2012-03-16T00:00:00.000Z&#34;,&#34;2012-03-23T00:00:00.000Z&#34;,&#34;2012-03-30T00:00:00.000Z&#34;,&#34;2012-04-05T00:00:00.000Z&#34;,&#34;2012-04-13T00:00:00.000Z&#34;,&#34;2012-04-20T00:00:00.000Z&#34;,&#34;2012-04-27T00:00:00.000Z&#34;,&#34;2012-05-04T00:00:00.000Z&#34;,&#34;2012-05-11T00:00:00.000Z&#34;,&#34;2012-05-18T00:00:00.000Z&#34;,&#34;2012-05-25T00:00:00.000Z&#34;,&#34;2012-06-01T00:00:00.000Z&#34;,&#34;2012-06-08T00:00:00.000Z&#34;,&#34;2012-06-15T00:00:00.000Z&#34;,&#34;2012-06-22T00:00:00.000Z&#34;,&#34;2012-06-29T00:00:00.000Z&#34;,&#34;2012-07-06T00:00:00.000Z&#34;,&#34;2012-07-13T00:00:00.000Z&#34;,&#34;2012-07-20T00:00:00.000Z&#34;,&#34;2012-07-27T00:00:00.000Z&#34;,&#34;2012-08-03T00:00:00.000Z&#34;,&#34;2012-08-10T00:00:00.000Z&#34;,&#34;2012-08-17T00:00:00.000Z&#34;,&#34;2012-08-24T00:00:00.000Z&#34;,&#34;2012-08-31T00:00:00.000Z&#34;,&#34;2012-09-07T00:00:00.000Z&#34;,&#34;2012-09-14T00:00:00.000Z&#34;,&#34;2012-09-21T00:00:00.000Z&#34;,&#34;2012-09-28T00:00:00.000Z&#34;,&#34;2012-10-05T00:00:00.000Z&#34;,&#34;2012-10-12T00:00:00.000Z&#34;,&#34;2012-10-19T00:00:00.000Z&#34;,&#34;2012-10-26T00:00:00.000Z&#34;,&#34;2012-11-02T00:00:00.000Z&#34;,&#34;2012-11-09T00:00:00.000Z&#34;,&#34;2012-11-16T00:00:00.000Z&#34;,&#34;2012-11-23T00:00:00.000Z&#34;,&#34;2012-11-30T00:00:00.000Z&#34;,&#34;2012-12-07T00:00:00.000Z&#34;,&#34;2012-12-14T00:00:00.000Z&#34;,&#34;2012-12-21T00:00:00.000Z&#34;,&#34;2012-12-28T00:00:00.000Z&#34;,&#34;2013-01-04T00:00:00.000Z&#34;,&#34;2013-01-11T00:00:00.000Z&#34;,&#34;2013-01-18T00:00:00.000Z&#34;,&#34;2013-01-25T00:00:00.000Z&#34;,&#34;2013-02-01T00:00:00.000Z&#34;,&#34;2013-02-08T00:00:00.000Z&#34;,&#34;2013-02-15T00:00:00.000Z&#34;,&#34;2013-02-22T00:00:00.000Z&#34;,&#34;2013-03-01T00:00:00.000Z&#34;,&#34;2013-03-08T00:00:00.000Z&#34;,&#34;2013-03-15T00:00:00.000Z&#34;,&#34;2013-03-22T00:00:00.000Z&#34;,&#34;2013-03-28T00:00:00.000Z&#34;,&#34;2013-04-05T00:00:00.000Z&#34;,&#34;2013-04-12T00:00:00.000Z&#34;,&#34;2013-04-19T00:00:00.000Z&#34;,&#34;2013-04-26T00:00:00.000Z&#34;,&#34;2013-05-03T00:00:00.000Z&#34;,&#34;2013-05-10T00:00:00.000Z&#34;,&#34;2013-05-17T00:00:00.000Z&#34;,&#34;2013-05-24T00:00:00.000Z&#34;,&#34;2013-05-31T00:00:00.000Z&#34;,&#34;2013-06-07T00:00:00.000Z&#34;,&#34;2013-06-14T00:00:00.000Z&#34;,&#34;2013-06-21T00:00:00.000Z&#34;,&#34;2013-06-28T00:00:00.000Z&#34;,&#34;2013-07-05T00:00:00.000Z&#34;,&#34;2013-07-12T00:00:00.000Z&#34;,&#34;2013-07-19T00:00:00.000Z&#34;,&#34;2013-07-26T00:00:00.000Z&#34;,&#34;2013-08-02T00:00:00.000Z&#34;,&#34;2013-08-09T00:00:00.000Z&#34;,&#34;2013-08-16T00:00:00.000Z&#34;,&#34;2013-08-23T00:00:00.000Z&#34;,&#34;2013-08-30T00:00:00.000Z&#34;,&#34;2013-09-06T00:00:00.000Z&#34;,&#34;2013-09-13T00:00:00.000Z&#34;,&#34;2013-09-20T00:00:00.000Z&#34;,&#34;2013-09-27T00:00:00.000Z&#34;,&#34;2013-10-04T00:00:00.000Z&#34;,&#34;2013-10-11T00:00:00.000Z&#34;,&#34;2013-10-18T00:00:00.000Z&#34;,&#34;2013-10-25T00:00:00.000Z&#34;,&#34;2013-11-01T00:00:00.000Z&#34;,&#34;2013-11-08T00:00:00.000Z&#34;,&#34;2013-11-15T00:00:00.000Z&#34;,&#34;2013-11-22T00:00:00.000Z&#34;,&#34;2013-11-29T00:00:00.000Z&#34;,&#34;2013-12-06T00:00:00.000Z&#34;,&#34;2013-12-13T00:00:00.000Z&#34;,&#34;2013-12-20T00:00:00.000Z&#34;,&#34;2013-12-27T00:00:00.000Z&#34;,&#34;2014-01-03T00:00:00.000Z&#34;,&#34;2014-01-10T00:00:00.000Z&#34;,&#34;2014-01-17T00:00:00.000Z&#34;,&#34;2014-01-24T00:00:00.000Z&#34;,&#34;2014-01-31T00:00:00.000Z&#34;,&#34;2014-02-07T00:00:00.000Z&#34;,&#34;2014-02-14T00:00:00.000Z&#34;,&#34;2014-02-21T00:00:00.000Z&#34;,&#34;2014-02-28T00:00:00.000Z&#34;,&#34;2014-03-07T00:00:00.000Z&#34;,&#34;2014-03-14T00:00:00.000Z&#34;,&#34;2014-03-21T00:00:00.000Z&#34;,&#34;2014-03-28T00:00:00.000Z&#34;,&#34;2014-04-04T00:00:00.000Z&#34;,&#34;2014-04-11T00:00:00.000Z&#34;,&#34;2014-04-17T00:00:00.000Z&#34;,&#34;2014-04-25T00:00:00.000Z&#34;,&#34;2014-05-02T00:00:00.000Z&#34;,&#34;2014-05-09T00:00:00.000Z&#34;,&#34;2014-05-16T00:00:00.000Z&#34;,&#34;2014-05-23T00:00:00.000Z&#34;,&#34;2014-05-30T00:00:00.000Z&#34;,&#34;2014-06-06T00:00:00.000Z&#34;,&#34;2014-06-13T00:00:00.000Z&#34;,&#34;2014-06-20T00:00:00.000Z&#34;,&#34;2014-06-27T00:00:00.000Z&#34;,&#34;2014-07-03T00:00:00.000Z&#34;,&#34;2014-07-11T00:00:00.000Z&#34;,&#34;2014-07-18T00:00:00.000Z&#34;,&#34;2014-07-25T00:00:00.000Z&#34;,&#34;2014-08-01T00:00:00.000Z&#34;,&#34;2014-08-08T00:00:00.000Z&#34;,&#34;2014-08-15T00:00:00.000Z&#34;,&#34;2014-08-22T00:00:00.000Z&#34;,&#34;2014-08-29T00:00:00.000Z&#34;,&#34;2014-09-05T00:00:00.000Z&#34;,&#34;2014-09-12T00:00:00.000Z&#34;,&#34;2014-09-19T00:00:00.000Z&#34;,&#34;2014-09-26T00:00:00.000Z&#34;,&#34;2014-10-03T00:00:00.000Z&#34;,&#34;2014-10-10T00:00:00.000Z&#34;,&#34;2014-10-17T00:00:00.000Z&#34;,&#34;2014-10-24T00:00:00.000Z&#34;,&#34;2014-10-31T00:00:00.000Z&#34;,&#34;2014-11-07T00:00:00.000Z&#34;,&#34;2014-11-14T00:00:00.000Z&#34;,&#34;2014-11-21T00:00:00.000Z&#34;,&#34;2014-11-28T00:00:00.000Z&#34;,&#34;2014-12-05T00:00:00.000Z&#34;,&#34;2014-12-12T00:00:00.000Z&#34;,&#34;2014-12-19T00:00:00.000Z&#34;,&#34;2014-12-26T00:00:00.000Z&#34;,&#34;2015-01-02T00:00:00.000Z&#34;,&#34;2015-01-09T00:00:00.000Z&#34;,&#34;2015-01-16T00:00:00.000Z&#34;,&#34;2015-01-23T00:00:00.000Z&#34;,&#34;2015-01-30T00:00:00.000Z&#34;,&#34;2015-02-06T00:00:00.000Z&#34;,&#34;2015-02-13T00:00:00.000Z&#34;,&#34;2015-02-20T00:00:00.000Z&#34;,&#34;2015-02-27T00:00:00.000Z&#34;,&#34;2015-03-06T00:00:00.000Z&#34;,&#34;2015-03-13T00:00:00.000Z&#34;,&#34;2015-03-20T00:00:00.000Z&#34;,&#34;2015-03-27T00:00:00.000Z&#34;,&#34;2015-04-02T00:00:00.000Z&#34;,&#34;2015-04-10T00:00:00.000Z&#34;,&#34;2015-04-17T00:00:00.000Z&#34;,&#34;2015-04-24T00:00:00.000Z&#34;,&#34;2015-05-01T00:00:00.000Z&#34;,&#34;2015-05-08T00:00:00.000Z&#34;,&#34;2015-05-15T00:00:00.000Z&#34;,&#34;2015-05-22T00:00:00.000Z&#34;,&#34;2015-05-29T00:00:00.000Z&#34;,&#34;2015-06-05T00:00:00.000Z&#34;,&#34;2015-06-12T00:00:00.000Z&#34;,&#34;2015-06-19T00:00:00.000Z&#34;,&#34;2015-06-26T00:00:00.000Z&#34;,&#34;2015-07-02T00:00:00.000Z&#34;,&#34;2015-07-10T00:00:00.000Z&#34;,&#34;2015-07-17T00:00:00.000Z&#34;,&#34;2015-07-24T00:00:00.000Z&#34;,&#34;2015-07-31T00:00:00.000Z&#34;,&#34;2015-08-07T00:00:00.000Z&#34;,&#34;2015-08-14T00:00:00.000Z&#34;,&#34;2015-08-21T00:00:00.000Z&#34;,&#34;2015-08-28T00:00:00.000Z&#34;,&#34;2015-09-04T00:00:00.000Z&#34;,&#34;2015-09-11T00:00:00.000Z&#34;,&#34;2015-09-18T00:00:00.000Z&#34;,&#34;2015-09-25T00:00:00.000Z&#34;,&#34;2015-10-02T00:00:00.000Z&#34;,&#34;2015-10-09T00:00:00.000Z&#34;,&#34;2015-10-16T00:00:00.000Z&#34;,&#34;2015-10-23T00:00:00.000Z&#34;,&#34;2015-10-30T00:00:00.000Z&#34;,&#34;2015-11-06T00:00:00.000Z&#34;,&#34;2015-11-13T00:00:00.000Z&#34;,&#34;2015-11-20T00:00:00.000Z&#34;,&#34;2015-11-27T00:00:00.000Z&#34;,&#34;2015-12-04T00:00:00.000Z&#34;,&#34;2015-12-11T00:00:00.000Z&#34;,&#34;2015-12-18T00:00:00.000Z&#34;,&#34;2015-12-24T00:00:00.000Z&#34;,&#34;2015-12-31T00:00:00.000Z&#34;,&#34;2016-01-08T00:00:00.000Z&#34;,&#34;2016-01-15T00:00:00.000Z&#34;,&#34;2016-01-22T00:00:00.000Z&#34;,&#34;2016-01-29T00:00:00.000Z&#34;,&#34;2016-02-05T00:00:00.000Z&#34;,&#34;2016-02-12T00:00:00.000Z&#34;,&#34;2016-02-19T00:00:00.000Z&#34;,&#34;2016-02-26T00:00:00.000Z&#34;,&#34;2016-03-04T00:00:00.000Z&#34;,&#34;2016-03-11T00:00:00.000Z&#34;,&#34;2016-03-18T00:00:00.000Z&#34;,&#34;2016-03-24T00:00:00.000Z&#34;,&#34;2016-04-01T00:00:00.000Z&#34;,&#34;2016-04-08T00:00:00.000Z&#34;,&#34;2016-04-15T00:00:00.000Z&#34;,&#34;2016-04-22T00:00:00.000Z&#34;,&#34;2016-04-29T00:00:00.000Z&#34;,&#34;2016-05-06T00:00:00.000Z&#34;,&#34;2016-05-13T00:00:00.000Z&#34;,&#34;2016-05-20T00:00:00.000Z&#34;,&#34;2016-05-27T00:00:00.000Z&#34;,&#34;2016-06-03T00:00:00.000Z&#34;,&#34;2016-06-10T00:00:00.000Z&#34;,&#34;2016-06-17T00:00:00.000Z&#34;,&#34;2016-06-24T00:00:00.000Z&#34;,&#34;2016-07-01T00:00:00.000Z&#34;,&#34;2016-07-08T00:00:00.000Z&#34;,&#34;2016-07-15T00:00:00.000Z&#34;,&#34;2016-07-22T00:00:00.000Z&#34;,&#34;2016-07-29T00:00:00.000Z&#34;,&#34;2016-08-05T00:00:00.000Z&#34;,&#34;2016-08-12T00:00:00.000Z&#34;,&#34;2016-08-19T00:00:00.000Z&#34;,&#34;2016-08-26T00:00:00.000Z&#34;,&#34;2016-09-02T00:00:00.000Z&#34;,&#34;2016-09-09T00:00:00.000Z&#34;,&#34;2016-09-16T00:00:00.000Z&#34;,&#34;2016-09-23T00:00:00.000Z&#34;,&#34;2016-09-30T00:00:00.000Z&#34;,&#34;2016-10-07T00:00:00.000Z&#34;,&#34;2016-10-14T00:00:00.000Z&#34;,&#34;2016-10-21T00:00:00.000Z&#34;,&#34;2016-10-28T00:00:00.000Z&#34;,&#34;2016-11-04T00:00:00.000Z&#34;,&#34;2016-11-11T00:00:00.000Z&#34;,&#34;2016-11-18T00:00:00.000Z&#34;,&#34;2016-11-25T00:00:00.000Z&#34;,&#34;2016-12-02T00:00:00.000Z&#34;,&#34;2016-12-09T00:00:00.000Z&#34;,&#34;2016-12-16T00:00:00.000Z&#34;,&#34;2016-12-23T00:00:00.000Z&#34;,&#34;2016-12-30T00:00:00.000Z&#34;,&#34;2017-01-06T00:00:00.000Z&#34;,&#34;2017-01-13T00:00:00.000Z&#34;,&#34;2017-01-20T00:00:00.000Z&#34;,&#34;2017-01-27T00:00:00.000Z&#34;,&#34;2017-02-03T00:00:00.000Z&#34;,&#34;2017-02-10T00:00:00.000Z&#34;,&#34;2017-02-17T00:00:00.000Z&#34;,&#34;2017-02-24T00:00:00.000Z&#34;,&#34;2017-03-03T00:00:00.000Z&#34;,&#34;2017-03-10T00:00:00.000Z&#34;,&#34;2017-03-17T00:00:00.000Z&#34;,&#34;2017-03-23T00:00:00.000Z&#34;],[null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,0.882009868611482,0.89639620738816,0.894623668366187,0.930126938147475,0.931125427505195,0.930281677942156,0.930394053139138,0.93157469379101,0.932820642856053,0.88872654820673,0.941355907382818,0.942540035721515,0.922777908475206,0.890219104431397,0.89264530260361,0.886332903777741,0.893755353596777,0.872516511174197,0.877087915200832,0.878601874448131,0.884486062778509,0.882058815514466,0.876876381886743,0.882244139294026,0.860919824283791,0.838014154321994,0.838279516609103,0.832527062145364,0.82607121049495,0.836993076782081,0.796642616989866,0.79466704143585,0.802550596446245,0.846690492809674,0.820424123675434,0.8430391755578,0.832613815094085,0.847582395839352,0.859596571829904,0.863306872388838,0.855750695251177,0.8560491315787,0.851871968001925,0.840030575901434,0.867296042235348,0.87080142042679,0.887981285418058,0.891663043978797,0.899547804661973,0.899197299456943,0.907583606879088,0.905334807901238,0.910222780581982,0.912509969988313,0.928702961584877,0.920913306216911,0.930713735137361,0.94002075450282,0.934412869933405,0.921970103146809,0.928184803291042,0.930956904744918,0.940499785492708,0.927725177018749,0.920968335601088,0.921219782913846,0.916229677628881,0.903490460174958,0.895551209824133,0.894664772859278,0.881990228357755,0.853801166212627,0.902621974777728,0.914858108289064,0.922798046099779,0.919513903099291,0.93696996976189,0.935328931369585,0.936925452297783,0.938498605897526,0.94991160962515,0.949685809857998,0.949816434691477,0.950624178934631,0.956967541588698,0.959528771667062,0.959145072759651,0.960561813364816,0.961574810389801,0.960590804004404,0.958827878466148,0.960987673225743,0.965093337591458,0.95927473579906,0.953081064793193,0.963348796940412,0.954521735000699,0.964177300787605,0.957494111147315,0.946759060765761,0.938201867925746,0.936948572704074,0.937100610541652,0.851259792547727,0.852804363274825,0.836472516319004,0.83658490107239,0.824674828574868,0.823458336243859,0.830487824915226,0.838730242294831,0.828411642806193,0.800620757486442,0.803476517752319,0.776685895920438,0.71811854270478,0.71282691436304,0.682668166584454,0.679733474184317,0.687758958097791,0.696037062850163,0.706223042251071,0.705735592665899,0.923471319597428,0.94195826118503,0.94374818628953,0.934527053225884,0.933704280967376,0.943637619295564,0.950573877594234,0.949743525078384,0.944540987084846,0.941435048291607,0.924584185245784,0.916270179645517,0.911551283404537,0.933230057936271,0.934137726650809,0.8983272626737,0.895553691854011,0.911750579682076,0.900056631694688,0.894869130968903,0.89438743711231,0.893203325797245,0.878897357560809,0.893245866611085,0.906582879329671,0.892035651198177,0.881153549732186,0.868771345740389,0.872739775739494,0.861056323067312,0.863838807922276,0.881623957137822,0.937805162670445,0.940215551150497,0.949134169492691,0.965727931711275,0.95988372630849,0.949480826779233,0.956485377668895,0.965562511767643,0.971385414889408,0.976350315094039,0.973651221079678,0.975054802009941,0.972562218465973,0.972932686060766,0.9736640376052,0.972612736569777,0.970355501546774,0.974710872904095,0.974560268472055,0.96045747169878,0.950878334440102,0.949221100144066,0.941524814916619,0.929676436148147,0.932884820748953,0.937118796004643,0.93709593426024,0.931261934246828,0.905409961649264,0.881379205729466,0.881066731773446,0.868619330388036,0.872704683166344,0.869669573055155,0.812125388527252,0.814921427350433,0.805150221388754,0.800111691591278,0.79600584320039,0.859006569492603,0.846384494778769,0.837539691279261,0.859919090440606,0.902899906766342,0.907457576390327,0.929488889865148,0.928314115350427,0.912172407746556,0.91224670821375,0.929295626414595,0.940097165030988,0.935610423548652,0.924260673527778,0.92633339089636,0.925747674691079,0.930674552387104,0.928547708925286,0.937457003782537,0.94600042618036,0.930552011414689,0.961677066142955,0.959632469080871,0.958963756948613,0.961271949319374,0.96210926137806,0.962611180020521,0.960842832055477,0.957419961171142,0.964897683020213,0.963288721517906,0.960733236847145,0.967235427527916,0.95354703894685,0.948162809642396,0.952595261822757,0.960277978424035,0.941354188144352,0.94389444602858,0.946291320922276,0.945129041896022,0.940901227068365,0.944981420519279,0.952929853543947,0.952591778086156,0.952373650503562,0.946481740101135,0.947226014600584,0.94685260738958,0.943403290252459,0.944928105846251,0.946093468086701,0.944101424614336,0.950690602580542,0.953715253611068,0.952792871125259,0.944186633849537,0.974493313026828,0.973044898320156,0.971677442931221,0.972741023797147,0.966977909918811,0.958652214495075,0.89532368107682,0.896869285572475,0.874227475878343,0.912539902246047,0.939912396348665,0.93510090088096,0.942755971576812,0.948440434585445,0.944300247817487,0.938810784181883,0.937643551012184,0.935245743479229,0.91984592566673,0.91460445859138,0.916247054299802,0.907221615524209,0.910119189745327,0.906876745682511,0.910696191223952,0.906321901051564,0.927312198666894,0.926498352241539,0.917201661556044,0.91473355442069,0.852288742614378,0.87346898093947,0.81665122240188,0.755093839223704,0.757976136169897,0.805619954498791,0.82201882194805,0.870249563129556,0.883844393736128,0.882786823488884,0.879981178554337,0.884758964866877,0.891854337628294,0.922536000046478,0.922811941798086,0.915019951309569,0.900161682055584,0.887172208871889,0.894519126736872,0.889323457863162,0.894899594670475,0.880039408756929,0.92209081849229,0.923863201767369,0.922820341619374,0.911059909345753,0.907943357290975,0.889534010159546,0.914337401221914,0.922942517588182,0.904388953875893,0.908665292789139,0.90310527149848,0.899631301171307,0.871104406936193,0.888004731076489,0.91931294272786,0.934621794739475,0.933357527471261,0.938257454770141,0.939332008463583,0.898693080161883,0.882578840414364,0.883618596407203,0.883722846329121,0.858217794850265,0.853451941269634,0.858119556056964,0.842055947949924,0.837219072783716,0.847367504965347,0.84313002586829,0.827601106293205,0.826237109828016,0.856312254382341,0.860332510460119,0.851949656524568,0.804032619510255,0.811871141460707,0.795472384967536,0.721529407425515,0.849273483910156,0.878313894368207,0.887912147037235,0.882791202209688,0.913087632303414,0.9117791718058,0.836595513659237,0.869205246296818,0.863466513241688,0.867889524306851,0.884544046204418,0.884212898036891,0.884049713318966,0.852270477645461,0.877643874944018,0.871389881235101,0.872206168317545,0.859053353878408,0.884016173936882,0.91329242516501,0.90988734705487,0.898478644845867,0.890403969668449,0.878293320009831,0.881634051438478,0.887429505782425,0.910267411337857,0.903957042504402,0.88777091694801,0.879650814148796,0.863700102359505,0.858289106515027,0.850483421869588,0.862442336428626,0.874877346212069,0.870954565313623,0.875917928655095,0.901425771973309,0.866354624235668,0.847440751961013,0.859454107020039,0.850845352497222,0.870928846847957,0.886282780701303,0.915910983548846,0.915026270228843,0.943581321025586,0.951218798934343,0.962592800304601,0.953988702465735,0.940401586239853,0.926014326119466,0.914538909511282,0.933081072984159,0.929915914710571,0.930356117655682,0.929895864599884,0.925130802002278,0.926657383529761,0.92816451942513,0.939594321466476,0.944756851339376,0.941207945686643,0.941154690379939,0.93028646644255,0.931879172444096,0.921662504260659,0.918423313001563,0.925307157786947,0.932126424152915,0.940904758410219,0.955019976028747,0.953304954122241,0.948683097709863,0.953428878195296,0.953680326730849,0.951247346115196,0.952171837642435,0.950900501446933,0.944754814587414,0.926386421415982,0.927238130434668,0.917710334104383,0.909138688814426,0.923208976687566,0.927289541757706,0.920603371810833,0.913598232704844,0.900990560644125,0.94771281418213,0.940712900207074,0.940519314535948,0.947746547310768,0.948118982558831,0.947663256753299,0.944275022164544,0.949639113775738,0.951192375148743,0.946948941914507,0.947733224240073,0.951865570775009,0.958282690200217,0.961764707451337,0.961838206188472,0.960375140600664,0.962741326922433,0.966146190579566,0.963924792439567,0.96440910368914,0.963971182278428,0.970046376323949,0.968236141158825,0.96766482397509,0.968742498862409,0.970601952929947,0.974077493546502,0.972504172117028,0.972501359730907,0.979409070021339,0.979803500258982,0.97837586587305,0.976838626101853,0.973787497489621,0.974008697637284,0.95616977125134,0.945896153105053,0.942831210257574,0.939582341236228,0.936745943065741,0.909062961922669,0.908653109036026,0.90918660367352,0.912185434660259,0.890380198743003,0.893439448399631,0.880429454263924,0.881517447348355,0.861528880799173,0.84350886989254,0.841632901300096,0.847567028245217,0.836015074459,0.817097233606457,0.822760441685308,0.915758867616332,0.898547735372562,0.885121775801818,0.883641711837632,0.888328872603158,0.872392145542029,0.875363971512212,0.876098846588909,0.876790623300233,0.778350155304277,0.739922376120829,0.738217622436721,0.704216962493225,0.778009770913344,0.792596825315964,0.793995043552431,0.800853439706685,0.812291024105335,0.812474964471585,0.810807722640305,0.777410812137181,0.820518893410709,0.82678536033314,0.834803797622674,0.833075674202895,0.829171710689881,0.821990185696194,0.816281471683799,0.789668045626429]]},&#34;evals&#34;:[&#34;attrs.interactionModel&#34;],&#34;jsHooks&#34;:[]}&lt;/script&gt;
&lt;p&gt;The correlation between the Tech ETF and the S&amp;amp;P 500 ETF seems quite high. It dipped a bit in the middle of 2009 and again towards the end of 2016. It would be interesting to see if this was true of the other sector ETFs as well. In other words, were these periods of generally declining correlations, or was it limited to the technology/SP500 relationship?&lt;/p&gt;
&lt;p&gt;The best way to do some exploratory analysis on that is, no surprise, build a shiny app that allows users to choose their own sectors and rolling windows. We’ll do that next time - see you in a few days!&lt;/p&gt;

        &lt;script&gt;window.location.href=&#39;https://rviews.rstudio.com/2017/01/18/reproducible-finance-with-r-sector-correlations/&#39;;&lt;/script&gt;
      </description>
    </item>
    
  </channel>
</rss>
