title: How to perform mann kendall and sen's slope in timeseries data in r
body: <p><a href="https://drive.google.com/file/d/0B3fQ9_46L-O0ZXVYb3lzZDBZaHM/view?usp=sharing" rel="nofollow noreferrer">https://drive.google.com/file/d/0B3fQ9_46L-O0ZXVYb3lzZDBZaHM/view?usp=sharing</a> <a href="https://drive.google.com/file/d/0B3fQ9_46L-O0TjJwYmF6UThNSGs/view?usp=sharing" rel="nofollow noreferrer">https://drive.google.com/file/d/0B3fQ9_46L-O0TjJwYmF6UThNSGs/view?usp=sharing</a></p>
  
  <p>Here, I have a time series data of precipitation of two stations of the same place in CSV format. I am trying to find these two stations precipitation trend as well as the magnitude of the trend. For doing that I used Mann-Kendall and Sen's slope. I tried in this particular way, I want to know whether I am doing right or not? In this below code, I calculate trend and magnitude individually but my aim is to calculate trend and magnitude of two stations together. How I can perform the pre-whitening, Mann-Kendall and Sen's slope test for two stations at once as well as their plot?</p>
  
  <pre><code>library(xts)
  library(Kendall)
  library(zyp)
  library(trend)
  setwd("~/Desktop/pawan thapa 2/pawan thapa/rautahat")
  ram = read.csv('ramoli_preci.csv',header=TRUE, stringsAsFactors=FALSE)
  gaur2= read.csv('preci_Gaur.csv',header=TRUE, stringsAsFactors=F)
  # Get data properties
  dim(gaur2)
  dim(ram)
  head(ram)
  date &lt;- as.Date(as.character(gaur2$Year), "%Y")
  date_r &lt;- as.Date(as.character(ram$Year), "%Y")
  gaur.ts&lt;-as.ts(gaur2)
  ram.ts&lt;-as.ts(ram)
  head(ram.ts)
  class(ram.ts)
  head(ram.ts)
  hist(ram.ts)
  acf(ram.ts)
  
  mk.test(ram.ts)
  sens.slope(ram.ts)
  
  head(date)
  tail(date)
  class(date)
  class(gaur2)
  str(gaur2)
  
  class(gaur.ts)
  head(gaur.ts)
  mk.test(gaur.ts)
  sens.slope(gaur.ts)
  hist(gaur.ts)
  </code></pre>