#NEWLINE# def fit( self , order = ( 0 , 0 ) , start_params = None , method = 'ls' , **optkwds ) : #NEWLINE# #INDENT# '\n        Estimate lag coefficients of an ARIMA process.\n\n        Parameters\n        ----------\n        order : sequence\n            p,d,q where p is the number of AR lags, d is the number of\n            differences to induce stationarity, and q is the number of\n            MA lags to estimate.\n        method : str {"ls", "ssm"}\n            Method of estimation.  LS is conditional least squares.\n            SSM is state-space model and the Kalman filter is used to\n            maximize the exact likelihood.\n        rhoy0, rhoe0 : array_like (optional)\n            starting values for estimation\n\n        Returns\n        -------\n        (rh, cov_x, infodict, mesg, ier) : output of scipy.optimize.leastsq\n\n        rh :\n            estimate of lag parameters, concatenated [rhoy, rhoe]\n        cov_x :\n            unscaled (!) covariance matrix of coefficient estimates\n        ' #NEWLINE# if ( not hasattr ( order , '__iter__' ) ) : #NEWLINE# #INDENT# raise ValueError ( ( 'order must be an iterable sequence.  Got type %s instead' % type ( order ) ) ) #NEWLINE# #UNINDENT# ( p , q ) = optim_kwds #NEWLINE# self . nar = p #NEWLINE# self . nma = q #NEWLINE# x = self . endog . squeeze ( ) #NEWLINE# if ( start_params is None ) : #NEWLINE# #INDENT# arcoefs0 = ( 0.5 * np . ones ( p ) ) #NEWLINE# macoefs0 = ( 0.5 * np . ones ( q ) ) #NEWLINE# start_params = np . r_ [ ( arcoefs0 , macoefs0 ) ] #NEWLINE# #UNINDENT# method = method . lower ( ) #NEWLINE# if ( method == 'ls' ) : #NEWLINE# #INDENT# optim_kwds = dict ( ftol = 1e-10 , full_output = True ) #NEWLINE# optim_kwds . update ( optkwds ) #NEWLINE# ( rh , cov_x , infodict , mesg , ier ) = optimize . leastsq ( self . geterrors , start_params , ** optim_kwds ) #NEWLINE# #UNINDENT# else : #NEWLINE# #INDENT# if ( method == 'ssm' ) : #NEWLINE# #INDENT# pass #NEWLINE# #UNINDENT# else : #NEWLINE# #INDENT# errfnsum = ( lambda rho : np . sum ( ( self . geterrors ( rho ) ** 2 ) ) ) #NEWLINE# optim_kwds = dict ( maxiter = 2 , full_output = True ) #NEWLINE# optim_kwds . update ( optkwds ) #NEWLINE# ( rh , fopt , gopt , cov_x , _ , _ , ier ) = optimize . fmin_bfgs ( errfnsum , start_params , ** optim_kwds ) #NEWLINE# ( infodict , mesg ) = ( None , None ) #NEWLINE# #UNINDENT# #UNINDENT# self . params = rh #NEWLINE# self . ar_est = np . concatenate ( ( [ 1 ] , ( - rh [ : p ] ) ) ) #NEWLINE# self . ma_est = np . concatenate ( ( [ 1 ] , rh [ p : ( p + q ) ] ) ) #NEWLINE# self . error_estimate = self . geterrors ( rh ) #NEWLINE# return ( rh , cov_x , infodict , mesg , ier )