admin管理员组文章数量:1023094
I computed AR's models to predict the value of BTC. In order to make the data stationary i have transformed it :
- yt=log(BTS_t)
- dyt = yt-yt-1 I take the difference of logarithms (interpretable as the growth rate between two consecutive days). However, I want to extract the forcast of the original value of the BTC.
My code is the following :
Construct data
df_byday <- read_excel("C:/Users/33610/Downloads/dfday.xlsx")
df_byday$log <- log(df_byday$Price)
df_byday$LOGdiff1 <- c(0, diff(df_byday$log, lag = 1))
tsBTC2 <- ts(df_byday$LOGdiff1, start=c(2017,01,01), frequency=365)
Estimate :
summary(mod_ar1)
mod_ma1 <- Arima(tsBTC2, order = c(0, 0, 1))
summary(mod_ma1)
mod_ar8 <- Arima(tsBTC2, order = c(8, 0, 0))
summary(mod_ar8)
mod_arma11 <- Arima(tsBTC2, order = c(1, 0, 1))
summary(mod_arma11)
Correct for non-significant coefficients :
mod_ar8fix <- Arima(tsBTC2, order = c(8, 0, 0), fixed=c(NA,0,0,0,0,0,0,NA,NA))
summary(mod_ar8fix)
Forecast (for the transformed data) :
forecast_ar8 <- forecast(mod_ar8fix, h = 5)
forecast_ar1 <- forecast(mod_ar1, h = 5)
forecast_ma1 <- forecast(mod_ma1, h = 5)
I want to use this forcast to predict the future value of the BTC and avoid the problem of the log and the difference
Thanks you for your helping!
I computed AR's models to predict the value of BTC. In order to make the data stationary i have transformed it :
- yt=log(BTS_t)
- dyt = yt-yt-1 I take the difference of logarithms (interpretable as the growth rate between two consecutive days). However, I want to extract the forcast of the original value of the BTC.
My code is the following :
Construct data
df_byday <- read_excel("C:/Users/33610/Downloads/dfday.xlsx")
df_byday$log <- log(df_byday$Price)
df_byday$LOGdiff1 <- c(0, diff(df_byday$log, lag = 1))
tsBTC2 <- ts(df_byday$LOGdiff1, start=c(2017,01,01), frequency=365)
Estimate :
summary(mod_ar1)
mod_ma1 <- Arima(tsBTC2, order = c(0, 0, 1))
summary(mod_ma1)
mod_ar8 <- Arima(tsBTC2, order = c(8, 0, 0))
summary(mod_ar8)
mod_arma11 <- Arima(tsBTC2, order = c(1, 0, 1))
summary(mod_arma11)
Correct for non-significant coefficients :
mod_ar8fix <- Arima(tsBTC2, order = c(8, 0, 0), fixed=c(NA,0,0,0,0,0,0,NA,NA))
summary(mod_ar8fix)
Forecast (for the transformed data) :
forecast_ar8 <- forecast(mod_ar8fix, h = 5)
forecast_ar1 <- forecast(mod_ar1, h = 5)
forecast_ma1 <- forecast(mod_ma1, h = 5)
I want to use this forcast to predict the future value of the BTC and avoid the problem of the log and the difference
Thanks you for your helping!
Share Improve this question edited Nov 19, 2024 at 9:17 Constantin Marguier asked Nov 19, 2024 at 9:11 Constantin MarguierConstantin Marguier 113 bronze badges1 Answer
Reset to default 1Build the log and difference into the fitted model, and the forecast()
function will take care of it for you.
e.g.,
library(forecast)
price <- ts(df_byday$Price, start = 2027, frequency = 365)
mod_arima011 <- Arima(price, order = c(0, 1, 1), lambda = 0)
forecast_arima011 <- forecast(mod_arima011, h = 5)
The lambda=0
argument specifies a logarithm. See https://otexts/fpp2/arima.html for a textbook introduction.
But since you're modelling daily data, you would be better off not using a ts
object or the forecast
package. Instead, consider tsibble
objects with the fable
package. See https://otexts/fpp3/arima.html.
I computed AR's models to predict the value of BTC. In order to make the data stationary i have transformed it :
- yt=log(BTS_t)
- dyt = yt-yt-1 I take the difference of logarithms (interpretable as the growth rate between two consecutive days). However, I want to extract the forcast of the original value of the BTC.
My code is the following :
Construct data
df_byday <- read_excel("C:/Users/33610/Downloads/dfday.xlsx")
df_byday$log <- log(df_byday$Price)
df_byday$LOGdiff1 <- c(0, diff(df_byday$log, lag = 1))
tsBTC2 <- ts(df_byday$LOGdiff1, start=c(2017,01,01), frequency=365)
Estimate :
summary(mod_ar1)
mod_ma1 <- Arima(tsBTC2, order = c(0, 0, 1))
summary(mod_ma1)
mod_ar8 <- Arima(tsBTC2, order = c(8, 0, 0))
summary(mod_ar8)
mod_arma11 <- Arima(tsBTC2, order = c(1, 0, 1))
summary(mod_arma11)
Correct for non-significant coefficients :
mod_ar8fix <- Arima(tsBTC2, order = c(8, 0, 0), fixed=c(NA,0,0,0,0,0,0,NA,NA))
summary(mod_ar8fix)
Forecast (for the transformed data) :
forecast_ar8 <- forecast(mod_ar8fix, h = 5)
forecast_ar1 <- forecast(mod_ar1, h = 5)
forecast_ma1 <- forecast(mod_ma1, h = 5)
I want to use this forcast to predict the future value of the BTC and avoid the problem of the log and the difference
Thanks you for your helping!
I computed AR's models to predict the value of BTC. In order to make the data stationary i have transformed it :
- yt=log(BTS_t)
- dyt = yt-yt-1 I take the difference of logarithms (interpretable as the growth rate between two consecutive days). However, I want to extract the forcast of the original value of the BTC.
My code is the following :
Construct data
df_byday <- read_excel("C:/Users/33610/Downloads/dfday.xlsx")
df_byday$log <- log(df_byday$Price)
df_byday$LOGdiff1 <- c(0, diff(df_byday$log, lag = 1))
tsBTC2 <- ts(df_byday$LOGdiff1, start=c(2017,01,01), frequency=365)
Estimate :
summary(mod_ar1)
mod_ma1 <- Arima(tsBTC2, order = c(0, 0, 1))
summary(mod_ma1)
mod_ar8 <- Arima(tsBTC2, order = c(8, 0, 0))
summary(mod_ar8)
mod_arma11 <- Arima(tsBTC2, order = c(1, 0, 1))
summary(mod_arma11)
Correct for non-significant coefficients :
mod_ar8fix <- Arima(tsBTC2, order = c(8, 0, 0), fixed=c(NA,0,0,0,0,0,0,NA,NA))
summary(mod_ar8fix)
Forecast (for the transformed data) :
forecast_ar8 <- forecast(mod_ar8fix, h = 5)
forecast_ar1 <- forecast(mod_ar1, h = 5)
forecast_ma1 <- forecast(mod_ma1, h = 5)
I want to use this forcast to predict the future value of the BTC and avoid the problem of the log and the difference
Thanks you for your helping!
Share Improve this question edited Nov 19, 2024 at 9:17 Constantin Marguier asked Nov 19, 2024 at 9:11 Constantin MarguierConstantin Marguier 113 bronze badges1 Answer
Reset to default 1Build the log and difference into the fitted model, and the forecast()
function will take care of it for you.
e.g.,
library(forecast)
price <- ts(df_byday$Price, start = 2027, frequency = 365)
mod_arima011 <- Arima(price, order = c(0, 1, 1), lambda = 0)
forecast_arima011 <- forecast(mod_arima011, h = 5)
The lambda=0
argument specifies a logarithm. See https://otexts/fpp2/arima.html for a textbook introduction.
But since you're modelling daily data, you would be better off not using a ts
object or the forecast
package. Instead, consider tsibble
objects with the fable
package. See https://otexts/fpp3/arima.html.
本文标签: time seriesExtract forecast from an ARIMA with log and difference (R)Stack Overflow
版权声明:本文标题:time series - Extract forecast from an ARIMA with log and difference (R) - Stack Overflow 内容由热心网友自发贡献,该文观点仅代表作者本人, 转载请联系作者并注明出处:http://it.en369.cn/questions/1745570983a2156735.html, 本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌抄袭侵权/违法违规的内容,一经查实,本站将立刻删除。
发表评论