如何将预测函数用于R中的简单移动平均模型? [英] how to use forecast function for simple moving average model in r?
本文介绍了如何将预测函数用于R中的简单移动平均模型?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我想为我的简单移动平均模型预测未来价值.我使用了以下过程:
I want to predict the future values for my simple moving average model. I used the following procedure:
x <- c(14,10,11,7,10,9,11,19,7,10,21,9,8,16,21,14,6,7)
df <- data.frame(x)
dftimeseries <- ts(df)
library(TTR)
smadf <- SMA(dftimeseries, 4) # lag is 4
library(forecast)
forecasteddf <- forecast(smadf, 4) # future 4 values
运行上面的代码时,接下来4天的预测值都相同.我编码正确吗?或者,我在概念上错了吗?
When run the above code, my forecast values are the same for all the next 4 days. Am I coding it correctly? Or, am I conceptually wrong?
指数移动平均线,加权移动平均线和ARIMA也是这种情况.
The same is the case with exponential moving average, weighted moving average, and ARIMA also.
推荐答案
For a moving average model you can read here
由于该模型假设一个恒定的基础均值,所以未来任何时期的预测都是相同的...".
因此,考虑到移动平均模式的特征,您的结果将是预期的.
So, your result are to be expected considering the characteristics of the moving average mode.
这篇关于如何将预测函数用于R中的简单移动平均模型?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文