Skip to content

Commit bb9ce42

Browse files
authored
Merge pull request #1437 from stan-dev/updated-jac-warning
Update pedantic mode warning for jacobian usage
2 parents b9877df + 140d686 commit bb9ce42

File tree

2 files changed

+23
-11
lines changed

2 files changed

+23
-11
lines changed

src/analysis_and_optimization/Pedantic_analysis.ml

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -391,7 +391,9 @@ let maybe_jacobian_adjustment_warnings (mir : Program.Typed.t) =
391391
, "Left-hand side of distribution statement (~) may contain a non-linear \
392392
transform of a parameter or local variable. If it does, you need to \
393393
include a target += statement with the log absolute determinant of \
394-
the Jacobian of the transform." ))
394+
the Jacobian of the transform. You could also consider defining a \
395+
transformed parameter and using jacobian += in the transformed \
396+
parameters block." ))
395397
locations
396398

397399
let multi_tildes_message (vname : string) : string =

test/integration/cli-args/warn-pedantic/stanc.expected

Lines changed: 20 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -466,61 +466,71 @@ Warning in 'jacobian_warning1.stan', line 7, column 2: Left-hand side of
466466
distribution statement (~) may contain a non-linear transform of a
467467
parameter or local variable. If it does, you need to include a target +=
468468
statement with the log absolute determinant of the Jacobian of the
469-
transform.
469+
transform. You could also consider defining a transformed parameter and
470+
using jacobian += in the transformed parameters block.
470471
Warning in 'jacobian_warning1.stan', line 5, column 2: Left-hand side of
471472
distribution statement (~) may contain a non-linear transform of a
472473
parameter or local variable. If it does, you need to include a target +=
473474
statement with the log absolute determinant of the Jacobian of the
474-
transform.
475+
transform. You could also consider defining a transformed parameter and
476+
using jacobian += in the transformed parameters block.
475477
Warning: The parameter y has 2 priors.
476478
$ ../../../../../install/default/bin/stanc --warn-pedantic jacobian_warning2.stan
477479
Warning in 'jacobian_warning2.stan', line 5, column 2: Left-hand side of
478480
distribution statement (~) may contain a non-linear transform of a
479481
parameter or local variable. If it does, you need to include a target +=
480482
statement with the log absolute determinant of the Jacobian of the
481-
transform.
483+
transform. You could also consider defining a transformed parameter and
484+
using jacobian += in the transformed parameters block.
482485
$ ../../../../../install/default/bin/stanc --warn-pedantic jacobian_warning3.stan
483486
Warning in 'jacobian_warning3.stan', line 5, column 2: Left-hand side of
484487
distribution statement (~) may contain a non-linear transform of a
485488
parameter or local variable. If it does, you need to include a target +=
486489
statement with the log absolute determinant of the Jacobian of the
487-
transform.
490+
transform. You could also consider defining a transformed parameter and
491+
using jacobian += in the transformed parameters block.
488492
$ ../../../../../install/default/bin/stanc --warn-pedantic jacobian_warning4.stan
489493
Warning in 'jacobian_warning4.stan', line 5, column 2: Left-hand side of
490494
distribution statement (~) may contain a non-linear transform of a
491495
parameter or local variable. If it does, you need to include a target +=
492496
statement with the log absolute determinant of the Jacobian of the
493-
transform.
497+
transform. You could also consider defining a transformed parameter and
498+
using jacobian += in the transformed parameters block.
494499
$ ../../../../../install/default/bin/stanc --warn-pedantic jacobian_warning5.stan
495500
Warning in 'jacobian_warning5.stan', line 5, column 2: Left-hand side of
496501
distribution statement (~) may contain a non-linear transform of a
497502
parameter or local variable. If it does, you need to include a target +=
498503
statement with the log absolute determinant of the Jacobian of the
499-
transform.
504+
transform. You could also consider defining a transformed parameter and
505+
using jacobian += in the transformed parameters block.
500506
$ ../../../../../install/default/bin/stanc --warn-pedantic jacobian_warning6.stan
501507
Warning in 'jacobian_warning6.stan', line 5, column 2: Left-hand side of
502508
distribution statement (~) may contain a non-linear transform of a
503509
parameter or local variable. If it does, you need to include a target +=
504510
statement with the log absolute determinant of the Jacobian of the
505-
transform.
511+
transform. You could also consider defining a transformed parameter and
512+
using jacobian += in the transformed parameters block.
506513
$ ../../../../../install/default/bin/stanc --warn-pedantic jacobian_warning7.stan
507514
Warning in 'jacobian_warning7.stan', line 6, column 2: Left-hand side of
508515
distribution statement (~) may contain a non-linear transform of a
509516
parameter or local variable. If it does, you need to include a target +=
510517
statement with the log absolute determinant of the Jacobian of the
511-
transform.
518+
transform. You could also consider defining a transformed parameter and
519+
using jacobian += in the transformed parameters block.
512520
Warning in 'jacobian_warning7.stan', line 5, column 2: Left-hand side of
513521
distribution statement (~) may contain a non-linear transform of a
514522
parameter or local variable. If it does, you need to include a target +=
515523
statement with the log absolute determinant of the Jacobian of the
516-
transform.
524+
transform. You could also consider defining a transformed parameter and
525+
using jacobian += in the transformed parameters block.
517526
Warning: The parameter y has 2 priors.
518527
$ ../../../../../install/default/bin/stanc --warn-pedantic jacobian_warning_user.stan
519528
Warning in 'jacobian_warning_user.stan', line 5, column 2: Left-hand side of
520529
distribution statement (~) may contain a non-linear transform of a
521530
parameter or local variable. If it does, you need to include a target +=
522531
statement with the log absolute determinant of the Jacobian of the
523-
transform.
532+
transform. You could also consider defining a transformed parameter and
533+
using jacobian += in the transformed parameters block.
524534
$ ../../../../../install/default/bin/stanc --warn-pedantic lp_fun.stan
525535
Warning: The parameter y has 2 priors.
526536
$ ../../../../../install/default/bin/stanc --warn-pedantic missing-prior-false-alarm.stan

0 commit comments

Comments
 (0)