[R] Magnitude of trend in time series
Hello, I am analyzing some climate time series data using the Mann Kendall package and was wondering if there was a way to calculate the trend using Sen's nonparametric estimator slope in R? Thank you in advance, Barry _ Barry Baker, Ph.D. Global Climate Change Initiative The Nature Conservancy 2424 Spruce St., Suite 100 Boulder, CO 80302 Tel: (303)-541-0322 Fax: (303)-449-4328 http://nature.org/tncscience/scientists/misc/baker.html __ R-help@stat.math.ethz.ch mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.
Re: [R] Magnitude of trend in time series
Rand Wilcox has produced a set of functions for S-Plus and (IIRC) R, which includes Theil-Sen regression. The following url gives a pdf to the workshop that they were designed to accompany, along with instructions on how to source and use them. http://psychology.usc.edu/rwilcox/workshop.pdf The following url is to his homepage which gives the above link plus those to the function files themselves. http://psychology.usc.edu/faculty_homepage.php?id=43 HTH Regards Mike -Original Message- From: [EMAIL PROTECTED] [mailto:[EMAIL PROTECTED] On Behalf Of Barry Baker Sent: 12 January 2007 23:48 To: r-help@stat.math.ethz.ch Subject: [R] Magnitude of trend in time series Hello, I am analyzing some climate time series data using the Mann Kendall package and was wondering if there was a way to calculate the trend using Sen's nonparametric estimator slope in R? Thank you in advance, Barry _ Barry Baker, Ph.D. Global Climate Change Initiative The Nature Conservancy 2424 Spruce St., Suite 100 Boulder, CO 80302 Tel: (303)-541-0322 Fax: (303)-449-4328 http://nature.org/tncscience/scientists/misc/baker.html __ R-help@stat.math.ethz.ch mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code. __ R-help@stat.math.ethz.ch mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.
Re: [R] Magnitude of trend in time series
I am analyzing some climate time series data using the Mann Kendall package and was wondering if there was a way to calculate the trend using Sen's nonparametric estimator slope in R? I think you can do it with the mblm package. But I vaguely remember that the results didn't look reasonable. I've included some simulation/testing code that I used below. b1 - 5 x - 1:20 - mean(1:20) y - 0 + b1 * x n1 - function() y + rnorm(20, 0, 2) ln1 - function() y + log(rnorm(20, 0, 0.7)) ln2 - function() y + log(rnorm(20, 0, 1.5)) fitlm - function(f=n1) { m - lm(n1() ~ x) ci - t(sapply(c(0.9, 0.95, 0.99), function(x) confint(m, level=x)[2,])) b1 ci[,1] b1 ci[,2] } fitts - function(f=n1) { x - x # because mblm mucks up the environments y2 - n1() m - mblm(y2 ~ x, repeated=FALSE) ci - t(sapply(c(0.9, 0.95, 0.99), function(x) confint(m, level=x)[2,])) b1 ci[,1] b1 ci[,2] } n1lm - replicate(1000, fitlm(n1)) n1ts - replicate(100, fitts(n1)) ln1lm - replicate(1000, fitlm(ln1)) ln1ts - replicate(100, fitts(ln1)) ln2lm - replicate(1000, fitlm(ln2)) ln2ts - replicate(100, fitts(ln2)) Hadley __ R-help@stat.math.ethz.ch mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.