setwd("C:/Work Files/Kendall/COVID")
DFA Example
library(haven) # Reading SPSS files
library(tidyverse) # Managing Data
── Attaching core tidyverse packages ──────────────────────── tidyverse 2.0.0 ──
✔ dplyr 1.1.4 ✔ readr 2.1.5
✔ forcats 1.0.0 ✔ stringr 1.5.1
✔ ggplot2 3.5.1 ✔ tibble 3.2.1
✔ lubridate 1.9.3 ✔ tidyr 1.3.1
✔ purrr 1.0.2
── Conflicts ────────────────────────────────────────── tidyverse_conflicts() ──
✖ dplyr::filter() masks stats::filter()
✖ dplyr::lag() masks stats::lag()
ℹ Use the conflicted package (<http://conflicted.r-lib.org/>) to force all conflicts to become errors
library(psych) # Psychometrics etc.
Attaching package: 'psych'
The following objects are masked from 'package:ggplot2':
%+%, alpha
library(MASS) # Package for DFA
Attaching package: 'MASS'
The following object is masked from 'package:dplyr':
select
<-read_sav("UWin_Analysis_Data_2.sav")
UWin_Analysis_Data_2
$V2_R <-factor(UWin_Analysis_Data_2$V2_R,
UWin_Analysis_Data_2levels = c(1, 2, 3),
labels = c("Vax Reisistant", "Vax Hessitant", "Vaccinated"))
table(UWin_Analysis_Data_2$V2_R)
Vax Reisistant Vax Hessitant Vaccinated
69 146 932
Based on the results of an EFA we created 5 subscales: Confidence in Testing (e.g., I feel that I can trust the results of covid testing); Covid Anxiety (e.g., I am worried about getting covid); Covid Misinformation (e.g.,. the Covid vaccine is a way of inserting a tracking device by the government); Vaccine safety (e.g., I believe the vaccine is safe and is effective at reducing covid severity); Covid Concerns (e.g., I think the university policy around covid is reasonable and keeps us all safe). These will be the DV’s which we hypothesize differentiate the three vaccine status groups (Will not get vaccinated, haven’t yet, but am interested/thinking about it, already at least partially vaccinated)
attach(UWin_Analysis_Data_2)
$f1_Confidence_Testing <-(B1+B2+B3+B4+B5+B6+B7+B8+G6+G7)/10
UWin_Analysis_Data_2detach(UWin_Analysis_Data_2)
attach(UWin_Analysis_Data_2)
$f2_Covid_Anxiety <-(C1+C2+C3+C4+C5+C6+C7+C8+C9)/9
UWin_Analysis_Data_2detach(UWin_Analysis_Data_2)
attach(UWin_Analysis_Data_2)
$f3_Covid_Misinformation <-(V9+V10+V11+V12+V13)/5
UWin_Analysis_Data_2detach(UWin_Analysis_Data_2)
attach(UWin_Analysis_Data_2)
$f4_Vaccine_Safe_Effective <-(V4+V5+V6+V7+V8)/5
UWin_Analysis_Data_2detach(UWin_Analysis_Data_2)
attach(UWin_Analysis_Data_2)
$f5_UWin_Covid_Concern <-(G1+G2+G3)/3
UWin_Analysis_Data_2detach(UWin_Analysis_Data_2)
Below is the code for the DFA (linear discriminant analysis). The results indicate that there are two discriminant functions - these are essentially latent factors and the loadings are similar to factor loadings. Subscales that differentiate the two factors are belief in covid misinformation, belief that the vaccines are safe and effective, and belief that the university covid policies are effective at keeping everyone safe. Looking at the group means being high in one’s belief of covid misinformation, lower belief in vaccine safety and efficacy and, less agreement with university covid policies suggests a greater likelihood of being vaccine resistant v. vaccinated.
<- lda(V2_R ~ f1_Confidence_Testing + f2_Covid_Anxiety + f3_Covid_Misinformation + f4_Vaccine_Safe_Effective + f5_UWin_Covid_Concern, data=UWin_Analysis_Data_2,
DFA_Fit na.action="na.omit", CV=FALSE)
DFA_Fit
Call:
lda(V2_R ~ f1_Confidence_Testing + f2_Covid_Anxiety + f3_Covid_Misinformation +
f4_Vaccine_Safe_Effective + f5_UWin_Covid_Concern, data = UWin_Analysis_Data_2,
CV = FALSE, na.action = "na.omit")
Prior probabilities of groups:
Vax Reisistant Vax Hessitant Vaccinated
0.06896552 0.10689655 0.82413793
Group means:
f1_Confidence_Testing f2_Covid_Anxiety f3_Covid_Misinformation
Vax Reisistant 3.487500 3.180556 3.475000
Vax Hessitant 3.467742 3.234767 2.761290
Vaccinated 3.868201 3.211297 2.141423
f4_Vaccine_Safe_Effective f5_UWin_Covid_Concern
Vax Reisistant 3.445000 3.083333
Vax Hessitant 3.206452 3.290323
Vaccinated 3.912971 3.567643
Coefficients of linear discriminants:
LD1 LD2
f1_Confidence_Testing 0.21129986 0.2468981
f2_Covid_Anxiety -0.02390577 -0.1346202
f3_Covid_Misinformation -0.70231453 0.6328547
f4_Vaccine_Safe_Effective 0.55710788 1.1143324
f5_UWin_Covid_Concern 0.06920667 -0.3618292
Proportion of trace:
LD1 LD2
0.862 0.138
plot(DFA_Fit)