Logo ROOT  
Reference Guide
 
Loading...
Searching...
No Matches
RatioOfProfiledLikelihoodsTestStat.cxx
Go to the documentation of this file.
1// @(#)root/roostats:$Id$
2// Author: Kyle Cranmer, Lorenzo Moneta, Gregory Schott, Wouter Verkerke
3/*************************************************************************
4 * Copyright (C) 1995-2008, Rene Brun and Fons Rademakers. *
5 * All rights reserved. *
6 * *
7 * For the licensing terms see $ROOTSYS/LICENSE. *
8 * For the list of contributors see $ROOTSYS/README/CREDITS. *
9 *************************************************************************/
10
11/** \class RooStats::RatioOfProfiledLikelihoodsTestStat
12 \ingroup Roostats
13
14TestStatistic that returns the ratio of profiled likelihoods.
15
16By default the calculation is:
17
18\f[
19 \log{ \frac{ \lambda(\mu_{alt} , {conditional \: MLE \: for \: alt \: nuisance}) }
20 { \lambda(\mu_{null} , {conditional \: MLE \: for \: null \: nuisance}) } }
21\f]
22
23where \f$ \lambda \f$ is the profile likelihood ratio, so the
24MLE for the null and alternate are subtracted off.
25
26If `SetSubtractMLE(false)` then it calculates:
27
28\f[
29 \log{ \frac{ L(\mu_{alt} , {conditional \: MLE \: for \: alt \: nuisance}) }
30 { L(\mu_{null} , {conditional \: MLE \: for \: null \: nuisance}) } }
31\f]
32
33where \f$ L \f$ is the Likelihood function.
34
35The values of the parameters of interest for the alternative
36hypothesis are taken at the time of the construction.
37If empty, it treats all free parameters as nuisance parameters.
38
39The value of the parameters of interest for the null hypotheses
40are given at each call of Evaluate.
41
42This test statistic is often called the Tevatron test statistic, because it has
43been used by the Tevatron experiments.
44*/
45
47
49
50#include "RooArgSet.h"
51#include "RooAbsData.h"
52#include "TMath.h"
53#include "RooMsgService.h"
54#include "RooGlobalFunc.h"
55
56
58
60
61////////////////////////////////////////////////////////////////////////////////
62/// returns -logL(poi, conditional MLE of nuisance params)
63/// subtract off the global MLE or not depending on the option
64/// It is the numerator or the denominator of the ratio (depending on the pdf)
65///
66/// L.M. : not sure why this method is needed now
67
69 int type = (fSubtractMLE) ? 0 : 2;
70
71 // null
72 if ( &pdf == fNullProfile.GetPdf() )
73 return fNullProfile.EvaluateProfileLikelihood(type, data, poi);
74 else if (&pdf == fAltProfile.GetPdf() )
75 return fAltProfile.EvaluateProfileLikelihood(type, data, poi);
76
77 oocoutE((TObject*)NULL,InputArguments) << "RatioOfProfiledLikelihoods::ProfileLikelihood - invalid pdf used for computing the profiled likelihood - return NaN"
78 << std::endl;
79
80 return TMath::QuietNaN();
81
82}
83
84////////////////////////////////////////////////////////////////////////////////
85/// evaluate the ratio of profile likelihood
86
88
89 int type = (fSubtractMLE) ? 0 : 2;
90
91 // null
92 double nullNLL = fNullProfile.EvaluateProfileLikelihood(type, data, nullParamsOfInterest);
93 const RooArgSet *nullset = fNullProfile.GetDetailedOutput();
94
95 // alt
96 double altNLL = fAltProfile.EvaluateProfileLikelihood(type, data, *fAltPOI);
97 const RooArgSet *altset = fAltProfile.GetDetailedOutput();
98
99 if (fDetailedOutput != NULL) {
100 delete fDetailedOutput;
101 fDetailedOutput = NULL;
102 }
103 if (fDetailedOutputEnabled) {
104 fDetailedOutput = new RooArgSet();
105 RooRealVar* var(0);
106 for(TIterator *it = nullset->createIterator();(var = dynamic_cast<RooRealVar*>(it->Next()));) {
107 RooRealVar* cloneVar = new RooRealVar(TString::Format("nullprof_%s", var->GetName()),
108 TString::Format("%s for null", var->GetTitle()), var->getVal());
109 fDetailedOutput->addOwned(*cloneVar);
110 }
111 for(TIterator *it = altset->createIterator();(var = dynamic_cast<RooRealVar*>(it->Next()));) {
112 RooRealVar* cloneVar = new RooRealVar(TString::Format("altprof_%s", var->GetName()),
113 TString::Format("%s for null", var->GetTitle()), var->getVal());
114 fDetailedOutput->addOwned(*cloneVar);
115 }
116 }
117
118/*
119// set variables back to where they were
120nullParamsOfInterest = *saveNullPOI;
121*allVars = *saveAll;
122delete saveAll;
123delete allVars;
124*/
125
126 return nullNLL -altNLL;
127}
#define oocoutE(o, a)
double Double_t
Definition RtypesCore.h:59
const Bool_t kTRUE
Definition RtypesCore.h:91
int type
Definition TGX11.cxx:121
TIterator * createIterator(Bool_t dir=kIterForward) const
TIterator-style iteration over contained elements.
RooAbsData is the common abstract base class for binned and unbinned datasets.
Definition RooAbsData.h:49
Double_t getVal(const RooArgSet *normalisationSet=nullptr) const
Evaluate object.
Definition RooAbsReal.h:91
RooArgSet is a container object that can hold multiple RooAbsArg objects.
Definition RooArgSet.h:29
RooRealVar represents a variable that can be changed from the outside.
Definition RooRealVar.h:39
Double_t ProfiledLikelihood(RooAbsData &data, RooArgSet &poi, RooAbsPdf &pdf)
returns -logL(poi, conditional MLE of nuisance params) subtract off the global MLE or not depending o...
virtual Double_t Evaluate(RooAbsData &data, RooArgSet &nullParamsOfInterest)
evaluate the ratio of profile likelihood
Iterator abstract base class.
Definition TIterator.h:30
virtual const char * GetTitle() const
Returns title of object.
Definition TNamed.h:48
virtual const char * GetName() const
Returns name of object.
Definition TNamed.h:47
Mother of all ROOT objects.
Definition TObject.h:37
static TString Format(const char *fmt,...)
Static method which formats a string using a printf style format descriptor and return a TString.
Definition TString.cxx:2331
Double_t QuietNaN()
Returns a quiet NaN as defined by IEEE 754
Definition TMath.h:901