'Parameters
method : str
Only "bfgs" is currently accepted.
start_params : array-like
The first guess on all parameters to be estimated.  This can
be in any order as long as the F,A,H,Q, and R functions handle
the parameters appropriately.
xi10 : array-like
The (r x 1) vector of initial states.  See notes.
F,A,H,Q,R : functions or array-like, optional
If functions, they should take start_params (or the current
value of params during iteration and return the F,A,H,Q,R matrices).
See notes.  If they are constant then can be given as array-like
objects.  If not included in the state-space representation then
can be left as None.  See example in class docstring.
penalty : bool,
Whether or not to include a penalty for solutions that violate
the bounds given by `lowerbounds` and `upperbounds`.
lowerbounds : array-like
Lower bounds on the parameter solutions.  Expected to be in the
same order as `start_params`.
upperbounds : array-like
Upper bounds on the parameter solutions.  Expected to be in the
same order as `start_params`'

def fit_kalman(self, start_params, xi10, ntrain=1, F=None, A=None, H=None, Q=None, R=None, method='bfgs', penalty=True, upperbounds=None, lowerbounds=None):

    y = self.endog
    ntrain = ntrain
    _updateloglike = self._updateloglike
    params = start_params
    if (method.lower() == 'bfgs'):
        (params, llf, score, cov_params, func_calls, grad_calls, warnflag) = optimize.fmin_bfgs(_updateloglike, params, args=(xi10, ntrain, penalty, upperbounds, lowerbounds, F, A, H, Q, R, False), gtol=1e-08, epsilon=1e-05, full_output=1)
    self.params = params
    self.llf = llf
    self.gradient = score
    self.cov_params = cov_params
    self.warnflag = warnflag
