power.trend: Calculates power by simulation to detect a specified trend.

Description Usage Arguments Details Value Author(s) References See Also Examples

View source: R/trends.r

Description

Calculates power for a specified trend wherethe signal for the trend is specified by xvalues and meanvalues (possibly generated by generate.trend), and the error distribution is specified by distribution. The statistical method to detect the trend is specified by method.The power is the proportion of repeat simulations for which the trend is detected with a p-value less than alpha (two-sided test).

Usage

1
2
3
power.trend(xvalues, reps=1,  meanvalues, distribution="Normal", sd=NA,
  nbsize=NA, method="linear regression", alpha=0.05, nsims=1000, nsims.mk=999,
  randeffect=F, randeffect.sd=NA)

Arguments

xvalues

Vector of, for example, time points at which the trend is evaluated.

reps

Vector of number of replicates per time point.

meanvalues

Vector of mean values that identify the signal of the trend.

distribution

Distribution (must be one of "Normal", "Poisson" or "Negbin" used to generate random values based on the signal in meanvalues.

sd

Standard deviation if distribution="Normal".

nbsize

Size parameter if distribution="Negbin".

method

Method used to identify the trend. Can be one of "linear regression", "mk", or "gam". The last of these fits a Generalised Additive Model (Wood, 2006) using function gam. It assumes Normal errors.

alpha

Type 1 error for detecting trend. Values less than alpha cause the null hypothesis of no trend to be rejected. Tests are 2-sided.

nsims

The number of simulations to be used in calculating the power. Default is 1000.

nsims.mk

The number of replicate permutations used in calculating the p-value for the Mann-Kendall test when method=mk. Default is 999.

randeffect

Not working yet

randeffect.sd

Not working yet

Details

The Mann Kendall tests are approriate only for monotonic increasing or decreasing trends, the linear regression method is only approriate for linearly increasing or decreasing trend. The GAM is appropriate for changing trends over time.

Several powers can be calculated on a single call to this function by placing more than one value in reps.

Value

The power is returned.

Author(s)

David Maxwell: david.maxwell@cefas.co.uk

References

Fryer RJ & Nicholson MD (1993) Need paper title. 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.

Wood S.N. (2006) Generalized Additive Models: An Introduction with R. Chapman and Hall/CRC Press.

See Also

mannkendall.stat, addnoise, gam, generate.trend

Examples

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
library(mgcv)

# In practice, \code{nsims} would be set to at least 1000

par(mfrow=c(2,2))
lin5 = generate.trend(nyears=10, change=5, type="linear")
plot(lin5$i, lin5$mu)
updown = generate.trend(nyears=15, change=5, type="updown", changeyear=8)
plot(updown$i, updown$mu)

power.trend(xvalues=lin5$i, meanvalues=lin5$mu, distribution="Normal", sd=2,
            method="linear regression", alpha=0.05, nsims=50)
power.trend(xvalues=lin5$i, meanvalues=lin5$mu, distribution="Poisson", method="mk", alpha=0.05,
      nsims=50)
power.trend(xvalues=updown$i, meanvalues=updown$mu, distribution="Normal", sd=2,
            method="gam", alpha=0.05, nsims=50)

emon documentation built on May 2, 2019, 10:21 a.m.