WEBVTT

00:00.560 --> 00:10.170
Welcome to the data hall youtube channel. In this
video, we are going to discuss how do we analyze the

00:10.170 --> 00:19.380
categorical latter. So specifically, we are going to see
how do we generate descriptive statistics and the graphs

00:19.380 --> 00:25.530
for categorical variables. So normally when
we are working with categorical variables

00:25.530 --> 00:30.490
we are mainly interested in in the frequencies

00:31.310 --> 00:40.390
in percentages. Um the count of the data, the account of the
different categories or were interested in the bar charts or the

00:40.390 --> 00:49.490
pie charts. So this is what we are going to discuss in
this video and see how do we generate these statistics

00:49.490 --> 00:59.310
these descriptive statistics and graphs are using stata.
So mainly if you click on statistics steps before

00:59.310 --> 01:07.190
that, let me show you the data. This is the question of data
that we had been using with our previous videos where we work

01:07.190 --> 01:11.760
with the questionnaires. You would remember
we have serial number, occupation, age

01:11.760 --> 01:17.020
gender and a couple of questions.
If I assure you it in the data view

01:17.020 --> 01:27.190
you would see we have already labeled them
and we have the the the the values are

01:27.190 --> 01:36.900
labeled values for each, for each question. Okay.
So mainly we would be working with this summary

01:36.900 --> 01:44.100
statistics. We click on statistics, summary statistics. Then
within summary statistics, we have this frequency tables

01:44.100 --> 01:53.560
Remember when we are working with categorical variables,
we the statistics that we are interested in in frequency

01:53.560 --> 01:59.360
distributions or frequencies. Um
So, so we have a couple of options

01:59.360 --> 02:04.070
We have five options over here
and out of these five options

02:04.070 --> 02:08.480
we would, we would cover the
first four options in this video

02:08.480 --> 02:15.130
And, but maybe later on, we would, we would
see how this stable calculator would work

02:15.130 --> 02:18.950
But for now in this video, we
are going to cover these four

02:18.950 --> 02:26.500
Um So when we work with, with categorical
variables, we have to generate tabulations

02:26.500 --> 02:30.610
right? So we have a one way
tabulation or to vote tabulations

02:31.610 --> 02:38.510
So we either generate one way tabulation in
one way tabulation. We generate a category

02:38.510 --> 02:47.500
a frequency distribution of a single variable
or X, right? In multiple or two week tabulation

02:47.500 --> 02:54.940
we generate a tabulation for different different
variables. So let's start with the one way tabulation

02:55.550 --> 02:59.750
the simple command S tablet and
then we write the variable name

02:59.750 --> 03:06.530
So if you tablet occupation, we would know that
we have three categories within occupation

03:06.770 --> 03:16.030
Um and 24% of the the observations
that we have our solid

03:16.030 --> 03:25.500
person and 40 to our students, we also have the
cumulative this uh the cumulative percentages and

03:25.500 --> 03:29.440
the frequencies we know there are
50 observations in our data set

03:29.440 --> 03:34.280
So this tells us that within the occupation
variable, we do not have any missing value

03:34.580 --> 03:39.870
Similarly, we can tablet the gender variable.
So again, this is the one way to abolition

03:39.870 --> 03:45.830
We are only generating a table based
on the categories of just one variable

03:45.830 --> 03:55.170
Uh or we can tablet through a single
question. So we have different categories

03:55.170 --> 03:58.690
or different, you know, it is
a liquid scale for question one

03:58.690 --> 04:06.210
either a person would strongly disagree,
disagree or I would strongly agree

04:06.210 --> 04:14.420
So these are five different categories in this. But if you
wanted to generate a tabulation for all these variables

04:14.420 --> 04:21.690
for multiple variables, it would be, you
know, we would have to write 33 commands

04:21.690 --> 04:27.370
But let's just say we wanted to
generate one way tabulation, you know

04:27.370 --> 04:32.800
all these these single tables that we
just generated but using a single command

04:32.800 --> 04:38.510
then we would use tab one. So we write tab
one, then all the variables that we want

04:38.510 --> 04:47.960
So I have also added Q four, we just hit
run and it has generated the one way a

04:47.960 --> 04:55.600
tabulation, right? For, for each of
the, of the variable. So in essence

04:55.600 --> 05:02.140
what it is doing, it is running the same
tabulation command four times for each variable

05:02.140 --> 05:09.070
So if I wanted to do this individually, then
I would have to write for tablet commands

05:10.280 --> 05:14.550
The way it can be used from the
menus is weekly con statistics

05:14.610 --> 05:20.810
then assembly statistics, frequency tables. And
if you wanted to generate a one way tabulation

05:20.810 --> 05:30.190
You would click on this option and give the name of the
variable that we had to submit and it would generate

05:30.190 --> 05:36.020
the one word abolition. This was a
simple, simple, simple tablet command

05:36.020 --> 05:39.210
If you wanted to have

05:40.200 --> 05:46.090
multiple one way tabulations, the
tab one command that we just saw

05:46.090 --> 05:50.610
this is the option that we can use.
We would select all the categories

05:50.610 --> 05:57.180
sorry, all the variables that we want it okay.
And it would generate the tables that we want

05:57.240 --> 05:58.100
Okay

06:00.000 --> 06:06.420
From this analysis, from the stable, we would
notice that all the variables have 50 observations

06:06.420 --> 06:13.490
But instead this Q4 would have 40 observations. We
would want to know how many missing values are there

06:13.490 --> 06:18.380
And we want to adjust these percentages
according to those missing values

06:18.380 --> 06:22.720
So currently it is generating these
percentages with respect to the valid responses

06:22.720 --> 06:28.480
See we have these valid responses,
but we also want But instead of this

06:28.480 --> 06:35.330
we want to have percentages that would also,
you know, account for the missing values

06:35.330 --> 06:42.730
So we use this tab one instead
of having all these categories

06:42.730 --> 06:49.890
So all these variables we just want are interested
in Q4. We would have probably 10 tablet

06:49.890 --> 06:57.470
but it's the same thing tab one for
only one variable is essentially tablet

06:58.280 --> 07:04.640
command. We introduced the missing
option. So if we execute this command

07:04.640 --> 07:14.330
we would see that it is somewhat similar to this one. But now we
have a role for the missing observations and these percentages are

07:14.330 --> 07:22.640
adjusted with respect to, you know, now, with respect to this
total number of observations rather than the violent responses

07:24.180 --> 07:29.130
Now, we have started this discussion
of wild responses and you know

07:29.130 --> 07:38.420
percentages with respect to the total number of observations.
It there is a user written command which is called F

07:38.420 --> 07:45.790
R E. If you haven't installed, you can simply write
SSC installed FRE because I have already installed it

07:45.790 --> 07:50.940
So I won't execute this command.
That's why I have commented it out

07:51.680 --> 07:57.130
So what this free would do, it was provide
the percentages of violent responses

07:57.130 --> 08:03.480
So in addition to this table, it
would give us additional statistics

08:03.480 --> 08:08.250
So let's execute this because Q one
and Q four have missing observations

08:08.250 --> 08:13.910
So I'm just executing this command
for the Q one and Q four variable

08:15.070 --> 08:19.950
Now we have this for the Q one variable
and this for the Q four variable

08:20.520 --> 08:26.200
The difference that you would see is
all the 41 we didn't have missing values

08:26.200 --> 08:31.950
This table is essentially similar to the
table that we had with the tablet command

08:31.950 --> 08:36.880
But this would be different here. We
would have the missing observations

08:36.880 --> 08:46.410
We would have percentages, you know, accounting for the missing
observations of percentage with respect to this 50 same that we generated

08:46.410 --> 08:49.860
you know, using the missing option

08:50.880 --> 08:55.140
And then we would have these percentages
with respect to the valid responses

08:55.140 --> 09:01.310
The table for Q for that we generated
without using the missing missing option

09:01.310 --> 09:10.570
So you have got, you know, the both the
values by just executing the one command

09:10.570 --> 09:20.280
The one more thing that I like about this, this free command
is that uh this tablet command will just give you the

09:20.280 --> 09:24.360
the value labels. It wouldn't give
you the pneumatic values, right

09:25.950 --> 09:33.510
But with the free command, it would give you
both right and sorted based on the numbers

09:34.060 --> 09:42.280
So it is kind of more, you know,
easy to analyze, easy to visualize

09:42.280 --> 09:48.210
Um probably we would want to
have this kind of, you know

09:48.210 --> 09:53.520
presentation with our graph. But
let's just say if you wanted to use

09:54.510 --> 10:03.680
the same tablet command, but now you want to
have these value labels and the values by

10:03.680 --> 10:09.730
both of these two. But with the tablet command,
you do not want to use the free command

10:09.730 --> 10:14.040
you want to use the tablet
command and you want both of these

10:14.040 --> 10:20.370
So if you use the tablet command
without this no label option

10:20.490 --> 10:29.970
it generates the default is to have
value labels. But if we use the no label

10:29.970 --> 10:37.030
the default, the the the the the tablet
command would generate only the values

10:37.890 --> 10:43.200
we want both of them. So the command
for this would be numb label all

10:43.200 --> 10:46.080
So it would add numbers to the labels

10:47.080 --> 10:48.790
So let's execute this command

10:50.120 --> 10:52.370
Now let's establish gender

10:53.610 --> 11:01.090
You will see that it is somewhat similar to the
representation that we have with the free command

11:01.090 --> 11:10.320
we can do tablet one, right? And we
would have the table for gender as

11:10.320 --> 11:14.780
well as for question number four. If
you wanted to remove the value labels

11:14.780 --> 11:22.850
sorry, the value numbers because they
are actually added in the data view

11:22.850 --> 11:29.600
right? So, so the value labels are actually
changed. So what this command had done

11:29.600 --> 11:36.040
it had added the value um as
a prefix of the value label

11:37.670 --> 11:47.120
If we wanted to go back to the original data, then we would
simply use num label and would use the option remove and

11:47.900 --> 11:50.400
our data would look like the way it was

11:53.500 --> 11:58.660
okay. So that was just
the one way tabulation. Uh

11:59.460 --> 12:07.760
If you wanted to see how many, you know,
businessmen's are there that are male

12:08.020 --> 12:17.110
So we want categorization based on two different variables.
So you want frequency based on two different variables for

12:17.110 --> 12:24.130
that, we would use the same tablet command,
but now we would add two variables

12:24.130 --> 12:29.440
So if we saw previously with tablet
command, we would just have one variable

12:29.440 --> 12:34.620
This would generate one way tabulation.
But if we wanted to have to a tabulation

12:34.620 --> 12:40.250
then we would add multiple
variables we can keep on adding

12:42.310 --> 12:48.620
Okay. So now this would give us
the idea of how many salaried male

12:48.620 --> 12:57.710
how many male students do we have in our data?
How many total number of obviously male and female

12:57.710 --> 12:58.870
students do we have

13:01.720 --> 13:06.840
There is one more command which is
tapped to and what the stab to will do

13:06.840 --> 13:13.200
it will generate all two way tables,
all possible paired to wait tables

13:13.870 --> 13:22.150
So we have four variables over here. So it would
generate a two way table for occupation and gender

13:22.150 --> 13:28.190
then it would generate a table for occupation
and Q one, then for occupation in Q four

13:28.260 --> 13:33.150
then for gender and Q one gender and Q
four. And lastly for Q one and Q four

13:34.900 --> 13:42.010
So it generated the table as uh
I have explained for occupation

13:42.010 --> 13:51.050
gender occupation, Q one and so on and so
forth. So all the possible to wait tables that

13:51.050 --> 14:00.280
can be generated had been generated before moving towards
the graphs. Let me again show you these commands from

14:00.280 --> 14:06.220
the, from the menus. We have discussed this
one way table and multiple one way tabulation

14:06.220 --> 14:10.780
If you want to wait tables,
you can use this command

14:12.100 --> 14:21.400
And if you want all the possible two tables, the
last command tap to that we just executed and

14:21.400 --> 14:23.290
this is the option that you want to use

14:24.140 --> 14:30.140
Okay. Let's see. How do we generate
graphs for categorical variables

14:30.950 --> 14:38.460
Normally we would use either pie charts or
bar chart to present categorical variables

14:38.460 --> 14:47.730
If we had continuous variable, we would probably use line chart.
But for categorical pie chart and bar chart is the way to go

14:48.680 --> 14:54.010
I will first show you from the
command menu. We click on graph

14:54.010 --> 14:57.050
then we click on pie chart

14:58.470 --> 15:07.420
And for now, I want to use the pie chart
for the queue for variable. So I would

15:08.270 --> 15:13.890
if I have different categories within a
single variable, then I would use this option

15:13.890 --> 15:20.590
If we have categories, um you know,
being converted into different variables

15:20.590 --> 15:28.300
we have a data into wide format. I would probably use
this this option But I have my data in long format

15:28.300 --> 15:37.030
I have categories within a variable in single variable.
So I would select the variable Q4 and I click submit

15:39.040 --> 15:44.260
Okay. It would generate a pie
shot, nice looking pie shot

15:46.030 --> 15:54.160
Uh And but what I want is I want
the smallest, you know, category

15:55.020 --> 15:59.950
being over here and then it should
move towards the largest category

15:59.950 --> 16:03.740
So I wanted to be somewhat sorted

16:05.620 --> 16:14.830
The option that I would use is the size order.
It would sort the variables based on sort the

16:14.830 --> 16:20.940
the the the pies in this
chart based on its size

16:23.540 --> 16:27.700
So now we see the smallest buyers over
here and the largest one is over here

16:27.700 --> 16:33.730
So the largest is the agreed and the smallest is
stronger, disagree for the question number four

16:33.730 --> 16:35.260
whatever the questionable four is

16:36.230 --> 16:45.560
probably I would want to exclude the missing observation. I would
use this option And it would give me the by chart excluding the

16:45.560 --> 16:53.770
missing observation, the sort option you have just
seen. And we for to remove the missing observation

16:53.770 --> 16:55.810
we will use C4

16:56.590 --> 17:00.780
But probably graphs can be easily, you know

17:01.720 --> 17:07.990
created using the menus rather than from, from command

17:10.310 --> 17:13.260
Next in date, a bar chart

17:18.150 --> 17:26.230
We would have a bar chart for frequencies. So
we'll use this option and the categorical variable

17:26.230 --> 17:30.500
let's use Q1 this time, let's generate this graph

17:32.620 --> 17:33.690
And

17:35.110 --> 17:40.460
it's a nice looking graph.
But we want to play with some

17:40.460 --> 17:47.600
you know, we can, instead of having
these value labels as horizontal

17:47.600 --> 17:53.620
we can probably have them vertical. It's,
you know, it's a bad idea in this case

17:53.620 --> 17:59.190
but sometimes you might need
it, we can change the label size

17:59.190 --> 18:06.480
probably would have small label sizes and
we can play with other options over here

18:06.480 --> 18:15.690
But the idea of this video is to give you some knowledge
of how do we work with the the categorical variables

18:15.690 --> 18:17.140
Thanks for watching the video
