Message Boards Message Boards


Cannot produce confidence contours of constant chi square for given data

Posted 1 year ago
0 Replies
0 Total Likes

I am trying to plot the experimental confidence regions that is 1 sigma, 2 sigma etc for a data which consists of experimental values of two quantities and corresponding delta chi square. So for the below mentioned sample data

I have tried this

x = Function[a, ArcSin[Sqrt[a]]*(180/\[Pi])]@
   Import["C:\\Desktop\\data1.txt", {"Data", \
{All}, {1}}];
y = Import[
   "C:\\Desktop\\data1.txt", {"Data", {All}, \
data = {x, y}\[Transpose];
deltaChisq = 
  Import["C:\\Desktop\\data1.txt", {"Data", \
{All}, {3}}];

(*define error Ellipse*)
ErrorEllipse[data_, percLevel_, points_: 100] := 
  Module[{eVa, eVec, coors, dchi, thetaGrid, ellipse, 
    rEllipse}, {eVa, eVec} = Eigensystem@Covariance[data];
   (*Get the coordinates of the data mean*)coors = Mean[data];
   (*Get the perc[%] confidence interval error ellipse*)
   dchi = \[Sqrt]Quantile[deltaChisq, percLevel/100];
   (*define error ellipse in x and y coordinates*)
   thetaGrid = Table[i, {i, 0, 2 \[Pi], 2 \[Pi]/99}];
   ellipse = {dchi \[Sqrt]eVa[[1]] Cos[thetaGrid], 
     dchi \[Sqrt]eVa[[2]] Sin[thetaGrid]};
   (*rotate the ellipse and center ellipse at coors*)
   rEllipse = coors + # & /@ (ellipse\[Transpose].eVec)];

(*visualize results*)
percentOneSigma = 66.3;
percentTwoSigma = 95.4;

 ListLinePlot[ErrorEllipse[data, percentOneSigma], 
  PlotStyle -> {Thick, Red}], 
 ListLinePlot[ErrorEllipse[data, percentTwoSigma], 
  PlotStyle -> {Thick, Blue}], 
 ListPlot[{Mean[data]}, PlotStyle -> {Thick, Red}], 
 ListLinePlot[ErrorEllipse[data, 99.7], PlotStyle -> {Dotted, Black}],
  PlotRange -> All]

Which giving me some ellipses, but I think they are not the exact confidence ellipses. Since this is a non linear data it should be a isocontour having constant chi square values. The contour should be the 2D 2 variable contour like this ![][1]

Reply to this discussion
Community posts can be styled and formatted using the Markdown syntax.
Reply Preview
or Discard

Group Abstract Group Abstract