ROOT  6.06/09
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 
12 
13 #include "RooArgSet.h"
14 #include "RooAbsData.h"
15 #include "TMath.h"
16 #include "RooMsgService.h"
17 #include "RooGlobalFunc.h"
18 
19 
21 
23 
24  ////////////////////////////////////////////////////////////////////////////
25  /// returns -logL(poi, conditonal MLE of nuisance params)
26  /// subtract off the global MLE or not depending on the option
27  /// It is the numerator or the denominator of the ratio (depending on the pdf)
28  ///L.M. : not sure why this method is needed now
29 
31  int type = (fSubtractMLE) ? 0 : 2;
32 
33  // null
34  if ( &pdf == fNullProfile.GetPdf() )
35  return fNullProfile.EvaluateProfileLikelihood(type, data, poi);
36  else if (&pdf == fAltProfile.GetPdf() )
37  return fAltProfile.EvaluateProfileLikelihood(type, data, poi);
38 
39  oocoutE((TObject*)NULL,InputArguments) << "RatioOfProfiledLikelihoods::ProfileLikelihood - invalid pdf used for computing the profiled likelihood - return NaN"
40  << std::endl;
41 
42  return TMath::QuietNaN();
43 
44 }
45 
46 ////////////////////////////////////////////////////////////////////////////////
47 /// evaluate the ratio of profile likelihood
48 
50 
51  int type = (fSubtractMLE) ? 0 : 2;
52 
53  // null
54  double nullNLL = fNullProfile.EvaluateProfileLikelihood(type, data, nullParamsOfInterest);
55  const RooArgSet *nullset = fNullProfile.GetDetailedOutput();
56 
57  // alt
58  double altNLL = fAltProfile.EvaluateProfileLikelihood(type, data, *fAltPOI);
59  const RooArgSet *altset = fAltProfile.GetDetailedOutput();
60 
61  if (fDetailedOutput != NULL) {
62  delete fDetailedOutput;
63  fDetailedOutput = NULL;
64  }
65  if (fDetailedOutputEnabled) {
66  fDetailedOutput = new RooArgSet();
67  RooRealVar* var(0);
68  for(TIterator *it = nullset->createIterator();(var = dynamic_cast<RooRealVar*>(it->Next()));) {
69  RooRealVar* cloneVar = new RooRealVar(TString::Format("nullprof_%s", var->GetName()),
70  TString::Format("%s for null", var->GetTitle()), var->getVal());
71  fDetailedOutput->addOwned(*cloneVar);
72  }
73  for(TIterator *it = altset->createIterator();(var = dynamic_cast<RooRealVar*>(it->Next()));) {
74  RooRealVar* cloneVar = new RooRealVar(TString::Format("altprof_%s", var->GetName()),
75  TString::Format("%s for null", var->GetTitle()), var->getVal());
76  fDetailedOutput->addOwned(*cloneVar);
77  }
78  }
79 
80 /*
81 // set variables back to where they were
82 nullParamsOfInterest = *saveNullPOI;
83 *allVars = *saveAll;
84 delete saveAll;
85 delete allVars;
86 */
87 
88  return nullNLL -altNLL;
89 }
virtual const char * GetTitle() const
Returns title of object.
Definition: TNamed.h:52
Double_t QuietNaN()
Definition: TMath.h:635
bool Bool_t
Definition: RtypesCore.h:59
Iterator abstract base class.
Definition: TIterator.h:32
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:2334
#define oocoutE(o, a)
Definition: RooMsgService.h:48
TIterator * createIterator(Bool_t dir=kIterForward) const
Double_t getVal(const RooArgSet *set=0) const
Definition: RooAbsReal.h:64
virtual const char * GetName() const
Returns name of object.
Definition: TNamed.h:51
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:58
RooAbsPdf is the abstract interface for all probability density functions The class provides hybrid a...
Definition: RooAbsPdf.h:41
#define NULL
Definition: Rtypes.h:82
const Bool_t kTRUE
Definition: Rtypes.h:91
Double_t ProfiledLikelihood(RooAbsData &data, RooArgSet &poi, RooAbsPdf &pdf)
returns -logL(poi, conditonal MLE of nuisance params) subtract off the global MLE or not depending on...