0
$\begingroup$

The y-values in these coordinates are the observed data from a simulation:

{{50.0251, -19.8231}, {531.214, 389.522}, {626.79, 470.827}, {723.357,552.976}, {820.686, 635.773}, {918.619, 719.084}}

The y-values in these coordinates are evaluations of the linear fit I applied to the previous coordinate list:

{{50.0251, -20.3943}, {531.214, 388.221}, {626.79, 469.381}, {723.357, 551.383}, {820.686, 634.033}, {918.619, 717.196}}

I want to get the Chi-Squared parameter for this fit, so I plug in the y-values of the first list for $observed$ and the y-values of the second list for $expected$ in the following formula as I read it in Wikipedia:

$$\sum \frac{(observed-expected)^2}{expected}$$

and the result is $-32.7844$.

I've never done anything related to statistics, just found the formula and plugged it, it seems very straightforward, what am I doing wrong? Thanks

EDIT: This is what I do, suppose the first list is $((x_1,y_1),...(x_6,y_6))$ and the second list is $((x_1,z_1),...(x_6,z_6))$, I apply the formula as

$\frac{(y1-z1)^2}{z_1}+\frac{(y2-z2)^2}{z_2}+\frac{(y3-z3)^2}{z_3}$

I have to be doing this wrong, because that's what I do and get the wrong number!

  • 0
    I think the formula is for comparing the expected number of samples fulfilling some criteria with the actual frequencies, the observed number of samples fulfilling the criteria. Maybe it could be generalized to not just probability spaces but that's way more than I know. (Perhaps you need a model that says it is linear plus some noise, and then calculate the expected values for that model given how many samples you have taken or something ?? )2017-02-25
  • 0
    The result cannot be negative. I am getting $0.007164036$. And yes, regressing your $y$ on your $x$ and a constant, I get predicted values $-19.82285$, $389.5213$, $470.8271$, $552.9761$, $635.7731$, $719.0841$ and your sum equal to $-1.82601E-09$.2017-02-25
  • 0
    Thx @Jan, Do you mean you also got a negative: $-1.82601 \times 10^{-9}?$ for my linear fit? Because I keep doing what I describe in the question and I keep getting -32.7844 This is what I do, suppose the first list is $((x_1,y_1),...(x_6,y_6))$ and the second list is $((x_1,z_1),...(x_6,z_6))$, I apply the formula $\frac{(y1-z1)^2}{z_1}+\frac{(y2-z2)^2}{z_2}+\frac{(y3-z3)^2}{z_3}$ I have to be doing this wrong, because that's what I do and get the wrong number!2017-02-26
  • 0
    Sorry, your $y_{1}$ is negative, I thus take my "the result cannot be negative". I think my $0.007164$ is correct. I have done it again. Check here: https://goo.gl/Hn2MH4.2017-02-26

0 Answers 0