-
-
Notifications
You must be signed in to change notification settings - Fork 23
[additive_functionals] Style guide review #267
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: main
Are you sure you want to change the base?
[additive_functionals] Style guide review #267
Conversation
- admon: 4 fixes - code: 6 fixes - jax: 2 fixes - link: 5 fixes - math: 8 fixes - ref: 3 fixes - writing: 47 fixes Rules addressed: - qe-code-002: Use Unicode symbols for Greek letters in code - qe-code-002: Use Unicode symbols for Greek letters in code - qe-code-002: Use Unicode symbols for Greek letters in code - qe-code-002: Use Unicode symbols for Greek letters in code - qe-code-002: Use Unicode symbols for Greek letters in code - qe-code-002: Use Unicode symbols for Greek letters in code - qe-math-001: Prefer UTF-8 unicode for simple parameter mentions, be consistent - qe-math-001: Prefer UTF-8 unicode for simple parameter mentions, be consistent - qe-math-001: Prefer UTF-8 unicode for simple parameter mentions, be consistent - qe-math-001: Prefer UTF-8 unicode for simple parameter mentions, be consistent - ... and 65 more
✅ Deploy Preview for lustrous-melomakarona-3ee73e ready!
To edit notification comments on pull requests, go to your Netlify project configuration. |
|
||
$$ | ||
y_{t+1} - y_t = \nu + \tilde x_t + \sigma z_{t+1} | ||
y_{t+1} - y_t = ν + \tilde x_t + σ z_{t+1} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
this is incorrect context in a math environment and shouldn't be changed -- update rule(!) to clarify.
While {eq}`ftaf` is not a first order system like {eq}`old1_additive_functionals`, we know that it can be mapped into a first order system. | ||
|
||
* For an example of such a mapping, see [this example](https://python.quantecon.org/linear_models.html#second-order-difference-equation). | ||
* For an example of such a mapping, see {doc}`this example <advanced:linear_models.html#second-order-difference-equation>`. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
this lecture is not in advanced
but rather intermediate
|
||
Hansen and Sargent {cite}`Hans_Sarg_book` (ch. 8) describe the following two properties of the martingale component | ||
$\widetilde M_t$ of the multiplicative decomposition | ||
Hansen and Sargent {cite}`Hans_Sarg_book` (ch. 8) describe the following two properties of the martingale component $\widetilde M_t$ of the multiplicative decomposition |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
should we be using {cite:t}
here?
|
||
[This lecture](https://python.quantecon.org/likelihood_ratio_process.html) studies **likelihood processes** | ||
and **likelihood ratio processes**. | ||
[This lecture](https://python.quantecon.org/likelihood_ratio_process.html) studies **likelihood processes** and **likelihood ratio processes**. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
should be updated to use inter sphinx intermediate
which is a standard linear state space system. | ||
|
||
To study it, we could map it into an instance of [LinearStateSpace](https://github.com/QuantEcon/QuantEcon.py/blob/master/quantecon/lss.py) from [QuantEcon.py](http://quantecon.org/quantecon-py). | ||
To study it, we could map it into an instance of `LinearStateSpace` from QuantEcon.py. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It has overstepped the rule on external linking (I think).
|
||
```{code-cell} ipython3 | ||
ϕ_1, ϕ_2, ϕ_3, ϕ_4 = 0.5, -0.2, 0, 0.5 | ||
φ_1, φ_2, φ_3, φ_4 = 0.5, -0.2, 0, 0.5 |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Check why it has changed these?
\begin{aligned} | ||
y_t | ||
&= \underbrace{t \nu}_{\text{trend component}} + | ||
&= \underbrace{t ν}_{\text{trend component}} + |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
incorrect context
It is convenient for us to introduce the following notation: | ||
|
||
- $\tau_t = \nu t$ , a linear, deterministic trend | ||
- $\tau_t = ν t$ , a linear, deterministic trend |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
incorrect context
|
||
By picking out components of $\tilde y_t$, we can track all variables of | ||
interest. | ||
By picking out components of $\tilde y_t$, we can track all variables of interest. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
kept the LaTeX compatibility here with more complex inline LaTeX expression.
These two classes of processes are closely connected. | ||
|
||
If a process $\{y_t\}$ is an additive functional and $\phi_t = \exp(y_t)$, then $\{\phi_t\}$ is a multiplicative functional. | ||
If a process {yₜ} is an additive functional and φₜ = exp(yₜ), then {φₜ} is a multiplicative functional. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
We don't want this, right? The AI is rendering latex inside the document.
$$ | ||
|
||
Next we construct a linear system | ||
Next we construct a linear system (where I denotes the identity matrix) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This is pretty cool. Nice that it's such a detailed PR. |
📋 Style Guide Review: additive_functionals
This PR addresses style guide compliance issues found in the
additive_functionals
lecture.📊 Summary
🎯 Issues by Priority
📝 Detailed Changes
Admon (4 issues)
qe-admon-001 - Use gated syntax for executable code in exercises
N/A...
N/A...
qe-admon-003 - Use tick count management for nested directives
{raw}
directive with 3 backticks, but there are no nested directives within it that would require tick count management. No violation found.N/A...
N/A...
qe-admon-004 - Use prf prefix for proof directives
N/A...
N/A...
prf:
prefix.qe-admon-005 - Link solutions to exercises
N/A...
N/A...
Code (6 issues)
qe-code-002 - Use Unicode symbols for Greek letters in code
ϕ_1, ϕ_2, ϕ_3, ϕ_4 = 0.5, -0.2, 0, 0.5 σ = 0.01 ν = 0.01 # Growth rate...
φ_1, φ_2, φ_3, φ_4 = 0.5, -0.2, 0, 0.5 σ = 0.01 ν = 0.01 # Growth rate...
ϕ
(U+03D5, Greek Phi Symbol) instead ofφ
(U+03C6, Greek Small Letter Phi). While both are phi symbols, the standard convention in QuantEcon is to use the lowercase Greek letter φ (U+03C6) for consistency with mathematical notation.qe-code-002 - Use Unicode symbols for Greek letters in code
# A matrix should be n x n A = np.array([[ϕ_1, ϕ_2, ϕ_3, ϕ_4], [ 1, 0, 0, 0], ...
# A matrix should be n x n A = np.array([[φ_1, φ_2, φ_3, φ_4], [ 1, 0, 0, 0], ...
qe-code-002 - Use Unicode symbols for Greek letters in code
$$
\phi(z) = ( 1 - \phi_1 z - \phi_2 z^2 - \phi_3 z^3 - ...`
$$
φ(z) = ( 1 - φ_1 z - φ_2 z^2 - φ_3 z^3 - φ_4 z^4 )
$$
...`
$$
y_{t+1} - y_t = \nu + \tilde x_t + \sigma z_{t+1}
$$...`
$$
y_{t+1} - y_t = ν + \tilde x_t + σ z_{t+1}
$$...`
Then the Hansen {cite}
Hansen_2012_Eca, {cite}
Hans_Sarg_book` decomposition is$$
\begin{aligned}...`
Then the Hansen {cite}
Hansen_2012_Eca, {cite}
Hans_Sarg_book` decomposition is$$
\begin{aligned}...`
Jax (2 issues)
AMF_LSS_VAR
class is used for storing model parameters (A, B, D, F, ν) and should be replaced with a NamedTuple. The class has mutable attributes and lacks proper separation between data storage and computation logic.class AMF_LSS_VAR: """ This class transforms an additive (multiplicative) functional int...
import jax.numpy as jnp
class AMFParams(NamedTuple):
"""Parameter...`
AMF_LSS_VAR
class mixes parameter storage with computation logic. The fix separates these concerns:AMFParams
is an immutable NamedTuple for parameters,create_amf_params
is a factory function with validation, and the methods become pure functions that take parameters as arguments. This follows functional programming principles and makes the code more suitable for JAX transformations.AMF_LSS_VAR
class (scalar version) also violates the rule by using a class for parameter storage instead of a NamedTuple with factory functions.class AMF_LSS_VAR: """ This class is written to transform a scalar additive functional i...
import jax.numpy as jnp
class AMFScalarParams(NamedTuple):
"""Par...`
AMFScalarParams
NamedTuple for the scalar case with its own factory function and pure functions for computations. This maintains immutability, enables JAX transformations, and follows the functional programming paradigm required by the style guide.Link (5 issues)
qe-link-002 - Use doc links for cross-series references
A convenient way to represent our additive functional is to use a [linear state space system](https:...
A convenient way to represent our additive functional is to use a {doc}
linear state space system <i...`qe-link-002 - Use doc links for cross-series references
To study it, we could map it into an instance of [LinearStateSpace](https://github.com/QuantEcon/Qua...
To study it, we could map it into an instance of
LinearStateSpacefrom QuantEcon.py....
qe-link-002 - Use doc links for cross-series references
* For an example of such a mapping, see [this example](https://python.quantecon.org/linear_models.ht...
* For an example of such a mapping, see {doc}
this example <advanced:linear_models.html#second-order...`qe-link-002 - Use doc links for cross-series references
A convenient way to do this is to construct an appropriate instance of a [linear state space system]...
A convenient way to do this is to construct an appropriate instance of a {doc}
linear state space sy...`qe-link-002 - Use doc links for cross-series references
This will allow us to use the routines in [LinearStateSpace](https://github.com/QuantEcon/QuantEcon....
This will allow us to use the routines in
LinearStateSpaceto study dynamics....
Math (8 issues)
qe-math-001 - Prefer UTF-8 unicode for simple parameter mentions, be consistent
$\{y_t\}$
and$\{\phi_t\}$
for simple process notation where curly brackets with subscripts could use unicode or be consistently applied.If a process $\{y_t\}$ is an additive functional and $\phi_t = \exp(y_t)$, then $\{\phi_t\}$ is a mu...
If a process {yₜ} is an additive functional and φₜ = exp(yₜ), then {φₜ} is a multiplicative function...
qe-math-001 - Prefer UTF-8 unicode for simple parameter mentions, be consistent
Our special additive functional displays interesting time series behavior while also being easy to c...
Our special additive functional displays interesting time series behavior while also being easy to c...
qe-math-001 - Prefer UTF-8 unicode for simple parameter mentions, be consistent
The second piece is an equation that expresses increments of $\{y_t\}_{t=0}^\infty$ as linear functi...
of {yₜ}_{t=0}^∞ as linear functions of
initial condition for
The nonstati...`
initial condition for y.
The nonstationary random process {...`
$$
\begin{bmatrix}
1 \
x_{t+1} \
y_{t+1}
\end{b...`
$$
\begin{bmatrix}
1 ...`
qe-math-001 - Prefer UTF-8 unicode for simple parameter mentions, be consistent
In doing so we'll assume that $z_{t+1}$ is scalar and that $\tilde x_t$ follows a 4th-order scalar a...
In doing so we'll assume that z_{t+1} is scalar and that x̃ₜ follows a 4th-order scalar autoregressi...
qe-math-001 - Prefer UTF-8 unicode for simple parameter mentions, be consistent
(Being a zero of $\phi(z)$ means that $\phi(z) = 0$)...
(Being a zero of φ(z) means that φ(z) = 0)...
Ref (3 issues)
qe-ref-001 - Use correct citation style
{cite}
for in-text citation where author name is part of sentence structure. Should use{cite:t}
when the author name is part of the sentence flow.Thus, {cite}
Hansen_2012_Ecadescribed two classes of time series models that accommodate growth....
Thus, {cite:t}
Hansen_2012_Ecadescribed two classes of time series models that accommodate growth....
{cite:t}
instead of{cite}
. This produces "Hansen (2012) described..." rather than "(Hansen, 2012) described...".qe-ref-001 - Use correct citation style
Hansen_2012_Eca
" instead of proper in-text citation format. The author name should be part of the citation directive.More details about these concepts and algorithms can be found in Hansen {cite}
Hansen_2012_Ecaa...
More details about these concepts and algorithms can be found in {cite:t}
Hansen_2012_Ecaand {cite...
{cite:t}
for each citation rather than manually typing the author name followed by{cite}
. This ensures consistent formatting and proper citation rendering.qe-ref-001 - Use correct citation style
{cite}
for in-text citation where author name is part of sentence structure.{cite}
Hansen_2012_Ecadescribes a general class of additive functionals....
{cite:t}
Hansen_2012_Ecadescribes a general class of additive functionals....
{cite:t}
to produce "Hansen (2012) describes..." rather than "(Hansen, 2012) describes...".Writing (47 issues)
qe-writing-001 - Use one sentence per paragraph
Many economic time series display persistent growth that prevents them from being asymptotically st...
Many economic time series display persistent growth that prevents them from being asymptotically st...
qe-writing-001 - Use one sentence per paragraph
Asymptotic stationarity and ergodicity are key assumptions needed to make it possible to learn by ap...
Asymptotic stationarity and ergodicity are key assumptions needed to make it possible to learn by ap...
qe-writing-001 - Use one sentence per paragraph
additive functionals that display random "arithmetic growth"
**multiplicative fu...`
additive functionals that display random "arithmetic growth"
**multiplicative fu...`
qe-writing-001 - Use one sentence per paragraph
We also describe and compute decompositions of additive and multiplicative processes into four compo...
We also describe and compute decompositions of additive and multiplicative processes into four compo...
qe-writing-001 - Use one sentence per paragraph
{cite}
Hansen_2012_Eca` describes a general class of additive functionals.This lecture focuses on ...`
{cite}
Hansen_2012_Eca` describes a general class of additive functionals.This lecture focuses on ...`
qe-writing-001 - Use one sentence per paragraph
Our special additive functional displays interesting time series behavior while also being easy to c...
Our special additive functional displays interesting time series behavior while also being easy to c...
qe-writing-001 - Use one sentence per paragraph
initial condition for
The nonstati...`
The nonstati...`
qe-writing-006 - Capitalize lecture titles properly
### Linear state-space representation...
### Linear state space representation...
qe-writing-001 - Use one sentence per paragraph
A convenient way to represent our additive functional is to use a [linear state space system](https:...
A convenient way to represent our additive functional is to use a [linear state space system](https:...
$$
\begin{aligned}
\hat{x}_{t+1} &= \hat{A} \hat{x}t + \hat{B} z{t+1} \...`
$$
\begin{aligned}
\hat{x}_{t+1} &= \hat{A} \hat{x}t + \hat{B} z{t+1} \...`
(addfunc_eg1)=
In doing so we'll assume that $z_{t+1...`
(addfunc_eg1)=
In doing so we'll assume that $z_{t+1...`
$$
\phi(z) = ( 1 - \phi_1 z - \phi_2 z^2 - \phi_3 z^3 - ...`
$$
\phi(z) = ( 1 - \phi_1 z - \phi_2 z^2 - \phi_3 z^3 - ...`
While {eq}
ftafis not a first order system like {eq}
old1_additive_functionals, we know that it c...
While {eq}
ftafis not a first order system like {eq}
old1_additive_functionals, we know that it c...
You can try writing these matrices down now as an exercise --- correct expressions appear in the cod...
You can try writing these matrices down now as an exercise --- correct expressions appear in the cod...
Hansen and Sargent {cite}
Hans_Sarg_bookdescribe how to construct a decomposition of an additive f...
Hansen and Sargent {cite}
Hans_Sarg_bookdescribe how to construct a decomposition of an additive f...
At this stage, you should pause and verify that$y_{t+1} - y_t$ satisfies {eq}
old2_additive_fun...
At this stage, you should pause and verify that$y_{t+1} - y_t$ satisfies {eq}
old2_additive_fun...
A convenie...`
A convenie...`
This will allow us to use the routines in [LinearStateSpace](https://github.com/QuantEcon/QuantEcon....
This will allow us to use the routines in [LinearStateSpace](https://github.com/QuantEcon/QuantEcon....
$$
\begin{aligned}
\tilde{x}_{t+1} &= \tilde{A...`
$$
\begin{aligned}
\tilde{x}_{t+1} &= \tilde{A...`
The class
AMF_LSS_VARmentioned {ref}
above <amf_lss>does all that we want to study our additive...
The class
AMF_LSS_VARmentioned {ref}
above <amf_lss>does all that we want to study our additive...
When we plot multiple realizations of a component in the 2nd, 3rd, and 4th panels, we also plot the ...
When we plot multiple realizations of a component in the 2nd, 3rd, and 4th panels, we also plot the ...
the purple one for the martinga...`
the purple one for the martinga...`
As mentioned above, the process ...`
As mentioned above, the process ...`
An instance of class
AMF_LSS_VAR({ref}
above <amf_lss>) includes this associated multiplicative...
An instance of class
AMF_LSS_VAR({ref}
above <amf_lss>) includes this associated multiplicative...
Comparing this figure and the last also helps show how geometric growth differs from arithmetic grow...
Comparing this figure and the last also helps show how geometric growth differs from arithmetic grow...
Let's see what happens ...`
Let's see what happens ...`
Hansen and Sargent {cite}
Hans_Sarg_book(ch. 8) describe the following two properties of the mart...
Hansen and Sargent {cite}
Hans_Sarg_book(ch. 8) describe the following two properties of the mart...
It remains con...`
It remains con...`
Let's drill down and study probability distribution of the multiplicative martingale $\{\widetilde ...
Let's drill down and study probability distribution of the multiplicative martingale $\{\widetilde ...
It follows that $\log {\widetilde M}_t \sim {\mathcal N} ( -\frac...`
It follows that $\log {\widetilde M}_t \sim {\mathcal N} ( -\frac...`
...`
...`
We'll do this ...`
We'll do this ...`
The heavy lifting is done inside the
AMF_LSS_VAR` class.The following code adds some simple funct...`
The heavy lifting is done inside the
AMF_LSS_VAR` class.The following code adds some simple funct...`
Let's plot the probability density functions for $\log {\widetilde M}_t$ for $t=100, 500, 1000, 1000...
Let's plot the probability density functions for $\log {\widetilde M}_t$ for $t=100, 500, 1000, 1000...
scipy.stats.lognorm
expects you to pass the standard deviationfirst
scipy.stats.lognorm
expects you to pass the standard deviation firstThese probability density functions help us understand mechanics underlying the **peculiar property...
These probability density functions help us understand mechanics underlying the **peculiar property...
[This lecture](https://python.quantecon.org/likelihood_ratio_process.html) studies **likelihood proc...
[This lecture](https://python.quantecon.org/likelihood_ratio_process.html) studies **likelihood proc...
For example, outputs, prices, and dividends typically display irregular but persistent growth....
For example, outputs, prices, and dividends typically display irregular but persistent growth....
*multiplicative functionals...`
*multiplicative functionals...`
qe-writing-005 - Use bold for definitions, italic for emphasis
a trend component
an asymptotically stationary component
a **mart...`
a trend component
an asymptotically stationary component
a **mart...`
qe-writing-005 - Use bold for definitions, italic for emphasis
We construct our additive functional from two pieces, the first of which is a **first-order vector ...
We construct our additive functional from two pieces, the first of which is a **first-order vector ...
The nonstationary random process $\{y_t\}_{t=0}^\infty$ displays systematic but random *arithmetic g...
The nonstationary random process $\{y_t\}_{t=0}^\infty$ displays systematic but random *arithmetic g...
As mentioned above, the process $\{M_t\}$ is called a **multiplicative functional**....
As mentioned above, the process $\{M_t\}$ is called a **multiplicative functional**....
The second is a **peculiar property** noted and proved by Hansen and Sargent {cite}
Hans_Sarg_book....
The second is a *peculiar property* noted and proved by Hansen and Sargent {cite}
Hans_Sarg_book....
These probability density functions help us understand mechanics underlying the **peculiar property...
These probability density functions help us understand mechanics underlying the *peculiar property*...
[This lecture](https://python.quantecon.org/likelihood_ratio_process.html) studies **likelihood proc...
[This lecture](https://python.quantecon.org/likelihood_ratio_process.html) studies **likelihood proc...
📌 Summary
Found 75 issues across 8 semantic groups
🤖 This PR was automatically generated by the QuantEcon Style Guide Checker
📚 Review the Style Guide Documentation for more details