MLINMIX_ERR
Name
MLINMIX_ERR
Purpose
Bayesian approach to multiple linear regression with errors in X and Y
Explanation
PERFORM LINEAR REGRESSION OF Y ON X WHEN THERE ARE MEASUREMENT
ERRORS IN BOTH VARIABLES. THE REGRESSION ASSUMES :
ETA = ALPHA + BETA ## XI + EPSILON
X = XI + XERR
Y = ETA + YERR
HERE, (ALPHA, BETA) ARE THE REGRESSION COEFFICIENTS, EPSILON IS THE
INTRINSIC RANDOM SCATTER ABOUT THE REGRESSION, XERR IS THE
MEASUREMENT ERROR IN X, AND YERR IS THE MEASUREMENT ERROR IN
Y. EPSILON IS ASSUMED TO BE NORMALLY-DISTRIBUTED WITH MEAN ZERO AND
VARIANCE SIGSQR. XERR AND YERR ARE ASSUMED TO BE
NORMALLY-DISTRIBUTED WITH MEANS EQUAL TO ZERO, COVARIANCE MATRICES
XVAR^2 FOR X, VARIANCES YSIG^2 FOR Y, AND COVARIANCE VECTORS
XYCOV. THE DISTRIBUTION OF XI IS MODELLED AS A MIXTURE OF NORMALS,
WITH GROUP PROPORTIONS PI, MEANS MU, AND COVARIANCES T. BAYESIAN
INFERENCE IS EMPLOYED, AND A STRUCTURE CONTAINING RANDOM DRAWS FROM
THE POSTERIOR IS RETURNED. CONVERGENCE OF THE MCMC TO THE POSTERIOR
IS MONITORED USING THE POTENTIAL SCALE REDUCTION FACTOR (RHAT,
GELMAN ET AL.2004). IN GENERAL, WHEN RHAT < 1.1 THEN APPROXIMATE
CONVERGENCE IS REACHED.
SIMPLE NON-DETECTIONS ON Y MAY ALSO BE INCLUDED
AUTHOR : BRANDON C. KELLY, STEWARD OBS., JULY 2006
Inputs
X - THE OBSERVED INDEPENDENT VARIABLES. THIS SHOULD BE AN
[NX, NP]-ELEMENT ARRAY.
Y - THE OBSERVED DEPENDENT VARIABLE. THIS SHOULD BE AN NX-ELEMENT
VECTOR.
Optional Inputs
XVAR - THE COVARIANCE MATRIX OF THE X ERRORS, AND
[NX,NP,NP]-ELEMENT ARRAY. XVAR[I,*,*] IS THE COVARIANCE
MATRIX FOR THE ERRORS ON X[I,*]. THE DIAGONAL OF
XVAR[I,*,*] MUST BE GREATER THAN ZERO FOR EACH DATA POINT.
YVAR - THE VARIANCE OF THE Y ERRORS, AND NX-ELEMENT VECTOR. YVAR
MUST BE GREATER THAN ZERO.
XYCOV - THE VECTOR OF COVARIANCES FOR THE MEASUREMENT ERRORS
BETWEEN X AND Y.
DELTA - AN NX-ELEMENT VECTOR INDICATING WHETHER A DATA POINT IS
CENSORED OR NOT. IF DELTA[i] = 1, THEN THE SOURCE IS
DETECTED, ELSE IF DELTA[i] = 0 THE SOURCE IS NOT DETECTED
AND Y[i] SHOULD BE AN UPPER LIMIT ON Y[i]. NOTE THAT IF
THERE ARE CENSORED DATA POINTS, THEN THE
MAXIMUM-LIKELIHOOD ESTIMATE (THETA) IS NOT VALID. THE
DEFAULT IS TO ASSUME ALL DATA POINTS ARE DETECTED, IE,
DELTA = REPLICATE(1, NX).
SILENT - SUPPRESS TEXT OUTPUT.
MINITER - MINIMUM NUMBER OF ITERATIONS PERFORMED BY THE GIBBS
SAMPLER. IN GENERAL, MINITER = 5000 SHOULD BE SUFFICIENT
FOR CONVERGENCE. THE DEFAULT IS MINITER = 5000. THE
GIBBS SAMPLER IS STOPPED AFTER RHAT < 1.1 FOR ALPHA,
BETA, AND SIGMA^2, AND THE NUMBER OF ITERATIONS
PERFORMED IS GREATER THAN MINITER.
MAXITER - THE MAXIMUM NUMBER OF ITERATIONS PERFORMED BY THE
MCMC. THE DEFAULT IS 1D5. THE GIBBS SAMPLER IS STOPPED
AUTOMATICALLY AFTER MAXITER ITERATIONS.
NGAUSS - THE NUMBER OF GAUSSIANS TO USE IN THE MIXTURE
MODELLING. THE DEFAULT IS 3.
Output
POST - A STRUCTURE CONTAINING THE RESULTS FROM THE GIBBS
SAMPLER. EACH ELEMENT OF POST IS A DRAW FROM THE POSTERIOR
DISTRIBUTION FOR EACH OF THE PARAMETERS.
ALPHA - THE CONSTANT IN THE REGRESSION.
BETA - THE SLOPES OF THE REGRESSION.
SIGSQR - THE VARIANCE OF THE INTRINSIC SCATTER.
PI - THE GAUSSIAN WEIGHTS FOR THE MIXTURE MODEL.
MU - THE GAUSSIAN MEANS FOR THE MIXTURE MODEL.
T - THE GAUSSIAN COVARIANCE MATRICES FOR THE MIXTURE
MODEL.
MU0 - THE HYPERPARAMETER GIVING THE MEAN VALUE OF THE
GAUSSIAN PRIOR ON MU.
U - THE HYPERPARAMETER DESCRIBING FOR THE PRIOR
COVARIANCE MATRIX OF THE INDIVIDUAL GAUSSIAN
CENTROIDS ABOUT MU0.
W - THE HYPERPARAMETER DESCRIBING THE `TYPICAL' SCALE
MATRIX FOR THE PRIOR ON (T,U).
XIMEAN - THE MEAN OF THE DISTRIBUTION FOR THE
INDEPENDENT VARIABLE, XI.
XIVAR - THE STANDARD COVARIANCE MATRIX FOR THE
DISTRIBUTION OF THE INDEPENDENT VARIABLE, XI.
XICORR - SAME AS XIVAR, BUT FOR THE CORRELATION MATRIX.
CORR - THE LINEAR CORRELATION COEFFICIENT BETWEEN THE
DEPENDENT AND INDIVIDUAL INDEPENDENT VARIABLES,
XI AND ETA.
PCORR - SAME AS CORR, BUT FOR THE PARTIAL CORRELATIONS.
Called Routines
RANDOMCHI, MRANDOMN, RANDOMWISH, RANDOMDIR, MULTINOM
References
Carroll, R.J., Roeder, K., & Wasserman, L., 1999, Flexible
Parametric Measurement Error Models, Biometrics, 55, 44
Kelly, B.C., 2007, Some Aspects of Measurement Error in
Linear Regression of Astronomical Data, ApJ, In press
(astro-ph/0705.2774)
Gelman, A., Carlin, J.B., Stern, H.S., & Rubin, D.B., 2004,
Bayesian Data Analysis, Chapman & Hall/CRC