The main problem is: I cannot obtain similar parameter estimates with EViews and R.

For reasons I do not know myself, I need to estimate parameters for certain data using EViews. This is done by picking the NLS (nonlinear least squares) option and using the following formula: indep_var c dep_var ar(1)

EViews claims that they estimate linear AR(1) processes such as: $$ Y_t = \alpha + \beta X_t + u_t $$ where $u_t$ errors are defined as: $$ u_t = \rho \cdot u_{t-1} + \varepsilon $$ by using an equivalent equation (with some algebraic substitutions): $$ Y_t = (1 - \rho) \alpha + \rho Y_{t - 1} + \beta X_t - \rho \beta X_{t - 1} + \varepsilon_t $$ Furthermore, this thread over at the EViews forums suggests that their NLS estimations are generated by the Marquardt algorithm.

Now, the go-to R function to estimate AR(1) processes is arima. However, there are two problems:

  1. the estimates are maximum likelihood estimates;
  2. the intercept estimate is not actually the intercept estimate (according to R.H. Shumway & D.S. Stoffer).

Therefore, I turned to the nlsLM function from the minpack.lm package. 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).

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.frame(independent = abs(rnorm(48)), dependent = abs(rnorm(48)))

To estimate parameters in the equation EViews claims to estimate (3rd one on this post), I use the following commands:

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. 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. I would also love to provide you the data I'm working with but it's impossible since it's confidential data.

  • 4
    $\begingroup$ Welcome to the site, @Fael. +1 for a clear question. I took the liberty of tweaking the formatting slightly to make it cleaner. Please make sure it still says what you want. $\endgroup$ – gung - Reinstate Monica Nov 14 '12 at 17:18
  • $\begingroup$ Wow, that was really nice of you. Thanks a lot, @gung ! $\endgroup$ – Fael Nov 14 '12 at 17:23
  • 2
    $\begingroup$ You cam always scale/code the data and post it. a transformation of the form [(y-constant1)/constant2 ] will do the trick. $\endgroup$ – IrishStat Nov 14 '12 at 17:38
  • $\begingroup$ BTW: Parameters of linear processes can be estimated through OLS. $\endgroup$ – Germaniawerks Jul 28 '14 at 19:23

Your NLLS has four ortoghonality conditions, one per variable plus the constant (analogue to normal equations in standard OLS) to solve for three parameters ($\rho, \beta, \alpha$ ). The Non-linear algorithms often have heterogenous configurations for tolerance parameters across softwares. MAy I suggest you drop $X_{t-1}$ from your equation in order to get exactly identified system and then test Eviews against R ? if both agree, it probably means one of them has troubles with the overidentification.


Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.