# Error propagation using ExternalConstraints()

Hi,

I’d just like some confirmation if I’m doing this the right way. I’m fitting a PDF which has a fixed parameter. For this parameter I need to propagate its error into the ift result.

So I defined a Gaussian PDF for this parameter and fed it into the ExternalConstraints() modifier of the fitTo() function. I also released the parameter so it’s no longer fixed (setConstant(false)). The fit indeed reports larger errors on the remaining parameters, however not so much as I expected.

Is this the way to go?

And just for my education: What does the ExternalConstraints() modifier exaclty do to the likelihood function?

I’m fitting a signal shape, z2+3*x^2, over a fixed, flat background. Obviously I can’t float the background level because it’s 100% correlated with z2.

Here is the code:

``````	//
// PDF
//
RooRealVar z2  ("z2",	"z2",	0.5, -2.0, 2.0);
RooRealVar nsig("nsig",	"nsig",	1000., -1000.0, 2000000.0);
RooRealVar nbkg("nbkg",	"nbkg",	nBkg, -100, 200);

RooGenericPdf om("om", "om", "@0+3.*@1^2", RooArgList(z2,var));

RooPolynomial p("p", "p", var, RooConst(0));

RooAddPdf sum("sum", "sum", RooArgSet(om, p), RooArgSet(nsig, nbkg));

RooArgSet* pars = sum.getParameters(data);

//
// constraint PDF to propagate error on nBkg
//
RooGaussian nBkgPdf("nBkgPdf", "nBkgPdf", nbkg, RooConst(nBkg), RooConst(nBkgErr));

//
// fit
//
sum.fitTo(*data, Minos(kTRUE), Save(kTRUE), Extended(kTRUE), ExternalConstraints(nBkgPdf));``````

Cheers,

• Moritz

Hi,

What you do looks correct. See e.g. also \$ROOTSYS/tutorials/roofit/rf604_constrains.C for a complete example.

What happens to the likelihood is that the log of the pdf that is specified
as external constraint is added to the regular log likelihood. (So
a Gaussian external constraint amounts to a parabolic term added
to the likelihood)

Note that if the constraint term is the result of a previous (RooFit) fit,
you can automatically obtain the pdf on the parameters as follows

RooAbsPdf* paramPdf = fitResult->createHessePdf(param) ;

where fitResult is the RooFitResult returned by that fit. This technique
also works for multiple parameters, for which the pdf is modeled
by a RooMultiVarGaussian object that includes the correlations that
were found by the fit. (See rf608_fitresultaspdf.C for more details)

Wouter

Thanks, Wouter! I’ll take my time to understand the statistical meaning of this, but in the meantime I’m happy I’m doing it correctly.

• Moritz