Statistics is all about collecting data and recording variables and then using
those to try and make generalizations about a population; so let's start with
talking about what is a variable? a variable is a recorded piece of
information or a characteristic about a person a case or unit in our study. So
variables are some characteristic info that's recorded for each person but it
varies or changes from person to person so for example we might record the age
of everyone in our sample and for every one we're recording the age but the age
is going to change or vary from person to person so this is kind of the
opposite of a constant which is always the same. For the sake of our discussion
we have a few examples here that we're going to talk about so we might record
the age, the weight, BMI, does someone have a disease? yes or no, biological sex,
country of birth and so on. The way we approach summarizing and analyzing data
depends largely on the type of variables that we have. Variables fall into one of
two broad categories. We can think of something like the country of birth is
placing people into categories, something like age or weight are numerical or
recorded quantities. so let's define those: The first type of variable we can
call categorical (variable) and this also sometimes gets called qualitative (variables); so this places
people into categories or it records qualities about them. The other type of
variable often gets labeled as numeric (variable) or we can also call this quantitative (variable). It
records quantities. So let's just write some of that down: categorical variables
place people or units, if we're not recording data about people, into groups
or categories; numeric are recorded numeric quantities and again for each
person or each case. There's all of other names that get used for these as well.
Through this set of videos I'm going to refer to variable types of categorical
or numeric and I'm going to abbreviate them with 'CAT' or 'NUM' before we go through
and place some of these variables into these different variable types let's
talk about how these can be further broken down
so categorical variables can be further broken down into what we call nominal or
ordinal and numeric variables can be further broken down into discrete so I'm
just going to summarize that 'DISC' or continuous. Again I'll just abbreviate
that 'CONT'; okay so let's talk about each of these categorical variables: things
like biological sex right male or female, country of birth, these sorts of things
nominal means that there is no ordering based on magnitude or size, right so
country of birth, you can order them alphabetically but there's no
smallest to largest ordering where if you think of something like the size of
coffee that someone orders right that's categorical maybe small medium or large
but there is a ordering based on the size or magnitude, right, small is smaller
than medium, medium is smaller than large right so there is an ordering or ranking
to these categories so that's what we call ordinal there is a rank or an
ordering to the categories.
Discrete and continuous it's a bit more of a gray
area between these two and they're often treated the same or very similarly in
analysis but discrete variables tend to take on integer only so things like take
on value zero one two three four in theory they can go all the way up to
infinity but integer only so things like the number of people who are in an
emergency room there's zero or one or two continuous variables these are
measured on a continuous scale so when we record someone's weight we often
report weights to the nearest pound or nearest kilogram but they're actually
measured on a continuous scale right your weight can be fifty seven point two
five eight kilograms for example so what we're gonna do now is go through and
take this list of variables and decide whether they're categorical or numeric
as well as which kind of scale of measurement has been used and
you might want to take a moment to pause the video and try and do this yourself
before looking at me do this
Okay so let's go through and place each of these variables and into which type
we think they are. So age is a recorded quantity and it's continuous
again while we report our age to the the nearest whole number, no one ever
says that they're thirty five point seven three eight years old but it
actually is measured on a continuous scale now thinking about weight
again that's a numeric measurement and it's on a continuous scale what else
disease recorded this yes or no that's categorical right, we are placing someone in
two categories and there's no ordering or rank to these
biological sex right again recorded as male or female that's a nominal
categorical variable country of birth I'll just shorten it right country here
just for the sake of space hair color again right that's categorical it's
nominal right no natural ordering to these again you can order them
alphabetically but we're talking about a ranking based on size or magnitude
income again that's a continuous variable what else you have the number
of people in the emergency room right now again number of people may be at a
moment in time or a number of people that show up in a day, this is a
quantity or a numeric variable and it's discrete it's gonna be 0 or 1 or 2 or 3
in theory can go up to infinity the number of live births in a day in a
hospital again that's discrete the size of coffee that you buying small medium
or large right that's a categorical variable and there was an ordering or
ranking to these and finally temperature recorded in degrees Celsius or degrees
Fahrenheit doesn't matter that's a numeric quantity and again
measured on a continuous scale: degrees Celsius or you could put it as degrees
Fahrenheit doesn't really matter now a few important things to note before we
continue on the first is that categorical variables sometimes are
recorded using numbers but that doesn't make them numeric so quite often with
things like does someone have a disease yes or no they often get recorded with
zeros and ones; one often indicating yes they do, zero they don't
or biological sexes male and female we might record males with zero females
with one but again these are not numeric variables we're just using numbers to
record them another good example is the Likert scale so again this is where we
ask people do you strongly disagree disagree neutral agree strongly agree
and we often ask them to rank it using one two three four or five so there
we're using numbers to indicate categories right levels of agreement or
disagreement and so there we're looking at an ordinal variable strongly disagree
and then a little bit higher than that is disagreeing and a bit higher is
neutral and higher agree and higher is strongly agree right so there is a
ranking or ordering to those but the numbers don't actually mean anything
other than being labels for these categories another example we can look
at is suppose we all decide to go and do a 10 kilometer race together so we can
record how long did it take us to finish the race right and this variable is a
numeric measurement recording how many minutes and seconds did it take us to
run 10 kilometers so that's a continuous variable so I'm going to add that in
here: the race time: how many minutes and seconds did it take
you to finish the race if we make it competitive and look at who finished in
first, who finished in second who finished in third and so on right now
we're looking at categories we're looking at the place that people
finished and there is a ranking to these first place was the fastest second was
the next fastest the third was the next fastest so here the place that someone
finishes in a race is a categorical variable and it's ordinal right there's
a ranking to them and so again a feature of ordinal variables is while the
categories can be ordered or ranked the spacing between them is not necessarily
equal, the distance between first and second place isn't necessarily the
same as the distance between second and third or the distance between third and
fourth and so on! all right so these are rank variables or ordinal variables so
as we mentioned before the sorts of plots that we make the summaries or the
method of analysis depends largely on are we
working with categorical variables, numeric (variables) or what combination of
of categorical and numeric. Okay so it's important to make this distinction.
Now a quick mention: categorical variables often get summarized using
proportions or percentages so if we're looking at let's just say biological sex
we often summarized that by looking at how many males and how many females or
or what percentage of males and percentage of females were there. Numeric variables
if we were looking at say something like age we often summarize that using the
mean or average age or the median age okay so in following videos we start to
talk about appropriate summaries for categorical or numeric variables
appropriate methods of analysis and so on. Now one more important note and this
really becomes a little bit more important further down the line but
we're gonna mention it now mostly for the sake of completeness: discrete or
continuous variables can be further subdivided into scales of measurement
looking at the ratio scale or the interval scale
okay so let's quickly mention what those are so the ratio scale has a meaningful
zero here a meaningful ratio and what that means is if we look at these
variables here age, weight, income, they're measured on a ratio scale meaning an age
of zero is that zero means something right there is no age or a weight of
zero there is no weight. Or another way to think of it: a ratio is meaningful
someone who's 20 years old is twice as old as a 10 year old someone who's
thirty is twice as old as a fifteen year old so that ratio makes sense. Things
like temperature, measured on degrees Celsius or degrees Fahrenheit
are measured on what we call an interval scale and this has a non meaningful
or an arbitrary zero and again what we mean by that is a temperature of zero
degrees Celsius or zero degrees Fahrenheit doesn't mean there's an
absence of temperature or they do not have a meaningful ratio: 20 degrees is
not twice as hot as 10 degrees right 30 degrees is not twice as hot as 15
degrees,this is a scale but the zero is not
an absence! the ratio was not meaningful. Now just a few other important notes for
us to talk about before we wrap this up: the first is identifiers so often either
there's identifiers that are used things like your student number or an employee ID
things like these. These are used to identify an individual but they're not
variables they sometimes fit in this conversation and that they're often one
of the columns in your dataset but they're really used to identify an
individual. They're not a true variable! another important note is that you can
always convert numeric variables into categorical variables okay so for
example we can take something like age and rather than using numeric age we can
convert that or break it down into say child, adult and say senior or we might
just break it into age categories of 0 to 10, 10 to 20, 20 to 30 and so on.
And then I guess one final note to mention that we've already said but I'm going to
write it down here is that sometimes categorical variables are recorded using
numbers this doesn't mean that they're numeric variables but we often use
numbers as placeholders for the categories so in the following videos we
start to explore how to summarize variables graphically and numerically
depending on whether they're categorical or numeric and then the methods of
analysis we build up again really focus on what type of variable or variables do we have
Don't forget to subscribe to marinstatslectures!