read_bugs {popbayes}R Documentation

Import a list of BUGS outputs previously exported

Description

This function imports a list of BUGS outputs previously exported by fit_trend(). Users can import one, several, or all models.

Usage

read_bugs(series = NULL, path = ".")

Arguments

series

a vector of character strings. One or several count series names. If NULL (default) BUGS outputs for all count series will be imported. Users can run list_series() to get the correct spelling of count series names.

path

a character string. The directory in which BUGS outputs have been saved by the function fit_trend().

Value

An n-element list (where n is the number of count series). See fit_trend() for further information.

Examples

## Load Garamba raw dataset ----
file_path <- system.file("extdata", "garamba_survey.csv", 
                         package = "popbayes")
                         
garamba <- read.csv(file = file_path)

## Create temporary folder ----
temp_path <- tempdir()

## Format dataset ----
garamba_formatted <- popbayes::format_data(
  data              = garamba, 
  path              = temp_path,
  field_method      = "field_method",
  pref_field_method = "pref_field_method",
  conversion_A2G    = "conversion_A2G",
  rmax              = "rmax")

## Select one serie ----
a_buselaphus <- popbayes::filter_series(garamba_formatted, 
                                        location = "Garamba",
                                        species  = "Alcelaphus buselaphus")

## Fit population trends (requires JAGS) ----
a_buselaphus_mod <- popbayes::fit_trend(a_buselaphus, path = temp_path)

## Import BUGS outputs for one count series ----
popbayes::read_bugs(series = "garamba__alcelaphus_buselaphus", 
                    path   = temp_path)

## Import BUGS outputs for all count series ----
popbayes::read_bugs(path = temp_path)


[Package popbayes version 1.2.0 Index]