Description Usage Arguments Details Value Author(s) See Also Examples
This function analyses observations for a significant trend.
1 2 3 4 5 |
processed.obs |
list.
See documentation for |
processed.config |
data.frame.
See documentation for |
path |
character. Path name of the folder where output data is written. |
id |
character. An analysis identifier that is used to construct output file names. |
sdate, edate |
Date or character.
Start and end date corresponding to the period of interest, respectively.
The required date format is YYYY-M-D ( |
control |
list.
Regression control values in the format produced by the |
sig.level |
numeric. Significance level to be coupled with the p-value, see ‘Value’ section. |
graphics.type |
character.
Graphics type for plot figures.
The default is the ‘active’ device, typically the normal screen device.
A file-based device can be selected by specifying either |
merge.pdfs |
logical.
If true and |
site.locations |
SpatialPointsDataFrame.
Geo-referenced site coordinates with a required data.frame component of |
is.seasonality |
logical. If true, seasonal patterns are modeled by a trigonometric regression; as covariates in the trend model. |
explanatory.var |
data.frame.
An explanatory variable added to the covariates of the trend model,
see value from the |
is.residual |
logical.
If true, the explanatory variable is transformed using its residuals from linear regression.
Should be used when the explanatory variable is monotonically increasing or
decreasing during the entire trend period.
Requires specification of the |
thin.obs.mo |
character. Full name of a calendar month; if specified, data is thinned to one observation per year collected during this month. Allows verification that the variable sampling frequencies don't substantially affect the trend results. Thinning the data also could remove serial correlation in the more frequently sampled years. |
The survreg
function is used to fit a parametric survival regression model
to the observed data, both censored and uncensored.
The specific class of survival model is known as the accelerated failure time (AFT) model.
A maximum-likelihood estimation (MLE) method is used to estimate parameters in the AFT model.
The MLE is solved by maximizing the log-likelihood using the Newton-Raphson method,
an iterative root-finding algorithm.
The likelihood function is dependent on the distribution of the observed data.
Data is assumed to follow a log-normal distribution because
most of the variables have values spanning two or more orders of magnitude.
If all observations are uncensored, the survival regression becomes
identical to ordinary least squares regression.
Returns a data.frame object with the following components:
unique site identifier
local site name
unique parameter identifier
common parameter name
start and end date corresponding to the period of interest, respectively.
number of observations in the analysis.
number of missing values.
number of exact (uncensored) observations.
number of left-censored observations.
number of interval-censored observations.
number of observations that are below the reporting level.
minimum and maximum, respectively.
median
mean and standard deviation, respectively. Set to NA if censored data is present.
number of Newton-Raphson iterations required for convergence. If NA, the regression failed or ran out of iterations and did not converge.
slope of the linear trend over time in percent change per year.
standard error for the linear trend over time in percent change per year.
p-value for the linear trend over time.
p-value for the parametric survival regression model.
significant trends are indicated by
a p-value (p
) less than or equal to the significance level.
The sign of the slope
indicates whether the significant trend is positive (+) or negative (-).
emphp-values greater than the significance level are specified as having no significant trend (none).
If arguments path
and id
are specified,
the returned data table of summary statistics (described above) is written to an external text file.
If in addition a file-based graphics type is selected, plots are drawn to external files.
J.C. Fisher and L.C. Davis, U.S. Geological Survey, Idaho Water Science Center
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 | # Specify global arguments for reading table formatted data in a text file
read.args <- list(header = TRUE, sep = "\t", colClasses = "character",
na.strings = "", fill = TRUE, strip.white = TRUE,
comment.char = "", flush = TRUE, stringsAsFactors = FALSE)
# Read input files
path.in <- system.file("extdata", package = "Trends")
file <- file.path(path.in, "Observations.tsv")
observations <- do.call(read.table, c(list(file), read.args))
file <- file.path(path.in, "Parameters.tsv")
parameters <- do.call(read.table, c(list(file), read.args))
file <- file.path(path.in, "Detection_Limits.tsv")
detection.limits <- do.call(read.table, c(list(file), read.args))
file <- file.path(path.in, "Config_VOC.tsv")
config <- do.call(read.table, c(list(file), read.args))
# Process observations
processed.obs <- ProcessObs(observations, parameters, detection.limits,
date.fmt = "\%m/\%d/\%Y")
# Plot data for a single parameter at a specific site
d <- processed.obs[["P32102"]]
d <- d[d$Site_id == "433002113021701", c("Date", "surv")]
DrawPlot(d, main = "RWMC Production", ylab = "Carbon Tetrachloride")
# Configure sites, parameters, and duration for analysis
processed.config <- tail(ProcessConfig(config, processed.obs))
# Run analysis
stats <- RunAnalysis(processed.obs, processed.config,
sdate = "1987-01-01", edate = "2012-12-31")
|
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.