Logo ROOT   6.14/05
Reference Guide
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 
14 TestStatistic that returns the ratio of profiled likelihoods.
15 
16 By 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 
23 where \f$ \lambda \f$ is the profile likelihood ratio, so the
24 MLE for the null and alternate are subtracted off.
25 
26 If `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 
33 where \f$ L \f$ is the Likelihood function.
34 
35 The values of the parameters of interest for the alternative
36 hypothesis are taken at the time of the construction.
37 If empty, it treats all free parameters as nuisance parameters.
38 
39 The value of the parameters of interest for the null hypotheses
40 are given at each call of Evaluate.
41 
42 This test statistic is often called the Tevatron test statistic, because it has
43 been 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  }
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
120 nullParamsOfInterest = *saveNullPOI;
121 *allVars = *saveAll;
122 delete saveAll;
123 delete allVars;
124 */
125 
126  return nullNLL -altNLL;
127 }
virtual const char * GetName() const
Returns name of object.
Definition: TNamed.h:47
TIterator * createIterator(Bool_t dir=kIterForward) const
virtual const RooArgSet * GetDetailedOutput(void) const
return detailed output: for fits this can be pulls, processing time, ... The returned pointer will no...
Double_t QuietNaN()
Returns a quiet NaN as defined by IEEE 754
Definition: TMath.h:900
Double_t getVal(const RooArgSet *set=0) const
Definition: RooAbsReal.h:64
bool Bool_t
Definition: RtypesCore.h:59
virtual Double_t EvaluateProfileLikelihood(int type, RooAbsData &data, RooArgSet &paramsOfInterest)
internal function to evaluate test statistics can do depending on type:
Iterator abstract base class.
Definition: TIterator.h:30
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:2286
#define oocoutE(o, a)
Definition: RooMsgService.h:47
RooRealVar represents a fundamental (non-derived) real valued object.
Definition: RooRealVar.h:36
virtual Bool_t addOwned(const RooAbsCollection &col, Bool_t silent=kFALSE)
Add a collection of arguments to this collection by calling addOwned() for each element in the source...
Definition: RooArgSet.h:90
RooAbsData is the common abstract base class for binned and unbinned datasets.
Definition: RooAbsData.h:37
double Double_t
Definition: RtypesCore.h:55
virtual Double_t Evaluate(RooAbsData &data, RooArgSet &nullParamsOfInterest)
evaluate the ratio of profile likelihood
int type
Definition: TGX11.cxx:120
Mother of all ROOT objects.
Definition: TObject.h:37
RooAbsPdf is the abstract interface for all probability density functions The class provides hybrid a...
Definition: RooAbsPdf.h:41
const Bool_t kTRUE
Definition: RtypesCore.h:87
virtual const char * GetTitle() const
Returns title of object.
Definition: TNamed.h:48
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...