|
10 | 10 | #' @param mcmc_list A list of MCMC control parameters. These include the number of 'iterations' (default = 1000), burn in or warmup (default = 500), chains (default = 3), and thinning (default = 1) |
11 | 11 | #' @param family A named distribution for the observation model, defaults to gaussian |
12 | 12 | #' @param marss A named list containing the following elements for specifying marss models: (states=NULL, obsVariances=NULL, proVariances=NULL, trends=NULL) |
13 | | -#' |
| 13 | +#' @param ... Any other arguments passed to [rstan::sampling()]. |
14 | 14 | #' @return an object of class 'rstan' |
15 | 15 | #' @importFrom rstan sampling |
16 | 16 | #' @export |
@@ -49,13 +49,13 @@ fit_stan <- function(y, x=NA, model_name = NA, |
49 | 49 |
|
50 | 50 | data <- NA |
51 | 51 | if(model_name == "regression") { |
52 | | - if(class(x)!="matrix") x = matrix(x,ncol=1) |
| 52 | + if(is.matrix(x)==FALSE) x = matrix(x,ncol=1) |
53 | 53 | object <- stanmodels$regression |
54 | 54 | data <- list("N"=length(y),"K"=dim(x)[2],"x"=x,"y"=y,"y_int"=round(y), "family"=family) |
55 | 55 | pars <- c("beta","sigma","pred","log_lik") |
56 | 56 | } |
57 | 57 | if(model_name == "regression_cor") { |
58 | | - if(class(x)!="matrix") x = matrix(x,ncol=1) |
| 58 | + if(is.matrix(x)==FALSE) x = matrix(x,ncol=1) |
59 | 59 | object <- stanmodels$regression_cor |
60 | 60 | data <- list("N"=length(y),"K"=dim(x)[2],"x"=x,"y"=y,"y_int"=round(y), "family"=family) |
61 | 61 | pars <- c("beta","sigma","pred","phi","sigma_cor","log_lik") |
@@ -126,21 +126,21 @@ fit_stan <- function(y, x=NA, model_name = NA, |
126 | 126 | if(is.na(x)) { |
127 | 127 | x <- matrix(0, nrow=length(y), ncol=1) |
128 | 128 | } |
129 | | - if(class(x)!="matrix") x <- matrix(x,ncol=1) |
| 129 | + if(is.matrix(x)==FALSE) x <- matrix(x,ncol=1) |
130 | 130 | data <- list("N"=length(y),"K"=dim(x)[2],"x"=x,"y"=y,"y_int"=round(y), "family"=family,"n_pos"=n_pos,"pos_indx"=pos_indx) |
131 | 131 | pars <- c("beta","sigma_obs","sigma_process","pred","intercept","log_lik") |
132 | 132 | } |
133 | 133 | if(model_name == "dlm-slope") { |
134 | 134 | object = stanmodels$dlm_slope |
135 | 135 | # constant estimated intercept, and time varying slopes |
136 | | - if(class(x)!="matrix") x <- matrix(x,ncol=1) |
| 136 | + if(is.matrix(x)==FALSE) x <- matrix(x,ncol=1) |
137 | 137 | data <- list("N"=length(y),"K"=dim(x)[2],"x"=x,"y"=y,"y_int"=round(y), "family"=family,"n_pos"=n_pos,"pos_indx"=pos_indx) |
138 | 138 | pars <- c("beta","sigma_obs","sigma_process","pred","log_lik") |
139 | 139 | } |
140 | 140 | if(model_name == "dlm") { |
141 | 141 | object = stanmodels$dlm |
142 | 142 | # this is just a time-varying model with time varying intercept and slopes |
143 | | - if(class(x)!="matrix") x <- matrix(x,ncol=1) |
| 143 | + if(is.matrix(x)==FALSE) x <- matrix(x,ncol=1) |
144 | 144 | data <- list("N"=length(y),"K"=dim(x)[2],"x"=x,"y"=y,"y_int"=round(y), "family"=family,"n_pos"=n_pos,"pos_indx"=pos_indx) |
145 | 145 | pars <- c("beta","sigma_obs","sigma_process","pred","log_lik") |
146 | 146 | } |
|
0 commit comments