Skip to content

Commit 601e59e

Browse files
committed
Use consistent syntax in profiling vignette
closes #1136
1 parent c062d6c commit 601e59e

1 file changed

Lines changed: 13 additions & 13 deletions

File tree

vignettes/profiling.Rmd

Lines changed: 13 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -29,7 +29,7 @@ However, be aware that the statistical assumptions that go into a model are
2929
the most important factors in overall model performance. It is often not
3030
possible to make up for model problems with just brute force computation. For
3131
ideas on how to address performance of your model from a statistical
32-
perspective, see Gelman (2020).
32+
perspective, see Gelman et al. (2020).
3333

3434
```{r library, message=FALSE}
3535
library(cmdstanr)
@@ -66,11 +66,11 @@ calculations with `profile` statements.
6666

6767
```
6868
profile("priors") {
69-
target += std_normal_lpdf(beta);
70-
target += std_normal_lpdf(alpha);
69+
beta ~ std_normal();
70+
alpha ~ std_normal();
7171
}
7272
profile("likelihood") {
73-
target += bernoulli_logit_lpmf(y | X * beta + alpha);
73+
y ~ bernoulli_logit(X * beta + alpha);
7474
}
7575
```
7676

@@ -92,11 +92,11 @@ parameters {
9292
}
9393
model {
9494
profile("priors") {
95-
target += std_normal_lpdf(beta);
96-
target += std_normal_lpdf(alpha);
95+
beta ~ std_normal();
96+
alpha ~ std_normal();
9797
}
9898
profile("likelihood") {
99-
target += bernoulli_logit_lpmf(y | X * beta + alpha);
99+
y ~ bernoulli_logit(X * beta + alpha);
100100
}
101101
}
102102
')
@@ -145,7 +145,7 @@ Stan's specialized glm functions can be used to make models like this faster. In
145145
this case the likelihood can be replaced with
146146

147147
```
148-
target += bernoulli_logit_glm_lpmf(y | X, alpha, beta);
148+
y ~ bernoulli_logit_glm(X, alpha, beta);
149149
```
150150

151151
We'll keep the same `profile()` statements so that the profiling information for
@@ -165,11 +165,11 @@ parameters {
165165
}
166166
model {
167167
profile("priors") {
168-
target += std_normal_lpdf(beta);
169-
target += std_normal_lpdf(alpha);
168+
beta ~ std_normal();
169+
alpha ~ std_normal();
170170
}
171171
profile("likelihood") {
172-
target += bernoulli_logit_glm_lpmf(y | X, alpha, beta);
172+
y ~ bernoulli_logit_glm(X, alpha, beta);
173173
}
174174
}
175175
')
@@ -184,8 +184,8 @@ fit_glm <- model_glm$sample(data = stan_data, chains = 1)
184184
fit_glm$profiles()
185185
```
186186

187-
We can see from the `total_time` column that this is much faster than the
188-
previous model.
187+
We can see from the `total_time` column that the likelihood computation is
188+
faster than in the previous model.
189189

190190
## Per-gradient timings, and memory usage
191191

0 commit comments

Comments
 (0)