Skip to content

Commit

Permalink
more ex speedup
Browse files Browse the repository at this point in the history
  • Loading branch information
Ian Jonsen committed Sep 1, 2020
1 parent a795daa commit e1d9c27
Show file tree
Hide file tree
Showing 15 changed files with 54 additions and 124 deletions.
19 changes: 14 additions & 5 deletions R/bsam-package.R
Original file line number Diff line number Diff line change
Expand Up @@ -37,8 +37,8 @@
#' \dontrun{
#' # Fit DCRW model for state filtering and regularization -
#' # using trivial adapt & samples values for speed
#' data(ellie)
#' fit <- fit_ssm(ellie, model = "DCRW", tstep = 1, adapt = 100, samples = 100,
#' data(ellie1)
#' fit <- fit_ssm(ellie1, model = "DCRW", tstep = 1, adapt = 10, samples = 100,
#' thin = 1, span = 0.2)
#' diag_ssm(fit)
#' map_ssm(fit)
Expand All @@ -54,9 +54,9 @@ NULL



##' @name ellie
##' @name ellie1
##' @docType data
##' @title Elephant seal Argos satellite data (2 individuals)
##' @title Elephant seal Argos satellite data (1 individual)
##' @format .RData
##' @keywords data
##' @description Example elephant seal Argos tracking data. Data were sourced from
Expand All @@ -65,4 +65,13 @@ NULL
##' Strategy and the Super Science Initiative.
NULL


##' @name ellie2
##' @docType data
##' @title Elephant seal Argos satellite data (2 individuals)
##' @format .RData
##' @keywords data
##' @description Example elephant seal Argos tracking data. Data were sourced from
##' the Integrated Marine Observing System (IMOS) - IMOS is supported by the
##' Australian Government through the National Collaborative Research Infrastructure
##' Strategy and the Super Science Initiative.
NULL
12 changes: 0 additions & 12 deletions R/diag_ssm.R
Original file line number Diff line number Diff line change
Expand Up @@ -12,18 +12,6 @@
#' increasing number of iterations. See the \code{coda} package for further details.
#' @references Brooks SP, Gelman A (1998) General methods for monitoring convergence of
#' iterative simulations. Journal of Computational and Graphical Statistics 7:434-455
#' @examples
#' \dontrun{
#' data(ellie)
#' fit.s <- fit_ssm(ellie, model = "DCRWS", tstep = 1, adapt = 100, samples = 100,
#' thin = 1, span = 0.1)
#' diag_ssm(fit.s)
#'
#' # increase burnin, posterior sample numbers, and thinning factor
#' fit.s2 <- fit_ssm(ellie, model = "DCRWS", tstep = 1, adapt = 100, samples = 100,
#' thin = 1, span = 0.1)
#' diag_ssm(fit.s2)
#' }
#' @importFrom coda autocorr.plot traceplot gelman.plot as.mcmc.list nvar varnames<-
#' @export
#'
Expand Down
23 changes: 10 additions & 13 deletions R/fit_ssm.R
Original file line number Diff line number Diff line change
Expand Up @@ -69,18 +69,14 @@
#'
#' # Fit DCRW model for state filtering and regularization -
#' # using trivial adapt & samples values for speed
#' data(ellie)
#' fit <- fit_ssm(ellie, model = "DCRW", tstep = 2, adapt = 100, samples = 100,
#' data(ellie1)
#' fit <- fit_ssm(ellie1, model = "DCRW", tstep = 4, adapt = 10, samples = 100,
#' thin = 1, span = 0.2)
#' diag_ssm(fit)
#' map_ssm(fit)
#' plot_fit(fit)
#' result <- get_summary(fit)
#'
#' \dontrun{
#' \donttest{
#' # Fit DCRWS model for state filtering, regularization and behavioural state estimation -
#' # using trivial adapt & samples values for speed
#' fit.s <- fit_ssm(ellie, model = "DCRWS", tstep = 2, adapt = 100, samples = 100,
#' fit.s <- fit_ssm(ellie1, model = "DCRWS", tstep = 2, adapt = 10, samples = 100,
#' thin = 1, span = 0.2)
#' diag_ssm(fit.s)
#' map_ssm(fit.s)
Expand All @@ -91,12 +87,13 @@
#' # this may provide better parameter and behavioural state estimation
#' # by borrowing strength across multiple track datasets -
#' # using trivial adapt & samples values for speed
#' hfit.s <- fit_ssm(ellie, model = "hDCRWS", tstep = 2, adapt = 100, samples = 100,
#' data(ellie2)
#' hfit.s <- fit_ssm(ellie2, model = "hDCRWS", tstep = 2, adapt = 10, samples = 100,
#' thin = 1, span = 0.2)
#' diag_ssm(hfit.s)
#' map_ssm(hfit.s)
#' plot_fit(hfit.s)
#' result.hs <- get_summary(hfit.s)
#' diag_ssm(hfit.s)
#' map_ssm(hfit.s)
#' plot_fit(hfit.s)
#' result.hs <- get_summary(hfit.s)
#' }
#' @importFrom tibble as_tibble
#' @export
Expand Down
20 changes: 0 additions & 20 deletions R/get_summary.R
Original file line number Diff line number Diff line change
Expand Up @@ -11,26 +11,6 @@
#' @return a summary data.frame printed either to the console (default) or written as .csv to a
#' specified file.
#'
#' @examples
#' \dontrun{
#' data(ellie)
#' fit <- fit_ssm(ellie, model = "DCRW", tstep = 1, adapt = 100, samples = 100,
#' thin = 1, span = 0.1)
#'
#' ## print to console
#' get_summary(fit)
#'
#' ## export to .csv file
#' get_summary(fit, file = "ellie_dcrw.csv")
#'
#' ## plot track of second animal (posterior mean longitude and latitude)
#' p <- ggplot(data = subset(get_summary(fit), id == unique(id)[2])) +
#' geom_point(aes(lat, lon), col = "firebrick", size = 2)
#' p
#'
#' ## overlay posterior median longitude and latitude
#' p + geom_point(aes(lat.5, lon.5), col = "dodgerblue", size = 1)
#' }
#' @importFrom utils write.csv
#' @export

Expand Down
11 changes: 0 additions & 11 deletions R/plot_fit.R
Original file line number Diff line number Diff line change
Expand Up @@ -8,17 +8,6 @@
#' @return Observed locations are plotted as filled circles and estimated locations as blue
#' lines with the 95\% credible interval as a ribbon. Uses \code{ggplot2} plotting functions.
#'
#' @examples
#' \dontrun{
#' data(ellie)
#' fit.s <- fit_ssm(ellie, model = "DCRWS", tstep = 1, adapt = 100, samples = 100,
#' thin = 1, span = 0.1)
#' plot_fit(fit.s)
#'
#' hfit.s <- fit_ssm(ellie, model = "hDCRWS", tstep = 1, adapt = 100, samples = 100,
#' thin = 1, span = 0.1)
#' plot_fit(hfit.s)
#' }
#' @importFrom ggplot2 ggplot aes ggtitle geom_point scale_color_gradient2 xlab ylab aes_string
#' @importFrom ggplot2 ylim geom_line geom_ribbon
#' @importFrom gridExtra grid.arrange
Expand Down
Binary file removed data/ellie.RData
Binary file not shown.
Binary file added data/ellie1.RData
Binary file not shown.
Binary file added data/ellie2.RData
Binary file not shown.
4 changes: 2 additions & 2 deletions man/bsam-package.Rd

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

13 changes: 0 additions & 13 deletions man/diag_ssm.Rd

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

16 changes: 16 additions & 0 deletions man/ellie1.Rd

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

4 changes: 2 additions & 2 deletions man/ellie.Rd → man/ellie2.Rd

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

23 changes: 10 additions & 13 deletions man/fit_ssm.Rd

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

21 changes: 0 additions & 21 deletions man/get_summary.Rd

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

12 changes: 0 additions & 12 deletions man/plot_fit.Rd

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

0 comments on commit e1d9c27

Please sign in to comment.