@@ -29,7 +29,7 @@ However, be aware that the statistical assumptions that go into a model are
2929the most important factors in overall model performance. It is often not
3030possible to make up for model problems with just brute force computation. For
3131ideas 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}
3535library(cmdstanr)
@@ -66,11 +66,11 @@ calculations with `profile` statements.
6666
6767```
6868profile("priors") {
69- target += std_normal_lpdf(beta );
70- target += std_normal_lpdf(alpha );
69+ beta ~ std_normal( );
70+ alpha ~ std_normal( );
7171}
7272profile("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}
9393model {
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
145145this 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
151151We'll keep the same ` profile() ` statements so that the profiling information for
@@ -165,11 +165,11 @@ parameters {
165165}
166166model {
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)
184184fit_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