I’ve chosen Switzerland on 9th round - just because someday I want to live there (among mountains and forests!)
library(ggthemr); library(foreign); library(ggplot2); library(stringr);
library(sjPlot); library(stargazer); library(jtools)
ggthemr("lilac", type = "outer")
df <- read.spss("ESS9CH.sav", use.value.labels = T, to.data.frame = T)
df <- na.omit(df[c("plnftr", "trstlgl", "agea", "rshpsts", "bthcld", "gndr")])
df <- na.omit(df)
Variables & model
My hypothesis: person’s attitude towards planning for future or taking each day as it comes relates on how stable are situation in country with legal system which can be evaluates through person’s trust in the legal system attitude - more trust person have to legal system, more she/he perceive situation in country as stable therefore more planning for future.
Such relation assumed to have different effect strength with people of different age and on people with/without partners and children: (I understand that hypotheses for control variables are not used usially, but why not)
- age: simple case - more years, more planning; complex case - more years (till 50s), more planning & more years (after 50s), less planning
- partner: if there are any partner now, assumed that person plan more
- children: if there are any child(ren), assumed that person plan more
Variables
- Dependent: plnftr: Plan for future or take each day as it comes
- Predictor: trstlgl: Trust in the legal system
- Control: agea: Age of respondent, calculated
- Control: rshpsts: Relationship with husband/wife/partner currently living with
- Control: bthcld: Ever given birth to/ fathered a child
Variables distributions: plnftr
ggplot(df, aes(x = plnftr)) + geom_bar(stat = "count") +
labs(x = "Plan for future or take each day as it comes", y = "Count") +
scale_x_discrete(labels = function(x) str_wrap(x, width = 15))
So dependent variable distributed not really equally but nevertheless - I will analyse it.
Variables distributions: trstlgl
ggplot(df, aes(x = trstlgl)) + geom_bar(stat = "count") +
labs(x = "Trust in the legal system", y = "Count")
There are strong skew to the right on the trust in the legal system for Switzerland - that’s good for them (but not good for the model)!
Variables distributions: agea
ggplot(df, aes(x = as.numeric(agea))) +
geom_density(fill = "salmon", stat = 'density') +
stat_function(fun = dnorm, args = list(mean = mean(as.numeric(df$agea)), sd = sd(as.numeric(df$agea)))) +
labs(x = "Age", y = "Density")
Age distributed normally as always in ESS (good job).
Variables distributions: rshpsts
ggplot(df, aes(x = rshpsts)) + geom_bar(stat = "count") +
scale_x_discrete(labels = function(x) str_wrap(x, width = 15)) +
labs(x = "Relationship with husband/wife/partner currently living with", y = "Count")
And here will be a lot of problems with such distribution. So let’s take gender as other control variable instead this one.
Variables distributions: gndr
ggplot(df, aes(x = gndr)) + geom_bar(stat = "count") +
labs(x = "Gender", y = "Count")
Very nice (almost uniform) distribution.
Variables distributions: bthcld
ggplot(df, aes(x = bthcld)) + geom_bar(stat = "count") +
labs(x = "Ever given birth to/ fathered a child", y = "Count")
Not really nice distribution but okay.
Models
Remember! I don’t revert the scale of planning for future - zero is more planning attitude!
Comparison
model1 <- lm(data = df, as.numeric(plnftr) ~ as.numeric(agea) + gndr + bthcld)
model2 <- lm(data = df, as.numeric(plnftr) ~ as.numeric(trstlgl))
# Main model
model <- lm(data = df, as.numeric(plnftr) ~ as.numeric(trstlgl) + as.numeric(agea) + gndr + bthcld)
tab_model(model, model1, model2, title = "Models comparison", dv.labels = c("predictor & control", "Only control", "Only predictor"))
predictor & control | Only control | Only predictor | |||||||
---|---|---|---|---|---|---|---|---|---|
Predictors | Estimates | CI | p | Estimates | CI | p | Estimates | CI | p |
(Intercept) | 4.59 | 3.69 – 5.50 | <0.001 | 3.49 | 2.96 – 4.03 | <0.001 | 7.41 | 6.69 – 8.13 | <0.001 |
trstlgl | -0.13 | -0.21 – -0.04 | 0.003 | -0.18 | -0.27 – -0.09 | <0.001 | |||
agea | 0.06 | 0.04 – 0.07 | <0.001 | 0.06 | 0.05 – 0.07 | <0.001 | |||
gndr [Female] | 0.75 | 0.41 – 1.08 | <0.001 | 0.77 | 0.43 – 1.11 | <0.001 | |||
bthcld [No] | -0.07 | -0.48 – 0.35 | 0.757 | -0.03 | -0.45 – 0.38 | 0.873 | |||
Observations | 918 | 918 | 918 | ||||||
R2 / R2 adjusted | 0.123 / 0.119 | 0.115 / 0.112 | 0.017 / 0.016 |
As can be seen main difference here is between model with only control variables and model with control variables and key predictor - latter is slightly better than model with only control variables so it can be assumed that usage of key predictor, trust in legal system, is justified.
stargazer(anova(model, model1), type = "html", title="ANoVA", intercept.bottom = FALSE,
single.row = TRUE, align=TRUE, ci=TRUE, ci.level=0.95, no.space=TRUE)
Statistic | N | Mean | St. Dev. | Min | Pctl(25) | Pctl(75) | Max |
Res.Df | 2 | 913.500 | 0.707 | 913 | 913.2 | 913.8 | 914 |
RSS | 2 | 6,139.137 | 41.447 | 6,109.830 | 6,124.483 | 6,153.791 | 6,168.445 |
Df | 1 | -1.000 | -1.000 | -1.000 | -1.000 | -1.000 | |
Sum of Sq | 1 | -58.615 | -58.615 | -58.615 | -58.615 | -58.615 | |
F | 1 | 8.759 | 8.759 | 8.759 | 8.759 | 8.759 | |
Pr(> F) | 1 | 0.003 | 0.003 | 0.003 | 0.003 | 0.003 | |
Main model
tab_model(model, title = "Main model", dv.labels = c("predictor & control"))
predictor & control | |||
---|---|---|---|
Predictors | Estimates | CI | p |
(Intercept) | 4.59 | 3.69 – 5.50 | <0.001 |
trstlgl | -0.13 | -0.21 – -0.04 | 0.003 |
agea | 0.06 | 0.04 – 0.07 | <0.001 |
gndr [Female] | 0.75 | 0.41 – 1.08 | <0.001 |
bthcld [No] | -0.07 | -0.48 – 0.35 | 0.757 |
Observations | 918 | ||
R2 / R2 adjusted | 0.123 / 0.119 |
Interpretation:
- trust in the legal system significantly leads to more planning attitude (more trust, more planning)!
- age too have significant effect, but against my hypothesis ()
- gender: have significant effect - females less plan for future than males.
- child(ren): not significant.
Assumptions
plot_model(model, type = "diag")[[1]]
## Registered S3 methods overwritten by 'car':
## method from
## influence.merMod lme4
## cooks.distance.influence.merMod lme4
## dfbeta.influence.merMod lme4
## dfbetas.influence.merMod lme4
We don’t have any multicollinearity!
plot_model(model, type = "diag")[[2]]
And even residuals distributed normally and there are no major outliers!
plot_model(model, type = "diag")[[3]]
Here again - residuals at the best shape and very nicely fits under the normal distribution line.
plot_model(model, type = "diag")[[4]]
Again - homoscedasticity just not for my models :(
Viz
plot_summs(model, plot.distributions = TRUE, inner_ci_level = .9)
Plot shows all that already was described in Interpretation.
Effects
plot_model(model, type = "pred")[[1]]
Trust in the legal system has significant negative effect and with greater trust people plan more (or with greater trust people less ‘take each day as it comes’)
plot_model(model, type = "pred")[[2]]
Age have significant effect and with more years being on Earth people tend to plan less and more ‘take each day as it comes’ - some wisdom is hidden here
plot_model(model, type = "pred")[[3]]
And gender - females more ‘take each day as it comes’ than males! (that’s interesting)
Summary
I came to the conclusion that it is really interesting topic to research - what influences on peoples attitudes to ‘planning for future’ or to ‘take each day as it comes’. I suppose that it is highly connected with perceived stability in the society besides self-efficacy and some minor factors.