Type: Package
Title: Linear Population Growth Scenarios
Version: 0.1.1
Maintainer: Biman Chakraborty <biman_c@yahoo.com>
Description: Fit linear splines to species time series to detect population growth scenarios based on Hyndman, R J and Mesgaran, M B and Cousens, R D (2015) <doi:10.1007/s10530-015-0962-8>.
License: GPL-3
Encoding: UTF-8
LazyData: true
RoxygenNote: 7.1.1
Imports: dplyr
Depends: R (≥ 2.10)
NeedsCompilation: no
Packaged: 2022-05-09 12:04:35 UTC; chakrabb
Author: Philipp Robeck [aut], Biman Chakraborty [cre]
Repository: CRAN
Date/Publication: 2022-05-10 10:40:06 UTC

Frequency and Specimens Data

Description

Example Frequency and Specimens data by year for each species to be used in 'PopulationGrowthR' package

Usage

fdata

Format

An object of class data.frame with 3771 rows and 4 columns.


Frequency plot for a lagphase fit

Description

Frequency plot for a lagphase fit

Usage

freqplot(
  fit1,
  fit2 = NULL,
  fit3 = NULL,
  fit4 = NULL,
  xlab = "Year",
  ylab = "Frequency",
  main = fit1$name,
  cols = 2:5,
  ...
)

Arguments

fit1, fit2, fit3, fit4

"lagphase" fit objects to plot

xlab

Label for the $x$-axis

ylab

Label for the $y$-axis

main

Title of the plot

cols

Colors to be used to draw the lines

...

(optional) parameters to pass to plot

Value

Produces a plot of observed and predicted frequencies for the species against year

Examples

Species = unique(fdata$Species) #List of all species
fit1 = lagfit(fdata, yeardata, species=Species[1])
freqplot(fit1$fit)

Produces plot of the fitted spline function after adjusting for number of Specimens

Description

Produces plot of the fitted spline function after adjusting for number of Specimens

Usage

growthplot(
  fit,
  ylim = NULL,
  xlab = "Year",
  ylab = "Adjusted Frequency",
  main = fit$name,
  ...
)

Arguments

fit

a "lagphase" fit object to plot

ylim

vector of size 2 - limits of the $y$-axis

xlab

Label for the $x$-axis

ylab

Label for the $y$-axis

main

Title of the plot

...

(optional) parameters to pass to plot

Value

Produces a plot of the fit with confidence bands

Examples

Species = unique(fdata$Species) #List of all species
fit1 = lagfit(fdata, yeardata, species=Species[1])
growthplot(fit1$fit)

Fits a piecewise glm model with lags

Description

This function fits a piecewise poisson model to the frequency data of different Species. It assumes that the data contains columns Year, Frequency and Specimens.

Usage

lagfit(
  data,
  yeardata,
  species = NULL,
  knots = NULL,
  zeros = TRUE,
  plotlag = FALSE,
  plotfreq = FALSE
)

Arguments

data

a dataframe containing the columns Species (optional), Year, Frequency and Specimens.

yeardata

a dataframe containing the columns Year and Specimens giving the total number of Specimens for each Year.

species

list of species for which the model is to be fitted. Default is NULL, which fits the model for all species in the data.

knots

a list of knots to be used for the piecewise model. Default is NULL, which chooses the optimal model with 0-4 knots.

zeros

logical. Specifies whether missing year for the species will be filled with zeros. Default is TRUE.

plotlag

logical. If TRUE a plot of the fitted model will be produced for each species.

plotfreq

logical. If TRUE frquency plots will be created for each species.

Value

If the model is fit for a single species following are returned as a list

If the number of species is more than one, then a list is returned with following items:

Examples

#Run lagfit for 1 species only
Species = unique(fdata$Species) #List of all species

fit1 = lagfit(fdata, yeardata, species=Species[1])
#Run lagfit for multiple species
fit2 = lagfit(fdata, yeardata, species=Species[1:3])
fitdata = fit2$fitdata  #Dataframe containing fits
fitcoefs = fit2$fitcoefs #List containing slopes of the fitted splines

## Not run: 
#Run lagfit for the whole dataset
fitall = lagfit(fdata, yeardata)

## End(Not run)

Extract Frequency and Specimen data from the raw data

Description

Extract Frequency and Specimen data from the raw data

Usage

raw2freqdata(rawdata, species = "species", year = "year")

Arguments

rawdata

a dataframe containing species, year

species

name of the column containing species names

year

name of the column containing year

Value

Retirns a list of two dataframes

Examples

cleandata = raw2freqdata(rawdata)
fdata = cleandata$data
yeardata = cleandata$yeardata

Raw GBIF Data

Description

Example raw GBIF data used in 'PopulationGrowthR' package

Usage

rawdata

Format

An object of class data.frame with 34088 rows and 50 columns.


Total Specimens Data

Description

Example total Specimens data by year to be used in 'PopulationGrowthR' package

Usage

yeardata

Format

An object of class data.frame with 60 rows and 2 columns.