Skip to content

Commit c8cd4da

Browse files
committed
vignettes
1 parent 57da549 commit c8cd4da

File tree

2 files changed

+8
-7
lines changed

2 files changed

+8
-7
lines changed

R/fit_stan.R

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@
1010
#' @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)
1111
#' @param family A named distribution for the observation model, defaults to gaussian
1212
#' @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()].
1414
#' @return an object of class 'rstan'
1515
#' @importFrom rstan sampling
1616
#' @export
@@ -49,13 +49,13 @@ fit_stan <- function(y, x=NA, model_name = NA,
4949

5050
data <- NA
5151
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)
5353
object <- stanmodels$regression
5454
data <- list("N"=length(y),"K"=dim(x)[2],"x"=x,"y"=y,"y_int"=round(y), "family"=family)
5555
pars <- c("beta","sigma","pred","log_lik")
5656
}
5757
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)
5959
object <- stanmodels$regression_cor
6060
data <- list("N"=length(y),"K"=dim(x)[2],"x"=x,"y"=y,"y_int"=round(y), "family"=family)
6161
pars <- c("beta","sigma","pred","phi","sigma_cor","log_lik")
@@ -126,21 +126,21 @@ fit_stan <- function(y, x=NA, model_name = NA,
126126
if(is.na(x)) {
127127
x <- matrix(0, nrow=length(y), ncol=1)
128128
}
129-
if(class(x)!="matrix") x <- matrix(x,ncol=1)
129+
if(is.matrix(x)==FALSE) x <- matrix(x,ncol=1)
130130
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)
131131
pars <- c("beta","sigma_obs","sigma_process","pred","intercept","log_lik")
132132
}
133133
if(model_name == "dlm-slope") {
134134
object = stanmodels$dlm_slope
135135
# 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)
137137
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)
138138
pars <- c("beta","sigma_obs","sigma_process","pred","log_lik")
139139
}
140140
if(model_name == "dlm") {
141141
object = stanmodels$dlm
142142
# 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)
144144
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)
145145
pars <- c("beta","sigma_obs","sigma_process","pred","log_lik")
146146
}

vignettes/dlm.Rmd

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,7 @@ knitr::opts_chunk$set(echo = TRUE)
1818
```{r install, eval=TRUE, warning=FALSE, message=FALSE, results='hide'}
1919
library(rstan)
2020
library(atsar)
21-
library(MARSS)
21+
2222
# for optimizing stan on your machine,
2323
#rstan_options(auto_write = TRUE)
2424
#options(mc.cores = parallel::detectCores())
@@ -30,6 +30,7 @@ mcmc_list = list(n_mcmc = 1000, n_burn = 500, n_chain = 1, n_thin = 1)
3030
We'll use the same data in the MARSS manual, from Mark's example in the Columbia River. The data are accessed with
3131

3232
```{r,eval=FALSE}
33+
library(MARSS)
3334
data(SalmonSurvCUI)
3435
```
3536

0 commit comments

Comments
 (0)