Download presentation
Presentation is loading. Please wait.
1
A Bayesian 2 test for goodness of fit 10/23/09 Multilevel RIT
2
Overview Talk about basic 2 test. Review with some examples. Talk about the paper with examples.
3
Basic 2 test The 2 test is used to test if a sample of data came from a population with a specific distribution. An attractive feature of the 2 goodness-of-fit test is that it can be applied to any univariate distribution for which you can calculate the CDF. y1y1 y3y3 y2y2 y4y4 ynyn y5y5
4
The value of the 2 depends on how you partition the support. The sample size needs to be a sufficient size for the approximation to be valid.
5
n is the sample size K is the number of partitions or bins specified over the sample space is the probability assigned by the null model to this interval is the number of observations within the k th bin The 2 statistic, in the case of the simple hypothesis, is: 2 with k-1 degrees of freedom, as n goes to infinity
6
4 examples We generate 4 sets of RVs: 1)1000 normal 2)1000 double exponential 3)1000 t distribution with 3 degrees of freedom 4)1000 lognormal We use the chi square test to see if each of the data sets fits a normal distribution. H o : the data come from a normal distribution
11
are the estimates of the bin probabilities based on either the MLE for the grouped data or on the minimum 2 method. The 2 statistic, in the case of composite hypothesis, is: 2 with k-s-1 degrees of freedom, as n goes to infinity Where s is the dimension of the underlying parameter vector
13
= 5.73
15
The MLE for the grouped data means maximizing this function with respect to , while minimum 2 estimation involves finding the value of that minimizes a function related to R g.
16
A Bayesian 2 statistic. Let y 1, ……., y n (= y) denote the scalar-valued, continuous, identically distributed, conditionally independent observations drawn from the pdf f(y| ). is indexed by an s-dimensional parameter vector R s We want to generate a sampled value from the posterior p( | y). To do that, we can apply the inverse of the probability integral transform method.
17
...... Set up these integrals, and then solve for’s Generally, in practice, the are calculated using the Gibbs sampler.
18
denotes a value of sampled from the posterior distribution based on y The MLE Notation considerations
21
This is interesting because if you contrast R B with R ^ we see that R ^ has k – s – 1 degrees of freedom while R B has K – 1 degrees of freedom. R B is independent of the number of parameters.
24
The process is:
25
1)Have data y 1, ……., y n
26
The process is: 1)Have data y 1, ……., y n 2)Generate from data y 1, ……., y n (by integral transform or Gibbs sampler).
27
The process is: 1)Have data y 1, ……., y n 2)Generate from data y 1, ……., y n (by integral transform or Gibbs sampler). 3)Create ’s
28
The process is: 1)Have data y 1, ……., y n 2)Generate from data y 1, ……., y n (by integral transform or Gibbs sampler). 3)Create ’s 4)Calculate R B
29
The process is: 1)Have data y 1, ……., y n 2)Generate from data y 1, ……., y n (by integral transform or Gibbs sampler). 3)Create ’s 4)Calculate R B 5)Repeat steps 2 to 4 to get many R B ’s
30
The process is: 1)Have data y 1, ……., y n 2)Generate from data y 1, ……., y n (by integral transform or Gibbs sampler). 3)Create ’s 4)Calculate R B 5)Repeat steps 2 to 4 to get many R B ’s 6)By LLN,
31
We can then report the proportion of R B values that exceeded the 95 th percentile of the reference 2 with k-1 degrees of freedom. If the proportion is higher than what is expected then, the excess can be attributed to dependence between R B values or lack of fit. If the R B values did represent independent draws from the 2, then the proportion of values falling in the critical region of the test would exactly equal the size of the test.
32
The statistic A is used in the event that formal significance tests must be performed to assess model adequacy.
33
A is related to a commonly used quantity in signal detection theory and represents the area under the ROC curve [e.g., Hanley and McNeil (1982)] for comparing the joint posterior distribution of R B values to a χ 2 K−1 random variable.
34
The statistic A is used in the event that formal significance tests must be performed to assess model adequacy. A is related to a commonly used quantity in signal detection theory and represents the area under the ROC curve [e.g., Hanley and McNeil (1982)] for comparing the joint posterior distribution of R b values to a χ 2 K−1 random variable. The expected value of A, if taken with respect to the joint sampling distribution of y and the posterior distribution of θ given y, would be 0.5. Large deviations in the expected value of A from 0.5, when the expectation is taken with respect to the posterior distribution of θ for a fixed value of y, indicate model lack of fit.
35
Some things to keep in mind Unfortunately, approximating the sampling distribution of A can be a lot of trouble.
36
Some things to keep in mind Unfortunately, approximating the sampling distribution of A can be a lot of trouble. How do you decide how many bins to make and how to assign probabilities to these bins? Consistency of tests against general alternatives requires that k as n .
37
Some things to keep in mind Unfortunately, approximating the sampling distribution of A can be a lot of trouble. How do you decide how many bins to make and how to assign probabilities to these bins? Consistency of tests against general alternatives requires that k as n . Having too many bins can result in loss of power.
38
Some things to keep in mind Unfortunately, approximating the sampling distribution of A can be a lot of trouble. How do you decide how many bins to make and how to assign probabilities to these bins? Consistency of tests against general alternatives requires that k as n . Having too many bins can result in loss of power. Mann and Wald suggested to use 3.8(n-1) 0.4 equiprobable cells.
39
Example Let y = (y 1, ….., y n ) denote a random sample from a normal distribution with unknown and 2 Let us assume a joint prior for ( , 2 ) to be proportional to 1/ 2.
40
For a given data vector y and posterior sample (μ˜,σ˜ ), bin counts m k (μ˜,σ˜ ) are determined by counting the number of observations y i that fall into the interval ( ˜σ −1 (a k−1 ) + ˜μ, ˜σ −1 (a k ) + ˜μ), where −1 (·) denotes the standard normal quantile function. Based on these counts, R B (μ˜,σ˜ ) is calculated according to
46
Power Calculation The next figure displays the proportion of times in 10,000 draws of t samples that the test statistic A was larger than the 0.95 quantile for the sampled values of A pp. (A pp comes from posterior predictive observations of y).
48
Essentially, the only requirement for their use is that observations be conditionally independent. Main advantages: Goodness-of-fit tests based on the statistic R B provide a simple way of assessing the adequacy of model fit in many Bayesian models. Values of RB generated from a posterior distribution may prove useful both as a convergence diagnostic for MCMC algorithms and for detecting errors written in computer code to implement these algorithms. From a computational perspective, such statistics can be calculated in a straightforward way using output from existing MCMC algorithms.
50
There is a later paper written in 2007 that uses the same methodology, but applied to censored data.
51
Bayesian Chi-square TTE fit Using Bayesian chi-square tests to assess goodness of fit for time-to-event data This software computes the Bayesian chi square test of Valen Johnson [1] for right-censored time-to-event data. It tests the goodness of fit of the best fit to the data from the following distribution families: exponential gamma inverse gamma Weibull log normal log logistic log odds rate
52
Bayesian chi square test results Input options Filesample1.txt Number of bins16 (default) Discrete timeyes RNG seedfrom system time Notation0 for alive and 1 for dead Bayesian chi square and related statistics Distributionmean X2var X295th percentilep-value boundBICDICDIC # parameters Gamma11.29196.2012615.718819009.48997.490.973041 LogOddsRate11.997212.751818.87519019.839002.041.49818 LogLogistic20.995932.491631.750.1365069027.919016.121.03674 LogNormal25.914335.212837.09380.02404349042.189030.310.996002 Weibull29.37649.0137134.65630.053953990359023.080.97273 InverseGamma113.822145.183133.813092109198.141.00249 Exponential379.83575.5927397.43809469.939463.990.493292
53
mean X2 is the Bayesian chi square (BCS) value, the mean of the chi-square values from 1000 samples from the posterior. var X2 is the corresponding sample variances of the chi square values. 95 percentile is this order statistic of the chi-square samples. p-value bound is the upper bound on the p-value corresponding to the order statistic using Rychlik's inequality. BIC is the 'Bayesian' information criteria. DIC is the deviance information criteria. DIC # parameters is the number of effective parameters as measured by the DIC.
54
Distributionparam1param2param3 Gamma2.9751917.4145 LogOddsRate2.3174349.91210.481747 LogLogistic2.73695-10.4045 LogNormal3.778470.644426 Weibull1.8812658.0321 InverseGamma2.1807275.8742 Exponential54.1108 This output produced by BCSTTE, Bayesian Chi-Square TTE fit, available at http://biostatistics.mdanderson.org/SoftwareDownload/http://biostatistics.mdanderson.org/SoftwareDownload/. Distribution parameters
55
Bayesian chi square test results Input options Filesample2.txt Number of bins5 Discrete timeno RNG seed12345 Notation0 for uncensored and 1 for censored Bayesian chi square and related statistics Distributionmean X2var X295th percentilep-value boundBICDICDIC # parameters Gamma4.043677.750878.6666711075.51067.840.952195 LogLogistic4.4459211.234613.08330.2132491081.611074.010.987576 LogOddsRate4.587676.405558.9166711079.921068.041.19743 LogNormal4.8371710.683312.33330.2948481085.411077.740.950352 Weibull5.28456.158829.750.8795331075.421067.830.990863 InverseGamma22.447286.243837.58332.6779e-0061115.821108.230.99144 Exponential31.99896.8495537.66672.57403e-0061107.981104.220.508292
56
Distribution parameters Distributionparam1param2param3 Gamma2.3485820.0585 LogLogistic2.3886-8.79073 LogOddsRate1.7934549.73350.134152 LogNormal3.633480.753531 Weibull1.6866352.402 InverseGamma1.5529342.0575 Exponential48.4923
57
Here is the math. That’s most of it…
72
Thanks for coming to the talk. Cao, Jing, Moosman, Ann, Johnson, V.E. (2008). ‘A Bayesian Chi-Squared Goodness-of-Fit Test for Censored Data Models.’ UT MD Anderson Cancer Center Department of Biostatistics Working Paper Series
Similar presentations
© 2025 SlidePlayer.com. Inc.
All rights reserved.