<p>I have data of total exports of fish from my country in the time period 2010-2020. Since our currency (NOK) has gotten weaker to the currencies we are trading with, we have gotten a lot more value from our exports the last decade.</p>
<p>I have made data who shows how much we have earned from every month the last year. To get precise data for further analysis, I have taken the total value from our exports and divided it by the quantity we have exported.</p>
<p>I want to remove the seasonality of the data. For an example, we will export more every october then january.</p>
<p>This is what I have done:</p>
<pre><code>library(rio)
library(ggplot2)
library(forecast)
library(tseries)
library(tidyverse)
library(zoo)
</code></pre>
<p>VM = value/quantity of our exports</p>
<pre><code>data_ma = ts(na.omit(data$VM), frequency = 12)

decomp = stl(data_ma, &quot;periodic&quot;)
deseasonal_cnt &lt;- seasadj(decomp)
plot(decomp)
</code></pre>
<p><a href="https://i.sstatic.net/BzAFu.png" rel="nofollow noreferrer"><img src="https://i.sstatic.net/BzAFu.png" alt="plot" /></a></p>
<pre><code>adf.test(data_ma, alternative = &quot;stationary&quot;)
</code></pre>
<p>Result shows p-value at 0.04</p>
<pre><code>Acf(data_ma, main = '')
</code></pre>
<p><a href="https://i.sstatic.net/QgH2Q.png" rel="nofollow noreferrer"><img src="https://i.sstatic.net/QgH2Q.png" alt="ACF" /></a></p>
<pre><code>Pacf(VM_ma, main = '')
</code></pre>
<p><a href="https://i.sstatic.net/78UZs.png" rel="nofollow noreferrer"><img src="https://i.sstatic.net/78UZs.png" alt="PACF" /></a></p>
<p>I now want to remove the seasonality, but the I dont know what to do with the ACF and PACF tests as there is so much lags. Can someone please help?</p>
<p>Data:</p>
<p><a href="https://drive.google.com/file/d/17QEiXrV8Zvx5IrIFjBbQGtpODu6ktT8o/view?usp=sharing" rel="nofollow noreferrer">https://drive.google.com/file/d/17QEiXrV8Zvx5IrIFjBbQGtpODu6ktT8o/view?usp=sharing</a></p>

CC BY-SA 4.0
2021-02-25T15:17:56.973Z
Could you please complete the Minimal Working Example by providing the data? That helps those users who want to provide solution to your problem with code.
1muflon1
CC BY-SA 4.0
2021-02-25T15:33:16.907Z
@1muflon1 I have edited the thing now, so you can see the head. Is this what you want or should I share the whole excel-file? If so, how? :) Thanks
schix
CC BY-SA 4.0
2021-02-25T15:43:54.103Z
often the head is enough as one can simulate data based on the head and give you solution but here you have specific problem that is tied to your data (or at least I understood the question that you want to know answer for this problem not just general discussion of how to remove seasonality- if I misunderstood the question then sorry for that). You can share it by for example putting it on a drop box or google docs or some other online service that allows you to upload data and then posting link here
1muflon1
CC BY-SA 4.0
2021-02-25T15:51:54.653Z
@1muflon1 thanks for the help. I think I have provided the data now.
schix
CC BY-SA 4.0
2021-02-27T09:50:17.173Z
There are several issues here. 1) ADF test should not be used on seasonal data. You need to first deseasinalize to apply adf test to check for unit root. 2) p-values for adf test are not easy to get. Often in `R` p-values for adf test are from the t-distribution which is wrong. `urdf` from `urca` is probably the most trust worthy function for adf test. It reports the test statistic and critical values. 3) There are various ways to deseasinalize and it is often not straight forward. The most widely used for official statistics is X13Arima or Tramo-Seats. Both are available in R in package...
Dayne
CC BY-SA 4.0
2021-02-27T09:51:20.290Z
...seasonal. 4) You can select lags in adf test based on some info criteria. This is easy to do in `urdf`.
Dayne
<macroeconomics><r>
Remove seasonality in R
schix
# Remove seasonality in R

(Asked by: username_0 on 2021-02-25)

I have data of total exports of fish from my country in the time period 2010-2020. Since our currency (NOK) has gotten weaker to the currencies we are trading with, we have gotten a lot more value from our exports the last decade.
I have made data who shows how much we have earned from every month the last year. To get precise data for further analysis, I have taken the total value from our exports and divided it by the quantity we have exported.
I want to remove the seasonality of the data. For an example, we will export more every october then january.
This is what I have done:
library(rio)
library(ggplot2)
library(forecast)
library(tseries)
library(tidyverse)
library(zoo)

VM = value/quantity of our exports
data_ma = ts(na.omit(data$VM), frequency = 12)

decomp = stl(data_ma, "periodic")
deseasonal_cnt <- seasadj(decomp)
plot(decomp)


adf.test(data_ma, alternative = "stationary")

Result shows p-value at 0.04
Acf(data_ma, main = '')


Pacf(VM_ma, main = '')


I now want to remove the seasonality, but the I dont know what to do with the ACF and PACF tests as there is so much lags. Can someone please help?
Data:
https://drive.google.com/file/d/17QEiXrV8Zvx5IrIFjBbQGtpODu6ktT8o/view?usp=sharing

**Tags:** macroeconomics, r

> **Comments:**
> **username_1**: Could you please complete the Minimal Working Example by providing the data? That helps those users who want to provide solution to your problem with code.  
> **username_0**: @username_1 I have edited the thing now, so you can see the head. Is this what you want or should I share the whole excel-file? If so, how? :) Thanks  
> **username_1**: often the head is enough as one can simulate data based on the head and give you solution but here you have specific problem that is tied to your data (or at least I understood the question that you want to know answer for this problem not just general discussion of how to remove seasonality- if I misunderstood the question then sorry for that). You can share it by for example putting it on a drop box or google docs or some other online service that allows you to upload data and then posting link here  
> **username_0**: @username_1 thanks for the help. I think I have provided the data now.  
> **username_2**: There are several issues here. 1) ADF test should not be used on seasonal data. You need to first deseasinalize to apply adf test to check for unit root. 2) p-values for adf test are not easy to get. Often in `R` p-values for adf test are from the t-distribution which is wrong. `urdf` from `urca` is probably the most trust worthy function for adf test. It reports the test statistic and critical values. 3) There are various ways to deseasinalize and it is often not straight forward. The most widely used for official statistics is X13Arima or Tramo-Seats. Both are available in R in package...  
> **username_2**: ...seasonal. 4) You can select lags in adf test based on some info criteria. This is easy to do in `urdf`.  

---

## 0 answers

