ROOT  6.07/01
Reference Guide
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Groups Pages
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 
14 
15 #include "RooArgSet.h"
16 #include "RooAbsData.h"
17 #include "TMath.h"
18 #include "RooMsgService.h"
19 #include "RooGlobalFunc.h"
20 
21 
23 
25 
26  ////////////////////////////////////////////////////////////////////////////
27  /// returns -logL(poi, conditonal MLE of nuisance params)
28  /// subtract off the global MLE or not depending on the option
29  /// It is the numerator or the denominator of the ratio (depending on the pdf)
30  ///L.M. : not sure why this method is needed now
31 
33  int type = (fSubtractMLE) ? 0 : 2;
34 
35  // null
36  if ( &pdf == fNullProfile.GetPdf() )
37  return fNullProfile.EvaluateProfileLikelihood(type, data, poi);
38  else if (&pdf == fAltProfile.GetPdf() )
39  return fAltProfile.EvaluateProfileLikelihood(type, data, poi);
40 
41  oocoutE((TObject*)NULL,InputArguments) << "RatioOfProfiledLikelihoods::ProfileLikelihood - invalid pdf used for computing the profiled likelihood - return NaN"
42  << std::endl;
43 
44  return TMath::QuietNaN();
45 
46 }
47 
48 ////////////////////////////////////////////////////////////////////////////////
49 /// evaluate the ratio of profile likelihood
50 
52 
53  int type = (fSubtractMLE) ? 0 : 2;
54 
55  // null
56  double nullNLL = fNullProfile.EvaluateProfileLikelihood(type, data, nullParamsOfInterest);
57  const RooArgSet *nullset = fNullProfile.GetDetailedOutput();
58 
59  // alt
60  double altNLL = fAltProfile.EvaluateProfileLikelihood(type, data, *fAltPOI);
61  const RooArgSet *altset = fAltProfile.GetDetailedOutput();
62 
63  if (fDetailedOutput != NULL) {
64  delete fDetailedOutput;
65  fDetailedOutput = NULL;
66  }
67  if (fDetailedOutputEnabled) {
68  fDetailedOutput = new RooArgSet();
69  RooRealVar* var(0);
70  for(TIterator *it = nullset->createIterator();(var = dynamic_cast<RooRealVar*>(it->Next()));) {
71  RooRealVar* cloneVar = new RooRealVar(TString::Format("nullprof_%s", var->GetName()),
72  TString::Format("%s for null", var->GetTitle()), var->getVal());
73  fDetailedOutput->addOwned(*cloneVar);
74  }
75  for(TIterator *it = altset->createIterator();(var = dynamic_cast<RooRealVar*>(it->Next()));) {
76  RooRealVar* cloneVar = new RooRealVar(TString::Format("altprof_%s", var->GetName()),
77  TString::Format("%s for null", var->GetTitle()), var->getVal());
78  fDetailedOutput->addOwned(*cloneVar);
79  }
80  }
81 
82 /*
83 // set variables back to where they were
84 nullParamsOfInterest = *saveNullPOI;
85 *allVars = *saveAll;
86 delete saveAll;
87 delete allVars;
88 */
89 
90  return nullNLL -altNLL;
91 }
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:2321
#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
RooRealVar represents a fundamental (non-derived) real valued object.
Definition: RooRealVar.h:37
virtual const char * GetName() const
Returns name of object.
Definition: TNamed.h:51
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: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...