est_phi1_theta1_AR1MA1 = function(r1,r2){ # # Estimates \phi_1 and \theta_1 in the ARIMA(1,d,1) model: # # w_t = \phi_1 w_{t-1} + a_t - \theta_1 a_{t-1} # # using a very simple version of Newton's method. # # Inputs: # r1,r2 = autocorrelation of lag 1 and 2 # # Written by: # -- # John L. Weatherwax 2009-04-21 # # email: wax@alum.mit.edu # # Please send comments and especially bug reports to the # above email address. # #----- # The estimate for phi_1 is simple: # phi1 = r2/r1 # For theta_2 we must solve for x in a nonlinear function (f(x)=0) # f = function(x) ( (1-x*phi1) * ( phi1 - x ) - r1 * ( 1 + x^2 - 2 * phi1 * x ) ) fprime = function(x) ( - phi1 * ( phi1 - x ) - ( 1 - x * phi1 ) - r1 * ( 2 * x - 2 * phi1 ) ) x0 = 0.0 for( ii in 1:20 ){ x1 = x0 - f(x0)/fprime(x0) x0 = x1 } theta1 = x0 c(phi1,theta1) # return the results }