Covariance Matrix
- To: mathgroup at smc.vnet.net
- Subject: [mg17090] Covariance Matrix
- From: Gianfranco Zosi <zosi at to.infn.it>
- Date: Sat, 17 Apr 1999 03:34:57 -0400
- Sender: owner-wri-mathgroup at wolfram.com
Question: How does Mathematica calculate the CovarianceMatrix ? I have the following simple data set (4 points) i 1 2 3 4 Xi -0.6 -0.2 +0.2 +0.6 Yi 5(2) 3(1) 5(1) 8(2) The value in () is the uncertainty (one sigma). I wish to estimate the best (Gauss) parameters of the fitting parabola AND the Covariance Matrix. ^^^ I have done the calculations case A) following usual matrix technique case B) using the command Regress in Mathematica (see attached program) Results: the coefficients of the parabola are OK but the two covariance matrices are different Case A) Cov Matrix = 0.664 0 -2.54 0 3.85 0 -2,54 0 24.48 Case B) Cov Matrix 0.229868 0 -0.878906 0 1.33136 0 -0.878906 0 8.45102 If my matrix (case A) is correct, it seems that Mathematica does not follow the standard definition Cov Matrix = (aT W a)**(-1) where aT is the transpose of a and a = 1 -0.6 (-0.6)**2 1 -0.2 (-0.2)**2 1 +0.2 (+0.2)**2 1 +0.6 (+0.6)**2 W = 1/4 0 0 0 0 1 0 0 0 0 1 0 0 0 0 1/4 I have noticed that i) the ratio of the coefficients of the two matrices is about 2.89, but it does not say much to me ii) the coefficients of the Mathematica Correlation Matrix coincide ^^^^^^^^^^^ with mine ----- begin of my Mathematica program with Regress ------------ Clear["Global`*"]; Needs["Statistics`LinearRegression`"]; SeedRandom[15]; data = {{-0.6,5.},{-0.2,3.},{0.2,5.},{0.6,8.}}; onesigma= {2.,1.,1.,2.}; weig= Map[1/#^2 &,onesigma]; aa= ListPlot[data]; b= Fit[data,{1,x,x^2},x]; c= Plot[b,{x,-0.6,0.6}]; Show[aa,c] datafit = Regress[data,{x^0,x^1,x^2},x,Weights->weig, RegressionReport->{BestFit, BestFitParameters, RSquared,EstimatedVariance,ParameterTable,ParameterCITable, ANOVATable,CovarianceMatrix,CorrelationMatrix}] ------------ end of my Mathematica program ---------- Many thanks for your help and clarification. G.Zosi Dip. Fisica Generale "A. Avogadro" v. P. Giuria 1 - 10125 Torino - Italy phone + 39 11 670 7426 (7425)