Results 1 to 7 of 7

Thread: [RESOLVED] What's the correlation coefficient i fthe standard deviation is zero?

  1. #1

    Thread Starter
    Super Moderator FunkyDexter's Avatar
    Join Date
    Apr 2005
    Location
    An obscure body in the SK system. The inhabitants call it Earth
    Posts
    7,957

    Resolved [RESOLVED] What's the correlation coefficient i fthe standard deviation is zero?

    Calling all statisticians, I need you

    I've inherited a program that, among other things, does some statistical analysis. I know absolutely nothing about stats

    The program started throwing up a divide by zero error and it's because of this bit of code:-
    VB Code:
    1. dblTemp = dblSPI - (dblIMean * dblTotalRawEntry)
    2. dblResult = QStandardDeviationFinal(xQuestionNumber) * dblSTI * lngCTOT
    3. dblResult = dblTemp / dblResult
    I could post the code to calculate those other values if needed but I'm hoping this'll be enough.

    The problem is that the standard deviation for the particular data this is happening on is zero, so the first dblResult calculates to zero and that causes the divide by zero error. So my question is:-

    If the standard deviation is zero what's the correlation coefficient? I'd assume it's 1 but could it be -1? or zero?

  2. #2
    Addicted Member Glaysher's Avatar
    Join Date
    Jul 2006
    Posts
    132

    Re: What's the correlation coefficient i fthe standard deviation is zero?

    If the standard deviation is zero that means that your data has zero spread and therefore every piece of data is the same

    eg 6, 6, 6, 6, 6, 6, 6

    Now if this data is used as the x-coordinate in a scatter diagram and the second set of data does not have a standard deviation of zero then you would get a vertical line

    If this data is used as the y-coordinate in a scatter diagram and the first set of data does not have a standard deviation of zero then you would get a horizontal line.

    In both cases you would get a strange kind of correlation (not really correlated) where the data can be fitted to a line.

    But the correlation coefficient measures postive correlation (postive gradient) or negative correlation (negative gradient). Your situation has neither because one of your variables doesn't vary. This is a situation where you would not test for correlation because correlation would not tell you anything useful.

    I don't know anything about code but in statistics you just wouldn't calculate a correlation value for data that has a standard deviation of zero.

  3. #3

    Thread Starter
    Super Moderator FunkyDexter's Avatar
    Join Date
    Apr 2005
    Location
    An obscure body in the SK system. The inhabitants call it Earth
    Posts
    7,957

    Re: What's the correlation coefficient i fthe standard deviation is zero?

    Thanks for the response.

    I'm not sure I fully understood that (I really dont know my correlation coefficient from my elbow I'm afraid) but I think I got the gist. Are you saying that, because the standard deviation in this case is zero, the correlation coefficient is meaningless?

    Bear in mind that the standard deviation produced by this program usually isn't zero for other data sets - in fact I believe this the first time it's happened. So assuming on a different dataset the standard deviation came out as non-zero would that mean my variable was 'varying'? ...and therefore the correlation co-efficient would have meaning?

    If that's the case I think I can probably get away with setting the correlation coefficient to an arbitrary value (probably zero) and leaving it for the user to recognise as meaningless. (I think zero has meaning - no correlation - but if I've got to set an arbitrary value it's as good as any other, maybe I could use a blank)

  4. #4
    Addicted Member Glaysher's Avatar
    Join Date
    Jul 2006
    Posts
    132

    Re: What's the correlation coefficient i fthe standard deviation is zero?

    Zero would be best.

    The point of correlation is to measure the relationship between two variables and how changing one will affect the other. The problem with one set of data having a standard deviation of zero is that since one set of data doesn't vary you can't measure the relationship because there is no way of knowing what will happen when the previously non varying variable is changed

  5. #5
    Fanatic Member Matt_T_hat's Avatar
    Join Date
    Dec 2001
    Location
    '76 Male Body Evil-Errors: 666
    Posts
    774

    Re: What's the correlation coefficient i fthe standard deviation is zero?

    Let me take the risk of looking like a total fool.

    I'm going toa ssume the writer(s) of the code knew what they were doing (somewhat) and that the data should contain varience (thus a standard deviation of some value).

    If some source of data is arriving with nil varience I would place good money on the source being "wrong" that is an null set or a single datam pair (just a dot on the graph).

    My instincts tell me to look where this data is coming from, what the data is and how it was achieved. It could be lagitimate data but meaningless to process.

    I would then want to add an if to catch the "bad" data as early as possible... if I had time on my hands I would use the same conditions at places that should be unreachable and throw an error if they ever are reached something like "ERROR: ***: How did you do that (john)" (more seriously I would have it log the event and return fail).

    A non math answer but is it of use to you?
    ?
    'What's this bit for anyway?
    For Jono

  6. #6
    Frenzied Member zaza's Avatar
    Join Date
    Apr 2001
    Location
    Borneo Rainforest Habits: Scratching
    Posts
    1,486

    Re: What's the correlation coefficient i fthe standard deviation is zero?

    What if you had a case where the variation in the data over a short period of time was very small, smaller than the resolution of your data collector perhaps, but in the longer period varied more substantially. In this case the standard deviation over the short period of time might well be zero, simply because the variation in the data is of the order of (say) 0.0001 and you can only measure to 0.01. However, over the course of the day your data might vary significantly more.


    An example might be the following. You want to track the performance of an air conditioning system, designed to hold your warehouse at 22 degrees during the day and 18 degrees at night, to a resolution of 0.5 degrees. You also need it to be monitoring once a minute, in case the system fails. Your aircon system controls the temperature to 0.1 degrees, so you have a set of data in the short term with 0 sd but in the longer term a much bigger sd. This doesn't make evaluation of the trend in the data any less valid, or any more suspicious. You just need to be aware of the likely nature of the data.

    zaza
    I use VB 6, VB.Net 2003 and Office 2010



    Code:
    Excel Graphing | Excel Timer | Excel Tips and Tricks | Add controls in Office | Data tables in Excel | Gaussian random number distribution (VB6/VBA,VB.Net) | Coordinates, Vectors and 3D volumes

  7. #7

    Thread Starter
    Super Moderator FunkyDexter's Avatar
    Join Date
    Apr 2005
    Location
    An obscure body in the SK system. The inhabitants call it Earth
    Posts
    7,957

    Re: What's the correlation coefficient i fthe standard deviation is zero?

    Thanks all for some extremely useful responses which have helped an ill educated fool like me understand the issue if not neccessarily the maths.

    I believe the data, in this case, is indeed suspect, mainly because the dataset is very small. It's candidates answers to a question in an exam against their overall score. For this particular run it's a test rerun that only includes two candidates. This is extremely unusual for this system. I'm guessing it genuinely does have a variance of zero, hence the problems I'm experiencing.

    From the sound of what you're saying I can effectively effectively call the correllation a meaningless stat and report it out as a zero.

    Thanks again for your help guys.

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  



Click Here to Expand Forum to Full Width