Learn R Programming

baytrends

Windows Linux OSX

The baytrends package was developed to enable users to evaluate long-term trends in the Chesapeake Bay using a Generalized Additive Modeling (GAM) approach. The model development includes selecting a GAM structure to describe nonlinear seasonally-varying changes over time, incorporation of hydrologic variability via either a river flow or salinity, the use of an intervention to deal with method or laboratory changes suspected to impact data values, and representation of left- and interval-censored data. This approach, which is fully transferable to other systems, allows for Chesapeake Bay water quality data to be evaluated in a statistically rigorous, yet flexible way to provide insights to a range of management- and research-focused questions.

Installation

The CRAN version of baytrends from CRAN can be installed with the code below.

install.packages("baytrends")

In some cases not all dependent packages are available on the user’s system. In these cases installing all dependencies is necessary.

install.packages("baytrends", dependencies = TRUE)

The development version (with vignettes) from GitHub can be installed with the code example below using the remotes package.

if(!require(remotes)){install.packages("remotes")}  #install if needed
install_github("tetratech/baytrends", force = TRUE, build_vignettes = TRUE)

Copy Link

Version

Install

install.packages('baytrends')

Monthly Downloads

322

Version

2.0.14

License

GPL-3

Issues

Pull Requests

Stars

Forks

Maintainer

Erik Leppo

Last Published

February 24th, 2026

Functions in baytrends (2.0.14)

dectime2Date

Date Conversion
detrended.flow

Create Seasonally Detrended Flow Data Set
detrended.salinity

Create Seasonally Detrended Salinty Data Set
.ExpLNmCens

Expectation maximization function: Log-normal case, Cens
.ExpLNrCens

Expectation maximization function: Log-normal case, right censured
.ExpNmCens

Expectation maximization function: Normal case
.ExpNrCens

Expectation maximization function: Normal case, right censured
createResiduals

Calculate GAM residuals
baseDay

Base Day
baseDay2decimal

Base Day
.ExpNiCens

Expectation maximization function: Normal case, i censured
dataCensored

Chesapeake Bay Program Monitoring Data, 1985-2016
.H5

Print out 5th level header (shortened pandoc.header)
.T

Print out table title (customization of pandoc.emphasis and pandoc.strong )
.H3

Print out 3rd level header (shortened pandoc.header)
.P

Paragraph (customization of pandoc.p)
analysisOrganizeData

Analysis Organization & Data Preparation
.F

Print out figure title (customization of pandoc.emphasis and pandoc.strong )
.H

Print out header (shortened pandoc.header)
.V

Print out text (blended pandoc.emphasis, .verbatim, and .strong)
.appendDateFeatures

Appends date features to data frame
.ExpLNiCens

Expectation maximization function: Log-normal case, i censured
appendDateFeatures

Append Date Features
.ExpLNlCens

Expectation maximization function: Log-normal case, left censured
.checkRange

Check Data Range -- function that checks for allowable values
.mergeFlow

merge flow variable into analysis data frame and update iSpec with variable name
.vTable

Print out character vector table in wrapped mode
.reAttDF

Re-attribute df based on previous df
.mergeSalinity

merge salinity into analysis data frame and update iSpec with variable name
.H4

Print out 4th level header (shortened pandoc.header)
.gamPlotCalc

plots data and gam fit vs. time
filterWgts

Create filter weights
.H2

Print out 2nd level header (shortened pandoc.header)
.gamDiffPORtbl

Compute and present report on percent different for log-transformed data
.initializeResults

#### Initialize stat.gam.result and chng.gam.result
.ExpNlCens

Expectation maximization function: Normal case, left censured
gamPlotDispSeason

Plot censored gam fits vs. time
.H1

Print out 1st level header (shortened pandoc.header)
.gamCoeff

Prepare table of coefficients for GAM analysis
impute

Impute Censored Values
gamDiff

Compute an estimate of difference based on GAM results
gamPlotDisp

Plot censored gam fits vs. time
makeSurvDF

Convert dataframe to include survival (Surv) objects
eventNum

Event Processing
fillMissing

Fill Missing Values
.fmtPval

Format pvalues
.gamANOVA

Prepare ANOVA table for GAM analysis
flwAveragePred

Flow Averaged Predictions
gamTestSeason

Perform GAM analysis for Specified Season
getUSGSflow

Retrieve USGS daily flow data in a wide format
.findFile

Find Recent File Information
.chkParameter

Reduce dataframe and parameter list based on user selected parameterFilt
layerAggregation

Aggregate data layers
layerLukup

Layer List
imputeDF

Impute Censored Values in dataframes
saveDF

Save R object to disk
sal

Salinity data
loadExcel

Load/Clean Excel sheet
loadModels

Load Built-in GAM formulas
loadModelsResid

Load Built-in GAM formulas for calculating residuals
loadData

Load/Clean CSV and TXT Data File
parameterList

Parameter List
nobs

Compute the Number of Non-Missing Observations
gamTest

Perform GAM analysis
unSurvDF

Converts Surv objects in a dataframe to "lo" and "hi" values
stationMasterList

Chesapeake Bay Program long-term tidal monitoring stations
usgsGages

USGS Gages
na2miss

Recode Data
seasAdjflow

Create Daily Seasonally-adjusted Log Flow Residuals
unSurv

Converts Surv object into a 3-column matrix
selectData

Select data for analysis from a larger data frame
baytrends-package

baytrends: Long Term Water Quality Trend Analysis
closeOut

Document Processing Time and Other Session Time
dectime

Decimal Time