1
$\begingroup$

This is a question I found surprisingly hard to answer using Google: How is interval scaled data implemented in R? For nominal, its factor(), for ordinal, it's ordered(), and for ratio scale, it's numeric(). Now I understand that it's easy to use numeric for interval scale variables as well. But the point about these data types is that addition will fail on factor() and ordered() variables, and greater/lesser comparisons fail on factor(), but not on ordered(). Likewise, is there a datatype for interval data that allows for addition and subtraction, but not division and multiplication?

$\endgroup$
7
  • 4
    $\begingroup$ The meaning of a measurement scale is at best only loosely and indirectly connected with a computer data type. Conflating those two may be creating a lot of confusion--which explains the difficulty in researching this with Google. In particular, there is no sense of "failure" (of division, etc) in a measurement type. The definition of type depends on which relationships among numbers remain meaningful as the numeric representation is modified in an allowable way. Although your question raises many issues, as asked it really is unanswerable. $\endgroup$
    – whuber
    Commented Mar 12, 2019 at 15:37
  • $\begingroup$ If you could suggest a better question, please feel free to do so. I would say however that there is a meaningful definition of failure. Try to add two ordinal variables, and you get "In Ops.ordered(y, y) : '+' is not meaningful for ordered factors". Same for categorical: "In Ops.factor(x, x) : ‘>’ not meaningful for factors". So R datatypes implement at least some concept of meaningful operations. $\endgroup$ Commented Mar 12, 2019 at 15:44
  • 1
    $\begingroup$ That's an idiosyncrasy of R: it's not inherent in the concept. A nice exposition was published by F.M. Lord as "On the Statistical Treatment of Football Numbers:" you can Google that. I am unable to propose a better question because I'm not quite sure where you trying to go with this or what you're trying to accomplish. $\endgroup$
    – whuber
    Commented Mar 12, 2019 at 15:45
  • 2
    $\begingroup$ I suspect reading over Lord's paper might indicate the sense in which few statistical tests actually "rely on" or require data on a particular scale and reveal why creating such a datatype might be counterproductive. Even procedures designed for count data have been effectively applied to data represented as real numbers. $\endgroup$
    – whuber
    Commented Mar 12, 2019 at 15:49
  • 1
    $\begingroup$ Thank you for sharing that. The literature is much larger--Lord's paper engendered many, many reactions. Although your particular reference decides Lord was wrong, their conclusion backs up my suggestion that this direction you are heading in--of attempting to enforce some kind of "measurement scale" as a computing data type--may be unwise. Don't misunderstand me: I think there is a place for strongly typed statistical computing languages (of which R is decidedly not an example). Just don't confuse measurement type with data type! $\endgroup$
    – whuber
    Commented Mar 12, 2019 at 16:45

1 Answer 1

2
$\begingroup$

Partially answered in comments:

The meaning of a measurement scale is at best only loosely and indirectly connected with a computer data type. Conflating those two may be creating a lot of confusion--which explains the difficulty in researching this with Google. In particular, there is no sense of "failure" (of division, etc) in a measurement type. The definition of type depends on which relationships among numbers remain meaningful as the numeric representation is modified in an allowable way. Although your question raises many issues, as asked it really is unanswerable.

– whuber

I suspect reading over Lord's paper might indicate the sense in which few statistical tests actually "rely on" or require data on a particular scale and reveal why creating such a datatype might be counterproductive. Even procedures designed for count data have been effectively applied to data represented as real numbers.

– whuber

Another viewpoint: A-reanalysis-of-Lords-statistical-treatment-of-football-numbers

Thank you for sharing that. The literature is much larger--Lord's paper engendered many, many reactions. Although your particular reference decides Lord was wrong, their conclusion backs up my suggestion that this direction you are heading in--of attempting to enforce some kind of "measurement scale" as a computing data type--may be unwise. Don't misunderstand me: I think there is a place for strongly typed statistical computing languages (of which R is decidedly not an example). Just don't confuse measurement type with data type!

– whuber

$\endgroup$

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.