NASSP Masters 5003F - Computational Astronomy - 2010 Lecture 7 – chi squared and all that Testing for goodness-of-fit continued. Uncertainties in the fitted.

Slides:



Advertisements
Similar presentations
NASSP Masters 5003F - Computational Astronomy Lecture 5: source detection. Test the null hypothesis (NH). –The NH says: let’s suppose there is no.
Advertisements

Physics 270 – Experimental Physics. Let say we are given a functional relationship between several measured variables Q(x, y, …) What is the uncertainty.
MARLAP Measurement Uncertainty
The Multiple Regression Model Prepared by Vera Tabakova, East Carolina University.
Lecture 9 Inexact Theories. Syllabus Lecture 01Describing Inverse Problems Lecture 02Probability and Measurement Error, Part 1 Lecture 03Probability and.
EPIDEMIOLOGY AND BIOSTATISTICS DEPT Esimating Population Value with Hypothesis Testing.
G. Cowan Lectures on Statistical Data Analysis 1 Statistical Data Analysis: Lecture 10 1Probability, Bayes’ theorem, random variables, pdfs 2Functions.
Evaluation.
Intro to Statistics for the Behavioral Sciences PSYC 1900 Lecture 10: Hypothesis Tests for Two Means: Related & Independent Samples.
4. Multiple Regression Analysis: Estimation -Most econometric regressions are motivated by a question -ie: Do Canadian Heritage commercials have a positive.
The Simple Regression Model
G. Cowan Lectures on Statistical Data Analysis Lecture 12 page 1 Statistical Data Analysis: Lecture 12 1Probability, Bayes’ theorem 2Random variables and.
G. Cowan Lectures on Statistical Data Analysis 1 Statistical Data Analysis: Lecture 8 1Probability, Bayes’ theorem, random variables, pdfs 2Functions of.
Statistical Background
G. Cowan 2011 CERN Summer Student Lectures on Statistics / Lecture 41 Introduction to Statistics − Day 4 Lecture 1 Probability Random variables, probability.
Estimation 8.
Chi Square Distribution (c2) and Least Squares Fitting
G. Cowan Lectures on Statistical Data Analysis Lecture 10 page 1 Statistical Data Analysis: Lecture 10 1Probability, Bayes’ theorem 2Random variables and.
G. Cowan Lectures on Statistical Data Analysis 1 Statistical Data Analysis: Lecture 7 1Probability, Bayes’ theorem, random variables, pdfs 2Functions of.
INFERENTIAL STATISTICS – Samples are only estimates of the population – Sample statistics will be slightly off from the true values of its population’s.
Objectives of Multiple Regression
Psy B07 Chapter 1Slide 1 ANALYSIS OF VARIANCE. Psy B07 Chapter 1Slide 2 t-test refresher  In chapter 7 we talked about analyses that could be conducted.
Physics 114: Lecture 15 Probability Tests & Linear Fitting Dale E. Gary NJIT Physics Department.
Hypothesis Testing. Distribution of Estimator To see the impact of the sample on estimates, try different samples Plot histogram of answers –Is it “normal”
Regression Analysis (2)
CORRELATION & REGRESSION
880.P20 Winter 2006 Richard Kass Propagation of Errors Suppose we measure the branching fraction BR(Higgs  +  - ) using the number of produced Higgs.
NASSP Masters 5003F - Computational Astronomy Lecture 4 Random variables continued. Monte Carlo Uncertainty propagation Correct presentation of.
880.P20 Winter 2006 Richard Kass 1 Confidence Intervals and Upper Limits Confidence intervals (CI) are related to confidence limits (CL). To calculate.
Today’s lesson Confidence intervals for the expected value of a random variable. Determining the sample size needed to have a specified probability of.
G. Cowan 2009 CERN Summer Student Lectures on Statistics1 Introduction to Statistics − Day 4 Lecture 1 Probability Random variables, probability densities,
G. Cowan Lectures on Statistical Data Analysis Lecture 3 page 1 Lecture 3 1 Probability (90 min.) Definition, Bayes’ theorem, probability densities and.
Topics: Statistics & Experimental Design The Human Visual System Color Science Light Sources: Radiometry/Photometry Geometric Optics Tone-transfer Function.
R. Kass/W03P416/Lecture 7 1 Lecture 7 Some Advanced Topics using Propagation of Errors and Least Squares Fitting Error on the mean (review from Lecture.
Section 8.1 Estimating  When  is Known In this section, we develop techniques for estimating the population mean μ using sample data. We assume that.
NASSP Masters 5003F - Computational Astronomy Lecture 3 First, a bit more python. Then some noise statistics.
Copyright © 2013, 2010 and 2007 Pearson Education, Inc. Section Inference about Two Means: Independent Samples 11.3.
SUPA Advanced Data Analysis Course, Jan 6th – 7th 2009 Advanced Data Analysis for the Physical Sciences Dr Martin Hendry Dept of Physics and Astronomy.
GG 313 Geological Data Analysis Lecture 13 Solution of Simultaneous Equations October 4, 2005.
© Copyright McGraw-Hill Correlation and Regression CHAPTER 10.
VI. Regression Analysis A. Simple Linear Regression 1. Scatter Plots Regression analysis is best taught via an example. Pencil lead is a ceramic material.
Chapter 2 Statistical Background. 2.3 Random Variables and Probability Distributions A variable X is said to be a random variable (rv) if for every real.
Issues concerning the interpretation of statistical significance tests.
PROBABILITY AND STATISTICS FOR ENGINEERING Hossein Sameti Department of Computer Engineering Sharif University of Technology Mean, Variance, Moments and.
NASSP Masters 5003F - Computational Astronomy Lecture 6 Objective functions for model fitting: –Sum of squared residuals (=> the ‘method of least.
6. Simple Regression and OLS Estimation Chapter 6 will expand on concepts introduced in Chapter 5 to cover the following: 1) Estimating parameters using.
Review of Statistics.  Estimation of the Population Mean  Hypothesis Testing  Confidence Intervals  Comparing Means from Different Populations  Scatterplots.
Chapter 15 The Chi-Square Statistic: Tests for Goodness of Fit and Independence PowerPoint Lecture Slides Essentials of Statistics for the Behavioral.
1 Introduction to Statistics − Day 4 Glen Cowan Lecture 1 Probability Random variables, probability densities, etc. Lecture 2 Brief catalogue of probability.
G. Cowan Lectures on Statistical Data Analysis Lecture 8 page 1 Statistical Data Analysis: Lecture 8 1Probability, Bayes’ theorem 2Random variables and.
Lecture 8 Source detection NASSP Masters 5003S - Computational Astronomy
1 Introduction to Statistics − Day 3 Glen Cowan Lecture 1 Probability Random variables, probability densities, etc. Brief catalogue of probability densities.
Example x y We wish to check for a non zero correlation.
G. Cowan Lectures on Statistical Data Analysis Lecture 4 page 1 Lecture 4 1 Probability (90 min.) Definition, Bayes’ theorem, probability densities and.
G. Cowan Computing and Statistical Data Analysis / Stat 9 1 Computing and Statistical Data Analysis Stat 9: Parameter Estimation, Limits London Postgraduate.
G. Cowan Lectures on Statistical Data Analysis Lecture 9 page 1 Statistical Data Analysis: Lecture 9 1Probability, Bayes’ theorem 2Random variables and.
G. Cowan Lectures on Statistical Data Analysis Lecture 12 page 1 Statistical Data Analysis: Lecture 12 1Probability, Bayes’ theorem 2Random variables and.
G. Cowan Lectures on Statistical Data Analysis Lecture 10 page 1 Statistical Data Analysis: Lecture 10 1Probability, Bayes’ theorem 2Random variables and.
Richard Kass/F02P416 Lecture 6 1 Lecture 6 Chi Square Distribution (  2 ) and Least Squares Fitting Chi Square Distribution (  2 ) (See Taylor Ch 8,
Statistical Decision Making. Almost all problems in statistics can be formulated as a problem of making a decision. That is given some data observed from.
R. Kass/Sp07P416/Lecture 71 More on Least Squares Fit (LSQF) In Lec 5, we discussed how we can fit our data points to a linear function (straight line)
NASSP Masters 5003F - Computational Astronomy Lecture 4: mostly about model fitting. The model is our estimate of the parent function. Let’s express.
Estimating standard error using bootstrap
Correlation and Regression
Chi Square Distribution (c2) and Least Squares Fitting
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.
Lecture 4 1 Probability Definition, Bayes’ theorem, probability densities and their properties, catalogue of pdfs, Monte Carlo 2 Statistical tests general.
Computing and Statistical Data Analysis / Stat 7
Lecture 4 1 Probability Definition, Bayes’ theorem, probability densities and their properties, catalogue of pdfs, Monte Carlo 2 Statistical tests general.
Presentation transcript:

NASSP Masters 5003F - Computational Astronomy Lecture 7 – chi squared and all that Testing for goodness-of-fit continued. Uncertainties in the fitted parameters. Confidence intervals. The Null Hypothesis.

Hypothesis testing continued. Procedure: 1.“Suppose the model is a perfect fit.” 2.Calculate survival function for χ 2 of pure noise of N-M degrees of freedom.. 3.Draw vertical at point of measured χ 2. 4.Y value where this vertical intercepts the SF is the probability that a perfect model would have this χ 2 value by random fluctuation. NASSP Masters 5003F - Computational Astronomy Survival function

Questions answered so far: In fitting a model, we want: 1.The best fit values of the parameters; 2.Then we want to know if these values are good enough! Ie if the model is a good fit to the data. 3. If the model passes, we want uncertainties in the best-fit parameters. Number 1 is accomplished. √ Number 2 is accomplished. √ NASSP Masters 5003F - Computational Astronomy

Uncertainties in the best-fit parameters Usually what one gets is a covariance matrix (mentioned in lecture 4): This is a symmetric matrix: σ ij 2 =σ ji 2 for all i,j. For U= χ 2, E=2(H bestfit ) -1, where H bestfit is the Hessian, evaluated at the best-fit values of the θ i. For U=-L, E=F -1, where F is the “Fisher Information Matrix”: These definitions are equivalent! –For Gaussian data, identical. NASSP Masters 5003F - Computational Astronomy

The Hessian or curvature matrix The contours are ellipses in the limit as the minimum is approached. –Ellipsoidal hypercontours in the general case that M>2. Semiaxes aligned with the eigenvectors of H. Small semiaxis:  large curvature;  small uncertainty in that direction. NASSP Masters 5003F - Computational Astronomy Contours of U: Arrows show the eigenvectors.

1-parameter example 1)Gaussian data, U= χ 2. –For this simple model, we can find the best fit θ without numerical minimization: –Setting this to zero gives: NASSP Masters 5003F - Computational Astronomy

Sidebar – optimum weighted average A weighted average is: Since the y i are random variables, so is μ ^. Therefore it will have a PDF and an uncertainty σ μ. The smallest uncertainty is given for –Exactly what we have from the χ 2 fit. NASSP Masters 5003F - Computational Astronomy

Back to the1-parameter example. –Again, because this model is so simple, we can calculate σ θ by direct propagation of uncertainties. θ^ is a function of N uncorrelated random variables y i, so It is fairly easy to show that: NASSP Masters 5003F - Computational Astronomy

What does the standard approach give? Hessian is a 1-element matrix: Hence QED. NASSP Masters 5003F - Computational Astronomy

1-parameter example continued 2)Poisson data, U= -L. (No point in using -L for gaussian data, it’s then mathematically the same as chi squared.) –Again it is simple to calculate the position of the minimum directly: –Setting this to zero gives Ie, the average of the ys. NASSP Masters 5003F - Computational Astronomy

Uncertainties in the Poisson/L case. –With our present simple model it is very easy by propagation of uncertainties to show that –Following the formal procedure for comparison: –Inverting this gives the same result. NASSP Masters 5003F - Computational Astronomy

1-parameter example continued 3)Poisson data, U=“chi squared”. –There are two flavours of “chi squared” for Poisson data! –Note that the following is simply incorrect: NASSP Masters 5003F - Computational Astronomy

Don’t use Pearson’s for fitting. It is not hard to prove it is biased. –Eg, keeping our simple model, –Setting this to zero gives –In his paper, Mighell calculates the limiting value of θ^ Pearson as N->∞ and shows it is not θ. NASSP Masters 5003F - Computational Astronomy

The Mighell formula is unbiased. –For this statistic, –Setting this to zero gives –Some not-too-hairy algebra shows that the limiting value of θ^ Mighell as N->∞ is equal to θ. NASSP Masters 5003F - Computational Astronomy

Goodness-of-fit: 1.The Gaussian/ χ 2 case has been covered already. 2.The Poisson/L case is a problem, because no general PDF for L is known for this noise distribution. –If we insist on using this, have to estimate SF via a Monte Carlo. Messy, time-consuming. 3.For the Poisson/”chi squared” case, where we have 2 competing formulae, we should do: –Use Mighell to fit; –Use Mighell for uncertainties; –But use Pearson (with the best-fit values of θ i ) for goodness-of-fit hypothesis testing. Because it has the same PDF (thus also SF) as χ 2. NASSP Masters 5003F - Computational Astronomy

Confidence intervals There is a hidden assumption behind frequentist model fitting: namely that it is meaningful to talk about p(θ i ^). NASSP Masters 5003F - Computational Astronomy

We already have some hints about its shape… and a Monte Carlo seems to offer a way to map it as accurately as we want. Confidence intervals NASSP Masters 5003F - Computational Astronomy

Bayesians think this is nonsense. Such a MC is like pretending that θ ^ is the ‘true’ value, and then generating lots of hypothetical experimental data. But all we really know is the single set of data which we measure in the real experiment. –Plus possibly some ‘prior knowledge’. We don’t want p( θ ^), we want p( θ ). But we’ll continue with the frequentist way for the time being. NASSP Masters 5003F - Computational Astronomy

Confidence intervals We also assume that p(θ i ) is approximately Gaussian (which may be entirely unwarranted!!) –We interpret this to mean that there is a 68% chance that the interval contains the truth value θ. NASSP Masters 5003F - Computational Astronomy

Confidence intervals Note that this is not the only interval which contains 68% of the probability. We can move the interval up and down the θ axis as we please. The –σ to +σ version is just a convention. FYI erf() is called the error function. NASSP Masters 5003F - Computational Astronomy

Confidence intervals For more than 1 parameter the q% confidence interval is the (hyper)contour within which the probability of the truth value occuring =q. Again, by convention, symmetrical contours are used. NASSP Masters 5003F - Computational Astronomy

When m=s+b (which is not always appropriate) It is of interest to ask (probably before we attempt to fit the parameters of s!): –Is there any signal present at all? In frequentist statistics this is again done via hypothesis testing. The hypothesis now is called the null hypothesis (‘null’ from Latin for ‘nothing’): –“Suppose there is no signal at all.” –and test what follows from this. NASSP Masters 5003F - Computational Astronomy

Testing the Null Hypothesis - details 1)Gaussian data, U= χ 2 : –Construct the survival function (SF). Degrees of freedom? –Depends whether we fit the background or not. –Suppose we have M b and M s. –If background fitted, υ =N-M b. –If not (in this case need to know the background from other information), υ =N. –From the set of measurements y i, calculate –From the SF read off that value of probability which corresponds to U meas. That is the probability that background alone would generate >=U meas. NASSP Masters 5003F - Computational Astronomy Note ONLY include background!

Testing the Null Hypothesis – details cont. 2)Poisson data, U=“ χ 2 ”: –The PDF, therefore the SF, are not known for the Mighell statistic. –However the PDF and SF for the Pearson statistic are identical to χ 2. –  Use Pearson statistic for Poisson hypothesis testing. 3)Poisson data, U=-L: –PDF and SF not known. –But one can compare two models via the Cash statistic. (Cash W, Ap J 228, 939 (1979). NASSP Masters 5003F - Computational Astronomy

The Cash statistic This is only valid providing the null model can be obtained by some combination of signal parameters. –This implies that one of the signal parameters will be an amplitude (ie, a scalar multiplying the whole signal function). –It also ensures that NASSP Masters 5003F - Computational Astronomy hence

The Cash statistic Cash showed that the PDF of C was the same shape as that of χ 2, but with υ =M fitted. Note that this is rather different from the usual p( χ 2 ), for which υ is approx. equal to the number of data values N. NASSP Masters 5003F - Computational Astronomy

Incomplete gamma functions - advice Recall the survival function for χ 2 is –The incomplete gamma function can be calculated via scipy.special.gammainc. It is very small values of P that we are interested in however – ie where Г ( υ /2,U/2)/ Г ( υ /2) becomes close to 1. In this regime it is better to use the complementary (means, 1 minus) incomplete gamma function: –scipy.special.gammaincc <– note 2 cs. –But NOTE the definition carefully. NASSP Masters 5003F - Computational Astronomy

General problems with fitting: When some of the θs are ‘near degenerate’. –Solution: avoid this. When several different models fit equally well (or poorly). –Solution: F-test (sometimes). Supposedly restricted to the case in which 2 models differ by an additive component.

NASSP Masters 5003F - Computational Astronomy Degenerate θs Data Model: two close gaussians – 2 par- ameters: the amp of each gaussian. Valley in U is long and narrow. Many combinations of θ 1 and θ 2 give about as good fit; parameters strongly correlated.

Overview of the grand plan NASSP Masters 5003F - Computational Astronomy Frequentist Bayesian T B D… Bayesian T B D… χ2υ=N-Mχ2υ=N-M χ2υ=N-Mχ2υ=N-M Null H Poisson -LPoisson χ 2 Gaussian ( χ 2  -L) GOF Uncert Fit No formula (MC) No formula (MC) U Pearson υ =N-M U Pearson υ =N-M χ2υ=Nχ2υ=N χ2υ=Nχ2υ=N Cash υ =M Cash υ =M U Pearson υ =N U Pearson υ =N Minimize χ 2 Minimize -L Minimize U Mighell E=2H -1 E=-F -1 E=2H -1

Flowchart to disentangle the uses of χ 2 : NASSP Masters 5003F - Computational Astronomy Minimize χ 2 to get best-fit θ. Test the hypothesis that it is.Test the Null Hypothesis: Compare to theoretical χ 2 surviv- al function (num deg free = N). P<P cut ? Yes – there is a signal No – no signal. P<P cut ? No – model is good. Yes – model is bad. Compare to theoretical χ 2 surviv- al function (num deg free = N-M). Is there any signal at all? Is the model an accurate des- cription? Decide on a cutoff probability P cut. Calculate χ 2 for the best fit θ. Decide on a cutoff probability P cut. Calculate χ 2 for θ= bkg values.