cond_sum_of_squares_ARMA_01 = function(theta,w_t){ # # Given a time series of differences in w_t this function computes the conditional sum of squares # for an AR(0) MA(1) model conditioned on the given value of theta and with a_0 = 0. # # 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. # #----- # Compute the sequence of a_{t} (forward) using the recursion a_t = w_t + theta * a_{t-1} and starting with a_0 = 0 : # a_t = rep(0,length(w_t)) for( ti in 1:length(w_t) ){ if( ti==1 ){ a_t[ti] = w_t[ti] }else{ a_t[ti] = w_t[ti] + theta * a_t[ti-1] } } # Compute the expressions S_star: # return( sum(a_t^2) ) }