Statistical Methods for Data Analysis Parameter estimates with RooFit Luca Lista INFN Napoli.

Slides:



Advertisements
Similar presentations
Statistical Methods for Data Analysis Random numbers with ROOT and RooFit Luca Lista INFN Napoli.
Advertisements

2nd level analysis – design matrix, contrasts and inference
A. The Basic Principle We consider the multivariate extension of multiple linear regression – modeling the relationship between m responses Y 1,…,Y m and.
Chapter 7 Introduction to Procedures. So far, all programs written in such way that all subtasks are integrated in one single large program. There is.
Wouter Verkerke (University of California Santa Barbara / NIKHEF)
Introduction to Function Minimization. Motivation example Data on height of a group of people, men and women Data on gender not recorded, not known.
Luca Lista, IEEE NSS-MIC 2003, Portland A Toolkit for Multi-variate Fitting Designed with Template Metaprogramming Luca Lista 1, Francesco Fabozzi 1,2.
Lecture 9 Today: Ch. 3: Multiple Regression Analysis Example with two independent variables Frisch-Waugh-Lovell theorem.
Computing the Posterior Probability The posterior probability distribution contains the complete information concerning the parameters, but need often.
Resampling techniques Why resampling? Jacknife Cross-validation Bootstrap Examples of application of bootstrap.
G. Cowan Lectures on Statistical Data Analysis 1 Statistical Data Analysis: Lecture 10 1Probability, Bayes’ theorem, random variables, pdfs 2Functions.
1 Chapter 3 Multiple Linear Regression Ray-Bing Chen Institute of Statistics National University of Kaohsiung.
Slide 1 Statistics for HEP Roger Barlow Manchester University Lecture 3: Estimation.
Part 4 Chapter 13 Linear Regression
Independent Component Analysis (ICA) and Factor Analysis (FA)
7. Least squares 7.1 Method of least squares K. Desch – Statistical methods of data analysis SS10 Another important method to estimate parameters Connection.
Cluster Validation.
Chi Square Distribution (c2) and Least Squares Fitting
Analysis of Individual Variables Descriptive – –Measures of Central Tendency Mean – Average score of distribution (1 st moment) Median – Middle score (50.
G. Cowan Lectures on Statistical Data Analysis Lecture 10 page 1 Statistical Data Analysis: Lecture 10 1Probability, Bayes’ theorem 2Random variables and.
Rao-Cramer-Frechet (RCF) bound of minimum variance (w/o proof) Variance of an estimator of single parameter is limited as: is called “efficient” when the.
Lecture II-2: Probability Review
Modern Navigation Thomas Herring
Normalised Least Mean-Square Adaptive Filtering
Physics 114: Lecture 15 Probability Tests & Linear Fitting Dale E. Gary NJIT Physics Department.
880.P20 Winter 2006 Richard Kass 1 Confidence Intervals and Upper Limits Confidence intervals (CI) are related to confidence limits (CL). To calculate.
880.P20 Winter 2006 Richard Kass 1 Maximum Likelihood Method (MLM) Does this procedure make sense? The MLM answers this question and provides a method.
RooFit/RooStats Tutorial CAT Meeting, June 2009
G. Cowan Lectures on Statistical Data Analysis Lecture 3 page 1 Lecture 3 1 Probability (90 min.) Definition, Bayes’ theorem, probability densities and.
Monte Carlo Simulation CWR 6536 Stochastic Subsurface Hydrology.
RooFit A tool kit for data modeling in ROOT
Multilevel Linear Models Field, Chapter 19. Why use multilevel models? Meeting the assumptions of the linear model – Homogeneity of regression coefficients.
RooFit – tools for ML fits Authors: Wouter Verkerke and David Kirkby.
1 Methods of Experimental Particle Physics Alexei Safonov Lecture #23.
CS 782 – Machine Learning Lecture 4 Linear Models for Classification  Probabilistic generative models  Probabilistic discriminative models.
Modern Navigation Thomas Herring MW 11:00-12:30 Room
Statistical Methods for Data Analysis Introduction to the course Luca Lista INFN Napoli.
Parallelization of likelihood functions for data analysis Alfio Lazzaro CERN openlab Forum on Concurrent Programming Models and Frameworks.
Review of fundamental 1 Data mining in 1D: curve fitting by LLS Approximation-generalization tradeoff First homework assignment.
NON-LINEAR REGRESSION Introduction Section 0 Lecture 1 Slide 1 Lecture 6 Slide 1 INTRODUCTION TO Modern Physics PHYX 2710 Fall 2004 Intermediate 3870 Fall.
Over-fitting and Regularization Chapter 4 textbook Lectures 11 and 12 on amlbook.com.
Introduction to RooFit W. Verkerke (NIKHEF) 1.Introduction and overview 2.Creation and basic use of models 3.Composing models 4.Working with (profile)
1 Introduction to Statistics − Day 4 Glen Cowan Lecture 1 Probability Random variables, probability densities, etc. Lecture 2 Brief catalogue of probability.
Tutorial I: Missing Value Analysis
G. Cowan Computing and Statistical Data Analysis / Stat 9 1 Computing and Statistical Data Analysis Stat 9: Parameter Estimation, Limits London Postgraduate.
Eco 6380 Predictive Analytics For Economists Spring 2016 Professor Tom Fomby Department of Economics SMU.
The KOSMOSHOWS What is it ? The statistic inside What it can do ? Future development Demonstration A. Tilquin (CPPM)
14/01/2008MICE CM23 - Beam Line Parallel Session1 Simulations: tools and status Marco Apollonio, Imperial College - London.
G. Cowan Lectures on Statistical Data Analysis Lecture 10 page 1 Statistical Data Analysis: Lecture 10 1Probability, Bayes’ theorem 2Random variables and.
Conditional Observables Joe Tuggle BaBar ROOT/RooFit Workshop December 2007.
Getting started – ROOT setup Start a ROOT 5.34/17 or higher session Load the roofit libraries If you see a message that RooFit v3.60 is loaded you are.
RooFit Tutorial – Topical Lectures June 2007
Hands-on exercises *. Getting started – ROOT 5.25/02 setup Start a ROOT 5.25/02 session –On your local laptop installation, or –On lxplus (SLC4) or lx64slc5.
Introduction to RooFit
Wouter Verkerke, UCSB Parameter estimation  2 and likelihood — Introduction to estimation — Properties of  2, ML estimators — Measuring and interpreting.
Wouter Verkerke, UCSB Data Analysis Exercises - Day 2 Wouter Verkerke (NIKHEF)
Part 3: Estimation of Parameters. Estimation of Parameters Most of the time, we have random samples but not the densities given. If the parametric form.
Analysis Tools interface - configuration Wouter Verkerke Wouter Verkerke, NIKHEF 1.
Clustering (2) Center-based algorithms Fuzzy k-means Density-based algorithms ( DBSCAN as an example ) Evaluation of clustering results Figures and equations.
(Day 3).
ROOT Tutorial Simulation and fitting in ROOT
CMS RooStats Higgs Combination Package
Linear regression Fitting a straight line to observations.
Where did we stop? The Bayes decision rule guarantees an optimal classification… … But it requires the knowledge of P(ci|x) (or p(x|ci) and P(ci)) We.
Lecture 3 1 Probability Definition, Bayes’ theorem, probability densities and their properties, catalogue of pdfs, Monte Carlo 2 Statistical tests general.
Statistical Methods for Data Analysis Parameter estimates with RooFit
Computing and Statistical Data Analysis / Stat 7
Statistical Methods for Data Analysis Modeling PDF’s with RooFit
Statistical Methods for Data Analysis Random numbers with ROOT and RooFit Luca Lista INFN Napoli.
Presentation transcript:

Statistical Methods for Data Analysis Parameter estimates with RooFit Luca Lista INFN Napoli

Luca ListaStatistical Methods for Data Analysis2 Fits with RooFit Get data sample (or generate it, for Toy Monte Carlo) Specify data model (PDF’s) Fit specified model to data set with preferred technique (ML, Extended ML, …)

Luca ListaStatistical Methods for Data Analysis3 Example RooRealVar x("x","x",-10,10) ; RooRealVar mean("mean","mean of gaussian",0,-10,10); RooRealVar sigma("sigma","width of gaussian",3); RooGaussian gauss("gauss","gaussian PDF",x,mean,sigma); RooDataSet* data = gauss.generate(x,10000); // ML fit is the default gauss.fitTo(*data); mean.Print(); // RooRealVar::mean = // / sigma.Print(); // RooRealVar::sigma = // / RooPlot* xframe = x.frame(); data->plotOn(xframe); gauss.plotOn(xframe); xframe->Draw(); PDF automatically normalized to dataset Further drawing options: pdf.paramOn(xframe,data); data.statOn(xframe);

Luca ListaStatistical Methods for Data Analysis4 Extended ML fits Specify extended ML fit adding one extra parameter: pdf.fitTo(*data, RooFit::Extended(kTRUE));

Luca ListaStatistical Methods for Data Analysis5 Import external data sets Read a ROOT tree: RooRealVar x(“x”,”x”,-10,10); RooRealVar c(“c”,”c”,0,30); RooDataSet data(“data”,”data”,inputTree, RooArgSet(x,c)); –Automatic removal of entries out of variable range Read an ASCII file: RooDataSet* data = RooDataSet::read(“ascii.file”, RooArgList(x,c)); –Une line per entry; variable order given by argument list

Luca ListaStatistical Methods for Data Analysis6 Histogram fits Use a binned data set: –RooDataHist instead of RooDataSet Fit with binned model xyz BinnedUnbinned RooDataSet RooDataHist RooAbsData

Luca ListaStatistical Methods for Data Analysis7 Import external histograms From ROOT TH1/TH2/TH3: RooDataHist bdata1(“bdata”,”bdata”,RooArgList(x),histo1d); RooDataHist bdata2(“bdata”,”bdata”,RooArgList(x,y),histo2d); RooDataHist bdata3(“bdata”,”bdata”,RooArgList(x,y,z),histo3d); Binning an unbinned data set: RooDataHist* binnedData = data->binnedClone(); Specifying binning: x.setBins(50); RooDataHist binnedData(“binnedData”, “data”, RooArgList(x), *data);

Luca ListaStatistical Methods for Data Analysis8 Discrete variables Indices automatically assigned if omitted Define categories E.g.: b-tag: RooCategory b0flav("b0flav", "B0 flavour"); b0flav.defineType("B0", -1); b0flav.defineType("B0bar", 1); Several tools defined to combine categories ( RooSuperCategory ) and analyze data according to categories –See Root user manual for more details… Switch between PDF’s based on a category can be implemented for simultaneous fits of multiple categories: RooSimultaneous simPdf("simPdf","simPdf", categoryType); simPdf.addPdf(pdfA,"A"); simPdf.addPdf(pdfB,"B");

Luca ListaStatistical Methods for Data Analysis9 Explicit Minuit minimization Build negative log-Likelihood finction (NLL) // Construct function object representing -log(L) RooNLLVar nll(“nll”, ”nll”, pdf, data); // Minimize nll w.r.t its parameters RooMinuit m(nll); m.migrad(); m.hesse(); Extra arguments: specify extended likelihood: RooNLLVar nll(“nll”,”nll”,pdf,data,Extended()); Chi-squared functions (only accepts RooDataHist ): RooNLLVar chi2(“chi2”,”chi2”,pdf,data);

Luca ListaStatistical Methods for Data Analysis10 Drive converging process // Start Minuit session on above nll RooMinuit m(nll); // MIGRAD likelihood minimization m.migrad(); // Run HESSE error analysis m.hesse(); // Set sx to 3, keep fixed in fit sx.setVal(3); sx.setConstant(kTRUE); // MIGRAD likelihood minimization m.migrad(); // Run MINOS error analysis m.minos(); // Draw 1,2,3 ‘sigma’ contours in sx,sy m.contour(sx, sy);

Luca ListaStatistical Methods for Data Analysis11 Minuit function MIGRAD Purpose: find minimum ********** ** 13 **MIGRAD ********** (some output omitted) MIGRAD MINIMIZATION HAS CONVERGED. MIGRAD WILL VERIFY CONVERGENCE AND ERROR MATRIX. COVARIANCE MATRIX CALCULATED SUCCESSFULLY FCN= FROM MIGRAD STATUS=CONVERGED 31 CALLS 32 TOTAL EDM= e-06 STRATEGY= 1 ERROR MATRIX ACCURATE EXT PARAMETER STEP FIRST NO. NAME VALUE ERROR SIZE DERIVATIVE 1 mean e e e e-02 2 sigma e e e e-02 ERR DEF= 0.5 EXTERNAL ERROR MATRIX. NDIM= 25 NPAR= 2 ERR DEF= e e e e-02 PARAMETER CORRELATION COEFFICIENTS NO. GLOBAL Parameter values and approximate errors reported by MINUIT Error definition (in this case 0.5 for a likelihood fit) Progress information, watch for errors here

Luca ListaStatistical Methods for Data Analysis12 Minuit function MIGRAD Purpose: find minimum ********** ** 13 **MIGRAD ********** (some output omitted) MIGRAD MINIMIZATION HAS CONVERGED. MIGRAD WILL VERIFY CONVERGENCE AND ERROR MATRIX. COVARIANCE MATRIX CALCULATED SUCCESSFULLY FCN= FROM MIGRAD STATUS=CONVERGED 31 CALLS 32 TOTAL EDM= e-06 STRATEGY= 1 ERROR MATRIX ACCURATE EXT PARAMETER STEP FIRST NO. NAME VALUE ERROR SIZE DERIVATIVE 1 mean e e e e-02 2 sigma e e e e-02 ERR DEF= 0.5 EXTERNAL ERROR MATRIX. NDIM= 25 NPAR= 2 ERR DEF= e e e e-02 PARAMETER CORRELATION COEFFICIENTS NO. GLOBAL Approximate Error matrix And covariance matrix Value of  2 or likelihood at minimum (NB:  2 values are not divided by N d.o.f )

Luca ListaStatistical Methods for Data Analysis13 Minuit function MIGRAD Purpose: find minimum ********** ** 13 **MIGRAD ********** (some output omitted) MIGRAD MINIMIZATION HAS CONVERGED. MIGRAD WILL VERIFY CONVERGENCE AND ERROR MATRIX. COVARIANCE MATRIX CALCULATED SUCCESSFULLY FCN= FROM MIGRAD STATUS=CONVERGED 31 CALLS 32 TOTAL EDM= e-06 STRATEGY= 1 ERROR MATRIX ACCURATE EXT PARAMETER STEP FIRST NO. NAME VALUE ERROR SIZE DERIVATIVE 1 mean e e e e-02 2 sigma e e e e-02 ERR DEF= 0.5 EXTERNAL ERROR MATRIX. NDIM= 25 NPAR= 2 ERR DEF= e e e e-02 PARAMETER CORRELATION COEFFICIENTS NO. GLOBAL Status: Should be ‘converged’ but can be ‘failed’ Estimated Distance to Minimum should be small O(10 -6 ) Error Matrix Quality should be ‘accurate’, but can be ‘approximate’ in case of trouble

Luca ListaStatistical Methods for Data Analysis14 Minuit function HESSE Purpose: calculate error matrix from ********** ** 18 **HESSE 1000 ********** COVARIANCE MATRIX CALCULATED SUCCESSFULLY FCN= FROM HESSE STATUS=OK 10 CALLS 42 TOTAL EDM= e-06 STRATEGY= 1 ERROR MATRIX ACCURATE EXT PARAMETER INTERNAL INTERNAL NO. NAME VALUE ERROR STEP SIZE VALUE 1 mean e e e e-03 2 sigma e e e e-01 ERR DEF= 0.5 EXTERNAL ERROR MATRIX. NDIM= 25 NPAR= 2 ERR DEF= e e e e-02 PARAMETER CORRELATION COEFFICIENTS NO. GLOBAL Symmetric errors calculated from 2 nd derivative of –ln(L) or  2

Luca ListaStatistical Methods for Data Analysis15 Minuit function HESSE Purpose: calculate error matrix from ********** ** 18 **HESSE 1000 ********** COVARIANCE MATRIX CALCULATED SUCCESSFULLY FCN= FROM HESSE STATUS=OK 10 CALLS 42 TOTAL EDM= e-06 STRATEGY= 1 ERROR MATRIX ACCURATE EXT PARAMETER INTERNAL INTERNAL NO. NAME VALUE ERROR STEP SIZE VALUE 1 mean e e e e-03 2 sigma e e e e-01 ERR DEF= 0.5 EXTERNAL ERROR MATRIX. NDIM= 25 NPAR= 2 ERR DEF= e e e e-02 PARAMETER CORRELATION COEFFICIENTS NO. GLOBAL Error matrix (Covariance Matrix) calculated from

Luca ListaStatistical Methods for Data Analysis16 Minuit function HESSE Purpose: calculate error matrix from ********** ** 18 **HESSE 1000 ********** COVARIANCE MATRIX CALCULATED SUCCESSFULLY FCN= FROM HESSE STATUS=OK 10 CALLS 42 TOTAL EDM= e-06 STRATEGY= 1 ERROR MATRIX ACCURATE EXT PARAMETER INTERNAL INTERNAL NO. NAME VALUE ERROR STEP SIZE VALUE 1 mean e e e e-03 2 sigma e e e e-01 ERR DEF= 0.5 EXTERNAL ERROR MATRIX. NDIM= 25 NPAR= 2 ERR DEF= e e e e-02 PARAMETER CORRELATION COEFFICIENTS NO. GLOBAL Correlation matrix  ij calculated from

Luca ListaStatistical Methods for Data Analysis17 Minuit function HESSE Purpose: calculate error matrix from ********** ** 18 **HESSE 1000 ********** COVARIANCE MATRIX CALCULATED SUCCESSFULLY FCN= FROM HESSE STATUS=OK 10 CALLS 42 TOTAL EDM= e-06 STRATEGY= 1 ERROR MATRIX ACCURATE EXT PARAMETER INTERNAL INTERNAL NO. NAME VALUE ERROR STEP SIZE VALUE 1 mean e e e e-03 2 sigma e e e e-01 ERR DEF= 0.5 EXTERNAL ERROR MATRIX. NDIM= 25 NPAR= 2 ERR DEF= e e e e-02 PARAMETER CORRELATION COEFFICIENTS NO. GLOBAL Global correlation vector: correlation of each parameter with all other parameters

Luca ListaStatistical Methods for Data Analysis18 Wouter Verkerke, NIKHEF Minuit function MINOS Error analysis through  nll contour finding ********** ** 23 **MINOS 1000 ********** FCN= FROM MINOS STATUS=SUCCESSFUL 52 CALLS 94 TOTAL EDM= e-06 STRATEGY= 1 ERROR MATRIX ACCURATE EXT PARAMETER PARABOLIC MINOS ERRORS NO. NAME VALUE ERROR NEGATIVE POSITIVE 1 mean e e e e-01 2 sigma e e e e-01 ERR DEF= 0.5 Symmetric error (repeated result from HESSE) MINOS error Can be asymmetric (in this example the ‘sigma’ error is slightly asymmetric)

Luca ListaStatistical Methods for Data Analysis19 Mitigating fit stability problems Strategy I – More orthogonal choice of parameters –Example: fitting sum of 2 Gaussians of similar width PARAMETER CORRELATION COEFFICIENTS NO. GLOBAL [ f] [ m] [s1] [s2] [ f] [ m] [s1] [s2] HESSE correlation matrix Widths s 1,s 2 strongly correlated fraction f

Luca ListaStatistical Methods for Data Analysis20 Mitigating fit stability problems –Different parameterization: –Correlation of width s2 and fraction f reduced from 0.92 to 0.68 –Choice of parameterization matters! Strategy II – Fix all but one of the correlated parameters –If floating parameters are highly correlated, some of them may be redundant and not contribute to additional degrees of freedom in your model PARAMETER CORRELATION COEFFICIENTS NO. GLOBAL [f] [m] [s1] [s2] [ f] [ m] [s1] [s2]

Luca ListaStatistical Methods for Data Analysis21 Fit stability with polynomials Warning: Regular parameterization of polynomials a 0 +a 1 x+a 2 x 2 +a 3 x 3 nearly always results in strong correlations between the coefficients a i. –Fit stability problems, inability to find right solution common at higher orders Solution: Use existing parameterizations of polynomials that have (mostly) uncorrelated variables –Example: Chebychev polynomials

Luca ListaStatistical Methods for Data Analysis22 Browsing fit results As fits grow in complexity (e.g. 45 floating parameters), number of output variables increases –Need better way to navigate output that MINUIT screen dump RooFitResult holds complete snapshot of fit results –Constant parameters –Initial and final values of floating parameters –Global correlations & full correlation matrix –Returned from RooAbsPdf::fitTo() when “ r ” option is supplied Compact & verbose printing mode fitres->Print() ; RooFitResult: min. NLL value: 1.6e+04, est. distance to min: 1.2e-05 Floating Parameter FinalValue +/- Error argpar e-01 +/- 7.11e-02 g2frac e-01 +/- 5.10e-03 mean e+00 +/- 7.11e-03 mean e+00 +/- 6.27e-03 sigma e-01 +/- 4.00e-03 Alphabetical parameter listing Compact Mode Constant parameters omitted in compact mode

Luca ListaStatistical Methods for Data Analysis23 Browsing fit results fitres->Print(“v”) ; RooFitResult: min. NLL value: 1.6e+04, est. distance to min: 1.2e-05 Constant Parameter Value cutoff e+00 g1frac e-01 Floating Parameter InitialValue FinalValue +/- Error GblCorr argpar e e-01 +/- 7.11e g2frac e e-01 +/- 5.10e mean e e+00 +/- 7.11e mean e e+00 +/- 6.27e sigma e e-01 +/- 4.00e Verbose printing mode Constant parameters listed separately Initial,final value and global corr. listed side-by-side Correlation matrix accessed separately

Luca ListaStatistical Methods for Data Analysis24 Browsing fit results Easy navigation of correlation matrix –Select single element or complete row by parameter name RooFitResult persistable with ROOT I/O –Save your batch fit results in a ROOT file and navigate your results just as easy afterwards fitres->correlation("argpar","sigma") (const Double_t)( e-02) fitres->correlation("mean1")->Print("v") RooArgList::C[mean1,*]: (Owning contents) 1) RooRealVar::C[mean1,argpar] : C 2) RooRealVar::C[mean1,g2frac] : C 3) RooRealVar::C[mean1,mean1] : C 4) RooRealVar::C[mean1,mean2] : C 5) RooRealVar::C[mean1,sigma] : C

Luca ListaStatistical Methods for Data Analysis25 References RooFit online tutorial – index.html Credits: –RooFit slides and examples extracted, adapted and/or inspired by original presentations by Wouter Verkerke