What

R data analysis for:

Start

options(digits = 2, width = 600)
library(pacman)
p_load(kirkegaard, readr, dplyr, rms, polycor, mirt)

#redefine describe
describe = function(...) psych::describe(...) %>% as.matrix()

Data

#load
vars = readr::read_csv2("data/question_data.csv")
## ℹ Using ',' as decimal and '.' as grouping mark. Use `read_delim()` for more control.
## Warning: Missing column names filled in: 'X1' [1]
## 
## ── Column specification ────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────
## cols(
##   X1 = col_character(),
##   text = col_character(),
##   option_1 = col_character(),
##   option_2 = col_character(),
##   option_3 = col_character(),
##   option_4 = col_character(),
##   N = col_double(),
##   Type = col_character(),
##   Order = col_character(),
##   Keywords = col_character()
## )
d = readr::read_rds("data/parsed_data.rds")
d_orig = d

#test items
iq_items_meta = read_csv("data/test_items.csv")
## Warning: Missing column names filled in: 'X1' [1]
## 
## ── Column specification ────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────
## cols(
##   X1 = col_character(),
##   ID = col_double(),
##   text = col_character(),
##   option_1 = col_character(),
##   option_2 = col_character(),
##   option_3 = col_character(),
##   option_4 = col_character(),
##   option_correct = col_double()
## )
#limited to persons with at last 5 IQ items
#included IQ items, some were removed due to ~0 datapoints
CA_items = intersect(iq_items_meta$X1, names(d))
d$CA_items = d[CA_items] %>% miss_by_case(reverse = T)
d = filter(d, CA_items >= 5)

Recode

#rename
d$age = d$d_age
d$sex = d$gender
d$country = d$d_country
d$sexual_orientation = d$gender_orientation
#anglophone = USA states, or regions or Canada (not Quebec) or a few others
d$anglophone = (d$country %in% c("Ontario", "British Columbia", "Alberta", "Manitoba", "Nova Scotia", "Saskatchewan", "New Brunswick", "Prince Edward Island", "Australia", "Singapore", "Ireland", "New Zealand")) | str_length(d$country) == 2
d$western = (d$country %in% c("Ontario", "British Columbia", "Alberta", "Manitoba", "Nova Scotia", "Saskatchewan", "New Brunswick", "Prince Edward Island", "Australia", "Ireland", "New Zealand")) | (str_length(d$country) == 2) | (d$country %in% c("Germany", "Netherlands", "Denmark", "Italy", "Sweden", "France", "Finland", "Israel", "Belgium", "Spain", "Austria", "Switzerland", "Norway", "Greece", "Portugal", "Iceland", "Luxembourg"))

#religion
#recode order
d$religion_seriousness = ordered(d$d_religion_seriosity,
                                 levels = c("and laughing about it", "but not too serious about it", "and somewhat serious about it", "and very serious about it"))
d$religion = d$d_religion_type %>% plyr::mapvalues("-", NA) %>% factor()
d$religion_combined = str_glue("{d$religion} + {d$religion_seriousness}")

Extract intelligence

#get scoring key
v_correct_answers_text = apply(iq_items_meta %>% filter(X1 %in% CA_items), MARGIN = 1, function(item) {
  item["option_" + 1:4][item["option_correct"] %>% as.numeric()]
})

#score items
CA_scored_items = score_items(d[CA_items], key = v_correct_answers_text)

#factor analysis / IRT
# irt_CA = irt.fa(CA_scored_items)
irt_CA = mirt(CA_scored_items, model = 1)
## 
Iteration: 1, Log-Lik: -151544.753, Max-Change: 3.37241
Iteration: 2, Log-Lik: -137049.017, Max-Change: 0.45960
Iteration: 3, Log-Lik: -135942.068, Max-Change: 0.28963
Iteration: 4, Log-Lik: -135346.752, Max-Change: 0.23959
Iteration: 5, Log-Lik: -135000.070, Max-Change: 0.16686
Iteration: 6, Log-Lik: -134805.781, Max-Change: 0.25781
Iteration: 7, Log-Lik: -134681.766, Max-Change: 0.09668
Iteration: 8, Log-Lik: -134606.564, Max-Change: 0.24591
Iteration: 9, Log-Lik: -134548.208, Max-Change: 0.14237
Iteration: 10, Log-Lik: -134519.358, Max-Change: 0.08380
Iteration: 11, Log-Lik: -134499.564, Max-Change: 0.06449
Iteration: 12, Log-Lik: -134485.274, Max-Change: 0.05566
Iteration: 13, Log-Lik: -134474.237, Max-Change: 0.03508
Iteration: 14, Log-Lik: -134468.174, Max-Change: 0.04288
Iteration: 15, Log-Lik: -134463.962, Max-Change: 0.03212
Iteration: 16, Log-Lik: -134461.212, Max-Change: 0.04777
Iteration: 17, Log-Lik: -134455.203, Max-Change: 0.01162
Iteration: 18, Log-Lik: -134454.203, Max-Change: 0.00664
Iteration: 19, Log-Lik: -134453.895, Max-Change: 0.00367
Iteration: 20, Log-Lik: -134453.713, Max-Change: 0.00224
Iteration: 21, Log-Lik: -134453.625, Max-Change: 0.00139
Iteration: 22, Log-Lik: -134453.609, Max-Change: 0.00142
Iteration: 23, Log-Lik: -134453.582, Max-Change: 0.00074
Iteration: 24, Log-Lik: -134453.567, Max-Change: 0.00094
Iteration: 25, Log-Lik: -134453.551, Max-Change: 0.00071
Iteration: 26, Log-Lik: -134453.547, Max-Change: 0.00026
Iteration: 27, Log-Lik: -134453.545, Max-Change: 0.00025
Iteration: 28, Log-Lik: -134453.544, Max-Change: 0.00020
Iteration: 29, Log-Lik: -134453.544, Max-Change: 0.00018
Iteration: 30, Log-Lik: -134453.543, Max-Change: 0.00019
Iteration: 31, Log-Lik: -134453.543, Max-Change: 0.00014
Iteration: 32, Log-Lik: -134453.543, Max-Change: 0.00016
Iteration: 33, Log-Lik: -134453.543, Max-Change: 0.00015
Iteration: 34, Log-Lik: -134453.543, Max-Change: 0.00012
Iteration: 35, Log-Lik: -134453.543, Max-Change: 0.00011
Iteration: 36, Log-Lik: -134453.542, Max-Change: 0.00011
Iteration: 37, Log-Lik: -134453.542, Max-Change: 0.00010
Iteration: 38, Log-Lik: -134453.542, Max-Change: 0.00009
irt_CA
## 
## Call:
## mirt(data = CA_scored_items, model = 1)
## 
## Full-information item factor analysis with 1 factor(s).
## Converged within 1e-04 tolerance after 38 EM iterations.
## mirt version: 1.33.2 
## M-step optimizer: BFGS 
## EM acceleration: Ramsay 
## Number of rectangular quadrature: 61
## Latent density type: Gaussian 
## 
## Log-likelihood = -134454
## Estimated parameters: 28 
## AIC = 268963; AICc = 268963
## BIC = 269202; SABIC = 269113
irt_CA@Fit
## $G2
## [1] NaN
## 
## $p
## [1] NaN
## 
## $TLI
## [1] NaN
## 
## $CFI
## [1] NaN
## 
## $RMSEA
## [1] NaN
## 
## $df
## [1] 16355
## 
## $AIC
## [1] 268963
## 
## $AICc
## [1] 268963
## 
## $BIC
## [1] 269202
## 
## $SABIC
## [1] 269113
## 
## $DIC
## [1] 268963
## 
## $HQ
## [1] 269039
## 
## $logLik
## [1] -134454
## 
## $logPrior
## [1] 0
## 
## $SElogLik
## [1] 0
## 
## $F
##          F1
## q178   0.74
## q255   0.70
## q1201  0.75
## q14835 0.38
## q8672  0.72
## q18154 0.74
## q12625 0.58
## q477   0.60
## q256   0.37
## q43639 0.75
## q267   0.48
## q18698 0.69
## q511   0.68
## q57844 0.69
## 
## $h2
##   q178   q255  q1201 q14835  q8672 q18154 q12625   q477   q256 q43639   q267 q18698   q511 q57844 
##   0.54   0.50   0.57   0.14   0.52   0.55   0.34   0.36   0.14   0.56   0.23   0.48   0.46   0.48
#score
# irt_CA_scores = scoreIrt(irt_CA, CA_scored_items)
irt_CA_scores = fscores(irt_CA, full.scores = T, full.scores.SE = T)

#save
d$CA_old = d$CA %>% standardize()
d$CA = irt_CA_scores[, 1] %>% standardize()

#plot scores
GG_scatter(d, "CA", "CA_old")
## `geom_smooth()` using formula 'y ~ x'

Subsets

#white Americans only
d_white_amer = d %>% filter(race == "White", country %in% state.abb)

Analyses

Descriptive

#Sex
d$sex %>% table2()
#sexual orientation
d$sexual_orientation %>% table2()
#age
d$age %>% describe()
##    vars     n mean  sd median trimmed mad min max range skew kurtosis    se
## X1    1 36975   33 7.8     32      32 7.4  18 100    82 0.93        2 0.041
#country / state
d$country %>% table2()
#anglo
d$anglophone %>% table2()
#western
d$western %>% table2()

Religious stance and seriousness of the belief

Whole sample

#plot
d %>% 
  GG_group_means("CA", groupvar = "religion", subgroupvar = "religion_seriousness", min_n = 5) +
  theme(axis.text.x = element_text(angle = -30, hjust = 0)) +
  scale_y_continuous("Mean intelligence") +
  scale_x_discrete("Religious position") +
  scale_fill_discrete("Seriousness")
## Missing values were removed.
## Warning: Problem with `mutate()` input `ci_bar`.
## ℹ NaNs produced
## ℹ Input `ci_bar` is `qt(1 - ((1 - CI)/1.96), df = n - 1)`.
## Scale for 'x' is already present. Adding another scale for 'x', which will replace the existing scale.
## Scale for 'fill' is already present. Adding another scale for 'fill', which will replace the existing scale.

  GG_save("figs/main.png")

#values
d %$% describeBy(CA, religion_combined, mat = T)
#without subgroups
d %>% 
  GG_group_means("CA", groupvar = "religion", min_n = 5) +
  theme(axis.text.x = element_text(angle = -30, hjust = 0)) +
  scale_y_continuous("Mean intelligence") +
  scale_x_discrete("Religious position") +
  scale_fill_discrete("Seriousness")
## Missing values were removed.
## Scale for 'x' is already present. Adding another scale for 'x', which will replace the existing scale.

GG_save("figs/main_alt.png")

#values
d %$% describeBy(CA, religion, mat = T)
#correlations by group
plyr::ddply(d, "religion", .fun = function(dd) {
  # fit_r = polyserial(dd$CA, dd$religion_seriousness %>% as.numeric() %>% as.data.frame())
  fit_r = polycor::hetcor(dd[c("CA", "religion_seriousness")])

  data_frame(
    n = nrow(dd),
    mean = wtd_mean(dd$CA), 
    r = fit_r$correlations[1, 2],
    se = fit_r$std.errors[1, 2],
    p = pnorm(abs(r) / se, lower.tail = F)
  )
})
## Warning: `data_frame()` is deprecated as of tibble 1.1.0.
## Please use `tibble()` instead.
## This warning is displayed once every 8 hours.
## Call `lifecycle::last_warnings()` to see where this warning was generated.

White Americans

#plot
d_white_amer %>% 
  GG_group_means("CA", groupvar = "religion", subgroupvar = "religion_seriousness", min_n = 5) +
  theme(axis.text.x = element_text(angle = -30, hjust = 0)) +
  scale_y_continuous("Mean intelligence") +
  scale_x_discrete("Religious position") +
  scale_fill_discrete("Seriousness") +
  ggtitle("Religion by group and subgroup\nWhite Americans subset")
## Missing values were removed.
## Warning: Problem with `mutate()` input `ci_bar`.
## ℹ NaNs produced
## ℹ Input `ci_bar` is `qt(1 - ((1 - CI)/1.96), df = n - 1)`.

## Warning: Problem with `mutate()` input `ci_bar`.
## ℹ NaNs produced
## ℹ Input `ci_bar` is `qt(1 - ((1 - CI)/1.96), df = n - 1)`.

## Warning: Problem with `mutate()` input `ci_bar`.
## ℹ NaNs produced
## ℹ Input `ci_bar` is `qt(1 - ((1 - CI)/1.96), df = n - 1)`.
## Scale for 'x' is already present. Adding another scale for 'x', which will replace the existing scale.
## Scale for 'fill' is already present. Adding another scale for 'fill', which will replace the existing scale.

GG_save("figs/main_whites.png")

#values
d_white_amer %$% describeBy(CA, religion_combined, mat = T)
#without subgroups
d_white_amer %>% 
  GG_group_means("CA", groupvar = "religion", min_n = 5) +
  theme(axis.text.x = element_text(angle = -30, hjust = 0)) +
  scale_y_continuous("Mean intelligence") +
  scale_x_discrete("Religious position") +
  scale_fill_discrete("Seriousness") +
  ggtitle("Religion by group\nWhite Americans subset")
## Missing values were removed.
## Scale for 'x' is already present. Adding another scale for 'x', which will replace the existing scale.

GG_save("figs/main_alt_whites.png")

#values
d_white_amer %$% describeBy(CA, religion, mat = T)
#correlations by group
plyr::ddply(d_white_amer, "religion", .fun = function(dd) {
  # fit_r = polyserial(dd$CA, dd$religion_seriousness %>% as.numeric() %>% as.data.frame())
  fit_r = polycor::hetcor(dd[c("CA", "religion_seriousness")])
  
  data_frame(
    n = nrow(dd),
    mean = wtd_mean(dd$CA), 
    r = fit_r$correlations[1, 2],
    se = fit_r$std.errors[1, 2],
    p = pnorm(abs(r) / se, lower.tail = F)
  )
})
## Warning in hetcor.data.frame(dd[c("CA", "religion_seriousness")]): could not compute polyserial correlation between variables 2 and 1
##     Message: Error in if (any(diff(cts) < 0)) return(Inf) : 
##   missing value where TRUE/FALSE needed
## Warning in hetcor.data.frame(dd[c("CA", "religion_seriousness")]): could not compute polyserial correlation between variables 2 and 1
##     Message: Error in if (any(diff(cts) < 0)) return(Inf) : 
##   missing value where TRUE/FALSE needed

Religious factor

Latent factor approach.

#subset items
d_religion = d[c("q41", "q42", "q61786", "q210", "q156917")]

#convert to integer for psych
d_religion_int = map_df(d_religion, as.integer)

#rows to keep (some are completely empty)
d_religion_miss = miss_by_case(d_religion)
d_religion_miss_thres = 3
d_religion_int = d_religion_int[d_religion_miss < d_religion_miss_thres, ]
d = d[d_religion_miss < d_religion_miss_thres, ]

#factor analyze / IRT
# irt_religion = irt.fa(d_religion_int, fm = "ml")
irt_religion = mirt(d_religion_int, model = 1)
## 
Iteration: 1, Log-Lik: -89794.887, Max-Change: 1.34487
Iteration: 2, Log-Lik: -77968.925, Max-Change: 1.57812
Iteration: 3, Log-Lik: -71638.757, Max-Change: 1.22459
Iteration: 4, Log-Lik: -69113.679, Max-Change: 0.93371
Iteration: 5, Log-Lik: -68093.657, Max-Change: 0.76060
Iteration: 6, Log-Lik: -67669.301, Max-Change: 0.56779
Iteration: 7, Log-Lik: -67480.120, Max-Change: 0.41534
Iteration: 8, Log-Lik: -67390.119, Max-Change: 0.29961
Iteration: 9, Log-Lik: -67346.210, Max-Change: 0.23439
Iteration: 10, Log-Lik: -67321.961, Max-Change: 0.17359
Iteration: 11, Log-Lik: -67308.597, Max-Change: 0.12710
Iteration: 12, Log-Lik: -67301.075, Max-Change: 0.09588
Iteration: 13, Log-Lik: -67296.791, Max-Change: 0.07066
Iteration: 14, Log-Lik: -67294.059, Max-Change: 0.05101
Iteration: 15, Log-Lik: -67292.370, Max-Change: 0.03862
Iteration: 16, Log-Lik: -67289.439, Max-Change: 0.00687
Iteration: 17, Log-Lik: -67289.159, Max-Change: 0.00714
Iteration: 18, Log-Lik: -67288.936, Max-Change: 0.00610
Iteration: 19, Log-Lik: -67288.665, Max-Change: 0.00523
Iteration: 20, Log-Lik: -67288.540, Max-Change: 0.00470
Iteration: 21, Log-Lik: -67288.443, Max-Change: 0.00389
Iteration: 22, Log-Lik: -67288.234, Max-Change: 0.00819
Iteration: 23, Log-Lik: -67288.177, Max-Change: 0.00279
Iteration: 24, Log-Lik: -67288.143, Max-Change: 0.00259
Iteration: 25, Log-Lik: -67288.062, Max-Change: 0.00252
Iteration: 26, Log-Lik: -67288.042, Max-Change: 0.00177
Iteration: 27, Log-Lik: -67288.032, Max-Change: 0.00168
Iteration: 28, Log-Lik: -67288.014, Max-Change: 0.00177
Iteration: 29, Log-Lik: -67288.006, Max-Change: 0.00099
Iteration: 30, Log-Lik: -67288.002, Max-Change: 0.00093
Iteration: 31, Log-Lik: -67287.984, Max-Change: 0.00033
Iteration: 32, Log-Lik: -67287.984, Max-Change: 0.00020
Iteration: 33, Log-Lik: -67287.983, Max-Change: 0.00020
Iteration: 34, Log-Lik: -67287.982, Max-Change: 0.00019
Iteration: 35, Log-Lik: -67287.982, Max-Change: 0.00089
Iteration: 36, Log-Lik: -67287.981, Max-Change: 0.00033
Iteration: 37, Log-Lik: -67287.980, Max-Change: 0.00018
Iteration: 38, Log-Lik: -67287.980, Max-Change: 0.00072
Iteration: 39, Log-Lik: -67287.980, Max-Change: 0.00056
Iteration: 40, Log-Lik: -67287.979, Max-Change: 0.00019
Iteration: 41, Log-Lik: -67287.979, Max-Change: 0.00068
Iteration: 42, Log-Lik: -67287.979, Max-Change: 0.00063
Iteration: 43, Log-Lik: -67287.978, Max-Change: 0.00018
Iteration: 44, Log-Lik: -67287.978, Max-Change: 0.00063
Iteration: 45, Log-Lik: -67287.978, Max-Change: 0.00058
Iteration: 46, Log-Lik: -67287.978, Max-Change: 0.00016
Iteration: 47, Log-Lik: -67287.978, Max-Change: 0.00060
Iteration: 48, Log-Lik: -67287.977, Max-Change: 0.00053
Iteration: 49, Log-Lik: -67287.977, Max-Change: 0.00015
Iteration: 50, Log-Lik: -67287.977, Max-Change: 0.00058
Iteration: 51, Log-Lik: -67287.977, Max-Change: 0.00049
Iteration: 52, Log-Lik: -67287.976, Max-Change: 0.00014
Iteration: 53, Log-Lik: -67287.976, Max-Change: 0.00057
Iteration: 54, Log-Lik: -67287.976, Max-Change: 0.00047
Iteration: 55, Log-Lik: -67287.976, Max-Change: 0.00013
Iteration: 56, Log-Lik: -67287.976, Max-Change: 0.00055
Iteration: 57, Log-Lik: -67287.975, Max-Change: 0.00044
Iteration: 58, Log-Lik: -67287.975, Max-Change: 0.00013
Iteration: 59, Log-Lik: -67287.975, Max-Change: 0.00054
Iteration: 60, Log-Lik: -67287.975, Max-Change: 0.00043
Iteration: 61, Log-Lik: -67287.975, Max-Change: 0.00012
Iteration: 62, Log-Lik: -67287.975, Max-Change: 0.00053
Iteration: 63, Log-Lik: -67287.974, Max-Change: 0.00041
Iteration: 64, Log-Lik: -67287.974, Max-Change: 0.00012
Iteration: 65, Log-Lik: -67287.974, Max-Change: 0.00052
Iteration: 66, Log-Lik: -67287.974, Max-Change: 0.00040
Iteration: 67, Log-Lik: -67287.974, Max-Change: 0.00011
Iteration: 68, Log-Lik: -67287.974, Max-Change: 0.00051
Iteration: 69, Log-Lik: -67287.974, Max-Change: 0.00038
Iteration: 70, Log-Lik: -67287.973, Max-Change: 0.00011
Iteration: 71, Log-Lik: -67287.973, Max-Change: 0.00050
Iteration: 72, Log-Lik: -67287.973, Max-Change: 0.00037
Iteration: 73, Log-Lik: -67287.973, Max-Change: 0.00011
Iteration: 74, Log-Lik: -67287.973, Max-Change: 0.00049
Iteration: 75, Log-Lik: -67287.973, Max-Change: 0.00036
Iteration: 76, Log-Lik: -67287.973, Max-Change: 0.00010
Iteration: 77, Log-Lik: -67287.972, Max-Change: 0.00048
Iteration: 78, Log-Lik: -67287.972, Max-Change: 0.00035
Iteration: 79, Log-Lik: -67287.972, Max-Change: 0.00010
Iteration: 80, Log-Lik: -67287.972, Max-Change: 0.00048
Iteration: 81, Log-Lik: -67287.972, Max-Change: 0.00035
Iteration: 82, Log-Lik: -67287.972, Max-Change: 0.00010
irt_religion
## 
## Call:
## mirt(data = d_religion_int, model = 1)
## 
## Full-information item factor analysis with 1 factor(s).
## Converged within 1e-04 tolerance after 82 EM iterations.
## mirt version: 1.33.2 
## M-step optimizer: BFGS 
## EM acceleration: Ramsay 
## Number of rectangular quadrature: 61
## Latent density type: Gaussian 
## 
## Log-likelihood = -67288
## Estimated parameters: 12 
## AIC = 134600; AICc = 134600
## BIC = 134699; SABIC = 134661
irt_religion@Fit
## $G2
## [1] NaN
## 
## $p
## [1] NaN
## 
## $TLI
## [1] NaN
## 
## $CFI
## [1] NaN
## 
## $RMSEA
## [1] NaN
## 
## $df
## [1] 51
## 
## $AIC
## [1] 134600
## 
## $AICc
## [1] 134600
## 
## $BIC
## [1] 134699
## 
## $SABIC
## [1] 134661
## 
## $DIC
## [1] 134600
## 
## $HQ
## [1] 134632
## 
## $logLik
## [1] -67288
## 
## $logPrior
## [1] 0
## 
## $SElogLik
## [1] 0
## 
## $F
##            F1
## q41      0.94
## q42      0.95
## q61786   0.69
## q210     0.97
## q156917 -0.95
## 
## $h2
##     q41     q42  q61786    q210 q156917 
##    0.89    0.90    0.47    0.95    0.89
#latent cors
d_religion_int %>% mixed.cor()
## 
## mixed.cor is deprecated, please use mixedCor.
## Call: mixedCor(data = x, c = NULL, p = p, d = d, smooth = smooth, correct = correct, 
##     global = global, ncat = ncat, use = use, method = method, 
##     weight = weight)
##         q41   q42   q6178 q210  q1569
## q41      1.00                        
## q42      0.89  1.00                  
## q61786   0.68  0.77  1.00            
## q210     0.90  0.82  0.62  1.00      
## q156917 -0.87 -0.73 -0.61 -0.94  1.00
#two items for example as a contingency table
table(believe_god = d$q210, atheist = d$q156917) %>% prop.table(margin = 1)
##            atheist
## believe_god   Yes    No
##         Yes 0.033 0.967
##         No  0.761 0.239
#score subjects
# irt_religion_scores = scoreIrt(irt_religion, items = d_religion_int, mod = "normal")
irt_religion_scores = fscores(irt_religion, full.scores = T, full.scores.SE = T)
#the normal here makes the scoring not give tons of warnings, and somehow prevents a bug with R notebook

#standardize
d$latent_religion = irt_religion_scores[, 1] %>% standardize() %>% multiply_by(-1)

#plot
GG_scatter(d, "CA", "latent_religion")
## `geom_smooth()` using formula 'y ~ x'

#correct for measurement error
#religion
(religion_reliability = empirical_rxx(irt_religion_scores))
##  F1 
## 0.8
#CA
(CA_reliability = empirical_rxx(irt_CA_scores))
##   F1 
## 0.63
#correct
cor_matrix(d[c("CA", "latent_religion")], reliabilities = c(CA_reliability, religion_reliability))
##                    CA latent_religion
## CA               0.63           -0.42
## latent_religion -0.42            0.80
#jews
d %>% 
  filter(q156914 == "Yes") %>% 
  {
    list(
      n = nrow(.),
      cor = wtd.cor(.$CA, .$latent_religion),
      cor2 = cor.test(.$CA, .$latent_religion)
    )
  }
## $n
## [1] 1490
## 
## $cor
##   correlation std.err t.value p.value
## Y       -0.24   0.025    -9.5 1.1e-20
## 
## $cor2
## 
##  Pearson's product-moment correlation
## 
## data:  .$CA and .$latent_religion
## t = -9, df = 1488, p-value <2e-16
## alternative hypothesis: true correlation is not equal to 0
## 95 percent confidence interval:
##  -0.29 -0.19
## sample estimates:
##   cor 
## -0.24

Models

list(
  ols(latent_religion ~ CA, data = d),
  ols(latent_religion ~ CA + rcs(age), data = d),
  ols(latent_religion ~ CA + gender_orientation + rcs(age), data = d),
  ols(latent_religion ~ CA + race + rcs(age), data = d),
  ols(latent_religion ~ CA + gender_orientation + race + rcs(age), data = d),
  ols(latent_religion ~ CA + gender_orientation + race + rcs(age) + country, data = d),
  ols(latent_religion ~ CA * anglophone + gender_orientation + race + rcs(age), data = d),
  ols(latent_religion ~ CA * western + gender_orientation + race + rcs(age), data = d)
  ) %>% 
  print() %>% 
  summarize_models()
## [[1]]
## Linear Regression Model
##  
##  ols(formula = latent_religion ~ CA, data = d)
##  
##                   Model Likelihood    Discrimination    
##                         Ratio Test           Indexes    
##  Obs   29169    LR chi2    2688.19    R2       0.088    
##  sigma0.9550    d.f.             1    R2 adj   0.088    
##  d.f.  29167    Pr(> chi2)  0.0000    g        0.338    
##  
##  Residuals
##  
##       Min       1Q   Median       3Q      Max 
##  -2.15477 -0.83376 -0.03887  0.69711  2.70535 
##  
##  
##            Coef    S.E.   t      Pr(>|t|)
##  Intercept  0.0263 0.0056   4.68 <0.0001 
##  CA        -0.3027 0.0057 -53.06 <0.0001 
##  
## 
## [[2]]
## Frequencies of Missing Values Due to Each Variable
## latent_religion              CA             age 
##               0               0             616 
## 
## Linear Regression Model
##  
##  ols(formula = latent_religion ~ CA + rcs(age), data = d)
##  
##  
##                   Model Likelihood    Discrimination    
##                         Ratio Test           Indexes    
##  Obs   28553    LR chi2    3182.36    R2       0.105    
##  sigma0.9458    d.f.             5    R2 adj   0.105    
##  d.f.  28547    Pr(> chi2)  0.0000    g        0.369    
##  
##  Residuals
##  
##       Min       1Q   Median       3Q      Max 
##  -2.25269 -0.81478 -0.04737  0.67781  2.81113 
##  
##  
##            Coef    S.E.   t      Pr(>|t|)
##  Intercept -0.8730 0.1175  -7.43 <0.0001 
##  CA        -0.3044 0.0058 -52.93 <0.0001 
##  age        0.0293 0.0047   6.29 <0.0001 
##  age'      -0.0192 0.0359  -0.54 0.5923  
##  age''     -0.0846 0.1526  -0.55 0.5793  
##  age'''     0.2783 0.2027   1.37 0.1697  
##  
## 
## [[3]]
## Frequencies of Missing Values Due to Each Variable
##    latent_religion                 CA gender_orientation                age 
##                  0                  0                961                616 
## 
## Linear Regression Model
##  
##  ols(formula = latent_religion ~ CA + gender_orientation + rcs(age), 
##      data = d)
##  
##  
##                   Model Likelihood    Discrimination    
##                         Ratio Test           Indexes    
##  Obs   28208    LR chi2    3432.37    R2       0.115    
##  sigma0.9417    d.f.            10    R2 adj   0.114    
##  d.f.  28197    Pr(> chi2)  0.0000    g        0.384    
##  
##  Residuals
##  
##       Min       1Q   Median       3Q      Max 
##  -2.42430 -0.80503 -0.04524  0.67363  2.88721 
##  
##  
##                                     Coef    S.E.   t      Pr(>|t|)
##  Intercept                          -0.6760 0.1204  -5.62 <0.0001 
##  CA                                 -0.2958 0.0058 -51.16 <0.0001 
##  gender_orientation=Bisexual_female -0.2938 0.0269 -10.92 <0.0001 
##  gender_orientation=Gay_female      -0.1450 0.0516  -2.81 0.0050  
##  gender_orientation=Gay_male        -0.1113 0.0278  -4.01 <0.0001 
##  gender_orientation=Bisexual_male   -0.3112 0.0407  -7.65 <0.0001 
##  gender_orientation=Hetero_male     -0.2203 0.0139 -15.86 <0.0001 
##  age                                 0.0277 0.0047   5.84 <0.0001 
##  age'                               -0.0030 0.0361  -0.08 0.9330  
##  age''                              -0.1224 0.1532  -0.80 0.4243  
##  age'''                              0.2886 0.2032   1.42 0.1554  
##  
## 
## [[4]]
## Frequencies of Missing Values Due to Each Variable
## latent_religion              CA            race             age 
##               0               0            2433             616 
## 
## Linear Regression Model
##  
##  ols(formula = latent_religion ~ CA + race + rcs(age), data = d)
##  
##  
##                   Model Likelihood    Discrimination    
##                         Ratio Test           Indexes    
##  Obs   26736    LR chi2    3843.62    R2       0.134    
##  sigma0.9314    d.f.            14    R2 adj   0.133    
##  d.f.  26721    Pr(> chi2)  0.0000    g        0.411    
##  
##  Residuals
##  
##       Min       1Q   Median       3Q      Max 
##  -2.40564 -0.79196 -0.04104  0.66203  2.86298 
##  
##  
##                        Coef    S.E.   t      Pr(>|t|)
##  Intercept             -1.1188 0.1212  -9.23 <0.0001 
##  CA                    -0.2788 0.0059 -46.91 <0.0001 
##  race=Mixed             0.2785 0.0194  14.35 <0.0001 
##  race=Asian             0.3086 0.0294  10.51 <0.0001 
##  race=Hispanic / Latin  0.3923 0.0297  13.20 <0.0001 
##  race=Black             0.7154 0.0301  23.78 <0.0001 
##  race=Other             0.0672 0.0359   1.87 0.0615  
##  race=Indian            0.2694 0.0603   4.47 <0.0001 
##  race=Middle Eastern    0.3097 0.0953   3.25 0.0012  
##  race=Native American   0.2989 0.1294   2.31 0.0209  
##  race=Pacific Islander  0.4465 0.1375   3.25 0.0012  
##  age                    0.0350 0.0048   7.30 <0.0001 
##  age'                  -0.0309 0.0368  -0.84 0.4016  
##  age''                 -0.0775 0.1561  -0.50 0.6196  
##  age'''                 0.3188 0.2072   1.54 0.1240  
##  
## 
## [[5]]
## Frequencies of Missing Values Due to Each Variable
##    latent_religion                 CA gender_orientation               race                age 
##                  0                  0                961               2433                616 
## 
## Linear Regression Model
##  
##  ols(formula = latent_religion ~ CA + gender_orientation + race + 
##      rcs(age), data = d)
##  
##  
##                   Model Likelihood    Discrimination    
##                         Ratio Test           Indexes    
##  Obs   26421    LR chi2    4110.45    R2       0.144    
##  sigma0.9266    d.f.            19    R2 adj   0.143    
##  d.f.  26401    Pr(> chi2)  0.0000    g        0.427    
##  
##  Residuals
##  
##       Min       1Q   Median       3Q      Max 
##  -2.37502 -0.78128 -0.04184  0.65334  2.95127 
##  
##  
##                                     Coef    S.E.   t      Pr(>|t|)
##  Intercept                          -0.9277 0.1241  -7.48 <0.0001 
##  CA                                 -0.2700 0.0060 -45.25 <0.0001 
##  gender_orientation=Bisexual_female -0.2894 0.0278 -10.41 <0.0001 
##  gender_orientation=Gay_female      -0.1778 0.0538  -3.31 0.0010  
##  gender_orientation=Gay_male        -0.1484 0.0280  -5.30 <0.0001 
##  gender_orientation=Bisexual_male   -0.3145 0.0423  -7.44 <0.0001 
##  gender_orientation=Hetero_male     -0.2359 0.0142 -16.61 <0.0001 
##  race=Mixed                          0.2927 0.0195  15.00 <0.0001 
##  race=Asian                          0.2742 0.0293   9.34 <0.0001 
##  race=Hispanic / Latin               0.4045 0.0297  13.61 <0.0001 
##  race=Black                          0.7121 0.0301  23.66 <0.0001 
##  race=Other                          0.0794 0.0360   2.21 0.0274  
##  race=Indian                         0.2988 0.0603   4.96 <0.0001 
##  race=Middle Eastern                 0.3222 0.0948   3.40 0.0007  
##  race=Native American                0.3063 0.1288   2.38 0.0174  
##  race=Pacific Islander               0.4295 0.1369   3.14 0.0017  
##  age                                 0.0339 0.0049   6.96 <0.0001 
##  age'                               -0.0162 0.0370  -0.44 0.6625  
##  age''                              -0.1092 0.1567  -0.70 0.4860  
##  age'''                              0.3205 0.2076   1.54 0.1226  
##  
## 
## [[6]]
## Frequencies of Missing Values Due to Each Variable
##    latent_religion                 CA gender_orientation               race                age            country 
##                  0                  0                961               2433                616                616 
## 
## Linear Regression Model
##  
##  ols(formula = latent_religion ~ CA + gender_orientation + race + 
##      rcs(age) + country, data = d)
##  
##  
##                   Model Likelihood    Discrimination    
##                         Ratio Test           Indexes    
##  Obs   26421    LR chi2    6247.81    R2       0.211    
##  sigma0.8928    d.f.           191    R2 adj   0.205    
##  d.f.  26229    Pr(> chi2)  0.0000    g        0.517    
##  
##  Residuals
##  
##       Min       1Q   Median       3Q      Max 
##  -2.48101 -0.70582 -0.04804  0.61752  3.09660 
##  
##  
##                                            Coef    S.E.   t      Pr(>|t|)
##  Intercept                                 -0.2834 0.1754  -1.62 0.1062  
##  CA                                        -0.2421 0.0058 -41.56 <0.0001 
##  gender_orientation=Bisexual_female        -0.2606 0.0269  -9.68 <0.0001 
##  gender_orientation=Gay_female             -0.1777 0.0520  -3.42 0.0006  
##  gender_orientation=Gay_male               -0.1869 0.0272  -6.87 <0.0001 
##  gender_orientation=Bisexual_male          -0.2908 0.0409  -7.11 <0.0001 
##  gender_orientation=Hetero_male            -0.2366 0.0138 -17.12 <0.0001 
##  race=Mixed                                 0.2451 0.0191  12.80 <0.0001 
##  race=Asian                                 0.1791 0.0321   5.59 <0.0001 
##  race=Hispanic / Latin                      0.3499 0.0297  11.77 <0.0001 
##  race=Black                                 0.6415 0.0294  21.83 <0.0001 
##  race=Other                                 0.1478 0.0350   4.22 <0.0001 
##  race=Indian                                0.3066 0.0649   4.72 <0.0001 
##  race=Middle Eastern                        0.3052 0.0961   3.18 0.0015  
##  race=Native American                       0.1770 0.1244   1.42 0.1548  
##  race=Pacific Islander                      0.4598 0.1324   3.47 0.0005  
##  age                                        0.0158 0.0048   3.32 0.0009  
##  age'                                       0.0397 0.0359   1.11 0.2687  
##  age''                                     -0.2137 0.1517  -1.41 0.1588  
##  age'''                                     0.3166 0.2011   1.57 0.1154  
##  country=AL                                 0.2570 0.1500   1.71 0.0866  
##  country=Alberta                           -0.3249 0.1477  -2.20 0.0279  
##  country=Algeria                            0.9918 0.9024   1.10 0.2718  
##  country=AR                                 0.2328 0.1582   1.47 0.1411  
##  country=Argentina                         -0.8530 0.2161  -3.95 <0.0001 
##  country=Australia                         -0.5539 0.1327  -4.18 <0.0001 
##  country=Austria                           -0.5735 0.1825  -3.14 0.0017  
##  country=AZ                                -0.0769 0.1346  -0.57 0.5675  
##  country=Bahamas                            1.4974 0.9019   1.66 0.0969  
##  country=Bahrain                           -1.0000 0.9018  -1.11 0.2675  
##  country=Bangladesh                         1.5590 0.9023   1.73 0.0840  
##  country=Belarus                            0.4460 0.9018   0.49 0.6209  
##  country=Belgium                           -0.6747 0.1660  -4.07 <0.0001 
##  country=Bermuda                           -0.5038 0.6440  -0.78 0.4340  
##  country=Bosnia and Herzegovina             0.8514 0.6439   1.32 0.1861  
##  country=Brazil                            -0.3302 0.1559  -2.12 0.0342  
##  country=British Columbia                  -0.4866 0.1385  -3.51 0.0004  
##  country=Brunei                             0.3654 0.9023   0.40 0.6855  
##  country=Bulgaria                          -0.4795 0.2507  -1.91 0.0559  
##  country=CA                                -0.1402 0.1275  -1.10 0.2714  
##  country=Cambodia                           0.1062 0.9023   0.12 0.9063  
##  country=Chile                              0.0993 0.3237   0.31 0.7590  
##  country=China                             -0.3288 0.1765  -1.86 0.0625  
##  country=CO                                -0.0404 0.1335  -0.30 0.7624  
##  country=Colombia                          -0.1372 0.3606  -0.38 0.7036  
##  country=Costa Rica                        -0.3925 0.2872  -1.37 0.1718  
##  country=Croatia                           -0.5424 0.2285  -2.37 0.0176  
##  country=CT                                -0.0302 0.1398  -0.22 0.8292  
##  country=Cyprus                             0.0867 0.6456   0.13 0.8932  
##  country=Czech Republic                    -0.5182 0.2508  -2.07 0.0388  
##  country=DC                                -0.1993 0.1456  -1.37 0.1710  
##  country=DE                                -0.1557 0.1968  -0.79 0.4288  
##  country=Denmark                           -0.5389 0.1415  -3.81 0.0001  
##  country=Dominican Republic                -0.0329 0.4190  -0.08 0.9375  
##  country=Ecuador                           -0.8281 0.5311  -1.56 0.1189  
##  country=Egypt                              0.3570 0.3411   1.05 0.2953  
##  country=El Salvador                        1.1155 0.9022   1.24 0.2163  
##  country=Estonia                           -1.1413 0.4640  -2.46 0.0139  
##  country=Falkland Islands (Islas Malvinas) -1.0522 0.9071  -1.16 0.2461  
##  country=Finland                           -0.5041 0.1540  -3.27 0.0011  
##  country=FL                                 0.0112 0.1299   0.09 0.9312  
##  country=France                            -0.6718 0.1504  -4.47 <0.0001 
##  country=GA                                 0.1596 0.1328   1.20 0.2296  
##  country=Georgia                            0.5318 0.6439   0.83 0.4089  
##  country=Germany                           -0.5350 0.1343  -3.98 <0.0001 
##  country=Greece                            -0.4647 0.2004  -2.32 0.0204  
##  country=GU                                 0.5208 0.9018   0.58 0.5636  
##  country=Guatemala                          0.1060 0.5309   0.20 0.8418  
##  country=Haiti                              0.0795 0.6440   0.12 0.9018  
##  country=HI                                -0.0321 0.1603  -0.20 0.8415  
##  country=Honduras                          -1.4480 0.9022  -1.60 0.1085  
##  country=Hong Kong                         -0.2858 0.2141  -1.33 0.1819  
##  country=Hungary                           -0.3475 0.2363  -1.47 0.1414  
##  country=IA                                 0.1728 0.1452   1.19 0.2339  
##  country=Iceland                           -0.7859 0.3093  -2.54 0.0111  
##  country=ID                                 0.0298 0.1610   0.19 0.8531  
##  country=IL                                -0.0712 0.1300  -0.55 0.5840  
##  country=IN                                 0.0618 0.1356   0.46 0.6485  
##  country=India                             -0.0975 0.1719  -0.57 0.5705  
##  country=Indonesia                          0.5445 0.2104   2.59 0.0097  
##  country=Iran                              -0.5709 0.4665  -1.22 0.2210  
##  country=Ireland                           -0.5195 0.1511  -3.44 0.0006  
##  country=Isle of Man                       -0.7408 0.9018  -0.82 0.4114  
##  country=Israel                            -0.2878 0.1628  -1.77 0.0770  
##  country=Italy                             -0.2875 0.1493  -1.92 0.0542  
##  country=Jamaica                            0.5243 0.6449   0.81 0.4163  
##  country=Japan                             -0.2748 0.1883  -1.46 0.1444  
##  country=Jordan                            -0.6489 0.6457  -1.01 0.3149  
##  country=Kazakhstan                         0.8785 0.6441   1.36 0.1726  
##  country=Kenya                             -1.2541 0.6441  -1.95 0.0515  
##  country=KS                                 0.1178 0.1466   0.80 0.4218  
##  country=Kuwait                             1.7544 0.6442   2.72 0.0065  
##  country=KY                                 0.1307 0.1430   0.91 0.3609  
##  country=LA                                -0.0295 0.1349  -0.22 0.8270  
##  country=Latvia                            -0.7967 0.4644  -1.72 0.0862  
##  country=Lebanon                            1.1637 0.9019   1.29 0.1970  
##  country=Lesotho                            0.5350 0.9025   0.59 0.5534  
##  country=Lithuania                         -0.3614 0.4640  -0.78 0.4360  
##  country=Luxembourg                        -0.9283 0.4189  -2.22 0.0267  
##  country=MA                                -0.1173 0.1310  -0.90 0.3703  
##  country=Macau                             -0.5850 0.9022  -0.65 0.5167  
##  country=Macedonia                          0.0019 0.6443   0.00 0.9977  
##  country=Malaysia                           0.2402 0.2100   1.14 0.2527  
##  country=Mali                              -1.4155 0.9103  -1.55 0.1200  
##  country=Malta                             -0.0932 0.4188  -0.22 0.8239  
##  country=Manitoba                          -0.6668 0.2022  -3.30 0.0010  
##  country=MD                                -0.0070 0.1338  -0.05 0.9583  
##  country=ME                                -0.2255 0.1631  -1.38 0.1667  
##  country=Mexico                            -0.2710 0.1759  -1.54 0.1235  
##  country=MI                                 0.0587 0.1320   0.44 0.6566  
##  country=MN                                -0.0200 0.1339  -0.15 0.8816  
##  country=MO                                 0.1793 0.1360   1.32 0.1873  
##  country=Morocco                            1.6352 0.9023   1.81 0.0699  
##  country=MS                                 0.2491 0.1703   1.46 0.1436  
##  country=MT                                 0.1558 0.1796   0.87 0.3857  
##  country=Namibia                            0.6339 0.9024   0.70 0.4824  
##  country=NC                                 0.1723 0.1332   1.29 0.1959  
##  country=ND                                -0.1451 0.2159  -0.67 0.5017  
##  country=NE                                -0.1057 0.1549  -0.68 0.4950  
##  country=Nepal                              0.5757 0.9023   0.64 0.5234  
##  country=Netherlands                       -0.7246 0.1396  -5.19 <0.0001 
##  country=Netherlands Antilles              -1.1875 0.9017  -1.32 0.1879  
##  country=New Brunswick                     -0.0434 0.2565  -0.17 0.8656  
##  country=New Zealand                       -0.5262 0.1882  -2.80 0.0052  
##  country=NH                                -0.1581 0.1544  -1.02 0.3060  
##  country=Nicaragua                          1.9284 0.9018   2.14 0.0325  
##  country=Nigeria                            1.3816 0.9025   1.53 0.1258  
##  country=NJ                                -0.0014 0.1326  -0.01 0.9915  
##  country=NM                                -0.0782 0.1517  -0.52 0.6064  
##  country=Norway                            -0.7962 0.1895  -4.20 <0.0001 
##  country=Nova Scotia                       -0.5540 0.2042  -2.71 0.0067  
##  country=NV                                -0.1094 0.1416  -0.77 0.4395  
##  country=NY                                -0.1648 0.1279  -1.29 0.1976  
##  country=OH                                 0.0623 0.1318   0.47 0.6366  
##  country=OK                                 0.2322 0.1429   1.63 0.1041  
##  country=Oman                               1.8470 0.9024   2.05 0.0407  
##  country=Ontario                           -0.3594 0.1322  -2.72 0.0066  
##  country=OR                                -0.2364 0.1324  -1.78 0.0743  
##  country=PA                                 0.0002 0.1302   0.00 0.9985  
##  country=Pakistan                           1.1681 0.5310   2.20 0.0278  
##  country=Panama                             1.1738 0.9022   1.30 0.1933  
##  country=Paraguay                          -0.2628 0.9022  -0.29 0.7709  
##  country=Peru                               0.1301 0.3095   0.42 0.6742  
##  country=Philippines                        0.7926 0.1675   4.73 <0.0001 
##  country=Poland                            -0.5157 0.2407  -2.14 0.0322  
##  country=Portugal                          -0.3814 0.2042  -1.87 0.0617  
##  country=PR                                -0.2820 0.2413  -1.17 0.2425  
##  country=Qatar                              0.4514 0.6447   0.70 0.4838  
##  country=Quebec                            -0.5687 0.1533  -3.71 0.0002  
##  country=RI                                -0.1073 0.1572  -0.68 0.4949  
##  country=Romania                           -0.2929 0.1969  -1.49 0.1368  
##  country=Russia                            -0.0216 0.2043  -0.11 0.9158  
##  country=Saskatchewan                      -0.4524 0.2408  -1.88 0.0603  
##  country=Saudi Arabia                       1.1005 0.3166   3.48 0.0005  
##  country=SC                                 0.1170 0.1435   0.82 0.4148  
##  country=SD                                 0.4915 0.2408   2.04 0.0412  
##  country=Serbia                            -0.3635 0.3400  -1.07 0.2851  
##  country=Singapore                          0.3398 0.1528   2.22 0.0262  
##  country=Slovakia                           0.1531 0.4188   0.37 0.7147  
##  country=Slovenia                          -0.5883 0.3604  -1.63 0.1026  
##  country=South Africa                      -0.1460 0.1923  -0.76 0.4475  
##  country=South Korea                       -0.0651 0.2189  -0.30 0.7660  
##  country=Spain                             -0.8590 0.1745  -4.92 <0.0001 
##  country=Sri Lanka                          0.1381 0.9023   0.15 0.8783  
##  country=Suriname                           0.2825 0.9022   0.31 0.7542  
##  country=Svalbard                          -0.2329 0.9027  -0.26 0.7964  
##  country=Sweden                            -0.6427 0.1467  -4.38 <0.0001 
##  country=Switzerland                       -0.4488 0.1847  -2.43 0.0151  
##  country=Taiwan                            -0.1621 0.2292  -0.71 0.4796  
##  country=Tajikistan                         0.1062 0.9018   0.12 0.9062  
##  country=Thailand                          -0.5895 0.2456  -2.40 0.0164  
##  country=TN                                 0.2079 0.1378   1.51 0.1314  
##  country=Trinidad and Tobago                1.2021 0.5312   2.26 0.0236  
##  country=Tunisia                            1.6849 0.9019   1.87 0.0617  
##  country=Turkey                             0.0127 0.1970   0.06 0.9485  
##  country=TX                                 0.1295 0.1287   1.01 0.3144  
##  country=UK                                -0.6340 0.1281  -4.95 <0.0001 
##  country=Ukraine                           -0.4440 0.3604  -1.23 0.2179  
##  country=United Arab Emirates               0.0761 0.2632   0.29 0.7726  
##  country=Uruguay                            0.2925 0.6440   0.45 0.6498  
##  country=UT                                 0.0871 0.1449   0.60 0.5480  
##  country=VA                                 0.1221 0.1324   0.92 0.3563  
##  country=Vanuatu                           -0.9902 0.9018  -1.10 0.2722  
##  country=Venezuela                          0.6402 0.3865   1.66 0.0977  
##  country=VI                                -1.3656 0.9018  -1.51 0.1300  
##  country=Vietnam                           -0.5458 0.3251  -1.68 0.0932  
##  country=VT                                -0.1129 0.1745  -0.65 0.5174  
##  country=WA                                -0.1579 0.1301  -1.21 0.2249  
##  country=WI                                -0.0313 0.1352  -0.23 0.8168  
##  country=WV                                 0.1220 0.1753   0.70 0.4865  
##  country=WY                                -0.1760 0.2700  -0.65 0.5145  
##  country=Zimbabwe                           0.6161 0.9018   0.68 0.4945  
##  
## 
## [[7]]
## Frequencies of Missing Values Due to Each Variable
##    latent_religion                 CA         anglophone gender_orientation               race                age 
##                  0                  0                616                961               2433                616 
## 
## Linear Regression Model
##  
##  ols(formula = latent_religion ~ CA * anglophone + gender_orientation + 
##      race + rcs(age), data = d)
##  
##  
##                   Model Likelihood    Discrimination    
##                         Ratio Test           Indexes    
##  Obs   26421    LR chi2    4363.05    R2       0.152    
##  sigma0.9222    d.f.            21    R2 adj   0.152    
##  d.f.  26399    Pr(> chi2)  0.0000    g        0.440    
##  
##  Residuals
##  
##       Min       1Q   Median       3Q      Max 
##  -2.36902 -0.77041 -0.04684  0.64820  3.17457 
##  
##  
##                                     Coef    S.E.   t      Pr(>|t|)
##  Intercept                          -1.1855 0.1246  -9.52 <0.0001 
##  CA                                 -0.2474 0.0191 -12.98 <0.0001 
##  anglophone                          0.2996 0.0192  15.60 <0.0001 
##  gender_orientation=Bisexual_female -0.2873 0.0277 -10.38 <0.0001 
##  gender_orientation=Gay_female      -0.1851 0.0536  -3.46 0.0005  
##  gender_orientation=Gay_male        -0.1608 0.0279  -5.76 <0.0001 
##  gender_orientation=Bisexual_male   -0.3093 0.0421  -7.35 <0.0001 
##  gender_orientation=Hetero_male     -0.2356 0.0141 -16.66 <0.0001 
##  race=Mixed                          0.2883 0.0194  14.84 <0.0001 
##  race=Asian                          0.3154 0.0294  10.73 <0.0001 
##  race=Hispanic / Latin               0.4078 0.0296  13.78 <0.0001 
##  race=Black                          0.6966 0.0300  23.24 <0.0001 
##  race=Other                          0.0931 0.0358   2.60 0.0094  
##  race=Indian                         0.3552 0.0601   5.91 <0.0001 
##  race=Middle Eastern                 0.3963 0.0945   4.19 <0.0001 
##  race=Native American                0.2789 0.1282   2.18 0.0296  
##  race=Pacific Islander               0.4151 0.1362   3.05 0.0023  
##  age                                 0.0335 0.0049   6.91 <0.0001 
##  age'                               -0.0171 0.0368  -0.47 0.6418  
##  age''                              -0.1002 0.1560  -0.64 0.5204  
##  age'''                              0.3031 0.2066   1.47 0.1423  
##  CA * anglophone                    -0.0188 0.0200  -0.94 0.3478  
##  
## 
## [[8]]
## Frequencies of Missing Values Due to Each Variable
##    latent_religion                 CA            western gender_orientation               race                age 
##                  0                  0                616                961               2433                616 
## 
## Linear Regression Model
##  
##  ols(formula = latent_religion ~ CA * western + gender_orientation + 
##      race + rcs(age), data = d)
##  
##  
##                   Model Likelihood    Discrimination    
##                         Ratio Test           Indexes    
##  Obs   26421    LR chi2    4111.27    R2       0.144    
##  sigma0.9266    d.f.            21    R2 adj   0.143    
##  d.f.  26399    Pr(> chi2)  0.0000    g        0.427    
##  
##  Residuals
##  
##       Min       1Q   Median       3Q      Max 
##  -2.40041 -0.78095 -0.04133  0.65376  2.96079 
##  
##  
##                                     Coef    S.E.   t      Pr(>|t|)
##  Intercept                          -0.9057 0.1276  -7.10 <0.0001 
##  CA                                 -0.2865 0.0287  -9.98 <0.0001 
##  western                            -0.0206 0.0283  -0.73 0.4670  
##  gender_orientation=Bisexual_female -0.2893 0.0278 -10.40 <0.0001 
##  gender_orientation=Gay_female      -0.1772 0.0538  -3.29 0.0010  
##  gender_orientation=Gay_male        -0.1480 0.0280  -5.28 <0.0001 
##  gender_orientation=Bisexual_male   -0.3142 0.0423  -7.44 <0.0001 
##  gender_orientation=Hetero_male     -0.2358 0.0142 -16.60 <0.0001 
##  race=Mixed                          0.2923 0.0195  14.97 <0.0001 
##  race=Asian                          0.2673 0.0305   8.78 <0.0001 
##  race=Hispanic / Latin               0.4033 0.0298  13.55 <0.0001 
##  race=Black                          0.7122 0.0301  23.66 <0.0001 
##  race=Other                          0.0786 0.0360   2.18 0.0291  
##  race=Indian                         0.2921 0.0608   4.80 <0.0001 
##  race=Middle Eastern                 0.3178 0.0950   3.34 0.0008  
##  race=Native American                0.3073 0.1288   2.39 0.0170  
##  race=Pacific Islander               0.4299 0.1369   3.14 0.0017  
##  age                                 0.0338 0.0049   6.94 <0.0001 
##  age'                               -0.0157 0.0370  -0.42 0.6722  
##  age''                              -0.1105 0.1567  -0.71 0.4807  
##  age'''                              0.3212 0.2076   1.55 0.1217  
##  CA * western                        0.0173 0.0293   0.59 0.5554  
##