def lsqfit(self, data=None, pdata=None, prior=None, p0=None, **kargs):
<EOL>if prior is None:<EOL><INDENT>raise ValueError('<STR_LIT>')<EOL><DEDENT>kargs, oldargs = self.set(**kargs)<EOL>fitter_args_kargs = (<EOL>self.chained_lsqfit,<EOL>dict(data=data, prior=prior, pdata=pdata, models=self.models),<EOL>dict(kargs),<EOL>)<EOL>fitprior = self.buildprior(prior=prior, mopt=self.mopt)<EOL>fitdata = self.builddata(<EOL>mopt=self.mopt, data=data, pdata=pdata, prior=prior<EOL>)<EOL>fitfcn = self.buildfitfcn()<EOL>self.fit = lsqfit.nonlinear_fit(<EOL>data=fitdata, prior=fitprior, fcn=fitfcn, p0=p0,<EOL>**self.fitterargs<EOL>)<EOL>if len(self.flatmodels) > <NUM_LIT:1>:<EOL><INDENT>fname = self.fitname(<EOL>'<STR_LIT:(>' +<EOL>'<STR_LIT:U+002C>'.join([self.fitname(k.datatag) for k in self.flatmodels])<EOL>+ '<STR_LIT:)>'<EOL>)<EOL><DEDENT>else:<EOL><INDENT>fname = self.fitname(self.flatmodels[<NUM_LIT:0>].datatag)<EOL><DEDENT>self.fit.chained_fits = collections.OrderedDict([(fname, self.fit)])<EOL>def _formatall(*args, **kargs):<EOL><INDENT>"<STR_LIT>"<EOL>ans = '<STR_LIT>'<EOL>for x in self.fit.chained_fits:<EOL><INDENT>ans += <NUM_LIT:10> * '<STR_LIT:=>' + '<STR_LIT:U+0020>' + str(x) + '<STR_LIT:\n>'<EOL>ans += self.fit.chained_fits[x].format(*args, **kargs)<EOL>ans += '<STR_LIT:\n>'<EOL><DEDENT>return ans[:-<NUM_LIT:1>]<EOL><DEDENT>self.fit.formatall = _formatall<EOL>def _show_plots(save=False, view='<STR_LIT>'):<EOL><INDENT>MultiFitter.show_plots(<EOL>fitdata=fitdata, fitval=fitfcn(self.fit.p),<EOL>save=save, view=view,<EOL>)<EOL><DEDENT>self.fit.show_plots = _show_plots<EOL>self.set(**oldargs)<EOL>fitter_args_kargs[<NUM_LIT:1>]['<STR_LIT>'] = self.fit.pmean<EOL>def _bstrap_iter(<EOL>n=None, datalist=None, pdatalist=None, **kargs<EOL>):<EOL><INDENT>return MultiFitter._bootstrapped_fit_iter(<EOL>fitter_args_kargs,<EOL>n=n, datalist=datalist, pdatalist=pdatalist, **kargs<EOL>)<EOL><DEDENT>self.fit.bootstrapped_fit_iter = _bstrap_iter<EOL>return self.fit<EOL>
Compute least-squares fit of models to data.

        :meth:`MultiFitter.lsqfit` fits all of the models together, in
        a single fit. It returns the |nonlinear_fit| object from the fit.

        To see plots of the fit data divided by the fit function
        with the best-fit parameters use

            fit.show_plots()

        This method has optional keyword arguments ``save`` and ``view``;
        see documentation for :class:`lsqfit.MultiFitter.show_plots`
        for more information. Plotting requires module :mod:`matplotlib`.

        To bootstrap a fit, use ``fit.bootstrapped_fit_iter(...)``;
        see :meth:`lsqfit.nonlinear_fit.bootstrapped_fit_iter` for more
        information.

        Args:
            data: Input data. One of ``data`` or ``pdata`` must be
                specified but not both. ``pdata`` is obtained from ``data``
                by collecting the output from ``m.builddata(data)``
                for each model ``m`` and storing it in a dictionary
                with key ``m.datatag``.
            pdata: Input data that has been processed by the
                models using :meth:`MultiFitter.process_data` or
                :meth:`MultiFitter.process_dataset`. One of
                ``data`` or ``pdata`` must be  specified but not both.
            prior (dict): Bayesian prior for fit parameters used by the models.
            p0: Dictionary , indexed by parameter labels, containing
                initial values for the parameters in the fit. Setting
                ``p0=None`` implies that initial values are extracted from the
                prior. Setting ``p0="filename"`` causes the fitter to look in
                the file with name ``"filename"`` for initial values and to
                write out best-fit parameter values after the fit (for the
                next call to ``self.lsqfit()``).
            kargs: Arguments that (temporarily) override parameters specified
                when the :class:`MultiFitter` was created. Can also include
                additional arguments to be passed through to the :mod:`lsqfit`
                fitter.