text:
\section{Introduction}

Financial markets can be regarded as a complex network in which nodes represent different financial assets and edges
represent one or many types of relationships among those assets.
Filtered correlation-based networks have successfully been used in the literature to study financial markets structure particularly
from observational data derived from empirical financial time series \cite{10.1371/journal.pone.0017994, Mantegna1999, aste2010correlation, Tumminello201040, Tumminello26072005}.
The underlying principle is to use correlations from empirical financial time series to construct a sparse network representing
the most relevant connections.
Analyses on filtered correlation-based networks for information extraction \cite{1367-2630-12-8-085009,song2008analysis,aste2010correlation}
have widely been used to
explain market interconnectedness from high-dimensional data.
Applications include asset allocation \cite{pozzi2013spread}, market stability assessments \cite{morales2012dynamical},
hierarchical structure analyses \cite{Mantegna1999, aste2010correlation,Tumminello201040, musmeci2014clustering, song2012hierarchical}
and the identification of lead-lag relationships \cite{curme2015coupled}.

The majority of literature so far has focused on the analysis of financial time series.
However, in recent years a large amount of information about financial markets has become available from exogenous sources such as social media.
It is reasonable to conceive that changes in social media sentiment \cite{1507.00955} and changes in asset prices might be related.
Some  previous studies have indeed demonstrated the existence of relationships which in some cases
indicated that social media can be used to predict changes in asset prices \cite{8252134, 1507.00784, citeulike:13108056, tetlock2007giving, Tobias:2013, mao2014quantifying}.
When new information hits the markets, investors may react either rationally or irrationally \cite{BondtandThaler1985, shleifer2000inefficient}.
They may express opinions on social media that can later become market actions, thus enabling opportunities to forecast future asset prices.
However, it has also been highlighted that not all assets behave in the same way.
Some are more influenced by social media sentiment, while others, on the contrary,
are more influential on the social media sentiment \cite{2016arXiv160104535S}.
Besides each single financial asset, we address in this study whether the entire stock market structure
is related to the structure constructed from
social media sentiment and whether there exist lead-lag relationships exist that can be used for forecasting one structure in terms of the other.

We use dynamical Kendall correlations computed over rolling windows to investigate the temporal
evolution of market structure represented by filtered correlation-based networks constructed from stock market prices and from Twitter sentiment signals.
We generate two networks: one from log-returns of stock prices and the other from Twitter sentiment.
The two networks are treated as a multilayer problem with two layers of networks that share the same nodes but have different edge sets.
We investigate whether financial market structure can be better predicted by
combining past financial information with past social media sentiment information.
The market structure forecasting problem is formulated as a link prediction problem where we estimate the probability of addition
or removal of a link in the future based on information about the structure of the financial and social networks in the past.

\section{Methods}

\subsection{Financial and Social Networks}
We selected $N = 100$ of the most capitalized companies that were part of the S\&P500 index
from 09/05/2012 to 08/25/2017.
The list of these companies' ticker symbols is reported in the Appendix \ref{sec:comps}.
For each stock $i$ the financial variable was defined as
the daily stock's log-return $R_i(\tau) = \log{Price(\tau)} - \log{Price(\tau-1)}$, where $Price(\tau)$ designates the closing price at time $\tau$.
The social media variable was defined as the the social media opinion $O_i$ of stock $i$
which was estimated as the total number of bullish daily tweets related to the stock $i$ at time $\tau$.
Twitter sentiment data were provided by PsychSignal.com \cite{PsychSignal}.
In this dataset, a Twitter message was defined to be related to a given stock when its ticker symbol was mentioned.
The dataset used only English language content and it was agnostic to the country source of the Twitter message.
We have provided further descriptive analytics of the Twitter sentiment dataset used in related literature \cite{8252134, 2016arXiv160104535S}.

Stock returns $R_i$ and social media opinion scores $O_i$ each amounted to a time series of length equals to 1251 trading days.
These series were divided time-wise into $M = 225$ windows $t = 1, 2, \ldots, M$
of width $T = 126$ trading days.
A window step length parameter of $\delta T = 5$ trading days defined the displacement of the window, i.e., the number of trading days
between two consecutive windows. The choice of window width $T$ and window step $\delta T$ is arbitrary, and
it is a trade-off between having analysis that is either too dynamic or too smooth.
The smaller the window width and the larger the window steps, the more dynamic the data are.

To characterize the synchronous time evolution of assets,
we used equal time Kendall's rank coefficients
between assets $i$ and $j$, defined as
\begin{equation}
 \rho_{i, j}(t) = \sum\limits_{t' < \tau}sgn(V_i(t') - V_i(\tau))sgn(V_j(t') - V_j(\tau)),
\end{equation}
where $t'$ and $\tau$ are time indexes within the window $t$ and $V_i \in \{R_i, O_i\}$.

Kendall's rank coefficients fulfill the condition $-1 \leq \rho_{i, j} \leq 1$ and form the $N \times N$ correlation matrix
$C(t)$ that served as the basis for the networks constructed in this paper. To construct
the asset-based financial and social networks, we defined a distance between a pair of stocks. This
distance was associated with the edge connecting the stocks, and it reflected the level at which they were correlated.
We used a simple non-linear transformation $d_{i, j}(t) = \sqrt{2(1 - \rho_{i,j}(t))}$ to obtain distances with the
property $2 \geq d_{i,j} \geq 0$, forming a $N \times N$ symmetric distance matrix $D(t)$.

We extracted the $N(N-1)/2$ distinct distance elements from the upper triangular part of the distance matrix
$D(t)$, which were then sorted in an ascending order to form an ordered sequence
$d_1(t), d_2(t), \ldots, d_{N(N-1)/2}(t)$. Since we require the graph to be representative of the market,
it is natural to build the network by including only the strongest connections. This is a network filtering procedure
that has been successfully applied in the construction of \textit{asset graphs} for the analyses of market structure \cite{1402-4896-2003-T106-011, refId0-Onnela-2004}.
The number of edges to include is arbitrary, and we included those from the bottom quartile,
which represented the 25\% shortest edges in the graph (largest correlations), thus giving $E(t) = \{d_1(t), d_2(t), \ldots, d_{\floor{N/4}}(t)\}$.

We denoted $E^{F}(t)$ and $E^{S}(t)$ as the set of edges constructed from the distance matrices derived from
stock returns $R(t)$ and social media opinion $O(t)$, respectively.
Two networks were considered as two layers of a duplex structure
$\mathcal{G} = \{G^{F}, G^{S}\}$ where $G^{F} = ( V, E^{F} )$, $G^{S} = ( V, E^{S} )$
and $V$ is the vertex set of stocks which is common to both layers.

\subsection{Persistence}
The state of an edge between vertices $u$ and $v$  in the financial layer at time $t$ was represented
with the corresponding adjacency matrix element $E^F_{u,v}(t)$: a binary variable with $E^F_{u,v}(t)=1$
indicating the existence of the edge and $E^F_{u,v}(t)=0$ its absence.
Analogously, the variable $E^S_{u,v}(t)$  accounted for the presence or absence of edge $(u,v)$ in the social ($S$) layer.
The variable $E_{u,v}(t)=E^F_{u,v}(t) \vee E^S_{u,v}(t)=1$ indicates instead the presence of at least one
edge between $u$ and $v$ in the two layers; $E_{u,v}(t)=0$ indicates that no edges are present between $u$ and $v$ in any layer.

\subsection{Triadic Closure}
Let $\mathcal{N}_{uv}$ be the set of nodes that are common neighbors to vertices $u$ and $v$.
We defined the triadic closure $T^F_{u,v}(t)$ of an edge $(u,v)$ at layer $F$ and time $t$ as the mean of the clustering coefficients of vertices in  $\mathcal{N}_{uv}$:
\begin{equation}
T^F_{u,v}(t) = \frac{1}{|\mathcal{N}_{uv}|}\sum_{i \in \mathcal{N}_{uv}} C^F_i(t),
\end{equation}
where term $C^F_i$ is the clustering coefficient of node $i$ which accounts for the
fraction of triads in the neighbors of $i$  that are closed in triangles. This is defined as
\begin{equation}
C^F_i = 2 \frac{\mbox{Number of triangles with a vertex on $i$}}{k_i (k_i - 1)} =  \frac{\sum_{j,k\in \mathcal{N}_i} E^F_{j,k}}{k_i (k_i - 1)},
\end{equation}
where $k_i$ is the degree of vertex $i$ and $\mathcal{N}_i$ is the neighborhood of $i$.

In the multiplex case, we kept the same definition but allowed triangles to form across several layers \cite{Battiston2017, 1367-2630-17-7-073029}.
For the multiplex case, we used the symbol $T_{u,v}(t)$.
\captionsetup[subfigure]{labelformat=empty}
\begin{figure}[!h]
\centering
\begin{subfigure}{.45\textwidth}
\caption{\textbf{A)}}
  \centering
  \includegraphics[width=.9\linewidth]{fig/ex_singlelayer_01}
  \label{fig:sub1}
\end{subfigure}%
\begin{subfigure}{.45\textwidth}
\caption{\textbf{B)}}
  \centering
  \includegraphics[width=.9\linewidth]{fig/ex_multilayer_01.pdf}
  \label{fig:sub2}
\end{subfigure}
\caption{Triads on a single layered network (Panel A) and on a multiplex network (Panel B).
The clustering coefficient of node $i$ accounts for the fraction of triads in the neighborhood of $i$ that are closed in triangles.
The triadic closure of an edge $(u,v)$ at layer $F$ is a function of the clustering coefficients of the common neighbors of the vertices $u$ and $v$.
Triangles can be formed in a single layer or across layers.}
\label{fig:TRIADS}
\end{figure}

\subsection{Link Prediction}
\label{sec:link}
We aim to predict the probability that an edge is inserted or removed in the financial network, $G^{F}(t+h)$, at a future time $t+h$
by using the information about the past structures of the financial and social networks at previous times $t' \le t$.
For this purpose we considered two mechanisms:
\begin{itemize}
\item[1)] the tendency of an edge present at a previous time to persist in the future ({\it edge persistence});
\item[2)] the propensity of triangles within or across layers to close ({\it triadic closure}).
\end{itemize}
The mechanism of growth by triadic closure is based on a principle of transitivity, often observed in real-world networks,
where there is a tendency to form triangles. Under this principle, two nodes tend to be connected if they share common neighbors with high transitivity, i.e., propensity to close triangles.

The probability that an edge will be inserted in the future is computed by means of a logistic regression of the edge persistence and the triadic closure coefficients.
We estimated regression coefficients by best fitting on a training set which was composed of rolling windows of 126 trading days that
initially ranged from 09/05/2012 to 09/10/2014.
Predictions concerning the presence of edges in the financial network were made at $h=1$ to $h=20$ weeks ahead of the end of the training set.
The test set initially ranged from 09/17/2014 to 08/25/2017.
The procedure was repeated by moving the training window forward in 1-week steps.

The probability $p_{u,v}(t+h)$ to observe vertices $u$, $v$ connected by an edge at $t+h$ can be inferred
in terms of the set of previous triadic closure coefficients,
$T_{u,v}(t)$, and edge persistence scores $E_{u,v}(t)$. We first considered a restricted model that used financial information only, which
is given by the following:
 \begin{equation}
   \log\frac{p^F_{u,v}(t+h)}{1 - p^F_{u,v}(t+h)} = \tilde\beta_0^h + \tilde\beta^h T^F_{u,v}(t) + \tilde\gamma^h E^F_{u,v}(t).
   \label{eq:logit2}
 \end{equation}
For this restricted model, we performed a 1-step ahead prediction for $h \in (1, 2, \ldots, 19, 20)$ weeks.

To calibrate the parameters in Eq. \ref{eq:logit2}, we considered a training window of $W = 126$ days which ends at time $t$.
The log-likelihood function \cite{faraway2006elm} over the training window for the logistic model from Eq. \ref{eq:logit2} is given by
\begin{equation} \label{eq:loglik2}
\begin{split}
 \mathcal{L}^F(t) =& \, \sum\limits_{t'=t-W+1}^{t}\,\sum\limits_{uv \in E^{F}(t'+h)} - \log{(1 + e^{\tilde\beta_0^h + \tilde\beta^h T^F_{u,v}(t') + \tilde\gamma^h E^F_{u,v}(t')})} \, + \\
 & \sum\limits_{t'=t-W+1}^{t}\,\sum\limits_{uv \in E^{F}(t'+h)} (1 - E_{uv}^F(t'+h))(\tilde\beta_0^h + \tilde\beta^h T^F_{u,v}(t') + \tilde\gamma^h E^F_{u,v}(t')).
\end{split}
\end{equation}

We differentiated the log-likelihood function given by Eq. \ref{eq:loglik2} in order to find maximum
log-likelihood estimates for the coefficients of Eq. \ref{eq:logit2}.

To verify whether the multiplex information is relevant in the prediction of links in the financial network compared to past a financial network alone,
we considered a full regression model that takes the set of previous triadic closure coefficients and edge persistence
from the financial layer ($T^F_{u,v}(t), E^F_{u,v}(t)$), social layer ($T^S_{u,v}(t), E^S_{u,v}(t)$) and the multiplex network ($T^F_{u,v}(t), E^F_{u,v}(t)$).
The full model is
\begin{equation} \label{eq:logit}
\begin{split}
   \log\frac{p_{u,v}(t+h)}{1 - p_{u,v}(t+h)} =& \, \beta_0^h + \beta_1^h T^F_{u,v}(t) + \beta_2^h E^F_{u,v}(t) \, + \\
   & \gamma_1^h T^S_{u,v}(t) + \gamma_2^h E^S_{u,v}(t) + \theta_1^h T_{u,v}(t) + \theta_2^h E_{u,v}(t).
 \end{split}
 \end{equation}

The log-likelihood function $\mathcal{L}(t)$ of the full model in Eq. \ref{eq:logit} and
the model fitting can be obtained in an analogous manner to the previously performed procedure for the restricted model from Eq. \ref{eq:logit2}.

The likelihood ratio statistic is
 \begin{equation}
\lambda(t) = -2 (\mathcal{L}_{max}(t) - \mathcal{L}_{max}^F(t)),
 \end{equation}
where $\mathcal{L}_{max}(t)$ and $\mathcal{L}_{max}^F(t)$ are,respectively, the maxima of the log-likelihood functions of the full and
restricted models in the training set window.
The likelihood ratio statistic $\lambda(t)$ can be assumed to follow a $\chi^2$ distribution \cite{faraway2006elm} with 4 degrees of freedom where a value of $\lambda > 18.47$
is assumed to be statistically significant at $p = 0.001$.
In that case, there is evidence to accept the full model that considers social and financial information
over the restricted model that considers financial information only.

The model performance was estimated by counting both the true positives (edges predicted to be there and indeed present in the future network)
and the false positives (edges predicted to be there but not present in the future network)
and measuring of AUC (area under the receiver operating characteristic curve) in the test set that originally ranged from 09/17/2014 to 08/25/2017.
AUC ranges from 0.50 to 1.00, with higher values indicating that the model discriminates better between the two categories of edge-present and edge-absent.

\section{Results}

\subsection{Market structure dynamics}
We first investigated financial network persistence by comparing the financial network $G^{F}(t)$
at time $t$ with a future financial network, $G^{F}(t+h)$ at $h$ steps ahead.
To quantify the changes in the correlation network structure, we used two measures:
A) the fraction of new edges in $G^{F}(t+h)$ that were not present in $G^{F}(t)$;
B) the Jaccard Distance, defined as
$$ Jaccard(G^{F}(t'), G^{F}(t)) = \frac{\|G^{F}(t') \cap G^{F}(t)\|}{\|G^{F}(t') \cup G^{F}(t)\|}.$$
Results are reported in Fig. \ref{fig:TRIADS1-rolling}, panels A) and B), respectively.

 \begin{figure}[!h]
\centering
\scalebox{0.28}{\includegraphics{fig/P1-new-edges-persistence.png}}
\caption{\textbf{Evidence that financial correlation structure changes considerably with time}.
Panel A) shows the mean percentage of new edges in the financial network at time $t+h$ with respect to the edge set at time $t$  ($1 \leq h \leq 20$ trading weeks).
We observe that edges change considerably in the financial network with almost 40\% of edges in financial networks changing after a period of $h = 20$ trading weeks.
Panel B) shows the cross-similarity among financial networks measured as the Jaccard Distance between $G^{F}(t')$ and $G^{F}(t)$ with $t$ and $t'$
ranging from 09/05/2012 to 21/02/2017. We observe that edge changes (persistence) are quite stable overtime, i.e.,
the number of edges that change is similar throughout the period.
Network $G^{F}(t)$ are constructed at each time $t$ from a correlation structure estimated from a sliding window of 126 trading days starting at time $t$.
The windows move with time step of 1 trading week.
Error bars in Panel A) indicate standard error.
}
\label{fig:TRIADS1-rolling}
 \end{figure}

Fig. \ref{fig:TRIADS1-rolling} panel A) shows the mean percentage of new edges in the financial network at time $t+h$ with respect to the edge set at time $t$  ($1 \leq h \leq 20$ trading weeks).
We observe that edges change considerably in the financial network with almost 40\% of edges in financial networks changing after a period of $h = 20$ trading weeks.
Fig. \ref{fig:TRIADS1-rolling} panel B) shows the cross-similarity among financial networks measured as the Jaccard Distance between $G^{F}(t')$ and $G^{F}(t)$ with $t$ and $t'$
ranging from 09/05/2012 to 21/02/2017. We observe that edge changes (persistence) are quite stable overtime, i.e.,
the number of edges that change is similar throughout the period.
Hence, results indicate that the constructed financial networks are time-variant across the entire period studied,
with a stable rate of edge changes over time.

\subsection{Prediction of Stock Market Structure}
We used Eq. \ref{eq:logit} to predict a the financial network $G^{F}(t+h)$ at a future time $t+h$
by using the information about the past structures of the financial and social networks at previous times $t' \le t$.
Fig. \ref{fig:TRIADS3-rolling} panel A) shows the performance obtained in the prediction of
out-of-sample edges for $h \in (1, 5, 10, 15, 20)$ trading steps ahead.
We achieved an overall high out-of-sample performance in financial network link prediction,
with performances in the range of 73\% to 95\% depending
on time-lag and time-period. Prediction power improved with a smaller time lag.

\begin{figure}[!h]
\centering
\scalebox{0.36}{\includegraphics{fig/P2-AUC-time-rolling_.png}}
\caption{\textbf{Evidence of high out-of-sample performance in financial network link prediction.}
Models were trained in an expanding window with initial start and end dates 09/05/2012.
and 09/10/2014, respectively. Test period ranges from 09/17/2014 and 08/25/2017.
Plots display the performance results (AUC) of a model to predict edges in a financial network at time $t + h$ trained with
information up to date $t$.
Panel A) shows the performance obtained in the prediction of out-of-sample edges for $h \in (1, 5, 10, 15, 20)$ trading weeks.
Panel B) shows the performance improvement ($AUC^*$) compared to a naive benchmark that assumes that the
correlation structure is time-invariant, i.e., $G^{F}(t+h) = G^{F}(t)$.
}
\label{fig:TRIADS3-rolling}
 \end{figure}

We compared our results to those obtained using a benchmark model that assumes that correlation structure is
time-invariant, i.e., $G^{F}(t+h) = G^{F}(t)$.
The performance improvement against the benchmark is estimated as $AUC^* = (AUC - 0.5)/(\widehat{AUC} - 0.5) - 1$, where $AUC$
represents the performance of the proposed model and $\widehat{AUC}$ is the performance of the benchmark.
From Fig. \ref{fig:TRIADS3-rolling} panel B), we observe that the higher the time lag, the higher the performance improvement over the benchmark.
Let us note that performance improvement over the naive benchmark reached values as high as 40\% for a long-term prediction with a lag of 20 trading weeks.

Fig. \ref{fig:TRIADS4-rolling} reports an aggregate overview of the previous results for the
out-of-sample prediction in terms of the number of weeks ahead.
We observe that as the lag increases, the prediction performance declines (panel A).
However, the improvement in performance over the naive benchmark improves (panel B).

\begin{figure}[!h]
\centering
\scalebox{0.28}{\includegraphics{fig/P3-AUC-lags-rolling_.png}}
\caption{\textbf{The effect of time-lag on out-of-sample predictive performance.}
Panel A) shows the mean performance (AUC) of the prediction of
out-of-sample edges of the full financial network $G^{F}$. Panel B) shows the performance improvement ($AUC^*$) against a naive benchmark that assumes that correlation structure is time-invariant, i.e., $G^{F}(t+h) = G^{F}(t)$.
Error bars indicate standard error.
}
\label{fig:TRIADS4-rolling}
 \end{figure}

In Appendix \ref{sec:exp}, we report the results obtained by using an expanding window rather than a rolling window as a training set.
We observe that expanding the training set does not necessarily lead to better performance.
In fact, the rolling window analysis yielded better performance overall.

To verify whether the multiplex network provides additional information to that
from the financial network only, we re-computed the same out-of-sample edge prediction by using the financial network only
and compared this to
the results from the full model that considers both the financial and social information layers.
A comparison between the two models was performed by comparing their respective likelihoods.
We have also disaggregated the prediction of the insertion of new edges $E^+$ and the prediction of edge deletions $E^-$.
We report the likelihood values and AUC performance obtained for the fit of each model in Table \ref{tb:NA0}.

We observed that the model that includes both financial and social information better fit the data compared to the model that considers financial data only,
particularly for the case of the prediction of insertion of new edges.
The likelihood ratio increases with prediction lag indicating that full models (i.e. those that consider both financial and social networks) are
particularly important in long-term link prediction.
Results confirm that the multiplex network is distinctly better than the single financial layer with all likelihood ratios
having p-value $< 0.001$ for all configurations tested.
\begin{table}[!h]
\centering
\caption{\textbf{Financial Link Prediction Performance Results.}
High out-of-sample AUCs obtained indicate that the model has high performance balancing
both false positives and false negatives predictions relative to true positive and negative values.
Log-likelihood ratios ($\lambda$) increase with prediction lag indicating that social media features are particularly important for long-term prediction.
The table reports mean $AUC$ values and log-likelihood ratios $\lambda$ over the test period with corresponding standard deviations in parentheses.
Results are reported for the prediction of new edges $E^*$ and edge deletions $E^-$.
We also report the average performance $AUC$ obtained in the prediction of the full-graph $G^F$, as well as,
the performance improvement $AUC^*$ over the benchmark that assumes that correlation structure is time-invariant, i.e., $G^{F}(t+h) = G^{F}(t)$.
Models were trained with a rolling window with initial start and end dates of 09/05/2012 and 09/10/2014, respectively.
The test period ranged from 09/17/2014 to 08/25/2017.
}
\label{tb:NA0}
\resizebox{\textwidth}{!}{%
\begin{tabular}{c|lr|lr|lr}
\multicolumn{1}{c}{} & \multicolumn{2}{c}{$E^+$} & \multicolumn{2}{c}{$E^-$} & \multicolumn{2}{c}{$G^{F}$}\tabularnewline
\cline{2-7}
\multicolumn{1}{l}{Lag}&\multicolumn{1}{c}{$AUC$}&\multicolumn{1}{c}{$\lambda$}&\multicolumn{1}{c}{${AUC}$}&
\multicolumn{1}{c}{$\lambda$}&\multicolumn{1}{c}{$AUC$}&\multicolumn{1}{c}{$AUC^*$ (\%)}\tabularnewline
\hline
$ 1$&87 (0.33)&21 (0.76)&93 (0.11)&34 (1.2)&97 (0.064)&4 (0.091)\tabularnewline
$ 2$&87 (0.37)&33 (1.2)&93 (0.1)&45 (1.5)&95 (0.092)&6 (0.14)\tabularnewline
$ 3$&86 (0.39)&48 (1.5)&93 (0.11)&60 (1.6)&94 (0.11)&8 (0.17)\tabularnewline
$ 4$&86 (0.39)&65 (2)&93 (0.11)&65 (1.9)&93 (0.13)&10 (0.21)\tabularnewline
$ 5$&85 (0.41)&85 (2.6)&93 (0.11)&66 (1.9)&92 (0.15)&11 (0.24)\tabularnewline
$ 6$&85 (0.41)&100 (3.2)&93 (0.1)&74 (2)&91 (0.16)&12 (0.27)\tabularnewline
$ 7$&84 (0.42)&120 (3.5)&93 (0.1)&70 (2.2)&90 (0.18)&13 (0.3)\tabularnewline
$ 8$&84 (0.43)&150 (4.3)&93 (0.1)&72 (1.9)&89 (0.19)&15 (0.33)\tabularnewline
$ 9$&83 (0.44)&180 (5.7)&93 (0.1)&74 (2.2)&88 (0.21)&16 (0.37)\tabularnewline
$10$&83 (0.43)&220 (6.3)&93 (0.096)&79 (1.9)&87 (0.21)&17 (0.4)\tabularnewline
$11$&82 (0.43)&260 (7.2)&93 (0.094)&78 (2)&87 (0.22)&18 (0.43)\tabularnewline
$12$&82 (0.42)&300 (7.9)&93 (0.09)&86 (2.4)&86 (0.22)&19 (0.45)\tabularnewline
$13$&82 (0.43)&330 (7.9)&93 (0.09)&95 (2.1)&85 (0.22)&20 (0.49)\tabularnewline
$14$&81 (0.43)&360 (9.2)&93 (0.084)&100 (2.4)&84 (0.23)&21 (0.51)\tabularnewline
$15$&81 (0.43)&390 (9.9)&93 (0.083)&110 (2.3)&84 (0.24)&22 (0.55)\tabularnewline
$16$&81 (0.43)&410 (10)&93 (0.08)&120 (3)&83 (0.24)&23 (0.58)\tabularnewline
$17$&80 (0.43)&440 (11)&94 (0.079)&130 (2.6)&82 (0.25)&24 (0.62)\tabularnewline
$18$&80 (0.44)&470 (12)&94 (0.076)&150 (3)&82 (0.25)&25 (0.67)\tabularnewline
$19$&80 (0.46)&500 (12)&94 (0.072)&160 (3.6)&81 (0.27)&26 (0.71)\tabularnewline
$20$&80 (0.48)&510 (12)&94 (0.068)&170 (3.7)&80 (0.28)&27 (0.79)\tabularnewline
\hline
\multicolumn{7}{l}{*A likelihood ratio of $\lambda > 18.47$ indicates statistical significance at $p = 0.001$.}
\end{tabular}
}
\end{table}
 \subsection{Prediction of Social Opinion Structure}
We have so far established that social opinion structure can provide statistically significant information about the future financial market structure.
In this section, we investigate the opposite relationship of whether financial market structure can also significantly improve the prediction
of future social opinion structure,
and we determine if this effect is larger or smaller.

The comparison between performance results is summarized in Fig. \ref{fig:SM-1-rolling},
where the prediction of social opinion structure $G^{S}$ is plotted together
with the results for the prediction of financial market structure $G^{F}$ that was discussed previously.
Surprisingly, results suggest that financial market structure has a higher predictability than social opinion structure.
We also observe that both the financial network and social opinion network predictions lead to an improvement
compared to the naive benchmark that considers time invariance in social network structure.
As previously observed, the relative performance improvement increases with time lag.
In this case, the relative improvement in prediction is higher for the social opinion structure than for the financial network as observed in Fig. \ref{fig:SM-1-rolling} panel B).

 \begin{figure}[!h]
\centering
\scalebox{0.38}{\includegraphics{fig/SM-P1-AUC-rolling_.png}}
\caption{\textbf{Evidence that financial market structure has higher predictability than social media structure.}
Panel A) shows mean performance (AUC) in the prediction of
out-of-sample edges of the full financial network $G^{F}$ and the social opinion network $G^{S}$.
Panel B) shows the performance improvement ($AUC^*$) against a naive benchmark that assumes that the correlation structure is time-invariant.
Error bars indicate standard error.
}
\label{fig:SM-1-rolling}
\end{figure}
One of the possible reasons why social opinion structure is less predictable compared to financial network structure is the higher structural variability of the former compared to the latter.
Fig. \ref{fig:SM-2} provides evidence that social media structure is less stable than financial market structure in terms of the
number of edge changes over time.
More edges changed in the social opinion network than in the financial network for all lags tested.
We observed that more than 50\% of the edges in the social media opinion structure
changed compared to 40\% in the financial network over a time lag of 20 trading weeks.
\begin{figure}[!h]
\centering
\scalebox{0.35}{\includegraphics{fig/SM-P2-new-edges-f-sm.png}}
\caption{\textbf{Evidence that social media structure is less stable than financial market structure in terms of number of edge changes in time.} We observe that almost 40\% of edges in Financial Networks
changed after a period of 20 trading weeks while the social media structure changed more than 50\% of its edges over the same time lag.
A network at time $t$ is constructed from a correlation structure estimated from a sliding window of 126 trading days starting at time $t$ that moves with time step of 1 trading week.
The financial network measures co-movement of stock returns while the social network measures co-movement of opinion over the same stocks.
Error bars indicate standard error.
}
\label{fig:SM-2}
\end{figure}
\section{Discussion and Conclusions}

We investigated whether financial market structure can be better predicted by combining past financial information with past social media sentiment information.
We considered the $N = 100$ most capitalized companies that were part of the S\&P500 index in the period between May 2012 and August 2017.
We generated two networks: A financial network constructed from log-returns of equity prices and a social network constructed from Twitter sentiment analytics.
We constructed filtered correlation-based networks by keeping the strongest top quartile correlations only that considered a rolling window of $T=126$ trading days.
The two networks were treated as a multiplex problem with two layers of networks that share the same nodes (stocks) but have different edge sets.

The financial market structure forecasting problem was formulated as a link prediction problem where we estimated the probability
of the addition or removal of a link in the  future on information about the past structure of financial and social opinion networks.

We proposed that financial network links were formed by a combination of the two mechanisms of triadic closure and edge persistence.
The first mechanism assumes that two stocks have a propensity to be correlated if they share common neighbors.
The edge persistence mechanism assumes that two connected stocks tend to remain connected in the future.
A logistic model was trained over a set of data between 09/05/2012 and 09/10/2014 and then results were reported for the
validation set over the following period from 09/17/2014 and 08/25/2017.

Our results indicate that financial market structure is considerably time variant,
which invalidates the commonly used assumption of time invariance in the determination of stock correlation structure.
The proposed model exhibited high out-of-sample performance in financial network link prediction,
particularly in the case of long-term predictions where we observed a performance improvement of up to
40\% over a naive benchmark that assumed that the correlation structure of the financial market was time invariant.
Likelihood ratio analysis demonstrated that models that considered both financial and social information better fit
the data when compared to a restricted model that considers financial information only.
This provides evidence that supports the use of social information in the prediction of financial market structure.

Finally, our findings indicate that social opinion structure is less stable than financial market structure.
Surprisingly, the prediction of financial market structure using past social and financial information presented higher performance
compared to the problem of predicting social opinion structure using past social and financial information.

Let us note that network link formation can occur due to mechanisms beyond the ones we studied here.
For instance, networks can form links as a result of a growth process that adds new nodes in the network, e.g.,
IPOs can generate growth in a financial network.
Among other possible mechanisms, link formation can occur due to preferential attachment, a phenomenon widely observed in real networks where new nodes
tend to link to the more connected ones \cite{barabasi2016network}.

In summary, this study indicates that social opinion structure is relevant to the prediction of future financial correlation structures.
This result has important consequences because of the fundamental importance of financial correlation structure in Modern Portfolio Theory (MPT) \cite{luenberger2014investment},
Capital Asset Pricing Model (CAPM) and Arbitrage Pricing Theory (APT) \cite{campbell1997econometrics}.
Future work should focus on the investigation of further mechanisms of financial link formation and on applications in portfolio allocation strategies.

\section{Acknowledgments}

This work was supported by PsychSignal.com, which provided social media data.
T. Aste acknowledges support of the UK Economic and Social Research Council (ESRC) in funding the Systemic Risk Centre (ES/K002309/1).
T.T.P. Souza acknowledges financial support from the Brazilian National Council for Scientific and Technological Development (CNPq).

\section{Introduction}

Financial markets can be regarded as a complex network in which nodes represent different financial assets and edges
represent one or many types of relationships among those assets.
Filtered correlation-based networks have successfully been used in the literature to study financial markets structure particularly
from observational data derived from empirical financial time series \cite{10.1371/journal.pone.0017994, Mantegna1999, aste2010correlation, Tumminello201040, Tumminello26072005}.
The underlying principle is to use correlations from empirical financial time series to construct a sparse network representing
the most relevant connections.
Analyses on filtered correlation-based networks for information extraction \cite{1367-2630-12-8-085009,song2008analysis,aste2010correlation}
have widely been used to
explain market interconnectedness from high-dimensional data.
Applications include asset allocation \cite{pozzi2013spread}, market stability assessments \cite{morales2012dynamical},
hierarchical structure analyses \cite{Mantegna1999, aste2010correlation,Tumminello201040, musmeci2014clustering, song2012hierarchical}
and the identification of lead-lag relationships \cite{curme2015coupled}.

The majority of literature so far has focused on the analysis of financial time series.
However, in recent years a large amount of information about financial markets has become available from exogenous sources such as social media.
It is reasonable to conceive that changes in social media sentiment \cite{1507.00955} and changes in asset prices might be related.
Some  previous studies have indeed demonstrated the existence of relationships which in some cases
indicated that social media can be used to predict changes in asset prices \cite{8252134, 1507.00784, citeulike:13108056, tetlock2007giving, Tobias:2013, mao2014quantifying}.
When new information hits the markets, investors may react either rationally or irrationally \cite{BondtandThaler1985, shleifer2000inefficient}.
They may express opinions on social media that can later become market actions, thus enabling opportunities to forecast future asset prices.
However, it has also been highlighted that not all assets behave in the same way.
Some are more influenced by social media sentiment, while others, on the contrary,
are more influential on the social media sentiment \cite{2016arXiv160104535S}.
Besides each single financial asset, we address in this study whether the entire stock market structure
is related to the structure constructed from
social media sentiment and whether there exist lead-lag relationships exist that can be used for forecasting one structure in terms of the other.

We use dynamical Kendall correlations computed over rolling windows to investigate the temporal
evolution of market structure represented by filtered correlation-based networks constructed from stock market prices and from Twitter sentiment signals.
We generate two networks: one from log-returns of stock prices and the other from Twitter sentiment.
The two networks are treated as a multilayer problem with two layers of networks that share the same nodes but have different edge sets.
We investigate whether financial market structure can be better predicted by
combining past financial information with past social media sentiment information.
The market structure forecasting problem is formulated as a link prediction problem where we estimate the probability of addition
or removal of a link in the future based on information about the structure of the financial and social networks in the past.

\section{Methods}

\subsection{Financial and Social Networks}
We selected $N = 100$ of the most capitalized companies that were part of the S\&P500 index
from 09/05/2012 to 08/25/2017.
The list of these companies' ticker symbols is reported in the Appendix \ref{sec:comps}.
For each stock $i$ the financial variable was defined as
the daily stock's log-return $R_i(\tau) = \log{Price(\tau)} - \log{Price(\tau-1)}$, where $Price(\tau)$ designates the closing price at time $\tau$.
The social media variable was defined as the the social media opinion $O_i$ of stock $i$
which was estimated as the total number of bullish daily tweets related to the stock $i$ at time $\tau$.
Twitter sentiment data were provided by PsychSignal.com \cite{PsychSignal}.
In this dataset, a Twitter message was defined to be related to a given stock when its ticker symbol was mentioned.
The dataset used only English language content and it was agnostic to the country source of the Twitter message.
We have provided further descriptive analytics of the Twitter sentiment dataset used in related literature \cite{8252134, 2016arXiv160104535S}.

Stock returns $R_i$ and social media opinion scores $O_i$ each amounted to a time series of length equals to 1251 trading days.
These series were divided time-wise into $M = 225$ windows $t = 1, 2, \ldots, M$
of width $T = 126$ trading days.
A window step length parameter of $\delta T = 5$ trading days defined the displacement of the window, i.e., the number of trading days
between two consecutive windows. The choice of window width $T$ and window step $\delta T$ is arbitrary, and
it is a trade-off between having analysis that is either too dynamic or too smooth.
The smaller the window width and the larger the window steps, the more dynamic the data are.

To characterize the synchronous time evolution of assets,
we used equal time Kendall's rank coefficients
between assets $i$ and $j$, defined as
\begin{equation}
 \rho_{i, j}(t) = \sum\limits_{t' < \tau}sgn(V_i(t') - V_i(\tau))sgn(V_j(t') - V_j(\tau)),
\end{equation}
where $t'$ and $\tau$ are time indexes within the window $t$ and $V_i \in \{R_i, O_i\}$.

Kendall's rank coefficients fulfill the condition $-1 \leq \rho_{i, j} \leq 1$ and form the $N \times N$ correlation matrix
$C(t)$ that served as the basis for the networks constructed in this paper. To construct
the asset-based financial and social networks, we defined a distance between a pair of stocks. This
distance was associated with the edge connecting the stocks, and it reflected the level at which they were correlated.
We used a simple non-linear transformation $d_{i, j}(t) = \sqrt{2(1 - \rho_{i,j}(t))}$ to obtain distances with the
property $2 \geq d_{i,j} \geq 0$, forming a $N \times N$ symmetric distance matrix $D(t)$.

We extracted the $N(N-1)/2$ distinct distance elements from the upper triangular part of the distance matrix
$D(t)$, which were then sorted in an ascending order to form an ordered sequence
$d_1(t), d_2(t), \ldots, d_{N(N-1)/2}(t)$. Since we require the graph to be representative of the market,
it is natural to build the network by including only the strongest connections. This is a network filtering procedure
that has been successfully applied in the construction of \textit{asset graphs} for the analyses of market structure \cite{1402-4896-2003-T106-011, refId0-Onnela-2004}.
The number of edges to include is arbitrary, and we included those from the bottom quartile,
which represented the 25\% shortest edges in the graph (largest correlations), thus giving $E(t) = \{d_1(t), d_2(t), \ldots, d_{\floor{N/4}}(t)\}$.

We denoted $E^{F}(t)$ and $E^{S}(t)$ as the set of edges constructed from the distance matrices derived from
stock returns $R(t)$ and social media opinion $O(t)$, respectively.
Two networks were considered as two layers of a duplex structure
$\mathcal{G} = \{G^{F}, G^{S}\}$ where $G^{F} = ( V, E^{F} )$, $G^{S} = ( V, E^{S} )$
and $V$ is the vertex set of stocks which is common to both layers.

\subsection{Persistence}
The state of an edge between vertices $u$ and $v$  in the financial layer at time $t$ was represented
with the corresponding adjacency matrix element $E^F_{u,v}(t)$: a binary variable with $E^F_{u,v}(t)=1$
indicating the existence of the edge and $E^F_{u,v}(t)=0$ its absence.
Analogously, the variable $E^S_{u,v}(t)$  accounted for the presence or absence of edge $(u,v)$ in the social ($S$) layer.
The variable $E_{u,v}(t)=E^F_{u,v}(t) \vee E^S_{u,v}(t)=1$ indicates instead the presence of at least one
edge between $u$ and $v$ in the two layers; $E_{u,v}(t)=0$ indicates that no edges are present between $u$ and $v$ in any layer.

\subsection{Triadic Closure}
Let $\mathcal{N}_{uv}$ be the set of nodes that are common neighbors to vertices $u$ and $v$.
We defined the triadic closure $T^F_{u,v}(t)$ of an edge $(u,v)$ at layer $F$ and time $t$ as the mean of the clustering coefficients of vertices in  $\mathcal{N}_{uv}$:
\begin{equation}
T^F_{u,v}(t) = \frac{1}{|\mathcal{N}_{uv}|}\sum_{i \in \mathcal{N}_{uv}} C^F_i(t),
\end{equation}
where term $C^F_i$ is the clustering coefficient of node $i$ which accounts for the
fraction of triads in the neighbors of $i$  that are closed in triangles. This is defined as
\begin{equation}
C^F_i = 2 \frac{\mbox{Number of triangles with a vertex on $i$}}{k_i (k_i - 1)} =  \frac{\sum_{j,k\in \mathcal{N}_i} E^F_{j,k}}{k_i (k_i - 1)},
\end{equation}
where $k_i$ is the degree of vertex $i$ and $\mathcal{N}_i$ is the neighborhood of $i$.

In the multiplex case, we kept the same definition but allowed triangles to form across several layers \cite{Battiston2017, 1367-2630-17-7-073029}.
For the multiplex case, we used the symbol $T_{u,v}(t)$.
\captionsetup[subfigure]{labelformat=empty}
\begin{figure}[!h]
\centering
\begin{subfigure}{.45\textwidth}
\caption{\textbf{A)}}
  \centering
  \includegraphics[width=.9\linewidth]{fig/ex_singlelayer_01}
  \label{fig:sub1}
\end{subfigure}%
\begin{subfigure}{.45\textwidth}
\caption{\textbf{B)}}
  \centering
  \includegraphics[width=.9\linewidth]{fig/ex_multilayer_01.pdf}
  \label{fig:sub2}
\end{subfigure}
\caption{Triads on a single layered network (Panel A) and on a multiplex network (Panel B).
The clustering coefficient of node $i$ accounts for the fraction of triads in the neighborhood of $i$ that are closed in triangles.
The triadic closure of an edge $(u,v)$ at layer $F$ is a function of the clustering coefficients of the common neighbors of the vertices $u$ and $v$.
Triangles can be formed in a single layer or across layers.}
\label{fig:TRIADS}
\end{figure}

\subsection{Link Prediction}
\label{sec:link}
We aim to predict the probability that an edge is inserted or removed in the financial network, $G^{F}(t+h)$, at a future time $t+h$
by using the information about the past structures of the financial and social networks at previous times $t' \le t$.
For this purpose we considered two mechanisms:
\begin{itemize}
\item[1)] the tendency of an edge present at a previous time to persist in the future ({\it edge persistence});
\item[2)] the propensity of triangles within or across layers to close ({\it triadic closure}).
\end{itemize}
The mechanism of growth by triadic closure is based on a principle of transitivity, often observed in real-world networks,
where there is a tendency to form triangles. Under this principle, two nodes tend to be connected if they share common neighbors with high transitivity, i.e., propensity to close triangles.

The probability that an edge will be inserted in the future is computed by means of a logistic regression of the edge persistence and the triadic closure coefficients.
We estimated regression coefficients by best fitting on a training set which was composed of rolling windows of 126 trading days that
initially ranged from 09/05/2012 to 09/10/2014.
Predictions concerning the presence of edges in the financial network were made at $h=1$ to $h=20$ weeks ahead of the end of the training set.
The test set initially ranged from 09/17/2014 to 08/25/2017.
The procedure was repeated by moving the training window forward in 1-week steps.

The probability $p_{u,v}(t+h)$ to observe vertices $u$, $v$ connected by an edge at $t+h$ can be inferred
in terms of the set of previous triadic closure coefficients,
$T_{u,v}(t)$, and edge persistence scores $E_{u,v}(t)$. We first considered a restricted model that used financial information only, which
is given by the following:
 \begin{equation}
   \log\frac{p^F_{u,v}(t+h)}{1 - p^F_{u,v}(t+h)} = \tilde\beta_0^h + \tilde\beta^h T^F_{u,v}(t) + \tilde\gamma^h E^F_{u,v}(t).
   \label{eq:logit2}
 \end{equation}
For this restricted model, we performed a 1-step ahead prediction for $h \in (1, 2, \ldots, 19, 20)$ weeks.

To calibrate the parameters in Eq. \ref{eq:logit2}, we considered a training window of $W = 126$ days which ends at time $t$.
The log-likelihood function \cite{faraway2006elm} over the training window for the logistic model from Eq. \ref{eq:logit2} is given by
\begin{equation} \label{eq:loglik2}
\begin{split}
 \mathcal{L}^F(t) =& \, \sum\limits_{t'=t-W+1}^{t}\,\sum\limits_{uv \in E^{F}(t'+h)} - \log{(1 + e^{\tilde\beta_0^h + \tilde\beta^h T^F_{u,v}(t') + \tilde\gamma^h E^F_{u,v}(t')})} \, + \\
 & \sum\limits_{t'=t-W+1}^{t}\,\sum\limits_{uv \in E^{F}(t'+h)} (1 - E_{uv}^F(t'+h))(\tilde\beta_0^h + \tilde\beta^h T^F_{u,v}(t') + \tilde\gamma^h E^F_{u,v}(t')).
\end{split}
\end{equation}

We differentiated the log-likelihood function given by Eq. \ref{eq:loglik2} in order to find maximum
log-likelihood estimates for the coefficients of Eq. \ref{eq:logit2}.

To verify whether the multiplex information is relevant in the prediction of links in the financial network compared to past a financial network alone,
we considered a full regression model that takes the set of previous triadic closure coefficients and edge persistence
from the financial layer ($T^F_{u,v}(t), E^F_{u,v}(t)$), social layer ($T^S_{u,v}(t), E^S_{u,v}(t)$) and the multiplex network ($T^F_{u,v}(t), E^F_{u,v}(t)$).
The full model is
\begin{equation} \label{eq:logit}
\begin{split}
   \log\frac{p_{u,v}(t+h)}{1 - p_{u,v}(t+h)} =& \, \beta_0^h + \beta_1^h T^F_{u,v}(t) + \beta_2^h E^F_{u,v}(t) \, + \\
   & \gamma_1^h T^S_{u,v}(t) + \gamma_2^h E^S_{u,v}(t) + \theta_1^h T_{u,v}(t) + \theta_2^h E_{u,v}(t).
 \end{split}
 \end{equation}

The log-likelihood function $\mathcal{L}(t)$ of the full model in Eq. \ref{eq:logit} and
the model fitting can be obtained in an analogous manner to the previously performed procedure for the restricted model from Eq. \ref{eq:logit2}.

The likelihood ratio statistic is
 \begin{equation}
\lambda(t) = -2 (\mathcal{L}_{max}(t) - \mathcal{L}_{max}^F(t)),
 \end{equation}
where $\mathcal{L}_{max}(t)$ and $\mathcal{L}_{max}^F(t)$ are,respectively, the maxima of the log-likelihood functions of the full and
restricted models in the training set window.
The likelihood ratio statistic $\lambda(t)$ can be assumed to follow a $\chi^2$ distribution \cite{faraway2006elm} with 4 degrees of freedom where a value of $\lambda > 18.47$
is assumed to be statistically significant at $p = 0.001$.
In that case, there is evidence to accept the full model that considers social and financial information
over the restricted model that considers financial information only.

The model performance was estimated by counting both the true positives (edges predicted to be there and indeed present in the future network)
and the false positives (edges predicted to be there but not present in the future network)
and measuring of AUC (area under the receiver operating characteristic curve) in the test set that originally ranged from 09/17/2014 to 08/25/2017.
AUC ranges from 0.50 to 1.00, with higher values indicating that the model discriminates better between the two categories of edge-present and edge-absent.

\section{Results}

\subsection{Market structure dynamics}
We first investigated financial network persistence by comparing the financial network $G^{F}(t)$
at time $t$ with a future financial network, $G^{F}(t+h)$ at $h$ steps ahead.
To quantify the changes in the correlation network structure, we used two measures:
A) the fraction of new edges in $G^{F}(t+h)$ that were not present in $G^{F}(t)$;
B) the Jaccard Distance, defined as
$$ Jaccard(G^{F}(t'), G^{F}(t)) = \frac{\|G^{F}(t') \cap G^{F}(t)\|}{\|G^{F}(t') \cup G^{F}(t)\|}.$$
Results are reported in Fig. \ref{fig:TRIADS1-rolling}, panels A) and B), respectively.

 \begin{figure}[!h]
\centering
\scalebox{0.28}{\includegraphics{fig/P1-new-edges-persistence.png}}
\caption{\textbf{Evidence that financial correlation structure changes considerably with time}.
Panel A) shows the mean percentage of new edges in the financial network at time $t+h$ with respect to the edge set at time $t$  ($1 \leq h \leq 20$ trading weeks).
We observe that edges change considerably in the financial network with almost 40\% of edges in financial networks changing after a period of $h = 20$ trading weeks.
Panel B) shows the cross-similarity among financial networks measured as the Jaccard Distance between $G^{F}(t')$ and $G^{F}(t)$ with $t$ and $t'$
ranging from 09/05/2012 to 21/02/2017. We observe that edge changes (persistence) are quite stable overtime, i.e.,
the number of edges that change is similar throughout the period.
Network $G^{F}(t)$ are constructed at each time $t$ from a correlation structure estimated from a sliding window of 126 trading days starting at time $t$.
The windows move with time step of 1 trading week.
Error bars in Panel A) indicate standard error.
}
\label{fig:TRIADS1-rolling}
 \end{figure}

Fig. \ref{fig:TRIADS1-rolling} panel A) shows the mean percentage of new edges in the financial network at time $t+h$ with respect to the edge set at time $t$  ($1 \leq h \leq 20$ trading weeks).
We observe that edges change considerably in the financial network with almost 40\% of edges in financial networks changing after a period of $h = 20$ trading weeks.
Fig. \ref{fig:TRIADS1-rolling} panel B) shows the cross-similarity among financial networks measured as the Jaccard Distance between $G^{F}(t')$ and $G^{F}(t)$ with $t$ and $t'$
ranging from 09/05/2012 to 21/02/2017. We observe that edge changes (persistence) are quite stable overtime, i.e.,
the number of edges that change is similar throughout the period.
Hence, results indicate that the constructed financial networks are time-variant across the entire period studied,
with a stable rate of edge changes over time.

\subsection{Prediction of Stock Market Structure}
We used Eq. \ref{eq:logit} to predict a the financial network $G^{F}(t+h)$ at a future time $t+h$
by using the information about the past structures of the financial and social networks at previous times $t' \le t$.
Fig. \ref{fig:TRIADS3-rolling} panel A) shows the performance obtained in the prediction of
out-of-sample edges for $h \in (1, 5, 10, 15, 20)$ trading steps ahead.
We achieved an overall high out-of-sample performance in financial network link prediction,
with performances in the range of 73\% to 95\% depending
on time-lag and time-period. Prediction power improved with a smaller time lag.

\begin{figure}[!h]
\centering
\scalebox{0.36}{\includegraphics{fig/P2-AUC-time-rolling_.png}}
\caption{\textbf{Evidence of high out-of-sample performance in financial network link prediction.}
Models were trained in an expanding window with initial start and end dates 09/05/2012.
and 09/10/2014, respectively. Test period ranges from 09/17/2014 and 08/25/2017.
Plots display the performance results (AUC) of a model to predict edges in a financial network at time $t + h$ trained with
information up to date $t$.
Panel A) shows the performance obtained in the prediction of out-of-sample edges for $h \in (1, 5, 10, 15, 20)$ trading weeks.
Panel B) shows the performance improvement ($AUC^*$) compared to a naive benchmark that assumes that the
correlation structure is time-invariant, i.e., $G^{F}(t+h) = G^{F}(t)$.
}
\label{fig:TRIADS3-rolling}
 \end{figure}

We compared our results to those obtained using a benchmark model that assumes that correlation structure is
time-invariant, i.e., $G^{F}(t+h) = G^{F}(t)$.
The performance improvement against the benchmark is estimated as $AUC^* = (AUC - 0.5)/(\widehat{AUC} - 0.5) - 1$, where $AUC$
represents the performance of the proposed model and $\widehat{AUC}$ is the performance of the benchmark.
From Fig. \ref{fig:TRIADS3-rolling} panel B), we observe that the higher the time lag, the higher the performance improvement over the benchmark.
Let us note that performance improvement over the naive benchmark reached values as high as 40\% for a long-term prediction with a lag of 20 trading weeks.

Fig. \ref{fig:TRIADS4-rolling} reports an aggregate overview of the previous results for the
out-of-sample prediction in terms of the number of weeks ahead.
We observe that as the lag increases, the prediction performance declines (panel A).
However, the improvement in performance over the naive benchmark improves (panel B).

\begin{figure}[!h]
\centering
\scalebox{0.28}{\includegraphics{fig/P3-AUC-lags-rolling_.png}}
\caption{\textbf{The effect of time-lag on out-of-sample predictive performance.}
Panel A) shows the mean performance (AUC) of the prediction of
out-of-sample edges of the full financial network $G^{F}$. Panel B) shows the performance improvement ($AUC^*$) against a naive benchmark that assumes that correlation structure is time-invariant, i.e., $G^{F}(t+h) = G^{F}(t)$.
Error bars indicate standard error.
}
\label{fig:TRIADS4-rolling}
 \end{figure}

In Appendix \ref{sec:exp}, we report the results obtained by using an expanding window rather than a rolling window as a training set.
We observe that expanding the training set does not necessarily lead to better performance.
In fact, the rolling window analysis yielded better performance overall.

To verify whether the multiplex network provides additional information to that
from the financial network only, we re-computed the same out-of-sample edge prediction by using the financial network only
and compared this to
the results from the full model that considers both the financial and social information layers.
A comparison between the two models was performed by comparing their respective likelihoods.
We have also disaggregated the prediction of the insertion of new edges $E^+$ and the prediction of edge deletions $E^-$.
We report the likelihood values and AUC performance obtained for the fit of each model in Table \ref{tb:NA0}.

We observed that the model that includes both financial and social information better fit the data compared to the model that considers financial data only,
particularly for the case of the prediction of insertion of new edges.
The likelihood ratio increases with prediction lag indicating that full models (i.e. those that consider both financial and social networks) are
particularly important in long-term link prediction.
Results confirm that the multiplex network is distinctly better than the single financial layer with all likelihood ratios
having p-value $< 0.001$ for all configurations tested.
\begin{table}[!h]
\centering
\caption{\textbf{Financial Link Prediction Performance Results.}
High out-of-sample AUCs obtained indicate that the model has high performance balancing
both false positives and false negatives predictions relative to true positive and negative values.
Log-likelihood ratios ($\lambda$) increase with prediction lag indicating that social media features are particularly important for long-term prediction.
The table reports mean $AUC$ values and log-likelihood ratios $\lambda$ over the test period with corresponding standard deviations in parentheses.
Results are reported for the prediction of new edges $E^*$ and edge deletions $E^-$.
We also report the average performance $AUC$ obtained in the prediction of the full-graph $G^F$, as well as,
the performance improvement $AUC^*$ over the benchmark that assumes that correlation structure is time-invariant, i.e., $G^{F}(t+h) = G^{F}(t)$.
Models were trained with a rolling window with initial start and end dates of 09/05/2012 and 09/10/2014, respectively.
The test period ranged from 09/17/2014 to 08/25/2017.
}
\label{tb:NA0}
\resizebox{\textwidth}{!}{%
\begin{tabular}{c|lr|lr|lr}
\multicolumn{1}{c}{} & \multicolumn{2}{c}{$E^+$} & \multicolumn{2}{c}{$E^-$} & \multicolumn{2}{c}{$G^{F}$}\tabularnewline
\cline{2-7}
\multicolumn{1}{l}{Lag}&\multicolumn{1}{c}{$AUC$}&\multicolumn{1}{c}{$\lambda$}&\multicolumn{1}{c}{${AUC}$}&
\multicolumn{1}{c}{$\lambda$}&\multicolumn{1}{c}{$AUC$}&\multicolumn{1}{c}{$AUC^*$ (\%)}\tabularnewline
\hline
$ 1$&87 (0.33)&21 (0.76)&93 (0.11)&34 (1.2)&97 (0.064)&4 (0.091)\tabularnewline
$ 2$&87 (0.37)&33 (1.2)&93 (0.1)&45 (1.5)&95 (0.092)&6 (0.14)\tabularnewline
$ 3$&86 (0.39)&48 (1.5)&93 (0.11)&60 (1.6)&94 (0.11)&8 (0.17)\tabularnewline
$ 4$&86 (0.39)&65 (2)&93 (0.11)&65 (1.9)&93 (0.13)&10 (0.21)\tabularnewline
$ 5$&85 (0.41)&85 (2.6)&93 (0.11)&66 (1.9)&92 (0.15)&11 (0.24)\tabularnewline
$ 6$&85 (0.41)&100 (3.2)&93 (0.1)&74 (2)&91 (0.16)&12 (0.27)\tabularnewline
$ 7$&84 (0.42)&120 (3.5)&93 (0.1)&70 (2.2)&90 (0.18)&13 (0.3)\tabularnewline
$ 8$&84 (0.43)&150 (4.3)&93 (0.1)&72 (1.9)&89 (0.19)&15 (0.33)\tabularnewline
$ 9$&83 (0.44)&180 (5.7)&93 (0.1)&74 (2.2)&88 (0.21)&16 (0.37)\tabularnewline
$10$&83 (0.43)&220 (6.3)&93 (0.096)&79 (1.9)&87 (0.21)&17 (0.4)\tabularnewline
$11$&82 (0.43)&260 (7.2)&93 (0.094)&78 (2)&87 (0.22)&18 (0.43)\tabularnewline
$12$&82 (0.42)&300 (7.9)&93 (0.09)&86 (2.4)&86 (0.22)&19 (0.45)\tabularnewline
$13$&82 (0.43)&330 (7.9)&93 (0.09)&95 (2.1)&85 (0.22)&20 (0.49)\tabularnewline
$14$&81 (0.43)&360 (9.2)&93 (0.084)&100 (2.4)&84 (0.23)&21 (0.51)\tabularnewline
$15$&81 (0.43)&390 (9.9)&93 (0.083)&110 (2.3)&84 (0.24)&22 (0.55)\tabularnewline
$16$&81 (0.43)&410 (10)&93 (0.08)&120 (3)&83 (0.24)&23 (0.58)\tabularnewline
$17$&80 (0.43)&440 (11)&94 (0.079)&130 (2.6)&82 (0.25)&24 (0.62)\tabularnewline
$18$&80 (0.44)&470 (12)&94 (0.076)&150 (3)&82 (0.25)&25 (0.67)\tabularnewline
$19$&80 (0.46)&500 (12)&94 (0.072)&160 (3.6)&81 (0.27)&26 (0.71)\tabularnewline
$20$&80 (0.48)&510 (12)&94 (0.068)&170 (3.7)&80 (0.28)&27 (0.79)\tabularnewline
\hline
\multicolumn{7}{l}{*A likelihood ratio of $\lambda > 18.47$ indicates statistical significance at $p = 0.001$.}
\end{tabular}
}
\end{table}
 \subsection{Prediction of Social Opinion Structure}
We have so far established that social opinion structure can provide statistically significant information about the future financial market structure.
In this section, we investigate the opposite relationship of whether financial market structure can also significantly improve the prediction
of future social opinion structure,
and we determine if this effect is larger or smaller.

The comparison between performance results is summarized in Fig. \ref{fig:SM-1-rolling},
where the prediction of social opinion structure $G^{S}$ is plotted together
with the results for the prediction of financial market structure $G^{F}$ that was discussed previously.
Surprisingly, results suggest that financial market structure has a higher predictability than social opinion structure.
We also observe that both the financial network and social opinion network predictions lead to an improvement
compared to the naive benchmark that considers time invariance in social network structure.
As previously observed, the relative performance improvement increases with time lag.
In this case, the relative improvement in prediction is higher for the social opinion structure than for the financial network as observed in Fig. \ref{fig:SM-1-rolling} panel B).

 \begin{figure}[!h]
\centering
\scalebox{0.38}{\includegraphics{fig/SM-P1-AUC-rolling_.png}}
\caption{\textbf{Evidence that financial market structure has higher predictability than social media structure.}
Panel A) shows mean performance (AUC) in the prediction of
out-of-sample edges of the full financial network $G^{F}$ and the social opinion network $G^{S}$.
Panel B) shows the performance improvement ($AUC^*$) against a naive benchmark that assumes that the correlation structure is time-invariant.
Error bars indicate standard error.
}
\label{fig:SM-1-rolling}
\end{figure}
One of the possible reasons why social opinion structure is less predictable compared to financial network structure is the higher structural variability of the former compared to the latter.
Fig. \ref{fig:SM-2} provides evidence that social media structure is less stable than financial market structure in terms of the
number of edge changes over time.
More edges changed in the social opinion network than in the financial network for all lags tested.
We observed that more than 50\% of the edges in the social media opinion structure
changed compared to 40\% in the financial network over a time lag of 20 trading weeks.
\begin{figure}[!h]
\centering
\scalebox{0.35}{\includegraphics{fig/SM-P2-new-edges-f-sm.png}}
\caption{\textbf{Evidence that social media structure is less stable than financial market structure in terms of number of edge changes in time.} We observe that almost 40\% of edges in Financial Networks
changed after a period of 20 trading weeks while the social media structure changed more than 50\% of its edges over the same time lag.
A network at time $t$ is constructed from a correlation structure estimated from a sliding window of 126 trading days starting at time $t$ that moves with time step of 1 trading week.
The financial network measures co-movement of stock returns while the social network measures co-movement of opinion over the same stocks.
Error bars indicate standard error.
}
\label{fig:SM-2}
\end{figure}
\section{Discussion and Conclusions}

We investigated whether financial market structure can be better predicted by combining past financial information with past social media sentiment information.
We considered the $N = 100$ most capitalized companies that were part of the S\&P500 index in the period between May 2012 and August 2017.
We generated two networks: A financial network constructed from log-returns of equity prices and a social network constructed from Twitter sentiment analytics.
We constructed filtered correlation-based networks by keeping the strongest top quartile correlations only that considered a rolling window of $T=126$ trading days.
The two networks were treated as a multiplex problem with two layers of networks that share the same nodes (stocks) but have different edge sets.

The financial market structure forecasting problem was formulated as a link prediction problem where we estimated the probability
of the addition or removal of a link in the  future on information about the past structure of financial and social opinion networks.

We proposed that financial network links were formed by a combination of the two mechanisms of triadic closure and edge persistence.
The first mechanism assumes that two stocks have a propensity to be correlated if they share common neighbors.
The edge persistence mechanism assumes that two connected stocks tend to remain connected in the future.
A logistic model was trained over a set of data between 09/05/2012 and 09/10/2014 and then results were reported for the
validation set over the following period from 09/17/2014 and 08/25/2017.

Our results indicate that financial market structure is considerably time variant,
which invalidates the commonly used assumption of time invariance in the determination of stock correlation structure.
The proposed model exhibited high out-of-sample performance in financial network link prediction,
particularly in the case of long-term predictions where we observed a performance improvement of up to
40\% over a naive benchmark that assumed that the correlation structure of the financial market was time invariant.
Likelihood ratio analysis demonstrated that models that considered both financial and social information better fit
the data when compared to a restricted model that considers financial information only.
This provides evidence that supports the use of social information in the prediction of financial market structure.

Finally, our findings indicate that social opinion structure is less stable than financial market structure.
Surprisingly, the prediction of financial market structure using past social and financial information presented higher performance
compared to the problem of predicting social opinion structure using past social and financial information.

Let us note that network link formation can occur due to mechanisms beyond the ones we studied here.
For instance, networks can form links as a result of a growth process that adds new nodes in the network, e.g.,
IPOs can generate growth in a financial network.
Among other possible mechanisms, link formation can occur due to preferential attachment, a phenomenon widely observed in real networks where new nodes
tend to link to the more connected ones \cite{barabasi2016network}.

In summary, this study indicates that social opinion structure is relevant to the prediction of future financial correlation structures.
This result has important consequences because of the fundamental importance of financial correlation structure in Modern Portfolio Theory (MPT) \cite{luenberger2014investment},
Capital Asset Pricing Model (CAPM) and Arbitrage Pricing Theory (APT) \cite{campbell1997econometrics}.
Future work should focus on the investigation of further mechanisms of financial link formation and on applications in portfolio allocation strategies.

\section{Acknowledgments}

This work was supported by PsychSignal.com, which provided social media data.
T. Aste acknowledges support of the UK Economic and Social Research Council (ESRC) in funding the Systemic Risk Centre (ES/K002309/1).
T.T.P. Souza acknowledges financial support from the Brazilian National Council for Scientific and Technological Development (CNPq).

redpajama_set_name: RedPajamaArXiv


text:
Communities to get relief from water, sewer woes. Is money spread fairly?
The legislature plans to spend $1.58 billion of American Rescue Plan money on water and sewer improvements, but only 14 of 115 communities designated as distressed would get funding earmarks under state House and Senate budget proposals.
When the Johnston County town of Benson began replacing its sewer lines along Main Street two years ago, it found that some of the pipes date back 71 years, Mayor Jerry Medlin said.
Some of those pipes were made out of clay, and some weren't even hooked up, Medlin said.
Benson got money to help replace the pipes through typical means, loans or grants from the state Department of Environmental Quality's Division of Water Infrastructure Authority. The division carefully oversees requests for federal and state money for water and sewer improvement projects.
The problem has been that there is never enough money to go around.
That burden was lifted to a degree this year though, after passage of the American Rescue Plan Act, a $1.9 trillion relief package approved by the Biden administration in March that seeks to combat the health and economic impacts caused by the COVID-19 pandemic.
While much of the rescue money went to providing Americans with stimulus checks, it has also been doled out to states to help them recover from the pandemic. North Carolina is slated to receive $5.7 billion in ARP funding. State Senate and House budget proposals call for spending $1.58 billion of that money on water and sewer infrastructure projects.
The money will provide huge relief to many municipalities, said Shadi Eskaf, the Division of Water Infrastructure's new director.
"There's a significant need for investment, especially for smaller local governments that might have a harder time accessing funds on their own through bonds and other avenues," Eskaf said. "So the $1.58 billion as budgeted so far would be a significant boost to a lot of local governments to invest in water and sewer that's needed for economic development, for public safety, for public health."
Overflows and health
It's no secret that many of the municipal water and sewer systems in North Carolina are old and deteriorating.
In 2017, the Division of Water Infrastructure Authority drafted a master plan that said North Carolina would need as much as $26 billion over 20 years to resurrect or replace failing water and sewer systems, mostly those in small communities.
Those small communities are hit hardest partly because some of them struggle to make water and sewer services pay for themselves through their customers. Once upon a time, those smaller towns had one or two large mills or manufacturers that helped support infrastructure through taxes and fees. But with the loss of industry from many small North Carolina towns, tax coffers have been emptied.
One way to get around the service costs is to defer maintenance, which over time has led to leaking pipes, malfunctioning treatment plants and what the industry calls sewer overflows.
North Carolina regulations require municipalities to report sewer overflows whenever 1,000 gallons or more of untreated wastewater escapes from their sewer treatment plants, lift stations, manholes or clogged or broken sewer pipes. Last year alone, more than 74 million gallons of raw sewage gushed into the state's surface waters, according to figures from the DEQ.
Was there a sewer overflow near you in 2020? You can search this database by town, water system, and address.
Those overflows — which are getting more common as the climate continues to change and sewer systems across the state continue to deteriorate — can lead to serious health and environmental problems.
According to Municipal Sewer and Water magazine, contact with or inhalation or ingestion of raw sewage "can cause diarrhea and nausea, as well as a variety of infections, including ear infections, respiratory infections and skin/wound infections. In worst-case scenarios, people exposed to these discharges can also contract life-threatening diseases, including cholera, dysentery, infectious hepatitis and severe gastroenteritis."
Sewer overflows can also cause algal blooms, which produce toxins that can sicken or kill people and animals and create dead zones in water bodies.
Are funds spread equitably?
With so many smaller communities struggling mightily to maintain their water and sewer systems, how was the American Rescue Plan money earmarked in the House and Senate budget proposals?
Some money definitely is going to municipalities that may not be in desperate straits.
The Division of Water Infrastructure Authority and the Local Government Commission teamed up to create a system that ranks municipalities' needs and eligibility for state and federal funding through a mechanism known as the Viable Utility Reserve.
The reserve was created last year to help fund water and sewer projects for municipalities designated as distressed. North Carolina has 496 municipalities with water or sewer systems, or both. Of those, 115 are listed in the Viable Utility Reserve, yet only 14 are proposed to receive earmarks totaling about $69 million.
Municipalities designated as "distressed" by DEQ/ Local Govt Commission Number of these municipalities receiving earmarks Total amount for those earmarks Total ARP funding for the Viable Utility Reserve
115 14 $69 million $500 million
That is $7 million less than the earmarks proposed for just three entities that didn't make it into the Viable Utility Reserve — the Water and Sewer Authority of Cabarrus County and the towns of Benson and Clayton.
Benson is in a second-tier of municipalities classified in the House and Senate budgets as "at-risk." Clayton and the Water and Sewer Authority of Cabarrus County are in a third-tier referred to as "other directed projects."
In the House budget, Benson is set to receive earmarks totaling more than $22 million, while Clayton would get $24 million and the Water and Sewer Authority of Cabarrus County $30 million. Other municipalities in the "other directed projects" classification would also get big earmarks under the budget proposals, including $39 million to King's Mountain, Republican House Speaker Tim Moore's hometown.
Municipalities designated as "at risk" by the General Assembly Number of these municipalities receiving earmarks Total amount for those earmarks Total ARP funding for those "at risk" systems
23 23 $107 million $300 million
Municipalities designated as "other directed projects" by the General Assembly Number of these municipalities receiving earmarks Total amount for those earmarks Total ARP funding for those "other" projects
Another $34 million is targeted for Sanford, represented by Rep. John Sauls, who chairs the House Commerce Committee and sits on the Energy and Public Utilities Committee.
And $30 million would go to the South Granville Water and Sewer Authority, represented by Rep. Larry Yarborough, who chairs the House Environment Committee.
Two years ago, residents of South Granville appeared outside Town Hall to complain about tap water that was often brown and smelled of rotten eggs or vomit, according to WTVD-Channel 11.
In all, municipalities in the Viable Utility Reserve would get about $69 million in earmarks, while the "at-risk" communities would get $107 million and the "other directed projects" nearly $500 million.
As it stands now, the "at-risk" and "other directed projects" classifications don't exist anywhere but in the House and Senate budget proposals.
"DEQ will develop a list of at-risk communities if/once a state budget passes that allocates funds to at-risk communities," Cathy Akroyd, a spokeswoman for the DEQ, said in an email to NC Health News.
Municipalities that don't qualify for the Viable Utility Reserve are eligible for funding allocated through two other pots of money, the Drinking Water State Reserve and the Wastewater State Reserve.
"The way the House budget is proposed, a portion of those funds are specifically designed to be used by "at risk" communities and the remainder can be used by all other local government utilities," Akroyd wrote. "All of the funds that would go towards water and wastewater infrastructure, regardless of which specific Reserve or which category the local government is classified under, will be used for necessary infrastructure investments.
"There is a significant need for infrastructure investment among all types of local government utilities."
Earmarks to growing towns
Medlin, Benson's mayor, said his town is in dire need of the funding. Benson plans to expand its sewer plant, add a larger water storage tank and fix more deteriorated pipes and a couple of sewer lift stations.
"This is two and a half years, probably, of work that we're going to be doing here to bring our infrastructure up to date," he said.
Medlin said the town had been negotiating with Sen. Brent Jackson (R-Autryville) and Rep. Larry Strickland (R-Pine Level) for more than a year to get funding to help fix its water and sewer problems. He said the negotiations began before the Biden administration approved the American Rescue Plan Act of 2021.
"We've had a lot of meetings along the way to sell our story," Medlin said. "And, you know, they took it to the legislature."
Benson lies at the intersection of interstates 40 and 95, which is being expanded to eight lanes through the town. The town of fewer than 4,000 people is poised for growth as people seek alternatives to the higher costs of living in Raleigh, about 30 miles north on I-40, and industries look to locate on less expensive land.
As it stands now, Medlin said, Benson could not accommodate a new industry that employs 400 workers because its sewer system doesn't have the capacity.
Just up I-40, the town of Clayton is experiencing even greater growing pains. Long before Clayton officials had known ARP money would exist, it began planning to build the Neuse River Reclamation Facility, a water treatment plant capable of treating 6 million gallons a day. The plant, estimated to cost $175 million, has been billed as the most expensive project in the town's history. It will replace a treatment plant that was built in the 1960s.
After learning about the American Rescue Plan money for water and sewer improvements, Clayton officials reached out to state Sen. Lisa Barnes (R-Spring Hope), according to an email from Nathanael Shelton, the town's spokesman.
Negotiations led to the $24 million earmark, of which $20 million would be used to defray costs of the new water treatment plant and $4 million would be used to provide more water storage, according to the Senate's budget proposal.
In Cabarrus County, officials said they plan to use the $30 million in rescue plan money to help expand the Rocky River Regional Wastewater Treatment Plant at an estimated total cost of $120 million.
Mount Olive gets left out
The town of Mount Olive in Wayne County is among the 115 municipalities designated as distressed in the Viable Utility Reserve. The town is not among the 14 communities in the reserve that would get an earmark under the House and Senate budget proposals.
Jammie Royall, Mount Olive's town manager, didn't know about the large earmarks for other communities before he was contacted by NC Health News.
Sewer capacity is so limited in Mount Olive that the state in 2015 slapped it with a moratorium that essentially prohibits the town from taking on any new commercial or residential development. The town is among 32 that were hit with moratoriums between 2003 and February 2019, according to a document from the DEQ.
Around 2017, Royall said, the town received a $5.5 million grant for its sewer system and has just started a project that is expected to one day lift the state's moratorium. But Royall said the town needs at least $10 million to $15 million more to completely fix its sewer system, which was further damaged by Hurricane Matthew in 2016 and Hurricane Florence in 2018.
Sewer overflows in Mount Olive last year resulted in more than 4 million gallons of raw sewage spilling into the state's surface waters, DEQ records show.
Royall laughed when told about the earmarks that other communities are expected to get.
"I will be glad to apply," he said. "We do need every penny that we could possibly get for it."
House and Senate leaders continue working to mold their separate budget proposals into a single document to present to Gov. Roy Cooper.
Rep. Dean Arp defends earmarks
State Rep. Dean Arp, (R-Monroe) helped draft the proposed House budget as a lead budget writer. Arp defends the earmarks, saying every municipality can benefit from American Rescue Plan funding through the grant process.
Arp noted that only $69 million of the $500 million in ARP funding set aside in the Viable Utility Reserve has been earmarked.
"You've got 86 percent of it still available for grants," he said.
The "at-risk" category would get $300 million, so about two-thirds of that money remains available for grants. But only about 20 percent of the $600 million in "other directed projects" remains unspent in the proposed House budget.
The remainder of the earmarked ARP money has been designated to a stormwater fund totaling $100 million and a training and assessments fund containing $80 million.
Arp said the American Rescue Plan money should go a long way to solving the state's water and infrastructure needs. He said it has been estimated that municipalities in the Viable Utility Reserve need $600 million to significantly reduce their water and sewer infrastructure problems.
"We're funding $500 (million) of that through this money," he said.
Arp said House leaders had considered putting $600 million into the Viable Utility Reserve but were concerned about municipalities being able to spend the money within the time constraints. Under the rescue plan funding guidelines, the money must be allocated by Dec. 31, 2024, and spent by the end of 2026.
DEQ says it will monitor communities
Eskaf, director of the state Division of Water Infrastructure , said his office has been checking with communities designated to receive earmarks to learn how they plan to spend the money and to ensure that they are following federal statutes and requirements under the American Rescue Plan Act.
"Even with all this funding that's available through this budget, it doesn't cover all the local governments' infrastructure needs," Eskaf said. "This will still be, you know, a significant boost to a lot of local governments to work on their water and sewer systems that they need to do, but there's going to be further needs going forward, as well.
"So I'm not concerned, as far as finding appropriate projects. There's definitely a significant need out there for all of the funds, and we will be working with local governments to make sure that all the projects meet their requirements."
Eskaf said he also isn't concerned that the municipalities getting the earmarks through the "other directed projects" funds are truly deserving of them when so many smaller communities are struggling.
"If the system doesn't have an earmark in the budget, they still have access to the funds," he said. "They just have to go through our usual process."
Arp dismissed any notion that the budget-writing process was not transparent or lacked public input.
"It troubles me that some are saying a lack of transparency when this is a grant program with a huge pot of money that they just have to apply for," he said.
Parent says Chatham County public school teacher bullied daughter for faith
A parent in Chatham County is claiming that a local public school teacher "bullied" his daughter for her Christian faith. The accusation came during a…
Asheboro woman charged with insurance fraud
Kenan Institute's Frontiers of Entrepreneurship event is now virtual, due to virus 'surge'
Appeals Court blocks ruling favoring DEQ in animal waste regulation dispute
Rent relief is still available – here's how it's being distributed

redpajama_set_name: RedPajamaCommonCrawl


Whisking is a technique of blending ingredients by hand to mix or fluff. It often serves to smooth the mixture or add air. It also helps to eliminate lumps in gravy often from the flour or cornstarch.
A whisk is a kitchen tool, most often made of metal, with a long, thin handle with wire loops joined at the end that form a large teardrop shape. Some newer whisks are coated with plastic for use with Teflon pans, metal can scratch the Teflon coating.
As we all know from our shopping trips into town, there seem to be a wide range of types and styles of whisks available to buy, but is there a real reason for this other than design?
Yes. While the required results result is the same, in that it is used to blend various ingredients together or to beat air into a recipe, there are many reasons for different designs and styles of the common metal wired whisk.
Whisks now come in all shapes and sizes and are made of a variety of materials, depending on their use. For example, one might prefer to use a dough whisk with a wooden handle for one job and an entirely different shaped end for blending together doughy ingredients in another kitchen application. A standard metal whisk would not be usable for this type of baking as you can understand, as it would not be sturdy enough to properly blend the ingredients.
Other varieties of whisks include nylon whisks, which are gentler when used with non-stick pans. The nylon material will not cause damage to the protective coating. Their main feature, which sets them apart from the rest is that they can be used at high temperatures without risk of melting and damaging the rest of the ingredients. Again, silicone whisks have similar features, and are quite easy to clean. The silicone whisk is strong enough to not be damaged when being used in a hard metal bowl. Unlike some types of plastics, they will also not absorb colors and stain. They are also dishwasher safe.
Another type of whisk has been made specifically for gravy with their metal wires placed very closely together as none of us like lumpy gravy with our Sunday dinners so we? Mini whisks have been created to give lighter, fluffier results when whisking eggs, cream and sauces. All of these can come with metal or rubber handles, but the latter is usually preferred for comfort when whisking for a long while.
Why is it important to select the correct type?
There are probably very few people in the world that enjoy baking and do not own an least one whisk. This is because it is a very valuable baking tool and holds great importance in every kitchen. Ensure that you make the proper whisk selection when you decide on the type of baking that you will be doing. Whisks can be used for beating eggs, whisking cake ingredients together and aerating meringues to ensure that they rise just the right amount.
Many people never give the tools in their kitchen a second thought. They are the tools of the trade for people who are serious about their cooking however, and having the right tool for the job is always a good idea.
Using the right tool for any kitchen job is important. You might also enjoy reading about choosing the right dispensers for use in your home.


text:
Former Burnley striker Crouch retires
Chris Boden
Peter Crouch has decided to hang up his boots after a distinguished career.
The 38-year-old ended the season with Burnley after signing a short-term deal in January and made six appearances either side of appendix surgery.
Sean Dyche kept the door open for the former England forward to return, but Crouch has opted to retire.
Crouch said in his Daily Mail column this morning: "Burnley, really, was the ideal place to finish. I didn't make the biggest impact after I went there in January but I was so glad I went.
"Sean Dyche is a top manager and the boys are quality. They have a fantastic set-up and I loved going in every day. They are a great club."
Dyche had said last week: "I've spoken to him a couple of times, but it's up to him to decide what he wants to do.
"He's just had another child and he has a lot of media as well.
"I spoke to him last week, and told him to let me know his thoughts, but beyond this week, we would have to know his decision one way or another.
"We enjoyed having him with us, and he did well in the time he had. He's kept himself fit, and he would be welcome back."
Burnley boss delighted with players' fitness levels
Dyche rules out Jones return
Barrowford Festival promises to hit all the right notes this weekend


text:
Q: What to use insread of Underscore.js ._where() for the arrays of property values Let's say we have the following data:
[
 {
      "name": "Experiment type10",
      "scale": ["Whole Brain", "Cell"],
      "datatype": "table"
 },
 {
     "name": "Experiment type11",
     "scale": ["Tissue", "Cell"],
     "datatype": "image"
 },
 {
     "name": "Experiment type12",
     "scale": "Tissue",
     "datatype": "text"
 }
]

With Underscore ._where I can filter out the objects with datatype "text", but I can't  filter out all the objects with scale equals to "Tissue" since it's in an array. Is that possible to do this type of filtering elegantly?

A: Use filter and contains:
    var hasTissues = function(item){
        return item.scale === 'Tissue' || _.contains(item.scale, 'Tissue');
    }

    var tissues = _.filter(list, hasTissues);

A: _.where is just a shortcut for the general purpose _.filter. _.filter uses a predicate function rather than a simple list of properties:
_(array).filter(function(h) {
    if(h.datatype !== 'text')
        return false;
    if(_(h.scale).isArray())
        return _(h.scale).indexOf('Tissue') !== -1;
    return h.scale === 'Tissue';
});

There are various ways of checking to see if h.scale is or contains 'Tissue': you could use a simple for-loop instead of _.indexOf, you could use typeof instead of _.isArray, you could say a = _([ h.scale ]).flatten() and check the array a, ...
Demo: http://jsfiddle.net/ambiguous/umwf348k/

redpajama_set_name: RedPajamaStackExchange


text:
Q: RxJava using zip to chain multiple calls I'm trying to construct an observable from a chain of API calls but I can't get it to work. What I have is four API calls ApiA, ApiB, ApiC and ApiD that return Observables using RxJavaCallAdapterFactory. ApiA and ApiB have to be called first and then after both are executed ApiC and ApiD should be called. After last two are executed View is initialized. I'm using zip operator for waiting to calls to finish, I'm not sure that's the way to go but I'm quite new to RxJava so if there is another and better way to do that please let me know.
Below is my code with comments showing where I got stuck
public Observable syncData() {
    return Observable.zip(
        // these two calls are executed
        callApiA(),
        callApiB(),
        (o, o2) -> Observable.zip(
            /* these two calls are not executed, it seems as if this zip has
            no subscriber but i don't know why ... */
            callApiC(),
            callApiD(),
            (o, o2) -> {
                someLogic();
                return Observable.empty();
            }));
}

And in view I just subsribe to this method
viewModel.syncData().subscribe(
            o -> mainAdapter.update(),
            throwable -> throwable.printStackTrace()
);

Again I'm fairly new to RxJava so any help will be appreciated. thanks

A: You are on the right track.
However, be aware that the .zip last parameter, Func is not returning Observable<R> from it's call function, but R directly.
So you are returning Observable to the Subscriber's onNext and not it's event.
flatMap in between is needed:
Observable.zip(callApi1(), callApi2(), Pair::new)
     .flatMap((pair) -> Observable.zip(
           Observable.just(pair.first()),
           Observable.just(pair.second()),
           callApiC(),
           callApiD(),
           (t1, t2, t3, t4) -> {
                 someLogic()
           }));

This is pseudocode, however I hope you get the idea:

*

*Zip first 2 calls (A, B)

*Return a Pair of objects returned from those functions

*Transform Pair using zip operator (using flatMap operator)

*Compose this Pair with the next 2 calls (C,D)

*Returns composed objects from someLogic() function (remembering, that someLogic should return R and not Observable<R>)

Hint for future:
Try writing it without lambda expressions first. Then you can see input and output parameters, so it is easier to write code. Then rewrite the same with lambda expressions.

A: The important part is that Observables are not executed until they are subscribed to.
So to explain what is happening the first Observable.zip is given a combination function (callApiA(),callApiB()) -> Observable<Something>, so it produces an Observable<Observable<Something>>.
The observable is sent as an element and never subscribed to.
To fix it you will need to flatten the observable stream: Observable.zip(...).flatmap(s -> s). This flattens the stream to Observable<Something> and subscribes to the inner observable.


text:
Q: "ModuleNotFoundError: No module named 'pyfingerprint'" I'm new to this coding and all I did was copying this instruction:
https://sicherheitskritisch.de/2015/03/fingerprint-sensor-fuer-den-raspberry-pi-und-debian-linux-en/
When I reach at the testing part I get this error:
from  pyfingerprint.pyfingerprint import PyFingerprint
ModuleNotFoundError: No module named 'pyfingerprint'

btw. I am using Raspberry Pi 3, running Python 3.7.3
and fingerprint scanner used is U.are.U 4500 Digital Persona

A: I think you missed the part of installing the python-fingerprint package from the tutorial you shared. Try installing it.
$ echo "deb http://apt.pm-codeworks.de wheezy main" | sudo tee -a /etc/apt/sources.list
$ wget -O - http://apt.pm-codeworks.de/pm-codeworks.de.gpg | sudo apt-key add -
$ sudo apt-get update
$ sudo apt-get install python-fingerprint


text:
Jody Bound Keeping Busy "Trading Four Tires for One Rubber Track"
By ladybug388 on March 26, 2020 • ( Leave a comment )
Story written with files from Jody Bound, compiled together by Ashley McCubbin
Everybody knows that through the summers, racers have a thrill for speed – though what happens when the winter months hit? Some of them go virtual racing, while others decide to trade in their car for a snowmobile.
Known for winning races and championships, Jody Bound and car owner Larry Wilson certainly have had success in the Outlaw Midgets. Though many do not realize that Wilson actually cut his roots competing in snowmobiles, both drag and oval competition, capturing several trophies in Canada and the United States.
Wilson hoped to get back to his roots this off-season, building a pair of snowmobiles to compete in the OSOR (Ontario Snowmobile Oval Racing) association which travels within Ontario. Though slowed down with pneumonia, he missed several events, but was gather enough strength to join the tour at Pinestone in Haliburton.
The initial plan was for Wilson to drive, with Bound cheering on the sidelines. However, plans would change on race day as a result of Wilson not feeling 100% and nobody else available. It was a whole new adventure for Bound, though, as he had never raced one himself and only witnessed three events prior to this one, but he was ready for the challenge.
"Can't be that hard," Bound explained. "Four corners, two straightaways, and turn left when you get to the corners – only difference was gas was on the right thumb instead of the right foot. Oh ya, and GO FAST!"
With zero laps of practice, one of the bumpiest tracks of the season, Bound managed to put the No. 5 on the podium with both sleds in second position.
"I was very happy with my finishes," he commented. "It was almost funny. I felt good finishing behind Andrew Daraugh, a fellow that had won world championship before at Eagle River Wisconsin."
Bound was back behind the controls for the last race of the season at the Polar Bear Cup in Cochrane, Ontario, with John (Beach) Schraa helping prepare the sleds for the event. Wilson entered his new (rookie) driver into three classes, including the open class against some of the most experienced, and the team was able to have success. Bound placed the No. 5 on the podium in second for all three classes, just inches from taking home the Polar Bear Cup.
"The OSOR has some great people and put on great events throughout the winter months in several locations," Bound commented. "With the racing age ranging from five-years-old in the 120 class to seasoned veterans in the Masters class, from entry level to full out race sleds, the club has something for everyone no matter your budget. There are other summer drivers that follow the winter circuit such as 2019 Outlaw Midget Champ Adam Carrothers and his partner Lynda Smith, both competing in there respective classes.
"It's a great opportunity to run equipment for Larry Wilson. His building ability in the car or snowmobiles is just amazing. Yes, the racing is fun and a great adrenaline fix, but its the time spent going to the track listening to old stories and just learning things from a such a knowledgeable person. Most of all, its true friendship."
Tagged as: featured, interview, jody bound
T.J. Edwards Ready for "Learning Year" in OSCAAR Modifieds
Brandon Feeney Welcomes Marketing Partners for 2020 Campaign


Hyperthyroidism is a condition characterized by high levels of hormones produced by the thyroid gland. It is also known as thyrotoxicosis. Hypothyroidism may be associated with diffuse toxic goiter and less frequently with toxic nodular goiter or toxic adeno ma. Most of these conditions of the thyroid gland occur in the early to mid adulthood. However, toxic nodular goiter may only arise after the age of 50 years despite the non-toxic form existing from earlier in life.
Although hypothyroidism (underactivity of the thyroid gland) is more common in the elderly, hyperthyroidism may also be seen in seniors. Excessive thyroid hormone causes generalized increase in metabolic rate of all body tissues. Hyperthyroidism is an excessive functional activity of thyroid gland that can be caused by an auto-immune condition known as Graves' disease or excessive replacement of thyroid hormones in hypothyroidism.
With Grave's disease, the eyes appear to pop out of the sockets, a condition known as exopthalmus. The skin is usually is warmer than normal and has a flushed appearance. The heart rate is generally increased in patients with hyperthyroidism. Palpitation may often be present and the blood pressure is typically elevated. The thyroid gland becomes diffusely enlarged, smooth, asymmetrical and nodular. The swelling over the gland moves while swallowing.
The most common cause of hyperthyroidism includes autoimmune disorders known as Graves' disease. In this condition the entire thyroid glands overproduces thyroid hormones due to disturbances in feedback mechanisms in between the thyroid gland and the pituitary gland. The condition is hereditary in nature. The trigger factors initiating Graves disease include head and neck radiation, stress, smoking and certain viral infections.
Hyperthyroidism can also be caused due to formation of a nodule within the gland. This is a less common cause of hyperthyroidism in most cases overall, however it is significant in the elderly. The condition is termed as toxic nodular goiter and is a non-cancerous growth of the gland. Thyroditis, a condition where there is inflammation of the thyroid gland, can be responsible for increased thyroid hormone production.
Antithyroid drugs include carbimazole, methylthiouracil and potassium perchlorate.The drugs are usually prescribed in combination with beta blocker drugs such as propranolol. Beta blockers are contraindicated in patients with cardiac failure, asthma and diabetes. This is a major concern when treating hyperthyroidism in the elderly, as cardiac conditions and diabetes are more common in seniors.
Surgical treatment such as subtotal thyroidectomy is the treatment of choice in young patients, who are too young to undergo radioactive iodine therapy. The surgical options are also preferred in patients unresponsive or allergic to antithyroid drugs. In patients over 40 years of age, radioactive iodine therapy is considered. Since thyroid hormones are produced from iodine, the radioactive forms are taken up by the thyroid gland and ultimately the gland is destroyed. This reduces thyroid hormone production.