diff --git a/rstan/rstan/R/misc.R b/rstan/rstan/R/misc.R index cd338e287..4def2db28 100644 --- a/rstan/rstan/R/misc.R +++ b/rstan/rstan/R/misc.R @@ -863,7 +863,7 @@ remove_empty_pars <- function(pars, model_dims) { # following stan model code: # # transformed data { int n; n <- 0; } - # parameters { real y[n]; } + # parameters { array[n] real y; } # # Args: # pars: a character vector of parameters names diff --git a/rstan/rstan/man/rstan.Rd b/rstan/rstan/man/rstan.Rd index 277afc7fd..9e5ffbf53 100644 --- a/rstan/rstan/man/rstan.Rd +++ b/rstan/rstan/man/rstan.Rd @@ -93,7 +93,7 @@ stanmodelcode <- " data { int N; - real y[N]; + array[N] real y; } parameters { diff --git a/rstan/rstan/man/sflist2stanfit.Rd b/rstan/rstan/man/sflist2stanfit.Rd index 876691e35..a368d5692 100644 --- a/rstan/rstan/man/sflist2stanfit.Rd +++ b/rstan/rstan/man/sflist2stanfit.Rd @@ -72,8 +72,8 @@ data { int N; } parameters { - real y1[N]; - real y2[N]; + array[N] real y1; + array[N] real y2; } model { y1 ~ normal(0, 1); diff --git a/rstan/rstan/man/stan.Rd b/rstan/rstan/man/stan.Rd index 40e0ddff3..b30ba009e 100644 --- a/rstan/rstan/man/stan.Rd +++ b/rstan/rstan/man/stan.Rd @@ -386,7 +386,7 @@ stan(file, model_name = "anon_model", model_code = "", fit = NA, } Stan treats a vector of length 1 in R as a scalar. So technically - if, for example, \code{"real y[1];"} is defined in the data block, an array + if, for example, \code{"array[1] real y;"} is defined in the data block, an array such as \code{"y = array(1.0, dim = 1)"} in R should be used. This is also the case for specifying initial values since the same underlying approach for reading data from R in Stan is used, in which @@ -425,7 +425,7 @@ stan(file, model_name = "anon_model", model_code = "", fit = NA, library(rstan) scode <- " parameters { - real y[2]; + array[2] real y; } model { y[1] ~ normal(0, 1); @@ -447,7 +447,7 @@ e2 <- extract(fit2, permuted = FALSE) excode <- ' transformed data { - real y[20]; + array[20] real y; y[1] = 0.5796; y[2] = 0.2276; y[3] = -0.2959; y[4] = -0.3742; y[5] = 0.3885; y[6] = -2.1585; y[7] = 0.7111; y[8] = 1.4424; y[9] = 2.5430; diff --git a/rstan/rstan/man/stanc.Rd b/rstan/rstan/man/stanc.Rd index fc80f61fb..bfb4e332f 100644 --- a/rstan/rstan/man/stanc.Rd +++ b/rstan/rstan/man/stanc.Rd @@ -121,7 +121,7 @@ Translate Stan model specification to C++ code stanmodelcode <- " data { int N; - real y[N]; + array[N] real y; } parameters { diff --git a/rstan/rstan/man/stanfit-class.Rd b/rstan/rstan/man/stanfit-class.Rd index 3456cd6d8..443ed98f7 100644 --- a/rstan/rstan/man/stanfit-class.Rd +++ b/rstan/rstan/man/stanfit-class.Rd @@ -200,7 +200,7 @@ summarizing results and various access methods also allow the underlying data showClass("stanfit") ecode <- ' parameters { - real y[2]; + array[2] real y; } model { y ~ exponential(1); @@ -241,7 +241,7 @@ print(y1star) # y1start should equal to y1 # excode <- ' transformed data { - real y[20]; + array[20] real y; y[1] <- 0.5796; y[2] <- 0.2276; y[3] <- -0.2959; y[4] <- -0.3742; y[5] <- 0.3885; y[6] <- -2.1585; y[7] <- 0.7111; y[8] <- 1.4424; y[9] <- 2.5430; diff --git a/rstan/rstan/man/stanfit-method-extract.Rd b/rstan/rstan/man/stanfit-method-extract.Rd index e3fb5589f..48210d8df 100644 --- a/rstan/rstan/man/stanfit-method-extract.Rd +++ b/rstan/rstan/man/stanfit-method-extract.Rd @@ -57,8 +57,8 @@ \examples{\dontrun{ ex_model_code <- ' parameters { - real alpha[2,3]; - real beta[2]; + array[2, 3] real alpha; + array[2] real beta; } model { for (i in 1:2) for (j in 1:3) @@ -110,7 +110,7 @@ dimnames(fit_ss2) # excode <- ' transformed data { - real y[20]; + array[20] real y; y[1] <- 0.5796; y[2] <- 0.2276; y[3] <- -0.2959; y[4] <- -0.3742; y[5] <- 0.3885; y[6] <- -2.1585; y[7] <- 0.7111; y[8] <- 1.4424; y[9] <- 2.5430; diff --git a/rstan/rstan/man/stanfit-method-summary.Rd b/rstan/rstan/man/stanfit-method-summary.Rd index 70049dd95..9b8f8f0fa 100644 --- a/rstan/rstan/man/stanfit-method-summary.Rd +++ b/rstan/rstan/man/stanfit-method-summary.Rd @@ -48,7 +48,7 @@ array of MCMC draws as its input rather than a \code{stanfit} object. \examples{\dontrun{ ecode <- ' parameters { - real y[2]; + array[2] real y; } model { y ~ exponential(1); diff --git a/rstan/rstan/man/stanfit-method-traceplot.Rd b/rstan/rstan/man/stanfit-method-traceplot.Rd index c18980c8d..9f97a4fd7 100644 --- a/rstan/rstan/man/stanfit-method-traceplot.Rd +++ b/rstan/rstan/man/stanfit-method-traceplot.Rd @@ -55,7 +55,7 @@ # excode <- ' transformed data { - real y[20]; + array[20] real y; y[1] <- 0.5796; y[2] <- 0.2276; y[3] <- -0.2959; y[4] <- -0.3742; y[5] <- 0.3885; y[6] <- -2.1585; y[7] <- 0.7111; y[8] <- 1.4424; y[9] <- 2.5430; diff --git a/rstan/rstan/man/stanfit2array-method.Rd b/rstan/rstan/man/stanfit2array-method.Rd index a2b873680..acc64a49c 100644 --- a/rstan/rstan/man/stanfit2array-method.Rd +++ b/rstan/rstan/man/stanfit2array-method.Rd @@ -71,8 +71,8 @@ \examples{\dontrun{ ex_model_code <- ' parameters { - real alpha[2,3]; - real beta[2]; + array[2, 3] real alpha; + array[2] real beta; } model { for (i in 1:2) for (j in 1:3) diff --git a/rstan/rstan/tests/testthat/test-partial_inits.R b/rstan/rstan/tests/testthat/test-partial_inits.R index c3deb14e0..5381efb10 100644 --- a/rstan/rstan/tests/testthat/test-partial_inits.R +++ b/rstan/rstan/tests/testthat/test-partial_inits.R @@ -4,7 +4,7 @@ test_that("partial_inits works", { stan_model_code <- " data { int N; - real y[N]; + array[N] real y; } parameters { diff --git a/rstan/rstan/tests/testthat/test-stan_fun.R b/rstan/rstan/tests/testthat/test-stan_fun.R index de4298f50..0b3d08907 100644 --- a/rstan/rstan/tests/testthat/test-stan_fun.R +++ b/rstan/rstan/tests/testthat/test-stan_fun.R @@ -6,7 +6,7 @@ test_that("Running stan() in parallel works", { data { int N; } parameters { - real y[N]; + array[N] real y; } model { y ~ normal(0, 1); } @@ -48,11 +48,11 @@ test_that("stan() arguments works", { diag_fname2 <- "diag2.csv" model_code <- " parameters { - real y[2]; + array[2] real y; real alpha; } transformed parameters { - real y2[2, 2]; + array[2, 2] real y2; y2[1, 1] = y[1]; y2[1, 2] = -y[1]; y2[2, 1] = -y[2]; diff --git a/rstan/rstan/tests/testthat/test-stanfit.R b/rstan/rstan/tests/testthat/test-stanfit.R index 0d90b1ca6..056e5d25c 100644 --- a/rstan/rstan/tests/testthat/test-stanfit.R +++ b/rstan/rstan/tests/testthat/test-stanfit.R @@ -8,11 +8,11 @@ test_that("outputing csv and extracting work", { n = 0; } parameters { - real y[2]; - real zeroleny[n]; + array[2] real y; + array[n] real zeroleny; } transformed parameters { - real y2[2, 2]; + array[2, 2] real y2; y2[1, 1] = y[1]; y2[1, 2] = -y[1]; y2[2, 1] = -y[2]; @@ -22,7 +22,7 @@ test_that("outputing csv and extracting work", { y ~ normal(0, 1); } generated quantities { - real y3[3, 2, 3]; + array[3, 2, 3] real y3; y3[1,1,1] = 1; y3[1,1,2] = 2; y3[1,1,3] = 3; y3[1,2,1] = 4; y3[1,2,2] = 5; y3[1,2,3] = 6; y3[2,1,1] = 7; y3[2,1,2] = 8; y3[2,1,3] = 9; @@ -182,7 +182,7 @@ test_that("grad log is correct", { code <- " data { - real y[20]; + array[20] real y; } parameters { real mu; @@ -241,7 +241,7 @@ test_that("Specifying arguments and data works", { code <- " data { int N; - real y[N]; + array[N] real y; } parameters { real mu;