Learn R Programming

emon (version 1.3)

generate.trend: Generates a set of mean values.

Description

This function is used to generate mean value scenarios for use in power.trend.

Usage

generate.trend(nyears, mu1=0, change, change.type="A", type = c("linear", "incident", "step", "updown"), changeyear, symmetric=F)

Arguments

nyears
Defines the number of time points for X axis
mu1
The mean Y value for the first time point
change
Difference between mu1 and largest (or smallest) mu_i. Can be negative for a decreasing trend.
change.type
Whether the parameter change represents an additive ("A") or percentage ("M") change.
type
Type of trend to assess the power against. Can be any of "linear", "incident", "step" or "updown". See examples below for more details.
changeyear
Year in which change in gradient occurs, for options 'incident' or 'updown'.
symmetric
If symmetric=T, nyears is even and changeyear = nyears / 2 then type='updown' generates a pattern where the two middle years are at level k.

Value

Generates a data frame where the first column ($i) is year and the second column ($mu) is the mean value.

Details

Assumes that surveys take place in years 1 to nyears (or could be any other equally spaced unit). Generates a set of mean values (or signal) for a specified trend over that time period. The approach is based on Fryer and Nicholson (1993, 1999). For type="linear", the slope is generated by b=k/(nyears-1). If type="updown", the slope until changeyear is generated by b=k/(changeyears-1). After changeyear, the slope is -b (except for the special case outlined by the symmetric parameter above, where changeyear and changeyear+1 are k and then the slope continues as -b).

References

Fryer RJ & Nicholson MD (1993) The power of a contaminant monitoring programme to detect linear trends and incidents. ICES Journal of Marine Science, 50, 161-168.

Fryer & Nicholson 1999 Using smoothers for comprehensive assessments of contaminant time series in marine biota. ICES Journal of Marine Science, 56, 779-790.

See Also

power.trend, addnoise

Examples

Run this code
lin0 = generate.trend(nyears=10, change=0, type="linear")
lin5 = generate.trend(nyears=10, change=5, type="linear")
inc5 = generate.trend(nyears=10, change=5, type="incident", changeyear=6)
step5 = generate.trend(nyears=10, change=5, type="step", changeyear=6)
updeven = generate.trend(nyears=10, change=5, type="updown", changeyear=5, symmetric=TRUE)
updodd = generate.trend(nyears=9, change=5, type="updown", changeyear=3)

par(mfrow=c(2,3))
plot(lin0$i, lin0$mu, type="o", pch=16, xlab='Time', ylab='Y')
plot(lin5$i, lin5$mu, type="o", pch=16, xlab='Time', ylab='Y')
plot(inc5$i, inc5$mu, type="o", pch=16, xlab='Time', ylab='Y')
plot(step5$i, step5$mu, type="o", pch=16, xlab='Time', ylab='Y')
plot(updeven$i, updeven$mu, type="o", pch=16, xlab='Time', ylab='Y')
plot(updodd$i, updodd$mu, type="o", pch=16, xlab='Time', ylab='Y')

Run the code above in your browser using DataLab