如何拟合模型"Y(t)=αX+βY(t-1)-βY(t-2)",在R中? [英] How can I fit the model “Y(t) = αX + βY(t-1) - βY(t-2)" in R?

查看:67
本文介绍了如何拟合模型"Y(t)=αX+βY(t-1)-βY(t-2)",在R中?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我必须使用R对时间序列 Y(t)提前进行一步预测.理论认为理想的模型应该是:

I have to make a one-step ahead forecast for a time series Y(t) using R. Theory suggests the ideal model should be:

Y(t)=αX+βY(t-1)-βY(t-2)

但是,我不知道如何处理以下问题:

However, I don't know how to deal with the following issues:

  • 我必须服用βY(t-1) βY(t-2).
  • 自回归( Y(t-1) Y(t-2))和外生strong>变量( X ).
  • 我必须测试"βY(t-1)-βY(t-2)"是否是表达自回归的最佳方法,而不是其他ARIMA模型.
  • I have to take βY(t-1) minus βY(t-2).
  • There are both autoregressive (Y(t-1),Y(t-2)) and exogenous variables (X).
  • I have to test whether or not "βY(t-1) - βY(t-2)" is the best way to express the autoregression, instead of other ARIMA models.

有问题的时间序列 Y(t)是:

Y <- c(57.4, 51.6, 36.1, 34.8, 41.2, 59.1, 62.5, 55.0, 53.8, 52.4, 44.5, 42.2, 50.1, 61.3, 49.6, 38.2, 51.1, 44.7, 40.8, 46.1, 53.5, 54.7, 50.3, 48.8, 53.7, 52.0)

使用的外生变量 X 是:

X <- c(-12.1, 30.0, 13.5, 30.0, -3.8, -24.3, 30.0, 30.0, 30.0, 30.0, -21.6, 30.0, 0.0, 26.5, -30.0, 20.5, -4.8, -9.2, 22.2, -7.3, 15.9, 16.0, 13.7, 5.6, 5.7, 1.8)

您可能会注意到,实际的X值在预测Y值方面没有太大帮助.不过,由于我正在寻找正确的X值,因此我举了一个例子.

As you may notice, this actual X does not provide much help in predicting Y. Nevertheless, I reported it as an example since I am currently looking for the right values of X.

如果有任何错误或不清楚的地方,请告诉我,我会给出必要的解释.

If anything was wrong or not clear, let me know and I will give the necessary explanations.

谢谢.

推荐答案

您可以使用 lag 函数进行转换,并使用 lm glm 进行回归:

You can use the lag function for the transformation and lm or glm for regression:

Y <- c(57.4, 51.6, 36.1, 34.8, 41.2, 59.1, 62.5, 55.0, 53.8, 52.4, 44.5, 42.2, 50.1, 61.3, 49.6, 38.2, 51.1, 44.7, 40.8, 46.1, 53.5, 54.7, 50.3, 48.8, 53.7, 52.0)
X <- c(-12.1, 30.0, 13.5, 30.0, -3.8, -24.3, 30.0, 30.0, 30.0, 30.0, -21.6, 30.0, 0.0, 26.5, -30.0, 20.5, -4.8, -9.2, 22.2, -7.3, 15.9, 16.0, 13.7, 5.6, 5.7, 1.8)

y_1 <- lag(Y)
y_2 <- lag(Y,2)

lm(Y~X+y_1+y_2)

您还可以直接在回归方程式中进行滞后变换:

You could also do the lag transformations directly in the regression equation:

lm(Y ~ X + I(lag(Y)) + I(lag(Y, 2)))

最后,区别只是运算符的不同:

Finally, the difference is just a change of the operator to this:

lm(Y ~ X + I(lag(Y)) - I(lag(Y, 2)))

Call:
lm(formula = Y ~ X + I(lag(Y)) - I(lag(Y, 2)))

Coefficients:
(Intercept)            X    I(lag(Y))  
  3.906e-14   -4.693e-18    1.000e+00

这篇关于如何拟合模型"Y(t)=αX+βY(t-1)-βY(t-2)",在R中?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
相关文章
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆