We have learned to compute
averages and standard deviations,
but now we will use the same information of
same knowledge to make comparisons between groups.
So we will use the same dataset that we have used so far.
That is the teaching evaluation data from
University of Texas, comprising 463 courses.
We are looking at the teaching evaluation,
beauty, and age.
We're comparing the averages for
these three variables for female instructor variable.
So those who are females,
their average teaching evaluation was 3.9
compared to those of men, 4.06.
Here we're looking at
the average teaching evaluation for tenured professors,
3.96 verses untenured, 4.13.
The average age of untenured professors was 50.2 years,
and that for tenured professors, 47.85 years.
One thing that is very important in
statistical analysis is to
think about the question and to think
about the population or sample that you are working with.
We are computing averages across 463 courses.
We find the average age or beauty,
but these are the attributes of instructors.
We know from our data to
their 94 instructors who have
collectively taught 463 courses,
and we know that there are duplicates,
that is the same instructor
who has taught multiple courses.
So when I compute the average age using 463 courses,
it's not necessarily the average age of
the instructors because it could be true that
older aged individuals may
have taught more courses than younger individuals,
resulting in an higher average.
That is not necessarily
the average age of the instructors.
So to avoid this problem,
we have to subset
the data so that we remove the duplicates and
have only one observation
per individual instructor in the dataset.
Instead of 463 observations,
you should have just 94 observations.
Now let's look at the comparison.
When we use 94 observations where
no instructor is repeated in the dataset,
the average age or average beauty score is 0.25.
When we look at the 463 courses,
the average value is 0.11.
Let's compare the age.
The average age using 94 observations
for males is 49.4 and for females is 44.9.
You see here that as for age,
we don't see much difference whether we
use 463 observations or 94.
But we certainly see much difference in
the beauty scores if you were to use the wrong dataset.
That is the dataset where
individuals are repeated multiple times.
Data visualization is a critical piece
of modern-day statistical analysis.
Their staples are helpful,
so you don't have to eyeball
the output to figure out what the trends are.
The visual displays are much easier to understand.
We will use the same datasets of teaching
evaluations and ask this question,
do instructors teaching
single credit courses get higher evaluations?
We see that, yes, they do.
By Mean evaluation, when plotted as the chart,
you see that instructors who teach single credit courses
have a slightly higher average teaching evaluation.
Let us start by determining
how many courses were taught by
male instructors and how many by female instructors.
For this, we can use a bar chart.
Notice that the information is
complete from a statistical point of view in
that we know how many courses were
taught by males versus females.
But we do not have some critical information from
this chart as it relates to communication.
Therefore, we can say
this chart serves as statistical purpose,
but it doesn't serve a communication purpose.
Let me illustrate this with an example.
Here you are looking at a street map.
You can see the streets and
the buildings and the highways,
but you don't see the street names.
Without street names, it is hard to
determine where you are
and in which direction you should be heading.
Even though it is according to scale,
it may be accurate in
its depiction of the streets in the neighborhood,
but it's still lacks the ability to
communicate information to you.
To add communication value to this map,
you can simply add the street names.
Let us apply the same philosophy to our graphic.
But once we add information about this infographic,
for example, adding just a title
makes this chart more informative.
To do this in Python,
we'll use the countplot function in
the seaborne library and set the title label.
This helps your graph to be more informative.
We can also add more dimensions to the data.
In addition to the gender of the instructors,
we could add the tenure status of
the instructors as well to the graphic.
To do that in Python,
you add hue argument to the countplot.
We can add another dimension to the data,
regenerating the same graphic with the same information.
That is, the number of
courses taught by gender and tenure.
Then adding the dimension of
courses being upper-division and lower division,
and presenting them in two rows or columns.
To do this in Python,
we can specify the rows argument
using the countplot function.
Now let's look at the situation where
our primary variables of
interest are continuous variables.
We would like to explore
the relationship between the two while adding
further categorical variables as an additional dimension.
Using the teaching evaluation data we ask this question,
does age effect teaching evaluations?
We then add two additional dimensions,
which are gender and tenure.
So our dataset consists of age and teaching evaluation,
which are the two primary variables of
interest and are continuous.
Then we add two other dimensions,
i.e., gender and tenure.
These are categorical variables.
Age is on the X axis and
the teaching evaluation scores on the Y axis.
The orange colored circles represent
males and the blue colored circles represent females.
The top panel is for tenured professors and
the bottom panel is for the untenured instructors.
To do this in Python,
we use the FacetGrid option,
which works for multiplot gridding
and allows tweaking the plot.
You create the row and hue for the categorical variables,
in our case, tenure and gender.
Then we use the map to apply
a plotting function to each subset of the data.