#NEWLINE# def predict( self , start = None , end = None , exog = None , dynamic = False , **kwargs ) : #NEWLINE# #INDENT# '\n        In-sample prediction and out-of-sample forecasting\n\n        Parameters\n        ----------\n        start : int, str, or datetime, optional\n            Zero-indexed observation number at which to start forecasting, ie.,\n            the first forecast is start. Can also be a date string to\n            parse or a datetime type. Default is the the zeroth observation.\n        end : int, str, or datetime, optional\n            Zero-indexed observation number at which to end forecasting, ie.,\n            the first forecast is start. Can also be a date string to\n            parse or a datetime type. However, if the dates index does not\n            have a fixed frequency, end must be an integer index if you\n            want out of sample prediction. Default is the last observation in\n            the sample.\n        exog : array_like, optional\n            If the model includes exogenous regressors, you must provide\n            exactly enough out-of-sample values for the exogenous variables if\n            end is beyond the last observation in the sample.\n        dynamic : boolean, int, str, or datetime, optional\n            Integer offset relative to `start` at which to begin dynamic\n            prediction. Can also be an absolute date string to parse or a\n            datetime type (these are not interpreted as offsets).\n            Prior to this observation, true endogenous values will be used for\n            prediction; starting with this observation and continuing through\n            the end of prediction, forecasted endogenous values will be used\n            instead.\n        full_results : boolean, optional\n            If True, returns a FilterResults instance; if False returns a\n            tuple with forecasts, the forecast errors, and the forecast error\n            covariance matrices. Default is False.\n        **kwargs\n            Additional arguments may required for forecasting beyond the end\n            of the sample. See `FilterResults.predict` for more details.\n\n        Returns\n        -------\n        forecast : array\n            Array of out of sample forecasts.\n        ' #NEWLINE# if ( start is None ) : #NEWLINE# #INDENT# start = 0 #NEWLINE# #UNINDENT# _start = self . model . _get_predict_start ( start ) #NEWLINE# ( _end , _out_of_sample ) = self . model . _get_predict_end ( end ) #NEWLINE# if ( _out_of_sample and ( self . model . k_exog > 0 ) ) : #NEWLINE# #INDENT# nobs = ( self . model . data . orig_endog . shape [ 0 ] + _out_of_sample ) #NEWLINE# endog = np . zeros ( ( nobs , self . model . k_endog ) ) #NEWLINE# if ( self . model . k_exog > 0 ) : #NEWLINE# #INDENT# if ( exog is None ) : #NEWLINE# #INDENT# raise ValueError ( 'Out-of-sample forecasting in a model with a regression component requires additional exogenous values via the `exog` argument.' ) #NEWLINE# #UNINDENT# exog = np . array ( exog ) #NEWLINE# required_exog_shape = ( _out_of_sample , self . model . k_exog ) #NEWLINE# if ( not ( exog . shape == required_exog_shape ) ) : #NEWLINE# #INDENT# raise ValueError ( ( 'Provided exogenous values are not of the appropriate shape. Required %s, got %s.' % ( str ( required_exog_shape ) , str ( exog . shape ) ) ) ) #NEWLINE# #UNINDENT# exog = np . c_ [ ( self . model . data . orig_exog . T , exog . T ) ] . T #NEWLINE# #UNINDENT# model_kwargs = self . _init_kwds . copy ( ) #NEWLINE# model_kwargs [ 'exog' ] = exog #NEWLINE# model = UnobservedComponents ( endog , ** model_kwargs ) #NEWLINE# model . update ( self . params ) #NEWLINE# for name in self . filter_results . shapes . keys ( ) : #NEWLINE# #INDENT# if ( name == 'obs' ) : #NEWLINE# #INDENT# continue #NEWLINE# #UNINDENT# mat = getattr ( model . ssm , name ) #NEWLINE# if ( mat . shape [ ( - 1 ) ] > 1 ) : #NEWLINE# #INDENT# if ( len ( mat . shape ) == 2 ) : #NEWLINE# #INDENT# kwargs [ name ] = mat [ : , ( - _out_of_sample ) : ] #NEWLINE# #UNINDENT# else : #NEWLINE# #INDENT# kwargs [ name ] = mat [ : , : , ( - kwargs ) : ] #NEWLINE# #UNINDENT# #UNINDENT# #UNINDENT# #UNINDENT# else : #NEWLINE# #INDENT# if ( ( self . model . k_exog == 0 ) and ( exog is not None ) ) : #NEWLINE# #INDENT# warn ( 'Exogenous array provided to predict, but additional data not required. `exog` argument ignored.' ) #NEWLINE# #UNINDENT# #UNINDENT# return super ( UnobservedComponentsResults , self ) . predict ( start = start , end = end , exog = exog , dynamic = dynamic , ** kwargs )