Re: [R] Kendall Theil line as fit?

From: jonbfish <aseeman_at_iasoybeans.com>
Date: Fri, 11 Mar 2011 14:43:57 -0800 (PST)

Thanks for the response, sorry I didn't post it initially.

kt.mat <-
function(x,y,z){
for(i in 1:length(x)){for(j in
1:length(y)){z[i,j]<-(y[j]-y[i])/(x[j]-x[i])}} return(z)}

kt.slope <-
function(x,y,z,s){
count<-0
for(i in 1:length(x)){for(j in 1:length(y)){ if(j >= i+1) {
count<-count+1
s[count]<-z[i,j]}
}}
print(count)
return(s)}

#Site23

x <- c(1999,2000,2001,2002,2003,2004,2005,2006,2007,2008,2009,2010) y <-
c(17.942,3.43,14.062,14.814,13.778,13.706,9.748,13.088,12.1309728,9.644646671,9.134,8.84)

z<-matrix(0:0,length(x),length(y))
z<-kt.mat(x,y,z)
z

s<-c(1:(length(x)*(length(x)-1)/2))
s<-kt.slope(x,y,z,s)
s
slope=median(s)
intercept=median(y)-slope*median(x)
cbind(slope,intercept)
plot(x,y)

abline(intercept,slope)

--
View this message in context: http://r.789695.n4.nabble.com/Kendall-Theil-line-as-fit-tp3344617p3349277.html
Sent from the R help mailing list archive at Nabble.com.

______________________________________________
R-help_at_r-project.org 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.
Received on Fri 11 Mar 2011 - 23:13:25 GMT

Archive maintained by Robert King, hosted by the discipline of statistics at the University of Newcastle, Australia.
Archive generated by hypermail 2.2.0, at Sat 12 Mar 2011 - 02:10:20 GMT.

Mailing list information is available at https://stat.ethz.ch/mailman/listinfo/r-help. Please read the posting guide before posting to the list.

list of date sections of archive