diff --git a/CRAN-RELEASE b/CRAN-RELEASE new file mode 100644 index 0000000..04019aa --- /dev/null +++ b/CRAN-RELEASE @@ -0,0 +1,2 @@ +This package was submitted to CRAN on 2021-05-18. +Once it is accepted, delete this file and tag the release (commit 037b6a9). diff --git a/DESCRIPTION b/DESCRIPTION index 9cd7e68..8524fd4 100644 --- a/DESCRIPTION +++ b/DESCRIPTION @@ -1,7 +1,7 @@ Package: bayesdfa Type: Package Title: Bayesian Dynamic Factor Analysis (DFA) with 'Stan' -Version: 1.0.0 +Version: 1.1.0 Authors@R: c( person(c("Eric", "J."), "Ward", role = c("aut", "cre"), email = "eric.ward@noaa.gov"), diff --git a/NEWS.md b/NEWS.md index 2201cf4..169365b 100644 --- a/NEWS.md +++ b/NEWS.md @@ -29,3 +29,7 @@ # bayesdfa 1.0.0 * Added constraint on diagonal of Z matrix to keep parameter estimates from 'flipping' within MCMC chains. Ensures convergence for problematic cases. This was present in 0.1.1, but later removed. + +# bayesdfa 1.1.0 + +* Following 1.0.0, included a new argument to fit_dfa() function 'expansion_prior' that allows user to toggle on / off the constraint. If not included (default=FALSE), there is no constraint on the Z diagonal, and post-hoc MCMC chain inverting resolves identifiability. If 'expansion_prior' = TRUE, then the positive constraint is applied, in combination with the expansion prior for trends and loadings. diff --git a/R/converge_rhat.R b/R/converge_rhat.R index 4b5f7d5..eb5c389 100644 --- a/R/converge_rhat.R +++ b/R/converge_rhat.R @@ -10,9 +10,8 @@ #' @export #' is_converged <- function(fitted_model, - threshold = 1.05, - parameters = c("sigma", "x", "Z")) { - + threshold = 1.05, + parameters = c("sigma", "x", "Z")) { Rhats <- fitted_model$monitor[which(grepl( paste(parameters, collapse = "|"), diff --git a/R/dfa_cv.R b/R/dfa_cv.R index 30e6aae..fcd3168 100644 --- a/R/dfa_cv.R +++ b/R/dfa_cv.R @@ -20,79 +20,79 @@ #' \dontrun{ #' set.seed(42) #' s <- sim_dfa(num_trends = 1, num_years = 20, num_ts = 3) -#' obs <- c(s$y_sim[1,], s$y_sim[2,], s$y_sim[3,]) -#' long = data.frame("obs" = obs, "ts" = sort(rep(1:3,20)), "time" = rep(1:20,3)) -#' m <- fit_dfa(y = long, iter = 50, chains = 1, data_shape="long", sample=FALSE) +#' obs <- c(s$y_sim[1, ], s$y_sim[2, ], s$y_sim[3, ]) +#' long <- data.frame("obs" = obs, "ts" = sort(rep(1:3, 20)), "time" = rep(1:20, 3)) +#' m <- fit_dfa(y = long, iter = 50, chains = 1, data_shape = "long", sample = FALSE) #' # random folds -#' fit_cv = dfa_cv(m, cv_method="loocv", n_folds = 5, iter=50, chains=1) +#' fit_cv <- dfa_cv(m, cv_method = "loocv", n_folds = 5, iter = 50, chains = 1) #' #' # folds can also be passed in -#' fold_ids = sample(1:5, size=nrow(long), replace=TRUE) -#' m <- fit_dfa(y = long, iter = 50, chains = 1, data_shape="long", sample=FALSE) -#' fit_cv = dfa_cv(m, cv_method="loocv", n_folds = 5, iter=50, chains=1, fold_ids=fold_ids) +#' fold_ids <- sample(1:5, size = nrow(long), replace = TRUE) +#' m <- fit_dfa(y = long, iter = 50, chains = 1, data_shape = "long", sample = FALSE) +#' fit_cv <- dfa_cv(m, cv_method = "loocv", n_folds = 5, iter = 50, chains = 1, fold_ids = fold_ids) #' #' # do an example of leave-time-out cross validation where years are dropped -#' fold_ids = long$time -#' m <- fit_dfa(y = long, iter = 50, chains = 1, data_shape="long", sample=FALSE) -#' fit_cv = dfa_cv(m, cv_method="loocv", iter=100, chains=1, fold_ids = fold_ids) +#' fold_ids <- long$time +#' m <- fit_dfa(y = long, iter = 50, chains = 1, data_shape = "long", sample = FALSE) +#' fit_cv <- dfa_cv(m, cv_method = "loocv", iter = 100, chains = 1, fold_ids = fold_ids) #' #' # example with covariates and long format data -#' obs_covar = expand.grid("time"=1:20,"timeseries"=1:3,"covariate"=1:2) -#' obs_covar$value=rnorm(nrow(obs_covar),0,0.1) -#' obs <- c(s$y_sim[1,], s$y_sim[2,], s$y_sim[3,]) -#' m <- fit_dfa(y = long, iter = 50, chains = 1, obs_covar=obs_covar,data_shape="long", sample=FALSE) -#' fit_cv = dfa_cv(m, cv_method="loocv", n_folds = 5, iter=50, chains=1) +#' obs_covar <- expand.grid("time" = 1:20, "timeseries" = 1:3, "covariate" = 1:2) +#' obs_covar$value <- rnorm(nrow(obs_covar), 0, 0.1) +#' obs <- c(s$y_sim[1, ], s$y_sim[2, ], s$y_sim[3, ]) +#' m <- fit_dfa(y = long, iter = 50, chains = 1, obs_covar = obs_covar, data_shape = "long", sample = FALSE) +#' fit_cv <- dfa_cv(m, cv_method = "loocv", n_folds = 5, iter = 50, chains = 1) #' } #' dfa_cv <- function(stanfit, - cv_method = c("loocv","lfocv"), - fold_ids = NULL, - n_folds = 10, - iter = 2000, - chains = 4, - thin = 1, - ...) { - - cv_method <- match.arg(cv_method, c("loocv","lfocv")) - if(is.null(fold_ids)) { + cv_method = c("loocv", "lfocv"), + fold_ids = NULL, + n_folds = 10, + iter = 2000, + chains = 4, + thin = 1, + ...) { + cv_method <- match.arg(cv_method, c("loocv", "lfocv")) + if (is.null(fold_ids)) { warning("the vector fold_ids containing fold ids is null, so random folds are being used") - fold_ids <- sample(1:n_folds, nrow(stanfit$orig_data), replace=TRUE) + fold_ids <- sample(1:n_folds, nrow(stanfit$orig_data), replace = TRUE) } - if(length(fold_ids) != nrow(stanfit$orig_data)) { + if (length(fold_ids) != nrow(stanfit$orig_data)) { stop("The length of the vector fold_ids needs to tbe the same as the number of rows in the long format dataframe") } - if(stanfit$shape!="long") { + if (stanfit$shape != "long") { stop("Error, please reshape the data into long format") } - if(!is.null(fold_ids)) n_folds = max(fold_ids) + if (!is.null(fold_ids)) n_folds <- max(fold_ids) y <- stanfit$orig_data - y$time = y$time - min(y$time) + 1 + y$time <- y$time - min(y$time) + 1 # loop over the folds, re-fitting the dfa model each time with the folds held out - log_lik <- matrix(0, nrow=ceiling(iter/(2*thin))*chains, ncol=n_folds) - for(f in 1:n_folds) { + log_lik <- matrix(0, nrow = ceiling(iter / (2 * thin)) * chains, ncol = n_folds) + for (f in 1:n_folds) { # fit model holding out each time slice. subset observed data and covar y_train <- y - y_train[which(fold_ids == f),"obs"] <- NA - y_test <- y[which(fold_ids == f),] - obs_covar_train=NULL - if(length(stanfit$sampling_args$data$obs_covar_value) > 0) { - stanfit$obs_covar$time_timeseries <- paste(stanfit$obs_covar$time,stanfit$obs_covar$timeseries) - y_train$time_timeseries <- paste(y_train$time,y_train$ts) - y_test$time_timeseries <- paste(y_test$time,y_test$ts) - obs_covar_train <- stanfit$obs_covar[which(stanfit$obs_covar$time_timeseries %in% y_train$time_timeseries[which(fold_ids!=f)]),1:4] - obs_covar_test <- stanfit$obs_covar[which(stanfit$obs_covar$time_timeseries %in% y_test$time_timeseries),1:4] + y_train[which(fold_ids == f), "obs"] <- NA + y_test <- y[which(fold_ids == f), ] + obs_covar_train <- NULL + if (length(stanfit$sampling_args$data$obs_covar_value) > 0) { + stanfit$obs_covar$time_timeseries <- paste(stanfit$obs_covar$time, stanfit$obs_covar$timeseries) + y_train$time_timeseries <- paste(y_train$time, y_train$ts) + y_test$time_timeseries <- paste(y_test$time, y_test$ts) + obs_covar_train <- stanfit$obs_covar[which(stanfit$obs_covar$time_timeseries %in% y_train$time_timeseries[which(fold_ids != f)]), 1:4] + obs_covar_test <- stanfit$obs_covar[which(stanfit$obs_covar$time_timeseries %in% y_test$time_timeseries), 1:4] } - pro_covar_train=NULL - if(length(stanfit$sampling_args$data$pro_covar_value) > 0) { - pro_covar_train <- stanfit$pro_covar[which(fold_ids != f),] - pro_covar_test <- stanfit$pro_covar[which(fold_ids == f),] + pro_covar_train <- NULL + if (length(stanfit$sampling_args$data$pro_covar_value) > 0) { + pro_covar_train <- stanfit$pro_covar[which(fold_ids != f), ] + pro_covar_test <- stanfit$pro_covar[which(fold_ids == f), ] } # fit the new model - fit.mod <- fit_dfa(y = y_train, + fit.mod <- fit_dfa( + y = y_train, num_trends = stanfit$sampling_args$data$K, varIndx = stanfit$sampling_args$data$varIndx, zscore = stanfit$zscore, @@ -103,7 +103,7 @@ dfa_cv <- function(stanfit, nu_fixed = stanfit$sampling_args$data$nu_fixed, est_correlation = stanfit$sampling_args$data$est_cor, estimate_nu = stanfit$sampling_args$data$estimate_nu, - estimate_trend_ar = ifelse(stanfit$sampling_args$data$est_phi==1, TRUE, FALSE), + estimate_trend_ar = ifelse(stanfit$sampling_args$data$est_phi == 1, TRUE, FALSE), estimate_trend_ma = ifelse(stanfit$sampling_args$data$est_theta == 1, TRUE, FALSE), estimate_process_sigma = ifelse(stanfit$sampling_args$data$est_sigma_process == 1, TRUE, FALSE), equal_process_sigma = ifelse(stanfit$sampling_args$data$n_sigma_process == 1, TRUE, FALSE), @@ -114,63 +114,67 @@ dfa_cv <- function(stanfit, z_bound = stanfit$z_bound, z_model = stanfit$z_model, trend_model = stanfit$trend_model, - verbose = FALSE) + verbose = FALSE + ) # extract posterior parameters for the training set pars <- rstan::extract(fit.mod$model) r <- rotate_trends(fit.mod) # loop over each iterations (mcmc sample) - for(j in 1:nrow(log_lik)) { + for (j in 1:nrow(log_lik)) { # determine if covariates are included - obs_covar_offset = rep(0, nrow(y_test)) - if(is.null(obs_covar_train) & is.null(pro_covar_train)) { - #pred <- pars$Z[j,,] %*% matrix(pars$x[j,,],nrow=stanfit$sampling_args$data$K) - pred <- r$Z_rot[j,,] %*% matrix(r$trends[j,,],nrow=stanfit$sampling_args$data$K) + obs_covar_offset <- rep(0, nrow(y_test)) + if (is.null(obs_covar_train) & is.null(pro_covar_train)) { + # pred <- pars$Z[j,,] %*% matrix(pars$x[j,,],nrow=stanfit$sampling_args$data$K) + pred <- r$Z_rot[j, , ] %*% matrix(r$trends[j, , ], nrow = stanfit$sampling_args$data$K) # subset predictions corresponding to observations - pred <- pred[cbind(y_test$ts,y_test$time)] - #pred = pars$Z[j,,] %*% matrix(pars$xstar[j,,],ncol=1) + pred <- pred[cbind(y_test$ts, y_test$time)] + # pred = pars$Z[j,,] %*% matrix(pars$xstar[j,,],ncol=1) } - if(!is.null(obs_covar_train) & is.null(pro_covar_train)) { - #pred = pars$Z[j,,] %*% matrix(pars$xstar[j,,],ncol=1) + pars$b_obs[j,,] * obs_covar_test$value - #pred <- pars$Z[j,,] %*% matrix(pars$x[j,,],nrow=stanfit$sampling_args$data$K) - pred <- r$Z_rot[j,,] %*% matrix(r$trends[j,,],nrow=stanfit$sampling_args$data$K) - pred <- pred[cbind(y_test$ts,y_test$time)] - for(i in 1:max(obs_covar_test$covariate)) { + if (!is.null(obs_covar_train) & is.null(pro_covar_train)) { + # pred = pars$Z[j,,] %*% matrix(pars$xstar[j,,],ncol=1) + pars$b_obs[j,,] * obs_covar_test$value + # pred <- pars$Z[j,,] %*% matrix(pars$x[j,,],nrow=stanfit$sampling_args$data$K) + pred <- r$Z_rot[j, , ] %*% matrix(r$trends[j, , ], nrow = stanfit$sampling_args$data$K) + pred <- pred[cbind(y_test$ts, y_test$time)] + for (i in 1:max(obs_covar_test$covariate)) { indx <- which(obs_covar_test$covariate == i) - pred <- pred + pars$b_obs[j,i,obs_covar_test$timeseries[indx]] * obs_covar_test$value[indx] + pred <- pred + pars$b_obs[j, i, obs_covar_test$timeseries[indx]] * obs_covar_test$value[indx] } } - log_lik[j,f] <- sum(dnorm(x = y_test$obs, + log_lik[j, f] <- sum(dnorm( + x = y_test$obs, mean = pred, - sd = pars$sigma[j,stanfit$sampling_args$data$varIndx], log=TRUE), na.rm=T) - #log_lik[j,k] = sum(dnorm(x = ytest, mean = pred, sd = pars$sigma[j,varIndx], log=TRUE), na.rm=T) + sd = pars$sigma[j, stanfit$sampling_args$data$varIndx], log = TRUE + ), na.rm = T) + # log_lik[j,k] = sum(dnorm(x = ytest, mean = pred, sd = pars$sigma[j,varIndx], log=TRUE), na.rm=T) } # Predictions now vary based on how the cross validation is done, and whether covariates used - #if(cv_method == "loocv") { - #} - #if(cv_method == "lfocv") { - # for(j in 1:nrow(log_lik)) { - # # loop over iterations - # if(is.null(obs_covar) & is.null(pro_covar)) { - # pred = pars$Z[j,,] %*% matrix(pars$xstar[j,,],ncol=1) - # } - # if(!is.null(obs_covar) & is.null(pro_covar)) { - # pred = pars$Z[j,,] %*% matrix(pars$xstar[j,,],ncol=1) + pars$b_obs[j,,] * covar_test$value - # } - # log_lik[j,k] = sum(dnorm(x = ytest, mean = pred, sd = pars$sigma[j,varIndx], log=TRUE), na.rm=T) - # } - #} - + # if(cv_method == "loocv") { + # } + # if(cv_method == "lfocv") { + # for(j in 1:nrow(log_lik)) { + # # loop over iterations + # if(is.null(obs_covar) & is.null(pro_covar)) { + # pred = pars$Z[j,,] %*% matrix(pars$xstar[j,,],ncol=1) + # } + # if(!is.null(obs_covar) & is.null(pro_covar)) { + # pred = pars$Z[j,,] %*% matrix(pars$xstar[j,,],ncol=1) + pars$b_obs[j,,] * covar_test$value + # } + # log_lik[j,k] = sum(dnorm(x = ytest, mean = pred, sd = pars$sigma[j,varIndx], log=TRUE), na.rm=T) + # } + # } } - elpds <- apply(log_lik,2,log_sum_exp) - elpd <- list("log_lik"=log_lik, + elpds <- apply(log_lik, 2, log_sum_exp) + elpd <- list( + "log_lik" = log_lik, "elpds" = elpds, - "elpd_kfold"=sum(elpds), - "se_elpd_kfold" = sqrt(length(elpds) * var(elpds))) + "elpd_kfold" = sum(elpds), + "se_elpd_kfold" = sqrt(length(elpds) * var(elpds)) + ) return(elpd) } diff --git a/R/dfa_fitted.R b/R/dfa_fitted.R index c3450d0..20a1ab9 100644 --- a/R/dfa_fitted.R +++ b/R/dfa_fitted.R @@ -18,11 +18,11 @@ dfa_fitted <- function(modelfit, conf_level = 0.95, names = NULL) { # pred and Y have same dimensions if data is wide - pred = predicted(modelfit) - n_mcmc = dim(pred)[1] - n_chains = dim(pred)[2] - n_years = dim(pred)[3] - n_ts = dim(pred)[4] + pred <- predicted(modelfit) + n_mcmc <- dim(pred)[1] + n_chains <- dim(pred)[2] + n_years <- dim(pred)[3] + n_ts <- dim(pred)[4] # this is the same for both data types df_pred <- data.frame( @@ -33,31 +33,33 @@ dfa_fitted <- function(modelfit, conf_level = 0.95, names = NULL) { "upper" = c(t(apply(pred, c(3, 4), quantile, (1 - conf_level) / 2))) ) - if(modelfit$shape == "wide") { + if (modelfit$shape == "wide") { df_obs <- data.frame( - "ID" = rep(seq_len(n_ts), n_years), - "time" = sort(rep(seq_len(n_years), n_ts)), - "y" = c(modelfit$orig_data)) + "ID" = rep(seq_len(n_ts), n_years), + "time" = sort(rep(seq_len(n_years), n_ts)), + "y" = c(modelfit$orig_data) + ) } else { df_obs <- data.frame( "ID" = modelfit$orig_data[["ts"]], "time" = modelfit$orig_data[["time"]], - "y" = modelfit$orig_data[["obs"]]) + "y" = modelfit$orig_data[["obs"]] + ) } df_obs$time <- df_obs$time - min(df_obs$time) + 1 # standardize - for(i in seq_len(n_ts)) { - indx = which(df_obs[["ID"]] == i) - df_obs[indx,"y"] = scale(df_obs[indx,"y" ], center = TRUE, scale = TRUE) + for (i in seq_len(n_ts)) { + indx <- which(df_obs[["ID"]] == i) + df_obs[indx, "y"] <- scale(df_obs[indx, "y"], center = TRUE, scale = TRUE) } df_obs <- df_obs[order(df_obs$ID, df_obs$time), ] df_pred <- df_pred[order(df_pred$ID, df_pred$time), ] if (!is.null(names)) { - if(length(names) != n_ts) { - warning("bayesdfa: Length of 'names' should match number of time series. Ignoring 'names'.") + if (length(names) != n_ts) { + warning("bayesdfa: Length of 'names' should match number of time series. Ignoring 'names'.") } else { df_pred$ID <- names[df_pred$ID] df_obs$ID <- names[df_obs$ID] @@ -66,5 +68,4 @@ dfa_fitted <- function(modelfit, conf_level = 0.95, names = NULL) { df <- merge(df_obs, df_pred, by = c("ID", "time"), sort = FALSE) return(df) - } diff --git a/R/dfa_loadings.R b/R/dfa_loadings.R index c1ec906..fc0c28b 100644 --- a/R/dfa_loadings.R +++ b/R/dfa_loadings.R @@ -23,18 +23,17 @@ #' r <- rotate_trends(m) #' loadings <- dfa_loadings(r, summary = TRUE) #' loadings <- dfa_loadings(r, summary = FALSE) - dfa_loadings <- function(rotated_modelfit, names = NULL, summary = TRUE, conf_level = 0.95) { - v <- reshape2::melt(rotated_modelfit$Z_rot, - varnames = c("iter", "name", "trend"), value.name = "loading") + varnames = c("iter", "name", "trend"), value.name = "loading" + ) v$draw <- as.numeric(gsub("_chain.*$", "", v$iter)) v$chain <- as.numeric(gsub("^[0-9]+_chain:", "", v$iter)) v$iter <- NULL - v <- v[ , c("chain", "draw", "name", "trend", "loading")] + v <- v[, c("chain", "draw", "name", "trend", "loading")] v$trend <- paste0("Trend ", v$trend) v$trend <- as.factor(v$trend) @@ -52,7 +51,7 @@ dfa_loadings <- function(rotated_modelfit, v <- as.data.frame(dplyr::ungroup(v)) out <- v - if(summary) { + if (summary) { vsum <- dplyr::group_by(v, .data$name, .data$trend) vsum <- dplyr::summarize(vsum, median = median(.data$loading), diff --git a/R/dfa_trends.R b/R/dfa_trends.R index 197e22f..4f37eff 100644 --- a/R/dfa_trends.R +++ b/R/dfa_trends.R @@ -15,7 +15,6 @@ #' r <- rotate_trends(m) #' trends <- dfa_trends(r) dfa_trends <- function(rotated_modelfit, years = NULL) { - rotated <- rotated_modelfit n_ts <- dim(rotated$Z_rot)[2] n_trends <- dim(rotated$Z_rot)[3] @@ -28,7 +27,8 @@ dfa_trends <- function(rotated_modelfit, years = NULL) { trend_number = paste0("Trend ", sort(rep(seq_len(n_trends), n_years))), estimate = c(t(rotated$trends_mean)), lower = c(t(rotated$trends_lower)), - upper = c(t(rotated$trends_upper))) + upper = c(t(rotated$trends_upper)) + ) return(df) } diff --git a/R/find_dfa_trends.R b/R/find_dfa_trends.R index ce0f92a..25f26f5 100644 --- a/R/find_dfa_trends.R +++ b/R/find_dfa_trends.R @@ -25,7 +25,8 @@ #' y = s$y_sim, iter = 50, #' kmin = 1, kmax = 2, chains = 1, compare_normal = FALSE, #' variance = "equal", convergence_threshold = 1.1, -#' control = list(adapt_delta = 0.95, max_treedepth = 20)) +#' control = list(adapt_delta = 0.95, max_treedepth = 20) +#' ) #' m$summary #' m$best_model #' } @@ -34,15 +35,14 @@ #' @importFrom rlang .data find_dfa_trends <- function(y = y, - kmin = 1, - kmax = 5, - iter = 2000, - thin = 1, - compare_normal = FALSE, - convergence_threshold = 1.05, - variance = c("equal", "unequal"), - ...) { - + kmin = 1, + kmax = 5, + iter = 2000, + thin = 1, + compare_normal = FALSE, + convergence_threshold = 1.05, + variance = c("equal", "unequal"), + ...) { df <- data.frame( model = seq(1, ifelse(compare_normal == FALSE, length(variance) * length(seq(kmin, kmax)), @@ -72,10 +72,10 @@ find_dfa_trends <- function(y = y, # relative effective sample size log_lik <- loo::extract_log_lik(model$model, merge_chains = FALSE) - n_chains <- dim(rstan::extract(model$model, "log_lik", permuted=FALSE))[2] + n_chains <- dim(rstan::extract(model$model, "log_lik", permuted = FALSE))[2] rel_eff <- loo::relative_eff(exp(log_lik)) # calculate looic - df$looic[indx] <- loo::loo(log_lik, r_eff = rel_eff)$estimates["looic",1] + df$looic[indx] <- loo::loo(log_lik, r_eff = rel_eff)$estimates["looic", 1] # if model is best, keep it if (df$looic[indx] < best_loo & df$converge[indx] == TRUE) { @@ -97,10 +97,10 @@ find_dfa_trends <- function(y = y, df$num_trends[indx] <- i log_lik <- loo::extract_log_lik(model$model, merge_chains = FALSE) - n_chains <- dim(rstan::extract(model$model, "log_lik", permuted=FALSE))[2] + n_chains <- dim(rstan::extract(model$model, "log_lik", permuted = FALSE))[2] rel_eff <- loo::relative_eff(exp(log_lik)) # calculate looic - df$looic[indx] <- loo::loo(log_lik, r_eff = rel_eff)$estimates["looic",1] + df$looic[indx] <- loo::loo(log_lik, r_eff = rel_eff)$estimates["looic", 1] df$converge[indx] <- is_converged(model, convergence_threshold) # if model is best, keep it @@ -125,10 +125,10 @@ find_dfa_trends <- function(y = y, df$num_trends[indx] <- i log_lik <- loo::extract_log_lik(model$model, merge_chains = FALSE) - n_chains <- dim(rstan::extract(model$model, "log_lik", permuted=FALSE))[2] + n_chains <- dim(rstan::extract(model$model, "log_lik", permuted = FALSE))[2] rel_eff <- loo::relative_eff(exp(log_lik)) # calculate looic - df$looic[indx] <- loo::loo(log_lik, r_eff = rel_eff)$estimates["looic",1] + df$looic[indx] <- loo::loo(log_lik, r_eff = rel_eff)$estimates["looic", 1] df$converge[indx] <- is_converged(model, convergence_threshold) # if model is best, keep it @@ -138,8 +138,8 @@ find_dfa_trends <- function(y = y, } df$error[indx] <- "normal" df$cor[indx] <- "equal" - #df$max_rhat[indx] <- max(as.data.frame(summary(model$model)$summary)[,"Rhat"]) - #df$min_neff[indx] <- min(as.data.frame(summary(model$model)$summary)[,"n_eff"]) + # df$max_rhat[indx] <- max(as.data.frame(summary(model$model)$summary)[,"Rhat"]) + # df$min_neff[indx] <- min(as.data.frame(summary(model$model)$summary)[,"n_eff"]) indx <- indx + 1 } } @@ -153,10 +153,10 @@ find_dfa_trends <- function(y = y, df$num_trends[indx] <- i log_lik <- loo::extract_log_lik(model$model, merge_chains = FALSE) - n_chains <- dim(rstan::extract(model$model, "log_lik", permuted=FALSE))[2] + n_chains <- dim(rstan::extract(model$model, "log_lik", permuted = FALSE))[2] rel_eff <- loo::relative_eff(exp(log_lik)) # calculate looic - df$looic[indx] <- loo::loo(log_lik, r_eff = rel_eff)$estimates["looic",1] + df$looic[indx] <- loo::loo(log_lik, r_eff = rel_eff)$estimates["looic", 1] df$converge[indx] <- is_converged(model, convergence_threshold) # if model is best, keep it @@ -166,8 +166,8 @@ find_dfa_trends <- function(y = y, } df$error[indx] <- "normal" df$cor[indx] <- "independent" - #df$max_rhat[indx] <- max(as.data.frame(summary(model$model)$summary)[,"Rhat"]) - #df$min_neff[indx] <- min(as.data.frame(summary(model$model)$summary)[,"n_eff"]) + # df$max_rhat[indx] <- max(as.data.frame(summary(model$model)$summary)[,"Rhat"]) + # df$min_neff[indx] <- min(as.data.frame(summary(model$model)$summary)[,"n_eff"]) indx <- indx + 1 } } diff --git a/R/find_regimes.R b/R/find_regimes.R index 56bf7c3..204acf2 100644 --- a/R/find_regimes.R +++ b/R/find_regimes.R @@ -16,16 +16,14 @@ #' @examples #' data(Nile) #' find_regimes(log(Nile), iter = 50, chains = 1, max_regimes = 2) - find_regimes <- function(y, - sds = NULL, - min_regimes = 1, - max_regimes = 3, - iter = 2000, - thin = 1, - chains = 1, - ...) { - + sds = NULL, + min_regimes = 1, + max_regimes = 3, + iter = 2000, + thin = 1, + chains = 1, + ...) { df <- data.frame(regimes = seq(min_regimes, max_regimes), looic = NA) best_loo <- 1.0e10 best_model <- NA @@ -35,9 +33,9 @@ find_regimes <- function(y, chains = chains, ... ) looic <- loo.bayesdfa(fit) - loo_bad <- loo::pareto_k_table(looic)["(0.7, 1]","Count"] - loo_very_bad <- loo::pareto_k_table(looic)["(1, Inf)","Count"] - df$looic[which(df$regimes == regime)] = looic$estimates["looic", "Estimate"] + loo_bad <- loo::pareto_k_table(looic)["(0.7, 1]", "Count"] + loo_very_bad <- loo::pareto_k_table(looic)["(1, Inf)", "Count"] + df$looic[which(df$regimes == regime)] <- looic$estimates["looic", "Estimate"] if (fit$looic < best_loo) { best_loo <- fit$looic @@ -47,6 +45,8 @@ find_regimes <- function(y, } } - list(table = df, best_model = best_model, n_loo_bad = n_loo_bad, - n_loo_very_bad = n_loo_very_bad) + list( + table = df, best_model = best_model, n_loo_bad = n_loo_bad, + n_loo_very_bad = n_loo_very_bad + ) } diff --git a/R/find_swans.R b/R/find_swans.R index 6e56427..f0fe753 100644 --- a/R/find_swans.R +++ b/R/find_swans.R @@ -14,7 +14,7 @@ #' set.seed(1) #' s <- sim_dfa(num_trends = 1, num_ts = 3, num_years = 30) #' s$y_sim[1, 15] <- s$y_sim[1, 15] - 6 -#' plot(s$y_sim[1,], type = "o") +#' plot(s$y_sim[1, ], type = "o") #' abline(v = 15, col = "red") #' # only 1 chain and 250 iterations used so example runs quickly: #' m <- fit_dfa(y = s$y_sim, num_trends = 1, iter = 50, chains = 1, nu_fixed = 2) @@ -23,7 +23,6 @@ #' print(p) #' # a 1 in 1000 probability if was from a normal distribution: #' find_swans(r, plot = TRUE, threshold = 0.001) -#' #' @references #' Anderson, S.C., Branch, T.A., Cooper, A.B., and Dulvy, N.K. 2017. #' Black-swan events in animal populations. Proceedings of the National Academy @@ -33,9 +32,8 @@ #' @importFrom stats pnorm find_swans <- function(rotated_modelfit, - threshold = 0.01, - plot = FALSE) { - + threshold = 0.01, + plot = FALSE) { x <- rotated_modelfit$trends_mean d <- apply(x, 1, function(xx) c(NA, diff(xx))) sds <- apply(d, 2, sd, na.rm = TRUE) # sds != 1 @@ -63,7 +61,8 @@ find_swans <- function(rotated_modelfit, x = "time", y = "trend_value", color = "below_threshold" )) + - geom_point() + facet_wrap(~ trend_number) + geom_point() + + facet_wrap(~trend_number) print(g) } invisible(trends) diff --git a/R/fit_dfa.R b/R/fit_dfa.R index b08f8e2..cb6912a 100644 --- a/R/fit_dfa.R +++ b/R/fit_dfa.R @@ -65,6 +65,7 @@ #' @param gp_theta_prior A 2-element vector controlling the prior on the Gaussian process parameter in cov_exp_quad. #' This prior is a half-Student t prior, with the first argument of gp_theta_prior being the degrees of freedom (nu), #' and the second element being the standard deviation +#' @param expansion_prior Defaults to FALSE, if TRUE uses the parameter expansion prior of Ghosh & Dunson 2009 #' @param ... Any other arguments to pass to [rstan::sampling()]. #' @param par_list A vector of parameter names of variables to be estimated by Stan. If NULL, this will default to #' c("x", "Z", "sigma", "log_lik", "psi","xstar") for most models -- though if AR / MA, or Student-t models are used @@ -93,54 +94,54 @@ #' s <- sim_dfa(num_trends = 1, num_years = 20, num_ts = 3) #' # only 1 chain and 250 iterations used so example runs quickly: #' m <- fit_dfa(y = s$y_sim, iter = 50, chains = 1) -#'\dontrun{ +#' \dontrun{ #' # example of observation error covariates #' set.seed(42) -#' obs_covar = expand.grid("time"=1:20,"timeseries"=1:3,"covariate"=1) -#' obs_covar$value=rnorm(nrow(obs_covar),0,0.1) -#' m <- fit_dfa(y = s$y_sim, iter = 50, chains = 1, obs_covar=obs_covar) +#' obs_covar <- expand.grid("time" = 1:20, "timeseries" = 1:3, "covariate" = 1) +#' obs_covar$value <- rnorm(nrow(obs_covar), 0, 0.1) +#' m <- fit_dfa(y = s$y_sim, iter = 50, chains = 1, obs_covar = obs_covar) #' #' # example of process error covariates -#' pro_covar = expand.grid("time"=1:20,"trend"=1:2,"covariate"=1) -#' pro_covar$value=rnorm(nrow(pro_covar),0,0.1) -#' m <- fit_dfa(y = s$y_sim, iter = 50, chains = 1, num_trends = 2, pro_covar=pro_covar) +#' pro_covar <- expand.grid("time" = 1:20, "trend" = 1:2, "covariate" = 1) +#' pro_covar$value <- rnorm(nrow(pro_covar), 0, 0.1) +#' m <- fit_dfa(y = s$y_sim, iter = 50, chains = 1, num_trends = 2, pro_covar = pro_covar) #' #' # example of long format data #' s <- sim_dfa(num_trends = 1, num_years = 20, num_ts = 3) -#' obs <- c(s$y_sim[1,], s$y_sim[2,], s$y_sim[3,]) -#' long = data.frame("obs" = obs, "ts" = sort(rep(1:3,20)), "time" = rep(1:20,3)) -#' m = fit_dfa(y = long, data_shape = "long", iter = 50, chains = 1) +#' obs <- c(s$y_sim[1, ], s$y_sim[2, ], s$y_sim[3, ]) +#' long <- data.frame("obs" = obs, "ts" = sort(rep(1:3, 20)), "time" = rep(1:20, 3)) +#' m <- fit_dfa(y = long, data_shape = "long", iter = 50, chains = 1) #' #' # example of long format data with obs covariates #' s <- sim_dfa(num_trends = 1, num_years = 20, num_ts = 3) -#' obs <- c(s$y_sim[1,], s$y_sim[2,], s$y_sim[3,]) -#' long = data.frame("obs" = obs, "ts" = sort(rep(1:3,20)), "time" = rep(1:20,3)) -#' obs_covar = expand.grid("time"=1:20,"timeseries"=1:3,"covariate"=1:2) -#' obs_covar$value=rnorm(nrow(obs_covar),0,0.1) -#' m = fit_dfa(y = long, data_shape = "long", iter = 50, chains = 1,obs_covar=obs_covar) +#' obs <- c(s$y_sim[1, ], s$y_sim[2, ], s$y_sim[3, ]) +#' long <- data.frame("obs" = obs, "ts" = sort(rep(1:3, 20)), "time" = rep(1:20, 3)) +#' obs_covar <- expand.grid("time" = 1:20, "timeseries" = 1:3, "covariate" = 1:2) +#' obs_covar$value <- rnorm(nrow(obs_covar), 0, 0.1) +#' m <- fit_dfa(y = long, data_shape = "long", iter = 50, chains = 1, obs_covar = obs_covar) #' #' # example of model with Z constrained to be proportions and wide format data #' s <- sim_dfa(num_trends = 1, num_years = 20, num_ts = 3) -#' m = fit_dfa(y = s$y_sim, z_model = "proportion", iter = 50, chains = 1) +#' m <- fit_dfa(y = s$y_sim, z_model = "proportion", iter = 50, chains = 1) #' #' # example of model with Z constrained to be proportions and long format data #' s <- sim_dfa(num_trends = 1, num_years = 20, num_ts = 3) -#' obs <- c(s$y_sim[1,], s$y_sim[2,], s$y_sim[3,]) -#' long = data.frame("obs" = obs, "ts" = sort(rep(1:3,20)), "time" = rep(1:20,3)) -#' m = fit_dfa(y = long, data_shape = "long", z_model = "proportion", iter = 50, chains = 1) +#' obs <- c(s$y_sim[1, ], s$y_sim[2, ], s$y_sim[3, ]) +#' long <- data.frame("obs" = obs, "ts" = sort(rep(1:3, 20)), "time" = rep(1:20, 3)) +#' m <- fit_dfa(y = long, data_shape = "long", z_model = "proportion", iter = 50, chains = 1) #' #' #' # example of B-spline model with wide format data #' s <- sim_dfa(num_trends = 1, num_years = 20, num_ts = 3) -#' m = fit_dfa(y = s$y_sim, iter = 50, chains = 1, trend_model = "spline", n_knots = 10) +#' m <- fit_dfa(y = s$y_sim, iter = 50, chains = 1, trend_model = "spline", n_knots = 10) #' #' # example of B-spline model with wide format data #' s <- sim_dfa(num_trends = 1, num_years = 20, num_ts = 3) -#' m = fit_dfa(y = s$y_sim, iter = 50, chains = 1, trend_model = "gp", n_knots = 5) -#'} +#' m <- fit_dfa(y = s$y_sim, iter = 50, chains = 1, trend_model = "gp", n_knots = 5) +#' } fit_dfa <- function(y = y, num_trends = 1, varIndx = NULL, - scale = c("zscore","center","none"), + scale = c("zscore", "center", "none"), iter = 2000, chains = 4, thin = 1, @@ -157,31 +158,34 @@ fit_dfa <- function(y = y, obs_covar = NULL, pro_covar = NULL, z_bound = NULL, - z_model = c("dfa","proportion"), - trend_model = c("rw","spline","gp"), + z_model = c("dfa", "proportion"), + trend_model = c("rw", "spline", "gp"), n_knots = NULL, knot_locs = NULL, par_list = NULL, family = "gaussian", verbose = FALSE, - gp_theta_prior = c(3,1), + gp_theta_prior = c(3, 1), + expansion_prior = FALSE, ...) { # check arguments - data_shape <- match.arg(data_shape, c("wide","long")) - z_model <- match.arg(z_model, c("dfa","proportion")) - trend_model <- match.arg(trend_model, c("rw","spline","gp")) + data_shape <- match.arg(data_shape, c("wide", "long")) + z_model <- match.arg(z_model, c("dfa", "proportion")) + trend_model <- match.arg(trend_model, c("rw", "spline", "gp")) - obs_model <- match(family, c("gaussian", "gamma", "poisson", "nbinom2", - "binomial", "lognormal")) - if(is.na(obs_model)) { + obs_model <- match(family, c( + "gaussian", "gamma", "poisson", "nbinom2", + "binomial", "lognormal" + )) + if (is.na(obs_model)) { stop("Error: family not found. Please enter family as gaussian(), gamma(), etc.") } - if(family != "gaussian") { - if(data_shape=="wide") stop("Error: if family is non-gaussian, data must be in long format") - if(est_correlation == TRUE) stop("Error: correlation can't be estimated with non-gaussian data. Please set est_correlation=FALSE") + if (family != "gaussian") { + if (data_shape == "wide") stop("Error: if family is non-gaussian, data must be in long format") + if (est_correlation == TRUE) stop("Error: correlation can't be estimated with non-gaussian data. Please set est_correlation=FALSE") } - orig_data = y # save original data + orig_data <- y # save original data if (ncol(y) < nrow(y) && data_shape[1] == "wide") { warning( @@ -190,45 +194,47 @@ fit_dfa <- function(y = y, ) } if (data_shape[1] == "long") { - if(est_correlation==TRUE) { + if (est_correlation == TRUE) { stop("Estimation of the observation error correlation matrix not currently estimated when data are in long format") } - if(length(which(names(y)=="ts"))==0) { + if (length(which(names(y) == "ts")) == 0) { stop("Error: data shape is long, and must contain a field 'ts' representing time series dimension") } - if(length(which(names(y)=="time"))==0) { + if (length(which(names(y) == "time")) == 0) { stop("Error: data shape is long, and must contain a field 'time' representing time dimension") } - if(length(which(names(y)=="obs"))==0) { + if (length(which(names(y) == "obs")) == 0) { stop("Error: data shape is long, and must contain a field 'obs' representing observations") } # rescale if needed - #y$time <- y$time - min(y[["time"]]) + 1 # min time now = 1 + # y$time <- y$time - min(y[["time"]]) + 1 # min time now = 1 y$ts <- as.numeric(as.factor(y[["ts"]])) N <- max(y[["time"]]) P <- max(y[["ts"]]) } - if(data_shape[1]=="wide") { + if (data_shape[1] == "wide") { N <- ncol(y) # number of time steps P <- nrow(y) # number of time series if (nrow(y) < 3) { - stop("fit_dfa() only works with 3 or more time series. We detected ", - nrow(y), " time series.") + stop( + "fit_dfa() only works with 3 or more time series. We detected ", + nrow(y), " time series." + ) } } - if(!is.null(obs_covar)) { - if(ncol(obs_covar) != 4) { + if (!is.null(obs_covar)) { + if (ncol(obs_covar) != 4) { stop("observation covariates must be in a data frame with 4 columns") } } - if(!is.null(pro_covar)) { - if(ncol(pro_covar) != 4) { + if (!is.null(pro_covar)) { + if (ncol(pro_covar) != 4) { stop("process covariates must be in a data frame with 4 columns") } } - if(!is.null(z_bound) && length(z_bound)!=2) { + if (!is.null(z_bound) && length(z_bound) != 2) { stop("if you're using z bounds, this needs to be a 2-element vector") } @@ -237,10 +243,10 @@ fit_dfa <- function(y = y, nZ <- P * K - sum(seq_len(K)) # number of non-zero parameters that are unconstrained # standardizing data by rows only works if data provided in "wide" format - if(family == "gaussian") { - if(data_shape[1] == "wide") { + if (family == "gaussian") { + if (data_shape[1] == "wide") { for (i in seq_len(P)) { - if (scale[1]=="zscore") { + if (scale[1] == "zscore") { if (length(unique(na.omit(c(y[i, ])))) == 1L) { stop("Can't scale one or more of the time series because all values ", "are the same. Remove this/these time series or set `scale` = `center`.", @@ -249,23 +255,23 @@ fit_dfa <- function(y = y, } y[i, ] <- scale(y[i, ], center = TRUE, scale = TRUE) } - if(scale[1]=="center") { + if (scale[1] == "center") { y[i, ] <- scale(y[i, ], center = TRUE, scale = FALSE) } } } else { - if(scale[1]=="zscore") { + if (scale[1] == "zscore") { # standardize - for(i in seq_len(P)) { - indx = which(y[["ts"]] == i) - y[indx,"obs"] = scale(y[indx,"obs" ], center = TRUE, scale = TRUE) + for (i in seq_len(P)) { + indx <- which(y[["ts"]] == i) + y[indx, "obs"] <- scale(y[indx, "obs"], center = TRUE, scale = TRUE) } } - if(scale[1]=="center") { + if (scale[1] == "center") { # just center - for(i in seq_len(P)) { - indx = which(y[["ts"]] == i) - y[indx,"obs"] = scale(y[indx, "obs"], center = TRUE, scale = FALSE) + for (i in seq_len(P)) { + indx <- which(y[["ts"]] == i) + y[indx, "obs"] <- scale(y[indx, "obs"], center = TRUE, scale = FALSE) } } } @@ -300,7 +306,7 @@ fit_dfa <- function(y = y, nVariances <- length(unique(varIndx)) # indices of positive values - Stan can't handle NAs - if(data_shape[1] == "wide") { + if (data_shape[1] == "wide") { row_indx_pos <- matrix(rep(seq_len(P), N), P, N)[!is.na(y)] col_indx_pos <- matrix(sort(rep(seq_len(N), P)), P, N)[!is.na(y)] n_pos <- length(row_indx_pos) @@ -309,15 +315,15 @@ fit_dfa <- function(y = y, n_na <- length(row_indx_na) y <- y[!is.na(y)] } else { - y = y[which(!is.na(y[["obs"]])),] - row_indx_pos = y[["ts"]] - col_indx_pos = y[["time"]] - n_pos = length(row_indx_pos) + y <- y[which(!is.na(y[["obs"]])), ] + row_indx_pos <- y[["ts"]] + col_indx_pos <- y[["time"]] + n_pos <- length(row_indx_pos) # these are just dummy placeholders - row_indx_na = matrix(1,1,1)[is.na(runif(1))] - col_indx_na = matrix(1,1,1)[is.na(runif(1))] + row_indx_na <- matrix(1, 1, 1)[is.na(runif(1))] + col_indx_na <- matrix(1, 1, 1)[is.na(runif(1))] n_na <- length(row_indx_na) - y = y[["obs"]] + y <- y[["obs"]] } # flag for whether to use a normal dist @@ -325,80 +331,86 @@ fit_dfa <- function(y = y, if (estimate_nu) use_normal <- 0 # competing flags # covariates - if(!is.null(obs_covar)) { - obs_covar_index <- as.matrix(obs_covar[,c("time","timeseries","covariate")]) + if (!is.null(obs_covar)) { + obs_covar_index <- as.matrix(obs_covar[, c("time", "timeseries", "covariate")]) num_obs_covar <- nrow(obs_covar_index) - n_obs_covar <- length(unique(obs_covar_index[,"covariate"])) - obs_covar_value <- obs_covar[,"value"] + n_obs_covar <- length(unique(obs_covar_index[, "covariate"])) + obs_covar_value <- obs_covar[, "value"] - if(data_shape[1] == "wide") { + if (data_shape[1] == "wide") { match_obs_covar <- rep(0, num_obs_covar) } else { - match_obs_covar <- match(paste(obs_covar$time,obs_covar$timeseries), paste(Y$time[which(!is.na(Y$obs))],Y$ts[which(!is.na(Y$obs))])) + match_obs_covar <- match(paste(obs_covar$time, obs_covar$timeseries), paste(Y$time[which(!is.na(Y$obs))], Y$ts[which(!is.na(Y$obs))])) + keep <- which(!is.na(match_obs_covar)) + # keep covariates not associated with missing values + obs_covar_index <- obs_covar_index[keep, ] + num_obs_covar <- nrow(obs_covar_index) + n_obs_covar <- length(unique(obs_covar_index[, "covariate"])) + obs_covar_value <- obs_covar[keep, "value"] + # keep matches + match_obs_covar <- match_obs_covar[keep] } - } else { num_obs_covar <- 0 n_obs_covar <- 0 obs_covar_value <- c(0)[0] match_obs_covar <- c(0)[0] - obs_covar_index <- matrix(0,1,3)[c(0)[0],] + obs_covar_index <- matrix(0, 1, 3)[c(0)[0], ] } - if(!is.null(pro_covar)) { - pro_covar_index <- as.matrix(pro_covar[,c("time","trend","covariate")]) + if (!is.null(pro_covar)) { + pro_covar_index <- as.matrix(pro_covar[, c("time", "trend", "covariate")]) num_pro_covar <- nrow(pro_covar_index) - n_pro_covar <- length(unique(pro_covar_index[,"covariate"])) - pro_covar_value <- pro_covar[,"value"] - + n_pro_covar <- length(unique(pro_covar_index[, "covariate"])) + pro_covar_value <- pro_covar[, "value"] } else { num_pro_covar <- 0 n_pro_covar <- 0 pro_covar_value <- c(0)[0] - pro_covar_index <- matrix(0,1,3)[c(0)[0],] + pro_covar_index <- matrix(0, 1, 3)[c(0)[0], ] } - if(is.null(z_bound)) { - z_bound <- c(-100,100) + if (is.null(z_bound)) { + z_bound <- c(-100, 100) } n_sigma_process <- 1 - if(equal_process_sigma == FALSE) n_sigma_process <- K + if (equal_process_sigma == FALSE) n_sigma_process <- K est_sigma_process <- 0 - if(estimate_process_sigma == TRUE) est_sigma_process <- 1 + if (estimate_process_sigma == TRUE) est_sigma_process <- 1 # default args that need to be passed in est_spline <- 0 est_gp <- 0 est_rw <- 1 # these are flags specifying model structure. default is rw - if(is.null(n_knots)) n_knots <- round(N/3) - if(is.null(knot_locs)) knot_locs = seq(1,N,length.out=n_knots) + if (is.null(n_knots)) n_knots <- round(N / 3) + if (is.null(knot_locs)) knot_locs <- seq(1, N, length.out = n_knots) distKnots <- matrix(0, n_knots, n_knots) - #distKnots21 <- matrix(0, N, n_knots) + # distKnots21 <- matrix(0, N, n_knots) distKnots21_pred <- rep(0, n_knots) # set up cubic b-splines design matrix B_spline <- matrix(0, n_knots, N) - if(trend_model == "spline") { + if (trend_model == "spline") { est_spline <- 1 est_rw <- 0 # turn of things conventionally estimated when trend is a random walk estimate_trend_ar <- FALSE estimate_trend_ma <- FALSE estimate_nu <- FALSE - B_spline <- t(splines::bs(1:N, df=n_knots, degree = 3, intercept = TRUE)) + B_spline <- t(splines::bs(1:N, df = n_knots, degree = 3, intercept = TRUE)) } - if(trend_model == "gp") { + if (trend_model == "gp") { # Gaussian kernel - est_gp = 1 + est_gp <- 1 est_rw <- 0 - if(is.null(knot_locs)) knot_locs = seq(1,N,length.out=n_knots) - distKnots = as.matrix(stats::dist(knot_locs)) # distances between time stamps - distAll = as.matrix(stats::dist(c(1:N,knot_locs))) # distances between data and knot locs - #distKnots21 <- t(distAll[-seq_len(N), 1:N]) - distKnots21_pred <- as.matrix(stats::dist(c(N+1,knot_locs)))[1,-1] - #distKnots <- distKnots ^ 2 - #distKnots21 <- distKnots21 ^ 2 - distKnots21_pred <- distKnots21_pred ^ 2 + if (is.null(knot_locs)) knot_locs <- seq(1, N, length.out = n_knots) + distKnots <- as.matrix(stats::dist(knot_locs)) # distances between time stamps + distAll <- as.matrix(stats::dist(c(1:N, knot_locs))) # distances between data and knot locs + # distKnots21 <- t(distAll[-seq_len(N), 1:N]) + distKnots21_pred <- as.matrix(stats::dist(c(N + 1, knot_locs)))[1, -1] + # distKnots <- distKnots ^ 2 + # distKnots21 <- distKnots21 ^ 2 + distKnots21_pred <- distKnots21_pred^2 est_sigma_process <- 1 # turn this on as a scale for variance estimate_trend_ar <- FALSE estimate_trend_ma <- FALSE @@ -406,12 +418,12 @@ fit_dfa <- function(y = y, } y_int <- rep(0, length(y)) - if(family %in% c("binomial", "nbinom2", "poisson")) { - y_int = as.integer(y) + if (family %in% c("binomial", "nbinom2", "poisson")) { + y_int <- as.integer(y) } - est_sigma_params <- ifelse(family %in% c("gaussian","lognormal"), 1, 0); - est_gamma_params <- ifelse(family=="gamma",1,0); - est_nb2_params <- ifelse(family=="nbinom2",1,0); + est_sigma_params <- ifelse(family %in% c("gaussian", "lognormal"), 1, 0) + est_gamma_params <- ifelse(family == "gamma", 1, 0) + est_nb2_params <- ifelse(family == "nbinom2", 1, 0) data_list <- list( N = N, @@ -449,8 +461,8 @@ fit_dfa <- function(y = y, pro_covar_value = pro_covar_value, pro_covar_index = pro_covar_index, z_bound = z_bound, - long_format = ifelse(data_shape[1]=="wide",0,1), - proportional_model = ifelse(z_model[1]=="dfa",0,1), + long_format = ifelse(data_shape[1] == "wide", 0, 1), + proportional_model = ifelse(z_model[1] == "dfa", 0, 1), est_sigma_process = est_sigma_process, n_sigma_process = n_sigma_process, est_rw = est_rw, @@ -459,39 +471,41 @@ fit_dfa <- function(y = y, n_knots = n_knots, knot_locs = knot_locs, est_gp = est_gp, - #distKnots = distKnots, - #distKnots21 = distKnots21, + # distKnots = distKnots, + # distKnots21 = distKnots21, obs_model = obs_model, - distKnots21_pred = matrix(distKnots21_pred,nrow=1), + distKnots21_pred = matrix(distKnots21_pred, nrow = 1), est_sigma_params = est_sigma_params, est_gamma_params = est_gamma_params, est_nb2_params = est_nb2_params, - gp_theta_prior = gp_theta_prior + gp_theta_prior = gp_theta_prior, + use_expansion_prior = as.integer(expansion_prior) ) - if(is.null(par_list)) { - pars <- c("x", "Z", "log_lik", "psi","xstar") + if (is.null(par_list)) { + pars <- c("x", "Z", "log_lik", "xstar") + if (expansion_prior) pars <- c(pars, "psi") } else { - pars = par_list + pars <- par_list } # family - if(family %in% c("gaussian","lognormal")) pars <- c(pars, "sigma") - if(family %in% c("gamma")) pars <- c(pars, "gamma_a") - if(family %in% c("nbinom2")) pars <- c(pars, "nb2_phi") + if (family %in% c("gaussian", "lognormal")) pars <- c(pars, "sigma") + if (family %in% c("gamma")) pars <- c(pars, "gamma_a") + if (family %in% c("nbinom2")) pars <- c(pars, "nb2_phi") if (est_correlation) pars <- c(pars, "Omega", "Sigma") # add correlation matrix if (estimate_nu) pars <- c(pars, "nu") if (estimate_trend_ar) pars <- c(pars, "phi") if (estimate_trend_ma) pars <- c(pars, "theta") - if(!is.null(obs_covar)) pars <- c(pars, "b_obs") - if(!is.null(pro_covar)) pars <- c(pars, "b_pro") - if(est_sigma_process) pars <- c(pars, "sigma_process") - if(trend_model=="gp") pars <- c(pars, "gp_theta") + if (!is.null(obs_covar)) pars <- c(pars, "b_obs") + if (!is.null(pro_covar)) pars <- c(pars, "b_pro") + if (est_sigma_process) pars <- c(pars, "sigma_process") + if (trend_model == "gp") pars <- c(pars, "gp_theta") - if(!is.null(par_list)) { - if(par_list[1]=="all") { - pars <- NA # removed pred + if (!is.null(par_list)) { + if (par_list[1] == "all") { + pars <- NA # removed pred } } @@ -521,6 +535,7 @@ fit_dfa <- function(y = y, ) } } + out[["sampling_args"]] <- sampling_args out[["orig_data"]] <- orig_data out[["shape"]] <- data_shape @@ -536,4 +551,3 @@ fit_dfa <- function(y = y, out <- structure(out, class = "bayesdfa") out } - diff --git a/R/fit_regimes.R b/R/fit_regimes.R index 86bf5f6..636d094 100644 --- a/R/fit_regimes.R +++ b/R/fit_regimes.R @@ -23,15 +23,13 @@ #' @examples #' data(Nile) #' fit_regimes(log(Nile), iter = 50, n_regimes = 1) - fit_regimes <- function(y, - sds = NULL, - n_regimes = 2, - iter = 2000, - thin = 1, - chains = 1, - ...) { - + sds = NULL, + n_regimes = 2, + iter = 2000, + thin = 1, + chains = 1, + ...) { est_sigma <- 0 if (is.null(sds)) { # estimate sigma, instead of using fixed values @@ -51,7 +49,8 @@ fit_regimes <- function(y, pars = c("mu_k", "sigma_k", "log_lik") ) - m <- rstan::sampling(object=stanmodels$regime_1, + m <- rstan::sampling( + object = stanmodels$regime_1, data = stan_data, iter = iter, chains = chains, @@ -76,7 +75,8 @@ fit_regimes <- function(y, ) ) - m <- rstan::sampling(object=stanmodels$hmm_gaussian, + m <- rstan::sampling( + object = stanmodels$hmm_gaussian, data = stan_data, iter = iter, thin = thin, @@ -88,11 +88,11 @@ fit_regimes <- function(y, ) } - log_lik <- loo::extract_log_lik(m, merge_chains=FALSE) - #n_chains = dim(rstan::extract(m, "log_lik", permuted=FALSE))[2] + log_lik <- loo::extract_log_lik(m, merge_chains = FALSE) + # n_chains = dim(rstan::extract(m, "log_lik", permuted=FALSE))[2] rel_eff <- loo::relative_eff(exp(log_lik)) # calculate looic - looic <- loo::loo(log_lik, r_eff = rel_eff)$estimates["looic",1] + looic <- loo::loo(log_lik, r_eff = rel_eff)$estimates["looic", 1] list(model = m, y = y, looic = looic) } diff --git a/R/invert_chains.R b/R/invert_chains.R index 5f3c76c..8bea5e6 100644 --- a/R/invert_chains.R +++ b/R/invert_chains.R @@ -20,21 +20,19 @@ #' m <- fit_dfa(y = s$y_sim, num_trends = 1, iter = 30, chains = 2) #' # chains were already inverted, but we can redo that, as an example, with: #' find_inverted_chains(m$model, plot = TRUE) - find_inverted_chains <- function(model, trend = 1, plot = FALSE) { - - chains = NULL # required for dplyr 0.8 update - parameters = NULL - value = NULL + chains <- NULL # required for dplyr 0.8 update + parameters <- NULL + value <- NULL e <- rstan::extract(model, permuted = FALSE) v <- reshape2::melt(e) vv <- v[grepl(paste0("x\\[", trend), v$parameters), ] - vv$parameters = as.factor(as.character(vv$parameters)) # needed with dplyr 0.8, all levels returned otherwise + vv$parameters <- as.factor(as.character(vv$parameters)) # needed with dplyr 0.8, all levels returned otherwise vv <- dplyr::group_by(vv, chains, parameters) vv <- dplyr::summarise(vv, estimate = stats::median(value)) zz <- v[grepl(paste0("Z\\["), v$parameters), ] - zz$parameters = as.factor(as.character(zz$parameters)) # needed with dplyr 0.8, all levels returned otherwise + zz$parameters <- as.factor(as.character(zz$parameters)) # needed with dplyr 0.8, all levels returned otherwise zz <- zz[grepl(paste0(trend, "]"), zz$parameters), ] zz <- dplyr::group_by(zz, chains, parameters) zz <- dplyr::summarise(zz, estimate = stats::median(value)) @@ -71,11 +69,11 @@ find_inverted_chains <- function(model, trend = 1, plot = FALSE) { (sum((pred1_loadings - pred0_loadings)^2) + sum((pred1_trend - pred0_trend)^2))) { # flip this chain -- seems to be something not right with commented out line - #flipped_chains <- ifelse(flipped_chains == 0, i, c(flipped_chains, i)) - if(flipped_chains==0) { - flipped_chains = i + # flipped_chains <- ifelse(flipped_chains == 0, i, c(flipped_chains, i)) + if (flipped_chains == 0) { + flipped_chains <- i } else { - flipped_chains = c(flipped_chains, i) + flipped_chains <- c(flipped_chains, i) } } } @@ -106,10 +104,10 @@ invert_chains <- function(model, trends = 1, print = FALSE, ...) { for (f_ in f) { for (i in grep(paste0("x\\[", k), pars)) { - e[, f_, i] <- -1*e[, f_, i] + e[, f_, i] <- -1 * e[, f_, i] } for (i in grep(paste0("Z\\[[0-9]+,", k, "\\]"), pars)) { - e[, f_, i] <- -1*e[, f_, i] + e[, f_, i] <- -1 * e[, f_, i] } } } diff --git a/R/loo.R b/R/loo.R index 8331382..f7639bc 100644 --- a/R/loo.R +++ b/R/loo.R @@ -30,7 +30,8 @@ loo.bayesdfa <- function(x, ...) { loo::loo.array(log_lik, r_eff = rel_eff, save_psis = FALSE, - ...) + ... + ) } #' @name loo diff --git a/R/plot_fitted.R b/R/plot_fitted.R index 2308d30..01212f0 100644 --- a/R/plot_fitted.R +++ b/R/plot_fitted.R @@ -22,33 +22,33 @@ #' print(p) #' } plot_fitted <- function(modelfit, conf_level = 0.95, names = NULL, spaghetti = FALSE) { - df <- dfa_fitted(modelfit, conf_level = conf_level, names = names) df$ID <- as.factor(df$ID) - if(spaghetti == TRUE) { - + if (spaghetti == TRUE) { cols <- viridis(length(unique((df$ID))), end = 0.8) p1 <- ggplot(df) + - geom_line(aes_string(x = "time", y = "y", group = "ID"), - color = "grey50", size = 0.5) + - geom_line(aes_string(x = "time", y = "estimate", group = "ID", color = "ID"), - size = 1.2) + - scale_color_manual(values = cols) + - xlab("Time") + - theme(legend.position = "none") - + geom_line(aes_string(x = "time", y = "y", group = "ID"), + color = "grey50", size = 0.5 + ) + + geom_line(aes_string(x = "time", y = "estimate", group = "ID", color = "ID"), + size = 1.2 + ) + + scale_color_manual(values = cols) + + xlab("Time") + + theme(legend.position = "none") } else { - p1 <- ggplot(df) + geom_ribbon(aes_string(x = "time", ymin = "lower", ymax = "upper"), alpha = 0.4) + geom_line(aes_string(x = "time", y = "estimate")) + geom_point(aes_string(x = "time", y = "y"), col = "red", size = 0.5, - alpha = 0.4) + + alpha = 0.4 + ) + facet_wrap("ID", scales = "free_y") + - xlab("Time") + ylab("") + xlab("Time") + + ylab("") } p1 } diff --git a/R/plot_loadings.R b/R/plot_loadings.R index e2a4d9e..3cfb1b4 100644 --- a/R/plot_loadings.R +++ b/R/plot_loadings.R @@ -30,22 +30,22 @@ #' plot_loadings(r, violin = FALSE, facet = FALSE) #' plot_loadings(r, violin = TRUE, facet = FALSE) #' plot_loadings(r, violin = TRUE, facet = TRUE) - plot_loadings <- function(rotated_modelfit, names = NULL, facet = TRUE, violin = TRUE, conf_level = 0.95, - threshold=NULL) { - + threshold = NULL) { v <- dfa_loadings(rotated_modelfit, - summary = FALSE, - names = names, - conf_level = conf_level) + summary = FALSE, + names = names, + conf_level = conf_level + ) df <- dfa_loadings(rotated_modelfit, - summary = TRUE, - names = names, - conf_level = conf_level) + summary = TRUE, + names = names, + conf_level = conf_level + ) # filter values below threshold if (!is.null(threshold)) { @@ -63,7 +63,9 @@ plot_loadings <- function(rotated_modelfit, position = position_dodge(0.3), width = 0 ) + geom_hline(yintercept = 0, lty = 2) + - coord_flip() + xlab("Time Series") + ylab("Loading") + coord_flip() + + xlab("Time Series") + + ylab("Loading") } if (violin) { @@ -73,11 +75,13 @@ plot_loadings <- function(rotated_modelfit, )) + geom_violin(color = NA) + geom_hline(yintercept = 0, lty = 2) + - coord_flip() + xlab("Time Series") + ylab("Loading") + coord_flip() + + xlab("Time Series") + + ylab("Loading") } if (facet) { - p1 <- p1 + facet_wrap(~ trend, scales = "free_x") + p1 <- p1 + facet_wrap(~trend, scales = "free_x") } p1 diff --git a/R/plot_regime_model.R b/R/plot_regime_model.R index e4b60ca..c966cb9 100644 --- a/R/plot_regime_model.R +++ b/R/plot_regime_model.R @@ -19,10 +19,10 @@ #' data(Nile) #' m <- fit_regimes(log(Nile), n_regimes = 2, chains = 1, iter = 50) #' plot_regime_model(m) -#' plot_regime_model(m, plot_prob_indices=c(2)) +#' plot_regime_model(m, plot_prob_indices = c(2)) #' plot_regime_model(m, type = "means") #' } - +#' plot_regime_model <- function(model, probs = c(0.05, 0.95), type = c("probability", "means"), regime_prob_threshold = 0.9, @@ -39,8 +39,9 @@ plot_regime_model <- function(model, probs = c(0.05, 0.95), mu_k_low <- apply(mu_k, 2, quantile, probs = probs[[1]]) mu_k_high <- apply(mu_k, 2, quantile, probs = probs[[2]]) mu_k <- apply(mu_k, 2, median) - confident_regimes <- apply(gamma_tk, 2:3, function(x) - mean(x > 0.5) > regime_prob_threshold) + confident_regimes <- apply(gamma_tk, 2:3, function(x) { + mean(x > 0.5) > regime_prob_threshold + }) regime_indexes <- apply(confident_regimes, 1, function(x) { w <- which(x) if (length(w) == 0) NA else w diff --git a/R/plot_trends.R b/R/plot_trends.R index e93f653..6610987 100644 --- a/R/plot_trends.R +++ b/R/plot_trends.R @@ -20,20 +20,20 @@ #' r <- rotate_trends(m) #' p <- plot_trends(r) #' print(p) - plot_trends <- function(rotated_modelfit, - years = NULL, - highlight_outliers = FALSE, - threshold = 0.01) { - + years = NULL, + highlight_outliers = FALSE, + threshold = 0.01) { rotated <- rotated_modelfit df <- dfa_trends(rotated, years = years) # make faceted ribbon plot of trends p1 <- ggplot(df, aes_string(x = "time", y = "estimate")) + geom_ribbon(aes_string(ymin = "lower", ymax = "upper"), alpha = 0.4) + - geom_line() + facet_wrap("trend_number") + - xlab("Time") + ylab("") + geom_line() + + facet_wrap("trend_number") + + xlab("Time") + + ylab("") if (highlight_outliers) { swans <- find_swans(rotated, threshold = threshold) diff --git a/R/predicted.R b/R/predicted.R index c8a4878..90f50ad 100644 --- a/R/predicted.R +++ b/R/predicted.R @@ -11,14 +11,14 @@ #' set.seed(42) #' s <- sim_dfa(num_trends = 1, num_years = 20, num_ts = 3) #' # only 1 chain and 1000 iterations used so example runs quickly: -#' m <- fit_dfa(y = s$y_sim, iter = 2000, chains = 3, num_trends=1) +#' m <- fit_dfa(y = s$y_sim, iter = 2000, chains = 3, num_trends = 1) #' pred <- predicted(m) #' } predicted <- function(fitted_model) { - Z <- rstan::extract(fitted_model$model, "Z", permuted=FALSE) - x <- rstan::extract(fitted_model$model, "x", permuted=FALSE) - Zperm <- rstan::extract(fitted_model$model, "Z", permuted=TRUE) - xperm <- rstan::extract(fitted_model$model, "x", permuted=TRUE) + Z <- rstan::extract(fitted_model$model, "Z", permuted = FALSE) + x <- rstan::extract(fitted_model$model, "x", permuted = FALSE) + Zperm <- rstan::extract(fitted_model$model, "Z", permuted = TRUE) + xperm <- rstan::extract(fitted_model$model, "x", permuted = TRUE) n_ts <- dim(Zperm$Z)[2] n_y <- dim(xperm$x)[3] @@ -27,12 +27,12 @@ predicted <- function(fitted_model) { n_mcmc <- dim(x)[1] pred <- array(0, c(n_mcmc, n_chains, n_y, n_ts)) - for(i in 1:n_mcmc) { - for(chain in 1:n_chains) { + for (i in 1:n_mcmc) { + for (chain in 1:n_chains) { # for each MCMC draw / chain - x_i <- t(matrix(x[i,chain,], nrow=n_trends, ncol=n_y)) - Z_i <- t(matrix(Z[i,chain,], nrow=n_ts, ncol=n_trends)) - pred[i,chain,,] <- x_i %*% Z_i + x_i <- t(matrix(x[i, chain, ], nrow = n_trends, ncol = n_y)) + Z_i <- t(matrix(Z[i, chain, ], nrow = n_ts, ncol = n_trends)) + pred[i, chain, , ] <- x_i %*% Z_i } } diff --git a/R/rotate_trends.R b/R/rotate_trends.R index 024aaa4..6a0d554 100644 --- a/R/rotate_trends.R +++ b/R/rotate_trends.R @@ -15,13 +15,12 @@ #' m <- fit_dfa(y = s$y_sim, iter = 50, chains = 1) #' r <- rotate_trends(m) #' plot_trends(r) - rotate_trends <- function(fitted_model, conf_level = 0.95, invert = FALSE) { # get the inverse of the rotation matrix n_mcmc <- dim(fitted_model$samples)[2] * dim(fitted_model$samples)[1] - flip <- ifelse(invert==FALSE, 1, -1) + flip <- ifelse(invert == FALSE, 1, -1) temp <- reshape_samples(fitted_model$samples) Z <- temp$Z diff --git a/R/sim.R b/R/sim.R index 9581924..b4da6cb 100644 --- a/R/sim.R +++ b/R/sim.R @@ -39,14 +39,17 @@ #' #' set.seed(42) #' x <- sim_dfa(extreme_value = -4, extreme_loc = 10) -#' matplot(t(x$x), type = "l");abline(v = 10) -#' matplot(t(x$pred), type = "l");abline(v = 10) +#' matplot(t(x$x), type = "l") +#' abline(v = 10) +#' matplot(t(x$pred), type = "l") +#' abline(v = 10) #' #' set.seed(42) #' x <- sim_dfa() -#' matplot(t(x$x), type = "l");abline(v = 10) -#' matplot(t(x$pred), type = "l");abline(v = 10) -#' +#' matplot(t(x$x), type = "l") +#' abline(v = 10) +#' matplot(t(x$pred), type = "l") +#' abline(v = 10) #' @export sim_dfa <- function(num_trends = 1, @@ -65,7 +68,7 @@ sim_dfa <- function(num_trends = 1, y_ignore <- matrix(rnorm(num_ts * num_years), nrow = num_ts, ncol = num_years) d <- fit_dfa(y_ignore, - num_trends = num_trends, sample = FALSE, scale="center", + num_trends = num_trends, sample = FALSE, scale = "center", varIndx = varIndx, nu_fixed = nu_fixed, trend_model = "rw" ) @@ -86,9 +89,8 @@ sim_dfa <- function(num_trends = 1, # initial state for each trend for (k in seq_len(d$sampling_args$data$K)) { - if (!is.null(user_supplied_deviations)) { - devs <- user_supplied_deviations[,k] + devs <- user_supplied_deviations[, k] } else { devs <- rt(d$sampling_args$data$N, df = d$sampling_args$data$nu_fixed) } diff --git a/R/trend_cor.R b/R/trend_cor.R index 788cd0b..0267001 100644 --- a/R/trend_cor.R +++ b/R/trend_cor.R @@ -35,23 +35,25 @@ #' s <- sim_dfa(num_trends = 1, num_years = 15) #' m <- fit_dfa(y = s$y_sim, num_trends = 1, iter = 50, chains = 1) #' r <- rotate_trends(m) -#' n_years <- ncol(r$trends[,1,]) +#' n_years <- ncol(r$trends[, 1, ]) #' fake_dat <- rnorm(n_years, 0, 1) #' correlation <- trend_cor(r, fake_dat, trend_samples = 25) #' hist(correlation) -#' correlation <- trend_cor(r, y = fake_dat, time_window = 5:15, -#' trend_samples = 25) +#' correlation <- trend_cor(r, +#' y = fake_dat, time_window = 5:15, +#' trend_samples = 25 +#' ) #' hist(correlation) #' @export trend_cor <- function(rotated_modelfit, - y, - trend = 1, - time_window = seq_len(length(y)), - trend_samples = 100, - stan_iter = 300, - stan_chains = 1, - ...) { + y, + trend = 1, + time_window = seq_len(length(y)), + trend_samples = 100, + stan_iter = 300, + stan_chains = 1, + ...) { # must be even to cleanly divide by 2 later: @@ -67,7 +69,8 @@ trend_cor <- function(rotated_modelfit, out <- vapply(seq_len(length(samples)), FUN = function(i) { xi <- as.numeric(scale(as.numeric(x[samples[i], ]))) - m <- rstan::sampling(object=stanmodels$corr, + m <- rstan::sampling( + object = stanmodels$corr, data = list(x = xi, y = y, N = length(y)), iter = stan_iter, chains = stan_chains, warmup = stan_iter / 2, ... ) diff --git a/docs/404.html b/docs/404.html index 24c26d7..660d11a 100644 --- a/docs/404.html +++ b/docs/404.html @@ -71,7 +71,7 @@ bayesdfa - 1.0.0 + 1.1.0 diff --git a/docs/articles/bayesdfa.html b/docs/articles/bayesdfa.html index 09d5b04..86c3e1b 100644 --- a/docs/articles/bayesdfa.html +++ b/docs/articles/bayesdfa.html @@ -31,7 +31,7 @@ bayesdfa - 1.0.0 + 1.1.0 @@ -97,7 +97,7 @@

Overview of the bayesdfa package

Eric J. Ward, Sean C. Anderson, Mary E. Hunsicker, Mike A. Litzow, Luis A. Damiano, Mark D. Scheuerell, Elizabeth E. Holmes, Nick Tolimieri

-

2021-05-18

+

2021-05-25

Source: vignettes/bayesdfa.Rmd @@ -200,10 +200,10 @@

 round(r2$Z_rot_mean, 2)
##        [,1]    [,2]
-## [1,]   1.25   -0.84
-## [2,] -60.06   40.73
-## [3,]  77.03 -112.99
-## [4,]  51.76  -30.41
+## [1,] -90.54 -41.89 +## [2,] -19.10 -117.64 +## [3,] -7.55 58.95 +## [4,] -49.06 15.14

These loadings can also be plotted with the plot_loadings() function. This shows the distribution of the densities as violin plots, with color proportional to being different from 0.

 plot_loadings(r2) + theme_bw()
@@ -217,10 +217,10 @@

loo1 <- loo(f1) loo1$estimates
##               Estimate           SE
-## elpd_loo -2.719423e+04 5.625610e+03
-## p_loo    -1.998401e-15 1.094370e-15
-## looic     5.438846e+04 1.125122e+04
-

where 5.438846210^{4} is the estimate and 1.12512210^{4} is the standard error.

+## elpd_loo -2.973137e+04 6.859515e+03 +## p_loo -2.220446e-16 2.107833e-15 +## looic 5.946275e+04 1.371903e+04 +

where 5.946274510^{4} is the estimate and 1.37190310^{4} is the standard error.

As an alternative to fitting each model individually as we did above, we also developed the find_dfa_trends() to automate fitting a larger number of models. In addition to evaluating different trends, this function allows the user to optionally evaluate models with normal and Student-t process errors, and alternative variance structures (observation variance of time series being equal, or not). For example, to fit models with 1:5 trends, both Student-t and normal errors, and equal and unequal variances, the call would be

 m <- find_dfa_trends(
@@ -290,13 +290,13 @@ 

We can also look at the estimated nu parameter, which shows some support for using the Student-t distribution (values greater than ~ 30 lead to similar behavior as a normal distribution),

 summary(rstan::extract(t2$model, "nu")[[1]])
-
##        V1       
-##  Min.   :2.364  
-##  1st Qu.:2.364  
-##  Median :2.364  
-##  Mean   :2.364  
-##  3rd Qu.:2.364  
-##  Max.   :2.364
+
##        V1      
+##  Min.   :2.82  
+##  1st Qu.:2.82  
+##  Median :2.82  
+##  Mean   :2.82  
+##  3rd Qu.:2.82  
+##  Max.   :2.82

diff --git a/docs/articles/bayesdfa_files/figure-html/fit-extreme-dfa-1.png b/docs/articles/bayesdfa_files/figure-html/fit-extreme-dfa-1.png index a1981f3..d92b49a 100644 Binary files a/docs/articles/bayesdfa_files/figure-html/fit-extreme-dfa-1.png and b/docs/articles/bayesdfa_files/figure-html/fit-extreme-dfa-1.png differ diff --git a/docs/articles/bayesdfa_files/figure-html/plot-1-fitted-example-1.png b/docs/articles/bayesdfa_files/figure-html/plot-1-fitted-example-1.png index ef9d36e..357dba7 100644 Binary files a/docs/articles/bayesdfa_files/figure-html/plot-1-fitted-example-1.png and b/docs/articles/bayesdfa_files/figure-html/plot-1-fitted-example-1.png differ diff --git a/docs/articles/bayesdfa_files/figure-html/plot-1-trend-1.png b/docs/articles/bayesdfa_files/figure-html/plot-1-trend-1.png index 15f3dde..01d630b 100644 Binary files a/docs/articles/bayesdfa_files/figure-html/plot-1-trend-1.png and b/docs/articles/bayesdfa_files/figure-html/plot-1-trend-1.png differ diff --git a/docs/articles/bayesdfa_files/figure-html/plot-2-fitted-example-1.png b/docs/articles/bayesdfa_files/figure-html/plot-2-fitted-example-1.png index b0938af..f131464 100644 Binary files a/docs/articles/bayesdfa_files/figure-html/plot-2-fitted-example-1.png and b/docs/articles/bayesdfa_files/figure-html/plot-2-fitted-example-1.png differ diff --git a/docs/articles/bayesdfa_files/figure-html/plot-extreme-loadings-1.png b/docs/articles/bayesdfa_files/figure-html/plot-extreme-loadings-1.png index 75d5367..b9ff0a4 100644 Binary files a/docs/articles/bayesdfa_files/figure-html/plot-extreme-loadings-1.png and b/docs/articles/bayesdfa_files/figure-html/plot-extreme-loadings-1.png differ diff --git a/docs/articles/bayesdfa_files/figure-html/plot-loadings-1.png b/docs/articles/bayesdfa_files/figure-html/plot-loadings-1.png index 0ae5a00..fbb878b 100644 Binary files a/docs/articles/bayesdfa_files/figure-html/plot-loadings-1.png and b/docs/articles/bayesdfa_files/figure-html/plot-loadings-1.png differ diff --git a/docs/articles/combining_data.html b/docs/articles/combining_data.html index 0344049..b26aeba 100644 --- a/docs/articles/combining_data.html +++ b/docs/articles/combining_data.html @@ -31,7 +31,7 @@ bayesdfa - 1.0.0 + 1.1.0

@@ -97,7 +97,7 @@

Combining data with bayesdfa

Eric J. Ward, Sean C. Anderson, Mary E. Hunsicker, Mike A. Litzow, Luis A. Damiano, Mark D. Scheuerell, Elizabeth E. Holmes, Nick Tolimieri

-

2021-05-18

+

2021-05-25

Source: vignettes/combining_data.Rmd @@ -151,10 +151,10 @@

r = rotate_trends(fit_1)
 round(r$Z_rot_mean,3)
-
##       1
-## 1 2.535
-## 2 4.551
-## 3 1.412
+
##         1
+## 1 -98.567
+## 2 -15.488
+## 3  19.395

Now, we’ll pretend that in time steps 1:50 we have observations from time series 1 (but not the others). We’ll fit several additional models, adding in back data points in steps of 10, and going backwards in time. All these runs would use time points 51:100 for time series 2 and 3, but they would include time steps 51:100, then 41:100, 31:100, etc. for time series 1.

Note for comparison purposes, we’ll also standardize all time series 1 time before passing them in as an argument. Time series # 1 won’t be re-scaled, but will be re-centered for each iteration. This is important because the time-series are non-stationary.

diff --git a/docs/articles/combining_data_files/figure-html/unnamed-chunk-8-1.png b/docs/articles/combining_data_files/figure-html/unnamed-chunk-8-1.png
index 3b97551..3558bbc 100644
Binary files a/docs/articles/combining_data_files/figure-html/unnamed-chunk-8-1.png and b/docs/articles/combining_data_files/figure-html/unnamed-chunk-8-1.png differ
diff --git a/docs/articles/combining_data_files/figure-html/unnamed-chunk-9-1.png b/docs/articles/combining_data_files/figure-html/unnamed-chunk-9-1.png
index ba62264..b6eabd0 100644
Binary files a/docs/articles/combining_data_files/figure-html/unnamed-chunk-9-1.png and b/docs/articles/combining_data_files/figure-html/unnamed-chunk-9-1.png differ
diff --git a/docs/articles/compositional.html b/docs/articles/compositional.html
index c32e50a..29a04c4 100644
--- a/docs/articles/compositional.html
+++ b/docs/articles/compositional.html
@@ -31,7 +31,7 @@
       
       
         bayesdfa
-        1.0.0
+        1.1.0
       
     
@@ -97,7 +97,7 @@

Fitting compositional dynamic factor models with bayesdfa

Eric J. Ward, Sean C. Anderson, Mary E. Hunsicker, Mike A. Litzow, Luis A. Damiano, Mark D. Scheuerell, Elizabeth E. Holmes, Nick Tolimieri

-

2021-05-18

+

2021-05-25

Source: vignettes/compositional.Rmd @@ -146,11 +146,11 @@

print(rounded_Z[,c(2,1)])
##       
 ##        [,1] [,2]
-##   [1,] 0.99 0.01
-##   [2,] 0.96 0.04
-##   [3,] 0.02 0.98
-##   [4,] 0.19 0.81
-##   [5,] 0.79 0.21
+## [1,] 0.98 0.02 +## [2,] 0.97 0.03 +## [3,] 0.01 0.99 +## [4,] 0.18 0.82 +## [5,] 0.76 0.24

Combining the estimated trends and true trends in the simulation shows that the trends are offset by an intercept, but track the overall simulated values very well (time series 1 represents the estimated trend trying to recover the true trend indicated with time series 3, time series 2 represents the estimated trend trying to recover the true trend indicated with time series 4)

 x = apply(pars$x, c(2,3), mean)[c(2,1),]
diff --git a/docs/articles/compositional_files/figure-html/unnamed-chunk-12-1.png b/docs/articles/compositional_files/figure-html/unnamed-chunk-12-1.png
index 8918861..8fb2255 100644
Binary files a/docs/articles/compositional_files/figure-html/unnamed-chunk-12-1.png and b/docs/articles/compositional_files/figure-html/unnamed-chunk-12-1.png differ
diff --git a/docs/articles/compositional_files/figure-html/unnamed-chunk-7-1.png b/docs/articles/compositional_files/figure-html/unnamed-chunk-7-1.png
index f4077cc..d845c83 100644
Binary files a/docs/articles/compositional_files/figure-html/unnamed-chunk-7-1.png and b/docs/articles/compositional_files/figure-html/unnamed-chunk-7-1.png differ
diff --git a/docs/articles/covariates.html b/docs/articles/covariates.html
index 29020a9..19d9c02 100644
--- a/docs/articles/covariates.html
+++ b/docs/articles/covariates.html
@@ -31,7 +31,7 @@
       
       
         bayesdfa
-        1.0.0
+        1.1.0
       
     
@@ -97,7 +97,7 @@

Examples of including covariates with bayesdfa

Eric J. Ward, Sean C. Anderson, Mary E. Hunsicker, Mike A. Litzow, Luis A. Damiano, Mark D. Scheuerell, Elizabeth E. Holmes, Nick Tolimieri

-

2021-05-18

+

2021-05-25

Source: vignettes/covariates.Rmd diff --git a/docs/articles/covariates_files/figure-html/unnamed-chunk-5-1.png b/docs/articles/covariates_files/figure-html/unnamed-chunk-5-1.png index 5e096fd..7eec8fe 100644 Binary files a/docs/articles/covariates_files/figure-html/unnamed-chunk-5-1.png and b/docs/articles/covariates_files/figure-html/unnamed-chunk-5-1.png differ diff --git a/docs/articles/estimate_process_sigma.html b/docs/articles/estimate_process_sigma.html index 32c8604..7e1de32 100644 --- a/docs/articles/estimate_process_sigma.html +++ b/docs/articles/estimate_process_sigma.html @@ -31,7 +31,7 @@ bayesdfa - 1.0.0 + 1.1.0 @@ -97,7 +97,7 @@

Estimating process trend variability with bayesdfa

Eric J. Ward, Sean C. Anderson, Mary E. Hunsicker, Mike A. Litzow, Luis A. Damiano, Mark D. Scheuerell, Elizabeth E. Holmes, Nick Tolimieri

-

2021-05-18

+

2021-05-25

Source: vignettes/estimate_process_sigma.Rmd @@ -206,43 +206,43 @@

The estimated loadings from the DFA where the trends are forced to have the same fixed variance are good

 print(round(r1$Z_rot_mean,2))
-
##        [,1]   [,2]
-## [1,]   5.47  -1.12
-## [2,] -47.55  11.24
-## [3,] -53.02  36.55
-## [4,]   4.51 -19.23
+
##        [,1]    [,2]
+## [1,] -91.70  -32.20
+## [2,] -10.27 -109.07
+## [3,]  42.34  -12.66
+## [4,] -28.00   -7.90

but some of the loadings are far off. These loadings are also not well estimated for either of the models that estimate the process variances,

 print(round(r2$Z_rot_mean,2))
-
##       [,1]  [,2]
-## [1,]  0.10  0.00
-## [2,] -0.09  8.19
-## [3,] -0.35  1.73
-## [4,]  0.40 11.18
+
##        [,1]    [,2]
+## [1,] -70.20   68.36
+## [2,] -14.61 -118.64
+## [3,] -66.64    9.32
+## [4,] -47.34  -10.62

or

 print(round(r3$Z_rot_mean,2))
##         [,1]   [,2]
-## [1,]    1.21   0.87
-## [2,] -124.53 -84.54
-## [3,]  -47.60 -98.89
-## [4,] -129.04 -53.41
+## [1,] -92.62 37.23 +## [2,] -100.07 -64.45 +## [3,] -3.13 -44.88 +## [4,] -83.12 -29.19

The loadings for Model 4 are given by

 print(round(r4$Z_rot_mean,2))
-
##       [,1]   [,2]
-## [1,]  3.46  -0.32
-## [2,]  9.05  -0.73
-## [3,] -3.52 -30.51
-## [4,]  1.81  -3.40
+
##        [,1]   [,2]
+## [1,] -99.51   5.65
+## [2,]  -7.46 -98.49
+## [3,]   8.32   2.71
+## [4,]   1.16   0.06

and Model 5 by

 print(round(r5$Z_rot_mean,2))
-
##         [,1]   [,2]
-## [1,]    6.25   4.94
-## [2,] -103.69 -81.06
-## [3,]   49.81  82.37
-## [4,] -119.48 -63.72
+
##        [,1]    [,2]
+## [1,] -89.54  -26.98
+## [2,] -19.58 -107.16
+## [3,]  44.17   66.35
+## [4,] -47.99  -90.43

If we calculate the RMSE of the different models, model # 3 (estimated process trends, raw data not standardized) performs the best

@@ -252,23 +252,23 @@

- + - + - + - + - +
16983.132924263.24
2200.170730917.61
354128.902133873.93
41133.354319927.94
544316.366537172.58
@@ -285,23 +285,23 @@

1 -1424.2040 +321.8506 2 -512.6400 +199.0063 3 -206.4361 +311.6231 4 -408.9431 +128.4473 5 -1171.1708 +320.6021 diff --git a/docs/articles/index.html b/docs/articles/index.html index 1caaaee..2375ef5 100644 --- a/docs/articles/index.html +++ b/docs/articles/index.html @@ -71,7 +71,7 @@ bayesdfa - 1.0.0 + 1.1.0 diff --git a/docs/authors.html b/docs/authors.html index b5befd5..cf0030b 100644 --- a/docs/authors.html +++ b/docs/authors.html @@ -71,7 +71,7 @@ bayesdfa - 1.0.0 + 1.1.0 diff --git a/docs/index.html b/docs/index.html index 4ee141f..5de8be6 100644 --- a/docs/index.html +++ b/docs/index.html @@ -38,7 +38,7 @@ bayesdfa - 1.0.0 + 1.1.0 diff --git a/docs/news/index.html b/docs/news/index.html index 03fc752..e3eb604 100644 --- a/docs/news/index.html +++ b/docs/news/index.html @@ -71,7 +71,7 @@ bayesdfa - 1.0.0 + 1.1.0 @@ -193,6 +193,22 @@

  • Added non-gaussian families (poisson, negative binomial, bernoulli, Gamma, lognormal). Also included a function for doing cross validation and calculating the expected log posterior density. Another new feature included smooth models (Gaussian process, B-splines) as alternative models for trends conventionally modeled as random walks. Added functions dfa_trends(), dfa_loadings() and dfa_fitted() for extracting trends, loadings, and fitted values.
+ +
+

+bayesdfa 1.0.0 2021-05-19 +

+
    +
  • Added constraint on diagonal of Z matrix to keep parameter estimates from ‘flipping’ within MCMC chains. Ensures convergence for problematic cases. This was present in 0.1.1, but later removed.
  • +
+
+
+

+bayesdfa 1.1.0 Unreleased +

+
    +
  • Following 1.0.0, included a new argument to fit_dfa() function ‘expansion_prior’ that allows user to toggle on / off the constraint. If not included (default=FALSE), there is no constraint on the Z diagonal, and post-hoc MCMC chain inverting resolves identifiability. If ‘expansion_prior’ = TRUE, then the positive constraint is applied, in combination with the expansion prior for trends and loadings.
  • +
diff --git a/docs/pkgdown.yml b/docs/pkgdown.yml index cd3d037..4d139d0 100644 --- a/docs/pkgdown.yml +++ b/docs/pkgdown.yml @@ -7,5 +7,5 @@ articles: compositional: compositional.html covariates: covariates.html estimate_process_sigma: estimate_process_sigma.html -last_built: 2021-05-18T20:31Z +last_built: 2021-05-25T13:09Z diff --git a/docs/reference/Rplot001.png b/docs/reference/Rplot001.png index 75100d5..9bdc743 100644 Binary files a/docs/reference/Rplot001.png and b/docs/reference/Rplot001.png differ diff --git a/docs/reference/Rplot002.png b/docs/reference/Rplot002.png index 78cff1a..10dd149 100644 Binary files a/docs/reference/Rplot002.png and b/docs/reference/Rplot002.png differ diff --git a/docs/reference/bayesdfa-package.html b/docs/reference/bayesdfa-package.html index 3d4cb9c..b8f3c7e 100644 --- a/docs/reference/bayesdfa-package.html +++ b/docs/reference/bayesdfa-package.html @@ -72,7 +72,7 @@ bayesdfa - 1.0.0 + 1.1.0 diff --git a/docs/reference/dfa_cv.html b/docs/reference/dfa_cv.html index f33fbd5..cd3daac 100644 --- a/docs/reference/dfa_cv.html +++ b/docs/reference/dfa_cv.html @@ -72,7 +72,7 @@ bayesdfa - 1.0.0 + 1.1.0 @@ -201,28 +201,28 @@

Examp
if (FALSE) { set.seed(42) s <- sim_dfa(num_trends = 1, num_years = 20, num_ts = 3) -obs <- c(s$y_sim[1,], s$y_sim[2,], s$y_sim[3,]) -long = data.frame("obs" = obs, "ts" = sort(rep(1:3,20)), "time" = rep(1:20,3)) -m <- fit_dfa(y = long, iter = 50, chains = 1, data_shape="long", sample=FALSE) +obs <- c(s$y_sim[1, ], s$y_sim[2, ], s$y_sim[3, ]) +long <- data.frame("obs" = obs, "ts" = sort(rep(1:3, 20)), "time" = rep(1:20, 3)) +m <- fit_dfa(y = long, iter = 50, chains = 1, data_shape = "long", sample = FALSE) # random folds -fit_cv = dfa_cv(m, cv_method="loocv", n_folds = 5, iter=50, chains=1) +fit_cv <- dfa_cv(m, cv_method = "loocv", n_folds = 5, iter = 50, chains = 1) # folds can also be passed in -fold_ids = sample(1:5, size=nrow(long), replace=TRUE) -m <- fit_dfa(y = long, iter = 50, chains = 1, data_shape="long", sample=FALSE) -fit_cv = dfa_cv(m, cv_method="loocv", n_folds = 5, iter=50, chains=1, fold_ids=fold_ids) +fold_ids <- sample(1:5, size = nrow(long), replace = TRUE) +m <- fit_dfa(y = long, iter = 50, chains = 1, data_shape = "long", sample = FALSE) +fit_cv <- dfa_cv(m, cv_method = "loocv", n_folds = 5, iter = 50, chains = 1, fold_ids = fold_ids) # do an example of leave-time-out cross validation where years are dropped -fold_ids = long$time -m <- fit_dfa(y = long, iter = 50, chains = 1, data_shape="long", sample=FALSE) -fit_cv = dfa_cv(m, cv_method="loocv", iter=100, chains=1, fold_ids = fold_ids) +fold_ids <- long$time +m <- fit_dfa(y = long, iter = 50, chains = 1, data_shape = "long", sample = FALSE) +fit_cv <- dfa_cv(m, cv_method = "loocv", iter = 100, chains = 1, fold_ids = fold_ids) # example with covariates and long format data -obs_covar = expand.grid("time"=1:20,"timeseries"=1:3,"covariate"=1:2) -obs_covar$value=rnorm(nrow(obs_covar),0,0.1) -obs <- c(s$y_sim[1,], s$y_sim[2,], s$y_sim[3,]) -m <- fit_dfa(y = long, iter = 50, chains = 1, obs_covar=obs_covar,data_shape="long", sample=FALSE) -fit_cv = dfa_cv(m, cv_method="loocv", n_folds = 5, iter=50, chains=1) +obs_covar <- expand.grid("time" = 1:20, "timeseries" = 1:3, "covariate" = 1:2) +obs_covar$value <- rnorm(nrow(obs_covar), 0, 0.1) +obs <- c(s$y_sim[1, ], s$y_sim[2, ], s$y_sim[3, ]) +m <- fit_dfa(y = long, iter = 50, chains = 1, obs_covar = obs_covar, data_shape = "long", sample = FALSE) +fit_cv <- dfa_cv(m, cv_method = "loocv", n_folds = 5, iter = 50, chains = 1) }
diff --git a/docs/reference/dfa_fitted.html b/docs/reference/dfa_fitted.html index 4bf7bf4..41fb158 100644 --- a/docs/reference/dfa_fitted.html +++ b/docs/reference/dfa_fitted.html @@ -72,7 +72,7 @@ bayesdfa - 1.0.0 + 1.1.0 @@ -177,8 +177,8 @@

Examp
#> #> SAMPLING FOR MODEL 'dfa' NOW (CHAIN 1). #> Chain 1: -#> Chain 1: Gradient evaluation took 0.000128 seconds -#> Chain 1: 1000 transitions using 10 leapfrog steps per transition would take 1.28 seconds. +#> Chain 1: Gradient evaluation took 0.000125 seconds +#> Chain 1: 1000 transitions using 10 leapfrog steps per transition would take 1.25 seconds. #> Chain 1: Adjust your expectations accordingly! #> Chain 1: #> Chain 1: @@ -203,10 +203,12 @@

Examp #> Chain 1: Iteration: 45 / 50 [ 90%] (Sampling) #> Chain 1: Iteration: 50 / 50 [100%] (Sampling) #> Chain 1: -#> Chain 1: Elapsed Time: 0.006084 seconds (Warm-up) -#> Chain 1: 0.012601 seconds (Sampling) -#> Chain 1: 0.018685 seconds (Total) -#> Chain 1:

#> Warning: There were 1 chains where the estimated Bayesian Fraction of Missing Information was low. See +#> Chain 1: Elapsed Time: 0.012032 seconds (Warm-up) +#> Chain 1: 0.105401 seconds (Sampling) +#> Chain 1: 0.117433 seconds (Total) +#> Chain 1:
#> Warning: There were 11 divergent transitions after warmup. See +#> http://mc-stan.org/misc/warnings.html#divergent-transitions-after-warmup +#> to find out why this is a problem and how to eliminate them.
#> Warning: There were 1 chains where the estimated Bayesian Fraction of Missing Information was low. See #> http://mc-stan.org/misc/warnings.html#bfmi-low
#> Warning: Examine the pairs() plot to diagnose sampling problems
#> Warning: The largest R-hat is NA, indicating chains have not mixed. #> Running the chains for more iterations may help. See #> http://mc-stan.org/misc/warnings.html#r-hat
#> Warning: Bulk Effective Samples Size (ESS) is too low, indicating posterior means and medians may be unreliable. @@ -215,141 +217,139 @@

Examp #> Running the chains for more iterations may help. See #> http://mc-stan.org/misc/warnings.html#tail-ess

#> Inference for the input samples (1 chains: each with iter = 25; warmup = 12): #> -#> Q5 Q50 Q95 Mean SD Rhat Bulk_ESS Tail_ESS -#> x[1,1] -0.7 -0.7 -0.7 -0.7 0.0 2.06 4 13 -#> x[2,1] -0.3 -0.3 -0.2 -0.2 0.0 1.87 7 13 -#> x[1,2] -0.9 -0.9 -0.8 -0.9 0.0 2.06 4 13 -#> x[2,2] 0.1 0.1 0.1 0.1 0.0 2.06 4 13 -#> x[1,3] -1.9 -1.8 -1.8 -1.9 0.0 2.06 4 13 -#> x[2,3] 0.5 0.5 0.5 0.5 0.0 2.06 4 13 -#> x[1,4] -0.6 -0.5 -0.5 -0.5 0.0 2.06 4 13 -#> x[2,4] 0.7 0.7 0.8 0.7 0.0 2.06 4 13 -#> x[1,5] 0.4 0.5 0.5 0.5 0.0 2.06 4 13 -#> x[2,5] -0.2 -0.2 -0.1 -0.2 0.0 2.06 4 13 -#> x[1,6] -0.7 -0.6 -0.6 -0.6 0.1 2.06 4 13 -#> x[2,6] -1.4 -1.4 -1.3 -1.4 0.1 2.06 4 13 -#> x[1,7] 0.6 0.8 0.8 0.7 0.1 2.06 4 13 -#> x[2,7] -1.7 -1.7 -1.5 -1.7 0.1 2.06 4 13 -#> x[1,8] 0.2 0.3 0.3 0.3 0.1 2.06 4 13 -#> x[2,8] -2.0 -2.0 -1.9 -2.0 0.1 2.06 4 13 -#> x[1,9] 0.4 0.6 0.6 0.5 0.1 2.06 4 13 -#> x[2,9] -2.6 -2.6 -2.4 -2.6 0.1 2.06 4 13 -#> x[1,10] -0.2 0.0 0.0 0.0 0.1 2.06 4 13 -#> x[2,10] -3.9 -3.9 -3.7 -3.9 0.1 2.06 4 13 -#> x[1,11] -0.6 -0.5 -0.5 -0.5 0.1 2.06 4 13 -#> x[2,11] -3.1 -3.1 -2.9 -3.1 0.1 2.06 4 13 -#> x[1,12] -1.8 -1.6 -1.6 -1.7 0.1 2.06 4 13 -#> x[2,12] -4.2 -4.2 -4.0 -4.2 0.1 2.06 4 13 -#> x[1,13] -2.6 -2.5 -2.5 -2.5 0.0 1.58 4 13 -#> x[2,13] -4.9 -4.8 -4.7 -4.8 0.1 2.06 4 13 -#> x[1,14] -3.0 -2.9 -2.9 -3.0 0.0 1.20 9 13 -#> x[2,14] -4.5 -4.5 -4.3 -4.5 0.1 2.06 4 13 -#> x[1,15] -4.3 -4.2 -4.2 -4.2 0.0 1.39 10 13 -#> x[2,15] -3.8 -3.8 -3.6 -3.7 0.1 2.06 4 13 -#> x[1,16] -5.3 -5.2 -5.2 -5.2 0.0 1.47 10 13 -#> x[2,16] -4.6 -4.6 -4.4 -4.5 0.1 2.06 4 13 -#> x[1,17] -5.9 -5.9 -5.9 -5.9 0.0 1.47 9 13 -#> x[2,17] -5.0 -5.0 -4.8 -4.9 0.1 2.06 4 13 -#> x[1,18] -7.0 -7.0 -7.0 -7.0 0.0 1.47 9 13 -#> x[2,18] -3.9 -3.9 -3.8 -3.9 0.1 2.06 4 13 -#> x[1,19] -7.3 -7.3 -7.3 -7.3 0.0 1.21 11 13 -#> x[2,19] -4.6 -4.6 -4.5 -4.6 0.0 2.06 3 13 -#> x[1,20] -6.6 -6.6 -6.5 -6.6 0.0 1.16 12 13 -#> x[2,20] -4.0 -4.0 -3.9 -4.0 0.0 2.06 3 13 -#> Z[1,1] 4.4 4.5 4.5 4.4 0.0 1.15 8 13 -#> Z[2,1] -5.5 14.9 18.2 11.4 8.8 2.06 3 13 -#> Z[3,1] -9.7 -9.3 -4.2 -8.2 2.3 2.06 4 13 -#> Z[4,1] -50.8 -49.0 -26.4 -44.4 10.1 2.06 3 13 -#> Z[1,2] 0.0 0.0 0.0 0.0 0.0 1.00 13 13 -#> Z[2,2] 0.8 0.8 0.8 0.8 0.0 2.06 13 13 -#> Z[3,2] 4.8 8.9 9.5 8.2 1.9 2.06 3 13 -#> Z[4,2] 29.8 50.2 51.3 46.0 9.2 2.06 3 13 -#> log_lik[1] -2.8 -2.4 -2.4 -2.5 0.1 2.06 3 13 -#> log_lik[2] -8.5 -5.9 -2.9 -5.9 2.1 2.06 3 13 -#> log_lik[3] -2.9 -2.8 -2.7 -2.8 0.1 2.06 4 13 -#> log_lik[4] -27.5 -23.0 -5.8 -20.1 8.4 2.06 3 13 -#> log_lik[5] -2.8 -2.4 -2.4 -2.5 0.1 2.06 3 13 -#> log_lik[6] -9.9 -6.7 -3.0 -6.6 2.6 2.06 3 13 -#> log_lik[7] -5.6 -5.1 -3.0 -4.8 1.0 2.06 3 13 -#> log_lik[8] -96.5 -81.8 -16.1 -70.3 31.2 2.06 3 13 -#> log_lik[9] -3.9 -3.8 -3.4 -3.7 0.2 2.06 3 13 -#> log_lik[10] -41.5 -25.0 -4.0 -24.2 13.9 2.06 3 13 -#> log_lik[11] -22.1 -18.6 -4.6 -16.2 6.8 2.06 3 13 -#> log_lik[12] -538.7 -454.5 -74.9 -387.8 180.4 2.06 3 13 -#> log_lik[13] -2.7 -2.3 -2.3 -2.4 0.2 2.06 3 13 -#> log_lik[14] -4.8 -3.7 -2.9 -3.8 0.7 2.06 3 13 -#> log_lik[15] -7.8 -6.8 -3.3 -6.3 1.7 2.06 3 13 -#> log_lik[16] -162.6 -139.6 -29.6 -120.1 51.9 2.06 3 13 -#> log_lik[17] -2.8 -2.7 -2.7 -2.7 0.1 1.58 9 13 -#> log_lik[18] -6.4 -4.9 -2.6 -4.7 1.4 2.06 3 13 -#> log_lik[19] -4.2 -3.9 -2.8 -3.7 0.6 2.06 4 13 -#> log_lik[20] -49.7 -41.3 -5.3 -34.9 17.3 2.06 3 13 -#> log_lik[21] -2.8 -2.5 -2.5 -2.6 0.1 2.06 3 13 -#> log_lik[22] -7.8 -5.7 -2.8 -5.6 1.9 2.06 3 13 -#> log_lik[23] -4.8 -4.3 -2.9 -4.1 0.7 2.06 3 13 -#> log_lik[24] -68.9 -59.7 -9.0 -50.0 23.6 2.06 3 13 -#> log_lik[25] -2.9 -2.9 -2.9 -2.9 0.0 1.33 5 13 -#> log_lik[26] -9.2 -6.3 -2.8 -6.2 2.4 2.06 3 13 -#> log_lik[27] -22.8 -18.8 -4.2 -16.4 7.2 2.06 3 13 -#> log_lik[28] -608.1 -514.1 -66.9 -433.3 211.4 2.06 3 13 -#> log_lik[29] -2.7 -2.5 -2.5 -2.5 0.1 2.06 3 13 -#> log_lik[30] -3.4 -2.9 -2.7 -3.0 0.3 2.06 3 13 -#> log_lik[31] -22.4 -18.4 -4.4 -16.1 6.9 2.06 3 13 -#> log_lik[32] -562.7 -477.6 -62.3 -401.8 195.7 2.06 3 13 -#> log_lik[33] -2.8 -2.6 -2.6 -2.7 0.1 1.10 8 13 -#> log_lik[34] -5.9 -4.4 -2.8 -4.4 1.2 2.06 3 13 -#> log_lik[35] -42.1 -34.4 -6.5 -29.9 13.7 2.06 3 13 -#> log_lik[36] -1027.8 -870.7 -118.0 -734.5 355.5 2.06 3 13 -#> log_lik[37] -2.7 -2.3 -2.2 -2.3 0.2 2.06 3 13 -#> log_lik[38] -2.7 -2.5 -2.5 -2.5 0.1 2.06 3 13 -#> log_lik[39] -61.8 -50.0 -9.0 -43.5 20.3 2.06 3 13 -#> log_lik[40] -1545.9 -1318.0 -190.9 -1112.6 530.3 2.06 3 13 -#> log_lik[41] -2.8 -2.5 -2.5 -2.6 0.2 2.06 3 13 -#> log_lik[42] -6.9 -5.4 -2.6 -5.2 1.6 2.06 3 13 -#> log_lik[43] -27.6 -22.3 -5.2 -19.7 8.6 2.06 3 13 -#> log_lik[44] -727.3 -621.5 -89.3 -523.6 249.9 2.06 3 13 -#> log_lik[45] -4.5 -4.4 -3.7 -4.3 0.3 2.06 3 13 -#> log_lik[46] -45.1 -29.0 -3.1 -26.9 15.6 2.06 3 13 -#> log_lik[47] -24.3 -19.5 -5.1 -17.4 7.3 2.06 3 13 -#> log_lik[48] -702.2 -609.4 -96.2 -512.9 238.7 2.06 3 13 -#> log_lik[49] -7.9 -7.4 -5.0 -7.0 1.1 2.06 3 13 -#> log_lik[50] -100.3 -63.1 -3.6 -58.4 35.9 2.06 3 13 -#> log_lik[51] -17.7 -14.1 -4.5 -12.9 5.0 2.06 3 13 -#> log_lik[52] -586.0 -517.0 -88.9 -434.5 197.1 2.06 3 13 -#> log_lik[53] -9.2 -8.5 -5.5 -8.0 1.4 2.06 3 13 -#> log_lik[54] -129.9 -80.0 -4.3 -74.6 46.6 2.06 3 13 -#> log_lik[55] -9.7 -7.9 -3.9 -7.5 2.2 2.06 3 13 -#> log_lik[56] -263.3 -238.7 -44.9 -199.5 87.7 2.06 3 13 -#> log_lik[57] -16.8 -15.4 -8.4 -14.1 3.3 2.06 3 13 -#> log_lik[58] -249.2 -151.2 -6.3 -141.5 90.0 2.06 3 13 -#> log_lik[59] -3.4 -3.3 -2.6 -3.2 0.3 1.87 4 13 -#> log_lik[60] -15.9 -10.1 -2.7 -10.0 4.8 2.06 3 13 -#> log_lik[61] -24.5 -22.2 -11.3 -20.3 5.2 2.06 3 13 -#> log_lik[62] -384.7 -232.9 -8.3 -217.8 139.5 2.06 3 13 -#> log_lik[63] -4.9 -4.6 -2.6 -4.2 0.9 2.06 4 13 -#> log_lik[64] -36.1 -23.4 -3.0 -22.0 12.3 2.06 3 13 -#> log_lik[65] -30.9 -28.0 -13.7 -25.4 6.7 2.06 3 13 -#> log_lik[66] -487.6 -294.8 -9.7 -275.7 177.2 2.06 3 13 -#> log_lik[67] -6.9 -6.4 -2.6 -5.7 1.7 2.06 4 13 -#> log_lik[68] -74.6 -50.3 -4.5 -45.9 26.3 2.06 3 13 -#> log_lik[69] -42.2 -38.1 -17.9 -34.4 9.5 2.06 3 13 -#> log_lik[70] -674.2 -405.1 -13.4 -379.9 244.9 2.06 3 13 -#> log_lik[71] -40.8 -34.7 -4.6 -29.3 14.4 2.06 3 13 -#> log_lik[72] -907.4 -718.6 -82.5 -619.2 316.0 2.06 3 13 -#> log_lik[73] -45.3 -40.9 -19.1 -36.9 10.3 2.06 3 13 -#> log_lik[74] -727.5 -436.6 -14.2 -409.6 264.3 2.06 3 13 -#> log_lik[75] -31.2 -26.8 -3.6 -22.6 10.9 2.06 4 13 -#> log_lik[76] -673.6 -522.5 -53.9 -452.4 236.4 2.06 3 13 -#> log_lik[77] -36.7 -33.2 -15.7 -30.0 8.2 2.06 3 13 -#> log_lik[78] -585.8 -350.6 -12.4 -329.6 212.5 2.06 3 13 -#> log_lik[79] -26.5 -22.6 -3.3 -19.2 9.2 2.06 4 13 -#> log_lik[80] -636.1 -496.4 -52.7 -429.1 222.8 2.06 3 13 -#> psi[1] 0.5 0.5 0.5 0.5 0.0 1.05 10 13 -#> psi[2] 0.4 0.4 0.4 0.4 0.0 1.06 12 13 -#> xstar[1,1] -7.6 -6.6 -4.3 -6.1 1.3 0.93 13 13 -#> xstar[2,1] -5.0 -3.5 -2.0 -3.4 1.1 0.95 13 13 -#> sigma[1] 3.6 3.8 5.8 4.2 0.9 2.06 3 13 -#> lp__ -14844.3 -11757.9 -1867.5 -10230.3 4939.7 2.06 3 13 +#> Q5 Q50 Q95 Mean SD Rhat Bulk_ESS Tail_ESS +#> x[1,1] -0.5 -0.1 0.2 -0.1 0.3 1.71 4 13 +#> x[2,1] 0.3 1.1 1.5 1.0 0.5 2.06 4 13 +#> x[1,2] -1.0 -0.7 -0.2 -0.7 0.3 1.12 13 13 +#> x[2,2] 0.5 0.9 1.1 0.9 0.2 1.09 7 13 +#> x[1,3] -2.2 -1.4 -0.7 -1.5 0.5 0.95 13 13 +#> x[2,3] 1.3 1.6 1.9 1.6 0.2 2.06 4 13 +#> x[1,4] -1.0 -0.7 0.6 -0.4 0.6 1.87 5 13 +#> x[2,4] 1.1 2.3 2.5 1.9 0.6 2.06 4 13 +#> x[1,5] -0.2 0.2 1.9 0.7 0.8 2.06 6 13 +#> x[2,5] 1.5 2.3 2.7 2.2 0.4 0.92 13 13 +#> x[1,6] -2.0 -1.7 0.0 -1.2 0.9 2.06 6 13 +#> x[2,6] 0.4 1.4 2.1 1.3 0.7 1.58 4 13 +#> x[1,7] -0.6 -0.4 2.0 0.4 1.1 1.87 5 13 +#> x[2,7] -0.1 0.5 1.4 0.6 0.6 1.58 5 13 +#> x[1,8] -0.6 -0.4 2.0 0.4 1.1 1.87 5 13 +#> x[2,8] -0.6 -0.3 0.6 -0.1 0.5 1.30 6 13 +#> x[1,9] -0.3 0.6 2.7 1.0 1.1 2.06 4 13 +#> x[2,9] -0.8 0.3 1.1 0.1 0.7 1.58 5 13 +#> x[1,10] 0.8 1.4 3.1 1.7 0.8 1.87 5 13 +#> x[2,10] -1.8 -0.9 0.0 -0.9 0.6 1.58 5 13 +#> x[1,11] 0.8 1.3 3.0 1.6 0.8 2.06 7 13 +#> x[2,11] -0.4 1.2 2.2 1.0 0.9 1.87 4 13 +#> x[1,12] -1.0 -0.1 1.2 0.0 0.8 1.33 5 13 +#> x[2,12] -1.7 -0.4 0.2 -0.5 0.7 2.06 4 13 +#> x[1,13] -0.6 0.0 1.7 0.2 0.8 1.47 9 13 +#> x[2,13] -2.3 -1.1 -0.4 -1.2 0.6 1.25 7 13 +#> x[1,14] -0.5 0.7 1.3 0.6 0.6 1.16 13 13 +#> x[2,14] -1.7 -1.1 -0.4 -1.0 0.5 1.09 13 13 +#> x[1,15] -0.7 1.1 1.6 0.9 1.0 1.13 13 13 +#> x[2,15] -1.4 -0.8 0.1 -0.7 0.5 1.14 7 13 +#> x[1,16] -1.0 1.2 1.7 0.9 1.4 1.20 9 13 +#> x[2,16] -2.4 -1.8 -1.3 -1.8 0.4 0.95 13 13 +#> x[1,17] -1.1 1.4 2.0 1.1 1.6 1.19 8 13 +#> x[2,17] -3.6 -2.9 -2.2 -2.9 0.5 1.05 9 13 +#> x[1,18] -2.0 1.0 1.9 0.6 1.9 1.87 4 13 +#> x[2,18] -2.9 -2.2 -1.1 -2.1 0.7 1.16 6 13 +#> x[1,19] -2.6 0.6 1.3 -0.1 1.9 2.06 4 13 +#> x[2,19] -3.9 -2.9 -2.1 -3.0 0.7 1.13 8 13 +#> x[1,20] -1.6 1.5 2.7 1.1 1.9 2.06 4 13 +#> x[2,20] -3.2 -2.1 -1.3 -2.2 0.7 1.13 8 13 +#> Z[1,1] -1.9 0.4 0.7 0.0 1.5 2.06 4 13 +#> Z[2,1] -0.6 0.1 0.3 0.0 0.3 1.32 7 13 +#> Z[3,1] -0.6 0.3 0.6 0.2 0.4 1.24 10 13 +#> Z[4,1] -0.3 0.1 0.6 0.1 0.3 1.19 13 13 +#> Z[1,2] 0.0 0.0 0.0 0.0 0.0 1.00 13 13 +#> Z[2,2] -0.7 -0.3 0.0 -0.3 0.3 1.58 13 13 +#> Z[3,2] 0.2 0.4 0.8 0.4 0.3 0.96 11 13 +#> Z[4,2] -0.6 -0.3 0.3 -0.3 0.4 1.19 13 13 +#> log_lik[1] -3.4 -1.4 -1.2 -1.8 1.3 0.95 13 13 +#> log_lik[2] -3.1 -0.8 -0.6 -1.2 1.5 1.12 13 13 +#> log_lik[3] -3.2 -0.7 -0.5 -1.2 1.5 2.06 9 13 +#> log_lik[4] -3.4 -1.3 -0.9 -1.7 1.3 1.15 7 13 +#> log_lik[5] -4.3 -1.9 -1.3 -2.3 1.2 1.19 6 13 +#> log_lik[6] -3.7 -1.5 -0.9 -1.7 1.3 1.06 13 13 +#> log_lik[7] -3.3 -0.8 -0.6 -1.3 1.5 1.07 13 13 +#> log_lik[8] -4.1 -2.2 -1.8 -2.5 1.1 2.06 13 13 +#> log_lik[9] -4.0 -1.2 -0.6 -1.8 1.4 1.47 5 13 +#> log_lik[10] -4.0 -1.2 -0.5 -1.6 1.5 1.01 13 13 +#> log_lik[11] -4.8 -1.1 -0.6 -1.6 1.6 0.99 11 13 +#> log_lik[12] -3.5 -1.4 -0.6 -1.6 1.4 0.94 13 13 +#> log_lik[13] -3.6 -1.0 -0.8 -1.5 1.4 1.71 5 13 +#> log_lik[14] -3.5 -0.7 -0.6 -1.2 1.5 2.06 13 13 +#> log_lik[15] -3.5 -0.9 -0.6 -1.4 1.4 1.71 13 13 +#> log_lik[16] -3.2 -0.8 -0.6 -1.2 1.5 1.05 11 13 +#> log_lik[17] -4.9 -2.3 -1.9 -2.8 1.2 1.45 13 13 +#> log_lik[18] -3.4 -0.9 -0.6 -1.4 1.4 1.58 13 13 +#> log_lik[19] -3.5 -1.0 -0.5 -1.4 1.5 1.30 13 13 +#> log_lik[20] -4.2 -1.4 -0.7 -1.7 1.4 1.37 13 13 +#> log_lik[21] -3.8 -1.3 -0.5 -1.6 1.4 1.09 10 13 +#> log_lik[22] -3.3 -0.8 -0.5 -1.3 1.5 0.92 13 13 +#> log_lik[23] -4.1 -1.3 -0.7 -1.7 1.4 0.96 13 13 +#> log_lik[24] -4.3 -2.0 -1.0 -2.1 1.4 1.38 13 13 +#> log_lik[25] -3.8 -1.0 -0.8 -1.6 1.4 1.58 4 13 +#> log_lik[26] -3.1 -0.7 -0.6 -1.2 1.5 1.24 7 13 +#> log_lik[27] -3.4 -1.0 -0.6 -1.4 1.4 1.71 13 13 +#> log_lik[28] -3.3 -0.7 -0.6 -1.2 1.5 1.33 5 13 +#> log_lik[29] -4.6 -1.4 -1.2 -2.1 1.4 2.06 4 13 +#> log_lik[30] -4.5 -1.7 -1.2 -2.0 1.3 1.21 6 13 +#> log_lik[31] -3.8 -0.9 -0.6 -1.4 1.5 0.98 13 13 +#> log_lik[32] -4.0 -1.0 -0.8 -1.6 1.4 1.19 6 13 +#> log_lik[33] -4.2 -1.5 -1.0 -2.0 1.4 1.58 4 13 +#> log_lik[34] -4.7 -1.7 -1.1 -2.1 1.4 1.21 13 13 +#> log_lik[35] -7.6 -2.6 -1.6 -3.4 2.3 1.18 8 13 +#> log_lik[36] -3.6 -0.8 -0.6 -1.3 1.5 2.06 4 13 +#> log_lik[37] -3.1 -0.8 -0.6 -1.2 1.5 1.00 13 13 +#> log_lik[38] -4.5 -1.4 -0.8 -1.8 1.5 1.06 13 13 +#> log_lik[39] -10.9 -5.5 -2.7 -5.9 3.8 1.16 9 13 +#> log_lik[40] -3.1 -0.7 -0.6 -1.2 1.5 2.06 4 13 +#> log_lik[41] -3.1 -0.6 -0.6 -1.1 1.5 1.32 13 13 +#> log_lik[42] -3.7 -1.2 -0.7 -1.6 1.4 1.15 11 13 +#> log_lik[43] -3.8 -0.9 -0.6 -1.4 1.5 1.04 13 13 +#> log_lik[44] -4.1 -1.6 -0.8 -2.0 1.3 1.15 13 13 +#> log_lik[45] -3.5 -1.2 -0.6 -1.5 1.4 1.03 13 13 +#> log_lik[46] -3.1 -0.9 -0.6 -1.3 1.4 1.48 13 13 +#> log_lik[47] -3.1 -0.7 -0.6 -1.1 1.5 1.04 13 13 +#> log_lik[48] -3.2 -0.9 -0.5 -1.3 1.5 1.58 13 13 +#> log_lik[49] -4.0 -1.7 -1.2 -2.1 1.3 1.12 13 13 +#> log_lik[50] -3.9 -1.9 -0.9 -2.0 1.3 2.06 13 13 +#> log_lik[51] -4.8 -2.0 -1.2 -2.5 1.3 0.95 13 13 +#> log_lik[52] -3.5 -1.2 -0.8 -1.6 1.4 1.24 13 13 +#> log_lik[53] -3.1 -0.7 -0.5 -1.1 1.5 2.06 13 13 +#> log_lik[54] -3.1 -0.7 -0.5 -1.1 1.5 1.30 13 13 +#> log_lik[55] -3.1 -0.7 -0.6 -1.1 1.5 1.30 13 13 +#> log_lik[56] -3.1 -0.6 -0.5 -1.1 1.5 1.71 13 13 +#> log_lik[57] -3.2 -0.8 -0.6 -1.2 1.5 2.06 4 13 +#> log_lik[58] -3.5 -0.9 -0.6 -1.4 1.4 1.87 4 13 +#> log_lik[59] -3.2 -0.8 -0.6 -1.3 1.5 1.00 13 13 +#> log_lik[60] -3.1 -0.7 -0.6 -1.2 1.5 1.37 6 13 +#> log_lik[61] -3.2 -0.7 -0.6 -1.2 1.5 2.06 4 13 +#> log_lik[62] -3.1 -1.0 -0.5 -1.2 1.5 1.06 13 13 +#> log_lik[63] -3.5 -1.1 -0.7 -1.5 1.4 1.20 13 13 +#> log_lik[64] -3.1 -0.8 -0.6 -1.2 1.5 1.00 13 13 +#> log_lik[65] -3.4 -1.0 -0.6 -1.4 1.4 2.06 4 13 +#> log_lik[66] -3.1 -0.9 -0.6 -1.2 1.5 1.48 5 13 +#> log_lik[67] -3.3 -1.0 -0.6 -1.4 1.4 2.06 4 13 +#> log_lik[68] -3.3 -0.7 -0.6 -1.2 1.5 1.45 13 13 +#> log_lik[69] -3.5 -0.9 -0.6 -1.5 1.4 2.06 4 13 +#> log_lik[70] -3.4 -1.1 -0.6 -1.4 1.4 0.98 13 13 +#> log_lik[71] -3.4 -1.2 -0.6 -1.5 1.4 1.12 11 13 +#> log_lik[72] -3.1 -0.7 -0.6 -1.1 1.5 1.24 6 13 +#> log_lik[73] -3.8 -1.3 -0.8 -1.8 1.4 2.06 4 13 +#> log_lik[74] -3.4 -0.7 -0.5 -1.2 1.5 1.58 13 13 +#> log_lik[75] -3.2 -0.8 -0.6 -1.2 1.5 1.05 11 13 +#> log_lik[76] -3.9 -0.8 -0.6 -1.4 1.5 1.37 13 13 +#> log_lik[77] -3.2 -0.8 -0.6 -1.3 1.5 1.30 6 13 +#> log_lik[78] -3.6 -1.2 -0.6 -1.4 1.4 1.24 13 13 +#> log_lik[79] -4.8 -1.4 -0.8 -1.9 1.5 0.94 13 13 +#> log_lik[80] -3.1 -0.7 -0.6 -1.2 1.5 1.58 13 13 +#> xstar[1,1] -2.2 2.0 3.5 1.5 2.2 2.06 4 13 +#> xstar[2,1] -4.0 -2.2 -0.6 -2.3 1.1 1.04 11 13 +#> sigma[1] 0.7 0.8 68.8 13.8 47.0 1.71 13 13 +#> lp__ -277.2 -83.7 -77.0 -119.4 117.0 1.87 4 13 #> #> For each parameter, Bulk_ESS and Tail_ESS are crude measures of #> effective sample size for bulk and tail quantities respectively (an ESS > 100 diff --git a/docs/reference/dfa_loadings.html b/docs/reference/dfa_loadings.html index 9b1318c..ba22b9a 100644 --- a/docs/reference/dfa_loadings.html +++ b/docs/reference/dfa_loadings.html @@ -72,7 +72,7 @@ bayesdfa - 1.0.0 + 1.1.0
@@ -187,8 +187,8 @@

Examp
#> #> SAMPLING FOR MODEL 'dfa' NOW (CHAIN 1). #> Chain 1: -#> Chain 1: Gradient evaluation took 3.7e-05 seconds -#> Chain 1: 1000 transitions using 10 leapfrog steps per transition would take 0.37 seconds. +#> Chain 1: Gradient evaluation took 2.9e-05 seconds +#> Chain 1: 1000 transitions using 10 leapfrog steps per transition would take 0.29 seconds. #> Chain 1: Adjust your expectations accordingly! #> Chain 1: #> Chain 1: @@ -213,12 +213,10 @@

Examp #> Chain 1: Iteration: 45 / 50 [ 90%] (Sampling) #> Chain 1: Iteration: 50 / 50 [100%] (Sampling) #> Chain 1: -#> Chain 1: Elapsed Time: 0.002869 seconds (Warm-up) -#> Chain 1: 0.330244 seconds (Sampling) -#> Chain 1: 0.333113 seconds (Total) -#> Chain 1:

#> Warning: There were 2 divergent transitions after warmup. See -#> http://mc-stan.org/misc/warnings.html#divergent-transitions-after-warmup -#> to find out why this is a problem and how to eliminate them.
#> Warning: There were 1 chains where the estimated Bayesian Fraction of Missing Information was low. See +#> Chain 1: Elapsed Time: 0.01819 seconds (Warm-up) +#> Chain 1: 0.211904 seconds (Sampling) +#> Chain 1: 0.230094 seconds (Total) +#> Chain 1:
#> Warning: There were 1 chains where the estimated Bayesian Fraction of Missing Information was low. See #> http://mc-stan.org/misc/warnings.html#bfmi-low
#> Warning: Examine the pairs() plot to diagnose sampling problems
#> Warning: The largest R-hat is NA, indicating chains have not mixed. #> Running the chains for more iterations may help. See #> http://mc-stan.org/misc/warnings.html#r-hat
#> Warning: Bulk Effective Samples Size (ESS) is too low, indicating posterior means and medians may be unreliable. @@ -227,81 +225,79 @@

Examp #> Running the chains for more iterations may help. See #> http://mc-stan.org/misc/warnings.html#tail-ess

#> Inference for the input samples (1 chains: each with iter = 25; warmup = 12): #> -#> Q5 Q50 Q95 Mean SD Rhat Bulk_ESS Tail_ESS -#> x[1,1] -1.0 0.0 0.5 -0.1 0.5 1.02 13 13 -#> x[2,1] -0.5 0.6 1.6 0.5 0.8 1.12 13 13 -#> x[1,2] 0.0 0.7 2.0 0.9 0.8 1.21 8 13 -#> x[2,2] 0.3 1.5 2.5 1.4 0.7 0.96 13 13 -#> x[1,3] 1.2 1.7 4.2 2.2 1.0 0.99 11 13 -#> x[2,3] -0.9 0.0 2.4 0.4 1.1 1.58 4 13 -#> x[1,4] -0.6 0.6 2.0 0.6 0.9 1.05 10 13 -#> x[2,4] 0.9 1.6 2.7 1.8 0.7 1.04 10 13 -#> x[1,5] -1.6 -0.2 0.7 -0.3 0.8 1.07 13 13 -#> x[2,5] 0.3 1.2 2.7 1.4 0.9 0.96 11 13 -#> x[1,6] -1.1 -0.4 -0.1 -0.5 0.4 0.94 13 13 -#> x[2,6] -1.0 0.0 0.6 -0.1 0.6 1.71 4 13 -#> x[1,7] -1.6 -0.8 -0.2 -0.8 0.5 1.00 9 13 -#> x[2,7] -3.4 -1.8 -0.1 -2.0 1.2 1.14 9 13 -#> x[1,8] -2.5 -0.9 -0.4 -1.1 0.9 1.30 6 13 -#> x[2,8] -4.1 -2.2 -0.7 -2.5 1.2 1.03 13 13 -#> x[1,9] -2.5 -1.1 -0.2 -1.1 0.8 1.33 7 13 -#> x[2,9] -4.0 -2.3 -0.7 -2.3 1.2 1.00 11 13 -#> x[1,10] -1.0 0.1 0.5 -0.1 0.5 1.02 13 13 -#> x[2,10] -3.5 -0.6 0.2 -1.0 1.5 0.93 13 13 -#> Z[1,1] 0.4 0.8 1.2 0.8 0.3 1.04 13 13 -#> Z[2,1] -1.8 -0.7 -0.3 -0.9 0.6 1.58 4 13 -#> Z[3,1] 0.2 0.9 2.3 1.1 0.7 1.13 9 13 -#> Z[4,1] -1.8 -0.6 -0.1 -0.8 0.6 1.58 4 13 -#> Z[1,2] 0.0 0.0 0.0 0.0 0.0 1.00 13 13 -#> Z[2,2] 0.2 0.7 1.3 0.7 0.4 1.06 13 13 -#> Z[3,2] -1.2 -0.6 -0.3 -0.6 0.3 1.22 7 13 -#> Z[4,2] 0.3 0.7 1.5 0.8 0.5 1.30 9 13 -#> log_lik[1] -0.6 -0.3 0.0 -0.3 0.2 1.24 6 13 -#> log_lik[2] -2.3 -0.5 -0.3 -0.9 0.9 1.04 10 13 -#> log_lik[3] -1.2 -0.4 0.0 -0.4 0.4 1.24 6 13 -#> log_lik[4] -1.0 -0.3 0.0 -0.4 0.4 1.21 7 13 -#> log_lik[5] -1.4 -0.4 -0.1 -0.5 0.5 1.71 13 13 -#> log_lik[6] -2.6 -1.7 -0.4 -1.6 0.8 1.06 13 13 -#> log_lik[7] -0.6 -0.3 0.1 -0.3 0.2 1.24 6 13 -#> log_lik[8] -1.4 -0.5 -0.1 -0.6 0.4 1.00 8 13 -#> log_lik[9] -3.7 -1.4 -0.2 -1.7 1.2 1.14 9 13 -#> log_lik[10] -2.8 -0.5 0.1 -0.8 1.0 1.33 6 13 -#> log_lik[11] -3.0 -0.5 -0.1 -1.1 1.1 0.98 13 13 -#> log_lik[12] -2.7 -0.6 0.0 -0.9 1.1 1.03 13 13 -#> log_lik[13] -1.9 -1.1 -0.1 -1.0 0.7 1.12 9 13 -#> log_lik[14] -1.0 -0.4 -0.1 -0.5 0.3 1.08 7 13 -#> log_lik[15] -1.5 -0.3 0.0 -0.5 0.6 1.09 8 13 -#> log_lik[16] -0.8 -0.4 0.0 -0.4 0.3 0.99 13 13 -#> log_lik[17] -1.4 -0.6 -0.2 -0.6 0.5 0.97 13 13 -#> log_lik[18] -1.3 -0.4 0.0 -0.5 0.5 1.00 13 13 -#> log_lik[19] -1.6 -0.6 -0.2 -0.8 0.5 1.03 13 13 -#> log_lik[20] -1.1 -0.3 0.0 -0.4 0.4 1.18 13 13 -#> log_lik[21] -0.6 -0.3 0.0 -0.3 0.2 1.71 4 13 -#> log_lik[22] -1.4 -0.4 0.0 -0.5 0.5 1.03 13 13 -#> log_lik[23] -1.3 -0.4 0.0 -0.5 0.5 1.18 7 13 -#> log_lik[24] -1.2 -0.3 0.0 -0.4 0.4 1.33 7 13 -#> log_lik[25] -0.9 -0.5 0.0 -0.5 0.3 0.96 13 13 -#> log_lik[26] -1.1 -0.4 0.0 -0.4 0.5 1.31 5 13 -#> log_lik[27] -2.0 -0.7 -0.1 -0.9 0.7 0.97 13 13 -#> log_lik[28] -1.0 -0.2 0.0 -0.3 0.4 1.71 4 13 -#> log_lik[29] -1.7 -0.3 0.0 -0.5 0.6 1.18 8 13 -#> log_lik[30] -2.3 -0.8 -0.2 -0.9 0.8 0.92 13 13 -#> log_lik[31] -1.4 -0.4 0.1 -0.6 0.5 1.06 8 13 -#> log_lik[32] -0.9 -0.3 -0.1 -0.4 0.3 1.18 7 13 -#> log_lik[33] -3.0 -0.7 -0.3 -1.0 1.0 1.25 8 13 -#> log_lik[34] -1.1 -0.6 0.0 -0.6 0.4 1.32 7 13 -#> log_lik[35] -1.7 -0.3 0.0 -0.5 0.6 1.58 5 13 -#> log_lik[36] -1.1 -0.3 0.0 -0.4 0.4 1.71 4 13 -#> log_lik[37] -1.8 -0.3 -0.1 -0.7 0.7 1.09 10 13 -#> log_lik[38] -0.8 -0.3 0.0 -0.3 0.3 1.71 4 13 -#> log_lik[39] -2.0 -0.6 -0.2 -0.9 0.7 1.12 11 13 -#> log_lik[40] -1.7 -0.5 -0.1 -0.7 0.6 0.96 13 13 -#> psi[1] 0.5 1.1 4.7 1.7 1.5 1.18 13 13 -#> psi[2] 1.0 2.4 3.8 2.3 1.0 0.92 8 13 -#> xstar[1,1] -0.8 0.6 2.4 0.8 1.1 1.00 13 13 -#> xstar[2,1] -3.8 0.5 2.6 -0.1 2.3 1.04 7 13 -#> sigma[1] 0.4 0.5 0.6 0.5 0.1 1.71 4 13 -#> lp__ -37.0 -24.8 -16.0 -25.8 7.1 1.04 7 13 +#> Q5 Q50 Q95 Mean SD Rhat Bulk_ESS Tail_ESS +#> x[1,1] -1.5 -0.7 0.8 -0.6 0.8 1.37 6 13 +#> x[2,1] -1.0 -0.2 0.6 -0.2 0.6 1.58 9 13 +#> x[1,2] -1.7 0.2 0.9 -0.3 1.1 2.06 4 13 +#> x[2,2] 0.2 0.5 1.2 0.6 0.4 1.16 12 13 +#> x[1,3] -1.6 0.0 0.8 -0.4 1.0 2.06 4 13 +#> x[2,3] -1.4 -0.2 0.3 -0.4 0.6 2.06 4 13 +#> x[1,4] -1.5 -0.4 0.7 -0.4 0.9 2.06 4 13 +#> x[2,4] -0.1 0.6 1.3 0.6 0.5 1.06 11 13 +#> x[1,5] -0.7 -0.2 0.7 -0.1 0.5 0.95 11 13 +#> x[2,5] -1.4 -0.6 1.5 -0.3 1.2 1.87 6 13 +#> x[1,6] -0.9 -0.3 0.3 -0.3 0.5 1.16 6 13 +#> x[2,6] -0.2 0.1 0.6 0.1 0.3 1.45 10 13 +#> x[1,7] -2.2 -1.2 0.3 -1.1 0.9 1.71 4 13 +#> x[2,7] -1.1 -0.1 0.9 -0.1 0.6 1.47 13 13 +#> x[1,8] -1.7 -0.8 0.5 -0.7 0.8 1.32 5 13 +#> x[2,8] -1.1 0.2 1.4 0.2 0.8 1.71 13 13 +#> x[1,9] -1.3 -0.2 0.7 -0.2 0.6 1.15 8 13 +#> x[2,9] -1.2 0.5 1.2 0.2 0.9 2.06 9 13 +#> x[1,10] -1.4 -0.7 0.2 -0.7 0.6 1.48 5 13 +#> x[2,10] -1.0 -0.4 0.3 -0.4 0.4 0.99 13 13 +#> Z[1,1] -3.6 0.3 3.6 0.2 2.4 2.06 13 13 +#> Z[2,1] -0.5 0.5 1.4 0.3 0.7 0.95 13 13 +#> Z[3,1] -1.5 -0.5 1.0 -0.4 0.9 1.87 4 13 +#> Z[4,1] -0.8 0.1 1.9 0.4 0.9 1.20 6 13 +#> Z[1,2] 0.0 0.0 0.0 0.0 0.0 1.00 13 13 +#> Z[2,2] -4.2 1.0 6.2 0.6 3.9 1.18 13 13 +#> Z[3,2] -1.7 -0.7 0.5 -0.6 0.8 1.06 8 13 +#> Z[4,2] -1.2 0.9 1.8 0.6 1.1 0.97 13 13 +#> log_lik[1] -4.3 -1.5 -0.6 -2.0 1.5 1.87 4 13 +#> log_lik[2] -4.3 -1.3 -0.6 -1.9 1.4 1.87 4 13 +#> log_lik[3] -4.3 -1.2 -0.6 -1.9 1.5 2.06 4 13 +#> log_lik[4] -4.3 -1.1 -0.5 -2.0 1.5 2.06 4 13 +#> log_lik[5] -4.3 -1.2 -0.8 -2.0 1.4 2.06 4 13 +#> log_lik[6] -4.3 -1.3 -0.6 -2.0 1.4 1.71 4 13 +#> log_lik[7] -4.3 -1.3 -0.6 -2.0 1.4 1.87 4 13 +#> log_lik[8] -4.7 -1.4 -0.5 -2.3 1.8 1.87 4 13 +#> log_lik[9] -5.7 -3.5 -2.2 -3.6 1.3 0.98 13 13 +#> log_lik[10] -4.3 -2.2 -0.5 -2.5 1.5 1.24 5 13 +#> log_lik[11] -4.3 -2.1 -0.6 -2.5 1.4 1.32 4 13 +#> log_lik[12] -4.3 -1.6 -0.6 -2.1 1.4 1.47 4 13 +#> log_lik[13] -4.3 -1.4 -0.6 -2.1 1.5 1.87 4 13 +#> log_lik[14] -4.3 -1.5 -0.5 -2.0 1.5 1.87 4 13 +#> log_lik[15] -4.3 -1.5 -0.6 -2.0 1.4 2.06 3 13 +#> log_lik[16] -4.3 -1.5 -0.6 -2.2 1.5 1.87 4 13 +#> log_lik[17] -4.3 -1.3 -0.5 -1.8 1.5 2.06 3 13 +#> log_lik[18] -4.4 -2.0 -0.5 -2.1 1.5 2.06 3 13 +#> log_lik[19] -4.3 -1.9 -0.6 -2.1 1.4 2.06 4 13 +#> log_lik[20] -4.3 -1.7 -0.5 -2.0 1.4 2.06 4 13 +#> log_lik[21] -4.3 -1.1 -0.5 -1.9 1.5 2.06 3 13 +#> log_lik[22] -4.3 -1.2 -0.6 -1.9 1.4 2.06 4 13 +#> log_lik[23] -4.3 -1.3 -0.7 -1.9 1.4 1.87 4 13 +#> log_lik[24] -4.3 -1.3 -0.7 -1.9 1.4 2.06 4 13 +#> log_lik[25] -4.4 -2.2 -0.6 -2.3 1.6 1.87 4 13 +#> log_lik[26] -4.3 -1.5 -0.7 -2.1 1.4 1.58 4 13 +#> log_lik[27] -4.3 -1.6 -0.6 -2.1 1.4 2.06 4 13 +#> log_lik[28] -4.3 -1.5 -0.9 -2.1 1.4 2.06 4 13 +#> log_lik[29] -4.3 -1.5 -0.9 -2.3 1.3 1.47 4 13 +#> log_lik[30] -4.3 -1.3 -0.7 -2.0 1.4 1.71 4 13 +#> log_lik[31] -4.3 -1.1 -0.5 -1.8 1.5 2.06 3 13 +#> log_lik[32] -4.3 -1.4 -0.6 -1.9 1.4 1.87 4 13 +#> log_lik[33] -4.3 -1.7 -1.0 -2.2 1.2 1.58 4 13 +#> log_lik[34] -4.3 -1.6 -0.7 -2.1 1.4 2.06 4 13 +#> log_lik[35] -4.3 -1.0 -0.5 -1.8 1.5 2.06 3 13 +#> log_lik[36] -4.3 -1.0 -0.6 -1.9 1.5 2.06 4 13 +#> log_lik[37] -4.3 -2.0 -0.7 -2.1 1.4 2.06 4 13 +#> log_lik[38] -4.3 -1.2 -0.5 -1.8 1.5 2.06 3 13 +#> log_lik[39] -4.3 -1.7 -0.6 -2.0 1.3 1.87 4 13 +#> log_lik[40] -4.3 -1.3 -0.6 -2.0 1.4 2.06 4 13 +#> xstar[1,1] -2.1 -0.5 1.3 -0.6 1.2 1.00 9 13 +#> xstar[2,1] -2.0 -0.4 1.2 -0.3 1.2 1.12 8 13 +#> sigma[1] 0.6 1.0 29.7 7.5 11.8 2.06 3 13 +#> lp__ -203.1 -43.1 -19.4 -78.8 72.9 2.06 3 13 #> #> For each parameter, Bulk_ESS and Tail_ESS are crude measures of #> effective sample size for bulk and tail quantities respectively (an ESS > 100 diff --git a/docs/reference/dfa_trends.html b/docs/reference/dfa_trends.html index 504e7fb..fba8d1f 100644 --- a/docs/reference/dfa_trends.html +++ b/docs/reference/dfa_trends.html @@ -72,7 +72,7 @@ bayesdfa - 1.0.0 + 1.1.0
@@ -173,8 +173,8 @@

Examp
#> #> SAMPLING FOR MODEL 'dfa' NOW (CHAIN 1). #> Chain 1: -#> Chain 1: Gradient evaluation took 3.3e-05 seconds -#> Chain 1: 1000 transitions using 10 leapfrog steps per transition would take 0.33 seconds. +#> Chain 1: Gradient evaluation took 4.6e-05 seconds +#> Chain 1: 1000 transitions using 10 leapfrog steps per transition would take 0.46 seconds. #> Chain 1: Adjust your expectations accordingly! #> Chain 1: #> Chain 1: @@ -199,9 +199,9 @@

Examp #> Chain 1: Iteration: 45 / 50 [ 90%] (Sampling) #> Chain 1: Iteration: 50 / 50 [100%] (Sampling) #> Chain 1: -#> Chain 1: Elapsed Time: 0.002321 seconds (Warm-up) -#> Chain 1: 0.006642 seconds (Sampling) -#> Chain 1: 0.008963 seconds (Total) +#> Chain 1: Elapsed Time: 0.003725 seconds (Warm-up) +#> Chain 1: 0.003703 seconds (Sampling) +#> Chain 1: 0.007428 seconds (Total) #> Chain 1:

#> Warning: There were 1 chains where the estimated Bayesian Fraction of Missing Information was low. See #> http://mc-stan.org/misc/warnings.html#bfmi-low
#> Warning: Examine the pairs() plot to diagnose sampling problems
#> Warning: The largest R-hat is 2.1, indicating chains have not mixed. #> Running the chains for more iterations may help. See @@ -212,114 +212,113 @@

Examp #> http://mc-stan.org/misc/warnings.html#tail-ess

#> Inference for the input samples (1 chains: each with iter = 25; warmup = 12): #> #> Q5 Q50 Q95 Mean SD Rhat Bulk_ESS Tail_ESS -#> x[1,1] -1.6 -1.6 -1.6 -1.6 0.0 1.87 4 13 -#> x[1,2] 0.6 0.6 0.6 0.6 0.0 2.06 9 13 -#> x[1,3] -2.1 -2.1 -2.1 -2.1 0.0 1.71 5 13 -#> x[1,4] -4.1 -4.1 -4.1 -4.1 0.0 1.58 4 13 -#> x[1,5] -1.2 -1.2 -1.2 -1.2 0.0 1.47 5 13 -#> x[1,6] 0.4 0.4 0.4 0.4 0.0 2.06 4 13 -#> x[1,7] 2.7 2.7 2.8 2.7 0.0 2.06 4 13 -#> x[1,8] 1.9 1.9 1.9 1.9 0.0 2.06 3 13 -#> x[1,9] 3.3 3.4 3.4 3.4 0.0 2.06 4 13 -#> x[1,10] 2.1 2.1 2.1 2.1 0.0 2.06 4 13 -#> x[1,11] -0.6 -0.6 -0.6 -0.6 0.0 1.09 7 13 -#> x[1,12] -0.9 -0.8 -0.8 -0.8 0.0 1.71 4 13 -#> x[1,13] -3.9 -3.9 -3.9 -3.9 0.0 2.06 4 13 -#> x[1,14] -1.6 -1.6 -1.6 -1.6 0.0 2.06 4 13 -#> x[1,15] -2.7 -2.7 -2.7 -2.7 0.0 2.06 4 13 -#> x[1,16] -1.6 -1.6 -1.6 -1.6 0.0 1.87 5 13 -#> x[1,17] 0.0 0.0 0.0 0.0 0.0 1.03 12 13 -#> x[1,18] 1.8 1.8 1.8 1.8 0.0 2.06 4 13 -#> x[1,19] 3.1 3.1 3.1 3.1 0.0 2.06 4 13 -#> x[1,20] 0.7 0.8 0.8 0.8 0.0 2.06 4 13 -#> Z[1,1] 0.2 0.2 0.2 0.2 0.0 2.06 4 13 -#> Z[2,1] 4.4 4.5 5.0 4.7 0.3 2.06 3 13 -#> Z[3,1] -25.6 -24.2 -23.7 -24.5 0.8 2.06 3 13 -#> Z[4,1] -12.9 -11.8 -11.5 -12.1 0.6 2.06 3 13 -#> log_lik[1] -1.6 -1.6 -1.5 -1.6 0.0 2.06 3 13 -#> log_lik[2] -14.4 -10.6 -9.8 -11.7 2.0 2.06 3 13 -#> log_lik[3] -291.9 -222.0 -204.6 -241.0 38.2 2.06 3 13 -#> log_lik[4] -78.8 -56.7 -52.1 -62.9 11.7 2.06 3 13 -#> log_lik[5] -1.8 -1.8 -1.7 -1.8 0.0 2.06 3 13 -#> log_lik[6] -5.8 -4.9 -4.7 -5.1 0.5 2.06 3 13 -#> log_lik[7] -52.5 -42.3 -39.2 -44.9 5.7 2.06 3 13 -#> log_lik[8] -8.3 -6.4 -5.9 -6.9 1.0 2.06 3 13 -#> log_lik[9] -2.4 -2.4 -2.4 -2.4 0.0 2.06 3 13 -#> log_lik[10] -18.4 -13.0 -12.1 -14.6 2.8 2.06 3 13 -#> log_lik[11] -439.0 -329.8 -304.4 -360.3 59.2 2.06 3 13 -#> log_lik[12] -142.0 -102.2 -94.3 -113.6 21.0 2.06 3 13 -#> log_lik[13] -2.0 -2.0 -2.0 -2.0 0.0 2.06 4 13 -#> log_lik[14] -63.3 -43.3 -39.7 -49.1 10.4 2.06 3 13 -#> log_lik[15] -1830.0 -1387.5 -1282.4 -1509.6 240.6 2.06 3 13 -#> log_lik[16] -499.6 -356.7 -328.5 -397.4 75.1 2.06 3 13 -#> log_lik[17] -1.6 -1.6 -1.5 -1.6 0.0 2.06 3 13 -#> log_lik[18] -8.5 -6.4 -6.1 -7.0 1.1 2.06 3 13 -#> log_lik[19] -166.6 -126.7 -118.5 -138.2 21.2 2.06 3 13 -#> log_lik[20] -45.2 -32.6 -30.5 -36.3 6.5 2.06 3 13 -#> log_lik[21] -1.6 -1.5 -1.5 -1.5 0.0 2.06 3 13 -#> log_lik[22] -2.6 -2.3 -2.2 -2.4 0.2 2.06 3 13 -#> log_lik[23] -27.6 -20.7 -18.4 -22.4 4.0 2.06 3 13 -#> log_lik[24] -6.1 -4.6 -4.2 -5.0 0.8 2.06 3 13 -#> log_lik[25] -1.6 -1.6 -1.5 -1.6 0.0 2.06 3 13 -#> log_lik[26] -37.6 -26.4 -24.2 -29.6 5.9 2.06 3 13 -#> log_lik[27] -850.6 -638.3 -583.3 -695.5 117.1 2.06 3 13 -#> log_lik[28] -215.5 -151.5 -137.8 -169.4 34.0 2.06 3 13 -#> log_lik[29] -1.6 -1.6 -1.5 -1.5 0.0 2.06 3 13 -#> log_lik[30] -17.9 -12.7 -11.6 -14.2 2.8 2.06 3 13 -#> log_lik[31] -433.8 -324.4 -296.1 -354.0 60.4 2.06 3 13 -#> log_lik[32] -104.3 -72.9 -66.2 -81.7 16.7 2.06 3 13 -#> log_lik[33] -1.6 -1.5 -1.5 -1.5 0.0 2.06 3 13 -#> log_lik[34] -45.9 -31.6 -28.8 -35.7 7.6 2.06 3 13 -#> log_lik[35] -1276.3 -963.2 -882.1 -1047.8 173.1 2.06 3 13 -#> log_lik[36] -323.1 -228.3 -208.0 -254.9 50.5 2.06 3 13 -#> log_lik[37] -1.6 -1.6 -1.5 -1.6 0.0 2.06 3 13 -#> log_lik[38] -20.0 -14.3 -13.1 -15.9 3.0 2.06 3 13 -#> log_lik[39] -475.6 -360.9 -329.2 -391.4 64.2 2.06 3 13 -#> log_lik[40] -133.7 -96.0 -87.5 -106.5 20.3 2.06 3 13 -#> log_lik[41] -1.6 -1.6 -1.5 -1.5 0.0 2.06 3 13 -#> log_lik[42] -2.9 -2.5 -2.5 -2.7 0.2 2.06 3 13 -#> log_lik[43] -45.5 -34.6 -32.7 -37.7 5.7 2.06 3 13 -#> log_lik[44] -12.8 -9.5 -9.0 -10.5 1.7 2.06 3 13 -#> log_lik[45] -1.6 -1.6 -1.6 -1.6 0.0 2.06 3 13 -#> log_lik[46] -2.8 -2.3 -2.3 -2.5 0.2 2.06 3 13 -#> log_lik[47] -80.9 -60.1 -56.2 -66.1 10.9 2.06 3 13 -#> log_lik[48] -23.6 -17.0 -15.9 -18.9 3.4 2.06 3 13 -#> log_lik[49] -1.6 -1.5 -1.5 -1.5 0.0 2.06 3 13 -#> log_lik[50] -69.3 -48.1 -44.2 -54.3 11.1 2.06 3 13 -#> log_lik[51] -1736.5 -1311.9 -1210.9 -1429.3 231.4 2.06 3 13 -#> log_lik[52] -432.2 -305.2 -280.1 -341.4 66.9 2.06 3 13 -#> log_lik[53] -1.6 -1.6 -1.5 -1.5 0.0 2.06 3 13 -#> log_lik[54] -14.9 -10.7 -10.0 -12.0 2.1 2.06 3 13 -#> log_lik[55] -298.4 -222.1 -205.7 -244.0 41.2 2.06 3 13 -#> log_lik[56] -73.2 -51.2 -47.2 -57.6 11.6 2.06 3 13 -#> log_lik[57] -1.6 -1.6 -1.5 -1.6 0.0 2.06 3 13 -#> log_lik[58] -34.1 -23.8 -22.0 -26.8 5.4 2.06 3 13 -#> log_lik[59] -824.7 -618.5 -571.4 -676.5 111.7 2.06 3 13 -#> log_lik[60] -198.8 -139.1 -127.7 -156.3 31.3 2.06 3 13 -#> log_lik[61] -1.6 -1.5 -1.5 -1.5 0.0 2.06 3 13 -#> log_lik[62] -18.4 -13.6 -12.8 -15.0 2.5 2.06 3 13 -#> log_lik[63] -282.9 -211.5 -197.1 -232.5 38.2 2.06 3 13 -#> log_lik[64] -69.1 -48.5 -45.0 -54.6 10.7 2.06 3 13 -#> log_lik[65] -1.6 -1.6 -1.5 -1.5 0.0 2.06 3 13 -#> log_lik[66] -1.6 -1.6 -1.5 -1.6 0.0 2.06 4 13 -#> log_lik[67] -1.8 -1.7 -1.7 -1.7 0.0 1.14 7 13 -#> log_lik[68] -1.6 -1.5 -1.5 -1.5 0.0 2.06 3 13 -#> log_lik[69] -2.2 -2.2 -2.2 -2.2 0.0 2.06 3 13 -#> log_lik[70] -15.6 -11.4 -10.4 -12.5 2.3 2.06 3 13 -#> log_lik[71] -334.3 -255.2 -230.0 -274.8 44.8 2.06 3 13 -#> log_lik[72] -104.5 -76.1 -68.8 -83.6 15.4 2.06 3 13 -#> log_lik[73] -2.1 -2.1 -2.1 -2.1 0.0 2.06 3 13 -#> log_lik[74] -35.1 -24.1 -21.7 -27.1 5.8 2.06 3 13 -#> log_lik[75] -1049.3 -795.6 -720.8 -860.2 142.0 2.06 3 13 -#> log_lik[76] -294.1 -210.6 -190.5 -233.0 44.9 2.06 3 13 -#> log_lik[77] -1.9 -1.9 -1.9 -1.9 0.0 2.06 3 13 -#> log_lik[78] -3.0 -2.5 -2.4 -2.7 0.3 2.06 3 13 -#> log_lik[79] -58.7 -43.4 -37.0 -46.6 9.2 2.06 3 13 -#> log_lik[80] -25.0 -18.4 -16.2 -19.9 3.8 2.06 3 13 -#> psi[1] 2.8 2.8 2.8 2.8 0.0 0.96 13 13 -#> xstar[1,1] -1.0 -0.5 0.2 -0.4 0.4 0.96 13 13 -#> sigma[1] 1.7 1.9 1.9 1.8 0.1 2.06 3 13 -#> lp__ -15022.5 -11363.7 -10479.9 -12366.4 1991.0 2.06 3 13 +#> x[1,1] -1.0 -1.0 -1.0 -1.0 0.0 2.06 3 13 +#> x[1,2] 0.4 0.4 0.4 0.4 0.0 2.06 4 13 +#> x[1,3] -1.2 -1.2 -1.2 -1.2 0.0 2.06 4 13 +#> x[1,4] -2.4 -2.4 -2.4 -2.4 0.0 2.06 4 13 +#> x[1,5] -0.7 -0.7 -0.7 -0.7 0.0 1.87 4 13 +#> x[1,6] 0.3 0.3 0.3 0.3 0.0 0.96 7 13 +#> x[1,7] 1.6 1.6 1.6 1.6 0.0 2.06 4 13 +#> x[1,8] 1.1 1.1 1.1 1.1 0.0 1.87 4 13 +#> x[1,9] 2.0 2.0 2.0 2.0 0.0 2.06 4 13 +#> x[1,10] 1.2 1.3 1.3 1.3 0.0 1.24 5 13 +#> x[1,11] -0.4 -0.4 -0.4 -0.4 0.0 1.71 4 13 +#> x[1,12] -0.5 -0.5 -0.5 -0.5 0.0 1.87 4 13 +#> x[1,13] -2.3 -2.3 -2.3 -2.3 0.0 2.06 4 13 +#> x[1,14] -0.9 -0.9 -0.9 -0.9 0.0 2.06 4 13 +#> x[1,15] -1.6 -1.6 -1.6 -1.6 0.0 2.06 4 13 +#> x[1,16] -0.9 -0.9 -0.9 -0.9 0.0 2.06 4 13 +#> x[1,17] 0.0 0.0 0.0 0.0 0.0 1.45 5 13 +#> x[1,18] 1.1 1.1 1.1 1.1 0.0 1.37 5 13 +#> x[1,19] 1.8 1.8 1.8 1.8 0.0 1.71 4 13 +#> x[1,20] 0.4 0.4 0.4 0.4 0.0 1.37 5 13 +#> Z[1,1] -99.6 -99.6 -99.6 -99.6 0.0 1.71 4 13 +#> Z[2,1] 37.1 37.3 37.8 37.3 0.2 2.06 4 13 +#> Z[3,1] 16.1 16.2 16.4 16.3 0.1 2.06 4 13 +#> Z[4,1] -60.8 -60.5 -60.4 -60.5 0.2 2.06 3 13 +#> log_lik[1] -763.9 -652.0 -620.6 -669.9 50.8 2.06 3 13 +#> log_lik[2] -115.3 -96.3 -91.1 -99.3 8.6 2.06 3 13 +#> log_lik[3] -23.6 -20.0 -18.9 -20.6 1.7 2.06 3 13 +#> log_lik[4] -291.8 -246.8 -234.0 -254.0 20.5 2.06 3 13 +#> log_lik[5] -130.4 -117.0 -112.2 -118.8 6.4 2.06 3 13 +#> log_lik[6] -23.9 -21.1 -20.2 -21.5 1.3 2.06 3 13 +#> log_lik[7] -3.8 -3.6 -3.5 -3.6 0.1 2.06 4 13 +#> log_lik[8] -40.2 -36.0 -34.5 -36.6 2.0 2.06 3 13 +#> log_lik[9] -1191.0 -1008.1 -960.6 -1038.5 81.8 2.06 3 13 +#> log_lik[10] -175.2 -144.9 -137.2 -149.9 13.5 2.06 3 13 +#> log_lik[11] -43.1 -36.1 -34.1 -37.3 3.2 2.06 3 13 +#> log_lik[12] -487.1 -408.8 -388.1 -421.7 35.1 2.06 3 13 +#> log_lik[13] -4836.0 -4119.4 -3929.1 -4237.3 322.0 2.06 3 13 +#> log_lik[14] -677.8 -562.6 -532.9 -581.5 51.4 2.06 3 13 +#> log_lik[15] -142.3 -118.7 -111.8 -122.5 10.8 2.06 3 13 +#> log_lik[16] -1852.6 -1562.7 -1484.6 -1610.2 130.6 2.06 3 13 +#> log_lik[17] -426.9 -356.8 -341.4 -369.6 30.7 2.06 3 13 +#> log_lik[18] -64.6 -53.0 -50.5 -55.1 5.1 2.06 3 13 +#> log_lik[19] -14.0 -11.8 -11.3 -12.2 1.0 2.06 3 13 +#> log_lik[20] -163.5 -135.6 -129.3 -140.6 12.3 2.06 3 13 +#> log_lik[21] -61.6 -55.0 -51.7 -55.6 3.5 2.06 3 13 +#> log_lik[22] -10.9 -9.8 -9.2 -9.9 0.6 2.06 3 13 +#> log_lik[23] -2.7 -2.7 -2.6 -2.7 0.0 2.06 4 13 +#> log_lik[24] -22.7 -20.3 -19.1 -20.5 1.3 2.06 3 13 +#> log_lik[25] -2201.5 -1891.3 -1793.6 -1936.6 143.6 2.06 3 13 +#> log_lik[26] -325.3 -272.8 -257.1 -280.6 24.1 2.06 3 13 +#> log_lik[27] -61.3 -51.7 -48.5 -53.2 4.5 2.06 3 13 +#> log_lik[28] -822.6 -699.8 -661.0 -717.8 56.9 2.06 3 13 +#> log_lik[29] -1091.4 -933.9 -883.5 -956.3 73.0 2.06 3 13 +#> log_lik[30] -156.6 -130.9 -123.1 -134.7 11.8 2.06 3 13 +#> log_lik[31] -28.9 -24.4 -22.9 -25.1 2.1 2.06 3 13 +#> log_lik[32] -397.9 -337.2 -317.8 -345.9 28.2 2.06 3 13 +#> log_lik[33] -3348.2 -2873.4 -2727.0 -2943.1 218.7 2.06 3 13 +#> log_lik[34] -468.3 -391.9 -369.4 -403.2 34.9 2.06 3 13 +#> log_lik[35] -92.0 -77.3 -72.5 -79.5 6.9 2.06 3 13 +#> log_lik[36] -1240.0 -1053.6 -995.9 -1081.0 86.0 2.06 3 13 +#> log_lik[37] -1304.0 -1122.5 -1063.5 -1147.0 84.0 2.06 3 13 +#> log_lik[38] -188.8 -158.7 -149.4 -162.9 13.8 2.06 3 13 +#> log_lik[39] -40.6 -34.4 -32.3 -35.3 2.9 2.06 4 13 +#> log_lik[40] -501.2 -427.4 -403.4 -437.5 34.2 2.06 3 13 +#> log_lik[41] -114.2 -93.8 -90.7 -98.3 8.8 2.06 4 13 +#> log_lik[42] -17.2 -14.1 -13.6 -14.8 1.3 2.06 4 13 +#> log_lik[43] -4.7 -4.2 -4.1 -4.3 0.2 2.06 4 13 +#> log_lik[44] -43.2 -35.4 -34.1 -37.1 3.4 2.06 3 13 +#> log_lik[45] -202.1 -163.2 -156.0 -171.2 16.8 2.06 3 13 +#> log_lik[46] -26.8 -21.4 -20.4 -22.5 2.3 2.06 3 13 +#> log_lik[47] -7.8 -6.6 -6.4 -6.9 0.5 2.06 3 13 +#> log_lik[48] -80.5 -64.8 -61.7 -67.9 6.8 2.06 3 13 +#> log_lik[49] -4509.2 -3816.0 -3634.1 -3933.2 311.7 2.06 3 13 +#> log_lik[50] -646.1 -533.2 -504.4 -552.1 50.5 2.06 3 13 +#> log_lik[51] -120.7 -99.9 -94.0 -103.4 9.5 2.06 3 13 +#> log_lik[52] -1661.2 -1391.7 -1320.0 -1437.0 121.5 2.06 3 13 +#> log_lik[53] -734.7 -604.7 -574.6 -628.5 57.4 2.06 3 13 +#> log_lik[54] -111.6 -90.1 -85.1 -93.9 9.5 2.06 3 13 +#> log_lik[55] -21.0 -17.2 -16.3 -17.9 1.7 2.06 3 13 +#> log_lik[56] -272.7 -222.4 -210.6 -231.6 22.3 2.06 3 13 +#> log_lik[57] -2111.4 -1777.3 -1689.6 -1833.5 150.1 2.06 3 13 +#> log_lik[58] -303.1 -249.0 -235.2 -258.1 24.2 2.06 3 13 +#> log_lik[59] -56.3 -46.5 -43.8 -48.2 4.5 2.06 3 13 +#> log_lik[60] -766.2 -638.4 -604.5 -659.8 57.5 2.06 3 13 +#> log_lik[61] -720.1 -603.1 -574.8 -624.2 52.3 2.06 3 13 +#> log_lik[62] -116.9 -96.1 -91.1 -99.8 9.3 2.06 3 13 +#> log_lik[63] -20.4 -17.0 -16.1 -17.6 1.5 2.06 4 13 +#> log_lik[64] -265.4 -220.3 -209.1 -228.3 20.2 2.06 3 13 +#> log_lik[65] -2.0 -2.0 -1.9 -2.0 0.0 1.25 13 13 +#> log_lik[66] -1.9 -1.9 -1.8 -1.9 0.0 2.06 3 13 +#> log_lik[67] -1.9 -1.9 -1.8 -1.9 0.0 2.06 3 13 +#> log_lik[68] -1.9 -1.9 -1.9 -1.9 0.0 1.58 4 13 +#> log_lik[69] -907.7 -773.7 -730.5 -791.8 61.6 2.06 3 13 +#> log_lik[70] -137.2 -114.3 -107.3 -117.5 10.4 2.06 3 13 +#> log_lik[71] -32.3 -27.3 -25.7 -28.0 2.3 2.06 4 13 +#> log_lik[72] -368.3 -311.2 -292.9 -319.0 26.3 2.06 3 13 +#> log_lik[73] -2786.6 -2372.0 -2246.2 -2432.4 188.9 2.06 3 13 +#> log_lik[74] -389.2 -323.0 -303.7 -332.8 29.9 2.06 3 13 +#> log_lik[75] -85.2 -71.2 -66.7 -73.3 6.5 2.06 3 13 +#> log_lik[76] -1082.2 -912.5 -860.8 -937.3 77.5 2.06 3 13 +#> log_lik[77] -151.7 -124.6 -115.7 -127.7 12.2 2.06 4 13 +#> log_lik[78] -22.4 -18.3 -17.0 -18.8 1.8 2.06 3 13 +#> log_lik[79] -8.5 -7.3 -6.9 -7.5 0.5 2.06 4 13 +#> log_lik[80] -69.2 -56.8 -52.8 -58.3 5.6 2.06 3 13 +#> xstar[1,1] -0.8 0.8 1.7 0.6 0.9 0.94 13 13 +#> sigma[1] 2.4 2.6 2.7 2.6 0.1 2.06 3 13 +#> lp__ -50482.1 -43853.2 -41986.7 -44903.8 3005.0 2.06 3 13 #> #> For each parameter, Bulk_ESS and Tail_ESS are crude measures of #> effective sample size for bulk and tail quantities respectively (an ESS > 100 diff --git a/docs/reference/find_dfa_trends.html b/docs/reference/find_dfa_trends.html index 10bcbe2..318d840 100644 --- a/docs/reference/find_dfa_trends.html +++ b/docs/reference/find_dfa_trends.html @@ -73,7 +73,7 @@ bayesdfa - 1.0.0 + 1.1.0
@@ -212,12 +212,13 @@

Examp y = s$y_sim, iter = 50, kmin = 1, kmax = 2, chains = 1, compare_normal = FALSE, variance = "equal", convergence_threshold = 1.1, - control = list(adapt_delta = 0.95, max_treedepth = 20)) + control = list(adapt_delta = 0.95, max_treedepth = 20) +)
#> #> SAMPLING FOR MODEL 'dfa' NOW (CHAIN 1). #> Chain 1: -#> Chain 1: Gradient evaluation took 4.5e-05 seconds -#> Chain 1: 1000 transitions using 10 leapfrog steps per transition would take 0.45 seconds. +#> Chain 1: Gradient evaluation took 4.3e-05 seconds +#> Chain 1: 1000 transitions using 10 leapfrog steps per transition would take 0.43 seconds. #> Chain 1: Adjust your expectations accordingly! #> Chain 1: #> Chain 1: @@ -242,12 +243,13 @@

Examp #> Chain 1: Iteration: 45 / 50 [ 90%] (Sampling) #> Chain 1: Iteration: 50 / 50 [100%] (Sampling) #> Chain 1: -#> Chain 1: Elapsed Time: 0.583761 seconds (Warm-up) -#> Chain 1: 0.662246 seconds (Sampling) -#> Chain 1: 1.24601 seconds (Total) -#> Chain 1:

#> Warning: There were 1 divergent transitions after warmup. See +#> Chain 1: Elapsed Time: 0.002605 seconds (Warm-up) +#> Chain 1: 0.156246 seconds (Sampling) +#> Chain 1: 0.158851 seconds (Total) +#> Chain 1:
#> Warning: There were 5 divergent transitions after warmup. See #> http://mc-stan.org/misc/warnings.html#divergent-transitions-after-warmup -#> to find out why this is a problem and how to eliminate them.
#> Warning: Examine the pairs() plot to diagnose sampling problems
#> Warning: The largest R-hat is 1.22, indicating chains have not mixed. +#> to find out why this is a problem and how to eliminate them.
#> Warning: There were 1 chains where the estimated Bayesian Fraction of Missing Information was low. See +#> http://mc-stan.org/misc/warnings.html#bfmi-low
#> Warning: Examine the pairs() plot to diagnose sampling problems
#> Warning: The largest R-hat is 2.1, indicating chains have not mixed. #> Running the chains for more iterations may help. See #> http://mc-stan.org/misc/warnings.html#r-hat
#> Warning: Bulk Effective Samples Size (ESS) is too low, indicating posterior means and medians may be unreliable. #> Running the chains for more iterations may help. See @@ -255,95 +257,94 @@

Examp #> Running the chains for more iterations may help. See #> http://mc-stan.org/misc/warnings.html#tail-ess

#> Inference for the input samples (1 chains: each with iter = 25; warmup = 12): #> -#> Q5 Q50 Q95 Mean SD Rhat Bulk_ESS Tail_ESS -#> x[1,1] 1.4 2.2 4.3 2.6 1.1 1.18 8 13 -#> x[1,2] 1.6 2.1 4.5 2.6 1.2 1.30 8 13 -#> x[1,3] 0.3 1.4 3.4 1.4 1.0 0.98 13 13 -#> x[1,4] -0.9 -0.2 0.9 -0.1 0.6 1.03 13 13 -#> x[1,5] -4.3 -2.2 -1.2 -2.4 1.2 1.12 13 13 -#> x[1,6] -5.6 -2.8 -2.2 -3.3 1.3 1.58 7 13 -#> x[1,7] -5.7 -3.3 -1.9 -3.4 1.3 1.30 5 13 -#> x[1,8] -6.1 -3.5 -1.9 -3.5 1.4 1.15 8 13 -#> x[1,9] -4.9 -3.7 -2.8 -3.7 0.8 1.30 6 13 -#> x[1,10] -5.5 -3.3 -2.6 -3.7 1.0 1.47 5 13 -#> x[1,11] -4.3 -2.2 -1.4 -2.6 1.0 1.10 11 13 -#> x[1,12] -2.6 -1.6 -0.6 -1.6 0.7 0.94 13 13 -#> x[1,13] -0.6 0.5 1.2 0.4 0.6 1.09 13 13 -#> x[1,14] 1.9 2.8 4.4 2.8 0.9 1.06 13 13 -#> x[1,15] 2.4 3.7 6.2 3.9 1.3 1.19 6 13 -#> x[1,16] 1.9 3.4 5.3 3.6 1.1 1.06 11 13 -#> x[1,17] 1.2 2.5 4.2 2.7 1.1 1.04 13 13 -#> x[1,18] 0.4 1.3 2.5 1.5 0.8 1.05 13 13 -#> x[1,19] 0.1 1.0 1.8 0.9 0.6 1.24 8 13 -#> x[1,20] 0.2 1.6 3.1 1.7 0.9 0.98 13 13 -#> Z[1,1] 0.2 0.3 0.4 0.3 0.1 1.18 7 13 -#> Z[2,1] 0.2 0.4 0.4 0.3 0.1 1.58 13 13 -#> Z[3,1] 0.2 0.3 0.4 0.3 0.1 1.27 6 13 -#> log_lik[1] -3.9 -2.8 -1.6 -2.6 0.9 0.94 13 13 -#> log_lik[2] -2.0 -1.1 -0.5 -1.2 0.6 0.92 13 13 -#> log_lik[3] -2.1 -1.0 -0.7 -1.2 0.5 1.03 13 13 -#> log_lik[4] -1.7 -1.0 -0.5 -1.1 0.5 1.00 13 13 -#> log_lik[5] -1.5 -0.8 -0.4 -0.8 0.4 0.94 13 13 -#> log_lik[6] -1.2 -0.7 -0.4 -0.7 0.3 0.93 13 13 -#> log_lik[7] -5.0 -2.7 -2.1 -3.1 1.2 0.92 13 13 -#> log_lik[8] -1.2 -0.6 -0.3 -0.7 0.4 1.01 13 13 -#> log_lik[9] -0.7 -0.4 -0.2 -0.4 0.2 1.00 13 13 -#> log_lik[10] -1.0 -0.7 -0.4 -0.7 0.2 1.09 13 13 -#> log_lik[11] -0.5 -0.3 -0.1 -0.3 0.1 0.98 13 13 -#> log_lik[12] -0.5 -0.3 -0.2 -0.3 0.1 1.39 13 13 -#> log_lik[13] -2.0 -1.2 -0.4 -1.2 0.6 1.02 13 13 -#> log_lik[14] -0.7 -0.4 -0.2 -0.4 0.2 0.98 13 13 -#> log_lik[15] -1.4 -1.0 -0.3 -0.8 0.4 0.92 13 13 -#> log_lik[16] -1.3 -0.8 -0.4 -0.8 0.3 1.03 13 13 -#> log_lik[17] -1.1 -0.8 -0.5 -0.8 0.2 0.95 13 13 -#> log_lik[18] -0.5 -0.3 -0.2 -0.3 0.1 1.10 13 13 -#> log_lik[19] -4.5 -2.5 -1.6 -2.7 1.2 0.94 13 13 -#> log_lik[20] -1.3 -0.5 -0.2 -0.6 0.4 0.94 13 13 -#> log_lik[21] -0.9 -0.4 -0.2 -0.5 0.2 0.96 13 13 -#> log_lik[22] -0.7 -0.4 -0.1 -0.4 0.2 0.98 12 13 -#> log_lik[23] -0.5 -0.3 -0.1 -0.4 0.1 1.19 11 13 -#> log_lik[24] -0.5 -0.4 -0.1 -0.3 0.1 1.16 10 13 -#> log_lik[25] -1.1 -0.6 -0.3 -0.6 0.3 1.08 13 13 -#> log_lik[26] -0.6 -0.4 -0.2 -0.4 0.2 1.03 8 13 -#> log_lik[27] -0.5 -0.3 -0.1 -0.3 0.2 1.00 13 13 -#> log_lik[28] -0.7 -0.4 -0.2 -0.4 0.2 1.87 13 13 -#> log_lik[29] -0.6 -0.4 -0.1 -0.3 0.2 1.03 13 13 -#> log_lik[30] -0.8 -0.4 -0.2 -0.5 0.2 1.16 13 13 -#> log_lik[31] -1.2 -1.0 -0.2 -0.8 0.3 0.92 13 13 -#> log_lik[32] -2.2 -1.3 -0.7 -1.3 0.5 0.98 13 13 -#> log_lik[33] -2.0 -0.7 -0.5 -1.0 0.6 0.93 13 13 -#> log_lik[34] -1.7 -1.1 -0.8 -1.1 0.4 0.97 13 13 -#> log_lik[35] -0.8 -0.3 -0.2 -0.4 0.2 0.94 13 13 -#> log_lik[36] -0.5 -0.3 -0.1 -0.3 0.1 0.98 13 13 -#> log_lik[37] -1.1 -0.6 -0.3 -0.7 0.3 0.94 13 13 -#> log_lik[38] -0.9 -0.5 -0.3 -0.5 0.3 0.99 13 13 -#> log_lik[39] -0.7 -0.4 -0.2 -0.4 0.2 1.01 13 13 -#> log_lik[40] -0.7 -0.4 -0.1 -0.4 0.2 1.71 13 13 -#> log_lik[41] -0.4 -0.3 -0.1 -0.3 0.1 1.33 13 13 -#> log_lik[42] -1.3 -0.7 -0.3 -0.7 0.3 1.04 13 13 -#> log_lik[43] -1.1 -0.6 -0.3 -0.6 0.3 0.95 13 13 -#> log_lik[44] -0.9 -0.5 -0.3 -0.5 0.2 0.93 13 13 -#> log_lik[45] -0.9 -0.3 -0.2 -0.4 0.3 1.10 13 13 -#> log_lik[46] -0.8 -0.5 -0.3 -0.5 0.2 1.16 13 13 -#> log_lik[47] -1.2 -0.4 -0.2 -0.6 0.4 0.99 13 13 -#> log_lik[48] -0.6 -0.3 -0.2 -0.4 0.2 1.38 6 13 -#> log_lik[49] -0.7 -0.4 -0.2 -0.4 0.2 0.97 13 13 -#> log_lik[50] -0.8 -0.4 -0.2 -0.4 0.2 1.45 8 13 -#> log_lik[51] -0.8 -0.3 -0.2 -0.4 0.2 1.05 11 13 -#> log_lik[52] -3.7 -2.7 -1.5 -2.6 0.8 1.11 13 13 -#> log_lik[53] -1.6 -0.8 -0.3 -0.9 0.4 1.02 13 13 -#> log_lik[54] -1.5 -0.6 -0.3 -0.8 0.5 1.10 13 13 -#> log_lik[55] -0.9 -0.6 -0.2 -0.6 0.2 1.03 13 13 -#> log_lik[56] -1.6 -0.9 -0.5 -1.0 0.4 1.04 13 13 -#> log_lik[57] -1.5 -0.8 -0.5 -0.9 0.4 0.98 13 13 -#> log_lik[58] -1.2 -0.5 -0.2 -0.6 0.4 0.93 13 13 -#> log_lik[59] -1.8 -0.6 -0.4 -0.8 0.5 0.93 13 13 -#> log_lik[60] -1.4 -0.5 -0.2 -0.6 0.4 1.01 13 13 -#> psi[1] 0.8 2.6 4.5 2.4 1.4 1.32 9 13 -#> xstar[1,1] 0.2 2.2 4.8 2.5 1.7 0.95 13 13 -#> sigma[1] 0.5 0.5 0.6 0.5 0.0 1.08 13 13 -#> nu[1] 7.0 23.3 51.2 24.1 17.4 0.96 13 13 -#> lp__ -59.5 -54.3 -49.1 -54.9 3.4 1.02 13 13 +#> Q5 Q50 Q95 Mean SD Rhat Bulk_ESS Tail_ESS +#> x[1,1] 0.3 0.8 1.1 0.8 0.3 2.06 4 13 +#> x[1,2] -0.5 0.0 0.5 0.0 0.3 2.06 7 13 +#> x[1,3] 0.5 0.6 1.8 0.9 0.5 2.06 4 13 +#> x[1,4] -0.6 -0.4 1.4 0.1 0.9 2.06 4 13 +#> x[1,5] -0.9 -0.6 2.5 0.3 1.4 2.06 4 13 +#> x[1,6] -0.2 0.0 2.3 0.7 1.0 1.87 8 13 +#> x[1,7] -0.3 -0.1 1.9 0.4 0.9 1.87 6 13 +#> x[1,8] 0.1 0.5 1.7 0.7 0.6 1.87 10 13 +#> x[1,9] -0.5 -0.2 2.9 0.6 1.3 2.06 6 13 +#> x[1,10] 0.7 1.1 3.9 1.8 1.3 2.06 6 13 +#> x[1,11] -0.4 -0.2 3.6 0.9 1.7 1.87 5 13 +#> x[1,12] -0.6 -0.3 1.6 0.2 0.9 2.06 6 13 +#> x[1,13] -0.2 1.1 1.7 0.8 0.7 2.06 7 13 +#> x[1,14] -1.3 -0.2 0.2 -0.4 0.5 1.18 8 13 +#> x[1,15] -3.2 -0.4 -0.2 -1.1 1.2 1.87 4 13 +#> x[1,16] -2.4 -0.5 0.2 -0.7 1.0 2.06 4 13 +#> x[1,17] -2.8 -1.0 -0.1 -1.1 1.1 2.06 4 13 +#> x[1,18] -3.2 -1.0 -0.5 -1.5 1.1 2.06 4 13 +#> x[1,19] -2.4 -0.6 -0.2 -1.1 0.8 1.27 6 13 +#> x[1,20] -1.1 1.0 1.4 0.4 1.0 2.06 6 13 +#> Z[1,1] -95.2 -5.2 -0.4 -30.0 43.3 2.06 4 13 +#> Z[2,1] -1.4 -0.3 1.7 0.0 1.1 1.71 13 13 +#> Z[3,1] -1.2 -0.4 0.8 -0.3 0.7 1.71 13 13 +#> log_lik[1] -14.4 -3.0 -0.5 -5.2 5.7 2.06 4 13 +#> log_lik[2] -4.2 -3.6 -1.9 -3.4 0.8 2.06 4 13 +#> log_lik[3] -4.2 -3.8 -2.3 -3.5 0.7 2.06 4 13 +#> log_lik[4] -4.2 -2.9 -0.5 -2.4 1.8 2.06 4 13 +#> log_lik[5] -4.2 -2.9 -1.8 -3.0 1.0 2.06 4 13 +#> log_lik[6] -4.2 -2.9 -1.7 -3.0 1.0 2.06 4 13 +#> log_lik[7] -6.9 -3.0 -0.6 -3.2 2.6 2.06 4 13 +#> log_lik[8] -4.2 -3.1 -1.1 -2.9 1.3 2.06 4 13 +#> log_lik[9] -4.2 -2.9 -1.0 -2.8 1.4 2.06 4 13 +#> log_lik[10] -6.9 -3.0 -0.8 -3.5 2.5 2.06 4 13 +#> log_lik[11] -4.2 -2.9 -0.5 -2.4 1.7 2.06 4 13 +#> log_lik[12] -4.2 -2.9 -0.6 -2.5 1.6 2.06 4 13 +#> log_lik[13] -8.2 -3.4 -0.7 -4.0 3.0 2.06 4 13 +#> log_lik[14] -4.2 -2.9 -0.6 -2.5 1.7 2.06 4 13 +#> log_lik[15] -4.2 -2.9 -0.7 -2.6 1.5 2.06 4 13 +#> log_lik[16] -4.2 -2.9 -0.6 -2.5 1.7 2.06 4 13 +#> log_lik[17] -4.2 -3.8 -1.0 -2.9 1.4 2.06 4 13 +#> log_lik[18] -4.2 -2.9 -0.7 -2.6 1.5 2.06 4 13 +#> log_lik[19] -4.6 -2.9 -0.7 -2.7 1.6 2.06 4 13 +#> log_lik[20] -4.2 -2.9 -1.1 -2.8 1.3 2.06 4 13 +#> log_lik[21] -4.2 -2.9 -1.0 -2.8 1.4 2.06 4 13 +#> log_lik[22] -6.3 -2.9 -0.6 -3.0 2.3 2.06 4 13 +#> log_lik[23] -4.2 -2.9 -0.7 -2.6 1.5 2.06 4 13 +#> log_lik[24] -4.2 -2.9 -0.8 -2.7 1.5 2.06 4 13 +#> log_lik[25] -4.9 -3.8 -0.7 -3.0 1.7 1.87 4 13 +#> log_lik[26] -4.2 -2.9 -0.7 -2.6 1.5 2.06 4 13 +#> log_lik[27] -4.2 -2.9 -0.6 -2.5 1.6 2.06 4 13 +#> log_lik[28] -13.0 -3.0 -0.6 -4.7 4.8 2.06 4 13 +#> log_lik[29] -4.2 -3.1 -0.6 -2.6 1.6 2.06 4 13 +#> log_lik[30] -4.2 -3.7 -0.5 -2.6 1.7 2.06 4 13 +#> log_lik[31] -5.2 -3.0 -0.6 -2.9 1.9 2.06 4 13 +#> log_lik[32] -4.2 -2.9 -0.7 -2.8 1.4 2.06 4 13 +#> log_lik[33] -4.2 -2.9 -0.8 -2.7 1.4 2.06 4 13 +#> log_lik[34] -6.1 -3.0 -0.8 -3.2 2.1 2.06 4 13 +#> log_lik[35] -4.2 -2.9 -0.5 -2.4 1.7 2.06 4 13 +#> log_lik[36] -4.2 -2.9 -0.5 -2.4 1.7 2.06 4 13 +#> log_lik[37] -16.9 -3.3 -0.8 -5.9 6.4 2.06 4 13 +#> log_lik[38] -4.2 -3.0 -0.5 -2.4 1.7 2.06 4 13 +#> log_lik[39] -4.2 -2.9 -0.5 -2.4 1.7 2.06 4 13 +#> log_lik[40] -4.4 -3.0 -0.8 -2.7 1.6 2.06 4 13 +#> log_lik[41] -4.2 -3.5 -0.9 -2.8 1.5 2.06 4 13 +#> log_lik[42] -4.3 -3.8 -1.7 -3.2 1.1 2.06 6 13 +#> log_lik[43] -5.0 -3.0 -0.6 -2.8 1.8 2.06 4 13 +#> log_lik[44] -5.2 -3.8 -0.7 -3.0 1.8 2.06 6 13 +#> log_lik[45] -4.2 -3.0 -0.5 -2.6 1.6 2.06 4 13 +#> log_lik[46] -4.3 -2.9 -0.6 -2.6 1.6 2.06 4 13 +#> log_lik[47] -4.2 -2.9 -0.5 -2.5 1.6 2.06 4 13 +#> log_lik[48] -4.2 -2.9 -0.6 -2.5 1.6 2.06 4 13 +#> log_lik[49] -4.9 -3.1 -0.5 -2.6 1.9 2.06 4 13 +#> log_lik[50] -4.2 -3.3 -0.5 -2.6 1.6 2.06 4 13 +#> log_lik[51] -4.2 -2.9 -0.5 -2.6 1.6 2.06 4 13 +#> log_lik[52] -7.8 -3.4 -0.6 -3.7 2.9 2.06 4 13 +#> log_lik[53] -4.2 -3.0 -0.9 -2.8 1.4 2.06 4 13 +#> log_lik[54] -4.2 -2.9 -0.9 -2.8 1.4 2.06 4 13 +#> log_lik[55] -7.0 -3.7 -0.6 -3.3 2.7 2.06 4 13 +#> log_lik[56] -4.2 -3.0 -0.8 -2.8 1.4 2.06 4 13 +#> log_lik[57] -4.2 -2.9 -0.9 -2.8 1.4 2.06 4 13 +#> log_lik[58] -14.5 -2.9 -0.8 -5.5 5.6 2.06 4 13 +#> log_lik[59] -4.2 -2.9 -0.7 -2.6 1.5 2.06 4 13 +#> log_lik[60] -4.2 -2.9 -0.7 -2.6 1.6 2.06 4 13 +#> xstar[1,1] -2.6 0.2 1.7 -0.1 1.5 1.18 7 13 +#> sigma[1] 0.6 7.4 25.4 11.7 11.5 2.06 4 13 +#> nu[1] 2.5 2.6 4.2 3.1 0.7 2.06 4 13 +#> lp__ -4856.7 -202.5 -67.7 -1503.1 2144.4 2.06 3 13 #> #> For each parameter, Bulk_ESS and Tail_ESS are crude measures of #> effective sample size for bulk and tail quantities respectively (an ESS > 100 @@ -351,8 +352,8 @@

Examp #> factor on rank normalized split chains (at convergence, Rhat <= 1.05).

#> Warning: Some Pareto k diagnostic values are too high. See help('pareto-k-diagnostic') for details.
#> #> SAMPLING FOR MODEL 'dfa' NOW (CHAIN 1). #> Chain 1: -#> Chain 1: Gradient evaluation took 4.4e-05 seconds -#> Chain 1: 1000 transitions using 10 leapfrog steps per transition would take 0.44 seconds. +#> Chain 1: Gradient evaluation took 3.4e-05 seconds +#> Chain 1: 1000 transitions using 10 leapfrog steps per transition would take 0.34 seconds. #> Chain 1: Adjust your expectations accordingly! #> Chain 1: #> Chain 1: @@ -377,12 +378,10 @@

Examp #> Chain 1: Iteration: 45 / 50 [ 90%] (Sampling) #> Chain 1: Iteration: 50 / 50 [100%] (Sampling) #> Chain 1: -#> Chain 1: Elapsed Time: 0.048697 seconds (Warm-up) -#> Chain 1: 0.972661 seconds (Sampling) -#> Chain 1: 1.02136 seconds (Total) -#> Chain 1:

#> Warning: There were 7 divergent transitions after warmup. See -#> http://mc-stan.org/misc/warnings.html#divergent-transitions-after-warmup -#> to find out why this is a problem and how to eliminate them.
#> Warning: There were 1 chains where the estimated Bayesian Fraction of Missing Information was low. See +#> Chain 1: Elapsed Time: 0.012887 seconds (Warm-up) +#> Chain 1: 0.015122 seconds (Sampling) +#> Chain 1: 0.028009 seconds (Total) +#> Chain 1:
#> Warning: There were 1 chains where the estimated Bayesian Fraction of Missing Information was low. See #> http://mc-stan.org/misc/warnings.html#bfmi-low
#> Warning: Examine the pairs() plot to diagnose sampling problems
#> Warning: The largest R-hat is NA, indicating chains have not mixed. #> Running the chains for more iterations may help. See #> http://mc-stan.org/misc/warnings.html#r-hat
#> Warning: Bulk Effective Samples Size (ESS) is too low, indicating posterior means and medians may be unreliable. @@ -391,128 +390,126 @@

Examp #> Running the chains for more iterations may help. See #> http://mc-stan.org/misc/warnings.html#tail-ess

#> Inference for the input samples (1 chains: each with iter = 25; warmup = 12): #> -#> Q5 Q50 Q95 Mean SD Rhat Bulk_ESS Tail_ESS -#> x[1,1] -0.4 0.8 2.6 1.1 1.1 1.08 8 13 -#> x[2,1] 0.9 1.5 3.6 1.9 1.0 1.09 9 13 -#> x[1,2] -0.3 0.5 1.8 0.6 0.7 1.58 5 13 -#> x[2,2] 0.8 1.5 5.0 2.5 1.6 1.58 9 13 -#> x[1,3] -1.6 -0.4 1.1 -0.5 0.9 0.95 13 13 -#> x[2,3] 0.8 1.8 6.0 2.6 1.9 1.39 5 13 -#> x[1,4] -4.2 -1.1 0.0 -1.6 1.5 1.12 7 13 -#> x[2,4] -0.4 1.7 5.2 1.7 2.1 1.71 4 13 -#> x[1,5] -6.7 -2.7 -0.8 -2.9 2.1 1.09 7 13 -#> x[2,5] -1.6 0.1 3.8 0.6 1.9 1.32 5 13 -#> x[1,6] -4.9 -2.3 -0.8 -2.6 1.4 1.10 7 13 -#> x[2,6] -3.4 -0.3 2.2 -0.5 1.8 1.05 13 13 -#> x[1,7] -3.9 -1.7 -0.3 -2.0 1.4 1.01 9 13 -#> x[2,7] -3.2 -0.7 0.3 -1.1 1.3 1.19 13 13 -#> x[1,8] -6.6 -1.8 -0.4 -2.7 2.2 0.93 12 13 -#> x[2,8] -4.5 -0.3 1.0 -0.8 1.9 1.19 7 13 -#> x[1,9] -7.5 -2.9 -1.3 -3.6 2.3 1.05 10 13 -#> x[2,9] -3.3 0.4 2.9 0.3 2.1 1.02 13 13 -#> x[1,10] -5.9 -3.2 -1.8 -3.7 1.6 0.92 9 13 -#> x[2,10] -2.0 1.0 3.2 0.9 1.8 1.12 13 13 -#> x[1,11] -5.2 -2.6 -1.2 -3.0 1.6 1.04 9 13 -#> x[2,11] -0.7 1.5 4.6 1.6 1.9 1.02 13 13 -#> x[1,12] -3.2 -1.9 -0.5 -1.9 1.0 1.14 13 13 -#> x[2,12] -1.0 0.2 4.0 0.7 1.7 1.32 13 13 -#> x[1,13] -0.3 0.5 1.8 0.5 0.8 1.24 13 13 -#> x[2,13] -1.8 -0.2 2.5 -0.2 1.5 1.27 13 13 -#> x[1,14] 1.6 2.3 6.9 3.5 2.1 1.01 13 13 -#> x[2,14] -2.4 -0.2 1.8 -0.4 1.4 1.21 13 13 -#> x[1,15] 1.9 3.2 8.4 4.5 2.6 0.99 13 13 -#> x[2,15] -3.2 -0.1 0.9 -0.7 1.4 1.05 13 13 -#> x[1,16] 2.0 3.4 7.8 4.2 2.5 1.01 11 13 -#> x[2,16] -5.5 -0.9 0.4 -1.4 2.0 1.32 8 13 -#> x[1,17] 1.7 2.8 6.5 3.4 1.9 1.04 11 13 -#> x[2,17] -5.4 -1.3 0.1 -1.7 1.9 1.19 7 13 -#> x[1,18] 1.3 2.1 6.0 2.9 1.8 0.97 13 13 -#> x[2,18] -6.4 -2.0 -0.5 -2.8 2.2 1.30 6 13 -#> x[1,19] 1.0 2.1 5.4 2.7 1.7 0.97 13 13 -#> x[2,19] -8.6 -3.2 -0.4 -3.8 3.0 1.30 6 13 -#> x[1,20] 1.6 4.4 8.5 4.7 2.7 1.13 8 13 -#> x[2,20] -9.2 -3.3 0.3 -3.9 3.5 1.71 4 13 -#> Z[1,1] 0.2 0.3 0.6 0.4 0.2 1.47 10 13 -#> Z[2,1] 0.2 0.4 0.6 0.4 0.2 1.12 13 13 -#> Z[3,1] 0.2 0.4 0.7 0.4 0.2 0.92 13 13 -#> Z[1,2] 0.0 0.0 0.0 0.0 0.0 1.00 13 13 -#> Z[2,2] 0.1 0.4 1.1 0.5 0.4 1.47 5 13 -#> Z[3,2] 0.1 0.4 1.1 0.5 0.4 1.47 4 13 -#> log_lik[1] -3.0 -1.7 -0.1 -1.6 1.0 1.03 11 13 -#> log_lik[2] -1.7 -0.3 0.0 -0.6 0.7 0.92 13 13 -#> log_lik[3] -1.6 -0.6 0.1 -0.7 0.7 1.16 8 13 -#> log_lik[4] -0.6 -0.1 0.1 -0.1 0.2 1.06 13 13 -#> log_lik[5] -1.1 -0.5 0.1 -0.4 0.4 1.03 13 13 -#> log_lik[6] -0.8 -0.2 0.1 -0.3 0.3 1.25 6 13 -#> log_lik[7] -4.0 -1.4 -0.5 -1.7 1.2 0.93 13 13 -#> log_lik[8] -0.4 -0.2 0.1 -0.2 0.2 1.19 10 13 -#> log_lik[9] -0.8 -0.1 0.1 -0.2 0.3 1.16 8 13 -#> log_lik[10] -4.6 -1.7 -0.7 -2.4 1.5 0.95 13 13 -#> log_lik[11] -0.3 -0.1 0.1 -0.1 0.2 0.93 13 13 -#> log_lik[12] -0.6 -0.2 0.0 -0.3 0.2 1.01 13 13 -#> log_lik[13] -3.2 -0.9 -0.2 -1.2 1.1 1.30 5 13 -#> log_lik[14] -0.9 -0.2 0.1 -0.2 0.4 1.03 8 13 -#> log_lik[15] -1.1 -0.3 0.0 -0.4 0.4 1.05 13 13 -#> log_lik[16] -1.1 -0.7 0.0 -0.5 0.4 1.58 5 13 -#> log_lik[17] -2.2 -0.7 0.0 -0.9 0.8 1.09 9 13 -#> log_lik[18] -0.9 -0.3 0.1 -0.3 0.4 1.14 12 13 -#> log_lik[19] -3.2 -1.7 -0.5 -1.8 1.0 1.16 10 13 -#> log_lik[20] -1.6 -0.4 -0.1 -0.6 0.5 0.99 13 13 -#> log_lik[21] -1.2 -0.3 0.1 -0.4 0.5 1.00 13 13 -#> log_lik[22] -1.5 -0.2 0.1 -0.4 0.6 0.98 12 13 -#> log_lik[23] -1.0 -0.1 0.1 -0.2 0.4 1.05 12 13 -#> log_lik[24] -0.6 -0.1 0.0 -0.2 0.2 0.95 13 13 -#> log_lik[25] -2.3 -0.6 0.0 -0.9 0.9 0.94 13 13 -#> log_lik[26] -1.5 -0.2 0.1 -0.4 0.7 0.92 13 13 -#> log_lik[27] -0.5 -0.1 0.2 -0.1 0.2 1.07 12 13 -#> log_lik[28] -1.0 -0.2 0.2 -0.3 0.4 1.03 13 13 -#> log_lik[29] -1.3 -0.3 0.1 -0.4 0.5 1.47 13 13 -#> log_lik[30] -1.6 -0.6 -0.1 -0.7 0.5 1.09 12 13 -#> log_lik[31] -1.8 -0.4 -0.1 -0.7 0.6 1.58 13 13 -#> log_lik[32] -2.1 -0.3 0.1 -0.6 0.8 1.24 6 13 -#> log_lik[33] -1.1 -0.2 0.1 -0.3 0.5 1.38 5 13 -#> log_lik[34] -2.0 -0.9 0.1 -1.0 0.7 0.99 13 13 -#> log_lik[35] -1.5 -0.7 -0.1 -0.7 0.5 1.25 13 13 -#> log_lik[36] -0.6 -0.2 0.1 -0.2 0.3 1.58 5 13 -#> log_lik[37] -1.4 -0.6 0.0 -0.6 0.6 0.93 13 13 -#> log_lik[38] -1.6 -0.2 0.1 -0.5 0.6 1.07 13 13 -#> log_lik[39] -0.8 -0.1 0.0 -0.3 0.3 1.14 11 13 -#> log_lik[40] -0.8 -0.2 0.1 -0.3 0.3 1.19 8 13 -#> log_lik[41] -0.6 -0.2 0.1 -0.2 0.2 1.00 13 13 -#> log_lik[42] -0.9 -0.5 0.0 -0.5 0.3 0.92 13 13 -#> log_lik[43] -1.1 -0.2 0.1 -0.3 0.4 0.96 13 13 -#> log_lik[44] -1.2 -0.2 0.0 -0.3 0.4 0.92 11 13 -#> log_lik[45] -1.7 -0.3 0.1 -0.6 0.6 0.95 13 13 -#> log_lik[46] -0.7 -0.2 0.1 -0.2 0.3 1.09 13 13 -#> log_lik[47] -0.9 -0.5 0.0 -0.5 0.3 0.97 11 13 -#> log_lik[48] -0.6 -0.3 0.1 -0.3 0.3 1.24 13 13 -#> log_lik[49] -1.3 -0.2 0.2 -0.3 0.5 1.09 12 13 -#> log_lik[50] -0.5 -0.1 0.1 -0.2 0.2 1.01 9 13 -#> log_lik[51] -0.6 -0.2 0.1 -0.2 0.2 1.71 13 13 -#> log_lik[52] -2.8 -1.4 -0.7 -1.6 0.7 1.09 13 13 -#> log_lik[53] -1.0 -0.3 -0.1 -0.4 0.4 1.10 13 13 -#> log_lik[54] -0.7 -0.2 0.0 -0.3 0.3 1.03 13 13 -#> log_lik[55] -0.3 -0.1 0.1 -0.1 0.2 1.38 5 13 -#> log_lik[56] -0.8 -0.2 0.1 -0.2 0.3 1.07 13 13 -#> log_lik[57] -0.7 -0.1 0.0 -0.2 0.3 0.93 13 13 -#> log_lik[58] -2.2 -0.9 0.0 -1.0 0.8 1.24 5 13 -#> log_lik[59] -2.7 -0.4 0.2 -0.7 1.0 1.15 8 13 -#> log_lik[60] -1.4 -0.3 0.0 -0.5 0.5 1.12 13 13 -#> psi[1] 0.7 1.2 6.6 2.7 2.4 0.92 13 13 -#> psi[2] 0.5 1.1 5.2 2.1 2.0 1.18 8 13 -#> xstar[1,1] 3.2 6.5 10.4 6.4 2.6 1.08 7 13 -#> xstar[2,1] -10.1 -3.2 1.0 -3.8 4.1 1.71 4 13 -#> sigma[1] 0.3 0.4 0.5 0.4 0.1 1.32 5 13 -#> nu[1] 5.9 17.2 66.9 26.6 26.3 1.18 7 13 -#> lp__ -69.6 -58.1 -43.9 -57.0 9.5 1.30 5 13 +#> Q5 Q50 Q95 Mean SD Rhat Bulk_ESS Tail_ESS +#> x[1,1] 0.2 0.3 0.3 0.3 0.0 1.58 4 13 +#> x[2,1] 2.0 2.1 2.1 2.0 0.0 2.06 4 13 +#> x[1,2] -0.1 -0.1 0.0 -0.1 0.0 1.12 7 13 +#> x[2,2] 0.6 0.7 0.8 0.7 0.0 2.06 4 13 +#> x[1,3] -0.5 -0.4 -0.3 -0.4 0.0 1.19 8 13 +#> x[2,3] -0.9 -0.8 -0.7 -0.8 0.0 2.06 4 13 +#> x[1,4] 0.2 0.4 0.4 0.3 0.1 1.39 7 13 +#> x[2,4] -2.4 -2.4 -2.3 -2.4 0.0 1.58 4 13 +#> x[1,5] -1.3 -1.2 -1.2 -1.2 0.0 1.58 7 13 +#> x[2,5] -0.3 -0.2 -0.1 -0.2 0.0 1.32 5 13 +#> x[1,6] 0.0 0.1 0.1 0.1 0.1 1.45 7 13 +#> x[2,6] 1.3 1.3 1.4 1.3 0.1 1.48 4 13 +#> x[1,7] -1.1 -1.1 -1.0 -1.0 0.0 1.38 7 13 +#> x[2,7] -0.4 -0.4 -0.3 -0.4 0.1 1.30 5 13 +#> x[1,8] -1.3 -1.2 -1.2 -1.2 0.1 1.25 6 13 +#> x[2,8] -1.5 -1.5 -1.3 -1.4 0.1 1.58 6 13 +#> x[1,9] -1.5 -1.4 -1.3 -1.4 0.1 0.98 7 13 +#> x[2,9] 0.5 0.5 0.7 0.6 0.1 1.39 4 13 +#> x[1,10] -0.5 -0.4 -0.3 -0.4 0.1 0.98 7 13 +#> x[2,10] 0.5 0.6 0.7 0.6 0.1 1.39 4 13 +#> x[1,11] 0.4 0.6 0.7 0.6 0.1 1.24 5 13 +#> x[2,11] -0.1 0.0 0.2 0.0 0.1 2.06 3 13 +#> x[1,12] 0.5 0.7 0.8 0.7 0.1 1.39 4 13 +#> x[2,12] 0.2 0.3 0.5 0.3 0.1 2.06 3 13 +#> x[1,13] 0.1 0.3 0.4 0.3 0.1 1.30 5 13 +#> x[2,13] 1.1 1.2 1.4 1.2 0.1 2.06 3 13 +#> x[1,14] -1.2 -1.1 -1.0 -1.1 0.1 1.45 5 13 +#> x[2,14] 0.2 0.2 0.5 0.3 0.1 1.71 4 13 +#> x[1,15] -0.1 0.1 0.1 0.0 0.1 1.45 5 13 +#> x[2,15] 0.4 0.4 0.6 0.4 0.1 1.21 5 13 +#> x[1,16] 0.0 0.2 0.2 0.2 0.1 1.71 5 13 +#> x[2,16] 1.8 1.8 2.0 1.8 0.1 1.58 4 13 +#> x[1,17] 1.2 1.3 1.4 1.3 0.1 1.58 4 13 +#> x[2,17] 0.6 0.6 0.7 0.6 0.0 0.98 10 13 +#> x[1,18] 2.4 2.6 2.7 2.6 0.1 1.87 4 13 +#> x[2,18] -0.9 -0.8 -0.6 -0.8 0.1 1.47 4 13 +#> x[1,19] 0.5 0.7 0.8 0.7 0.1 1.87 4 13 +#> x[2,19] -1.5 -1.4 -1.3 -1.4 0.1 1.58 4 13 +#> x[1,20] -0.4 -0.2 -0.1 -0.3 0.1 1.71 4 13 +#> x[2,20] -3.1 -3.0 -2.8 -2.9 0.1 1.58 4 13 +#> Z[1,1] -95.9 -95.0 -90.4 -94.4 2.2 2.06 3 13 +#> Z[2,1] -1.1 -0.2 1.4 -0.1 0.8 1.04 9 13 +#> Z[3,1] -0.3 0.4 1.1 0.5 0.5 1.27 5 13 +#> Z[1,2] 0.0 0.0 0.0 0.0 0.0 1.00 13 13 +#> Z[2,2] -77.1 -38.5 1.1 -39.8 29.3 2.06 3 13 +#> Z[3,2] -1.1 0.9 1.3 0.5 0.9 1.87 4 13 +#> log_lik[1] -4.9 -4.9 -4.8 -4.9 0.0 1.87 4 13 +#> log_lik[2] -10.7 -6.4 -4.7 -7.2 2.3 2.06 4 13 +#> log_lik[3] -4.7 -4.7 -4.7 -4.7 0.0 1.18 9 13 +#> log_lik[4] -4.8 -4.7 -4.7 -4.7 0.0 0.93 9 13 +#> log_lik[5] -5.3 -4.9 -4.7 -5.0 0.2 2.06 4 13 +#> log_lik[6] -4.7 -4.7 -4.7 -4.7 0.0 1.04 9 13 +#> log_lik[7] -5.2 -5.0 -5.0 -5.1 0.1 1.14 9 13 +#> log_lik[8] -5.8 -4.9 -4.7 -5.1 0.4 2.06 3 13 +#> log_lik[9] -4.7 -4.7 -4.7 -4.7 0.0 1.11 8 13 +#> log_lik[10] -5.1 -5.0 -4.8 -5.0 0.1 1.21 6 13 +#> log_lik[11] -13.4 -6.9 -4.7 -8.1 3.4 2.06 4 13 +#> log_lik[12] -4.7 -4.7 -4.7 -4.7 0.0 1.30 8 13 +#> log_lik[13] -8.5 -8.2 -7.9 -8.1 0.2 1.37 12 13 +#> log_lik[14] -4.8 -4.7 -4.7 -4.8 0.0 2.06 4 13 +#> log_lik[15] -4.7 -4.7 -4.7 -4.7 0.0 1.05 9 13 +#> log_lik[16] -4.8 -4.7 -4.7 -4.7 0.0 1.13 6 13 +#> log_lik[17] -7.1 -5.3 -4.7 -5.7 0.9 2.06 3 13 +#> log_lik[18] -4.7 -4.7 -4.7 -4.7 0.0 1.18 8 13 +#> log_lik[19] -7.5 -7.1 -6.9 -7.2 0.2 1.27 12 13 +#> log_lik[20] -5.0 -4.8 -4.7 -4.8 0.1 2.06 4 13 +#> log_lik[21] -4.7 -4.7 -4.7 -4.7 0.0 1.05 9 13 +#> log_lik[22] -8.7 -8.1 -7.8 -8.1 0.3 1.13 13 13 +#> log_lik[23] -7.9 -5.6 -4.7 -6.0 1.2 2.06 4 13 +#> log_lik[24] -4.7 -4.7 -4.7 -4.7 0.0 1.18 9 13 +#> log_lik[25] -9.9 -9.2 -8.7 -9.2 0.5 0.95 13 13 +#> log_lik[26] -5.1 -4.8 -4.7 -4.9 0.2 2.06 4 13 +#> log_lik[27] -4.7 -4.7 -4.7 -4.7 0.0 1.05 9 13 +#> log_lik[28] -5.3 -5.2 -5.0 -5.1 0.1 0.98 7 13 +#> log_lik[29] -5.2 -4.8 -4.7 -4.9 0.2 2.06 4 13 +#> log_lik[30] -4.7 -4.7 -4.7 -4.7 0.0 1.05 9 13 +#> log_lik[31] -5.8 -5.5 -5.0 -5.5 0.3 1.24 5 13 +#> log_lik[32] -4.7 -4.7 -4.7 -4.7 0.0 1.48 5 13 +#> log_lik[33] -4.7 -4.7 -4.7 -4.7 0.0 1.04 9 13 +#> log_lik[34] -6.1 -5.7 -5.2 -5.7 0.3 1.47 4 13 +#> log_lik[35] -4.8 -4.7 -4.7 -4.7 0.0 2.06 4 13 +#> log_lik[36] -4.7 -4.7 -4.7 -4.7 0.0 1.04 10 13 +#> log_lik[37] -5.1 -4.9 -4.8 -4.9 0.1 1.45 4 13 +#> log_lik[38] -6.6 -5.2 -4.7 -5.5 0.7 2.06 4 13 +#> log_lik[39] -4.7 -4.7 -4.7 -4.7 0.0 1.11 8 13 +#> log_lik[40] -7.9 -7.4 -6.9 -7.3 0.4 1.32 5 13 +#> log_lik[41] -4.8 -4.7 -4.7 -4.7 0.0 2.06 4 13 +#> log_lik[42] -4.7 -4.7 -4.7 -4.7 0.0 1.05 10 13 +#> log_lik[43] -4.8 -4.7 -4.7 -4.7 0.0 1.00 12 13 +#> log_lik[44] -5.0 -4.8 -4.7 -4.8 0.1 2.06 4 13 +#> log_lik[45] -4.7 -4.7 -4.7 -4.7 0.0 1.04 9 13 +#> log_lik[46] -4.9 -4.8 -4.7 -4.8 0.1 1.71 4 13 +#> log_lik[47] -9.5 -6.0 -4.7 -6.7 1.9 2.06 4 13 +#> log_lik[48] -4.7 -4.7 -4.7 -4.7 0.0 1.18 9 13 +#> log_lik[49] -9.2 -8.9 -7.8 -8.7 0.5 1.71 4 13 +#> log_lik[50] -5.3 -4.9 -4.7 -5.0 0.2 2.06 4 13 +#> log_lik[51] -4.7 -4.7 -4.7 -4.7 0.0 1.07 8 13 +#> log_lik[52] -21.3 -20.1 -16.3 -19.6 1.7 1.71 4 13 +#> log_lik[53] -5.9 -4.9 -4.7 -5.1 0.4 2.06 4 13 +#> log_lik[54] -4.7 -4.7 -4.7 -4.7 0.0 1.11 8 13 +#> log_lik[55] -6.1 -5.8 -5.2 -5.8 0.3 1.87 4 13 +#> log_lik[56] -8.1 -5.4 -4.7 -6.0 1.3 2.06 4 13 +#> log_lik[57] -4.7 -4.7 -4.7 -4.7 0.0 1.05 9 13 +#> log_lik[58] -5.1 -4.8 -4.8 -4.9 0.1 1.71 4 13 +#> log_lik[59] -18.6 -8.0 -4.7 -10.1 5.4 2.06 3 13 +#> log_lik[60] -4.7 -4.7 -4.7 -4.7 0.0 1.30 7 13 +#> xstar[1,1] -4.4 -0.1 1.4 -0.5 2.4 0.93 13 13 +#> xstar[2,1] -4.3 -3.0 -1.3 -2.9 1.1 1.03 13 13 +#> sigma[1] 44.0 44.6 45.1 44.6 0.4 1.04 9 13 +#> nu[1] 2.4 2.4 2.5 2.4 0.0 1.19 8 13 +#> lp__ -7979.1 -5627.7 -4448.7 -6026.9 1321.7 2.06 3 13 #> #> For each parameter, Bulk_ESS and Tail_ESS are crude measures of #> effective sample size for bulk and tail quantities respectively (an ESS > 100 #> per chain is considered good), and Rhat is the potential scale reduction #> factor on rank normalized split chains (at convergence, Rhat <= 1.05).
#> Warning: Some Pareto k diagnostic values are too high. See help('pareto-k-diagnostic') for details.
m$summary
#> model num_trends looic cor error converge -#> 1 1 1 101.3445 equal student-t FALSE -#> 2 2 2 309.6716 equal student-t FALSE
m$best_model +#> 1 1 1 2194.503 equal student-t FALSE +#> 2 2 2 3030.814 equal student-t FALSE
m$best_model
#> NULL
# }
diff --git a/docs/reference/find_inverted_chains-1.png b/docs/reference/find_inverted_chains-1.png index 89c20f1..eb3de6b 100644 Binary files a/docs/reference/find_inverted_chains-1.png and b/docs/reference/find_inverted_chains-1.png differ diff --git a/docs/reference/find_inverted_chains.html b/docs/reference/find_inverted_chains.html index 27f53af..58c95c6 100644 --- a/docs/reference/find_inverted_chains.html +++ b/docs/reference/find_inverted_chains.html @@ -73,7 +73,7 @@ bayesdfa - 1.0.0 + 1.1.0 @@ -178,8 +178,8 @@

Examp
#> #> SAMPLING FOR MODEL 'dfa' NOW (CHAIN 1). #> Chain 1: -#> Chain 1: Gradient evaluation took 3.7e-05 seconds -#> Chain 1: 1000 transitions using 10 leapfrog steps per transition would take 0.37 seconds. +#> Chain 1: Gradient evaluation took 3.5e-05 seconds +#> Chain 1: 1000 transitions using 10 leapfrog steps per transition would take 0.35 seconds. #> Chain 1: Adjust your expectations accordingly! #> Chain 1: #> Chain 1: @@ -199,15 +199,15 @@

Examp #> Chain 1: Iteration: 27 / 30 [ 90%] (Sampling) #> Chain 1: Iteration: 30 / 30 [100%] (Sampling) #> Chain 1: -#> Chain 1: Elapsed Time: 0.047819 seconds (Warm-up) -#> Chain 1: 0.3836 seconds (Sampling) -#> Chain 1: 0.431419 seconds (Total) +#> Chain 1: Elapsed Time: 0.001916 seconds (Warm-up) +#> Chain 1: 0.004819 seconds (Sampling) +#> Chain 1: 0.006735 seconds (Total) #> Chain 1: #> #> SAMPLING FOR MODEL 'dfa' NOW (CHAIN 2). #> Chain 2: -#> Chain 2: Gradient evaluation took 2.8e-05 seconds -#> Chain 2: 1000 transitions using 10 leapfrog steps per transition would take 0.28 seconds. +#> Chain 2: Gradient evaluation took 4.3e-05 seconds +#> Chain 2: 1000 transitions using 10 leapfrog steps per transition would take 0.43 seconds. #> Chain 2: Adjust your expectations accordingly! #> Chain 2: #> Chain 2: @@ -227,21 +227,19 @@

Examp #> Chain 2: Iteration: 27 / 30 [ 90%] (Sampling) #> Chain 2: Iteration: 30 / 30 [100%] (Sampling) #> Chain 2: -#> Chain 2: Elapsed Time: 0.001877 seconds (Warm-up) -#> Chain 2: 0.090565 seconds (Sampling) -#> Chain 2: 0.092442 seconds (Total) -#> Chain 2:

#> Warning: There were 2 divergent transitions after warmup. See -#> http://mc-stan.org/misc/warnings.html#divergent-transitions-after-warmup -#> to find out why this is a problem and how to eliminate them.
#> Warning: There were 1 chains where the estimated Bayesian Fraction of Missing Information was low. See -#> http://mc-stan.org/misc/warnings.html#bfmi-low
#> Warning: Examine the pairs() plot to diagnose sampling problems
#> Warning: The largest R-hat is 2.52, indicating chains have not mixed. +#> Chain 2: Elapsed Time: 0.00178 seconds (Warm-up) +#> Chain 2: 0.002975 seconds (Sampling) +#> Chain 2: 0.004755 seconds (Total) +#> Chain 2:
#> Warning: There were 2 chains where the estimated Bayesian Fraction of Missing Information was low. See +#> http://mc-stan.org/misc/warnings.html#bfmi-low
#> Warning: Examine the pairs() plot to diagnose sampling problems
#> Warning: The largest R-hat is 3.12, indicating chains have not mixed. #> Running the chains for more iterations may help. See #> http://mc-stan.org/misc/warnings.html#r-hat
#> Warning: Bulk Effective Samples Size (ESS) is too low, indicating posterior means and medians may be unreliable. #> Running the chains for more iterations may help. See #> http://mc-stan.org/misc/warnings.html#bulk-ess
#> Warning: Tail Effective Samples Size (ESS) is too low, indicating posterior variances and tail quantiles may be unreliable. #> Running the chains for more iterations may help. See -#> http://mc-stan.org/misc/warnings.html#tail-ess
#> Inverting chains 2 for trend 1
# chains were already inverted, but we can redo that, as an example, with: +#> http://mc-stan.org/misc/warnings.html#tail-ess
#> Inverting chains 0 for trend 1
# chains were already inverted, but we can redo that, as an example, with: find_inverted_chains(m$model, plot = TRUE) -
#> [1] 2
+
#> [1] 0
@@ -202,8 +202,8 @@

Examp
#> #> SAMPLING FOR MODEL 'regime_1' NOW (CHAIN 1). #> Chain 1: -#> Chain 1: Gradient evaluation took 2e-05 seconds -#> Chain 1: 1000 transitions using 10 leapfrog steps per transition would take 0.2 seconds. +#> Chain 1: Gradient evaluation took 1.6e-05 seconds +#> Chain 1: 1000 transitions using 10 leapfrog steps per transition would take 0.16 seconds. #> Chain 1: Adjust your expectations accordingly! #> Chain 1: #> Chain 1: @@ -228,9 +228,9 @@

Examp #> Chain 1: Iteration: 45 / 50 [ 90%] (Sampling) #> Chain 1: Iteration: 50 / 50 [100%] (Sampling) #> Chain 1: -#> Chain 1: Elapsed Time: 0.001067 seconds (Warm-up) -#> Chain 1: 0.000758 seconds (Sampling) -#> Chain 1: 0.001825 seconds (Total) +#> Chain 1: Elapsed Time: 0.000976 seconds (Warm-up) +#> Chain 1: 0.000729 seconds (Sampling) +#> Chain 1: 0.001705 seconds (Total) #> Chain 1:

#> Warning: The largest R-hat is 1.43, indicating chains have not mixed. #> Running the chains for more iterations may help. See #> http://mc-stan.org/misc/warnings.html#r-hat
#> Warning: Bulk Effective Samples Size (ESS) is too low, indicating posterior means and medians may be unreliable. @@ -266,9 +266,9 @@

Examp #> Chain 1: Iteration: 45 / 50 [ 90%] (Sampling) #> Chain 1: Iteration: 50 / 50 [100%] (Sampling) #> Chain 1: -#> Chain 1: Elapsed Time: 0.221094 seconds (Warm-up) -#> Chain 1: 0.234495 seconds (Sampling) -#> Chain 1: 0.455589 seconds (Total) +#> Chain 1: Elapsed Time: 0.209232 seconds (Warm-up) +#> Chain 1: 0.23348 seconds (Sampling) +#> Chain 1: 0.442712 seconds (Total) #> Chain 1:

#> Warning: The largest R-hat is NA, indicating chains have not mixed. #> Running the chains for more iterations may help. See #> http://mc-stan.org/misc/warnings.html#r-hat
#> Warning: Bulk Effective Samples Size (ESS) is too low, indicating posterior means and medians may be unreliable. @@ -491,7 +491,7 @@

Examp #> log_lik[100] 0.17 0.02 0.09 -0.05 0.13 0.19 0.24 0.28 25 0.96 #> lp__ 114.02 0.15 0.74 112.57 113.57 114.22 114.57 114.94 25 1.09 #> -#> Samples were drawn using NUTS(diag_e) at Tue May 18 13:31:30 2021. +#> Samples were drawn using NUTS(diag_e) at Tue May 25 06:10:06 2021. #> For each parameter, n_eff is a crude measure of effective sample size, #> and Rhat is the potential scale reduction factor on split chains (at #> convergence, Rhat=1). diff --git a/docs/reference/find_swans-2.png b/docs/reference/find_swans-2.png index 7940e2e..219deca 100644 Binary files a/docs/reference/find_swans-2.png and b/docs/reference/find_swans-2.png differ diff --git a/docs/reference/find_swans-3.png b/docs/reference/find_swans-3.png index 3f60377..2b052ea 100644 Binary files a/docs/reference/find_swans-3.png and b/docs/reference/find_swans-3.png differ diff --git a/docs/reference/find_swans.html b/docs/reference/find_swans.html index eb578d4..5508b4d 100644 --- a/docs/reference/find_swans.html +++ b/docs/reference/find_swans.html @@ -72,7 +72,7 @@ bayesdfa - 1.0.0 + 1.1.0

@@ -179,15 +179,15 @@

Examp
set.seed(1) s <- sim_dfa(num_trends = 1, num_ts = 3, num_years = 30) s$y_sim[1, 15] <- s$y_sim[1, 15] - 6 -plot(s$y_sim[1,], type = "o") +plot(s$y_sim[1, ], type = "o")
abline(v = 15, col = "red")
# only 1 chain and 250 iterations used so example runs quickly: m <- fit_dfa(y = s$y_sim, num_trends = 1, iter = 50, chains = 1, nu_fixed = 2)
#> #> SAMPLING FOR MODEL 'dfa' NOW (CHAIN 1). #> Chain 1: -#> Chain 1: Gradient evaluation took 5.2e-05 seconds -#> Chain 1: 1000 transitions using 10 leapfrog steps per transition would take 0.52 seconds. +#> Chain 1: Gradient evaluation took 4.1e-05 seconds +#> Chain 1: 1000 transitions using 10 leapfrog steps per transition would take 0.41 seconds. #> Chain 1: Adjust your expectations accordingly! #> Chain 1: #> Chain 1: @@ -212,11 +212,12 @@

Examp #> Chain 1: Iteration: 45 / 50 [ 90%] (Sampling) #> Chain 1: Iteration: 50 / 50 [100%] (Sampling) #> Chain 1: -#> Chain 1: Elapsed Time: 0.005366 seconds (Warm-up) -#> Chain 1: 0.055166 seconds (Sampling) -#> Chain 1: 0.060532 seconds (Total) -#> Chain 1:

#> Warning: There were 1 chains where the estimated Bayesian Fraction of Missing Information was low. See -#> http://mc-stan.org/misc/warnings.html#bfmi-low
#> Warning: Examine the pairs() plot to diagnose sampling problems
#> Warning: The largest R-hat is 2.1, indicating chains have not mixed. +#> Chain 1: Elapsed Time: 0.134745 seconds (Warm-up) +#> Chain 1: 0.00172 seconds (Sampling) +#> Chain 1: 0.136465 seconds (Total) +#> Chain 1:
#> Warning: There were 25 divergent transitions after warmup. See +#> http://mc-stan.org/misc/warnings.html#divergent-transitions-after-warmup +#> to find out why this is a problem and how to eliminate them.
#> Warning: Examine the pairs() plot to diagnose sampling problems
#> Warning: The largest R-hat is NA, indicating chains have not mixed. #> Running the chains for more iterations may help. See #> http://mc-stan.org/misc/warnings.html#r-hat
#> Warning: Bulk Effective Samples Size (ESS) is too low, indicating posterior means and medians may be unreliable. #> Running the chains for more iterations may help. See @@ -224,134 +225,133 @@

Examp #> Running the chains for more iterations may help. See #> http://mc-stan.org/misc/warnings.html#tail-ess

#> Inference for the input samples (1 chains: each with iter = 25; warmup = 12): #> -#> Q5 Q50 Q95 Mean SD Rhat Bulk_ESS Tail_ESS -#> x[1,1] 1.6 1.8 1.8 1.7 0.1 2.06 4 13 -#> x[1,2] -0.8 -0.4 -0.4 -0.6 0.2 2.06 4 13 -#> x[1,3] -1.0 -0.4 -0.4 -0.6 0.3 2.06 4 13 -#> x[1,4] 0.8 1.6 1.7 1.3 0.4 2.06 4 13 -#> x[1,5] 0.3 1.2 1.2 0.8 0.4 2.06 4 13 -#> x[1,6] -2.2 -1.2 -1.2 -1.6 0.5 2.06 4 13 -#> x[1,7] 0.0 1.0 1.1 0.6 0.5 2.06 4 13 -#> x[1,8] 1.9 2.9 3.0 2.5 0.5 2.06 4 13 -#> x[1,9] -0.2 0.7 0.7 0.4 0.4 2.06 4 13 -#> x[1,10] -1.8 -1.0 -1.0 -1.3 0.3 2.06 4 13 -#> x[1,11] -0.6 0.0 0.0 -0.2 0.3 2.06 4 13 -#> x[1,12] -0.3 0.2 0.2 0.1 0.2 2.06 3 13 -#> x[1,13] 0.4 0.8 0.8 0.7 0.2 2.06 4 13 -#> x[1,14] 0.3 0.6 0.8 0.6 0.2 2.06 8 13 -#> x[1,15] 3.1 3.2 3.6 3.3 0.2 2.06 8 13 -#> x[1,16] 0.9 0.9 1.6 1.1 0.3 2.06 3 13 -#> x[1,17] -1.8 -1.8 -0.7 -1.4 0.5 2.06 3 13 -#> x[1,18] -2.1 -2.1 -0.6 -1.5 0.7 2.06 4 13 -#> x[1,19] -2.5 -2.5 -0.5 -1.7 0.9 2.06 3 13 -#> x[1,20] -0.4 -0.4 1.6 0.4 0.9 2.06 3 13 -#> x[1,21] -2.7 -2.7 -0.9 -2.0 0.9 2.06 3 13 -#> x[1,22] -3.0 -3.0 -1.3 -2.3 0.8 2.06 3 13 -#> x[1,23] -0.5 -0.5 0.8 0.0 0.6 2.06 3 13 -#> x[1,24] 0.8 0.8 1.5 1.1 0.4 2.06 4 13 -#> x[1,25] 1.0 1.0 1.2 1.1 0.1 2.06 4 13 -#> x[1,26] -1.8 -1.8 -1.7 -1.8 0.0 2.06 4 13 -#> x[1,27] -0.2 0.2 0.2 0.0 0.2 2.06 4 13 -#> x[1,28] -1.5 -0.6 -0.6 -1.0 0.4 2.06 4 13 -#> x[1,29] 0.2 1.6 1.6 1.0 0.7 2.06 4 13 -#> x[1,30] 2.3 4.0 4.1 3.3 0.9 2.06 4 13 -#> Z[1,1] 1.5 1.6 1.6 1.6 0.0 2.06 4 13 -#> Z[2,1] -9.4 33.5 33.9 17.9 18.7 2.06 4 13 -#> Z[3,1] -15.6 38.9 39.2 20.3 23.2 2.06 4 13 -#> log_lik[1] -3.8 -2.2 -2.2 -2.9 0.8 2.06 4 13 -#> log_lik[2] -351.6 -307.6 -3.8 -181.0 171.1 2.06 4 13 -#> log_lik[3] -470.1 -414.5 -4.0 -242.2 229.7 2.06 4 13 -#> log_lik[4] -3.9 -2.0 -2.0 -2.8 0.9 2.06 4 13 -#> log_lik[5] -23.8 -21.9 -3.8 -14.1 10.0 2.06 3 13 -#> log_lik[6] -30.6 -28.2 -3.8 -17.8 13.3 2.06 3 13 -#> log_lik[7] -3.9 -2.0 -1.9 -2.8 1.0 2.06 4 13 -#> log_lik[8] -18.8 -17.8 -3.8 -11.7 7.5 2.06 3 13 -#> log_lik[9] -24.4 -23.2 -3.8 -14.7 10.3 2.06 3 13 -#> log_lik[10] -3.8 -2.0 -2.0 -2.8 0.9 2.06 4 13 -#> log_lik[11] -299.1 -257.1 -3.8 -153.2 144.5 2.06 3 13 -#> log_lik[12] -400.3 -346.7 -3.8 -205.0 194.4 2.06 3 13 -#> log_lik[13] -3.8 -1.9 -1.9 -2.8 1.0 2.06 4 13 -#> log_lik[14] -157.0 -132.8 -3.8 -80.7 74.5 2.06 3 13 -#> log_lik[15] -209.3 -178.4 -3.8 -107.3 100.2 2.06 3 13 -#> log_lik[16] -3.9 -2.5 -2.5 -3.1 0.7 2.06 4 13 -#> log_lik[17] -174.9 -160.0 -3.8 -92.7 85.4 2.06 3 13 -#> log_lik[18] -231.7 -213.6 -4.1 -122.8 113.6 2.06 3 13 -#> log_lik[19] -3.8 -1.9 -1.8 -2.7 1.0 2.06 4 13 -#> log_lik[20] -121.5 -101.7 -3.7 -62.6 57.0 2.06 4 13 -#> log_lik[21] -162.6 -137.1 -3.8 -83.3 77.1 2.06 3 13 -#> log_lik[22] -3.9 -3.3 -3.2 -3.5 0.3 2.06 4 13 -#> log_lik[23] -966.8 -833.8 -3.8 -491.9 471.8 2.06 4 13 -#> log_lik[24] -1291.6 -1122.7 -4.1 -658.5 632.0 2.06 4 13 -#> log_lik[25] -3.8 -1.8 -1.7 -2.7 1.0 2.06 4 13 -#> log_lik[26] -58.6 -47.8 -3.7 -30.8 26.3 2.06 4 13 -#> log_lik[27] -77.9 -63.9 -3.7 -40.5 35.7 2.06 4 13 -#> log_lik[28] -3.9 -2.3 -2.3 -3.0 0.8 2.06 4 13 -#> log_lik[29] -119.2 -110.4 -3.8 -63.9 57.7 2.06 3 13 -#> log_lik[30] -157.6 -147.1 -3.9 -84.3 76.9 2.06 3 13 -#> log_lik[31] -3.8 -1.8 -1.8 -2.7 1.0 2.06 4 13 -#> log_lik[32] -3.9 -2.1 -1.8 -2.8 1.0 2.06 4 13 -#> log_lik[33] -4.0 -2.1 -1.8 -2.8 1.0 2.06 3 13 -#> log_lik[34] -3.8 -1.8 -1.7 -2.7 1.0 2.06 4 13 -#> log_lik[35] -7.1 -5.6 -3.7 -5.2 1.5 2.06 4 13 -#> log_lik[36] -9.3 -7.3 -3.7 -6.3 2.5 2.06 4 13 -#> log_lik[37] -3.8 -1.8 -1.8 -2.7 1.0 2.06 4 13 -#> log_lik[38] -75.8 -64.4 -3.8 -40.0 35.0 2.06 3 13 -#> log_lik[39] -100.8 -86.2 -3.8 -52.7 47.3 2.06 4 13 -#> log_lik[40] -3.8 -1.8 -1.7 -2.7 1.0 2.06 4 13 -#> log_lik[41] -37.3 -31.9 -3.8 -20.6 16.3 2.06 3 13 -#> log_lik[42] -49.8 -42.9 -3.8 -27.0 22.4 2.06 4 13 -#> log_lik[43] -7.7 -7.2 -3.9 -5.8 1.9 2.06 4 13 -#> log_lik[44] -1156.3 -1013.2 -4.0 -592.0 567.4 2.06 4 13 -#> log_lik[45] -1544.0 -1363.5 -4.9 -792.7 759.0 2.06 4 13 -#> log_lik[46] -3.8 -1.9 -1.8 -2.7 1.0 2.06 4 13 -#> log_lik[47] -86.6 -76.6 -3.8 -46.3 40.9 2.06 4 13 -#> log_lik[48] -114.9 -102.4 -4.0 -61.1 54.8 2.06 4 13 -#> log_lik[49] -3.9 -2.9 -2.8 -3.3 0.5 2.06 4 13 -#> log_lik[50] -381.6 -330.2 -3.8 -195.0 184.9 2.06 3 13 -#> log_lik[51] -506.7 -441.8 -3.8 -259.1 246.6 2.06 3 13 -#> log_lik[52] -3.8 -3.0 -2.9 -3.3 0.4 2.06 4 13 -#> log_lik[53] -508.8 -437.8 -3.8 -258.9 246.8 2.06 3 13 -#> log_lik[54] -677.5 -587.3 -3.8 -345.0 329.9 2.06 3 13 -#> log_lik[55] -3.8 -3.4 -3.2 -3.5 0.3 2.06 4 13 -#> log_lik[56] -689.4 -592.1 -3.8 -349.9 334.8 2.06 3 13 -#> log_lik[57] -920.5 -796.8 -3.8 -467.8 448.6 2.06 3 13 -#> log_lik[58] -3.8 -1.8 -1.8 -2.7 1.0 2.06 4 13 -#> log_lik[59] -23.0 -18.0 -3.8 -12.9 8.8 2.06 4 13 -#> log_lik[60] -30.7 -24.0 -3.9 -16.8 12.3 2.06 4 13 -#> log_lik[61] -3.8 -3.4 -3.2 -3.5 0.3 2.06 4 13 -#> log_lik[62] -831.8 -713.3 -3.8 -421.5 404.1 2.06 3 13 -#> log_lik[63] -1109.1 -958.5 -3.8 -562.9 540.5 2.06 3 13 -#> log_lik[64] -4.1 -3.9 -3.7 -3.9 0.1 2.06 4 13 -#> log_lik[65] -1032.7 -890.1 -3.8 -523.9 503.0 2.06 3 13 -#> log_lik[66] -1375.7 -1194.9 -3.9 -699.3 671.9 2.06 3 13 -#> log_lik[67] -3.8 -1.8 -1.8 -2.7 1.0 2.06 4 13 -#> log_lik[68] -26.3 -21.4 -3.8 -14.6 10.5 2.06 3 13 -#> log_lik[69] -34.5 -28.2 -3.8 -18.7 14.4 2.06 4 13 -#> log_lik[70] -3.9 -2.2 -2.1 -2.9 0.9 2.06 4 13 -#> log_lik[71] -69.7 -63.4 -3.8 -38.1 32.9 2.06 3 13 -#> log_lik[72] -91.0 -83.4 -3.9 -49.5 43.6 2.06 4 13 -#> log_lik[73] -3.9 -2.3 -2.3 -3.0 0.8 2.06 4 13 -#> log_lik[74] -125.6 -111.5 -3.8 -66.5 60.5 2.06 3 13 -#> log_lik[75] -165.2 -147.8 -3.8 -87.3 80.2 2.06 3 13 -#> log_lik[76] -3.8 -2.1 -2.1 -2.9 0.9 2.06 4 13 -#> log_lik[77] -333.5 -293.1 -3.8 -171.6 161.9 2.06 4 13 -#> log_lik[78] -445.8 -394.8 -4.1 -229.6 217.3 2.06 4 13 -#> log_lik[79] -3.8 -2.0 -2.0 -2.8 0.9 2.06 4 13 -#> log_lik[80] -10.6 -9.3 -3.8 -7.2 3.3 2.06 4 13 -#> log_lik[81] -13.1 -11.4 -3.8 -8.5 4.5 2.06 4 13 -#> log_lik[82] -3.8 -1.8 -1.8 -2.7 1.0 2.06 4 13 -#> log_lik[83] -30.0 -27.2 -3.8 -17.2 12.7 2.06 4 13 -#> log_lik[84] -40.0 -36.5 -4.0 -22.5 17.5 2.06 4 13 -#> log_lik[85] -3.9 -3.7 -3.5 -3.7 0.1 2.06 4 13 -#> log_lik[86] -311.8 -268.8 -3.7 -160.3 151.5 2.06 4 13 -#> log_lik[87] -410.2 -356.1 -3.7 -210.8 200.2 2.06 4 13 -#> log_lik[88] -8.3 -7.7 -3.8 -6.1 2.2 2.06 4 13 -#> log_lik[89] -1895.4 -1647.1 -3.8 -966.9 930.8 2.06 3 13 -#> log_lik[90] -2513.3 -2200.8 -4.1 -1285.1 1237.0 2.06 3 13 -#> psi[1] 2.5 2.5 2.5 2.5 0.0 1.33 13 13 -#> xstar[1,1] 3.5 5.5 7.4 5.3 1.4 1.58 4 13 -#> sigma[1] 2.3 2.4 18.6 9.3 7.8 2.06 4 13 -#> lp__ -26610.9 -23557.0 -449.9 -13949.9 12784.3 2.06 3 13 +#> Q5 Q50 Q95 Mean SD Rhat Bulk_ESS Tail_ESS +#> x[1,1] -1.3 -1.3 -1.3 -1.3 0.0 1.00 13 13 +#> x[1,2] -1.9 -1.9 -1.9 -1.9 0.0 1.00 13 13 +#> x[1,3] -2.2 -2.2 -2.2 -2.2 0.0 1.00 13 13 +#> x[1,4] -2.4 -2.4 -2.4 -2.4 0.0 1.00 13 13 +#> x[1,5] -2.7 -2.7 -2.7 -2.7 0.0 1.00 13 13 +#> x[1,6] -2.1 -2.1 -2.1 -2.1 0.0 1.00 13 13 +#> x[1,7] -2.1 -2.1 -2.1 -2.1 0.0 1.00 13 13 +#> x[1,8] -2.3 -2.3 -2.3 -2.3 0.0 1.00 13 13 +#> x[1,9] -2.1 -2.1 -2.1 -2.1 0.0 1.00 13 13 +#> x[1,10] -1.8 -1.8 -1.8 -1.8 0.0 1.00 13 13 +#> x[1,11] -1.8 -1.8 -1.8 -1.8 0.0 1.00 13 13 +#> x[1,12] -1.4 -1.4 -1.4 -1.4 0.0 1.00 13 13 +#> x[1,13] -1.1 -1.1 -1.1 -1.1 0.0 1.00 13 13 +#> x[1,14] -0.8 -0.8 -0.8 -0.8 0.0 1.00 13 13 +#> x[1,15] -0.3 -0.3 -0.3 -0.3 0.0 1.00 13 13 +#> x[1,16] -0.7 -0.7 -0.7 -0.7 0.0 1.00 13 13 +#> x[1,17] -1.0 -1.0 -1.0 -1.0 0.0 1.00 13 13 +#> x[1,18] -0.6 -0.6 -0.6 -0.6 0.0 1.00 13 13 +#> x[1,19] -0.3 -0.3 -0.3 -0.3 0.0 1.00 13 13 +#> x[1,20] 0.2 0.2 0.2 0.2 0.0 1.00 13 13 +#> x[1,21] 1.3 1.3 1.3 1.3 0.0 1.00 13 13 +#> x[1,22] 1.1 1.1 1.1 1.1 0.0 1.00 13 13 +#> x[1,23] 0.8 0.8 0.8 0.8 0.0 1.00 13 13 +#> x[1,24] 1.8 1.8 1.8 1.8 0.0 1.00 13 13 +#> x[1,25] 1.9 1.9 1.9 1.9 0.0 1.00 13 13 +#> x[1,26] 3.1 3.1 3.1 3.1 0.0 1.00 13 13 +#> x[1,27] 4.1 4.1 4.1 4.1 0.0 1.00 13 13 +#> x[1,28] 4.9 4.9 4.9 4.9 0.0 1.00 13 13 +#> x[1,29] 5.5 5.5 5.5 5.5 0.0 1.00 13 13 +#> x[1,30] 5.5 5.5 5.5 5.5 0.0 1.00 13 13 +#> Z[1,1] -0.3 -0.3 -0.3 -0.3 0.0 1.00 13 13 +#> Z[2,1] -0.4 -0.4 -0.4 -0.4 0.0 1.00 13 13 +#> Z[3,1] -0.3 -0.3 -0.3 -0.3 0.0 1.00 13 13 +#> log_lik[1] -0.4 -0.4 -0.4 -0.4 0.0 1.00 13 13 +#> log_lik[2] -0.1 -0.1 -0.1 -0.1 0.0 1.00 13 13 +#> log_lik[3] -0.1 -0.1 -0.1 -0.1 0.0 1.00 13 13 +#> log_lik[4] -0.6 -0.6 -0.6 -0.6 0.0 1.00 13 13 +#> log_lik[5] 0.0 0.0 0.0 0.0 0.0 1.00 13 13 +#> log_lik[6] 0.0 0.0 0.0 0.0 0.0 1.00 13 13 +#> log_lik[7] -0.1 -0.1 -0.1 -0.1 0.0 1.00 13 13 +#> log_lik[8] 0.0 0.0 0.0 0.0 0.0 1.00 13 13 +#> log_lik[9] -0.2 -0.2 -0.2 -0.2 0.0 1.00 13 13 +#> log_lik[10] -0.4 -0.4 -0.4 -0.4 0.0 1.00 13 13 +#> log_lik[11] -0.1 -0.1 -0.1 -0.1 0.0 1.00 13 13 +#> log_lik[12] -0.3 -0.3 -0.3 -0.3 0.0 1.00 13 13 +#> log_lik[13] 0.0 0.0 0.0 0.0 0.0 1.00 13 13 +#> log_lik[14] -0.2 -0.2 -0.2 -0.2 0.0 1.00 13 13 +#> log_lik[15] 0.0 0.0 0.0 0.0 0.0 1.00 13 13 +#> log_lik[16] -0.2 -0.2 -0.2 -0.2 0.0 1.00 13 13 +#> log_lik[17] -0.1 -0.1 -0.1 -0.1 0.0 1.00 13 13 +#> log_lik[18] 0.0 0.0 0.0 0.0 0.0 1.00 13 13 +#> log_lik[19] 0.0 0.0 0.0 0.0 0.0 1.00 13 13 +#> log_lik[20] 0.0 0.0 0.0 0.0 0.0 1.00 13 13 +#> log_lik[21] -0.1 -0.1 -0.1 -0.1 0.0 1.00 13 13 +#> log_lik[22] 0.0 0.0 0.0 0.0 0.0 1.00 13 13 +#> log_lik[23] 0.0 0.0 0.0 0.0 0.0 1.00 13 13 +#> log_lik[24] -0.1 -0.1 -0.1 -0.1 0.0 1.00 13 13 +#> log_lik[25] -0.3 -0.3 -0.3 -0.3 0.0 1.00 13 13 +#> log_lik[26] -0.1 -0.1 -0.1 -0.1 0.0 1.00 13 13 +#> log_lik[27] 0.0 0.0 0.0 0.0 0.0 1.00 13 13 +#> log_lik[28] -0.1 -0.1 -0.1 -0.1 0.0 1.00 13 13 +#> log_lik[29] 0.0 0.0 0.0 0.0 0.0 1.00 13 13 +#> log_lik[30] -0.1 -0.1 -0.1 -0.1 0.0 1.00 13 13 +#> log_lik[31] 0.0 0.0 0.0 0.0 0.0 1.00 13 13 +#> log_lik[32] 0.0 0.0 0.0 0.0 0.0 1.00 13 13 +#> log_lik[33] 0.0 0.0 0.0 0.0 0.0 1.00 13 13 +#> log_lik[34] -0.3 -0.3 -0.3 -0.3 0.0 1.00 13 13 +#> log_lik[35] -0.3 -0.3 -0.3 -0.3 0.0 1.00 13 13 +#> log_lik[36] -0.2 -0.2 -0.2 -0.2 0.0 1.00 13 13 +#> log_lik[37] -0.7 -0.7 -0.7 -0.7 0.0 1.00 13 13 +#> log_lik[38] -0.3 -0.3 -0.3 -0.3 0.0 1.00 13 13 +#> log_lik[39] -0.5 -0.5 -0.5 -0.5 0.0 1.00 13 13 +#> log_lik[40] -0.5 -0.5 -0.5 -0.5 0.0 1.00 13 13 +#> log_lik[41] -0.1 -0.1 -0.1 -0.1 0.0 1.00 13 13 +#> log_lik[42] -0.1 -0.1 -0.1 -0.1 0.0 1.00 13 13 +#> log_lik[43] -22.6 -22.6 -22.6 -22.6 0.0 1.00 13 13 +#> log_lik[44] -0.5 -0.5 -0.5 -0.5 0.0 1.00 13 13 +#> log_lik[45] -0.4 -0.4 -0.4 -0.4 0.0 1.00 13 13 +#> log_lik[46] -0.2 -0.2 -0.2 -0.2 0.0 1.00 13 13 +#> log_lik[47] 0.0 0.0 0.0 0.0 0.0 1.00 13 13 +#> log_lik[48] -0.1 -0.1 -0.1 -0.1 0.0 1.00 13 13 +#> log_lik[49] -0.1 -0.1 -0.1 -0.1 0.0 1.00 13 13 +#> log_lik[50] 0.0 0.0 0.0 0.0 0.0 1.00 13 13 +#> log_lik[51] 0.0 0.0 0.0 0.0 0.0 1.00 13 13 +#> log_lik[52] 0.0 0.0 0.0 0.0 0.0 1.00 13 13 +#> log_lik[53] 0.0 0.0 0.0 0.0 0.0 1.00 13 13 +#> log_lik[54] 0.0 0.0 0.0 0.0 0.0 1.00 13 13 +#> log_lik[55] 0.0 0.0 0.0 0.0 0.0 1.00 13 13 +#> log_lik[56] -0.2 -0.2 -0.2 -0.2 0.0 1.00 13 13 +#> log_lik[57] 0.0 0.0 0.0 0.0 0.0 1.00 13 13 +#> log_lik[58] -0.1 -0.1 -0.1 -0.1 0.0 1.00 13 13 +#> log_lik[59] -0.4 -0.4 -0.4 -0.4 0.0 1.00 13 13 +#> log_lik[60] -0.3 -0.3 -0.3 -0.3 0.0 1.00 13 13 +#> log_lik[61] 0.0 0.0 0.0 0.0 0.0 1.00 13 13 +#> log_lik[62] 0.0 0.0 0.0 0.0 0.0 1.00 13 13 +#> log_lik[63] -0.1 -0.1 -0.1 -0.1 0.0 1.00 13 13 +#> log_lik[64] -0.4 -0.4 -0.4 -0.4 0.0 1.00 13 13 +#> log_lik[65] 0.0 0.0 0.0 0.0 0.0 1.00 13 13 +#> log_lik[66] 0.0 0.0 0.0 0.0 0.0 1.00 13 13 +#> log_lik[67] 0.0 0.0 0.0 0.0 0.0 1.00 13 13 +#> log_lik[68] 0.0 0.0 0.0 0.0 0.0 1.00 13 13 +#> log_lik[69] -0.1 -0.1 -0.1 -0.1 0.0 1.00 13 13 +#> log_lik[70] -0.3 -0.3 -0.3 -0.3 0.0 1.00 13 13 +#> log_lik[71] 0.0 0.0 0.0 0.0 0.0 1.00 13 13 +#> log_lik[72] -0.1 -0.1 -0.1 -0.1 0.0 1.00 13 13 +#> log_lik[73] 0.0 0.0 0.0 0.0 0.0 1.00 13 13 +#> log_lik[74] -0.1 -0.1 -0.1 -0.1 0.0 1.00 13 13 +#> log_lik[75] -0.1 -0.1 -0.1 -0.1 0.0 1.00 13 13 +#> log_lik[76] -0.1 -0.1 -0.1 -0.1 0.0 1.00 13 13 +#> log_lik[77] 0.0 0.0 0.0 0.0 0.0 1.00 13 13 +#> log_lik[78] -0.1 -0.1 -0.1 -0.1 0.0 1.00 13 13 +#> log_lik[79] 0.0 0.0 0.0 0.0 0.0 1.00 13 13 +#> log_lik[80] 0.0 0.0 0.0 0.0 0.0 1.00 13 13 +#> log_lik[81] -0.1 -0.1 -0.1 -0.1 0.0 1.00 13 13 +#> log_lik[82] -0.1 -0.1 -0.1 -0.1 0.0 1.00 13 13 +#> log_lik[83] 0.0 0.0 0.0 0.0 0.0 1.00 13 13 +#> log_lik[84] -0.4 -0.4 -0.4 -0.4 0.0 1.00 13 13 +#> log_lik[85] -0.2 -0.2 -0.2 -0.2 0.0 1.00 13 13 +#> log_lik[86] 0.0 0.0 0.0 0.0 0.0 1.00 13 13 +#> log_lik[87] -0.3 -0.3 -0.3 -0.3 0.0 1.00 13 13 +#> log_lik[88] 0.0 0.0 0.0 0.0 0.0 1.00 13 13 +#> log_lik[89] 0.0 0.0 0.0 0.0 0.0 1.00 13 13 +#> log_lik[90] -0.2 -0.2 -0.2 -0.2 0.0 1.00 13 13 +#> xstar[1,1] 4.1 5.8 7.8 5.9 1.3 1.07 13 13 +#> sigma[1] 0.4 0.4 0.4 0.4 0.0 1.00 13 13 +#> lp__ -29.7 -29.7 -29.7 -29.7 0.0 1.00 13 13 #> #> For each parameter, Bulk_ESS and Tail_ESS are crude measures of #> effective sample size for bulk and tail quantities respectively (an ESS > 100 @@ -361,8 +361,7 @@

Examp print(p)

# a 1 in 1000 probability if was from a normal distribution: find_swans(r, plot = TRUE, threshold = 0.001) -
-
+
@@ -173,6 +173,7 @@

Fit a Bayesian DFA

family = "gaussian", verbose = FALSE, gp_theta_prior = c(3, 1), + expansion_prior = FALSE, ... ) @@ -335,6 +336,10 @@

Arg This prior is a half-Student t prior, with the first argument of gp_theta_prior being the degrees of freedom (nu), and the second element being the standard deviation

+ + expansion_prior +

Defaults to FALSE, if TRUE uses the parameter expansion prior of Ghosh & Dunson 2009

+ ...

Any other arguments to pass to rstan::sampling().

@@ -359,8 +364,8 @@

Examp
#> #> SAMPLING FOR MODEL 'dfa' NOW (CHAIN 1). #> Chain 1: -#> Chain 1: Gradient evaluation took 5.7e-05 seconds -#> Chain 1: 1000 transitions using 10 leapfrog steps per transition would take 0.57 seconds. +#> Chain 1: Gradient evaluation took 4.4e-05 seconds +#> Chain 1: 1000 transitions using 10 leapfrog steps per transition would take 0.44 seconds. #> Chain 1: Adjust your expectations accordingly! #> Chain 1: #> Chain 1: @@ -385,11 +390,13 @@

Examp #> Chain 1: Iteration: 45 / 50 [ 90%] (Sampling) #> Chain 1: Iteration: 50 / 50 [100%] (Sampling) #> Chain 1: -#> Chain 1: Elapsed Time: 0.002928 seconds (Warm-up) -#> Chain 1: 0.00524 seconds (Sampling) -#> Chain 1: 0.008168 seconds (Total) -#> Chain 1:

#> Warning: There were 1 chains where the estimated Bayesian Fraction of Missing Information was low. See -#> http://mc-stan.org/misc/warnings.html#bfmi-low
#> Warning: Examine the pairs() plot to diagnose sampling problems
#> Warning: The largest R-hat is 2.1, indicating chains have not mixed. +#> Chain 1: Elapsed Time: 0.005033 seconds (Warm-up) +#> Chain 1: 0.063874 seconds (Sampling) +#> Chain 1: 0.068907 seconds (Total) +#> Chain 1:
#> Warning: There were 16 divergent transitions after warmup. See +#> http://mc-stan.org/misc/warnings.html#divergent-transitions-after-warmup +#> to find out why this is a problem and how to eliminate them.
#> Warning: There were 1 chains where the estimated Bayesian Fraction of Missing Information was low. See +#> http://mc-stan.org/misc/warnings.html#bfmi-low
#> Warning: Examine the pairs() plot to diagnose sampling problems
#> Warning: The largest R-hat is 2.11, indicating chains have not mixed. #> Running the chains for more iterations may help. See #> http://mc-stan.org/misc/warnings.html#r-hat
#> Warning: Bulk Effective Samples Size (ESS) is too low, indicating posterior means and medians may be unreliable. #> Running the chains for more iterations may help. See @@ -397,94 +404,93 @@

Examp #> Running the chains for more iterations may help. See #> http://mc-stan.org/misc/warnings.html#tail-ess

#> Inference for the input samples (1 chains: each with iter = 25; warmup = 12): #> -#> Q5 Q50 Q95 Mean SD Rhat Bulk_ESS Tail_ESS -#> x[1,1] 1.0 1.0 1.0 1.0 0.0 1.13 6 13 -#> x[1,2] -0.2 -0.2 -0.2 -0.2 0.0 1.48 5 13 -#> x[1,3] 1.1 1.1 1.1 1.1 0.0 1.87 4 13 -#> x[1,4] 1.3 1.3 1.3 1.3 0.0 1.87 4 13 -#> x[1,5] -0.1 -0.1 -0.1 -0.1 0.0 2.06 4 13 -#> x[1,6] 1.0 1.0 1.0 1.0 0.0 2.06 4 13 -#> x[1,7] 0.1 0.1 0.1 0.1 0.0 2.06 4 13 -#> x[1,8] 1.4 1.5 1.5 1.5 0.0 2.06 4 13 -#> x[1,9] 0.7 0.7 0.7 0.7 0.0 2.06 4 13 -#> x[1,10] 1.9 1.9 1.9 1.9 0.0 2.06 4 13 -#> x[1,11] 2.5 2.5 2.5 2.5 0.0 2.06 4 13 -#> x[1,12] 2.0 2.0 2.0 2.0 0.0 2.06 4 13 -#> x[1,13] 1.1 1.1 1.1 1.1 0.0 2.06 4 13 -#> x[1,14] 0.5 0.5 0.5 0.5 0.0 1.48 4 13 -#> x[1,15] -0.1 -0.1 -0.1 -0.1 0.0 1.13 7 13 -#> x[1,16] -0.9 -0.9 -0.9 -0.9 0.0 1.58 8 13 -#> x[1,17] -1.9 -1.9 -1.9 -1.9 0.0 1.06 9 13 -#> x[1,18] -2.0 -2.0 -2.0 -2.0 0.0 1.45 5 13 -#> x[1,19] -1.7 -1.7 -1.6 -1.7 0.0 1.45 4 13 -#> x[1,20] -2.3 -2.3 -2.3 -2.3 0.0 1.58 4 13 -#> Z[1,1] 0.5 0.5 0.5 0.5 0.0 1.07 7 13 -#> Z[2,1] -32.6 -28.6 -23.8 -28.4 3.0 2.06 3 13 -#> Z[3,1] 1.4 1.6 1.9 1.6 0.2 2.06 4 13 -#> log_lik[1] -1.5 -1.5 -1.4 -1.5 0.0 2.06 3 13 -#> log_lik[2] -274.4 -202.4 -136.1 -203.2 47.0 2.06 3 13 -#> log_lik[3] -2.0 -1.8 -1.6 -1.8 0.1 2.06 4 13 -#> log_lik[4] -1.3 -1.3 -1.3 -1.3 0.0 2.06 3 13 -#> log_lik[5] -13.9 -10.9 -7.7 -10.9 2.1 2.06 3 13 -#> log_lik[6] -1.3 -1.3 -1.3 -1.3 0.0 2.06 3 13 -#> log_lik[7] -1.6 -1.5 -1.5 -1.5 0.0 2.06 3 13 -#> log_lik[8] -321.0 -234.7 -156.7 -235.8 55.9 2.06 3 13 -#> log_lik[9] -1.8 -1.6 -1.5 -1.6 0.1 2.06 4 13 -#> log_lik[10] -1.6 -1.6 -1.6 -1.6 0.0 2.06 3 13 -#> log_lik[11] -441.1 -320.6 -211.6 -322.1 78.0 2.06 3 13 -#> log_lik[12] -3.8 -3.1 -2.7 -3.1 0.3 2.06 3 13 -#> log_lik[13] -1.3 -1.3 -1.3 -1.3 0.0 2.06 3 13 -#> log_lik[14] -3.7 -3.3 -2.8 -3.3 0.3 2.06 3 13 -#> log_lik[15] -1.4 -1.4 -1.4 -1.4 0.0 2.06 3 13 -#> log_lik[16] -1.7 -1.7 -1.7 -1.7 0.0 2.06 3 13 -#> log_lik[17] -261.8 -189.8 -124.5 -190.7 46.8 2.06 3 13 -#> log_lik[18] -2.6 -2.3 -2.1 -2.3 0.2 2.06 3 13 -#> log_lik[19] -1.3 -1.3 -1.3 -1.3 0.0 2.06 3 13 -#> log_lik[20] -2.5 -2.0 -1.7 -2.0 0.3 2.06 3 13 -#> log_lik[21] -1.4 -1.4 -1.4 -1.4 0.0 2.06 4 13 -#> log_lik[22] -1.3 -1.3 -1.3 -1.3 0.0 2.06 3 13 -#> log_lik[23] -553.1 -399.1 -261.3 -401.5 99.3 2.06 3 13 -#> log_lik[24] -3.5 -2.9 -2.4 -2.9 0.4 2.06 3 13 -#> log_lik[25] -1.4 -1.3 -1.3 -1.3 0.0 2.06 3 13 -#> log_lik[26] -139.0 -99.4 -65.6 -100.4 25.0 2.06 3 13 -#> log_lik[27] -2.6 -2.3 -2.1 -2.3 0.1 2.06 3 13 -#> log_lik[28] -2.5 -2.5 -2.5 -2.5 0.0 2.06 3 13 -#> log_lik[29] -971.7 -699.8 -458.4 -704.6 174.7 2.06 3 13 -#> log_lik[30] -8.1 -6.4 -5.3 -6.5 0.9 2.06 3 13 -#> log_lik[31] -3.7 -3.6 -3.5 -3.6 0.1 2.06 3 13 -#> log_lik[32] -1645.8 -1195.9 -789.6 -1202.3 291.4 2.06 3 13 -#> log_lik[33] -12.0 -9.4 -7.6 -9.4 1.5 2.06 3 13 -#> log_lik[34] -3.3 -3.2 -3.1 -3.2 0.1 2.06 3 13 -#> log_lik[35] -982.2 -706.3 -459.4 -710.7 178.1 2.06 3 13 -#> log_lik[36] -7.6 -6.0 -4.9 -6.0 0.9 2.06 3 13 -#> log_lik[37] -1.6 -1.6 -1.6 -1.6 0.0 2.06 3 13 -#> log_lik[38] -289.1 -207.0 -135.5 -208.7 52.4 2.06 3 13 -#> log_lik[39] -3.0 -2.5 -2.3 -2.5 0.2 2.06 3 13 -#> log_lik[40] -1.4 -1.4 -1.3 -1.4 0.0 2.06 3 13 -#> log_lik[41] -82.3 -59.7 -40.6 -60.3 14.3 2.06 3 13 -#> log_lik[42] -1.4 -1.4 -1.4 -1.4 0.0 1.45 5 13 -#> log_lik[43] -1.8 -1.8 -1.8 -1.8 0.0 1.10 6 13 -#> log_lik[44] -6.0 -4.8 -3.4 -4.7 0.9 2.06 3 13 -#> log_lik[45] -1.6 -1.6 -1.6 -1.6 0.0 1.19 5 13 -#> log_lik[46] -2.4 -2.4 -2.4 -2.4 0.0 2.06 3 13 -#> log_lik[47] -236.0 -173.1 -113.4 -173.2 41.5 2.06 3 13 -#> log_lik[48] -3.9 -3.4 -3.0 -3.4 0.3 2.06 3 13 -#> log_lik[49] -3.1 -3.0 -3.0 -3.0 0.0 2.06 3 13 -#> log_lik[50] -861.3 -620.7 -398.0 -622.6 157.1 2.06 3 13 -#> log_lik[51] -8.4 -6.8 -5.6 -6.8 0.9 2.06 3 13 -#> log_lik[52] -2.2 -2.2 -2.2 -2.2 0.0 2.06 3 13 -#> log_lik[53] -1012.3 -732.1 -472.7 -734.3 183.2 2.06 3 13 -#> log_lik[54] -8.4 -6.6 -5.4 -6.7 0.9 2.06 3 13 -#> log_lik[55] -2.1 -2.1 -2.1 -2.1 0.0 2.06 3 13 -#> log_lik[56] -758.7 -554.8 -364.5 -555.7 133.8 2.06 3 13 -#> log_lik[57] -5.0 -4.0 -3.3 -4.0 0.5 2.06 3 13 -#> log_lik[58] -2.0 -1.9 -1.9 -1.9 0.0 2.06 3 13 -#> log_lik[59] -1381.6 -1005.5 -655.9 -1007.9 246.6 2.06 3 13 -#> log_lik[60] -6.8 -5.1 -4.0 -5.2 0.9 2.06 3 13 -#> psi[1] 0.5 0.5 0.5 0.5 0.0 1.19 8 13 -#> xstar[1,1] -4.3 -2.7 -1.5 -2.9 1.1 1.14 10 13 -#> sigma[1] 1.4 1.5 1.5 1.5 0.0 2.06 3 13 -#> lp__ -10661.4 -7770.3 -5136.2 -7803.2 1877.9 2.06 3 13 +#> Q5 Q50 Q95 Mean SD Rhat Bulk_ESS Tail_ESS +#> x[1,1] 0.3 0.3 0.7 0.4 0.2 2.19 13 13 +#> x[1,2] -0.2 0.0 0.0 0.0 0.1 1.72 4 13 +#> x[1,3] 0.2 0.2 0.9 0.5 0.3 2.19 4 13 +#> x[1,4] 0.5 0.6 1.0 0.7 0.2 2.19 6 13 +#> x[1,5] -0.2 0.5 1.0 0.4 0.4 2.19 13 13 +#> x[1,6] 0.4 1.3 1.4 1.1 0.4 2.19 8 13 +#> x[1,7] 0.3 1.0 1.0 0.8 0.3 2.10 6 13 +#> x[1,8] 0.5 0.7 1.1 0.7 0.3 2.19 13 13 +#> x[1,9] 0.4 0.5 1.4 0.7 0.6 1.62 12 13 +#> x[1,10] 1.5 1.6 2.5 1.8 0.5 2.19 12 13 +#> x[1,11] 2.0 2.7 2.9 2.6 0.4 2.08 6 13 +#> x[1,12] 0.8 2.2 2.3 1.8 0.6 2.10 4 13 +#> x[1,13] 0.0 1.2 1.3 0.8 0.6 2.10 7 13 +#> x[1,14] -0.9 -0.2 0.1 -0.3 0.4 2.08 6 13 +#> x[1,15] -1.0 -1.0 -0.3 -0.7 0.3 2.08 4 13 +#> x[1,16] -2.2 -2.0 -1.3 -1.8 0.4 2.10 4 13 +#> x[1,17] -2.6 -2.4 -2.0 -2.3 0.2 2.08 9 13 +#> x[1,18] -2.4 -2.0 -1.3 -1.9 0.5 1.18 8 13 +#> x[1,19] -1.9 -1.7 -0.7 -1.4 0.5 2.08 7 13 +#> x[1,20] -1.4 -1.2 0.0 -0.8 0.5 2.10 8 13 +#> Z[1,1] -0.9 -0.7 -0.6 -0.7 0.1 1.20 13 13 +#> Z[2,1] -0.7 -0.4 -0.2 -0.4 0.2 1.46 13 13 +#> Z[3,1] -0.8 -0.5 -0.4 -0.6 0.1 1.72 4 13 +#> log_lik[1] -0.7 -0.4 -0.4 -0.5 0.1 2.19 13 13 +#> log_lik[2] -2.4 -2.1 -1.8 -2.1 0.2 1.95 13 13 +#> log_lik[3] -1.0 -0.6 -0.6 -0.7 0.2 1.18 8 13 +#> log_lik[4] -0.8 -0.5 -0.4 -0.5 0.1 2.08 12 13 +#> log_lik[5] -0.8 -0.5 -0.5 -0.6 0.1 2.08 13 13 +#> log_lik[6] -0.7 -0.5 -0.4 -0.5 0.1 2.08 12 13 +#> log_lik[7] -0.7 -0.6 -0.4 -0.6 0.1 2.19 13 13 +#> log_lik[8] -2.2 -1.3 -1.2 -1.5 0.4 1.95 6 13 +#> log_lik[9] -2.4 -1.1 -1.0 -1.4 0.5 2.10 4 13 +#> log_lik[10] -0.7 -0.4 -0.4 -0.5 0.1 2.19 4 13 +#> log_lik[11] -0.7 -0.4 -0.4 -0.5 0.1 2.10 9 13 +#> log_lik[12] -0.8 -0.7 -0.3 -0.6 0.2 1.62 13 13 +#> log_lik[13] -1.3 -0.7 -0.7 -0.8 0.3 1.33 5 13 +#> log_lik[14] -0.9 -0.6 -0.4 -0.6 0.2 2.08 12 13 +#> log_lik[15] -2.5 -1.1 -0.8 -1.3 0.6 2.19 13 13 +#> log_lik[16] -0.9 -0.5 -0.4 -0.5 0.2 1.18 9 13 +#> log_lik[17] -0.7 -0.5 -0.4 -0.5 0.1 1.77 8 13 +#> log_lik[18] -0.8 -0.6 -0.4 -0.6 0.1 1.88 4 13 +#> log_lik[19] -0.9 -0.8 -0.4 -0.7 0.2 1.63 7 13 +#> log_lik[20] -0.7 -0.6 -0.5 -0.6 0.1 2.08 13 13 +#> log_lik[21] -0.8 -0.5 -0.4 -0.6 0.1 1.88 11 13 +#> log_lik[22] -2.5 -2.0 -1.6 -2.0 0.3 1.51 8 13 +#> log_lik[23] -0.8 -0.6 -0.5 -0.6 0.1 2.08 13 13 +#> log_lik[24] -0.8 -0.5 -0.4 -0.5 0.2 1.77 10 13 +#> log_lik[25] -1.6 -0.6 -0.6 -0.8 0.6 1.33 5 13 +#> log_lik[26] -0.8 -0.5 -0.5 -0.6 0.1 1.95 13 13 +#> log_lik[27] -1.1 -1.0 -0.7 -1.0 0.1 1.30 5 13 +#> log_lik[28] -1.0 -0.5 -0.4 -0.6 0.3 2.19 7 13 +#> log_lik[29] -0.9 -0.7 -0.4 -0.7 0.2 1.03 13 13 +#> log_lik[30] -1.4 -1.0 -0.4 -0.9 0.4 1.72 4 13 +#> log_lik[31] -0.8 -0.5 -0.4 -0.6 0.2 1.00 9 13 +#> log_lik[32] -3.7 -2.3 -1.1 -2.3 0.9 1.03 13 13 +#> log_lik[33] -1.2 -0.7 -0.4 -0.8 0.3 1.05 8 13 +#> log_lik[34] -2.0 -0.9 -0.5 -1.0 0.6 2.08 4 13 +#> log_lik[35] -3.9 -2.2 -1.8 -2.4 0.7 1.50 5 13 +#> log_lik[36] -1.1 -0.5 -0.4 -0.6 0.3 1.18 7 13 +#> log_lik[37] -1.0 -0.6 -0.5 -0.7 0.2 1.51 5 13 +#> log_lik[38] -2.1 -1.1 -1.0 -1.3 0.4 2.19 4 13 +#> log_lik[39] -1.0 -0.5 -0.4 -0.6 0.2 2.19 4 13 +#> log_lik[40] -1.7 -0.6 -0.6 -0.9 0.4 2.19 4 13 +#> log_lik[41] -0.8 -0.5 -0.3 -0.5 0.1 1.46 13 13 +#> log_lik[42] -0.9 -0.5 -0.3 -0.6 0.2 2.08 13 13 +#> log_lik[43] -2.5 -1.2 -1.0 -1.5 0.6 1.77 13 13 +#> log_lik[44] -0.7 -0.5 -0.3 -0.5 0.1 1.18 12 13 +#> log_lik[45] -1.1 -0.8 -0.5 -0.8 0.2 1.58 7 13 +#> log_lik[46] -1.3 -0.5 -0.4 -0.8 0.3 2.08 4 13 +#> log_lik[47] -1.5 -1.2 -0.7 -1.1 0.3 1.46 10 13 +#> log_lik[48] -1.0 -0.7 -0.5 -0.8 0.2 1.12 8 13 +#> log_lik[49] -1.1 -0.5 -0.4 -0.6 0.3 1.77 7 13 +#> log_lik[50] -5.1 -4.3 -1.7 -4.0 1.2 1.19 13 13 +#> log_lik[51] -1.3 -0.9 -0.4 -0.9 0.3 1.09 8 13 +#> log_lik[52] -1.5 -0.7 -0.4 -0.8 0.4 1.41 13 13 +#> log_lik[53] -2.4 -1.7 -1.3 -1.8 0.4 1.18 11 13 +#> log_lik[54] -1.1 -0.8 -0.5 -0.8 0.2 0.99 13 13 +#> log_lik[55] -0.9 -0.6 -0.5 -0.6 0.1 1.33 13 13 +#> log_lik[56] -4.2 -3.4 -2.3 -3.3 0.7 2.19 4 5 +#> log_lik[57] -0.8 -0.5 -0.4 -0.5 0.1 1.62 13 13 +#> log_lik[58] -0.8 -0.7 -0.5 -0.7 0.1 0.97 13 13 +#> log_lik[59] -0.7 -0.6 -0.4 -0.6 0.1 2.08 13 13 +#> log_lik[60] -0.8 -0.5 -0.5 -0.6 0.1 1.30 6 13 +#> xstar[1,1] -2.7 -0.7 1.1 -0.7 1.2 1.09 13 13 +#> sigma[1] 0.6 0.6 0.8 0.7 0.1 2.08 13 13 +#> lp__ -59.5 -49.2 -46.5 -51.7 5.4 2.10 4 13 #> #> For each parameter, Bulk_ESS and Tail_ESS are crude measures of #> effective sample size for bulk and tail quantities respectively (an ESS > 100 @@ -492,46 +498,46 @@

Examp #> factor on rank normalized split chains (at convergence, Rhat <= 1.05).

if (FALSE) { # example of observation error covariates set.seed(42) -obs_covar = expand.grid("time"=1:20,"timeseries"=1:3,"covariate"=1) -obs_covar$value=rnorm(nrow(obs_covar),0,0.1) -m <- fit_dfa(y = s$y_sim, iter = 50, chains = 1, obs_covar=obs_covar) +obs_covar <- expand.grid("time" = 1:20, "timeseries" = 1:3, "covariate" = 1) +obs_covar$value <- rnorm(nrow(obs_covar), 0, 0.1) +m <- fit_dfa(y = s$y_sim, iter = 50, chains = 1, obs_covar = obs_covar) # example of process error covariates -pro_covar = expand.grid("time"=1:20,"trend"=1:2,"covariate"=1) -pro_covar$value=rnorm(nrow(pro_covar),0,0.1) -m <- fit_dfa(y = s$y_sim, iter = 50, chains = 1, num_trends = 2, pro_covar=pro_covar) +pro_covar <- expand.grid("time" = 1:20, "trend" = 1:2, "covariate" = 1) +pro_covar$value <- rnorm(nrow(pro_covar), 0, 0.1) +m <- fit_dfa(y = s$y_sim, iter = 50, chains = 1, num_trends = 2, pro_covar = pro_covar) # example of long format data s <- sim_dfa(num_trends = 1, num_years = 20, num_ts = 3) -obs <- c(s$y_sim[1,], s$y_sim[2,], s$y_sim[3,]) -long = data.frame("obs" = obs, "ts" = sort(rep(1:3,20)), "time" = rep(1:20,3)) -m = fit_dfa(y = long, data_shape = "long", iter = 50, chains = 1) +obs <- c(s$y_sim[1, ], s$y_sim[2, ], s$y_sim[3, ]) +long <- data.frame("obs" = obs, "ts" = sort(rep(1:3, 20)), "time" = rep(1:20, 3)) +m <- fit_dfa(y = long, data_shape = "long", iter = 50, chains = 1) # example of long format data with obs covariates s <- sim_dfa(num_trends = 1, num_years = 20, num_ts = 3) -obs <- c(s$y_sim[1,], s$y_sim[2,], s$y_sim[3,]) -long = data.frame("obs" = obs, "ts" = sort(rep(1:3,20)), "time" = rep(1:20,3)) -obs_covar = expand.grid("time"=1:20,"timeseries"=1:3,"covariate"=1:2) -obs_covar$value=rnorm(nrow(obs_covar),0,0.1) -m = fit_dfa(y = long, data_shape = "long", iter = 50, chains = 1,obs_covar=obs_covar) +obs <- c(s$y_sim[1, ], s$y_sim[2, ], s$y_sim[3, ]) +long <- data.frame("obs" = obs, "ts" = sort(rep(1:3, 20)), "time" = rep(1:20, 3)) +obs_covar <- expand.grid("time" = 1:20, "timeseries" = 1:3, "covariate" = 1:2) +obs_covar$value <- rnorm(nrow(obs_covar), 0, 0.1) +m <- fit_dfa(y = long, data_shape = "long", iter = 50, chains = 1, obs_covar = obs_covar) # example of model with Z constrained to be proportions and wide format data s <- sim_dfa(num_trends = 1, num_years = 20, num_ts = 3) -m = fit_dfa(y = s$y_sim, z_model = "proportion", iter = 50, chains = 1) +m <- fit_dfa(y = s$y_sim, z_model = "proportion", iter = 50, chains = 1) # example of model with Z constrained to be proportions and long format data s <- sim_dfa(num_trends = 1, num_years = 20, num_ts = 3) -obs <- c(s$y_sim[1,], s$y_sim[2,], s$y_sim[3,]) -long = data.frame("obs" = obs, "ts" = sort(rep(1:3,20)), "time" = rep(1:20,3)) -m = fit_dfa(y = long, data_shape = "long", z_model = "proportion", iter = 50, chains = 1) +obs <- c(s$y_sim[1, ], s$y_sim[2, ], s$y_sim[3, ]) +long <- data.frame("obs" = obs, "ts" = sort(rep(1:3, 20)), "time" = rep(1:20, 3)) +m <- fit_dfa(y = long, data_shape = "long", z_model = "proportion", iter = 50, chains = 1) #' # example of B-spline model with wide format data s <- sim_dfa(num_trends = 1, num_years = 20, num_ts = 3) -m = fit_dfa(y = s$y_sim, iter = 50, chains = 1, trend_model = "spline", n_knots = 10) +m <- fit_dfa(y = s$y_sim, iter = 50, chains = 1, trend_model = "spline", n_knots = 10) # example of B-spline model with wide format data s <- sim_dfa(num_trends = 1, num_years = 20, num_ts = 3) -m = fit_dfa(y = s$y_sim, iter = 50, chains = 1, trend_model = "gp", n_knots = 5) +m <- fit_dfa(y = s$y_sim, iter = 50, chains = 1, trend_model = "gp", n_knots = 5) }
diff --git a/docs/reference/fit_regimes.html b/docs/reference/fit_regimes.html index 1b6441e..02eb9df 100644 --- a/docs/reference/fit_regimes.html +++ b/docs/reference/fit_regimes.html @@ -72,7 +72,7 @@ bayesdfa - 1.0.0 + 1.1.0 @@ -197,8 +197,8 @@

Examp
#> #> SAMPLING FOR MODEL 'regime_1' NOW (CHAIN 1). #> Chain 1: -#> Chain 1: Gradient evaluation took 9e-06 seconds -#> Chain 1: 1000 transitions using 10 leapfrog steps per transition would take 0.09 seconds. +#> Chain 1: Gradient evaluation took 1e-05 seconds +#> Chain 1: 1000 transitions using 10 leapfrog steps per transition would take 0.1 seconds. #> Chain 1: Adjust your expectations accordingly! #> Chain 1: #> Chain 1: @@ -223,9 +223,9 @@

Examp #> Chain 1: Iteration: 45 / 50 [ 90%] (Sampling) #> Chain 1: Iteration: 50 / 50 [100%] (Sampling) #> Chain 1: -#> Chain 1: Elapsed Time: 0.000912 seconds (Warm-up) -#> Chain 1: 0.00084 seconds (Sampling) -#> Chain 1: 0.001752 seconds (Total) +#> Chain 1: Elapsed Time: 0.000884 seconds (Warm-up) +#> Chain 1: 0.000774 seconds (Sampling) +#> Chain 1: 0.001658 seconds (Total) #> Chain 1:

#> Warning: The largest R-hat is 1.52, indicating chains have not mixed. #> Running the chains for more iterations may help. See #> http://mc-stan.org/misc/warnings.html#r-hat
#> Warning: Bulk Effective Samples Size (ESS) is too low, indicating posterior means and medians may be unreliable. @@ -442,7 +442,7 @@

Examp #> log_lik[100] 0.16 0.03 0.13 -0.05 0.06 0.15 0.27 0.38 17 0.97 #> lp__ 113.34 0.44 1.19 111.43 112.13 113.48 114.37 114.92 7 1.50 #> -#> Samples were drawn using NUTS(diag_e) at Tue May 18 13:31:34 2021. +#> Samples were drawn using NUTS(diag_e) at Tue May 25 06:10:10 2021. #> For each parameter, n_eff is a crude measure of effective sample size, #> and Rhat is the potential scale reduction factor on split chains (at #> convergence, Rhat=1). diff --git a/docs/reference/hmm_init.html b/docs/reference/hmm_init.html index 1cfe9d2..b46f56d 100644 --- a/docs/reference/hmm_init.html +++ b/docs/reference/hmm_init.html @@ -72,7 +72,7 @@ bayesdfa - 1.0.0 + 1.1.0

diff --git a/docs/reference/index.html b/docs/reference/index.html index 723bfee..8668f74 100644 --- a/docs/reference/index.html +++ b/docs/reference/index.html @@ -71,7 +71,7 @@ bayesdfa - 1.0.0 + 1.1.0 diff --git a/docs/reference/invert_chains.html b/docs/reference/invert_chains.html index 899a5a0..57a3bf8 100644 --- a/docs/reference/invert_chains.html +++ b/docs/reference/invert_chains.html @@ -72,7 +72,7 @@ bayesdfa - 1.0.0 + 1.1.0 diff --git a/docs/reference/is_converged.html b/docs/reference/is_converged.html index 7c7d8d7..0b69820 100644 --- a/docs/reference/is_converged.html +++ b/docs/reference/is_converged.html @@ -73,7 +73,7 @@ bayesdfa - 1.0.0 + 1.1.0 diff --git a/docs/reference/loo.html b/docs/reference/loo.html index e288f08..457e83b 100644 --- a/docs/reference/loo.html +++ b/docs/reference/loo.html @@ -82,7 +82,7 @@ bayesdfa - 1.0.0 + 1.1.0 @@ -189,8 +189,8 @@

Examp
#> #> SAMPLING FOR MODEL 'dfa' NOW (CHAIN 1). #> Chain 1: -#> Chain 1: Gradient evaluation took 4.3e-05 seconds -#> Chain 1: 1000 transitions using 10 leapfrog steps per transition would take 0.43 seconds. +#> Chain 1: Gradient evaluation took 8.3e-05 seconds +#> Chain 1: 1000 transitions using 10 leapfrog steps per transition would take 0.83 seconds. #> Chain 1: Adjust your expectations accordingly! #> Chain 1: #> Chain 1: @@ -215,10 +215,13 @@

Examp #> Chain 1: Iteration: 45 / 50 [ 90%] (Sampling) #> Chain 1: Iteration: 50 / 50 [100%] (Sampling) #> Chain 1: -#> Chain 1: Elapsed Time: 0.506592 seconds (Warm-up) -#> Chain 1: 0.642068 seconds (Sampling) -#> Chain 1: 1.14866 seconds (Total) -#> Chain 1:

#> Warning: The largest R-hat is 1.95, indicating chains have not mixed. +#> Chain 1: Elapsed Time: 0.004749 seconds (Warm-up) +#> Chain 1: 0.191317 seconds (Sampling) +#> Chain 1: 0.196066 seconds (Total) +#> Chain 1:
#> Warning: There were 2 divergent transitions after warmup. See +#> http://mc-stan.org/misc/warnings.html#divergent-transitions-after-warmup +#> to find out why this is a problem and how to eliminate them.
#> Warning: There were 1 chains where the estimated Bayesian Fraction of Missing Information was low. See +#> http://mc-stan.org/misc/warnings.html#bfmi-low
#> Warning: Examine the pairs() plot to diagnose sampling problems
#> Warning: The largest R-hat is 1.95, indicating chains have not mixed. #> Running the chains for more iterations may help. See #> http://mc-stan.org/misc/warnings.html#r-hat
#> Warning: Bulk Effective Samples Size (ESS) is too low, indicating posterior means and medians may be unreliable. #> Running the chains for more iterations may help. See @@ -227,93 +230,92 @@

Examp #> http://mc-stan.org/misc/warnings.html#tail-ess

#> Inference for the input samples (1 chains: each with iter = 25; warmup = 12): #> #> Q5 Q50 Q95 Mean SD Rhat Bulk_ESS Tail_ESS -#> x[1,1] 1.4 2.3 4.2 2.6 1.0 0.98 13 13 -#> x[1,2] 1.3 1.8 3.3 1.9 0.7 1.14 13 13 -#> x[1,3] 0.9 1.5 3.4 1.7 0.9 1.01 13 13 -#> x[1,4] 0.5 0.9 2.2 1.2 0.6 1.10 13 13 -#> x[1,5] -1.2 0.0 0.7 -0.1 0.7 0.94 13 13 -#> x[1,6] -2.5 -1.3 -0.7 -1.5 0.6 0.92 13 13 -#> x[1,7] -3.7 -2.4 -1.4 -2.5 0.9 0.98 13 13 -#> x[1,8] -4.5 -2.5 -1.0 -2.4 1.4 1.71 13 13 -#> x[1,9] -2.9 -1.2 0.0 -1.3 1.1 1.47 13 13 -#> x[1,10] -2.5 -0.9 -0.1 -1.0 0.9 1.18 13 13 -#> x[1,11] -1.0 -0.6 0.1 -0.5 0.4 0.95 13 13 -#> x[1,12] -1.5 -0.7 -0.1 -0.7 0.5 0.96 13 13 -#> x[1,13] -1.5 -0.2 0.4 -0.3 0.6 0.92 13 13 -#> x[1,14] -1.5 0.2 0.7 -0.2 0.8 1.04 13 13 -#> x[1,15] 0.3 1.0 1.9 1.0 0.6 1.22 8 13 -#> x[1,16] 0.5 0.9 2.4 1.1 0.7 1.31 6 13 -#> x[1,17] 0.2 1.2 2.7 1.3 0.8 1.14 10 13 -#> x[1,18] -0.2 0.6 1.4 0.6 0.6 1.21 7 13 -#> x[1,19] -0.4 -0.1 0.9 0.0 0.4 0.91 13 13 -#> x[1,20] -2.4 -1.1 -0.5 -1.3 0.6 1.10 7 13 -#> Z[1,1] 0.3 0.5 1.0 0.6 0.2 0.97 13 13 -#> Z[2,1] -0.4 -0.1 0.1 -0.2 0.2 1.18 13 13 -#> Z[3,1] 0.3 0.6 1.0 0.6 0.2 1.04 13 13 -#> log_lik[1] -2.0 -1.2 -0.6 -1.3 0.5 1.16 13 13 -#> log_lik[2] -2.1 -1.1 -0.7 -1.3 0.5 1.05 13 13 -#> log_lik[3] -1.7 -0.9 -0.5 -1.0 0.4 1.02 12 13 -#> log_lik[4] -1.4 -0.8 -0.5 -0.9 0.3 0.96 13 13 -#> log_lik[5] -3.2 -2.2 -1.2 -2.2 0.7 1.14 13 13 -#> log_lik[6] -1.1 -0.6 -0.5 -0.7 0.2 1.18 13 13 -#> log_lik[7] -0.9 -0.6 -0.4 -0.6 0.2 1.00 13 13 -#> log_lik[8] -1.2 -0.7 -0.5 -0.8 0.3 0.96 13 13 -#> log_lik[9] -0.9 -0.6 -0.4 -0.6 0.2 1.45 13 13 -#> log_lik[10] -1.1 -0.7 -0.5 -0.8 0.2 0.94 11 13 -#> log_lik[11] -0.8 -0.6 -0.4 -0.6 0.1 1.07 10 13 -#> log_lik[12] -0.9 -0.7 -0.4 -0.7 0.2 0.92 13 13 -#> log_lik[13] -1.0 -0.7 -0.4 -0.7 0.2 1.18 13 13 -#> log_lik[14] -1.7 -1.2 -1.0 -1.2 0.3 1.07 13 13 -#> log_lik[15] -0.9 -0.8 -0.5 -0.8 0.2 1.09 10 13 -#> log_lik[16] -1.0 -0.7 -0.4 -0.7 0.2 0.98 13 13 -#> log_lik[17] -2.5 -1.8 -1.2 -1.9 0.5 0.92 13 13 -#> log_lik[18] -1.0 -0.7 -0.4 -0.7 0.2 0.93 13 13 -#> log_lik[19] -1.6 -0.8 -0.4 -0.9 0.4 1.07 13 13 -#> log_lik[20] -1.1 -0.7 -0.4 -0.7 0.3 1.00 9 13 -#> log_lik[21] -1.3 -0.8 -0.6 -0.8 0.2 1.19 13 13 -#> log_lik[22] -1.7 -0.8 -0.4 -0.9 0.4 1.02 10 13 -#> log_lik[23] -1.6 -0.8 -0.6 -0.9 0.4 0.94 13 13 -#> log_lik[24] -1.9 -0.7 -0.5 -0.9 0.5 0.98 10 13 -#> log_lik[25] -1.5 -0.7 -0.6 -0.9 0.4 1.19 7 13 -#> log_lik[26] -1.8 -1.6 -1.1 -1.5 0.3 0.98 12 13 -#> log_lik[27] -1.2 -0.7 -0.5 -0.8 0.3 0.92 13 13 -#> log_lik[28] -0.9 -0.7 -0.5 -0.7 0.1 1.32 13 13 -#> log_lik[29] -1.8 -1.4 -1.0 -1.3 0.2 1.27 13 13 -#> log_lik[30] -1.1 -0.7 -0.5 -0.8 0.2 1.21 13 13 -#> log_lik[31] -1.0 -0.7 -0.5 -0.7 0.2 0.94 13 13 -#> log_lik[32] -0.8 -0.6 -0.4 -0.6 0.1 1.15 13 13 -#> log_lik[33] -0.8 -0.7 -0.5 -0.7 0.1 1.03 9 13 -#> log_lik[34] -1.0 -0.7 -0.5 -0.7 0.2 0.95 13 13 -#> log_lik[35] -1.8 -1.5 -1.3 -1.5 0.2 0.95 13 13 -#> log_lik[36] -1.1 -0.7 -0.4 -0.8 0.2 0.91 13 13 -#> log_lik[37] -1.0 -0.7 -0.5 -0.7 0.2 0.98 13 13 +#> x[1,1] -2.1 -1.6 -0.5 -1.4 0.6 1.71 9 13 +#> x[1,2] -1.8 -1.2 -0.8 -1.2 0.4 0.94 13 13 +#> x[1,3] -1.6 -1.3 -0.6 -1.2 0.4 0.95 13 13 +#> x[1,4] -1.5 -0.5 0.0 -0.6 0.5 0.91 13 13 +#> x[1,5] -0.5 0.3 0.7 0.2 0.5 1.58 5 13 +#> x[1,6] 0.6 0.8 1.3 0.9 0.3 0.98 13 13 +#> x[1,7] 0.8 1.5 2.3 1.5 0.5 1.01 13 13 +#> x[1,8] 0.8 1.7 2.4 1.6 0.6 1.10 13 13 +#> x[1,9] 0.3 0.9 1.6 0.9 0.5 1.00 13 13 +#> x[1,10] 0.2 0.9 1.3 0.8 0.4 0.94 13 13 +#> x[1,11] -0.3 0.5 0.7 0.4 0.4 1.25 7 13 +#> x[1,12] -0.4 1.1 1.8 0.9 0.7 1.12 8 13 +#> x[1,13] -0.2 0.5 1.0 0.4 0.4 1.24 13 13 +#> x[1,14] 0.1 0.5 1.2 0.6 0.4 1.00 13 13 +#> x[1,15] -1.7 -0.9 -0.3 -1.0 0.5 1.06 13 13 +#> x[1,16] -1.5 -0.6 -0.2 -0.6 0.4 1.19 11 13 +#> x[1,17] -1.6 -0.5 0.0 -0.7 0.6 1.00 13 13 +#> x[1,18] -1.1 -0.3 0.6 -0.3 0.6 0.93 13 13 +#> x[1,19] -0.9 -0.1 0.8 0.0 0.6 1.15 10 13 +#> x[1,20] -0.1 0.6 1.5 0.7 0.6 1.01 13 13 +#> Z[1,1] -1.1 -0.8 -0.5 -0.8 0.2 1.01 13 13 +#> Z[2,1] -0.1 0.1 0.5 0.2 0.2 0.96 13 13 +#> Z[3,1] -1.0 -0.9 -0.5 -0.8 0.2 1.21 12 13 +#> log_lik[1] -3.1 -1.8 -0.7 -1.8 0.8 1.71 4 13 +#> log_lik[2] -2.1 -1.5 -0.7 -1.4 0.5 0.96 13 13 +#> log_lik[3] -2.4 -1.2 -0.6 -1.4 0.7 1.58 4 13 +#> log_lik[4] -1.3 -0.7 -0.6 -0.8 0.2 0.96 13 13 +#> log_lik[5] -3.0 -2.2 -1.7 -2.2 0.5 1.18 13 13 +#> log_lik[6] -1.2 -0.8 -0.5 -0.8 0.2 1.12 13 13 +#> log_lik[7] -1.1 -0.8 -0.5 -0.8 0.2 0.96 13 13 +#> log_lik[8] -1.0 -0.8 -0.5 -0.8 0.2 1.19 13 13 +#> log_lik[9] -1.1 -0.8 -0.6 -0.8 0.2 0.93 9 13 +#> log_lik[10] -1.3 -1.0 -0.6 -1.0 0.3 0.94 13 13 +#> log_lik[11] -0.8 -0.7 -0.5 -0.7 0.1 0.97 13 13 +#> log_lik[12] -1.2 -0.8 -0.5 -0.9 0.2 0.97 13 13 +#> log_lik[13] -1.1 -0.8 -0.6 -0.8 0.2 1.48 5 13 +#> log_lik[14] -1.4 -1.2 -1.0 -1.2 0.2 1.07 13 13 +#> log_lik[15] -0.9 -0.8 -0.6 -0.8 0.1 0.95 13 13 +#> log_lik[16] -1.1 -0.8 -0.5 -0.8 0.2 1.16 9 13 +#> log_lik[17] -2.5 -1.9 -1.4 -2.0 0.4 1.25 13 13 +#> log_lik[18] -0.9 -0.8 -0.6 -0.7 0.1 1.58 4 13 +#> log_lik[19] -2.1 -1.1 -0.5 -1.2 0.6 0.97 13 13 +#> log_lik[20] -0.9 -0.7 -0.5 -0.7 0.1 0.97 13 13 +#> log_lik[21] -1.5 -0.7 -0.5 -0.8 0.5 0.95 13 13 +#> log_lik[22] -1.5 -0.8 -0.5 -0.9 0.3 1.04 12 13 +#> log_lik[23] -1.5 -1.0 -0.6 -1.0 0.3 0.91 13 13 +#> log_lik[24] -1.7 -0.9 -0.6 -1.1 0.4 1.39 5 13 +#> log_lik[25] -1.8 -0.8 -0.6 -0.9 0.4 0.99 13 13 +#> log_lik[26] -2.2 -1.4 -1.1 -1.5 0.4 0.98 13 13 +#> log_lik[27] -1.2 -0.7 -0.5 -0.8 0.3 1.37 8 13 +#> log_lik[28] -1.1 -0.8 -0.5 -0.8 0.2 1.08 10 13 +#> log_lik[29] -1.9 -1.2 -1.0 -1.3 0.3 0.98 13 13 +#> log_lik[30] -1.0 -0.7 -0.5 -0.7 0.2 1.13 12 13 +#> log_lik[31] -0.9 -0.8 -0.6 -0.8 0.1 0.93 13 13 +#> log_lik[32] -0.8 -0.7 -0.5 -0.7 0.1 0.99 13 13 +#> log_lik[33] -0.9 -0.7 -0.5 -0.7 0.1 1.09 12 13 +#> log_lik[34] -1.6 -0.8 -0.5 -0.9 0.4 1.16 13 13 +#> log_lik[35] -2.0 -1.5 -1.1 -1.5 0.3 0.91 13 13 +#> log_lik[36] -2.0 -0.8 -0.5 -1.0 0.6 0.97 13 13 +#> log_lik[37] -1.0 -0.7 -0.6 -0.7 0.1 1.37 6 13 #> log_lik[38] -1.0 -0.8 -0.6 -0.8 0.1 0.94 13 13 -#> log_lik[39] -0.9 -0.6 -0.5 -0.7 0.1 1.03 12 13 -#> log_lik[40] -1.1 -0.9 -0.5 -0.8 0.2 1.14 11 13 -#> log_lik[41] -2.3 -1.9 -1.4 -1.9 0.3 0.93 13 13 -#> log_lik[42] -1.5 -1.1 -0.4 -1.0 0.4 1.19 13 13 -#> log_lik[43] -2.3 -1.5 -0.7 -1.5 0.6 1.14 11 13 -#> log_lik[44] -5.3 -4.2 -2.7 -4.0 0.9 0.93 13 13 -#> log_lik[45] -2.5 -1.5 -0.9 -1.7 0.6 1.19 9 13 -#> log_lik[46] -1.9 -1.0 -0.6 -1.1 0.5 1.07 9 13 -#> log_lik[47] -1.3 -1.0 -0.8 -1.0 0.2 1.02 13 13 -#> log_lik[48] -1.6 -0.7 -0.6 -0.9 0.4 1.00 9 13 -#> log_lik[49] -1.5 -0.7 -0.4 -0.8 0.4 1.45 12 13 -#> log_lik[50] -1.0 -0.7 -0.6 -0.7 0.2 1.18 13 13 -#> log_lik[51] -1.4 -0.7 -0.4 -0.8 0.3 1.07 13 13 -#> log_lik[52] -0.9 -0.7 -0.5 -0.7 0.1 1.25 13 13 -#> log_lik[53] -7.2 -5.4 -4.1 -5.6 1.1 0.91 13 13 -#> log_lik[54] -1.5 -0.7 -0.5 -0.8 0.5 1.05 13 13 -#> log_lik[55] -1.1 -0.8 -0.6 -0.8 0.2 1.00 13 13 -#> log_lik[56] -1.0 -0.8 -0.7 -0.8 0.1 0.95 12 13 -#> log_lik[57] -0.9 -0.6 -0.5 -0.6 0.1 1.58 13 13 -#> log_lik[58] -1.0 -0.6 -0.4 -0.6 0.2 1.19 13 13 -#> log_lik[59] -1.0 -0.8 -0.6 -0.8 0.2 1.02 13 13 -#> log_lik[60] -1.2 -0.8 -0.6 -0.8 0.2 1.07 9 13 -#> psi[1] 0.5 2.1 4.4 2.3 1.4 0.95 13 13 -#> xstar[1,1] -3.0 -1.7 -0.3 -1.6 1.0 1.08 10 13 -#> sigma[1] 0.6 0.7 0.9 0.7 0.1 1.30 13 13 -#> lp__ -74.9 -65.5 -63.4 -67.4 4.4 1.03 7 13 +#> log_lik[39] -1.2 -0.8 -0.5 -0.8 0.2 1.30 5 13 +#> log_lik[40] -1.1 -0.7 -0.5 -0.7 0.2 1.87 13 13 +#> log_lik[41] -2.2 -1.8 -1.3 -1.8 0.3 1.05 13 13 +#> log_lik[42] -1.0 -0.7 -0.6 -0.7 0.2 0.96 11 13 +#> log_lik[43] -2.4 -1.1 -0.9 -1.4 0.7 1.10 13 13 +#> log_lik[44] -5.3 -3.7 -2.6 -3.8 1.0 0.97 13 13 +#> log_lik[45] -2.6 -1.4 -0.9 -1.5 0.7 0.96 11 13 +#> log_lik[46] -2.2 -0.9 -0.6 -1.0 0.5 1.05 13 13 +#> log_lik[47] -1.3 -1.1 -0.7 -1.1 0.2 0.95 13 13 +#> log_lik[48] -1.3 -0.7 -0.6 -0.8 0.4 1.18 11 13 +#> log_lik[49] -1.6 -1.3 -0.6 -1.2 0.4 1.21 8 13 +#> log_lik[50] -0.9 -0.8 -0.6 -0.8 0.1 0.92 13 13 +#> log_lik[51] -1.6 -1.0 -0.7 -1.0 0.3 1.58 13 13 +#> log_lik[52] -1.3 -0.7 -0.5 -0.8 0.3 0.92 13 13 +#> log_lik[53] -6.0 -5.0 -3.6 -4.8 0.9 1.01 13 13 +#> log_lik[54] -2.2 -0.8 -0.7 -1.1 0.5 0.95 13 13 +#> log_lik[55] -1.7 -0.8 -0.6 -1.0 0.4 1.07 13 13 +#> log_lik[56] -1.1 -0.9 -0.6 -0.9 0.2 0.92 13 13 +#> log_lik[57] -1.2 -0.8 -0.6 -0.8 0.2 1.06 13 13 +#> log_lik[58] -1.4 -0.9 -0.6 -0.9 0.3 1.01 13 13 +#> log_lik[59] -1.1 -0.8 -0.6 -0.8 0.2 1.00 13 13 +#> log_lik[60] -2.0 -0.9 -0.7 -1.1 0.5 1.05 13 13 +#> xstar[1,1] -0.6 1.0 2.0 0.7 1.0 0.98 13 13 +#> sigma[1] 0.7 0.8 0.9 0.8 0.1 0.99 13 13 +#> lp__ -68.0 -64.4 -60.4 -64.5 2.6 2.06 4 13 #> #> For each parameter, Bulk_ESS and Tail_ESS are crude measures of #> effective sample size for bulk and tail quantities respectively (an ESS > 100 @@ -323,18 +325,18 @@

Examp #> Computed from 25 by 60 log-likelihood matrix #> #> Estimate SE -#> elpd_loo -77.1 6.3 -#> p_loo 12.4 2.5 -#> looic 154.3 12.6 +#> elpd_loo -260.5 12.8 +#> p_loo 175.8 13.3 +#> looic 521.1 25.6 #> ------ #> Monte Carlo SE of elpd_loo is NA. #> #> Pareto k diagnostic values: #> Count Pct. Min. n_eff -#> (-Inf, 0.5] (good) 34 56.7% 2 -#> (0.5, 0.7] (ok) 14 23.3% 3 -#> (0.7, 1] (bad) 8 13.3% 2 -#> (1, Inf) (very bad) 4 6.7% 6 +#> (-Inf, 0.5] (good) 42 70.0% 1 +#> (0.5, 0.7] (ok) 3 5.0% 1 +#> (0.7, 1] (bad) 6 10.0% 1 +#> (1, Inf) (very bad) 9 15.0% 0 #> See help('pareto-k-diagnostic') for details.

# }
diff --git a/docs/reference/plot_fitted-1.png b/docs/reference/plot_fitted-1.png index fe97d81..ac8eb89 100644 Binary files a/docs/reference/plot_fitted-1.png and b/docs/reference/plot_fitted-1.png differ diff --git a/docs/reference/plot_fitted-2.png b/docs/reference/plot_fitted-2.png index 1c19127..6a4246b 100644 Binary files a/docs/reference/plot_fitted-2.png and b/docs/reference/plot_fitted-2.png differ diff --git a/docs/reference/plot_fitted.html b/docs/reference/plot_fitted.html index 7820a12..1ceb84e 100644 --- a/docs/reference/plot_fitted.html +++ b/docs/reference/plot_fitted.html @@ -72,7 +72,7 @@ bayesdfa - 1.0.0 + 1.1.0 @@ -204,10 +204,12 @@

Examp #> Chain 1: Iteration: 45 / 50 [ 90%] (Sampling) #> Chain 1: Iteration: 50 / 50 [100%] (Sampling) #> Chain 1: -#> Chain 1: Elapsed Time: 0.006719 seconds (Warm-up) -#> Chain 1: 0.009244 seconds (Sampling) -#> Chain 1: 0.015963 seconds (Total) -#> Chain 1:
#> Warning: There were 1 chains where the estimated Bayesian Fraction of Missing Information was low. See +#> Chain 1: Elapsed Time: 0.005592 seconds (Warm-up) +#> Chain 1: 0.021775 seconds (Sampling) +#> Chain 1: 0.027367 seconds (Total) +#> Chain 1:
#> Warning: There were 19 divergent transitions after warmup. See +#> http://mc-stan.org/misc/warnings.html#divergent-transitions-after-warmup +#> to find out why this is a problem and how to eliminate them.
#> Warning: There were 1 chains where the estimated Bayesian Fraction of Missing Information was low. See #> http://mc-stan.org/misc/warnings.html#bfmi-low
#> Warning: Examine the pairs() plot to diagnose sampling problems
#> Warning: The largest R-hat is NA, indicating chains have not mixed. #> Running the chains for more iterations may help. See #> http://mc-stan.org/misc/warnings.html#r-hat
#> Warning: Bulk Effective Samples Size (ESS) is too low, indicating posterior means and medians may be unreliable. @@ -216,141 +218,139 @@

Examp #> Running the chains for more iterations may help. See #> http://mc-stan.org/misc/warnings.html#tail-ess

#> Inference for the input samples (1 chains: each with iter = 25; warmup = 12): #> -#> Q5 Q50 Q95 Mean SD Rhat Bulk_ESS Tail_ESS -#> x[1,1] -2.6 -2.6 -2.6 -2.6 0.0 1.58 7 13 -#> x[2,1] -0.1 -0.1 -0.1 -0.1 0.0 2.06 4 13 -#> x[1,2] 0.1 0.2 0.2 0.2 0.0 2.06 3 13 -#> x[2,2] -0.6 -0.6 -0.6 -0.6 0.0 2.06 3 13 -#> x[1,3] 1.1 1.2 1.2 1.1 0.0 2.06 3 13 -#> x[2,3] -0.6 -0.6 -0.6 -0.6 0.0 2.06 3 13 -#> x[1,4] 1.1 1.3 1.3 1.2 0.1 2.06 3 13 -#> x[2,4] -0.8 -0.8 -0.8 -0.8 0.0 2.06 3 13 -#> x[1,5] 3.6 3.7 3.7 3.7 0.1 2.06 3 13 -#> x[2,5] -1.1 -1.1 -1.0 -1.0 0.0 2.06 3 13 -#> x[1,6] -0.5 -0.4 -0.4 -0.4 0.1 2.06 3 13 -#> x[2,6] -1.1 -1.1 -1.1 -1.1 0.0 2.06 3 13 -#> x[1,7] 0.9 1.1 1.2 1.1 0.1 2.06 3 13 -#> x[2,7] -0.9 -0.9 -0.8 -0.8 0.0 2.06 3 13 -#> x[1,8] 1.5 1.7 1.8 1.6 0.1 2.06 3 13 -#> x[2,8] -0.2 -0.2 -0.2 -0.2 0.0 2.06 3 13 -#> x[1,9] 3.3 3.5 3.5 3.4 0.1 2.06 3 13 -#> x[2,9] -0.9 -0.9 -0.9 -0.9 0.0 2.06 3 13 -#> x[1,10] 3.8 4.0 4.1 4.0 0.1 2.06 3 13 -#> x[2,10] -0.5 -0.5 -0.5 -0.5 0.0 2.06 4 13 -#> x[1,11] 2.8 3.0 3.1 3.0 0.1 2.06 3 13 -#> x[2,11] -0.9 -0.9 -0.8 -0.9 0.0 2.06 3 13 -#> x[1,12] 0.1 0.3 0.3 0.2 0.1 2.06 3 13 -#> x[2,12] -0.8 -0.8 -0.8 -0.8 0.0 2.06 3 13 -#> x[1,13] 3.0 3.1 3.2 3.1 0.1 2.06 4 13 -#> x[2,13] 0.0 0.0 0.0 0.0 0.0 2.06 3 13 -#> x[1,14] 4.6 4.7 4.7 4.7 0.1 2.06 4 13 -#> x[2,14] -0.7 -0.7 -0.7 -0.7 0.0 2.06 3 13 -#> x[1,15] 1.9 1.9 1.9 1.9 0.0 1.87 4 13 -#> x[2,15] -0.1 -0.1 -0.1 -0.1 0.0 2.06 4 13 -#> x[1,16] -1.4 -1.4 -1.3 -1.4 0.0 2.06 3 13 -#> x[2,16] 0.5 0.5 0.5 0.5 0.0 2.06 4 13 -#> x[1,17] -4.9 -4.8 -4.7 -4.8 0.1 2.06 3 13 -#> x[2,17] 0.1 0.1 0.1 0.1 0.0 2.06 4 13 -#> x[1,18] -4.7 -4.6 -4.5 -4.6 0.1 2.06 3 13 -#> x[2,18] 0.0 0.0 0.1 0.1 0.0 2.06 3 13 -#> x[1,19] -0.6 -0.5 -0.4 -0.5 0.1 2.06 3 13 -#> x[2,19] -0.5 -0.5 -0.5 -0.5 0.0 2.06 3 13 -#> x[1,20] -2.9 -2.9 -2.7 -2.8 0.1 2.06 3 13 -#> x[2,20] 0.1 0.1 0.2 0.1 0.0 2.06 3 13 -#> Z[1,1] 2.7 2.7 2.7 2.7 0.0 1.45 5 13 -#> Z[2,1] -26.1 -25.8 -23.9 -25.2 1.0 2.06 3 13 -#> Z[3,1] 14.9 16.2 16.4 15.8 0.6 2.06 3 13 -#> Z[4,1] -2.3 -2.2 -2.2 -2.2 0.0 1.00 8 13 -#> Z[1,2] 0.0 0.0 0.0 0.0 0.0 1.00 13 13 -#> Z[2,2] 2.5 2.5 2.5 2.5 0.0 1.87 6 13 -#> Z[3,2] 56.2 59.8 60.6 58.7 1.9 2.06 3 13 -#> Z[4,2] -17.7 -17.2 -14.7 -16.5 1.3 2.06 3 13 -#> log_lik[1] -5.5 -5.3 -4.4 -5.0 0.5 2.06 3 13 -#> log_lik[2] -420.3 -378.9 -225.0 -332.7 82.8 2.06 3 13 -#> log_lik[3] -206.9 -185.6 -107.6 -162.6 41.9 2.06 3 13 -#> log_lik[4] -6.5 -5.9 -4.6 -5.6 0.8 2.06 3 13 -#> log_lik[5] -2.0 -1.9 -1.8 -1.9 0.1 2.06 3 13 -#> log_lik[6] -6.2 -5.4 -3.6 -5.0 1.1 2.06 3 13 -#> log_lik[7] -96.7 -87.2 -53.3 -77.1 18.4 2.06 3 13 -#> log_lik[8] -9.6 -8.6 -5.2 -7.6 1.9 2.06 3 13 -#> log_lik[9] -3.1 -3.0 -2.7 -2.9 0.2 2.06 3 13 -#> log_lik[10] -85.1 -74.2 -38.4 -63.9 19.7 2.06 3 13 -#> log_lik[11] -24.2 -22.3 -15.6 -20.2 3.7 2.06 3 13 -#> log_lik[12] -7.2 -6.5 -4.0 -5.8 1.4 2.06 3 13 -#> log_lik[13] -3.7 -3.6 -3.1 -3.4 0.3 2.06 3 13 -#> log_lik[14] -105.8 -92.4 -46.7 -79.0 24.9 2.06 3 13 -#> log_lik[15] -75.7 -68.6 -44.9 -61.5 13.1 2.06 3 13 -#> log_lik[16] -12.3 -10.9 -5.8 -9.5 2.7 2.06 3 13 -#> log_lik[17] -12.1 -11.2 -8.0 -10.3 1.7 2.06 3 13 -#> log_lik[18] -874.5 -775.9 -422.4 -671.5 191.5 2.06 3 13 -#> log_lik[19] -2.9 -2.2 -2.1 -2.4 0.3 2.06 4 13 -#> log_lik[20] -9.2 -8.2 -3.9 -6.9 2.3 2.06 3 13 -#> log_lik[21] -2.1 -1.9 -1.8 -1.9 0.1 2.06 3 13 -#> log_lik[22] -7.5 -5.3 -4.9 -6.0 1.2 2.06 4 13 -#> log_lik[23] -449.8 -404.2 -249.8 -359.0 84.2 2.06 3 13 -#> log_lik[24] -35.8 -31.3 -16.6 -27.2 8.1 2.06 3 13 -#> log_lik[25] -3.6 -3.5 -2.9 -3.3 0.3 2.06 3 13 -#> log_lik[26] -87.6 -74.8 -31.7 -62.1 23.9 2.06 3 13 -#> log_lik[27] -88.2 -79.8 -53.5 -72.2 14.5 2.06 3 13 -#> log_lik[28] -14.8 -13.0 -7.0 -11.3 3.3 2.06 3 13 -#> log_lik[29] -4.6 -4.4 -3.4 -4.1 0.5 2.06 3 13 -#> log_lik[30] -182.7 -157.2 -70.5 -131.7 47.9 2.06 3 13 -#> log_lik[31] -24.7 -21.8 -11.0 -18.6 5.8 2.06 3 13 -#> log_lik[32] -2.1 -1.9 -1.8 -1.9 0.1 2.06 3 13 -#> log_lik[33] -11.4 -10.6 -7.4 -9.6 1.7 2.06 3 13 -#> log_lik[34] -794.3 -702.8 -362.9 -601.5 183.9 2.06 3 13 -#> log_lik[35] -2.3 -2.2 -2.0 -2.2 0.1 2.06 4 13 -#> log_lik[36] -6.6 -5.9 -3.2 -5.1 1.5 2.06 3 13 -#> log_lik[37] -12.5 -11.6 -8.0 -10.6 1.9 2.06 3 13 -#> log_lik[38] -1019.5 -904.0 -474.0 -776.1 232.2 2.06 3 13 -#> log_lik[39] -112.4 -100.5 -51.5 -86.1 25.8 2.06 3 13 -#> log_lik[40] -2.2 -1.8 -1.8 -1.9 0.2 2.06 3 13 -#> log_lik[41] -6.5 -6.1 -4.5 -5.6 0.8 2.06 3 13 -#> log_lik[42] -592.4 -525.5 -269.8 -448.6 137.9 2.06 3 13 -#> log_lik[43] -3.1 -2.4 -2.3 -2.6 0.3 2.06 4 13 -#> log_lik[44] -8.5 -7.6 -4.0 -6.6 1.9 2.06 3 13 -#> log_lik[45] -2.0 -1.9 -1.8 -1.9 0.1 2.06 3 13 -#> log_lik[46] -9.7 -8.1 -2.9 -6.6 3.0 2.06 3 13 -#> log_lik[47] -187.2 -167.8 -105.9 -149.9 34.2 2.06 3 13 -#> log_lik[48] -20.6 -18.1 -9.9 -15.8 4.5 2.06 3 13 -#> log_lik[49] -6.8 -6.4 -4.8 -5.9 0.8 2.06 3 13 -#> log_lik[50] -614.6 -545.7 -290.2 -469.9 138.2 2.06 3 13 -#> log_lik[51] -203.4 -183.0 -106.4 -160.8 40.7 2.06 3 13 -#> log_lik[52] -5.0 -4.7 -4.3 -4.6 0.2 1.58 4 13 -#> log_lik[53] -15.1 -14.1 -10.1 -12.9 2.2 2.06 3 13 -#> log_lik[54] -1400.8 -1253.6 -707.1 -1090.9 295.0 2.06 3 13 -#> log_lik[55] -93.0 -84.6 -50.4 -74.8 17.8 2.06 3 13 -#> log_lik[56] -2.2 -2.2 -2.0 -2.1 0.1 2.06 4 13 -#> log_lik[57] -4.4 -4.3 -3.6 -4.1 0.3 2.06 3 13 -#> log_lik[58] -233.8 -210.2 -119.4 -183.0 49.2 2.06 3 13 -#> log_lik[59] -56.3 -51.9 -36.0 -47.4 8.4 2.06 3 13 -#> log_lik[60] -2.7 -2.3 -2.3 -2.5 0.2 2.06 4 13 -#> log_lik[61] -3.6 -3.5 -3.1 -3.4 0.2 2.06 3 13 -#> log_lik[62] -116.2 -102.1 -58.2 -89.6 23.8 2.06 3 13 -#> log_lik[63] -6.8 -5.0 -4.5 -5.5 1.0 2.06 4 13 -#> log_lik[64] -3.9 -3.8 -3.1 -3.6 0.4 2.06 3 13 -#> log_lik[65] -16.9 -15.6 -11.1 -14.3 2.4 2.06 3 13 -#> log_lik[66] -1393.8 -1235.4 -692.4 -1076.4 293.6 2.06 3 13 -#> log_lik[67] -492.4 -430.4 -218.4 -369.3 115.2 2.06 3 13 -#> log_lik[68] -8.1 -6.9 -5.1 -6.6 1.2 2.06 3 13 -#> log_lik[69] -18.4 -16.9 -11.8 -15.4 2.7 2.06 3 13 -#> log_lik[70] -1325.1 -1169.1 -648.1 -1016.9 283.2 2.06 3 13 -#> log_lik[71] -516.7 -449.7 -226.7 -385.5 122.0 2.06 3 13 -#> log_lik[72] -12.4 -10.7 -7.3 -9.8 2.1 2.06 3 13 -#> log_lik[73] -2.9 -2.8 -2.5 -2.7 0.2 2.06 3 13 -#> log_lik[74] -17.6 -13.6 -4.6 -11.2 5.2 2.06 3 13 -#> log_lik[75] -157.6 -133.4 -58.9 -112.0 41.7 2.06 3 13 -#> log_lik[76] -14.6 -12.6 -6.6 -10.9 3.4 2.06 3 13 -#> log_lik[77] -9.7 -8.9 -6.4 -8.2 1.4 2.06 3 13 -#> log_lik[78] -539.5 -471.6 -245.9 -405.8 123.0 2.06 3 13 -#> log_lik[79] -164.8 -139.7 -59.2 -116.6 44.6 2.06 3 13 -#> log_lik[80] -7.3 -6.4 -4.5 -5.9 1.1 2.06 3 13 -#> psi[1] 4.5 4.5 4.5 4.5 0.0 2.06 4 13 -#> psi[2] 0.2 0.2 0.2 0.2 0.0 1.87 4 13 -#> xstar[1,1] -5.4 -5.0 -2.7 -4.6 1.0 1.30 5 13 -#> xstar[2,1] 1.1 2.0 3.8 2.2 0.9 1.87 13 13 -#> sigma[1] 2.4 2.5 3.0 2.6 0.3 2.06 3 13 -#> lp__ -15656.7 -14104.7 -8511.2 -12454.1 3021.5 2.06 3 13 +#> Q5 Q50 Q95 Mean SD Rhat Bulk_ESS Tail_ESS +#> x[1,1] -0.6 -0.6 -0.6 -0.6 0.0 1.03 13 13 +#> x[2,1] 0.4 0.4 0.4 0.4 0.0 1.16 9 13 +#> x[1,2] 1.0 1.0 1.0 1.0 0.0 1.16 9 13 +#> x[2,2] -0.7 -0.6 -0.6 -0.6 0.0 1.11 8 13 +#> x[1,3] 1.7 1.7 1.7 1.7 0.0 2.16 3 6 +#> x[2,3] -0.2 -0.1 -0.1 -0.1 0.0 1.16 7 13 +#> x[1,4] 1.6 1.6 1.6 1.6 0.0 2.16 3 6 +#> x[2,4] -0.4 -0.4 -0.4 -0.4 0.0 0.99 9 13 +#> x[1,5] 2.8 2.8 2.8 2.8 0.0 2.16 3 6 +#> x[2,5] -1.0 -1.0 -1.0 -1.0 0.0 1.16 10 13 +#> x[1,6] 1.0 1.1 1.1 1.1 0.0 2.16 3 6 +#> x[2,6] -1.6 -1.6 -1.6 -1.6 0.0 2.23 9 13 +#> x[1,7] 2.0 2.1 2.1 2.1 0.0 2.16 3 6 +#> x[2,7] -0.6 -0.6 -0.6 -0.6 0.0 1.63 10 13 +#> x[1,8] 1.9 1.9 1.9 1.9 0.0 2.16 3 6 +#> x[2,8] 0.3 0.3 0.3 0.3 0.0 1.63 10 13 +#> x[1,9] 2.4 2.5 2.5 2.5 0.0 2.16 3 6 +#> x[2,9] -1.3 -1.3 -1.3 -1.3 0.0 2.22 9 13 +#> x[1,10] 2.9 2.9 2.9 2.9 0.0 2.16 3 6 +#> x[2,10] -0.3 -0.3 -0.2 -0.3 0.0 1.63 9 13 +#> x[1,11] 2.3 2.4 2.4 2.4 0.0 2.16 3 6 +#> x[2,11] -0.9 -0.9 -0.8 -0.9 0.0 2.22 9 13 +#> x[1,12] 1.1 1.2 1.2 1.2 0.0 2.16 3 6 +#> x[2,12] -0.7 -0.7 -0.6 -0.7 0.0 2.22 9 13 +#> x[1,13] 2.1 2.2 2.2 2.2 0.0 2.16 3 6 +#> x[2,13] 1.0 1.1 1.1 1.1 0.0 2.22 10 13 +#> x[1,14] 3.2 3.3 3.3 3.3 0.0 2.16 3 6 +#> x[2,14] -0.8 -0.8 -0.8 -0.8 0.0 1.63 10 13 +#> x[1,15] 1.9 2.0 2.0 2.0 0.0 2.16 3 6 +#> x[2,15] 0.9 1.0 1.0 1.0 0.0 2.22 9 13 +#> x[1,16] 0.1 0.2 0.2 0.2 0.0 2.16 3 6 +#> x[2,16] 2.1 2.1 2.1 2.1 0.0 1.63 13 13 +#> x[1,17] -0.7 -0.6 -0.6 -0.6 0.0 2.16 3 6 +#> x[2,17] 1.2 1.3 1.3 1.3 0.0 2.22 9 13 +#> x[1,18] -0.9 -0.9 -0.8 -0.9 0.0 2.16 3 6 +#> x[2,18] 0.4 0.4 0.4 0.4 0.0 1.14 12 13 +#> x[1,19] 0.5 0.5 0.5 0.5 0.0 2.16 3 6 +#> x[2,19] -0.7 -0.6 -0.6 -0.6 0.0 1.03 13 13 +#> x[1,20] -0.5 -0.4 -0.4 -0.5 0.0 2.16 3 6 +#> x[2,20] 0.8 0.8 0.8 0.8 0.0 1.21 12 13 +#> Z[1,1] -0.3 -0.2 -0.1 -0.2 0.1 1.60 4 13 +#> Z[2,1] 0.0 0.1 0.1 0.1 0.0 0.92 13 13 +#> Z[3,1] -0.2 -0.1 0.2 -0.1 0.1 0.91 13 13 +#> Z[4,1] -0.2 0.2 0.3 0.1 0.2 1.35 7 13 +#> Z[1,2] 0.0 0.0 0.0 0.0 0.0 1.00 13 13 +#> Z[2,2] 0.1 0.3 0.6 0.3 0.2 1.50 4 13 +#> Z[3,2] 0.2 0.4 0.5 0.3 0.1 1.18 13 13 +#> Z[4,2] -0.4 -0.2 -0.1 -0.2 0.1 1.05 8 13 +#> log_lik[1] -1.0 -1.0 -0.9 -1.0 0.0 2.13 4 13 +#> log_lik[2] -2.5 -2.2 -2.1 -2.2 0.1 1.20 5 13 +#> log_lik[3] -1.9 -1.6 -1.5 -1.7 0.1 0.95 8 6 +#> log_lik[4] -1.2 -1.1 -1.0 -1.1 0.1 1.18 9 13 +#> log_lik[5] -0.8 -0.8 -0.8 -0.8 0.0 2.12 4 13 +#> log_lik[6] -1.5 -1.2 -1.1 -1.2 0.1 1.20 5 13 +#> log_lik[7] -1.0 -0.9 -0.8 -0.9 0.1 0.95 10 6 +#> log_lik[8] -1.0 -0.9 -0.8 -0.9 0.1 1.65 9 6 +#> log_lik[9] -1.0 -0.9 -0.9 -0.9 0.1 1.60 4 13 +#> log_lik[10] -2.2 -2.0 -1.9 -2.0 0.1 0.92 13 13 +#> log_lik[11] -1.6 -1.1 -1.0 -1.2 0.2 0.91 13 13 +#> log_lik[12] -0.9 -0.9 -0.8 -0.9 0.0 0.93 13 13 +#> log_lik[13] -1.6 -1.5 -1.2 -1.5 0.1 1.60 4 13 +#> log_lik[14] -1.6 -1.5 -1.3 -1.5 0.1 1.39 5 13 +#> log_lik[15] -1.9 -1.4 -1.2 -1.5 0.3 0.96 11 13 +#> log_lik[16] -1.8 -1.2 -1.1 -1.3 0.3 1.16 9 6 +#> log_lik[17] -1.0 -0.9 -0.9 -1.0 0.1 1.62 4 13 +#> log_lik[18] -0.9 -0.9 -0.8 -0.9 0.0 1.63 12 13 +#> log_lik[19] -1.5 -0.9 -0.8 -1.0 0.3 0.96 11 13 +#> log_lik[20] -1.8 -1.0 -0.8 -1.1 0.4 1.35 9 6 +#> log_lik[21] -0.9 -0.9 -0.8 -0.9 0.0 1.60 4 13 +#> log_lik[22] -2.0 -1.3 -1.0 -1.3 0.4 1.26 5 13 +#> log_lik[23] -1.2 -1.0 -0.8 -1.0 0.1 0.95 10 13 +#> log_lik[24] -0.9 -0.8 -0.8 -0.8 0.0 1.02 9 4 +#> log_lik[25] -1.7 -1.6 -1.2 -1.6 0.2 1.60 4 13 +#> log_lik[26] -2.3 -2.1 -1.6 -2.1 0.2 1.19 7 13 +#> log_lik[27] -2.8 -1.8 -1.5 -2.0 0.4 0.96 11 13 +#> log_lik[28] -1.0 -0.8 -0.8 -0.9 0.1 1.35 4 13 +#> log_lik[29] -1.2 -1.1 -1.0 -1.1 0.1 1.60 4 13 +#> log_lik[30] -1.9 -1.7 -1.6 -1.7 0.1 1.49 13 13 +#> log_lik[31] -2.7 -1.8 -1.5 -1.9 0.4 0.91 13 13 +#> log_lik[32] -1.4 -0.8 -0.8 -1.0 0.2 1.35 7 13 +#> log_lik[33] -1.2 -1.1 -0.9 -1.1 0.1 1.60 4 13 +#> log_lik[34] -1.2 -0.9 -0.8 -0.9 0.1 1.20 6 13 +#> log_lik[35] -1.1 -0.9 -0.8 -0.9 0.1 1.50 10 6 +#> log_lik[36] -1.3 -0.9 -0.8 -1.0 0.2 1.35 9 6 +#> log_lik[37] -1.1 -0.8 -0.8 -0.9 0.1 2.13 4 13 +#> log_lik[38] -0.9 -0.9 -0.8 -0.9 0.0 1.01 13 13 +#> log_lik[39] -1.9 -1.5 -0.9 -1.4 0.3 0.91 13 13 +#> log_lik[40] -1.4 -1.2 -0.8 -1.1 0.2 1.16 11 13 +#> log_lik[41] -2.3 -1.7 -1.6 -1.8 0.3 1.60 4 13 +#> log_lik[42] -0.9 -0.8 -0.8 -0.9 0.0 1.79 12 13 +#> log_lik[43] -1.2 -1.0 -0.8 -0.9 0.1 1.26 13 6 +#> log_lik[44] -1.5 -1.2 -0.8 -1.2 0.3 1.06 9 13 +#> log_lik[45] -1.0 -0.9 -0.9 -0.9 0.0 2.13 4 13 +#> log_lik[46] -0.9 -0.9 -0.8 -0.9 0.0 1.20 5 13 +#> log_lik[47] -1.5 -1.2 -1.0 -1.2 0.1 0.95 10 6 +#> log_lik[48] -1.5 -1.3 -1.1 -1.3 0.2 1.18 9 13 +#> log_lik[49] -2.2 -1.7 -1.5 -1.8 0.3 1.60 4 13 +#> log_lik[50] -1.1 -0.9 -0.8 -1.0 0.1 1.27 5 13 +#> log_lik[51] -1.5 -1.1 -0.8 -1.1 0.3 0.93 13 13 +#> log_lik[52] -1.1 -1.1 -0.8 -1.0 0.1 1.16 5 4 +#> log_lik[53] -1.8 -1.2 -1.0 -1.3 0.4 1.60 4 13 +#> log_lik[54] -2.5 -1.8 -1.6 -1.9 0.3 1.39 5 6 +#> log_lik[55] -3.3 -2.5 -1.3 -2.3 0.6 0.95 11 6 +#> log_lik[56] -1.6 -1.2 -0.8 -1.2 0.3 1.06 11 13 +#> log_lik[57] -0.9 -0.8 -0.8 -0.8 0.0 1.18 13 13 +#> log_lik[58] -1.1 -0.9 -0.8 -0.9 0.1 1.27 5 13 +#> log_lik[59] -1.1 -0.8 -0.8 -0.9 0.1 1.16 5 13 +#> log_lik[60] -1.1 -0.9 -0.8 -0.9 0.1 2.11 4 13 +#> log_lik[61] -1.3 -1.3 -1.3 -1.3 0.0 1.18 9 13 +#> log_lik[62] -1.9 -1.3 -0.8 -1.4 0.4 1.50 4 13 +#> log_lik[63] -1.4 -0.9 -0.8 -1.0 0.3 1.18 12 13 +#> log_lik[64] -0.9 -0.8 -0.8 -0.9 0.0 1.41 7 4 +#> log_lik[65] -0.8 -0.8 -0.8 -0.8 0.0 1.04 10 13 +#> log_lik[66] -2.0 -1.6 -1.1 -1.6 0.3 1.26 5 13 +#> log_lik[67] -0.9 -0.8 -0.8 -0.8 0.0 1.01 12 13 +#> log_lik[68] -2.1 -1.8 -1.7 -1.9 0.2 1.48 12 13 +#> log_lik[69] -1.7 -1.6 -1.4 -1.6 0.1 2.13 4 13 +#> log_lik[70] -1.0 -0.9 -0.9 -0.9 0.0 1.19 7 6 +#> log_lik[71] -2.1 -1.8 -1.5 -1.8 0.2 0.95 10 13 +#> log_lik[72] -1.3 -1.1 -1.0 -1.1 0.1 1.35 9 6 +#> log_lik[73] -3.8 -3.6 -3.6 -3.6 0.1 1.33 5 13 +#> log_lik[74] -1.5 -1.2 -1.1 -1.3 0.1 1.26 5 13 +#> log_lik[75] -2.4 -2.0 -1.9 -2.1 0.2 0.96 9 6 +#> log_lik[76] -3.0 -2.7 -2.7 -2.8 0.1 0.93 11 13 +#> log_lik[77] -2.4 -2.4 -2.2 -2.4 0.1 2.13 4 13 +#> log_lik[78] -2.9 -2.2 -2.0 -2.3 0.3 1.26 5 13 +#> log_lik[79] -1.0 -0.9 -0.8 -0.9 0.1 0.95 10 13 +#> log_lik[80] -5.4 -5.2 -4.8 -5.2 0.2 0.93 11 4 +#> xstar[1,1] -2.4 -0.6 1.0 -0.6 1.3 1.12 10 13 +#> xstar[2,1] -0.3 0.5 1.5 0.5 0.7 1.37 6 13 +#> sigma[1] 0.9 0.9 0.9 0.9 0.0 1.50 7 13 +#> lp__ -105.9 -102.5 -102.3 -103.5 1.6 1.25 6 6 #> #> For each parameter, Bulk_ESS and Tail_ESS are crude measures of #> effective sample size for bulk and tail quantities respectively (an ESS > 100 diff --git a/docs/reference/plot_loadings-1.png b/docs/reference/plot_loadings-1.png index 05141a0..a07b7b3 100644 Binary files a/docs/reference/plot_loadings-1.png and b/docs/reference/plot_loadings-1.png differ diff --git a/docs/reference/plot_loadings-2.png b/docs/reference/plot_loadings-2.png index 7e69221..6e03deb 100644 Binary files a/docs/reference/plot_loadings-2.png and b/docs/reference/plot_loadings-2.png differ diff --git a/docs/reference/plot_loadings-3.png b/docs/reference/plot_loadings-3.png index a306186..0d55ee9 100644 Binary files a/docs/reference/plot_loadings-3.png and b/docs/reference/plot_loadings-3.png differ diff --git a/docs/reference/plot_loadings-4.png b/docs/reference/plot_loadings-4.png index 2b32afa..2d8059c 100644 Binary files a/docs/reference/plot_loadings-4.png and b/docs/reference/plot_loadings-4.png differ diff --git a/docs/reference/plot_loadings.html b/docs/reference/plot_loadings.html index 71a9a7c..a72b335 100644 --- a/docs/reference/plot_loadings.html +++ b/docs/reference/plot_loadings.html @@ -72,7 +72,7 @@ bayesdfa - 1.0.0 + 1.1.0
@@ -199,8 +199,8 @@

Examp
#> #> SAMPLING FOR MODEL 'dfa' NOW (CHAIN 1). #> Chain 1: -#> Chain 1: Gradient evaluation took 4.3e-05 seconds -#> Chain 1: 1000 transitions using 10 leapfrog steps per transition would take 0.43 seconds. +#> Chain 1: Gradient evaluation took 3.2e-05 seconds +#> Chain 1: 1000 transitions using 10 leapfrog steps per transition would take 0.32 seconds. #> Chain 1: Adjust your expectations accordingly! #> Chain 1: #> Chain 1: @@ -225,12 +225,10 @@

Examp #> Chain 1: Iteration: 45 / 50 [ 90%] (Sampling) #> Chain 1: Iteration: 50 / 50 [100%] (Sampling) #> Chain 1: -#> Chain 1: Elapsed Time: 0.003718 seconds (Warm-up) -#> Chain 1: 0.324694 seconds (Sampling) -#> Chain 1: 0.328412 seconds (Total) -#> Chain 1:

#> Warning: There were 2 divergent transitions after warmup. See -#> http://mc-stan.org/misc/warnings.html#divergent-transitions-after-warmup -#> to find out why this is a problem and how to eliminate them.
#> Warning: There were 1 chains where the estimated Bayesian Fraction of Missing Information was low. See +#> Chain 1: Elapsed Time: 0.021759 seconds (Warm-up) +#> Chain 1: 0.209865 seconds (Sampling) +#> Chain 1: 0.231624 seconds (Total) +#> Chain 1:
#> Warning: There were 1 chains where the estimated Bayesian Fraction of Missing Information was low. See #> http://mc-stan.org/misc/warnings.html#bfmi-low
#> Warning: Examine the pairs() plot to diagnose sampling problems
#> Warning: The largest R-hat is NA, indicating chains have not mixed. #> Running the chains for more iterations may help. See #> http://mc-stan.org/misc/warnings.html#r-hat
#> Warning: Bulk Effective Samples Size (ESS) is too low, indicating posterior means and medians may be unreliable. @@ -239,81 +237,79 @@

Examp #> Running the chains for more iterations may help. See #> http://mc-stan.org/misc/warnings.html#tail-ess

#> Inference for the input samples (1 chains: each with iter = 25; warmup = 12): #> -#> Q5 Q50 Q95 Mean SD Rhat Bulk_ESS Tail_ESS -#> x[1,1] -1.0 0.0 0.5 -0.1 0.5 1.02 13 13 -#> x[2,1] -0.5 0.6 1.6 0.5 0.8 1.12 13 13 -#> x[1,2] 0.0 0.7 2.0 0.9 0.8 1.21 8 13 -#> x[2,2] 0.3 1.5 2.5 1.4 0.7 0.96 13 13 -#> x[1,3] 1.2 1.7 4.2 2.2 1.0 0.99 11 13 -#> x[2,3] -0.9 0.0 2.4 0.4 1.1 1.58 4 13 -#> x[1,4] -0.6 0.6 2.0 0.6 0.9 1.05 10 13 -#> x[2,4] 0.9 1.6 2.7 1.8 0.7 1.04 10 13 -#> x[1,5] -1.6 -0.2 0.7 -0.3 0.8 1.07 13 13 -#> x[2,5] 0.3 1.2 2.7 1.4 0.9 0.96 11 13 -#> x[1,6] -1.1 -0.4 -0.1 -0.5 0.4 0.94 13 13 -#> x[2,6] -1.0 0.0 0.6 -0.1 0.6 1.71 4 13 -#> x[1,7] -1.6 -0.8 -0.2 -0.8 0.5 1.00 9 13 -#> x[2,7] -3.4 -1.8 -0.1 -2.0 1.2 1.14 9 13 -#> x[1,8] -2.5 -0.9 -0.4 -1.1 0.9 1.30 6 13 -#> x[2,8] -4.1 -2.2 -0.7 -2.5 1.2 1.03 13 13 -#> x[1,9] -2.5 -1.1 -0.2 -1.1 0.8 1.33 7 13 -#> x[2,9] -4.0 -2.3 -0.7 -2.3 1.2 1.00 11 13 -#> x[1,10] -1.0 0.1 0.5 -0.1 0.5 1.02 13 13 -#> x[2,10] -3.5 -0.6 0.2 -1.0 1.5 0.93 13 13 -#> Z[1,1] 0.4 0.8 1.2 0.8 0.3 1.04 13 13 -#> Z[2,1] -1.8 -0.7 -0.3 -0.9 0.6 1.58 4 13 -#> Z[3,1] 0.2 0.9 2.3 1.1 0.7 1.13 9 13 -#> Z[4,1] -1.8 -0.6 -0.1 -0.8 0.6 1.58 4 13 -#> Z[1,2] 0.0 0.0 0.0 0.0 0.0 1.00 13 13 -#> Z[2,2] 0.2 0.7 1.3 0.7 0.4 1.06 13 13 -#> Z[3,2] -1.2 -0.6 -0.3 -0.6 0.3 1.22 7 13 -#> Z[4,2] 0.3 0.7 1.5 0.8 0.5 1.30 9 13 -#> log_lik[1] -0.6 -0.3 0.0 -0.3 0.2 1.24 6 13 -#> log_lik[2] -2.3 -0.5 -0.3 -0.9 0.9 1.04 10 13 -#> log_lik[3] -1.2 -0.4 0.0 -0.4 0.4 1.24 6 13 -#> log_lik[4] -1.0 -0.3 0.0 -0.4 0.4 1.21 7 13 -#> log_lik[5] -1.4 -0.4 -0.1 -0.5 0.5 1.71 13 13 -#> log_lik[6] -2.6 -1.7 -0.4 -1.6 0.8 1.06 13 13 -#> log_lik[7] -0.6 -0.3 0.1 -0.3 0.2 1.24 6 13 -#> log_lik[8] -1.4 -0.5 -0.1 -0.6 0.4 1.00 8 13 -#> log_lik[9] -3.7 -1.4 -0.2 -1.7 1.2 1.14 9 13 -#> log_lik[10] -2.8 -0.5 0.1 -0.8 1.0 1.33 6 13 -#> log_lik[11] -3.0 -0.5 -0.1 -1.1 1.1 0.98 13 13 -#> log_lik[12] -2.7 -0.6 0.0 -0.9 1.1 1.03 13 13 -#> log_lik[13] -1.9 -1.1 -0.1 -1.0 0.7 1.12 9 13 -#> log_lik[14] -1.0 -0.4 -0.1 -0.5 0.3 1.08 7 13 -#> log_lik[15] -1.5 -0.3 0.0 -0.5 0.6 1.09 8 13 -#> log_lik[16] -0.8 -0.4 0.0 -0.4 0.3 0.99 13 13 -#> log_lik[17] -1.4 -0.6 -0.2 -0.6 0.5 0.97 13 13 -#> log_lik[18] -1.3 -0.4 0.0 -0.5 0.5 1.00 13 13 -#> log_lik[19] -1.6 -0.6 -0.2 -0.8 0.5 1.03 13 13 -#> log_lik[20] -1.1 -0.3 0.0 -0.4 0.4 1.18 13 13 -#> log_lik[21] -0.6 -0.3 0.0 -0.3 0.2 1.71 4 13 -#> log_lik[22] -1.4 -0.4 0.0 -0.5 0.5 1.03 13 13 -#> log_lik[23] -1.3 -0.4 0.0 -0.5 0.5 1.18 7 13 -#> log_lik[24] -1.2 -0.3 0.0 -0.4 0.4 1.33 7 13 -#> log_lik[25] -0.9 -0.5 0.0 -0.5 0.3 0.96 13 13 -#> log_lik[26] -1.1 -0.4 0.0 -0.4 0.5 1.31 5 13 -#> log_lik[27] -2.0 -0.7 -0.1 -0.9 0.7 0.97 13 13 -#> log_lik[28] -1.0 -0.2 0.0 -0.3 0.4 1.71 4 13 -#> log_lik[29] -1.7 -0.3 0.0 -0.5 0.6 1.18 8 13 -#> log_lik[30] -2.3 -0.8 -0.2 -0.9 0.8 0.92 13 13 -#> log_lik[31] -1.4 -0.4 0.1 -0.6 0.5 1.06 8 13 -#> log_lik[32] -0.9 -0.3 -0.1 -0.4 0.3 1.18 7 13 -#> log_lik[33] -3.0 -0.7 -0.3 -1.0 1.0 1.25 8 13 -#> log_lik[34] -1.1 -0.6 0.0 -0.6 0.4 1.32 7 13 -#> log_lik[35] -1.7 -0.3 0.0 -0.5 0.6 1.58 5 13 -#> log_lik[36] -1.1 -0.3 0.0 -0.4 0.4 1.71 4 13 -#> log_lik[37] -1.8 -0.3 -0.1 -0.7 0.7 1.09 10 13 -#> log_lik[38] -0.8 -0.3 0.0 -0.3 0.3 1.71 4 13 -#> log_lik[39] -2.0 -0.6 -0.2 -0.9 0.7 1.12 11 13 -#> log_lik[40] -1.7 -0.5 -0.1 -0.7 0.6 0.96 13 13 -#> psi[1] 0.5 1.1 4.7 1.7 1.5 1.18 13 13 -#> psi[2] 1.0 2.4 3.8 2.3 1.0 0.92 8 13 -#> xstar[1,1] -0.8 0.6 2.4 0.8 1.1 1.00 13 13 -#> xstar[2,1] -3.8 0.5 2.6 -0.1 2.3 1.04 7 13 -#> sigma[1] 0.4 0.5 0.6 0.5 0.1 1.71 4 13 -#> lp__ -37.0 -24.8 -16.0 -25.8 7.1 1.04 7 13 +#> Q5 Q50 Q95 Mean SD Rhat Bulk_ESS Tail_ESS +#> x[1,1] -1.5 -0.7 0.8 -0.6 0.8 1.37 6 13 +#> x[2,1] -1.0 -0.2 0.6 -0.2 0.6 1.58 9 13 +#> x[1,2] -1.7 0.2 0.9 -0.3 1.1 2.06 4 13 +#> x[2,2] 0.2 0.5 1.2 0.6 0.4 1.16 12 13 +#> x[1,3] -1.6 0.0 0.8 -0.4 1.0 2.06 4 13 +#> x[2,3] -1.4 -0.2 0.3 -0.4 0.6 2.06 4 13 +#> x[1,4] -1.5 -0.4 0.7 -0.4 0.9 2.06 4 13 +#> x[2,4] -0.1 0.6 1.3 0.6 0.5 1.06 11 13 +#> x[1,5] -0.7 -0.2 0.7 -0.1 0.5 0.95 11 13 +#> x[2,5] -1.4 -0.6 1.5 -0.3 1.2 1.87 6 13 +#> x[1,6] -0.9 -0.3 0.3 -0.3 0.5 1.16 6 13 +#> x[2,6] -0.2 0.1 0.6 0.1 0.3 1.45 10 13 +#> x[1,7] -2.2 -1.2 0.3 -1.1 0.9 1.71 4 13 +#> x[2,7] -1.1 -0.1 0.9 -0.1 0.6 1.47 13 13 +#> x[1,8] -1.7 -0.8 0.5 -0.7 0.8 1.32 5 13 +#> x[2,8] -1.1 0.2 1.4 0.2 0.8 1.71 13 13 +#> x[1,9] -1.3 -0.2 0.7 -0.2 0.6 1.15 8 13 +#> x[2,9] -1.2 0.5 1.2 0.2 0.9 2.06 9 13 +#> x[1,10] -1.4 -0.7 0.2 -0.7 0.6 1.48 5 13 +#> x[2,10] -1.0 -0.4 0.3 -0.4 0.4 0.99 13 13 +#> Z[1,1] -3.6 0.3 3.6 0.2 2.4 2.06 13 13 +#> Z[2,1] -0.5 0.5 1.4 0.3 0.7 0.95 13 13 +#> Z[3,1] -1.5 -0.5 1.0 -0.4 0.9 1.87 4 13 +#> Z[4,1] -0.8 0.1 1.9 0.4 0.9 1.20 6 13 +#> Z[1,2] 0.0 0.0 0.0 0.0 0.0 1.00 13 13 +#> Z[2,2] -4.2 1.0 6.2 0.6 3.9 1.18 13 13 +#> Z[3,2] -1.7 -0.7 0.5 -0.6 0.8 1.06 8 13 +#> Z[4,2] -1.2 0.9 1.8 0.6 1.1 0.97 13 13 +#> log_lik[1] -4.3 -1.5 -0.6 -2.0 1.5 1.87 4 13 +#> log_lik[2] -4.3 -1.3 -0.6 -1.9 1.4 1.87 4 13 +#> log_lik[3] -4.3 -1.2 -0.6 -1.9 1.5 2.06 4 13 +#> log_lik[4] -4.3 -1.1 -0.5 -2.0 1.5 2.06 4 13 +#> log_lik[5] -4.3 -1.2 -0.8 -2.0 1.4 2.06 4 13 +#> log_lik[6] -4.3 -1.3 -0.6 -2.0 1.4 1.71 4 13 +#> log_lik[7] -4.3 -1.3 -0.6 -2.0 1.4 1.87 4 13 +#> log_lik[8] -4.7 -1.4 -0.5 -2.3 1.8 1.87 4 13 +#> log_lik[9] -5.7 -3.5 -2.2 -3.6 1.3 0.98 13 13 +#> log_lik[10] -4.3 -2.2 -0.5 -2.5 1.5 1.24 5 13 +#> log_lik[11] -4.3 -2.1 -0.6 -2.5 1.4 1.32 4 13 +#> log_lik[12] -4.3 -1.6 -0.6 -2.1 1.4 1.47 4 13 +#> log_lik[13] -4.3 -1.4 -0.6 -2.1 1.5 1.87 4 13 +#> log_lik[14] -4.3 -1.5 -0.5 -2.0 1.5 1.87 4 13 +#> log_lik[15] -4.3 -1.5 -0.6 -2.0 1.4 2.06 3 13 +#> log_lik[16] -4.3 -1.5 -0.6 -2.2 1.5 1.87 4 13 +#> log_lik[17] -4.3 -1.3 -0.5 -1.8 1.5 2.06 3 13 +#> log_lik[18] -4.4 -2.0 -0.5 -2.1 1.5 2.06 3 13 +#> log_lik[19] -4.3 -1.9 -0.6 -2.1 1.4 2.06 4 13 +#> log_lik[20] -4.3 -1.7 -0.5 -2.0 1.4 2.06 4 13 +#> log_lik[21] -4.3 -1.1 -0.5 -1.9 1.5 2.06 3 13 +#> log_lik[22] -4.3 -1.2 -0.6 -1.9 1.4 2.06 4 13 +#> log_lik[23] -4.3 -1.3 -0.7 -1.9 1.4 1.87 4 13 +#> log_lik[24] -4.3 -1.3 -0.7 -1.9 1.4 2.06 4 13 +#> log_lik[25] -4.4 -2.2 -0.6 -2.3 1.6 1.87 4 13 +#> log_lik[26] -4.3 -1.5 -0.7 -2.1 1.4 1.58 4 13 +#> log_lik[27] -4.3 -1.6 -0.6 -2.1 1.4 2.06 4 13 +#> log_lik[28] -4.3 -1.5 -0.9 -2.1 1.4 2.06 4 13 +#> log_lik[29] -4.3 -1.5 -0.9 -2.3 1.3 1.47 4 13 +#> log_lik[30] -4.3 -1.3 -0.7 -2.0 1.4 1.71 4 13 +#> log_lik[31] -4.3 -1.1 -0.5 -1.8 1.5 2.06 3 13 +#> log_lik[32] -4.3 -1.4 -0.6 -1.9 1.4 1.87 4 13 +#> log_lik[33] -4.3 -1.7 -1.0 -2.2 1.2 1.58 4 13 +#> log_lik[34] -4.3 -1.6 -0.7 -2.1 1.4 2.06 4 13 +#> log_lik[35] -4.3 -1.0 -0.5 -1.8 1.5 2.06 3 13 +#> log_lik[36] -4.3 -1.0 -0.6 -1.9 1.5 2.06 4 13 +#> log_lik[37] -4.3 -2.0 -0.7 -2.1 1.4 2.06 4 13 +#> log_lik[38] -4.3 -1.2 -0.5 -1.8 1.5 2.06 3 13 +#> log_lik[39] -4.3 -1.7 -0.6 -2.0 1.3 1.87 4 13 +#> log_lik[40] -4.3 -1.3 -0.6 -2.0 1.4 2.06 4 13 +#> xstar[1,1] -2.1 -0.5 1.3 -0.6 1.2 1.00 9 13 +#> xstar[2,1] -2.0 -0.4 1.2 -0.3 1.2 1.12 8 13 +#> sigma[1] 0.6 1.0 29.7 7.5 11.8 2.06 3 13 +#> lp__ -203.1 -43.1 -19.4 -78.8 72.9 2.06 3 13 #> #> For each parameter, Bulk_ESS and Tail_ESS are crude measures of #> effective sample size for bulk and tail quantities respectively (an ESS > 100 diff --git a/docs/reference/plot_regime_model.html b/docs/reference/plot_regime_model.html index 7ee6c5d..5634aa5 100644 --- a/docs/reference/plot_regime_model.html +++ b/docs/reference/plot_regime_model.html @@ -72,7 +72,7 @@ bayesdfa - 1.0.0 + 1.1.0
@@ -197,8 +197,8 @@

Examp
#> #> SAMPLING FOR MODEL 'hmm_gaussian' NOW (CHAIN 1). #> Chain 1: -#> Chain 1: Gradient evaluation took 7.1e-05 seconds -#> Chain 1: 1000 transitions using 10 leapfrog steps per transition would take 0.71 seconds. +#> Chain 1: Gradient evaluation took 8.4e-05 seconds +#> Chain 1: 1000 transitions using 10 leapfrog steps per transition would take 0.84 seconds. #> Chain 1: Adjust your expectations accordingly! #> Chain 1: #> Chain 1: @@ -223,9 +223,9 @@

Examp #> Chain 1: Iteration: 45 / 50 [ 90%] (Sampling) #> Chain 1: Iteration: 50 / 50 [100%] (Sampling) #> Chain 1: -#> Chain 1: Elapsed Time: 0.153984 seconds (Warm-up) -#> Chain 1: 0.178113 seconds (Sampling) -#> Chain 1: 0.332097 seconds (Total) +#> Chain 1: Elapsed Time: 0.159431 seconds (Warm-up) +#> Chain 1: 0.173489 seconds (Sampling) +#> Chain 1: 0.33292 seconds (Total) #> Chain 1:

#> Warning: The largest R-hat is NA, indicating chains have not mixed. #> Running the chains for more iterations may help. See #> http://mc-stan.org/misc/warnings.html#r-hat
#> Warning: Bulk Effective Samples Size (ESS) is too low, indicating posterior means and medians may be unreliable. @@ -233,9 +233,10 @@

Examp #> http://mc-stan.org/misc/warnings.html#bulk-ess

#> Warning: Tail Effective Samples Size (ESS) is too low, indicating posterior variances and tail quantiles may be unreliable. #> Running the chains for more iterations may help. See #> http://mc-stan.org/misc/warnings.html#tail-ess
#> Warning: Some Pareto k diagnostic values are too high. See help('pareto-k-diagnostic') for details.
plot_regime_model(m) -
plot_regime_model(m, plot_prob_indices=c(2)) +
plot_regime_model(m, plot_prob_indices = c(2))
plot_regime_model(m, type = "means")
# } +
@@ -186,8 +186,8 @@

Examp
#> #> SAMPLING FOR MODEL 'dfa' NOW (CHAIN 1). #> Chain 1: -#> Chain 1: Gradient evaluation took 4.2e-05 seconds -#> Chain 1: 1000 transitions using 10 leapfrog steps per transition would take 0.42 seconds. +#> Chain 1: Gradient evaluation took 8e-05 seconds +#> Chain 1: 1000 transitions using 10 leapfrog steps per transition would take 0.8 seconds. #> Chain 1: Adjust your expectations accordingly! #> Chain 1: #> Chain 1: @@ -212,9 +212,9 @@

Examp #> Chain 1: Iteration: 45 / 50 [ 90%] (Sampling) #> Chain 1: Iteration: 50 / 50 [100%] (Sampling) #> Chain 1: -#> Chain 1: Elapsed Time: 0.002574 seconds (Warm-up) -#> Chain 1: 0.007206 seconds (Sampling) -#> Chain 1: 0.00978 seconds (Total) +#> Chain 1: Elapsed Time: 0.003483 seconds (Warm-up) +#> Chain 1: 0.003669 seconds (Sampling) +#> Chain 1: 0.007152 seconds (Total) #> Chain 1:

#> Warning: There were 1 chains where the estimated Bayesian Fraction of Missing Information was low. See #> http://mc-stan.org/misc/warnings.html#bfmi-low
#> Warning: Examine the pairs() plot to diagnose sampling problems
#> Warning: The largest R-hat is 2.1, indicating chains have not mixed. #> Running the chains for more iterations may help. See @@ -225,114 +225,113 @@

Examp #> http://mc-stan.org/misc/warnings.html#tail-ess

#> Inference for the input samples (1 chains: each with iter = 25; warmup = 12): #> #> Q5 Q50 Q95 Mean SD Rhat Bulk_ESS Tail_ESS -#> x[1,1] -1.6 -1.6 -1.6 -1.6 0.0 1.87 4 13 -#> x[1,2] 0.6 0.6 0.6 0.6 0.0 2.06 9 13 -#> x[1,3] -2.1 -2.1 -2.1 -2.1 0.0 1.71 5 13 -#> x[1,4] -4.1 -4.1 -4.1 -4.1 0.0 1.58 4 13 -#> x[1,5] -1.2 -1.2 -1.2 -1.2 0.0 1.47 5 13 -#> x[1,6] 0.4 0.4 0.4 0.4 0.0 2.06 4 13 -#> x[1,7] 2.7 2.7 2.8 2.7 0.0 2.06 4 13 -#> x[1,8] 1.9 1.9 1.9 1.9 0.0 2.06 3 13 -#> x[1,9] 3.3 3.4 3.4 3.4 0.0 2.06 4 13 -#> x[1,10] 2.1 2.1 2.1 2.1 0.0 2.06 4 13 -#> x[1,11] -0.6 -0.6 -0.6 -0.6 0.0 1.09 7 13 -#> x[1,12] -0.9 -0.8 -0.8 -0.8 0.0 1.71 4 13 -#> x[1,13] -3.9 -3.9 -3.9 -3.9 0.0 2.06 4 13 -#> x[1,14] -1.6 -1.6 -1.6 -1.6 0.0 2.06 4 13 -#> x[1,15] -2.7 -2.7 -2.7 -2.7 0.0 2.06 4 13 -#> x[1,16] -1.6 -1.6 -1.6 -1.6 0.0 1.87 5 13 -#> x[1,17] 0.0 0.0 0.0 0.0 0.0 1.03 12 13 -#> x[1,18] 1.8 1.8 1.8 1.8 0.0 2.06 4 13 -#> x[1,19] 3.1 3.1 3.1 3.1 0.0 2.06 4 13 -#> x[1,20] 0.7 0.8 0.8 0.8 0.0 2.06 4 13 -#> Z[1,1] 0.2 0.2 0.2 0.2 0.0 2.06 4 13 -#> Z[2,1] 4.4 4.5 5.0 4.7 0.3 2.06 3 13 -#> Z[3,1] -25.6 -24.2 -23.7 -24.5 0.8 2.06 3 13 -#> Z[4,1] -12.9 -11.8 -11.5 -12.1 0.6 2.06 3 13 -#> log_lik[1] -1.6 -1.6 -1.5 -1.6 0.0 2.06 3 13 -#> log_lik[2] -14.4 -10.6 -9.8 -11.7 2.0 2.06 3 13 -#> log_lik[3] -291.9 -222.0 -204.6 -241.0 38.2 2.06 3 13 -#> log_lik[4] -78.8 -56.7 -52.1 -62.9 11.7 2.06 3 13 -#> log_lik[5] -1.8 -1.8 -1.7 -1.8 0.0 2.06 3 13 -#> log_lik[6] -5.8 -4.9 -4.7 -5.1 0.5 2.06 3 13 -#> log_lik[7] -52.5 -42.3 -39.2 -44.9 5.7 2.06 3 13 -#> log_lik[8] -8.3 -6.4 -5.9 -6.9 1.0 2.06 3 13 -#> log_lik[9] -2.4 -2.4 -2.4 -2.4 0.0 2.06 3 13 -#> log_lik[10] -18.4 -13.0 -12.1 -14.6 2.8 2.06 3 13 -#> log_lik[11] -439.0 -329.8 -304.4 -360.3 59.2 2.06 3 13 -#> log_lik[12] -142.0 -102.2 -94.3 -113.6 21.0 2.06 3 13 -#> log_lik[13] -2.0 -2.0 -2.0 -2.0 0.0 2.06 4 13 -#> log_lik[14] -63.3 -43.3 -39.7 -49.1 10.4 2.06 3 13 -#> log_lik[15] -1830.0 -1387.5 -1282.4 -1509.6 240.6 2.06 3 13 -#> log_lik[16] -499.6 -356.7 -328.5 -397.4 75.1 2.06 3 13 -#> log_lik[17] -1.6 -1.6 -1.5 -1.6 0.0 2.06 3 13 -#> log_lik[18] -8.5 -6.4 -6.1 -7.0 1.1 2.06 3 13 -#> log_lik[19] -166.6 -126.7 -118.5 -138.2 21.2 2.06 3 13 -#> log_lik[20] -45.2 -32.6 -30.5 -36.3 6.5 2.06 3 13 -#> log_lik[21] -1.6 -1.5 -1.5 -1.5 0.0 2.06 3 13 -#> log_lik[22] -2.6 -2.3 -2.2 -2.4 0.2 2.06 3 13 -#> log_lik[23] -27.6 -20.7 -18.4 -22.4 4.0 2.06 3 13 -#> log_lik[24] -6.1 -4.6 -4.2 -5.0 0.8 2.06 3 13 -#> log_lik[25] -1.6 -1.6 -1.5 -1.6 0.0 2.06 3 13 -#> log_lik[26] -37.6 -26.4 -24.2 -29.6 5.9 2.06 3 13 -#> log_lik[27] -850.6 -638.3 -583.3 -695.5 117.1 2.06 3 13 -#> log_lik[28] -215.5 -151.5 -137.8 -169.4 34.0 2.06 3 13 -#> log_lik[29] -1.6 -1.6 -1.5 -1.5 0.0 2.06 3 13 -#> log_lik[30] -17.9 -12.7 -11.6 -14.2 2.8 2.06 3 13 -#> log_lik[31] -433.8 -324.4 -296.1 -354.0 60.4 2.06 3 13 -#> log_lik[32] -104.3 -72.9 -66.2 -81.7 16.7 2.06 3 13 -#> log_lik[33] -1.6 -1.5 -1.5 -1.5 0.0 2.06 3 13 -#> log_lik[34] -45.9 -31.6 -28.8 -35.7 7.6 2.06 3 13 -#> log_lik[35] -1276.3 -963.2 -882.1 -1047.8 173.1 2.06 3 13 -#> log_lik[36] -323.1 -228.3 -208.0 -254.9 50.5 2.06 3 13 -#> log_lik[37] -1.6 -1.6 -1.5 -1.6 0.0 2.06 3 13 -#> log_lik[38] -20.0 -14.3 -13.1 -15.9 3.0 2.06 3 13 -#> log_lik[39] -475.6 -360.9 -329.2 -391.4 64.2 2.06 3 13 -#> log_lik[40] -133.7 -96.0 -87.5 -106.5 20.3 2.06 3 13 -#> log_lik[41] -1.6 -1.6 -1.5 -1.5 0.0 2.06 3 13 -#> log_lik[42] -2.9 -2.5 -2.5 -2.7 0.2 2.06 3 13 -#> log_lik[43] -45.5 -34.6 -32.7 -37.7 5.7 2.06 3 13 -#> log_lik[44] -12.8 -9.5 -9.0 -10.5 1.7 2.06 3 13 -#> log_lik[45] -1.6 -1.6 -1.6 -1.6 0.0 2.06 3 13 -#> log_lik[46] -2.8 -2.3 -2.3 -2.5 0.2 2.06 3 13 -#> log_lik[47] -80.9 -60.1 -56.2 -66.1 10.9 2.06 3 13 -#> log_lik[48] -23.6 -17.0 -15.9 -18.9 3.4 2.06 3 13 -#> log_lik[49] -1.6 -1.5 -1.5 -1.5 0.0 2.06 3 13 -#> log_lik[50] -69.3 -48.1 -44.2 -54.3 11.1 2.06 3 13 -#> log_lik[51] -1736.5 -1311.9 -1210.9 -1429.3 231.4 2.06 3 13 -#> log_lik[52] -432.2 -305.2 -280.1 -341.4 66.9 2.06 3 13 -#> log_lik[53] -1.6 -1.6 -1.5 -1.5 0.0 2.06 3 13 -#> log_lik[54] -14.9 -10.7 -10.0 -12.0 2.1 2.06 3 13 -#> log_lik[55] -298.4 -222.1 -205.7 -244.0 41.2 2.06 3 13 -#> log_lik[56] -73.2 -51.2 -47.2 -57.6 11.6 2.06 3 13 -#> log_lik[57] -1.6 -1.6 -1.5 -1.6 0.0 2.06 3 13 -#> log_lik[58] -34.1 -23.8 -22.0 -26.8 5.4 2.06 3 13 -#> log_lik[59] -824.7 -618.5 -571.4 -676.5 111.7 2.06 3 13 -#> log_lik[60] -198.8 -139.1 -127.7 -156.3 31.3 2.06 3 13 -#> log_lik[61] -1.6 -1.5 -1.5 -1.5 0.0 2.06 3 13 -#> log_lik[62] -18.4 -13.6 -12.8 -15.0 2.5 2.06 3 13 -#> log_lik[63] -282.9 -211.5 -197.1 -232.5 38.2 2.06 3 13 -#> log_lik[64] -69.1 -48.5 -45.0 -54.6 10.7 2.06 3 13 -#> log_lik[65] -1.6 -1.6 -1.5 -1.5 0.0 2.06 3 13 -#> log_lik[66] -1.6 -1.6 -1.5 -1.6 0.0 2.06 4 13 -#> log_lik[67] -1.8 -1.7 -1.7 -1.7 0.0 1.14 7 13 -#> log_lik[68] -1.6 -1.5 -1.5 -1.5 0.0 2.06 3 13 -#> log_lik[69] -2.2 -2.2 -2.2 -2.2 0.0 2.06 3 13 -#> log_lik[70] -15.6 -11.4 -10.4 -12.5 2.3 2.06 3 13 -#> log_lik[71] -334.3 -255.2 -230.0 -274.8 44.8 2.06 3 13 -#> log_lik[72] -104.5 -76.1 -68.8 -83.6 15.4 2.06 3 13 -#> log_lik[73] -2.1 -2.1 -2.1 -2.1 0.0 2.06 3 13 -#> log_lik[74] -35.1 -24.1 -21.7 -27.1 5.8 2.06 3 13 -#> log_lik[75] -1049.3 -795.6 -720.8 -860.2 142.0 2.06 3 13 -#> log_lik[76] -294.1 -210.6 -190.5 -233.0 44.9 2.06 3 13 -#> log_lik[77] -1.9 -1.9 -1.9 -1.9 0.0 2.06 3 13 -#> log_lik[78] -3.0 -2.5 -2.4 -2.7 0.3 2.06 3 13 -#> log_lik[79] -58.7 -43.4 -37.0 -46.6 9.2 2.06 3 13 -#> log_lik[80] -25.0 -18.4 -16.2 -19.9 3.8 2.06 3 13 -#> psi[1] 2.8 2.8 2.8 2.8 0.0 0.96 13 13 -#> xstar[1,1] -1.0 -0.5 0.2 -0.4 0.4 0.96 13 13 -#> sigma[1] 1.7 1.9 1.9 1.8 0.1 2.06 3 13 -#> lp__ -15022.5 -11363.7 -10479.9 -12366.4 1991.0 2.06 3 13 +#> x[1,1] -1.0 -1.0 -1.0 -1.0 0.0 2.06 3 13 +#> x[1,2] 0.4 0.4 0.4 0.4 0.0 2.06 4 13 +#> x[1,3] -1.2 -1.2 -1.2 -1.2 0.0 2.06 4 13 +#> x[1,4] -2.4 -2.4 -2.4 -2.4 0.0 2.06 4 13 +#> x[1,5] -0.7 -0.7 -0.7 -0.7 0.0 1.87 4 13 +#> x[1,6] 0.3 0.3 0.3 0.3 0.0 0.96 7 13 +#> x[1,7] 1.6 1.6 1.6 1.6 0.0 2.06 4 13 +#> x[1,8] 1.1 1.1 1.1 1.1 0.0 1.87 4 13 +#> x[1,9] 2.0 2.0 2.0 2.0 0.0 2.06 4 13 +#> x[1,10] 1.2 1.3 1.3 1.3 0.0 1.24 5 13 +#> x[1,11] -0.4 -0.4 -0.4 -0.4 0.0 1.71 4 13 +#> x[1,12] -0.5 -0.5 -0.5 -0.5 0.0 1.87 4 13 +#> x[1,13] -2.3 -2.3 -2.3 -2.3 0.0 2.06 4 13 +#> x[1,14] -0.9 -0.9 -0.9 -0.9 0.0 2.06 4 13 +#> x[1,15] -1.6 -1.6 -1.6 -1.6 0.0 2.06 4 13 +#> x[1,16] -0.9 -0.9 -0.9 -0.9 0.0 2.06 4 13 +#> x[1,17] 0.0 0.0 0.0 0.0 0.0 1.45 5 13 +#> x[1,18] 1.1 1.1 1.1 1.1 0.0 1.37 5 13 +#> x[1,19] 1.8 1.8 1.8 1.8 0.0 1.71 4 13 +#> x[1,20] 0.4 0.4 0.4 0.4 0.0 1.37 5 13 +#> Z[1,1] -99.6 -99.6 -99.6 -99.6 0.0 1.71 4 13 +#> Z[2,1] 37.1 37.3 37.8 37.3 0.2 2.06 4 13 +#> Z[3,1] 16.1 16.2 16.4 16.3 0.1 2.06 4 13 +#> Z[4,1] -60.8 -60.5 -60.4 -60.5 0.2 2.06 3 13 +#> log_lik[1] -763.9 -652.0 -620.6 -669.9 50.8 2.06 3 13 +#> log_lik[2] -115.3 -96.3 -91.1 -99.3 8.6 2.06 3 13 +#> log_lik[3] -23.6 -20.0 -18.9 -20.6 1.7 2.06 3 13 +#> log_lik[4] -291.8 -246.8 -234.0 -254.0 20.5 2.06 3 13 +#> log_lik[5] -130.4 -117.0 -112.2 -118.8 6.4 2.06 3 13 +#> log_lik[6] -23.9 -21.1 -20.2 -21.5 1.3 2.06 3 13 +#> log_lik[7] -3.8 -3.6 -3.5 -3.6 0.1 2.06 4 13 +#> log_lik[8] -40.2 -36.0 -34.5 -36.6 2.0 2.06 3 13 +#> log_lik[9] -1191.0 -1008.1 -960.6 -1038.5 81.8 2.06 3 13 +#> log_lik[10] -175.2 -144.9 -137.2 -149.9 13.5 2.06 3 13 +#> log_lik[11] -43.1 -36.1 -34.1 -37.3 3.2 2.06 3 13 +#> log_lik[12] -487.1 -408.8 -388.1 -421.7 35.1 2.06 3 13 +#> log_lik[13] -4836.0 -4119.4 -3929.1 -4237.3 322.0 2.06 3 13 +#> log_lik[14] -677.8 -562.6 -532.9 -581.5 51.4 2.06 3 13 +#> log_lik[15] -142.3 -118.7 -111.8 -122.5 10.8 2.06 3 13 +#> log_lik[16] -1852.6 -1562.7 -1484.6 -1610.2 130.6 2.06 3 13 +#> log_lik[17] -426.9 -356.8 -341.4 -369.6 30.7 2.06 3 13 +#> log_lik[18] -64.6 -53.0 -50.5 -55.1 5.1 2.06 3 13 +#> log_lik[19] -14.0 -11.8 -11.3 -12.2 1.0 2.06 3 13 +#> log_lik[20] -163.5 -135.6 -129.3 -140.6 12.3 2.06 3 13 +#> log_lik[21] -61.6 -55.0 -51.7 -55.6 3.5 2.06 3 13 +#> log_lik[22] -10.9 -9.8 -9.2 -9.9 0.6 2.06 3 13 +#> log_lik[23] -2.7 -2.7 -2.6 -2.7 0.0 2.06 4 13 +#> log_lik[24] -22.7 -20.3 -19.1 -20.5 1.3 2.06 3 13 +#> log_lik[25] -2201.5 -1891.3 -1793.6 -1936.6 143.6 2.06 3 13 +#> log_lik[26] -325.3 -272.8 -257.1 -280.6 24.1 2.06 3 13 +#> log_lik[27] -61.3 -51.7 -48.5 -53.2 4.5 2.06 3 13 +#> log_lik[28] -822.6 -699.8 -661.0 -717.8 56.9 2.06 3 13 +#> log_lik[29] -1091.4 -933.9 -883.5 -956.3 73.0 2.06 3 13 +#> log_lik[30] -156.6 -130.9 -123.1 -134.7 11.8 2.06 3 13 +#> log_lik[31] -28.9 -24.4 -22.9 -25.1 2.1 2.06 3 13 +#> log_lik[32] -397.9 -337.2 -317.8 -345.9 28.2 2.06 3 13 +#> log_lik[33] -3348.2 -2873.4 -2727.0 -2943.1 218.7 2.06 3 13 +#> log_lik[34] -468.3 -391.9 -369.4 -403.2 34.9 2.06 3 13 +#> log_lik[35] -92.0 -77.3 -72.5 -79.5 6.9 2.06 3 13 +#> log_lik[36] -1240.0 -1053.6 -995.9 -1081.0 86.0 2.06 3 13 +#> log_lik[37] -1304.0 -1122.5 -1063.5 -1147.0 84.0 2.06 3 13 +#> log_lik[38] -188.8 -158.7 -149.4 -162.9 13.8 2.06 3 13 +#> log_lik[39] -40.6 -34.4 -32.3 -35.3 2.9 2.06 4 13 +#> log_lik[40] -501.2 -427.4 -403.4 -437.5 34.2 2.06 3 13 +#> log_lik[41] -114.2 -93.8 -90.7 -98.3 8.8 2.06 4 13 +#> log_lik[42] -17.2 -14.1 -13.6 -14.8 1.3 2.06 4 13 +#> log_lik[43] -4.7 -4.2 -4.1 -4.3 0.2 2.06 4 13 +#> log_lik[44] -43.2 -35.4 -34.1 -37.1 3.4 2.06 3 13 +#> log_lik[45] -202.1 -163.2 -156.0 -171.2 16.8 2.06 3 13 +#> log_lik[46] -26.8 -21.4 -20.4 -22.5 2.3 2.06 3 13 +#> log_lik[47] -7.8 -6.6 -6.4 -6.9 0.5 2.06 3 13 +#> log_lik[48] -80.5 -64.8 -61.7 -67.9 6.8 2.06 3 13 +#> log_lik[49] -4509.2 -3816.0 -3634.1 -3933.2 311.7 2.06 3 13 +#> log_lik[50] -646.1 -533.2 -504.4 -552.1 50.5 2.06 3 13 +#> log_lik[51] -120.7 -99.9 -94.0 -103.4 9.5 2.06 3 13 +#> log_lik[52] -1661.2 -1391.7 -1320.0 -1437.0 121.5 2.06 3 13 +#> log_lik[53] -734.7 -604.7 -574.6 -628.5 57.4 2.06 3 13 +#> log_lik[54] -111.6 -90.1 -85.1 -93.9 9.5 2.06 3 13 +#> log_lik[55] -21.0 -17.2 -16.3 -17.9 1.7 2.06 3 13 +#> log_lik[56] -272.7 -222.4 -210.6 -231.6 22.3 2.06 3 13 +#> log_lik[57] -2111.4 -1777.3 -1689.6 -1833.5 150.1 2.06 3 13 +#> log_lik[58] -303.1 -249.0 -235.2 -258.1 24.2 2.06 3 13 +#> log_lik[59] -56.3 -46.5 -43.8 -48.2 4.5 2.06 3 13 +#> log_lik[60] -766.2 -638.4 -604.5 -659.8 57.5 2.06 3 13 +#> log_lik[61] -720.1 -603.1 -574.8 -624.2 52.3 2.06 3 13 +#> log_lik[62] -116.9 -96.1 -91.1 -99.8 9.3 2.06 3 13 +#> log_lik[63] -20.4 -17.0 -16.1 -17.6 1.5 2.06 4 13 +#> log_lik[64] -265.4 -220.3 -209.1 -228.3 20.2 2.06 3 13 +#> log_lik[65] -2.0 -2.0 -1.9 -2.0 0.0 1.25 13 13 +#> log_lik[66] -1.9 -1.9 -1.8 -1.9 0.0 2.06 3 13 +#> log_lik[67] -1.9 -1.9 -1.8 -1.9 0.0 2.06 3 13 +#> log_lik[68] -1.9 -1.9 -1.9 -1.9 0.0 1.58 4 13 +#> log_lik[69] -907.7 -773.7 -730.5 -791.8 61.6 2.06 3 13 +#> log_lik[70] -137.2 -114.3 -107.3 -117.5 10.4 2.06 3 13 +#> log_lik[71] -32.3 -27.3 -25.7 -28.0 2.3 2.06 4 13 +#> log_lik[72] -368.3 -311.2 -292.9 -319.0 26.3 2.06 3 13 +#> log_lik[73] -2786.6 -2372.0 -2246.2 -2432.4 188.9 2.06 3 13 +#> log_lik[74] -389.2 -323.0 -303.7 -332.8 29.9 2.06 3 13 +#> log_lik[75] -85.2 -71.2 -66.7 -73.3 6.5 2.06 3 13 +#> log_lik[76] -1082.2 -912.5 -860.8 -937.3 77.5 2.06 3 13 +#> log_lik[77] -151.7 -124.6 -115.7 -127.7 12.2 2.06 4 13 +#> log_lik[78] -22.4 -18.3 -17.0 -18.8 1.8 2.06 3 13 +#> log_lik[79] -8.5 -7.3 -6.9 -7.5 0.5 2.06 4 13 +#> log_lik[80] -69.2 -56.8 -52.8 -58.3 5.6 2.06 3 13 +#> xstar[1,1] -0.8 0.8 1.7 0.6 0.9 0.94 13 13 +#> sigma[1] 2.4 2.6 2.7 2.6 0.1 2.06 3 13 +#> lp__ -50482.1 -43853.2 -41986.7 -44903.8 3005.0 2.06 3 13 #> #> For each parameter, Bulk_ESS and Tail_ESS are crude measures of #> effective sample size for bulk and tail quantities respectively (an ESS > 100 diff --git a/docs/reference/predicted.html b/docs/reference/predicted.html index 8f0efd8..a446f66 100644 --- a/docs/reference/predicted.html +++ b/docs/reference/predicted.html @@ -73,7 +73,7 @@ bayesdfa - 1.0.0 + 1.1.0
@@ -164,7 +164,7 @@

Examp set.seed(42) s <- sim_dfa(num_trends = 1, num_years = 20, num_ts = 3) # only 1 chain and 1000 iterations used so example runs quickly: -m <- fit_dfa(y = s$y_sim, iter = 2000, chains = 3, num_trends=1) +m <- fit_dfa(y = s$y_sim, iter = 2000, chains = 3, num_trends = 1) pred <- predicted(m) } diff --git a/docs/reference/rotate_trends-1.png b/docs/reference/rotate_trends-1.png index 0eed136..16c4986 100644 Binary files a/docs/reference/rotate_trends-1.png and b/docs/reference/rotate_trends-1.png differ diff --git a/docs/reference/rotate_trends.html b/docs/reference/rotate_trends.html index 5ef43ca..2cccb57 100644 --- a/docs/reference/rotate_trends.html +++ b/docs/reference/rotate_trends.html @@ -72,7 +72,7 @@ bayesdfa - 1.0.0 + 1.1.0 @@ -172,8 +172,8 @@

Examp
#> #> SAMPLING FOR MODEL 'dfa' NOW (CHAIN 1). #> Chain 1: -#> Chain 1: Gradient evaluation took 3.7e-05 seconds -#> Chain 1: 1000 transitions using 10 leapfrog steps per transition would take 0.37 seconds. +#> Chain 1: Gradient evaluation took 3.4e-05 seconds +#> Chain 1: 1000 transitions using 10 leapfrog steps per transition would take 0.34 seconds. #> Chain 1: Adjust your expectations accordingly! #> Chain 1: #> Chain 1: @@ -198,11 +198,13 @@

Examp #> Chain 1: Iteration: 45 / 50 [ 90%] (Sampling) #> Chain 1: Iteration: 50 / 50 [100%] (Sampling) #> Chain 1: -#> Chain 1: Elapsed Time: 0.003213 seconds (Warm-up) -#> Chain 1: 0.005565 seconds (Sampling) -#> Chain 1: 0.008778 seconds (Total) -#> Chain 1:

#> Warning: There were 1 chains where the estimated Bayesian Fraction of Missing Information was low. See -#> http://mc-stan.org/misc/warnings.html#bfmi-low
#> Warning: Examine the pairs() plot to diagnose sampling problems
#> Warning: The largest R-hat is 2.1, indicating chains have not mixed. +#> Chain 1: Elapsed Time: 0.005142 seconds (Warm-up) +#> Chain 1: 0.070047 seconds (Sampling) +#> Chain 1: 0.075189 seconds (Total) +#> Chain 1:
#> Warning: There were 16 divergent transitions after warmup. See +#> http://mc-stan.org/misc/warnings.html#divergent-transitions-after-warmup +#> to find out why this is a problem and how to eliminate them.
#> Warning: There were 1 chains where the estimated Bayesian Fraction of Missing Information was low. See +#> http://mc-stan.org/misc/warnings.html#bfmi-low
#> Warning: Examine the pairs() plot to diagnose sampling problems
#> Warning: The largest R-hat is 2.11, indicating chains have not mixed. #> Running the chains for more iterations may help. See #> http://mc-stan.org/misc/warnings.html#r-hat
#> Warning: Bulk Effective Samples Size (ESS) is too low, indicating posterior means and medians may be unreliable. #> Running the chains for more iterations may help. See @@ -210,94 +212,93 @@

Examp #> Running the chains for more iterations may help. See #> http://mc-stan.org/misc/warnings.html#tail-ess

#> Inference for the input samples (1 chains: each with iter = 25; warmup = 12): #> -#> Q5 Q50 Q95 Mean SD Rhat Bulk_ESS Tail_ESS -#> x[1,1] 1.0 1.0 1.0 1.0 0.0 1.13 6 13 -#> x[1,2] -0.2 -0.2 -0.2 -0.2 0.0 1.48 5 13 -#> x[1,3] 1.1 1.1 1.1 1.1 0.0 1.87 4 13 -#> x[1,4] 1.3 1.3 1.3 1.3 0.0 1.87 4 13 -#> x[1,5] -0.1 -0.1 -0.1 -0.1 0.0 2.06 4 13 -#> x[1,6] 1.0 1.0 1.0 1.0 0.0 2.06 4 13 -#> x[1,7] 0.1 0.1 0.1 0.1 0.0 2.06 4 13 -#> x[1,8] 1.4 1.5 1.5 1.5 0.0 2.06 4 13 -#> x[1,9] 0.7 0.7 0.7 0.7 0.0 2.06 4 13 -#> x[1,10] 1.9 1.9 1.9 1.9 0.0 2.06 4 13 -#> x[1,11] 2.5 2.5 2.5 2.5 0.0 2.06 4 13 -#> x[1,12] 2.0 2.0 2.0 2.0 0.0 2.06 4 13 -#> x[1,13] 1.1 1.1 1.1 1.1 0.0 2.06 4 13 -#> x[1,14] 0.5 0.5 0.5 0.5 0.0 1.48 4 13 -#> x[1,15] -0.1 -0.1 -0.1 -0.1 0.0 1.13 7 13 -#> x[1,16] -0.9 -0.9 -0.9 -0.9 0.0 1.58 8 13 -#> x[1,17] -1.9 -1.9 -1.9 -1.9 0.0 1.06 9 13 -#> x[1,18] -2.0 -2.0 -2.0 -2.0 0.0 1.45 5 13 -#> x[1,19] -1.7 -1.7 -1.6 -1.7 0.0 1.45 4 13 -#> x[1,20] -2.3 -2.3 -2.3 -2.3 0.0 1.58 4 13 -#> Z[1,1] 0.5 0.5 0.5 0.5 0.0 1.07 7 13 -#> Z[2,1] -32.6 -28.6 -23.8 -28.4 3.0 2.06 3 13 -#> Z[3,1] 1.4 1.6 1.9 1.6 0.2 2.06 4 13 -#> log_lik[1] -1.5 -1.5 -1.4 -1.5 0.0 2.06 3 13 -#> log_lik[2] -274.4 -202.4 -136.1 -203.2 47.0 2.06 3 13 -#> log_lik[3] -2.0 -1.8 -1.6 -1.8 0.1 2.06 4 13 -#> log_lik[4] -1.3 -1.3 -1.3 -1.3 0.0 2.06 3 13 -#> log_lik[5] -13.9 -10.9 -7.7 -10.9 2.1 2.06 3 13 -#> log_lik[6] -1.3 -1.3 -1.3 -1.3 0.0 2.06 3 13 -#> log_lik[7] -1.6 -1.5 -1.5 -1.5 0.0 2.06 3 13 -#> log_lik[8] -321.0 -234.7 -156.7 -235.8 55.9 2.06 3 13 -#> log_lik[9] -1.8 -1.6 -1.5 -1.6 0.1 2.06 4 13 -#> log_lik[10] -1.6 -1.6 -1.6 -1.6 0.0 2.06 3 13 -#> log_lik[11] -441.1 -320.6 -211.6 -322.1 78.0 2.06 3 13 -#> log_lik[12] -3.8 -3.1 -2.7 -3.1 0.3 2.06 3 13 -#> log_lik[13] -1.3 -1.3 -1.3 -1.3 0.0 2.06 3 13 -#> log_lik[14] -3.7 -3.3 -2.8 -3.3 0.3 2.06 3 13 -#> log_lik[15] -1.4 -1.4 -1.4 -1.4 0.0 2.06 3 13 -#> log_lik[16] -1.7 -1.7 -1.7 -1.7 0.0 2.06 3 13 -#> log_lik[17] -261.8 -189.8 -124.5 -190.7 46.8 2.06 3 13 -#> log_lik[18] -2.6 -2.3 -2.1 -2.3 0.2 2.06 3 13 -#> log_lik[19] -1.3 -1.3 -1.3 -1.3 0.0 2.06 3 13 -#> log_lik[20] -2.5 -2.0 -1.7 -2.0 0.3 2.06 3 13 -#> log_lik[21] -1.4 -1.4 -1.4 -1.4 0.0 2.06 4 13 -#> log_lik[22] -1.3 -1.3 -1.3 -1.3 0.0 2.06 3 13 -#> log_lik[23] -553.1 -399.1 -261.3 -401.5 99.3 2.06 3 13 -#> log_lik[24] -3.5 -2.9 -2.4 -2.9 0.4 2.06 3 13 -#> log_lik[25] -1.4 -1.3 -1.3 -1.3 0.0 2.06 3 13 -#> log_lik[26] -139.0 -99.4 -65.6 -100.4 25.0 2.06 3 13 -#> log_lik[27] -2.6 -2.3 -2.1 -2.3 0.1 2.06 3 13 -#> log_lik[28] -2.5 -2.5 -2.5 -2.5 0.0 2.06 3 13 -#> log_lik[29] -971.7 -699.8 -458.4 -704.6 174.7 2.06 3 13 -#> log_lik[30] -8.1 -6.4 -5.3 -6.5 0.9 2.06 3 13 -#> log_lik[31] -3.7 -3.6 -3.5 -3.6 0.1 2.06 3 13 -#> log_lik[32] -1645.8 -1195.9 -789.6 -1202.3 291.4 2.06 3 13 -#> log_lik[33] -12.0 -9.4 -7.6 -9.4 1.5 2.06 3 13 -#> log_lik[34] -3.3 -3.2 -3.1 -3.2 0.1 2.06 3 13 -#> log_lik[35] -982.2 -706.3 -459.4 -710.7 178.1 2.06 3 13 -#> log_lik[36] -7.6 -6.0 -4.9 -6.0 0.9 2.06 3 13 -#> log_lik[37] -1.6 -1.6 -1.6 -1.6 0.0 2.06 3 13 -#> log_lik[38] -289.1 -207.0 -135.5 -208.7 52.4 2.06 3 13 -#> log_lik[39] -3.0 -2.5 -2.3 -2.5 0.2 2.06 3 13 -#> log_lik[40] -1.4 -1.4 -1.3 -1.4 0.0 2.06 3 13 -#> log_lik[41] -82.3 -59.7 -40.6 -60.3 14.3 2.06 3 13 -#> log_lik[42] -1.4 -1.4 -1.4 -1.4 0.0 1.45 5 13 -#> log_lik[43] -1.8 -1.8 -1.8 -1.8 0.0 1.10 6 13 -#> log_lik[44] -6.0 -4.8 -3.4 -4.7 0.9 2.06 3 13 -#> log_lik[45] -1.6 -1.6 -1.6 -1.6 0.0 1.19 5 13 -#> log_lik[46] -2.4 -2.4 -2.4 -2.4 0.0 2.06 3 13 -#> log_lik[47] -236.0 -173.1 -113.4 -173.2 41.5 2.06 3 13 -#> log_lik[48] -3.9 -3.4 -3.0 -3.4 0.3 2.06 3 13 -#> log_lik[49] -3.1 -3.0 -3.0 -3.0 0.0 2.06 3 13 -#> log_lik[50] -861.3 -620.7 -398.0 -622.6 157.1 2.06 3 13 -#> log_lik[51] -8.4 -6.8 -5.6 -6.8 0.9 2.06 3 13 -#> log_lik[52] -2.2 -2.2 -2.2 -2.2 0.0 2.06 3 13 -#> log_lik[53] -1012.3 -732.1 -472.7 -734.3 183.2 2.06 3 13 -#> log_lik[54] -8.4 -6.6 -5.4 -6.7 0.9 2.06 3 13 -#> log_lik[55] -2.1 -2.1 -2.1 -2.1 0.0 2.06 3 13 -#> log_lik[56] -758.7 -554.8 -364.5 -555.7 133.8 2.06 3 13 -#> log_lik[57] -5.0 -4.0 -3.3 -4.0 0.5 2.06 3 13 -#> log_lik[58] -2.0 -1.9 -1.9 -1.9 0.0 2.06 3 13 -#> log_lik[59] -1381.6 -1005.5 -655.9 -1007.9 246.6 2.06 3 13 -#> log_lik[60] -6.8 -5.1 -4.0 -5.2 0.9 2.06 3 13 -#> psi[1] 0.5 0.5 0.5 0.5 0.0 1.19 8 13 -#> xstar[1,1] -4.3 -2.7 -1.5 -2.9 1.1 1.14 10 13 -#> sigma[1] 1.4 1.5 1.5 1.5 0.0 2.06 3 13 -#> lp__ -10661.4 -7770.3 -5136.2 -7803.2 1877.9 2.06 3 13 +#> Q5 Q50 Q95 Mean SD Rhat Bulk_ESS Tail_ESS +#> x[1,1] 0.3 0.3 0.7 0.4 0.2 2.19 13 13 +#> x[1,2] -0.2 0.0 0.0 0.0 0.1 1.72 4 13 +#> x[1,3] 0.2 0.2 0.9 0.5 0.3 2.19 4 13 +#> x[1,4] 0.5 0.6 1.0 0.7 0.2 2.19 6 13 +#> x[1,5] -0.2 0.5 1.0 0.4 0.4 2.19 13 13 +#> x[1,6] 0.4 1.3 1.4 1.1 0.4 2.19 8 13 +#> x[1,7] 0.3 1.0 1.0 0.8 0.3 2.10 6 13 +#> x[1,8] 0.5 0.7 1.1 0.7 0.3 2.19 13 13 +#> x[1,9] 0.4 0.5 1.4 0.7 0.6 1.62 12 13 +#> x[1,10] 1.5 1.6 2.5 1.8 0.5 2.19 12 13 +#> x[1,11] 2.0 2.7 2.9 2.6 0.4 2.08 6 13 +#> x[1,12] 0.8 2.2 2.3 1.8 0.6 2.10 4 13 +#> x[1,13] 0.0 1.2 1.3 0.8 0.6 2.10 7 13 +#> x[1,14] -0.9 -0.2 0.1 -0.3 0.4 2.08 6 13 +#> x[1,15] -1.0 -1.0 -0.3 -0.7 0.3 2.08 4 13 +#> x[1,16] -2.2 -2.0 -1.3 -1.8 0.4 2.10 4 13 +#> x[1,17] -2.6 -2.4 -2.0 -2.3 0.2 2.08 9 13 +#> x[1,18] -2.4 -2.0 -1.3 -1.9 0.5 1.18 8 13 +#> x[1,19] -1.9 -1.7 -0.7 -1.4 0.5 2.08 7 13 +#> x[1,20] -1.4 -1.2 0.0 -0.8 0.5 2.10 8 13 +#> Z[1,1] -0.9 -0.7 -0.6 -0.7 0.1 1.20 13 13 +#> Z[2,1] -0.7 -0.4 -0.2 -0.4 0.2 1.46 13 13 +#> Z[3,1] -0.8 -0.5 -0.4 -0.6 0.1 1.72 4 13 +#> log_lik[1] -0.7 -0.4 -0.4 -0.5 0.1 2.19 13 13 +#> log_lik[2] -2.4 -2.1 -1.8 -2.1 0.2 1.95 13 13 +#> log_lik[3] -1.0 -0.6 -0.6 -0.7 0.2 1.18 8 13 +#> log_lik[4] -0.8 -0.5 -0.4 -0.5 0.1 2.08 12 13 +#> log_lik[5] -0.8 -0.5 -0.5 -0.6 0.1 2.08 13 13 +#> log_lik[6] -0.7 -0.5 -0.4 -0.5 0.1 2.08 12 13 +#> log_lik[7] -0.7 -0.6 -0.4 -0.6 0.1 2.19 13 13 +#> log_lik[8] -2.2 -1.3 -1.2 -1.5 0.4 1.95 6 13 +#> log_lik[9] -2.4 -1.1 -1.0 -1.4 0.5 2.10 4 13 +#> log_lik[10] -0.7 -0.4 -0.4 -0.5 0.1 2.19 4 13 +#> log_lik[11] -0.7 -0.4 -0.4 -0.5 0.1 2.10 9 13 +#> log_lik[12] -0.8 -0.7 -0.3 -0.6 0.2 1.62 13 13 +#> log_lik[13] -1.3 -0.7 -0.7 -0.8 0.3 1.33 5 13 +#> log_lik[14] -0.9 -0.6 -0.4 -0.6 0.2 2.08 12 13 +#> log_lik[15] -2.5 -1.1 -0.8 -1.3 0.6 2.19 13 13 +#> log_lik[16] -0.9 -0.5 -0.4 -0.5 0.2 1.18 9 13 +#> log_lik[17] -0.7 -0.5 -0.4 -0.5 0.1 1.77 8 13 +#> log_lik[18] -0.8 -0.6 -0.4 -0.6 0.1 1.88 4 13 +#> log_lik[19] -0.9 -0.8 -0.4 -0.7 0.2 1.63 7 13 +#> log_lik[20] -0.7 -0.6 -0.5 -0.6 0.1 2.08 13 13 +#> log_lik[21] -0.8 -0.5 -0.4 -0.6 0.1 1.88 11 13 +#> log_lik[22] -2.5 -2.0 -1.6 -2.0 0.3 1.51 8 13 +#> log_lik[23] -0.8 -0.6 -0.5 -0.6 0.1 2.08 13 13 +#> log_lik[24] -0.8 -0.5 -0.4 -0.5 0.2 1.77 10 13 +#> log_lik[25] -1.6 -0.6 -0.6 -0.8 0.6 1.33 5 13 +#> log_lik[26] -0.8 -0.5 -0.5 -0.6 0.1 1.95 13 13 +#> log_lik[27] -1.1 -1.0 -0.7 -1.0 0.1 1.30 5 13 +#> log_lik[28] -1.0 -0.5 -0.4 -0.6 0.3 2.19 7 13 +#> log_lik[29] -0.9 -0.7 -0.4 -0.7 0.2 1.03 13 13 +#> log_lik[30] -1.4 -1.0 -0.4 -0.9 0.4 1.72 4 13 +#> log_lik[31] -0.8 -0.5 -0.4 -0.6 0.2 1.00 9 13 +#> log_lik[32] -3.7 -2.3 -1.1 -2.3 0.9 1.03 13 13 +#> log_lik[33] -1.2 -0.7 -0.4 -0.8 0.3 1.05 8 13 +#> log_lik[34] -2.0 -0.9 -0.5 -1.0 0.6 2.08 4 13 +#> log_lik[35] -3.9 -2.2 -1.8 -2.4 0.7 1.50 5 13 +#> log_lik[36] -1.1 -0.5 -0.4 -0.6 0.3 1.18 7 13 +#> log_lik[37] -1.0 -0.6 -0.5 -0.7 0.2 1.51 5 13 +#> log_lik[38] -2.1 -1.1 -1.0 -1.3 0.4 2.19 4 13 +#> log_lik[39] -1.0 -0.5 -0.4 -0.6 0.2 2.19 4 13 +#> log_lik[40] -1.7 -0.6 -0.6 -0.9 0.4 2.19 4 13 +#> log_lik[41] -0.8 -0.5 -0.3 -0.5 0.1 1.46 13 13 +#> log_lik[42] -0.9 -0.5 -0.3 -0.6 0.2 2.08 13 13 +#> log_lik[43] -2.5 -1.2 -1.0 -1.5 0.6 1.77 13 13 +#> log_lik[44] -0.7 -0.5 -0.3 -0.5 0.1 1.18 12 13 +#> log_lik[45] -1.1 -0.8 -0.5 -0.8 0.2 1.58 7 13 +#> log_lik[46] -1.3 -0.5 -0.4 -0.8 0.3 2.08 4 13 +#> log_lik[47] -1.5 -1.2 -0.7 -1.1 0.3 1.46 10 13 +#> log_lik[48] -1.0 -0.7 -0.5 -0.8 0.2 1.12 8 13 +#> log_lik[49] -1.1 -0.5 -0.4 -0.6 0.3 1.77 7 13 +#> log_lik[50] -5.1 -4.3 -1.7 -4.0 1.2 1.19 13 13 +#> log_lik[51] -1.3 -0.9 -0.4 -0.9 0.3 1.09 8 13 +#> log_lik[52] -1.5 -0.7 -0.4 -0.8 0.4 1.41 13 13 +#> log_lik[53] -2.4 -1.7 -1.3 -1.8 0.4 1.18 11 13 +#> log_lik[54] -1.1 -0.8 -0.5 -0.8 0.2 0.99 13 13 +#> log_lik[55] -0.9 -0.6 -0.5 -0.6 0.1 1.33 13 13 +#> log_lik[56] -4.2 -3.4 -2.3 -3.3 0.7 2.19 4 5 +#> log_lik[57] -0.8 -0.5 -0.4 -0.5 0.1 1.62 13 13 +#> log_lik[58] -0.8 -0.7 -0.5 -0.7 0.1 0.97 13 13 +#> log_lik[59] -0.7 -0.6 -0.4 -0.6 0.1 2.08 13 13 +#> log_lik[60] -0.8 -0.5 -0.5 -0.6 0.1 1.30 6 13 +#> xstar[1,1] -2.7 -0.7 1.1 -0.7 1.2 1.09 13 13 +#> sigma[1] 0.6 0.6 0.8 0.7 0.1 2.08 13 13 +#> lp__ -59.5 -49.2 -46.5 -51.7 5.4 2.10 4 13 #> #> For each parameter, Bulk_ESS and Tail_ESS are crude measures of #> effective sample size for bulk and tail quantities respectively (an ESS > 100 diff --git a/docs/reference/sim_dfa.html b/docs/reference/sim_dfa.html index f2d9ceb..da597a1 100644 --- a/docs/reference/sim_dfa.html +++ b/docs/reference/sim_dfa.html @@ -72,7 +72,7 @@ bayesdfa - 1.0.0 + 1.1.0
@@ -231,15 +231,18 @@

Examp
set.seed(42) x <- sim_dfa(extreme_value = -4, extreme_loc = 10) -matplot(t(x$x), type = "l");abline(v = 10) -
matplot(t(x$pred), type = "l");abline(v = 10) +matplot(t(x$x), type = "l") +
abline(v = 10) +
matplot(t(x$pred), type = "l") +
abline(v = 10)
set.seed(42) x <- sim_dfa() -matplot(t(x$x), type = "l");abline(v = 10) -
matplot(t(x$pred), type = "l");abline(v = 10) -
-
+matplot(t(x$x), type = "l") +
abline(v = 10) +
matplot(t(x$pred), type = "l") +
abline(v = 10) +
@@ -221,8 +221,8 @@

Examp
#> #> SAMPLING FOR MODEL 'dfa' NOW (CHAIN 1). #> Chain 1: -#> Chain 1: Gradient evaluation took 4.5e-05 seconds -#> Chain 1: 1000 transitions using 10 leapfrog steps per transition would take 0.45 seconds. +#> Chain 1: Gradient evaluation took 4.3e-05 seconds +#> Chain 1: 1000 transitions using 10 leapfrog steps per transition would take 0.43 seconds. #> Chain 1: Adjust your expectations accordingly! #> Chain 1: #> Chain 1: @@ -247,10 +247,11 @@

Examp #> Chain 1: Iteration: 45 / 50 [ 90%] (Sampling) #> Chain 1: Iteration: 50 / 50 [100%] (Sampling) #> Chain 1: -#> Chain 1: Elapsed Time: 0.054609 seconds (Warm-up) -#> Chain 1: 0.287247 seconds (Sampling) -#> Chain 1: 0.341856 seconds (Total) -#> Chain 1:

#> Warning: The largest R-hat is 1.29, indicating chains have not mixed. +#> Chain 1: Elapsed Time: 0.010906 seconds (Warm-up) +#> Chain 1: 0.191305 seconds (Sampling) +#> Chain 1: 0.202211 seconds (Total) +#> Chain 1:
#> Warning: There were 1 chains where the estimated Bayesian Fraction of Missing Information was low. See +#> http://mc-stan.org/misc/warnings.html#bfmi-low
#> Warning: Examine the pairs() plot to diagnose sampling problems
#> Warning: The largest R-hat is 2.1, indicating chains have not mixed. #> Running the chains for more iterations may help. See #> http://mc-stan.org/misc/warnings.html#r-hat
#> Warning: Bulk Effective Samples Size (ESS) is too low, indicating posterior means and medians may be unreliable. #> Running the chains for more iterations may help. See @@ -258,103 +259,102 @@

Examp #> Running the chains for more iterations may help. See #> http://mc-stan.org/misc/warnings.html#tail-ess

#> Inference for the input samples (1 chains: each with iter = 25; warmup = 12): #> -#> Q5 Q50 Q95 Mean SD Rhat Bulk_ESS Tail_ESS -#> x[1,1] -1.0 -0.1 0.1 -0.3 0.4 1.31 7 13 -#> x[1,2] -1.7 -1.1 -0.6 -1.1 0.4 1.02 13 13 -#> x[1,3] -3.3 -1.7 -0.8 -1.8 0.9 0.94 13 13 -#> x[1,4] -3.8 -1.7 -0.9 -2.0 1.1 0.95 13 13 -#> x[1,5] -2.1 -1.1 -0.7 -1.2 0.6 1.07 13 13 -#> x[1,6] -1.5 -0.3 0.4 -0.4 0.6 1.12 12 13 -#> x[1,7] -1.5 -0.1 0.3 -0.4 0.7 1.32 11 13 -#> x[1,8] -1.6 -0.5 -0.1 -0.7 0.6 0.98 10 13 -#> x[1,9] -0.7 -0.4 0.2 -0.3 0.3 0.95 13 13 -#> x[1,10] 0.2 0.7 2.3 0.9 0.7 1.08 13 13 -#> x[1,11] 1.2 2.1 4.5 2.4 1.2 1.09 13 13 -#> x[1,12] 1.4 2.3 6.8 3.0 1.9 1.00 12 13 -#> x[1,13] 0.8 1.9 3.6 1.9 1.0 1.15 9 13 -#> x[1,14] -0.1 0.5 1.4 0.6 0.5 1.07 13 13 -#> x[1,15] -1.3 -0.3 0.3 -0.4 0.6 1.08 10 13 -#> Z[1,1] 0.3 0.7 1.1 0.7 0.3 1.47 10 13 -#> Z[2,1] -0.9 -0.5 -0.3 -0.6 0.2 1.13 11 13 -#> Z[3,1] 0.4 0.6 1.1 0.7 0.3 1.04 13 13 -#> Z[4,1] 0.1 0.2 0.3 0.2 0.1 0.98 13 13 -#> log_lik[1] -0.8 -0.5 -0.4 -0.6 0.1 0.98 13 13 -#> log_lik[2] -1.2 -0.7 -0.6 -0.8 0.2 1.16 10 13 -#> log_lik[3] -0.8 -0.5 -0.5 -0.6 0.1 0.92 13 13 -#> log_lik[4] -1.1 -1.1 -0.7 -1.0 0.1 1.25 8 13 -#> log_lik[5] -2.2 -1.3 -0.7 -1.4 0.6 1.14 13 13 -#> log_lik[6] -1.4 -1.0 -0.5 -0.9 0.3 1.24 13 13 -#> log_lik[7] -1.4 -0.7 -0.6 -0.9 0.3 1.14 11 13 -#> log_lik[8] -1.9 -1.4 -1.2 -1.4 0.3 1.27 13 13 -#> log_lik[9] -0.9 -0.6 -0.4 -0.7 0.2 1.03 13 13 -#> log_lik[10] -0.7 -0.6 -0.5 -0.6 0.1 1.37 5 13 -#> log_lik[11] -1.1 -0.6 -0.4 -0.6 0.3 1.47 4 13 -#> log_lik[12] -0.9 -0.7 -0.4 -0.6 0.2 1.24 11 13 -#> log_lik[13] -0.9 -0.6 -0.4 -0.6 0.2 1.31 5 13 -#> log_lik[14] -2.1 -1.6 -0.9 -1.6 0.4 1.24 13 13 -#> log_lik[15] -0.9 -0.5 -0.4 -0.6 0.2 1.45 5 13 -#> log_lik[16] -0.8 -0.6 -0.5 -0.6 0.1 1.12 12 13 -#> log_lik[17] -1.1 -0.7 -0.5 -0.7 0.3 1.71 13 13 -#> log_lik[18] -1.1 -0.7 -0.4 -0.8 0.3 1.33 13 13 -#> log_lik[19] -1.2 -0.8 -0.5 -0.8 0.3 1.45 13 13 -#> log_lik[20] -1.7 -1.1 -1.0 -1.2 0.3 1.05 13 13 -#> log_lik[21] -1.0 -0.6 -0.4 -0.7 0.3 1.19 6 13 -#> log_lik[22] -1.1 -0.7 -0.5 -0.7 0.2 1.02 9 13 -#> log_lik[23] -1.4 -0.8 -0.5 -0.9 0.3 0.97 10 13 -#> log_lik[24] -0.6 -0.5 -0.4 -0.5 0.1 1.39 5 13 -#> log_lik[25] -0.9 -0.5 -0.4 -0.6 0.2 1.30 5 13 -#> log_lik[26] -0.8 -0.6 -0.4 -0.6 0.1 1.24 6 13 -#> log_lik[27] -1.1 -0.6 -0.4 -0.6 0.2 1.58 4 13 -#> log_lik[28] -0.7 -0.6 -0.4 -0.6 0.1 1.37 5 13 -#> log_lik[29] -1.1 -0.7 -0.5 -0.7 0.2 0.94 13 13 -#> log_lik[30] -1.2 -0.8 -0.6 -0.9 0.2 0.98 13 13 -#> log_lik[31] -1.2 -0.8 -0.5 -0.8 0.3 1.07 13 13 -#> log_lik[32] -0.7 -0.6 -0.5 -0.6 0.1 1.13 10 13 -#> log_lik[33] -0.7 -0.5 -0.4 -0.6 0.1 1.03 11 13 -#> log_lik[34] -1.6 -1.1 -0.8 -1.1 0.3 0.98 13 13 -#> log_lik[35] -0.9 -0.6 -0.4 -0.6 0.2 1.16 13 13 -#> log_lik[36] -1.0 -0.9 -0.7 -0.9 0.1 1.24 13 13 -#> log_lik[37] -0.9 -0.5 -0.4 -0.6 0.2 1.20 6 13 -#> log_lik[38] -0.9 -0.7 -0.5 -0.7 0.2 1.16 7 13 -#> log_lik[39] -1.1 -0.6 -0.4 -0.6 0.3 1.31 5 13 -#> log_lik[40] -1.2 -0.8 -0.7 -0.9 0.2 1.12 13 13 -#> log_lik[41] -0.9 -0.6 -0.5 -0.6 0.2 0.95 13 13 -#> log_lik[42] -2.1 -1.0 -0.7 -1.2 0.5 0.94 13 13 -#> log_lik[43] -1.2 -0.7 -0.5 -0.7 0.3 0.92 13 13 -#> log_lik[44] -6.1 -3.4 -2.6 -4.0 1.4 1.00 13 13 -#> log_lik[45] -1.2 -0.8 -0.5 -0.8 0.3 0.98 13 13 -#> log_lik[46] -1.3 -0.6 -0.4 -0.7 0.3 1.10 10 13 -#> log_lik[47] -1.9 -0.8 -0.5 -0.9 0.5 1.71 4 13 -#> log_lik[48] -7.0 -5.4 -2.9 -5.4 1.4 1.19 12 13 -#> log_lik[49] -0.9 -0.5 -0.5 -0.6 0.1 1.10 6 13 -#> log_lik[50] -1.1 -0.7 -0.4 -0.7 0.2 1.06 8 13 -#> log_lik[51] -1.3 -0.6 -0.4 -0.8 0.3 1.45 5 13 -#> log_lik[52] -1.1 -0.9 -0.5 -0.8 0.2 0.97 13 13 -#> log_lik[53] -0.8 -0.6 -0.4 -0.6 0.1 0.93 13 13 -#> log_lik[54] -0.8 -0.6 -0.5 -0.6 0.1 1.12 12 13 -#> log_lik[55] -0.7 -0.6 -0.4 -0.6 0.1 1.12 11 13 -#> log_lik[56] -3.7 -2.4 -2.1 -2.6 0.6 0.99 13 13 -#> log_lik[57] -2.2 -1.0 -0.6 -1.2 0.6 1.00 13 13 -#> log_lik[58] -2.6 -1.6 -0.7 -1.6 0.6 1.16 8 13 -#> log_lik[59] -2.1 -1.0 -0.6 -1.1 0.5 1.05 12 13 -#> log_lik[60] -2.0 -1.7 -1.2 -1.6 0.3 1.09 11 13 -#> psi[1] 0.3 1.0 3.9 1.5 1.3 1.01 9 13 -#> xstar[1,1] -3.1 -1.9 -1.3 -2.0 0.6 0.92 13 13 -#> sigma[1] 0.6 0.7 0.8 0.7 0.1 1.14 8 13 -#> lp__ -60.8 -57.1 -52.8 -57.0 3.2 1.24 6 13 +#> Q5 Q50 Q95 Mean SD Rhat Bulk_ESS Tail_ESS +#> x[1,1] -1.6 -0.3 0.9 -0.4 0.9 1.30 6 13 +#> x[1,2] -0.7 0.6 1.3 0.4 0.8 1.47 5 13 +#> x[1,3] 0.0 1.1 1.9 0.9 0.7 1.71 4 13 +#> x[1,4] 0.3 0.9 2.0 1.1 0.7 2.06 4 13 +#> x[1,5] -0.2 0.5 1.4 0.6 0.6 2.06 4 13 +#> x[1,6] -0.5 0.2 0.9 0.1 0.5 0.92 13 13 +#> x[1,7] -0.3 0.2 1.1 0.4 0.5 1.71 8 13 +#> x[1,8] -0.4 0.0 1.2 0.2 0.6 0.93 12 13 +#> x[1,9] 0.0 0.4 0.8 0.4 0.3 1.45 5 13 +#> x[1,10] -1.0 0.2 0.7 0.0 0.6 1.45 5 13 +#> x[1,11] -2.2 -1.4 -0.6 -1.4 0.6 1.20 6 13 +#> x[1,12] -2.5 -1.3 0.3 -1.2 1.1 2.06 4 13 +#> x[1,13] -1.8 -0.9 0.8 -0.7 1.1 2.06 4 13 +#> x[1,14] -0.8 -0.4 0.3 -0.3 0.4 0.96 13 13 +#> x[1,15] -0.8 0.5 0.9 0.2 0.6 1.09 12 13 +#> Z[1,1] -4.9 -0.9 7.8 0.0 6.2 1.87 13 13 +#> Z[2,1] 0.0 0.5 1.1 0.5 0.4 1.33 13 13 +#> Z[3,1] -1.7 -0.7 1.0 -0.5 0.9 1.71 11 13 +#> Z[4,1] -0.7 -0.2 0.7 -0.1 0.5 1.71 9 13 +#> log_lik[1] -4.5 -0.8 -0.5 -1.8 1.6 1.71 4 13 +#> log_lik[2] -3.7 -1.0 -0.5 -1.5 1.2 1.39 5 13 +#> log_lik[3] -3.7 -1.0 -0.5 -1.5 1.2 1.71 4 13 +#> log_lik[4] -3.7 -1.1 -0.7 -1.6 1.1 1.07 10 13 +#> log_lik[5] -3.8 -1.8 -0.7 -2.1 1.1 1.87 4 13 +#> log_lik[6] -3.7 -0.9 -0.7 -1.6 1.1 1.48 5 13 +#> log_lik[7] -3.7 -1.0 -0.5 -1.5 1.1 1.71 4 13 +#> log_lik[8] -3.7 -1.5 -1.1 -2.0 0.9 1.18 7 13 +#> log_lik[9] -3.7 -1.1 -0.4 -1.6 1.2 2.06 4 13 +#> log_lik[10] -3.7 -0.6 -0.5 -1.4 1.2 1.71 4 13 +#> log_lik[11] -3.7 -1.4 -0.5 -1.6 1.1 2.06 4 13 +#> log_lik[12] -3.7 -0.8 -0.5 -1.4 1.2 1.71 5 13 +#> log_lik[13] -3.9 -1.2 -0.4 -1.6 1.2 1.58 4 13 +#> log_lik[14] -3.7 -2.3 -1.1 -2.3 0.9 1.30 5 13 +#> log_lik[15] -3.7 -1.5 -0.5 -1.6 1.1 1.33 5 13 +#> log_lik[16] -3.7 -0.8 -0.5 -1.3 1.2 1.87 4 13 +#> log_lik[17] -3.7 -0.9 -0.5 -1.5 1.2 1.58 5 13 +#> log_lik[18] -3.7 -0.8 -0.5 -1.3 1.2 1.30 5 13 +#> log_lik[19] -3.7 -1.0 -0.5 -1.5 1.1 1.58 4 13 +#> log_lik[20] -3.7 -1.2 -1.0 -1.7 1.0 1.08 8 13 +#> log_lik[21] -3.8 -0.8 -0.4 -1.6 1.3 1.71 4 13 +#> log_lik[22] -3.7 -0.8 -0.5 -1.4 1.2 1.58 4 13 +#> log_lik[23] -3.7 -0.9 -0.5 -1.5 1.2 1.71 4 13 +#> log_lik[24] -3.7 -0.7 -0.4 -1.3 1.2 2.06 4 13 +#> log_lik[25] -4.1 -0.8 -0.4 -1.5 1.4 1.87 4 13 +#> log_lik[26] -3.7 -0.8 -0.4 -1.3 1.2 2.06 4 13 +#> log_lik[27] -3.7 -0.7 -0.4 -1.4 1.2 2.06 4 13 +#> log_lik[28] -3.7 -0.6 -0.4 -1.3 1.2 1.87 4 13 +#> log_lik[29] -3.7 -1.1 -0.6 -1.5 1.1 1.21 6 13 +#> log_lik[30] -3.7 -0.9 -0.5 -1.4 1.2 1.48 5 13 +#> log_lik[31] -3.7 -1.2 -0.7 -1.7 1.1 1.19 7 13 +#> log_lik[32] -3.7 -0.6 -0.5 -1.3 1.2 1.58 4 13 +#> log_lik[33] -3.8 -0.6 -0.4 -1.3 1.3 1.58 5 13 +#> log_lik[34] -3.7 -1.2 -0.8 -1.6 1.0 1.08 8 13 +#> log_lik[35] -3.7 -0.8 -0.5 -1.4 1.2 1.71 4 13 +#> log_lik[36] -3.7 -0.9 -0.8 -1.5 1.1 1.06 8 13 +#> log_lik[37] -3.7 -0.9 -0.5 -1.4 1.2 1.71 4 13 +#> log_lik[38] -3.7 -0.8 -0.4 -1.3 1.2 1.71 4 13 +#> log_lik[39] -3.7 -0.9 -0.5 -1.6 1.2 1.31 5 13 +#> log_lik[40] -3.7 -1.0 -0.6 -1.4 1.1 1.71 4 13 +#> log_lik[41] -4.6 -1.0 -0.4 -1.7 1.6 1.39 5 13 +#> log_lik[42] -3.7 -2.1 -0.9 -2.2 0.9 1.45 5 13 +#> log_lik[43] -4.3 -1.2 -0.5 -1.9 1.6 1.71 5 13 +#> log_lik[44] -4.7 -3.4 -1.3 -3.3 1.2 1.05 13 13 +#> log_lik[45] -4.0 -1.7 -0.5 -1.9 1.4 1.87 6 13 +#> log_lik[46] -3.7 -0.7 -0.6 -1.5 1.2 1.58 6 13 +#> log_lik[47] -3.7 -0.9 -0.5 -1.7 1.3 1.58 4 13 +#> log_lik[48] -7.4 -4.9 -2.4 -4.7 1.9 1.05 13 13 +#> log_lik[49] -4.0 -0.9 -0.5 -1.7 1.4 1.87 4 13 +#> log_lik[50] -3.7 -1.2 -0.5 -1.6 1.1 2.06 4 13 +#> log_lik[51] -3.7 -1.4 -0.5 -1.7 1.1 1.19 6 13 +#> log_lik[52] -3.7 -0.9 -0.7 -1.5 1.1 1.71 4 13 +#> log_lik[53] -3.8 -0.9 -0.5 -1.4 1.2 2.06 4 13 +#> log_lik[54] -3.7 -0.8 -0.4 -1.3 1.2 1.58 4 13 +#> log_lik[55] -3.7 -0.9 -0.5 -1.4 1.2 2.06 4 13 +#> log_lik[56] -3.7 -2.2 -1.4 -2.4 0.9 1.45 8 13 +#> log_lik[57] -5.0 -1.3 -0.6 -2.1 1.8 1.58 5 13 +#> log_lik[58] -3.7 -2.3 -0.8 -2.2 1.1 0.98 10 13 +#> log_lik[59] -4.1 -1.3 -0.5 -1.8 1.4 1.48 5 13 +#> log_lik[60] -3.7 -2.0 -0.9 -2.1 1.0 1.71 8 13 +#> xstar[1,1] -2.2 0.7 2.1 0.4 1.5 1.21 13 13 +#> sigma[1] 0.6 0.7 15.9 3.5 5.7 1.58 4 13 +#> lp__ -315.4 -60.3 -46.3 -110.6 108.8 2.06 4 13 #> #> For each parameter, Bulk_ESS and Tail_ESS are crude measures of #> effective sample size for bulk and tail quantities respectively (an ESS > 100 #> per chain is considered good), and Rhat is the potential scale reduction #> factor on rank normalized split chains (at convergence, Rhat <= 1.05).
r <- rotate_trends(m) -n_years <- ncol(r$trends[,1,]) +n_years <- ncol(r$trends[, 1, ]) fake_dat <- rnorm(n_years, 0, 1) correlation <- trend_cor(r, fake_dat, trend_samples = 25)
#> #> SAMPLING FOR MODEL 'corr' NOW (CHAIN 1). #> Chain 1: -#> Chain 1: Gradient evaluation took 1.2e-05 seconds -#> Chain 1: 1000 transitions using 10 leapfrog steps per transition would take 0.12 seconds. +#> Chain 1: Gradient evaluation took 1.1e-05 seconds +#> Chain 1: 1000 transitions using 10 leapfrog steps per transition would take 0.11 seconds. #> Chain 1: Adjust your expectations accordingly! #> Chain 1: #> Chain 1: @@ -371,10 +371,10 @@

Examp #> Chain 1: Iteration: 270 / 300 [ 90%] (Sampling) #> Chain 1: Iteration: 300 / 300 [100%] (Sampling) #> Chain 1: -#> Chain 1: Elapsed Time: 0.002473 seconds (Warm-up) -#> Chain 1: 0.001935 seconds (Sampling) -#> Chain 1: 0.004408 seconds (Total) -#> Chain 1:

#> Warning: The largest R-hat is 1.1, indicating chains have not mixed. +#> Chain 1: Elapsed Time: 0.002798 seconds (Warm-up) +#> Chain 1: 0.002067 seconds (Sampling) +#> Chain 1: 0.004865 seconds (Total) +#> Chain 1:
#> Warning: The largest R-hat is 1.09, indicating chains have not mixed. #> Running the chains for more iterations may help. See #> http://mc-stan.org/misc/warnings.html#r-hat
#> Warning: Bulk Effective Samples Size (ESS) is too low, indicating posterior means and medians may be unreliable. #> Running the chains for more iterations may help. See @@ -383,8 +383,8 @@

Examp #> http://mc-stan.org/misc/warnings.html#tail-ess

#> #> SAMPLING FOR MODEL 'corr' NOW (CHAIN 1). #> Chain 1: -#> Chain 1: Gradient evaluation took 6e-06 seconds -#> Chain 1: 1000 transitions using 10 leapfrog steps per transition would take 0.06 seconds. +#> Chain 1: Gradient evaluation took 4e-06 seconds +#> Chain 1: 1000 transitions using 10 leapfrog steps per transition would take 0.04 seconds. #> Chain 1: Adjust your expectations accordingly! #> Chain 1: #> Chain 1: @@ -401,9 +401,9 @@

Examp #> Chain 1: Iteration: 270 / 300 [ 90%] (Sampling) #> Chain 1: Iteration: 300 / 300 [100%] (Sampling) #> Chain 1: -#> Chain 1: Elapsed Time: 0.002634 seconds (Warm-up) -#> Chain 1: 0.002491 seconds (Sampling) -#> Chain 1: 0.005125 seconds (Total) +#> Chain 1: Elapsed Time: 0.002513 seconds (Warm-up) +#> Chain 1: 0.001891 seconds (Sampling) +#> Chain 1: 0.004404 seconds (Total) #> Chain 1:

#> Warning: Bulk Effective Samples Size (ESS) is too low, indicating posterior means and medians may be unreliable. #> Running the chains for more iterations may help. See #> http://mc-stan.org/misc/warnings.html#bulk-ess
#> Warning: Tail Effective Samples Size (ESS) is too low, indicating posterior variances and tail quantiles may be unreliable. @@ -411,8 +411,8 @@

Examp #> http://mc-stan.org/misc/warnings.html#tail-ess

#> #> SAMPLING FOR MODEL 'corr' NOW (CHAIN 1). #> Chain 1: -#> Chain 1: Gradient evaluation took 7e-06 seconds -#> Chain 1: 1000 transitions using 10 leapfrog steps per transition would take 0.07 seconds. +#> Chain 1: Gradient evaluation took 5e-06 seconds +#> Chain 1: 1000 transitions using 10 leapfrog steps per transition would take 0.05 seconds. #> Chain 1: Adjust your expectations accordingly! #> Chain 1: #> Chain 1: @@ -429,20 +429,16 @@

Examp #> Chain 1: Iteration: 270 / 300 [ 90%] (Sampling) #> Chain 1: Iteration: 300 / 300 [100%] (Sampling) #> Chain 1: -#> Chain 1: Elapsed Time: 0.002766 seconds (Warm-up) -#> Chain 1: 0.002197 seconds (Sampling) -#> Chain 1: 0.004963 seconds (Total) -#> Chain 1:

#> Warning: The largest R-hat is 1.09, indicating chains have not mixed. -#> Running the chains for more iterations may help. See -#> http://mc-stan.org/misc/warnings.html#r-hat
#> Warning: Bulk Effective Samples Size (ESS) is too low, indicating posterior means and medians may be unreliable. -#> Running the chains for more iterations may help. See -#> http://mc-stan.org/misc/warnings.html#bulk-ess
#> Warning: Tail Effective Samples Size (ESS) is too low, indicating posterior variances and tail quantiles may be unreliable. +#> Chain 1: Elapsed Time: 0.002251 seconds (Warm-up) +#> Chain 1: 0.001418 seconds (Sampling) +#> Chain 1: 0.003669 seconds (Total) +#> Chain 1:
#> Warning: Bulk Effective Samples Size (ESS) is too low, indicating posterior means and medians may be unreliable. #> Running the chains for more iterations may help. See -#> http://mc-stan.org/misc/warnings.html#tail-ess
#> +#> http://mc-stan.org/misc/warnings.html#bulk-ess
#> #> SAMPLING FOR MODEL 'corr' NOW (CHAIN 1). #> Chain 1: -#> Chain 1: Gradient evaluation took 1.3e-05 seconds -#> Chain 1: 1000 transitions using 10 leapfrog steps per transition would take 0.13 seconds. +#> Chain 1: Gradient evaluation took 4e-06 seconds +#> Chain 1: 1000 transitions using 10 leapfrog steps per transition would take 0.04 seconds. #> Chain 1: Adjust your expectations accordingly! #> Chain 1: #> Chain 1: @@ -459,9 +455,9 @@

Examp #> Chain 1: Iteration: 270 / 300 [ 90%] (Sampling) #> Chain 1: Iteration: 300 / 300 [100%] (Sampling) #> Chain 1: -#> Chain 1: Elapsed Time: 0.003287 seconds (Warm-up) -#> Chain 1: 0.001723 seconds (Sampling) -#> Chain 1: 0.00501 seconds (Total) +#> Chain 1: Elapsed Time: 0.002372 seconds (Warm-up) +#> Chain 1: 0.001688 seconds (Sampling) +#> Chain 1: 0.00406 seconds (Total) #> Chain 1:

#> Warning: Bulk Effective Samples Size (ESS) is too low, indicating posterior means and medians may be unreliable. #> Running the chains for more iterations may help. See #> http://mc-stan.org/misc/warnings.html#bulk-ess
#> Warning: Tail Effective Samples Size (ESS) is too low, indicating posterior variances and tail quantiles may be unreliable. @@ -469,8 +465,8 @@

Examp #> http://mc-stan.org/misc/warnings.html#tail-ess

#> #> SAMPLING FOR MODEL 'corr' NOW (CHAIN 1). #> Chain 1: -#> Chain 1: Gradient evaluation took 1.1e-05 seconds -#> Chain 1: 1000 transitions using 10 leapfrog steps per transition would take 0.11 seconds. +#> Chain 1: Gradient evaluation took 4e-06 seconds +#> Chain 1: 1000 transitions using 10 leapfrog steps per transition would take 0.04 seconds. #> Chain 1: Adjust your expectations accordingly! #> Chain 1: #> Chain 1: @@ -487,9 +483,9 @@

Examp #> Chain 1: Iteration: 270 / 300 [ 90%] (Sampling) #> Chain 1: Iteration: 300 / 300 [100%] (Sampling) #> Chain 1: -#> Chain 1: Elapsed Time: 0.002768 seconds (Warm-up) -#> Chain 1: 0.002004 seconds (Sampling) -#> Chain 1: 0.004772 seconds (Total) +#> Chain 1: Elapsed Time: 0.002119 seconds (Warm-up) +#> Chain 1: 0.001444 seconds (Sampling) +#> Chain 1: 0.003563 seconds (Total) #> Chain 1:

#> Warning: Bulk Effective Samples Size (ESS) is too low, indicating posterior means and medians may be unreliable. #> Running the chains for more iterations may help. See #> http://mc-stan.org/misc/warnings.html#bulk-ess
#> Warning: Tail Effective Samples Size (ESS) is too low, indicating posterior variances and tail quantiles may be unreliable. @@ -497,8 +493,8 @@

Examp #> http://mc-stan.org/misc/warnings.html#tail-ess

#> #> SAMPLING FOR MODEL 'corr' NOW (CHAIN 1). #> Chain 1: -#> Chain 1: Gradient evaluation took 8e-06 seconds -#> Chain 1: 1000 transitions using 10 leapfrog steps per transition would take 0.08 seconds. +#> Chain 1: Gradient evaluation took 4e-06 seconds +#> Chain 1: 1000 transitions using 10 leapfrog steps per transition would take 0.04 seconds. #> Chain 1: Adjust your expectations accordingly! #> Chain 1: #> Chain 1: @@ -515,9 +511,9 @@

Examp #> Chain 1: Iteration: 270 / 300 [ 90%] (Sampling) #> Chain 1: Iteration: 300 / 300 [100%] (Sampling) #> Chain 1: -#> Chain 1: Elapsed Time: 0.002458 seconds (Warm-up) -#> Chain 1: 0.001701 seconds (Sampling) -#> Chain 1: 0.004159 seconds (Total) +#> Chain 1: Elapsed Time: 0.002406 seconds (Warm-up) +#> Chain 1: 0.001734 seconds (Sampling) +#> Chain 1: 0.00414 seconds (Total) #> Chain 1:

#> Warning: Bulk Effective Samples Size (ESS) is too low, indicating posterior means and medians may be unreliable. #> Running the chains for more iterations may help. See #> http://mc-stan.org/misc/warnings.html#bulk-ess
#> Warning: Tail Effective Samples Size (ESS) is too low, indicating posterior variances and tail quantiles may be unreliable. @@ -525,8 +521,8 @@

Examp #> http://mc-stan.org/misc/warnings.html#tail-ess

#> #> SAMPLING FOR MODEL 'corr' NOW (CHAIN 1). #> Chain 1: -#> Chain 1: Gradient evaluation took 8e-06 seconds -#> Chain 1: 1000 transitions using 10 leapfrog steps per transition would take 0.08 seconds. +#> Chain 1: Gradient evaluation took 4e-06 seconds +#> Chain 1: 1000 transitions using 10 leapfrog steps per transition would take 0.04 seconds. #> Chain 1: Adjust your expectations accordingly! #> Chain 1: #> Chain 1: @@ -543,20 +539,18 @@

Examp #> Chain 1: Iteration: 270 / 300 [ 90%] (Sampling) #> Chain 1: Iteration: 300 / 300 [100%] (Sampling) #> Chain 1: -#> Chain 1: Elapsed Time: 0.002648 seconds (Warm-up) -#> Chain 1: 0.002036 seconds (Sampling) -#> Chain 1: 0.004684 seconds (Total) -#> Chain 1:

#> Warning: The largest R-hat is 1.06, indicating chains have not mixed. -#> Running the chains for more iterations may help. See -#> http://mc-stan.org/misc/warnings.html#r-hat
#> Warning: Bulk Effective Samples Size (ESS) is too low, indicating posterior means and medians may be unreliable. +#> Chain 1: Elapsed Time: 0.002502 seconds (Warm-up) +#> Chain 1: 0.001838 seconds (Sampling) +#> Chain 1: 0.00434 seconds (Total) +#> Chain 1:
#> Warning: Bulk Effective Samples Size (ESS) is too low, indicating posterior means and medians may be unreliable. #> Running the chains for more iterations may help. See #> http://mc-stan.org/misc/warnings.html#bulk-ess
#> Warning: Tail Effective Samples Size (ESS) is too low, indicating posterior variances and tail quantiles may be unreliable. #> Running the chains for more iterations may help. See #> http://mc-stan.org/misc/warnings.html#tail-ess
#> #> SAMPLING FOR MODEL 'corr' NOW (CHAIN 1). #> Chain 1: -#> Chain 1: Gradient evaluation took 6e-06 seconds -#> Chain 1: 1000 transitions using 10 leapfrog steps per transition would take 0.06 seconds. +#> Chain 1: Gradient evaluation took 5e-06 seconds +#> Chain 1: 1000 transitions using 10 leapfrog steps per transition would take 0.05 seconds. #> Chain 1: Adjust your expectations accordingly! #> Chain 1: #> Chain 1: @@ -573,18 +567,20 @@

Examp #> Chain 1: Iteration: 270 / 300 [ 90%] (Sampling) #> Chain 1: Iteration: 300 / 300 [100%] (Sampling) #> Chain 1: -#> Chain 1: Elapsed Time: 0.002394 seconds (Warm-up) -#> Chain 1: 0.001751 seconds (Sampling) -#> Chain 1: 0.004145 seconds (Total) -#> Chain 1:

#> Warning: Bulk Effective Samples Size (ESS) is too low, indicating posterior means and medians may be unreliable. +#> Chain 1: Elapsed Time: 0.002299 seconds (Warm-up) +#> Chain 1: 0.001566 seconds (Sampling) +#> Chain 1: 0.003865 seconds (Total) +#> Chain 1:
#> Warning: The largest R-hat is 1.08, indicating chains have not mixed. +#> Running the chains for more iterations may help. See +#> http://mc-stan.org/misc/warnings.html#r-hat
#> Warning: Bulk Effective Samples Size (ESS) is too low, indicating posterior means and medians may be unreliable. #> Running the chains for more iterations may help. See #> http://mc-stan.org/misc/warnings.html#bulk-ess
#> Warning: Tail Effective Samples Size (ESS) is too low, indicating posterior variances and tail quantiles may be unreliable. #> Running the chains for more iterations may help. See #> http://mc-stan.org/misc/warnings.html#tail-ess
#> #> SAMPLING FOR MODEL 'corr' NOW (CHAIN 1). #> Chain 1: -#> Chain 1: Gradient evaluation took 6e-06 seconds -#> Chain 1: 1000 transitions using 10 leapfrog steps per transition would take 0.06 seconds. +#> Chain 1: Gradient evaluation took 7e-06 seconds +#> Chain 1: 1000 transitions using 10 leapfrog steps per transition would take 0.07 seconds. #> Chain 1: Adjust your expectations accordingly! #> Chain 1: #> Chain 1: @@ -601,9 +597,9 @@

Examp #> Chain 1: Iteration: 270 / 300 [ 90%] (Sampling) #> Chain 1: Iteration: 300 / 300 [100%] (Sampling) #> Chain 1: -#> Chain 1: Elapsed Time: 0.002848 seconds (Warm-up) -#> Chain 1: 0.001696 seconds (Sampling) -#> Chain 1: 0.004544 seconds (Total) +#> Chain 1: Elapsed Time: 0.002573 seconds (Warm-up) +#> Chain 1: 0.001835 seconds (Sampling) +#> Chain 1: 0.004408 seconds (Total) #> Chain 1:

#> Warning: Bulk Effective Samples Size (ESS) is too low, indicating posterior means and medians may be unreliable. #> Running the chains for more iterations may help. See #> http://mc-stan.org/misc/warnings.html#bulk-ess
#> Warning: Tail Effective Samples Size (ESS) is too low, indicating posterior variances and tail quantiles may be unreliable. @@ -611,8 +607,8 @@

Examp #> http://mc-stan.org/misc/warnings.html#tail-ess

#> #> SAMPLING FOR MODEL 'corr' NOW (CHAIN 1). #> Chain 1: -#> Chain 1: Gradient evaluation took 8e-06 seconds -#> Chain 1: 1000 transitions using 10 leapfrog steps per transition would take 0.08 seconds. +#> Chain 1: Gradient evaluation took 7e-06 seconds +#> Chain 1: 1000 transitions using 10 leapfrog steps per transition would take 0.07 seconds. #> Chain 1: Adjust your expectations accordingly! #> Chain 1: #> Chain 1: @@ -629,9 +625,9 @@

Examp #> Chain 1: Iteration: 270 / 300 [ 90%] (Sampling) #> Chain 1: Iteration: 300 / 300 [100%] (Sampling) #> Chain 1: -#> Chain 1: Elapsed Time: 0.002524 seconds (Warm-up) -#> Chain 1: 0.001972 seconds (Sampling) -#> Chain 1: 0.004496 seconds (Total) +#> Chain 1: Elapsed Time: 0.002221 seconds (Warm-up) +#> Chain 1: 0.001523 seconds (Sampling) +#> Chain 1: 0.003744 seconds (Total) #> Chain 1:

#> Warning: Bulk Effective Samples Size (ESS) is too low, indicating posterior means and medians may be unreliable. #> Running the chains for more iterations may help. See #> http://mc-stan.org/misc/warnings.html#bulk-ess
#> Warning: Tail Effective Samples Size (ESS) is too low, indicating posterior variances and tail quantiles may be unreliable. @@ -639,8 +635,8 @@

Examp #> http://mc-stan.org/misc/warnings.html#tail-ess

#> #> SAMPLING FOR MODEL 'corr' NOW (CHAIN 1). #> Chain 1: -#> Chain 1: Gradient evaluation took 5e-06 seconds -#> Chain 1: 1000 transitions using 10 leapfrog steps per transition would take 0.05 seconds. +#> Chain 1: Gradient evaluation took 8e-06 seconds +#> Chain 1: 1000 transitions using 10 leapfrog steps per transition would take 0.08 seconds. #> Chain 1: Adjust your expectations accordingly! #> Chain 1: #> Chain 1: @@ -657,9 +653,9 @@

Examp #> Chain 1: Iteration: 270 / 300 [ 90%] (Sampling) #> Chain 1: Iteration: 300 / 300 [100%] (Sampling) #> Chain 1: -#> Chain 1: Elapsed Time: 0.002372 seconds (Warm-up) -#> Chain 1: 0.001444 seconds (Sampling) -#> Chain 1: 0.003816 seconds (Total) +#> Chain 1: Elapsed Time: 0.002252 seconds (Warm-up) +#> Chain 1: 0.0016 seconds (Sampling) +#> Chain 1: 0.003852 seconds (Total) #> Chain 1:

#> Warning: Bulk Effective Samples Size (ESS) is too low, indicating posterior means and medians may be unreliable. #> Running the chains for more iterations may help. See #> http://mc-stan.org/misc/warnings.html#bulk-ess
#> Warning: Tail Effective Samples Size (ESS) is too low, indicating posterior variances and tail quantiles may be unreliable. @@ -667,8 +663,8 @@

Examp #> http://mc-stan.org/misc/warnings.html#tail-ess

#> #> SAMPLING FOR MODEL 'corr' NOW (CHAIN 1). #> Chain 1: -#> Chain 1: Gradient evaluation took 4e-06 seconds -#> Chain 1: 1000 transitions using 10 leapfrog steps per transition would take 0.04 seconds. +#> Chain 1: Gradient evaluation took 8e-06 seconds +#> Chain 1: 1000 transitions using 10 leapfrog steps per transition would take 0.08 seconds. #> Chain 1: Adjust your expectations accordingly! #> Chain 1: #> Chain 1: @@ -685,18 +681,20 @@

Examp #> Chain 1: Iteration: 270 / 300 [ 90%] (Sampling) #> Chain 1: Iteration: 300 / 300 [100%] (Sampling) #> Chain 1: -#> Chain 1: Elapsed Time: 0.002185 seconds (Warm-up) -#> Chain 1: 0.001582 seconds (Sampling) -#> Chain 1: 0.003767 seconds (Total) -#> Chain 1:

#> Warning: Bulk Effective Samples Size (ESS) is too low, indicating posterior means and medians may be unreliable. +#> Chain 1: Elapsed Time: 0.002236 seconds (Warm-up) +#> Chain 1: 0.001985 seconds (Sampling) +#> Chain 1: 0.004221 seconds (Total) +#> Chain 1:
#> Warning: The largest R-hat is 1.12, indicating chains have not mixed. +#> Running the chains for more iterations may help. See +#> http://mc-stan.org/misc/warnings.html#r-hat
#> Warning: Bulk Effective Samples Size (ESS) is too low, indicating posterior means and medians may be unreliable. #> Running the chains for more iterations may help. See #> http://mc-stan.org/misc/warnings.html#bulk-ess
#> Warning: Tail Effective Samples Size (ESS) is too low, indicating posterior variances and tail quantiles may be unreliable. #> Running the chains for more iterations may help. See #> http://mc-stan.org/misc/warnings.html#tail-ess
#> #> SAMPLING FOR MODEL 'corr' NOW (CHAIN 1). #> Chain 1: -#> Chain 1: Gradient evaluation took 6e-06 seconds -#> Chain 1: 1000 transitions using 10 leapfrog steps per transition would take 0.06 seconds. +#> Chain 1: Gradient evaluation took 1e-05 seconds +#> Chain 1: 1000 transitions using 10 leapfrog steps per transition would take 0.1 seconds. #> Chain 1: Adjust your expectations accordingly! #> Chain 1: #> Chain 1: @@ -713,9 +711,9 @@

Examp #> Chain 1: Iteration: 270 / 300 [ 90%] (Sampling) #> Chain 1: Iteration: 300 / 300 [100%] (Sampling) #> Chain 1: -#> Chain 1: Elapsed Time: 0.002314 seconds (Warm-up) -#> Chain 1: 0.001893 seconds (Sampling) -#> Chain 1: 0.004207 seconds (Total) +#> Chain 1: Elapsed Time: 0.002818 seconds (Warm-up) +#> Chain 1: 0.002051 seconds (Sampling) +#> Chain 1: 0.004869 seconds (Total) #> Chain 1:

#> Warning: Bulk Effective Samples Size (ESS) is too low, indicating posterior means and medians may be unreliable. #> Running the chains for more iterations may help. See #> http://mc-stan.org/misc/warnings.html#bulk-ess
#> Warning: Tail Effective Samples Size (ESS) is too low, indicating posterior variances and tail quantiles may be unreliable. @@ -723,8 +721,8 @@

Examp #> http://mc-stan.org/misc/warnings.html#tail-ess

#> #> SAMPLING FOR MODEL 'corr' NOW (CHAIN 1). #> Chain 1: -#> Chain 1: Gradient evaluation took 7e-06 seconds -#> Chain 1: 1000 transitions using 10 leapfrog steps per transition would take 0.07 seconds. +#> Chain 1: Gradient evaluation took 6e-06 seconds +#> Chain 1: 1000 transitions using 10 leapfrog steps per transition would take 0.06 seconds. #> Chain 1: Adjust your expectations accordingly! #> Chain 1: #> Chain 1: @@ -741,9 +739,9 @@

Examp #> Chain 1: Iteration: 270 / 300 [ 90%] (Sampling) #> Chain 1: Iteration: 300 / 300 [100%] (Sampling) #> Chain 1: -#> Chain 1: Elapsed Time: 0.002826 seconds (Warm-up) -#> Chain 1: 0.002221 seconds (Sampling) -#> Chain 1: 0.005047 seconds (Total) +#> Chain 1: Elapsed Time: 0.002573 seconds (Warm-up) +#> Chain 1: 0.00165 seconds (Sampling) +#> Chain 1: 0.004223 seconds (Total) #> Chain 1:

#> Warning: Bulk Effective Samples Size (ESS) is too low, indicating posterior means and medians may be unreliable. #> Running the chains for more iterations may help. See #> http://mc-stan.org/misc/warnings.html#bulk-ess
#> Warning: Tail Effective Samples Size (ESS) is too low, indicating posterior variances and tail quantiles may be unreliable. @@ -751,8 +749,8 @@

Examp #> http://mc-stan.org/misc/warnings.html#tail-ess

#> #> SAMPLING FOR MODEL 'corr' NOW (CHAIN 1). #> Chain 1: -#> Chain 1: Gradient evaluation took 1.2e-05 seconds -#> Chain 1: 1000 transitions using 10 leapfrog steps per transition would take 0.12 seconds. +#> Chain 1: Gradient evaluation took 7e-06 seconds +#> Chain 1: 1000 transitions using 10 leapfrog steps per transition would take 0.07 seconds. #> Chain 1: Adjust your expectations accordingly! #> Chain 1: #> Chain 1: @@ -769,9 +767,9 @@

Examp #> Chain 1: Iteration: 270 / 300 [ 90%] (Sampling) #> Chain 1: Iteration: 300 / 300 [100%] (Sampling) #> Chain 1: -#> Chain 1: Elapsed Time: 0.002736 seconds (Warm-up) -#> Chain 1: 0.001768 seconds (Sampling) -#> Chain 1: 0.004504 seconds (Total) +#> Chain 1: Elapsed Time: 0.002881 seconds (Warm-up) +#> Chain 1: 0.002095 seconds (Sampling) +#> Chain 1: 0.004976 seconds (Total) #> Chain 1:

#> Warning: Bulk Effective Samples Size (ESS) is too low, indicating posterior means and medians may be unreliable. #> Running the chains for more iterations may help. See #> http://mc-stan.org/misc/warnings.html#bulk-ess
#> Warning: Tail Effective Samples Size (ESS) is too low, indicating posterior variances and tail quantiles may be unreliable. @@ -779,8 +777,8 @@

Examp #> http://mc-stan.org/misc/warnings.html#tail-ess

#> #> SAMPLING FOR MODEL 'corr' NOW (CHAIN 1). #> Chain 1: -#> Chain 1: Gradient evaluation took 8e-06 seconds -#> Chain 1: 1000 transitions using 10 leapfrog steps per transition would take 0.08 seconds. +#> Chain 1: Gradient evaluation took 6e-06 seconds +#> Chain 1: 1000 transitions using 10 leapfrog steps per transition would take 0.06 seconds. #> Chain 1: Adjust your expectations accordingly! #> Chain 1: #> Chain 1: @@ -797,20 +795,18 @@

Examp #> Chain 1: Iteration: 270 / 300 [ 90%] (Sampling) #> Chain 1: Iteration: 300 / 300 [100%] (Sampling) #> Chain 1: -#> Chain 1: Elapsed Time: 0.002558 seconds (Warm-up) -#> Chain 1: 0.001771 seconds (Sampling) -#> Chain 1: 0.004329 seconds (Total) -#> Chain 1:

#> Warning: The largest R-hat is 1.12, indicating chains have not mixed. -#> Running the chains for more iterations may help. See -#> http://mc-stan.org/misc/warnings.html#r-hat
#> Warning: Bulk Effective Samples Size (ESS) is too low, indicating posterior means and medians may be unreliable. +#> Chain 1: Elapsed Time: 0.002698 seconds (Warm-up) +#> Chain 1: 0.002075 seconds (Sampling) +#> Chain 1: 0.004773 seconds (Total) +#> Chain 1:
#> Warning: Bulk Effective Samples Size (ESS) is too low, indicating posterior means and medians may be unreliable. #> Running the chains for more iterations may help. See #> http://mc-stan.org/misc/warnings.html#bulk-ess
#> Warning: Tail Effective Samples Size (ESS) is too low, indicating posterior variances and tail quantiles may be unreliable. #> Running the chains for more iterations may help. See #> http://mc-stan.org/misc/warnings.html#tail-ess
#> #> SAMPLING FOR MODEL 'corr' NOW (CHAIN 1). #> Chain 1: -#> Chain 1: Gradient evaluation took 6e-06 seconds -#> Chain 1: 1000 transitions using 10 leapfrog steps per transition would take 0.06 seconds. +#> Chain 1: Gradient evaluation took 8e-06 seconds +#> Chain 1: 1000 transitions using 10 leapfrog steps per transition would take 0.08 seconds. #> Chain 1: Adjust your expectations accordingly! #> Chain 1: #> Chain 1: @@ -827,9 +823,9 @@

Examp #> Chain 1: Iteration: 270 / 300 [ 90%] (Sampling) #> Chain 1: Iteration: 300 / 300 [100%] (Sampling) #> Chain 1: -#> Chain 1: Elapsed Time: 0.002652 seconds (Warm-up) -#> Chain 1: 0.001877 seconds (Sampling) -#> Chain 1: 0.004529 seconds (Total) +#> Chain 1: Elapsed Time: 0.002996 seconds (Warm-up) +#> Chain 1: 0.001633 seconds (Sampling) +#> Chain 1: 0.004629 seconds (Total) #> Chain 1:

#> Warning: Bulk Effective Samples Size (ESS) is too low, indicating posterior means and medians may be unreliable. #> Running the chains for more iterations may help. See #> http://mc-stan.org/misc/warnings.html#bulk-ess
#> Warning: Tail Effective Samples Size (ESS) is too low, indicating posterior variances and tail quantiles may be unreliable. @@ -855,9 +851,9 @@

Examp #> Chain 1: Iteration: 270 / 300 [ 90%] (Sampling) #> Chain 1: Iteration: 300 / 300 [100%] (Sampling) #> Chain 1: -#> Chain 1: Elapsed Time: 0.002758 seconds (Warm-up) -#> Chain 1: 0.001814 seconds (Sampling) -#> Chain 1: 0.004572 seconds (Total) +#> Chain 1: Elapsed Time: 0.002308 seconds (Warm-up) +#> Chain 1: 0.001939 seconds (Sampling) +#> Chain 1: 0.004247 seconds (Total) #> Chain 1:

#> Warning: Bulk Effective Samples Size (ESS) is too low, indicating posterior means and medians may be unreliable. #> Running the chains for more iterations may help. See #> http://mc-stan.org/misc/warnings.html#bulk-ess
#> Warning: Tail Effective Samples Size (ESS) is too low, indicating posterior variances and tail quantiles may be unreliable. @@ -865,8 +861,8 @@

Examp #> http://mc-stan.org/misc/warnings.html#tail-ess

#> #> SAMPLING FOR MODEL 'corr' NOW (CHAIN 1). #> Chain 1: -#> Chain 1: Gradient evaluation took 6e-06 seconds -#> Chain 1: 1000 transitions using 10 leapfrog steps per transition would take 0.06 seconds. +#> Chain 1: Gradient evaluation took 7e-06 seconds +#> Chain 1: 1000 transitions using 10 leapfrog steps per transition would take 0.07 seconds. #> Chain 1: Adjust your expectations accordingly! #> Chain 1: #> Chain 1: @@ -883,9 +879,9 @@

Examp #> Chain 1: Iteration: 270 / 300 [ 90%] (Sampling) #> Chain 1: Iteration: 300 / 300 [100%] (Sampling) #> Chain 1: -#> Chain 1: Elapsed Time: 0.002732 seconds (Warm-up) -#> Chain 1: 0.002181 seconds (Sampling) -#> Chain 1: 0.004913 seconds (Total) +#> Chain 1: Elapsed Time: 0.002423 seconds (Warm-up) +#> Chain 1: 0.001582 seconds (Sampling) +#> Chain 1: 0.004005 seconds (Total) #> Chain 1:

#> Warning: Bulk Effective Samples Size (ESS) is too low, indicating posterior means and medians may be unreliable. #> Running the chains for more iterations may help. See #> http://mc-stan.org/misc/warnings.html#bulk-ess
#> Warning: Tail Effective Samples Size (ESS) is too low, indicating posterior variances and tail quantiles may be unreliable. @@ -893,8 +889,8 @@

Examp #> http://mc-stan.org/misc/warnings.html#tail-ess

#> #> SAMPLING FOR MODEL 'corr' NOW (CHAIN 1). #> Chain 1: -#> Chain 1: Gradient evaluation took 4e-06 seconds -#> Chain 1: 1000 transitions using 10 leapfrog steps per transition would take 0.04 seconds. +#> Chain 1: Gradient evaluation took 7e-06 seconds +#> Chain 1: 1000 transitions using 10 leapfrog steps per transition would take 0.07 seconds. #> Chain 1: Adjust your expectations accordingly! #> Chain 1: #> Chain 1: @@ -911,9 +907,9 @@

Examp #> Chain 1: Iteration: 270 / 300 [ 90%] (Sampling) #> Chain 1: Iteration: 300 / 300 [100%] (Sampling) #> Chain 1: -#> Chain 1: Elapsed Time: 0.002372 seconds (Warm-up) -#> Chain 1: 0.001612 seconds (Sampling) -#> Chain 1: 0.003984 seconds (Total) +#> Chain 1: Elapsed Time: 0.002396 seconds (Warm-up) +#> Chain 1: 0.00195 seconds (Sampling) +#> Chain 1: 0.004346 seconds (Total) #> Chain 1:

#> Warning: Bulk Effective Samples Size (ESS) is too low, indicating posterior means and medians may be unreliable. #> Running the chains for more iterations may help. See #> http://mc-stan.org/misc/warnings.html#bulk-ess
#> Warning: Tail Effective Samples Size (ESS) is too low, indicating posterior variances and tail quantiles may be unreliable. @@ -921,8 +917,8 @@

Examp #> http://mc-stan.org/misc/warnings.html#tail-ess

#> #> SAMPLING FOR MODEL 'corr' NOW (CHAIN 1). #> Chain 1: -#> Chain 1: Gradient evaluation took 4e-06 seconds -#> Chain 1: 1000 transitions using 10 leapfrog steps per transition would take 0.04 seconds. +#> Chain 1: Gradient evaluation took 5e-06 seconds +#> Chain 1: 1000 transitions using 10 leapfrog steps per transition would take 0.05 seconds. #> Chain 1: Adjust your expectations accordingly! #> Chain 1: #> Chain 1: @@ -939,9 +935,9 @@

Examp #> Chain 1: Iteration: 270 / 300 [ 90%] (Sampling) #> Chain 1: Iteration: 300 / 300 [100%] (Sampling) #> Chain 1: -#> Chain 1: Elapsed Time: 0.002382 seconds (Warm-up) -#> Chain 1: 0.001661 seconds (Sampling) -#> Chain 1: 0.004043 seconds (Total) +#> Chain 1: Elapsed Time: 0.00209 seconds (Warm-up) +#> Chain 1: 0.001639 seconds (Sampling) +#> Chain 1: 0.003729 seconds (Total) #> Chain 1:

#> Warning: Bulk Effective Samples Size (ESS) is too low, indicating posterior means and medians may be unreliable. #> Running the chains for more iterations may help. See #> http://mc-stan.org/misc/warnings.html#bulk-ess
#> Warning: Tail Effective Samples Size (ESS) is too low, indicating posterior variances and tail quantiles may be unreliable. @@ -949,8 +945,8 @@

Examp #> http://mc-stan.org/misc/warnings.html#tail-ess

#> #> SAMPLING FOR MODEL 'corr' NOW (CHAIN 1). #> Chain 1: -#> Chain 1: Gradient evaluation took 5e-06 seconds -#> Chain 1: 1000 transitions using 10 leapfrog steps per transition would take 0.05 seconds. +#> Chain 1: Gradient evaluation took 6e-06 seconds +#> Chain 1: 1000 transitions using 10 leapfrog steps per transition would take 0.06 seconds. #> Chain 1: Adjust your expectations accordingly! #> Chain 1: #> Chain 1: @@ -967,20 +963,18 @@

Examp #> Chain 1: Iteration: 270 / 300 [ 90%] (Sampling) #> Chain 1: Iteration: 300 / 300 [100%] (Sampling) #> Chain 1: -#> Chain 1: Elapsed Time: 0.002056 seconds (Warm-up) -#> Chain 1: 0.00169 seconds (Sampling) -#> Chain 1: 0.003746 seconds (Total) -#> Chain 1:

#> Warning: The largest R-hat is 1.07, indicating chains have not mixed. -#> Running the chains for more iterations may help. See -#> http://mc-stan.org/misc/warnings.html#r-hat
#> Warning: Bulk Effective Samples Size (ESS) is too low, indicating posterior means and medians may be unreliable. +#> Chain 1: Elapsed Time: 0.002092 seconds (Warm-up) +#> Chain 1: 0.00171 seconds (Sampling) +#> Chain 1: 0.003802 seconds (Total) +#> Chain 1:
#> Warning: Bulk Effective Samples Size (ESS) is too low, indicating posterior means and medians may be unreliable. #> Running the chains for more iterations may help. See #> http://mc-stan.org/misc/warnings.html#bulk-ess
#> Warning: Tail Effective Samples Size (ESS) is too low, indicating posterior variances and tail quantiles may be unreliable. #> Running the chains for more iterations may help. See #> http://mc-stan.org/misc/warnings.html#tail-ess
#> #> SAMPLING FOR MODEL 'corr' NOW (CHAIN 1). #> Chain 1: -#> Chain 1: Gradient evaluation took 4e-06 seconds -#> Chain 1: 1000 transitions using 10 leapfrog steps per transition would take 0.04 seconds. +#> Chain 1: Gradient evaluation took 5e-06 seconds +#> Chain 1: 1000 transitions using 10 leapfrog steps per transition would take 0.05 seconds. #> Chain 1: Adjust your expectations accordingly! #> Chain 1: #> Chain 1: @@ -997,9 +991,9 @@

Examp #> Chain 1: Iteration: 270 / 300 [ 90%] (Sampling) #> Chain 1: Iteration: 300 / 300 [100%] (Sampling) #> Chain 1: -#> Chain 1: Elapsed Time: 0.002491 seconds (Warm-up) -#> Chain 1: 0.00172 seconds (Sampling) -#> Chain 1: 0.004211 seconds (Total) +#> Chain 1: Elapsed Time: 0.002915 seconds (Warm-up) +#> Chain 1: 0.001398 seconds (Sampling) +#> Chain 1: 0.004313 seconds (Total) #> Chain 1:

#> Warning: Bulk Effective Samples Size (ESS) is too low, indicating posterior means and medians may be unreliable. #> Running the chains for more iterations may help. See #> http://mc-stan.org/misc/warnings.html#bulk-ess
#> Warning: Tail Effective Samples Size (ESS) is too low, indicating posterior variances and tail quantiles may be unreliable. @@ -1007,8 +1001,8 @@

Examp #> http://mc-stan.org/misc/warnings.html#tail-ess

#> #> SAMPLING FOR MODEL 'corr' NOW (CHAIN 1). #> Chain 1: -#> Chain 1: Gradient evaluation took 7e-06 seconds -#> Chain 1: 1000 transitions using 10 leapfrog steps per transition would take 0.07 seconds. +#> Chain 1: Gradient evaluation took 5e-06 seconds +#> Chain 1: 1000 transitions using 10 leapfrog steps per transition would take 0.05 seconds. #> Chain 1: Adjust your expectations accordingly! #> Chain 1: #> Chain 1: @@ -1025,12 +1019,10 @@

Examp #> Chain 1: Iteration: 270 / 300 [ 90%] (Sampling) #> Chain 1: Iteration: 300 / 300 [100%] (Sampling) #> Chain 1: -#> Chain 1: Elapsed Time: 0.003089 seconds (Warm-up) -#> Chain 1: 0.002068 seconds (Sampling) -#> Chain 1: 0.005157 seconds (Total) -#> Chain 1:

#> Warning: The largest R-hat is 1.05, indicating chains have not mixed. -#> Running the chains for more iterations may help. See -#> http://mc-stan.org/misc/warnings.html#r-hat
#> Warning: Bulk Effective Samples Size (ESS) is too low, indicating posterior means and medians may be unreliable. +#> Chain 1: Elapsed Time: 0.002576 seconds (Warm-up) +#> Chain 1: 0.001446 seconds (Sampling) +#> Chain 1: 0.004022 seconds (Total) +#> Chain 1:
#> Warning: Bulk Effective Samples Size (ESS) is too low, indicating posterior means and medians may be unreliable. #> Running the chains for more iterations may help. See #> http://mc-stan.org/misc/warnings.html#bulk-ess
#> Warning: Tail Effective Samples Size (ESS) is too low, indicating posterior variances and tail quantiles may be unreliable. #> Running the chains for more iterations may help. See @@ -1055,21 +1047,23 @@

Examp #> Chain 1: Iteration: 270 / 300 [ 90%] (Sampling) #> Chain 1: Iteration: 300 / 300 [100%] (Sampling) #> Chain 1: -#> Chain 1: Elapsed Time: 0.002259 seconds (Warm-up) -#> Chain 1: 0.001573 seconds (Sampling) -#> Chain 1: 0.003832 seconds (Total) +#> Chain 1: Elapsed Time: 0.002531 seconds (Warm-up) +#> Chain 1: 0.001643 seconds (Sampling) +#> Chain 1: 0.004174 seconds (Total) #> Chain 1:

#> Warning: Bulk Effective Samples Size (ESS) is too low, indicating posterior means and medians may be unreliable. #> Running the chains for more iterations may help. See #> http://mc-stan.org/misc/warnings.html#bulk-ess
#> Warning: Tail Effective Samples Size (ESS) is too low, indicating posterior variances and tail quantiles may be unreliable. #> Running the chains for more iterations may help. See #> http://mc-stan.org/misc/warnings.html#tail-ess
hist(correlation) -
correlation <- trend_cor(r, y = fake_dat, time_window = 5:15, - trend_samples = 25) +
correlation <- trend_cor(r, + y = fake_dat, time_window = 5:15, + trend_samples = 25 +)
#> #> SAMPLING FOR MODEL 'corr' NOW (CHAIN 1). #> Chain 1: -#> Chain 1: Gradient evaluation took 8e-06 seconds -#> Chain 1: 1000 transitions using 10 leapfrog steps per transition would take 0.08 seconds. +#> Chain 1: Gradient evaluation took 7e-06 seconds +#> Chain 1: 1000 transitions using 10 leapfrog steps per transition would take 0.07 seconds. #> Chain 1: Adjust your expectations accordingly! #> Chain 1: #> Chain 1: @@ -1086,20 +1080,18 @@

Examp #> Chain 1: Iteration: 270 / 300 [ 90%] (Sampling) #> Chain 1: Iteration: 300 / 300 [100%] (Sampling) #> Chain 1: -#> Chain 1: Elapsed Time: 0.003104 seconds (Warm-up) -#> Chain 1: 0.002208 seconds (Sampling) -#> Chain 1: 0.005312 seconds (Total) -#> Chain 1:

#> Warning: The largest R-hat is 1.15, indicating chains have not mixed. -#> Running the chains for more iterations may help. See -#> http://mc-stan.org/misc/warnings.html#r-hat
#> Warning: Bulk Effective Samples Size (ESS) is too low, indicating posterior means and medians may be unreliable. +#> Chain 1: Elapsed Time: 0.002638 seconds (Warm-up) +#> Chain 1: 0.001956 seconds (Sampling) +#> Chain 1: 0.004594 seconds (Total) +#> Chain 1:
#> Warning: Bulk Effective Samples Size (ESS) is too low, indicating posterior means and medians may be unreliable. #> Running the chains for more iterations may help. See #> http://mc-stan.org/misc/warnings.html#bulk-ess
#> Warning: Tail Effective Samples Size (ESS) is too low, indicating posterior variances and tail quantiles may be unreliable. #> Running the chains for more iterations may help. See #> http://mc-stan.org/misc/warnings.html#tail-ess
#> #> SAMPLING FOR MODEL 'corr' NOW (CHAIN 1). #> Chain 1: -#> Chain 1: Gradient evaluation took 6e-06 seconds -#> Chain 1: 1000 transitions using 10 leapfrog steps per transition would take 0.06 seconds. +#> Chain 1: Gradient evaluation took 1.1e-05 seconds +#> Chain 1: 1000 transitions using 10 leapfrog steps per transition would take 0.11 seconds. #> Chain 1: Adjust your expectations accordingly! #> Chain 1: #> Chain 1: @@ -1116,9 +1108,9 @@

Examp #> Chain 1: Iteration: 270 / 300 [ 90%] (Sampling) #> Chain 1: Iteration: 300 / 300 [100%] (Sampling) #> Chain 1: -#> Chain 1: Elapsed Time: 0.002943 seconds (Warm-up) -#> Chain 1: 0.001652 seconds (Sampling) -#> Chain 1: 0.004595 seconds (Total) +#> Chain 1: Elapsed Time: 0.002282 seconds (Warm-up) +#> Chain 1: 0.00216 seconds (Sampling) +#> Chain 1: 0.004442 seconds (Total) #> Chain 1:

#> Warning: Bulk Effective Samples Size (ESS) is too low, indicating posterior means and medians may be unreliable. #> Running the chains for more iterations may help. See #> http://mc-stan.org/misc/warnings.html#bulk-ess
#> Warning: Tail Effective Samples Size (ESS) is too low, indicating posterior variances and tail quantiles may be unreliable. @@ -1126,8 +1118,8 @@

Examp #> http://mc-stan.org/misc/warnings.html#tail-ess

#> #> SAMPLING FOR MODEL 'corr' NOW (CHAIN 1). #> Chain 1: -#> Chain 1: Gradient evaluation took 7e-06 seconds -#> Chain 1: 1000 transitions using 10 leapfrog steps per transition would take 0.07 seconds. +#> Chain 1: Gradient evaluation took 8e-06 seconds +#> Chain 1: 1000 transitions using 10 leapfrog steps per transition would take 0.08 seconds. #> Chain 1: Adjust your expectations accordingly! #> Chain 1: #> Chain 1: @@ -1144,9 +1136,9 @@

Examp #> Chain 1: Iteration: 270 / 300 [ 90%] (Sampling) #> Chain 1: Iteration: 300 / 300 [100%] (Sampling) #> Chain 1: -#> Chain 1: Elapsed Time: 0.002087 seconds (Warm-up) -#> Chain 1: 0.001634 seconds (Sampling) -#> Chain 1: 0.003721 seconds (Total) +#> Chain 1: Elapsed Time: 0.00324 seconds (Warm-up) +#> Chain 1: 0.002252 seconds (Sampling) +#> Chain 1: 0.005492 seconds (Total) #> Chain 1:

#> Warning: Bulk Effective Samples Size (ESS) is too low, indicating posterior means and medians may be unreliable. #> Running the chains for more iterations may help. See #> http://mc-stan.org/misc/warnings.html#bulk-ess
#> Warning: Tail Effective Samples Size (ESS) is too low, indicating posterior variances and tail quantiles may be unreliable. @@ -1154,8 +1146,8 @@

Examp #> http://mc-stan.org/misc/warnings.html#tail-ess

#> #> SAMPLING FOR MODEL 'corr' NOW (CHAIN 1). #> Chain 1: -#> Chain 1: Gradient evaluation took 1.1e-05 seconds -#> Chain 1: 1000 transitions using 10 leapfrog steps per transition would take 0.11 seconds. +#> Chain 1: Gradient evaluation took 9e-06 seconds +#> Chain 1: 1000 transitions using 10 leapfrog steps per transition would take 0.09 seconds. #> Chain 1: Adjust your expectations accordingly! #> Chain 1: #> Chain 1: @@ -1172,10 +1164,10 @@

Examp #> Chain 1: Iteration: 270 / 300 [ 90%] (Sampling) #> Chain 1: Iteration: 300 / 300 [100%] (Sampling) #> Chain 1: -#> Chain 1: Elapsed Time: 0.002684 seconds (Warm-up) -#> Chain 1: 0.001758 seconds (Sampling) -#> Chain 1: 0.004442 seconds (Total) -#> Chain 1:

#> Warning: The largest R-hat is 1.09, indicating chains have not mixed. +#> Chain 1: Elapsed Time: 0.002503 seconds (Warm-up) +#> Chain 1: 0.001925 seconds (Sampling) +#> Chain 1: 0.004428 seconds (Total) +#> Chain 1:
#> Warning: The largest R-hat is 1.05, indicating chains have not mixed. #> Running the chains for more iterations may help. See #> http://mc-stan.org/misc/warnings.html#r-hat
#> Warning: Bulk Effective Samples Size (ESS) is too low, indicating posterior means and medians may be unreliable. #> Running the chains for more iterations may help. See @@ -1184,8 +1176,8 @@

Examp #> http://mc-stan.org/misc/warnings.html#tail-ess

#> #> SAMPLING FOR MODEL 'corr' NOW (CHAIN 1). #> Chain 1: -#> Chain 1: Gradient evaluation took 8e-06 seconds -#> Chain 1: 1000 transitions using 10 leapfrog steps per transition would take 0.08 seconds. +#> Chain 1: Gradient evaluation took 6e-06 seconds +#> Chain 1: 1000 transitions using 10 leapfrog steps per transition would take 0.06 seconds. #> Chain 1: Adjust your expectations accordingly! #> Chain 1: #> Chain 1: @@ -1202,9 +1194,9 @@

Examp #> Chain 1: Iteration: 270 / 300 [ 90%] (Sampling) #> Chain 1: Iteration: 300 / 300 [100%] (Sampling) #> Chain 1: -#> Chain 1: Elapsed Time: 0.002893 seconds (Warm-up) -#> Chain 1: 0.001923 seconds (Sampling) -#> Chain 1: 0.004816 seconds (Total) +#> Chain 1: Elapsed Time: 0.002822 seconds (Warm-up) +#> Chain 1: 0.001859 seconds (Sampling) +#> Chain 1: 0.004681 seconds (Total) #> Chain 1:

#> Warning: Bulk Effective Samples Size (ESS) is too low, indicating posterior means and medians may be unreliable. #> Running the chains for more iterations may help. See #> http://mc-stan.org/misc/warnings.html#bulk-ess
#> Warning: Tail Effective Samples Size (ESS) is too low, indicating posterior variances and tail quantiles may be unreliable. @@ -1212,8 +1204,8 @@

Examp #> http://mc-stan.org/misc/warnings.html#tail-ess

#> #> SAMPLING FOR MODEL 'corr' NOW (CHAIN 1). #> Chain 1: -#> Chain 1: Gradient evaluation took 6e-06 seconds -#> Chain 1: 1000 transitions using 10 leapfrog steps per transition would take 0.06 seconds. +#> Chain 1: Gradient evaluation took 8e-06 seconds +#> Chain 1: 1000 transitions using 10 leapfrog steps per transition would take 0.08 seconds. #> Chain 1: Adjust your expectations accordingly! #> Chain 1: #> Chain 1: @@ -1230,18 +1222,20 @@

Examp #> Chain 1: Iteration: 270 / 300 [ 90%] (Sampling) #> Chain 1: Iteration: 300 / 300 [100%] (Sampling) #> Chain 1: -#> Chain 1: Elapsed Time: 0.002843 seconds (Warm-up) -#> Chain 1: 0.001724 seconds (Sampling) -#> Chain 1: 0.004567 seconds (Total) -#> Chain 1:

#> Warning: Bulk Effective Samples Size (ESS) is too low, indicating posterior means and medians may be unreliable. +#> Chain 1: Elapsed Time: 0.002775 seconds (Warm-up) +#> Chain 1: 0.00183 seconds (Sampling) +#> Chain 1: 0.004605 seconds (Total) +#> Chain 1:
#> Warning: The largest R-hat is 1.05, indicating chains have not mixed. +#> Running the chains for more iterations may help. See +#> http://mc-stan.org/misc/warnings.html#r-hat
#> Warning: Bulk Effective Samples Size (ESS) is too low, indicating posterior means and medians may be unreliable. #> Running the chains for more iterations may help. See #> http://mc-stan.org/misc/warnings.html#bulk-ess
#> Warning: Tail Effective Samples Size (ESS) is too low, indicating posterior variances and tail quantiles may be unreliable. #> Running the chains for more iterations may help. See #> http://mc-stan.org/misc/warnings.html#tail-ess
#> #> SAMPLING FOR MODEL 'corr' NOW (CHAIN 1). #> Chain 1: -#> Chain 1: Gradient evaluation took 8e-06 seconds -#> Chain 1: 1000 transitions using 10 leapfrog steps per transition would take 0.08 seconds. +#> Chain 1: Gradient evaluation took 5e-06 seconds +#> Chain 1: 1000 transitions using 10 leapfrog steps per transition would take 0.05 seconds. #> Chain 1: Adjust your expectations accordingly! #> Chain 1: #> Chain 1: @@ -1258,18 +1252,20 @@

Examp #> Chain 1: Iteration: 270 / 300 [ 90%] (Sampling) #> Chain 1: Iteration: 300 / 300 [100%] (Sampling) #> Chain 1: -#> Chain 1: Elapsed Time: 0.003071 seconds (Warm-up) -#> Chain 1: 0.002024 seconds (Sampling) -#> Chain 1: 0.005095 seconds (Total) -#> Chain 1:

#> Warning: Bulk Effective Samples Size (ESS) is too low, indicating posterior means and medians may be unreliable. +#> Chain 1: Elapsed Time: 0.003134 seconds (Warm-up) +#> Chain 1: 0.002323 seconds (Sampling) +#> Chain 1: 0.005457 seconds (Total) +#> Chain 1:
#> Warning: The largest R-hat is 1.14, indicating chains have not mixed. +#> Running the chains for more iterations may help. See +#> http://mc-stan.org/misc/warnings.html#r-hat
#> Warning: Bulk Effective Samples Size (ESS) is too low, indicating posterior means and medians may be unreliable. #> Running the chains for more iterations may help. See #> http://mc-stan.org/misc/warnings.html#bulk-ess
#> Warning: Tail Effective Samples Size (ESS) is too low, indicating posterior variances and tail quantiles may be unreliable. #> Running the chains for more iterations may help. See #> http://mc-stan.org/misc/warnings.html#tail-ess
#> #> SAMPLING FOR MODEL 'corr' NOW (CHAIN 1). #> Chain 1: -#> Chain 1: Gradient evaluation took 7e-06 seconds -#> Chain 1: 1000 transitions using 10 leapfrog steps per transition would take 0.07 seconds. +#> Chain 1: Gradient evaluation took 8e-06 seconds +#> Chain 1: 1000 transitions using 10 leapfrog steps per transition would take 0.08 seconds. #> Chain 1: Adjust your expectations accordingly! #> Chain 1: #> Chain 1: @@ -1286,20 +1282,18 @@

Examp #> Chain 1: Iteration: 270 / 300 [ 90%] (Sampling) #> Chain 1: Iteration: 300 / 300 [100%] (Sampling) #> Chain 1: -#> Chain 1: Elapsed Time: 0.002508 seconds (Warm-up) -#> Chain 1: 0.001959 seconds (Sampling) -#> Chain 1: 0.004467 seconds (Total) -#> Chain 1:

#> Warning: The largest R-hat is 1.09, indicating chains have not mixed. -#> Running the chains for more iterations may help. See -#> http://mc-stan.org/misc/warnings.html#r-hat
#> Warning: Bulk Effective Samples Size (ESS) is too low, indicating posterior means and medians may be unreliable. +#> Chain 1: Elapsed Time: 0.002618 seconds (Warm-up) +#> Chain 1: 0.002055 seconds (Sampling) +#> Chain 1: 0.004673 seconds (Total) +#> Chain 1:
#> Warning: Bulk Effective Samples Size (ESS) is too low, indicating posterior means and medians may be unreliable. #> Running the chains for more iterations may help. See #> http://mc-stan.org/misc/warnings.html#bulk-ess
#> Warning: Tail Effective Samples Size (ESS) is too low, indicating posterior variances and tail quantiles may be unreliable. #> Running the chains for more iterations may help. See #> http://mc-stan.org/misc/warnings.html#tail-ess
#> #> SAMPLING FOR MODEL 'corr' NOW (CHAIN 1). #> Chain 1: -#> Chain 1: Gradient evaluation took 6e-06 seconds -#> Chain 1: 1000 transitions using 10 leapfrog steps per transition would take 0.06 seconds. +#> Chain 1: Gradient evaluation took 7e-06 seconds +#> Chain 1: 1000 transitions using 10 leapfrog steps per transition would take 0.07 seconds. #> Chain 1: Adjust your expectations accordingly! #> Chain 1: #> Chain 1: @@ -1316,9 +1310,9 @@

Examp #> Chain 1: Iteration: 270 / 300 [ 90%] (Sampling) #> Chain 1: Iteration: 300 / 300 [100%] (Sampling) #> Chain 1: -#> Chain 1: Elapsed Time: 0.002578 seconds (Warm-up) -#> Chain 1: 0.001963 seconds (Sampling) -#> Chain 1: 0.004541 seconds (Total) +#> Chain 1: Elapsed Time: 0.002742 seconds (Warm-up) +#> Chain 1: 0.002585 seconds (Sampling) +#> Chain 1: 0.005327 seconds (Total) #> Chain 1:

#> Warning: Bulk Effective Samples Size (ESS) is too low, indicating posterior means and medians may be unreliable. #> Running the chains for more iterations may help. See #> http://mc-stan.org/misc/warnings.html#bulk-ess
#> Warning: Tail Effective Samples Size (ESS) is too low, indicating posterior variances and tail quantiles may be unreliable. @@ -1344,9 +1338,9 @@

Examp #> Chain 1: Iteration: 270 / 300 [ 90%] (Sampling) #> Chain 1: Iteration: 300 / 300 [100%] (Sampling) #> Chain 1: -#> Chain 1: Elapsed Time: 0.002222 seconds (Warm-up) -#> Chain 1: 0.001523 seconds (Sampling) -#> Chain 1: 0.003745 seconds (Total) +#> Chain 1: Elapsed Time: 0.001912 seconds (Warm-up) +#> Chain 1: 0.001559 seconds (Sampling) +#> Chain 1: 0.003471 seconds (Total) #> Chain 1:

#> Warning: Bulk Effective Samples Size (ESS) is too low, indicating posterior means and medians may be unreliable. #> Running the chains for more iterations may help. See #> http://mc-stan.org/misc/warnings.html#bulk-ess
#> Warning: Tail Effective Samples Size (ESS) is too low, indicating posterior variances and tail quantiles may be unreliable. @@ -1354,8 +1348,8 @@

Examp #> http://mc-stan.org/misc/warnings.html#tail-ess

#> #> SAMPLING FOR MODEL 'corr' NOW (CHAIN 1). #> Chain 1: -#> Chain 1: Gradient evaluation took 4e-06 seconds -#> Chain 1: 1000 transitions using 10 leapfrog steps per transition would take 0.04 seconds. +#> Chain 1: Gradient evaluation took 5e-06 seconds +#> Chain 1: 1000 transitions using 10 leapfrog steps per transition would take 0.05 seconds. #> Chain 1: Adjust your expectations accordingly! #> Chain 1: #> Chain 1: @@ -1372,9 +1366,9 @@

Examp #> Chain 1: Iteration: 270 / 300 [ 90%] (Sampling) #> Chain 1: Iteration: 300 / 300 [100%] (Sampling) #> Chain 1: -#> Chain 1: Elapsed Time: 0.002168 seconds (Warm-up) -#> Chain 1: 0.001592 seconds (Sampling) -#> Chain 1: 0.00376 seconds (Total) +#> Chain 1: Elapsed Time: 0.002058 seconds (Warm-up) +#> Chain 1: 0.001602 seconds (Sampling) +#> Chain 1: 0.00366 seconds (Total) #> Chain 1:

#> Warning: Bulk Effective Samples Size (ESS) is too low, indicating posterior means and medians may be unreliable. #> Running the chains for more iterations may help. See #> http://mc-stan.org/misc/warnings.html#bulk-ess
#> Warning: Tail Effective Samples Size (ESS) is too low, indicating posterior variances and tail quantiles may be unreliable. @@ -1400,9 +1394,9 @@

Examp #> Chain 1: Iteration: 270 / 300 [ 90%] (Sampling) #> Chain 1: Iteration: 300 / 300 [100%] (Sampling) #> Chain 1: -#> Chain 1: Elapsed Time: 0.002104 seconds (Warm-up) -#> Chain 1: 0.001614 seconds (Sampling) -#> Chain 1: 0.003718 seconds (Total) +#> Chain 1: Elapsed Time: 0.002723 seconds (Warm-up) +#> Chain 1: 0.001713 seconds (Sampling) +#> Chain 1: 0.004436 seconds (Total) #> Chain 1:

#> Warning: Bulk Effective Samples Size (ESS) is too low, indicating posterior means and medians may be unreliable. #> Running the chains for more iterations may help. See #> http://mc-stan.org/misc/warnings.html#bulk-ess
#> Warning: Tail Effective Samples Size (ESS) is too low, indicating posterior variances and tail quantiles may be unreliable. @@ -1428,9 +1422,9 @@

Examp #> Chain 1: Iteration: 270 / 300 [ 90%] (Sampling) #> Chain 1: Iteration: 300 / 300 [100%] (Sampling) #> Chain 1: -#> Chain 1: Elapsed Time: 0.002066 seconds (Warm-up) -#> Chain 1: 0.001305 seconds (Sampling) -#> Chain 1: 0.003371 seconds (Total) +#> Chain 1: Elapsed Time: 0.002355 seconds (Warm-up) +#> Chain 1: 0.001802 seconds (Sampling) +#> Chain 1: 0.004157 seconds (Total) #> Chain 1:

#> Warning: Bulk Effective Samples Size (ESS) is too low, indicating posterior means and medians may be unreliable. #> Running the chains for more iterations may help. See #> http://mc-stan.org/misc/warnings.html#bulk-ess
#> Warning: Tail Effective Samples Size (ESS) is too low, indicating posterior variances and tail quantiles may be unreliable. @@ -1438,8 +1432,8 @@

Examp #> http://mc-stan.org/misc/warnings.html#tail-ess

#> #> SAMPLING FOR MODEL 'corr' NOW (CHAIN 1). #> Chain 1: -#> Chain 1: Gradient evaluation took 4e-06 seconds -#> Chain 1: 1000 transitions using 10 leapfrog steps per transition would take 0.04 seconds. +#> Chain 1: Gradient evaluation took 5e-06 seconds +#> Chain 1: 1000 transitions using 10 leapfrog steps per transition would take 0.05 seconds. #> Chain 1: Adjust your expectations accordingly! #> Chain 1: #> Chain 1: @@ -1456,18 +1450,20 @@

Examp #> Chain 1: Iteration: 270 / 300 [ 90%] (Sampling) #> Chain 1: Iteration: 300 / 300 [100%] (Sampling) #> Chain 1: -#> Chain 1: Elapsed Time: 0.001978 seconds (Warm-up) -#> Chain 1: 0.001542 seconds (Sampling) -#> Chain 1: 0.00352 seconds (Total) -#> Chain 1:

#> Warning: Bulk Effective Samples Size (ESS) is too low, indicating posterior means and medians may be unreliable. +#> Chain 1: Elapsed Time: 0.002325 seconds (Warm-up) +#> Chain 1: 0.001563 seconds (Sampling) +#> Chain 1: 0.003888 seconds (Total) +#> Chain 1:
#> Warning: The largest R-hat is 1.08, indicating chains have not mixed. +#> Running the chains for more iterations may help. See +#> http://mc-stan.org/misc/warnings.html#r-hat
#> Warning: Bulk Effective Samples Size (ESS) is too low, indicating posterior means and medians may be unreliable. #> Running the chains for more iterations may help. See #> http://mc-stan.org/misc/warnings.html#bulk-ess
#> Warning: Tail Effective Samples Size (ESS) is too low, indicating posterior variances and tail quantiles may be unreliable. #> Running the chains for more iterations may help. See #> http://mc-stan.org/misc/warnings.html#tail-ess
#> #> SAMPLING FOR MODEL 'corr' NOW (CHAIN 1). #> Chain 1: -#> Chain 1: Gradient evaluation took 4e-06 seconds -#> Chain 1: 1000 transitions using 10 leapfrog steps per transition would take 0.04 seconds. +#> Chain 1: Gradient evaluation took 5e-06 seconds +#> Chain 1: 1000 transitions using 10 leapfrog steps per transition would take 0.05 seconds. #> Chain 1: Adjust your expectations accordingly! #> Chain 1: #> Chain 1: @@ -1484,20 +1480,18 @@

Examp #> Chain 1: Iteration: 270 / 300 [ 90%] (Sampling) #> Chain 1: Iteration: 300 / 300 [100%] (Sampling) #> Chain 1: -#> Chain 1: Elapsed Time: 0.002627 seconds (Warm-up) -#> Chain 1: 0.001693 seconds (Sampling) -#> Chain 1: 0.00432 seconds (Total) -#> Chain 1:

#> Warning: The largest R-hat is 1.08, indicating chains have not mixed. -#> Running the chains for more iterations may help. See -#> http://mc-stan.org/misc/warnings.html#r-hat
#> Warning: Bulk Effective Samples Size (ESS) is too low, indicating posterior means and medians may be unreliable. +#> Chain 1: Elapsed Time: 0.002435 seconds (Warm-up) +#> Chain 1: 0.001488 seconds (Sampling) +#> Chain 1: 0.003923 seconds (Total) +#> Chain 1:
#> Warning: Bulk Effective Samples Size (ESS) is too low, indicating posterior means and medians may be unreliable. #> Running the chains for more iterations may help. See #> http://mc-stan.org/misc/warnings.html#bulk-ess
#> Warning: Tail Effective Samples Size (ESS) is too low, indicating posterior variances and tail quantiles may be unreliable. #> Running the chains for more iterations may help. See #> http://mc-stan.org/misc/warnings.html#tail-ess
#> #> SAMPLING FOR MODEL 'corr' NOW (CHAIN 1). #> Chain 1: -#> Chain 1: Gradient evaluation took 5e-06 seconds -#> Chain 1: 1000 transitions using 10 leapfrog steps per transition would take 0.05 seconds. +#> Chain 1: Gradient evaluation took 6e-06 seconds +#> Chain 1: 1000 transitions using 10 leapfrog steps per transition would take 0.06 seconds. #> Chain 1: Adjust your expectations accordingly! #> Chain 1: #> Chain 1: @@ -1514,9 +1508,9 @@

Examp #> Chain 1: Iteration: 270 / 300 [ 90%] (Sampling) #> Chain 1: Iteration: 300 / 300 [100%] (Sampling) #> Chain 1: -#> Chain 1: Elapsed Time: 0.002124 seconds (Warm-up) -#> Chain 1: 0.001585 seconds (Sampling) -#> Chain 1: 0.003709 seconds (Total) +#> Chain 1: Elapsed Time: 0.001989 seconds (Warm-up) +#> Chain 1: 0.001643 seconds (Sampling) +#> Chain 1: 0.003632 seconds (Total) #> Chain 1:

#> Warning: Bulk Effective Samples Size (ESS) is too low, indicating posterior means and medians may be unreliable. #> Running the chains for more iterations may help. See #> http://mc-stan.org/misc/warnings.html#bulk-ess
#> Warning: Tail Effective Samples Size (ESS) is too low, indicating posterior variances and tail quantiles may be unreliable. @@ -1524,8 +1518,8 @@

Examp #> http://mc-stan.org/misc/warnings.html#tail-ess

#> #> SAMPLING FOR MODEL 'corr' NOW (CHAIN 1). #> Chain 1: -#> Chain 1: Gradient evaluation took 4e-06 seconds -#> Chain 1: 1000 transitions using 10 leapfrog steps per transition would take 0.04 seconds. +#> Chain 1: Gradient evaluation took 6e-06 seconds +#> Chain 1: 1000 transitions using 10 leapfrog steps per transition would take 0.06 seconds. #> Chain 1: Adjust your expectations accordingly! #> Chain 1: #> Chain 1: @@ -1542,9 +1536,9 @@

Examp #> Chain 1: Iteration: 270 / 300 [ 90%] (Sampling) #> Chain 1: Iteration: 300 / 300 [100%] (Sampling) #> Chain 1: -#> Chain 1: Elapsed Time: 0.001892 seconds (Warm-up) -#> Chain 1: 0.002182 seconds (Sampling) -#> Chain 1: 0.004074 seconds (Total) +#> Chain 1: Elapsed Time: 0.002566 seconds (Warm-up) +#> Chain 1: 0.001662 seconds (Sampling) +#> Chain 1: 0.004228 seconds (Total) #> Chain 1:

#> Warning: Bulk Effective Samples Size (ESS) is too low, indicating posterior means and medians may be unreliable. #> Running the chains for more iterations may help. See #> http://mc-stan.org/misc/warnings.html#bulk-ess
#> Warning: Tail Effective Samples Size (ESS) is too low, indicating posterior variances and tail quantiles may be unreliable. @@ -1552,8 +1546,8 @@

Examp #> http://mc-stan.org/misc/warnings.html#tail-ess

#> #> SAMPLING FOR MODEL 'corr' NOW (CHAIN 1). #> Chain 1: -#> Chain 1: Gradient evaluation took 7e-06 seconds -#> Chain 1: 1000 transitions using 10 leapfrog steps per transition would take 0.07 seconds. +#> Chain 1: Gradient evaluation took 1.1e-05 seconds +#> Chain 1: 1000 transitions using 10 leapfrog steps per transition would take 0.11 seconds. #> Chain 1: Adjust your expectations accordingly! #> Chain 1: #> Chain 1: @@ -1570,18 +1564,20 @@

Examp #> Chain 1: Iteration: 270 / 300 [ 90%] (Sampling) #> Chain 1: Iteration: 300 / 300 [100%] (Sampling) #> Chain 1: -#> Chain 1: Elapsed Time: 0.002568 seconds (Warm-up) -#> Chain 1: 0.001443 seconds (Sampling) -#> Chain 1: 0.004011 seconds (Total) -#> Chain 1:

#> Warning: Bulk Effective Samples Size (ESS) is too low, indicating posterior means and medians may be unreliable. +#> Chain 1: Elapsed Time: 0.002763 seconds (Warm-up) +#> Chain 1: 0.001996 seconds (Sampling) +#> Chain 1: 0.004759 seconds (Total) +#> Chain 1:
#> Warning: The largest R-hat is 1.05, indicating chains have not mixed. +#> Running the chains for more iterations may help. See +#> http://mc-stan.org/misc/warnings.html#r-hat
#> Warning: Bulk Effective Samples Size (ESS) is too low, indicating posterior means and medians may be unreliable. #> Running the chains for more iterations may help. See #> http://mc-stan.org/misc/warnings.html#bulk-ess
#> Warning: Tail Effective Samples Size (ESS) is too low, indicating posterior variances and tail quantiles may be unreliable. #> Running the chains for more iterations may help. See #> http://mc-stan.org/misc/warnings.html#tail-ess
#> #> SAMPLING FOR MODEL 'corr' NOW (CHAIN 1). #> Chain 1: -#> Chain 1: Gradient evaluation took 5e-06 seconds -#> Chain 1: 1000 transitions using 10 leapfrog steps per transition would take 0.05 seconds. +#> Chain 1: Gradient evaluation took 1e-05 seconds +#> Chain 1: 1000 transitions using 10 leapfrog steps per transition would take 0.1 seconds. #> Chain 1: Adjust your expectations accordingly! #> Chain 1: #> Chain 1: @@ -1598,10 +1594,10 @@

Examp #> Chain 1: Iteration: 270 / 300 [ 90%] (Sampling) #> Chain 1: Iteration: 300 / 300 [100%] (Sampling) #> Chain 1: -#> Chain 1: Elapsed Time: 0.002529 seconds (Warm-up) -#> Chain 1: 0.002099 seconds (Sampling) -#> Chain 1: 0.004628 seconds (Total) -#> Chain 1:

#> Warning: The largest R-hat is 1.1, indicating chains have not mixed. +#> Chain 1: Elapsed Time: 0.003244 seconds (Warm-up) +#> Chain 1: 0.002044 seconds (Sampling) +#> Chain 1: 0.005288 seconds (Total) +#> Chain 1:
#> Warning: The largest R-hat is 1.08, indicating chains have not mixed. #> Running the chains for more iterations may help. See #> http://mc-stan.org/misc/warnings.html#r-hat
#> Warning: Bulk Effective Samples Size (ESS) is too low, indicating posterior means and medians may be unreliable. #> Running the chains for more iterations may help. See @@ -1610,8 +1606,8 @@

Examp #> http://mc-stan.org/misc/warnings.html#tail-ess

#> #> SAMPLING FOR MODEL 'corr' NOW (CHAIN 1). #> Chain 1: -#> Chain 1: Gradient evaluation took 1.4e-05 seconds -#> Chain 1: 1000 transitions using 10 leapfrog steps per transition would take 0.14 seconds. +#> Chain 1: Gradient evaluation took 9e-06 seconds +#> Chain 1: 1000 transitions using 10 leapfrog steps per transition would take 0.09 seconds. #> Chain 1: Adjust your expectations accordingly! #> Chain 1: #> Chain 1: @@ -1628,9 +1624,9 @@

Examp #> Chain 1: Iteration: 270 / 300 [ 90%] (Sampling) #> Chain 1: Iteration: 300 / 300 [100%] (Sampling) #> Chain 1: -#> Chain 1: Elapsed Time: 0.002694 seconds (Warm-up) -#> Chain 1: 0.001685 seconds (Sampling) -#> Chain 1: 0.004379 seconds (Total) +#> Chain 1: Elapsed Time: 0.002671 seconds (Warm-up) +#> Chain 1: 0.001901 seconds (Sampling) +#> Chain 1: 0.004572 seconds (Total) #> Chain 1:

#> Warning: Bulk Effective Samples Size (ESS) is too low, indicating posterior means and medians may be unreliable. #> Running the chains for more iterations may help. See #> http://mc-stan.org/misc/warnings.html#bulk-ess
#> Warning: Tail Effective Samples Size (ESS) is too low, indicating posterior variances and tail quantiles may be unreliable. @@ -1638,8 +1634,8 @@

Examp #> http://mc-stan.org/misc/warnings.html#tail-ess

#> #> SAMPLING FOR MODEL 'corr' NOW (CHAIN 1). #> Chain 1: -#> Chain 1: Gradient evaluation took 1e-05 seconds -#> Chain 1: 1000 transitions using 10 leapfrog steps per transition would take 0.1 seconds. +#> Chain 1: Gradient evaluation took 6e-06 seconds +#> Chain 1: 1000 transitions using 10 leapfrog steps per transition would take 0.06 seconds. #> Chain 1: Adjust your expectations accordingly! #> Chain 1: #> Chain 1: @@ -1656,9 +1652,9 @@

Examp #> Chain 1: Iteration: 270 / 300 [ 90%] (Sampling) #> Chain 1: Iteration: 300 / 300 [100%] (Sampling) #> Chain 1: -#> Chain 1: Elapsed Time: 0.002861 seconds (Warm-up) -#> Chain 1: 0.002082 seconds (Sampling) -#> Chain 1: 0.004943 seconds (Total) +#> Chain 1: Elapsed Time: 0.002654 seconds (Warm-up) +#> Chain 1: 0.00215 seconds (Sampling) +#> Chain 1: 0.004804 seconds (Total) #> Chain 1:

#> Warning: Bulk Effective Samples Size (ESS) is too low, indicating posterior means and medians may be unreliable. #> Running the chains for more iterations may help. See #> http://mc-stan.org/misc/warnings.html#bulk-ess
#> Warning: Tail Effective Samples Size (ESS) is too low, indicating posterior variances and tail quantiles may be unreliable. @@ -1666,8 +1662,8 @@

Examp #> http://mc-stan.org/misc/warnings.html#tail-ess

#> #> SAMPLING FOR MODEL 'corr' NOW (CHAIN 1). #> Chain 1: -#> Chain 1: Gradient evaluation took 5e-06 seconds -#> Chain 1: 1000 transitions using 10 leapfrog steps per transition would take 0.05 seconds. +#> Chain 1: Gradient evaluation took 7e-06 seconds +#> Chain 1: 1000 transitions using 10 leapfrog steps per transition would take 0.07 seconds. #> Chain 1: Adjust your expectations accordingly! #> Chain 1: #> Chain 1: @@ -1684,9 +1680,9 @@

Examp #> Chain 1: Iteration: 270 / 300 [ 90%] (Sampling) #> Chain 1: Iteration: 300 / 300 [100%] (Sampling) #> Chain 1: -#> Chain 1: Elapsed Time: 0.002732 seconds (Warm-up) -#> Chain 1: 0.002171 seconds (Sampling) -#> Chain 1: 0.004903 seconds (Total) +#> Chain 1: Elapsed Time: 0.002808 seconds (Warm-up) +#> Chain 1: 0.002502 seconds (Sampling) +#> Chain 1: 0.00531 seconds (Total) #> Chain 1:

#> Warning: Bulk Effective Samples Size (ESS) is too low, indicating posterior means and medians may be unreliable. #> Running the chains for more iterations may help. See #> http://mc-stan.org/misc/warnings.html#bulk-ess
#> Warning: Tail Effective Samples Size (ESS) is too low, indicating posterior variances and tail quantiles may be unreliable. @@ -1694,8 +1690,8 @@

Examp #> http://mc-stan.org/misc/warnings.html#tail-ess

#> #> SAMPLING FOR MODEL 'corr' NOW (CHAIN 1). #> Chain 1: -#> Chain 1: Gradient evaluation took 5e-06 seconds -#> Chain 1: 1000 transitions using 10 leapfrog steps per transition would take 0.05 seconds. +#> Chain 1: Gradient evaluation took 6e-06 seconds +#> Chain 1: 1000 transitions using 10 leapfrog steps per transition would take 0.06 seconds. #> Chain 1: Adjust your expectations accordingly! #> Chain 1: #> Chain 1: @@ -1712,9 +1708,9 @@

Examp #> Chain 1: Iteration: 270 / 300 [ 90%] (Sampling) #> Chain 1: Iteration: 300 / 300 [100%] (Sampling) #> Chain 1: -#> Chain 1: Elapsed Time: 0.002578 seconds (Warm-up) -#> Chain 1: 0.00187 seconds (Sampling) -#> Chain 1: 0.004448 seconds (Total) +#> Chain 1: Elapsed Time: 0.002982 seconds (Warm-up) +#> Chain 1: 0.002035 seconds (Sampling) +#> Chain 1: 0.005017 seconds (Total) #> Chain 1:

#> Warning: Bulk Effective Samples Size (ESS) is too low, indicating posterior means and medians may be unreliable. #> Running the chains for more iterations may help. See #> http://mc-stan.org/misc/warnings.html#bulk-ess
#> Warning: Tail Effective Samples Size (ESS) is too low, indicating posterior variances and tail quantiles may be unreliable. @@ -1722,8 +1718,8 @@

Examp #> http://mc-stan.org/misc/warnings.html#tail-ess

#> #> SAMPLING FOR MODEL 'corr' NOW (CHAIN 1). #> Chain 1: -#> Chain 1: Gradient evaluation took 1.3e-05 seconds -#> Chain 1: 1000 transitions using 10 leapfrog steps per transition would take 0.13 seconds. +#> Chain 1: Gradient evaluation took 9e-06 seconds +#> Chain 1: 1000 transitions using 10 leapfrog steps per transition would take 0.09 seconds. #> Chain 1: Adjust your expectations accordingly! #> Chain 1: #> Chain 1: @@ -1740,20 +1736,18 @@

Examp #> Chain 1: Iteration: 270 / 300 [ 90%] (Sampling) #> Chain 1: Iteration: 300 / 300 [100%] (Sampling) #> Chain 1: -#> Chain 1: Elapsed Time: 0.002909 seconds (Warm-up) -#> Chain 1: 0.001758 seconds (Sampling) -#> Chain 1: 0.004667 seconds (Total) -#> Chain 1:

#> Warning: The largest R-hat is 1.07, indicating chains have not mixed. -#> Running the chains for more iterations may help. See -#> http://mc-stan.org/misc/warnings.html#r-hat
#> Warning: Bulk Effective Samples Size (ESS) is too low, indicating posterior means and medians may be unreliable. +#> Chain 1: Elapsed Time: 0.002476 seconds (Warm-up) +#> Chain 1: 0.00203 seconds (Sampling) +#> Chain 1: 0.004506 seconds (Total) +#> Chain 1:
#> Warning: Bulk Effective Samples Size (ESS) is too low, indicating posterior means and medians may be unreliable. #> Running the chains for more iterations may help. See #> http://mc-stan.org/misc/warnings.html#bulk-ess
#> Warning: Tail Effective Samples Size (ESS) is too low, indicating posterior variances and tail quantiles may be unreliable. #> Running the chains for more iterations may help. See #> http://mc-stan.org/misc/warnings.html#tail-ess
#> #> SAMPLING FOR MODEL 'corr' NOW (CHAIN 1). #> Chain 1: -#> Chain 1: Gradient evaluation took 9e-06 seconds -#> Chain 1: 1000 transitions using 10 leapfrog steps per transition would take 0.09 seconds. +#> Chain 1: Gradient evaluation took 6e-06 seconds +#> Chain 1: 1000 transitions using 10 leapfrog steps per transition would take 0.06 seconds. #> Chain 1: Adjust your expectations accordingly! #> Chain 1: #> Chain 1: @@ -1770,9 +1764,9 @@

Examp #> Chain 1: Iteration: 270 / 300 [ 90%] (Sampling) #> Chain 1: Iteration: 300 / 300 [100%] (Sampling) #> Chain 1: -#> Chain 1: Elapsed Time: 0.003002 seconds (Warm-up) -#> Chain 1: 0.00198 seconds (Sampling) -#> Chain 1: 0.004982 seconds (Total) +#> Chain 1: Elapsed Time: 0.002979 seconds (Warm-up) +#> Chain 1: 0.001812 seconds (Sampling) +#> Chain 1: 0.004791 seconds (Total) #> Chain 1:

#> Warning: Bulk Effective Samples Size (ESS) is too low, indicating posterior means and medians may be unreliable. #> Running the chains for more iterations may help. See #> http://mc-stan.org/misc/warnings.html#bulk-ess
#> Warning: Tail Effective Samples Size (ESS) is too low, indicating posterior variances and tail quantiles may be unreliable. diff --git a/inst/stan/dfa.stan b/inst/stan/dfa.stan index 7ffe475..9fe0249 100644 --- a/inst/stan/dfa.stan +++ b/inst/stan/dfa.stan @@ -118,6 +118,7 @@ data { int est_sigma_params; int est_gamma_params; int est_nb2_params; + int use_expansion_prior; real gp_theta_prior[2]; } transformed data { @@ -128,6 +129,7 @@ transformed data { vector[K*proportional_model] alpha_vec; vector[n_knots] muZeros; real gp_delta = 1e-9; // stabilizing value for GP model + real lower_bound_z; for(i in 1:N) { data_locs[i] = i; @@ -165,13 +167,17 @@ transformed data { if(proportional_model==1) { for(k in 1:K) alpha_vec[k] = 1; } + + // for zpos + lower_bound_z = -100; + if(use_expansion_prior==1) lower_bound_z = 0; } parameters { matrix[K * est_rw,(N-1) * est_rw] devs; // random deviations of trends vector[K] x0; // initial state - vector[K*(1-proportional_model)] psi; // expansion parameters + vector[K*(1-proportional_model)*use_expansion_prior] psi; // expansion parameters vector[nZ*(1-proportional_model)] z; // estimated loadings in vec form - vector[K*(1-proportional_model)] zpos; // constrained positive values + vector[K*(1-proportional_model)] zpos; // constrained positive values simplex[K] p_z[P*proportional_model]; // alternative for proportional Z matrix[K * est_spline, n_knots * est_spline] spline_a; // weights for b-splines matrix[n_obs_covar, P] b_obs; // coefficients on observation model @@ -192,14 +198,14 @@ transformed parameters { matrix[P,N] pred; //vector[P] pred[N]; matrix[P,K] Z; matrix[P,N] yall; - vector[P*est_sigma_params] sigma_vec; - vector[P*est_gamma_params] gamma_a_vec; - vector[P*est_nb2_params] nb_phi_vec; + vector[P*est_sigma_params] sigma_vec; + vector[P*est_gamma_params] gamma_a_vec; + vector[P*est_nb2_params] nb_phi_vec; vector[K] phi_vec; // for AR(1) part vector[K] theta_vec; // for MA(1) part matrix[K,N] x; //vector[N] x[P]; // random walk-trends vector[K] indicator; // indicates whether diagonal is neg or pos - vector[K] psi_root; // derived sqrt(expansion parameter psi) + vector[K*use_expansion_prior] psi_root; // derived sqrt(expansion parameter psi) matrix[n_pcor*long_format*est_cor, n_pcor*long_format*est_cor] Sigma_derived;// temporary for calculations for MVN model matrix[(n_pcor-1)*long_format*est_cor, (n_pcor-1)*long_format*est_cor] Sigma_temp;// temporary for calculations for MVN model matrix[n_pcor-1,1] sigma12_vec;// temporary for calculations for MVN model @@ -229,20 +235,20 @@ transformed parameters { // phi is the ar(1) parameter, fixed or estimated if(est_phi == 1) { - //for(k in 1:K) {phi_vec[k] = phi[k];} - phi_vec = to_vector(phi); + for(k in 1:K) {phi_vec[k] = phi[k];} + //phi_vec = to_vector(phi); } else { - //for(k in 1:K) {phi_vec[k] = 1;} - phi_vec = rep_vector(1.0, K); + for(k in 1:K) {phi_vec[k] = 1;} + //phi_vec = rep_vector(1.0, K); } // theta is the ma(1) parameter, fixed or estimated if(est_theta == 1) { - //for(k in 1:K) {theta_vec[k] = theta[k];} - theta_vec = to_vector(theta); + for(k in 1:K) {theta_vec[k] = theta[k];} + //theta_vec = to_vector(theta); } else { - //for(k in 1:K) {theta_vec[k] = 0;} - theta_vec = rep_vector(1.0, K); + for(k in 1:K) {theta_vec[k] = 0;} + //theta_vec = rep_vector(1.0, K); } if(est_sigma_params == 1) { @@ -282,17 +288,22 @@ transformed parameters { Z[k,k] = zpos[k];// add constraint for Z diagonal } // this block is for the expansion prior - for(k in 1:K) { - if(zpos[k] < 0) { - indicator[k] = -1; - } else { - indicator[k] = 1; - } - psi_root[k] = sqrt(psi[k]); - for(p in 1:P) { - Z[p,k] = Z[p,k] * indicator[k] * (1/psi_root[k]); + if(use_expansion_prior==1) { + for(k in 1:K) { + if(zpos[k] < 0) { + indicator[k] = -1; + } else { + indicator[k] = 1; + } + // psi_root here should really be named inv_psi_root, because it's the inv + psi_root[k] = sqrt(psi[k]); + for(p in 1:P) { + // see Ghosh & Dunson 2009 eq 3 + Z[p,k] = Z[p,k] * indicator[k] * (1/psi_root[k]); + } } } + // initial state for each trend if(est_rw == 1) { for(k in 1:K) { @@ -337,9 +348,12 @@ transformed parameters { } // this block also for the expansion prior, used to convert trends - for(k in 1:K) { - //x[k,1:N] = x[k,1:N] * indicator[k] * psi_root[k]; - x[k] = x[k] * indicator[k] * psi_root[k]; + if(use_expansion_prior==1) { + for(k in 1:K) { + //x[k,1:N] = x[k,1:N] * indicator[k] * psi_root[k]; + // see Ghosh and Dunson 2009 eq 3. psi_root[k] here is really psi^(-1/2) + x[k] = x[k] * indicator[k] * psi_root[k]; + } } } @@ -406,6 +420,7 @@ transformed parameters { // [PxN] = [PxK] * [KxN] pred = Z * x; + // obs_cov_offset is specific to each non-NA observation for(i in 1:n_pos) { obs_cov_offset[i] = 0; } @@ -463,7 +478,9 @@ model { // initial state for each trend x0 ~ normal(0, 1); // initial state estimate at t=1 - psi ~ gamma(2, 1); // expansion parameter for par-expanded priors + if(use_expansion_prior==1) { + psi ~ gamma(2, 1); // expansion parameter for par-expanded priors + } // prior for df parameter for t-distribution if (estimate_nu == 1) { diff --git a/man/dfa_cv.Rd b/man/dfa_cv.Rd index 84e5bd3..a06d513 100644 --- a/man/dfa_cv.Rd +++ b/man/dfa_cv.Rd @@ -43,28 +43,28 @@ Apply cross validation to DFA model \dontrun{ set.seed(42) s <- sim_dfa(num_trends = 1, num_years = 20, num_ts = 3) -obs <- c(s$y_sim[1,], s$y_sim[2,], s$y_sim[3,]) -long = data.frame("obs" = obs, "ts" = sort(rep(1:3,20)), "time" = rep(1:20,3)) -m <- fit_dfa(y = long, iter = 50, chains = 1, data_shape="long", sample=FALSE) +obs <- c(s$y_sim[1, ], s$y_sim[2, ], s$y_sim[3, ]) +long <- data.frame("obs" = obs, "ts" = sort(rep(1:3, 20)), "time" = rep(1:20, 3)) +m <- fit_dfa(y = long, iter = 50, chains = 1, data_shape = "long", sample = FALSE) # random folds -fit_cv = dfa_cv(m, cv_method="loocv", n_folds = 5, iter=50, chains=1) +fit_cv <- dfa_cv(m, cv_method = "loocv", n_folds = 5, iter = 50, chains = 1) # folds can also be passed in -fold_ids = sample(1:5, size=nrow(long), replace=TRUE) -m <- fit_dfa(y = long, iter = 50, chains = 1, data_shape="long", sample=FALSE) -fit_cv = dfa_cv(m, cv_method="loocv", n_folds = 5, iter=50, chains=1, fold_ids=fold_ids) +fold_ids <- sample(1:5, size = nrow(long), replace = TRUE) +m <- fit_dfa(y = long, iter = 50, chains = 1, data_shape = "long", sample = FALSE) +fit_cv <- dfa_cv(m, cv_method = "loocv", n_folds = 5, iter = 50, chains = 1, fold_ids = fold_ids) # do an example of leave-time-out cross validation where years are dropped -fold_ids = long$time -m <- fit_dfa(y = long, iter = 50, chains = 1, data_shape="long", sample=FALSE) -fit_cv = dfa_cv(m, cv_method="loocv", iter=100, chains=1, fold_ids = fold_ids) +fold_ids <- long$time +m <- fit_dfa(y = long, iter = 50, chains = 1, data_shape = "long", sample = FALSE) +fit_cv <- dfa_cv(m, cv_method = "loocv", iter = 100, chains = 1, fold_ids = fold_ids) # example with covariates and long format data -obs_covar = expand.grid("time"=1:20,"timeseries"=1:3,"covariate"=1:2) -obs_covar$value=rnorm(nrow(obs_covar),0,0.1) -obs <- c(s$y_sim[1,], s$y_sim[2,], s$y_sim[3,]) -m <- fit_dfa(y = long, iter = 50, chains = 1, obs_covar=obs_covar,data_shape="long", sample=FALSE) -fit_cv = dfa_cv(m, cv_method="loocv", n_folds = 5, iter=50, chains=1) +obs_covar <- expand.grid("time" = 1:20, "timeseries" = 1:3, "covariate" = 1:2) +obs_covar$value <- rnorm(nrow(obs_covar), 0, 0.1) +obs <- c(s$y_sim[1, ], s$y_sim[2, ], s$y_sim[3, ]) +m <- fit_dfa(y = long, iter = 50, chains = 1, obs_covar = obs_covar, data_shape = "long", sample = FALSE) +fit_cv <- dfa_cv(m, cv_method = "loocv", n_folds = 5, iter = 50, chains = 1) } } diff --git a/man/find_dfa_trends.Rd b/man/find_dfa_trends.Rd index 0f18bfb..d7d88e0 100644 --- a/man/find_dfa_trends.Rd +++ b/man/find_dfa_trends.Rd @@ -51,7 +51,8 @@ m <- find_dfa_trends( y = s$y_sim, iter = 50, kmin = 1, kmax = 2, chains = 1, compare_normal = FALSE, variance = "equal", convergence_threshold = 1.1, - control = list(adapt_delta = 0.95, max_treedepth = 20)) + control = list(adapt_delta = 0.95, max_treedepth = 20) +) m$summary m$best_model } diff --git a/man/find_swans.Rd b/man/find_swans.Rd index 5fa65df..5b8fa1e 100644 --- a/man/find_swans.Rd +++ b/man/find_swans.Rd @@ -26,7 +26,7 @@ Find outlying "black swan" jumps in trends set.seed(1) s <- sim_dfa(num_trends = 1, num_ts = 3, num_years = 30) s$y_sim[1, 15] <- s$y_sim[1, 15] - 6 -plot(s$y_sim[1,], type = "o") +plot(s$y_sim[1, ], type = "o") abline(v = 15, col = "red") # only 1 chain and 250 iterations used so example runs quickly: m <- fit_dfa(y = s$y_sim, num_trends = 1, iter = 50, chains = 1, nu_fixed = 2) @@ -35,7 +35,6 @@ p <- plot_trends(r) #+ geom_vline(xintercept = 15, colour = "red") print(p) # a 1 in 1000 probability if was from a normal distribution: find_swans(r, plot = TRUE, threshold = 0.001) - } \references{ Anderson, S.C., Branch, T.A., Cooper, A.B., and Dulvy, N.K. 2017. diff --git a/man/fit_dfa.Rd b/man/fit_dfa.Rd index 2d17222..a652f38 100644 --- a/man/fit_dfa.Rd +++ b/man/fit_dfa.Rd @@ -33,6 +33,7 @@ fit_dfa( family = "gaussian", verbose = FALSE, gp_theta_prior = c(3, 1), + expansion_prior = FALSE, ... ) } @@ -137,6 +138,8 @@ gaussian family is assumed to be identity, and the rest are log-link.} This prior is a half-Student t prior, with the first argument of gp_theta_prior being the degrees of freedom (nu), and the second element being the standard deviation} +\item{expansion_prior}{Defaults to FALSE, if TRUE uses the parameter expansion prior of Ghosh & Dunson 2009} + \item{...}{Any other arguments to pass to \code{\link[rstan:stanmodel-method-sampling]{rstan::sampling()}}.} } \description{ @@ -156,46 +159,46 @@ m <- fit_dfa(y = s$y_sim, iter = 50, chains = 1) \dontrun{ # example of observation error covariates set.seed(42) -obs_covar = expand.grid("time"=1:20,"timeseries"=1:3,"covariate"=1) -obs_covar$value=rnorm(nrow(obs_covar),0,0.1) -m <- fit_dfa(y = s$y_sim, iter = 50, chains = 1, obs_covar=obs_covar) +obs_covar <- expand.grid("time" = 1:20, "timeseries" = 1:3, "covariate" = 1) +obs_covar$value <- rnorm(nrow(obs_covar), 0, 0.1) +m <- fit_dfa(y = s$y_sim, iter = 50, chains = 1, obs_covar = obs_covar) # example of process error covariates -pro_covar = expand.grid("time"=1:20,"trend"=1:2,"covariate"=1) -pro_covar$value=rnorm(nrow(pro_covar),0,0.1) -m <- fit_dfa(y = s$y_sim, iter = 50, chains = 1, num_trends = 2, pro_covar=pro_covar) +pro_covar <- expand.grid("time" = 1:20, "trend" = 1:2, "covariate" = 1) +pro_covar$value <- rnorm(nrow(pro_covar), 0, 0.1) +m <- fit_dfa(y = s$y_sim, iter = 50, chains = 1, num_trends = 2, pro_covar = pro_covar) # example of long format data s <- sim_dfa(num_trends = 1, num_years = 20, num_ts = 3) -obs <- c(s$y_sim[1,], s$y_sim[2,], s$y_sim[3,]) -long = data.frame("obs" = obs, "ts" = sort(rep(1:3,20)), "time" = rep(1:20,3)) -m = fit_dfa(y = long, data_shape = "long", iter = 50, chains = 1) +obs <- c(s$y_sim[1, ], s$y_sim[2, ], s$y_sim[3, ]) +long <- data.frame("obs" = obs, "ts" = sort(rep(1:3, 20)), "time" = rep(1:20, 3)) +m <- fit_dfa(y = long, data_shape = "long", iter = 50, chains = 1) # example of long format data with obs covariates s <- sim_dfa(num_trends = 1, num_years = 20, num_ts = 3) -obs <- c(s$y_sim[1,], s$y_sim[2,], s$y_sim[3,]) -long = data.frame("obs" = obs, "ts" = sort(rep(1:3,20)), "time" = rep(1:20,3)) -obs_covar = expand.grid("time"=1:20,"timeseries"=1:3,"covariate"=1:2) -obs_covar$value=rnorm(nrow(obs_covar),0,0.1) -m = fit_dfa(y = long, data_shape = "long", iter = 50, chains = 1,obs_covar=obs_covar) +obs <- c(s$y_sim[1, ], s$y_sim[2, ], s$y_sim[3, ]) +long <- data.frame("obs" = obs, "ts" = sort(rep(1:3, 20)), "time" = rep(1:20, 3)) +obs_covar <- expand.grid("time" = 1:20, "timeseries" = 1:3, "covariate" = 1:2) +obs_covar$value <- rnorm(nrow(obs_covar), 0, 0.1) +m <- fit_dfa(y = long, data_shape = "long", iter = 50, chains = 1, obs_covar = obs_covar) # example of model with Z constrained to be proportions and wide format data s <- sim_dfa(num_trends = 1, num_years = 20, num_ts = 3) -m = fit_dfa(y = s$y_sim, z_model = "proportion", iter = 50, chains = 1) +m <- fit_dfa(y = s$y_sim, z_model = "proportion", iter = 50, chains = 1) # example of model with Z constrained to be proportions and long format data s <- sim_dfa(num_trends = 1, num_years = 20, num_ts = 3) -obs <- c(s$y_sim[1,], s$y_sim[2,], s$y_sim[3,]) -long = data.frame("obs" = obs, "ts" = sort(rep(1:3,20)), "time" = rep(1:20,3)) -m = fit_dfa(y = long, data_shape = "long", z_model = "proportion", iter = 50, chains = 1) +obs <- c(s$y_sim[1, ], s$y_sim[2, ], s$y_sim[3, ]) +long <- data.frame("obs" = obs, "ts" = sort(rep(1:3, 20)), "time" = rep(1:20, 3)) +m <- fit_dfa(y = long, data_shape = "long", z_model = "proportion", iter = 50, chains = 1) #' # example of B-spline model with wide format data s <- sim_dfa(num_trends = 1, num_years = 20, num_ts = 3) -m = fit_dfa(y = s$y_sim, iter = 50, chains = 1, trend_model = "spline", n_knots = 10) +m <- fit_dfa(y = s$y_sim, iter = 50, chains = 1, trend_model = "spline", n_knots = 10) # example of B-spline model with wide format data s <- sim_dfa(num_trends = 1, num_years = 20, num_ts = 3) -m = fit_dfa(y = s$y_sim, iter = 50, chains = 1, trend_model = "gp", n_knots = 5) +m <- fit_dfa(y = s$y_sim, iter = 50, chains = 1, trend_model = "gp", n_knots = 5) } } \seealso{ diff --git a/man/plot_regime_model.Rd b/man/plot_regime_model.Rd index bf13eb2..b657ecf 100644 --- a/man/plot_regime_model.Rd +++ b/man/plot_regime_model.Rd @@ -41,7 +41,8 @@ between 0 and 1. data(Nile) m <- fit_regimes(log(Nile), n_regimes = 2, chains = 1, iter = 50) plot_regime_model(m) -plot_regime_model(m, plot_prob_indices=c(2)) +plot_regime_model(m, plot_prob_indices = c(2)) plot_regime_model(m, type = "means") } + } diff --git a/man/predicted.Rd b/man/predicted.Rd index 760e91d..a09b654 100644 --- a/man/predicted.Rd +++ b/man/predicted.Rd @@ -19,7 +19,7 @@ number of MCMC draws x number of MCMC chains x time series length x number of ti set.seed(42) s <- sim_dfa(num_trends = 1, num_years = 20, num_ts = 3) # only 1 chain and 1000 iterations used so example runs quickly: -m <- fit_dfa(y = s$y_sim, iter = 2000, chains = 3, num_trends=1) +m <- fit_dfa(y = s$y_sim, iter = 2000, chains = 3, num_trends = 1) pred <- predicted(m) } } diff --git a/man/sim_dfa.Rd b/man/sim_dfa.Rd index 6ba1c22..321cf64 100644 --- a/man/sim_dfa.Rd +++ b/man/sim_dfa.Rd @@ -69,12 +69,15 @@ matplot(t(x$x), type = "l") set.seed(42) x <- sim_dfa(extreme_value = -4, extreme_loc = 10) -matplot(t(x$x), type = "l");abline(v = 10) -matplot(t(x$pred), type = "l");abline(v = 10) +matplot(t(x$x), type = "l") +abline(v = 10) +matplot(t(x$pred), type = "l") +abline(v = 10) set.seed(42) x <- sim_dfa() -matplot(t(x$x), type = "l");abline(v = 10) -matplot(t(x$pred), type = "l");abline(v = 10) - +matplot(t(x$x), type = "l") +abline(v = 10) +matplot(t(x$pred), type = "l") +abline(v = 10) } diff --git a/man/trend_cor.Rd b/man/trend_cor.Rd index b37d13d..e3de137 100644 --- a/man/trend_cor.Rd +++ b/man/trend_cor.Rd @@ -61,11 +61,13 @@ set.seed(1) s <- sim_dfa(num_trends = 1, num_years = 15) m <- fit_dfa(y = s$y_sim, num_trends = 1, iter = 50, chains = 1) r <- rotate_trends(m) -n_years <- ncol(r$trends[,1,]) +n_years <- ncol(r$trends[, 1, ]) fake_dat <- rnorm(n_years, 0, 1) correlation <- trend_cor(r, fake_dat, trend_samples = 25) hist(correlation) -correlation <- trend_cor(r, y = fake_dat, time_window = 5:15, - trend_samples = 25) +correlation <- trend_cor(r, + y = fake_dat, time_window = 5:15, + trend_samples = 25 +) hist(correlation) } diff --git a/src/stanExports_dfa.h b/src/stanExports_dfa.h index 36bc1a3..e5efdf4 100644 --- a/src/stanExports_dfa.h +++ b/src/stanExports_dfa.h @@ -33,7 +33,7 @@ static int current_statement_begin__; stan::io::program_reader prog_reader__() { stan::io::program_reader reader; reader.add_event(0, 0, "start", "model_dfa"); - reader.add_event(661, 659, "end", "model_dfa"); + reader.add_event(678, 676, "end", "model_dfa"); return reader; } template @@ -275,6 +275,7 @@ class model_dfa int est_sigma_params; int est_gamma_params; int est_nb2_params; + int use_expansion_prior; std::vector gp_theta_prior; int n_pcor; int n_loglik; @@ -283,6 +284,7 @@ class model_dfa vector_d alpha_vec; vector_d muZeros; double gp_delta; + double lower_bound_z; public: model_dfa(stan::io::var_context& context__, std::ostream* pstream__ = 0) @@ -777,6 +779,14 @@ class model_dfa check_greater_or_equal(function__, "est_nb2_params", est_nb2_params, 0); check_less_or_equal(function__, "est_nb2_params", est_nb2_params, 1); current_statement_begin__ = 121; + context__.validate_dims("data initialization", "use_expansion_prior", "int", context__.to_vec()); + use_expansion_prior = int(0); + vals_i__ = context__.vals_i("use_expansion_prior"); + pos__ = 0; + use_expansion_prior = vals_i__[pos__++]; + check_greater_or_equal(function__, "use_expansion_prior", use_expansion_prior, 0); + check_less_or_equal(function__, "use_expansion_prior", use_expansion_prior, 1); + current_statement_begin__ = 122; validate_non_negative_index("gp_theta_prior", "2", 2); context__.validate_dims("data initialization", "gp_theta_prior", "double", context__.to_vec(2)); gp_theta_prior = std::vector(2, double(0)); @@ -787,162 +797,172 @@ class model_dfa gp_theta_prior[k_0__] = vals_r__[pos__++]; } // initialize transformed data variables - current_statement_begin__ = 124; + current_statement_begin__ = 125; n_pcor = int(0); stan::math::fill(n_pcor, std::numeric_limits::min()); - current_statement_begin__ = 125; + current_statement_begin__ = 126; n_loglik = int(0); stan::math::fill(n_loglik, std::numeric_limits::min()); - current_statement_begin__ = 126; + current_statement_begin__ = 127; validate_non_negative_index("zeros", "K", K); zeros = Eigen::Matrix(K); stan::math::fill(zeros, DUMMY_VAR__); - current_statement_begin__ = 127; + current_statement_begin__ = 128; validate_non_negative_index("data_locs", "N", N); data_locs = std::vector(N, double(0)); stan::math::fill(data_locs, DUMMY_VAR__); - current_statement_begin__ = 128; + current_statement_begin__ = 129; validate_non_negative_index("alpha_vec", "(K * proportional_model)", (K * proportional_model)); alpha_vec = Eigen::Matrix((K * proportional_model)); stan::math::fill(alpha_vec, DUMMY_VAR__); - current_statement_begin__ = 129; + current_statement_begin__ = 130; validate_non_negative_index("muZeros", "n_knots", n_knots); muZeros = Eigen::Matrix(n_knots); stan::math::fill(muZeros, DUMMY_VAR__); - current_statement_begin__ = 130; + current_statement_begin__ = 131; gp_delta = double(0); stan::math::fill(gp_delta, DUMMY_VAR__); stan::math::assign(gp_delta,1e-9); - // execute transformed data statements current_statement_begin__ = 132; + lower_bound_z = double(0); + stan::math::fill(lower_bound_z, DUMMY_VAR__); + // execute transformed data statements + current_statement_begin__ = 134; for (int i = 1; i <= N; ++i) { - current_statement_begin__ = 133; + current_statement_begin__ = 135; stan::model::assign(data_locs, stan::model::cons_list(stan::model::index_uni(i), stan::model::nil_index_list()), i, "assigning variable data_locs"); } - current_statement_begin__ = 135; + current_statement_begin__ = 137; for (int k = 1; k <= K; ++k) { - current_statement_begin__ = 136; + current_statement_begin__ = 138; stan::model::assign(zeros, stan::model::cons_list(stan::model::index_uni(k), stan::model::nil_index_list()), 0, "assigning variable zeros"); } - current_statement_begin__ = 138; + current_statement_begin__ = 140; for (int k = 1; k <= n_knots; ++k) { - current_statement_begin__ = 139; + current_statement_begin__ = 141; stan::model::assign(muZeros, stan::model::cons_list(stan::model::index_uni(k), stan::model::nil_index_list()), 0, "assigning variable muZeros"); } - current_statement_begin__ = 143; + current_statement_begin__ = 145; stan::math::assign(n_loglik, n_pos); - current_statement_begin__ = 144; + current_statement_begin__ = 146; if (as_bool(logical_eq(long_format, 0))) { - current_statement_begin__ = 145; + current_statement_begin__ = 147; if (as_bool(logical_eq(est_cor, 0))) { - current_statement_begin__ = 146; + current_statement_begin__ = 148; stan::math::assign(n_loglik, (P * N)); } else { - current_statement_begin__ = 148; + current_statement_begin__ = 150; stan::math::assign(n_loglik, N); } } - current_statement_begin__ = 152; + current_statement_begin__ = 154; if (as_bool(logical_eq(est_cor, 0))) { - current_statement_begin__ = 154; + current_statement_begin__ = 156; stan::math::assign(n_pcor, P); - current_statement_begin__ = 155; + current_statement_begin__ = 157; if (as_bool(logical_lt(nVariances, 2))) { - current_statement_begin__ = 157; + current_statement_begin__ = 159; stan::math::assign(n_pcor, 2); } } else { - current_statement_begin__ = 161; + current_statement_begin__ = 163; stan::math::assign(n_pcor, P); } - current_statement_begin__ = 165; + current_statement_begin__ = 167; if (as_bool(logical_eq(proportional_model, 1))) { - current_statement_begin__ = 166; + current_statement_begin__ = 168; for (int k = 1; k <= K; ++k) { - current_statement_begin__ = 166; + current_statement_begin__ = 168; stan::model::assign(alpha_vec, stan::model::cons_list(stan::model::index_uni(k), stan::model::nil_index_list()), 1, "assigning variable alpha_vec"); } } + current_statement_begin__ = 172; + stan::math::assign(lower_bound_z, -(100)); + current_statement_begin__ = 173; + if (as_bool(logical_eq(use_expansion_prior, 1))) { + current_statement_begin__ = 173; + stan::math::assign(lower_bound_z, 0); + } // validate transformed data // validate, set parameter ranges num_params_r__ = 0U; param_ranges_i__.clear(); - current_statement_begin__ = 170; + current_statement_begin__ = 176; validate_non_negative_index("devs", "(K * est_rw)", (K * est_rw)); validate_non_negative_index("devs", "((N - 1) * est_rw)", ((N - 1) * est_rw)); num_params_r__ += ((K * est_rw) * ((N - 1) * est_rw)); - current_statement_begin__ = 171; + current_statement_begin__ = 177; validate_non_negative_index("x0", "K", K); num_params_r__ += K; - current_statement_begin__ = 172; - validate_non_negative_index("psi", "(K * (1 - proportional_model))", (K * (1 - proportional_model))); - num_params_r__ += (K * (1 - proportional_model)); - current_statement_begin__ = 173; + current_statement_begin__ = 178; + validate_non_negative_index("psi", "((K * (1 - proportional_model)) * use_expansion_prior)", ((K * (1 - proportional_model)) * use_expansion_prior)); + num_params_r__ += ((K * (1 - proportional_model)) * use_expansion_prior); + current_statement_begin__ = 179; validate_non_negative_index("z", "(nZ * (1 - proportional_model))", (nZ * (1 - proportional_model))); num_params_r__ += (nZ * (1 - proportional_model)); - current_statement_begin__ = 174; + current_statement_begin__ = 180; validate_non_negative_index("zpos", "(K * (1 - proportional_model))", (K * (1 - proportional_model))); num_params_r__ += (K * (1 - proportional_model)); - current_statement_begin__ = 175; + current_statement_begin__ = 181; validate_non_negative_index("p_z", "K", K); validate_non_negative_index("p_z", "(P * proportional_model)", (P * proportional_model)); num_params_r__ += ((K - 1) * (P * proportional_model)); - current_statement_begin__ = 176; + current_statement_begin__ = 182; validate_non_negative_index("spline_a", "(K * est_spline)", (K * est_spline)); validate_non_negative_index("spline_a", "(n_knots * est_spline)", (n_knots * est_spline)); num_params_r__ += ((K * est_spline) * (n_knots * est_spline)); - current_statement_begin__ = 177; + current_statement_begin__ = 183; validate_non_negative_index("b_obs", "n_obs_covar", n_obs_covar); validate_non_negative_index("b_obs", "P", P); num_params_r__ += (n_obs_covar * P); - current_statement_begin__ = 178; + current_statement_begin__ = 184; validate_non_negative_index("b_pro", "n_pro_covar", n_pro_covar); validate_non_negative_index("b_pro", "K", K); num_params_r__ += (n_pro_covar * K); - current_statement_begin__ = 179; + current_statement_begin__ = 185; validate_non_negative_index("sigma", "(nVariances * est_sigma_params)", (nVariances * est_sigma_params)); num_params_r__ += (1 * (nVariances * est_sigma_params)); - current_statement_begin__ = 180; + current_statement_begin__ = 186; validate_non_negative_index("gamma_a", "(nVariances * est_gamma_params)", (nVariances * est_gamma_params)); num_params_r__ += (1 * (nVariances * est_gamma_params)); - current_statement_begin__ = 181; + current_statement_begin__ = 187; validate_non_negative_index("nb2_phi", "(nVariances * est_nb2_params)", (nVariances * est_nb2_params)); num_params_r__ += (1 * (nVariances * est_nb2_params)); - current_statement_begin__ = 182; + current_statement_begin__ = 188; validate_non_negative_index("nu", "estimate_nu", estimate_nu); num_params_r__ += (1 * estimate_nu); - current_statement_begin__ = 183; + current_statement_begin__ = 189; validate_non_negative_index("ymiss", "n_na", n_na); num_params_r__ += (1 * n_na); - current_statement_begin__ = 184; + current_statement_begin__ = 190; validate_non_negative_index("phi", "(est_phi * K)", (est_phi * K)); num_params_r__ += (1 * (est_phi * K)); - current_statement_begin__ = 185; + current_statement_begin__ = 191; validate_non_negative_index("theta", "(est_theta * K)", (est_theta * K)); num_params_r__ += (1 * (est_theta * K)); - current_statement_begin__ = 186; + current_statement_begin__ = 192; validate_non_negative_index("gp_theta", "(est_gp * K)", (est_gp * K)); num_params_r__ += (1 * (est_gp * K)); - current_statement_begin__ = 187; + current_statement_begin__ = 193; validate_non_negative_index("Lcorr", "n_pcor", n_pcor); validate_non_negative_index("Lcorr", "n_pcor", n_pcor); num_params_r__ += ((n_pcor * (n_pcor - 1)) / 2); - current_statement_begin__ = 188; + current_statement_begin__ = 194; validate_non_negative_index("sigma_process", "(est_sigma_process * n_sigma_process)", (est_sigma_process * n_sigma_process)); num_params_r__ += (1 * (est_sigma_process * n_sigma_process)); - current_statement_begin__ = 189; + current_statement_begin__ = 195; validate_non_negative_index("effectsKnots", "(n_knots * est_gp)", (n_knots * est_gp)); validate_non_negative_index("effectsKnots", "(K * est_gp)", (K * est_gp)); num_params_r__ += ((n_knots * est_gp) * (K * est_gp)); @@ -963,7 +983,7 @@ class model_dfa (void) pos__; // dummy call to supress warning std::vector vals_r__; std::vector vals_i__; - current_statement_begin__ = 170; + current_statement_begin__ = 176; if (!(context__.contains_r("devs"))) stan::lang::rethrow_located(std::runtime_error(std::string("Variable devs missing")), current_statement_begin__, prog_reader__()); vals_r__ = context__.vals_r("devs"); @@ -984,7 +1004,7 @@ class model_dfa } catch (const std::exception& e) { stan::lang::rethrow_located(std::runtime_error(std::string("Error transforming variable devs: ") + e.what()), current_statement_begin__, prog_reader__()); } - current_statement_begin__ = 171; + current_statement_begin__ = 177; if (!(context__.contains_r("x0"))) stan::lang::rethrow_located(std::runtime_error(std::string("Variable x0 missing")), current_statement_begin__, prog_reader__()); vals_r__ = context__.vals_r("x0"); @@ -1001,15 +1021,15 @@ class model_dfa } catch (const std::exception& e) { stan::lang::rethrow_located(std::runtime_error(std::string("Error transforming variable x0: ") + e.what()), current_statement_begin__, prog_reader__()); } - current_statement_begin__ = 172; + current_statement_begin__ = 178; if (!(context__.contains_r("psi"))) stan::lang::rethrow_located(std::runtime_error(std::string("Variable psi missing")), current_statement_begin__, prog_reader__()); vals_r__ = context__.vals_r("psi"); pos__ = 0U; - validate_non_negative_index("psi", "(K * (1 - proportional_model))", (K * (1 - proportional_model))); - context__.validate_dims("parameter initialization", "psi", "vector_d", context__.to_vec((K * (1 - proportional_model)))); - Eigen::Matrix psi((K * (1 - proportional_model))); - size_t psi_j_1_max__ = (K * (1 - proportional_model)); + validate_non_negative_index("psi", "((K * (1 - proportional_model)) * use_expansion_prior)", ((K * (1 - proportional_model)) * use_expansion_prior)); + context__.validate_dims("parameter initialization", "psi", "vector_d", context__.to_vec(((K * (1 - proportional_model)) * use_expansion_prior))); + Eigen::Matrix psi(((K * (1 - proportional_model)) * use_expansion_prior)); + size_t psi_j_1_max__ = ((K * (1 - proportional_model)) * use_expansion_prior); for (size_t j_1__ = 0; j_1__ < psi_j_1_max__; ++j_1__) { psi(j_1__) = vals_r__[pos__++]; } @@ -1018,7 +1038,7 @@ class model_dfa } catch (const std::exception& e) { stan::lang::rethrow_located(std::runtime_error(std::string("Error transforming variable psi: ") + e.what()), current_statement_begin__, prog_reader__()); } - current_statement_begin__ = 173; + current_statement_begin__ = 179; if (!(context__.contains_r("z"))) stan::lang::rethrow_located(std::runtime_error(std::string("Variable z missing")), current_statement_begin__, prog_reader__()); vals_r__ = context__.vals_r("z"); @@ -1035,7 +1055,7 @@ class model_dfa } catch (const std::exception& e) { stan::lang::rethrow_located(std::runtime_error(std::string("Error transforming variable z: ") + e.what()), current_statement_begin__, prog_reader__()); } - current_statement_begin__ = 174; + current_statement_begin__ = 180; if (!(context__.contains_r("zpos"))) stan::lang::rethrow_located(std::runtime_error(std::string("Variable zpos missing")), current_statement_begin__, prog_reader__()); vals_r__ = context__.vals_r("zpos"); @@ -1048,11 +1068,11 @@ class model_dfa zpos(j_1__) = vals_r__[pos__++]; } try { - writer__.vector_lb_unconstrain(0, zpos); + writer__.vector_lb_unconstrain(lower_bound_z, zpos); } catch (const std::exception& e) { stan::lang::rethrow_located(std::runtime_error(std::string("Error transforming variable zpos: ") + e.what()), current_statement_begin__, prog_reader__()); } - current_statement_begin__ = 175; + current_statement_begin__ = 181; if (!(context__.contains_r("p_z"))) stan::lang::rethrow_located(std::runtime_error(std::string("Variable p_z missing")), current_statement_begin__, prog_reader__()); vals_r__ = context__.vals_r("p_z"); @@ -1076,7 +1096,7 @@ class model_dfa stan::lang::rethrow_located(std::runtime_error(std::string("Error transforming variable p_z: ") + e.what()), current_statement_begin__, prog_reader__()); } } - current_statement_begin__ = 176; + current_statement_begin__ = 182; if (!(context__.contains_r("spline_a"))) stan::lang::rethrow_located(std::runtime_error(std::string("Variable spline_a missing")), current_statement_begin__, prog_reader__()); vals_r__ = context__.vals_r("spline_a"); @@ -1097,7 +1117,7 @@ class model_dfa } catch (const std::exception& e) { stan::lang::rethrow_located(std::runtime_error(std::string("Error transforming variable spline_a: ") + e.what()), current_statement_begin__, prog_reader__()); } - current_statement_begin__ = 177; + current_statement_begin__ = 183; if (!(context__.contains_r("b_obs"))) stan::lang::rethrow_located(std::runtime_error(std::string("Variable b_obs missing")), current_statement_begin__, prog_reader__()); vals_r__ = context__.vals_r("b_obs"); @@ -1118,7 +1138,7 @@ class model_dfa } catch (const std::exception& e) { stan::lang::rethrow_located(std::runtime_error(std::string("Error transforming variable b_obs: ") + e.what()), current_statement_begin__, prog_reader__()); } - current_statement_begin__ = 178; + current_statement_begin__ = 184; if (!(context__.contains_r("b_pro"))) stan::lang::rethrow_located(std::runtime_error(std::string("Variable b_pro missing")), current_statement_begin__, prog_reader__()); vals_r__ = context__.vals_r("b_pro"); @@ -1139,7 +1159,7 @@ class model_dfa } catch (const std::exception& e) { stan::lang::rethrow_located(std::runtime_error(std::string("Error transforming variable b_pro: ") + e.what()), current_statement_begin__, prog_reader__()); } - current_statement_begin__ = 179; + current_statement_begin__ = 185; if (!(context__.contains_r("sigma"))) stan::lang::rethrow_located(std::runtime_error(std::string("Variable sigma missing")), current_statement_begin__, prog_reader__()); vals_r__ = context__.vals_r("sigma"); @@ -1159,7 +1179,7 @@ class model_dfa stan::lang::rethrow_located(std::runtime_error(std::string("Error transforming variable sigma: ") + e.what()), current_statement_begin__, prog_reader__()); } } - current_statement_begin__ = 180; + current_statement_begin__ = 186; if (!(context__.contains_r("gamma_a"))) stan::lang::rethrow_located(std::runtime_error(std::string("Variable gamma_a missing")), current_statement_begin__, prog_reader__()); vals_r__ = context__.vals_r("gamma_a"); @@ -1179,7 +1199,7 @@ class model_dfa stan::lang::rethrow_located(std::runtime_error(std::string("Error transforming variable gamma_a: ") + e.what()), current_statement_begin__, prog_reader__()); } } - current_statement_begin__ = 181; + current_statement_begin__ = 187; if (!(context__.contains_r("nb2_phi"))) stan::lang::rethrow_located(std::runtime_error(std::string("Variable nb2_phi missing")), current_statement_begin__, prog_reader__()); vals_r__ = context__.vals_r("nb2_phi"); @@ -1199,7 +1219,7 @@ class model_dfa stan::lang::rethrow_located(std::runtime_error(std::string("Error transforming variable nb2_phi: ") + e.what()), current_statement_begin__, prog_reader__()); } } - current_statement_begin__ = 182; + current_statement_begin__ = 188; if (!(context__.contains_r("nu"))) stan::lang::rethrow_located(std::runtime_error(std::string("Variable nu missing")), current_statement_begin__, prog_reader__()); vals_r__ = context__.vals_r("nu"); @@ -1219,7 +1239,7 @@ class model_dfa stan::lang::rethrow_located(std::runtime_error(std::string("Error transforming variable nu: ") + e.what()), current_statement_begin__, prog_reader__()); } } - current_statement_begin__ = 183; + current_statement_begin__ = 189; if (!(context__.contains_r("ymiss"))) stan::lang::rethrow_located(std::runtime_error(std::string("Variable ymiss missing")), current_statement_begin__, prog_reader__()); vals_r__ = context__.vals_r("ymiss"); @@ -1239,7 +1259,7 @@ class model_dfa stan::lang::rethrow_located(std::runtime_error(std::string("Error transforming variable ymiss: ") + e.what()), current_statement_begin__, prog_reader__()); } } - current_statement_begin__ = 184; + current_statement_begin__ = 190; if (!(context__.contains_r("phi"))) stan::lang::rethrow_located(std::runtime_error(std::string("Variable phi missing")), current_statement_begin__, prog_reader__()); vals_r__ = context__.vals_r("phi"); @@ -1259,7 +1279,7 @@ class model_dfa stan::lang::rethrow_located(std::runtime_error(std::string("Error transforming variable phi: ") + e.what()), current_statement_begin__, prog_reader__()); } } - current_statement_begin__ = 185; + current_statement_begin__ = 191; if (!(context__.contains_r("theta"))) stan::lang::rethrow_located(std::runtime_error(std::string("Variable theta missing")), current_statement_begin__, prog_reader__()); vals_r__ = context__.vals_r("theta"); @@ -1279,7 +1299,7 @@ class model_dfa stan::lang::rethrow_located(std::runtime_error(std::string("Error transforming variable theta: ") + e.what()), current_statement_begin__, prog_reader__()); } } - current_statement_begin__ = 186; + current_statement_begin__ = 192; if (!(context__.contains_r("gp_theta"))) stan::lang::rethrow_located(std::runtime_error(std::string("Variable gp_theta missing")), current_statement_begin__, prog_reader__()); vals_r__ = context__.vals_r("gp_theta"); @@ -1299,7 +1319,7 @@ class model_dfa stan::lang::rethrow_located(std::runtime_error(std::string("Error transforming variable gp_theta: ") + e.what()), current_statement_begin__, prog_reader__()); } } - current_statement_begin__ = 187; + current_statement_begin__ = 193; if (!(context__.contains_r("Lcorr"))) stan::lang::rethrow_located(std::runtime_error(std::string("Variable Lcorr missing")), current_statement_begin__, prog_reader__()); vals_r__ = context__.vals_r("Lcorr"); @@ -1320,7 +1340,7 @@ class model_dfa } catch (const std::exception& e) { stan::lang::rethrow_located(std::runtime_error(std::string("Error transforming variable Lcorr: ") + e.what()), current_statement_begin__, prog_reader__()); } - current_statement_begin__ = 188; + current_statement_begin__ = 194; if (!(context__.contains_r("sigma_process"))) stan::lang::rethrow_located(std::runtime_error(std::string("Variable sigma_process missing")), current_statement_begin__, prog_reader__()); vals_r__ = context__.vals_r("sigma_process"); @@ -1340,7 +1360,7 @@ class model_dfa stan::lang::rethrow_located(std::runtime_error(std::string("Error transforming variable sigma_process: ") + e.what()), current_statement_begin__, prog_reader__()); } } - current_statement_begin__ = 189; + current_statement_begin__ = 195; if (!(context__.contains_r("effectsKnots"))) stan::lang::rethrow_located(std::runtime_error(std::string("Variable effectsKnots missing")), current_statement_begin__, prog_reader__()); vals_r__ = context__.vals_r("effectsKnots"); @@ -1389,42 +1409,42 @@ class model_dfa try { stan::io::reader in__(params_r__, params_i__); // model parameters - current_statement_begin__ = 170; + current_statement_begin__ = 176; Eigen::Matrix devs; (void) devs; // dummy to suppress unused var warning if (jacobian__) devs = in__.matrix_constrain((K * est_rw), ((N - 1) * est_rw), lp__); else devs = in__.matrix_constrain((K * est_rw), ((N - 1) * est_rw)); - current_statement_begin__ = 171; + current_statement_begin__ = 177; Eigen::Matrix x0; (void) x0; // dummy to suppress unused var warning if (jacobian__) x0 = in__.vector_constrain(K, lp__); else x0 = in__.vector_constrain(K); - current_statement_begin__ = 172; + current_statement_begin__ = 178; Eigen::Matrix psi; (void) psi; // dummy to suppress unused var warning if (jacobian__) - psi = in__.vector_lb_constrain(0, (K * (1 - proportional_model)), lp__); + psi = in__.vector_lb_constrain(0, ((K * (1 - proportional_model)) * use_expansion_prior), lp__); else - psi = in__.vector_lb_constrain(0, (K * (1 - proportional_model))); - current_statement_begin__ = 173; + psi = in__.vector_lb_constrain(0, ((K * (1 - proportional_model)) * use_expansion_prior)); + current_statement_begin__ = 179; Eigen::Matrix z; (void) z; // dummy to suppress unused var warning if (jacobian__) z = in__.vector_lub_constrain(get_base1(z_bound, 1, "z_bound", 1), get_base1(z_bound, 2, "z_bound", 1), (nZ * (1 - proportional_model)), lp__); else z = in__.vector_lub_constrain(get_base1(z_bound, 1, "z_bound", 1), get_base1(z_bound, 2, "z_bound", 1), (nZ * (1 - proportional_model))); - current_statement_begin__ = 174; + current_statement_begin__ = 180; Eigen::Matrix zpos; (void) zpos; // dummy to suppress unused var warning if (jacobian__) - zpos = in__.vector_lb_constrain(0, (K * (1 - proportional_model)), lp__); + zpos = in__.vector_lb_constrain(lower_bound_z, (K * (1 - proportional_model)), lp__); else - zpos = in__.vector_lb_constrain(0, (K * (1 - proportional_model))); - current_statement_begin__ = 175; + zpos = in__.vector_lb_constrain(lower_bound_z, (K * (1 - proportional_model))); + current_statement_begin__ = 181; std::vector > p_z; size_t p_z_d_0_max__ = (P * proportional_model); p_z.reserve(p_z_d_0_max__); @@ -1434,28 +1454,28 @@ class model_dfa else p_z.push_back(in__.simplex_constrain(K)); } - current_statement_begin__ = 176; + current_statement_begin__ = 182; Eigen::Matrix spline_a; (void) spline_a; // dummy to suppress unused var warning if (jacobian__) spline_a = in__.matrix_constrain((K * est_spline), (n_knots * est_spline), lp__); else spline_a = in__.matrix_constrain((K * est_spline), (n_knots * est_spline)); - current_statement_begin__ = 177; + current_statement_begin__ = 183; Eigen::Matrix b_obs; (void) b_obs; // dummy to suppress unused var warning if (jacobian__) b_obs = in__.matrix_constrain(n_obs_covar, P, lp__); else b_obs = in__.matrix_constrain(n_obs_covar, P); - current_statement_begin__ = 178; + current_statement_begin__ = 184; Eigen::Matrix b_pro; (void) b_pro; // dummy to suppress unused var warning if (jacobian__) b_pro = in__.matrix_constrain(n_pro_covar, K, lp__); else b_pro = in__.matrix_constrain(n_pro_covar, K); - current_statement_begin__ = 179; + current_statement_begin__ = 185; std::vector sigma; size_t sigma_d_0_max__ = (nVariances * est_sigma_params); sigma.reserve(sigma_d_0_max__); @@ -1465,7 +1485,7 @@ class model_dfa else sigma.push_back(in__.scalar_lb_constrain(0)); } - current_statement_begin__ = 180; + current_statement_begin__ = 186; std::vector gamma_a; size_t gamma_a_d_0_max__ = (nVariances * est_gamma_params); gamma_a.reserve(gamma_a_d_0_max__); @@ -1475,7 +1495,7 @@ class model_dfa else gamma_a.push_back(in__.scalar_lb_constrain(0)); } - current_statement_begin__ = 181; + current_statement_begin__ = 187; std::vector nb2_phi; size_t nb2_phi_d_0_max__ = (nVariances * est_nb2_params); nb2_phi.reserve(nb2_phi_d_0_max__); @@ -1485,7 +1505,7 @@ class model_dfa else nb2_phi.push_back(in__.scalar_lb_constrain(0)); } - current_statement_begin__ = 182; + current_statement_begin__ = 188; std::vector nu; size_t nu_d_0_max__ = estimate_nu; nu.reserve(nu_d_0_max__); @@ -1495,7 +1515,7 @@ class model_dfa else nu.push_back(in__.scalar_lb_constrain(2)); } - current_statement_begin__ = 183; + current_statement_begin__ = 189; std::vector ymiss; size_t ymiss_d_0_max__ = n_na; ymiss.reserve(ymiss_d_0_max__); @@ -1505,7 +1525,7 @@ class model_dfa else ymiss.push_back(in__.scalar_constrain()); } - current_statement_begin__ = 184; + current_statement_begin__ = 190; std::vector phi; size_t phi_d_0_max__ = (est_phi * K); phi.reserve(phi_d_0_max__); @@ -1515,7 +1535,7 @@ class model_dfa else phi.push_back(in__.scalar_lub_constrain(-(1), 1)); } - current_statement_begin__ = 185; + current_statement_begin__ = 191; std::vector theta; size_t theta_d_0_max__ = (est_theta * K); theta.reserve(theta_d_0_max__); @@ -1525,7 +1545,7 @@ class model_dfa else theta.push_back(in__.scalar_lub_constrain(-(1), 1)); } - current_statement_begin__ = 186; + current_statement_begin__ = 192; std::vector gp_theta; size_t gp_theta_d_0_max__ = (est_gp * K); gp_theta.reserve(gp_theta_d_0_max__); @@ -1535,14 +1555,14 @@ class model_dfa else gp_theta.push_back(in__.scalar_lb_constrain(0)); } - current_statement_begin__ = 187; + current_statement_begin__ = 193; Eigen::Matrix Lcorr; (void) Lcorr; // dummy to suppress unused var warning if (jacobian__) Lcorr = in__.cholesky_factor_corr_constrain(n_pcor, lp__); else Lcorr = in__.cholesky_factor_corr_constrain(n_pcor); - current_statement_begin__ = 188; + current_statement_begin__ = 194; std::vector sigma_process; size_t sigma_process_d_0_max__ = (est_sigma_process * n_sigma_process); sigma_process.reserve(sigma_process_d_0_max__); @@ -1552,7 +1572,7 @@ class model_dfa else sigma_process.push_back(in__.scalar_lb_constrain(0)); } - current_statement_begin__ = 189; + current_statement_begin__ = 195; std::vector > effectsKnots; size_t effectsKnots_d_0_max__ = (K * est_gp); effectsKnots.reserve(effectsKnots_d_0_max__); @@ -1563,152 +1583,152 @@ class model_dfa effectsKnots.push_back(in__.vector_constrain((n_knots * est_gp))); } // transformed parameters - current_statement_begin__ = 192; + current_statement_begin__ = 198; validate_non_negative_index("pred", "P", P); validate_non_negative_index("pred", "N", N); Eigen::Matrix pred(P, N); stan::math::initialize(pred, DUMMY_VAR__); stan::math::fill(pred, DUMMY_VAR__); - current_statement_begin__ = 193; + current_statement_begin__ = 199; validate_non_negative_index("Z", "P", P); validate_non_negative_index("Z", "K", K); Eigen::Matrix Z(P, K); stan::math::initialize(Z, DUMMY_VAR__); stan::math::fill(Z, DUMMY_VAR__); - current_statement_begin__ = 194; + current_statement_begin__ = 200; validate_non_negative_index("yall", "P", P); validate_non_negative_index("yall", "N", N); Eigen::Matrix yall(P, N); stan::math::initialize(yall, DUMMY_VAR__); stan::math::fill(yall, DUMMY_VAR__); - current_statement_begin__ = 195; + current_statement_begin__ = 201; validate_non_negative_index("sigma_vec", "(P * est_sigma_params)", (P * est_sigma_params)); Eigen::Matrix sigma_vec((P * est_sigma_params)); stan::math::initialize(sigma_vec, DUMMY_VAR__); stan::math::fill(sigma_vec, DUMMY_VAR__); - current_statement_begin__ = 196; + current_statement_begin__ = 202; validate_non_negative_index("gamma_a_vec", "(P * est_gamma_params)", (P * est_gamma_params)); Eigen::Matrix gamma_a_vec((P * est_gamma_params)); stan::math::initialize(gamma_a_vec, DUMMY_VAR__); stan::math::fill(gamma_a_vec, DUMMY_VAR__); - current_statement_begin__ = 197; + current_statement_begin__ = 203; validate_non_negative_index("nb_phi_vec", "(P * est_nb2_params)", (P * est_nb2_params)); Eigen::Matrix nb_phi_vec((P * est_nb2_params)); stan::math::initialize(nb_phi_vec, DUMMY_VAR__); stan::math::fill(nb_phi_vec, DUMMY_VAR__); - current_statement_begin__ = 198; + current_statement_begin__ = 204; validate_non_negative_index("phi_vec", "K", K); Eigen::Matrix phi_vec(K); stan::math::initialize(phi_vec, DUMMY_VAR__); stan::math::fill(phi_vec, DUMMY_VAR__); - current_statement_begin__ = 199; + current_statement_begin__ = 205; validate_non_negative_index("theta_vec", "K", K); Eigen::Matrix theta_vec(K); stan::math::initialize(theta_vec, DUMMY_VAR__); stan::math::fill(theta_vec, DUMMY_VAR__); - current_statement_begin__ = 200; + current_statement_begin__ = 206; validate_non_negative_index("x", "K", K); validate_non_negative_index("x", "N", N); Eigen::Matrix x(K, N); stan::math::initialize(x, DUMMY_VAR__); stan::math::fill(x, DUMMY_VAR__); - current_statement_begin__ = 201; + current_statement_begin__ = 207; validate_non_negative_index("indicator", "K", K); Eigen::Matrix indicator(K); stan::math::initialize(indicator, DUMMY_VAR__); stan::math::fill(indicator, DUMMY_VAR__); - current_statement_begin__ = 202; - validate_non_negative_index("psi_root", "K", K); - Eigen::Matrix psi_root(K); + current_statement_begin__ = 208; + validate_non_negative_index("psi_root", "(K * use_expansion_prior)", (K * use_expansion_prior)); + Eigen::Matrix psi_root((K * use_expansion_prior)); stan::math::initialize(psi_root, DUMMY_VAR__); stan::math::fill(psi_root, DUMMY_VAR__); - current_statement_begin__ = 203; + current_statement_begin__ = 209; validate_non_negative_index("Sigma_derived", "((n_pcor * long_format) * est_cor)", ((n_pcor * long_format) * est_cor)); validate_non_negative_index("Sigma_derived", "((n_pcor * long_format) * est_cor)", ((n_pcor * long_format) * est_cor)); Eigen::Matrix Sigma_derived(((n_pcor * long_format) * est_cor), ((n_pcor * long_format) * est_cor)); stan::math::initialize(Sigma_derived, DUMMY_VAR__); stan::math::fill(Sigma_derived, DUMMY_VAR__); - current_statement_begin__ = 204; + current_statement_begin__ = 210; validate_non_negative_index("Sigma_temp", "(((n_pcor - 1) * long_format) * est_cor)", (((n_pcor - 1) * long_format) * est_cor)); validate_non_negative_index("Sigma_temp", "(((n_pcor - 1) * long_format) * est_cor)", (((n_pcor - 1) * long_format) * est_cor)); Eigen::Matrix Sigma_temp((((n_pcor - 1) * long_format) * est_cor), (((n_pcor - 1) * long_format) * est_cor)); stan::math::initialize(Sigma_temp, DUMMY_VAR__); stan::math::fill(Sigma_temp, DUMMY_VAR__); - current_statement_begin__ = 205; + current_statement_begin__ = 211; validate_non_negative_index("sigma12_vec", "(n_pcor - 1)", (n_pcor - 1)); validate_non_negative_index("sigma12_vec", "1", 1); Eigen::Matrix sigma12_vec((n_pcor - 1), 1); stan::math::initialize(sigma12_vec, DUMMY_VAR__); stan::math::fill(sigma12_vec, DUMMY_VAR__); - current_statement_begin__ = 206; + current_statement_begin__ = 212; validate_non_negative_index("temp_sums", "((P * long_format) * est_cor)", ((P * long_format) * est_cor)); validate_non_negative_index("temp_sums", "((N * long_format) * est_cor)", ((N * long_format) * est_cor)); Eigen::Matrix temp_sums(((P * long_format) * est_cor), ((N * long_format) * est_cor)); stan::math::initialize(temp_sums, DUMMY_VAR__); stan::math::fill(temp_sums, DUMMY_VAR__); - current_statement_begin__ = 207; + current_statement_begin__ = 213; validate_non_negative_index("temp_counts", "((P * long_format) * est_cor)", ((P * long_format) * est_cor)); validate_non_negative_index("temp_counts", "((N * long_format) * est_cor)", ((N * long_format) * est_cor)); Eigen::Matrix temp_counts(((P * long_format) * est_cor), ((N * long_format) * est_cor)); stan::math::initialize(temp_counts, DUMMY_VAR__); stan::math::fill(temp_counts, DUMMY_VAR__); - current_statement_begin__ = 208; + current_statement_begin__ = 214; validate_non_negative_index("cond_sigma_vec", "((P * long_format) * est_cor)", ((P * long_format) * est_cor)); Eigen::Matrix cond_sigma_vec(((P * long_format) * est_cor)); stan::math::initialize(cond_sigma_vec, DUMMY_VAR__); stan::math::fill(cond_sigma_vec, DUMMY_VAR__); - current_statement_begin__ = 209; + current_statement_begin__ = 215; validate_non_negative_index("cond_mean_vec", "((P * long_format) * est_cor)", ((P * long_format) * est_cor)); Eigen::Matrix cond_mean_vec(((P * long_format) * est_cor)); stan::math::initialize(cond_mean_vec, DUMMY_VAR__); stan::math::fill(cond_mean_vec, DUMMY_VAR__); - current_statement_begin__ = 210; + current_statement_begin__ = 216; local_scalar_t__ sigma11; (void) sigma11; // dummy to suppress unused var warning stan::math::initialize(sigma11, DUMMY_VAR__); stan::math::fill(sigma11, DUMMY_VAR__); - current_statement_begin__ = 211; + current_statement_begin__ = 217; validate_non_negative_index("sigma_pro", "K", K); Eigen::Matrix sigma_pro(K); stan::math::initialize(sigma_pro, DUMMY_VAR__); stan::math::fill(sigma_pro, DUMMY_VAR__); - current_statement_begin__ = 212; + current_statement_begin__ = 218; validate_non_negative_index("spline_a_trans", "(K * est_spline)", (K * est_spline)); validate_non_negative_index("spline_a_trans", "(n_knots * est_spline)", (n_knots * est_spline)); Eigen::Matrix spline_a_trans((K * est_spline), (n_knots * est_spline)); stan::math::initialize(spline_a_trans, DUMMY_VAR__); stan::math::fill(spline_a_trans, DUMMY_VAR__); - current_statement_begin__ = 213; + current_statement_begin__ = 219; validate_non_negative_index("SigmaKnots", "n_knots", n_knots); validate_non_negative_index("SigmaKnots", "n_knots", n_knots); validate_non_negative_index("SigmaKnots", "K", K); std::vector > SigmaKnots(K, Eigen::Matrix(n_knots, n_knots)); stan::math::initialize(SigmaKnots, DUMMY_VAR__); stan::math::fill(SigmaKnots, DUMMY_VAR__); - current_statement_begin__ = 216; + current_statement_begin__ = 222; validate_non_negative_index("obs_cov_offset", "n_pos", n_pos); Eigen::Matrix obs_cov_offset(n_pos); stan::math::initialize(obs_cov_offset, DUMMY_VAR__); stan::math::fill(obs_cov_offset, DUMMY_VAR__); // transformed parameters block statements - current_statement_begin__ = 219; + current_statement_begin__ = 225; for (int k = 1; k <= K; ++k) { - current_statement_begin__ = 220; + current_statement_begin__ = 226; stan::model::assign(sigma_pro, stan::model::cons_list(stan::model::index_uni(k), stan::model::nil_index_list()), 1, "assigning variable sigma_pro"); - current_statement_begin__ = 221; + current_statement_begin__ = 227; if (as_bool(logical_eq(est_sigma_process, 1))) { - current_statement_begin__ = 222; + current_statement_begin__ = 228; if (as_bool(logical_eq(n_sigma_process, 1))) { - current_statement_begin__ = 223; + current_statement_begin__ = 229; stan::model::assign(sigma_pro, stan::model::cons_list(stan::model::index_uni(k), stan::model::nil_index_list()), get_base1(sigma_process, 1, "sigma_process", 1), "assigning variable sigma_pro"); } else { - current_statement_begin__ = 225; + current_statement_begin__ = 231; stan::model::assign(sigma_pro, stan::model::cons_list(stan::model::index_uni(k), stan::model::nil_index_list()), get_base1(sigma_process, k, "sigma_process", 1), @@ -1716,70 +1736,94 @@ class model_dfa } } } - current_statement_begin__ = 231; + current_statement_begin__ = 237; if (as_bool(logical_eq(est_phi, 1))) { - current_statement_begin__ = 233; - stan::math::assign(phi_vec, to_vector(phi)); + current_statement_begin__ = 238; + for (int k = 1; k <= K; ++k) { + current_statement_begin__ = 238; + stan::model::assign(phi_vec, + stan::model::cons_list(stan::model::index_uni(k), stan::model::nil_index_list()), + get_base1(phi, k, "phi", 1), + "assigning variable phi_vec"); + } } else { - current_statement_begin__ = 236; - stan::math::assign(phi_vec, rep_vector(1.0, K)); + current_statement_begin__ = 241; + for (int k = 1; k <= K; ++k) { + current_statement_begin__ = 241; + stan::model::assign(phi_vec, + stan::model::cons_list(stan::model::index_uni(k), stan::model::nil_index_list()), + 1, + "assigning variable phi_vec"); + } } - current_statement_begin__ = 240; + current_statement_begin__ = 246; if (as_bool(logical_eq(est_theta, 1))) { - current_statement_begin__ = 242; - stan::math::assign(theta_vec, to_vector(theta)); + current_statement_begin__ = 247; + for (int k = 1; k <= K; ++k) { + current_statement_begin__ = 247; + stan::model::assign(theta_vec, + stan::model::cons_list(stan::model::index_uni(k), stan::model::nil_index_list()), + get_base1(theta, k, "theta", 1), + "assigning variable theta_vec"); + } } else { - current_statement_begin__ = 245; - stan::math::assign(theta_vec, rep_vector(1.0, K)); + current_statement_begin__ = 250; + for (int k = 1; k <= K; ++k) { + current_statement_begin__ = 250; + stan::model::assign(theta_vec, + stan::model::cons_list(stan::model::index_uni(k), stan::model::nil_index_list()), + 0, + "assigning variable theta_vec"); + } } - current_statement_begin__ = 248; + current_statement_begin__ = 254; if (as_bool(logical_eq(est_sigma_params, 1))) { - current_statement_begin__ = 249; + current_statement_begin__ = 255; for (int p = 1; p <= P; ++p) { - current_statement_begin__ = 249; + current_statement_begin__ = 255; stan::model::assign(sigma_vec, stan::model::cons_list(stan::model::index_uni(p), stan::model::nil_index_list()), get_base1(sigma, get_base1(varIndx, p, "varIndx", 1), "sigma", 1), "assigning variable sigma_vec"); } } - current_statement_begin__ = 251; + current_statement_begin__ = 257; if (as_bool(logical_eq(est_gamma_params, 1))) { - current_statement_begin__ = 252; + current_statement_begin__ = 258; for (int p = 1; p <= P; ++p) { - current_statement_begin__ = 252; + current_statement_begin__ = 258; stan::model::assign(gamma_a_vec, stan::model::cons_list(stan::model::index_uni(p), stan::model::nil_index_list()), get_base1(gamma_a, get_base1(varIndx, p, "varIndx", 1), "gamma_a", 1), "assigning variable gamma_a_vec"); } } - current_statement_begin__ = 254; + current_statement_begin__ = 260; if (as_bool(logical_eq(est_nb2_params, 1))) { - current_statement_begin__ = 255; + current_statement_begin__ = 261; for (int p = 1; p <= P; ++p) { - current_statement_begin__ = 255; + current_statement_begin__ = 261; stan::model::assign(nb_phi_vec, stan::model::cons_list(stan::model::index_uni(p), stan::model::nil_index_list()), get_base1(nb2_phi, get_base1(varIndx, p, "varIndx", 1), "nb2_phi", 1), "assigning variable nb_phi_vec"); } } - current_statement_begin__ = 258; + current_statement_begin__ = 264; if (as_bool(logical_eq(long_format, 0))) { - current_statement_begin__ = 260; + current_statement_begin__ = 266; for (int i = 1; i <= n_pos; ++i) { - current_statement_begin__ = 261; + current_statement_begin__ = 267; stan::model::assign(yall, stan::model::cons_list(stan::model::index_uni(get_base1(row_indx_pos, i, "row_indx_pos", 1)), stan::model::cons_list(stan::model::index_uni(get_base1(col_indx_pos, i, "col_indx_pos", 1)), stan::model::nil_index_list())), get_base1(y, i, "y", 1), "assigning variable yall"); } - current_statement_begin__ = 264; + current_statement_begin__ = 270; if (as_bool(logical_gt(n_na, 0))) { - current_statement_begin__ = 265; + current_statement_begin__ = 271; for (int i = 1; i <= n_na; ++i) { - current_statement_begin__ = 266; + current_statement_begin__ = 272; stan::model::assign(yall, stan::model::cons_list(stan::model::index_uni(get_base1(row_indx_na, i, "row_indx_na", 1)), stan::model::cons_list(stan::model::index_uni(get_base1(col_indx_na, i, "col_indx_na", 1)), stan::model::nil_index_list())), get_base1(ymiss, i, "ymiss", 1), @@ -1787,77 +1831,80 @@ class model_dfa } } } - current_statement_begin__ = 271; + current_statement_begin__ = 277; if (as_bool(logical_eq(proportional_model, 0))) { - current_statement_begin__ = 272; + current_statement_begin__ = 278; for (int i = 1; i <= nZ; ++i) { - current_statement_begin__ = 273; + current_statement_begin__ = 279; stan::model::assign(Z, stan::model::cons_list(stan::model::index_uni(get_base1(row_indx, i, "row_indx", 1)), stan::model::cons_list(stan::model::index_uni(get_base1(col_indx, i, "col_indx", 1)), stan::model::nil_index_list())), get_base1(z, i, "z", 1), "assigning variable Z"); } - current_statement_begin__ = 276; + current_statement_begin__ = 282; if (as_bool(logical_gt(nZero, 2))) { - current_statement_begin__ = 277; + current_statement_begin__ = 283; for (int i = 1; i <= (nZero - 2); ++i) { - current_statement_begin__ = 278; + current_statement_begin__ = 284; stan::model::assign(Z, stan::model::cons_list(stan::model::index_uni(get_base1(row_indx_z, i, "row_indx_z", 1)), stan::model::cons_list(stan::model::index_uni(get_base1(col_indx_z, i, "col_indx_z", 1)), stan::model::nil_index_list())), 0, "assigning variable Z"); } } - current_statement_begin__ = 281; + current_statement_begin__ = 287; for (int k = 1; k <= K; ++k) { - current_statement_begin__ = 282; + current_statement_begin__ = 288; stan::model::assign(Z, stan::model::cons_list(stan::model::index_uni(k), stan::model::cons_list(stan::model::index_uni(k), stan::model::nil_index_list())), get_base1(zpos, k, "zpos", 1), "assigning variable Z"); } - current_statement_begin__ = 285; - for (int k = 1; k <= K; ++k) { - current_statement_begin__ = 286; - if (as_bool(logical_lt(get_base1(zpos, k, "zpos", 1), 0))) { - current_statement_begin__ = 287; - stan::model::assign(indicator, - stan::model::cons_list(stan::model::index_uni(k), stan::model::nil_index_list()), - -(1), - "assigning variable indicator"); - } else { - current_statement_begin__ = 289; - stan::model::assign(indicator, - stan::model::cons_list(stan::model::index_uni(k), stan::model::nil_index_list()), - 1, - "assigning variable indicator"); - } - current_statement_begin__ = 291; - stan::model::assign(psi_root, - stan::model::cons_list(stan::model::index_uni(k), stan::model::nil_index_list()), - stan::math::sqrt(get_base1(psi, k, "psi", 1)), - "assigning variable psi_root"); + current_statement_begin__ = 291; + if (as_bool(logical_eq(use_expansion_prior, 1))) { current_statement_begin__ = 292; - for (int p = 1; p <= P; ++p) { + for (int k = 1; k <= K; ++k) { current_statement_begin__ = 293; - stan::model::assign(Z, - stan::model::cons_list(stan::model::index_uni(p), stan::model::cons_list(stan::model::index_uni(k), stan::model::nil_index_list())), - ((get_base1(Z, p, k, "Z", 1) * get_base1(indicator, k, "indicator", 1)) * (1 / get_base1(psi_root, k, "psi_root", 1))), - "assigning variable Z"); + if (as_bool(logical_lt(get_base1(zpos, k, "zpos", 1), 0))) { + current_statement_begin__ = 294; + stan::model::assign(indicator, + stan::model::cons_list(stan::model::index_uni(k), stan::model::nil_index_list()), + -(1), + "assigning variable indicator"); + } else { + current_statement_begin__ = 296; + stan::model::assign(indicator, + stan::model::cons_list(stan::model::index_uni(k), stan::model::nil_index_list()), + 1, + "assigning variable indicator"); + } + current_statement_begin__ = 299; + stan::model::assign(psi_root, + stan::model::cons_list(stan::model::index_uni(k), stan::model::nil_index_list()), + stan::math::sqrt(get_base1(psi, k, "psi", 1)), + "assigning variable psi_root"); + current_statement_begin__ = 300; + for (int p = 1; p <= P; ++p) { + current_statement_begin__ = 302; + stan::model::assign(Z, + stan::model::cons_list(stan::model::index_uni(p), stan::model::cons_list(stan::model::index_uni(k), stan::model::nil_index_list())), + ((get_base1(Z, p, k, "Z", 1) * get_base1(indicator, k, "indicator", 1)) * (1 / get_base1(psi_root, k, "psi_root", 1))), + "assigning variable Z"); + } } } - current_statement_begin__ = 297; + current_statement_begin__ = 308; if (as_bool(logical_eq(est_rw, 1))) { - current_statement_begin__ = 298; + current_statement_begin__ = 309; for (int k = 1; k <= K; ++k) { - current_statement_begin__ = 299; + current_statement_begin__ = 310; stan::model::assign(x, stan::model::cons_list(stan::model::index_uni(k), stan::model::cons_list(stan::model::index_uni(1), stan::model::nil_index_list())), get_base1(x0, k, "x0", 1), "assigning variable x"); - current_statement_begin__ = 303; + current_statement_begin__ = 314; for (int t = 2; t <= N; ++t) { - current_statement_begin__ = 304; + current_statement_begin__ = 315; stan::model::assign(x, stan::model::cons_list(stan::model::index_uni(k), stan::model::cons_list(stan::model::index_uni(t), stan::model::nil_index_list())), ((get_base1(phi_vec, k, "phi_vec", 1) * get_base1(x, k, (t - 1), "x", 1)) + get_base1(devs, k, (t - 1), "devs", 1)), @@ -1865,53 +1912,53 @@ class model_dfa } } } - current_statement_begin__ = 308; + current_statement_begin__ = 319; if (as_bool(logical_eq(est_spline, 1))) { - current_statement_begin__ = 310; + current_statement_begin__ = 321; for (int k = 1; k <= K; ++k) { - current_statement_begin__ = 310; + current_statement_begin__ = 321; stan::model::assign(spline_a_trans, stan::model::cons_list(stan::model::index_uni(k), stan::model::nil_index_list()), multiply(get_base1(spline_a, k, "spline_a", 1), get_base1(sigma_pro, k, "sigma_pro", 1)), "assigning variable spline_a_trans"); } - current_statement_begin__ = 311; + current_statement_begin__ = 322; stan::math::assign(x, multiply(spline_a_trans, B_spline)); - current_statement_begin__ = 312; + current_statement_begin__ = 323; for (int k = 1; k <= K; ++k) { - current_statement_begin__ = 312; + current_statement_begin__ = 323; stan::model::assign(x, stan::model::cons_list(stan::model::index_uni(k), stan::model::nil_index_list()), add(get_base1(x0, k, "x0", 1), get_base1(x, k, "x", 1)), "assigning variable x"); } } - current_statement_begin__ = 314; + current_statement_begin__ = 325; if (as_bool(logical_eq(est_gp, 1))) { - current_statement_begin__ = 316; + current_statement_begin__ = 327; for (int k = 1; k <= K; ++k) { - current_statement_begin__ = 317; + current_statement_begin__ = 328; stan::model::assign(SigmaKnots, stan::model::cons_list(stan::model::index_uni(k), stan::model::nil_index_list()), cov_exp_quad(knot_locs, get_base1(sigma_pro, k, "sigma_pro", 1), get_base1(gp_theta, k, "gp_theta", 1)), "assigning variable SigmaKnots"); - current_statement_begin__ = 320; + current_statement_begin__ = 331; for (int i = 1; i <= n_knots; ++i) { - current_statement_begin__ = 321; + current_statement_begin__ = 332; stan::model::assign(SigmaKnots, stan::model::cons_list(stan::model::index_uni(k), stan::model::cons_list(stan::model::index_uni(i), stan::model::cons_list(stan::model::index_uni(i), stan::model::nil_index_list()))), (stan::model::rvalue(SigmaKnots, stan::model::cons_list(stan::model::index_uni(k), stan::model::cons_list(stan::model::index_uni(i), stan::model::cons_list(stan::model::index_uni(i), stan::model::nil_index_list()))), "SigmaKnots") + gp_delta), "assigning variable SigmaKnots"); } - current_statement_begin__ = 330; + current_statement_begin__ = 341; if (as_bool(logical_eq(n_knots, N))) { - current_statement_begin__ = 332; + current_statement_begin__ = 343; stan::model::assign(x, stan::model::cons_list(stan::model::index_uni(k), stan::model::nil_index_list()), to_row_vector(multiply(cholesky_decompose(get_base1(SigmaKnots, k, "SigmaKnots", 1)), get_base1(effectsKnots, k, "effectsKnots", 1))), "assigning variable x"); } else { - current_statement_begin__ = 334; + current_statement_begin__ = 345; stan::model::assign(x, stan::model::cons_list(stan::model::index_uni(k), stan::model::nil_index_list()), to_row_vector(multiply(multiply(multiply(cov_exp_quad(data_locs, knot_locs, get_base1(sigma_pro, k, "sigma_pro", 1), get_base1(gp_theta, k, "gp_theta", 1)), inverse_spd(get_base1(SigmaKnots, k, "SigmaKnots", 1))), cholesky_decompose(get_base1(SigmaKnots, k, "SigmaKnots", 1))), get_base1(effectsKnots, k, "effectsKnots", 1))), @@ -1919,29 +1966,32 @@ class model_dfa } } } - current_statement_begin__ = 340; - for (int k = 1; k <= K; ++k) { - current_statement_begin__ = 342; - stan::model::assign(x, - stan::model::cons_list(stan::model::index_uni(k), stan::model::nil_index_list()), - multiply(multiply(get_base1(x, k, "x", 1), get_base1(indicator, k, "indicator", 1)), get_base1(psi_root, k, "psi_root", 1)), - "assigning variable x"); + current_statement_begin__ = 351; + if (as_bool(logical_eq(use_expansion_prior, 1))) { + current_statement_begin__ = 352; + for (int k = 1; k <= K; ++k) { + current_statement_begin__ = 355; + stan::model::assign(x, + stan::model::cons_list(stan::model::index_uni(k), stan::model::nil_index_list()), + multiply(multiply(get_base1(x, k, "x", 1), get_base1(indicator, k, "indicator", 1)), get_base1(psi_root, k, "psi_root", 1)), + "assigning variable x"); + } } } - current_statement_begin__ = 346; + current_statement_begin__ = 360; if (as_bool(logical_eq(proportional_model, 1))) { - current_statement_begin__ = 348; + current_statement_begin__ = 362; if (as_bool(logical_eq(est_rw, 1))) { - current_statement_begin__ = 349; + current_statement_begin__ = 363; for (int k = 1; k <= K; ++k) { - current_statement_begin__ = 350; + current_statement_begin__ = 364; stan::model::assign(x, stan::model::cons_list(stan::model::index_uni(k), stan::model::cons_list(stan::model::index_uni(1), stan::model::nil_index_list())), get_base1(x0, k, "x0", 1), "assigning variable x"); - current_statement_begin__ = 354; + current_statement_begin__ = 368; for (int t = 2; t <= N; ++t) { - current_statement_begin__ = 355; + current_statement_begin__ = 369; stan::model::assign(x, stan::model::cons_list(stan::model::index_uni(k), stan::model::cons_list(stan::model::index_uni(t), stan::model::nil_index_list())), ((get_base1(phi_vec, k, "phi_vec", 1) * get_base1(x, k, (t - 1), "x", 1)) + get_base1(devs, k, (t - 1), "devs", 1)), @@ -1949,53 +1999,53 @@ class model_dfa } } } - current_statement_begin__ = 359; + current_statement_begin__ = 373; if (as_bool(logical_eq(est_spline, 1))) { - current_statement_begin__ = 360; + current_statement_begin__ = 374; for (int k = 1; k <= K; ++k) { - current_statement_begin__ = 360; + current_statement_begin__ = 374; stan::model::assign(spline_a_trans, stan::model::cons_list(stan::model::index_uni(k), stan::model::nil_index_list()), multiply(get_base1(spline_a, k, "spline_a", 1), get_base1(sigma_pro, k, "sigma_pro", 1)), "assigning variable spline_a_trans"); } - current_statement_begin__ = 361; + current_statement_begin__ = 375; stan::math::assign(x, multiply(spline_a_trans, B_spline)); - current_statement_begin__ = 362; + current_statement_begin__ = 376; for (int k = 1; k <= K; ++k) { - current_statement_begin__ = 362; + current_statement_begin__ = 376; stan::model::assign(x, stan::model::cons_list(stan::model::index_uni(k), stan::model::nil_index_list()), add(get_base1(x0, k, "x0", 1), get_base1(x, k, "x", 1)), "assigning variable x"); } } - current_statement_begin__ = 364; + current_statement_begin__ = 378; if (as_bool(logical_eq(est_gp, 1))) { - current_statement_begin__ = 365; + current_statement_begin__ = 379; for (int k = 1; k <= K; ++k) { - current_statement_begin__ = 366; + current_statement_begin__ = 380; stan::model::assign(SigmaKnots, stan::model::cons_list(stan::model::index_uni(k), stan::model::nil_index_list()), cov_exp_quad(knot_locs, get_base1(sigma_pro, k, "sigma_pro", 1), get_base1(gp_theta, k, "gp_theta", 1)), "assigning variable SigmaKnots"); - current_statement_begin__ = 369; + current_statement_begin__ = 383; for (int i = 1; i <= n_knots; ++i) { - current_statement_begin__ = 370; + current_statement_begin__ = 384; stan::model::assign(SigmaKnots, stan::model::cons_list(stan::model::index_uni(k), stan::model::cons_list(stan::model::index_uni(i), stan::model::cons_list(stan::model::index_uni(i), stan::model::nil_index_list()))), (stan::model::rvalue(SigmaKnots, stan::model::cons_list(stan::model::index_uni(k), stan::model::cons_list(stan::model::index_uni(i), stan::model::cons_list(stan::model::index_uni(i), stan::model::nil_index_list()))), "SigmaKnots") + gp_delta), "assigning variable SigmaKnots"); } - current_statement_begin__ = 379; + current_statement_begin__ = 393; if (as_bool(logical_eq(n_knots, N))) { - current_statement_begin__ = 381; + current_statement_begin__ = 395; stan::model::assign(x, stan::model::cons_list(stan::model::index_uni(k), stan::model::nil_index_list()), to_row_vector(multiply(cholesky_decompose(get_base1(SigmaKnots, k, "SigmaKnots", 1)), get_base1(effectsKnots, k, "effectsKnots", 1))), "assigning variable x"); } else { - current_statement_begin__ = 383; + current_statement_begin__ = 397; stan::model::assign(x, stan::model::cons_list(stan::model::index_uni(k), stan::model::nil_index_list()), to_row_vector(multiply(multiply(multiply(cov_exp_quad(data_locs, knot_locs, get_base1(sigma_pro, k, "sigma_pro", 1), get_base1(gp_theta, k, "gp_theta", 1)), inverse_spd(get_base1(SigmaKnots, k, "SigmaKnots", 1))), cholesky_decompose(get_base1(SigmaKnots, k, "SigmaKnots", 1))), get_base1(effectsKnots, k, "effectsKnots", 1))), @@ -2003,52 +2053,52 @@ class model_dfa } } } - current_statement_begin__ = 389; + current_statement_begin__ = 403; for (int p = 1; p <= P; ++p) { - current_statement_begin__ = 393; + current_statement_begin__ = 407; stan::model::assign(Z, stan::model::cons_list(stan::model::index_uni(p), stan::model::nil_index_list()), to_row_vector(get_base1(p_z, p, "p_z", 1)), "assigning variable Z"); } } - current_statement_begin__ = 398; + current_statement_begin__ = 412; if (as_bool(logical_gt(num_pro_covar, 0))) { - current_statement_begin__ = 399; + current_statement_begin__ = 413; for (int i = 1; i <= num_pro_covar; ++i) { - current_statement_begin__ = 401; + current_statement_begin__ = 415; stan::model::assign(x, stan::model::cons_list(stan::model::index_uni(get_base1(get_base1(pro_covar_index, i, "pro_covar_index", 1), 2, "pro_covar_index", 2)), stan::model::cons_list(stan::model::index_uni(get_base1(get_base1(pro_covar_index, i, "pro_covar_index", 1), 1, "pro_covar_index", 2)), stan::model::nil_index_list())), (stan::model::rvalue(x, stan::model::cons_list(stan::model::index_uni(get_base1(get_base1(pro_covar_index, i, "pro_covar_index", 1), 2, "pro_covar_index", 2)), stan::model::cons_list(stan::model::index_uni(get_base1(get_base1(pro_covar_index, i, "pro_covar_index", 1), 1, "pro_covar_index", 2)), stan::model::nil_index_list())), "x") + (get_base1(b_pro, get_base1(get_base1(pro_covar_index, i, "pro_covar_index", 1), 3, "pro_covar_index", 2), get_base1(get_base1(pro_covar_index, i, "pro_covar_index", 1), 2, "pro_covar_index", 2), "b_pro", 1) * get_base1(pro_covar_value, i, "pro_covar_value", 1))), "assigning variable x"); } } - current_statement_begin__ = 407; + current_statement_begin__ = 421; stan::math::assign(pred, multiply(Z, x)); - current_statement_begin__ = 409; + current_statement_begin__ = 424; for (int i = 1; i <= n_pos; ++i) { - current_statement_begin__ = 410; + current_statement_begin__ = 425; stan::model::assign(obs_cov_offset, stan::model::cons_list(stan::model::index_uni(i), stan::model::nil_index_list()), 0, "assigning variable obs_cov_offset"); } - current_statement_begin__ = 413; + current_statement_begin__ = 428; if (as_bool(logical_gt(num_obs_covar, 0))) { - current_statement_begin__ = 414; + current_statement_begin__ = 429; if (as_bool(logical_eq(long_format, 0))) { - current_statement_begin__ = 415; + current_statement_begin__ = 430; for (int i = 1; i <= num_obs_covar; ++i) { - current_statement_begin__ = 418; + current_statement_begin__ = 433; stan::model::assign(pred, stan::model::cons_list(stan::model::index_uni(get_base1(get_base1(obs_covar_index, i, "obs_covar_index", 1), 2, "obs_covar_index", 2)), stan::model::cons_list(stan::model::index_uni(get_base1(get_base1(obs_covar_index, i, "obs_covar_index", 1), 1, "obs_covar_index", 2)), stan::model::nil_index_list())), (stan::model::rvalue(pred, stan::model::cons_list(stan::model::index_uni(get_base1(get_base1(obs_covar_index, i, "obs_covar_index", 1), 2, "obs_covar_index", 2)), stan::model::cons_list(stan::model::index_uni(get_base1(get_base1(obs_covar_index, i, "obs_covar_index", 1), 1, "obs_covar_index", 2)), stan::model::nil_index_list())), "pred") + (get_base1(b_obs, get_base1(get_base1(obs_covar_index, i, "obs_covar_index", 1), 3, "obs_covar_index", 2), get_base1(get_base1(obs_covar_index, i, "obs_covar_index", 1), 2, "obs_covar_index", 2), "b_obs", 1) * get_base1(obs_covar_value, i, "obs_covar_value", 1))), "assigning variable pred"); } } else { - current_statement_begin__ = 423; + current_statement_begin__ = 438; for (int i = 1; i <= num_obs_covar; ++i) { - current_statement_begin__ = 424; + current_statement_begin__ = 439; stan::model::assign(obs_cov_offset, stan::model::cons_list(stan::model::index_uni(get_base1(match_obs_covar, i, "match_obs_covar", 1)), stan::model::nil_index_list()), (stan::model::rvalue(obs_cov_offset, stan::model::cons_list(stan::model::index_uni(get_base1(match_obs_covar, i, "match_obs_covar", 1)), stan::model::nil_index_list()), "obs_cov_offset") + (get_base1(b_obs, get_base1(get_base1(obs_covar_index, i, "obs_covar_index", 1), 3, "obs_covar_index", 2), get_base1(get_base1(obs_covar_index, i, "obs_covar_index", 1), 2, "obs_covar_index", 2), "b_obs", 1) * get_base1(obs_covar_value, i, "obs_covar_value", 1))), @@ -2056,64 +2106,64 @@ class model_dfa } } } - current_statement_begin__ = 429; + current_statement_begin__ = 444; if (as_bool((primitive_value(logical_eq(long_format, 1)) && primitive_value(logical_eq(est_cor, 1))))) { - current_statement_begin__ = 431; + current_statement_begin__ = 446; for (int n = 1; n <= N; ++n) { - current_statement_begin__ = 432; + current_statement_begin__ = 447; for (int p = 1; p <= P; ++p) { - current_statement_begin__ = 433; + current_statement_begin__ = 448; stan::model::assign(temp_sums, stan::model::cons_list(stan::model::index_uni(p), stan::model::cons_list(stan::model::index_uni(n), stan::model::nil_index_list())), 0.0, "assigning variable temp_sums"); - current_statement_begin__ = 434; + current_statement_begin__ = 449; stan::model::assign(temp_counts, stan::model::cons_list(stan::model::index_uni(p), stan::model::cons_list(stan::model::index_uni(n), stan::model::nil_index_list())), 0.0, "assigning variable temp_counts"); } } - current_statement_begin__ = 437; + current_statement_begin__ = 452; for (int i = 1; i <= n_pos; ++i) { - current_statement_begin__ = 438; + current_statement_begin__ = 453; stan::model::assign(temp_sums, stan::model::cons_list(stan::model::index_uni(get_base1(row_indx_pos, i, "row_indx_pos", 1)), stan::model::cons_list(stan::model::index_uni(get_base1(col_indx_pos, i, "col_indx_pos", 1)), stan::model::nil_index_list())), (stan::model::rvalue(temp_sums, stan::model::cons_list(stan::model::index_uni(get_base1(row_indx_pos, i, "row_indx_pos", 1)), stan::model::cons_list(stan::model::index_uni(get_base1(col_indx_pos, i, "col_indx_pos", 1)), stan::model::nil_index_list())), "temp_sums") + (get_base1(y, i, "y", 1) - get_base1(pred, get_base1(row_indx_pos, i, "row_indx_pos", 1), get_base1(col_indx_pos, i, "col_indx_pos", 1), "pred", 1))), "assigning variable temp_sums"); - current_statement_begin__ = 439; + current_statement_begin__ = 454; stan::model::assign(temp_counts, stan::model::cons_list(stan::model::index_uni(get_base1(row_indx_pos, i, "row_indx_pos", 1)), stan::model::cons_list(stan::model::index_uni(get_base1(col_indx_pos, i, "col_indx_pos", 1)), stan::model::nil_index_list())), (stan::model::rvalue(temp_counts, stan::model::cons_list(stan::model::index_uni(get_base1(row_indx_pos, i, "row_indx_pos", 1)), stan::model::cons_list(stan::model::index_uni(get_base1(col_indx_pos, i, "col_indx_pos", 1)), stan::model::nil_index_list())), "temp_counts") + 1), "assigning variable temp_counts"); } - current_statement_begin__ = 441; + current_statement_begin__ = 456; for (int n = 1; n <= N; ++n) { - current_statement_begin__ = 442; + current_statement_begin__ = 457; for (int p = 1; p <= P; ++p) { - current_statement_begin__ = 444; + current_statement_begin__ = 459; stan::model::assign(temp_sums, stan::model::cons_list(stan::model::index_uni(p), stan::model::cons_list(stan::model::index_uni(n), stan::model::nil_index_list())), (get_base1(temp_sums, p, n, "temp_sums", 1) / get_base1(temp_counts, p, n, "temp_counts", 1)), "assigning variable temp_sums"); } } - current_statement_begin__ = 448; + current_statement_begin__ = 463; stan::math::assign(Sigma_derived, quad_form_diag(multiply_lower_tri_self_transpose(Lcorr), sigma_vec)); - current_statement_begin__ = 450; + current_statement_begin__ = 465; for (int p = 1; p <= P; ++p) { - current_statement_begin__ = 451; + current_statement_begin__ = 466; stan::math::assign(sigma11, get_base1(Sigma_derived, p, p, "Sigma_derived", 1)); - current_statement_begin__ = 452; + current_statement_begin__ = 467; stan::math::assign(Sigma_temp, inverse(subset(Sigma_derived, p, P, pstream__))); - current_statement_begin__ = 453; + current_statement_begin__ = 468; stan::math::assign(sigma12_vec, subsetvec(Sigma_derived, p, P, pstream__)); - current_statement_begin__ = 455; + current_statement_begin__ = 470; stan::model::assign(cond_mean_vec, stan::model::cons_list(stan::model::index_uni(p), stan::model::nil_index_list()), multiply(multiply(to_row_vector(sigma12_vec), Sigma_temp), to_vector(subsetvec2(col(temp_sums, p), p, P, pstream__))), "assigning variable cond_mean_vec"); - current_statement_begin__ = 457; + current_statement_begin__ = 472; stan::model::assign(cond_sigma_vec, stan::model::cons_list(stan::model::index_uni(p), stan::model::nil_index_list()), stan::math::sqrt((sigma11 - multiply(multiply(to_row_vector(sigma12_vec), Sigma_temp), to_vector(sigma12_vec)))), @@ -2123,7 +2173,7 @@ class model_dfa // validate transformed parameters const char* function__ = "validate transformed params"; (void) function__; // dummy to suppress unused var warning - current_statement_begin__ = 192; + current_statement_begin__ = 198; size_t pred_j_1_max__ = P; size_t pred_j_2_max__ = N; for (size_t j_1__ = 0; j_1__ < pred_j_1_max__; ++j_1__) { @@ -2135,7 +2185,7 @@ class model_dfa } } } - current_statement_begin__ = 193; + current_statement_begin__ = 199; size_t Z_j_1_max__ = P; size_t Z_j_2_max__ = K; for (size_t j_1__ = 0; j_1__ < Z_j_1_max__; ++j_1__) { @@ -2147,7 +2197,7 @@ class model_dfa } } } - current_statement_begin__ = 194; + current_statement_begin__ = 200; size_t yall_j_1_max__ = P; size_t yall_j_2_max__ = N; for (size_t j_1__ = 0; j_1__ < yall_j_1_max__; ++j_1__) { @@ -2159,7 +2209,7 @@ class model_dfa } } } - current_statement_begin__ = 195; + current_statement_begin__ = 201; size_t sigma_vec_j_1_max__ = (P * est_sigma_params); for (size_t j_1__ = 0; j_1__ < sigma_vec_j_1_max__; ++j_1__) { if (stan::math::is_uninitialized(sigma_vec(j_1__))) { @@ -2168,7 +2218,8 @@ class model_dfa stan::lang::rethrow_located(std::runtime_error(std::string("Error initializing variable sigma_vec: ") + msg__.str()), current_statement_begin__, prog_reader__()); } } - current_statement_begin__ = 196; + check_greater_or_equal(function__, "sigma_vec", sigma_vec, 0); + current_statement_begin__ = 202; size_t gamma_a_vec_j_1_max__ = (P * est_gamma_params); for (size_t j_1__ = 0; j_1__ < gamma_a_vec_j_1_max__; ++j_1__) { if (stan::math::is_uninitialized(gamma_a_vec(j_1__))) { @@ -2177,7 +2228,8 @@ class model_dfa stan::lang::rethrow_located(std::runtime_error(std::string("Error initializing variable gamma_a_vec: ") + msg__.str()), current_statement_begin__, prog_reader__()); } } - current_statement_begin__ = 197; + check_greater_or_equal(function__, "gamma_a_vec", gamma_a_vec, 0); + current_statement_begin__ = 203; size_t nb_phi_vec_j_1_max__ = (P * est_nb2_params); for (size_t j_1__ = 0; j_1__ < nb_phi_vec_j_1_max__; ++j_1__) { if (stan::math::is_uninitialized(nb_phi_vec(j_1__))) { @@ -2186,7 +2238,8 @@ class model_dfa stan::lang::rethrow_located(std::runtime_error(std::string("Error initializing variable nb_phi_vec: ") + msg__.str()), current_statement_begin__, prog_reader__()); } } - current_statement_begin__ = 198; + check_greater_or_equal(function__, "nb_phi_vec", nb_phi_vec, 0); + current_statement_begin__ = 204; size_t phi_vec_j_1_max__ = K; for (size_t j_1__ = 0; j_1__ < phi_vec_j_1_max__; ++j_1__) { if (stan::math::is_uninitialized(phi_vec(j_1__))) { @@ -2195,7 +2248,7 @@ class model_dfa stan::lang::rethrow_located(std::runtime_error(std::string("Error initializing variable phi_vec: ") + msg__.str()), current_statement_begin__, prog_reader__()); } } - current_statement_begin__ = 199; + current_statement_begin__ = 205; size_t theta_vec_j_1_max__ = K; for (size_t j_1__ = 0; j_1__ < theta_vec_j_1_max__; ++j_1__) { if (stan::math::is_uninitialized(theta_vec(j_1__))) { @@ -2204,7 +2257,7 @@ class model_dfa stan::lang::rethrow_located(std::runtime_error(std::string("Error initializing variable theta_vec: ") + msg__.str()), current_statement_begin__, prog_reader__()); } } - current_statement_begin__ = 200; + current_statement_begin__ = 206; size_t x_j_1_max__ = K; size_t x_j_2_max__ = N; for (size_t j_1__ = 0; j_1__ < x_j_1_max__; ++j_1__) { @@ -2216,7 +2269,7 @@ class model_dfa } } } - current_statement_begin__ = 201; + current_statement_begin__ = 207; size_t indicator_j_1_max__ = K; for (size_t j_1__ = 0; j_1__ < indicator_j_1_max__; ++j_1__) { if (stan::math::is_uninitialized(indicator(j_1__))) { @@ -2225,8 +2278,8 @@ class model_dfa stan::lang::rethrow_located(std::runtime_error(std::string("Error initializing variable indicator: ") + msg__.str()), current_statement_begin__, prog_reader__()); } } - current_statement_begin__ = 202; - size_t psi_root_j_1_max__ = K; + current_statement_begin__ = 208; + size_t psi_root_j_1_max__ = (K * use_expansion_prior); for (size_t j_1__ = 0; j_1__ < psi_root_j_1_max__; ++j_1__) { if (stan::math::is_uninitialized(psi_root(j_1__))) { std::stringstream msg__; @@ -2234,7 +2287,8 @@ class model_dfa stan::lang::rethrow_located(std::runtime_error(std::string("Error initializing variable psi_root: ") + msg__.str()), current_statement_begin__, prog_reader__()); } } - current_statement_begin__ = 203; + check_greater_or_equal(function__, "psi_root", psi_root, 0); + current_statement_begin__ = 209; size_t Sigma_derived_j_1_max__ = ((n_pcor * long_format) * est_cor); size_t Sigma_derived_j_2_max__ = ((n_pcor * long_format) * est_cor); for (size_t j_1__ = 0; j_1__ < Sigma_derived_j_1_max__; ++j_1__) { @@ -2246,7 +2300,7 @@ class model_dfa } } } - current_statement_begin__ = 204; + current_statement_begin__ = 210; size_t Sigma_temp_j_1_max__ = (((n_pcor - 1) * long_format) * est_cor); size_t Sigma_temp_j_2_max__ = (((n_pcor - 1) * long_format) * est_cor); for (size_t j_1__ = 0; j_1__ < Sigma_temp_j_1_max__; ++j_1__) { @@ -2258,7 +2312,7 @@ class model_dfa } } } - current_statement_begin__ = 205; + current_statement_begin__ = 211; size_t sigma12_vec_j_1_max__ = (n_pcor - 1); size_t sigma12_vec_j_2_max__ = 1; for (size_t j_1__ = 0; j_1__ < sigma12_vec_j_1_max__; ++j_1__) { @@ -2270,7 +2324,7 @@ class model_dfa } } } - current_statement_begin__ = 206; + current_statement_begin__ = 212; size_t temp_sums_j_1_max__ = ((P * long_format) * est_cor); size_t temp_sums_j_2_max__ = ((N * long_format) * est_cor); for (size_t j_1__ = 0; j_1__ < temp_sums_j_1_max__; ++j_1__) { @@ -2282,7 +2336,7 @@ class model_dfa } } } - current_statement_begin__ = 207; + current_statement_begin__ = 213; size_t temp_counts_j_1_max__ = ((P * long_format) * est_cor); size_t temp_counts_j_2_max__ = ((N * long_format) * est_cor); for (size_t j_1__ = 0; j_1__ < temp_counts_j_1_max__; ++j_1__) { @@ -2294,7 +2348,7 @@ class model_dfa } } } - current_statement_begin__ = 208; + current_statement_begin__ = 214; size_t cond_sigma_vec_j_1_max__ = ((P * long_format) * est_cor); for (size_t j_1__ = 0; j_1__ < cond_sigma_vec_j_1_max__; ++j_1__) { if (stan::math::is_uninitialized(cond_sigma_vec(j_1__))) { @@ -2303,7 +2357,7 @@ class model_dfa stan::lang::rethrow_located(std::runtime_error(std::string("Error initializing variable cond_sigma_vec: ") + msg__.str()), current_statement_begin__, prog_reader__()); } } - current_statement_begin__ = 209; + current_statement_begin__ = 215; size_t cond_mean_vec_j_1_max__ = ((P * long_format) * est_cor); for (size_t j_1__ = 0; j_1__ < cond_mean_vec_j_1_max__; ++j_1__) { if (stan::math::is_uninitialized(cond_mean_vec(j_1__))) { @@ -2312,13 +2366,13 @@ class model_dfa stan::lang::rethrow_located(std::runtime_error(std::string("Error initializing variable cond_mean_vec: ") + msg__.str()), current_statement_begin__, prog_reader__()); } } - current_statement_begin__ = 210; + current_statement_begin__ = 216; if (stan::math::is_uninitialized(sigma11)) { std::stringstream msg__; msg__ << "Undefined transformed parameter: sigma11"; stan::lang::rethrow_located(std::runtime_error(std::string("Error initializing variable sigma11: ") + msg__.str()), current_statement_begin__, prog_reader__()); } - current_statement_begin__ = 211; + current_statement_begin__ = 217; size_t sigma_pro_j_1_max__ = K; for (size_t j_1__ = 0; j_1__ < sigma_pro_j_1_max__; ++j_1__) { if (stan::math::is_uninitialized(sigma_pro(j_1__))) { @@ -2327,7 +2381,7 @@ class model_dfa stan::lang::rethrow_located(std::runtime_error(std::string("Error initializing variable sigma_pro: ") + msg__.str()), current_statement_begin__, prog_reader__()); } } - current_statement_begin__ = 212; + current_statement_begin__ = 218; size_t spline_a_trans_j_1_max__ = (K * est_spline); size_t spline_a_trans_j_2_max__ = (n_knots * est_spline); for (size_t j_1__ = 0; j_1__ < spline_a_trans_j_1_max__; ++j_1__) { @@ -2339,7 +2393,7 @@ class model_dfa } } } - current_statement_begin__ = 213; + current_statement_begin__ = 219; size_t SigmaKnots_k_0_max__ = K; size_t SigmaKnots_j_1_max__ = n_knots; size_t SigmaKnots_j_2_max__ = n_knots; @@ -2354,7 +2408,7 @@ class model_dfa } } } - current_statement_begin__ = 216; + current_statement_begin__ = 222; size_t obs_cov_offset_j_1_max__ = n_pos; for (size_t j_1__ = 0; j_1__ < obs_cov_offset_j_1_max__; ++j_1__) { if (stan::math::is_uninitialized(obs_cov_offset(j_1__))) { @@ -2364,199 +2418,202 @@ class model_dfa } } // model body - current_statement_begin__ = 465; + current_statement_begin__ = 480; lp_accum__.add(normal_log(x0, 0, 1)); - current_statement_begin__ = 466; - lp_accum__.add(gamma_log(psi, 2, 1)); - current_statement_begin__ = 469; + current_statement_begin__ = 481; + if (as_bool(logical_eq(use_expansion_prior, 1))) { + current_statement_begin__ = 482; + lp_accum__.add(gamma_log(psi, 2, 1)); + } + current_statement_begin__ = 486; if (as_bool(logical_eq(estimate_nu, 1))) { - current_statement_begin__ = 470; + current_statement_begin__ = 487; lp_accum__.add(gamma_log(get_base1(nu, 1, "nu", 1), 2, 0.1)); } - current_statement_begin__ = 473; + current_statement_begin__ = 490; if (as_bool(logical_eq(est_phi, 1))) { - current_statement_begin__ = 474; + current_statement_begin__ = 491; lp_accum__.add(normal_log(phi, 0, 1)); } - current_statement_begin__ = 477; + current_statement_begin__ = 494; if (as_bool(logical_eq(est_theta, 1))) { - current_statement_begin__ = 478; + current_statement_begin__ = 495; lp_accum__.add(normal_log(theta, 0, 1)); } - current_statement_begin__ = 481; + current_statement_begin__ = 498; if (as_bool(est_sigma_process)) { - current_statement_begin__ = 482; + current_statement_begin__ = 499; lp_accum__.add(normal_log(sigma_process, 0, 1)); } - current_statement_begin__ = 485; + current_statement_begin__ = 502; if (as_bool(logical_eq(est_sigma_params, 1))) { - current_statement_begin__ = 485; + current_statement_begin__ = 502; lp_accum__.add(student_t_log(sigma, 3, 0, 1)); } - current_statement_begin__ = 486; + current_statement_begin__ = 503; if (as_bool(logical_eq(est_gamma_params, 1))) { - current_statement_begin__ = 486; + current_statement_begin__ = 503; lp_accum__.add(student_t_log(gamma_a, 3, 0, 1)); } - current_statement_begin__ = 487; + current_statement_begin__ = 504; if (as_bool(logical_eq(est_nb2_params, 1))) { - current_statement_begin__ = 487; + current_statement_begin__ = 504; lp_accum__.add(student_t_log(nb2_phi, 3, 0, 1)); } - current_statement_begin__ = 490; + current_statement_begin__ = 507; if (as_bool(logical_eq(est_cor, 1))) { - current_statement_begin__ = 491; + current_statement_begin__ = 508; lp_accum__.add(lkj_corr_cholesky_log(Lcorr, 1)); } - current_statement_begin__ = 493; + current_statement_begin__ = 510; if (as_bool(logical_eq(est_gp, 1))) { - current_statement_begin__ = 498; + current_statement_begin__ = 515; lp_accum__.add(inv_gamma_log(gp_theta, get_base1(gp_theta_prior, 1, "gp_theta_prior", 1), get_base1(gp_theta_prior, 2, "gp_theta_prior", 1))); - current_statement_begin__ = 500; + current_statement_begin__ = 517; for (int k = 1; k <= K; ++k) { - current_statement_begin__ = 501; + current_statement_begin__ = 518; lp_accum__.add(std_normal_log(get_base1(effectsKnots, k, "effectsKnots", 1))); } } - current_statement_begin__ = 507; + current_statement_begin__ = 524; if (as_bool(logical_eq(est_rw, 1))) { - current_statement_begin__ = 508; + current_statement_begin__ = 525; for (int k = 1; k <= K; ++k) { - current_statement_begin__ = 509; + current_statement_begin__ = 526; if (as_bool(logical_eq(use_normal, 0))) { - current_statement_begin__ = 510; + current_statement_begin__ = 527; for (int t = 1; t <= 1; ++t) { - current_statement_begin__ = 511; + current_statement_begin__ = 528; if (as_bool(logical_eq(estimate_nu, 1))) { - current_statement_begin__ = 512; + current_statement_begin__ = 529; lp_accum__.add(student_t_log(get_base1(devs, k, t, "devs", 1), get_base1(nu, 1, "nu", 1), 0, get_base1(sigma_pro, k, "sigma_pro", 1))); } else { - current_statement_begin__ = 514; + current_statement_begin__ = 531; lp_accum__.add(student_t_log(get_base1(devs, k, t, "devs", 1), nu_fixed, 0, get_base1(sigma_pro, k, "sigma_pro", 1))); } } - current_statement_begin__ = 517; + current_statement_begin__ = 534; for (int t = 2; t <= (N - 1); ++t) { - current_statement_begin__ = 519; + current_statement_begin__ = 536; if (as_bool(logical_eq(estimate_nu, 1))) { - current_statement_begin__ = 520; + current_statement_begin__ = 537; lp_accum__.add(student_t_log(get_base1(devs, k, t, "devs", 1), get_base1(nu, 1, "nu", 1), (get_base1(theta_vec, k, "theta_vec", 1) * get_base1(devs, k, (t - 1), "devs", 1)), get_base1(sigma_pro, k, "sigma_pro", 1))); } else { - current_statement_begin__ = 522; + current_statement_begin__ = 539; lp_accum__.add(student_t_log(get_base1(devs, k, t, "devs", 1), nu_fixed, (get_base1(theta_vec, k, "theta_vec", 1) * get_base1(devs, k, (t - 1), "devs", 1)), get_base1(sigma_pro, k, "sigma_pro", 1))); } } } else { - current_statement_begin__ = 527; + current_statement_begin__ = 544; lp_accum__.add(normal_log(get_base1(devs, k, 1, "devs", 1), 0, 1)); - current_statement_begin__ = 528; + current_statement_begin__ = 545; for (int t = 2; t <= (N - 1); ++t) { - current_statement_begin__ = 530; + current_statement_begin__ = 547; lp_accum__.add(normal_log(get_base1(devs, k, t, "devs", 1), (get_base1(theta_vec, k, "theta_vec", 1) * get_base1(devs, k, (t - 1), "devs", 1)), get_base1(sigma_pro, k, "sigma_pro", 1))); } } } } - current_statement_begin__ = 536; + current_statement_begin__ = 553; if (as_bool(logical_eq(est_spline, 1))) { - current_statement_begin__ = 537; + current_statement_begin__ = 554; for (int k = 1; k <= K; ++k) { - current_statement_begin__ = 538; + current_statement_begin__ = 555; lp_accum__.add(std_normal_log(get_base1(spline_a, k, "spline_a", 1))); } } - current_statement_begin__ = 542; + current_statement_begin__ = 559; if (as_bool(logical_eq(proportional_model, 0))) { - current_statement_begin__ = 544; + current_statement_begin__ = 561; lp_accum__.add(std_normal_log(z)); - current_statement_begin__ = 545; + current_statement_begin__ = 562; lp_accum__.add(std_normal_log(zpos)); } else { - current_statement_begin__ = 547; + current_statement_begin__ = 564; for (int p = 1; p <= P; ++p) { - current_statement_begin__ = 548; + current_statement_begin__ = 565; lp_accum__.add(dirichlet_log(get_base1(p_z, p, "p_z", 1), alpha_vec)); } } - current_statement_begin__ = 553; + current_statement_begin__ = 570; if (as_bool(logical_eq(est_cor, 0))) { - current_statement_begin__ = 554; + current_statement_begin__ = 571; if (as_bool(logical_eq(long_format, 0))) { - current_statement_begin__ = 555; + current_statement_begin__ = 572; if (as_bool(logical_eq(obs_model, 1))) { - current_statement_begin__ = 555; + current_statement_begin__ = 572; for (int i = 1; i <= P; ++i) { - current_statement_begin__ = 555; + current_statement_begin__ = 572; lp_accum__.add(normal_log(get_base1(yall, i, "yall", 1), get_base1(pred, i, "pred", 1), get_base1(sigma_vec, i, "sigma_vec", 1))); } } } else { - current_statement_begin__ = 557; + current_statement_begin__ = 574; if (as_bool(logical_eq(obs_model, 1))) { - current_statement_begin__ = 557; + current_statement_begin__ = 574; for (int i = 1; i <= n_pos; ++i) { - current_statement_begin__ = 557; + current_statement_begin__ = 574; lp_accum__.add(normal_log(get_base1(y, i, "y", 1), (get_base1(pred, get_base1(row_indx_pos, i, "row_indx_pos", 1), get_base1(col_indx_pos, i, "col_indx_pos", 1), "pred", 1) + get_base1(obs_cov_offset, i, "obs_cov_offset", 1)), get_base1(sigma_vec, get_base1(row_indx_pos, i, "row_indx_pos", 1), "sigma_vec", 1))); } } - current_statement_begin__ = 558; + current_statement_begin__ = 575; if (as_bool(logical_eq(obs_model, 2))) { - current_statement_begin__ = 558; + current_statement_begin__ = 575; for (int i = 1; i <= n_pos; ++i) { - current_statement_begin__ = 558; + current_statement_begin__ = 575; lp_accum__.add(gamma_log(get_base1(y, i, "y", 1), get_base1(gamma_a_vec, get_base1(row_indx_pos, i, "row_indx_pos", 1), "gamma_a_vec", 1), (get_base1(gamma_a_vec, get_base1(row_indx_pos, i, "row_indx_pos", 1), "gamma_a_vec", 1) / stan::math::exp((get_base1(pred, get_base1(row_indx_pos, i, "row_indx_pos", 1), get_base1(col_indx_pos, i, "col_indx_pos", 1), "pred", 1) + get_base1(obs_cov_offset, i, "obs_cov_offset", 1)))))); } } - current_statement_begin__ = 559; + current_statement_begin__ = 576; if (as_bool(logical_eq(obs_model, 3))) { - current_statement_begin__ = 559; + current_statement_begin__ = 576; for (int i = 1; i <= n_pos; ++i) { - current_statement_begin__ = 559; + current_statement_begin__ = 576; lp_accum__.add(poisson_log_log(get_base1(y_int, i, "y_int", 1), (get_base1(pred, get_base1(row_indx_pos, i, "row_indx_pos", 1), get_base1(col_indx_pos, i, "col_indx_pos", 1), "pred", 1) + get_base1(obs_cov_offset, i, "obs_cov_offset", 1)))); } } - current_statement_begin__ = 560; + current_statement_begin__ = 577; if (as_bool(logical_eq(obs_model, 4))) { - current_statement_begin__ = 560; + current_statement_begin__ = 577; for (int i = 1; i <= n_pos; ++i) { - current_statement_begin__ = 560; + current_statement_begin__ = 577; lp_accum__.add(neg_binomial_2_log_log(get_base1(y_int, i, "y_int", 1), (get_base1(pred, get_base1(row_indx_pos, i, "row_indx_pos", 1), get_base1(col_indx_pos, i, "col_indx_pos", 1), "pred", 1) + get_base1(obs_cov_offset, i, "obs_cov_offset", 1)), get_base1(nb_phi_vec, get_base1(row_indx_pos, i, "row_indx_pos", 1), "nb_phi_vec", 1))); } } - current_statement_begin__ = 561; + current_statement_begin__ = 578; if (as_bool(logical_eq(obs_model, 5))) { - current_statement_begin__ = 561; + current_statement_begin__ = 578; for (int i = 1; i <= n_pos; ++i) { - current_statement_begin__ = 561; + current_statement_begin__ = 578; lp_accum__.add(bernoulli_logit_log(get_base1(y_int, i, "y_int", 1), (get_base1(pred, get_base1(row_indx_pos, i, "row_indx_pos", 1), get_base1(col_indx_pos, i, "col_indx_pos", 1), "pred", 1) + get_base1(obs_cov_offset, i, "obs_cov_offset", 1)))); } } - current_statement_begin__ = 562; + current_statement_begin__ = 579; if (as_bool(logical_eq(obs_model, 6))) { - current_statement_begin__ = 562; + current_statement_begin__ = 579; for (int i = 1; i <= n_pos; ++i) { - current_statement_begin__ = 562; + current_statement_begin__ = 579; lp_accum__.add(lognormal_log(get_base1(y, i, "y", 1), (get_base1(pred, get_base1(row_indx_pos, i, "row_indx_pos", 1), get_base1(col_indx_pos, i, "col_indx_pos", 1), "pred", 1) + get_base1(obs_cov_offset, i, "obs_cov_offset", 1)), get_base1(sigma_vec, get_base1(row_indx_pos, i, "row_indx_pos", 1), "sigma_vec", 1))); } } } } else { - current_statement_begin__ = 566; + current_statement_begin__ = 583; if (as_bool(logical_eq(long_format, 0))) { - current_statement_begin__ = 567; + current_statement_begin__ = 584; if (as_bool(logical_eq(obs_model, 1))) { - current_statement_begin__ = 567; + current_statement_begin__ = 584; for (int i = 1; i <= N; ++i) { - current_statement_begin__ = 567; + current_statement_begin__ = 584; lp_accum__.add(multi_normal_cholesky_log(col(yall, i), col(pred, i), diag_pre_multiply(sigma_vec, Lcorr))); } } } else { - current_statement_begin__ = 569; + current_statement_begin__ = 586; if (as_bool(logical_eq(obs_model, 1))) { - current_statement_begin__ = 569; + current_statement_begin__ = 586; for (int i = 1; i <= n_pos; ++i) { - current_statement_begin__ = 569; + current_statement_begin__ = 586; lp_accum__.add(normal_log(get_base1(y, i, "y", 1), ((get_base1(pred, get_base1(row_indx_pos, i, "row_indx_pos", 1), get_base1(col_indx_pos, i, "col_indx_pos", 1), "pred", 1) + get_base1(obs_cov_offset, i, "obs_cov_offset", 1)) + get_base1(cond_mean_vec, get_base1(row_indx_pos, i, "row_indx_pos", 1), "cond_mean_vec", 1)), get_base1(cond_sigma_vec, get_base1(row_indx_pos, i, "row_indx_pos", 1), "cond_sigma_vec", 1))); } } @@ -2645,7 +2702,7 @@ class model_dfa dims__.push_back(K); dimss__.push_back(dims__); dims__.resize(0); - dims__.push_back((K * (1 - proportional_model))); + dims__.push_back(((K * (1 - proportional_model)) * use_expansion_prior)); dimss__.push_back(dims__); dims__.resize(0); dims__.push_back((nZ * (1 - proportional_model))); @@ -2739,7 +2796,7 @@ class model_dfa dims__.push_back(K); dimss__.push_back(dims__); dims__.resize(0); - dims__.push_back(K); + dims__.push_back((K * use_expansion_prior)); dimss__.push_back(dims__); dims__.resize(0); dims__.push_back(((n_pcor * long_format) * est_cor)); @@ -2839,8 +2896,8 @@ class model_dfa for (size_t j_1__ = 0; j_1__ < x0_j_1_max__; ++j_1__) { vars__.push_back(x0(j_1__)); } - Eigen::Matrix psi = in__.vector_lb_constrain(0, (K * (1 - proportional_model))); - size_t psi_j_1_max__ = (K * (1 - proportional_model)); + Eigen::Matrix psi = in__.vector_lb_constrain(0, ((K * (1 - proportional_model)) * use_expansion_prior)); + size_t psi_j_1_max__ = ((K * (1 - proportional_model)) * use_expansion_prior); for (size_t j_1__ = 0; j_1__ < psi_j_1_max__; ++j_1__) { vars__.push_back(psi(j_1__)); } @@ -2849,7 +2906,7 @@ class model_dfa for (size_t j_1__ = 0; j_1__ < z_j_1_max__; ++j_1__) { vars__.push_back(z(j_1__)); } - Eigen::Matrix zpos = in__.vector_lb_constrain(0, (K * (1 - proportional_model))); + Eigen::Matrix zpos = in__.vector_lb_constrain(lower_bound_z, (K * (1 - proportional_model))); size_t zpos_j_1_max__ = (K * (1 - proportional_model)); for (size_t j_1__ = 0; j_1__ < zpos_j_1_max__; ++j_1__) { vars__.push_back(zpos(j_1__)); @@ -3010,152 +3067,152 @@ class model_dfa if (!include_tparams__ && !include_gqs__) return; try { // declare and define transformed parameters - current_statement_begin__ = 192; + current_statement_begin__ = 198; validate_non_negative_index("pred", "P", P); validate_non_negative_index("pred", "N", N); Eigen::Matrix pred(P, N); stan::math::initialize(pred, DUMMY_VAR__); stan::math::fill(pred, DUMMY_VAR__); - current_statement_begin__ = 193; + current_statement_begin__ = 199; validate_non_negative_index("Z", "P", P); validate_non_negative_index("Z", "K", K); Eigen::Matrix Z(P, K); stan::math::initialize(Z, DUMMY_VAR__); stan::math::fill(Z, DUMMY_VAR__); - current_statement_begin__ = 194; + current_statement_begin__ = 200; validate_non_negative_index("yall", "P", P); validate_non_negative_index("yall", "N", N); Eigen::Matrix yall(P, N); stan::math::initialize(yall, DUMMY_VAR__); stan::math::fill(yall, DUMMY_VAR__); - current_statement_begin__ = 195; + current_statement_begin__ = 201; validate_non_negative_index("sigma_vec", "(P * est_sigma_params)", (P * est_sigma_params)); Eigen::Matrix sigma_vec((P * est_sigma_params)); stan::math::initialize(sigma_vec, DUMMY_VAR__); stan::math::fill(sigma_vec, DUMMY_VAR__); - current_statement_begin__ = 196; + current_statement_begin__ = 202; validate_non_negative_index("gamma_a_vec", "(P * est_gamma_params)", (P * est_gamma_params)); Eigen::Matrix gamma_a_vec((P * est_gamma_params)); stan::math::initialize(gamma_a_vec, DUMMY_VAR__); stan::math::fill(gamma_a_vec, DUMMY_VAR__); - current_statement_begin__ = 197; + current_statement_begin__ = 203; validate_non_negative_index("nb_phi_vec", "(P * est_nb2_params)", (P * est_nb2_params)); Eigen::Matrix nb_phi_vec((P * est_nb2_params)); stan::math::initialize(nb_phi_vec, DUMMY_VAR__); stan::math::fill(nb_phi_vec, DUMMY_VAR__); - current_statement_begin__ = 198; + current_statement_begin__ = 204; validate_non_negative_index("phi_vec", "K", K); Eigen::Matrix phi_vec(K); stan::math::initialize(phi_vec, DUMMY_VAR__); stan::math::fill(phi_vec, DUMMY_VAR__); - current_statement_begin__ = 199; + current_statement_begin__ = 205; validate_non_negative_index("theta_vec", "K", K); Eigen::Matrix theta_vec(K); stan::math::initialize(theta_vec, DUMMY_VAR__); stan::math::fill(theta_vec, DUMMY_VAR__); - current_statement_begin__ = 200; + current_statement_begin__ = 206; validate_non_negative_index("x", "K", K); validate_non_negative_index("x", "N", N); Eigen::Matrix x(K, N); stan::math::initialize(x, DUMMY_VAR__); stan::math::fill(x, DUMMY_VAR__); - current_statement_begin__ = 201; + current_statement_begin__ = 207; validate_non_negative_index("indicator", "K", K); Eigen::Matrix indicator(K); stan::math::initialize(indicator, DUMMY_VAR__); stan::math::fill(indicator, DUMMY_VAR__); - current_statement_begin__ = 202; - validate_non_negative_index("psi_root", "K", K); - Eigen::Matrix psi_root(K); + current_statement_begin__ = 208; + validate_non_negative_index("psi_root", "(K * use_expansion_prior)", (K * use_expansion_prior)); + Eigen::Matrix psi_root((K * use_expansion_prior)); stan::math::initialize(psi_root, DUMMY_VAR__); stan::math::fill(psi_root, DUMMY_VAR__); - current_statement_begin__ = 203; + current_statement_begin__ = 209; validate_non_negative_index("Sigma_derived", "((n_pcor * long_format) * est_cor)", ((n_pcor * long_format) * est_cor)); validate_non_negative_index("Sigma_derived", "((n_pcor * long_format) * est_cor)", ((n_pcor * long_format) * est_cor)); Eigen::Matrix Sigma_derived(((n_pcor * long_format) * est_cor), ((n_pcor * long_format) * est_cor)); stan::math::initialize(Sigma_derived, DUMMY_VAR__); stan::math::fill(Sigma_derived, DUMMY_VAR__); - current_statement_begin__ = 204; + current_statement_begin__ = 210; validate_non_negative_index("Sigma_temp", "(((n_pcor - 1) * long_format) * est_cor)", (((n_pcor - 1) * long_format) * est_cor)); validate_non_negative_index("Sigma_temp", "(((n_pcor - 1) * long_format) * est_cor)", (((n_pcor - 1) * long_format) * est_cor)); Eigen::Matrix Sigma_temp((((n_pcor - 1) * long_format) * est_cor), (((n_pcor - 1) * long_format) * est_cor)); stan::math::initialize(Sigma_temp, DUMMY_VAR__); stan::math::fill(Sigma_temp, DUMMY_VAR__); - current_statement_begin__ = 205; + current_statement_begin__ = 211; validate_non_negative_index("sigma12_vec", "(n_pcor - 1)", (n_pcor - 1)); validate_non_negative_index("sigma12_vec", "1", 1); Eigen::Matrix sigma12_vec((n_pcor - 1), 1); stan::math::initialize(sigma12_vec, DUMMY_VAR__); stan::math::fill(sigma12_vec, DUMMY_VAR__); - current_statement_begin__ = 206; + current_statement_begin__ = 212; validate_non_negative_index("temp_sums", "((P * long_format) * est_cor)", ((P * long_format) * est_cor)); validate_non_negative_index("temp_sums", "((N * long_format) * est_cor)", ((N * long_format) * est_cor)); Eigen::Matrix temp_sums(((P * long_format) * est_cor), ((N * long_format) * est_cor)); stan::math::initialize(temp_sums, DUMMY_VAR__); stan::math::fill(temp_sums, DUMMY_VAR__); - current_statement_begin__ = 207; + current_statement_begin__ = 213; validate_non_negative_index("temp_counts", "((P * long_format) * est_cor)", ((P * long_format) * est_cor)); validate_non_negative_index("temp_counts", "((N * long_format) * est_cor)", ((N * long_format) * est_cor)); Eigen::Matrix temp_counts(((P * long_format) * est_cor), ((N * long_format) * est_cor)); stan::math::initialize(temp_counts, DUMMY_VAR__); stan::math::fill(temp_counts, DUMMY_VAR__); - current_statement_begin__ = 208; + current_statement_begin__ = 214; validate_non_negative_index("cond_sigma_vec", "((P * long_format) * est_cor)", ((P * long_format) * est_cor)); Eigen::Matrix cond_sigma_vec(((P * long_format) * est_cor)); stan::math::initialize(cond_sigma_vec, DUMMY_VAR__); stan::math::fill(cond_sigma_vec, DUMMY_VAR__); - current_statement_begin__ = 209; + current_statement_begin__ = 215; validate_non_negative_index("cond_mean_vec", "((P * long_format) * est_cor)", ((P * long_format) * est_cor)); Eigen::Matrix cond_mean_vec(((P * long_format) * est_cor)); stan::math::initialize(cond_mean_vec, DUMMY_VAR__); stan::math::fill(cond_mean_vec, DUMMY_VAR__); - current_statement_begin__ = 210; + current_statement_begin__ = 216; double sigma11; (void) sigma11; // dummy to suppress unused var warning stan::math::initialize(sigma11, DUMMY_VAR__); stan::math::fill(sigma11, DUMMY_VAR__); - current_statement_begin__ = 211; + current_statement_begin__ = 217; validate_non_negative_index("sigma_pro", "K", K); Eigen::Matrix sigma_pro(K); stan::math::initialize(sigma_pro, DUMMY_VAR__); stan::math::fill(sigma_pro, DUMMY_VAR__); - current_statement_begin__ = 212; + current_statement_begin__ = 218; validate_non_negative_index("spline_a_trans", "(K * est_spline)", (K * est_spline)); validate_non_negative_index("spline_a_trans", "(n_knots * est_spline)", (n_knots * est_spline)); Eigen::Matrix spline_a_trans((K * est_spline), (n_knots * est_spline)); stan::math::initialize(spline_a_trans, DUMMY_VAR__); stan::math::fill(spline_a_trans, DUMMY_VAR__); - current_statement_begin__ = 213; + current_statement_begin__ = 219; validate_non_negative_index("SigmaKnots", "n_knots", n_knots); validate_non_negative_index("SigmaKnots", "n_knots", n_knots); validate_non_negative_index("SigmaKnots", "K", K); std::vector > SigmaKnots(K, Eigen::Matrix(n_knots, n_knots)); stan::math::initialize(SigmaKnots, DUMMY_VAR__); stan::math::fill(SigmaKnots, DUMMY_VAR__); - current_statement_begin__ = 216; + current_statement_begin__ = 222; validate_non_negative_index("obs_cov_offset", "n_pos", n_pos); Eigen::Matrix obs_cov_offset(n_pos); stan::math::initialize(obs_cov_offset, DUMMY_VAR__); stan::math::fill(obs_cov_offset, DUMMY_VAR__); // do transformed parameters statements - current_statement_begin__ = 219; + current_statement_begin__ = 225; for (int k = 1; k <= K; ++k) { - current_statement_begin__ = 220; + current_statement_begin__ = 226; stan::model::assign(sigma_pro, stan::model::cons_list(stan::model::index_uni(k), stan::model::nil_index_list()), 1, "assigning variable sigma_pro"); - current_statement_begin__ = 221; + current_statement_begin__ = 227; if (as_bool(logical_eq(est_sigma_process, 1))) { - current_statement_begin__ = 222; + current_statement_begin__ = 228; if (as_bool(logical_eq(n_sigma_process, 1))) { - current_statement_begin__ = 223; + current_statement_begin__ = 229; stan::model::assign(sigma_pro, stan::model::cons_list(stan::model::index_uni(k), stan::model::nil_index_list()), get_base1(sigma_process, 1, "sigma_process", 1), "assigning variable sigma_pro"); } else { - current_statement_begin__ = 225; + current_statement_begin__ = 231; stan::model::assign(sigma_pro, stan::model::cons_list(stan::model::index_uni(k), stan::model::nil_index_list()), get_base1(sigma_process, k, "sigma_process", 1), @@ -3163,70 +3220,94 @@ class model_dfa } } } - current_statement_begin__ = 231; + current_statement_begin__ = 237; if (as_bool(logical_eq(est_phi, 1))) { - current_statement_begin__ = 233; - stan::math::assign(phi_vec, to_vector(phi)); + current_statement_begin__ = 238; + for (int k = 1; k <= K; ++k) { + current_statement_begin__ = 238; + stan::model::assign(phi_vec, + stan::model::cons_list(stan::model::index_uni(k), stan::model::nil_index_list()), + get_base1(phi, k, "phi", 1), + "assigning variable phi_vec"); + } } else { - current_statement_begin__ = 236; - stan::math::assign(phi_vec, rep_vector(1.0, K)); + current_statement_begin__ = 241; + for (int k = 1; k <= K; ++k) { + current_statement_begin__ = 241; + stan::model::assign(phi_vec, + stan::model::cons_list(stan::model::index_uni(k), stan::model::nil_index_list()), + 1, + "assigning variable phi_vec"); + } } - current_statement_begin__ = 240; + current_statement_begin__ = 246; if (as_bool(logical_eq(est_theta, 1))) { - current_statement_begin__ = 242; - stan::math::assign(theta_vec, to_vector(theta)); + current_statement_begin__ = 247; + for (int k = 1; k <= K; ++k) { + current_statement_begin__ = 247; + stan::model::assign(theta_vec, + stan::model::cons_list(stan::model::index_uni(k), stan::model::nil_index_list()), + get_base1(theta, k, "theta", 1), + "assigning variable theta_vec"); + } } else { - current_statement_begin__ = 245; - stan::math::assign(theta_vec, rep_vector(1.0, K)); + current_statement_begin__ = 250; + for (int k = 1; k <= K; ++k) { + current_statement_begin__ = 250; + stan::model::assign(theta_vec, + stan::model::cons_list(stan::model::index_uni(k), stan::model::nil_index_list()), + 0, + "assigning variable theta_vec"); + } } - current_statement_begin__ = 248; + current_statement_begin__ = 254; if (as_bool(logical_eq(est_sigma_params, 1))) { - current_statement_begin__ = 249; + current_statement_begin__ = 255; for (int p = 1; p <= P; ++p) { - current_statement_begin__ = 249; + current_statement_begin__ = 255; stan::model::assign(sigma_vec, stan::model::cons_list(stan::model::index_uni(p), stan::model::nil_index_list()), get_base1(sigma, get_base1(varIndx, p, "varIndx", 1), "sigma", 1), "assigning variable sigma_vec"); } } - current_statement_begin__ = 251; + current_statement_begin__ = 257; if (as_bool(logical_eq(est_gamma_params, 1))) { - current_statement_begin__ = 252; + current_statement_begin__ = 258; for (int p = 1; p <= P; ++p) { - current_statement_begin__ = 252; + current_statement_begin__ = 258; stan::model::assign(gamma_a_vec, stan::model::cons_list(stan::model::index_uni(p), stan::model::nil_index_list()), get_base1(gamma_a, get_base1(varIndx, p, "varIndx", 1), "gamma_a", 1), "assigning variable gamma_a_vec"); } } - current_statement_begin__ = 254; + current_statement_begin__ = 260; if (as_bool(logical_eq(est_nb2_params, 1))) { - current_statement_begin__ = 255; + current_statement_begin__ = 261; for (int p = 1; p <= P; ++p) { - current_statement_begin__ = 255; + current_statement_begin__ = 261; stan::model::assign(nb_phi_vec, stan::model::cons_list(stan::model::index_uni(p), stan::model::nil_index_list()), get_base1(nb2_phi, get_base1(varIndx, p, "varIndx", 1), "nb2_phi", 1), "assigning variable nb_phi_vec"); } } - current_statement_begin__ = 258; + current_statement_begin__ = 264; if (as_bool(logical_eq(long_format, 0))) { - current_statement_begin__ = 260; + current_statement_begin__ = 266; for (int i = 1; i <= n_pos; ++i) { - current_statement_begin__ = 261; + current_statement_begin__ = 267; stan::model::assign(yall, stan::model::cons_list(stan::model::index_uni(get_base1(row_indx_pos, i, "row_indx_pos", 1)), stan::model::cons_list(stan::model::index_uni(get_base1(col_indx_pos, i, "col_indx_pos", 1)), stan::model::nil_index_list())), get_base1(y, i, "y", 1), "assigning variable yall"); } - current_statement_begin__ = 264; + current_statement_begin__ = 270; if (as_bool(logical_gt(n_na, 0))) { - current_statement_begin__ = 265; + current_statement_begin__ = 271; for (int i = 1; i <= n_na; ++i) { - current_statement_begin__ = 266; + current_statement_begin__ = 272; stan::model::assign(yall, stan::model::cons_list(stan::model::index_uni(get_base1(row_indx_na, i, "row_indx_na", 1)), stan::model::cons_list(stan::model::index_uni(get_base1(col_indx_na, i, "col_indx_na", 1)), stan::model::nil_index_list())), get_base1(ymiss, i, "ymiss", 1), @@ -3234,77 +3315,80 @@ class model_dfa } } } - current_statement_begin__ = 271; + current_statement_begin__ = 277; if (as_bool(logical_eq(proportional_model, 0))) { - current_statement_begin__ = 272; + current_statement_begin__ = 278; for (int i = 1; i <= nZ; ++i) { - current_statement_begin__ = 273; + current_statement_begin__ = 279; stan::model::assign(Z, stan::model::cons_list(stan::model::index_uni(get_base1(row_indx, i, "row_indx", 1)), stan::model::cons_list(stan::model::index_uni(get_base1(col_indx, i, "col_indx", 1)), stan::model::nil_index_list())), get_base1(z, i, "z", 1), "assigning variable Z"); } - current_statement_begin__ = 276; + current_statement_begin__ = 282; if (as_bool(logical_gt(nZero, 2))) { - current_statement_begin__ = 277; + current_statement_begin__ = 283; for (int i = 1; i <= (nZero - 2); ++i) { - current_statement_begin__ = 278; + current_statement_begin__ = 284; stan::model::assign(Z, stan::model::cons_list(stan::model::index_uni(get_base1(row_indx_z, i, "row_indx_z", 1)), stan::model::cons_list(stan::model::index_uni(get_base1(col_indx_z, i, "col_indx_z", 1)), stan::model::nil_index_list())), 0, "assigning variable Z"); } } - current_statement_begin__ = 281; + current_statement_begin__ = 287; for (int k = 1; k <= K; ++k) { - current_statement_begin__ = 282; + current_statement_begin__ = 288; stan::model::assign(Z, stan::model::cons_list(stan::model::index_uni(k), stan::model::cons_list(stan::model::index_uni(k), stan::model::nil_index_list())), get_base1(zpos, k, "zpos", 1), "assigning variable Z"); } - current_statement_begin__ = 285; - for (int k = 1; k <= K; ++k) { - current_statement_begin__ = 286; - if (as_bool(logical_lt(get_base1(zpos, k, "zpos", 1), 0))) { - current_statement_begin__ = 287; - stan::model::assign(indicator, - stan::model::cons_list(stan::model::index_uni(k), stan::model::nil_index_list()), - -(1), - "assigning variable indicator"); - } else { - current_statement_begin__ = 289; - stan::model::assign(indicator, - stan::model::cons_list(stan::model::index_uni(k), stan::model::nil_index_list()), - 1, - "assigning variable indicator"); - } - current_statement_begin__ = 291; - stan::model::assign(psi_root, - stan::model::cons_list(stan::model::index_uni(k), stan::model::nil_index_list()), - stan::math::sqrt(get_base1(psi, k, "psi", 1)), - "assigning variable psi_root"); + current_statement_begin__ = 291; + if (as_bool(logical_eq(use_expansion_prior, 1))) { current_statement_begin__ = 292; - for (int p = 1; p <= P; ++p) { + for (int k = 1; k <= K; ++k) { current_statement_begin__ = 293; - stan::model::assign(Z, - stan::model::cons_list(stan::model::index_uni(p), stan::model::cons_list(stan::model::index_uni(k), stan::model::nil_index_list())), - ((get_base1(Z, p, k, "Z", 1) * get_base1(indicator, k, "indicator", 1)) * (1 / get_base1(psi_root, k, "psi_root", 1))), - "assigning variable Z"); + if (as_bool(logical_lt(get_base1(zpos, k, "zpos", 1), 0))) { + current_statement_begin__ = 294; + stan::model::assign(indicator, + stan::model::cons_list(stan::model::index_uni(k), stan::model::nil_index_list()), + -(1), + "assigning variable indicator"); + } else { + current_statement_begin__ = 296; + stan::model::assign(indicator, + stan::model::cons_list(stan::model::index_uni(k), stan::model::nil_index_list()), + 1, + "assigning variable indicator"); + } + current_statement_begin__ = 299; + stan::model::assign(psi_root, + stan::model::cons_list(stan::model::index_uni(k), stan::model::nil_index_list()), + stan::math::sqrt(get_base1(psi, k, "psi", 1)), + "assigning variable psi_root"); + current_statement_begin__ = 300; + for (int p = 1; p <= P; ++p) { + current_statement_begin__ = 302; + stan::model::assign(Z, + stan::model::cons_list(stan::model::index_uni(p), stan::model::cons_list(stan::model::index_uni(k), stan::model::nil_index_list())), + ((get_base1(Z, p, k, "Z", 1) * get_base1(indicator, k, "indicator", 1)) * (1 / get_base1(psi_root, k, "psi_root", 1))), + "assigning variable Z"); + } } } - current_statement_begin__ = 297; + current_statement_begin__ = 308; if (as_bool(logical_eq(est_rw, 1))) { - current_statement_begin__ = 298; + current_statement_begin__ = 309; for (int k = 1; k <= K; ++k) { - current_statement_begin__ = 299; + current_statement_begin__ = 310; stan::model::assign(x, stan::model::cons_list(stan::model::index_uni(k), stan::model::cons_list(stan::model::index_uni(1), stan::model::nil_index_list())), get_base1(x0, k, "x0", 1), "assigning variable x"); - current_statement_begin__ = 303; + current_statement_begin__ = 314; for (int t = 2; t <= N; ++t) { - current_statement_begin__ = 304; + current_statement_begin__ = 315; stan::model::assign(x, stan::model::cons_list(stan::model::index_uni(k), stan::model::cons_list(stan::model::index_uni(t), stan::model::nil_index_list())), ((get_base1(phi_vec, k, "phi_vec", 1) * get_base1(x, k, (t - 1), "x", 1)) + get_base1(devs, k, (t - 1), "devs", 1)), @@ -3312,53 +3396,53 @@ class model_dfa } } } - current_statement_begin__ = 308; + current_statement_begin__ = 319; if (as_bool(logical_eq(est_spline, 1))) { - current_statement_begin__ = 310; + current_statement_begin__ = 321; for (int k = 1; k <= K; ++k) { - current_statement_begin__ = 310; + current_statement_begin__ = 321; stan::model::assign(spline_a_trans, stan::model::cons_list(stan::model::index_uni(k), stan::model::nil_index_list()), multiply(get_base1(spline_a, k, "spline_a", 1), get_base1(sigma_pro, k, "sigma_pro", 1)), "assigning variable spline_a_trans"); } - current_statement_begin__ = 311; + current_statement_begin__ = 322; stan::math::assign(x, multiply(spline_a_trans, B_spline)); - current_statement_begin__ = 312; + current_statement_begin__ = 323; for (int k = 1; k <= K; ++k) { - current_statement_begin__ = 312; + current_statement_begin__ = 323; stan::model::assign(x, stan::model::cons_list(stan::model::index_uni(k), stan::model::nil_index_list()), add(get_base1(x0, k, "x0", 1), get_base1(x, k, "x", 1)), "assigning variable x"); } } - current_statement_begin__ = 314; + current_statement_begin__ = 325; if (as_bool(logical_eq(est_gp, 1))) { - current_statement_begin__ = 316; + current_statement_begin__ = 327; for (int k = 1; k <= K; ++k) { - current_statement_begin__ = 317; + current_statement_begin__ = 328; stan::model::assign(SigmaKnots, stan::model::cons_list(stan::model::index_uni(k), stan::model::nil_index_list()), cov_exp_quad(knot_locs, get_base1(sigma_pro, k, "sigma_pro", 1), get_base1(gp_theta, k, "gp_theta", 1)), "assigning variable SigmaKnots"); - current_statement_begin__ = 320; + current_statement_begin__ = 331; for (int i = 1; i <= n_knots; ++i) { - current_statement_begin__ = 321; + current_statement_begin__ = 332; stan::model::assign(SigmaKnots, stan::model::cons_list(stan::model::index_uni(k), stan::model::cons_list(stan::model::index_uni(i), stan::model::cons_list(stan::model::index_uni(i), stan::model::nil_index_list()))), (stan::model::rvalue(SigmaKnots, stan::model::cons_list(stan::model::index_uni(k), stan::model::cons_list(stan::model::index_uni(i), stan::model::cons_list(stan::model::index_uni(i), stan::model::nil_index_list()))), "SigmaKnots") + gp_delta), "assigning variable SigmaKnots"); } - current_statement_begin__ = 330; + current_statement_begin__ = 341; if (as_bool(logical_eq(n_knots, N))) { - current_statement_begin__ = 332; + current_statement_begin__ = 343; stan::model::assign(x, stan::model::cons_list(stan::model::index_uni(k), stan::model::nil_index_list()), to_row_vector(multiply(cholesky_decompose(get_base1(SigmaKnots, k, "SigmaKnots", 1)), get_base1(effectsKnots, k, "effectsKnots", 1))), "assigning variable x"); } else { - current_statement_begin__ = 334; + current_statement_begin__ = 345; stan::model::assign(x, stan::model::cons_list(stan::model::index_uni(k), stan::model::nil_index_list()), to_row_vector(multiply(multiply(multiply(cov_exp_quad(data_locs, knot_locs, get_base1(sigma_pro, k, "sigma_pro", 1), get_base1(gp_theta, k, "gp_theta", 1)), inverse_spd(get_base1(SigmaKnots, k, "SigmaKnots", 1))), cholesky_decompose(get_base1(SigmaKnots, k, "SigmaKnots", 1))), get_base1(effectsKnots, k, "effectsKnots", 1))), @@ -3366,29 +3450,32 @@ class model_dfa } } } - current_statement_begin__ = 340; - for (int k = 1; k <= K; ++k) { - current_statement_begin__ = 342; - stan::model::assign(x, - stan::model::cons_list(stan::model::index_uni(k), stan::model::nil_index_list()), - multiply(multiply(get_base1(x, k, "x", 1), get_base1(indicator, k, "indicator", 1)), get_base1(psi_root, k, "psi_root", 1)), - "assigning variable x"); + current_statement_begin__ = 351; + if (as_bool(logical_eq(use_expansion_prior, 1))) { + current_statement_begin__ = 352; + for (int k = 1; k <= K; ++k) { + current_statement_begin__ = 355; + stan::model::assign(x, + stan::model::cons_list(stan::model::index_uni(k), stan::model::nil_index_list()), + multiply(multiply(get_base1(x, k, "x", 1), get_base1(indicator, k, "indicator", 1)), get_base1(psi_root, k, "psi_root", 1)), + "assigning variable x"); + } } } - current_statement_begin__ = 346; + current_statement_begin__ = 360; if (as_bool(logical_eq(proportional_model, 1))) { - current_statement_begin__ = 348; + current_statement_begin__ = 362; if (as_bool(logical_eq(est_rw, 1))) { - current_statement_begin__ = 349; + current_statement_begin__ = 363; for (int k = 1; k <= K; ++k) { - current_statement_begin__ = 350; + current_statement_begin__ = 364; stan::model::assign(x, stan::model::cons_list(stan::model::index_uni(k), stan::model::cons_list(stan::model::index_uni(1), stan::model::nil_index_list())), get_base1(x0, k, "x0", 1), "assigning variable x"); - current_statement_begin__ = 354; + current_statement_begin__ = 368; for (int t = 2; t <= N; ++t) { - current_statement_begin__ = 355; + current_statement_begin__ = 369; stan::model::assign(x, stan::model::cons_list(stan::model::index_uni(k), stan::model::cons_list(stan::model::index_uni(t), stan::model::nil_index_list())), ((get_base1(phi_vec, k, "phi_vec", 1) * get_base1(x, k, (t - 1), "x", 1)) + get_base1(devs, k, (t - 1), "devs", 1)), @@ -3396,53 +3483,53 @@ class model_dfa } } } - current_statement_begin__ = 359; + current_statement_begin__ = 373; if (as_bool(logical_eq(est_spline, 1))) { - current_statement_begin__ = 360; + current_statement_begin__ = 374; for (int k = 1; k <= K; ++k) { - current_statement_begin__ = 360; + current_statement_begin__ = 374; stan::model::assign(spline_a_trans, stan::model::cons_list(stan::model::index_uni(k), stan::model::nil_index_list()), multiply(get_base1(spline_a, k, "spline_a", 1), get_base1(sigma_pro, k, "sigma_pro", 1)), "assigning variable spline_a_trans"); } - current_statement_begin__ = 361; + current_statement_begin__ = 375; stan::math::assign(x, multiply(spline_a_trans, B_spline)); - current_statement_begin__ = 362; + current_statement_begin__ = 376; for (int k = 1; k <= K; ++k) { - current_statement_begin__ = 362; + current_statement_begin__ = 376; stan::model::assign(x, stan::model::cons_list(stan::model::index_uni(k), stan::model::nil_index_list()), add(get_base1(x0, k, "x0", 1), get_base1(x, k, "x", 1)), "assigning variable x"); } } - current_statement_begin__ = 364; + current_statement_begin__ = 378; if (as_bool(logical_eq(est_gp, 1))) { - current_statement_begin__ = 365; + current_statement_begin__ = 379; for (int k = 1; k <= K; ++k) { - current_statement_begin__ = 366; + current_statement_begin__ = 380; stan::model::assign(SigmaKnots, stan::model::cons_list(stan::model::index_uni(k), stan::model::nil_index_list()), cov_exp_quad(knot_locs, get_base1(sigma_pro, k, "sigma_pro", 1), get_base1(gp_theta, k, "gp_theta", 1)), "assigning variable SigmaKnots"); - current_statement_begin__ = 369; + current_statement_begin__ = 383; for (int i = 1; i <= n_knots; ++i) { - current_statement_begin__ = 370; + current_statement_begin__ = 384; stan::model::assign(SigmaKnots, stan::model::cons_list(stan::model::index_uni(k), stan::model::cons_list(stan::model::index_uni(i), stan::model::cons_list(stan::model::index_uni(i), stan::model::nil_index_list()))), (stan::model::rvalue(SigmaKnots, stan::model::cons_list(stan::model::index_uni(k), stan::model::cons_list(stan::model::index_uni(i), stan::model::cons_list(stan::model::index_uni(i), stan::model::nil_index_list()))), "SigmaKnots") + gp_delta), "assigning variable SigmaKnots"); } - current_statement_begin__ = 379; + current_statement_begin__ = 393; if (as_bool(logical_eq(n_knots, N))) { - current_statement_begin__ = 381; + current_statement_begin__ = 395; stan::model::assign(x, stan::model::cons_list(stan::model::index_uni(k), stan::model::nil_index_list()), to_row_vector(multiply(cholesky_decompose(get_base1(SigmaKnots, k, "SigmaKnots", 1)), get_base1(effectsKnots, k, "effectsKnots", 1))), "assigning variable x"); } else { - current_statement_begin__ = 383; + current_statement_begin__ = 397; stan::model::assign(x, stan::model::cons_list(stan::model::index_uni(k), stan::model::nil_index_list()), to_row_vector(multiply(multiply(multiply(cov_exp_quad(data_locs, knot_locs, get_base1(sigma_pro, k, "sigma_pro", 1), get_base1(gp_theta, k, "gp_theta", 1)), inverse_spd(get_base1(SigmaKnots, k, "SigmaKnots", 1))), cholesky_decompose(get_base1(SigmaKnots, k, "SigmaKnots", 1))), get_base1(effectsKnots, k, "effectsKnots", 1))), @@ -3450,52 +3537,52 @@ class model_dfa } } } - current_statement_begin__ = 389; + current_statement_begin__ = 403; for (int p = 1; p <= P; ++p) { - current_statement_begin__ = 393; + current_statement_begin__ = 407; stan::model::assign(Z, stan::model::cons_list(stan::model::index_uni(p), stan::model::nil_index_list()), to_row_vector(get_base1(p_z, p, "p_z", 1)), "assigning variable Z"); } } - current_statement_begin__ = 398; + current_statement_begin__ = 412; if (as_bool(logical_gt(num_pro_covar, 0))) { - current_statement_begin__ = 399; + current_statement_begin__ = 413; for (int i = 1; i <= num_pro_covar; ++i) { - current_statement_begin__ = 401; + current_statement_begin__ = 415; stan::model::assign(x, stan::model::cons_list(stan::model::index_uni(get_base1(get_base1(pro_covar_index, i, "pro_covar_index", 1), 2, "pro_covar_index", 2)), stan::model::cons_list(stan::model::index_uni(get_base1(get_base1(pro_covar_index, i, "pro_covar_index", 1), 1, "pro_covar_index", 2)), stan::model::nil_index_list())), (stan::model::rvalue(x, stan::model::cons_list(stan::model::index_uni(get_base1(get_base1(pro_covar_index, i, "pro_covar_index", 1), 2, "pro_covar_index", 2)), stan::model::cons_list(stan::model::index_uni(get_base1(get_base1(pro_covar_index, i, "pro_covar_index", 1), 1, "pro_covar_index", 2)), stan::model::nil_index_list())), "x") + (get_base1(b_pro, get_base1(get_base1(pro_covar_index, i, "pro_covar_index", 1), 3, "pro_covar_index", 2), get_base1(get_base1(pro_covar_index, i, "pro_covar_index", 1), 2, "pro_covar_index", 2), "b_pro", 1) * get_base1(pro_covar_value, i, "pro_covar_value", 1))), "assigning variable x"); } } - current_statement_begin__ = 407; + current_statement_begin__ = 421; stan::math::assign(pred, multiply(Z, x)); - current_statement_begin__ = 409; + current_statement_begin__ = 424; for (int i = 1; i <= n_pos; ++i) { - current_statement_begin__ = 410; + current_statement_begin__ = 425; stan::model::assign(obs_cov_offset, stan::model::cons_list(stan::model::index_uni(i), stan::model::nil_index_list()), 0, "assigning variable obs_cov_offset"); } - current_statement_begin__ = 413; + current_statement_begin__ = 428; if (as_bool(logical_gt(num_obs_covar, 0))) { - current_statement_begin__ = 414; + current_statement_begin__ = 429; if (as_bool(logical_eq(long_format, 0))) { - current_statement_begin__ = 415; + current_statement_begin__ = 430; for (int i = 1; i <= num_obs_covar; ++i) { - current_statement_begin__ = 418; + current_statement_begin__ = 433; stan::model::assign(pred, stan::model::cons_list(stan::model::index_uni(get_base1(get_base1(obs_covar_index, i, "obs_covar_index", 1), 2, "obs_covar_index", 2)), stan::model::cons_list(stan::model::index_uni(get_base1(get_base1(obs_covar_index, i, "obs_covar_index", 1), 1, "obs_covar_index", 2)), stan::model::nil_index_list())), (stan::model::rvalue(pred, stan::model::cons_list(stan::model::index_uni(get_base1(get_base1(obs_covar_index, i, "obs_covar_index", 1), 2, "obs_covar_index", 2)), stan::model::cons_list(stan::model::index_uni(get_base1(get_base1(obs_covar_index, i, "obs_covar_index", 1), 1, "obs_covar_index", 2)), stan::model::nil_index_list())), "pred") + (get_base1(b_obs, get_base1(get_base1(obs_covar_index, i, "obs_covar_index", 1), 3, "obs_covar_index", 2), get_base1(get_base1(obs_covar_index, i, "obs_covar_index", 1), 2, "obs_covar_index", 2), "b_obs", 1) * get_base1(obs_covar_value, i, "obs_covar_value", 1))), "assigning variable pred"); } } else { - current_statement_begin__ = 423; + current_statement_begin__ = 438; for (int i = 1; i <= num_obs_covar; ++i) { - current_statement_begin__ = 424; + current_statement_begin__ = 439; stan::model::assign(obs_cov_offset, stan::model::cons_list(stan::model::index_uni(get_base1(match_obs_covar, i, "match_obs_covar", 1)), stan::model::nil_index_list()), (stan::model::rvalue(obs_cov_offset, stan::model::cons_list(stan::model::index_uni(get_base1(match_obs_covar, i, "match_obs_covar", 1)), stan::model::nil_index_list()), "obs_cov_offset") + (get_base1(b_obs, get_base1(get_base1(obs_covar_index, i, "obs_covar_index", 1), 3, "obs_covar_index", 2), get_base1(get_base1(obs_covar_index, i, "obs_covar_index", 1), 2, "obs_covar_index", 2), "b_obs", 1) * get_base1(obs_covar_value, i, "obs_covar_value", 1))), @@ -3503,64 +3590,64 @@ class model_dfa } } } - current_statement_begin__ = 429; + current_statement_begin__ = 444; if (as_bool((primitive_value(logical_eq(long_format, 1)) && primitive_value(logical_eq(est_cor, 1))))) { - current_statement_begin__ = 431; + current_statement_begin__ = 446; for (int n = 1; n <= N; ++n) { - current_statement_begin__ = 432; + current_statement_begin__ = 447; for (int p = 1; p <= P; ++p) { - current_statement_begin__ = 433; + current_statement_begin__ = 448; stan::model::assign(temp_sums, stan::model::cons_list(stan::model::index_uni(p), stan::model::cons_list(stan::model::index_uni(n), stan::model::nil_index_list())), 0.0, "assigning variable temp_sums"); - current_statement_begin__ = 434; + current_statement_begin__ = 449; stan::model::assign(temp_counts, stan::model::cons_list(stan::model::index_uni(p), stan::model::cons_list(stan::model::index_uni(n), stan::model::nil_index_list())), 0.0, "assigning variable temp_counts"); } } - current_statement_begin__ = 437; + current_statement_begin__ = 452; for (int i = 1; i <= n_pos; ++i) { - current_statement_begin__ = 438; + current_statement_begin__ = 453; stan::model::assign(temp_sums, stan::model::cons_list(stan::model::index_uni(get_base1(row_indx_pos, i, "row_indx_pos", 1)), stan::model::cons_list(stan::model::index_uni(get_base1(col_indx_pos, i, "col_indx_pos", 1)), stan::model::nil_index_list())), (stan::model::rvalue(temp_sums, stan::model::cons_list(stan::model::index_uni(get_base1(row_indx_pos, i, "row_indx_pos", 1)), stan::model::cons_list(stan::model::index_uni(get_base1(col_indx_pos, i, "col_indx_pos", 1)), stan::model::nil_index_list())), "temp_sums") + (get_base1(y, i, "y", 1) - get_base1(pred, get_base1(row_indx_pos, i, "row_indx_pos", 1), get_base1(col_indx_pos, i, "col_indx_pos", 1), "pred", 1))), "assigning variable temp_sums"); - current_statement_begin__ = 439; + current_statement_begin__ = 454; stan::model::assign(temp_counts, stan::model::cons_list(stan::model::index_uni(get_base1(row_indx_pos, i, "row_indx_pos", 1)), stan::model::cons_list(stan::model::index_uni(get_base1(col_indx_pos, i, "col_indx_pos", 1)), stan::model::nil_index_list())), (stan::model::rvalue(temp_counts, stan::model::cons_list(stan::model::index_uni(get_base1(row_indx_pos, i, "row_indx_pos", 1)), stan::model::cons_list(stan::model::index_uni(get_base1(col_indx_pos, i, "col_indx_pos", 1)), stan::model::nil_index_list())), "temp_counts") + 1), "assigning variable temp_counts"); } - current_statement_begin__ = 441; + current_statement_begin__ = 456; for (int n = 1; n <= N; ++n) { - current_statement_begin__ = 442; + current_statement_begin__ = 457; for (int p = 1; p <= P; ++p) { - current_statement_begin__ = 444; + current_statement_begin__ = 459; stan::model::assign(temp_sums, stan::model::cons_list(stan::model::index_uni(p), stan::model::cons_list(stan::model::index_uni(n), stan::model::nil_index_list())), (get_base1(temp_sums, p, n, "temp_sums", 1) / get_base1(temp_counts, p, n, "temp_counts", 1)), "assigning variable temp_sums"); } } - current_statement_begin__ = 448; + current_statement_begin__ = 463; stan::math::assign(Sigma_derived, quad_form_diag(multiply_lower_tri_self_transpose(Lcorr), sigma_vec)); - current_statement_begin__ = 450; + current_statement_begin__ = 465; for (int p = 1; p <= P; ++p) { - current_statement_begin__ = 451; + current_statement_begin__ = 466; stan::math::assign(sigma11, get_base1(Sigma_derived, p, p, "Sigma_derived", 1)); - current_statement_begin__ = 452; + current_statement_begin__ = 467; stan::math::assign(Sigma_temp, inverse(subset(Sigma_derived, p, P, pstream__))); - current_statement_begin__ = 453; + current_statement_begin__ = 468; stan::math::assign(sigma12_vec, subsetvec(Sigma_derived, p, P, pstream__)); - current_statement_begin__ = 455; + current_statement_begin__ = 470; stan::model::assign(cond_mean_vec, stan::model::cons_list(stan::model::index_uni(p), stan::model::nil_index_list()), multiply(multiply(to_row_vector(sigma12_vec), Sigma_temp), to_vector(subsetvec2(col(temp_sums, p), p, P, pstream__))), "assigning variable cond_mean_vec"); - current_statement_begin__ = 457; + current_statement_begin__ = 472; stan::model::assign(cond_sigma_vec, stan::model::cons_list(stan::model::index_uni(p), stan::model::nil_index_list()), stan::math::sqrt((sigma11 - multiply(multiply(to_row_vector(sigma12_vec), Sigma_temp), to_vector(sigma12_vec)))), @@ -3571,6 +3658,14 @@ class model_dfa // validate transformed parameters const char* function__ = "validate transformed params"; (void) function__; // dummy to suppress unused var warning + current_statement_begin__ = 201; + check_greater_or_equal(function__, "sigma_vec", sigma_vec, 0); + current_statement_begin__ = 202; + check_greater_or_equal(function__, "gamma_a_vec", gamma_a_vec, 0); + current_statement_begin__ = 203; + check_greater_or_equal(function__, "nb_phi_vec", nb_phi_vec, 0); + current_statement_begin__ = 208; + check_greater_or_equal(function__, "psi_root", psi_root, 0); // write transformed parameters if (include_tparams__) { size_t pred_j_2_max__ = N; @@ -3625,7 +3720,7 @@ class model_dfa for (size_t j_1__ = 0; j_1__ < indicator_j_1_max__; ++j_1__) { vars__.push_back(indicator(j_1__)); } - size_t psi_root_j_1_max__ = K; + size_t psi_root_j_1_max__ = (K * use_expansion_prior); for (size_t j_1__ = 0; j_1__ < psi_root_j_1_max__; ++j_1__) { vars__.push_back(psi_root(j_1__)); } @@ -3701,72 +3796,72 @@ class model_dfa } if (!include_gqs__) return; // declare and define generated quantities - current_statement_begin__ = 574; + current_statement_begin__ = 591; validate_non_negative_index("log_lik", "n_loglik", n_loglik); Eigen::Matrix log_lik(n_loglik); stan::math::initialize(log_lik, DUMMY_VAR__); stan::math::fill(log_lik, DUMMY_VAR__); - current_statement_begin__ = 575; + current_statement_begin__ = 592; validate_non_negative_index("Omega", "n_pcor", n_pcor); validate_non_negative_index("Omega", "n_pcor", n_pcor); Eigen::Matrix Omega(n_pcor, n_pcor); stan::math::initialize(Omega, DUMMY_VAR__); stan::math::fill(Omega, DUMMY_VAR__); - current_statement_begin__ = 576; + current_statement_begin__ = 593; validate_non_negative_index("Sigma", "n_pcor", n_pcor); validate_non_negative_index("Sigma", "n_pcor", n_pcor); Eigen::Matrix Sigma(n_pcor, n_pcor); stan::math::initialize(Sigma, DUMMY_VAR__); stan::math::fill(Sigma, DUMMY_VAR__); - current_statement_begin__ = 577; + current_statement_begin__ = 594; validate_non_negative_index("xstar", "K", K); validate_non_negative_index("xstar", "1", 1); Eigen::Matrix xstar(K, 1); stan::math::initialize(xstar, DUMMY_VAR__); stan::math::fill(xstar, DUMMY_VAR__); - current_statement_begin__ = 578; + current_statement_begin__ = 595; validate_non_negative_index("future_devs", "K", K); Eigen::Matrix future_devs(K); stan::math::initialize(future_devs, DUMMY_VAR__); stan::math::fill(future_devs, DUMMY_VAR__); - current_statement_begin__ = 579; + current_statement_begin__ = 596; validate_non_negative_index("SigmaKnots_pred", "n_knots", n_knots); validate_non_negative_index("SigmaKnots_pred", "n_knots", n_knots); Eigen::Matrix SigmaKnots_pred(n_knots, n_knots); stan::math::initialize(SigmaKnots_pred, DUMMY_VAR__); stan::math::fill(SigmaKnots_pred, DUMMY_VAR__); - current_statement_begin__ = 580; + current_statement_begin__ = 597; validate_non_negative_index("SigmaOffDiag_pred", "n_knots", n_knots); Eigen::Matrix SigmaOffDiag_pred(n_knots); stan::math::initialize(SigmaOffDiag_pred, DUMMY_VAR__); stan::math::fill(SigmaOffDiag_pred, DUMMY_VAR__); - current_statement_begin__ = 581; + current_statement_begin__ = 598; int j; (void) j; // dummy to suppress unused var warning stan::math::fill(j, std::numeric_limits::min()); // generated quantities statements - current_statement_begin__ = 582; + current_statement_begin__ = 599; stan::math::assign(j, 0); - current_statement_begin__ = 584; + current_statement_begin__ = 601; if (as_bool(logical_eq(est_cor, 1))) { - current_statement_begin__ = 585; + current_statement_begin__ = 602; stan::math::assign(Omega, multiply_lower_tri_self_transpose(Lcorr)); - current_statement_begin__ = 586; + current_statement_begin__ = 603; stan::math::assign(Sigma, quad_form_diag(Omega, sigma_vec)); } - current_statement_begin__ = 590; + current_statement_begin__ = 607; if (as_bool(logical_eq(est_cor, 0))) { - current_statement_begin__ = 591; + current_statement_begin__ = 608; if (as_bool(logical_eq(long_format, 0))) { - current_statement_begin__ = 592; + current_statement_begin__ = 609; stan::math::assign(j, 0); - current_statement_begin__ = 593; + current_statement_begin__ = 610; for (int n = 1; n <= N; ++n) { - current_statement_begin__ = 594; + current_statement_begin__ = 611; for (int p = 1; p <= P; ++p) { - current_statement_begin__ = 595; + current_statement_begin__ = 612; stan::math::assign(j, (j + 1)); - current_statement_begin__ = 596; + current_statement_begin__ = 613; stan::model::assign(log_lik, stan::model::cons_list(stan::model::index_uni(j), stan::model::nil_index_list()), normal_log(get_base1(yall, p, n, "yall", 1), get_base1(pred, p, n, "pred", 1), get_base1(sigma_vec, p, "sigma_vec", 1)), @@ -3774,66 +3869,66 @@ class model_dfa } } } else { - current_statement_begin__ = 600; + current_statement_begin__ = 617; if (as_bool(logical_eq(obs_model, 1))) { - current_statement_begin__ = 600; + current_statement_begin__ = 617; for (int i = 1; i <= n_pos; ++i) { - current_statement_begin__ = 600; + current_statement_begin__ = 617; stan::model::assign(log_lik, stan::model::cons_list(stan::model::index_uni(i), stan::model::nil_index_list()), normal_log(get_base1(y, i, "y", 1), (get_base1(pred, get_base1(row_indx_pos, i, "row_indx_pos", 1), get_base1(col_indx_pos, i, "col_indx_pos", 1), "pred", 1) + get_base1(obs_cov_offset, i, "obs_cov_offset", 1)), get_base1(sigma_vec, get_base1(row_indx_pos, i, "row_indx_pos", 1), "sigma_vec", 1)), "assigning variable log_lik"); } } - current_statement_begin__ = 601; + current_statement_begin__ = 618; if (as_bool(logical_eq(obs_model, 2))) { - current_statement_begin__ = 601; + current_statement_begin__ = 618; for (int i = 1; i <= n_pos; ++i) { - current_statement_begin__ = 601; + current_statement_begin__ = 618; stan::model::assign(log_lik, stan::model::cons_list(stan::model::index_uni(i), stan::model::nil_index_list()), gamma_log(get_base1(y, i, "y", 1), get_base1(gamma_a_vec, get_base1(row_indx_pos, i, "row_indx_pos", 1), "gamma_a_vec", 1), (get_base1(gamma_a_vec, get_base1(row_indx_pos, i, "row_indx_pos", 1), "gamma_a_vec", 1) / stan::math::exp((get_base1(pred, get_base1(row_indx_pos, i, "row_indx_pos", 1), get_base1(col_indx_pos, i, "col_indx_pos", 1), "pred", 1) + get_base1(obs_cov_offset, i, "obs_cov_offset", 1))))), "assigning variable log_lik"); } } - current_statement_begin__ = 602; + current_statement_begin__ = 619; if (as_bool(logical_eq(obs_model, 3))) { - current_statement_begin__ = 602; + current_statement_begin__ = 619; for (int i = 1; i <= n_pos; ++i) { - current_statement_begin__ = 602; + current_statement_begin__ = 619; stan::model::assign(log_lik, stan::model::cons_list(stan::model::index_uni(i), stan::model::nil_index_list()), poisson_log_log(get_base1(y_int, i, "y_int", 1), (get_base1(pred, get_base1(row_indx_pos, i, "row_indx_pos", 1), get_base1(col_indx_pos, i, "col_indx_pos", 1), "pred", 1) + get_base1(obs_cov_offset, i, "obs_cov_offset", 1))), "assigning variable log_lik"); } } - current_statement_begin__ = 603; + current_statement_begin__ = 620; if (as_bool(logical_eq(obs_model, 4))) { - current_statement_begin__ = 603; + current_statement_begin__ = 620; for (int i = 1; i <= n_pos; ++i) { - current_statement_begin__ = 603; + current_statement_begin__ = 620; stan::model::assign(log_lik, stan::model::cons_list(stan::model::index_uni(i), stan::model::nil_index_list()), neg_binomial_2_log_log(get_base1(y_int, i, "y_int", 1), (get_base1(pred, get_base1(row_indx_pos, i, "row_indx_pos", 1), get_base1(col_indx_pos, i, "col_indx_pos", 1), "pred", 1) + get_base1(obs_cov_offset, i, "obs_cov_offset", 1)), get_base1(nb_phi_vec, get_base1(row_indx_pos, i, "row_indx_pos", 1), "nb_phi_vec", 1)), "assigning variable log_lik"); } } - current_statement_begin__ = 604; + current_statement_begin__ = 621; if (as_bool(logical_eq(obs_model, 5))) { - current_statement_begin__ = 604; + current_statement_begin__ = 621; for (int i = 1; i <= n_pos; ++i) { - current_statement_begin__ = 604; + current_statement_begin__ = 621; stan::model::assign(log_lik, stan::model::cons_list(stan::model::index_uni(i), stan::model::nil_index_list()), bernoulli_logit_log(get_base1(y_int, i, "y_int", 1), (get_base1(pred, get_base1(row_indx_pos, i, "row_indx_pos", 1), get_base1(col_indx_pos, i, "col_indx_pos", 1), "pred", 1) + get_base1(obs_cov_offset, i, "obs_cov_offset", 1))), "assigning variable log_lik"); } } - current_statement_begin__ = 605; + current_statement_begin__ = 622; if (as_bool(logical_eq(obs_model, 6))) { - current_statement_begin__ = 605; + current_statement_begin__ = 622; for (int i = 1; i <= n_pos; ++i) { - current_statement_begin__ = 605; + current_statement_begin__ = 622; stan::model::assign(log_lik, stan::model::cons_list(stan::model::index_uni(i), stan::model::nil_index_list()), lognormal_log(get_base1(y, i, "y", 1), get_base1(pred, get_base1(row_indx_pos, i, "row_indx_pos", 1), get_base1(col_indx_pos, i, "col_indx_pos", 1), "pred", 1), (get_base1(sigma_vec, get_base1(row_indx_pos, i, "row_indx_pos", 1), "sigma_vec", 1) + get_base1(obs_cov_offset, i, "obs_cov_offset", 1))), @@ -3842,20 +3937,20 @@ class model_dfa } } } else { - current_statement_begin__ = 610; + current_statement_begin__ = 627; if (as_bool(logical_eq(long_format, 0))) { - current_statement_begin__ = 611; + current_statement_begin__ = 628; for (int i = 1; i <= N; ++i) { - current_statement_begin__ = 612; + current_statement_begin__ = 629; stan::model::assign(log_lik, stan::model::cons_list(stan::model::index_uni(i), stan::model::nil_index_list()), multi_normal_cholesky_log(col(yall, i), col(pred, i), diag_pre_multiply(sigma_vec, Lcorr)), "assigning variable log_lik"); } } else { - current_statement_begin__ = 615; + current_statement_begin__ = 632; for (int i = 1; i <= n_pos; ++i) { - current_statement_begin__ = 617; + current_statement_begin__ = 634; stan::model::assign(log_lik, stan::model::cons_list(stan::model::index_uni(i), stan::model::nil_index_list()), normal_log(get_base1(y, i, "y", 1), ((get_base1(pred, get_base1(row_indx_pos, i, "row_indx_pos", 1), get_base1(col_indx_pos, i, "col_indx_pos", 1), "pred", 1) + get_base1(obs_cov_offset, i, "obs_cov_offset", 1)) + get_base1(cond_mean_vec, get_base1(row_indx_pos, i, "row_indx_pos", 1), "cond_mean_vec", 1)), get_base1(cond_sigma_vec, get_base1(row_indx_pos, i, "row_indx_pos", 1), "cond_sigma_vec", 1)), @@ -3863,76 +3958,76 @@ class model_dfa } } } - current_statement_begin__ = 622; + current_statement_begin__ = 639; for (int k = 1; k <= K; ++k) { - current_statement_begin__ = 623; + current_statement_begin__ = 640; stan::model::assign(future_devs, stan::model::cons_list(stan::model::index_uni(k), stan::model::nil_index_list()), 0, "assigning variable future_devs"); } - current_statement_begin__ = 626; + current_statement_begin__ = 643; if (as_bool(logical_eq(est_rw, 1))) { - current_statement_begin__ = 627; + current_statement_begin__ = 644; for (int k = 1; k <= K; ++k) { - current_statement_begin__ = 628; + current_statement_begin__ = 645; if (as_bool(logical_eq(use_normal, 0))) { - current_statement_begin__ = 630; + current_statement_begin__ = 647; if (as_bool(logical_eq(estimate_nu, 1))) { - current_statement_begin__ = 631; + current_statement_begin__ = 648; stan::model::assign(future_devs, stan::model::cons_list(stan::model::index_uni(k), stan::model::nil_index_list()), student_t_rng(get_base1(nu, 1, "nu", 1), (get_base1(theta_vec, k, "theta_vec", 1) * get_base1(devs, k, (N - 1), "devs", 1)), get_base1(sigma_pro, k, "sigma_pro", 1), base_rng__), "assigning variable future_devs"); } else { - current_statement_begin__ = 633; + current_statement_begin__ = 650; stan::model::assign(future_devs, stan::model::cons_list(stan::model::index_uni(k), stan::model::nil_index_list()), student_t_rng(nu_fixed, (get_base1(theta_vec, k, "theta_vec", 1) * get_base1(devs, k, (N - 1), "devs", 1)), get_base1(sigma_pro, k, "sigma_pro", 1), base_rng__), "assigning variable future_devs"); } } else { - current_statement_begin__ = 637; + current_statement_begin__ = 654; stan::model::assign(future_devs, stan::model::cons_list(stan::model::index_uni(k), stan::model::nil_index_list()), normal_rng((get_base1(theta_vec, k, "theta_vec", 1) * get_base1(devs, k, (N - 1), "devs", 1)), get_base1(sigma_pro, k, "sigma_pro", 1), base_rng__), "assigning variable future_devs"); } - current_statement_begin__ = 639; + current_statement_begin__ = 656; stan::model::assign(xstar, stan::model::cons_list(stan::model::index_uni(k), stan::model::cons_list(stan::model::index_uni(1), stan::model::nil_index_list())), (get_base1(x, k, N, "x", 1) + get_base1(future_devs, k, "future_devs", 1)), "assigning variable xstar"); } } - current_statement_begin__ = 642; + current_statement_begin__ = 659; if (as_bool(logical_eq(est_spline, 1))) { - current_statement_begin__ = 644; + current_statement_begin__ = 661; for (int k = 1; k <= K; ++k) { - current_statement_begin__ = 645; + current_statement_begin__ = 662; stan::model::assign(xstar, stan::model::cons_list(stan::model::index_uni(k), stan::model::cons_list(stan::model::index_uni(1), stan::model::nil_index_list())), (get_base1(spline_a_trans, k, n_knots, "spline_a_trans", 1) * get_base1(B_spline, n_knots, N, "B_spline", 1)), "assigning variable xstar"); } } - current_statement_begin__ = 648; + current_statement_begin__ = 665; if (as_bool(logical_eq(est_gp, 1))) { - current_statement_begin__ = 649; + current_statement_begin__ = 666; for (int k = 1; k <= K; ++k) { - current_statement_begin__ = 650; + current_statement_begin__ = 667; stan::math::assign(SigmaKnots_pred, cov_exp_quad(knot_locs, get_base1(sigma_pro, k, "sigma_pro", 1), get_base1(gp_theta, k, "gp_theta", 1))); - current_statement_begin__ = 651; + current_statement_begin__ = 668; for (int i = 1; i <= n_knots; ++i) { - current_statement_begin__ = 652; + current_statement_begin__ = 669; stan::model::assign(SigmaKnots_pred, stan::model::cons_list(stan::model::index_uni(i), stan::model::cons_list(stan::model::index_uni(i), stan::model::nil_index_list())), (stan::model::rvalue(SigmaKnots_pred, stan::model::cons_list(stan::model::index_uni(i), stan::model::cons_list(stan::model::index_uni(i), stan::model::nil_index_list())), "SigmaKnots_pred") + gp_delta), "assigning variable SigmaKnots_pred"); } - current_statement_begin__ = 655; + current_statement_begin__ = 672; stan::math::assign(SigmaOffDiag_pred, multiply(to_row_vector(multiply(square(get_base1(sigma_pro, k, "sigma_pro", 1)), stan::math::exp(divide(minus(distKnots21_pred), (2.0 * pow(get_base1(gp_theta, k, "gp_theta", 1), 2.0)))))), inverse_spd(SigmaKnots_pred))); - current_statement_begin__ = 656; + current_statement_begin__ = 673; stan::model::assign(xstar, stan::model::cons_list(stan::model::index_uni(k), stan::model::cons_list(stan::model::index_uni(1), stan::model::nil_index_list())), multiply(multiply(SigmaOffDiag_pred, cholesky_decompose(get_base1(SigmaKnots, k, "SigmaKnots", 1))), get_base1(effectsKnots, k, "effectsKnots", 1)), @@ -3940,12 +4035,12 @@ class model_dfa } } // validate, write generated quantities - current_statement_begin__ = 574; + current_statement_begin__ = 591; size_t log_lik_j_1_max__ = n_loglik; for (size_t j_1__ = 0; j_1__ < log_lik_j_1_max__; ++j_1__) { vars__.push_back(log_lik(j_1__)); } - current_statement_begin__ = 575; + current_statement_begin__ = 592; size_t Omega_j_2_max__ = n_pcor; size_t Omega_j_1_max__ = n_pcor; for (size_t j_2__ = 0; j_2__ < Omega_j_2_max__; ++j_2__) { @@ -3953,7 +4048,7 @@ class model_dfa vars__.push_back(Omega(j_1__, j_2__)); } } - current_statement_begin__ = 576; + current_statement_begin__ = 593; size_t Sigma_j_2_max__ = n_pcor; size_t Sigma_j_1_max__ = n_pcor; for (size_t j_2__ = 0; j_2__ < Sigma_j_2_max__; ++j_2__) { @@ -3961,7 +4056,7 @@ class model_dfa vars__.push_back(Sigma(j_1__, j_2__)); } } - current_statement_begin__ = 577; + current_statement_begin__ = 594; size_t xstar_j_2_max__ = 1; size_t xstar_j_1_max__ = K; for (size_t j_2__ = 0; j_2__ < xstar_j_2_max__; ++j_2__) { @@ -3969,12 +4064,12 @@ class model_dfa vars__.push_back(xstar(j_1__, j_2__)); } } - current_statement_begin__ = 578; + current_statement_begin__ = 595; size_t future_devs_j_1_max__ = K; for (size_t j_1__ = 0; j_1__ < future_devs_j_1_max__; ++j_1__) { vars__.push_back(future_devs(j_1__)); } - current_statement_begin__ = 579; + current_statement_begin__ = 596; size_t SigmaKnots_pred_j_2_max__ = n_knots; size_t SigmaKnots_pred_j_1_max__ = n_knots; for (size_t j_2__ = 0; j_2__ < SigmaKnots_pred_j_2_max__; ++j_2__) { @@ -3982,12 +4077,12 @@ class model_dfa vars__.push_back(SigmaKnots_pred(j_1__, j_2__)); } } - current_statement_begin__ = 580; + current_statement_begin__ = 597; size_t SigmaOffDiag_pred_j_1_max__ = n_knots; for (size_t j_1__ = 0; j_1__ < SigmaOffDiag_pred_j_1_max__; ++j_1__) { vars__.push_back(SigmaOffDiag_pred(j_1__)); } - current_statement_begin__ = 581; + current_statement_begin__ = 598; check_greater_or_equal(function__, "j", j, 0); vars__.push_back(j); } catch (const std::exception& e) { @@ -4035,7 +4130,7 @@ class model_dfa param_name_stream__ << "x0" << '.' << j_1__ + 1; param_names__.push_back(param_name_stream__.str()); } - size_t psi_j_1_max__ = (K * (1 - proportional_model)); + size_t psi_j_1_max__ = ((K * (1 - proportional_model)) * use_expansion_prior); for (size_t j_1__ = 0; j_1__ < psi_j_1_max__; ++j_1__) { param_name_stream__.str(std::string()); param_name_stream__ << "psi" << '.' << j_1__ + 1; @@ -4235,7 +4330,7 @@ class model_dfa param_name_stream__ << "indicator" << '.' << j_1__ + 1; param_names__.push_back(param_name_stream__.str()); } - size_t psi_root_j_1_max__ = K; + size_t psi_root_j_1_max__ = (K * use_expansion_prior); for (size_t j_1__ = 0; j_1__ < psi_root_j_1_max__; ++j_1__) { param_name_stream__.str(std::string()); param_name_stream__ << "psi_root" << '.' << j_1__ + 1; @@ -4413,7 +4508,7 @@ class model_dfa param_name_stream__ << "x0" << '.' << j_1__ + 1; param_names__.push_back(param_name_stream__.str()); } - size_t psi_j_1_max__ = (K * (1 - proportional_model)); + size_t psi_j_1_max__ = ((K * (1 - proportional_model)) * use_expansion_prior); for (size_t j_1__ = 0; j_1__ < psi_j_1_max__; ++j_1__) { param_name_stream__.str(std::string()); param_name_stream__ << "psi" << '.' << j_1__ + 1; @@ -4610,7 +4705,7 @@ class model_dfa param_name_stream__ << "indicator" << '.' << j_1__ + 1; param_names__.push_back(param_name_stream__.str()); } - size_t psi_root_j_1_max__ = K; + size_t psi_root_j_1_max__ = (K * use_expansion_prior); for (size_t j_1__ = 0; j_1__ < psi_root_j_1_max__; ++j_1__) { param_name_stream__.str(std::string()); param_name_stream__ << "psi_root" << '.' << j_1__ + 1; diff --git a/tests/testthat/test-fit.R b/tests/testthat/test-fit.R index f47abb0..bbd8101 100644 --- a/tests/testthat/test-fit.R +++ b/tests/testthat/test-fit.R @@ -24,8 +24,10 @@ test_that("est_correlation = TRUE works", { skip_on_cran() set.seed(42) s <- sim_dfa(num_trends = 2, num_years = 20, num_ts = 3) - m <- fit_dfa(y = s$y_sim, iter = 50, chains = 1, - num_trends = 2, est_correlation = TRUE) + m <- fit_dfa( + y = s$y_sim, iter = 50, chains = 1, + num_trends = 2, est_correlation = TRUE + ) expect_equal(class(m$model)[[1]], "stanfit") }) @@ -33,7 +35,7 @@ test_that("NA indexing works", { yy <- matrix(nrow = 3, ncol = 3, data = 1) yy[1, 1] <- NA yy[2, 3] <- NA - m <- fit_dfa(yy, num_trends = 1, sample = FALSE, scale="center") + m <- fit_dfa(yy, num_trends = 1, sample = FALSE, scale = "center") expect_equal(m$sampling_args$data$n_na, 2L) expect_equal(m$sampling_args$data$row_indx_na, c(1L, 2L)) expect_equal(m$sampling_args$data$col_indx_na, c(1L, 3L)) @@ -55,7 +57,8 @@ test_that("find_dfa_trends works", { kmin = 1, kmax = 2, chains = 1, compare_normal = FALSE, variance = "equal", convergence_threshold = 1.1, control = list(adapt_delta = 0.95, max_treedepth = 20) - )}) + ) + }) expect_equal(x$summary$model, c(2L, 1L)) expect_lt(x$summary$looic[[1]], x$summary$looic[[2]]) @@ -66,12 +69,14 @@ test_that("long format data works", { set.seed(42) s <- sim_dfa(num_trends = 1, num_years = 20, num_ts = 3) m <- fit_dfa(y = s$y_sim, iter = 100, chains = 1, num_trends = 1, seed = 42) - wide_means = apply(extract(m$model, "x")$x[, 1, ], 2, mean) + wide_means <- apply(extract(m$model, "x")$x[, 1, ], 2, mean) # fit long format data - long = data.frame("obs" = c(s$y_sim[1,], s$y_sim[2,], s$y_sim[3,]), - "ts" = sort(rep(1:3,20)), "time" = rep(1:20,3)) - m2 = fit_dfa(y = long, data_shape = "long", iter = 100, chains = 1, num_trends = 1, seed = 42) - long_means = apply(extract(m2$model, "x")$x[, 1, ], 2, mean) + long <- data.frame( + "obs" = c(s$y_sim[1, ], s$y_sim[2, ], s$y_sim[3, ]), + "ts" = sort(rep(1:3, 20)), "time" = rep(1:20, 3) + ) + m2 <- fit_dfa(y = long, data_shape = "long", iter = 100, chains = 1, num_trends = 1, seed = 42) + long_means <- apply(extract(m2$model, "x")$x[, 1, ], 2, mean) expect_equal(cor(wide_means, long_means), 1, tolerance = 0.01) }) @@ -79,8 +84,10 @@ test_that("compositional model works", { skip_on_cran() set.seed(42) s <- sim_dfa(num_trends = 1, num_years = 20, num_ts = 3) - m <- fit_dfa(y = s$y_sim, iter = 50, chains = 1, num_trends = 2, seed = 42, - z_model = "proportion") + m <- fit_dfa( + y = s$y_sim, iter = 50, chains = 1, num_trends = 2, seed = 42, + z_model = "proportion" + ) expect_equal(class(m$model)[[1]], "stanfit") }) @@ -89,8 +96,10 @@ test_that("compositional model works_2", { skip_on_cran() set.seed(42) s <- sim_dfa(num_trends = 2, num_years = 20, num_ts = 3) - m <- fit_dfa(y = s$y_sim, iter = 50, chains = 1, num_trends = 2, seed = 42, - z_model = "proportion") + m <- fit_dfa( + y = s$y_sim, iter = 50, chains = 1, num_trends = 2, seed = 42, + z_model = "proportion" + ) expect_equal(class(m$model)[[1]], "stanfit") }) @@ -99,8 +108,10 @@ test_that("estimate_sigma_process_1", { skip_on_cran() set.seed(42) s <- sim_dfa(num_trends = 1, num_years = 20, num_ts = 3) - m <- fit_dfa(y = s$y_sim, iter = 50, chains = 1, num_trends = 2, seed = 42, - estimate_process_sigma = TRUE, equal_process_sigma = TRUE) + m <- fit_dfa( + y = s$y_sim, iter = 50, chains = 1, num_trends = 2, seed = 42, + estimate_process_sigma = TRUE, equal_process_sigma = TRUE + ) expect_equal(class(m$model)[[1]], "stanfit") }) @@ -109,8 +120,10 @@ test_that("estimate_sigma_process_k", { skip_on_cran() set.seed(42) s <- sim_dfa(num_trends = 1, num_years = 20, num_ts = 3) - m <- fit_dfa(y = s$y_sim, iter = 50, chains = 1, num_trends = 2, seed = 42, - estimate_process_sigma = TRUE, equal_process_sigma = FALSE) + m <- fit_dfa( + y = s$y_sim, iter = 50, chains = 1, num_trends = 2, seed = 42, + estimate_process_sigma = TRUE, equal_process_sigma = FALSE + ) expect_equal(class(m$model)[[1]], "stanfit") })