diff --git a/src/functions-reference/deprecated_functions.Rmd b/src/functions-reference/deprecated_functions.Rmd index 4351c1298..a2fe1c403 100644 --- a/src/functions-reference/deprecated_functions.Rmd +++ b/src/functions-reference/deprecated_functions.Rmd @@ -8,39 +8,8 @@ the renaming of `get_lp` or `multiply_log`) will be removed 3 versions later e.g., functions deprecated in Stan 2.20 will be removed in Stan 2.23 and placed in [Removed Functions]. The Stan compiler can [automatically update](https://mc-stan.org/docs/stan-users-guide/stanc-pretty-printing.html) -these on the behalf of the user. - - - -## `multiply_log` and `binomial_coefficient_log` functions - -*Deprecated*: Currently two non-conforming functions ending in suffix - `_log`. - -*Replacement*: Replace `multiply_log(...)` with `lmultiply(...)`. - Replace `binomial_coefficient_log(...)` with `lchoose(...)`. - -*Scheduled Removal*: Stan 2.32 - - -## `get_lp()` function - -*Deprecated*: The built-in no-argument function `get_lp()` is deprecated. - -*Replacement*: Use the no-argument function `target()` instead. - -*Scheduled Removal*: Stan 2.33 - - -## `fabs` function - -*Deprecated*: The unary function `fabs` is deprecated. - -*Replacement*: Use the unary function `abs` instead. Note that the return type -for `abs` is different for integer overloads, but this replacement is safe due -to Stan's type promotion rules. - -*Scheduled Removal*: Stan 2.33 +these on the behalf of the user for the entire deprecation window and at least +one version following the removal. ## Integer division with `operator/` @@ -345,65 +314,3 @@ the same size. The parameters, real data, and integer data will be passed from the solver directly to the system function. - - -## Exponentiated quadratic covariance functions {#cov_exp_quad} - -These covariance functions have been replaced by those described in: - -```{r results='asis', echo=FALSE} -if (knitr::is_html_output()) { - cat(' * Gaussian Process Covariance Functions\n') -} -``` - -With magnitude $\alpha$ and length scale $l$, the exponentiated quadratic kernel is: - -$$ -k(x_i, x_j) = \alpha^2 \exp \left(-\dfrac{1}{2\rho^2} \sum_{d=1}^D (x_{i,d} - x_{j,d})^2 \right) -$$ - - -\index{{\tt \bfseries cov\_exp\_quad }!{\tt (row\_vectors x, real alpha, real rho): matrix}|hyperpage} - -`matrix` **`cov_exp_quad`**`(row_vectors x, real alpha, real rho)`
\newline -The covariance matrix with an exponentiated quadratic kernel of x. -`r since("2.16, deprecated since 2.20, scheduled for removal in 2.33")` - - -\index{{\tt \bfseries cov\_exp\_quad }!{\tt (vectors x, real alpha, real rho): matrix}|hyperpage} - -`matrix` **`cov_exp_quad`**`(vectors x, real alpha, real rho)`
\newline -The covariance matrix with an exponentiated quadratic kernel of x. -`r since("2.16, deprecated since 2.20, scheduled for removal in 2.33")` - - -\index{{\tt \bfseries cov\_exp\_quad }!{\tt (array[] real x, real alpha, real rho): matrix}|hyperpage} - -`matrix` **`cov_exp_quad`**`(array[] real x, real alpha, real rho)`
\newline -The covariance matrix with an exponentiated quadratic kernel of x. -`r since("2.16, deprecated since 2.20, scheduled for removal in 2.33")` - - -\index{{\tt \bfseries cov\_exp\_quad }!{\tt (row\_vectors x1, row\_vectors x2, real alpha, real rho): matrix}|hyperpage} - -`matrix` **`cov_exp_quad`**`(row_vectors x1, row_vectors x2, real alpha, real rho)`
\newline -The covariance matrix with an exponentiated quadratic kernel of x1 and -x2. -`r since("2.18, deprecated since 2.20, scheduled for removal in 2.33")` - - -\index{{\tt \bfseries cov\_exp\_quad }!{\tt (vectors x1, vectors x2, real alpha, real rho): matrix}|hyperpage} - -`matrix` **`cov_exp_quad`**`(vectors x1, vectors x2, real alpha, real rho)`
\newline -The covariance matrix with an exponentiated quadratic kernel of x1 and -x2. -`r since("2.18, deprecated since 2.20, scheduled for removal in 2.33")` - - -\index{{\tt \bfseries cov\_exp\_quad }!{\tt (array[] real x1, array[] real x2, real alpha, real rho): matrix}|hyperpage} - -`matrix` **`cov_exp_quad`**`(array[] real x1, array[] real x2, real alpha, real rho)`
\newline -The covariance matrix with an exponentiated quadratic kernel of x1 and -x2. -`r since("2.18, deprecated since 2.20, scheduled for removal in 2.33")` diff --git a/src/functions-reference/real-valued_basic_functions.Rmd b/src/functions-reference/real-valued_basic_functions.Rmd index 8c5e5ff9d..38c3a926d 100644 --- a/src/functions-reference/real-valued_basic_functions.Rmd +++ b/src/functions-reference/real-valued_basic_functions.Rmd @@ -380,14 +380,11 @@ value returned by the Stan program. Stan provides a special built-in function `target()` that takes no arguments and returns the current value of the log probability -accumulator.[^fn_lp] This function is primarily useful for debugging +accumulator. This function is primarily useful for debugging purposes, where for instance, it may be used with a print statement to display the log probability accumulator at various stages of execution to see where it becomes ill defined. -[^fn_lp]: This function used to be called `get_lp()`, but that name -has been deprecated; using it will print a warning. The function -`get_lp()` will be removed in Stan 2.33.0. \index{{\tt \bfseries target }!{\tt (): real}|hyperpage} @@ -396,17 +393,8 @@ has been deprecated; using it will print a warning. The function Return the current value of the log probability accumulator. `r since("2.10")` - -\index{{\tt \bfseries get\_lp }!{\tt (): real}|hyperpage} - -`real` **`get_lp`**`()`
\newline -Return the current value of the log probability accumulator; -**deprecated;** - use `target()` instead. -`r since("2.5, scheduled for removal in 2.33.0")` - -Both `target` and the deprecated `get_lp` act like other functions -ending in `_lp`, meaning that they may only may only be used in the -model block. +`target` acts like a function ending in `_lp`, meaning that it may only may only +be used in the model block. ## Logical functions @@ -724,13 +712,6 @@ of those types, `abs` returns the same type where each element has had its absolute value taken. `r since("2.0, vectorized in 2.30")` - -\index{{\tt \bfseries fabs }!{\tt (T x): R}|hyperpage} - -`R` **`fabs`**`(T x)`
\newline -absolute value of x -`r since("2.0, vectorized in 2.13, deprecated in 2.30")` - \index{{\tt \bfseries fdim }!{\tt (real x, real y): real}|hyperpage} @@ -1317,26 +1298,6 @@ defined for positive a and nonnegative z. \[ \mathrm{gamma\_q}(a,z) = Vectorized implementation of the `gamma_q` function `r since("2.25")` - -\index{{\tt \bfseries binomial\_coefficient\_log }!{\tt (real x, real y): real}|hyperpage} - -`real` **`binomial_coefficient_log`**`(real x, real y)`
\newline -_**Warning:**_ This function is deprecated and should be replaced with -`lchoose`. Return the natural logarithm of the binomial coefficient of -x and y. For non-negative integer inputs, the binomial coefficient -function is written as $\binom{x}{y}$ and pronounced "x choose y." -This function generalizes to real numbers using the gamma function. -For $0 \leq y \leq x$, \[ \mathrm{binomial\_coefficient\_log}(x,y) = -\log\Gamma(x+1) - \log\Gamma(y+1) - \log\Gamma(x-y+1). \] -`r since("2.0, deprecated since 2.10, scheduled for removal in 2.33")` - - -\index{{\tt \bfseries binomial\_coefficient\_log }!{\tt (T1 x, T2 y): R}|hyperpage} - -`R` **`binomial_coefficient_log`**`(T1 x, T2 y)`
\newline -Vectorized implementation of the `binomial_coefficient_log` function -`r since("2.25")` - \index{{\tt \bfseries choose }!{\tt (int x, int y): int}|hyperpage} @@ -1546,24 +1507,6 @@ Return z plus the result of x multiplied by y. \[ \text{fma}(x,y,z) = (x \times y) + z \] `r since("2.0")` - -\index{{\tt \bfseries multiply\_log }!{\tt (real x, real y): real}|hyperpage} - -`real` **`multiply_log`**`(real x, real y)`
\newline -_**Warning:**_ This function is deprecated and should be replaced with -`lmultiply`. Return the product of x and the natural logarithm of y. -\[ \mathrm{multiply\_log}(x,y) = \begin{cases} 0 & \text{if } x = y = -0 \\ x \log y & \text{if } x, y \neq 0 \\ \text{NaN} & -\text{otherwise} \end{cases} \] -`r since("2.0, deprecated since 2.10, scheduled for removal in 2.33")` - - -\index{{\tt \bfseries multiply\_log }!{\tt (T1 x, T2 y): R}|hyperpage} - -`R` **`multiply_log`**`(T1 x, T2 y)`
\newline -Vectorized implementation of the `multiply_log` function -`r since("2.25")` - \index{{\tt \bfseries ldexp }!{\tt (real x, int y): real}|hyperpage} diff --git a/src/functions-reference/removed_functions.Rmd b/src/functions-reference/removed_functions.Rmd index 5f26c63bd..6377973ed 100644 --- a/src/functions-reference/removed_functions.Rmd +++ b/src/functions-reference/removed_functions.Rmd @@ -1,6 +1,96 @@ # Removed Functions Functions which once existed in the Stan language and have since been replaced -or removed will be listed here. +or removed are listed here. -As of the current version of Stan, there are no such functions. + +## `multiply_log` and `binomial_coefficient_log` functions + +*Removed*: Currently two non-conforming functions ending in suffix + `_log`. + +*Replacement*: Replace `multiply_log(...)` with `lmultiply(...)`. + Replace `binomial_coefficient_log(...)` with `lchoose(...)`. + +*Removed In*: Stan 2.33 + + +## `get_lp()` function + +*Removed*: The built-in no-argument function `get_lp()` is deprecated. + +*Replacement*: Use the no-argument function `target()` instead. + +*Removed In*: Stan 2.33 + +## `fabs` function + +*Removed*: The unary function `fabs` is deprecated. + +*Replacement*: Use the unary function `abs` instead. Note that the return type +for `abs` is different for integer overloads, but this replacement is safe due +to Stan's type promotion rules. + +*Removed In*: Stan 2.33 + + +## Exponentiated quadratic covariance functions {#cov_exp_quad} + +These covariance functions have been replaced by those described in: + +```{r results='asis', echo=FALSE} +if (knitr::is_html_output()) { + cat(' * Gaussian Process Covariance Functions\n') +} +``` + +With magnitude $\alpha$ and length scale $l$, the exponentiated quadratic kernel is: + +$$ +k(x_i, x_j) = \alpha^2 \exp \left(-\dfrac{1}{2\rho^2} \sum_{d=1}^D (x_{i,d} - x_{j,d})^2 \right) +$$ + + +\index{{\tt \bfseries cov\_exp\_quad }!{\tt (row\_vectors x, real alpha, real rho): matrix}|hyperpage} + +`matrix` **`cov_exp_quad`**`(row_vectors x, real alpha, real rho)`
\newline +The covariance matrix with an exponentiated quadratic kernel of x. +`r since("2.16, deprecated since 2.20, removed in in 2.33")` + + +\index{{\tt \bfseries cov\_exp\_quad }!{\tt (vectors x, real alpha, real rho): matrix}|hyperpage} + +`matrix` **`cov_exp_quad`**`(vectors x, real alpha, real rho)`
\newline +The covariance matrix with an exponentiated quadratic kernel of x. +`r since("2.16, deprecated since 2.20, removed in in 2.33")` + + +\index{{\tt \bfseries cov\_exp\_quad }!{\tt (array[] real x, real alpha, real rho): matrix}|hyperpage} + +`matrix` **`cov_exp_quad`**`(array[] real x, real alpha, real rho)`
\newline +The covariance matrix with an exponentiated quadratic kernel of x. +`r since("2.16, deprecated since 2.20, removed in in 2.33")` + + +\index{{\tt \bfseries cov\_exp\_quad }!{\tt (row\_vectors x1, row\_vectors x2, real alpha, real rho): matrix}|hyperpage} + +`matrix` **`cov_exp_quad`**`(row_vectors x1, row_vectors x2, real alpha, real rho)`
\newline +The covariance matrix with an exponentiated quadratic kernel of x1 and +x2. +`r since("2.18, deprecated since 2.20, removed in in 2.33")` + + +\index{{\tt \bfseries cov\_exp\_quad }!{\tt (vectors x1, vectors x2, real alpha, real rho): matrix}|hyperpage} + +`matrix` **`cov_exp_quad`**`(vectors x1, vectors x2, real alpha, real rho)`
\newline +The covariance matrix with an exponentiated quadratic kernel of x1 and +x2. +`r since("2.18, deprecated since 2.20, removed in in 2.33")` + + +\index{{\tt \bfseries cov\_exp\_quad }!{\tt (array[] real x1, array[] real x2, real alpha, real rho): matrix}|hyperpage} + +`matrix` **`cov_exp_quad`**`(array[] real x1, array[] real x2, real alpha, real rho)`
\newline +The covariance matrix with an exponentiated quadratic kernel of x1 and +x2. +`r since("2.18, deprecated since 2.20, removed in in 2.33")` diff --git a/src/reference-manual/deprecations.Rmd b/src/reference-manual/deprecations.Rmd index d3f035186..1515c09e8 100644 --- a/src/reference-manual/deprecations.Rmd +++ b/src/reference-manual/deprecations.Rmd @@ -7,135 +7,18 @@ Starting with Stan 2.29, minor (syntax-level) deprecations can be removed 3 versions after release; e.g., syntax deprecated in Stan 2.20 will be removed in Stan 2.23 and placed in [Removed Features]. The Stan compiler can [automatically update](https://mc-stan.org/docs/stan-users-guide/stanc-pretty-printing.html) -many of these on the behalf of the user. +many of these on the behalf of the user for at least one version after they are +removed. Any feature which changes semantic meaning (such as the upgraded ODE solver interface) will not be removed until a major version change (e.g., Stan 3.0). -## Assignment with `<-` - -*Deprecated*: The deprecated syntax uses the operator `<-` for - assignment, e.g., - -```stan -a <- b; -``` - -*Replacement*: The new syntax uses the operator `=` for assignment, - e.g., - -```stan -a = b; -``` - -*Scheduled Removal*: Stan 2.33 - -## `increment_log_prob` statement - - -*Deprecated*: The deprecated syntax for incrementing the log density - accumulator by `u` is - -```stan -increment_log_prob(u); -``` - -If `u` is an expression of real type, the underlying log density -accumulator is incremented by `u`; if `u` is a container, the -underlying log density is incremented with each element. - -*Replacement*: Replace the above statement with - -```stan -target += u; -``` - -*Scheduled Removal*: Stan 2.33 - -## `get_lp()` function - - -*Deprecated*: The built-in no-argument function `get_lp()` is deprecated. - -*Replacement*: Use the no-argument function `target()` instead. - - -*Scheduled Removal*: Stan 2.33 - -## `_log` density and mass functions - - -*Deprecated*: The probability function for the distribution `foo` will -be applied to an outcome variable `y` and sequence of zero or more -parameters `...` to produce the expression `foo_log(y, ...)`. - -*Replacement*: If `y` can be a real value (including vectors -or matrices), replace - -```stan -foo_log(y, ...) -``` - -with the log probability density function notation - -```stan -foo_lpdf(y | ...). -``` - -If `y` must be an integer (including arrays), instead replace - -```stan -foo_log(y, ... -``` - -with the log probability mass function - -```stan -foo_lpmf(y | ...). -``` - -*Scheduled Removal*: Stan 2.33 - -## `cdf_log` and `ccdf_log` cumulative distribution functions - -*Deprecated*: The log cumulative distribution and complementary -cumulative distribution functions for a distribution `foo` are -currently written as `foo_cdf_log` and `foo_ccdf_log`. - -*Replacement*: Replace `foo_cdf_log(y, ...)` with `foo_lcdf(y | ...)`. -Replace `foo_ccdf_log(y, ...)` with `foo_lccdf(y | ...)`. - - -## User-defined function with `_log` suffix - -*Deprecated*: A user-defined function ending in `_log` can - be used in sampling statements, with - -```stan -y ~ foo(...); -``` - -having the same effect as - -```stan -target += foo_log(y, ...); -``` - -*Replacement*: Replace the `_log` suffix with `_lpdf` for density -functions or `_lpmf` for mass functions in the user-defined function. - - -*Scheduled Removal*: Stan 2.33 - -Note: Following Stan 2.33, users can still define a function ending in `_log`, -it will just no longer have a special meaning or support the `~` syntax. - ## `lkj_cov` distribution *Deprecated*:The distribution `lkj_cov` is deprecated. -*Replacement*: Replace `lkj_cov_log(...)` with an `lkj_corr` +*Replacement*: Replace `lkj_cov_lpdf(...)` with an `lkj_corr` distribution on the correlation matrix and independent lognormal distributions on the scales. That is, replace @@ -165,106 +48,6 @@ would use Cholesky factors rather than full correlation matrix types. *Scheduled Removal*: Stan 3.0 or later. -## `if_else` function - -*Deprecated*:The function `if_else` is deprecated. This function -takes three arguments `a`, `b`, and `c`, where `a` is an `int` value -and `b` and `c` are scalars. It returns `b` if `a` is non-zero and `c` -otherwise. - -*Replacement*: Use the conditional operator which allows more -flexibility in the types of `b` and `c` and is much more efficient in -that it only evaluates whichever of `b` or `c` is returned. - -```stan -x = if_else(a, b, c); -``` - -with - -```stan -x = a ? b : c; -``` - -*Scheduled Removal*: Stan 2.33 - -## Character `#` as comment prefix - -*Deprecated*: The use of `#` for line-based comments is - deprecated. From the first occurrence of `#` onward, the rest - of the line is ignored. This happens after includes are resolved - starting with `#include`. - -*Replacement*: Use a pair of forward slashes, `//`, for line - comments. - -*Scheduled Removal*: Stan 2.33 - -## Brackets array syntax - -Before Stan 2.26, arrays were declared by writing syntax after the -variable. As of version 2.26, the old syntax has been deprecated and -replaced with a keyword-based syntax. - -*Deprecated*: The use of array declarations like -```stan -int n[5]; -real a[3, 4]; -real z[5, 4, 2]; -vector[7] mu[3]; -matrix[7, 2] mu[15, 12]; -cholesky_factor_cov[5, 6] mu[2, 3, 4]; -``` - -*Replacement*: The use of the `array` keyword, which replaces the - above examples with -```stan -array[5] int n; -array[3, 4] real a; -array[5, 4, 2] real z; -array[3] vector[7] mu; -array[15, 12] matrix[7, 2] mu; -array[2, 3, 4] cholesky_factor_cov[5, 6] mu; -``` - -*Scheduled Removal*: Stan 2.33 - - -## New Keywords - -*Deprecated*: The following identifiers will become -[reserved](#reserved-names) -in the language in the specified version. - -*Replacement*: Rename any variables or functions with these names. - -| Identifier | Version | -|------------|---------| -| array | 2.33 | -| lower | 2.33 | -| upper | 2.33 | -| offset | 2.33 | -| multiplier | 2.33 | - - -## Nested multiple indexing in assignments - -Stan interprets nested indexing in assignments as flat indexing so that a statement like -```stan -a[:][1] = b; -``` -is the same as -```stan -a[:,1] = b; -``` -However, this is inconsistent with -[multiple indexing rules](https://mc-stan.org/docs/reference-manual/language-multi-indexing.html). -To avoid confusion nested multiple indexing in assignment will be an error after Stan 2.33. -Nesting single indexing is still allowed as it cannot lead to ambiguity. - -*Scheduled Removal*: Stan 2.33 - - ## Real values in conditionals *Deprecated*: Using a real value in a conditional diff --git a/src/reference-manual/expressions.Rmd b/src/reference-manual/expressions.Rmd index 5dd2fded1..732b2e8e0 100644 --- a/src/reference-manual/expressions.Rmd +++ b/src/reference-manual/expressions.Rmd @@ -136,7 +136,8 @@ the tokens are reserved for future use. ``` for, in, while, repeat, until, if, then, else, true, false, target, struct, typedef, export, -auto, extern, var, static +auto, extern, var, static, lower, upper, offset, +multiplier ``` Variables should not be named after types, either, and thus may not be @@ -146,7 +147,7 @@ any of the following. int, real, complex, vector, simplex, unit_vector, ordered, positive_ordered, row_vector, matrix, cholesky_factor_corr, cholesky_factor_cov, -corr_matrix, cov_matrix +corr_matrix, cov_matrix, array ``` The following built in functions are also reserved and @@ -169,10 +170,9 @@ transformed, generated Variable names will also conflict with the names of distributions suffixed with `_lpdf`, `_lpmf`, `_lcdf`, and `_lccdf`, `_cdf`, and -`_ccdf`, such as `normal_lcdf_log`; this also holds for the deprecated -forms `_log`, `_cdf_log`, and `_ccdf_log`. No user-defined variable -can take a name ending in `_lupdf` or `_lupmf` even if a corresponding -`_lpdf` or `_lpmf` is not defined. +`_ccdf`, such as `normal_lcdf_log`. No user-defined variable can take a name +ending in `_lupdf` or `_lupmf` even if a corresponding `_lpdf` or `_lpmf` is not +defined. Using any of these variable names causes the `stanc` translator to halt and report the name and location of the variable causing the @@ -247,7 +247,7 @@ three elements with real values 1.0, 10.0, and 100.0. Applying the transpose operator to a row vector expression produces a vector expression. This syntax provides a way declare and define small vectors a single -line, as follows. +line, as follows. ```stan row_vector[2] rv2 = [ 1, 2 ]; @@ -297,7 +297,7 @@ complex_matrix[2, 3] = [[1 + 2i, 3 - 1.7i, 0], The empty expression `[ ]` is ambiguous and therefore is not allowed and similarly expressions such as `[ [ ] ]` or -`[ [ ], [ ] ]` are not allowed. +`[ [ ], [ ] ]` are not allowed. ### Array expressions {-} @@ -1140,7 +1140,7 @@ singly-indexed function. Suppose `e` is an expression and `i` is an expression of primitive type `int`. Then * if `e` is an expression of type `array[i1, i2, ..., iN] T` and `k,` `i1`, - ..., `iN` are expressions of type `int`, then + ..., `iN` are expressions of type `int`, then `e[k]` is an expression of type `array[i2, ..., iN] T`, * if `e` is an expression of type `array[i] T` with `i` and `k` expressions of type `int`, then `e[k]` is of type `T`, @@ -1153,7 +1153,7 @@ expression of primitive type `int`. Then `e[i]` is an expression of type `complex`, and * if `e` has implementation type `complex_matrix`, and `i` is an expression of type `int`, then `e[i]` is an expression of type - `complex_row_vector`. + `complex_row_vector`. #### Function application {-} diff --git a/src/reference-manual/removals.Rmd b/src/reference-manual/removals.Rmd index ecaadbdd2..959a1a1a3 100644 --- a/src/reference-manual/removals.Rmd +++ b/src/reference-manual/removals.Rmd @@ -24,3 +24,186 @@ target += e; The value of `lp__` is available through the no-argument function `target()`. + + +## Assignment with `<-` + +*Removed*: The operator `<-` for assignment, e.g., + +```stan +a <- b; +``` + +is no longer available. + +*Replacement*: The new syntax uses the operator `=` for assignment, + e.g., + +```stan +a = b; +``` + +*Removed In*: Stan 2.33 + +## `increment_log_prob` statement + + +*Removed*: The `increment_log_prob(u)` statement for incrementing the log +density accumulator by `u` is no longer available. + +*Replacement*: Replace the above statement with + +```stan +target += u; +``` + +*Removed In*: Stan 2.33 + +## `get_lp()` function + + +*Removed*: The built-in no-argument function `get_lp()` is no longer available. + +*Replacement*: Use the no-argument function `target()` instead. + + +*Removed In*: Stan 2.33 + +## `_log` density and mass functions + + +*Removed*: Formerly, the probability function for the distribution `foo` would +be applied to an outcome variable `y` and sequence of zero or more parameters +`...` to produce the expression `foo_log(y, ...)`. This suffix is no longer a +special value. + +*Replacement*: If `y` can be a real value (including vectors +or matrices), replace + +```stan +foo_log(y, ...) +``` + +with the log probability density function notation + +```stan +foo_lpdf(y | ...). +``` + +If `y` must be an integer (including arrays), instead replace + +```stan +foo_log(y, ... +``` + +with the log probability mass function + +```stan +foo_lpmf(y | ...). +``` + +*Removed In*: Stan 2.33 + +## `cdf_log` and `ccdf_log` cumulative distribution functions + +*Removed*: The log cumulative distribution and complementary +cumulative distribution functions for a distribution `foo` were formerly written +as `foo_cdf_log` and `foo_ccdf_log`. + +*Replacement*: + +Replace `foo_cdf_log(y, ...)` with `foo_lcdf(y | ...)`. + +Replace `foo_ccdf_log(y, ...)` with `foo_lccdf(y | ...)`. + + +## User-defined function with `_log` suffix + +*Removed*: A user-defined function ending in `_log` can be no longer be used in +sampling statements. + +*Replacement*: Replace the `_log` suffix with `_lpdf` for density +functions or `_lpmf` for mass functions in the user-defined function. + + +*Removed In*: Stan 2.33 + +Note: Following Stan 2.33, users can stil define a function ending in `_log`, +it simply no longer has a special meaning or is supported in the `~` syntax. + + +## `if_else` function + +*Removed*: The function `if_else` is no longer available. + +*Replacement*: Use the conditional operator which allows more +flexibility in the types of `b` and `c` and is much more efficient in +that it only evaluates whichever of `b` or `c` is returned. + +```stan +x = if_else(a, b, c); +``` + +with + +```stan +x = a ? b : c; +``` + +*Removed In*: Stan 2.33 + +## Character `#` as comment prefix + +*Removed*: The use of `#` for line-based comments is no longer permitted. `#` +may only be used for `#include` statements. + +*Replacement*: Use a pair of forward slashes, `//`, for line comments. + +*Removed In*: Stan 2.33 + +## Postfix brackets array syntax + +Before Stan 2.26, arrays were declared by writing syntax after the +variable. + +*Removed*: The use of array declarations like +```stan +int n[5]; +real a[3, 4]; +real z[5, 4, 2]; +vector[7] mu[3]; +matrix[7, 2] mu[15, 12]; +cholesky_factor_cov[5, 6] mu[2, 3, 4]; +``` + +*Replacement*: The use of the `array` keyword, which replaces the + above examples with +```stan +array[5] int n; +array[3, 4] real a; +array[5, 4, 2] real z; +array[3] vector[7] mu; +array[15, 12] matrix[7, 2] mu; +array[2, 3, 4] cholesky_factor_cov[5, 6] mu; +``` + +*Removed In*: Stan 2.33 + +## Nested multiple indexing in assignments + +Stan interprets nested indexing in assingments as flat indexing so that a statement like +```stan +a[:][1] = b; +``` +is the same as +```stan +a[:,1] = b; +``` +However, this is inconsistent with +[multiple indexing +rules](https://mc-stan.org/docs/reference-manual/language-multi-indexing.html). + +To avoid confusion nested multiple indexing in assignment became an error in Stan 2.33. +Nesting single indexing is still allowed as it cannot lead to ambiguity. + +*Removed In*: Stan 2.33 diff --git a/src/reference-manual/statements.Rmd b/src/reference-manual/statements.Rmd index aba8fee28..722058ece 100644 --- a/src/reference-manual/statements.Rmd +++ b/src/reference-manual/statements.Rmd @@ -34,7 +34,7 @@ An assignment statement consists of a variable (possibly multivariate with indexing information) and an expression. Executing an assignment statement evaluates the expression on the right-hand side and assigns it to the (indexed) variable on the left-hand side. -An example of a simple assignment is as follows.^[In versions of Stan before 2.18.0, the operator `<-` was used for assignment rather than using the equal sign `=`. The old operator `<-` is now deprecated and will print a warning. In Stan 2.33, it will be removed.] +An example of a simple assignment is as follows. ```stan n = 0; @@ -247,7 +247,7 @@ density (the Jacobian adjustment may be skipped for optimization). Sampling and log probability increment statements may add to the log density in the model block. A log probability increment statement directly increments the log density with the value of an expression as -follows.^[The current notation replaces two previous versions. Originally, a variable `lp__` was directly exposed and manipulated; this is no longer allowed. The original statement syntax for `target += u` was `increment_log_prob(u)`, but this form has been deprecated and will be removed in Stan 2.33] +follows.^[The current notation replaces two previous versions. Originally, a variable `lp__` was directly exposed and manipulated; this is no longer allowed. The original statement syntax for `target += u` was `increment_log_prob(u)`, but this form was removed in Stan 2.33] ```stan target += -0.5 * y * y; @@ -470,7 +470,7 @@ definitions. For the case above, the following adjustment will account for the log transform.^[Because $\log | \frac{d}{dy} \log y | = \log | 1/y | = - \log |y|$.] ```stan -target += - log(fabs(y)); +target += - log(abs(y)); ``` diff --git a/src/reference-manual/types.Rmd b/src/reference-manual/types.Rmd index 7cbb4122a..8db87ac6e 100644 --- a/src/reference-manual/types.Rmd +++ b/src/reference-manual/types.Rmd @@ -78,8 +78,8 @@ real values, declares `m` to be a two-dimensional array of size $6 \times 7$ containing values that are $3 \times 3$ matrices, and declares `z` to be a $12 \times 8 \times 15$ array of complex numbers. -Prior to 2.26 Stan models used a different syntax. The old syntax has -been deprecated as described in the [Deprecated Features] chapter. +Prior to 2.26 Stan models used a different syntax which has since been removed. +See the [Removed Features] chapter for more details. ### Tuple types diff --git a/src/stan-users-guide/custom-probability.Rmd b/src/stan-users-guide/custom-probability.Rmd index 6f81e4853..19e87cf3f 100644 --- a/src/stan-users-guide/custom-probability.Rmd +++ b/src/stan-users-guide/custom-probability.Rmd @@ -40,7 +40,7 @@ parameters { real y; } model { - target += log1m(fabs(y)); + target += log1m(abs(y)); } ``` @@ -48,7 +48,7 @@ The single scalar parameter `y` is declared as lying in the interval `(-1,1)`. The total log probability is incremented with the joint log probability of all parameters, i.e., $\log \mathsf{Triangle}(y \mid -1,1)$. This value is coded in Stan as -`log1m(fabs(y))`. The function `log1m` is defined so +`log1m(abs(y))`. The function `log1m` is defined so that `log1m(x)` has the same value as $\log(1-x)$, but the computation is faster, more accurate, and more stable. @@ -64,7 +64,7 @@ $\mathbb{R}$ as follows by defining the probability to be `log(0.0)`, i.e., $-\infty$, for values outside of $(-1,1)$. ```stan -target += log(fmax(0.0,1 - fabs(y))); +target += log(fmax(0.0,1 - abs(y))); ``` With the constraint on `y` in place, this is just a less @@ -137,7 +137,7 @@ The following Stan program implements this function, ```stan real binormal_cdf(real z1, real z2, real rho) { if (z1 != 0 || z2 != 0) { - real denom = fabs(rho) < 1.0 ? sqrt((1 + rho) * (1 - rho)) + real denom = abs(rho) < 1.0 ? sqrt((1 + rho) * (1 - rho)) : not_a_number(); real a1 = (z2 / z1 - rho) / denom; real a2 = (z1 / z2 - rho) / denom; diff --git a/src/stan-users-guide/reparameterization.Rmd b/src/stan-users-guide/reparameterization.Rmd index 77cb46ada..88e6c0909 100644 --- a/src/stan-users-guide/reparameterization.Rmd +++ b/src/stan-users-guide/reparameterization.Rmd @@ -472,7 +472,7 @@ transformed parameters { matrix[K, K] J; // Jacobian matrix of transform // ... compute v as a function of u ... // ... compute J[m, n] = d.v[m] / d.u[n] ... - target += log(fabs(determinant(J))); + target += log(abs(determinant(J))); // ... } model { diff --git a/src/stan-users-guide/simulation-based-calibration.Rmd b/src/stan-users-guide/simulation-based-calibration.Rmd index 27d325189..1e42fc262 100644 --- a/src/stan-users-guide/simulation-based-calibration.Rmd +++ b/src/stan-users-guide/simulation-based-calibration.Rmd @@ -468,10 +468,10 @@ parameters. ```stan transformed data { real mu_sim = normal_rng(0, 5); - real tau_sim = fabs(normal_rng(0, 5)); + real tau_sim = abs(normal_rng(0, 5)); int J = 8; array[J] real theta_sim = normal_rng(rep_vector(mu_sim, J), tau_sim); - array[J] real sigma = fabs(normal_rng(rep_vector(0, J), 5)); + array[J] real sigma = abs(normal_rng(rep_vector(0, J), 5)); array[J] real y = normal_rng(theta_sim, sigma); } parameters { diff --git a/src/stan-users-guide/user-functions.Rmd b/src/stan-users-guide/user-functions.Rmd index 96dee04ab..2d65b40e2 100644 --- a/src/stan-users-guide/user-functions.Rmd +++ b/src/stan-users-guide/user-functions.Rmd @@ -20,8 +20,8 @@ functions { real relative_diff(real x, real y) { real abs_diff; real avg_scale; - abs_diff = fabs(x - y); - avg_scale = (fabs(x) + fabs(y)) / 2; + abs_diff = abs(x - y); + avg_scale = (abs(x) + abs(y)) / 2; return abs_diff / avg_scale; } } diff --git a/src/stan-users-guide/using-stanc.Rmd b/src/stan-users-guide/using-stanc.Rmd index 9b26a2684..20b50054a 100644 --- a/src/stan-users-guide/using-stanc.Rmd +++ b/src/stan-users-guide/using-stanc.Rmd @@ -121,7 +121,7 @@ Errors differ from warnings in their severity and format. In particular, errors are _fatal_ and stop compilation, so at most one error is displayed per run of stanc. -There are four kinds of errors emitted by stanc3 +There are five kinds of errors emitted by stanc3 1. File errors occur when the file passed to stanc is either missing or cannot be opened (i.e. has permissions issues). They look like @@ -197,7 +197,13 @@ There are four kinds of errors emitted by stanc3 Ill-typed arguments supplied to assignment operator =: lhs has type int and rhs has type real ``` -4. Finally, the compiler can raise an internal error. These are caused by bugs +4. The compiler will raise an error for use of any [removed + features](https://mc-stan.org/docs/reference-manual/removed-features.html) + for at least one version following their removal. The deprecation warnings + mentioned above eventually turn into this kind of error to prompt the user to + update their model. After the version of removal, these errors will be + converted to one of the other types listed here, depending on the feature. +5. Finally, the compiler can raise an internal error. These are caused by bugs in the compiler, **not** your model, and we would appreciate it if you report them on the [stanc3 repo](https://github.com/stan-dev/stanc3/issues) with the error message provided. These errors usually say something like "This should