library(pacman)
p_load(kirkegaard, haven)
options(digits = 3)
d = read_spss("data/GSS_panel_2010_2014.sav") %>% df_legalize_names()
#split by names into year waves
waves = list(
year_2010 = d["word" + letters[1:10] + "_1"],
year_2012 = d["word" + letters[1:10] + "_2"],
year_2014 = d["word" + letters[1:10] + "_3"]
)
#IRT fit by wave
IRTs = map(waves, irt.fa)
#score
IRT_score_dfs = map(1:3, function(i) {
x = scoreIrt(IRTs[[i]], waves[[i]])
x2 = data_frame(
x = x$theta1 %>% standardize()
)
names(x2) = names(waves)[i]
x2
})
#combine
IRT_scores = IRT_score_dfs %>% as.data.frame() %>% as_data_frame()
#cors
wtd.cors(IRT_scores)
## year_2010 year_2012 year_2014
## year_2010 1.000 0.678 0.700
## year_2012 0.678 1.000 0.676
## year_2014 0.700 0.676 1.000
#plots
GG_scatter(IRT_scores, "year_2010", "year_2012")
GG_scatter(IRT_scores, "year_2010", "year_2014")
GG_scatter(IRT_scores, "year_2012", "year_2014")
#write data
IRT_scores %>% write_csv("data/IRT_scores.csv", na = "")