prepare.data: Prepare data frame for MAR analysis

Description Usage Arguments Details Value Author(s) References Examples

View source: R/prepare.data.R

Description

Formats a data frame of variable time-series for use in run.mar

Usage

1
2
3
prepare.data(data, increment=c("month","year","week","day"), fill.gap=0, 
	replace.0s=c(FALSE,"rand.half","add.ones"),	log=FALSE, 
	z.method=c(FALSE,"standard","deseason"), order=NULL)

Arguments

data

Data frame to be transformed: first column dates, following columns variable time-series

increment

Time-step increment data are to be averaged into: "month", "year", "week", or "day"

fill.gap

Maximum length of gap between time-steps to be filled by linear interpolation

replace.0s

How zeros in the time-series should be dealt with:

"rand.half" : replace zeros with random values less than 1/2 the minimum non-zero value for the variable
"add.ones" : add 1 to all values in time-series
FALSE : leave zeros in the data
log

Should the data be log-transformed?

z.method

Standardize the data so all variables have equal means and standard deviations:

"standard" : subtracts the overall variable mean and divides by the overall variable standard deviation
"deseason" : subtracts the variable mean for the increment (across years) and divides by the variable
standard deviation for the increment
FALSE : do not standardize the data
order

The order in which year, month, and day are recorded in the date format in the first column of data. Defaults to NULL, for which an attempt is made by the function to distinguish the date format, but the argument should be provided as "ymd", "mdy", etc., if the function cannot distinguish the order on its own

Details

The run.mar function requires a data frame consisting of a continuous time-block indicator variable in the first column, dates/time-steps in the second column, and variable time-series with evenly spaced time-step increments in the remaining columns. This function automatically creates the continuous time-block variable column and aggregates the time-series into evenly spaced increments as indicated by the increment argument. Although it automatically tries to assess the format of the dates in data, the order argument may have to be provided if this fails (for example, in the case where all dates in the dataset fall before the 12th of each month).

Other transformations that are commonly applied to ecological data prior to MAR modeling (e.g., Hampton et al. 2006, Ives et al. 2003) can optionally be performed, but are skipped by default with their respective arguments set to FALSE.

Value

A data frame with a continuous time-block indicator variable in the first column, dates/time-steps in the second column, and variable time-series with evenly spaced time-step increments in the remaining columns

Author(s)

LP Scheef

References

Hampton SE, Scheuerell MD, and Schindler DE (2006) Coalescence in the Lake Washington story: Interaction strengths in a planktonic food web. Limnology and Oceanography 51:2042-2051

Ives AR, Dennis B, Cottingham KL, and Carpenter SR (2003) Estimating community stability and ecological interactions from time-series data. Ecological Monographs 73:301-330

Examples

1
2
3
data(L4.AllDates)
L4.mar<-prepare.data(data=L4.AllDates, increment="month", fill.gap=0, 
replace.0s="rand.half", log=TRUE, z.method="deseason")

MAR1 documentation built on May 29, 2017, 4:18 p.m.