简体   繁体   English

使用Marquardt算法的具有非线性最小二乘法的AR(1):EViews与R

[英]AR(1) with Nonlinear Least Squares using Marquardt Algorithm: EViews vs R

Some weeks ago, I posted a poorly thought-out question plagued with vague information. 几周前,我发布了一个经过深思熟虑的问题,困扰着模糊的信息。 This is my attempt to correct the original question and get better answers. 这是我纠正原始问题并获得更好答案的尝试。

The main problem is: I cannot obtain similar parameter estimates with EViews and R. 主要问题是:我无法使用EViews和R获得类似的参数估计。

For reasons I do not know myself, I need to estimate parameters for certain data using EViews. 由于我不了解自己的原因,我需要使用EViews估算某些数据的参数。 This is done by picking the NLS (nonlinear least squares) option and using the following formula: indep_var c dep_var ar(1) 这是通过选择NLS(非线性最小二乘)选项并使用以下公式完成的: indep_var c dep_var ar(1)

EViews claims that they estimate linear AR(1) processes such as: EViews声称他们估计线性AR(1)过程,例如:

Y t = a + B * X t + u t Y t = a + B * X t + u t

where u t errors are defined as 其中,u t个错误被定义为

u t = p * u t-1 + e u t = p * u t-1 + e

by using an equivalent equation (with some algebraic substitutions): 通过使用等效方程式(带有一些代数替换):

Y t = (1 - p) * a + p * Y t - 1 + B * X t - p * B * X t - 1 + e t Y t =(1-p)* a + p * Y t-1 + B * X t -p * B * X t-1 + e t

Furthermore, this thread over at the EViews forums suggests that their NLS estimations are generated by the Marquardt algorithm. 此外, 在EViews论坛上的讨论提示,其NLS估计值是由Marquardt算法生成的。

Now, the go-to R function to estimate AR(1) processes is arima . 现在,用于估计AR(1)过程的R函数为arima However, there are two problems: 1) the estimates are maximum likelihood estimates; 但是,存在两个问题:1)估计是最大似然估计; 2) the intercept estimate is not actually the intercept estimate . 2)截距估计实际上不是截距估计

Therefore, I turned to the nlsLM function from the minpack.lm package. 因此,我从minpack.lm包转向了nlsLM函数。 This function uses the Marquardt algorithm to achieve nonlinear least squares estimates, which should yield the same results as the EViews implementation (or very similar ones, at least). 此函数使用Marquardt算法获得非线性最小二乘估计,该估计应产生与EViews实现相同的结果(至少是非常相似的结果)。

Now the code. 现在的代码。 I have a data frame ( data ) with an independent variable and a dependent variable such as the one generated by the following code: 我有一个带有自变量和因变量的数据帧( data ),例如由以下代码生成的变量:

data <- data.frame(independent = abs(rnorm(48)), dependent = abs(rnorm(48)))

To estimate parameters in the equation EViews claims to estimate (3 rd one on this post), I use the following commands: 为了估计方程的EViews要求来估计( 第三一个在此篇)中的参数,我使用下面的命令:

library(minpack.lm)
result <-
nlsLM(dependentB ~ ((1 - theta1) * theta2) + (theta1 * dependentA) +
                    (theta3 * independentB) - (theta1 * theta3 * independentA),
data = list(dependentB = data$dependent[2:48], dependentA = data$dependent[1:47],
   independentB = data$independent[2:48], independentA = data$independent[1:47]),
start = list(theta1 = -10, theta2 = -10, theta3 = -10)
)

Unfortunately, the estimates output by nlsLM are not close to the ones output by EViews. 不幸的是, nlsLM输出的估计值与EViews输出的估计值并不接近。 Do you have any idea of what might be causing this? 您有什么可能的原因吗? Or maybe my code is wrong? 也许我的代码是错误的?

Finally, I would like to say that I personally am an R user - that is exactly why I'm trying to do this in R instead of EViews. 最后,我想说我个人是R用户-这就是为什么我试图在R中而不是EViews中执行此操作。 I would also love to provide you the data I'm working with but it's impossible since it's confidential data. 我也很乐意向您提供我正在使用的数据,但这是不可能的,因为它是机密数据。

Eviews规范似乎应该是:

dep_var  c indep_var ar(1)

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM