diff --git a/.github/workflows/cache.yml b/.github/workflows/cache.yml index bd6f50e2..384638b4 100644 --- a/.github/workflows/cache.yml +++ b/.github/workflows/cache.yml @@ -18,23 +18,10 @@ jobs: python-version: "3.10" environment-file: environment.yml activate-environment: quantecon - # - name: Install latex dependencies - # run: | - # sudo apt-get -qq update - # sudo apt-get install -y \ - # texlive-latex-recommended \ - # texlive-latex-extra \ - # texlive-fonts-recommended \ - # texlive-fonts-extra \ - # texlive-xetex \ - # latexmk \ - # xindy \ - # dvipng \ - # cm-super - name: Build HTML shell: bash -l {0} run: | - jb build lectures --path-output ./ + jb build lectures --path-output ./ -W --keep-going - name: Upload "_build" folder (cache) uses: actions/upload-artifact@v2 with: diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index 64d3a4f8..e46f62dd 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -15,22 +15,22 @@ jobs: python-version: "3.10" environment-file: environment.yml activate-environment: quantecon - # - name: Graphics Support - # run: | - # sudo apt-get -qq update && sudo apt-get install -y graphviz - # - name: Install latex dependencies - # run: | - # sudo apt-get -qq update - # sudo apt-get install -y \ - # texlive-latex-recommended \ - # texlive-latex-extra \ - # texlive-fonts-recommended \ - # texlive-fonts-extra \ - # texlive-xetex \ - # latexmk \ - # xindy \ - # dvipng \ - # cm-super + - name: Graphics Support #TODO: Review if graphviz is needed + run: | + sudo apt-get -qq update && sudo apt-get install -y graphviz + - name: Install latex dependencies + run: | + sudo apt-get -qq update + sudo apt-get install -y \ + texlive-latex-recommended \ + texlive-latex-extra \ + texlive-fonts-recommended \ + texlive-fonts-extra \ + texlive-xetex \ + latexmk \ + xindy \ + dvipng \ + cm-super - name: Display Conda Environment Versions shell: bash -l {0} run: conda list @@ -45,12 +45,12 @@ jobs: name: build-cache path: _build # Build Assets (Download Notebooks and PDF via LaTeX) - # - name: Build PDF from LaTeX - # shell: bash -l {0} - # run: | - # jb build lectures --builder pdflatex --path-output ./ -n --keep-going - # mkdir -p _build/html/_pdf - # cp -u _build/latex/*.pdf _build/html/_pdf + - name: Build PDF from LaTeX + shell: bash -l {0} + run: | + jb build lectures --builder pdflatex --path-output ./ -n --keep-going + mkdir -p _build/html/_pdf + cp -u _build/latex/*.pdf _build/html/_pdf - name: Build Download Notebooks (sphinx-tojupyter) shell: bash -l {0} run: | diff --git a/.github/workflows/publish.yml b/.github/workflows/publish.yml index 6a01b0e6..cd9343d0 100644 --- a/.github/workflows/publish.yml +++ b/.github/workflows/publish.yml @@ -19,19 +19,19 @@ jobs: python-version: "3.10" environment-file: environment.yml activate-environment: quantecon - # - name: Install latex dependencies - # run: | - # sudo apt-get -qq update - # sudo apt-get install -y \ - # texlive-latex-recommended \ - # texlive-latex-extra \ - # texlive-fonts-recommended \ - # texlive-fonts-extra \ - # texlive-xetex \ - # latexmk \ - # xindy \ - # dvipng \ - # cm-super + - name: Install latex dependencies + run: | + sudo apt-get -qq update + sudo apt-get install -y \ + texlive-latex-recommended \ + texlive-latex-extra \ + texlive-fonts-recommended \ + texlive-fonts-extra \ + texlive-xetex \ + latexmk \ + xindy \ + dvipng \ + cm-super - name: Display Conda Environment Versions shell: bash -l {0} run: conda list @@ -46,15 +46,15 @@ jobs: name: build-cache path: _build # Build Assets (Download Notebooks and PDF via LaTeX) - # - name: Build PDF from LaTeX - # shell: bash -l {0} - # run: | - # jb build lectures --builder pdflatex --path-output ./ -n --keep-going - # - name: Copy LaTeX PDF for GH-PAGES - # shell: bash -l {0} - # run: | - # mkdir -p _build/html/_pdf - # cp -u _build/latex/*.pdf _build/html/_pdf + - name: Build PDF from LaTeX + shell: bash -l {0} + run: | + jb build lectures --builder pdflatex --path-output ./ -n --keep-going + - name: Copy LaTeX PDF for GH-PAGES + shell: bash -l {0} + run: | + mkdir -p _build/html/_pdf + cp -u _build/latex/*.pdf _build/html/_pdf - name: Build Download Notebooks (sphinx-tojupyter) shell: bash -l {0} run: | diff --git a/lectures/_config.yml b/lectures/_config.yml index 254479fb..ac3efae1 100644 --- a/lectures/_config.yml +++ b/lectures/_config.yml @@ -60,6 +60,11 @@ sphinx: binderhub_url : https://mybinder.org # The URL of the BinderHub (e.g., https://mybinder.org) colab_url : https://colab.research.google.com thebe : false # Add a thebe button to pages (requires the repository to run on Binder) + mathjax3_config: + tex: + macros: + "argmax" : "arg\\,max" + "argmin" : "arg\\,min" mathjax_path: https://cdn.jsdelivr.net/npm/mathjax@3/es5/tex-mml-chtml.js rediraffe_redirects: index_toc.md: intro.md diff --git a/lectures/cagan_adaptive.md b/lectures/cagan_adaptive.md index 05e68c78..512ff90e 100644 --- a/lectures/cagan_adaptive.md +++ b/lectures/cagan_adaptive.md @@ -11,10 +11,6 @@ kernelspec: name: python3 --- -+++ {"user_expressions": []} - - - # A Fiscal Theory of Price Level with Adaptive Expectations ## Introduction @@ -27,29 +23,23 @@ from collections import namedtuple import matplotlib.pyplot as plt ``` -+++ {"user_expressions": []} - - - This lecture is a sequel or prequel to this lecture {doc}`fiscal theory of the price level `. We'll use linear algebra to do some experiments with an alternative "fiscal theory of the price level". Like the model in this lecture {doc}`fiscal theory of the price level `, the model asserts that when a government persistently spends more than it collects in taxes and prints money to finance the shortfall, it puts upward pressure on the price level and generates persistent inflation. +Instead of the "perfect foresight" or "rational expectations" version of the model in this lecture {doc}`fiscal theory of the price level `, our model in the present lecture is an "adaptive expectations" version of a model that Philip Cagan {cite}`Cagan` used to study the monetary dynamics of hyperinflations. +It combines these components: -Instead of the "perfect foresight" or "rational expectations" version of the model in this lecture {doc}`fiscal theory of the price level `, our model in the present lecture is an "adaptive expectations" version of a model that Philip Cagan {cite}`Cagan` used to study the monetary dynamics of hyperinflations. +* a demand function for real money balances that asserts that the logarithm of the quantity of real balances demanded depends inversely on the public's expected rate of inflation -It combines these components: +* an **adaptive expectations** model that describes how the public's anticipated rate of inflation responds to past values of actual inflation - * a demand function for real money balances that asserts that the logarithm of the quantity of real balances demanded depends inversely on the public's expected rate of inflation - - * an **adaptive expectations** model that describes how the public's anticipated rate of inflation responds to past values of actual inflation - - * an equilibrium condition that equates the demand for money to the supply - - * an exogenous sequence of rates of growth of the money supply +* an equilibrium condition that equates the demand for money to the supply + +* an exogenous sequence of rates of growth of the money supply Our model stays quite close to Cagan's original specification. @@ -62,13 +52,13 @@ the model. Let - * $ m_t $ be the log of the supply of nominal money balances; - * $\mu_t = m_{t+1} - m_t $ be the net rate of growth of nominal balances; - * $p_t $ be the log of the price level; - * $\pi_t = p_{t+1} - p_t $ be the net rate of inflation between $t$ and $ t+1$; - * $\pi_t^*$ be the public's expected rate of inflation between $t$ and $t+1$; - * $T$ the horizon -- i.e., the last period for which the model will determine $p_t$ - * $\pi_0^*$ public's initial expected rate of inflation between time $0$ and time $1$. +* $ m_t $ be the log of the supply of nominal money balances; +* $\mu_t = m_{t+1} - m_t $ be the net rate of growth of nominal balances; +* $p_t $ be the log of the price level; +* $\pi_t = p_{t+1} - p_t $ be the net rate of inflation between $t$ and $ t+1$; +* $\pi_t^*$ be the public's expected rate of inflation between $t$ and $t+1$; +* $T$ the horizon -- i.e., the last period for which the model will determine $p_t$ +* $\pi_0^*$ public's initial expected rate of inflation between time $0$ and time $1$. The demand for real balances $\exp\left(\frac{m_t^d}{p_t}\right)$ is governed by the following version of the Cagan demand function @@ -91,8 +81,6 @@ $$ (eq:eqfiscth1) Taking the difference between equation {eq}`eq:eqfiscth1` at time $t+1$ and at time $t$ gives - - $$ \pi_t = \mu_t + \alpha \pi_{t+1}^* - \alpha \pi_t^* $$ (eq:eqpipi) @@ -112,15 +100,10 @@ As endogenous outputs of our model we want to find sequences $\pi = \{\pi_t\}_{t We'll do some mental experiments by studying how the model outputs vary as we vary the model inputs. - - - ## Representing key equations with linear algebra We begin by writing the equation {eq}`eq:adaptexpn` adaptive expectations model for $\pi_t^*$ for $t=0, \ldots, T$ as - - $$ \begin{bmatrix} 1 & 0 & 0 & \cdots & 0 & 0 \cr -\lambda & 1 & 0 & \cdots & 0 & 0 \cr @@ -153,12 +136,11 @@ $$ (eq:eq1) where the $(T+2) \times (T+2) $matrix $A$, the $(T+2)\times (T+1)$ matrix $B$, and the vectors $\pi^* , \pi_0, \pi_0^*$ are defined implicitly by aligning these two equations. - - Next we write the key equation {eq}`eq:eqpipi` in matrix notation as -$$ \begin{bmatrix} +$$ +\begin{bmatrix} \pi_0 \cr \pi_1 \cr \pi_1 \cr \vdots \cr \pi_T \end{bmatrix} = \begin{bmatrix} \mu_0 \cr \mu_1 \cr \mu_2 \cr \vdots \cr \mu_T \end{bmatrix} @@ -185,21 +167,18 @@ $$ (eq:eq2) where the $(T+1) \times (T+2)$ matrix $C$ is defined implicitly to align this equation with the preceding equation system. - - ## Harvesting returns from our matrix formulation - We now have all of the ingredients we need to solve for $\pi$ as a function of $\mu, \pi_0, \pi_0^*$. Combine equations {eq}`eq:eq1`and {eq}`eq:eq2` to get $$ -\begin{align*} +\begin{aligned} A \pi^* & = (1-\lambda) B \pi + \pi_0^* \cr & = (1-\lambda) B \left[ \mu + C \pi^* \right] + \pi_0^* -\end{align*} +\end{aligned} $$ which implies that @@ -228,7 +207,6 @@ Knowing these, we can then quickly calculate the associated sequence $p$ of the from equation {eq}`eq:eqfiscth1`. Let's fill in the details for this step. - Since we now know $\mu$ it is easy to compute $m$. @@ -290,8 +268,6 @@ $$ which is just $\pi^*$ with the last element dropped. - - ## Forecast errors Our computations will verify that @@ -416,30 +392,25 @@ $$ (eq:suffcond) The source of this condition is the following string of deductions: $$ -\begin{align*} +\begin{aligned} \pi_{t}&=\mu_{t}+\alpha\pi_{t+1}^{*}-\alpha\pi_{t}^{*}\\\pi_{t+1}^{*}&=\lambda\pi_{t}^{*}+(1-\lambda)\pi_{t}\\\pi_{t}&=\frac{\mu_{t}}{1-\alpha(1-\lambda)}-\frac{\alpha(1-\lambda)}{1-\alpha(1-\lambda)}\pi_{t}^{*}\\\implies\pi_{t}^{*}&=\frac{1}{\alpha(1-\lambda)}\mu_{t}-\frac{1-\alpha(1-\lambda)}{\alpha(1-\lambda)}\pi_{t}\\\pi_{t+1}&=\frac{\mu_{t+1}}{1-\alpha(1-\lambda)}-\frac{\alpha(1-\lambda)}{1-\alpha(1-\lambda)}\left(\lambda\pi_{t}^{*}+(1-\lambda)\pi_{t}\right)\\&=\frac{\mu_{t+1}}{1-\alpha(1-\lambda)}-\frac{\lambda}{1-\alpha(1-\lambda)}\mu_{t}+\frac{\lambda-\alpha(1-\lambda)}{1-\alpha(1-\lambda)}\pi_{t} -\end{align*} +\end{aligned} $$ By assuring that the coefficient on $\pi_t$ is less than one in absolute value, condition {eq}`eq:suffcond` assures stability of the dynamics of $\{\pi_t\}$ described by the last line of our string of deductions. The reader is free to study outcomes in examples that violate condition {eq}`eq:suffcond`. - ```{code-cell} ipython3 print(np.abs((λ - α*(1-λ))/(1 - α*(1-λ)))) ``` -+++ {"user_expressions": []} ```{code-cell} ipython3 print(λ - α*(1-λ)) ``` -+++ {"user_expressions": []} Now we'll turn to some experiments. - - ### Experiment 1 We'll study a situation in which the rate of growth of the money supply is $\mu_0$ @@ -460,14 +431,12 @@ Notice that we studied exactly this experiment in a rational expectations vers So by comparing outcomes across the two lectures, we can learn about consequences of assuming adaptive expectations, as we do here, instead of rational expectations as we assumed in that other lecture. - ```{code-cell} ipython3 μ_seq_1 = np.append(μ0*np.ones(T1), μ_star*np.ones(T+1-T1)) # solve and plot π_seq_1, Eπ_seq_1, m_seq_1, p_seq_1 = solve_and_plot(md, μ_seq_1) ``` -+++ {"user_expressions": []} We invite the reader to compare outcomes with those under rational expectations studied in this lecture {doc}`fiscal theory of the price level `. @@ -494,4 +463,3 @@ The sluggish fall in inflation is explained by how anticipated inflation $\pi_t # solve and plot π_seq_2, Eπ_seq_2, m_seq_2, p_seq_2 = solve_and_plot(md, μ_seq_2) ``` -+++ {"user_expressions": []} \ No newline at end of file diff --git a/lectures/cagan_ree.md b/lectures/cagan_ree.md index edfc68ef..981c4064 100644 --- a/lectures/cagan_ree.md +++ b/lectures/cagan_ree.md @@ -11,8 +11,6 @@ kernelspec: name: python3 --- -+++ {"user_expressions": []} - # A Fiscal Theory of the Price Level ## Introduction @@ -25,9 +23,6 @@ from collections import namedtuple import matplotlib.pyplot as plt ``` -+++ {"user_expressions": []} - - We'll use linear algebra first to explain and then do some experiments with a "fiscal theory of the price level". A fiscal theory of the price level was described by Thomas Sargent and Neil Wallace in chapter 5 of @@ -43,9 +38,9 @@ persistent inflation. The "fiscal theory of the price level" asserts that - * to **start** a persistent inflation the government simply persistently runs a money-financed government deficit - - * to **stop** a persistent inflation the government simply stops persistently running a money-financed government deficit +* to **start** a persistent inflation the government simply persistently runs a money-financed government deficit + +* to **stop** a persistent inflation the government simply stops persistently running a money-financed government deficit Our model is a "rational expectations" (or "perfect foresight") version of a model that Philip Cagan {cite}`Cagan` used to study the monetary dynamics of hyperinflations. @@ -65,23 +60,23 @@ As in the {doc}`present values ` and {doc}`consumption smoothing 0 ; \quad t = 0, 1, \ldots, T . $$ (eq:caganmd) - This equation asserts that the demand for real balances is inversely related to the public's expected rate of inflation. - People somehow acquire **perfect foresight** by their having solved a forecasting problem. @@ -103,9 +96,9 @@ $$ \pi_t^* = \pi_t , % \forall t $$ (eq:ree) -while equating demand for money to supply lets us set $m_t^d = m_t$ for all $t \geq 0$. +while equating demand for money to supply lets us set $m_t^d = m_t$ for all $t \geq 0$. -The preceding equations then imply +The preceding equations then imply $$ m_t - p_t = -\alpha(p_{t+1} - p_t) \: , \: \alpha > 0 @@ -121,17 +114,17 @@ $$ which we rewrite as a forward-looking first-order linear difference equation in $\pi_s$ with $\mu_s$ as a "forcing variable": -\begin{equation} +$$ \pi_t = \frac{\alpha}{1+\alpha} \pi_{t+1} + \frac{1}{1+\alpha} \mu_t , \quad t= 0, 1, \ldots , T -\end{equation} +$$ where $ 0< \frac{\alpha}{1+\alpha} <1 $. Setting $\delta =\frac{\alpha}{1+\alpha}$ let's us represent the preceding equation as -\begin{equation} +$$ \pi_t = \delta \pi_{t+1} + (1-\delta) \mu_t , \quad t =0, 1, \ldots, T -\end{equation} +$$ Write this system of $T+1$ equations as the single matrix equation @@ -240,8 +233,6 @@ def create_cagan_model(m0, α, T, μ_seq): return CaganREE(m0, T, μ_seq, α, δ, π_end) ``` -+++ {"user_expressions": []} - Here we use the following parameter values: ```{code-cell} ipython3 @@ -255,8 +246,6 @@ m0 = 1 μ_star = 0 ``` -+++ {"user_expressions": []} - Now we can solve the model to compute $\pi_t$, $m_t$ and $p_t$ for $t =1, \ldots, T+1$ using the matrix equation above ```{code-cell} ipython3 @@ -280,8 +269,6 @@ def solve(model): return π_seq, m_seq, p_seq ``` -+++ {"user_expressions": []} - ### Some quantitative experiments In the experiments below, we'll use formula {eq}`eq:piterm` as our terminal condition for expected inflation. @@ -387,7 +374,7 @@ $$ p_t = m_t + \alpha \pi_t $$ (eq:pformula2) -or, by using equation {eq}`eq:fisctheory1`, +or, by using equation {eq}`eq:fisctheory1`, $$ p_t = m_t + \alpha \left[ (1-\delta) \sum_{s=t}^T \delta^{s-t} \mu_s + \delta^{T+1-t} \pi_{T+1}^* \right] @@ -402,14 +389,12 @@ equation {eq}`eq:pformula2`, the log of real balances jumps But in order for $m_t - p_t$ to jump, which variable jumps, $m_{T_1}$ or $p_{T_1}$? - ### What jumps? What jumps at $T_1$? Is it $p_{T_1}$ or $m_{T_1}$? - If we insist that the money supply $m_{T_1}$ is locked at its value $m_{T_1}^1$ inherited from the past, then formula {eq}`eq:pformula2` implies that the price level jumps downward at time $T_1$, to coincide with the downward jump in $\pi_{T_1}$ @@ -417,7 +402,7 @@ An alternative assumption about the money supply level is that as part of the "i the government resets $m_{T_1}$ according to $$ - m_{T_1}^2 - m_{T_1}^1 = \alpha (\pi^1 - \pi^2) +m_{T_1}^2 - m_{T_1}^1 = \alpha (\pi^1 - \pi^2) $$ (eq:eqnmoneyjump) By letting money jump according to equation {eq}`eq:eqnmoneyjump` the monetary authority prevents the price level from **falling** at the moment that the unanticipated stabilization arrives. @@ -436,10 +421,11 @@ We'll study both cases. #### $m_{T_{1}}$ does not jump. $$ -\begin{align*} +\begin{aligned} m_{T_{1}}&=m_{T_{1}-1}+\mu_{0}\\\pi_{T_{1}}&=\mu^{*}\\p_{T_{1}}&=m_{T_{1}}+\alpha\pi_{T_{1}} -\end{align*} +\end{aligned} $$ + Simply glue the sequences $t\leq T_1$ and $t > T_1$. #### $m_{T_{1}}$ jumps. @@ -489,7 +475,6 @@ We set this up so that the $\{\mu_t\}$ sequences that describe the sudden stabil are identical to those for experiment 1, the foreseen sudden stabilization. The following code does the calculations and plots outcomes. - ```{code-cell} ipython3 # path 1 @@ -565,8 +550,6 @@ plt.tight_layout() plt.show() ``` -+++ {"user_expressions": []} - We invite you to compare these graphs with corresponding ones for the foreseen stabilization analyzed in experiment 1 above. Note how the inflation graph in the top middle panel is now identical to the @@ -575,15 +558,14 @@ money growth graph in the top left panel, and how now the log of real balances p The bottom panels plot $m$ and $p$ under two possible ways that $m_{T_1}$ might adjust as required by the upward jump in $m - p$ at $T_1$. - * the orange line lets $m_{T_1}$ jump upward in order to make sure that the log price level $p_{T_1}$ does not fall. - - * the blue line lets $p_{T_1}$ fall while stopping the money supply from jumping. +* the orange line lets $m_{T_1}$ jump upward in order to make sure that the log price level $p_{T_1}$ does not fall. + +* the blue line lets $p_{T_1}$ fall while stopping the money supply from jumping. Here is a way to interpret what the government is doing when the orange line policy is in place. The government prints money to finance expenditure with the "velocity dividend" that it reaps from the increased demand for real balances brought about by the permanent decrease in the rate of growth of the money supply. - The next code generates a multi-panel graph that includes outcomes of both experiments 1 and 2. That allows us to assess how important it is to understand whether the sudden permanent drop in $\mu_t$ at $t=T_1$ is fully unanticipated, as in experiment 1, or completely @@ -635,10 +617,6 @@ plt.tight_layout() plt.show() ``` -+++ {"user_expressions": []} - - - #### Experiment 3 **Foreseen gradual stabilization** @@ -652,7 +630,6 @@ $$ \mu_t = \phi^t \mu_0 + (1 - \phi^t) \mu^* . $$ - Next we perform an experiment in which there is a perfectly foreseen **gradual** decrease in the rate of growth of the money supply. The following code does the calculations and plots the results. diff --git a/lectures/heavy_tails.md b/lectures/heavy_tails.md index 114b4012..3b156588 100644 --- a/lectures/heavy_tails.md +++ b/lectures/heavy_tails.md @@ -757,6 +757,7 @@ df_gdp1 = extract_wb(varlist=variable_code, s="2021", e="2021", varnames=variable_names) +df_gdp1.dropna(inplace=True) ``` ```{code-cell} ipython3 diff --git a/lectures/networks.md b/lectures/networks.md index 46c6a3a7..b041a854 100644 --- a/lectures/networks.md +++ b/lectures/networks.md @@ -528,18 +528,16 @@ convenient for numerical work, is via a matrix. The **adjacency matrix** of a weighted directed graph with nodes $\{v_1, \ldots, v_n\}$, edges $E$ and weight function $w$ is the matrix $$ -\begin{equation*} - A = (a_{ij})_{1 \leq i,j \leq n} - \quad \text{with} \quad - a_{ij} = - % - \begin{cases} - w(v_i, v_j) & \text{ if } (v_i, v_j) \in E - \\ - 0 & \text{ otherwise}. - \end{cases} - % -\end{equation*} +A = (a_{ij})_{1 \leq i,j \leq n} +\quad \text{with} \quad +a_{ij} = +% +\begin{cases} + w(v_i, v_j) & \text{ if } (v_i, v_j) \in E + \\ + 0 & \text{ otherwise}. +\end{cases} +% $$ Once the nodes in $V$ are enumerated, the weight function and @@ -679,11 +677,9 @@ The following result is useful in many applications: For distinct nodes $i, j$ in $V$ and any integer $k$, we have $$ -\begin{equation*} - a^k_{i j} > 0 - \quad \text{if and only if} \quad - \text{ $j$ is accessible from $i$}. -\end{equation*} +a^k_{i j} > 0 +\quad \text{if and only if} \quad +\text{ $j$ is accessible from $i$}. $$ ```` @@ -905,12 +901,11 @@ Let $r(A)$ denote the {ref}`spectral radius` of $A$. The **eigenvector centrality** of the graph is defined as the $n$-vector $e$ that solves -```{math} -:label: ev_central +$$ \begin{aligned} e = \frac{1}{r(A)} A e. \end{aligned} -``` +$$ (ev_central) In other words, $e$ is the dominant eigenvector of $A$ (the eigenvector of the largest eigenvalue --- see the discussion of the {ref}`Perron-Frobenius theorem` in the eigenvalue lecture. @@ -918,12 +913,11 @@ largest eigenvalue --- see the discussion of the {ref}`Perron-Frobenius theorem< To better understand {eq}`ev_central`, we write out the full expression for some element $e_i$ -```{math} -:label: eq_eicen +$$ \begin{aligned} e_i = \frac{1}{r(A)} \sum_{1 \leq j \leq n} a_{ij} e_j \end{aligned} -``` +$$ (eq_eicen) Note the recursive nature of the definition: the centrality obtained by node @@ -1027,21 +1021,19 @@ centrality for networks called Katz centrality. Fixing $\beta$ in $(0, 1/r(A))$, the **Katz centrality** of a weighted directed graph with adjacency matrix $A$ is defined as the vector $\kappa$ that solves - -```{math} -:label: katz_central - \kappa_i = \beta \sum_{1 \leq j 1} a_{ij} \kappa_j + 1 - \qquad \text{for all } i \in \{0, \ldots, n-1\}. -``` + +$$ +\kappa_i = \beta \sum_{1 \leq j 1} a_{ij} \kappa_j + 1 +\qquad \text{for all } i \in \{0, \ldots, n-1\}. +$$ (katz_central) Here $\beta$ is a parameter that we can choose. In vector form we can write -```{math} -:label: katz_central_vec - \kappa = \mathbf 1 + \beta A \kappa -``` +$$ +\kappa = \mathbf 1 + \beta A \kappa +$$ (katz_central_vec) where $\mathbf 1$ is a column vector of ones. @@ -1055,7 +1047,7 @@ because then $r(\beta A) < 1$. This means that {eq}`katz_central_vec` has the unique solution $$ - \kappa = (I - \beta A)^{-1} \mathbf{1} +\kappa = (I - \beta A)^{-1} \mathbf{1} $$ @@ -1097,10 +1089,9 @@ with high centrality.) For example, the **authority-based eigenvector centrality** of a weighted directed graph with adjacency matrix $A$ is the vector $e$ solving -```{math} -:label: eicena0 - e = \frac{1}{r(A)} A^\top e. -``` +$$ +e = \frac{1}{r(A)} A^\top e. +$$ (eicena0) The only difference from the original definition is that $A$ is replaced by its transpose. @@ -1109,10 +1100,9 @@ its transpose. Element-by-element, this is given by -```{math} -:label: eicena - e_j = \frac{1}{r(A)} \sum_{1 \leq i \leq n} a_{ij} e_i -``` +$$ +e_j = \frac{1}{r(A)} \sum_{1 \leq i \leq n} a_{ij} e_i +$$ (eicena) We see $e_j$ will be high if many nodes with high authority rankings link to $j$.