L2- 209 Lecture: Null Hypotheses and Variable Types
Secrets to Success in BILE 209
Learning Programming with R:
Learning to program is acknowledged as an overwhelming experience for beginners.
First introductions to R occur in the week one lab sessions.
Study Recommendations:
Revisit Lab Recordings: Recordings of week one labs are posted to allow students to review the material at their own pace (faster or slower) to catch missed details.
Compare Solutions: Solutions for lab documents are provided to compare student work with the expected results, though slight differences are normal.
Open Practice: Students are encouraged to practice creating objects and vectors in R.
Data Carpentry: Links to a "data carpentry" site on the "Learn" platform provide additional exercises to develop coding skills.
Handling Errors:
Error messages are common, even for experienced coders.
Google is recommended as a primary resource for troubleshooting by copying and pasting the specific error message into the search engine.
Generative AI Warning:
While Generative AI is a known tool for coding, research suggests that relying on it in the early stages of learning how to code can actually slow down the learning process.
Curated course resources are specifically designed to align with the teaching curriculum and are considered more effective and less confusing for students than general sources pulled by AI.
Classification of Variable Types
Understanding data types is the prerequisite for developing predictions, models, and experimental designs.
Variables are broadly categorized into Categorical and Numeric.
Categorical Variables:
Nominal: These variables have no inherent or natural order.
Examples: Hair color (blonde, brunette, black, red), eye color, and types of animals (dogs, cats, lizards, fish).
Ordinal: These variables have a specific inherent order or ranking.
Examples: Level of study (first year, second year), grades, playing card suits (king, queen), and sides of a coin (dichotomous).
Numeric Variables:
Continuous: These can take any value, including decimals and fractions.
Examples: Weight, height, age (if measured precisely), and growth rates.
Discrete: These are generally integers or whole numbers representing counts.
Examples: Number of siblings (you cannot have a half-sibling), counts of fish, and age (if measured only in whole years).
Importance of Context and Measurement:
The way a variable is measured determines its type and dictates the analysis that can be performed.
Example: Coin Flips:
Can be treated as Ordinal if one side is defined as "winning" over the other.
Can be treated as Nominal if there is no defined hierarchy.
Can be treated as Discrete when involved in probability distributions (discussed in future lectures).
Example: "One in three" () Fish:
If counting individual fish, it is Discrete.
If calculating the proportion or fraction of fish, it is Continuous.
Defining Hypotheses
Notation and Modeling:
Hypotheses and models in R are often set up using the notation where the response is a function of the predictor: .
The tilde symbol () indicates the "function of" relationship.
The Null Hypothesis ():
Definition: States that the predictor variable does not have an effect on the response variable.
This represents a state of "no effect" or patterns driven purely by random chance.
The Alternative Hypothesis ():
Definition: States that the predictor variable does have an effect on the response variable.
Non-directional: Simply states an effect exists without specifying direction ().
Directional: Specifies the nature of the effect (e.g., "Predictor increases Response" or "Predictor decreases Response").
Exam Requirement: When writing hypotheses for tests or quizzes, students must replace the generic terms "predictor" and "response" with the specific variable names from the problem to receive full marks.
The Scientific Method and Null Hypothesis Testing
Process Steps:
Observation: Initial identification of a pattern (e.g., observing plastic in fish samples).
Define Hypotheses: Formulate (no effect) and (effect exists).
Data Collection: Gathering a large enough sample size to evaluate the pattern.
Evaluation: Determining whether to reject or fail to reject the null hypothesis.
Interpreting Results:
Rejecting : Evidence suggests the pattern is not due to random chance.
Failing to Reject : There is insufficient evidence to say an effect exists; patterns are consistent with random chance.
Crucial Rule: We never conclude that the null hypothesis is "true." We only ever "fail to reject" it. Every outcome is possible; some are just more likely than others under random chance.
Alternative Caveat: We cannot definitively say the alternative hypothesis is "true" even if the null is rejected, as confounding factors (unmeasured variables) might actually be driving the pattern.
Evidence, Significance, and Random Chance
Independent Variables: In the context of a true null hypothesis, variables are considered independent with no relationship between them.
Statistical Analysis Aim: To determine what constitutes a "significant" change or effect versus a difference caused by random chance.
The Multiverse Approach: Testing a null hypothesis can be thought of as sampling across a "multiverse" of potential outcomes to see how probable the observed data is relative to all possible outcomes.
Probability Distributions: Mathematical models of random probabilities used to compare observations to what would be expected at random. These remove the need to manually calculate every possible outcome.
Case Studies and Examples
Statement 1: Fish in warming Scottish seas grow faster but reach a smaller size.
Predictor: Warming Scottish seas (could be nominal categorical if using "warm vs. cool" or continuous if measuring temperature).
Response 1: Growth rate (Continuous numeric).
Response 2: Overall size (Continuous numeric).
Statement 2: Pipefish preference.
Observation: "Pipefish prefer seagrass over bare patches."
Null Hypothesis (): Pipefish have no preference between seagrass and bare patches.
Sample Data Scenario: If pipefish are in seagrass and are in a bare patch, the difference might be due to random chance, small sample size, or confounding variables (e.g., fish clustering together).
Statement 3: Height by location.
Predictor: Location of origin (Nominal categorical).
Response: Student height (Continuous numeric).
Conceptual Test: If the null is true, sorting by height would result in a random mix of locations. If all tall students are from Christchurch and short students are from elsewhere, the null can be rejected.
Statement 4: Marine mammals in the Banks Peninsula.
Observation: out of marine mammals in the Banks Peninsula are threatened or at risk.
Subject Species: Southern right whale, New Zealand fur seal, Hector's dolphin, orca, and sea lion.
Analysis: Compare the observation to a table of all possible outcomes ( at risk, at risk, …, at risk) to determine the likelihood given random chance.
Statement 5: Ocean Acidification.
Observation: Changes in levels over time since .
Predictor: Year (Numeric; usually discrete in studies).
Response: (Numeric; continuous).
Requirements for Meaningful Pattern: More data points between years are needed to ensure the line isn't following random fluctuations, and metadata such as the time of year the sample was taken is required.
Questions & Discussion
Question regarding coin sides as ordinal: A student noted that sides of a coin can be ordinal if one is winning. The instructor confirmed that context and how the variable is defined/measured determines whether it is nominal, ordinal, or discrete.
Question regarding "one in three" fish: A student asked if this was a fraction (continuous) or discrete. The instructor explained that it depends on measurement: counting fish is discrete, but analyzing the proportion is continuous.
Question on concluding the null is true: Through an echo poll, the class discussed if the null can ever be "true." The instructor clarified that we only "reject" or "fail to reject" based on evidence.
Predictor for Christchurch height study: A student suggested that the predictor is categorical because it is "Christchurch vs. somewhere else." The instructor confirmed it is a nominal categorical variable.