2025-02-03

Understanding P-Values

This R Markdown presentation will dive into the definition of what makes a P-Value, and the impact it has within the statistics.

P-Value can be characterized as a probability factor, and helps to measure the ‘likely hood’ of an observed difference between groups.

The fallacies of P-Values deal with if those that conduct the survey but don’t fully understand the observations captured. A threshold could provide correlations however, this reasoning could be inaccurate.

P-Value Formula: p = P(data | (H0)

  • If the p-value is small (\(< 0.05\)), we reject the null hypothesis.
  • If the p-value is large, we fail to reject the null hypothesis.

Plotly Slide of Bee Charactertistics

Here, we visualize the data of different bee types. We could use this data to test whether size, weight, and wing span are related using a statistical hypothesis test.

  • Null Hypothesis: There is no relationship between bee size, weight, and wing span.
  • Alternative Hypothesis: There is a relationship between these variables.

Plotly Graph

Example Two: Hypothesis Testing with P-Value

We can use a statistical test (e.g., Pearson correlation) to test if bee size and weight are correlated.

  • Null Hypothesis: No correlation between size and weight.
  • Alternative Hypothesis: There is a correlation between size and weight.
## [1] 0.6245623

Boxplot of Group Differences and P-Value

We’ll compare two groups (Group A and Group B) using a boxplot and determine whether their means differ significantly using a t-test.

Mathematical Formula for P-Value

The p-value represents the probability of observing data as extreme as, or more extreme than, the observed data, assuming the null hypothesis is true:

\[ p = P(\text{data} \mid H_0) \] Where: - \(H_0\) is the null hypothesis. - \(P(\text{data} \mid H_0)\) is the likelihood of observing the data given that \(H_0\) is true.

R Code for Plots and p-value Calculation

Here’s the R code used to generate the plots and perform hypothesis testing.

Load necessary libraries

library(ggplot2) library(plotly)

Create 3D scatter plot

set.seed(123) bee_data <- data.frame( size = rnorm(100, mean = 5, sd = 1.5), weight = rnorm(100, mean = 0.1, sd = 0.02), wing_span = rnorm(100, mean = 3.5, sd = 0.7) ) plot_ly(bee_data, x = ~size, y = ~weight, z = ~wing_span, type = “scatter3d”, mode = “markers”, marker = list(size = 5, color = bee_data$size, colorscale = “Viridis”, showscale = TRUE)) %>% layout(title = “3D Scatter Plot of Bee Characteristics”, scene = list( xaxis = list(title = “Size (cm)”), yaxis = list(title = “Weight (g)”), zaxis = list(title = “Wing Span (cm)”) ))

Boxplot for Group Comparison

group_a <- rnorm(30, mean = 5.2, sd = 1.1) group_b <- rnorm(30, mean = 5.7, sd = 1.2) data <- data.frame(value = c(group_a, group_b), group = rep(c(“A”, “B”), each = 30))

ggplot(data, aes(x = group, y = value)) + geom_boxplot() + labs(title = “Boxplot of Group A vs Group B”)

p-value from correlation test

cor_test <- cor.test(bee_data\(size, bee_data\)weight) cor_test$p.value

Reference(s)

Thank you!!!