Rationale

The Elaboration Likelihood Model (or ELM) looks at how people or viewers are able to perceive and retain strong persuasive information, and whether the effect of this information has a lasting impact on the viewer. In this study, the participants are tracked on how much time they spend looking at high-quality information about legalizing marijuana. This represents to a degree how much the participants processed the high-quality information compared to what is deemed lower quality. ELM supports the idea that those who spent more time on the high quality information are more likely to support the legalization of marijuana.

Hypothesis

Time (minutes) spent viewing high-quality information is associated with the likelihood of being more in favor of legalizing recreational marijuana use in Tennessee.

Variables & Method

The categorical dependent variable in this study was whether or not participants supported or opposed the legalization of recreational marijuana in Tennessee a month after the study was conducted. The independent variable was how much time the participants spent looking at the high quality persuasive information in favor of legalizing recreational marijuana in Tennessee.

The method of this analysis began with 200 participants who were asked to spend 30 minutes with an eye tracker watching them browse the website of a made-up organization’s website which was advocating to legalize marijuana in Tennessee. All 200 had answered prior to they were on the website that they did not have strong opinions. The eye tracker measured how much of the 30 minutes the participants spent looking at high quality persuasive information in favor of legalizing marijuana rather than what was deemed to be low quality information. A month after the participants looked at the website, they were contacted and asked whether they favored or opposed the legalization of marijuana.

Results & Discussion

Logistic regression was used for the data analysis. The results of this regression aligned with the hypothesis that the time spent viewing high-quality information led to a higher likelihood of being more likely to be in favor of legalizing marijuana. The curve shows a positive relationship between the two variables, as participants who spent more time on high quality information had a higher probability of supporting the legalization of marijuana. These findings are also consistent with ELM.

logit_plotly
results_table
linearity_table
inflection_table

Code

# ------------------------------
# Install and load required packages
# ------------------------------
if (!require("tidyverse")) install.packages("tidyverse")
if (!require("gt")) install.packages("gt")
if (!require("gtExtras")) install.packages("gtExtras")
if (!require("plotly")) install.packages("plotly")

library(ggplot2)
library(dplyr)
library(gt)
library(gtExtras)
library(plotly)


# ------------------------------
# Read the data
# ------------------------------
mydata <- read.csv("mydata <- read.csv("https://github.com/drkblake/Data/raw/refs/heads/main/ELM.csv")

# ################################################
# # (Optional) Remove specific case(es)s by row number
# ################################################
# # Example: remove rows 10 and 25
# rows_to_remove <- c(10, 25) # Edit and uncomment this line
# mydata <- mydata[-rows_to_remove, ] # Uncomment this line

# Specify dependent (DV) and independent (IV) variables
mydata$DV <- mydata$Favor_1   # <-- EDIT DV column
mydata$IV <- mydata$Minutes   # <-- EDIT IV column

# Ensure DV is binary numeric (0/1)
mydata$DV <- as.numeric(as.character(mydata$DV))


# ------------------------------
# Logistic regression plot 
# ------------------------------
logit_plot <- ggplot(mydata, aes(x = IV, y = DV)) +
  geom_point(alpha = 0.5) +   # scatterplot of observed data
  geom_smooth(method = "glm",
              method.args = list(family = "binomial"),
              se = FALSE,
              color = "#1f78b4") +
  labs(title = "Logistic Regression Curve",
       x = "Independent Variable (IV)",
       y = "Dependent Variable (DV)")

logit_plotly <- ggplotly(logit_plot)


# ------------------------------
# Run logistic regression
# ------------------------------
options(scipen = 999)
log.ed <- glm(DV ~ IV, data = mydata, family = "binomial")

# Extract coefficients and odds ratios
results <- broom::tidy(log.ed, conf.int = TRUE, exponentiate = TRUE) %>%
  select(term, estimate, conf.low, conf.high, p.value) %>%
  rename(Odds_Ratio = estimate,
         CI_Lower = conf.low,
         CI_Upper = conf.high,
         P_Value = p.value)

# Display results as a nice gt table
results_table <- results %>%
  gt() %>%
  fmt_number(columns = c(Odds_Ratio, CI_Lower, CI_Upper), decimals = 3) %>%
  fmt_number(columns = P_Value, decimals = 4) %>%
  tab_header(
    title = "Logistic Regression Results",
    subtitle = "Odds Ratios with 95% Confidence Intervals"
  )


# ------------------------------
# Check linearity of the logit (Box-Tidwell test)
# ------------------------------
# (Assumes IV > 0; shift IV if needed)
mydata$IV_log <- mydata$IV * log(mydata$IV)
linearity_test <- glm(DV ~ IV + IV_log, data = mydata, family = "binomial")

linearity_results <- broom::tidy(linearity_test) %>%
  select(term, estimate, std.error, p.value) %>%
  rename(Estimate = estimate,
         Std_Error = std.error,
         P_Value = p.value)

linearity_table <- linearity_results %>%
  gt() %>%
  fmt_number(columns = c(Estimate, Std_Error), decimals = 3) %>%
  fmt_number(columns = P_Value, decimals = 4) %>%
  tab_header(
    title = "Linearity of the Logit Test (Box-Tidwell)",
    subtitle = "Interaction term indicates violation if significant"
  )


# ------------------------------
# Calculate the inflection point (p = .50)
# ------------------------------
p <- 0.50
Inflection_point <- (log(p/(1-p)) - coef(log.ed)[1]) / coef(log.ed)[2]

inflection_table <- tibble(
  Probability = 0.5,
  Inflection_Point = Inflection_point
) %>%
  gt() %>%
  fmt_number(columns = Inflection_Point, decimals = 3) %>%
  tab_header(
    title = "Inflection Point of Logistic Curve",
    subtitle = "Value of IV where predicted probability = 0.50"
  )


# ------------------------------
# Outputs
# ------------------------------
# Interactive plot
logit_plotly

# Tables
results_table
linearity_table
inflection_table