knitr::opts_chunk$set(echo = TRUE, warning = FALSE, message = FALSE)
library(psych)
## Warning: package 'psych' was built under R version 4.3.3
library(lavaan)
## Warning: package 'lavaan' was built under R version 4.3.3
## This is lavaan 0.6-19
## lavaan is FREE software! Please report any bugs.
##
## Attaching package: 'lavaan'
## The following object is masked from 'package:psych':
##
## cor2cov
library(dplyr)
##
## Attaching package: 'dplyr'
## The following objects are masked from 'package:stats':
##
## filter, lag
## The following objects are masked from 'package:base':
##
## intersect, setdiff, setequal, union
library(kableExtra)
## Warning: package 'kableExtra' was built under R version 4.3.3
##
## Attaching package: 'kableExtra'
## The following object is masked from 'package:dplyr':
##
## group_rows
library(semPlot)
## Warning: package 'semPlot' was built under R version 4.3.3
## Warning in check_dep_version(): ABI version mismatch:
## lme4 was built with Matrix ABI version 0
## Current Matrix ABI version is 1
## Please re-install lme4 from source or restore original 'Matrix' package
library(tinytex)
## Warning: package 'tinytex' was built under R version 4.3.3
library(webshot)
## Warning: package 'webshot' was built under R version 4.3.3
library(ggplot2)
## Warning: package 'ggplot2' was built under R version 4.3.3
##
## Attaching package: 'ggplot2'
## The following objects are masked from 'package:psych':
##
## %+%, alpha
library(ggpubr)
library(broom)
## Warning: package 'broom' was built under R version 4.3.3
library(interactions)
## Warning: package 'interactions' was built under R version 4.3.3
# Set working directory and load data
setwd("C:/Users/mitch/Desktop/120_R")
# Load dataset
df <- read.csv("Cleaned_CC_Mood_thinking_Patterns_2025.csv")
# Create affective state composite variables
states <- c("Confident", "Curious", "Bothered", "Interested", "Frustrated", "Uncertain")
for (state in states) {
items <- grep(paste0("_", state, "$"), names(df), value = TRUE)
df[[paste0("State_", state)]] <- rowMeans(df[, items], na.rm = TRUE)
}
# Create InfoSeek variable from *_5sec columns
info_seek_items <- grep("_5sec$", names(df), value = TRUE)
df$InfoSeek <- rowMeans(df[, info_seek_items] == 1, na.rm = TRUE)
# Create Curiosity as composite of I_Type and D_Type
df$Curiosity <- rowMeans(df[, c("I_Type", "D_Type")], na.rm = TRUE)
vars <- c("Curiosity", paste0("State_", states), "InfoSeek", "PANAS_Positive", "PANAS_Negative")
desc_stats <- describe(df[, vars])[, c("mean", "sd")]
# Omega calculation only for state variables
omega_safe <- function(vars) {
if (length(vars) > 1) {
out <- omega(df[, vars], warnings = FALSE)
return(c(omega.tot = out$omega.tot, omega.h = out$omega.h))
} else {
return(c(omega.tot = NA, omega.h = NA))
}
}
omega_total <- omega_hier <- rep(NA, length(vars))
for (i in seq_along(vars)) {
if (grepl("^State_", vars[i])) {
items <- grep(paste0("_", sub("State_", "", vars[i]), "$"), names(df), value = TRUE)
o <- omega_safe(items)
omega_total[i] <- o["omega.tot"]
omega_hier[i] <- o["omega.h"]
}
}
## Loading required namespace: GPArotation
## In smc, smcs > 1 were set to 1.0
## In smc, smcs < 0 were set to .0
## In smc, smcs > 1 were set to 1.0
## In smc, smcs < 0 were set to .0
## In smc, smcs > 1 were set to 1.0
## In smc, smcs < 0 were set to .0
## Warning in cor.smooth(r): Matrix was not positive definite, smoothing was done
## Warning in fac(r = r, nfactors = nfactors, n.obs = n.obs, rotate = rotate, : An
## ultra-Heywood case was detected. Examine the results carefully
## In smc, smcs > 1 were set to 1.0
## In smc, smcs < 0 were set to .0
## Warning in cor.smooth(r): Matrix was not positive definite, smoothing was done
## Warning in cor.smooth(r): Matrix was not positive definite, smoothing was done

## In smc, smcs > 1 were set to 1.0
## In smc, smcs < 0 were set to .0
## In smc, smcs > 1 were set to 1.0
## In smc, smcs < 0 were set to .0
## In smc, smcs > 1 were set to 1.0
## In smc, smcs < 0 were set to .0
## Warning in cor.smooth(r): Matrix was not positive definite, smoothing was done
## Warning in fac(r = r, nfactors = nfactors, n.obs = n.obs, rotate = rotate, : An
## ultra-Heywood case was detected. Examine the results carefully
## Warning in sqrt(1/diag(V)): NaNs produced
## Warning in cov2cor(t(w) %*% r %*% w): diag(.) had 0 or NA entries; non-finite
## result is doubtful
## In smc, smcs > 1 were set to 1.0
## In smc, smcs < 0 were set to .0
## Warning in cor.smooth(r): Matrix was not positive definite, smoothing was done
## Warning in cor.smooth(r): Matrix was not positive definite, smoothing was done

## Warning in fa.stats(r = r, f = f, phi = phi, n.obs = n.obs, np.obs = np.obs, :
## The estimated weights for the factor scores are probably incorrect. Try a
## different factor score estimation method.
## Warning in fac(r = r, nfactors = nfactors, n.obs = n.obs, rotate = rotate, : An
## ultra-Heywood case was detected. Examine the results carefully
## Warning in fa.stats(r = r, f = f, phi = phi, n.obs = n.obs, np.obs = np.obs, :
## The estimated weights for the factor scores are probably incorrect. Try a
## different factor score estimation method.
## Warning in fac(r = r, nfactors = nfactors, n.obs = n.obs, rotate = rotate, : An
## ultra-Heywood case was detected. Examine the results carefully
## Warning in fa.stats(r = r, f = f, phi = phi, n.obs = n.obs, np.obs = np.obs, :
## The estimated weights for the factor scores are probably incorrect. Try a
## different factor score estimation method.
## Warning in cov2cor(t(w) %*% r %*% w): diag(.) had 0 or NA entries; non-finite
## result is doubtful
## Warning in fa.stats(r = r, f = f, phi = phi, n.obs = n.obs, np.obs = np.obs, :
## The estimated weights for the factor scores are probably incorrect. Try a
## different factor score estimation method.

## Warning in fa.stats(r = r, f = f, phi = phi, n.obs = n.obs, np.obs = np.obs, :
## The estimated weights for the factor scores are probably incorrect. Try a
## different factor score estimation method.
## Warning in fac(r = r, nfactors = nfactors, n.obs = n.obs, rotate = rotate, : An
## ultra-Heywood case was detected. Examine the results carefully
## Warning in fa.stats(r = r, f = f, phi = phi, n.obs = n.obs, np.obs = np.obs, :
## The estimated weights for the factor scores are probably incorrect. Try a
## different factor score estimation method.
## Warning in fac(r = r, nfactors = nfactors, n.obs = n.obs, rotate = rotate, : An
## ultra-Heywood case was detected. Examine the results carefully
## Warning in fa.stats(r = r, f = f, phi = phi, n.obs = n.obs, np.obs = np.obs, :
## The estimated weights for the factor scores are probably incorrect. Try a
## different factor score estimation method.
## Warning in cov2cor(t(w) %*% r %*% w): diag(.) had 0 or NA entries; non-finite
## result is doubtful
## Warning in fa.stats(r = r, f = f, phi = phi, n.obs = n.obs, np.obs = np.obs, :
## The estimated weights for the factor scores are probably incorrect. Try a
## different factor score estimation method.

## Warning in fa.stats(r = r, f = f, phi = phi, n.obs = n.obs, np.obs = np.obs, :
## The estimated weights for the factor scores are probably incorrect. Try a
## different factor score estimation method.
## Warning in fac(r = r, nfactors = nfactors, n.obs = n.obs, rotate = rotate, : An
## ultra-Heywood case was detected. Examine the results carefully
## Warning in fa.stats(r = r, f = f, phi = phi, n.obs = n.obs, np.obs = np.obs, :
## The estimated weights for the factor scores are probably incorrect. Try a
## different factor score estimation method.
## Warning in fac(r = r, nfactors = nfactors, n.obs = n.obs, rotate = rotate, : An
## ultra-Heywood case was detected. Examine the results carefully
## Warning in fa.stats(r = r, f = f, phi = phi, n.obs = n.obs, np.obs = np.obs, :
## The estimated weights for the factor scores are probably incorrect. Try a
## different factor score estimation method.
## Warning in cov2cor(t(w) %*% r %*% w): diag(.) had 0 or NA entries; non-finite
## result is doubtful
## Warning in fa.stats(r = r, f = f, phi = phi, n.obs = n.obs, np.obs = np.obs, :
## The estimated weights for the factor scores are probably incorrect. Try a
## different factor score estimation method.

## In smc, smcs > 1 were set to 1.0
## In smc, smcs < 0 were set to .0
## In smc, smcs > 1 were set to 1.0
## In smc, smcs < 0 were set to .0
## In smc, smcs > 1 were set to 1.0
## In smc, smcs < 0 were set to .0
## Warning in cor.smooth(r): Matrix was not positive definite, smoothing was done
## Warning in fac(r = r, nfactors = nfactors, n.obs = n.obs, rotate = rotate, : An
## ultra-Heywood case was detected. Examine the results carefully
## In smc, smcs > 1 were set to 1.0
## In smc, smcs < 0 were set to .0
## Warning in cor.smooth(r): Matrix was not positive definite, smoothing was done
## Warning in cor.smooth(r): Matrix was not positive definite, smoothing was done

# Combine for table
desc_df <- as.data.frame(desc_stats)
desc_df$omega_h <- omega_hier
desc_df$omega_t <- omega_total
desc_df$Variable <- vars
desc_df %>%
kbl(caption = "Table 1. Descriptive Statistics and Omega Reliability", digits = 2) %>%
kable_styling(full_width = TRUE, latex_options = "striped")
Table 1. Descriptive Statistics and Omega Reliability
|
|
mean
|
sd
|
omega_h
|
omega_t
|
Variable
|
|
Curiosity
|
12.88
|
2.50
|
NA
|
NA
|
Curiosity
|
|
State_Confident
|
2.15
|
0.73
|
NA
|
0.95
|
State_Confident
|
|
State_Curious
|
3.47
|
0.79
|
NA
|
0.97
|
State_Curious
|
|
State_Bothered
|
2.32
|
0.91
|
NA
|
0.98
|
State_Bothered
|
|
State_Interested
|
3.51
|
0.76
|
NA
|
0.97
|
State_Interested
|
|
State_Frustrated
|
2.22
|
0.90
|
NA
|
0.98
|
State_Frustrated
|
|
State_Uncertain
|
3.78
|
0.81
|
NA
|
0.97
|
State_Uncertain
|
|
InfoSeek
|
0.51
|
0.35
|
NA
|
NA
|
InfoSeek
|
|
PANAS_Positive
|
22.56
|
8.84
|
NA
|
NA
|
PANAS_Positive
|
|
PANAS_Negative
|
16.57
|
7.99
|
NA
|
NA
|
PANAS_Negative
|
cor_matrix <- round(cor(df[, vars], use = "pairwise.complete.obs"), 2)
kbl(cor_matrix, caption = "Table 2. Pearson Correlation Matrix", digits = 2) %>%
kable_styling(full_width = TRUE, latex_options = "striped")
Table 2. Pearson Correlation Matrix
|
|
Curiosity
|
State_Confident
|
State_Curious
|
State_Bothered
|
State_Interested
|
State_Frustrated
|
State_Uncertain
|
InfoSeek
|
PANAS_Positive
|
PANAS_Negative
|
|
Curiosity
|
1.00
|
0.33
|
0.36
|
0.32
|
0.34
|
0.32
|
-0.05
|
0.27
|
0.32
|
0.17
|
|
State_Confident
|
0.33
|
1.00
|
0.18
|
0.22
|
0.20
|
0.21
|
-0.38
|
-0.03
|
0.39
|
0.14
|
|
State_Curious
|
0.36
|
0.18
|
1.00
|
0.47
|
0.98
|
0.40
|
0.26
|
0.46
|
0.20
|
-0.11
|
|
State_Bothered
|
0.32
|
0.22
|
0.47
|
1.00
|
0.48
|
0.97
|
0.19
|
0.14
|
0.20
|
0.16
|
|
State_Interested
|
0.34
|
0.20
|
0.98
|
0.48
|
1.00
|
0.40
|
0.23
|
0.45
|
0.22
|
-0.12
|
|
State_Frustrated
|
0.32
|
0.21
|
0.40
|
0.97
|
0.40
|
1.00
|
0.16
|
0.12
|
0.19
|
0.18
|
|
State_Uncertain
|
-0.05
|
-0.38
|
0.26
|
0.19
|
0.23
|
0.16
|
1.00
|
0.14
|
0.02
|
-0.03
|
|
InfoSeek
|
0.27
|
-0.03
|
0.46
|
0.14
|
0.45
|
0.12
|
0.14
|
1.00
|
0.14
|
-0.09
|
|
PANAS_Positive
|
0.32
|
0.39
|
0.20
|
0.20
|
0.22
|
0.19
|
0.02
|
0.14
|
1.00
|
0.11
|
|
PANAS_Negative
|
0.17
|
0.14
|
-0.11
|
0.16
|
-0.12
|
0.18
|
-0.03
|
-0.09
|
0.11
|
1.00
|
model <- '
# Predict states from Curiosity
State_Curious ~ Curiosity
State_Frustrated ~ Curiosity
State_Confident ~ Curiosity
State_Bothered ~ Curiosity
State_Interested ~ Curiosity
State_Uncertain ~ Curiosity
# Predict InfoSeek
InfoSeek ~ State_Curious + State_Frustrated + State_Confident +
State_Bothered + State_Interested + State_Uncertain
# PANAS manipulation checks
PANAS_Positive ~ Curiosity
PANAS_Negative ~ Curiosity
'
fit <- sem(model, data = df, estimator = "ML")
summary(fit, standardized = TRUE, fit.measures = TRUE)
## lavaan 0.6-19 ended normally after 46 iterations
##
## Estimator ML
## Optimization method NLMINB
## Number of model parameters 26
##
## Used Total
## Number of observations 110 111
##
## Model Test User Model:
##
## Test statistic 746.079
## Degrees of freedom 28
## P-value (Chi-square) 0.000
##
## Model Test Baseline Model:
##
## Test statistic 857.938
## Degrees of freedom 45
## P-value 0.000
##
## User Model versus Baseline Model:
##
## Comparative Fit Index (CFI) 0.117
## Tucker-Lewis Index (TLI) -0.420
##
## Loglikelihood and Information Criteria:
##
## Loglikelihood user model (H0) -1559.486
## Loglikelihood unrestricted model (H1) -1186.446
##
## Akaike (AIC) 3170.972
## Bayesian (BIC) 3241.185
## Sample-size adjusted Bayesian (SABIC) 3159.024
##
## Root Mean Square Error of Approximation:
##
## RMSEA 0.483
## 90 Percent confidence interval - lower 0.453
## 90 Percent confidence interval - upper 0.513
## P-value H_0: RMSEA <= 0.050 0.000
## P-value H_0: RMSEA >= 0.080 1.000
##
## Standardized Root Mean Square Residual:
##
## SRMR 0.225
##
## Parameter Estimates:
##
## Standard errors Standard
## Information Expected
## Information saturated (h1) model Structured
##
## Regressions:
## Estimate Std.Err z-value P(>|z|) Std.lv Std.all
## State_Curious ~
## Curiosity 0.111 0.028 3.935 0.000 0.111 0.351
## State_Frustrated ~
## Curiosity 0.122 0.033 3.726 0.000 0.122 0.335
## State_Confident ~
## Curiosity 0.094 0.026 3.557 0.000 0.094 0.321
## State_Bothered ~
## Curiosity 0.121 0.033 3.635 0.000 0.121 0.327
## State_Interested ~
## Curiosity 0.103 0.027 3.750 0.000 0.103 0.337
## State_Uncertain ~
## Curiosity -0.014 0.031 -0.438 0.662 -0.014 -0.042
## InfoSeek ~
## State_Curious 0.180 0.038 4.787 0.000 0.180 0.410
## State_Frustrtd 0.037 0.033 1.117 0.264 0.037 0.095
## State_Confidnt -0.062 0.040 -1.540 0.124 -0.062 -0.131
## State_Bothered -0.062 0.032 -1.926 0.054 -0.062 -0.164
## State_Interstd 0.052 0.039 1.352 0.176 0.052 0.115
## State_Uncertan -0.018 0.036 -0.506 0.613 -0.018 -0.042
## PANAS_Positive ~
## Curiosity 1.107 0.322 3.432 0.001 1.107 0.311
## PANAS_Negative ~
## Curiosity 0.675 0.295 2.287 0.022 0.675 0.213
##
## Covariances:
## Estimate Std.Err z-value P(>|z|) Std.lv Std.all
## .InfoSeek ~~
## .PANAS_Positive 0.149 0.243 0.613 0.540 0.149 0.059
## .PANAS_Negative -0.120 0.222 -0.538 0.590 -0.120 -0.051
## .PANAS_Positive ~~
## .PANAS_Negative 3.506 6.135 0.571 0.568 3.506 0.055
##
## Variances:
## Estimate Std.Err z-value P(>|z|) Std.lv Std.all
## .State_Curious 0.537 0.072 7.416 0.000 0.537 0.877
## .State_Frustrtd 0.717 0.097 7.416 0.000 0.717 0.888
## .State_Confidnt 0.473 0.064 7.416 0.000 0.473 0.897
## .State_Bothered 0.743 0.100 7.416 0.000 0.743 0.893
## .State_Interstd 0.509 0.069 7.416 0.000 0.509 0.887
## .State_Uncertan 0.641 0.086 7.416 0.000 0.641 0.998
## .InfoSeek 0.092 0.012 7.416 0.000 0.092 0.777
## .PANAS_Positive 70.202 9.466 7.416 0.000 70.202 0.903
## .PANAS_Negative 58.799 7.928 7.416 0.000 58.799 0.955
sem_output <- parameterEstimates(fit, standardized = TRUE)
sem_table <- sem_output %>%
filter(op == "~") %>%
select(lhs, rhs, est, se, z, pvalue, ci.lower, ci.upper, std.all) %>%
mutate(across(where(is.numeric), round, 3))
## Warning: There was 1 warning in `mutate()`.
## ℹ In argument: `across(where(is.numeric), round, 3)`.
## Caused by warning:
## ! The `...` argument of `across()` is deprecated as of dplyr 1.1.0.
## Supply arguments directly to `.fns` through an anonymous function instead.
##
## # Previously
## across(a:b, mean, na.rm = TRUE)
##
## # Now
## across(a:b, \(x) mean(x, na.rm = TRUE))
colnames(sem_table) <- c("Outcome", "Predictor", "b", "SE", "z", "p", "CI_low", "CI_high", "β")
sem_table %>%
kbl(caption = "Table 3. SEM Path Estimates", digits = 3) %>%
kable_styling(full_width = TRUE, latex_options = "striped")
Table 3. SEM Path Estimates
|
Outcome
|
Predictor
|
b
|
SE
|
z
|
p
|
CI_low
|
CI_high
|
β
|
|
State_Curious
|
Curiosity
|
0.111
|
0.028
|
3.935
|
0.000
|
0.056
|
0.166
|
0.351
|
|
State_Frustrated
|
Curiosity
|
0.122
|
0.033
|
3.726
|
0.000
|
0.058
|
0.185
|
0.335
|
|
State_Confident
|
Curiosity
|
0.094
|
0.026
|
3.557
|
0.000
|
0.042
|
0.146
|
0.321
|
|
State_Bothered
|
Curiosity
|
0.121
|
0.033
|
3.635
|
0.000
|
0.056
|
0.186
|
0.327
|
|
State_Interested
|
Curiosity
|
0.103
|
0.027
|
3.750
|
0.000
|
0.049
|
0.157
|
0.337
|
|
State_Uncertain
|
Curiosity
|
-0.014
|
0.031
|
-0.438
|
0.662
|
-0.074
|
0.047
|
-0.042
|
|
InfoSeek
|
State_Curious
|
0.180
|
0.038
|
4.787
|
0.000
|
0.106
|
0.254
|
0.410
|
|
InfoSeek
|
State_Frustrated
|
0.037
|
0.033
|
1.117
|
0.264
|
-0.028
|
0.101
|
0.095
|
|
InfoSeek
|
State_Confident
|
-0.062
|
0.040
|
-1.540
|
0.124
|
-0.142
|
0.017
|
-0.131
|
|
InfoSeek
|
State_Bothered
|
-0.062
|
0.032
|
-1.926
|
0.054
|
-0.125
|
0.001
|
-0.164
|
|
InfoSeek
|
State_Interested
|
0.052
|
0.039
|
1.352
|
0.176
|
-0.024
|
0.129
|
0.115
|
|
InfoSeek
|
State_Uncertain
|
-0.018
|
0.036
|
-0.506
|
0.613
|
-0.089
|
0.052
|
-0.042
|
|
PANAS_Positive
|
Curiosity
|
1.107
|
0.322
|
3.432
|
0.001
|
0.475
|
1.738
|
0.311
|
|
PANAS_Negative
|
Curiosity
|
0.675
|
0.295
|
2.287
|
0.022
|
0.096
|
1.253
|
0.213
|
fitMeasures(fit, c("cfi", "rmsea", "srmr"))
## cfi rmsea srmr
## 0.117 0.483 0.225
semPaths(fit,
what = "std",
layout = "tree2",
edge.label.cex = .7,
fade = FALSE,
nCharNodes = 0,
style = "lisrel",
residuals = FALSE,
sizeMan = 8,
sizeLat = 10,
mar = c(10, 10, 10, 10)) # Add margins to prevent crowding

########I type and D type as seperate predictors###
# Define state suffixes
states <- c("Confident", "Curious", "Bothered", "Interested", "Frustrated", "Uncertain")
# Create state composite variables
for (state in states) {
items <- grep(paste0("_", state, "$"), names(df), value = TRUE)
df[[paste0("State_", state)]] <- rowMeans(df[, items], na.rm = TRUE)
}
# Info-seeking based on _5sec columns
info_seek_items <- grep("_5sec$", names(df), value = TRUE)
df$InfoSeek <- rowMeans(df[, info_seek_items] == 1, na.rm = TRUE)
# Variables to summarize
vars <- c("I_Type", "D_Type", paste0("State_", states), "InfoSeek", "PANAS_Positive", "PANAS_Negative")
desc_stats <- describe(df[, vars])[, c("mean", "sd")]
# Function to compute omega safely
omega_safe <- function(vars) {
if (length(vars) > 1) {
out <- omega(df[, vars], warnings = FALSE)
return(c(omega.tot = out$omega.tot, omega.h = out$omega.h))
} else {
return(c(omega.tot = NA, omega.h = NA))
}
}
# Add omega values for states only
omega_total <- omega_hier <- rep(NA, length(vars))
for (i in seq_along(vars)) {
if (grepl("^State_", vars[i])) {
items <- grep(paste0("_", sub("State_", "", vars[i]), "$"), names(df), value = TRUE)
o <- omega_safe(items)
omega_total[i] <- o["omega.tot"]
omega_hier[i] <- o["omega.h"]
}
}
## In smc, smcs > 1 were set to 1.0
## In smc, smcs < 0 were set to .0
## In smc, smcs > 1 were set to 1.0
## In smc, smcs < 0 were set to .0
## In smc, smcs > 1 were set to 1.0
## In smc, smcs < 0 were set to .0
## Warning in cor.smooth(r): Matrix was not positive definite, smoothing was done
## Warning in fac(r = r, nfactors = nfactors, n.obs = n.obs, rotate = rotate, : An
## ultra-Heywood case was detected. Examine the results carefully
## In smc, smcs > 1 were set to 1.0
## In smc, smcs < 0 were set to .0
## Warning in cor.smooth(r): Matrix was not positive definite, smoothing was done
## Warning in cor.smooth(r): Matrix was not positive definite, smoothing was done

## In smc, smcs > 1 were set to 1.0
## In smc, smcs < 0 were set to .0
## In smc, smcs > 1 were set to 1.0
## In smc, smcs < 0 were set to .0
## In smc, smcs > 1 were set to 1.0
## In smc, smcs < 0 were set to .0
## Warning in cor.smooth(r): Matrix was not positive definite, smoothing was done
## Warning in fac(r = r, nfactors = nfactors, n.obs = n.obs, rotate = rotate, : An
## ultra-Heywood case was detected. Examine the results carefully
## Warning in sqrt(1/diag(V)): NaNs produced
## Warning in cov2cor(t(w) %*% r %*% w): diag(.) had 0 or NA entries; non-finite
## result is doubtful
## In smc, smcs > 1 were set to 1.0
## In smc, smcs < 0 were set to .0
## Warning in cor.smooth(r): Matrix was not positive definite, smoothing was done
## Warning in cor.smooth(r): Matrix was not positive definite, smoothing was done

## Warning in fa.stats(r = r, f = f, phi = phi, n.obs = n.obs, np.obs = np.obs, :
## The estimated weights for the factor scores are probably incorrect. Try a
## different factor score estimation method.
## Warning in fac(r = r, nfactors = nfactors, n.obs = n.obs, rotate = rotate, : An
## ultra-Heywood case was detected. Examine the results carefully
## Warning in fa.stats(r = r, f = f, phi = phi, n.obs = n.obs, np.obs = np.obs, :
## The estimated weights for the factor scores are probably incorrect. Try a
## different factor score estimation method.
## Warning in fac(r = r, nfactors = nfactors, n.obs = n.obs, rotate = rotate, : An
## ultra-Heywood case was detected. Examine the results carefully
## Warning in fa.stats(r = r, f = f, phi = phi, n.obs = n.obs, np.obs = np.obs, :
## The estimated weights for the factor scores are probably incorrect. Try a
## different factor score estimation method.
## Warning in cov2cor(t(w) %*% r %*% w): diag(.) had 0 or NA entries; non-finite
## result is doubtful
## Warning in fa.stats(r = r, f = f, phi = phi, n.obs = n.obs, np.obs = np.obs, :
## The estimated weights for the factor scores are probably incorrect. Try a
## different factor score estimation method.

## Warning in fa.stats(r = r, f = f, phi = phi, n.obs = n.obs, np.obs = np.obs, :
## The estimated weights for the factor scores are probably incorrect. Try a
## different factor score estimation method.
## Warning in fac(r = r, nfactors = nfactors, n.obs = n.obs, rotate = rotate, : An
## ultra-Heywood case was detected. Examine the results carefully
## Warning in fa.stats(r = r, f = f, phi = phi, n.obs = n.obs, np.obs = np.obs, :
## The estimated weights for the factor scores are probably incorrect. Try a
## different factor score estimation method.
## Warning in fac(r = r, nfactors = nfactors, n.obs = n.obs, rotate = rotate, : An
## ultra-Heywood case was detected. Examine the results carefully
## Warning in fa.stats(r = r, f = f, phi = phi, n.obs = n.obs, np.obs = np.obs, :
## The estimated weights for the factor scores are probably incorrect. Try a
## different factor score estimation method.
## Warning in cov2cor(t(w) %*% r %*% w): diag(.) had 0 or NA entries; non-finite
## result is doubtful
## Warning in fa.stats(r = r, f = f, phi = phi, n.obs = n.obs, np.obs = np.obs, :
## The estimated weights for the factor scores are probably incorrect. Try a
## different factor score estimation method.

## Warning in fa.stats(r = r, f = f, phi = phi, n.obs = n.obs, np.obs = np.obs, :
## The estimated weights for the factor scores are probably incorrect. Try a
## different factor score estimation method.
## Warning in fac(r = r, nfactors = nfactors, n.obs = n.obs, rotate = rotate, : An
## ultra-Heywood case was detected. Examine the results carefully
## Warning in fa.stats(r = r, f = f, phi = phi, n.obs = n.obs, np.obs = np.obs, :
## The estimated weights for the factor scores are probably incorrect. Try a
## different factor score estimation method.
## Warning in fac(r = r, nfactors = nfactors, n.obs = n.obs, rotate = rotate, : An
## ultra-Heywood case was detected. Examine the results carefully
## Warning in fa.stats(r = r, f = f, phi = phi, n.obs = n.obs, np.obs = np.obs, :
## The estimated weights for the factor scores are probably incorrect. Try a
## different factor score estimation method.
## Warning in cov2cor(t(w) %*% r %*% w): diag(.) had 0 or NA entries; non-finite
## result is doubtful
## Warning in fa.stats(r = r, f = f, phi = phi, n.obs = n.obs, np.obs = np.obs, :
## The estimated weights for the factor scores are probably incorrect. Try a
## different factor score estimation method.

## In smc, smcs > 1 were set to 1.0
## In smc, smcs < 0 were set to .0
## In smc, smcs > 1 were set to 1.0
## In smc, smcs < 0 were set to .0
## In smc, smcs > 1 were set to 1.0
## In smc, smcs < 0 were set to .0
## Warning in cor.smooth(r): Matrix was not positive definite, smoothing was done
## Warning in fac(r = r, nfactors = nfactors, n.obs = n.obs, rotate = rotate, : An
## ultra-Heywood case was detected. Examine the results carefully
## In smc, smcs > 1 were set to 1.0
## In smc, smcs < 0 were set to .0
## Warning in cor.smooth(r): Matrix was not positive definite, smoothing was done
## Warning in cor.smooth(r): Matrix was not positive definite, smoothing was done

# Combine descriptives and reliability
desc_df <- as.data.frame(desc_stats)
desc_df$omega_h <- omega_hier
desc_df$omega_t <- omega_total
desc_df$Variable <- vars
desc_df %>%
kbl(caption = "Table 3. Descriptive Statistics and Reliability", digits = 2) %>%
kable_styling(full_width = FALSE, latex_options = "striped")
Table 3. Descriptive Statistics and Reliability
|
|
mean
|
sd
|
omega_h
|
omega_t
|
Variable
|
|
I_Type
|
14.47
|
2.82
|
NA
|
NA
|
I_Type
|
|
D_Type
|
11.30
|
3.19
|
NA
|
NA
|
D_Type
|
|
State_Confident
|
2.15
|
0.73
|
NA
|
0.95
|
State_Confident
|
|
State_Curious
|
3.47
|
0.79
|
NA
|
0.97
|
State_Curious
|
|
State_Bothered
|
2.32
|
0.91
|
NA
|
0.98
|
State_Bothered
|
|
State_Interested
|
3.51
|
0.76
|
NA
|
0.97
|
State_Interested
|
|
State_Frustrated
|
2.22
|
0.90
|
NA
|
0.98
|
State_Frustrated
|
|
State_Uncertain
|
3.78
|
0.81
|
NA
|
0.97
|
State_Uncertain
|
|
InfoSeek
|
0.51
|
0.35
|
NA
|
NA
|
InfoSeek
|
|
PANAS_Positive
|
22.56
|
8.84
|
NA
|
NA
|
PANAS_Positive
|
|
PANAS_Negative
|
16.57
|
7.99
|
NA
|
NA
|
PANAS_Negative
|
# SEM model
model <- '
# Predict affective states
State_Curious ~ I_Type + D_Type
State_Frustrated ~ I_Type + D_Type
State_Confident ~ I_Type + D_Type
State_Bothered ~ I_Type + D_Type
State_Interested ~ I_Type + D_Type
State_Uncertain ~ I_Type + D_Type
# Info seeking predicted by all states
InfoSeek ~ State_Curious + State_Frustrated + State_Confident +
State_Bothered + State_Interested + State_Uncertain
# PANAS manipulation checks
PANAS_Positive ~ I_Type
PANAS_Negative ~ D_Type
'
# Fit model
fit <- sem(model, data = df, estimator = "ML")
summary(fit, standardized = TRUE, fit.measures = TRUE)
## lavaan 0.6-19 ended normally after 55 iterations
##
## Estimator ML
## Optimization method NLMINB
## Number of model parameters 32
##
## Used Total
## Number of observations 110 111
##
## Model Test User Model:
##
## Test statistic 750.555
## Degrees of freedom 31
## P-value (Chi-square) 0.000
##
## Model Test Baseline Model:
##
## Test statistic 880.614
## Degrees of freedom 54
## P-value 0.000
##
## User Model versus Baseline Model:
##
## Comparative Fit Index (CFI) 0.130
## Tucker-Lewis Index (TLI) -0.516
##
## Loglikelihood and Information Criteria:
##
## Loglikelihood user model (H0) -1550.386
## Loglikelihood unrestricted model (H1) -1175.108
##
## Akaike (AIC) 3164.771
## Bayesian (BIC) 3251.187
## Sample-size adjusted Bayesian (SABIC) 3150.066
##
## Root Mean Square Error of Approximation:
##
## RMSEA 0.459
## 90 Percent confidence interval - lower 0.431
## 90 Percent confidence interval - upper 0.488
## P-value H_0: RMSEA <= 0.050 0.000
## P-value H_0: RMSEA >= 0.080 1.000
##
## Standardized Root Mean Square Residual:
##
## SRMR 0.207
##
## Parameter Estimates:
##
## Standard errors Standard
## Information Expected
## Information saturated (h1) model Structured
##
## Regressions:
## Estimate Std.Err z-value P(>|z|) Std.lv Std.all
## State_Curious ~
## I_Type 0.104 0.026 3.927 0.000 0.104 0.370
## D_Type 0.016 0.023 0.686 0.492 0.016 0.065
## State_Frustrated ~
## I_Type -0.002 0.030 -0.059 0.953 -0.002 -0.006
## D_Type 0.112 0.027 4.229 0.000 0.112 0.398
## State_Confident ~
## I_Type 0.042 0.025 1.653 0.098 0.042 0.161
## D_Type 0.052 0.022 2.327 0.020 0.052 0.226
## State_Bothered ~
## I_Type -0.005 0.031 -0.156 0.876 -0.005 -0.015
## D_Type 0.114 0.027 4.223 0.000 0.114 0.398
## State_Interested ~
## I_Type 0.092 0.026 3.546 0.000 0.092 0.338
## D_Type 0.018 0.023 0.815 0.415 0.018 0.078
## State_Uncertain ~
## I_Type -0.020 0.029 -0.691 0.490 -0.020 -0.071
## D_Type 0.004 0.026 0.172 0.863 0.004 0.018
## InfoSeek ~
## State_Curious 0.188 0.038 5.009 0.000 0.188 0.423
## State_Frustrtd 0.037 0.033 1.134 0.257 0.037 0.096
## State_Confidnt -0.067 0.040 -1.647 0.099 -0.067 -0.139
## State_Bothered -0.066 0.032 -2.039 0.041 -0.066 -0.172
## State_Interstd 0.048 0.039 1.232 0.218 0.048 0.104
## State_Uncertan -0.021 0.036 -0.570 0.569 -0.021 -0.047
## PANAS_Positive ~
## I_Type 0.870 0.288 3.021 0.003 0.870 0.276
## PANAS_Negative ~
## D_Type 0.523 0.229 2.289 0.022 0.523 0.213
##
## Covariances:
## Estimate Std.Err z-value P(>|z|) Std.lv Std.all
## .InfoSeek ~~
## .PANAS_Positive 0.204 0.246 0.831 0.406 0.204 0.079
## .PANAS_Negative -0.103 0.222 -0.464 0.643 -0.103 -0.044
## .PANAS_Positive ~~
## .PANAS_Negative 3.680 6.188 0.595 0.552 3.680 0.057
##
## Variances:
## Estimate Std.Err z-value P(>|z|) Std.lv Std.all
## .State_Curious 0.516 0.070 7.416 0.000 0.516 0.842
## .State_Frustrtd 0.680 0.092 7.416 0.000 0.680 0.843
## .State_Confidnt 0.473 0.064 7.416 0.000 0.473 0.896
## .State_Bothered 0.703 0.095 7.416 0.000 0.703 0.845
## .State_Interstd 0.494 0.067 7.416 0.000 0.494 0.861
## .State_Uncertan 0.640 0.086 7.416 0.000 0.640 0.996
## .InfoSeek 0.092 0.012 7.416 0.000 0.092 0.760
## .PANAS_Positive 71.707 9.669 7.416 0.000 71.707 0.924
## .PANAS_Negative 58.551 7.895 7.416 0.000 58.551 0.955
sem_output <- parameterEstimates(fit, standardized = TRUE)
sem_table <- sem_output %>%
filter(op == "~") %>%
select(lhs, rhs, est, se, z, pvalue, ci.lower, ci.upper, std.all) %>%
mutate(across(where(is.numeric), round, 3))
colnames(sem_table) <- c("Outcome", "Predictor", "b", "SE", "z", "p", "CI_low", "CI_high", "β")
sem_table %>%
kbl(caption = "Table 4. SEM Path Estimates", digits = 3) %>%
kable_styling(full_width = FALSE, latex_options = "striped")
Table 4. SEM Path Estimates
|
Outcome
|
Predictor
|
b
|
SE
|
z
|
p
|
CI_low
|
CI_high
|
β
|
|
State_Curious
|
I_Type
|
0.104
|
0.026
|
3.927
|
0.000
|
0.052
|
0.155
|
0.370
|
|
State_Curious
|
D_Type
|
0.016
|
0.023
|
0.686
|
0.492
|
-0.029
|
0.061
|
0.065
|
|
State_Frustrated
|
I_Type
|
-0.002
|
0.030
|
-0.059
|
0.953
|
-0.061
|
0.058
|
-0.006
|
|
State_Frustrated
|
D_Type
|
0.112
|
0.027
|
4.229
|
0.000
|
0.060
|
0.164
|
0.398
|
|
State_Confident
|
I_Type
|
0.042
|
0.025
|
1.653
|
0.098
|
-0.008
|
0.091
|
0.161
|
|
State_Confident
|
D_Type
|
0.052
|
0.022
|
2.327
|
0.020
|
0.008
|
0.095
|
0.226
|
|
State_Bothered
|
I_Type
|
-0.005
|
0.031
|
-0.156
|
0.876
|
-0.065
|
0.056
|
-0.015
|
|
State_Bothered
|
D_Type
|
0.114
|
0.027
|
4.223
|
0.000
|
0.061
|
0.167
|
0.398
|
|
State_Interested
|
I_Type
|
0.092
|
0.026
|
3.546
|
0.000
|
0.041
|
0.142
|
0.338
|
|
State_Interested
|
D_Type
|
0.018
|
0.023
|
0.815
|
0.415
|
-0.026
|
0.063
|
0.078
|
|
State_Uncertain
|
I_Type
|
-0.020
|
0.029
|
-0.691
|
0.490
|
-0.078
|
0.037
|
-0.071
|
|
State_Uncertain
|
D_Type
|
0.004
|
0.026
|
0.172
|
0.863
|
-0.046
|
0.055
|
0.018
|
|
InfoSeek
|
State_Curious
|
0.188
|
0.038
|
5.009
|
0.000
|
0.114
|
0.262
|
0.423
|
|
InfoSeek
|
State_Frustrated
|
0.037
|
0.033
|
1.134
|
0.257
|
-0.027
|
0.101
|
0.096
|
|
InfoSeek
|
State_Confident
|
-0.067
|
0.040
|
-1.647
|
0.099
|
-0.146
|
0.013
|
-0.139
|
|
InfoSeek
|
State_Bothered
|
-0.066
|
0.032
|
-2.039
|
0.041
|
-0.129
|
-0.003
|
-0.172
|
|
InfoSeek
|
State_Interested
|
0.048
|
0.039
|
1.232
|
0.218
|
-0.028
|
0.124
|
0.104
|
|
InfoSeek
|
State_Uncertain
|
-0.021
|
0.036
|
-0.570
|
0.569
|
-0.091
|
0.050
|
-0.047
|
|
PANAS_Positive
|
I_Type
|
0.870
|
0.288
|
3.021
|
0.003
|
0.306
|
1.435
|
0.276
|
|
PANAS_Negative
|
D_Type
|
0.523
|
0.229
|
2.289
|
0.022
|
0.075
|
0.971
|
0.213
|
fitMeasures(fit, c("cfi", "rmsea", "srmr"))
## cfi rmsea srmr
## 0.130 0.459 0.207
# Plot SEM diagram (larger and clearer layout)
semPaths(fit,
what = "std",
layout = "tree",
edge.label.cex = .7,
fade = FALSE,
nCharNodes = 0,
style = "lisrel",
residuals = FALSE,
sizeMan = 5,
sizeLat = 10)

Effects
You can also embed plots, for example:
library(dplyr)
library(kableExtra)
# Median split on I-Type
i_median <- median(df$I_Type, na.rm = TRUE)
df_I <- df %>%
mutate(I_Group = ifelse(I_Type > i_median, "High I-Type", "Low I-Type"))
# Descriptive table
desc_I <- df_I %>%
group_by(I_Group, Condition) %>%
summarise(
Mean_InfoSeek = round(mean(InfoSeek, na.rm = TRUE), 2),
SD_InfoSeek = round(sd(InfoSeek, na.rm = TRUE), 2),
N = n(),
.groups = "drop"
)
desc_I %>%
kbl(caption = "Table 1. Descriptive Statistics for Information Seeking by I-Type and Condition") %>%
kable_styling(full_width = FALSE, latex_options = "striped")
Table 1. Descriptive Statistics for Information Seeking by I-Type and
Condition
|
I_Group
|
Condition
|
Mean_InfoSeek
|
SD_InfoSeek
|
N
|
|
High I-Type
|
Negative
|
0.53
|
0.37
|
27
|
|
High I-Type
|
Positive
|
0.62
|
0.31
|
22
|
|
Low I-Type
|
Negative
|
0.37
|
0.28
|
32
|
|
Low I-Type
|
Positive
|
0.54
|
0.39
|
30
|
library(broom)
# Regress InfoSeek on Condition, separately by I-Type group
model_I_high <- lm(InfoSeek ~ Condition, data = filter(df_I, I_Group == "High I-Type"))
model_I_low <- lm(InfoSeek ~ Condition, data = filter(df_I, I_Group == "Low I-Type"))
# Combine and format
reg_I_high <- tidy(model_I_high, conf.int = TRUE) %>%
mutate(Group = "High I-Type")
reg_I_low <- tidy(model_I_low, conf.int = TRUE) %>%
mutate(Group = "Low I-Type")
bind_rows(reg_I_high, reg_I_low) %>%
mutate(across(where(is.numeric), round, 3)) %>%
kbl(caption = "Table 2. Regression Results: InfoSeek ~ Condition (by I-Type)") %>%
kable_styling(full_width = FALSE, latex_options = "striped")
Table 2. Regression Results: InfoSeek ~ Condition (by I-Type)
|
term
|
estimate
|
std.error
|
statistic
|
p.value
|
conf.low
|
conf.high
|
Group
|
|
(Intercept)
|
0.533
|
0.067
|
8.001
|
0.000
|
0.399
|
0.667
|
High I-Type
|
|
ConditionPositive
|
0.089
|
0.099
|
0.899
|
0.373
|
-0.111
|
0.290
|
High I-Type
|
|
(Intercept)
|
0.374
|
0.060
|
6.205
|
0.000
|
0.254
|
0.495
|
Low I-Type
|
|
ConditionPositive
|
0.166
|
0.086
|
1.928
|
0.059
|
-0.006
|
0.338
|
Low I-Type
|
# Median split on D-Type
d_median <- median(df$D_Type, na.rm = TRUE)
df_D <- df %>%
mutate(D_Group = ifelse(D_Type > d_median, "High D-Type", "Low D-Type"))
# Descriptive table
desc_D <- df_D %>%
group_by(D_Group, Condition) %>%
summarise(
Mean_InfoSeek = round(mean(InfoSeek, na.rm = TRUE), 2),
SD_InfoSeek = round(sd(InfoSeek, na.rm = TRUE), 2),
N = n(),
.groups = "drop"
)
desc_D %>%
kbl(caption = "Table 3. Descriptive Statistics for Information Seeking by D-Type and Condition") %>%
kable_styling(full_width = FALSE, latex_options = "striped")
Table 3. Descriptive Statistics for Information Seeking by D-Type and
Condition
|
D_Group
|
Condition
|
Mean_InfoSeek
|
SD_InfoSeek
|
N
|
|
High D-Type
|
Negative
|
0.49
|
0.38
|
25
|
|
High D-Type
|
Positive
|
0.63
|
0.33
|
28
|
|
Low D-Type
|
Negative
|
0.42
|
0.30
|
34
|
|
Low D-Type
|
Positive
|
0.51
|
0.38
|
24
|
# Regress InfoSeek on Condition, separately by D-Type group
model_D_high <- lm(InfoSeek ~ Condition, data = filter(df_D, D_Group == "High D-Type"))
model_D_low <- lm(InfoSeek ~ Condition, data = filter(df_D, D_Group == "Low D-Type"))
# Combine and format
reg_D_high <- tidy(model_D_high, conf.int = TRUE) %>%
mutate(Group = "High D-Type")
reg_D_low <- tidy(model_D_low, conf.int = TRUE) %>%
mutate(Group = "Low D-Type")
bind_rows(reg_D_high, reg_D_low) %>%
mutate(across(where(is.numeric), round, 3)) %>%
kbl(caption = "Table 4. Regression Results: InfoSeek ~ Condition (by D-Type)") %>%
kable_styling(full_width = FALSE, latex_options = "striped")
Table 4. Regression Results: InfoSeek ~ Condition (by D-Type)
|
term
|
estimate
|
std.error
|
statistic
|
p.value
|
conf.low
|
conf.high
|
Group
|
|
(Intercept)
|
0.488
|
0.071
|
6.897
|
0.000
|
0.346
|
0.630
|
High D-Type
|
|
ConditionPositive
|
0.141
|
0.097
|
1.444
|
0.155
|
-0.055
|
0.336
|
High D-Type
|
|
(Intercept)
|
0.418
|
0.058
|
7.204
|
0.000
|
0.302
|
0.535
|
Low D-Type
|
|
ConditionPositive
|
0.094
|
0.089
|
1.054
|
0.296
|
-0.085
|
0.274
|
Low D-Type
|
#######
# Main effect model
mod_I_main <- lm(InfoSeek ~ Condition + I_Type, data = df)
# Interaction model
mod_I_interact <- lm(InfoSeek ~ Condition * I_Type, data = df)
# Compare models
anova(mod_I_main, mod_I_interact)
AIC(mod_I_main, mod_I_interact)
BIC(mod_I_main, mod_I_interact)
# Output model summary for interaction
summary(mod_I_interact)
##
## Call:
## lm(formula = InfoSeek ~ Condition * I_Type, data = df)
##
## Residuals:
## Min 1Q Median 3Q Max
## -0.5855 -0.2951 -0.0352 0.3135 0.5451
##
## Coefficients:
## Estimate Std. Error t value Pr(>|t|)
## (Intercept) -0.17974 0.23680 -0.759 0.44951
## ConditionPositive 0.39259 0.33507 1.172 0.24397
## I_Type 0.04347 0.01611 2.698 0.00811 **
## ConditionPositive:I_Type -0.01862 0.02267 -0.821 0.41329
## ---
## Signif. codes: 0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1
##
## Residual standard error: 0.3319 on 106 degrees of freedom
## (1 observation deleted due to missingness)
## Multiple R-squared: 0.1145, Adjusted R-squared: 0.08942
## F-statistic: 4.568 on 3 and 106 DF, p-value: 0.004752
library(ggplot2)
library(ggpubr)
# Add median split for plot clarity
i_median <- median(df$I_Type, na.rm = TRUE)
df <- df %>%
mutate(I_Group = ifelse(I_Type > i_median, "High I-Type", "Low I-Type"))
ggplot(df, aes(x = Condition, y = InfoSeek, fill = I_Group)) +
stat_summary(fun = mean, geom = "bar", position = position_dodge(0.9), width = 0.7) +
stat_summary(fun.data = mean_se, geom = "errorbar",
position = position_dodge(0.9), width = 0.2) +
labs(title = "Interaction: I-Type Curiosity × Condition",
y = "Information Seeking", fill = "I-Type Curiosity") +
theme_minimal(base_size = 14)

# Main effect model
mod_D_main <- lm(InfoSeek ~ Condition + D_Type, data = df)
# Interaction model
mod_D_interact <- lm(InfoSeek ~ Condition * D_Type, data = df)
# Compare models
anova(mod_D_main, mod_D_interact)
AIC(mod_D_main, mod_D_interact)
BIC(mod_D_main, mod_D_interact)
# Output model summary for interaction
summary(mod_D_interact)
##
## Call:
## lm(formula = InfoSeek ~ Condition * D_Type, data = df)
##
## Residuals:
## Min 1Q Median 3Q Max
## -0.6069 -0.3145 -0.0350 0.3258 0.6124
##
## Coefficients:
## Estimate Std. Error t value Pr(>|t|)
## (Intercept) 0.316534 0.172628 1.834 0.0695 .
## ConditionPositive 0.006579 0.241615 0.027 0.9783
## D_Type 0.011847 0.014989 0.790 0.4311
## ConditionPositive:D_Type 0.009984 0.020553 0.486 0.6282
## ---
## Signif. codes: 0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1
##
## Residual standard error: 0.3419 on 106 degrees of freedom
## (1 observation deleted due to missingness)
## Multiple R-squared: 0.0603, Adjusted R-squared: 0.03371
## F-statistic: 2.267 on 3 and 106 DF, p-value: 0.08492
# Median split
d_median <- median(df$D_Type, na.rm = TRUE)
df <- df %>%
mutate(D_Group = ifelse(D_Type > d_median, "High D-Type", "Low D-Type"))
ggplot(df, aes(x = Condition, y = InfoSeek, fill = D_Group)) +
stat_summary(fun = mean, geom = "bar", position = position_dodge(0.9), width = 0.7) +
stat_summary(fun.data = mean_se, geom = "errorbar",
position = position_dodge(0.9), width = 0.2) +
labs(title = "Interaction: D-Type Curiosity × Condition",
y = "Information Seeking", fill = "D-Type Curiosity") +
theme_minimal(base_size = 14)

#############################
# Median splits
i_median <- median(df$I_Type, na.rm = TRUE)
d_median <- median(df$D_Type, na.rm = TRUE)
# Filter to High I-Type and High D-Type groups
df_high_I <- df %>%
filter(I_Type > i_median) %>%
mutate(CuriosityType = "High I-Type")
df_high_D <- df %>%
filter(D_Type > d_median) %>%
mutate(CuriosityType = "High D-Type")
# Combine for plot
df_combined <- bind_rows(df_high_I, df_high_D)
# Run models
model_I <- lm(InfoSeek ~ Condition, data = df_high_I)
model_D <- lm(InfoSeek ~ Condition, data = df_high_D)
# Extract p-values
p_I <- summary(model_I)$coefficients[2, 4]
p_D <- summary(model_D)$coefficients[2, 4]
# Format nicely
p_I_text <- paste0("p = ", format.pval(p_I, digits = 3, eps = .001))
p_D_text <- paste0("p = ", format.pval(p_D, digits = 3, eps = .001))
library(ggplot2)
ggplot(df_combined, aes(x = Condition, y = InfoSeek, fill = CuriosityType)) +
stat_summary(fun = mean, geom = "bar", position = position_dodge(0.9), width = 0.7) +
stat_summary(fun.data = mean_se, geom = "errorbar", position = position_dodge(0.9), width = 0.2) +
labs(
title = "Information Seeking by Condition and Curiosity Type",
x = "Condition",
y = "Information Seeking",
fill = "Curiosity Type"
) +
theme_minimal(base_size = 14) +
scale_fill_manual(values = c("#4575b4", "#d73027")) +
theme(panel.grid.major.x = element_blank()) +
annotate("text", x = 1.5, y = max(df$InfoSeek, na.rm = TRUE) + 0.05,
label = paste("High I-Type:", p_I_text, "\nHigh D-Type:", p_D_text),
size = 4, hjust = 0.5)

###########
# Run model
model_compare <- lm(InfoSeek ~ I_Type + D_Type, data = df)
# Tidy and add asterisk labels for p-values
reg_table <- tidy(model_compare, conf.int = TRUE) %>%
mutate(
p_label = case_when(
p.value < 0.001 ~ "***",
p.value < 0.01 ~ "**",
p.value < 0.05 ~ "*",
p.value < 0.1 ~ ".",
TRUE ~ ""
),
p_combined = paste0(round(p.value, 3), p_label)
) %>%
select(term, estimate, std.error, statistic, conf.low, conf.high, p_combined) %>%
rename(
Term = term,
b = estimate,
SE = std.error,
t = statistic,
CI_low = conf.low,
CI_high = conf.high,
`p-value` = p_combined
)
# Print nicely
reg_table %>%
kbl(
caption = "Table: Predicting Information Seeking from I-Type and D-Type Curiosity",
digits = 3
) %>%
kable_styling(full_width = FALSE, latex_options = "striped")
Table: Predicting Information Seeking from I-Type and D-Type Curiosity
|
Term
|
b
|
SE
|
t
|
CI_low
|
CI_high
|
p-value
|
|
(Intercept)
|
-0.037
|
0.179
|
-0.206
|
-0.391
|
0.318
|
0.838
|
|
I_Type
|
0.031
|
0.012
|
2.514
|
0.007
|
0.056
|
0.013*
|
|
D_Type
|
0.008
|
0.011
|
0.769
|
-0.013
|
0.030
|
0.443
|
library(broom)
library(dplyr)
library(kableExtra)
# Run model
model_compare <- lm(InfoSeek ~ I_Type + D_Type, data = df)
# Tidy and add asterisk labels for p-values
reg_table <- tidy(model_compare, conf.int = TRUE) %>%
mutate(
p_label = case_when(
p.value < 0.001 ~ "***",
p.value < 0.01 ~ "**",
p.value < 0.05 ~ "*",
p.value < 0.1 ~ ".",
TRUE ~ ""
),
p_combined = paste0(round(p.value, 3), p_label)
) %>%
select(term, estimate, std.error, statistic, conf.low, conf.high, p_combined) %>%
rename(
Term = term,
b = estimate,
SE = std.error,
t = statistic,
CI_low = conf.low,
CI_high = conf.high,
`p-value` = p_combined
)
# Print nicely
reg_table %>%
kbl(
caption = "Table: Predicting Information Seeking from I-Type and D-Type Curiosity",
digits = 3
) %>%
kable_styling(full_width = FALSE, latex_options = "striped")
Table: Predicting Information Seeking from I-Type and D-Type Curiosity
|
Term
|
b
|
SE
|
t
|
CI_low
|
CI_high
|
p-value
|
|
(Intercept)
|
-0.037
|
0.179
|
-0.206
|
-0.391
|
0.318
|
0.838
|
|
I_Type
|
0.031
|
0.012
|
2.514
|
0.007
|
0.056
|
0.013*
|
|
D_Type
|
0.008
|
0.011
|
0.769
|
-0.013
|
0.030
|
0.443
|
library(broom)
library(dplyr)
library(ggplot2)
library(patchwork) # for combining plots
library(tidyr)
### 🔹 Part 1: Regression Coefficient Plot ----
# Fit model
model_compare <- lm(InfoSeek ~ I_Type + D_Type, data = df)
# Get coefficients
coef_plot_data <- tidy(model_compare, conf.int = TRUE) %>%
filter(term != "(Intercept)") %>%
mutate(
Sig = case_when(
p.value < 0.001 ~ "***",
p.value < 0.01 ~ "**",
p.value < 0.05 ~ "*",
p.value < 0.1 ~ ".",
TRUE ~ ""
),
Curiosity_Type = recode(term,
I_Type = "I-Type Curiosity",
D_Type = "D-Type Curiosity"),
label = paste0("p = ", round(p.value, 3), Sig)
)
# Coefficient plot
p1 <- ggplot(coef_plot_data, aes(x = Curiosity_Type, y = estimate)) +
geom_point(size = 4, color = "#1f78b4") +
geom_errorbar(aes(ymin = conf.low, ymax = conf.high), width = 0.1) +
geom_text(aes(label = label), vjust = -1, size = 4.5) +
geom_hline(yintercept = 0, linetype = "dashed") +
labs(
title = "Regression Coefficients",
x = NULL,
y = "Effect on Information Seeking (b)"
) +
theme_minimal(base_size = 13)
### 🔹 Part 2: Scatter + Smooth Line Plot ----
# Prepare long data
df_long <- df %>%
select(InfoSeek, I_Type, D_Type) %>%
pivot_longer(cols = c(I_Type, D_Type),
names_to = "Curiosity_Type",
values_to = "Curiosity_Score") %>%
mutate(Curiosity_Type = recode(Curiosity_Type,
I_Type = "I-Type Curiosity",
D_Type = "D-Type Curiosity"))
# Prediction plot
p2 <- ggplot(df_long, aes(x = Curiosity_Score, y = InfoSeek, color = Curiosity_Type)) +
geom_point(alpha = 0.3) +
geom_smooth(method = "lm", se = TRUE, size = 1.1) +
labs(
title = "Observed Relationships",
x = "Curiosity Score",
y = "Information Seeking Behavior",
color = "Curiosity Type"
) +
scale_color_manual(values = c("I-Type Curiosity" = "#1f78b4", "D-Type Curiosity" = "#d73027")) +
theme_minimal(base_size = 13) +
theme(legend.position = "top")
### 🔹 Combine the Plots ----
p1 + p2 + plot_layout(ncol = 1, heights = c(0.8, 1.2))

Note that the echo = FALSE parameter was added to the
code chunk to prevent printing of the R code that generated the
plot.