Skip to content

Search Broadly Epi

P-values and statistical significance

In this tutorial, we will explore the concepts of p-values and statistical significance, which are fundamental to interpreting results in inferential statistics. p-values help researchers determine whether the results of a study are likely due to chance or represent a true effect in the population. Understanding p-values and statistical significance is essential for public health professionals and a key topic on the Certified in Public Health (CPH) exam.

By the end of this tutorial, you will understand what a p-value is, how to interpret it, and how it relates to statistical significance. Practice questions are included to help reinforce your knowledge.

1. Introduction to p-Values and Statistical Significance

In public health research, researchers often test hypotheses to determine whether an observed effect or association is real or if it could have occurred by chance. The p-value is a statistical measure that helps assess this probability. It is used in hypothesis testing to determine whether the results of a study are statistically significant—that is, unlikely to have occurred by chance alone.

A result is considered statistically significant if the p-value is below a predetermined threshold (usually 0.05), indicating that there is strong evidence against the null hypothesis (the assumption that there is no effect or association).

2. What is a p-Value?

2.1 Definition of a p-Value

A p-value is the probability of observing the data, or something more extreme, assuming that the null hypothesis is true. The null hypothesis typically states that there is no effect or no association between the variables being studied.

The p-value helps us determine whether the observed results could have occurred by chance. A smaller p-value indicates stronger evidence against the null hypothesis, while a larger p-value suggests that the results are more likely due to random variation.

2.2 p-Value Threshold (e.g., 0.05)

The most commonly used threshold for statistical significance is 0.05. This means that if the p-value is less than 0.05, the result is considered statistically significant, and the null hypothesis is rejected.

2.3 Interpreting p-Values

It is important to interpret p-values in the context of the study:

However, a statistically significant result (p < 0.05) does not prove that the effect is large or important; it simply means that the effect is unlikely to be due to chance. Conversely, a non-significant result (p ≥ 0.05) does not necessarily mean that there is no effect; it could indicate that the study lacked sufficient power to detect a difference.

3. Statistical Significance

3.1 Definition of Statistical Significance

Statistical significance refers to the likelihood that an observed effect or relationship in a study is not due to random chance. If a result is statistically significant, it means that the evidence is strong enough to reject the null hypothesis, suggesting that the effect is real. The threshold for statistical significance is typically set at p < 0.05, but this threshold can vary depending on the context of the study.

It is important to note that statistical significance does not necessarily imply clinical or practical significance. A small p-value may indicate a statistically significant result, but the effect size might still be too small to have meaningful public health implications.

3.2 Type I and Type II Errors

In hypothesis testing, there are two types of errors that researchers need to be aware of:

Researchers aim to minimize both types of errors by choosing an appropriate significance level and ensuring that the study has sufficient power (large enough sample size) to detect meaningful effects.

3.3 Limitations of p-Values

While p-values are a useful tool for hypothesis testing, they have limitations:

4. Practice Questions

Test your understanding of p-values and statistical significance with these practice questions. Try answering them before checking the solutions.

Question 1:

A study finds that a new treatment reduces blood pressure, and the p-value for this result is 0.02. Is this result statistically significant?

Answer 1:

Answer, click to reveal

It depends! If the cut-off is 0.05 then yes, the result is statistically significant because the p-value (0.02) is less than 0.05. This suggests that the effect is unlikely to be due to chance. Keep in mind that other cut-offs may exist (0.01 is another common cut-off).

Question 2:

A clinical trial testing a new vaccine reports a p-value of 0.08. Assuming a p-value cut-off of 0.05,  What does this mean in terms of statistical significance?

Answer 2:

Answer, click to reveal

The p-value of 0.08 is greater than 0.05, meaning the result is not statistically significant at the 0.05 level. The study does not provide strong enough evidence to reject the null hypothesis, so the effect could be due to chance.

Question 3:

When might a researcher have a p-value cut-off 0.01 instead of 0.05?

Answer 3:

Answer, click to reveal

Typically, a higher cut-off p-value is used when incorrect conclusions run the risk of having more severe consequences, especially in the case of conclusions drawn from Type I errors.

5. Conclusion

p-values and statistical significance are key concepts in inferential statistics that help researchers determine whether an observed effect is likely due to chance. A statistically significant result provides evidence against the null hypothesis, but it does not measure the size or importance of the effect.

Humanities Moment

The Featured Image for this article is Klänge Pl.19 (1913) by Wassily Kandinsky (Russian, 1866 – 1944). Kandinsky was a Russian painter and art theorist recognized as a pioneering figure in abstract art. Initially trained in law and economics, he turned to art at age 30, studying in Munich and later teaching at Germany’s Bauhaus school until its closure by the Nazis. He spent his final years in France, where he created many significant works and became a French citizen before his death in 1944.

Confidence intervals

In this tutorial, we will explore the concept of confidence intervals, a fundamental tool in inferential statistics. Confidence intervals are used to estimate the range within which a population parameter (e.g., a mean or proportion) is likely to lie, based on sample data. Understanding confidence intervals is essential for making informed decisions in public health research and is also a key topic for the Certified in Public Health (CPH) exam.

By the end of this tutorial, you will understand what a confidence interval is, how to calculate it, and how to interpret it. Practice questions are provided to help reinforce your understanding.

1. Introduction to Confidence Intervals

In inferential statistics, researchers often use data from a sample to make inferences about a population. A confidence interval (CI) is a range of values, derived from sample data, that is likely to contain the true population parameter (such as a mean or proportion). Unlike a single point estimate (e.g., a sample mean), a confidence interval provides a range of plausible values for the population parameter, along with an associated level of confidence.

For example, instead of estimating that the average blood pressure in a population is exactly 120 mmHg, a confidence interval might state that the true average is between 118 and 122 mmHg, with 95% confidence.

2. What is a Confidence Interval?

2.1 Definition of Confidence Intervals

A confidence interval is a range of values around a sample estimate (such as a sample mean) that is likely to contain the true population parameter. It is typically expressed with a confidence level, such as 95%, which indicates how confident we are that the interval contains the true parameter. A 95% confidence interval means that if we were to take 100 different samples and calculate a confidence interval for each, we would expect about 95 of them to contain the true population parameter.

2.2 Confidence Level (e.g., 95%, 99%)

The confidence level reflects the degree of certainty that the confidence interval contains the true population parameter. Common confidence levels are 90%, 95%, and 99%, with 95% being the most frequently used in public health research. A higher confidence level means a wider confidence interval, providing greater assurance that the interval contains the true value, but at the cost of precision.

2.3 Interpretation of Confidence Intervals

Interpreting a confidence interval involves understanding what it tells you about the population parameter:

3. How to Calculate Confidence Intervals

The calculation of a confidence interval depends on the type of data and whether the population standard deviation is known or not. In most public health applications, we calculate confidence intervals for the population mean or proportion based on sample data.

3.1 Confidence Interval for a Population Mean

The formula for calculating a confidence interval for a population mean when the sample standard deviation (s) is known or estimated is:

CI=x‾±Z(sn) \text{CI} = \overline{x} \pm Z \left( \frac{s}{\sqrt{n}} \right)

Where:

Steps to Calculate the Confidence Interval for a Mean:

3.2 Confidence Interval for a Population Proportion

The formula for calculating a confidence interval for a population proportion is:

CI=p±Z(p(1−p)n) \text{CI} = p \pm Z \left( \sqrt{\frac{p(1 – p)}{n}} \right)

Where:

Steps to Calculate the Confidence Interval for a Proportion:

4. Practice Questions

Test your understanding of confidence intervals with these practice questions. Try answering them before checking the solutions.

Question 1:

A study reports that the mean cholesterol level in a sample of 100 adults is 200 mg/dL, with a standard deviation of 15 mg/dL. Calculate the 95% confidence interval for the mean cholesterol level in the population.

Answer 1:

Answer, click to reveal

Step 1: Sample mean (x̄) = 200 mg/dL

Step 2: Standard error (SE) = s / √n = 15 / √100 = 1.5

Step 3: Z-score for 95% confidence = 1.96

Step 4: Margin of error = 1.96 * 1.5 = 2.94

Step 5: Confidence interval = 200 ± 2.94 = [197.06, 202.94]

Question 2:

A survey finds that 40% of respondents support a new public health policy, with a sample size of 500. Calculate the 95% confidence interval for the population proportion.

Answer 2:

Answer, click to reveal

Step 1: Sample proportion (p) = 0.40

Step 2: Standard error (SE) = √[p(1 – p) / n] = √[0.40(0.60) / 500] = 0.0219

Step 3: Z-score for 95% confidence = 1.96

Step 4: Margin of error = 1.96 * 0.0219 = 0.0429

Step 5: Confidence interval = 0.40 ± 0.0429 = [0.3571, 0.4429]

5. Conclusion

Confidence intervals are an essential tool in inferential statistics that provide a range of plausible values for a population parameter, based on sample data. They offer more information than a single point estimate and allow researchers to make informed conclusions about the population.

Remember:

Final Tip for the CPH Exam:

Ensure you understand how to calculate and interpret confidence intervals for both means and proportions, and keep in mind that the standard error and margin of error are unique values, as there might be a question or two on that point as well.

Humanities Moment

The featured image of this article is Great Falls of Snake River, Idaho Territory (1876) by Thomas Moran (American, 1837-1926). Moran was a prominent American landscape painter of the Hudson River School and the Rocky Mountain School, renowned for his vivid depictions of the American West, notably Yellowstone National Park, which his artwork helped establish. Influenced significantly by British artist J.M.W. Turner, Moran excelled in multiple mediums including oils, watercolors, and chromolithography. His celebrated works such as The Grand Canyon of the Yellowstone (1872) solidified his reputation, earning him national acclaim and securing his legacy as one of America’s premier landscape artists.

Sampling methods and sample size

In this tutorial, we will explore two key concepts in inferential statistics: sampling methods and sample size calculation. Sampling refers to the process of selecting a subset of individuals from a population to represent the whole population, while sample size calculation ensures that the sample is large enough to draw valid and reliable conclusions.

By the end of this tutorial, you will understand different types of sampling methods, how to calculate the appropriate sample size, and why these steps are crucial in research design. Practice questions are included to help reinforce your knowledge.

1. Introduction to Sampling and Sample Size

Sampling is the process of selecting a subset (or sample) of individuals from a larger population to estimate population parameters and make inferences. Since it is often impractical to study an entire population, sampling allows researchers to make generalizations about a population based on a smaller, manageable group.

Sample size calculation determines the number of individuals needed in a sample to ensure that the results are statistically valid and reliable. If the sample size is too small, the study may lack the power to detect significant differences. If the sample is too large, resources may be wasted.

2. Types of Sampling Methods

There are several methods of sampling, each with its strengths and weaknesses. The choice of sampling method depends on the research design, the population, and the goals of the study.

2.1 Random Sampling

Random sampling (also called simple random sampling) is a method where each individual in the population has an equal chance of being selected for the sample. Random sampling helps minimize bias and ensures that the sample is representative of the population.

2.2 Systematic Sampling

Systematic sampling involves selecting individuals from a population at regular intervals (e.g., every 10th person on a list). While this method is easier to implement than random sampling, it can introduce bias if there is a pattern in the population list.

2.3 Stratified Sampling

Stratified sampling involves dividing the population into subgroups (or strata) based on characteristics such as age, gender, or income, and then selecting a random sample from each subgroup. This method ensures that all subgroups are represented in the sample.

2.4 Cluster Sampling

Cluster sampling involves dividing the population into clusters (e.g., geographic areas or schools) and then randomly selecting entire clusters to include in the study. This method is often used in large, geographically dispersed populations, but it can introduce bias if clusters are not representative.

2.5 Convenience Sampling

Convenience sampling involves selecting individuals who are readily available or easy to reach. While this method is inexpensive and easy to implement, it is prone to bias and may not be representative of the population.

3. Sample Size Calculation

Sample size calculation is an important step in research design because it ensures that the sample is large enough to detect meaningful differences or associations. The calculation is based on several factors, including the desired level of precision, confidence level, and expected effect size.

3.1 Importance of Sample Size

Choosing the correct sample size is crucial for the validity of a study. If the sample size is too small, the study may not have enough power to detect significant differences or associations, leading to false-negative results. On the other hand, if the sample size is too large, the study may be unnecessarily expensive or time-consuming.

3.2 Factors Influencing Sample Size

Several factors influence the calculation of sample size:

3.3 Sample Size Formula

The formula for calculating the sample size depends on whether the study is estimating a proportion or a mean. A basic formula for estimating sample size when proportions are involved is:

n=Z2p(1−p)E2 n = \frac{Z^2 p(1-p)}{E^2}

Where:

For estimating the sample size for means, the formula is:

n=Z2σ2E2 n = \frac{Z^2 \sigma^2}{E^2}

Where:

4. Practice Questions

Test your understanding of sampling methods and sample size calculation with these practice questions. Try answering them before checking the solutions.

Question 1:

A researcher wants to study the prevalence of diabetes in different income groups. What type of sampling method should the researcher use?

Answer 1:

Answer, click to reveal

The researcher should use stratified sampling to ensure that all income groups are represented in the sample.

Question 2:

A study is conducted to evaluate the effectiveness of a new vaccine, and participants are selected by choosing every 10th person from a list of patients. What type of sampling method is this?

Answer 2:

Answer, click to reveal

This is an example of systematic sampling, where individuals are selected at regular intervals.

Question 3:

A public health study requires a 95% confidence level. The population has an estimated variance of 25, and the desired margin of error is 5. What is the minimum sample size required for the study?

Answer 3:

Answer, click to reveal

Using the formula for sample size when estimating the mean:

n=Z2σ2E2 n = \frac{Z^2 \sigma^2}{E^2}

For a 95% confidence level, Z = 1.96, σ² = 25, and E = 5:

n=(1.96)2(25)52=3.8416×2525=3.8416×1=3.8416≈4 n = \frac{(1.96)^2 (25)}{5^2} = \frac{3.8416 \times 25}{25} = 3.8416 \times 1 = 3.8416 \approx 4

Thus, a minimum sample size of 4 participants is required.

5. Conclusion

Sampling methods and sample size calculation are fundamental aspects of research design in public health. The choice of sampling method ensures that the sample is representative of the population, while sample size calculation ensures that the study is adequately powered to detect meaningful differences or associations.

Remember:

Final Tip for the CPH Exam:

Make sure you understand how to choose the appropriate sampling method and how to calculate the required sample size for different types of studies. Practice identifying different sampling techniques mentioned in various studies, and practice calculating sample sizes.

Humanities Moment

The featured image for this CPH Focus is La Cène (1898) by Alexandre Falguière (French, 1831 – 1900). Falguière  was a renowned French sculptor and painter, celebrated for works like Victor of the Cockfight, Joan of Arc, and The Dancer. A Prix de Rome winner and Officer of the Legion of Honor, he was also a prominent teacher and member of the Académie des Beaux-Arts, leaving behind a legacy of iconic sculptures and paintings now housed in major museums like the Musée d’Orsay.

Data visualization

In this tutorial, we will explore the use of data visualization techniques, including charts, graphs, and histograms, to present and interpret data effectively. Visualizing data allows public health professionals to understand patterns, trends, and distributions within datasets and to communicate findings clearly. Understanding these methods is key for the Certified in Public Health (CPH) exam and for presenting public health data.

By the end of this tutorial, you will understand different types of data visualizations, how to create and interpret them, and when to use each type. Practice questions are included to help reinforce your knowledge.

1. Introduction to Data Visualization

Data visualization is the process of creating graphical representations of data to make complex data easier to understand. Charts, graphs, and histograms are widely used in public health research to display descriptive statistics and to identify trends, distributions, and relationships within datasets.

Effective data visualization helps communicate data insights to diverse audiences, from policymakers to the public. The choice of visualization depends on the type of data and the information you want to convey.

2. Bar Charts

Bar charts are used to display categorical data by representing each category as a bar, with the length of the bar corresponding to the frequency or value of that category. Bar charts are useful for comparing the sizes of different groups or categories.

2.1 Definition of Bar Charts

A bar chart consists of rectangular bars, where the length of each bar represents the magnitude or frequency of the corresponding category. Bars can be arranged vertically or horizontally, and they are typically separated by gaps to emphasize that the data are categorical rather than continuous.

2.2 When to Use Bar Charts

Bar charts are best used when you are comparing discrete categories or groups, such as age groups, gender, or types of diseases. They are especially useful for illustrating the frequency of occurrences or for comparing quantities across different categories.

2.3 How to Create and Interpret Bar Charts

To create a bar chart:

When interpreting a bar chart, look at the lengths of the bars to compare the values or frequencies across categories. For example, a bar chart might show the number of people vaccinated in different age groups, with the longest bar representing the age group with the highest vaccination rate.

3. Line Graphs

Line graphs are used to display trends in data over time or continuous data. A line graph connects individual data points with a line, allowing viewers to see how a variable changes over time or across a continuous range.

3.1 Definition of Line Graphs

A line graph uses points connected by a line to represent data points in a sequence. It is most commonly used to track changes over time, but it can also be used to display continuous data. Line graphs are particularly effective for showing trends, patterns, and relationships over time.

3.2 When to Use Line Graphs

Line graphs are best used when you want to visualize changes over time or trends in continuous data. They are ideal for displaying data such as disease incidence rates over time, temperature changes, or population growth trends.

3.3 How to Create and Interpret Line Graphs

To create a line graph:

When interpreting a line graph, look for trends over time or patterns in the data. For example, a line graph might show the rise and fall of flu cases throughout a year, with peaks during the winter months.

4. Histograms

Histograms are used to display the distribution of continuous data. They group data into intervals (bins) and display the frequency of data points that fall within each interval. Histograms provide a visual representation of the shape of the data distribution, such as whether the data are skewed or normally distributed.

4.1 Definition of Histograms

A histogram is similar to a bar chart, but it is used to display continuous data rather than categorical data. The x-axis represents the intervals (bins) of the continuous data, and the y-axis represents the frequency of data points within each bin. Unlike bar charts, the bars in a histogram touch each other to indicate that the data are continuous.

4.2 When to Use Histograms

Histograms are best used when you want to visualize the distribution of continuous data. They are particularly useful for showing the frequency of data points within specified ranges and for identifying patterns such as skewness, modality, or the presence of outliers.

4.3 How to Create and Interpret Histograms

To create a histogram:

When interpreting a histogram, look for the shape of the distribution. For example, a histogram might show that most data points are clustered around a central value, indicating a normal distribution, or it might reveal a skewed distribution with more data points on one side.

5. Practice Questions

Test your understanding of data visualization with these practice questions. Try answering them before checking the solutions.

Question 1:

A public health researcher wants to compare the number of flu cases in different cities. What type of graph should the researcher use?

Answer 1:

Answer, click to reveal

The researcher should use a bar chart to compare the number of flu cases across different cities, as bar charts are best for comparing categorical data.

Question 2:

A study tracks the daily number of new COVID-19 cases over the course of a year. What type of graph is most appropriate to display this data?

Answer 2:

Answer, click to reveal

A line graph is most appropriate, as it can display trends in the number of cases over time.

Question 3:

A public health researcher is analyzing the distribution of ages in a population. The ages range from 18 to 80. What type of visualization should the researcher use to show the distribution of ages?

Answer 3:

Answer, click to reveal

A histogram should be used, as it can show the frequency of ages within specified intervals, making it easy to see the overall distribution of the data.

6. Conclusion

Data visualization is a critical tool for understanding and communicating public health data. Charts, graphs, and histograms help present complex data in a clear and interpretable way, allowing public health professionals to identify trends, distributions, and relationships in their data. Each type of visualization has its strengths, and choosing the right one depends on the type of data and the message you want to convey.

Remember:

Final Tip for the CPH Exam:

Ensure you understand when each type of visualization is best suited for what sort of underlying data. It’s encouraged you look at several studies, examine what data types they are using in their study, and how that data is then represented. Ask yourself if it was appropriate or if a better choice was available.

Humanities Moment

The featured image for this CPH Focus is Fruit Still Life With Two Parrots (1623) by Balthasar van der Ast (Dutch, 1593-1657). Balthasar van der Ast, a Dutch Golden Age painter born in Middelburg around 1593-1594, was a pioneer of shell still lifes and known for his intricate still life paintings of flowers, fruit, insects, and lizards. Trained by his brother-in-law Ambrosius Bosschaert the Elder, van der Ast influenced the “Bosschaert dynasty” and other prominent painters, eventually settling in Delft, where he joined the Guild of St. Luke and lived until his death in 1657.

Text data types for NLP in Python

Welcome to PyFriday! If this is your first time exploring Natural Language Processing (NLP), you’re in the right place. NLP is all about teaching computers to understand, interpret, and interact with human language. To do that effectively, we use various text data types to represent and process text. Before we dig into the big NLP topics that will go from data cleaning to building out your own Machine Learning models, we’ll need to take some time to learn about these text data types.

Please keep in mind, while we aim to keep this tutorial very beginner friendly, there is some assumptions of experience in Python. If you're completely new to Python, we recommend checking out our earlier PyFriday entries!   Normally, we host all code presented on Cody’s Github. This time however, since it's a bunch of smaller examples, we'll keep the examples in the article.

What is Text Data in NLP?

In NLP, text data refers to the words, sentences, or paragraphs we process. Computers can’t understand text like humans do—they need structured representations of text to work with it. These representations are the text data types we’ll discuss. Imagine you want a computer to analyze this sentence:
“Welcome to PyFriday!”
The computer must:
  1. Store the text.
  2. Break it into parts (e.g., words or letters).
  3. Analyze it (e.g., find the most important words).
  4. Apply meaning (e.g., recognize “PyFriday” as a name).
We use different data processing for each step, which often includes breaking up the data into several types.

Strings: Definition, Use Cases, and Examples

What Are Strings?

A string is a basic data type that represents text. You can think of it as a single piece of text, like a word, sentence, or paragraph. Computers use strings to store and manipulate text, and can be as short as one letter, to entire books.

Why Use Strings in NLP?

Strings are fundamental for:
  • Storing raw text data, like a tweet or a paragraph. It’s basically as fundamental a data type as integers or boolean values.
  • Doing simple text processing, such as converting to lowercase or removing punctuation.

Example

Here, we assign a sentence or string as text, and print it. Next, we turn all letters lowercase and print again. Lastly, we split the string into a list of tokens (both terms will be discussed shortly), and print that. These are quick examples of how string data is read in, and can be cleaned.

Lists of Strings: Definition, Use Cases, and Examples

What Are Lists of Strings?

A list is like a container that can hold multiple pieces of text (strings). When you split a sentence into words, you usually end up with a list of strings.

Why Use Lists of Strings in NLP?

  • Storing tokenized text (text broken into smaller pieces like words).
  • Processing multiple pieces of text in order (e.g., sentences in a paragraph).
  • Can better organize/categorize data (e.g. a list of strings can give you an organized way to look at chief complaints by visit).
    • These can be further abstracted into lists of lists of strings, like if you want to see chief complaint by patient over time, by hospital.

Examples

Here, we take our original sentence, split it by word to form a list, and then rejoin the words from a list back into a string, with a space between each list entry to make things intelligible.

Dictionaries: Definition, Use Cases, and Examples

What Are Dictionaries?

A dictionary is a data type that pairs values with keys. Think of it like a mini-database where each key has a value. In NLP, dictionaries are often used to store information about words, like their frequency in a document.

Why Use Dictionaries in NLP?

  • To count words (important for understanding which words are common or rare).
  • To map words to other data, like their synonyms or embeddings (discussed later).

Examples

For this example, we’re taking a sentence and putting it into a variable. Then, we set up an empty dictionary called word_counts. From there, we use a for loop to iterate over every word, and each time a word shows up, we add to its count value in the dictionary.

DataFrames: Definition, Use Cases, and Example

What Are DataFrames?

A DataFrame is a table-like data structure (think of an Excel sheet). It’s great for handling text data with additional information, such as labels or metadata.

Why Use DataFrames in NLP?

  • To organize large datasets, like medical records with lots of subfields.
  • To store text and related attributes for machine learning, analysis, etc.

Example

Token Objects:  Tokens for NLP, Use Cases, and Example

A token object is a specialized representation of a word or a segment of text used by NLP libraries such as spaCy or NLTK. Tokens go beyond just being individual words—they include additional information that helps computers understand the structure and meaning of the text. For instance, a token might know whether it’s a noun, verb, or adjective, its base form (lemma), or even its position in a sentence. When raw text is processed by an NLP library, the library “tokenizes” the text, breaking it into smaller parts (tokens). Each token becomes a rich object containing metadata about that piece of text.

Key Features of Token Objects

  1. Text Content: The actual word or segment of text represented by the token.
  2. Lemma: The base form of the word (e.g., “running” becomes “run”).
  3. Part of Speech (POS): The grammatical category of the word (e.g., noun, verb, adjective).
  4. Dependencies: Relationships between words in the sentence (e.g., subject, object).
  5. Offsets: Start and end positions of the token in the original text.
  6. Attributes: Whether the token is a punctuation mark, stop word (common but unimportant word like “the” or “and”), or other special text.

Why Use Token Objects in NLP?

Token objects are invaluable because they allow detailed linguistic analysis without having to write custom code for parsing and annotating text. These objects make it easy to:
  • Analyze grammatical structure: Understand how words function in a sentence.
  • Extract metadata: Retrieve information like lemmas and part-of-speech tags for downstream tasks.
  • Annotate text efficiently: Use built-in attributes to quickly identify features like stop words or punctuation. Some functions within NLTK and SpaCy actually do the part of speech annotation for you in some circumstances, making some tasks much less troublesome.

Examples

For this example, we’re loading in Spacy and from it, loading in a small English pipeline that’s very feature rich. We then use this pipeline to take core data from our sentence using the nlp method. Then for each word, we print out the text, the lemma, and the part of speech the word or symbol belongs to.

Sparse Matrices: Efficient Data Structures, Use Cases, and Examples

What Are Sparse Matrices?

A sparse matrix is a compact way to store data with lots of zeroes. In NLP, it’s used to represent text as numbers, like in the bag-of-words model, where each word’s presence is encoded as 1 (present) or 0 (absent). It should be noted that “compact” does not mean small; While the storage requirements are usually much smaller than some other matrix based interaction tables, for large corpi you can quickly hit a matrix with billions of cells.

Why Use Sparse Matrices in NLP?

  • To efficiently store large datasets.
  • To prepare text for simpler machine learning models. Dense Matrices, which are much less memory efficient are often used for more complex tasks.

Examples

This one is a bit trickier without some underlying knowledge, but let’s dig into it. First, we’ll import SciKitLearn, a machine learning package, and assign the tool for converting text into a numerical matrix (CountVectorizer()) to an easier to use “vectorizer”. Then, we have our documents that we want to fit into a matrix. When we say fit, we mean it looks at the word choices for each document and identifies each unique word, and converts this information into a matrix showing if any of the unique words actually show up in the document. In this case, the words “fun”, “nlp”, “is”, “with” and “pyfriday” are all unique terms. Normally this function will also arrange words in alphabetical order, so we need to keep that in mind when examining whether a word is or is not present in the subsequent matrix.

Vectors and Embeddings: Dense Vector Representations, Use Cases, and Examples

What Are Vectors and Embeddings?

In NLP, vectors are numerical representations of text. They are a way to convert words, phrases, or even entire documents into a format that machines can process: arrays of numbers. Each dimension in a vector represents some aspect of the text, such as its occurrence in a corpus, its relationship to other words, or its position in a semantic space. Embeddings are a specific type of vector representation that go beyond simple numerical representations like one-hot encoding or term frequency. Embeddings are dense vectors learned from data, and they capture the semantic meaning of words by placing similar words closer together in the vector space.

Why Use Vectors and Embeddings in NLP?

  • To represent text numerically for machine learning.
  • To capture relationships between words (e.g., “king” and “queen” are related).

Examples

here, we have a slightly different bit of code than we did with the sparse matrix. Namely, we’re using a vectorizer that takes into account relative importance as well as position, so we don’t just have 1’s and 0’s, but rather the relationship dynamic as well that ranges from 0-1 showing how critical a term is to the text.

Sequences: Ordered Collections for Modeling, and Examples

What Are Sequences?

A sequence in NLP refers to an ordered list of elements that can represent words, characters, or tokens. Sequences preserve the order in which these elements appear in the text, which is crucial for understanding the context and meaning of the text. Unlike individual words or isolated tokens, sequences allow models to capture the relationships between elements over time or across positions. Sequences are used in models designed to process and understand text step-by-step, such as Recurrent Neural Networks (RNNs), Long Short-Term Memory networks (LSTMs), and modern architectures like Transformers.

Why Use Sequences in NLP?

  • Language inherently depends on order. For example:
    • The sentence “I ate the cake” is vastly different from “The cake ate I.”
    • Words gain meaning from their position and their relationship with surrounding words.Language inherently depends on order. For example:
  • Sequences help capture:
    • Context: Understanding how earlier elements in the sequence influence later ones (e.g., “not happy” conveys a different meaning than “happy”).
    • Order: The specific arrangement of elements matters (e.g., the difference between “He eats quickly” and “Quickly, he eats”).
    • Dependency: Words or tokens often depend on one another over long distances in a text.

Examples

This itself is an incredibly simple example, mostly as we’ll cover sequences much later and it’ll require much more depth. For now though, the most basic of basics will do.

Conclusion

In this tutorial, we explored the foundational text data types used in natural language processing: strings for raw text; lists of strings for tokenized words or sentences; dictionaries for mapping words to values; and DataFrames for organizing datasets with metadata. We also introduced token objects, sparse matrices, vectors and embeddings, and sequences. Together, these data types provide a foundation for processing, analyzing, and modeling text.

Happy learning, and see you at the next PyFriday!

Humanities Moment

The featured image for this PyFriday is Manuscript Book mural in Evolution of the Book series (1896) by John White Alexander (American, 1856-1915). John White Alexander was an American painter and illustrator known for his portraits, decorative works, and murals. Orphaned as a child, he was raised by his grandparents and later mentored by Edward J. Allen, who nurtured his artistic talent. Starting as an illustrator for Harper’s Weekly, he pursued formal training in Europe, gaining influence from artists like Whistler and Duveneck. Returning to New York, he achieved acclaim for his portraits of prominent figures and murals like "Apotheosis of Pittsburgh," with his works displayed in major museums across the United States and Europe.

Measures of dispersion

In this tutorial, we will explore the key measures of dispersion used in descriptive statistics: range, variance, and standard deviation. These measures help describe the spread or variability of data in a dataset.

By the end of this tutorial, you will understand what each measure of dispersion represents, how to calculate them, and when to use them. We will also provide practice questions to help reinforce your understanding.

1. Introduction to Measures of Dispersion

Measures of dispersion describe how spread out or scattered the values in a dataset are. While measures of central tendency (mean, median, mode) summarize the center of the data, measures of dispersion provide insights into the variability of the data. This is important because two datasets can have the same mean but different levels of variability, which can impact data interpretation.

The most common measures of dispersion are range, variance, and standard deviation.

2. What is the Range?

The range is the simplest measure of dispersion. It represents the difference between the highest and lowest values in a dataset, showing the total spread of the data.

2.1 Definition of Range

The range is the difference between the maximum and minimum values in a dataset. It provides a basic measure of the overall spread of the data, but it does not consider the distribution of the values between the extremes.

2.2 How to Calculate the Range

The formula for calculating the range is:

Range=Maximum Value−Minimum Value \text{Range} = \text{Maximum Value} – \text{Minimum Value}

For example, if the highest value in a dataset is 90 and the lowest value is 50, the range is:

Range=90−50=40 \text{Range} = 90 – 50 = 40

2.3 When to Use the Range

The range is useful when you want a quick, general sense of the spread of data. However, it is sensitive to outliers, as a single extreme value can significantly affect the range. Therefore, it is not always the most reliable measure of dispersion for datasets with outliers.

3. What is the Variance?

Variance is a measure of dispersion that calculates how much each value in a dataset differs from the mean. Variance gives more weight to larger deviations from the mean, making it a good measure of variability, especially in datasets with widely spread values.

3.1 Definition of Variance

Variance is the average of the squared differences between each data point and the mean of the dataset. It provides insight into the overall variability of the data, but because the differences are squared, variance is not in the same unit as the original data (e.g., if the data are in units of dollars, the variance is in dollars squared).

3.2 How to Calculate the Variance

The formula for variance differs slightly depending on whether you are calculating it for a population or a sample.

Where:

3.3 When to Use the Variance

Variance is useful when you want to understand the overall variability of a dataset, especially in datasets with large differences from the mean. However, because variance is in squared units, it is often less interpretable than standard deviation, which presents the variability in the same units as the original data.

4. What is the Standard Deviation?

The standard deviation is the square root of the variance. It provides a measure of dispersion in the same units as the original data, making it easier to interpret than variance. Standard deviation is widely used in public health and biostatistics to measure the variability or spread of data.

4.1 Definition of Standard Deviation

Standard deviation measures the average amount by which each data point differs from the mean. It is widely used because it is in the same units as the original data, making it easier to understand. A low standard deviation indicates that the data points are close to the mean, while a high standard deviation indicates that the data points are spread out over a wider range of values.

4.2 How to Calculate the Standard Deviation

The formula for standard deviation is:

Where:

4.3 When to Use the Standard Deviation

Standard deviation is used when you need a measure of variability that is easy to interpret. It is useful for comparing the spread of data between different datasets and for understanding the typical amount by which data points deviate from the mean.

5. Practice Questions

Test your understanding of the measures of dispersion with these practice questions. Try answering them before checking the solutions.

Question 1:

A dataset contains the following values: 10, 15, 20, 25, 30. What is the range?

Answer 1:

Answer, click to reveal

Range=30−10=20 \text{Range} = 30 – 10 = 20

Question 2:

A dataset contains the values 5, 7, 8, 10, and 12. Calculate the variance (sample variance).

Answer 2:

Answer, click to reveal

Step 1: Find the mean: x‾=5+7+8+10+125=8.4 \overline{x} = \frac{5 + 7 + 8 + 10 + 12}{5} = 8.4

Step 2: Subtract the mean from each value and square the result: (5−8.4)2=11.56 (5 – 8.4)^2 = 11.56 , (7−8.4)2=1.96 (7 – 8.4)^2 = 1.96 , (8−8.4)2=0.16 (8 – 8.4)^2 = 0.16 , (10−8.4)2=2.56 (10 – 8.4)^2 = 2.56 , (12−8.4)2=12.96 (12 – 8.4)^2 = 12.96

Step 3: Sum the squared differences: 11.56+1.96+0.16+2.56+12.96=29.2 11.56 + 1.96 + 0.16 + 2.56 + 12.96 = 29.2

Step 4: Divide by (n – 1): s2=29.24=7.3 s^2 = \frac{29.2}{4} = 7.3

Question 3:

A sample has a variance of 9. What is the standard deviation?

Answer 3:

Answer, click to reveal

s=9=3 s = \sqrt{9} = 3

6. Conclusion

Measures of dispersion—range, variance, and standard deviation—are critical tools in descriptive statistics that help us understand the spread or variability of data. While the range provides a quick overview of the data spread, variance and standard deviation offer more detailed insights into how data points deviate from the mean.

Remember:

Final Tip for the CPH Exam:

Make sure you understand how to calculate and interpret each measure of dispersion, and how they are used in studies.

Humanities Moment

The featured image for this article is Öland (1912) by Helge Johansson (Swedish, 1886–1926). Unfortunately, despite Johansson’s artwork showing up at multiple auctions and the works garnering thousands of dollars, there is very little biographical information available.

Mean, median and mode

In this tutorial, we will explore the three primary measures of central tendency: the mean, median, and mode. These statistical tools are used to summarize data by identifying a central point or typical value in a dataset.

By the end of this tutorial, you will understand what each measure of central tendency represents, how they are calculated, and when to use them. We will also provide practice questions to help reinforce your understanding.

1. Introduction to Descriptive Statistics

Descriptive statistics provide a way to summarize and describe the main features of a dataset. Measures of central tendency—mean, median, and mode—are used to identify a single value (or in many cases, a set of values) that represents the center of the data. These measures give us insight into where the majority of data points lie and help us understand the overall pattern in the dataset.

Each measure of central tendency has its own strengths and weaknesses, and it is important to choose the right one depending on the data distribution and the context of the analysis.

2. What is the Mean?

The mean (often referred to as the average) is the most commonly used measure of central tendency. It represents the arithmetic average of a set of values and is calculated by summing all the values in the dataset and then dividing by the number of values.

2.1 How to Calculate the Mean

The formula for calculating the mean is:

Mean=∑xn \text{Mean} = \frac{\sum{x}}{n}

Where:

2.2 When to Use the Mean

The mean is useful when you have a dataset without extreme outliers and when you want to take all values into account. It provides a comprehensive measure of central tendency but can be misleading if the data are heavily skewed by outliers.

3. What is the Median?

The median is the middle value in a dataset when the values are arranged in ascending or descending order. If the dataset has an odd number of values, the median is the middle value; if the dataset has an even number of values, the median is the average of the two middle values.

3.1 Definition of the Median

The median is the value that separates the dataset into two equal halves: 50% of the data points are smaller than the median, and 50% are larger. The median is not affected by outliers, making it a better measure of central tendency for skewed distributions.

3.2 How to Calculate the Median

To calculate the median:

3.3 When to Use the Median

The median is useful when the dataset contains outliers or when the data are skewed. It provides a more accurate representation of the center of the data in these situations compared to the mean.

4. What is the Mode?

The mode is the value that appears most frequently in a dataset. Unlike the mean and median, the mode can be used for both numerical and categorical data. A dataset may have more than one mode (bimodal or multimodal) if multiple values occur with the same highest frequency.

4.1 Definition of the Mode

The mode is the value that occurs most often in a dataset. In some cases, there may be no mode if no value repeats, or there may be multiple modes if several values have the same frequency.

4.2 How to Calculate the Mode

To calculate the mode:

4.3 When to Use the Mode

The mode is useful for categorical data (e.g., identifying the most common category) or for datasets with repeated values. It is less commonly used for continuous data unless you want to identify the most frequent value.

5. Practice Questions

Test your understanding of the measures of central tendency with these practice questions. Try answering them before checking the solutions.

Question 1:

A dataset contains the following values: 2, 4, 4, 5, 7, 8, 10. What is the mean of this dataset?

Answer 1:

Answer, click to reveal

Mean=2+4+4+5+7+8+107=407≈5.71 \text{Mean} = \frac{2 + 4 + 4 + 5 + 7 + 8 + 10}{7} = \frac{40}{7} \approx 5.71

Question 2:

The following values represent the number of hours worked by a group of individuals: 20, 25, 30, 35, 40. What is the median?

Answer 2:

Answer, click to reveal

Since there is an odd number of values, the median is the middle value, which is 30.

Question 3:

A set of test scores contains the following values: 85, 90, 90, 95, 100. What is the mode?

Answer 3:

Answer, click to reveal

The mode is 90, as it appears more frequently than the other values.

6. Conclusion

Measures of central tendency—mean, median, and mode—are fundamental tools in descriptive statistics that help summarize data by identifying its central point. Each measure has its own strengths and is appropriate for different types of data or distributions. Choosing the right measure of central tendency depends on the characteristics of the data, such as whether the data include outliers or are skewed.

Remember:

Final Tip for the CPH Exam:

Ensure you understand how to calculate and interpret each measure of central tendency. In particular, keep in mind what might be the best for situations with normal distributions, skewed distributions, and so on.

Humanities Moment

The featured image for this article is Albicocca Alessandrina a Mandorla Amara. [Armeniaca Alexandrina ; Apricot (1817-1839) by Giorgio Gallesio (Italian, 1772-1839). Giorgio Gallesio, an 18th-19th century Italian botanist, specialized in citrus and authored the influential Traité du citrus, which challenged prevailing ideas by showing hybrids result from outcross pollination, not grafting. He also explored species compatibility and coined the term “dominant” in hereditary studies, cementing his legacy in botany and genetics.

Create Leaflet maps with Folium and GeoPandas

Introduction

Welcome to this PyFriday tutorial! Today, we're diving into a project where we'll use Python to create an interactive map that shows critical health infrastructure across the United States. Imagine you've been assigned a project to understand the distribution of two types of hospitals:

Our goal is to help public health analysts quickly understand where these resources are located, providing insights into how well regions are served by medical facilities. In this tutorial, we will be using Folium for mapping,GeoPandas for handling geographic data, and Pandas for data processing. Let’s get started with a step-by-step approach!

1. Importing Necessary Libraries

The first step in any Python project is to import the necessary libraries. Here, we're using Folium, GeoPandas, and Pandas:

Each library has its unique role in this project:

2. Loading the Data

Next, we load the hospital and county boundary data. This includes a GeoJSON file for hospitals and a shapefile for county boundaries:

You may have noticed they're the same command; GeoPandas read_file() can take multiple file types due to the nature of the function itself. Both datasets are loaded into GeoDataFrames, which are like Pandas DataFrames but are specially designed to work with geographic data.

3. Handling JSON Serialization Issues

Sometimes, the hospital data contains columns that cannot be directly converted into JSON format, such as datetime fields. This can cause issues when adding data to the map, and unlucky for us, we have some datetime objects in our geojson data. To solve this, we convert any datetime columns to strings:

For the above chunk, we're using hospitals.select_dtypes(include=['datetime', 'datetimetz']) to go into the hospitals DataFrame, then selecting any columns with the data type of datetime or the alternative datetimetz, and once these are selected, we simply use the hospitals[column] = hospitals[column].astype(str) to reassign the type from a date type to a type of string.  By converting datetime fields to strings, we make the data compatible for visualization. Folium uses GeoJSON, which requires all data to be serializable (i.e., easy to convert into a JSON format that the browser can read).

4. Filtering the Data for Specific Criteria

General Hospitals with 100+ Beds

We only want to display general medical and surgical hospitals with 100 or more beds, as these represent significant healthcare resources:

Here, we use filtered_hospitals_points to create a new dataset from the hospitals data, but only keep rows that match our conditions:

This ensures that our map only shows larger hospitals capable of handling more patients. As an aside, this also greatly reduces the amount of data being used, and thus the end product will be more manageable. To create an end product for all hospitals in a way similar to how we're doing it would create an interactive map over 10GB in size.

5. Adding Tooltips for Hospital Information

To make our map interactive, we add tooltips. A tooltip is the information box that pops up when you hover over a point on the map. We add details like hospital name, address, and bed count:

  The tooltips give more context to users of the map. You'll notice that within the pop-up, html is used for bolding and creating new lines, and we can call values to be displayed by pointing to the column name, with the row being the location being clicked on.

6. Creating the Base Map

Now it’s time to create our base map. We will center it on the USA, with a zoom level of 5:

Explanation for New Users: The folium.Map() function creates a basic map that will serve as the canvas. We use:

7. Adding Hospital Data to the Map

We can now add a layer to display the general hospitals with 100+ beds. This layer will be initially hidden so users can choose to see it:

We use folium.FeatureGroup to create this group of features (in this case, hospital points).

8. Visualizing Trauma Level I Facilities by County

Now we’ll add information about Level I trauma facilities, focusing on county-level aggregation:

9. Adding Styling and Tooltips for Trauma Layers

To make the trauma data more visually informative, we define a color scale based on the number of Level I trauma centers in each county. This helps users quickly see which areas may have potential gaps or much higher expenses associated with accessing care.

We use different shades of color to visually communicate the distribution of trauma facilities. The darker the color, the more trauma centers are present in that county. We also are joining our hospital locations to our county layer, making it so that users can see exactly where facilities are, alongside a count of how many facilities are available by county.

10. Adding a Custom Legend

A map is much easier to interpret if it has a legend that explains the color coding. We add a custom HTML legend to the map:

This custom HTML legend helps users understand what the different colors on the map represent, making it much more intuitive to interpret. There is a weakness to this approach in that it won't adjust if there's a sudden influx or removal of facilities, but considering the fact most Trauma I facilities last for decades and take a long time to build, this isn't so much of a concern here.

11. Finalizing the Map with Layer Control and Saving

To complete our interactive map, we add a layer control widget that allows users to toggle between different layers:

Finally, we save the map to an HTML file so it can be viewed in a web browser:

Saving the map as an HTML file means that anyone with a browser can view it. It also makes sharing easy, allowing the map to be embedded in websites or shared directly. It should be noted though that depending on the size of your map, some ways of sending data (e.g. email) may not be ideal.  

Checking Results

Now that we have a map, let's open it up and check our results. Keep in mind you can adjust layers using the sandwich marker on the right hand side.

Open the interactive map in a new tab. This historical tutorial output is approximately 37 MB and may take time to load. It is not a current directory of hospital services.

Conclusion and Further Improvements

Congratulations on completing this project! You now have a functional, interactive map that provides insights into the distribution of major hospitals and trauma centers in the United States. This project has covered some core concepts:

Ideas for Further Development

We hope this tutorial has helped you feel more comfortable with mapping in Python! Keep in mind this is an entire field on its own, so there's plenty more to learn!

References

Humanities Moment

The featured image for this article is Boy with Map of Scandinavia (1771) by Ulrika Pasch (Swedish, 1735-1796). Ulrika "Ulla" Fredrica Pasch was a prominent Swedish Rococo painter and miniaturist. Born into an artistic family, she was the daughter of painter Lorens Pasch the Elder and the sister of Lorens Pasch the Younger. Trained by her father, Ulrika began her professional career in the 1750s, eventually establishing her own studio and clientele. In 1773, she became the only female member inducted into the Royal Swedish Academy of Arts that year. Throughout her career, Pasch was commissioned by members of the Swedish aristocracy and royal court, earning recognition as one of the most successful female artists in Sweden before the 19th century.

Causal inference in public health

In this tutorial, we will explore the concept of causal inference in public health research. Causal inference refers to the process of determining whether an observed association between an exposure and an outcome reflects a true causal relationship. This process is essential in epidemiology because public health interventions rely on accurate identification of causal factors that impact health outcomes. Understanding causal inference is key for the Certified in Public Health (CPH) exam and for interpreting research that informs public health decisions.

By the end of this tutorial, you will understand the importance of causal inference, the methods used to establish causality, and the challenges involved in determining causality in public health research. Practice questions are included to reinforce your knowledge.

1. Introduction to Causal Inference

Causal inference refers to the process of determining whether an exposure causes an outcome. It involves evaluating whether changes in one variable (e.g., smoking) lead to changes in another variable (e.g., lung cancer). While observational studies often reveal associations between exposures and outcomes, they do not necessarily imply causality. Causal inference requires careful consideration of the evidence and the use of appropriate methods to rule out alternative explanations such as confounding, bias, or random chance.

2. Why is Causal Inference Important in Public Health?

In public health, understanding the cause of health outcomes is critical for designing effective interventions and policies. If we can identify a true cause of a health issue, we can take action to prevent it. However, if the cause is incorrectly identified due to improper causal inference, interventions may be ineffective or even harmful. For example, knowing that smoking causes lung cancer has led to significant public health campaigns and policies to reduce smoking rates, saving countless lives.

Accurate causal inference allows public health professionals to:

3. Challenges in Establishing Causality

Establishing causality in public health research can be difficult due to several challenges:

4. Methods for Causal Inference

Several methods are used to establish causal relationships in public health research. While no single method can definitively prove causality, the combination of evidence from multiple sources strengthens the case for a causal relationship.

4.1 Experimental Studies (Randomized Controlled Trials)

Randomized controlled trials (RCTs) are considered the gold standard for establishing causality. In RCTs, participants are randomly assigned to receive either an intervention or a control (e.g., placebo). Randomization helps to evenly distribute confounders across the groups, reducing the risk of bias and allowing researchers to draw stronger conclusions about the causal effect of the intervention on the outcome.

However, RCTs are often impractical or unethical in public health research, especially for harmful exposures like smoking or pollution.

4.2 Observational Studies (Cohort and Case-Control Studies)

Cohort studies and case-control studies are the most common types of observational studies used in public health research. While these studies cannot definitively establish causality, they provide valuable evidence about associations between exposures and outcomes.

4.3 Statistical Methods for Adjusting for Confounding

Confounding can distort the relationship between an exposure and an outcome, making it appear that there is a causal relationship when there is not. To address confounding, researchers use statistical methods to adjust for confounders and isolate the effect of the exposure.

4.4 Hill’s Criteria for Causation

Hill’s criteria for causation provide a framework for evaluating whether an observed association is likely to be causal. These nine criteria include:

5. Practice Questions

Test your understanding of causal inference with these practice questions. Try answering them before checking the solutions.

Question 1:

A study finds that individuals who exercise regularly have a lower risk of heart disease. However, individuals who exercise may also eat healthier diets and be wealthier. What issue does this example highlight?

Answer 1:

Answer, click to reveal

This example highlights the issue of confounding, where factors such as diet and wealth may influence the relationship between exercise and heart disease, potentially distorting the observed association.

Question 2:

A randomized controlled trial finds that a new medication reduces blood pressure in individuals compared to a placebo. What method was used to minimize confounding in this study?

Answer 2:

Answer, click to reveal

Randomization was used to minimize confounding by evenly distributing potential confounders across the treatment and placebo groups.

Question 3:

A researcher uses multivariable regression to adjust for age and smoking status when examining the relationship between alcohol consumption and liver disease. What is the researcher trying to control for?

Answer 3:

Answer, click to reveal

The researcher is trying to control for confounding by adjusting for age and smoking status, which could influence the relationship between alcohol consumption and liver disease.

6. Conclusion

Causal inference is a critical process in public health research, allowing researchers to determine whether observed associations are truly causal. While it is challenging to establish causality, the combination of evidence from randomized controlled trials, observational studies, and statistical methods can provide strong support for causal relationships.

Remember:

Final Tip for the CPH Exam:

Make sure you understand the various methods used for causal inference and the challenges involved in establishing causality. Practice applying these methods to different research scenarios, as this knowledge is crucial for answering questions related to causality in the Certified in Public Health (CPH) exam.

Humanities Moment

The featured image for this CPH Focus is Anacardium occidentale (1909) by Ellen Isham Schutt (American, 1873 – 1955).  Schutt was an American botanical illustrator renowned for her contributions to the U.S. Department of Agriculture’s Pomological Watercolor Collection, painting over 700 detailed watercolors of fruits and nuts. Born in Arlington, Virginia, she was also an early resident of Cherrydale, where she built a notable neoclassical home and contributed to genealogical research. Her precise illustrations, often highlighting fruit imperfections, supported agricultural studies and reflected Progressive Era ideals of nature control. Later, she painted an extensive series of apples for the University of California and modeled fruit in wax to study preservation. Schutt’s legacy endures through her detailed botanical art.

Association versus causation

In this tutorial, we will explore the critical distinction between association and causation in epidemiology. While association refers to a statistical relationship between two variables, causation means that one variable directly influences another. Understanding this difference is crucial for public health professionals, as it affects how research findings are interpreted and how public health policies are shaped. This topic is also essential for the Certified in Public Health (CPH) exam.

By the end of this tutorial, you will understand the concepts of association and causation, the challenges in establishing causality, and the importance of this distinction in public health research. Practice questions are provided to reinforce your knowledge.

1. Introduction to Association and Causation

In epidemiology, researchers often observe a relationship between two variables, such as an exposure (e.g., smoking) and an outcome (e.g., lung cancer). However, the presence of an association between these variables does not necessarily mean that one causes the other. Causation implies that changes in one variable directly result in changes in another. Distinguishing between association and causation is fundamental for making accurate public health recommendations and implementing effective interventions.

2. What is Association?

Association refers to a statistical relationship between two variables. If two variables are associated, it means that changes in one variable are related to changes in another. However, association does not imply that one variable causes the other; it merely indicates that they are linked in some way.

2.1 Definition of Association

An association between two variables exists when the occurrence or level of one variable is related to the occurrence or level of another variable. Associations can be positive (both variables increase or decrease together) or negative (as one variable increases, the other decreases).

2.2 Examples of Association

3. What is Causation?

Causation refers to a direct relationship between two variables, where changes in one variable directly result in changes in another. For example, if smoking causes lung cancer, this means that smoking directly increases the risk of developing lung cancer, regardless of other factors.

3.1 Definition of Causation

Causation occurs when there is sufficient evidence to show that changes in an exposure lead directly to changes in the outcome. Establishing causality requires more than just an observed association; it also involves demonstrating that the exposure precedes the outcome and that the relationship is not explained by other factors.

3.2 Challenges in Establishing Causation

While associations are relatively easy to identify in observational studies, establishing causation is much more difficult. The following are some key challenges in determining causality:

4. Methods to Assess Causality

To assess whether an association is likely to be causal, researchers use several methods, including:

5. Practice Questions

Test your understanding of the difference between association and causation with these practice questions. Try answering them before checking the solutions.

Question 1:

A study finds that people who drink more coffee tend to have lower rates of depression. Can we conclude that drinking coffee prevents depression?

Answer 1:

Answer, click to reveal

No, this study demonstrates an association between coffee consumption and lower rates of depression, but it does not prove causation. Other factors, such as lifestyle or genetics, may be involved in the relationship.

Question 2:

A clinical trial randomly assigns participants to either receive a vaccine or a placebo. After two years, the vaccinated group has a significantly lower rate of infection compared to the placebo group. Can this study conclude causality?

Answer 2:

Answer, click to reveal

Yes, this randomized controlled trial provides strong evidence for causality, as participants were randomly assigned to exposure groups, reducing the risk of bias and confounding. The vaccine likely caused the reduction in infection rates.

Question 3:

A study finds that people who eat more vegetables have lower rates of heart disease. However, people who eat vegetables also tend to exercise more and have higher incomes. What issue might complicate the interpretation of this association?

Answer 3:

Answer, click to reveal

This is an example of confounding, where factors such as exercise and income may be influencing the relationship between vegetable consumption and heart disease. These factors need to be controlled for to assess whether the association is causal.

6. Conclusion

In epidemiology, it is essential to distinguish between association and causation. While associations are often observed in studies, they do not necessarily imply that one variable causes the other. Establishing causality requires a more rigorous evaluation, including demonstrating that the exposure precedes the outcome, ruling out confounding factors, and providing evidence from experimental or longitudinal studies.

Remember:

Final Tip for the CPH Exam:

Make sure you understand the distinction between association and causation. One helpful exercise is skimming science news articles, and then reading the underlying studies. Did the author of the article state causation from association? Or were they accurate to the source material? How do you know? This distinction is crucial for interpreting research findings and making sound public health decisions, and will be tested on the Certified in Public Health (CPH) exam.

Humanities Moment

The featured image for this CPH Focus is Histoire naturelle des champignons Pl.54 (1883) by Guillaume Sicard (French, 1829-1886). Sicard actually has very little known of himself aside from his work being published within Histoire naturelle des champignons, or “The Natural History of Mushrooms”. This is particularly interesting as the work itself has been seen as a critical work of plant and fungus taxonomical art.