EcoGenetics (version 1.2.1-4)

eco.theilsen: Theil-sen regression for a raster time series

Description

This function computes the theil-sen estimator and the associated P-value, for each pixel over time in a stack of images. The output consists of two rasters (one for the estimators and one for the P-values). It is recommended to use a "RasterBrick", which is more efficient in memory management.

Usage

eco.theilsen(stacked, date, adjust = "none")

Arguments

stacked

Stacked images ("RasterLayer" or "RasterBrick").

date

data vector with decimal dates for each image.

adjust

P-values correction method for multiple tests passed to p.adjust. Defalut is "none".

References

Sen, P. 1968. Estimates of the regression coefficient based on Kendall's tau. Journal of the American Statistical Association, Taylor and Francis Group, 63: 1379-1389.

Theil H. 1950. A rank-invariant method of linear and polynomial regression analysis, Part 3 Proceedings of Koninalijke Nederlandse Akademie van Weinenschatpen A, 53: 397-1412.

See Also

rkt.

Examples

Run this code
# NOT RUN {
require("raster")
set.seed(6)

temp <- list()
for(i in 1:100) {
temp[[i]] <- runif(36,-1, 1)
temp[[i]] <- matrix(temp[[i]], 6, 6)
temp[[i]] <- raster(temp[[i]])
}

temp <- brick(temp)


writeRaster(temp,"temporal.tif", overwrite=T)
rm(temp)
ndvisim <- brick("temporal.tif")

date <- seq(from = 1990.1, length.out = 100, by = 0.2)

eco.theilsen(ndvisim, date)

slope <- raster("slope.tif")
pvalue <- raster("pvalue.tif")

par(mfrow = c(1, 2))
plot(slope, main = "slope")
plot(pvalue, main = "p-value")


file.remove(c("temporal.tif", "slope.tif", "pvalue.tif"))
# }
# NOT RUN {
# }

Run the code above in your browser using DataCamp Workspace