• Skip to secondary menu
  • Skip to main content
  • Skip to primary sidebar

Statistics By Jim

Making statistics intuitive

Comparing Hypothesis Tests for Continuous, Binary, and Count Data

By Jim Frost 46 Comments

In a previous blog post, I introduced the basic concepts of hypothesis testing and explained the need for performing these tests. In this post, I’ll build on that and compare various types of hypothesis tests that you can use with different types of data, explore some of the options, and explain how to interpret the results. Along the way, I’ll point out important planning considerations, related analyses, and pitfalls to avoid.

A hypothesis test uses sample data to assess two mutually exclusive theories about the properties of a population . Hypothesis tests allow you to use a manageable-sized sample from the process to draw inferences about the entire population.

I’ll cover common hypothesis tests for three types of variables —continuous, binary, and count data. Recognizing the different types of data is crucial because the type of data determines the hypothesis tests you can perform and, critically, the nature of the conclusions that you can draw. If you collect the wrong data, you might not be able to get the answers that you need.

Related posts : Qualitative vs. Quantitative Data , Guide to Data Types and How to Graph Them , Discrete vs. Continuous , and Nominal, Ordinal, Interval, and Ratio Scales

Hypothesis Tests for Continuous Data

Continuous data can take on any numeric value, and it can be meaningfully divided into smaller increments, including fractional and decimal values. There are an infinite number of possible values between any two values. You often measure a continuous variable on a scale. For example, when you measure height, weight, and temperature, you have continuous data . With continuous variables, you can use hypothesis tests to assess the mean, median, and standard deviation.

When you collect continuous data, you usually get more bang for your data buck compared to discrete data. The two key advantages of continuous data are that you can:

  • Draw conclusions with a smaller sample size.
  • Use a wider variety of analyses, which allows you to learn more.

I’ll cover two of the more common hypothesis tests that you can use with continuous data—t-tests to assess means and variance tests to evaluate dispersion around the mean. Both of these tests come in one-sample and two-sample versions. One-sample tests allow you to compare your sample estimate to a target value. The two-sample tests let you compare the samples to each other. I’ll cover examples of both types.

There is also a group of tests that assess the median rather than the mean. These are known as nonparametric tests and practitioners use them less frequently. However, consider using a nonparametric test if your data are highly skewed and the median better represents the actual center of your data than the mean.

Related posts : Nonparametric vs. Parametric Tests and Determining Which Measure of Central Tendency is Best for Your Data

Graphing the data for the example scenario

Suppose we have two production methods, and our goal is to determine which one produces a stronger product. To evaluate the two methods, we draw a random sample of 30 products from each production line and measure the strength of each unit. Before performing any analyses, it’s always a good idea to graph the data because it provides an excellent overview. Here is the CSV data file in case you want to follow along: Continuous_Data_Examples .

Histogram for continuous data

These histograms suggest that Method 2 produces a higher mean strength while Method 1 produces more consistent strength scores. The higher mean strength is good for our product, but the greater variability might produce more defects.

Graphs provide a good picture, but they do not test the data statistically. The differences in the graphs might be caused by random sample error rather than an actual difference between production methods. If the observed differences are due to random error, it would not be surprising if another sample showed different patterns. It can be a costly mistake to base decisions on “results” that vary with each sample. Hypothesis tests factor in random error to improve our chances of making correct decisions.

Keep this graph in mind when we look at binary data because they illustrate how much more information continuous data convey.

Related posts : Using Histograms to Understand Your Data and How Hypothesis Tests Work: Significance Levels and P-values

Two-sample t-test to compare means

The first thing we want to determine is whether one of the methods produces stronger products. We’ll use a two-sample t-test to determine whether the population means are different. The hypotheses for our 2-sample t-test are:

  • Null hypothesis: The mean strengths for the two populations are equal.
  • Alternative hypothesis : The mean strengths for the two populations are different.

A p-value less than the significance level indicates that you can reject the null hypothesis. In other words, the sample provides sufficient evidence to conclude that the population means are different. Below is the output for the analysis.

2-sample t-test results for continuous data.

The p-value (0.034) is less than 0.05. From the output, we can see that the difference between the mean of Method 2 (98.39) and Method 1 (95.39) is statistically significant. We can conclude that Method 2 produces a stronger product on average.

That sounds great, and it appears that we should use Method 2 to manufacture a stronger product. However, there are other considerations. The t-test tells us that Method 2’s mean strength is greater than Method 1, but it says nothing about the variability of strength values. For that, we need to use another test.

Related posts : How T-Tests Work and How to Interpret P-values Correctly and Step-by-Step Instructions for How to Do t-Tests in Excel .

2-Variances test to compare variability

A production method that has excessive variability creates too many defects. Consequently, we will also assess the standard deviations of both methods. To determine whether either method produces greater variability in the product’s strength, we’ll use the 2 Variances test. The hypotheses for our 2 Variances test are:

  • Null hypothesis: The standard deviations for the populations are equal.
  • Alternative hypothesis: The standard deviations for the populations are different.

A p-value less than the significance level indicates that you can reject the null hypothesis. In other words, the sample provides sufficient evidence for concluding that the population standard deviations are different. The 2-Variances output for our product is below.

2 Variances hypothesis test results for continuous data.

Both of the p-values are less than 0.05. The output indicates that the variability of Method 1 is significantly less than Method 2. We can conclude that Method 1 produces a more consistent product.

Related post : Measures of Variability

What we learned and did not learn with the hypothesis tests

The hypothesis test results confirm the patterns in the graphs. Method 2 produces stronger products on average while Method 1 produces a more consistent product. The statistically significant test results indicate that these results are likely to represent actual differences between the production methods rather than sampling error.

Our example also illustrates how you can assess different properties using continuous data, which can point towards different decisions. We might want the stronger products of Method 2 but the greater consistency of Method 1. To navigate this dilemma, we’ll need to use our process knowledge.

Finally, it’s crucial to note that the tests produce estimates of population parameters—the population means (μ) and the population standard deviations (σ). While these parameters can help us make decisions, they tell us little about where individual values are likely to fall. In certain circumstances, knowing the proportion of values that fall within specified intervals is crucial.

For the examples, the products must fall within spec limits. Even when the mean falls within the spec limit, it’s possible that too many individual items will fall outside the spec limits if the variability is too high.

Other types of analyses

To better understand the distribution of individual values rather than the population parameters, use the following analyses:

Tolerance intervals : A tolerance interval is a range that likely contains a specific proportion of a population. For our example, we might want to know the range where 99% of the population falls for each production method. We can compare the tolerance interval to our requirements to determine whether there is too much variability.

Capability analysis : This type of analysis uses sample data to determine how effectively a process produces output with characteristics that fall within the spec limits. These tools incorporate both the mean and spread of your data to estimate the proportion of defects.

Related post : Confidence Intervals vs. Prediction Intervals vs. Tolerance Intervals

Proportion Hypothesis Tests for Binary Data

Let’s switch gears and move away from continuous data. Suppose we take another random sample of our product from each of the production lines. However, instead of measuring a characteristic, inspectors evaluate each product and either accept or reject it.

Binary data can have only two values. If you can place an observation into only two categories, you have a  binary variable . For example, pass/fail and accept/reject data are binary. Quality improvement practitioners often use binary data to record defective units.

Binary data are useful for calculating proportions or percentages, such as the proportion of defective products in a sample. You simply take the number of defective products and divide by the sample size. Hypothesis tests that assess proportions require binary data and allow you to use sample data to make inferences about the proportions of populations.

2 Proportions test to compare two samples

For our first example, we will make a decision based on the proportions of defective parts. Our goal is to determine whether the two methods produce different proportions of defective parts.

To make this determination, we’ll use the 2 Proportions test. For this test, the hypotheses are as follows:

  • Null hypothesis: The proportions of defective parts for the two populations are equal.
  • Alternative hypothesis: The proportions of defective parts for the two populations are different.

A p-value less than the significance level indicates that you can reject the null hypothesis. In this case, the sample provides sufficient evidence for concluding that the population proportions are different. The 2 Proportions output for our product is below.

2 proportions hypothesis test results for binary data.

Both p-values are less than 0.05. The output indicates that the difference between the proportion of defective parts for Method 1 (~0.062) and Method 2 (~0.146) is statistically significant. We can conclude that Method 1 produces defective parts less frequently.

1 Proportion test example: comparison to a target

The 1 Proportion test is also handy because you can compare a sample to a target value. Suppose you receive parts from a supplier who guarantees that less than 3% of all parts they produce are defective. You can use the 1 Proportion test to assess this claim.

First, collect a random sample of parts and determine how many are defective. Then, use the 1 Proportion test to compare your sample estimate to the target proportion of 0.03. Because we are interested in detecting only whether the population proportion is greater than 0.03, we’ll use a one-sided test. One-sided tests have greater power to detect differences in one direction, but no ability to detect differences in the other direction. Our one-sided 1 Proportion test has the following hypotheses:

  • Null hypothesis: The proportion of defective parts for the population equals 0.03 or less.
  • Alternative hypothesis: The proportion of defective parts for the population is greater than 0.03.

For this test, a significant p-value indicates that the supplier is in trouble! The sample provides sufficient evidence to conclude that the proportion of all parts from the supplier’s process is greater than 0.03 despite their assertions to the contrary.

Comparing continuous data to binary data

Think back to the graphs for the continuous data. At a glance, you can see both the central location and spread of the data. If we added spec limits, we could see how many data points are close and far away from them. Is the process centered between the spec limits? Continuous data provide a lot of insight into our processes.

Now, compare that to the binary data that we used in the 2 Proportions test. All we learn from that data is the proportion of defects for Method 1 (0.062) and Method 2 (0.146). There is no distribution to analyze, no indication of how close the items are to the specs, and no indication of how they failed the inspection. We only know the two proportions.

Additionally, the samples sizes are much larger for the binary data than the continuous data (130 vs. 30). When the difference between proportions is smaller, the required sample sizes can become quite large. Had we used a sample size of 30 like before, we almost certainly would not have detected this difference.

In general, binary data provide less information than an equivalent amount of continuous data. If you can collect continuous data, it’s the better route to take!

Related post : Estimating a Good Sample Size for Your Study Using Power Analysis

Poisson Hypothesis Tests for Count Data

Count data can have only non-negative integers (e.g., 0, 1, 2, etc.). In statistics , we often model count data using the Poisson distribution. Poisson data are a count of the presence of a characteristic, result, or activity over a constant amount of time, area, or other length of observation. For example, you can use count data to record the number of defects per item or defective units per batch. With Poisson data, you can assess a rate of occurrence.

For this scenario, we’ll assume that we receive shipments of parts from two different suppliers. Each supplier sends the parts in the same sized batch. We need to determine whether one supplier produces fewer defects per batch than the other supplier.

To perform this analysis, we’ll randomly sample batches of parts from both suppliers. The inspectors examine all parts in each batch and record the count of defective parts. We’ll randomly sample 30 batches from each supplier. Here is the CSV data file for this example: Count_Data_Example .

Performing the Two-Sample Poisson Rate Test

We’ll use the 2-Sample Poisson Rate test. For this test, the hypotheses are as follows:

  • Null hypothesis: The rates of defective parts for the two populations are equal.
  • Alternative hypothesis: The rates of defective parts for the two populations are different.

A p-value less than the significance level indicates that you can reject the null hypothesis because the sample provides sufficient evidence to conclude that the population rates are different. The 2-Sample Poisson Rate output for our product is below.

2 sample Poisson rate hypothesis test results for count data.

Both p-values are less than 0.05. The output indicates that the difference between the rate of defects per batch for Supplier 1 (3.56667) and Supplier 2 (5.36667) is statistically significant. We can conclude that Supplier 1 produces defects at a lower rate than Supplier 2.

Hypothesis tests are a great tool that allow you to take relatively small samples and draw conclusions about entire populations. There is a selection of tests available, and different options within the tests, which make them useful for a wide variety of situations.

To see an alternative approach to these traditional hypothesis testing methods, learn about bootstrapping in statistics !

Share this:

hypothesis test nominal data

Reader Interactions

' src=

May 10, 2024 at 11:06 am

Ah that explains why I couldn’t find an R function that returned the same output! Thank you very much for your reply – I can stop looking now!

May 9, 2024 at 11:24 am

Thank you for this article, I’ve learned a lot from reading it.

Your Two-Sample Poisson Rate Test example is very similar in structure to my data so I am trying to follow the same approach. The results pictured look like output from an R function – but I have been unable to find one that outputs results in this way. If these were indeed created by an R library/function, would you mind sharing which one you used, please?

Kind regards, Ash

' src=

May 9, 2024 at 4:49 pm

Sorry, I’m not using R. The results are from Minitab statistical software.

' src=

September 29, 2023 at 3:21 pm

Hello guys, what is the outcome varaible in independent sample t test? binary or not? Because it compares the means of two independent populations as which is greater or lower

September 29, 2023 at 5:47 pm

The outcome variable for an independent sample t-test is continuous because you’re using it to calculate the means for two groups.

The binary variable is the categorical factor in the design. The binary variable defines the two groups for which you’re calculating the means. For example, your binary variable could be gender (male/female), experimental group (control/treatment), or material type (A/B). But the outcome variable is continuous so you can calculate the means for both groups and compare them. Click the link to learn more about the test.

' src=

March 22, 2023 at 3:32 pm

The document can’t be found, is the link still working?

March 22, 2023 at 3:35 pm

You’ll need to specify which link you’re talking about so I can check it. All links should be working.

' src=

October 9, 2021 at 3:28 am

Greetings!!! Very intuitive explanation. Liked the way you have explained with sufficient examples.

Jim based on Inferential Statistics, could you include an article on A/B Testing Methodology incorporating from basics like —Data Collection Process, Dataset Splitting Procedures & Duration for carrying out such experiments.

Also if you could incorporate illustrations from different industries viz. Healthcare, Manufacturing, Logistics, Quality, Ecommerce, Marketing, Advertisement Domains, this would indeed be useful.

Nowadays A/B Testing & Multivariate Testing is being incorporated & implemented in a robust manner across Data Science domain. Article or Write-up regarding this would immensely be useful.

Looking forward to a favourable and positive response.

' src=

August 21, 2021 at 1:22 pm

The poisson test example has N of 30. I am wondering the appropriate distribution if the sample is lower than 30. Is it a t statistic or chi-square

' src=

June 16, 2021 at 12:02 pm

Hi, great post! I have an expected and observed data set and want to do additional testing to see if they differ signficantly from each other. Furthermore, the specific entries that contribute to the most weight in that significance or places that should have special attention. I did chi-square goodness of fit, but want to go further. Just to add, this is count data.

June 19, 2021 at 4:17 pm

I’m not 100% sure what you want to do to go further. Because it’s count data, you could model it with the Poisson or Negative Binomial distribution. If you have other relevant variables, you can fit a Poisson or Negative Binomial regression model to explore relationships in your data. I talk a bit about those types of models in my post about choosing the correct type of regression model . You can also perform hypothesis tests designed for that type of data. The chi-squared test you performed seems like a good one to see how the expected and observed differs!

' src=

April 29, 2021 at 11:44 pm

How do you do a independence test in Stata for a categorical variable with 6 levels and a binary variable.

April 30, 2021 at 12:23 am

I’m not a Stata user, but it sounds like you need to perform a chi-square test of independence .

' src=

December 13, 2020 at 1:00 pm

Hi Jim – thank you for this great site! I have a situation where there is a reference standard (tells me if there is truly fat in a mass) and I have 2 different methods of detecting if there is (or is not) fat in the mass. My null hypothesis is that there is no difference in detection. I have a set of masses where I know if there is fat in the masses and used the 2 methods to detect whether they were able to detect the fat. Is the 2 proportions test the most appropriate for this question? Thank you so much!

' src=

December 3, 2020 at 8:31 am

Thank you Jim for the wonderful post. It was clearly written and I enjoyed reading through it. I have an additional query. I wanted to compare the variances of two methods of measurement applied at each observation point of a field survey. The variables from both methods have binary data type. How can I do the statistical test. Thank you in advance for your help.

December 3, 2020 at 3:02 pm

With binary data, you can’t compare variances. You can compare proportions using a proportions test. I discuss these tests in the binary section of this post. To read an example of a 2-sample proportions test, read my post about flu shot effectiveness . In it, I use 2-proportions tests to evaluate real flu study data. Or read my post about Mythbusters test about whether yawns are contagious , where I use a 2-proportions test. That way you can see what these tests can do. I cover them, and many other tests, in much more detail in my Hypothesis Testing book !

I hope this helps!

' src=

August 5, 2020 at 9:36 pm

Hi Jim. Just wanted to follow up and see if you’ve had a chance to review this question yet?

August 6, 2020 at 1:09 am

Hi Jack, thanks for the reminder! I just replied!

' src=

August 3, 2020 at 4:45 am

Hi Jim , a green belt has a project on flu vaccinations , with 5 data points, % vaccination rates per year averaging about 36% of staff numbers. Her project was to increase vaccination rates this year , and has accumulated a lot of data points to measure vaccination rates in different office areas as a percent of total staff numbers which have almost doubled. Should she use 2 sample t test to measure difference in means between before and after data ( continuous) or should she use 2 sample test for proportions (attribute). There is small sample size for before data and large sample size for after data

August 5, 2020 at 12:46 am

I see two possibilities. The choice depends on whether she measured the same sites in the before and after. If they’re different sites before and after, she has independent groups and can use the regular 2-sample proportions test.

If they’re the same sites before and after, she can use either the test of marginal homogeneity or McNemar’s test. I have not used these tests myself and cannot provide more information. However, if she used the same sites before and after, she has proportions data for dependent groups (same groups) and should not use the regular 2-sample proportions test. These two tests can handle proportions for dependent groups.

' src=

July 19, 2020 at 3:18 am

Hi Jim. Would I be able to use the 2 Proportion Test for comparing 2 proportions from different time periods? Example scenario: I run a satisfaction survey on a MOOC site during Q1 to a random sample of visitors and find that 80% of them were satisfied with their experience. The following quarter I run the same survey and find that 75% were satisfied. Is the 5 percentage point drop statistically significant or just due to random noise?

Sorry about the delay in replying! Sometimes comments slip through the cracks!

Yes, you can do as you suggest assuming the respondents are different in the two quarters and assuming that the data are binary (satisfied/not satisfied). The 2 proportions test is designed for independent groups and binary data.

I hope that helps even belatedly!

' src=

May 19, 2020 at 9:58 pm

Thanks…Let me see that document

May 19, 2020 at 7:04 pm

I would like to ask about 2 sample poisson rate. How do you calculate the 95% CI and test for difference ? Your answer is really appreciated. Thank you so much for giving this tutorial.

May 19, 2020 at 9:17 pm

This document describes the calculations. I hope it helps!

' src=

March 6, 2020 at 4:52 am

Thank you so much for your kind support. Esteemed regards.

March 5, 2020 at 9:23 pm

Thanks for your helpful comments. Basically I have developed my research model based on competing theories. For example, I have one IV (Exploitation) and Two DV’s (Incremental innovation and Radical Innovation). Each variable in the model has own indicators. Some researchers claims that exploitation support only incremental innovations. On the other hand there are also studies that claims that in-depth exploitation also support radical innovation. However, these researchers claim that exploitation support radical innovations in a limited capacity as compared to incremental innovation. ON the basis of these competing theories I developed my hypothesis as: Exploitation significantly and positively influences both incremental and radical innovation, however exploitation influence incremental innovation more than radical innovation.

Thank you very much for your quick response. Its really helpful.

March 6, 2020 at 1:46 am

Hi Shabahat,

Thanks you for the additional information. I messed up one thing in my previous reply to you. Because you only have the one IV, you don’t need to worry about standardizing that IV for comparability. However, assuming the DVs use different units of measurement, that’ll make comparisons problematic. Consequently, you probably need to standardize the two dependent variables instead. You’d learn how a one unit change in the IV relates to the standard deviation of each DV. That puts the DVs on the same scale. See how other researchers have handled this situation in your field to be sure that’s an accepted approach.

Additionally, if you find a significant relationship between exploitation and radical innovation, then you’d have good evidence to support that claim you’re making.

March 5, 2020 at 2:37 am

Hi Jim, Its really amazing. However I have a query regarding my analysis. I have one independent variable (Continuous) and Two dependent variables (Continuous). In the linear regression, the Independent variable significantly explains both dependent variables. Problem: Now i want to compare the effect of my Independent variable on both dependent variables. How can I compare?. If the effect is different, how can I test whether the effect difference is statistically significant or not in SPSS.

March 5, 2020 at 4:01 pm

The fact that you’re talking about different DVs complicates things because they’re presumably measuring different things and using different units, which makes comparison difficult. The standardized coefficients can help you get around that but it changes the interpretation of the results.

Assuming that the two DV variables measure different characteristics, you might try standardizing your IVs and fitting the model using the standardized values. This process produces standardized coefficients, which use the same units and allows you to compare–although it does change the interpretation of the coefficients. I write about this in my post about assessing the importance of your predictors . You can also look at the CIs for the standardized coefficients and see if they overlap. If they don’t overlap, you know the difference between the standardized coefficients is statistically significant.

' src=

January 20, 2019 at 12:40 pm

Great Post! Can we test proportions from a continuos variable with unknown distribution using the poisson distribution using a cut-off value for good and bad samples and couting them?

' src=

November 14, 2018 at 4:05 pm

Hi Jim, I really enjoy reading your posts and they have cleared many stat concepts!

I had a question about the chi square probability distribution. Although it is a non-parametric test, why does it fall into a continuous probability distribution and why can we use the chi square distribution for categorical data if it’s a continuous probability distribution?

November 14, 2018 at 10:53 pm

Hi Sanjana,

That’s a great question! I’m glad you’re thinking about the types of variables and distributions, and how they’re used together.

You’re correct on both counts. Chi-squared test of independent is nonparameteric because it doesn’t assume a particular data distribution. Additionally, analysts use it to test the independence of categorical variables . There are other ways to use this distribution as well.

Now, onto why we use chi-square (a distribution for continuous data) with categorical variables! Yes, it involves categorical variables, but the analysis assesses the observed and expected counts of these variables. For each cell, the analysis takes the squared difference between the observed count and the expected count and then divides that by the expected count. These values are summed acrossed all cells to produce the chi-square value. This process produces a continuous variable that is based on the differences between the observed and expected counts of the categorical variables. When the value of this variable is large enough, we know that the difference between the observed counts and the expected counts is large enough to be unlikely due to chance. And, that’s why we use a continuous distribution to analyze categorical variables.

' src=

May 27, 2018 at 12:58 am

This is very helpful! Thank you!

May 26, 2018 at 11:38 pm

Hi Jim, Great post. I was wondering, do you know of any references that discuss the difference in sample size between binary and continuous data? I am looking for a reference to cite in a journal article. Thanks, Amanda.

May 26, 2018 at 11:55 pm

The article I cite below discusses the different sample sizes in terms of observations per model term in order to avoid overfitting your model. I also cover these ideas in my post about how to avoid overfitting regression models . For regression models, this provides a good context for sample size requirements.

Babyak, MA., What You See May Not Be What You Get: A Brief, Nontechnical Introduction to Overfitting in Regression-Type Models, Psychosomatic Medicine 66:411-421 (2004).

' src=

February 3, 2018 at 7:04 am

I am totally new to statistics,

Following a small sample from my dataset.

Views PosEmo NegEmo 1650077 2.63 1.27 753826 2.39 0.47 926647 1.71 1.02

Views = Dependent continous Variable PosEmo = Independent Continous Variable NegEmo = Independent Continous Variable

My query : 1. How to run Hypothesis testing on same, Im pretty confused what to use , what to do , I am using SPSS modeler and SPSS statistics tool. 2.I think Multiple Regression is Ok for this . Let me know how to use it in SPSS modeler or stats tool.

Regards Sarika

February 5, 2018 at 1:30 am

Hi Sarika, yes, it sounds like you can use multiple regression for those data. The hypothesis test in this case would be the p-values for the regression coefficients . Click that link to learn more about that. In your stats software, choose multiple linear regression and then specify the dependent variable and the two independent variables. Fit the model and then check the statistical output and the residual plots to see if you have a good model. Be sure to check out my regression tutorial too. That covers many aspects of regression analysis.

' src=

November 30, 2017 at 8:45 pm

Thanks for your sharing!

In the binary case (or proportion case), is there any comparison between “two proportion test” and “Chi-square” test? Is there any guideline to choose which test to use?

November 30, 2017 at 9:46 pm

You’re welcome! Regarding your question, a two proportion test requires one categorical variable with two levels. For example, the variable could be “test result” and the two levels are “pass” and “fail.”

A chi-square test of independence requires at least two categorical variables. Those variables can have two or more levels. You can read an example of the chi-square test of independence that I’ve written about. The example is based on the original Star Trek TV series and determines whether the uniform color affects the fatality rate. That analysis has two categorical variables–fatalities and uniform color. Fatalities has two levels that indicate whether a crewmember survived or died. Uniform color has three levels–gold, blue, and red.

As you can see, the data requirements for the two tests are different.

I hope this helps! Jim

' src=

November 30, 2017 at 2:18 am

' src=

November 29, 2017 at 10:41 pm

Great post. Thanks for sharing your expertise.

November 29, 2017 at 11:38 pm

Thank you! I’m glad it was helpful.

' src=

November 29, 2017 at 9:02 pm

Very nice article. Could you explain more on hypothesis testing on median?

November 29, 2017 at 11:39 pm

Thank you! For more information about testing the median, click the link in the article for where I compare parametric vs nonparametric analyses.

' src=

November 29, 2017 at 6:51 pm

Please let me know when one can use Probit Analysis. May I know the Procedure in SPSS.

Comments and Questions Cancel reply

Logo for Pressbooks at Virginia Tech

Want to create or adapt books like this? Learn more about how Pressbooks supports open publishing practices.

5.5 Introduction to Hypothesis Tests

Dalmation puppy near man sitting on the floor.

One job of a statistician is to make statistical inferences about populations based on samples taken from the population. Confidence intervals are one way to estimate a population parameter.

Another way to make a statistical inference is to make a decision about a parameter. For instance, a car dealership advertises that its new small truck gets 35 miles per gallon on average. A tutoring service claims that its method of tutoring helps 90% of its students get an A or a B. A company says that female managers in their company earn an average of $60,000 per year. A statistician may want to make a decision about or evaluate these claims. A hypothesis test can be used to do this.

A hypothesis test involves collecting data from a sample and evaluating the data. Then the statistician makes a decision as to whether or not there is sufficient evidence to reject the null hypothesis based upon analyses of the data.

In this section, you will conduct hypothesis tests on single means when the population standard deviation is known.

Hypothesis testing consists of two contradictory hypotheses or statements, a decision based on the data, and a conclusion. To perform a hypothesis test, a statistician will perform some variation of these steps:

  • Define hypotheses.
  • Collect and/or use the sample data to determine the correct distribution to use.
  • Calculate test statistic.
  • Make a decision.
  • Write a conclusion.

Defining your hypotheses

The actual test begins by considering two hypotheses: the null hypothesis and the alternative hypothesis. These hypotheses contain opposing viewpoints.

The null hypothesis ( H 0 ) is often a statement of the accepted historical value or norm. This is your starting point that you must assume from the beginning in order to show an effect exists.

The alternative hypothesis ( H a ) is a claim about the population that is contradictory to H 0 and what we conclude when we reject H 0 .

Since the null and alternative hypotheses are contradictory, you must examine evidence to decide if you have enough evidence to reject the null hypothesis or not. The evidence is in the form of sample data.

After you have determined which hypothesis the sample supports, you make a decision . There are two options for a decision. They are “reject H 0 ” if the sample information favors the alternative hypothesis or “do not reject H 0 ” or “decline to reject H 0 ” if the sample information is insufficient to reject the null hypothesis.

The following table shows mathematical symbols used in H 0 and H a :

Figure 5.12: Null and alternative hypotheses
equal (=) not equal (≠) greater than (>) less than (<)
equal (=) less than (<)
equal (=) more than (>)

NOTE: H 0 always has a symbol with an equal in it. H a never has a symbol with an equal in it. The choice of symbol in the alternative hypothesis depends on the wording of the hypothesis test. Despite this, many researchers may use =, ≤, or ≥ in the null hypothesis. This practice is acceptable because our only decision is to reject or not reject the null hypothesis.

We want to test whether the mean GPA of students in American colleges is 2.0 (out of 4.0). The null hypothesis is: H 0 : μ = 2.0. What is the alternative hypothesis?

A medical trial is conducted to test whether or not a new medicine reduces cholesterol by 25%. State the null and alternative hypotheses.

Using the Sample to Test the Null Hypothesis

Once you have defined your hypotheses, the next step in the process is to collect sample data. In a classroom context, the data or summary statistics will usually be given to you.

Then you will have to determine the correct distribution to perform the hypothesis test, given the assumptions you are able to make about the situation. Right now, we are demonstrating these ideas in a test for a mean when the population standard deviation is known using the z distribution. We will see other scenarios in the future.

Calculating a Test Statistic

Next you will start evaluating the data. This begins with calculating your test statistic , which is a measure of the distance between what you observed and what you are assuming to be true. In this context, your test statistic, z ο , quantifies the number of standard deviations between the sample mean, x, and the population mean, µ . Calculating the test statistic is analogous to the previously discussed process of standardizing observations with z -scores:

z=\frac{\overline{x}-{\mu }_{o}}{\left(\frac{\sigma }{\sqrt{n}}\right)}

where µ o   is the value assumed to be true in the null hypothesis.

Making a Decision

Once you have your test statistic, there are two methods to use it to make your decision:

  • Critical value method (discussed further in later chapters)
  • p -value method (our current focus)

p -Value Method

To find a p -value , we use the test statistic to calculate the actual probability of getting the test result. Formally, the p -value is the probability that, if the null hypothesis is true, the results from another randomly selected sample will be as extreme or more extreme as the results obtained from the given sample.

A large p -value calculated from the data indicates that we should not reject the null hypothesis. The smaller the p -value, the more unlikely the outcome and the stronger the evidence is against the null hypothesis. We would reject the null hypothesis if the evidence is strongly against it.

Draw a graph that shows the p -value. The hypothesis test is easier to perform if you use a graph because you see the problem more clearly.

Suppose a baker claims that his bread height is more than 15 cm on average. Several of his customers do not believe him. To persuade his customers that he is right, the baker decides to do a hypothesis test. He bakes ten loaves of bread. The mean height of the sample loaves is 17 cm. The baker knows from baking hundreds of loaves of bread that the standard deviation for the height is 0.5 cm and the distribution of heights is normal.

The null hypothesis could be H 0 : μ ≤ 15.

The alternate hypothesis is H a : μ > 15.

The words “is more than” calls for the use of the > symbol, so “ μ > 15″ goes into the alternate hypothesis. The null hypothesis must contradict the alternate hypothesis.

\frac{\sigma }{\sqrt{n}}

Suppose the null hypothesis is true (the mean height of the loaves is no more than 15 cm). Then, is the mean height (17 cm) calculated from the sample unexpectedly large? The hypothesis test works by asking how unlikely the sample mean would be if the null hypothesis were true. The graph shows how far out the sample mean is on the normal curve. The p -value is the probability that, if we were to take other samples, any other sample mean would fall at least as far out as 17 cm.

This means that the p -value is the probability that a sample mean is the same or greater than 17 cm when the population mean is, in fact, 15 cm. We can calculate this probability using the normal distribution for means.

Normal distribution curve on average bread heights with values 15, as the population mean, and 17, as the point to determine the p-value, on the x-axis.

A p -value of approximately zero tells us that it is highly unlikely that a loaf of bread rises no more than 15 cm on average. That is, almost 0% of all loaves of bread would be at least as high as 17 cm purely by CHANCE had the population mean height really been 15 cm. Because the outcome of 17 cm is so unlikely (meaning it is happening NOT by chance alone), we conclude that the evidence is strongly against the null hypothesis that the mean height would be at most 15 cm. There is sufficient evidence that the true mean height for the population of the baker’s loaves of bread is greater than 15 cm.

A normal distribution has a standard deviation of one. We want to verify a claim that the mean is greater than 12. A sample of 36 is taken with a sample mean of 12.5.

Find the p -value.

Decision and Conclusion

A systematic way to decide whether to reject or not reject the null hypothesis is to compare the p -value and a preset or preconceived α (also called a significance level ). A preset α is the probability of a type I error (rejecting the null hypothesis when the null hypothesis is true). It may or may not be given to you at the beginning of the problem. If there is no given preconceived α , then use α = 0.05.

When you make a decision to reject or not reject H 0 , do as follows:

  • If α > p -value, reject H 0 . The results of the sample data are statistically significant . You can say there is sufficient evidence to conclude that H 0 is an incorrect belief and that the alternative hypothesis, H a , may be correct.
  • If α ≤ p -value, fail to reject H 0 . The results of the sample data are not significant. There is not sufficient evidence to conclude that the alternative hypothesis, H a , may be correct.

After you make your decision, write a thoughtful conclusion in the context of the scenario incorporating the hypotheses.

NOTE: When you “do not reject H 0 ,” it does not mean that you should believe that H 0 is true. It simply means that the sample data have failed to provide sufficient evidence to cast serious doubt about the truthfulness of H o .

When using the p -value to evaluate a hypothesis test, the following rhymes can come in handy:

If the p -value is low, the null must go.

If the p -value is high, the null must fly.

This memory aid relates a p -value less than the established alpha (“the p -value is low”) as rejecting the null hypothesis and, likewise, relates a p -value higher than the established alpha (“the p -value is high”) as not rejecting the null hypothesis.

Fill in the blanks:

  • Reject the null hypothesis when              .
  • The results of the sample data             .
  • Do not reject the null when hypothesis when             .

It’s a Boy Genetics Labs claim their procedures improve the chances of a boy being born. The results for a test of a single population proportion are as follows:

  • H 0 : p = 0.50, H a : p > 0.50
  • p -value = 0.025

Interpret the results and state a conclusion in simple, non-technical terms.

Click here for more multimedia resources, including podcasts, videos, lecture notes, and worked examples.

Figure References

Figure 5.11: Alora Griffiths (2019). dalmatian puppy near man in blue shorts kneeling. Unsplash license. https://unsplash.com/photos/7aRQZtLsvqw

Figure 5.13: Kindred Grey (2020). Bread height probability. CC BY-SA 4.0.

A decision-making procedure for determining whether sample evidence supports a hypothesis

The claim that is assumed to be true and is tested in a hypothesis test

A working hypothesis that is contradictory to the null hypothesis

A measure of the difference between observations and the hypothesized (or claimed) value

The probability that an event will occur, assuming the null hypothesis is true

Probability that a true null hypothesis will be rejected, also known as type I error and denoted by α

Finding sufficient evidence that the observed effect is not just due to variability, often from rejecting the null hypothesis

Significant Statistics Copyright © 2024 by John Morgan Russell, OpenStaxCollege, OpenIntro is licensed under a Creative Commons Attribution-ShareAlike 4.0 International License , except where otherwise noted.

Share This Book

Have a thesis expert improve your writing

Check your thesis for plagiarism in 10 minutes, generate your apa citations for free.

  • Knowledge Base
  • What Is Nominal Data? | Examples & Definition

What Is Nominal Data? | Examples & Definition

Published on 18 September 2022 by Pritha Bhandari . Revised on 9 January 2023.

Nominal data is labelled into mutually exclusive categories within a variable. These categories cannot be ordered in a meaningful way.

For example, pref erred mode of transportation is a nominal variable, because the data is sorted into categories: car, bus, train, tram, bicycle, etc.

Table of contents

Levels of measurement, examples of nominal data, how to collect nominal data, how to analyse nominal data, frequently asked questions about nominal datra.

The level of measurement indicates how precisely data is recorded. There are 4 hierarchical levels: nominal, ordinal , interval , and ratio . The higher the level, the more complex the measurement.

The 4 levels of measurement: nominal, ordinal, interval, and ratio

Nominal data is the least precise and complex level. The word nominal means ‘in name’, so this kind of data can only be labelled. It does not have a rank order, equal spacing between values, or a true zero value.

At a nominal level, each response or observation fits only into one category.

Nominal data can be expressed in words or in numbers. But even if there are numerical labels for your data, you can’t order the labels in a meaningful way or perform arithmetic operations with them.

In social scientific research, nominal variables often include gender, ethnicity, political preferences or student identity number.

Examples of nominal variables
Variable Categories
Zip code
Political preferences
Employment status
Literary genre

Variables that can be coded in only 2 ways (e.g. yes/no or employed/unemployed) are called binary or dichotomous. Since the order of the labels within those variables doesn’t matter, they are types of nominal variable.

Nominal data can be collected through open- or closed-ended survey questions.

If the variable you are interested in has only a few possible labels that capture all of the data, use closed-ended questions.

What is your gender? Male
Female
Other
Prefer not to answer
Do you own a smartphone? Yes
No
What is your favorite movie genre? Romance
Action
Mystery
Animation
Musical
Comedy
Thriller

If your variable of interest has many possible labels, or labels that you cannot generate a complete list for, use open-ended questions.

  • What is your student ID number?
  • What is your zip code?
  • What is your native language?

To analyse nominal data, you can organise and visualise your data in tables and charts.

Then, you can gather some descriptive statistics about your data set. These help you assess the frequency distribution and find the central tendency of your data. But not all measures of central tendency or variability are applicable to nominal data.

Data set
Republican
Democrat
Independent
Independent
Republican
Republican
Republican
Democrat
Independent
Independent
Republican
Democrat
Democrat
Democrat
Democrat
Republican
Democrat
Democrat
Democrat
Republican
Democrat
Democrat
Independent
Republican
Republican
Democrat
Democrat

Distribution

To organise this data set, you can create a frequency distribution table to show you the number of responses for each category of political preference.

  • Simple frequency distribution
  • Percentage frequency distribution
Political preference Frequency
Democrat 13
Republican 9
Independent 5
Political preference Percent
Democrat 48.1%
Republican 33.3%
Independent 18.5%

Using these tables, you can also visualise the distribution of your data set in graphs and charts.

Displaying nominal data in a bar chart

Central tendency

The central tendency of your data set tells you where most of your values lie.

The mode , mean , and median are three most commonly used measures of central tendency. However, only the mode can be used with nominal data.

To get the median of a data set, you have to be able to order values from low to high. For the mean, you need to be able to perform arithmetic operations like addition and division on the values in the data set. While nominal data can be grouped by category, it cannot be ordered nor summed up.

Therefore, the central tendency of nominal data can only be expressed by the mode – the most frequently recurring value.

Statistical tests for nominal data

Inferential statistics help you test scientific hypotheses about your data. Nonparametric statistical tests are used with nominal data.

While parametric tests assume certain characteristics about a data set, like a normal distribution of scores, these do not apply to nominal data because the data cannot be ordered in any meaningful way.

Chi-square tests are nonparametric statistical tests for categorical variables. The goodness of fit chi-square test can be used on a data set with one variable, while the chi-square test of independence is used on a data set with two variables.

The chi-square goodness of fit test is used when you have gathered data from a single population through random sampling. To measure how representative your sample is, you can use this test to assess whether the frequency distribution of your sample matches what you would expect from the broader population.

With the chi-square test of independence, you can find out whether a relationship between two categorical variables is significant.

Levels of measurement tell you how precisely variables are recorded. There are 4 levels of measurement, which can be ranked from low to high:

  • Nominal : the data can only be categorised.
  • Ordinal : the data can be categorised and ranked.
  • Interval : the data can be categorised and ranked, and evenly spaced.
  • Ratio : the data can be categorised, ranked, evenly spaced and has a natural zero.

Some variables have fixed levels. For example, gender and ethnicity are always nominal level data because they cannot be ranked.

However, for other variables, you can choose the level of measurement . For example, income is a variable that can be recorded on an ordinal or a ratio scale:

  • At an ordinal level , you could create 5 income groupings and code the incomes that fall within them from 1–5.
  • At a ratio level , you would record exact numbers for income.

If you have a choice, the ratio level is always preferable because you can analyse data in more ways. The higher the level of measurement, the more precise your data is.

Nominal and ordinal are two of the four levels of measurement . Nominal level data can only be classified, while ordinal level data can be classified and ordered.

Cite this Scribbr article

If you want to cite this source, you can copy and paste the citation or click the ‘Cite this Scribbr article’ button to automatically add the citation to our free Reference Generator.

Bhandari, P. (2023, January 09). What Is Nominal Data? | Examples & Definition. Scribbr. Retrieved 3 September 2024, from https://www.scribbr.co.uk/stats/nominal-data-meaning/

Is this article helpful?

Pritha Bhandari

Pritha Bhandari

Other students also liked, levels of measurement: nominal, ordinal, interval, ratio, what is ordinal data | examples & definition, what is interval data | examples & definition.

An Introduction to Nominal Variables: Understanding Types of Data

Data analysis involves interpreting data to produce reliable, consistent results. For this process, accurate data measurement is crucial, as it influences the choice of statistical methods and the insights derived, which support strategic decision-making and innovation.

Different data types require specific collection and analysis methods, and understanding data characteristics is essential for exploring distributions, trends, and relationships. Data is categorized into four types: nominal, ordinal, interval, and ratio variables.

This article introduces nominal variables , covering the definition of nominal variables, levels of data measurement, types of nominal variables, methods for analyzing nominal variables, and examples of nominal variables in statistical analysis.

What Are Nominal Variables?

Nominal variable is a type of categorical data that does not possess any quantitative value nor inherent ordering or hierarchy. The categories of nominal variables are mutually exclusive and can be identified as unique labels. This type of data is mainly used in statistical analysis with the objective of providing grouping and classification.

Put simply, a nominal variable is a type of data used to label or categorize things without assigning any numerical value or order. For example, if you're looking at a list of different fruits (like apples, oranges, and bananas), each fruit is a category, and there's no ranking or value assigned to them.

Nominal data is collected through surveys, questionnaires, observations, or existing forms and records. The questions are usually multiple-choice, yes/no, closed-ended, or open-ended.

Examples of Nominal Variables

Below, we’ve included some examples of how nominal variables are collected:

Multiple choice question

Which car brand do you prefer?

Yes/No questions

Do you possess a driving license?

Close-ended questions

Would you recommend your current car brand to others?

a) Extremely likely

d) Unlikely

e) Extremely unlikely

Open-ended questions

What are the best features of your car?

As seen above the answers to the various types of questions will be in the form of words or labels. Analyzing this data can be challenging while collecting responses from a large sample of individuals. However, its applications extend across diverse domains, enabling researchers and stakeholders to make targeted decisions.

Levels of Measurement of Variables

Data analysis can include two types of approaches:

Quantitative data analysis

Quantitative data analysis involves the examination of data that is numeric and tangible in nature. This type of data can be analyzed using straightforward mathematical methods and visualizations. For example, obtaining temperature readings for a week falls under quantitative data analysis.

Qualitative data analysis

Qualitative data analysis focuses on data expressed as labels and descriptions of characteristics. In this approach, patterns and relationships between data variables are analyzed to gain meaningful insights. For instance, analyzing customer purchase behavior over a month is an example of qualitative data analysis.

Nominal and ordinal are classified as qualitative data while interval and ratio are classified as quantitative data. Nominal provides the lowest level of detail while interval and ratio provide the highest level of detail.

Other Types of Variables

Let us briefly look through the characteristics of the other types of data.

Ordinal variables

These are descriptive qualitative data that includes some ordering amongst labels. The main difference between nominal and ordinal data is the presence of hierarchy, which makes ordinal data easier to interpret.

  • Income level can be low, moderate, and high with the understanding that low<moderate<high.
  • Customer feedback can be excellent, good, satisfactory, or poor, with an incremental ordering of poor=1 to excellent=4.

Interval variables

Interval data is quantifiable with equal intervals between data points.

An important characteristic is the absence of a true zero point, which implies that zero is treated as a valid reference point.

  • Measurement of temperature recorded as 0C is an actual temperature, which can be midway on a scale as temperatures can lower into minus values.
  • The difference between any two academic test scores is meaningful, but the value zero does not imply a lack of academic ability.

Ratio variables

Ratio data is similar to interval data in terms of equal distance between values. However, it differs because of the fact that zero value is considered to be absolute below which no meaningful measurements can be obtained. Due to the absence of negative values, ratio data is most suitable for mathematical operations(addition, subtraction, division and multiplication) and precise statistical analysis.

  • The age of an individual, which cannot be zero.
  • Income is measured as a ratio value and zero income represents the absence of earnings. Ratios between the income of two individuals can also be meaningful (income of one is twice that of the other)

Below is a table that summarizes the four data variable types:

Classified

🗸

🗸

🗸

🗸

Ordering

🗸

🗸

🗸

Uniform intervals

🗸

🗸

True zero value

🗸

Different Types of Nominal Variables

Nominal variables are further classified into the following types:

Binary variables

Binary variables typically have only two possible categories, implying that the outcome or response can be only one type.

Do you possess a driving license?

Yes/no

Outcome of a medical investigation of a disease

Positive/negative

Multiple category variables

These variables can have more than two categories. There exists no fixed ordering amongst categories and each type has equal probability of occurrence.

Select your ethnicity

British, Asian, African, American

Specify your marital status

Married, single, divorced, widowed

Ordered nominal variables

Represent a type of nominal variable with categories that have a ranking order. However, the difference between categories may not be uniform or measured accurately.

Would you recommend our product to others?

Extremely likely, likely, neither likely nor unlikely, unlikely, extremely unlikely

(Extremely likely could have the highest score while unlikely would have the lowest)

What is your highest level of qualification?

Less than high school, high school, bachelor’s degree, master’s degree, doctoral degree

(Here, less than high school could have the lowest rank while a doctoral degree would have the highest rank)

Unordered nominal variables

These variables represent categories without any inherent order or hierarchy. Each type has an equal weightage and there is no specific sequencing that exists.

Select your preferred mode of payment

Cash, credit card, debit card, online bank transfer, PayPal

How did you learn about this job opportunity?

LinkedIn, Indeed, Company website, recruitment agency, others

These examples give a clear understanding of the type of nominal variables.

A detailed analysis of categorical data can be done using various library functions available in Python.

Ways to Analyze Nominal Variables

The type of data investigation techniques employed depend on the research problem, data quality, size of the dataset and various other factors.

Some statistical methods of analyzing nominal variables are listed below:

Frequency distribution

Frequency distribution involves identifying various categories and calculating the number of occurrences under each category. This frequency count can be used to understand data trends and patterns.

Central tendency

Central tendency calculates the mode, which identifies the highest-occurring category in the dataset. This value can highlight the most preferred choice or can be used to reveal differences or similarities across distribution of categories.

Chi-Square test

Chi-square tests are statistical tests that determine the association between two categorical variables. The observed frequency of categories is calculated and compared with the expected frequency of the categories obtained under the assumption of independence.

Contingency table analysis

This is a cross-tabulation method of constructing a table with variables representing rows and columns. For each combination of categories, a frequency count of the occurrence is obtained which highlights the relationship between the two categories. You can learn more in our course, Contingency Analysis using R .

Visualization charts

Bar charts and pie charts are highly effective in communicating nominal data distribution in a visually appealing manner. Check out our data visualization cheat sheet to discover more.

These methods can be implemented by learning detailed approaches to statistics for data analysis.

Tools for Analyzing Nominal Variables

When analyzing nominal variables, several powerful Python tools and libraries can assist in data manipulation, visualization, and statistical analysis:

  • Pandas : Ideal for handling and manipulating datasets. Use groupby() and value_counts() to summarize and analyze categorical data.
  • NumPy : Provides fundamental array operations and mathematical functions to support data analysis.
  • Matplotlib : Useful for creating bar charts and pie charts to visualize the distribution of nominal variables.
  • Seaborn : Enhances data visualization with high-level interfaces, making it easy to create informative count plots and categorical plots.
  • SciPy : Offers statistical functions like chi2_contingency( ) to perform chi-square tests and assess relationships between categorical variables.
  • Statsmodels : Facilitates detailed statistical modeling and hypothesis testing, useful for analyzing relationships in categorical data.
  • Scikit-learn : Contains tools for preprocessing data, such as LabelEncoder() , and for conducting machine learning analyses on categorical data.

Examples of Nominal Variables Used in Statistical Analysis

Nominal data is widely used across research and business to uncover relationships and useful patterns from the colossal amount of data generated rapidly.

Some useful examples of nominal variables used in statistics is discussed below:

Demographic surveys

Nominal data collected through survey forms is highly useful in understanding the population composition. By grouping individuals based on these defined categories different needs and preferences can be identified that can aid in effective marketing strategies for launching of new products.

Age bracket

under 18, 18-24, 25-34, 35-44, 45-54, 55-64, 65 & above

Preferred mode of receiving marketing information

email, phone call, sms, promotional ads

Gender

male, female, nonbinary, prefer not to say

Income levels

under £35000, £35,000- £54,999,£55,000- £74,999

above £75,000

Relevant Data Analysis Technique: Chi-Square Test

The Chi-Square test can be used to determine if there is a significant association between two categorical variables.

Understanding customer feedback

Nominal variables can aid businesses in identifying key issues related to customer satisfaction and bring about improvements in services provided.

Based on the different categories of data effective communication can be established through tailored content shared specific to customer groups.

This qualitative customer survey is an effective tool to monitor changing trends, patterns and preferences towards products and services thereby improving customer relationships.

Rating the satisfaction of using the product

excellent, very good, good, average, poor

Usability

very easy, somewhat easy, neutral, somewhat difficult, very difficult

Recommend the product to a friend

very likely, likely, neutral, unlikely, very unlikely

Relevant Data Analysis Technique: Sentiment Analysis

Sentiment analysis helps in categorizing textual feedback into various sentiments like positive, negative, or neutral.

Evaluation of a business

Performance metric can be categorized based on product category, region, time periods to provide a structured approach to analyzing the business performance against competitors or industry benchmarks. Resource allocation based on nominal data helps businesses effectively invest in areas of high returns or draws attention to underperforming sectors.

Rating profit margins

very low, low, average, high, very high

Preferences for resource allocation

sales, marketing, research, operations, customer service, HR

Select revenue growth

exceeded expectations, met expectations, below expectations

Relevant Data Analysis Technique: ANOVA (Analysis of Variance)

ANOVA can be used to compare the means of three or more groups based on nominal variables.

Human resource management

Data can be analyzed to predict future workforce needs based on business growth and identify the most effective recruitment models.

Employee performance can be assessed to reward top performers as well as provide additional training to underperformers.

Talent analytics is also heavily dependent on data to identify critical roles that need to be filled in.

Types of employee benefits

health insurance, retirement plans, bonuses

How inclusive do you perceive the work environment to be?

very inclusive, partly inclusive, not very inclusive, not inclusive at all

Relevant Data Analysis Technique: Logistic Regression

Logistic regression can be used to model the relationship between a binary dependent variable and one or more nominal independent variables.

Medical research

Nominal variables are used in medical research to help identify factors related to occurrence of a disease, analyze patient information and study the overall healthcare system with a goal to improve existing practices or provide new treatment facilities.

Data from healthcare systems can be categorized on the basis of patient details, disease information, diagnostic methods, treatments and outcomes.

Categorize patients based on healthcare insurance

employer-sponsored insurance, individual health plan, medicare, medi-aid, others

Disease classification based on symptoms

fever, cold, runny nose, headache, fatigue, diarrhea

Assessing if healthcare providers have provided adequate care to patients

always, sometimes, rarely, never

Relevant Data Analysis Technique: Crosstab Analysis

Crosstab analysis is used to examine relationships within data that are categorical.

Get Started With Data Analysis

Nominal variables are highly significant in almost every type of data driven application related to business operations, marketing, medical research and many others.

This article gives an overall understanding of nominal variables, their characteristics, types, and examples of usage in different areas of implementation. Each type offers different insights which determine the appropriate statistical methods to be employed.

Next, it would be ideal to learn more about statistics and its uses in the real world through case studies and projects provided by the Introduction to Statistics course. The course can equip you with the skills needed to analyze large datasets and draw useful conclusions.

How are nominal variables different from other data types? .css-18x2vi3{-webkit-flex-shrink:0;-ms-flex-negative:0;flex-shrink:0;height:18px;padding-top:6px;-webkit-transform:rotate(0.5turn) translate(21%, -10%);-moz-transform:rotate(0.5turn) translate(21%, -10%);-ms-transform:rotate(0.5turn) translate(21%, -10%);transform:rotate(0.5turn) translate(21%, -10%);-webkit-transition:-webkit-transform 0.3s cubic-bezier(0.85, 0, 0.15, 1);transition:transform 0.3s cubic-bezier(0.85, 0, 0.15, 1);width:18px;}

A nominal variable is a type of categorical data that does not possess any quantitative value nor inherent ordering or hierarchy. The categories of nominal variables are mutually exclusive and can be identified as unique labels.

What are the different methods of collecting nominal data? .css-167dpqb{-webkit-flex-shrink:0;-ms-flex-negative:0;flex-shrink:0;height:18px;padding-top:6px;-webkit-transform:none;-moz-transform:none;-ms-transform:none;transform:none;-webkit-transition:-webkit-transform 0.3s cubic-bezier(0.85, 0, 0.15, 1);transition:transform 0.3s cubic-bezier(0.85, 0, 0.15, 1);width:18px;}

Nominal data is collected by means of surveys ,questionnaires ,observations or existent forms and records. The questions are usually multiple choice, yes/no, closed ended or open ended .

How can nominal variables be analyzed?

Frequency distribution, central tendency, contingency tables, chi square test and visualization charts are used to analyze nominal variables.

Photo of Shona Afonso

Continue Your Learning Journey Today!

.css-1531qan{-webkit-text-decoration:none;text-decoration:none;color:inherit;} Associate Data Analyst

.css-1531qan{-webkit-text-decoration:none;text-decoration:none;color:inherit;} data engineer, .css-1531qan{-webkit-text-decoration:none;text-decoration:none;color:inherit;} data scientist.

Quantitative vs. Qualitative Data

Data Demystified: Quantitative vs. Qualitative Data

Richie Cotton's photo

Richie Cotton

An Overview of Descriptive Statistics

Data Demystified: An Overview of Descriptive Statistics

The Four Types of Analytics

Data Demystified: The Four Types of Analytics

Data types in excel and their uses: a complete guide.

Laiba Siddiqui's photo

Laiba Siddiqui

An Introduction to Graph Theory

Kurtis Pykes 's photo

Kurtis Pykes

A Comprehensive Introduction to Anomaly Detection

Bex Tuychiev's photo

Bex Tuychiev

hypothesis test nominal data

  • What DataKleenr Can Do For You
  • How DataKleenr Works
  • DataKleenr Credits
  • Ways to Earn
  • What CorrelViz Can Do For You
  • How CorrelViz Works
  • CorrelViz Credits
  • Book a Call
  • The Hive – Home
  • Course Pricing
  • Membership Pricing
  • Members Area
  • Need Help Subscribing? Start Here
  • How To Enrol on Our Courses
  • Log in to The Hive
  • Reset Hive Password
  • The Captain’s Blog
  • Discover Data
  • Discover Stats
  • Discover Visualisation

December 15

What is Nominal Data? Definition, Examples, Analysis & Statistics

Blog, Discover Data

0    comments

Nominal data is one of only 4 types of data in statistics.

Do you know what they all are and what you can do with them?

If you want to know everything there is to know about Nominal data - definitions, examples, analysis and statistics - then you're in the right place.

When you're done here, you'll also want to read this post's sister articles on quantitative data and qualitative data , Ordinal data , Interval data and Ratio data .

For now, though, here is our guide to Nominal data  and how to deal with them...

Disclosure: we may earn an affiliate commission for purchases you make when using the links to products on this page. As an Amazon Affiliate we earn from qualifying purchases.

This post forms part of a series on the 4 types of data in statistics.

For more detail, choose from the options below:

4 Types of Data in Statistics: Introduction

Nominal data, ordinal data, interval data, all 4 types of data compared, statistical hypothesis testing, what is nominal data.

If you want a simple definition of Nominal data, it would be this:

Nominal Data Definition

Nominal data is the statistical data type that has the following characteristics:

Nominal Data - Characteristics

Nominal Data are observed, not measured, are unordered, non-equidistant and have no meaningful zero

We can differentiate between categories based only on their names, hence the title 'nominal' (from the Latin  nomen , meaning 'name').

It it also worth noting that there is a sub-type of Nominal data with only 2 categories called 'dichotomous data'.

What is Nominal Data?

Pin it for later

Need to save this for later?

Pin it to your favourite board  and you can get back to it when you're ready.

Nominal Data Examples

Examples of Nominal data include:

  • Gender (male, female)
  • Nationality (British, American, Spanish,...)
  • Genre/Style (Rock, Hip-Hop, Jazz, Classical,...)
  • Favourite colour (red, green, blue,...)
  • Favourite animal (aarvark, koala, sloth,...)
  • Favourite spelling of 'favourite' (favourite, favorite)

You can see that in each of these examples of Nominal data the categories have no order. See if you can spot in the above examples of Nominal data which of them are dichotomous data, and which are not.

Nominal Data Examples

What Can You Calculate With Nominal Variables?

When Nominal data are used in analysis, they are called Nominal Variables, so that's what we'll call them from here.

The only mathematical or logical operations you can perform on Nominal variables is to say that an observation is (or is not) the same as another ( equality or inequality ), and you can use this information to group them together.

You can't order Nominal data, so you can't sort them. Neither can you do any mathematical operations because they are reserved for numerical data.

Nominal Data - Mathematical Features

For example, you can group people according to their nationalities (British, American, Spanish, etc.), but you can't sort nationalities. The nations may have different sized populations, or different sized land masses but they are different data.

3 Simple Questions...

What's Stopping You Reaching YOUR Data Ninja Potential?

Answer 3 questions and we'll recommend the best route to

super-charge your data career

What Descriptive Statistics Can You Do With Nominal Variables?

With Nominal variables you can calculate the following:

  • Frequencies - count how many you have in each category
  • Proportions - determine how often something happens by dividing the frequency by the total number of events
  • Percentages - transform the proportions to percentages by multiplying by 100
  • Central point - you can determine the most common item by finding the mode (do you remember this from High School classes?).

Other ways of finding the middle of the class, such as median or mean make no sense because ranking is meaningless for nominal variables.

Nominal Data - What Is It, And How Do You Analyse It? Everything You Need To Know (And More) @chi2innovations #dataanalytics #datatypes #statistics

For example, if we have a bag of red, blue and green marbles, let's work out the statistics:

  • Frequencies: 10 red, 15 blue, 5 green
  • Proportions: total = 30, so red proportion is 10/30, blue proportion is 15/30 and green proportion is 5/30
  • Percentages: percentage of red marbles is 100*10/30, blue marbles is 100*15/30 and green is 100*5/30
  • Central point - the mode, the most common, marble in the bag is the blue marble

Learn More About Statistics and Data with These Books:

What data visualisations can you do with nominal variables.

Since the only descriptive statistics you can do with Nominal variables are frequencies, proportions and percentages, the only ways to visualise these are with pie charts and bar charts.

Nominal Data - Stats & Graphs

Nominal Data Make Great Dummy Variables!

So far we've talked about all the things that you can't do with Nominal data, but they have a super power - they make great dummy variables!

Analysing categorical data with various statistical tests can be difficult when they have more than 2 categories, and a common workaround is to transform them into dummy variables.

To create a dummy variable from a Nominal variable, all you do is pick a category of interest and code those data points as 1, then code all other data points as 0.

Technically, dummy variables are dichotomous, quantitative variables, and can take only 2 values, and typically, 1 represents the presence of a qualitative attribute, and 0 represents the absence.

For example, let's say you have the Nominal variable of 'Animal', for which the possible values are Pig, Sheep and Goat.

If you're interested in analysing the Pig data, then you code each instance of Pig as 1, and all other instances as 0.

Similarly with the Sheep and Goat data, like this:

Nominal Data as Dummy Variables

In this example, you might want to check whether your pigs are, on average, heavier than the other animals on your farm. You collect together the 'weight' data for all the instances where Pig=1 and calculate the mean weight. Then you do the same for all Pig=0 data. Now you know whether your pigs are heavier, and you can do the same analysis for your sheep and goats.

What Statistics Can You Do With Nominal Variables?

As well as the simpler descriptive statistics, Nominal variables can also be analysed using advanced statistical methods, such as in hypothesis testing.

In statistical hypothesis testing you compare one variable (or sometimes more) with another to test a hypothesis, a process which is known as 'pairwise testing', and will likely look something like this:

"If I (do this to this variable), then (this will happen to this other variable)".

Examples of this might be:

  • If I increase the amount I water my plants, then my plants will increase in size
  • If I get more than 6 hours of sleep, then my exam results will improve
  • If I drink less coffee before going to bed, then I will fall asleep sooner

Nominal variables can be used in pairwise statistical hypothesis testing, either as one of the variables or both.

For example, you can use Nominal variables in a Fisher's Exact Test or a Chi-Squared Test , where it is tested against other categorical data.

You can also test Nominal variables against numerical data using a 2-sample t-test or an ANOVA.

Nominal Data - Statistical Tests

Ordinal vs Nominal Data - What's The Difference?

Ordinal data and Nominal data are both qualitative data, and the difference between them is that Nominal data can only be classified - arranged into classes or categories - whereas Ordinal data can be classified and ordered.

One of the assumptions of Ordinal data is that although the categories are ordered, they do not have equal intervals.

Dirty Data Dojo - Data Cleaning

UNIQUE VIDEO COURSE

In less than 2 hours

your data can be:

  • Fit-For-Purpose
  • Analysis Ready

Nominal Data: Summary

The basics of statistics, like data collection , data cleaning and data integrity aren't sexy, and as a result are often neglected, and that is also the case with data types.

In my experience, few people that have to do statistics as part of their research know and understand the statistical data types, and as a result struggle to get to grips with what they can and can't do with their data.

That's a shame, because if you know the 4 types of data in statistics you know:

  • How to handle them correctly
  • What you can calculate with them
  • Which descriptive statistics and visualisations are appropriate
  • Which statistical hypothesis tests you can use

In short, data types are a roadmap to doing your entire study properly.

They really are that important!

Hopefully, by now you have a good understanding of what Nominal data are, and what you can do with them.

Nominal Data are observed, not measured. They are unordered, non-equidistant and have no meaningful zero. Their categories are named, and you can group together data points that are the same and separate those that are different.

Nominal data are types of Qualitative data (also known as categorical data), and you cannot perform any mathematical operations on Nominal data.

Now that you know everything there is to know about Nominal data, you might also like to read this post's sister articles on quantitative data and qualitative data , Ordinal data , Interval data and Ratio data .

In the final posts we'll compare each of the 4 types of data and I'll also show you how to choose the correct statistical hypothesis test .

Do you have any questions about Nominal data? Is there something that I've missed out?

Let me know in the comments below - your feedback will help me to improve the post and make learning about data and statistics easier for everybody!

Ever looked at your data and wondered how and where to get started? If you don't know the difference between quantitative data and qualitative data then you're in the right place. Here is our guide to data types and how to deal with them... #datatips #data

data tips, nominal data, qualitative data

You may also like

45+ awesome gifts for data scientists, statisticians and other geeks, computational statistics is the new holy grail – experts, 3 crucial tips for data processing and analysis, correlation is not causation – pirates prove it, cracking chi-square tests: step-by-step, chi-square test: the key to categorical analysis, types of data in statistics, free booklet.

Download your FREE Booklet and learn how to deal with Statistical Data Types - all of them!

Types of Data in Statistics

types of Data in Statistics

Free booklet.

Have you ever looked at your data and wondered how and where to get started?

If you don't know the difference between Quantitative and Qualitative data, or between Ratio, Interval, Ordinal, and Nominal data, then you're in the right place.

Here is our guide to statistical data types and how to deal with them.

hypothesis test nominal data

Nominal Data

Data that is used to label variables without providing quantitative values

What is Nominal Data?

In statistics, nominal data (also known as nominal scale) is a type of data that is used to label variables without providing any quantitative value. It is the simplest form of a scale of measure. Unlike ordinal data , nominal data cannot be ordered and cannot be measured.

Nominal Data

Dissimilar to interval or ratio data, nominal data cannot be manipulated using available mathematical operators. Thus, the only measure of central tendency for such data is the mode.

Characteristics of Nominal Data

Nominal data can be both qualitative and quantitative. However, the quantitative labels lack a numerical value or relationship (e.g., identification number). On the other hand, various types of qualitative data can be represented in nominal form. They may include words, letters, and symbols. Names of people, gender, and nationality are just a few of the most common examples of nominal data.

How to Analyze Nominal Data?

Nominal data can be analyzed using the grouping method. The variables can be grouped together into categories, and for each category, the frequency or percentage can be calculated. The data can also be presented visually, such as by using a pie chart.

Although nominal data cannot be treated using mathematical operators, they still can be analyzed using advanced statistical methods. For example, one way to analyze the data is through hypothesis testing .

For nominal data, hypothesis testing can be carried out using nonparametric tests such as the chi-squared test . The chi-squared test aims to determine whether there is a significant difference between the expected frequency and the observed frequency of the given values.

More Resources

CFI offers the Business Intelligence & Data Analyst (BIDA)®  certification program for those looking to take their careers to the next level. To keep learning and advancing your career, the following CFI resources will be helpful:

  • Basic Statistics Concepts in Finance
  • Independent Events
  • Positively Skewed Distribution
  • Quantitative Analysis
  • See all data science resources
  • Share this article

Excel Fundamentals - Formulas for Finance

Create a free account to unlock this Template

Access and download collection of free Templates to help power your productivity and performance.

Already have an account? Log in

Supercharge your skills with Premium Templates

Take your learning and productivity to the next level with our Premium Templates.

Upgrading to a paid membership gives you access to our extensive collection of plug-and-play Templates designed to power your performance—as well as CFI's full course catalog and accredited Certification Programs.

Already have a Self-Study or Full-Immersion membership? Log in

Access Exclusive Templates

Gain unlimited access to more than 250 productivity Templates, CFI's full course catalog and accredited Certification Programs, hundreds of resources, expert reviews and support, the chance to work with real-world finance and research tools, and more.

Already have a Full-Immersion membership? Log in

[banner]

Summary and Analysis of Extension Program Evaluation in R

Salvatore S. Mangiafico

Search Rcompanion.org

  • Purpose of this Book
  • Author of this Book
  • Statistics Textbooks and Other Resources
  • Why Statistics?
  • Evaluation Tools and Surveys
  • Types of Variables
  • Descriptive Statistics
  • Confidence Intervals
  • Basic Plots
  • Hypothesis Testing and p-values
  • Reporting Results of Data and Analyses
  • Choosing a Statistical Test
  • Independent and Paired Values
  • Introduction to Likert Data
  • Descriptive Statistics for Likert Item Data
  • Descriptive Statistics with the likert Package
  • Confidence Intervals for Medians
  • Converting Numeric Data to Categories
  • Introduction to Traditional Nonparametric Tests
  • One-sample Wilcoxon Signed-rank Test
  • Sign Test for One-sample Data
  • Two-sample Mann–Whitney U Test
  • Mood’s Median Test for Two-sample Data
  • Two-sample Paired Signed-rank Test
  • Sign Test for Two-sample Paired Data
  • Kruskal–Wallis Test
  • Mood’s Median Test
  • Friedman Test
  • Scheirer–Ray–Hare Test
  • Aligned Ranks Transformation ANOVA
  • Nonparametric Regression and Local Regression
  • Nonparametric Regression for Time Series
  • Introduction to Permutation Tests
  • One-way Permutation Test for Ordinal Data
  • One-way Permutation Test for Paired Ordinal Data
  • Permutation Tests for Medians and Percentiles
  • Association Tests for Ordinal Tables
  • Measures of Association for Ordinal Tables
  • Introduction to Linear Models
  • Using Random Effects in Models
  • What are Estimated Marginal Means?
  • Estimated Marginal Means for Multiple Comparisons
  • Factorial ANOVA: Main Effects, Interaction Effects, and Interaction Plots
  • p-values and R-square Values for Models
  • Accuracy and Errors for Models
  • Introduction to Cumulative Link Models (CLM) for Ordinal Data
  • Two-sample Ordinal Test with CLM
  • Two-sample Paired Ordinal Test with CLMM
  • One-way Ordinal Regression with CLM
  • One-way Repeated Ordinal Regression with CLMM
  • Two-way Ordinal Regression with CLM
  • Two-way Repeated Ordinal Regression with CLMM

Introduction to Tests for Nominal Variables

  • Confidence Intervals for Proportions
  • Goodness-of-Fit Tests for Nominal Variables
  • Association Tests for Nominal Variables
  • Measures of Association for Nominal Variables
  • Tests for Paired Nominal Data
  • Cochran–Mantel–Haenszel Test for 3-Dimensional Tables
  • Cochran’s Q Test for Paired Nominal Data
  • Models for Nominal Data
  • Introduction to Parametric Tests
  • One-sample t-test
  • Two-sample t-test
  • Paired t-test
  • One-way ANOVA
  • One-way ANOVA with Blocks
  • One-way ANOVA with Random Blocks
  • Two-way ANOVA
  • Repeated Measures ANOVA
  • Correlation and Linear Regression
  • Advanced Parametric Methods
  • Transforming Data
  • Normal Scores Transformation
  • Regression for Count Data
  • Beta Regression for Percent and Proportion Data
  • An R Companion for the Handbook of Biological Statistics

The tests for nominal variables presented in this book are commonly used.  They might be used to determine if there is an association between two nominal variables (“association tests”), or if counts of observations for a nominal variable match a theoretical set of proportions for that variable (“goodness-of-fit tests”).

Tests of symmetric margins, or marginal homogeneity, can determine if frequencies for one nominal variable are greater than that for another, or if there was a change in frequencies from sampling at one time to another.  These are described here as “tests for paired nominal data.”

For tests of association, a measure of association, or effect size, should be reported.

When contingency tables include one or more ordinal variables, different tests of association are called for. (See Association Tests for Ordinal Tables ).  Effect sizes are specific for these situations. (See Measures of Association for Ordinal Tables .)

As a more advanced approach, models can be specified with nominal dependent variables.  A common type of model with a nominal dependent variable is logistic regression.

Packages used in this chapter

The packages used in this chapter include:

•  ggmosaic

The following commands will install these packages if they are not already installed:

if(!require( tidyr )){install.packages(" tidyr ")} if(!require( ggplot2 )){install.packages(" ggplot2 ")} if(!require( ggmosaic )){install.packages(" ggmosaic ")}

Descriptive statistics and plots for nominal data

Descriptive statistics for nominal data are discussed in the “Descriptive statistics for nominal data” section in the Descriptive Statistics chapter. 

Descriptive plots for nominal data are discussed in the “Examples of basic plots for nominal data” section in the Basic Plots chapter.

Contingency tables and matrices

Nominal data are often arranged in a contingency table of counts of observations for each cell of the table.  For example, if there were 6 males and 4 females reading Sappho, 3 males and 4 females reading Stephen Crane, and 2 males and 5 females reading Judith Viorst, the data could be arranged as:

          Gender           Male    Female

Poet  Sappho   6       4  Crane    3       4  Viorst   2       5

This data can be read into R in the following manner as a matrix.

Matrix = as.matrix(read.table(header=TRUE, row.names=1, text=" Poet     Male    Female Sappho   6       4      Crane    3       4 Viorst   2       5 ")) Matrix

       Male Female Sappho    6      4 Crane     3      4 Viorst    2      5

It is helpful to look at totals for columns and rows.

colSums(Matrix)

  Male Female     11     13

rowSums(Matrix)

Sappho  Crane Viorst     10      7      7

Simple bar charts and mosaic plots are also helpful.

barplot(Matrix,         beside = TRUE,         legend = TRUE,         ylim = c(0, 8),    ### y-axis: used to prevent legend overlapping bars         cex.names = 0.8,  ### Text size for bars         cex.axis = 0.8,   ### Text size for axis         args.legend = list(x   = "topright",   ### Legend location                            cex = 0.8,           ### Legend text size                            bty = "n"))         ### Remove legend box

Matrix.t = t(Matrix)      ### Transpose Matrix for the next plot barplot(Matrix.t,         beside = TRUE,         legend = TRUE,         ylim = c(0, 8),   ### y-axis: used to prevent legend overlapping bars         cex.names = 0.8,  ### Text size for bars         cex.axis = 0.8,   ### Text size for axis         args.legend = list(x   = "topright",   ### Legend location                            cex = 0.8,          ### Legend text size                            bty = "n"))         ### Remove legend box

Mosaic plots

Mosaic plots are very useful for visualizing the association between two nominal variables but can be somewhat tricky to interpret for those unfamiliar with them.  Note that the column width is determined by the number of observations in that category.  In this case, the Sappho column is wider because more students are reading Sappho than the other two poets.  Note, too, that the number of observations in each cell is determined by the area of the cell, not its height.  In this case, the Sappho–Female cell and the Crane–Female cell have the same count (4), and so the same area.  The Crane–Female cell is taller than the Sappho–Female because it is a higher proportion of observations for that author (4 out of 7 Crane readers compared with 4 out of 10 Sappho readers).

mosaicplot(Matrix,            color=TRUE,            cex.axis=0.8)

Working with proportions

It is often useful to look at proportions of counts within nominal tables.

In this example we may want to look at the proportion of each Gender within each Poet .  That is, the proportions in each row of the first table below sum to 1.  This arrangement is indicated with the margin=1 option.

Props = prop.table(Matrix, margin = 1) Props

            Male    Female Sappho 0.6000000 0.4000000 Crane  0.4285714 0.5714286 Viorst 0.2857143 0.7142857

To plot these proportions, we will first transpose the table.

Props.t = t(Props) Props.t

       Sappho     Crane    Viorst Male      0.6 0.4285714 0.2857143 Female    0.4 0.5714286 0.7142857

barplot(Props.t,         beside    = TRUE,         legend    = TRUE,         ylim      = c(0, 1),   ### y-axis: used to prevent legend overlapping bars         cex.names = 0.8,       ### Text size for bars         cex.axis  = 0.8,       ### Text size for axis         col       = c("mediumorchid1","mediumorchid4"),         ylab      = "Proportion within each Poet",         xlab      = "Poet",

        args.legend = list(x   = "topright",   ### Legend location                            cex = 0.8,          ### Legend text size                            bty = "n"))         ### Remove box

Optional analyses: converting among matrices, tables, counts, and cases

In R, most simple analyses for nominal data expect the data to be in a matrix format.  However, data may be in a long format, either with each row representing a single observation ( cases ), or with each row containing a count of observations ( counts ). 

It is relatively easy to convert among these different forms of data.

Long-format with each row as an observation (cases)

Data = read.table(header=TRUE, stringsAsFactors=TRUE, text=" Poet     Gender Sappho   Male Sappho   Male Sappho   Male Sappho   Male Sappho   Male Sappho   Male Sappho   Female Sappho   Female Sappho   Female Sappho   Female Crane    Male Crane    Male Crane    Male Crane    Female Crane    Female Crane    Female Crane    Female Viorst   Male Viorst   Male Viorst   Female Viorst   Female Viorst   Female Viorst   Female Viorst   Female ") ###  Order factors by the order in data frame

###  Otherwise, xtabs will alphabetize them Data$Poet = factor(Data$Poet,                    levels=unique(Data$Poet)) Data$Gender = factor(Data$Gender,                      levels=unique(Data$Gender))

Cases to table

Table = xtabs(~ Poet + Gender,               data=Data) Table

        Gender Poet     Male Female   Sappho    6      4   Crane     3      4   Viorst    2      5

Cases to Counts

     Table = xtabs(~ Poet + Gender,                    data=Data)      Counts = as.data.frame(Table)           Counts

    Poet Gender Freq 1 Sappho   Male    6 2  Crane   Male    3 3 Viorst   Male    2 4 Sappho Female    4 5  Crane Female    4 6 Viorst Female    5

Long-format with counts of observations (counts)

Counts = read.table(header=TRUE, stringsAsFactors=TRUE, text=" Poet     Gender  Freq Sappho   Male     6 Sappho   Female   4 Crane    Male     3 Crane    Female   4 Viorst   Male     2 Viorst   Female   5 ") ###  Order factors by the order in data frame ###  Otherwise, xtabs will alphabetize them Counts$Poet = factor(Counts$Poet,                    levels=unique(Counts$Poet)) Counts$Gender = factor(Counts$Gender,                    levels=unique(Counts$Gender))

Counts to Table

Table = xtabs(Freq ~ Poet + Gender,               data=Counts) Table

Counts to Cases

(Some code taken from Stack Overflow (2011).)

  Long = Counts[rep(row.names(Counts), Counts$Freq), c("Poet", "Gender")]     rownames(Long) = seq(1:nrow(Long))       Long

     Poet Gender 1  Sappho   Male 2  Sappho   Male 3  Sappho   Male 4  Sappho   Male 5  Sappho   Male 6  Sappho   Male 7  Sappho Female 8  Sappho Female 9  Sappho Female 10 Sappho Female 11  Crane   Male 12  Crane   Male 13  Crane   Male 14  Crane Female 15  Crane Female 16  Crane Female 17  Crane Female 18 Viorst   Male 19 Viorst   Male 20 Viorst Female 21 Viorst Female 22 Viorst Female 23 Viorst Female 24 Viorst Female

Counts to Cases with tidyr

Using the uncount function in the tidyr package will make quick work of converting a data frame of counts to cases in long format.

library(tidyr) Long = uncount(Counts, Freq) Long

Matrix form

Matrix to table.

Table = as.table(Matrix) Table

Matrix to counts

Table = as.table(Matrix) Counts = as.data.frame(Table) colnames(Counts) = c("Poet", "Gender", "Freq") Counts

Matrix to Cases

Table = as.table(Matrix) Counts = as.data.frame(Table) colnames(Counts) = c("Poet", "Gender", "Freq") Long = Counts[rep(row.names(Counts), Counts$Freq), c("Poet", "Gender")] rownames(Long) = seq(1:nrow(Long)) Long

     Poet Gender 1  Sappho   Male 2  Sappho   Male 3  Sappho   Male 4  Sappho   Male 5  Sappho   Male 6  Sappho   Male 7   Crane   Male 8   Crane   Male 9   Crane   Male 10 Viorst   Male 11 Viorst   Male 12 Sappho Female 13 Sappho Female 14 Sappho Female 15 Sappho Female 16  Crane Female 17  Crane Female 18  Crane Female 19  Crane Female 20 Viorst Female 21 Viorst Female 22 Viorst Female 23 Viorst Female 24 Viorst Female

Matrix to Cases with tidyr

Table = as.table(Matrix) Counts = as.data.frame(Table) colnames(Counts) = c("Poet", "Gender", "Freq") library(tidyr) Long = uncount(Counts, Freq) rownames(Long) = seq(1:nrow(Long)) Long

Table to matrix

Matrix = as.matrix(Table) Matrix

Optional analyses: obtaining information about a matrix or table object

class(Matrix)

[1] "matrix"

typeof(Matrix)

[1]"integer"

attributes(Matrix)

$dim [1] 3 2 $dimnames $dimnames[[1]] [1] "Sappho" "Crane"  "Viorst" $dimnames[[2]] [1] "Male"   "Female"

str(Matrix)

 int [1:3, 1:2] 6 3 2 4 4 5  - attr(*, "dimnames")=List of 2   ..$ : chr [1:3] "Sappho" "Crane" "Viorst"   ..$ : chr [1:2] "Male" "Female"

colnames(Matrix)

[1] "Male"   "Female"

rownames(Matrix)

[1] "Sappho" "Crane"  "Viorst"

Optional analyses: adding headings to the names of the rows and columns

names(dimnames(Matrix))=c("Poet", "Gender") Matrix

$dim [1] 3 2 $dimnames $dimnames$Poet [1] "Sappho" "Crane"  "Viorst" $dimnames$Gender [1] "Male"   "Female" str(Matrix)

int [1:3, 1:2] 6 3 2 4 4 5  - attr(*, "dimnames")=List of 2   ..$ Poet: chr [1:3] "Sappho" "Crane" "Viorst"   ..$ Gender: chr [1:2] "Male" "Female"

Optional analyses: creating a matrix or table from a vector of values

In the following example, the data are entered by row, and the byrow=TRUE option is used.  Also note that the value for ncol should specify the number of columns so that the matrix is constructed as intended.

The dimnames function is used to specify the row names, column names, and the headings for the rows and columns.  Another example is given using the rownames and colnames functions, which may be easier to parse.

Also note that the 4 , 3 , 2 , and 1 in the first table are the labels for the columns.  I bolded and underlined them in the output to make this a little more clear.  Normally this formatting doesn’t appear in the output.

### Example from Freeman (1965), Table 10.7 Counts = c(52, 28, 40, 34, 7, 9, 16, 10, 8, 4, 10, 9, 12, 6, 7, 5) Courtship = matrix(Counts,                    byrow = TRUE,                    ncol = 4,                    dimnames = list(Preferred.trait = c("Companionability",                                                        "PhysicalAppearance",                                                        "SocialGrace",                                                        "Intelligence"),                                 Family.income = c("4", "3", "2", "1"))) Courtship

                    Family.income Preferred.trait       4  3  2  1   Companionability   52 28 40 34   PhysicalAppearance  7  9 16 10   SocialGrace         8  4 10  9   Intelligence       12  6  7  5

### Example from Freeman (1965), Table 10.6 Counts = c(1, 2, 5, 2, 0, 10, 5, 5, 0, 0, 0, 0, 2, 2, 1, 0, 0, 0, 2, 3) Social = matrix(Counts, byrow=TRUE, ncol=5) Social

     [,1] [,2] [,3] [,4] [,5] [1,]    1    2    5    2    0 [2,]   10    5    5    0    0 [3,]    0    0    2    2    1 [4,]    0    0    0    2    3

rownames(Social) = c("Single", "Married", "Widowed", "Divorced") colnames(Social) = c("5", "4", "3", "2", "1") names(dimnames(Social)) = c("Marital.status", "Social.adjustment") Social

              Social.adjustment Marital.status  5 4 3 2 1       Single    1 2 5 2 0       Married  10 5 5 0 0       Widowed   0 0 2 2 1       Divorced  0 0 0 2 3

Optional analyses: plots with ggplot2

###  Create the data frame as counts Counts = read.table(header=TRUE, stringsAsFactors=TRUE, text=" Poet     Gender  Freq Sappho   Male     6 Sappho   Female   4 Crane    Male     3 Crane    Female   4 Viorst   Male     2 Viorst   Female   5 ") ###  Convert the data frame to long form library(tidyr) Long = uncount(Counts, Freq) rownames(Long) = seq(1:nrow(Long)) ###  Order factors by the order in data frame ###  Otherwise, ggplot will alphabetize them Long$Poet = factor(Long$Poet,                    levels=unique(Long$Poet)) Long$Gender = factor(Long$Gender,                      levels=unique(Long$Gender)) ###  Create the first bar plot of counts library(ggplot2) ggplot(Long, aes(Gender, ..count..)) +   geom_bar(aes(fill = Poet), position = "dodge") +   scale_fill_manual(values=c("blue", "cornflowerblue", "deepskyblue")) +   ylab("Count\n") +   xlab("\nGender") +   theme_bw() +   theme(axis.text.x = element_text(face="bold"),         axis.text.y = element_text(face="bold"))

###  Create the second bar plot of counts ggplot(Long, aes(Poet, ..count..)) +   geom_bar(aes(fill = Gender), position = "dodge") +   scale_fill_manual(values=c("darkseagreen", "seagreen")) +   ylab("Count\n") +   xlab("\nPoet") +   theme_bw() +   theme(axis.text.x = element_text(face="bold"),         axis.text.y = element_text(face="bold"))

###  Create a bar plot with proportions XT = xtabs(~ Gender + Poet, data=Long) Props = prop.table(XT, margin = 2) DataProps = as.data.frame(Props) ggplot(DataProps, aes(x=Poet, y=Freq, fill=Gender)) +   geom_bar(stat="identity", position = "dodge") +   scale_fill_manual(values=c("mediumorchid1","mediumorchid4")) +   ylab("Proportion within each poet\n") +   xlab("\nPoet") +   theme_bw() +   theme(axis.text.x = element_text(face="bold"),         axis.text.y = element_text(face="bold"))

###  Create a mosaic plot library(ggmosaic) ggplot(data = Long) +   geom_mosaic(aes(x = product(Poet), fill = Gender)) +   scale_fill_manual(values=c("darkseagreen", "seagreen")) +   ylab("Gender\n") +   xlab("\nPoet") +   theme_bw() +   theme(axis.text.x = element_text(face="bold"),         axis.text.y = element_text(face="bold"))

Freeman, L.C. 1965. Elementary Applied Statistics for Students in Behavioral Science . Wiley.

Stack Overflow. 2011. “Replicate each row of data.frame and specify the number of replications for each row.” stackoverflow.com/questions/2894775/repeat-each-row-of-data-frame-the-number-of-times-specified-in-a-column .

©2016 by Salvatore S. Mangiafico. Rutgers Cooperative Extension, New Brunswick, NJ.

Non-commercial reproduction of this content, with attribution, is permitted. For-profit reproduction without permission is prohibited.

If you use the code or information in this site in a published work, please cite it as a source.  Also, if you are an instructor and use this book in your course, please let me know.   My contact information is on the About the Author of this Book page.

Mangiafico, S.S. 2016. Summary and Analysis of Extension Program Evaluation in R, version 1.20.07, revised 2024. rcompanion.org/handbook/ . (Pdf version: rcompanion.org/documents/RHandbookProgramEvaluation.pdf .)

University Library

SPSS Tutorial: General Statistics and Hypothesis Testing

  • About This Tutorial
  • SPSS Components
  • Importing Data
  • General Statistics and Hypothesis Testing
  • Further Resources

Merging Files based on a shared variable.

This section and the "Graphics" section provide a quick tutorial for a few common functions in SPSS, primarily to provide the reader with a feel for the SPSS user interface. This is not a comprehensive tutorial, but SPSS itself provides comprehensive tutorials and case studies through it's help menu. SPSS's help menu is more than a quick reference. It provides detailed information on how and when to use SPSS's various menu options. See the "Further Resources" section for more information. 

To perform a one sample t-test click "Analyze"→"Compare Means"→"One Sample T-Test" and the following dialog box will appear:

hypothesis test nominal data

The dialogue allows selection of any scale variable from the box at the left and a test value that represents a hypothetical mean. Select the test variable and set the test value, then press "Ok." Three tables will appear in the Output Viewer:

hypothesis test nominal data

The first table gives descriptive statistics about the variable. The second shows the results of the t_test, including the "t" statistic, the degrees of freedom ("df") the p-value ("Sig."), the difference of the test value from the variable mean, and the upper and lower bounds for a ninety-five percent confidence interval. The final table shows one-sample effect sizes.

One-Way ANOVA

In the Data Editor, select "Analyze"→"Compare Means"→"One-Way ANOVA..." to open the dialog box shown below.

hypothesis test nominal data

To generate the ANOVA statistic the variables chosen cannot have a "Nominal" level of measurement; they must be "ordinal." 

Once the nominal variables have been changed to ordinal, select "the dependent variable and  the factor, then click "OK." The following output will appear in the Output Viewer:

hypothesis test nominal data

Linear Regression

To obtain a linear regression select "Analyze"->"Regression"->"Linear" from the menu, calling up the dialog box shown below:

hypothesis test nominal data

The output of this most basic case produces a summary chart showing R, R-square, and the Standard error of the prediction; an ANOVA chart; and a chart providing statistics on model coefficients:

hypothesis test nominal data

For Multiple regression, simply add more independent variables in the "Linear Regression" dialogue box. To plot a regression line see the "Legacy Dialogues" section of the "Graphics" tab.

Scholarly Commons

Profile Photo

  • << Previous: Importing Data
  • Next: Graphics >>
  • Last Updated: Jul 9, 2024 5:55 PM
  • URL: https://guides.library.illinois.edu/spss

Hypothesis test

Hypothesis tests are statistical test procedures, such as the t-test or an analysis of variance, with which you can test hypotheses based on collected data.

When do I need a hypothesis test?

A hypothesis test is used whenever you want to test a hypothesis about the population with the help of a sample. So whenever you want to prove or say something about the population with a sample, hypothesis tests are used.

Population, sample and hypothesis testing

A possible example would be that the company "My-Muesli" would like to know whether their produced muesli bars really weigh 250g. For this purpose, a random sample is taken and a hypothesis test is then used to draw conclusions about all the muesli bars produced.

Hypothesis Testing

In statistics, hypothesis tests aim to test hypotheses about the population on the basis of sample characteristics.

Hypothesis testing and the null hypothesis

As we know from the previous tutorial on hypotheses , there is always a null and an alternative hypothesis. In "classical" inferential statistics, the null hypothesis is always tested using a hypothesis test. The hypothesis is tested to see if there is no difference or no relationship.

If you want to be 100% accurate, the null hypothesis H0 can only ever be rejected or not rejected using a hypothesis test. The non-rejection of H0 is not a sufficient reason to conclude that H0 is true. Therefore, the wording "H0 was not rejected" is preferable to "H0 was retained."

Briefly anticipating the p-value: if the p-value is less than 0.05, the null hypothesis is rejected; if the p-value is greater than 0.05, it is not rejected.

Why is there a probability of error in a hypothesis test?

Whether an assumption or hypothesis about the population is rejected or not rejected by a hypothesis test can only ever be determined with a certain probability of error. But why does the probability of error exist?

Probability of error

Here is the short answer: each time you take a sample, you of course get a different one, which means that the results are different every time. In the worst case, a sample is taken that happens to deviate very strongly from the population and the wrong statement is made. Therefore there is always a probability of error for every statement or hypothesis.

Level of significance

A hypothesis test can never reject the null hypothesis with absolute certainty. There is always a certain probability of error that the null hypothesis is rejected even though it is actually true. This probability of error is called the significance level or α .

Usually, a significance level of 5% or 1% is set. If a significance level of 5% is set, it means that it is 5% likely to reject the null hypothesis even though it is actually true.

Illustrated by the two-sample t-test , this means that the observed means of two samples have a certain distance to each other. The greater the observed distance between the mean values, the less likely it is that both samples come from the same population. The question now is, at what point is it "unlikely enough" to reject the null hypothesis? If a significance level of 5% is set, at 5% it is "unlikely enough" to reject the null hypothesis.

The probability that two samples are drawn from a population and that they have the observed mean difference, or even a greater one, is indicated by the p-value. Accordingly, if the p-value is less than the significance level, the null hypothesis is rejected; if the p-value is greater than the significance level, the null hypothesis is not rejected.

If, for example, a p-value of 0.04 results, the probability that two groups with an observed mean distance or an even greater distance come from the same population is 4%. The p-value is thus less than the significance level of 5% and thus the null hypothesis is rejected.

It is important to note that the significance level is always set before the test and may not be changed afterwards in order to obtain the "desired" statement after all. To ensure a certain degree of comparability, the significance level is usually 5% or 1%.

  • α ≤ 0.01 highly significant (h.s.)
  • α ≤ 0.05 significant (s.)
  • α > 0.05 not significant (n.s.)

Example Significance level and p-value

H0: Men and women in Austria do not differ in their average monthly net income.

To test this hypothesis, a significance level of 5% is set and a survey is conducted asking 600 women and 600 men about their monthly net income. An independent t-test gives a p-value of 0.04

The p-value 0.04 is less than the significance level of 0.05, thus we rejecting the null hypothesis. Based on the data collected, we have sufficient evidence that there is a statistically significant difference in average monthly next income for the population of men and women in Austria.

Types of errors

Because a hypothesis can only be rejected with a certain probability, different types of errors occur. Due to the sample selection, it can happen that the null hypothesis is rejected by chance, although in reality there is no difference, i.e. the null hypothesis is valid. Conversely, the result of the hypothesis test can also be that the null hypothesis is not rejected, although in reality there is a difference and thus the alternative hypothesis is actually true.

Accordingly, there are two types of errors in hypothesis testing:

  • Type 1 error: If the alternative hypothesis is accepted although the null hypothesis is valid.
  • Type 2 error: If the null hypothesis is not rejected although the alternative hypothesis applies.

Overall, the following cases arise:

Types of errors hypothesis test

Significance vs effect size

We now know that we usually accept the alternative hypothesis when the p-value is less than 0.05. We then assume that there is an effect , e.g., a difference between two groups.

However, it is important to keep in mind that just because an effect is statistically significant does not mean that the effect is relevant.

If a very large sample is taken and the sample has a very small spread, even a very small difference between two groups may be significant, but it may not be relevant to you.

A company sells frozen pizza and wants to test whether higher quality packaging leads to increased sales.

Based on the data collected, it shows that the p-value is less than 0.05 and therefore there is a statistically significant increase.

So the company can assume that the higher quality packaging will increase the sales statistically significant. It is less than 5% probable that this increase or an even greater increase would occur if the packaging had no influence.

But now the question is whether the increase is also economically relevant. It may be that the income from the increased sales figures does not compensate for the higher costs of the packaging.

Therefore, one should always consider both whether an effect is significant and whether the effect is relevant at all.

How do I find the right hypothesis test

In order to test hypotheses, various test procedures are available. On the one hand, these are divided according to the levels of measurement of the sample

  • Nominal scale
  • Ordinal scale
  • Metric scale

and, on the other hand, how many samples are present and how the samples are related to each other.

DATAtab helps you to find the right test, you just need to select the data you want to evaluate. Depending on the scale level of your data, DATAtab will suggest the appropriate test.

Find hypothesis test

Depending on which variables are selected, is calculated:

  • t-test one sample
  • t-test independent samples
  • t-test dependent samples
  • Chi Square-Test
  • Binomial test
  • ANOVA with/without rep. measures
  • 2 way ANOVA with/without rep. measures
  • Wilcoxon-Test
  • Mann-Whitney U-Test
  • Friedman Test
  • Kruskal-Wallis Test

The following table lists the relevant test procedures. If you know the scale level of the variables in your hypothesis, you can see in the table which test could fit!

Level of measurement
nominal ordinal metric
1 x nominal
1 x metric
1 x or 2 x nominal
1 x nominal with two categories 1 x metric
1 x nominal with two categories 1 x ordinal
1 x nominal with more than two categories 1 x metric
1 x nominal with more than two categories 1 x ordinal
2 x metric
2 x ordinal
1 x nominal with two categories 1 x metric
2 x metric
2 x ordinal
more than 2 x metric
more than 2 x ordinal

If a correlation hypothesis is to be tested, a correlation analysis is calculated. Either the Pearson correlation or the Spearman correlation is then used here.

Examples of hypothesis testing

Independent sample t-test.

Is there a difference in the average number of burglaries (dependent variable) in houses with and without alarm systems (independent variable with 2 groups)?

Paired t-test

Does the consumption of cigarettes have a negative effect on the blood pressure? (Before and after measurement)

People living in small, medium or large cities (independent variable with three groups) differ in their health awareness (dependent variable).

Statistics made easy

  • many illustrative examples
  • ideal for exams and theses
  • statistics made easy on 412 pages
  • 5rd revised edition (April 2024)
  • Only 8.99 €

Datatab

"Super simple written"

"It could not be simpler"

"So many helpful examples"

Statistics Calculator

Cite DATAtab: DATAtab Team (2024). DATAtab: Online Statistics Calculator. DATAtab e.U. Graz, Austria. URL https://datatab.net

Hypothesis Tests in R

This tutorial covers basic hypothesis testing in R.

  • Normality tests
  • Shapiro-Wilk normality test
  • Kolmogorov-Smirnov test
  • Comparing central tendencies: Tests with continuous / discrete data
  • One-sample t-test : Normally-distributed sample vs. expected mean
  • Two-sample t-test : Two normally-distributed samples
  • Wilcoxen rank sum : Two non-normally-distributed samples
  • Weighted two-sample t-test : Two continuous samples with weights
  • Comparing proportions: Tests with categorical data
  • Chi-squared goodness of fit test : Sampled frequencies of categorical values vs. expected frequencies
  • Chi-squared independence test : Two sampled frequencies of categorical values
  • Weighted chi-squared independence test : Two weighted sampled frequencies of categorical values
  • Comparing multiple groups: Tests with categorical and continuous / discrete data
  • Analysis of Variation (ANOVA) : Normally-distributed samples in groups defined by categorical variable(s)
  • Kruskal-Wallace One-Way Analysis of Variance : Nonparametric test of the significance of differences between two or more groups

Hypothesis Testing

Science is "knowledge or a system of knowledge covering general truths or the operation of general laws especially as obtained and tested through scientific method" (Merriam-Webster 2022) .

The idealized world of the scientific method is question-driven , with the collection and analysis of data determined by the formulation of research questions and the testing of hypotheses. Hypotheses are tentative assumptions about what the answers to your research questions may be.

  • Formulate questions: How can I understand some phenomenon?
  • Literature review: What does existing research say about my questions?
  • Formulate hypotheses: What do I think the answers to my questions will be?
  • Collect data: What data can I gather to test my hypothesis?
  • Test hypotheses: Does the data support my hypothesis?
  • Communicate results: Who else needs to know about this?
  • Formulate questions: Frame missing knowledge about a phenomenon as research question(s).
  • Literature review: A literature review is an investigation of what existing research says about the phenomenon you are studying. A thorough literature review is essential to identify gaps in existing knowledge you can fill, and to avoid unnecessarily duplicating existing research.
  • Formulate hypotheses: Develop possible answers to your research questions.
  • Collect data: Acquire data that supports or refutes the hypothesis.
  • Test hypotheses: Run tools to determine if the data corroborates the hypothesis.
  • Communicate results: Share your findings with the broader community that might find them useful.

While the process of knowledge production is, in practice, often more iterative than this waterfall model, the testing of hypotheses is usually a fundamental element of scientific endeavors involving quantitative data.

hypothesis test nominal data

The Problem of Induction

The scientific method looks to the past or present to build a model that can be used to infer what will happen in the future. General knowledge asserts that given a particular set of conditions, a particular outcome will or is likely to occur.

The problem of induction is that we cannot be 100% certain that what we are assuming is a general principle is not, in fact, specific to the particular set of conditions when we made our empirical observations. We cannot prove that that such principles will hold true under future conditions or different locations that we have not yet experienced (Vickers 2014) .

The problem of induction is often associated with the 18th-century British philosopher David Hume . This problem is especially vexing in the study of human beings, where behaviors are a function of complex social interactions that vary over both space and time.

hypothesis test nominal data

Falsification

One way of addressing the problem of induction was proposed by the 20th-century Viennese philosopher Karl Popper .

Rather than try to prove a hypothesis is true, which we cannot do because we cannot know all possible situations that will arise in the future, we should instead concentrate on falsification , where we try to find situations where a hypothesis is false. While you cannot prove your hypothesis will always be true, you only need to find one situation where the hypothesis is false to demonstrate that the hypothesis can be false (Popper 1962) .

If a hypothesis is not demonstrated to be false by a particular test, we have corroborated that hypothesis. While corroboration does not "prove" anything with 100% certainty, by subjecting a hypothesis to multiple tests that fail to demonstrate that it is false, we can have increasing confidence that our hypothesis reflects reality.

hypothesis test nominal data

Null and Alternative Hypotheses

In scientific inquiry, we are often concerned with whether a factor we are considering (such as taking a specific drug) results in a specific effect (such as reduced recovery time).

To evaluate whether a factor results in an effect, we will perform an experiment and / or gather data. For example, in a clinical drug trial, half of the test subjects will be given the drug, and half will be given a placebo (something that appears to be the drug but is actually a neutral substance).

hypothesis test nominal data

Because the data we gather will usually only be a portion (sample) of total possible people or places that could be affected (population), there is a possibility that the sample is unrepresentative of the population. We use a statistical test that considers that uncertainty when assessing whether an effect is associated with a factor.

  • Statistical testing begins with an alternative hypothesis (H 1 ) that states that the factor we are considering results in a particular effect. The alternative hypothesis is based on the research question and the type of statistical test being used.
  • Because of the problem of induction , we cannot prove our alternative hypothesis. However, under the concept of falsification , we can evaluate the data to see if there is a significant probability that our data falsifies our alternative hypothesis (Wilkinson 2012) .
  • The null hypothesis (H 0 ) states that the factor has no effect. The null hypothesis is the opposite of the alternative hypothesis. The null hypothesis is what we are testing when we perform a hypothesis test.

hypothesis test nominal data

The output of a statistical test like the t-test is a p -value. A p -value is the probability that any effects we see in the sampled data are the result of random sampling error (chance).

  • If a p -value is greater than the significance level (0.05 for 5% significance) we fail to reject the null hypothesis since there is a significant possibility that our results falsify our alternative hypothesis.
  • If a p -value is lower than the significance level (0.05 for 5% significance) we reject the null hypothesis and have corroborated (provided evidence for) our alternative hypothesis.

The calculation and interpretation of the p -value goes back to the central limit theorem , which states that random sampling error has a normal distribution.

hypothesis test nominal data

Using our example of a clinical drug trial, if the mean recovery times for the two groups are close enough together that there is a significant possibility ( p > 0.05) that the recovery times are the same (falsification), we fail to reject the null hypothesis.

hypothesis test nominal data

However, if the mean recovery times for the two groups are far enough apart that the probability they are the same is under the level of significance ( p < 0.05), we reject the null hypothesis and have corroborated our alternative hypothesis.

hypothesis test nominal data

Significance means that an effect is "probably caused by something other than mere chance" (Merriam-Webster 2022) .

  • The significance level (α) is the threshold for significance and, by convention, is usually 5%, 10%, or 1%, which corresponds to 95% confidence, 90% confidence, or 99% confidence, respectively.
  • A factor is considered statistically significant if the probability that the effect we see in the data is a result of random sampling error (the p -value) is below the chosen significance level.
  • A statistical test is used to evaluate whether a factor being considered is statistically significant (Gallo 2016) .

Type I vs. Type II Errors

Although we are making a binary choice between rejecting and failing to reject the null hypothesis, because we are using sampled data, there is always the possibility that the choice we have made is an error.

There are two types of errors that can occur in hypothesis testing.

  • Type I error (false positive) occurs when a low p -value causes us to reject the null hypothesis, but the factor does not actually result in the effect.
  • Type II error (false negative) occurs when a high p -value causes us to fail to reject the null hypothesis, but the factor does actually result in the effect.

The numbering of the errors reflects the predisposition of the scientific method to be fundamentally skeptical . Accepting a fact about the world as true when it is not true is considered worse than rejecting a fact about the world that actually is true.

hypothesis test nominal data

Statistical Significance vs. Importance

When we fail to reject the null hypothesis, we have found information that is commonly called statistically significant . But there are multiple challenges with this terminology.

First, statistical significance is distinct from importance (NIST 2012) . For example, if sampled data reveals a statistically significant difference in cancer rates, that does not mean that the increased risk is important enough to justify expensive mitigation measures. All statistical results require critical interpretation within the context of the phenomenon being observed. People with different values and incentives can have different interpretations of whether statistically significant results are important.

Second, the use of 95% probability for defining confidence intervals is an arbitrary convention. This creates a good vs. bad binary that suggests a "finality and certitude that are rarely justified." Alternative approaches like Beyesian statistics that express results as probabilities can offer more nuanced ways of dealing with complexity and uncertainty (Clayton 2022) .

Science vs. Non-science

Not all ideas can be falsified, and Popper uses the distinction between falsifiable and non-falsifiable ideas to make a distinction between science and non-science. In order for an idea to be science it must be an idea that can be demonstrated to be false.

While Popper asserts there is still value in ideas that are not falsifiable, such ideas are not science in his conception of what science is. Such non-science ideas often involve questions of subjective values or unseen forces that are complex, amorphous, or difficult to objectively observe.

Falsifiable
(Science)
Non-Falsifiable
(Non-Science)
Murder death rates by firearms tend to be higher in countries with higher gun ownership rates Murder is wrong
Marijuana users may be more likely than nonusers to The benefits of marijuana outweigh the risks
Job candidates who meaningfully research the companies they are interviewing with have higher success rates Prayer improves success in job interviews

Example Data

As example data, this tutorial will use a table of anonymized individual responses from the CDC's Behavioral Risk Factor Surveillance System . The BRFSS is a "system of health-related telephone surveys that collect state data about U.S. residents regarding their health-related risk behaviors, chronic health conditions, and use of preventive services" (CDC 2019) .

A CSV file with the selected variables used in this tutorial is available here and can be imported into R with read.csv() .

Guidance on how to download and process this data directly from the CDC website is available here...

Variable Types

The publicly-available BRFSS data contains a wide variety of discrete, ordinal, and categorical variables. Variables often contain special codes for non-responsiveness or missing (NA) values. Examples of how to clean these variables are given here...

The BRFSS has a codebook that gives the survey questions associated with each variable, and the way that responses are encoded in the variable values.

hypothesis test nominal data

Normality Tests

Tests are commonly divided into two groups depending on whether they are built on the assumption that the continuous variable has a normal distribution.

  • Parametric tests presume a normal distribution.
  • Non-parametric tests can work with normal and non-normal distributions.

The distinction between parametric and non-parametric techniques is especially important when working with small numbers of samples (less than 40 or so) from a larger population.

The normality tests given below do not work with large numbers of values, but with many statistical techniques, violations of normality assumptions do not cause major problems when large sample sizes are used. (Ghasemi and Sahediasi 2012) .

The Shapiro-Wilk Normality Test

  • Data: A continuous or discrete sampled variable
  • R Function: shapiro.test()
  • Null hypothesis (H 0 ): The population distribution from which the sample is drawn is not normal
  • History: Samuel Sanford Shapiro and Martin Wilk (1965)

This is an example with random values from a normal distribution.

This is an example with random values from a uniform (non-normal) distribution.

The Kolmogorov-Smirnov Test

The Kolmogorov-Smirnov is a more-generalized test than the Shapiro-Wilks test that can be used to test whether a sample is drawn from any type of distribution.

  • Data: A continuous or discrete sampled variable and a reference probability distribution
  • R Function: ks.test()
  • Null hypothesis (H 0 ): The population distribution from which the sample is drawn does not match the reference distribution
  • History: Andrey Kolmogorov (1933) and Nikolai Smirnov (1948)
  • pearson.test() The Pearson Chi-square Normality Test from the nortest library. Lower p-values (closer to 0) means to reject the reject the null hypothesis that the distribution IS normal.

Modality Tests of Samples

Comparing two central tendencies: tests with continuous / discrete data, one sample t-test (two-sided).

The one-sample t-test tests the significance of the difference between the mean of a sample and an expected mean.

  • Data: A continuous or discrete sampled variable and a single expected mean (μ)
  • Parametric (normal distributions)
  • R Function: t.test()
  • Null hypothesis (H 0 ): The means of the sampled distribution matches the expected mean.
  • History: William Sealy Gosset (1908)

t = ( Χ - μ) / (σ̂ / √ n )

  • t : The value of t used to find the p-value
  • Χ : The sample mean
  • μ: The population mean
  • σ̂: The estimate of the standard deviation of the population (usually the stdev of the sample
  • n : The sample size

T-tests should only be used when the population is at least 20 times larger than its respective sample. If the sample size is too large, the low p-value makes the insignificant look significant. .

For example, we test a hypothesis that the mean weight in IL in 2020 is different than the 2005 continental mean weight.

Walpole et al. (2012) estimated that the average adult weight in North America in 2005 was 178 pounds. We could presume that Illinois is a comparatively normal North American state that would follow the trend of both increased age and increased weight (CDC 2021) .

hypothesis test nominal data

The low p-value leads us to reject the null hypothesis and corroborate our alternative hypothesis that mean weight changed between 2005 and 2020 in Illinois.

One Sample T-Test (One-Sided)

Because we were expecting an increase, we can modify our hypothesis that the mean weight in 2020 is higher than the continental weight in 2005. We can perform a one-sided t-test using the alternative="greater" parameter.

The low p-value leads us to again reject the null hypothesis and corroborate our alternative hypothesis that mean weight in 2020 is higher than the continental weight in 2005.

Note that this does not clearly evaluate whether weight increased specifically in Illinois, or, if it did, whether that was caused by an aging population or decreasingly healthy diets. Hypotheses based on such questions would require more detailed analysis of individual data.

Although we can see that the mean cancer incidence rate is higher for counties near nuclear plants, there is the possiblity that the difference in means happened by accident and the nuclear plants have nothing to do with those higher rates.

The t-test allows us to test a hypothesis. Note that a t-test does not "prove" or "disprove" anything. It only gives the probability that the differences we see between two areas happened by chance. It also does not evaluate whether there are other problems with the data, such as a third variable, or inaccurate cancer incidence rate estimates.

hypothesis test nominal data

Note that this does not prove that nuclear power plants present a higher cancer risk to their neighbors. It simply says that the slightly higher risk is probably not due to chance alone. But there are a wide variety of other other related or unrelated social, environmental, or economic factors that could contribute to this difference.

Box-and-Whisker Chart

One visualization commonly used when comparing distributions (collections of numbers) is a box-and-whisker chart. The boxes show the range of values in the middle 25% to 50% to 75% of the distribution and the whiskers show the extreme high and low values.

hypothesis test nominal data

Although Google Sheets does not provide the capability to create box-and-whisker charts, Google Sheets does have candlestick charts , which are similar to box-and-whisker charts, and which are normally used to display the range of stock price changes over a period of time.

This video shows how to create a candlestick chart comparing the distributions of cancer incidence rates. The QUARTILE() function gets the values that divide the distribution into four equally-sized parts. This shows that while the range of incidence rates in the non-nuclear counties are wider, the bulk of the rates are below the rates in nuclear counties, giving a visual demonstration of the numeric output of our t-test.

While categorical data can often be reduced to dichotomous data and used with proportions tests or t-tests, there are situations where you are sampling data that falls into more than two categories and you would like to make hypothesis tests about those categories. This tutorial describes a group of tests that can be used with that type of data.

Two-Sample T-Test

When comparing means of values from two different groups in your sample, a two-sample t-test is in order.

The two-sample t-test tests the significance of the difference between the means of two different samples.

  • Two normally-distributed, continuous or discrete sampled variables, OR
  • A normally-distributed continuous or sampled variable and a parallel dichotomous variable indicating what group each of the values in the first variable belong to
  • Null hypothesis (H 0 ): The means of the two sampled distributions are equal.

For example, given the low incomes and delicious foods prevalent in Mississippi, we might presume that average weight in Mississippi would be higher than in Illinois.

hypothesis test nominal data

We test a hypothesis that the mean weight in IL in 2020 is less than the 2020 mean weight in Mississippi.

The low p-value leads us to reject the null hypothesis and corroborate our alternative hypothesis that mean weight in Illinois is less than in Mississippi.

While the difference in means is statistically significant, it is small (182 vs. 187), which should lead to caution in interpretation that you avoid using your analysis simply to reinforce unhelpful stigmatization.

Wilcoxen Rank Sum Test (Mann-Whitney U-Test)

The Wilcoxen rank sum test tests the significance of the difference between the means of two different samples. This is a non-parametric alternative to the t-test.

  • Data: Two continuous sampled variables
  • Non-parametric (normal or non-normal distributions)
  • R Function: wilcox.test()
  • Null hypothesis (H 0 ): For randomly selected values X and Y from two populations, the probability of X being greater than Y is equal to the probability of Y being greater than X.
  • History: Frank Wilcoxon (1945) and Henry Mann and Donald Whitney (1947)

The test is is implemented with the wilcox.test() function.

  • When the test is performed on one sample in comparison to an expected value around which the distribution is symmetrical (μ), the test is known as a Mann-Whitney U test .
  • When the test is performed to compare two samples, the test is known as a Wilcoxon rank sum test .

For this example, we will use AVEDRNK3: During the past 30 days, on the days when you drank, about how many drinks did you drink on the average?

  • 1 - 76: Number of drinks
  • 77: Don’t know/Not sure
  • 99: Refused
  • NA: Not asked or Missing

The histogram clearly shows this to be a non-normal distribution.

hypothesis test nominal data

Continuing the comparison of Illinois and Mississippi from above, we might presume that with all that warm weather and excellent food in Mississippi, they might be inclined to drink more. The means of average number of drinks per month seem to suggest that Mississippians do drink more than Illinoians.

We can test use wilcox.test() to test a hypothesis that the average amount of drinking in Illinois is different than in Mississippi. Like the t-test, the alternative can be specified as two-sided or one-sided, and for this example we will test whether the sampled Illinois value is indeed less than the Mississippi value.

The low p-value leads us to reject the null hypothesis and corroborates our hypothesis that average drinking is lower in Illinois than in Mississippi. As before, this tells us nothing about why this is the case.

Weighted Two-Sample T-Test

The downloadable BRFSS data is raw, anonymized survey data that is biased by uneven geographic coverage of survey administration (noncoverage) and lack of responsiveness from some segments of the population (nonresponse). The X_LLCPWT field (landline, cellphone weighting) is a weighting factor added by the CDC that can be assigned to each response to compensate for these biases.

The wtd.t.test() function from the weights library has a weights parameter that can be used to include a weighting factor as part of the t-test.

Comparing Proportions: Tests with Categorical Data

Chi-squared goodness of fit.

  • Tests the significance of the difference between sampled frequencies of different values and expected frequencies of those values
  • Data: A categorical sampled variable and a table of expected frequencies for each of the categories
  • R Function: chisq.test()
  • Null hypothesis (H 0 ): The relative proportions of categories in one variable are different from the expected proportions
  • History: Karl Pearson (1900)
  • Example Question: Are the voting preferences of voters in my district significantly different from the current national polls?

For example, we test a hypothesis that smoking rates changed between 2000 and 2020.

In 2000, the estimated rate of adult smoking in Illinois was 22.3% (Illinois Department of Public Health 2004) .

The variable we will use is SMOKDAY2: Do you now smoke cigarettes every day, some days, or not at all?

  • 1: Current smoker - now smokes every day
  • 2: Current smoker - now smokes some days
  • 3: Not at all
  • 7: Don't know
  • NA: Not asked or missing - NA is used for people who have never smoked

We subset only yes/no responses in Illinois and convert into a dummy variable (yes = 1, no = 0).

The listing of the table as percentages indicates that smoking rates were halved between 2000 and 2020, but since this is sampled data, we need to run a chi-squared test to make sure the difference can't be explained by the randomness of sampling.

In this case, the very low p-value leads us to reject the null hypothesis and corroborates the alternative hypothesis that smoking rates changed between 2000 and 2020.

Chi-Squared Contingency Analysis / Test of Independence

  • Tests the significance of the difference between frequencies between two different groups
  • Data: Two categorical sampled variables
  • Null hypothesis (H 0 ): The relative proportions of one variable are independent of the second variable.

We can also compare categorical proportions between two sets of sampled categorical variables.

The chi-squared test can is used to determine if two categorical variables are independent. What is passed as the parameter is a contingency table created with the table() function that cross-classifies the number of rows that are in the categories specified by the two categorical variables.

The null hypothesis with this test is that the two categories are independent. The alternative hypothesis is that there is some dependency between the two categories.

For this example, we can compare the three categories of smokers (daily = 1, occasionally = 2, never = 3) across the two categories of states (Illinois and Mississippi).

hypothesis test nominal data

The low p-value leads us to reject the null hypotheses that the categories are independent and corroborates our hypotheses that smoking behaviors in the two states are indeed different.

p-value = 1.516e-09

Weighted Chi-Squared Contingency Analysis

As with the weighted t-test above, the weights library contains the wtd.chi.sq() function for incorporating weighting into chi-squared contingency analysis.

As above, the even lower p-value leads us to again reject the null hypothesis that smoking behaviors are independent in the two states.

Suppose that the Macrander campaign would like to know how partisan this election is. If people are largely choosing to vote along party lines, the campaign will seek to get their base voters out to the polls. If people are splitting their ticket, the campaign may focus their efforts more broadly.

In the example below, the Macrander campaign took a small poll of 30 people asking who they wished to vote for AND what party they most strongly affiliate with.

The output of table() shows fairly strong relationship between party affiliation and candidates. Democrats tend to vote for Macrander, while Republicans tend to vote for Stewart, while independents all vote for Miller.

This is reflected in the very low p-value from the chi-squared test. This indicates that there is a very low probability that the two categories are independent. Therefore we reject the null hypothesis.

In contrast, suppose that the poll results had showed there were a number of people crossing party lines to vote for candidates outside their party. The simulated data below uses the runif() function to randomly choose 50 party names.

The contingency table() shows no clear relationship between party affiliation and candidate. This is validated quantitatively by the chi-squared test. The fairly high p-value of 0.4018 indicates a 40% chance that the two categories are independent. Therefore, we fail to reject the null hypothesis and the campaign should focus their efforts on the broader electorate.

The warning message given by the chisq.test() function indicates that the sample size is too small to make an accurate analysis. The simulate.p.value = T parameter adds Monte Carlo simulation to the test to improve the estimation and get rid of the warning message. However, the best way to get rid of this message is to get a larger sample.

Comparing Categorical and Continuous Variables

Analysis of variation (anova).

Analysis of Variance (ANOVA) is a test that you can use when you have a categorical variable and a continuous variable. It is a test that considers variability between means for different categories as well as the variability of observations within groups.

There are a wide variety of different extensions of ANOVA that deal with covariance (ANCOVA), multiple variables (MANOVA), and both of those together (MANCOVA). These techniques can become quite complicated and also assume that the values in the continuous variables have a normal distribution.

  • Data: One or more categorical (independent) variables and one continuous (dependent) sampled variable
  • R Function: aov()
  • Null hypothesis (H 0 ): There is no difference in means of the groups defined by each level of the categorical (independent) variable
  • History: Ronald Fisher (1921)
  • Example Question: Do low-, middle- and high-income people vary in the amount of time they spend watching TV?

As an example, we look at the continuous weight variable (WEIGHT2) split into groups by the eight income categories in INCOME2: Is your annual household income from all sources?

  • 1: Less than $10,000
  • 2: $10,000 to less than $15,000
  • 3: $15,000 to less than $20,000
  • 4: $20,000 to less than $25,000
  • 5: $25,000 to less than $35,000
  • 6: $35,000 to less than $50,000
  • 7: $50,000 to less than $75,000)
  • 8: $75,000 or more

The barplot() of means does show variation among groups, although there is no clear linear relationship between income and weight.

hypothesis test nominal data

To test whether this variation could be explained by randomness in the sample, we run the ANOVA test.

The low p-value leads us to reject the null hypothesis that there is no difference in the means of the different groups, and corroborates the alternative hypothesis that mean weights differ based on income group.

However, it gives us no clear model for describing that relationship and offers no insights into why income would affect weight, especially in such a nonlinear manner.

Suppose you are performing research into obesity in your city. You take a sample of 30 people in three different neighborhoods (90 people total), collecting information on health and lifestyle. Two variables you collect are height and weight so you can calculate body mass index . Although this index can be misleading for some populations (notably very athletic people), ordinary sedentary people can be classified according to BMI:

Average BMI in the US from 2007-2010 was around 28.6 and rising, standard deviation of around 5 .

You would like to know if there is a difference in BMI between different neighborhoods so you can know whether to target specific neighborhoods or make broader city-wide efforts. Since you have more than two groups, you cannot use a t-test().

Kruskal-Wallace One-Way Analysis of Variance

A somewhat simpler test is the Kruskal-Wallace test which is a nonparametric analogue to ANOVA for testing the significance of differences between two or more groups.

  • R Function: kruskal.test()
  • Null hypothesis (H 0 ): The samples come from the same distribution.
  • History: William Kruskal and W. Allen Wallis (1952)

For this example, we will investigate whether mean weight varies between the three major US urban states: New York, Illinois, and California.

hypothesis test nominal data

To test whether this variation could be explained by randomness in the sample, we run the Kruskal-Wallace test.

The low p-value leads us to reject the null hypothesis that the samples come from the same distribution. This corroborates the alternative hypothesis that mean weights differ based on state.

A convienent way of visualizing a comparison between continuous and categorical data is with a box plot , which shows the distribution of a continuous variable across different groups:

hypothesis test nominal data

A percentile is the level at which a given percentage of the values in the distribution are below: the 5th percentile means that five percent of the numbers are below that value.

The quartiles divide the distribution into four parts. 25% of the numbers are below the first quartile. 75% are below the third quartile. 50% are below the second quartile, making it the median.

Box plots can be used with both sampled data and population data.

The first parameter to the box plot is a formula: the continuous variable as a function of (the tilde) the second variable. A data= parameter can be added if you are using variables in a data frame.

The chi-squared test can be used to determine if two categorical variables are independent of each other.

Stack Exchange Network

Stack Exchange network consists of 183 Q&A communities including Stack Overflow , the largest, most trusted online community for developers to learn, share their knowledge, and build their careers.

Q&A for work

Connect and share knowledge within a single location that is structured and easy to search.

What is the concepts of nominal and actual significance level?

Although I understood these concepts about five years ago, I totally forgot the notion and cannot find that in Google.

  • hypothesis-testing
  • statistical-significance

M.C. Park's user avatar

Note: I suspect that there are at least two different meanings of "actual significance level" around, but here's one that makes sense to me:

The nominal significance level is the significance level a test is designed to achieve. This is very often 5% or 1%. Now in many situations the nominal significance level can't be achieved precisely. This can happen because the distribution is discrete and doesn't allow for a precise given rejection probability, and/or because the theory behind the test is asymptotic, i.e., the nominal level is only achieved for $n\to\infty$ .

Here's an example. We toss a coin 5 times and we want to test at nominal 5% level whether it's biased in favour of "heads". The probability for five times heads is 1/32<0.05, the probability for four times heads is 5/32>0.05. We can't reject for four heads because then we go beyond the nominal level, therefore we only reject for five heads, leaving us with an actual significance level of 1/32. (In fact Neyman and Pearson had the concept of a randomised test that in case of four heads would reject randomly with a certain probability chosen so that the overall rejection probability is 5% so that nominal and actual significance level are the same, but this is not very appealing.)

Christian Hennig's user avatar

  • $\begingroup$ Thank you for the detailed answer. Your answer is the bestest! $\endgroup$ –  M.C. Park Commented Jul 27, 2021 at 15:52
  • 2 $\begingroup$ A very common reason nominal differs from actual is that some assumption used in obtaining the nominal level has been broken (independence, constant variance, a distributional assumption, etc) $\endgroup$ –  Glen_b Commented Jul 27, 2021 at 17:42
  • $\begingroup$ @Glen_b I actually disagree. The p-value is computed relative to the null model including all its assumptions, and as such doesn't mind whether this model is actually not true. Of course all assumptions are always broken, actually there is no such thing as a real true probability anyway, but this also means that there is no such thing as an "actual p-value" that could be computed for any "really true model" in which all assumptions are broken. The concept of "actual p-value" only makes sense still assuming the H0 as it is. $\endgroup$ –  Christian Hennig Commented Oct 6, 2021 at 21:58

Your Answer

Sign up or log in, post as a guest.

Required, but never shown

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 hypothesis-testing statistical-significance or ask your own question .

  • Featured on Meta
  • Announcing a change to the data-dump process
  • Bringing clarity to status tag usage on meta sites

Hot Network Questions

  • How do I safely download and run an older version of software for testing without interfering with the currently installed version?
  • Why isn't a confidence level of anything >50% "good enough"?
  • Pull up resistor question
  • In roulette, is the frequency of getting long sequences of reds lower than that of shorter sequences?
  • An instructor is being added to co-teach a course for questionable reasons, against the course author's wishes—what can be done?
  • Creating Layout of 2D Board game
  • How to run only selected lines of a shell script?
  • What was the first "Star Trek" style teleporter in SF?
  • How can I give alternate numbered distance in a 2D array in Geometry Nodes?
  • Using rule-based symbology for overlapping layers in QGIS
  • Upstairs washer suds coming out of basement sink
  • Clarification Regarding a Possible Typo in David J. Griffiths' Introduction to Electrodynamics
  • Why is notation in logic so different from algebra?
  • Dirichlet Series that fail to be L-functions
  • "It never works" vs "It better work"
  • How can I play MechWarrior 2?
  • Blackboard math font that is compatible with mlmodern
  • How should I tell my manager that he could delay my retirement with a raise?
  • Nausea during high altitude cycling climbs
  • Does a party have to wait 1d4 hours to start a Short Rest if no healing is available and an ally is only stabilized?
  • How can I close all other windows on the same side of a vertical split where the current window is?
  • Problem about ratio between circumradius and inradius
  • How Does This Antique Television Circuit Work?
  • Is there a way to do a PhD such that you get a broad view of a field or subfield as a whole?

hypothesis test nominal data

Ordinal Scale and Nonparametric Methods

As ordinal scales are frequently encountered in research studies, the usual parametric tests don't hold true because of two reasons. First, they assume a level of measurement of interval/ratio scales. Second, they assume that the samples are drawn from a population with a known distribution such as the normal distribution. Measurement of attitudes, consumer tastes and preferences, and ranking of attributes are very prevalent in research. You need exclusive hypothesis testing procedures that deal with ordinal scales. These fall under a set of elegant nonparametric methods.

This article attempts to give an illustrative account of nonparametric methods that are used in ordinal scales of measurement. The coverage is by no means exhaustive. However typical situations are discussed to throw light on how useful these tests are.

Next-Kolmogorov-Smirnov Test

Kolmogorov-Smirnov Test:

Kolmogorov-Smirnov test is a test of goodness of fit for the univariate case when the scale of measurement is ordinal. It is similar to the chi-square test of goodness of fit in the sense it also examines whether the observed frequencies are in accordance with the expected frequencies under a well defined null hypothesis. Of course the chi-square test involves nominal measurement. Kolmogorov-Smirnov test is more powerful than the chi-square test when ordinal data are encountered in any decision problem. In the concluding remarks, you will see the advantages of using Kolmogorov-Smirnov test over the chi-square test. To understand how this test works in practice, let us take an example.

A manufacturing company producing decorative paints is interested in knowing whether the consumers have distinct preferences for different shades in the context of a new decorative paint that it proposes to market. If the consumers have special preference for any particular shade, then the company would market only that shade. Else, it would plan to market all the shades. A sample of 150 consumers was interviewed and the data collected on shade preferences are given in the table below:

Table showing shade preferences

Very Light 25
Light 35
Medium 55
Dark 20
Very Dark 15

What are your conclusions?

  Next-Analysis and Interpretations                         previous

Analysis and Interpretations:

The test involves comparing the expected cumulative distribution function under the null hypothesis being true with that of observed cumulative distribution function. If we designate Fo(X) as the expected cumulative distribution function and Sn(X) as the observed cumulative distribution function, Kolmogorov-Smirnov D is calculated as D = Max |Fo(X)-Sn(X)| (D is the absolute difference between the expected cumulative proportion and the observed cumulative proportion). Please note that n is the sample size. The following table shows the necessary calculations.

Table1: Basic Calculations for the Example

Shade

Observed Frequency

Observed Proportion Observed Cumulative Proportion Sn(X) Expected Proportion

Expected Cumulative Proportion

Fo(X)

|Fo(X)-Sn(X)| 
Very Light 25 0.1667 0.1667 0.2000 0.2000 0.0333
Light 35 0.2333 0.4000 0.2000 0.4000 0.0000
Medium 55 0.3667 0.7667 0.2000 0.6000 0.1667
Dark 20 0.1333 0.9000 0.2000 0.8000 0.1000
Very Dark 15 0.1000 1.0000 0.2000 1.000 0.0000

The null hypothesis is that all shades are equally preferred

The alternative hypothesis is that they are not equally preferred

Computed D = Max |Fo(X)-Sn(X)| = 0.1667. The critical D value for a level of significance of 5% is given by

Substituting for n in the left side expression, you get D =0.1110. Since the calculated D(0.1667) exceeds the critical D(0.1110), reject the null hypothesis at 5% level. The conclusion is that all shades are not equally preferred. The results show a significant preference for medium shade.

Next- Concluding Remarks on Kolmogorov-Smirnov Test                        previous

Concluding Remarks on Kolmogorov-Smirnov Test

You could very well have used the chi-square test of goodness of fit for testing the hypothesis of equal preference for all shades in this example instead of the Kolmogorov-Smirnov test. When the data measurement are ordinal, Kolmogorov-Smirnov test is more powerful than the chi-square test for the following reasons. 

Median Test

Median Test:

Median test is used for testing whether two groups differ in their median value. In simple terms, median test will focus on whether the two groups come from populations with the same median. This test stipulates the measurement scale is at least ordinal and the samples are independent (not necessary of the same sample size). The null hypothesis structured is that the two populations have the same median. Let us take an example to appreciate how this test is useful in a typical practical situation.

Example:   A private bank is interested in finding out whether the customers belonging to two groups differ in their satisfaction level. The two groups are customers belonging to current account holders and savings account holders. A random sample of 20 customers of each category was interviewed regarding their perceptions of the bank's service quality using a Likert-type (ordinal scale) statements. A score of "1" represents very dissatisfied and a score of "5" represents very satisfied. The compiled aggregate scores for each respondent in each groupare tabulated be given below:

What are your conclusions regarding the satisfaction level of these two groups?

Next-Analysis and Interpretations                             previous

The first task in the median test is to obtain the grand median. Arrange the combined data of both the groups in the descending  order of magnitude. That is rank them from the highest to the lowest. Select the middle most observation in the ranked data. In this case, median is the average of 20th and 21st observation in the array that has been arranged in the descending order of magnitude. 

Table showing descending order of aggregate score and rank in the combined sample

Descending
Order
Rank Descending
Order
Rank
86
85
85
80
80
80
80
79
75
75
75
75
73
70
70
65
65
65
63
62

1
2.5
2.5
5.5
5.5
5.5
5.5
8
10.5
10.5
10.5
10.5
13
14.5
14.5
17
17
17
19
20

61
60
55
55
55
55
50
50
50
50
50
50
50
45
40
40
38
30
30
20

21
22
24.5
24.5
24.5
24.5
30
30
30
30
30
30
30
34
35.5
35.5
37
38.5
38.5
40

Grand median is the average of 20th and 21st observation = (62+61)/2 =61.5. Please note that in the above table, average rank is taken whenever the scores are tied. The next step is to prepare a contingency table of two rows and two columns. The cells represent the number of observations that are above and below the grand median in each group. Whenever some observations in each group coincide with the median value, the accepted practice is to first count the observations that are strictly above grand median and put the rest under below grand median. In other words, below grand median in such cases would include less than or equal to grand median.

Scores of Current Account Holders and Savings Account Holders as compared with Grand Median

  Current Account Holders Savings Account Holders Marginal Total
Above Grand Median 8(a) 12(b) 20(a+b)
Below Grand Median 12(c) 8(d) 20(c+d)
Marginal Total 20(a+c) 20(b+d) 40(a+b+c+d)

= n

Null Hypothesis: There is no difference between the current account holders and savings account holders in the perceived satisfaction level.

alternative Hypothesis: There is difference between the current account holders and savings account holders in the perceived satisfaction level.

The test statistic to be used is given by

The chi-square statistic shown on the left side of the table is the one we would have obtained in  a contingency table with nominal data except for the factor (n / 2) used in the numerator as a correction for continuity . This is because a continuous distribution is used to approximate a discrete distribution. 

on substituting the values of  a, b, c, d, and n we have

Critical chi-square for 1 d.f at 5% level of significance = 3.84. Since the computed chi-square(0.90) is less than critical chi-square(3.84), we have no convincing evidence to reject the null hypothesis. Thus the the data are consistent with the null hypothesis that there is no difference between the current account holders and savings account holders in the perceived satisfaction level.

  Home

Have a language expert improve your writing

Run a free plagiarism check in 10 minutes, generate accurate citations for free.

  • Knowledge Base

Levels of Measurement | Nominal, Ordinal, Interval and Ratio

Published on July 16, 2020 by Pritha Bhandari . Revised on June 21, 2023.

Levels of measurement, also called scales of measurement, tell you how precisely variables are recorded. In scientific research, a variable is anything that can take on different values across your data set (e.g., height or test scores).

There are 4 levels of measurement:

  • Nominal : the data can only be categorized
  • Ordinal : the data can be categorized and ranked
  • Interval : the data can be categorized, ranked, and evenly spaced
  • Ratio : the data can be categorized, ranked, evenly spaced, and has a natural zero.

Depending on the level of measurement of the variable, what you can do to analyze your data may be limited. There is a hierarchy in the complexity and precision of the level of measurement, from low (nominal) to high (ratio).

Table of contents

Nominal, ordinal, interval, and ratio data, why are levels of measurement important, which descriptive statistics can i apply on my data, quiz: nominal, ordinal, interval, or ratio, other interesting articles, frequently asked questions about levels of measurement.

Going from lowest to highest, the 4 levels of measurement are cumulative. This means that they each take on the properties of lower levels and add new properties.

Nominal level Examples of nominal scales
You can categorize your data by them in mutually exclusive groups, but there is no order between the categories.
Ordinal level Examples of ordinal scales
You can categorize and rank your data in an order, but you cannot say anything about the intervals between the rankings.

Although you can rank the top 5 Olympic medallists, this scale does not tell you how close or far apart they are in number of wins.

  (e.g., very dissatisfied to very satisfied)
Interval level Examples of interval scales
You can categorize, rank, and equal intervals between neighboring data points, but there is no true zero point.

The difference between any two adjacent temperatures is the same: one degree. But  zero degrees is defined differently depending on the scale – it doesn’t mean an absolute absence of temperature.

The same is true for test scores and personality inventories. A zero on a test is arbitrary; it does not mean that the test-taker has an absolute lack of the trait being measured.

Ratio level Examples of ratio scales
You can categorize, rank, and infer equal intervals between neighboring data points, and there is a true zero point.

A true zero means there is an absence of the variable of interest. In ratio scales, zero does mean an absolute lack of the variable.

For example, in the Kelvin temperature scale, there are no negative degrees of temperature – zero means an absolute lack of thermal energy.

Receive feedback on language, structure, and formatting

Professional editors proofread and edit your paper by focusing on:

  • Academic style
  • Vague sentences
  • Style consistency

See an example

hypothesis test nominal data

The level at which you measure a variable determines how you can analyze your data.

The different levels limit which descriptive statistics you can use to get an overall summary of your data, and which type of inferential statistics you can perform on your data to support or refute your hypothesis .

In many cases, your variables can be measured at different levels, so you have to choose the level of measurement you will use before data collection begins.

  • Ordinal level: You create brackets of income ranges: $0–$19,999, $20,000–$39,999, and $40,000–$59,999. You ask participants to select the bracket that represents their annual income. The brackets are coded with numbers from 1–3.
  • Ratio level: You collect data on the exact annual incomes of your participants.
Participant Income (ordinal level) Income (ratio level)
A Bracket 1 $12,550
B Bracket 2 $39,700
C Bracket 3 $40,300

At a ratio level, you can see that the difference between A and B’s incomes is far greater than the difference between B and C’s incomes.

Descriptive statistics help you get an idea of the “middle” and “spread” of your data through measures of central tendency and variability .

When measuring the central tendency or variability of your data set, your level of measurement decides which methods you can use based on the mathematical operations that are appropriate for each level.

The methods you can apply are cumulative; at higher levels, you can apply all mathematical operations and measures used at lower levels.

Data type Mathematical operations Measures of central tendency Measures of variability
Nominal
Ordinal
Interval
Ratio

Prevent plagiarism. Run a free check.

If you want to know more about statistics , methodology , or research bias , make sure to check out some of our other articles with explanations and examples.

  • Student’s  t -distribution
  • Normal distribution
  • Null and Alternative Hypotheses
  • Chi square tests
  • Confidence interval

Methodology

  • Cluster sampling
  • Stratified sampling
  • Data cleansing
  • Reproducibility vs Replicability
  • Peer review
  • Likert scale

Research bias

  • Implicit bias
  • Framing effect
  • Cognitive bias
  • Placebo effect
  • Hawthorne effect
  • Hindsight bias
  • Affect heuristic

Levels of measurement tell you how precisely variables are recorded. There are 4 levels of measurement, which can be ranked from low to high:

  • Nominal : the data can only be categorized.
  • Ordinal : the data can be categorized and ranked.
  • Interval : the data can be categorized and ranked, and evenly spaced.
  • Ratio : the data can be categorized, ranked, evenly spaced and has a natural zero.

Depending on the level of measurement , you can perform different descriptive statistics to get an overall summary of your data and inferential statistics to see if your results support or refute your hypothesis .

Some variables have fixed levels. For example, gender and ethnicity are always nominal level data because they cannot be ranked.

However, for other variables, you can choose the level of measurement . For example, income is a variable that can be recorded on an ordinal or a ratio scale:

  • At an ordinal level , you could create 5 income groupings and code the incomes that fall within them from 1–5.
  • At a ratio level , you would record exact numbers for income.

If you have a choice, the ratio level is always preferable because you can analyze data in more ways. The higher the level of measurement, the more precise your data is.

Cite this Scribbr article

If you want to cite this source, you can copy and paste the citation or click the “Cite this Scribbr article” button to automatically add the citation to our free Citation Generator.

Bhandari, P. (2023, June 21). Levels of Measurement | Nominal, Ordinal, Interval and Ratio. Scribbr. Retrieved September 4, 2024, from https://www.scribbr.com/statistics/levels-of-measurement/

Is this article helpful?

Pritha Bhandari

Pritha Bhandari

Other students also liked, descriptive statistics | definitions, types, examples, central tendency | understanding the mean, median & mode, nominal data | definition, examples, data collection & analysis, what is your plagiarism score.

IMAGES

  1. What is Nominal Data? Definition, Examples, Analysis & Statistics

    hypothesis test nominal data

  2. Statistical Hypothesis Testing: Step by Step

    hypothesis test nominal data

  3. PPT

    hypothesis test nominal data

  4. Your Guide to Master Hypothesis Testing in Statistics

    hypothesis test nominal data

  5. What is Nominal Data? Definition, Characteristics, Examples

    hypothesis test nominal data

  6. Hypothesis Testing Steps & Real Life Examples

    hypothesis test nominal data

VIDEO

  1. Hypothesis Testing

  2. Chapter 09: Hypothesis testing: non-directional worked example

  3. Psychology 210

  4. Hypothesis Testing, Test Types and Scaling| Research methodology Part-4, NET- 2018 Paper-1(in Hindi)

  5. Hypothsis Testing in Statistics Part 2 Steps to Solving a Problem

  6. How to Perform the McNemar's Test for Paired Nominal Data using R: A Step by Step Guide

COMMENTS

  1. Choosing the Right Statistical Test

    Categorical variables represent groupings of things (e.g. the different tree species in a forest). Types of categorical variables include: Ordinal: represent data with an order (e.g. rankings). Nominal: represent group names (e.g. brands or species names). Binary: represent data with a yes/no or 1/0 outcome (e.g. win or lose).

  2. 2: Tests for Nominal Variables

    2.3: Chi-Square Test of Goodness-of-Fit. Use the chi-square test of goodness-of-fit when you have one nominal variable with two or more values. You compare the observed counts of observations in each category with the expected counts, which you calculate using some kind of theoretical expectation. If the expected number of observations in any ...

  3. Nominal Data

    The level of measurement indicates how precisely data is recorded. There are 4 hierarchical levels: nominal, ordinal, interval, and ratio. The higher the level, the more complex the measurement. Nominal data is the least precise and complex level. The word nominal means "in name," so this kind of data can only be labelled.

  4. Nominal Data: Definition & Examples

    The definition of nominal in statistics is "in name only.". This definition indicates how these data consist of category names—all you can do is name the group to which each observation belongs. Nominal and categorical data are synonyms, and I'll use them interchangeably. For example, literary genre is a nominal variable that can have ...

  5. Comparing Hypothesis Tests for Continuous, Binary, and Count Data

    A hypothesis test uses sample data to assess two mutually exclusive theories about the properties of a population. Hypothesis tests allow you to use a manageable-sized sample from the process to draw inferences about the entire population. I'll cover common hypothesis tests for three —continuous, binary, and count data.

  6. Hypothesis Testing

    Table of contents. Step 1: State your null and alternate hypothesis. Step 2: Collect data. Step 3: Perform a statistical test. Step 4: Decide whether to reject or fail to reject your null hypothesis. Step 5: Present your findings. Other interesting articles. Frequently asked questions about hypothesis testing.

  7. 5.5 Introduction to Hypothesis Tests

    A hypothesis test can be used to do this. A hypothesis test involves collecting data from a sample and evaluating the data. Then the statistician makes a decision as to whether or not there is sufficient evidence to reject the null hypothesis based upon analyses of the data. In this section, you will conduct hypothesis tests on single means ...

  8. 4: Tests for Ordinal Data and Small Samples

    The tests discussed so far that use the chi-square approximation, including the Pearson and LRT for nominal data as well as the Mantel-Haenszel test for ordinal data, perform well when the contingency tables have a reasonable number of observations in each cell, as already discussed in Lesson 1. When samples are small, the distributions of \ (X ...

  9. What Is Nominal Data?

    There are 4 hierarchical levels: nominal, ordinal, interval, and ratio. The higher the level, the more complex the measurement. Nominal data is the least precise and complex level. The word nominal means 'in name', so this kind of data can only be labelled. It does not have a rank order, equal spacing between values, or a true zero value.

  10. An Introduction to Nominal Variables: Understanding Types of Data

    Statsmodels: Facilitates detailed statistical modeling and hypothesis testing, useful for analyzing relationships in categorical data. Scikit-learn: Contains tools for preprocessing data, such as LabelEncoder(), and for conducting machine learning analyses on categorical data. Examples of Nominal Variables Used in Statistical Analysis

  11. PDF Chapter 6 Hypothesis Testing

    Chi-square Test (Nominal Data) • A chi-square test is used to investigate relationships • Relationships between categorical, or nominal-scale, variables representing attributes of people, interaction techniques, systems, etc. • Data organized in a contingency table - cross tabulation containing counts (frequency data) for number of

  12. What is Nominal Data? Definition, Examples, Analysis & Statistics

    Nominal variables can be used in pairwise statistical hypothesis testing, either as one of the variables or both. For example, you can use Nominal variables in a Fisher's Exact Test or a Chi-Squared Test, where it is tested against other categorical data. You can also test Nominal variables against numerical data using a 2-sample t-test or an ...

  13. 7.1: Basics of Hypothesis Testing

    The null hypothesis has the same parameter and number with an equal sign. H0: μ = $30, 000 HA: μ> $30, 000. b. x = number od students who like math. p = proportion of students who like math. The guess is that p < 0.10 and that is the alternative hypothesis. H0: p = 0.10 HA: p <0.10. c. x = age of students in this class.

  14. Nominal Data

    For nominal data, hypothesis testing can be carried out using nonparametric tests such as the chi-squared test. The chi-squared test aims to determine whether there is a significant difference between the expected frequency and the observed frequency of the given values.

  15. R Handbook: Introduction to Tests for Nominal Variables

    Tests of symmetric margins, or marginal homogeneity, can determine if frequencies for one nominal variable are greater than that for another, or if there was a change in frequencies from sampling at one time to another. These are described here as "tests for paired nominal data.". For tests of association, a measure of association, or ...

  16. SPSS Tutorial: General Statistics and Hypothesis Testing

    To generate the ANOVA statistic the variables chosen cannot have a "Nominal" level of measurement; they must be "ordinal." Once the nominal variables have been changed to ordinal, select "the dependent variable and the factor, then click "OK." The following output will appear in the Output Viewer:

  17. Tutorial Hypothesis testing • Simply explained

    DATAtab helps you to find the right test, you just need to select the data you want to evaluate. Depending on the scale level of your data, DATAtab will suggest the appropriate test. Depending on which variables are selected, is calculated: t-test one sample. t-test independent samples. t-test dependent samples.

  18. Hypothesis Tests in R

    This tutorial covers basic hypothesis testing in R. Normality tests. Shapiro-Wilk normality test. Kolmogorov-Smirnov test. Comparing central tendencies: Tests with continuous / discrete data. One-sample t-test: Normally-distributed sample vs. expected mean. Two-sample t-test: Two normally-distributed samples.

  19. Statistical hypothesis test

    The above image shows a table with some of the most common test statistics and their corresponding tests or models.. A statistical hypothesis test is a method of statistical inference used to decide whether the data sufficiently supports a particular hypothesis. A statistical hypothesis test typically involves a calculation of a test statistic.Then a decision is made, either by comparing the ...

  20. hypothesis testing

    Here's an example. We toss a coin 5 times and we want to test at nominal 5% level whether it's biased in favour of "heads". The probability for five times heads is 1/32<0.05, the probability for four times heads is 5/32>0.05.

  21. Ordinal Scale and Hypothesis Testing

    Of course the chi-square test involves nominal measurement. Kolmogorov-Smirnov test is more powerful than the chi-square test when ordinal data are encountered in any decision problem. ... (3.84), we have no convincing evidence to reject the null hypothesis. Thus the the data are consistent with the null hypothesis that there is no difference ...

  22. Chi-Square (Χ²) Tests

    The chi-square goodness of fit test is used to test whether the frequency distribution of a categorical variable is different from your expectations. The chi-square test of independence is used to test whether two categorical variables are related to each other. Chi-square is often written as Χ 2 and is pronounced "kai-square" (rhymes with ...

  23. 8.1: The null and alternative hypotheses

    a probability value or p-value which is associated with the test statistic, assuming a null hypothesis is "true" in the population from which we sample. Note that as discussed in (Chapter 8.2), this is not strictly the interpretation of p-value, but a shorthand for how likely the data is to fit the null hypothesis. P-value alone can't ...

  24. Levels of Measurement

    In scientific research, a variable is anything that can take on different values across your data set (e.g., height or test scores). There are 4 levels of measurement: Nominal: the data can only be categorized. Ordinal: the data can be categorized and ranked. Interval: the data can be categorized, ranked, and evenly spaced.