knitr::opts_chunk$set(fig.width=12, fig.height=8, fig.path='Figs/',
echo=FALSE, warning=FALSE, message=FALSE)
library(tidyverse)
## ── Attaching packages ─────────────────────────────────────────────────────────── tidyverse 1.2.1 ──
## ✔ ggplot2 3.2.1 ✔ purrr 0.3.2
## ✔ tibble 2.1.3 ✔ dplyr 0.8.3
## ✔ tidyr 1.0.0 ✔ stringr 1.4.0
## ✔ readr 1.3.1 ✔ forcats 0.4.0
## ── Conflicts ────────────────────────────────────────────────────────────── tidyverse_conflicts() ──
## ✖ dplyr::filter() masks stats::filter()
## ✖ dplyr::lag() masks stats::lag()
library(tsibble)
##
## Attaching package: 'tsibble'
## The following object is masked from 'package:dplyr':
##
## id
library(forecast)
## Registered S3 method overwritten by 'xts':
## method from
## as.zoo.xts zoo
## Registered S3 method overwritten by 'quantmod':
## method from
## as.zoo.data.frame zoo
## Registered S3 methods overwritten by 'forecast':
## method from
## fitted.fracdiff fracdiff
## residuals.fracdiff fracdiff
# import data from txt
rain <- read.table(header=T, 'time_series_rain_ubatuba.txt')
# remove the accumulated for the year and remove the year in the row
d <- rain[,2:13]
# transform in a tsibble
values <- c(t(d)) # get the values as a vector
# remove NAs
values <- values[!is.na(values)]
date <- yearmonth('1935 Jan') + 0:( length(values) - 1) # create the date index
raining <- tsibble(date = date, value = values) # create the tsibble
## Using `date` as index variable.
Consist of \(67*12\) observable accumulated rain for each month starting january 1935 and finish Jul 2001.
The entire date range.
For each year how rain behaved.
Using Polar coordinates
Formula for correlation between x and y. $ r = $