Skip to content

Commit 26cb940

Browse files
committed
updated using new array syntax
1 parent 33beccb commit 26cb940

File tree

4 files changed

+20
-18
lines changed

4 files changed

+20
-18
lines changed

education/causal_iv_one-sided/case_study_02_IV_one-sided.html

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -3381,12 +3381,12 @@ <h3 data-number="4.1" class="anchored" data-anchor-id="stan-model-with-exclusion
33813381
<section id="data-block" class="level4">
33823382
<h4 class="anchored" data-anchor-id="data-block">Data block</h4>
33833383
<div class="sourceCode" id="cb3"><pre class="sourceCode stan code-with-copy"><code class="sourceCode stan"><span id="cb3-1"><a href="#cb3-1" aria-hidden="true" tabindex="-1"></a><span class="kw">data</span> {</span>
3384-
<span id="cb3-2"><a href="#cb3-2" aria-hidden="true" tabindex="-1"></a> <span class="dt">int</span>&lt;<span class="kw">lower</span>=<span class="dv">1</span>&gt; N; <span class="co">// Sample size N </span></span>
3385-
<span id="cb3-3"><a href="#cb3-3" aria-hidden="true" tabindex="-1"></a> <span class="dt">int</span>&lt;<span class="kw">lower</span>=<span class="dv">0</span>, <span class="kw">upper</span>=<span class="dv">1</span>&gt; Z[N]; <span class="co">// Treatment assigned Z</span></span>
3386-
<span id="cb3-4"><a href="#cb3-4" aria-hidden="true" tabindex="-1"></a> <span class="dt">int</span>&lt;<span class="kw">lower</span>=<span class="dv">0</span>, <span class="kw">upper</span>=<span class="dv">1</span>&gt; W[N]; <span class="co">// Treatment received W </span></span>
3387-
<span id="cb3-5"><a href="#cb3-5" aria-hidden="true" tabindex="-1"></a> <span class="dt">int</span>&lt;<span class="kw">lower</span>=<span class="dv">0</span>, <span class="kw">upper</span>=<span class="dv">1</span>&gt; Y[N]; <span class="co">// Outcome Y </span></span>
3384+
<span id="cb3-2"><a href="#cb3-2" aria-hidden="true" tabindex="-1"></a> <span class="dt">int</span>&lt;<span class="kw">lower</span>=<span class="dv">1</span>&gt; N; <span class="co">// Sample size N </span></span>
3385+
<span id="cb3-3"><a href="#cb3-3" aria-hidden="true" tabindex="-1"></a> <span class="dt">array</span>[N] <span class="dt">int</span>&lt;<span class="kw">lower</span>=<span class="dv">0</span>, <span class="kw">upper</span>=<span class="dv">1</span>&gt; Z; <span class="co">// Treatment assigned Z</span></span>
3386+
<span id="cb3-4"><a href="#cb3-4" aria-hidden="true" tabindex="-1"></a> <span class="dt">array</span>[N] <span class="dt">int</span>&lt;<span class="kw">lower</span>=<span class="dv">0</span>, <span class="kw">upper</span>=<span class="dv">1</span>&gt; W; <span class="co">// Treatment received W</span></span>
3387+
<span id="cb3-5"><a href="#cb3-5" aria-hidden="true" tabindex="-1"></a> <span class="dt">array</span>[N] <span class="dt">int</span>&lt;<span class="kw">lower</span>=<span class="dv">0</span>, <span class="kw">upper</span>=<span class="dv">1</span>&gt; Y; <span class="co">// Outcome Y</span></span>
33883388
<span id="cb3-6"><a href="#cb3-6" aria-hidden="true" tabindex="-1"></a>}</span></code><button title="Copy to Clipboard" class="code-copy-button"><i class="bi"></i></button></pre></div>
3389-
<p>For the model’s data inputs, we initially encode three observed binary variables (<span class="math inline">\(Z_{i}\)</span>, <span class="math inline">\(W_{i}^{\text{obs}}\)</span>, and <span class="math inline">\(Y_{i}^{\text{obs}}\)</span>) along with the number of units in the sample (<span class="math inline">\(N\)</span>).</p>
3389+
<p>For the model’s data inputs, we initially encode three observed binary variables (<span class="math inline">\(Z_{i}\)</span>, <span class="math inline">\(W_{i}^{\text{obs}}\)</span>, and <span class="math inline">\(Y_{i}^{\text{obs}}\)</span>) along with the number of units in the sample (<span class="math inline">\(N\)</span>). With the updated Stan syntax, we have shifted to using the <code>array</code> function for array declarations, which provides a more explicit and streamlined way to denote multidimensional structures. This modern syntax not only enhances clarity but also aligns with the direction of Stan’s evolution, ensuring compatibility with future versions.</p>
33903390
</section>
33913391
<section id="parameters-block" class="level4">
33923392
<h4 class="anchored" data-anchor-id="parameters-block">Parameters block</h4>

education/causal_iv_one-sided/case_study_02_IV_one-sided.qmd

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -192,14 +192,14 @@ The model-based estimation strategy offers several advantages over the moment-ba
192192

193193
``` stan
194194
data {
195-
int<lower=1> N; // Sample size N
196-
int<lower=0, upper=1> Z[N]; // Treatment assigned Z
197-
int<lower=0, upper=1> W[N]; // Treatment received W
198-
int<lower=0, upper=1> Y[N]; // Outcome Y
195+
int<lower=1> N; // Sample size N
196+
array[N] int<lower=0, upper=1> Z; // Treatment assigned Z
197+
array[N] int<lower=0, upper=1> W; // Treatment received W
198+
array[N] int<lower=0, upper=1> Y; // Outcome Y
199199
}
200200
```
201201

202-
For the model's data inputs, we initially encode three observed binary variables ($Z_{i}$, $W_{i}^{\text{obs}}$, and $Y_{i}^{\text{obs}}$) along with the number of units in the sample ($N$).
202+
For the model's data inputs, we initially encode three observed binary variables ($Z_{i}$, $W_{i}^{\text{obs}}$, and $Y_{i}^{\text{obs}}$) along with the number of units in the sample ($N$). With the updated Stan syntax, we have shifted to using the `array` function for array declarations, which provides a more explicit and streamlined way to denote multidimensional structures. This modern syntax not only enhances clarity but also aligns with the direction of Stan's evolution, ensuring compatibility with future versions.
203203

204204

205205
#### Parameters block

education/causal_iv_one-sided/stan/cace_with_exclusion.stan

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,8 @@
11
data {
2-
int<lower=1> N; // Sample size N
3-
int<lower=0, upper=1> Z[N]; // Treatment assigned Z
4-
int<lower=0, upper=1> W[N]; // Treatment received W
5-
int<lower=0, upper=1> Y[N]; // Outcome Y
2+
int<lower=1> N; // Sample size N
3+
array[N] int<lower=0, upper=1> Z; // Treatment assigned Z
4+
array[N] int<lower=0, upper=1> W; // Treatment received W
5+
array[N] int<lower=0, upper=1> Y; // Outcome Y
66
}
77

88
parameters {
@@ -57,3 +57,4 @@ model {
5757
}
5858
}
5959
}
60+

education/causal_iv_one-sided/stan/cace_without_exclusion.stan

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,8 @@
11
data {
2-
int<lower=1> N; // Sample size N
3-
int<lower=0, upper=1> Z[N]; // Treatment assigned Z
4-
int<lower=0, upper=1> W[N]; // Treatment received W
5-
int<lower=0, upper=1> Y[N]; // Outcome Y
2+
int<lower=1> N; // Sample size N
3+
array[N] int<lower=0, upper=1> Z; // Treatment assigned Z
4+
array[N] int<lower=0, upper=1> W; // Treatment received W
5+
array[N] int<lower=0, upper=1> Y; // Outcome Y
66
}
77

88
parameters {
@@ -59,3 +59,4 @@ model {
5959
}
6060
}
6161
}
62+

0 commit comments

Comments
 (0)