knitr::opts_chunk$set(echo = TRUE, fig.width=8, fig.height=4)
knitr::opts_knit$set(root.dir = "C:/Users/Peter/Documents/GU/data/som/")
library(dplyr)
## Warning: Installed Rcpp (0.12.12) different from Rcpp used to build dplyr (0.12.11).
## Please reinstall dplyr to avoid random crashes or undefined behavior.
##
## 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(rio)
library(ggplot2)
library(RColorBrewer)
library(tidyverse)
## Loading tidyverse: tibble
## Loading tidyverse: tidyr
## Loading tidyverse: readr
## Loading tidyverse: purrr
## Conflicts with tidy packages ----------------------------------------------
## filter(): dplyr, stats
## lag(): dplyr, stats
theme_set(theme_minimal())
set.seed(1234)
# Läs in Super-SOM.
if(file.exists("supersom.RData"))
{
print("Load RData")
load("supersom.rdata")
} else {
print("Import")
system.time(supersom <- import("supersom/SND0905_SuperRSOM_v5.sav"))
print("Saving RData")
save.image(file="supersom.rdata")
}
## [1] "Load RData"
# Recode rank variable into binary categorical factor.
dummy <- function(x, one=c(1, 2, 3, 4), zero=c(6, 7), labels=c("5 days/week or more", "More seldom"))
{
newx <- NA
newx[x %in% one] <- 1
newx[x %in% zero] <- 0
newx <- factor(newx, levels=c(1, 0), labels=labels)
return(newx)
}
# Recode rank variable into trichotomous categorical factor.
trichotomy <- function(x, two, one, zero, labels=c("Daily", "Weekly", "Never/seldom"))
{
newx <- NA
newx[x %in% two] <- 2
newx[x %in% one] <- 1
newx[x %in% zero] <- 0
newx <- factor(newx, levels=c(2, 1, 0), labels=labels)
return(newx)
}
In general:
# Set election years to a binary variable.
supersom <- supersom %>% mutate(electionyear = case_when(year %in% c(1988, 1991, 1994, 1998, 2002, 2006, 2010, 2014) ~ 1, TRUE ~ 0))
# Demography.
supersom$age4a <- rio::factorize(supersom$age4a)
supersom$edu3 <- rio::factorize(supersom$edu3)
supersom$ideology <- supersom$ba10 # Self-reported political left/right placement 1-5.
supersom$ideology[supersom$ideology >= 98] <- NA
supersom$polinterest <- supersom$ca10 %>% recode("1"="4", "2"="3", "3"="2", "4"="1") %>% as.numeric()
supersom$polinterest <- factor(supersom$polinterest, levels=c(1, 2, 3, 4), labels=c("No political interest", "Low", "Medium", "High political interest"))
supersom$polinterest.num <- as.numeric(supersom$polinterest) # Numeric 1-4 political interest.
# Public service.
supersom$svt1 <- supersom$jd20a # SVT1
supersom$svt2 <- supersom$jd20b # SVT2 (1992-2014)
supersom$svt1svt2 <- supersom$jd20c # SVT1/SVT2 (2006-2013)
supersom$rapport <- supersom$jh10d # SVT1 Rapport
supersom$aktuellt <- supersom$jh10c # SVT2 Aktuellt
supersom$aktuelltrapport <- supersom$jh10e # Aktuellt/Rapport
supersom$ekot <- supersom$jh10b # SR Ekot
# Trust SVT.
supersom$trust.svt <- supersom$ka502a %>% recode("1"="3", "2"="3", "3"="2", "4"="1", "5"="1")
## Warning: Unreplaced values treated as NA as .x is not compatible. Please
## specify replacements exhaustively or supply .default
supersom$trust.svt <- factor(supersom$trust.svt, levels=c(3, 2, 1), labels=c("High trust", "Neither low nor high", "Low trust"))
supersom$trust.sr <- supersom$ka502e %>% recode("1"="3", "2"="3", "3"="2", "4"="1", "5"="1")
## Warning: Unreplaced values treated as NA as .x is not compatible. Please
## specify replacements exhaustively or supply .default
supersom$trust.sr <- factor(supersom$trust.sr, levels=c(3, 2, 1), labels=c("High trust", "Neither low nor high", "Low trust"))
# Trust SVT binary.
supersom$trust.svt.dich <- supersom$ka502a %>% recode("1"="1", "2"="1", "3"="999", "4"="0", "5"="0")
## Warning: Unreplaced values treated as NA as .x is not compatible. Please
## specify replacements exhaustively or supply .default
supersom$trust.svt.dich <- factor(supersom$trust.svt.dich, levels=c(1, 0), labels=c("High trust", "Low trust"))
supersom$trust.sr.dich <- supersom$ka502e %>% recode("1"="1", "2"="1", "3"="0", "4"="999", "5"="0")
## Warning: Unreplaced values treated as NA as .x is not compatible. Please
## specify replacements exhaustively or supply .default
supersom$trust.sr.dich <- factor(supersom$trust.sr.dich, levels=c(1, 0), labels=c("High trust", "Low trust"))
# Internet, social networking sites.
supersom$internet <- supersom$jb19 # Internet use last 12 months (1995-)
supersom$internetnews <- supersom$jb110c # Internet news use (2005-)
supersom$sns <- supersom$jb110p # Social media use, e.g. Facebook, Twitter (2009-)
# Recode into binary.
supersom$svt1.dich <- dummy(supersom$svt1, one=c(2, 3), zero=c(4, 5, 6, 7))
supersom$svt2.dich <- dummy(supersom$svt2, one=c(2, 3), zero=c(4, 5, 6, 7))
supersom$rapport.dich <- dummy(supersom$rapport, one=c(1, 2), zero=c(3, 4, 5, 6))
supersom$aktuellt.dich <- dummy(supersom$aktuellt, one=c(1, 2), zero=c(3, 4, 5, 6))
supersom$ekot.dich <- dummy(supersom$ekot, one=c(1, 2), zero=c(3, 4, 5, 6))
supersom$sns.dich <- dummy(supersom$sns, one=c(7, 6), zero=c(5, 4, 3, 2, 1))
supersom$internet.dich <- dummy(supersom$internet, one=c(5), zero=c(4,3,2,1), labels=c("Use internet daily", "Use internet more seldom"))
supersom$internetnews.dich <- dummy(supersom$internetnews, one=c(7,6), zero=c(5,4,3,2,1))
# Recode into trichotomoy
supersom$svt1.tri <- trichotomy(supersom$svt1, two=c(2), one=c(3, 4, 5), zero=c(6, 7))
supersom$svt2.tri <- trichotomy(supersom$svt2, two=c(2), one=c(3, 4, 5), zero=c(6, 7))
supersom$rapport.tri <- trichotomy(supersom$rapport, two=c(1), one=c(2, 3, 4), zero=c(5, 6))
supersom$aktuellt.tri <- trichotomy(supersom$aktuellt, two=c(1), one=c(2, 3, 4), zero=c(5, 6))
supersom$ekot.tri <- trichotomy(supersom$ekot, two=c(1), one=c(2, 3, 4), zero=c(5, 6))
supersom$sns.tri <- trichotomy(supersom$sns, two=c(7), one=c(6, 5), zero=c(4, 3, 2, 1))
# Combine Aktuellt/Rapport into single variable.
supersom$aktuelltrapport.dich[supersom$year %in% c(1984:2004)] <- ifelse(supersom$aktuellt[supersom$year %in% c(1984:2004)] <= 5 | supersom$rapport[supersom$year %in% c(1984:2004)] <= 5, 1, 0)
supersom$aktuelltrapport.dich[supersom$year %in% c(2005:2015)] <- ifelse(supersom$aktuelltrapport[supersom$year %in% c(2005:2015)] <= 5, 1, 0)
# Public service use: Using Rapport/Aktuellt/Ekot at least 5 days/week (or not).
supersom <- supersom %>%
mutate(psuse = case_when(is.na(aktuelltrapport.dich) & is.na(ekot.dich) ~ 999,
aktuelltrapport.dich == 1 ~ 1, # Aktuellt/Rapport
ekot.dich == 1 ~ 1, # Ekot
TRUE ~ 0))
supersom$psuse <- factor(supersom$psuse, levels=c(1, 0), labels=c("PS news at least 5 days/week", "PS news more seldom"))
# Daily public service use: Using Rapport/Aktuellt/Ekot daily (or not).
supersom <- supersom %>%
mutate(psuse.daily = case_when(jh10b == 1 ~ 1, # Ekot
jh10c == 1 ~ 1, # Aktuellt
jh10d == 1 ~ 1, # Rapport
jh10e == 1 ~ 1, # Aktuellt/Rapport
is.na(jh10b) & is.na(jh10c) & is.na(jh10d) & is.na(jh10e) ~ 999,
TRUE ~ 0))
supersom$psuse.daily <- factor(supersom$psuse.daily, levels=c(1, 0), labels=c("PS news daily", "PS news more seldom"))
supersom$aktuelltrapport.dich <- factor(supersom$aktuelltrapport.dich, levels=c(1, 0), labels=c("Daily/weekly", "Never/seldom"))
# Lef/right block.
supersom$partyblock[supersom$cb10 %in% c(1, 2)] <- 1 # Left: S+V
supersom$partyblock[supersom$cb10 %in% c(3, 4, 5, 6)] <- 2 # Right: C+L+M+KD
supersom$partyblock[supersom$partyblock > 2] <- NA
supersom$partyblock <- factor(supersom$partyblock, levels=1:2, labels=c("Left", "Right"), ordered=FALSE)
supersom$partyblock.num <- as.numeric(supersom$partyblock %>% recode("1"="-1", "2"="-1", "3"="1", "4"="1", "5"="1", "6"="1"))
# Party.
#supersom$party <- factor(supersom$cb10, levels=c(1:7, 10:13, 30), labels=c("Vänsterpartiet", "Socialdemokraterna", "Centerpartiet", "Liberalerna", "Moderaterna", "Kristdemokraterna", "Miljöpartiet", "Sverigedemokraterna", "Feministiskt initiativ", "Piratpartiet", "Ny demokrati", "Övriga"), ordered=FALSE)
supersom$party <- factor(supersom$cb10, levels=c(1:7, 10:13, 30), labels=c("Left Party (V)", "Social Democrats (S)", "Centre Party (C)", "Liberals (L)", "Moderate Party (M)", "Christian Democrats (KD)", "Green Party (MP)", "Sweden Democrats (SD)", "Feminist Initiative (FI)", "Pirate Party (PP)", "New Democracy (NyD)", "Other"), ordered=FALSE)
supersom$partysymbol <- factor(supersom$cb10, levels=c(1:7, 10:13, 30), labels=c("V", "S", "C", "L", "M", "KD", "MP", "SD", "FI", "PP", "NyD", "Other"), ordered=FALSE)
PartyColor <- unlist(list(V = "#DA291C",
S = "#E8112d",
C = "#009933",
L = "#006AB3",
M = "#52BDEC",
KD = "#000077",
MP = "#83CF39",
SD = "#DDDD00",
FI = "#CD1B68",
PP = "#572B85",
NyD = "#572B85",
Other = "#CCCCCC"), use.names=FALSE)
# Ideological extremism (center = 0, toward left/right = 2)
supersom$polextreme <- supersom$ideology %>% recode("1"="2", "2"="1", "3"="0", "4"="1", "5"="2") %>% as.numeric()
# Strong supporter of party?
supersom$partystrength <- supersom$cb20 %>% recode("1"="2", "2"="1", "3"="0")
supersom$partystrength <- factor(supersom$partystrength, levels=c(0,1,2), labels=c("No party supporter", "Weak party supporter", "Strong party supporter"), ordered=FALSE)
# Political leaning: left/center/right.
supersom$leaning <- supersom$ideology %>% recode("1"="1", "2"="1", "3"="2", "4"="3", "5"="3")
supersom$leaning <- factor(supersom$leaning, levels=c(1,2,3), labels=c("Left", "Center", "Right"), ordered=FALSE)
supersom$leaning.num <- as.numeric(supersom$ideology %>% recode("1"="-2", "2"="-1", "3"="0", "4"="1", "5"="2"))
# Factor sex.
supersom$sex <- factor(supersom$sex, levels=c(1, 2), labels=c("Female", "Male"), ordered=FALSE)
# Convert year to date yyyy-mm-dd.
supersom$date <- as.Date(paste(supersom$year, "-01-01", sep=""))
Calculate feelings towards other parties by subtracting feelings toward out-parties from feelings toward the in-party.
Since there are multiple out-parties, add them all together and average them.
# Like own party & dislike other parties.
supersom$C <- supersom$cb50a
supersom$M <- supersom$cb50b
supersom$V <- supersom$cb50c
supersom$L <- supersom$cb50d
supersom$S <- supersom$cb50e
supersom$MP <- supersom$cb50f
supersom$KD <- supersom$cb50g
#supersom$Nydemok <- supersom$cb50h
supersom$FI <- supersom$cb50i
supersom$SD <- supersom$cb50m
supersom$likeindex <- colSums(rbind(supersom$C, supersom$M, supersom$V, supersom$L, supersom$S, supersom$MP, supersom$KD, supersom$SD, supersom$FI), na.rm = TRUE)
# Add all affects from 9 parties.
supersom$affect <- colSums(rbind(supersom$C, supersom$M, supersom$V, supersom$L, supersom$S, supersom$MP, supersom$KD, supersom$SD), na.rm = TRUE)
# Subtract in-party from total affect (leaving only out-party affect), and then average the out-party affect.
supersom$affect.outparty <- if_else(supersom$partysymbol == "S", (supersom$affect - supersom$S) / 8, supersom$affect)
supersom$affect.outparty <- if_else(supersom$partysymbol == "M", (supersom$affect - supersom$M) / 8, supersom$affect.outparty)
supersom$affect.outparty <- if_else(supersom$partysymbol == "V", (supersom$affect - supersom$V) / 8, supersom$affect.outparty)
supersom$affect.outparty <- if_else(supersom$partysymbol == "MP", (supersom$affect - supersom$MP) / 8, supersom$affect.outparty)
supersom$affect.outparty <- if_else(supersom$partysymbol == "KD", (supersom$affect - supersom$KD) / 8, supersom$affect.outparty)
supersom$affect.outparty <- if_else(supersom$partysymbol == "C", (supersom$affect - supersom$C) / 8, supersom$affect.outparty)
supersom$affect.outparty <- if_else(supersom$partysymbol == "L", (supersom$affect - supersom$L) / 8, supersom$affect.outparty)
#supersom$affect.outparty <- if_else(supersom$partysymbol == "SD", (supersom$affect - supersom$SD) / 8, supersom$affect.outparty)
# Make new variable for in-party affect.
supersom$affect.inparty <- if_else(supersom$partysymbol == "S", supersom$S, supersom$affect)
supersom$affect.inparty <- if_else(supersom$partysymbol == "M", supersom$M, supersom$affect.inparty)
supersom$affect.inparty <- if_else(supersom$partysymbol == "V", supersom$V, supersom$affect.inparty)
supersom$affect.inparty <- if_else(supersom$partysymbol == "MP", supersom$MP, supersom$affect.inparty)
supersom$affect.inparty <- if_else(supersom$partysymbol == "KD", supersom$KD, supersom$affect.inparty)
supersom$affect.inparty <- if_else(supersom$partysymbol == "C", supersom$C, supersom$affect.inparty)
supersom$affect.inparty <- if_else(supersom$partysymbol == "L", supersom$L, supersom$affect.inparty)
#supersom$affect.inparty <- if_else(supersom$partysymbol == "SD", supersom$SD, supersom$affect.inparty)
# Onl keep parties in parliament.
supersom$affect.inparty[!supersom$partysymbol %in% c("S", "M", "V", "MP", "KD", "C", "L")] <- NA
supersom$affect.outparty[!supersom$partysymbol %in% c("S", "M", "V", "MP", "KD", "C", "L")] <- NA
supersom$jobmarket <- dummy(supersom$db900i, one=c(1, 2), zero=c(4, 5), labels=c("Agree", "Disagree"))
supersom$privatehealthcare <- dummy(supersom$ed900a, one=c(1, 2), zero=c(4, 5), labels=c("Agree", "Disagree"))
supersom$economy.change <- dummy(supersom$da11c, one=c(1:2), zero=c(4:5), labels=c("Better", "Worse"))
supersom$economy.politics <- dummy(supersom$cd110l, one=c(1:2), zero=c(4:5), labels=c("Good", "Bad"))
supersom$marry <- dummy(supersom$fc10e, one=c(1, 2, 3), zero=c(4), labels=c("Agree", "Disagree")) # "I would not like immigrant marriying family member."
supersom$womendiscrimination <- dummy(supersom$bb100b, one=c(6:10), zero=c(0:4), labels=c("Agree", "Disagree")) # "Women are often discriminated against on the job market"
Create a additive public service index, with the use of Rapport/Aktuellt/Ekot which is then averaged.
Continous scale ranging from 1 (never) to 6 (daily).
# First, combine Aktuellt & Rapport (1986-2005). Use the highest frequency from either variable. In other words, if respondent use either Aktuellt or Rapport daily, then the value is daily.
# (Cumbersome coding because bug in case_when, see https://github.com/tidyverse/dplyr/issues/2927)
supersom$aktuelltrapport_early[supersom$aktuellt == 6 | supersom$aktuellt == 6] <- 6
supersom$aktuelltrapport_early[supersom$aktuellt == 5 | supersom$aktuellt == 5] <- 5
supersom$aktuelltrapport_early[supersom$aktuellt == 4 | supersom$aktuellt == 4] <- 4
supersom$aktuelltrapport_early[supersom$aktuellt == 3 | supersom$aktuellt == 3] <- 3
supersom$aktuelltrapport_early[supersom$aktuellt == 2 | supersom$aktuellt == 2] <- 2
supersom$aktuelltrapport_early[supersom$aktuellt == 1 | supersom$aktuellt == 1] <- 1
# Add to variable 1986-2004.
supersom$aktuelltrapport.combined[supersom$year <= 2004] <- supersom$aktuelltrapport_early[supersom$year <= 2004]
# Use the Aktuellt/Rapport measure from 2005 an onwards.
supersom$aktuelltrapport.combined[supersom$year >= 2005] <- supersom$jh10e[supersom$year >= 2005]
# Add values (Aktuellt and Rapport + Ekot) and divide by 2, thus creating a continous interval scale, from 1-6.
supersom$psindex <- (supersom$aktuelltrapport.combined + supersom$ekot) / 2
# Reverse code index, so that 6=daily, 1=never.
supersom$psindex.rev <- min(supersom$psindex, na.rm=TRUE) + max(supersom$psindex, na.rm=TRUE) - supersom$psindex
library(sjlabelled)
set_label(supersom$psindex.rev, "label") <- "Public service index"
# Histogram of index.
ggplot(supersom, aes(psindex.rev)) +
geom_histogram() +
labs(title="Histogram of public service index",
y="Count",
x="Public service index (higher value = more frequent use)")
## `stat_bin()` using `bins = 30`. Pick better value with `binwidth`.
## Warning: Removed 14972 rows containing non-finite values (stat_bin).
library(moments)
mean(supersom$psindex.rev, na.rm=TRUE)
## [1] 3.687983
sd(supersom$psindex.rev, na.rm=TRUE)
## [1] 1.391549
skewness(supersom$psindex.rev, na.rm=TRUE)
## [1] 0.03896865
kurtosis(supersom$psindex.rev, na.rm=TRUE)
## [1] 2.114573
supersom %>%
select(date, svt1.dich) %>%
na.exclude() %>%
group_by(date, svt1.dich) %>%
summarize(n = n()) %>%
mutate(percent = (n / sum(n)) * 100) %>%
ggplot(aes(date, percent, color=factor(svt1.dich))) +
geom_line(size=1.2) +
scale_color_manual(values = c("#000000", "#CCCCCC"), name=NULL) +
scale_y_continuous(labels=scales::comma, limit=c(0, 100)) +
scale_x_date(date_label="%Y", date_breaks="2 year") +
theme(legend.position = "bottom") +
labs(title="Tittar på SVT", x="Year", y="Percent")
supersom %>%
select(date, svt1.dich, leaning) %>%
na.exclude() %>%
group_by(leaning, date, svt1.dich) %>%
summarize(n = n()) %>%
mutate(percent = n / sum(n) * 100) %>%
ggplot(aes(date, percent, color=factor(svt1.dich))) +
geom_line(size=1.2) +
scale_color_manual(values = c("#000000", "#CCCCCC"), name=NULL) +
scale_y_continuous(labels=scales::comma, limit=c(0, 100)) +
scale_x_date(date_label="%Y", date_breaks="2 year") +
theme(legend.position = "bottom", axis.text.x = element_text(angle=90)) +
labs(title="SVT1 + leaning",
x="Year",
y="Percent") +
facet_grid(~ leaning)
supersom %>%
select(date, svt1.dich, polinterest) %>%
na.exclude() %>%
group_by(polinterest, date, svt1.dich) %>%
summarize(n = n()) %>%
mutate(percent = n / sum(n) * 100) %>%
ggplot(aes(date, percent, color=factor(svt1.dich))) +
geom_line(size=1.2) +
#geom_smooth(method="lm") +
scale_color_manual(values = c("#000000", "#CCCCCC"), name=NULL) +
scale_y_continuous(labels=scales::comma, limit=c(0, 100)) +
scale_x_date(date_label="%Y", date_breaks="2 year") +
theme(legend.position = "bottom", axis.text.x = element_text(angle=90)) +
labs(title="SVT1 & political interest",
x="Year",
y="Percent") +
facet_grid(~ polinterest)
Are public service viewers more extreme in their views?
supersom %>%
select(date, svt1.dich, polextreme) %>%
na.exclude() %>%
group_by(svt1.dich, date) %>%
summarize(meanextremism = mean(polextreme, na.rm=TRUE)) %>%
ggplot(aes(date, meanextremism, color=svt1.dich)) +
geom_line(alpha=0.5) +
geom_smooth(method="loess") +
scale_y_continuous(labels=scales::comma) +
scale_x_date(date_label="%Y", date_breaks="2 year") +
theme(legend.position = "none", axis.text.x = element_text(angle=90)) +
labs(title="SVT1 + ideological extremism",
x="Year",
y="Ideological extremism") +
facet_grid(~ svt1.dich)
supersom %>%
select(date, svt2.dich, leaning) %>%
na.exclude() %>%
group_by(leaning, date, svt2.dich) %>%
summarize(n = n()) %>%
mutate(percent = n / sum(n) * 100) %>%
ggplot(aes(date, percent, color=factor(svt2.dich))) +
geom_line(size=1.2) +
scale_color_manual(values = c("#000000", "#CCCCCC"), name=NULL) +
scale_y_continuous(labels=scales::comma, limit=c(0, 100)) +
scale_x_date(date_label="%Y", date_breaks="2 year") +
theme(legend.position = "bottom", axis.text.x = element_text(angle=90)) +
labs(title="SVT2 + leaning",
x="Year",
y="Percent") +
facet_grid(~ leaning)
supersom %>%
select(date, svt2.dich, polinterest) %>%
na.exclude() %>%
group_by(polinterest, date, svt2.dich) %>%
summarize(n = n()) %>%
mutate(percent = n / sum(n) * 100) %>%
ggplot(aes(date, percent, color=factor(svt2.dich))) +
geom_line(size=1.2) +
#geom_smooth(method="lm") +
scale_color_manual(values = c("#000000", "#CCCCCC"), name=NULL) +
scale_y_continuous(labels=scales::comma, limit=c(0, 100)) +
scale_x_date(date_label="%Y", date_breaks="2 year") +
theme(legend.position = "bottom", axis.text.x = element_text(angle=90)) +
labs(title="SVT2 + political interest",
x="Year",
y="Percent") +
facet_grid(~ polinterest)
Swedish Television news programmes Rapport and Aktuellt in SVT1 and SVT2, respectively.
supersom %>%
select(date, rapport.dich, leaning) %>%
na.exclude() %>%
group_by(leaning, date, rapport.dich) %>%
summarize(n = n()) %>%
mutate(percent = n / sum(n) * 100) %>%
ggplot(aes(date, percent, color=factor(rapport.dich))) +
geom_line(size=1.2) +
scale_color_manual(values = c("#000000", "#CCCCCC"), name=NULL) +
scale_y_continuous(labels=scales::comma, limit=c(0, 100)) +
scale_x_date(date_label="%Y", date_breaks="2 year") +
theme(legend.position = "bottom", axis.text.x = element_text(angle=90)) +
labs(title="Use SVT Rapport",
x="Year",
y="Percent") +
facet_grid(~ leaning)
supersom %>%
select(date, rapport.dich, polinterest) %>%
na.exclude() %>%
group_by(polinterest, date, rapport.dich) %>%
summarize(n = n()) %>%
mutate(percent = n / sum(n) * 100) %>%
ggplot(aes(date, percent, color=factor(rapport.dich))) +
geom_line(size=1.2) +
#geom_smooth(method="lm") +
scale_color_manual(values = c("#000000", "#CCCCCC"), name=NULL) +
scale_y_continuous(labels=scales::comma, limit=c(0, 100)) +
scale_x_date(date_label="%Y", date_breaks="2 year") +
theme(legend.position = "bottom", axis.text.x = element_text(angle=90)) +
labs(title="Use SVT Rapport",
x="Year",
y="Percent") +
facet_grid(~ polinterest)
supersom %>%
select(date, aktuellt.dich, leaning) %>%
na.exclude() %>%
group_by(leaning, date, aktuellt.dich) %>%
summarize(n = n()) %>%
mutate(percent = n / sum(n) * 100) %>%
ggplot(aes(date, percent, color=factor(aktuellt.dich))) +
geom_line(size=1.2) +
scale_color_manual(values = c("#000000", "#CCCCCC"), name=NULL) +
scale_y_continuous(labels=scales::comma, limit=c(0, 100)) +
scale_x_date(date_label="%Y", date_breaks="2 year") +
theme(legend.position = "bottom", axis.text.x = element_text(angle=90)) +
labs(title="Use Aktuellt",
x="Year",
y="Percent") +
facet_grid(~ leaning)
supersom %>%
select(date, aktuellt.dich, polinterest) %>%
na.exclude() %>%
group_by(polinterest, date, aktuellt.dich) %>%
summarize(n = n()) %>%
mutate(percent = n / sum(n) * 100) %>%
ggplot(aes(date, percent, color=factor(aktuellt.dich))) +
geom_line(size=1.2) +
#geom_smooth(method="lm") +
scale_color_manual(values = c("#000000", "#CCCCCC"), name=NULL) +
scale_y_continuous(labels=scales::comma, limit=c(0, 100)) +
scale_x_date(date_label="%Y", date_breaks="2 year") +
theme(legend.position = "bottom", axis.text.x = element_text(angle=90)) +
labs(title="Use Aktuellt",
x="Year",
y="Percent") +
facet_grid(~ polinterest)
supersom %>%
select(date, aktuelltrapport.dich, leaning) %>%
na.exclude() %>%
group_by(leaning, date, aktuelltrapport.dich) %>%
summarize(n = n()) %>%
mutate(percent = n / sum(n) * 100) %>%
ggplot(aes(date, percent, color=factor(aktuelltrapport.dich))) +
geom_line(size=1.2) +
scale_color_manual(values = c("#000000", "#CCCCCC"), name=NULL) +
scale_y_continuous(labels=scales::comma, limit=c(0, 100)) +
scale_x_date(date_label="%Y", date_breaks="2 year") +
theme(legend.position = "bottom", axis.text.x = element_text(angle=90)) +
labs(title="Aktuellt/Rapport",
x="Year",
y="Percent") +
facet_grid(~ leaning)
Combine the two survey questions from 1986-2004 (Aktuellt and Rapport, respectively) with the single survey question from 2005-2014 (Aktuellt/Rapport, combined).
supersom %>%
select(date, aktuelltrapport.dich, leaning) %>%
na.exclude() %>%
group_by(leaning, date, aktuelltrapport.dich) %>%
summarize(n = n()) %>%
mutate(percent = n / sum(n) * 100) %>%
ggplot(aes(date, percent, color=factor(aktuelltrapport.dich))) +
geom_line(size=1.2) +
scale_color_manual(values = c("#000000", "#CCCCCC"), name=NULL) +
scale_y_continuous(labels=scales::comma, limit=c(0, 100)) +
scale_x_date(date_label="%Y", date_breaks="2 year") +
theme(legend.position = "bottom", axis.text.x = element_text(angle=90)) +
labs(title="Aktuell/Rapport",
x="Year",
y="Percent") +
#geom_vline(xintercept = as.numeric(as.Date("2005-01-01")), color="black", alpha=0.9, linetype=2) + # Vertical line that indicate change in survey question
facet_grid(~ leaning)
supersom %>%
select(date, aktuelltrapport.dich, polinterest) %>%
na.exclude() %>%
group_by(polinterest, date, aktuelltrapport.dich) %>%
summarize(n = n()) %>%
mutate(percent = n / sum(n) * 100) %>%
ggplot(aes(date, percent, color=factor(aktuelltrapport.dich))) +
geom_line(size=1.2) +
scale_color_manual(values = c("#000000", "#CCCCCC"), name=NULL) +
scale_y_continuous(labels=scales::comma, limit=c(0, 100)) +
scale_x_date(date_label="%Y", date_breaks="4 year") +
theme(legend.position = "bottom", axis.text.x = element_text(angle=90)) +
labs(title="Aktuellt/Rapport",
x="Year",
y="Percent") +
geom_vline(xintercept = as.numeric(as.Date("2005-01-01")), color="black", alpha=0.9, linetype=2) +
facet_grid(~ polinterest)
corr1 <- cor.test(supersom$polextreme, supersom$polinterest.num)
corr2 <- cor.test(as.numeric(supersom$partystrength), supersom$polinterest.num)
Correlation between political extremity (left or right) and political interest: r(97193) = 0.2548581, p=0.
Correlation between party strength and political interest: r(92937) = 0.2322776, p=0.
supersom %>%
select(date, ekot.dich, leaning) %>%
na.exclude() %>%
group_by(leaning, date, ekot.dich) %>%
summarize(n = n()) %>%
mutate(percent = n / sum(n) * 100) %>%
ggplot(aes(date, percent, color=factor(ekot.dich))) +
geom_line(size=1.2) +
scale_color_manual(values = c("#000000", "#CCCCCC"), name=NULL) +
scale_y_continuous(labels=scales::comma, limit=c(0, 100)) +
scale_x_date(date_label="%Y", date_breaks="4 year") +
theme(legend.position = "bottom", axis.text.x = element_text(angle=90)) +
labs(title="Ekot", x="Year", y="Percent") +
facet_grid(~ leaning)
supersom %>%
select(date, ekot.dich, polinterest) %>%
na.exclude() %>%
group_by(polinterest, date, ekot.dich) %>%
summarize(n = n()) %>%
mutate(percent = n / sum(n) * 100) %>%
ggplot(aes(date, percent, color=factor(ekot.dich))) +
geom_line(size=1.2) +
#geom_smooth(method="lm") +
scale_color_manual(values = sort(brewer.pal(3, "Paired")), name=NULL) +
scale_y_continuous(labels=scales::comma, limit=c(0, 100)) +
scale_x_date(date_label="%Y", date_breaks="4 year") +
theme(legend.position = "bottom", axis.text.x = element_text(angle=90, vjust = 0.5)) +
labs(title="Ekot", x="Year", y="Percent") +
facet_grid(~ polinterest)
Use any of Aktuellt, Rapport or Ekot.
Frequency table of public service news use.
supersom %>%
select(year, psuse) %>%
group_by(year, psuse) %>%
na.exclude() %>%
count() %>%
spread(psuse, n)
## # A tibble: 30 x 3
## # Groups: year [30]
## year `PS news at least 5 days/week` `PS news more seldom`
## * <dbl> <int> <int>
## 1 1986 1594 21
## 2 1987 1636 13
## 3 1988 1613 16
## 4 1989 1545 16
## 5 1990 1547 16
## 6 1991 1539 20
## 7 1992 1835 22
## 8 1993 1777 39
## 9 1994 1628 36
## 10 1995 1699 42
## # ... with 20 more rows
supersom %>%
select(date, psuse, leaning) %>%
na.exclude() %>%
group_by(leaning, date, psuse) %>%
summarize(n = n()) %>%
mutate(percent = n / sum(n) * 100) %>%
ggplot(aes(date, percent, color=factor(psuse))) +
geom_line(size=1.2) +
#geom_smooth(method="lm") +
#geom_text(aes(label=round(percent), alpha=0.7), nudge_y=-6, size=2) +
scale_color_manual(values = sort(brewer.pal(3, "Paired")), name=NULL) +
scale_y_continuous(labels=scales::comma, limit=c(0, 100), breaks=seq(0, 100, 20)) +
scale_x_date(date_label="%Y", date_breaks="5 year") +
theme(legend.position = "bottom", axis.text.x = element_text(angle=90)) +
labs(title="Use of public service news programs",
subtitle=NULL,
x="Year",
y="Percent") +
facet_wrap(~ leaning)
print(paste("n =", supersom %>%
select(date, psuse, leaning) %>%
na.exclude() %>% count()))
## [1] "n = 95462"
For the latest year, is the difference statistically significant between the left and right?
left <- supersom %>% filter(year == max(year) & leaning == "Left") %>% select(psuse) %>% na.exclude()
center <- supersom %>% filter(year == max(year) & leaning == "Center") %>% select(psuse) %>% na.exclude()
right <- supersom %>% filter(year == max(year) & leaning == "Right") %>% select(psuse) %>% na.exclude()
t.test(x=as.numeric(center$psuse), y=as.numeric(left$psuse), alternative=c("two.sided"), conf.level=0.95)
##
## Welch Two Sample t-test
##
## data: as.numeric(center$psuse) and as.numeric(left$psuse)
## t = 4.0702, df = 4216.9, p-value = 4.784e-05
## alternative hypothesis: true difference in means is not equal to 0
## 95 percent confidence interval:
## 0.01665289 0.04760469
## sample estimates:
## mean of x mean of y
## 1.092959 1.060830
t.test(x=as.numeric(center$psuse), y=as.numeric(right$psuse), alternative=c("two.sided"), conf.level=0.95)
##
## Welch Two Sample t-test
##
## data: as.numeric(center$psuse) and as.numeric(right$psuse)
## t = 5.1399, df = 3946.9, p-value = 2.882e-07
## alternative hypothesis: true difference in means is not equal to 0
## 95 percent confidence interval:
## 0.02374627 0.05303310
## sample estimates:
## mean of x mean of y
## 1.092959 1.054569
t.test(x=as.numeric(left$psuse), y=as.numeric(right$psuse), alternative=c("two.sided"), conf.level=0.95)
##
## Welch Two Sample t-test
##
## data: as.numeric(left$psuse) and as.numeric(right$psuse)
## t = 0.98434, df = 5090.1, p-value = 0.325
## alternative hypothesis: true difference in means is not equal to 0
## 95 percent confidence interval:
## -0.006208472 0.018730249
## sample estimates:
## mean of x mean of y
## 1.060830 1.054569
supersom %>%
select(date, psuse, polinterest) %>%
na.exclude() %>%
group_by(polinterest, date, psuse) %>%
summarize(n = n()) %>%
mutate(percent = n / sum(n) * 100) %>%
ggplot(aes(date, percent, color=factor(psuse))) +
geom_line(size=1.2) +
scale_color_manual(values = sort(brewer.pal(3, "Paired")), name=NULL) +
scale_y_continuous(labels=scales::comma, limit=c(0, 100), breaks=seq(0, 100, 20)) +
scale_x_date(date_label="%Y", date_breaks="5 year") +
theme(legend.position = "bottom", axis.text.x = element_text(angle=90)) +
labs(title="Use of public service news programs",
subtitle=NULL,
x="Year",
y="Percent") +
facet_grid(~ polinterest)
Frequency table of public service news use 1986 and 2015.
print(paste("n =", supersom %>%
select(date, psuse, polinterest) %>%
na.exclude() %>% count()))
## [1] "n = 97257"
supersom %>%
select(year, psuse, polinterest) %>%
na.exclude() %>%
group_by(polinterest, year, psuse) %>%
summarize(n = n()) %>%
mutate(percent = n / sum(n) * 100) %>%
filter(year %in% c(1986, 2015)) %>%
spread(psuse, n)
## # A tibble: 16 x 5
## # Groups: polinterest, year [8]
## polinterest year percent `PS news at least 5 days/week`
## * <fctr> <dbl> <dbl> <int>
## 1 No political interest 1986 2.6845638 NA
## 2 No political interest 1986 97.3154362 145
## 3 No political interest 2015 30.2663438 NA
## 4 No political interest 2015 69.7336562 288
## 5 Low 1986 0.8498584 NA
## 6 Low 1986 99.1501416 700
## 7 Low 2015 7.9604131 NA
## 8 Low 2015 92.0395869 2139
## 9 Medium 1986 0.6633499 NA
## 10 Medium 1986 99.3366501 599
## 11 Medium 2015 4.2438893 NA
## 12 Medium 2015 95.7561107 3565
## 13 High political interest 1986 3.4965035 NA
## 14 High political interest 1986 96.5034965 138
## 15 High political interest 2015 5.0886662 NA
## 16 High political interest 2015 94.9113338 1231
## # ... with 1 more variables: `PS news more seldom` <int>
supersom %>%
select(date, psuse, polextreme) %>%
na.exclude() %>%
group_by(psuse, date) %>%
summarize(meanextremism = mean(polextreme, na.rm=TRUE)) %>%
ggplot(aes(date, meanextremism, color=psuse)) +
geom_line(alpha=0.5) +
geom_smooth(method="loess") +
scale_y_continuous(labels=scales::comma) +
scale_x_date(date_label="%Y", date_breaks="2 year") +
theme(legend.position = "none", axis.text.x = element_text(angle=90)) +
labs(title="Public service use and ideological extremity",
x="Year",
y="Ideological extremism") +
facet_grid(~ psuse)
print(paste("n =", supersom %>%
select(date, psuse, polextreme) %>%
na.exclude() %>% count()))
## [1] "n = 95462"
supersom %>%
select(date, psuse, party) %>%
na.exclude() %>%
group_by(party, date, psuse) %>%
summarize(n = n()) %>%
mutate(percent = n / sum(n) * 100) %>%
#filter(!party %in% c("Feministiskt initiativ", "Piratpartiet", "Ny demokrati", "Övriga")) %>%
ggplot(aes(date, percent, color=factor(psuse))) +
geom_line(size=1.2) +
#geom_smooth(method="lm") +
scale_color_manual(values = sort(brewer.pal(3, "Paired")), name=NULL) +
scale_y_continuous(labels=scales::comma, limit=c(0, 100), breaks=seq(0, 100, 20)) +
scale_x_date(date_label="%Y", date_breaks="5 year") +
theme(legend.position = "bottom", axis.text.x = element_text(angle=90)) +
labs(title="Use of public service news programs",
subtitle=NULL,
x="Year",
y="Percent") +
facet_wrap(~ party, ncol = 4)
print(paste("n =", supersom %>%
select(date, psuse, party) %>%
na.exclude() %>%
#filter(!party %in% c("Feministiskt initiativ", "Piratpartiet", "Ny demokrati", "Övriga")) %>%
count()))
## [1] "n = 89929"
# jh10e = Use of Aktuellt/Rapport.
# ka502a = Trust in Swedish Television (SVT).
df <- supersom %>% select(ka502a, jh10e) %>% na.exclude()
corr.df <- cor.test(df$ka502a, df$jh10e)$parameter[[1]]
corr.p <- cor.test(df$ka502a, df$jh10e)$p.value
corr.r <- cor(df$ka502a, df$jh10e)
Correlation between trust in SVT and use of Aktuellt/Rapport: r(9177) = 0.2324653, p=7.003867810^{-113}.
# jh10b = Use of Ekonyheterna
# ka502e = Trust in Swedish Radio (SR).
df <- supersom %>% select(ka502e, jh10b) %>% na.exclude()
corr.df <- cor.test(df$ka502e, df$jh10b)$parameter[[1]]
corr.p <- cor.test(df$ka502e, df$jh10b)$p.value
corr.r <- cor(df$ka502e, df$jh10b)
Correlation between trust in SR and use of Ekonyheterna: r(6934) = 0.3077295, p=4.972765810^{-152}.
supersom %>%
select(date, psuse, partystrength) %>%
na.exclude() %>%
group_by(partystrength, date, psuse) %>%
summarize(n = n()) %>%
mutate(percent = n / sum(n) * 100) %>%
ggplot(aes(date, percent, color=factor(psuse))) +
geom_line(size=1.2) +
#geom_smooth(method="lm") +
scale_color_manual(values = sort(brewer.pal(3, "Paired")), name=NULL) +
scale_y_continuous(labels=scales::comma, limit=c(0, 100), breaks=seq(0, 100, 20)) +
scale_x_date(date_label="%Y", date_breaks="4 year") +
theme(legend.position = "bottom", axis.text.x = element_text(angle=90)) +
labs(title="Use of public service news programs",
subtitle="Use any of Aktuellt, Rapport or Ekot.",
x="Year",
y="Percent") +
facet_wrap(~ partystrength)
print(paste("n =", supersom %>%
select(date, psuse, partystrength) %>%
na.exclude() %>% count()))
## [1] "n = 91375"
df <- supersom %>%
select(partystrength, psuse) %>%
na.exclude() %>%
mutate(partystrength = as.numeric(partystrength), psuse=as.numeric(psuse))
corr.df <- cor.test(df$partystrength, df$psuse)$parameter[[1]]
corr.p <- cor.test(df$partystrength, df$psuse)$p.value
corr.r <- cor(df$partystrength, df$psuse)
Correlation between public service news use and party identification/support: r(91373) = -0.0367499, p=1.091096210^{-28}.
supersom %>%
select(date, internetnews.dich, leaning) %>%
na.exclude() %>%
group_by(leaning, date, internetnews.dich) %>%
summarize(n = n()) %>%
mutate(percent = n / sum(n) * 100) %>%
ggplot(aes(date, percent, color=factor(internetnews.dich))) +
geom_line(size=1.2) +
scale_color_manual(values = c("#005800", "#9cfb9c"), name=NULL) +
scale_y_continuous(labels=scales::comma, limit=c(0, 100)) +
scale_x_date(date_label="%Y", date_breaks="2 year") +
theme(legend.position = "bottom", axis.text.x = element_text(angle=90)) +
labs(title="Use internet news + leaning",
x="Year",
y="Percent") +
facet_grid(~ leaning)
supersom %>%
select(date, internetnews.dich, party) %>%
na.exclude() %>%
group_by(party, date, internetnews.dich) %>%
summarize(n = n()) %>%
mutate(percent = n / sum(n) * 100) %>%
ggplot(aes(date, percent, color=factor(internetnews.dich))) +
geom_line(size=1.2) +
scale_color_manual(values = c("#005800", "#9cfb9c"), name=NULL) +
scale_y_continuous(labels=scales::comma, limit=c(0, 100)) +
scale_x_date(date_label="%Y", date_breaks="1 year") +
theme(legend.position = "bottom", axis.text.x = element_text(angle=90)) +
labs(title="Use internet news + party",
x="Year",
y="Percent") +
facet_wrap(~ party)
supersom %>%
select(date, internetnews.dich, polinterest) %>%
na.exclude() %>%
group_by(polinterest, date, internetnews.dich) %>%
summarize(n = n()) %>%
mutate(percent = n / sum(n) * 100) %>%
ggplot(aes(date, percent, color=factor(internetnews.dich))) +
geom_line(size=1.2) +
scale_color_manual(values = c("#005800", "#9cfb9c"), name=NULL) +
scale_y_continuous(labels=scales::comma, limit=c(0, 100)) +
scale_x_date(date_label="%Y", date_breaks="2 year") +
theme(legend.position = "bottom", axis.text.x = element_text(angle=90)) +
labs(title="Use internet news + political interest",
x="Year",
y="Percent") +
facet_grid(~ polinterest)
supersom %>%
select(date, internetnews.dich, psuse) %>%
na.exclude() %>%
group_by(psuse, date, internetnews.dich) %>%
summarize(n = n()) %>%
mutate(percent = n / sum(n) * 100) %>%
ggplot(aes(date, percent, color=factor(internetnews.dich))) +
geom_line(size=1.2) +
scale_color_manual(values = c("#005800", "#9cfb9c"), name="Use of internet news") +
scale_y_continuous(labels=scales::comma, limit=c(0, 100), breaks=seq(0, 100, 20)) +
scale_x_date(date_label="%Y", date_breaks="2 year") +
theme(legend.position = "bottom", axis.text.x = element_text(angle=0)) +
labs(title="Use of internet news among public service (PS) news users",
x="Year",
y="Percent") +
facet_grid(~ psuse)
supersom %>%
select(date, trust.svt) %>%
na.exclude() %>%
group_by(date, trust.svt) %>%
summarize(n = n()) %>%
mutate(percent = (n / sum(n)) * 100) %>%
ggplot(aes(date, percent, color=factor(trust.svt))) +
geom_line(size=1, alpha=1) +
geom_point(size=2) +
geom_text(aes(label=round(percent), alpha=0.7), nudge_y=6) +
scale_y_continuous(labels=scales::comma, limit=c(0, 100), breaks=seq(0, 100, 10)) +
scale_x_date(date_label="%Y", date_breaks="1 year") +
theme(legend.position = "right", axis.text.x = element_text(angle=0)) +
labs(title="Trust SVT", x="Year", y="Percent")
supersom %>%
select(date, trust.svt, leaning) %>%
na.exclude() %>%
group_by(leaning, date, trust.svt) %>%
summarize(n = n()) %>%
mutate(percent = (n / sum(n)) * 100) %>%
ggplot(aes(date, percent, color=factor(trust.svt))) +
geom_line(size=1, alpha=1) +
geom_point(size=2) +
geom_text(aes(label=round(percent), alpha=0.7), nudge_y=6) +
#geom_smooth(method="lm", alpha=0.5) +
scale_y_continuous(labels=scales::comma, limit=c(0, 100), breaks=seq(0, 100, 20)) +
scale_x_date(date_label="%Y", date_breaks="1 year") +
theme(legend.position = "bottom", axis.text.x = element_text(angle = 0)) +
labs(title="Trust SVT", x="Year", y="Percent") +
facet_wrap(~leaning)
supersom %>%
select(date, trust.svt, polinterest) %>%
na.exclude() %>%
group_by(polinterest, date, trust.svt) %>%
summarize(n = n()) %>%
mutate(percent = (n / sum(n)) * 100) %>%
ggplot(aes(date, percent, color=factor(trust.svt))) +
geom_line(size=1, alpha=1) +
geom_point(size=2) +
geom_text(aes(label=round(percent), alpha=0.7), nudge_y=6) +
#geom_smooth(method="lm", alpha=0.5) +
scale_y_continuous(labels=scales::comma, limit=c(0, 100), breaks=seq(0, 100, 20)) +
scale_x_date(date_label="%Y", date_breaks="2 year") +
theme(legend.position = "bottom", axis.text.x = element_text(angle = 0)) +
labs(title="Trust SVT", x="Year", y="Percent") +
facet_grid(~polinterest)
supersom %>%
select(date, trust.svt, party) %>%
na.exclude() %>%
group_by(party, date, trust.svt) %>%
summarize(n = n()) %>%
mutate(percent = (n / sum(n)) * 100) %>%
ggplot(aes(date, percent, color=factor(trust.svt))) +
geom_line(size=1, alpha=1) +
geom_point(size=2) +
geom_text(aes(label=round(percent), alpha=0.7), nudge_y=10) +
#geom_smooth(method="lm", alpha=0.5) +
scale_y_continuous(labels=scales::comma, limit=c(0, 100), breaks=seq(0, 100, 20)) +
scale_x_date(date_label="%Y", date_breaks="2 year") +
theme(legend.position = "bottom", axis.text.x = element_text(angle = 0)) +
labs(title="Förtroende för SVT",
x="Year",
y="Percent",
caption="Data: Super-SOM 1986-2015") +
facet_wrap(~party)
## Warning: Removed 7 rows containing missing values (geom_text).
supersom %>%
select(date, trust.svt, sns.dich) %>%
na.exclude() %>%
group_by(sns.dich, date, trust.svt) %>%
summarize(n = n()) %>%
mutate(percent = (n / sum(n)) * 100) %>%
ggplot(aes(date, percent, color=factor(trust.svt))) +
geom_line(size=1, alpha=1) +
geom_point(size=2) +
#geom_smooth(method="lm", alpha=0.5) +
geom_text(aes(label=round(percent), alpha=0.8), nudge_y=8, size=3.5) +
scale_y_continuous(labels=scales::comma, limit=c(0, 100), breaks=seq(0, 100, 20)) +
scale_x_date(date_label="%Y", date_breaks="1 year") +
theme(legend.position = "bottom", axis.text.x = element_text(angle = 0)) +
labs(title="Trust SVT and social networking site use",
x="Year",
y="Percent") +
facet_wrap(~sns.dich)
supersom %>%
select(date, trust.sr) %>%
na.exclude() %>%
group_by(date, trust.sr) %>%
summarize(n = n()) %>%
mutate(percent = (n / sum(n)) * 100) %>%
ggplot(aes(date, percent, color=factor(trust.sr))) +
geom_line(size=1, alpha=1) +
geom_point(size=2) +
geom_text(aes(label=round(percent), alpha=0.8), nudge_y=8, size=3.5) +
scale_y_continuous(labels=scales::comma, limit=c(0, 100), breaks=seq(0, 100, 20)) +
scale_x_date(date_label="%Y", date_breaks="1 year") +
theme(legend.position = "right", axis.text.x = element_text(angle=0)) +
labs(title="Trust SR", x="Year", y="Percent")
supersom %>%
select(date, trust.sr, leaning) %>%
na.exclude() %>%
group_by(leaning, date, trust.sr) %>%
summarize(n = n()) %>%
mutate(percent = (n / sum(n)) * 100) %>%
ggplot(aes(date, percent, color=factor(trust.sr))) +
geom_line(size=1, alpha=1) +
geom_point(size=2) +
geom_text(aes(label=round(percent), alpha=0.8), nudge_y=8, size=3.5) +
#geom_smooth(method="lm", alpha=0.5) +
scale_y_continuous(labels=scales::comma, limit=c(0, 100), breaks=seq(0, 100, 20)) +
scale_x_date(date_label="%Y", date_breaks="2 year") +
theme(legend.position = "bottom", axis.text.x = element_text(angle = 0)) +
labs(title="Trust SR", x="Year", y="Percent") +
facet_wrap(~leaning)
supersom %>%
select(date, trust.sr, polinterest) %>%
na.exclude() %>%
group_by(polinterest, date, trust.sr) %>%
summarize(n = n()) %>%
mutate(percent = (n / sum(n)) * 100) %>%
ggplot(aes(date, percent, color=factor(trust.sr))) +
geom_line(size=1, alpha=1) +
geom_point(size=2) +
geom_text(aes(label=round(percent), alpha=0.8), nudge_y=8, size=3.5) +
#geom_smooth(method="lm", alpha=0.5) +
scale_y_continuous(labels=scales::comma, limit=c(0, 100), breaks=seq(0, 100, 20)) +
scale_x_date(date_label="%Y", date_breaks="2 year") +
theme(legend.position = "bottom", axis.text.x = element_text(angle = 0)) +
labs(title="Trust SR", x="Year", y="Percent") +
facet_grid(~polinterest)
supersom %>%
select(date, trust.sr, party) %>%
na.exclude() %>%
group_by(party, date, trust.sr) %>%
summarize(n = n()) %>%
mutate(percent = (n / sum(n)) * 100) %>%
ggplot(aes(date, percent, color=factor(trust.sr))) +
geom_line(size=1, alpha=1) +
geom_point(size=2) +
geom_text(aes(label=round(percent), alpha=0.8), nudge_y=8, size=3.5) +
#geom_smooth(method="lm", alpha=0.5) +
scale_y_continuous(labels=scales::comma, limit=c(0, 100), breaks=seq(0, 100, 20)) +
scale_x_date(date_label="%Y", date_breaks="1 year") +
theme(legend.position = "bottom", axis.text.x = element_text(angle = 0)) +
labs(title="Förtroende för SR",
x="Year",
y="Percent",
caption="Data: Super-SOM 1986-2015") +
facet_wrap(~party)
## Warning: Removed 3 rows containing missing values (geom_text).
supersom %>%
select(date, trust.sr, sns.dich) %>%
na.exclude() %>%
group_by(sns.dich, date, trust.sr) %>%
summarize(n = n()) %>%
mutate(percent = (n / sum(n)) * 100) %>%
ggplot(aes(date, percent, color=factor(trust.sr))) +
geom_line(size=1, alpha=1) +
geom_point(size=2) +
geom_text(aes(label=round(percent), alpha=0.8), nudge_y=8, size=3.5) +
#geom_smooth(method="lm", alpha=0.5) +
scale_y_continuous(labels=scales::comma, limit=c(0, 100), breaks=seq(0, 100, 10)) +
scale_x_date(date_label="%Y", date_breaks="1 year") +
theme(legend.position = "bottom", axis.text.x = element_text(angle = 0)) +
labs(title="Trust SR, by social networking site use",
x="Year",
y="Percent") +
facet_wrap(~sns.dich)
supersom %>%
select(date, psuse, age4a) %>%
na.exclude() %>%
group_by(age4a, date, psuse) %>%
summarize(n = n()) %>%
mutate(percent = n / sum(n) * 100) %>%
ggplot(aes(date, percent, color=factor(psuse))) +
geom_line(size=1.2) +
#geom_smooth(method="lm") +
scale_color_manual(values = sort(brewer.pal(3, "Paired")), name=NULL) +
scale_y_continuous(labels=scales::comma, limit=c(0, 100), breaks=seq(0, 100, 20)) +
scale_x_date(date_label="%Y", date_breaks="4 year") +
theme(legend.position = "bottom", axis.text.x = element_text(angle=0)) +
labs(title="Ues of public service news programs and age",
subtitle=NULL,
x="Year",
y="Percent") +
facet_wrap(~ age4a)
print(paste("n =", supersom %>%
select(date, psuse, age8a) %>%
na.exclude() %>% count()))
## [1] "n = 97830"
supersom %>%
select(date, psuse, sex) %>%
na.exclude() %>%
filter(as.numeric(sex) < 3) %>%
group_by(sex, date, psuse) %>%
summarize(n = n()) %>%
mutate(percent = n / sum(n) * 100) %>%
ggplot(aes(date, percent, color=factor(psuse))) +
geom_line(size=1.2) +
#geom_smooth(method="lm") +
scale_color_manual(values = sort(brewer.pal(3, "Paired")), name=NULL) +
scale_y_continuous(labels=scales::comma, limit=c(0, 100), breaks=seq(0, 100, 20)) +
scale_x_date(date_label="%Y", date_breaks="4 year") +
theme(legend.position = "bottom", axis.text.x = element_text(angle=0)) +
labs(title="Ues of public service news programs and female/male",
subtitle="Use any of Aktuellt, Rapport or Ekot.",
x="Year",
y="Percent") +
facet_wrap(~ sex)
print(paste("n =", supersom %>%
select(date, psuse, sex) %>%
na.exclude() %>% count()))
## [1] "n = 98565"
supersom %>%
select(date, psuse, edu3) %>%
na.exclude() %>%
group_by(edu3, date, psuse) %>%
summarize(n = n()) %>%
mutate(percent = n / sum(n) * 100) %>%
ggplot(aes(date, percent, color=factor(psuse))) +
geom_line(size=1.2) +
#geom_smooth(method="lm") +
scale_color_manual(values = sort(brewer.pal(3, "Paired")), name=NULL) +
scale_y_continuous(labels=scales::comma, limit=c(0, 100), breaks=seq(0, 100, 20)) +
scale_x_date(date_label="%Y", date_breaks="4 year") +
theme(legend.position = "bottom", axis.text.x = element_text(angle=0)) +
labs(title="Ues of public service news programs and education",
subtitle="Use any of Aktuellt, Rapport or Ekot.",
x="Year",
y="Percent") +
facet_wrap(~ edu3)
print(paste("n =", supersom %>%
select(date, psuse, edu3) %>%
na.exclude() %>% count()))
## [1] "n = 94621"
supersom %>%
select(date, year, partystrength) %>%
group_by(year, partystrength) %>%
na.exclude() %>%
summarize(n=NROW(partystrength)) %>%
mutate(percent = (n / sum(n)) * 100) %>%
ggplot(aes(year, percent)) +
geom_line(aes(linetype=partystrength, color=partystrength), size=1.2) +
theme(legend.position = "right") +
labs(title="Party support",
x="Year",
y="Percent")
Political (ideological) leaning on the left-right scale (1-5).
supersom %>%
select(date, year, ideology) %>%
group_by(year, ideology) %>%
summarize(n=NROW(ideology)) %>%
mutate(percent = (n / sum(n)) * 100) %>%
ggplot(aes(ideology, percent)) +
geom_area(fill="#666666") +
labs(title="Distribution of political ideology by year",
x="Left/right ideology",
y="Percent") +
facet_wrap(~year)
## Warning: Removed 31 rows containing missing values (position_stack).
supersom %>%
select(date, year, leaning) %>%
group_by(year, leaning) %>%
na.exclude() %>%
summarize(n=NROW(leaning)) %>%
mutate(percent = (n / sum(n)) * 100) %>%
ggplot(aes(year, percent, color=leaning)) +
geom_line(aes(linetype=leaning), size=1.2) +
theme(legend.position = "bottom") +
labs(title="Political leaning by year",
x="Year",
y="Percent")
We should expect an increase in standard deviation over time if people are becoming more polarized along the left-right scale.
supersom %>%
select(ideology, date) %>%
group_by(date) %>%
summarize(meanideology = mean(ideology, na.rm=TRUE), ideology_sd = sd(ideology, na.rm=TRUE)) %>%
ggplot(aes(date, ideology_sd)) +
geom_line() +
#geom_smooth(method="lm") +
geom_smooth(method="lm", formula=y ~ splines::ns(x, df=2)) + # Use cubic with 2 df.
#geom_smooth(method="loess") +
labs(title="Left/right political polarization",
x="Year",
y="Left-right ideology standard deviation")
Ideological consistency, or sorting, where individuals align themselves to parties consistent with their ideology.
supersom %>%
select(year, ideology, partyblock) %>%
#na.exclude() %>%
group_by(year, partyblock, ideology) %>%
summarize(n=n()) %>%
mutate(percent = (n / sum(n)) * 100) %>%
na.exclude() %>%
ggplot() +
geom_area(aes(x=ideology, y=percent, fill=factor(partyblock)), alpha=.8, position="identity") +
scale_color_manual(values=c("#CD614E", "#1B2B5F")) +
scale_fill_manual(values=c("#CD614E", "#1B2B5F")) +
theme(legend.position = "bottom") +
labs(title="Political leaning by party block",
subtitle=NULL,
x="Left/right leaning",
y="Percent",
caption="Left block: V, S. Right block: C, L, KD, M") +
facet_wrap(~ year)
Correlation between leaning and party block identification over time. If polarization is increasing, correlation should increase over time.
df <- supersom %>%
select(leaning.num, partyblock.num, date) %>%
group_by(date, leaning.num, partyblock.num)
df.corr <- plyr::ddply(df, "date", summarise, corr=cor(leaning.num, partyblock.num, method="pearson", use="na.or.complete"))
df.corr %>% mutate(date = format(date, "%Y"))
## date corr
## 1 1986 0.7425293
## 2 1987 0.7257491
## 3 1988 0.7373112
## 4 1989 0.6921111
## 5 1990 0.7101502
## 6 1991 0.7518332
## 7 1992 0.7221279
## 8 1993 0.7050289
## 9 1994 0.7409642
## 10 1995 0.7447632
## 11 1996 0.6914982
## 12 1997 0.7020527
## 13 1998 0.7388663
## 14 1999 0.7312772
## 15 2000 0.7117998
## 16 2001 0.7128053
## 17 2002 0.7598317
## 18 2003 0.6852369
## 19 2004 0.7240041
## 20 2005 0.7062038
## 21 2006 0.7686267
## 22 2007 0.7426668
## 23 2008 0.7388060
## 24 2009 0.7537652
## 25 2010 0.7811740
## 26 2011 0.7575875
## 27 2012 0.7622348
## 28 2013 0.7627043
## 29 2014 0.7937577
## 30 2015 0.7765756
df.corr %>%
ggplot(aes(date, corr)) +
geom_line() +
#geom_point(size=2) +
geom_smooth(method="lm", formula = y ~ splines::ns(x, df=2)) + # Cubic spline w/ 2 df
#geom_text(aes(label=round(corr, 2)), nudge_y=0) +
scale_y_continuous(labels=scales::comma) +
scale_x_date(date_label="%Y", date_breaks="3 year") +
theme(legend.position = "right", axis.text.x = element_text(angle=0)) +
labs(title="Ideological consistency / sorting",
subtitle=NULL,
x="Year",
y="Pearson correlation")
Compare high and low public service users.
Too few in the never/seldom category to be meaningful. Therefore, those who use PS news daily is contrasted with those who use it more seldom.
supersom %>%
select(leaning.num, psuse, partyblock.num, date) %>%
group_by(date, psuse, leaning.num) %>%
plyr::ddply(c("date", "psuse"), summarise, corr=cor(leaning.num, partyblock.num, method="pearson", use="na.or.complete")) %>%
na.exclude() %>%
ggplot(aes(date, corr)) +
geom_line() +
geom_smooth(method="lm") +
#geom_point(size=2) +
#geom_text(aes(label=round(corr, 2)), nudge_y=0) +
scale_y_continuous(labels=scales::comma, breaks=seq(0, 1, 0.05)) +
scale_x_date(date_label="%Y", date_breaks="3 year") +
theme(legend.position = "right", axis.text.x = element_text(angle=0)) +
labs(title="Ideological consistency (sorting)",
subtitle=NULL,
x="Year",
y="Pearson correlation") +
facet_grid(~ psuse)
Compare high and low internet users.
supersom %>%
select(leaning.num, internetnews.dich, partyblock.num, date) %>%
group_by(date, internetnews.dich, leaning.num, partyblock.num) %>%
plyr::ddply(c("date", "internetnews.dich"), summarise, corr=cor(leaning.num, partyblock.num, method="pearson", use="na.or.complete")) %>%
na.exclude() %>%
ggplot(aes(date, corr)) +
geom_line() +
geom_smooth(method="lm") +
#geom_point(size=2) +
#geom_text(aes(label=round(corr, 2)), nudge_y=0) +
scale_y_continuous(labels=scales::comma, breaks=seq(0, 1, 0.02)) +
scale_x_date(date_label="%Y", date_breaks="3 year") +
theme(legend.position = "right", axis.text.x = element_text(angle=0)) +
labs(title="Ideological consistency (sorting)",
subtitle=NULL,
x="Year",
y="Pearson Correlation") +
facet_grid(~ internetnews.dich)
# Get block party + ideology for all years.
df <- supersom %>%
select(date, year, ideology, partyblock) %>%
filter(partyblock == "Left" | partyblock == "Right") %>% # Only include left + right parties, exclude small parties.
group_by(year, partyblock) %>%
summarize(n=NROW(ideology)) %>%
mutate(percent = (n / sum(n)) * 100)
# Sort after year, decreasing.
df <- within(df, year <- ordered(year, levels=rev(sort(unique(year)))))
# Fix order of the geom_bar.
df$position[df$partyblock == "Left"] <- 2
## Warning: Unknown or uninitialised column: 'position'.
df$position[df$partyblock == "Right"] <- 1
# Stacked bar plot.
ggplot(df, aes(x=factor(year), y=percent, fill=partyblock, group=position)) + # group=position stacks the geom_bar.
geom_bar(stat="identity") +
scale_color_manual(values=c("red", "blue")) +
scale_fill_manual(values=c("red", "blue")) +
#scale_y_continuous(trans="reverse") +
theme(legend.position="bottom", legend.title = element_blank()) +
geom_hline(yintercept=50, color="white", alpha=0.5) +
geom_text(data=df[df$partyblock=="Left", ], y=5, aes(label=formatC(round(percent, 1), format='f', digits=1)), color="white", alpha=.5, position="identity") + # Add percent to bar
geom_text(data=df[df$partyblock=="Right", ], y=95, aes(label=formatC(round(percent, 1), format='f', digits=1)), color="white", alpha=.4, position="identity") + # Add percent to bar
labs(title="Support for party block over time",
x="Year",
y="Percent") +
coord_flip()
# Note: Keep trailing zeros (i.e., 43.0): formatC(round(percent, 1), format='f', digits=1)
# Order by increasing year in facet_wrap.
df$year <- factor(df$year, levels = sort(unique(df$year), decreasing = TRUE))
# Facet by year.
ggplot(df, aes(x=partyblock, y=percent, color=partyblock, fill=partyblock)) +
geom_bar(stat="identity") +
scale_color_manual(values=c("red", "blue")) +
scale_fill_manual(values=c("red", "blue")) +
theme_bw() +
labs(title="Support for party block over time",
x="Left/right ideology",
y="Percent") +
facet_wrap(~year, strip.position = "top")
Like and dislike of political parties.
library(reshape2)
##
## Attaching package: 'reshape2'
## The following object is masked from 'package:tidyr':
##
## smiths
supersom %>%
select(C, M, V, L, S, MP, KD, SD, year) %>%
melt(id="year", measure.vars=c("C", "M", "V", "L", "S", "MP", "KD", "SD")) %>%
filter(value < 10) %>%
ggplot(aes(x=variable, y=value, fill=variable)) +
geom_boxplot() +
theme(legend.position = "none") +
labs(title="Like and dislike of party by year",
x="Party identification",
y="Like/dislike") +
coord_flip() +
facet_wrap(~ year)
## Warning: attributes are not identical across measure variables; they will
## be dropped
supersom %>%
select(date, likeindex) %>%
na.exclude() %>%
dplyr::group_by(date) %>%
dplyr::summarize(meanlike = mean(likeindex, na.rm=TRUE)) %>%
ggplot(aes(date, meanlike)) +
geom_line() +
geom_point(size=2) +
#geom_smooth(method="lm", alpha=0.3) +
#scale_color_manual(values = c("#000000", "#CCCCCC"), name="Social networking site use") +
#scale_y_continuous(labels=scales::comma, limits=c(-10, 10)) +
scale_x_date(date_label="%Y", date_breaks="1 year") +
theme(legend.position = "bottom", axis.text.x = element_text(angle=90)) +
labs(title="Like/dislike",
x="Year",
y="Mean value -45 to +45")
supersom %>%
select(date, leaning, likeindex) %>%
na.exclude() %>%
dplyr::group_by(date, leaning) %>%
dplyr::summarize(meanlike = mean(likeindex, na.rm=TRUE)) %>%
ggplot(aes(date, meanlike)) +
geom_line() +
geom_point(size=2) +
#geom_smooth(method="lm", alpha=0.3) +
#scale_color_manual(values = c("#000000", "#CCCCCC"), name="Social networking site use") +
#scale_y_continuous(labels=scales::comma, limits=c(-10, 10)) +
scale_x_date(date_label="%Y", date_breaks="1 year") +
theme(legend.position = "bottom", axis.text.x = element_text(angle=90)) +
labs(title="Like/dislike",
x="Year",
y="Mean value -45 to +45") +
facet_grid(~ leaning)
supersom %>%
select(C, M, V, L, S, MP, KD, SD, year, party) %>%
melt(id="party", measure.vars=c("C", "M", "V", "L", "S", "MP", "KD", "SD")) %>%
filter(value < 10) %>%
na.exclude() %>%
ggplot(aes(x=variable, y=value, fill=variable)) +
geom_boxplot() +
labs(title="Like and dislike of parties by party", x="Party", y="Like/dislike") +
theme(legend.position = "none") +
coord_flip() +
facet_wrap(~ party)
## Warning: attributes are not identical across measure variables; they will
## be dropped
supersom %>%
select(C, M, V, L, S, MP, KD, SD, party, date) %>%
melt(id=c("party", "date"), measure.vars=c("C", "M", "V", "L", "S", "MP", "KD", "SD")) %>%
filter(value < 10) %>%
na.exclude() %>%
group_by(party, date) %>%
summarize(meanvalue = mean(value, na.rm=TRUE)) %>%
ggplot(aes(date, meanvalue, color=party)) +
geom_line(size=1) +
#geom_point(size=1.2) +
#geom_smooth(method="lm", alpha=0.3) +
#scale_color_manual(values = c("#000000", "#CCCCCC"), name="Social networking site use") +
scale_color_manual(values = unlist(PartyColor, use.names = FALSE)) +
#scale_y_continuous(labels=scales::comma, limits=c(0, 10)) +
#scale_x_date(date_label="%Y", date_breaks="1 year") +
geom_hline(yintercept = 0, alpha=0.4, linetype=2) +
theme(legend.position = "none", axis.text.x = element_text(angle=0)) +
labs(title="Like/dislike of political parties, by party identity",
x="Year",
y="Mean value -5 to +5") +
facet_wrap(~ party)
## Warning: attributes are not identical across measure variables; they will
## be dropped
# Affect in-party.
supersom %>%
select(date, party, partysymbol, affect.inparty) %>%
filter(partysymbol %in% c("S", "V", "MP", "L", "C", "KD", "M", "SD")) %>%
na.exclude() %>%
group_by(date, party) %>%
summarize(val = mean(affect.inparty)) %>%
ggplot(aes(date, val)) +
geom_line(size=1.2, color="green") +
geom_smooth(method="lm") +
geom_hline(yintercept = 0, alpha=0.4, linetype=2) +
#scale_y_continuous(labels=scales::comma, limit=c(-11, 11)) +
scale_x_date(date_label="%Y", date_breaks="4 year") +
theme(legend.position = "bottom", axis.text.x = element_text(angle=90)) +
labs(title="In-party affect",
subtitle=NULL,
x="Year",
y="In-party affect (mean)") +
facet_wrap(~ party, ncol=4)
# Affect in-party + social networking sites.
supersom %>%
select(date, sns.dich, affect.inparty) %>%
na.exclude() %>%
group_by(date, sns.dich) %>%
summarize(val = mean(affect.inparty)) %>%
ggplot(aes(date, val)) +
geom_line(size=1.2, color="darkgreen", alpha=0.2) +
geom_smooth(method="lm", alpha=0.2, color="black") +
#scale_y_continuous(labels=scales::comma, limit=c(-2, 2)) +
scale_x_date(date_label="%Y", date_breaks="2 year") +
theme(legend.position = "bottom", axis.text.x = element_text(angle=0)) +
labs(title="In-party affect + SNS",
subtitle=NULL,
x="Year",
y="In-party affect (mean)") +
facet_wrap(~ sns.dich, ncol=4)
# Affect out-party.
supersom %>%
select(date, party, partysymbol, affect.outparty) %>%
filter(partysymbol %in% c("S", "V", "MP", "L", "C", "KD", "M", "SD")) %>%
na.exclude() %>%
group_by(date, party) %>%
summarize(val = mean(affect.outparty)) %>%
ggplot(aes(date, val)) +
geom_line(size=1.2, color="red") +
geom_hline(yintercept = 0, alpha=0.4, linetype=2) +
geom_smooth(method="lm") +
#scale_y_continuous(labels=scales::comma, limit=c(-5, 5)) +
scale_x_date(date_label="%Y", date_breaks="4 year") +
theme(legend.position = "bottom", axis.text.x = element_text(angle=90)) +
labs(title="Out-party affect",
subtitle=NULL,
x="Year",
y="Out-party affect (mean)") +
facet_wrap(~ party, ncol=4)
# Affect out-party + internet.
supersom %>%
select(date, internet.dich, affect.outparty, partysymbol) %>%
filter(partysymbol %in% c("S", "V", "MP", "L", "C", "KD", "M", "SD")) %>%
na.exclude() %>%
group_by(date, internet.dich) %>%
summarize(val = mean(affect.outparty)) %>%
ggplot(aes(date, val)) +
geom_line(size=1.2, color="red") +
geom_hline(yintercept = 0, alpha=0.4, linetype=2) +
scale_y_continuous(labels=scales::comma, limit=c(-2, 2)) +
scale_x_date(date_label="%Y", date_breaks="2 year") +
theme(legend.position = "bottom", axis.text.x = element_text(angle=0)) +
labs(title="Out-party affect + internet",
subtitle=NULL,
x="Year",
y="Out-party affect (mean)") +
facet_wrap(~ internet.dich, ncol=4)
# Affect out-party + social networking sites.
supersom %>%
select(date, sns.dich, affect.outparty, partysymbol) %>%
filter(partysymbol %in% c("S", "V", "MP", "L", "C", "KD", "M", "SD")) %>%
na.exclude() %>%
group_by(date, sns.dich) %>%
summarize(val = mean(affect.outparty)) %>%
ggplot(aes(date, val)) +
geom_line(size=1.2, color="red") +
geom_hline(yintercept = 0, alpha=0.4, linetype=2) +
scale_y_continuous(labels=scales::comma, limit=c(-2, 2)) +
scale_x_date(date_label="%Y", date_breaks="2 year") +
theme(legend.position = "bottom", axis.text.x = element_text(angle=0)) +
labs(title="Out-party affect + SNS",
subtitle=NULL,
x="Year",
y="Out-party affect (mean)") +
facet_wrap(~ sns.dich, ncol=4)
# Affect in-party + PS.
gg1 <- supersom %>%
select(date, psuse, affect.inparty, partysymbol) %>%
filter(partysymbol %in% c("S", "V", "MP", "L", "C", "KD", "M", "SD")) %>%
na.exclude() %>%
group_by(date, psuse) %>%
summarize(val = mean(affect.inparty)) %>%
ggplot(aes(date, val)) +
geom_line(size=1.2, color="red", alpha=0.2) +
geom_smooth(method="loess", alpha=0.2, color="black") +
# Vertical lines every election year.
geom_vline(xintercept = as.numeric(as.Date(paste0(c(1988, 1991, 1994, 1998, 2002, 2006, 2010, 2014), "-01-01"))), alpha=0.3, linetype=2) +
#scale_y_continuous(labels=scales::comma, limit=c(-2, 2)) +
scale_x_date(date_label="%Y", date_breaks="4 year") +
theme(legend.position = "bottom", axis.text.x = element_text(angle=0)) +
labs(title="In-party affect",
subtitle=NULL,
x="Year",
y="Affect (mean)") +
facet_wrap(~ psuse, ncol=4)
# Affect out-party + PS
gg2 <- supersom %>%
select(date, psuse, affect.outparty, partysymbol) %>%
filter(partysymbol %in% c("S", "V", "MP", "L", "C", "KD", "M", "SD")) %>%
na.exclude() %>%
group_by(date, psuse) %>%
summarize(val = mean(affect.outparty)) %>%
ggplot(aes(date, val)) +
geom_line(size=1.2, color="blue", alpha=0.2) +
geom_smooth(method="loess", alpha=0.2, color="black") +
# Vertical lines every election year.
geom_vline(xintercept = as.numeric(as.Date(paste0(c(1988, 1991, 1994, 1998, 2002, 2006, 2010, 2014), "-01-01"))), alpha=0.3, linetype=2) +
#geom_hline(yintercept = 0, alpha=0.4, linetype=2) +
#scale_y_continuous(labels=scales::comma, limit=c(-2, 2)) +
scale_x_date(date_label="%Y", date_breaks="4 year") +
theme(legend.position = "bottom", axis.text.x = element_text(angle=0)) +
labs(title="Out-party affect",
subtitle=NULL,
x="Year",
y="Affect (mean)") +
facet_wrap(~ psuse, ncol=4)
library(gridExtra)
##
## Attaching package: 'gridExtra'
## The following object is masked from 'package:dplyr':
##
## combine
grid.arrange(gg1, gg2)
# Affect in-party + political interest
gg1 <- supersom %>%
select(date, polinterest, affect.inparty) %>%
na.exclude() %>%
group_by(date, polinterest) %>%
summarize(val = mean(affect.inparty)) %>%
ggplot(aes(date, val)) +
geom_line(size=1.2, color="red", alpha=0.2) +
geom_smooth(method="lm", alpha=0.2, color="black") +
#geom_hline(yintercept = 0, alpha=0.4) +
#scale_y_continuous(labels=scales::comma, limit=c(-2, 2)) +
scale_x_date(date_label="%Y", date_breaks="8 year") +
theme(legend.position = "bottom", axis.text.x = element_text(angle=90)) +
labs(title="In-party affect",
subtitle=NULL,
x="Year",
y="Affect (mean)") +
facet_grid(~ polinterest)
# Affect out-party + political interest
gg2 <- supersom %>%
select(date, polinterest, affect.outparty) %>%
na.exclude() %>%
group_by(date, polinterest) %>%
summarize(val = mean(affect.outparty)) %>%
ggplot(aes(date, val)) +
geom_line(size=1.2, color="blue", alpha=0.2) +
geom_smooth(method="lm", alpha=0.2, color="black") +
#geom_hline(yintercept = 0, alpha=0.4, linetype=2) +
#scale_y_continuous(labels=scales::comma, limit=c(-2, 2)) +
scale_x_date(date_label="%Y", date_breaks="8 year") +
theme(legend.position = "bottom", axis.text.x = element_text(angle=90)) +
labs(title="Out-party affect",
subtitle=NULL,
x="Year",
y="Affect (mean)") +
facet_grid(~ polinterest)
library(gridExtra)
grid.arrange(gg1, gg2)
Beliefs, views and attitudes on various issues.
# Increase unenyployment insurance (a-kassa).
gg.issue1 <- supersom %>%
select(date, jobmarket, psuse) %>%
na.exclude() %>%
group_by(date, psuse, jobmarket) %>%
summarize(n = n()) %>%
mutate(percent = n / sum(n) * 100) %>%
filter(jobmarket == "Agree") %>%
ggplot(aes(date, percent, color=factor(psuse), linetype=factor(psuse))) +
geom_line(size=1.2) +
#geom_point(size=2) +
scale_y_continuous(labels=scales::comma, limits=c(0, 100), breaks=seq(0, 100, 10)) +
scale_x_date(date_label="%Y", date_breaks="2 year") +
scale_color_manual(values = sort(brewer.pal(3, "Paired")), name=NULL) +
#geom_text(aes(label=round(percent, 0)), nudge_y=10, nudge_x=2) +
theme(legend.position = "none", axis.text.x = element_text(angle=0, vjust = 0.5)) +
labs(title="Raise unemployment insurance",
x="Year",
y="Percent agreement",
linetype=NULL,
color=NULL)
# More privatized healthcare.
gg.issue2 <- supersom %>%
select(date, privatehealthcare, psuse) %>%
na.exclude() %>%
group_by(date, psuse, privatehealthcare) %>%
summarize(n = n()) %>%
mutate(percent = n / sum(n) * 100) %>%
filter(privatehealthcare == "Agree") %>%
ggplot(aes(date, percent, color=factor(psuse), linetype=factor(psuse))) +
geom_line(size=1.2) +
#geom_point(size=2) +
scale_y_continuous(labels=scales::comma, limits=c(0, 100), breaks=seq(0, 100, 10)) +
scale_x_date(date_label="%Y", date_breaks="4 year") +
scale_color_manual(values = sort(brewer.pal(3, "Paired")), name=NULL) +
#geom_text(aes(label=round(percent, 0)), nudge_y=10, nudge_x=2) +
theme(legend.position = "none", axis.text.x = element_text(angle=0, vjust = 0.5)) +
labs(title="More privatized healthcare",
x="Year",
y="Percent agreement",
linetype=NULL,
color=NULL)
# Economy better or worse last 12 months.
gg.issue3 <- supersom %>%
select(date, economy.change, psuse) %>%
na.exclude() %>%
group_by(date, psuse, economy.change) %>%
summarize(n = n()) %>%
mutate(percent = n / sum(n) * 100) %>%
filter(economy.change == "Better") %>%
ggplot(aes(date, percent, color=factor(psuse), linetype=factor(psuse))) +
geom_line(size=1.2) +
#geom_point(size=2) +
scale_y_continuous(labels=scales::comma, limits=c(0, 100), breaks=seq(0, 100, 10)) +
scale_x_date(date_label="%Y", date_breaks="1 year") +
scale_color_manual(values = sort(brewer.pal(3, "Paired")), name=NULL) +
#geom_text(aes(label=round(percent, 0)), nudge_y=10, nudge_x=2) +
theme(legend.position = "none", axis.text.x = element_text(angle=0, vjust = 0.5)) +
labs(title="Economy better last 12 months",
subtitle=NULL,
x="Year",
y="Percent better",
linetype=NULL)
# Combine into one graph.
library(gridExtra)
grid.arrange(gg.issue1, gg.issue2, gg.issue3, ncol=3)
supersom %>%
select(date, economy.politics, psuse.daily) %>%
na.exclude() %>%
group_by(psuse.daily, date, economy.politics) %>%
summarize(n = n()) %>%
mutate(percent = n / sum(n) * 100) %>%
filter(economy.politics == "Good") %>%
ggplot(aes(date, percent)) +
geom_line(size=1.2, color="#7F00FF") +
geom_point(size=2, color="#7F00FF") +
scale_y_continuous(labels=scales::comma, limits=c(0, 100), breaks=seq(0, 100, 10)) +
scale_x_date(date_label="%Y", date_breaks="1 year") +
scale_color_manual(values = sort(brewer.pal(3, "Paired")), name=NULL) +
geom_text(aes(label=round(percent, 0), alpha=0.5), nudge_y=10) +
theme(legend.position = "none", axis.text.x = element_text(angle=0)) +
labs(title="\"What do you think of the politics in these areas? Economy.\" (percent good)",
subtitle=NULL,
x="Year",
y="Percent good/very good") +
facet_grid(~ psuse.daily)
Internet use.
supersom %>%
select(date, womendiscrimination, internet.dich) %>%
na.exclude() %>%
group_by(internet.dich, date, womendiscrimination) %>%
summarize(n = n()) %>%
mutate(percent = n / sum(n) * 100) %>%
filter(womendiscrimination == "Agree") %>%
ggplot(aes(date, percent)) +
geom_line(size=1.2, color="#106FAF") +
geom_point(size=2, color="#106FAF") +
scale_y_continuous(labels=scales::comma, limits=c(0, 100), breaks=seq(0, 100, 10)) +
scale_x_date(date_label="%Y", date_breaks="2 year") +
scale_color_manual(values = sort(brewer.pal(3, "Paired")), name=NULL) +
geom_text(aes(label=round(percent, 0), alpha=0.5), nudge_y=10) +
theme(legend.position = "none", axis.text.x = element_text(angle=0)) +
labs(title="\"Women are often discriminated against on the job market\"",
subtitle=NULL,
x="Year",
y="Percent agreement") +
facet_grid(~ internet.dich)
PS use.
supersom %>%
select(date, womendiscrimination, psuse.daily) %>%
na.exclude() %>%
group_by(psuse.daily, date, womendiscrimination) %>%
summarize(n = n()) %>%
mutate(percent = n / sum(n) * 100) %>%
filter(womendiscrimination == "Agree") %>%
ggplot(aes(date, percent)) +
geom_line(size=1.2, color="#106FAF") +
geom_point(size=2, color="#106FAF") +
scale_y_continuous(labels=scales::comma, limits=c(0, 100), breaks=seq(0, 100, 10)) +
scale_x_date(date_label="%Y", date_breaks="2 year") +
scale_color_manual(values = sort(brewer.pal(3, "Paired")), name=NULL) +
geom_text(aes(label=round(percent, 0), alpha=0.5), nudge_y=10) +
theme(legend.position = "none", axis.text.x = element_text(angle=0)) +
labs(title="\"Women are often discriminated against on the job market\"",
subtitle=NULL,
x="Year",
y="Percent agreement") +
facet_grid(~ psuse.daily)
High and low internet use.
supersom %>%
select(date, marry, internet.dich) %>%
na.exclude() %>%
group_by(internet.dich, date, marry) %>%
summarize(n = n()) %>%
mutate(percent = n / sum(n) * 100) %>%
filter(marry == "Agree") %>%
ggplot(aes(date, percent)) +
geom_line(size=1.2, color="#005800") +
geom_point(size=1.2) +
scale_y_continuous(labels=scales::comma, limits=c(0, 100), breaks=seq(0, 100, 10)) +
scale_x_date(date_label="%Y", date_breaks="2 year") +
#scale_color_manual(values = "#005800", name=NULL) +
theme(legend.position = "bottom", axis.text.x = element_text(angle=0)) +
labs(title="\"I would not like an immigrant marrying a family member\"",
subtitle=NULL,
x="Year",
y="Percent agreement") +
facet_grid(~ internet.dich)
High and low public service news use.
supersom %>%
select(date, marry, psuse.daily) %>%
na.exclude() %>%
group_by(psuse.daily, date, marry) %>%
summarize(n = n()) %>%
mutate(percent = n / sum(n) * 100) %>%
filter(marry == "Agree") %>%
ggplot(aes(date, percent)) +
geom_line(size=1.2, color="#106FAF") +
geom_point(size=2, color="#106FAF") +
scale_y_continuous(labels=scales::comma, limits=c(0, 100), breaks=seq(0, 100, 10)) +
scale_x_date(date_label="%Y", date_breaks="2 year") +
scale_color_manual(values = sort(brewer.pal(3, "Paired")), name=NULL) +
geom_text(aes(label=round(percent, 0), alpha=0.5), nudge_y=10) +
theme(legend.position = "none", axis.text.x = element_text(angle=0)) +
labs(title="\"I would not like an immigrant marrying a family member\"",
subtitle=NULL,
x="Year",
y="Percent agreement") +
facet_grid(~ psuse.daily)
supersom %>%
select(date, leaning, fc10e) %>%
na.exclude() %>%
filter(fc10e < 10) %>%
group_by(date, leaning) %>%
summarize(meanvalue = mean(fc10e, na.rm=TRUE)) %>%
ggplot(aes(date, meanvalue)) +
geom_line(size=1) +
geom_point(size=3) +
#geom_smooth(method="lm", alpha=0.3) +
scale_color_manual(values = c("#000000", "#CCCCCC")) +
scale_y_continuous(labels=scales::comma) +
scale_x_date(date_label="%Y", date_breaks="1 year") +
theme(legend.position = "bottom", axis.text.x = element_text(angle=90)) +
labs(title="I would not like immigrant marriying family member",
x="Year",
y="Mean value") +
facet_grid(~ leaning)
supersom %>%
select(date, leaning, fc10b) %>%
na.exclude() %>%
filter(fc10b < 10) %>%
group_by(date, leaning) %>%
summarize(meanvalue = mean(fc10b, na.rm=TRUE)) %>%
ggplot(aes(date, meanvalue)) +
geom_line(size=1) +
geom_point(size=3) +
#geom_smooth(method="lm", alpha=0.3) +
scale_color_manual(values = c("#000000", "#CCCCCC")) +
scale_y_continuous(labels=scales::comma) +
scale_x_date(date_label="%Y", date_breaks="1 year") +
theme(legend.position = "bottom", axis.text.x = element_text(angle=90)) +
labs(title="Immigrants should be able to practice their religion freely",
x="Year",
y="Mean value") +
facet_grid(~ leaning)
supersom %>%
select(date, leaning, bb100k) %>%
na.exclude() %>%
filter(bb100k < 50) %>%
group_by(date, leaning) %>%
summarize(meaninternet = mean(bb100k, na.rm=TRUE)) %>%
ggplot(aes(date, meaninternet)) +
geom_line(size=1) +
geom_point(size=3) +
#geom_smooth(method="lm", alpha=0.3) +
scale_color_manual(values = c("#000000", "#CCCCCC"), name="Social networking site use") +
scale_y_continuous(labels=scales::comma, limits=c(0, 10)) +
scale_x_date(date_label="%Y", date_breaks="1 year") +
theme(legend.position = "bottom", axis.text.x = element_text(angle=90)) +
labs(title="Internet is essential to stay informed about news",
x="Year",
y="Mean value (1-10)") +
facet_grid(~ leaning)
supersom %>%
select(date, leaning, bb100h) %>%
na.exclude() %>%
filter(bb100h < 50) %>%
group_by(date, leaning) %>%
summarize(meanvalue = mean(bb100h, na.rm=TRUE)) %>%
ggplot(aes(date, meanvalue)) +
geom_line(size=1) +
geom_point(size=3) +
#geom_smooth(method="lm", alpha=0.3) +
scale_color_manual(values = c("#000000", "#CCCCCC"), name="Social networking site use") +
scale_y_continuous(labels=scales::comma, limits=c(0, 10)) +
scale_x_date(date_label="%Y", date_breaks="1 year") +
theme(legend.position = "bottom", axis.text.x = element_text(angle=90)) +
labs(title="Internet can only complement news papers, radio and television",
x="Year",
y="Mean value (1-10)") +
facet_grid(~ leaning)
Demography, summary statistics, number of respondents etc.
supersom %>%
group_by(date) %>%
select(date, polinterest.num) %>%
summarize(meaninterest=mean(polinterest.num, na.rm=TRUE)) %>%
ggplot(aes(date, meaninterest)) +
geom_line(alpha=0.4) +
geom_smooth(method = "loess", level=0.95, color="blue", alpha=0.3) +
scale_y_continuous(labels=scales::comma) +
scale_x_date(date_label="%Y", date_breaks="2 year") +
geom_vline(xintercept = as.numeric(as.Date("2004-01-01")), color="black", alpha=0.9, linetype=2) +
#geom_vline(xintercept = as.numeric(as.Date("2006-01-01")), color="black", alpha=0.9, linetype=4)
annotate("text", x=as.Date("2008-06-01"), y=2.35, label="Facebook launches 2004") +
labs(title="Mean political interest",
subtitle="Loess smoothing with 95 % CI.",
x="Year",
y="Political interest (1–4)")
supersom %>%
group_by(leaning, date) %>%
select(date, polinterest.num) %>%
na.exclude() %>%
summarize(meaninterest=mean(polinterest.num, na.rm=TRUE)) %>%
ggplot(aes(date, meaninterest)) +
geom_line(alpha=0.4) +
#geom_smooth(method = "loess", level=0.95, color="blue", alpha=0.3) +
#geom_smooth(method = "lm", level=0.95, color="blue", alpha=0.3) +
geom_smooth(method = "lm", formula=y ~ splines::ns(x, df=2), level=0.95, color="blue", alpha=0.3) +
scale_y_continuous(labels=scales::comma, limits = c(2, 3)) +
scale_x_date(date_label="%Y", date_breaks="2 year") +
theme(axis.text.x = element_text(angle=90)) +
labs(title="Political interest (mean)",
subtitle=NULL,
x="Year",
y="Political interest (1–4)") +
#geom_vline(xintercept = as.numeric(as.Date("2004-01-01")), color="black", alpha=0.9, linetype=2) +
#geom_vline(xintercept = as.numeric(as.Date("2006-01-01")), color="black", alpha=0.9, linetype=4)
#annotate("text", x=as.Date("2008-06-01"), y=2.35, label="Facebook launches 2004") +
facet_wrap(~ leaning)
## Adding missing grouping variables: `leaning`
supersom %>%
group_by(date) %>%
select(date, ideology) %>%
summarize(meanideology=mean(ideology, na.rm=TRUE)) %>%
ggplot(aes(date, meanideology)) +
geom_line() +
#geom_smooth(method = "lm", level=0.95) +
scale_y_continuous(labels=scales::comma) +
scale_x_date(date_label="%Y", date_breaks="2 year") +
geom_hline(yintercept=3, linetype=2) +
labs(title="Ideology per year (mean)", x="Year", y="Ideology (1=left, 5=right)")
Ideological extremism by year.
supersom %>%
group_by(date) %>%
select(date, polextreme) %>%
summarize(meanextremism=mean(polextreme, na.rm=TRUE)) %>%
ggplot(aes(date, meanextremism)) +
geom_line(alpha=0.4) +
geom_smooth(method = "loess", level=0.95, color="blue", alpha=0.3) +
scale_y_continuous(labels=scales::comma) +
scale_x_date(date_label="%Y", date_breaks="2 year") +
labs(title="Ideological extremism (mean)",
subtitle=NULL,
x="Year",
y="Ideological extremism (0-2)") +
geom_vline(xintercept = as.numeric(as.Date("2004-01-01")), color="black", alpha=0.9, linetype=2) +
#geom_vline(xintercept = as.numeric(as.Date("2006-01-01")), color="black", alpha=0.9, linetype=4)
annotate("text", x=as.Date("2008-06-01"), y=1.23, label="Facebook launches 2004")
Ideological extremism by party block.
supersom %>%
group_by(leaning, date) %>%
select(date, polextreme, leaning) %>%
na.exclude() %>%
summarize(meanextremism=mean(polextreme, na.rm=TRUE)) %>%
filter(meanextremism > 0) %>%
ggplot(aes(date, meanextremism, color=leaning)) +
geom_line(alpha=0.8) +
geom_smooth(method = "loess", level=0.95, alpha=0.15) +
scale_y_continuous(labels=scales::comma) +
scale_x_date(date_label="%Y", date_breaks="2 year") +
theme(legend.position = "bottom", axis.text.x = element_text(angle=90)) +
labs(title="Ideological extremism (mean)",
subtitle=NULL,
x="Year",
y="Ideological extremism (0–2)") +
facet_grid(~leaning)
supersom %>%
ggplot(aes(year)) +
geom_bar(position="stack", aes(fill=factor(formular))) +
theme(legend.position = "none") +
labs(title="Respondents per year and survey",
subtitle="Colors indicate the different surveys.",
x="Year",
y="Respondents")
Sample size statistics.
# Sample size min, max, mean.
supersom %>% group_by(year) %>% summarize(n = NROW(year)) %>% select(n) %>% unlist() %>% summary()
## Min. 1st Qu. Median Mean 3rd Qu. Max.
## 1573 1760 3467 3453 3666 8406
# Sample size std dev.
supersom %>% group_by(year) %>% summarize(n = NROW(year)) %>% select(n) %>% unlist() %>% sd()
## [1] 1953.831
Sample and demography.
library(broom)
print(paste("Total n =", nrow(supersom)))
## [1] "Total n = 103589"
# Respondents descriptive.
supersom %>% group_by(year) %>% summarize(respondents = n()) %>% print(n = nrow(.))
## # A tibble: 30 x 2
## year respondents
## <dbl> <int>
## 1 1986 1624
## 2 1987 1671
## 3 1988 1643
## 4 1989 1578
## 5 1990 1582
## 6 1991 1573
## 7 1992 1889
## 8 1993 1857
## 9 1994 1704
## 10 1995 1777
## 11 1996 1779
## 12 1997 1754
## 13 1998 3561
## 14 1999 3503
## 15 2000 3546
## 16 2001 3638
## 17 2002 3609
## 18 2003 3675
## 19 2004 3612
## 20 2005 3499
## 21 2006 3336
## 22 2007 3435
## 23 2008 3259
## 24 2009 4926
## 25 2010 5007
## 26 2011 4720
## 27 2012 6289
## 28 2013 8406
## 29 2014 6876
## 30 2015 8261
# % education.
round(prop.table(table(rio::factorize(supersom$edu3))) * 100, 0)
##
## Låg (max grundskola eller motsvarande)
## 24
## Medel (allt över grundskola men ej högskola/universitet)
## 44
## Hög (studier/examen från högskola/universitet)
## 32
## Frågan ej ställd
## 0
## Ej svar
## 0
# % age.
round(prop.table(table(rio::factorize(supersom$age4a))) * 100, 0)
##
## 16-29 år 30-49 år 50-64 år 65--
## 18 32 26 23
## Ej svar/uppgift
## 0
# % sex.
round(prop.table(table(rio::factorize(supersom$sex))) * 100, 0)
##
## Female Male
## 52 48
# Age, political interest, political leaning
supersom %>% select(age, polinterest, leaning) %>% tidy()
## column n mean sd median trimmed mad min
## 1 age 101663 48.512605 18.1446076 49 48.602648 22.2390 15
## 2 polinterest* 100126 2.589717 0.8002844 3 2.587501 1.4826 1
## 3 leaning* 98155 2.019174 0.8271697 2 2.023967 1.4826 1
## max range skew kurtosis se
## 1 85 70 -0.04716512 -1.0131801 0.056907056
## 2 4 3 -0.06749927 -0.4641424 0.002529129
## 3 3 2 -0.03567317 -1.5376058 0.002640209
Data from page 542 table 5: http://som.gu.se/digitalAssets/1487/1487725_531-560-frida-vernersdotter--metod.pdf
surveys <- data.frame(
year=1986:2015,
date=as.Date(seq.Date(as.Date("1986-01-01"), as.Date("2015-01-01"), by = "year")),
responserate=c(65,67,66,63,63,63,67,66,61,63,63,63,64,63,59,61,60,61,60,58,55,57,54,55,56,52,52,49,51,51)
)
print(paste("Response rate M =", mean(surveys$responserate)))
## [1] "Response rate M = 59.6"
print(paste("Response rate SD =", sd(surveys$responserate)))
## [1] "Response rate SD = 5.24963052887107"
surveys %>% ggplot(aes(date, responserate)) +
geom_line() +
scale_y_continuous(limits = c(0, 100)) +
labs(title="Response rate", x="Year", y="Percent")
(Not included)
# Append significance stars depending on p-value.
sigstars <- function(p) {
p <- as.numeric(p)
if(p < 0.001) { return ("***") }
if(p < 0.01) { return ("**") }
if(p < 0.05) { return ("*") }
return("")
}
# Coefficient plot for LM.
coefplot <- function(model, intercept=FALSE, sort=FALSE, title="Predictors", caption="*p<0.05 **p<0.01 ***p<0.001. Bars represent 95 % C.I.", labels=NULL, nudge_y=0.3, nudge_x=0) {
library(broom)
if(!is.null(labels)) {
names(model$coefficients) <- labels # Rename labels.
}
df <- tidy(model, conf.int=TRUE)
if(intercept == FALSE){
df <- df %>% filter(term != "(Intercept)")
}
df <- df %>% mutate(label = paste(round(estimate, 2), sapply(p.value, FUN=sigstars), sep=""))
if(sort == TRUE) {
df$term <- reorder(df$term, df$estimate) # Sort by estimate, descdending order.
}
ggplot(df, aes(estimate, term)) +
geom_point(size=3, fill="black") +
geom_errorbarh(aes(xmin=conf.low, xmax=conf.high), width=0.2, height=0, lwd=1, lty=1, col="black") +
geom_vline(xintercept = 0, color="black", alpha=0.5, linetype=2) +
geom_text(aes(label=label, alpha=1), nudge_y=nudge_y, nudge_x=nudge_x) +
theme(legend.position = "none") +
labs(title=title,
caption=caption,
x="Regression coefficient (unstandardized)",
y=NULL)
}
# Coefficient plot for MLM.
coefplot_mlm <- function(model, intercept=FALSE, sort=FALSE, title="Predictors", caption="Bars represent 95 % C.I.", labels=NULL, nudge_y=0.3, nudge_x=0) {
library(broom)
df <- tidy(model, conf.int=TRUE) %>%
mutate(label = paste(round(estimate, 2), sep=""))
if(!is.null(labels)) {
# Rename labels.
df$term <- labels
}
if(sort == TRUE) {
df$term <- reorder(df$term, df$estimate) # Sort by estimate, descdending order.
}
if(intercept == FALSE){
df <- df %>% filter(term != "(Intercept)")
}
df %>%
na.exclude() %>%
ggplot(aes(estimate, term)) +
geom_point(size=3, fill="black") +
geom_errorbarh(aes(xmin=conf.low, xmax=conf.high), width=0.2, height=0, lwd=1, lty=1, col="black") +
geom_vline(xintercept = 0, color="black", alpha=0.5, linetype=2) +
geom_text(aes(label=label, alpha=1), nudge_y=nudge_y, nudge_x=nudge_x) +
theme(legend.position = "none") +
labs(title=title,
caption=caption,
x="Estimate",
y=NULL)
}
Prepare data for models: set reference category and center variables.
# Set reference categories.
supersom$polinterest <- relevel(supersom$polinterest, ref="No political interest")
supersom$party <- relevel(supersom$party, ref="Social Democrats (S)")
supersom$leaning <- relevel(supersom$leaning, ref="Center")
supersom$psuse <- relevel(supersom$psuse, ref="PS news more seldom")
supersom$psuse.daily <- relevel(supersom$psuse.daily, ref="PS news more seldom")
supersom$trust.svt.dich <- relevel(supersom$trust.svt.dich, ref="Low trust")
supersom$trust.sr.dich <- relevel(supersom$trust.sr.dich, ref="Low trust")
# Center year 1986 as 1.
supersom$time <- 1 + supersom$year - 1986
Mean public service news use by year, including standard deviation.
supersom %>% group_by(year) %>% summarize(psindex = mean(psindex.rev, na.rm=TRUE), psindex.stddev = sd(psindex.rev, na.rm=TRUE))
## # A tibble: 30 x 3
## year psindex psindex.stddev
## <dbl> <dbl> <dbl>
## 1 1986 3.698120 1.171195
## 2 1987 3.746021 1.170325
## 3 1988 3.695931 1.169697
## 4 1989 3.759178 1.163525
## 5 1990 3.829512 1.188226
## 6 1991 3.716186 1.210169
## 7 1992 3.699074 1.194761
## 8 1993 3.653678 1.217431
## 9 1994 3.647945 1.261966
## 10 1995 3.573587 1.310519
## # ... with 20 more rows
Pooled cross-section OLS.
Simple model with only the main predictors.
# Linear model.
m1 <- lm(psindex.rev ~ leaning + polinterest.num + time, data=supersom)
summary(m1)
##
## Call:
## lm(formula = psindex.rev ~ leaning + polinterest.num + time,
## data = supersom)
##
## Residuals:
## Min 1Q Median 3Q Max
## -3.5659 -0.9266 0.0400 1.0450 3.2953
##
## Coefficients:
## Estimate Std. Error t value Pr(>|t|)
## (Intercept) 2.2849762 0.0184955 123.542 < 2e-16 ***
## leaningLeft 0.0024665 0.0114787 0.215 0.83
## leaningRight 0.0739870 0.0112834 6.557 5.52e-11 ***
## polinterest.num 0.5677834 0.0057936 98.001 < 2e-16 ***
## time -0.0049355 0.0005479 -9.007 < 2e-16 ***
## ---
## Signif. codes: 0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1
##
## Residual standard error: 1.309 on 85296 degrees of freedom
## (18288 observations deleted due to missingness)
## Multiple R-squared: 0.1087, Adjusted R-squared: 0.1086
## F-statistic: 2600 on 4 and 85296 DF, p-value: < 2.2e-16
coefplot(m1, title=NULL, labels=c("(Intercept)", "Leaning left", "Leaning right", "Political interest", "Time (1-30)"))
## Warning: Ignoring unknown parameters: width
More predictors.
m2 <- lm(psindex.rev ~ factor(polinterest) + sex + factor(age4a) + edu3 + leaning + time + I(time * as.integer(polinterest)), data=supersom)
library(stargazer)
##
## Please cite as:
## Hlavac, Marek (2015). stargazer: Well-Formatted Regression and Summary Statistics Tables.
## R package version 5.2. http://CRAN.R-project.org/package=stargazer
stargazer(m2, type="text")
##
## ==========================================================================================
## Dependent variable:
## -----------------------------
## psindex.rev
## ------------------------------------------------------------------------------------------
## factor(polinterest)Low 0.364***
## (0.021)
##
## factor(polinterest)Medium 0.640***
## (0.031)
##
## factor(polinterest)High political interest 0.762***
## (0.045)
##
## sexMale 0.148***
## (0.008)
##
## factor(age4a)30-49 år 0.646***
## (0.012)
##
## factor(age4a)50-64 år 1.228***
## (0.013)
##
## factor(age4a)65-- 1.782***
## (0.014)
##
## edu3Medel (allt över grundskola men ej högskola/universitet) 0.084***
## (0.012)
##
## edu3Hög (studier/examen från högskola/universitet) 0.154***
## (0.013)
##
## leaningLeft 0.054***
## (0.011)
##
## leaningRight 0.071***
## (0.010)
##
## time -0.036***
## (0.002)
##
## I(time * as.integer(polinterest)) 0.008***
## (0.001)
##
## Constant 2.420***
## (0.030)
##
## ------------------------------------------------------------------------------------------
## Observations 81,567
## R2 0.285
## Adjusted R2 0.284
## Residual Std. Error 1.172 (df = 81553)
## F Statistic 2,494.863*** (df = 13; 81553)
## ==========================================================================================
## Note: *p<0.1; **p<0.05; ***p<0.01
print(paste("n =", nrow(model.frame(m2))))
## [1] "n = 81567"
coefplot(m2, sort=TRUE, intercept=TRUE, title=NULL, caption=NULL,
labels=c("(Intercept)", "Low political interest", "Medium political interest", "High political interest", "Male", "30–49 years", "50–64 years", "65 years or older", "Medium education", "High education", "Leaning left", "Leaning right", "Time (1–30)", "Time × Political interest"),
nudge_y=0, nudge_x=0.2)
## Warning: Ignoring unknown parameters: width
Add party.
m3 <- lm(psindex.rev ~ factor(polinterest) + sex + factor(age4a) + edu3 + leaning + as.numeric(partystrength) + time + I(time * as.integer(polinterest)) + factor(party), data=supersom)
stargazer(m3, type="text")
##
## ==========================================================================================
## Dependent variable:
## -----------------------------
## psindex.rev
## ------------------------------------------------------------------------------------------
## factor(polinterest)Low 0.357***
## (0.023)
##
## factor(polinterest)Medium 0.629***
## (0.034)
##
## factor(polinterest)High political interest 0.762***
## (0.048)
##
## sexMale 0.159***
## (0.009)
##
## factor(age4a)30-49 år 0.625***
## (0.012)
##
## factor(age4a)50-64 år 1.202***
## (0.013)
##
## factor(age4a)65-- 1.742***
## (0.015)
##
## edu3Medel (allt över grundskola men ej högskola/universitet) 0.088***
## (0.012)
##
## edu3Hög (studier/examen från högskola/universitet) 0.156***
## (0.014)
##
## leaningLeft 0.062***
## (0.013)
##
## leaningRight 0.046***
## (0.013)
##
## as.numeric(partystrength) 0.002
## (0.006)
##
## time -0.034***
## (0.002)
##
## I(time * as.integer(polinterest)) 0.007***
## (0.001)
##
## factor(party)Left Party (V) -0.045***
## (0.017)
##
## factor(party)Centre Party (C) 0.167***
## (0.021)
##
## factor(party)Liberals (L) 0.084***
## (0.019)
##
## factor(party)Moderate Party (M) -0.014
## (0.017)
##
## factor(party)Christian Democrats (KD) 0.049**
## (0.022)
##
## factor(party)Green Party (MP) -0.091***
## (0.017)
##
## factor(party)Sweden Democrats (SD) -0.205***
## (0.025)
##
## factor(party)Feminist Initiative (FI) -0.141**
## (0.057)
##
## factor(party)Pirate Party (PP) -0.576***
## (0.071)
##
## factor(party)New Democracy (NyD) -0.001
## (0.067)
##
## factor(party)Other -0.169***
## (0.034)
##
## Constant 2.409***
## (0.035)
##
## ------------------------------------------------------------------------------------------
## Observations 74,698
## R2 0.283
## Adjusted R2 0.283
## Residual Std. Error 1.166 (df = 74672)
## F Statistic 1,179.950*** (df = 25; 74672)
## ==========================================================================================
## Note: *p<0.1; **p<0.05; ***p<0.01
print(paste("n =", nrow(model.frame(m3))))
## [1] "n = 74698"
coefplot(m3, sort=TRUE, intercept=TRUE, title=NULL, caption=NULL,
labels=c("(Intercept)", "Low political interest", "Medium political interest", "High political interest", "Male", "30–49 years", "50–64 years", "65 years or older", "Medium education", "High education", "Leaning left", "Leaning right", "Party ID strength (1–3)", "Time (1–30)", "Time × Political interest", "Left Party (V)", "Centre Party(C)", "Liberals (L)", "Moderate Party (M)", "Christian Democrats (KD)", "Green Party (MP)", "Sweden Democrats (SD)", "Feminist Initiative (FI)", "Pirate Party (PP)", "New Democracy (NyD)", "Other party"),
nudge_y=0, nudge_x=0.3)
## Warning: Ignoring unknown parameters: width
Add internet news use + social networking site use + SVT trust + SR trust.
m4 <- lm(psindex.rev ~ sex + factor(age4a) + internetnews + sns + edu3 + factor(polinterest) + leaning + as.numeric(partystrength) + factor(party) + factor(trust.svt) + (trust.sr) + time + I(time * as.integer(polinterest)), data=supersom)
stargazer(m4, type="text")
##
## ========================================================================================
## Dependent variable:
## ---------------------------
## psindex.rev
## ----------------------------------------------------------------------------------------
## sexMale 0.081**
## (0.034)
##
## factor(age4a)30-49 år 0.751***
## (0.050)
##
## factor(age4a)50-64 år 1.419***
## (0.054)
##
## factor(age4a)65-- 1.947***
## (0.063)
##
## internetnews 0.020**
## (0.009)
##
## sns -0.041***
## (0.007)
##
## edu3Medel (allt över grundskola men ej högskola/universitet) 0.039
## (0.056)
##
## edu3Hög (studier/examen från högskola/universitet) 0.028
## (0.060)
##
## factor(polinterest)Low 0.110
## (0.343)
##
## factor(polinterest)Medium 0.518
## (0.671)
##
## factor(polinterest)High political interest 0.735
## (1.007)
##
## leaningLeft -0.131**
## (0.052)
##
## leaningRight 0.019
## (0.049)
##
## as.numeric(partystrength) 0.015
## (0.024)
##
## factor(party)Left Party (V) 0.008
## (0.072)
##
## factor(party)Centre Party (C) 0.019
## (0.084)
##
## factor(party)Liberals (L) -0.027
## (0.079)
##
## factor(party)Moderate Party (M) -0.131**
## (0.062)
##
## factor(party)Christian Democrats (KD) -0.140
## (0.098)
##
## factor(party)Green Party (MP) -0.080
## (0.059)
##
## factor(party)Sweden Democrats (SD) -0.113
## (0.078)
##
## factor(party)Feminist Initiative (FI) -0.134
## (0.166)
##
## factor(party)Pirate Party (PP) -0.502**
## (0.216)
##
## factor(party)Other -0.248
## (0.180)
##
## factor(trust.svt)Neither low nor high -0.103
## (0.063)
##
## factor(trust.svt)Low trust -0.050
## (0.128)
##
## trust.srNeither low nor high -0.428***
## (0.062)
##
## trust.srLow trust -0.651***
## (0.126)
##
## time -0.032
## (0.036)
##
## I(time * as.integer(polinterest)) 0.002
## (0.012)
##
## Constant 3.202***
## (0.656)
##
## ----------------------------------------------------------------------------------------
## Observations 4,876
## R2 0.363
## Adjusted R2 0.359
## Residual Std. Error 1.105 (df = 4845)
## F Statistic 91.944*** (df = 30; 4845)
## ========================================================================================
## Note: *p<0.1; **p<0.05; ***p<0.01
coefplot(m4, sort=TRUE, title="Predictor of public service news use", nudge_y=0, nudge_x=0.5,
labels=c("(Intercept)", "Male", "30–49 years", "50–64 years", "65 years or older", "Medium education", "High education", "Leaning left", "Leaning right", "Low political interest", "Medium political interest", "High political interest", "Party ID strength (1–3)", "Left Party (V)", "Centre Party(C)", "Liberals (L)", "Moderate Party (M)", "Christian Democrats (KD)", "Green Party (MP)", "Sweden Democrats (SD)", "Feminist Initiative (FI)", "Pirate Party (PP)", "New Democracy (NyD)", "Other party"))
## Warning: Ignoring unknown parameters: width
Empty model: DV + year as random intercept.
library(lme4)
## Loading required package: Matrix
##
## Attaching package: 'Matrix'
## The following object is masked from 'package:tidyr':
##
## expand
##
## Attaching package: 'lme4'
## The following object is masked _by_ '.GlobalEnv':
##
## dummy
## The following object is masked from 'package:rio':
##
## factorize
mlm1 <- lmer(psindex.rev ~ 1 + (1 | time), data=supersom, REML=FALSE)
summary(mlm1)
## Linear mixed model fit by maximum likelihood ['lmerMod']
## Formula: psindex.rev ~ 1 + (1 | time)
## Data: supersom
##
## AIC BIC logLik deviance df.resid
## 309955.1 309983.2 -154974.5 309949.1 88614
##
## Scaled residuals:
## Min 1Q Median 3Q Max
## -2.0143 -0.8376 -0.1137 0.6458 1.7837
##
## Random effects:
## Groups Name Variance Std.Dev.
## time (Intercept) 0.00395 0.06285
## Residual 1.93309 1.39036
## Number of obs: 88617, groups: time, 30
##
## Fixed effects:
## Estimate Std. Error t value
## (Intercept) 3.6911 0.0126 292.9
Year as random intercept + political interest as fixed slope.
Year as random intercept + political leaning as fixed slope.
Year as random intercept + party as fixed slope.
library(lme4)
mlm2a <- lmer(psindex.rev ~ 1 + time + polinterest + (1 | time), data=supersom, REML=FALSE)
summary(mlm2a)
## Linear mixed model fit by maximum likelihood ['lmerMod']
## Formula: psindex.rev ~ 1 + time + polinterest + (1 | time)
## Data: supersom
##
## AIC BIC logLik deviance df.resid
## 294822.0 294887.7 -147404.0 294808.0 87388
##
## Scaled residuals:
## Min 1Q Median 3Q Max
## -2.69379 -0.73401 -0.00648 0.76590 2.73277
##
## Random effects:
## Groups Name Variance Std.Dev.
## time (Intercept) 0.005753 0.07585
## Residual 1.706808 1.30645
## Number of obs: 87395, groups: time, 30
##
## Fixed effects:
## Estimate Std. Error t value
## (Intercept) 2.632472 0.034365 76.60
## time -0.002927 0.001703 -1.72
## polinterestLow 0.789839 0.017340 45.55
## polinterestMedium 1.405913 0.017114 82.15
## polinterestHigh political interest 1.768394 0.020230 87.42
##
## Correlation of Fixed Effects:
## (Intr) time plntrL plntrM
## time -0.790
## polintrstLw -0.418 0.004
## polntrstMdm -0.419 -0.001 0.833
## plntrstHgpi -0.349 -0.007 0.705 0.717
mlm2b <- lmer(psindex.rev ~ 1 + time + leaning + (1 | time), data=supersom, REML=FALSE)
summary(mlm2b)
## Linear mixed model fit by maximum likelihood ['lmerMod']
## Formula: psindex.rev ~ 1 + time + leaning + (1 | time)
## Data: supersom
##
## AIC BIC logLik deviance df.resid
## 299660.9 299717.1 -149824.4 299648.9 86045
##
## Scaled residuals:
## Min 1Q Median 3Q Max
## -2.12650 -0.75416 -0.01242 0.77270 1.91046
##
## Random effects:
## Groups Name Variance Std.Dev.
## time (Intercept) 0.003796 0.06161
## Residual 1.903542 1.37969
## Number of obs: 86051, groups: time, 30
##
## Fixed effects:
## Estimate Std. Error t value
## (Intercept) 3.543880 0.027236 130.12
## time -0.001578 0.001441 -1.10
## leaningLeft 0.242864 0.011780 20.62
## leaningRight 0.293495 0.011618 25.26
##
## Correlation of Fixed Effects:
## (Intr) time lnngLf
## time -0.852
## leaningLeft -0.211 -0.015
## leaningRght -0.209 -0.020 0.533
mlm2c <- lmer(psindex.rev ~ 1 + time + party + (1 | time), data=supersom, REML=FALSE)
summary(mlm2c)
## Linear mixed model fit by maximum likelihood ['lmerMod']
## Formula: psindex.rev ~ 1 + time + party + (1 | time)
## Data: supersom
##
## AIC BIC logLik deviance df.resid
## 281310.3 281449.9 -140640.2 281280.3 81138
##
## Scaled residuals:
## Min 1Q Median 3Q Max
## -2.2275 -0.7662 -0.0148 0.7904 2.6446
##
## Random effects:
## Groups Name Variance Std.Dev.
## time (Intercept) 0.003424 0.05851
## Residual 1.873010 1.36858
## Number of obs: 81153, groups: time, 30
##
## Fixed effects:
## Estimate Std. Error t value
## (Intercept) 3.711892 0.026448 140.34
## time 0.001700 0.001395 1.22
## partyLeft Party (V) -0.100862 0.019356 -5.21
## partyCentre Party (C) 0.202994 0.021592 9.40
## partyLiberals (L) 0.110847 0.018651 5.94
## partyModerate Party (M) 0.024208 0.012880 1.88
## partyChristian Democrats (KD) 0.180575 0.022541 8.01
## partyGreen Party (MP) -0.316469 0.018983 -16.67
## partySweden Democrats (SD) -0.334814 0.027139 -12.34
## partyFeminist Initiative (FI) -0.298670 0.064647 -4.62
## partyPirate Party (PP) -1.458968 0.080685 -18.08
## partyNew Democracy (NyD) -0.252710 0.076103 -3.32
## partyOther -0.499747 0.034561 -14.46
##
## Correlation matrix not shown by default, as p = 13 > 12.
## Use print(x, correlation=TRUE) or
## vcov(x) if you need it
mlm2d <- lmer(psindex.rev ~ 1 + time + factor(polinterest) + leaning + (1 | time), data=supersom, REML=FALSE)
summary(mlm2d)
## Linear mixed model fit by maximum likelihood ['lmerMod']
## Formula: psindex.rev ~ 1 + time + factor(polinterest) + leaning + (1 |
## time)
## Data: supersom
##
## AIC BIC logLik deviance df.resid
## 287518.5 287602.7 -143750.3 287500.5 85292
##
## Scaled residuals:
## Min 1Q Median 3Q Max
## -2.73119 -0.72900 -0.00856 0.77131 2.72800
##
## Random effects:
## Groups Name Variance Std.Dev.
## time (Intercept) 0.005559 0.07456
## Residual 1.701933 1.30458
## Number of obs: 85301, groups: time, 30
##
## Fixed effects:
## Estimate Std. Error t value
## (Intercept) 2.636428 0.034482 76.46
## time -0.002843 0.001681 -1.69
## factor(polinterest)Low 0.773920 0.018025 42.94
## factor(polinterest)Medium 1.381687 0.018019 76.68
## factor(polinterest)High political interest 1.746914 0.021128 82.68
## leaningLeft -0.007951 0.011469 -0.69
## leaningRight 0.057095 0.011292 5.06
##
## Correlation of Fixed Effects:
## (Intr) time fct()L fct()M f()Hpi lnngLf
## time -0.777
## fctr(plnt)L -0.418 0.006
## fctr(plnt)M -0.405 0.002 0.841
## fctr(pl)Hpi -0.337 -0.004 0.721 0.739
## leaningLeft -0.096 -0.010 -0.098 -0.172 -0.177
## leaningRght -0.090 -0.014 -0.110 -0.182 -0.169 0.554
coefplot_mlm(mlm2d, title="Public service news use", caption=NULL, sort=TRUE, nudge_y=0, nudge_x=0.2,
labels=c("(Intercept)", "Time (1–30)", "Low political interest", "Medium political interest", "High political interest","Leaning left", "Leaning right", "", ""))
## Warning: Ignoring unknown parameters: width
library(sjlabelled)
library(sjPlot)
sjt.lmer(mlm2a, mlm2b, mlm2c, p.kr=FALSE)
## Computing p-values via Wald-statistics approximation (treating t as Wald z).
## Computing p-values via Wald-statistics approximation (treating t as Wald z).
## Computing p-values via Wald-statistics approximation (treating t as Wald z).
## Warning: This function will be removed in future versions of sjmisc and
## has been moved to package 'sjlabelled'. Please use sjlabelled::get_label()
## instead.
## Warning: This function will be removed in future versions of sjmisc and
## has been moved to package 'sjlabelled'. Please use sjlabelled::get_label()
## instead.
## Warning: This function will be removed in future versions of sjmisc and
## has been moved to package 'sjlabelled'. Please use sjlabelled::get_label()
## instead.
## Warning: This function will be removed in future versions of sjmisc and
## has been moved to package 'sjlabelled'. Please use sjlabelled::get_label()
## instead.
## Warning: This function will be removed in future versions of sjmisc and
## has been moved to package 'sjlabelled'. Please use sjlabelled::get_label()
## instead.
## Warning: This function will be removed in future versions of sjmisc and
## has been moved to package 'sjlabelled'. Please use sjlabelled::get_label()
## instead.
Public service index | Public service index | Public service index | ||||||||||
B | CI | p | B | CI | p | B | CI | p | ||||
Fixed Parts | ||||||||||||
(Intercept) | 2.63 | 2.57 – 2.70 | <.001 | 3.54 | 3.49 – 3.60 | <.001 | 3.71 | 3.66 – 3.76 | <.001 | |||
UndersökningsÃ¥r | -0.00 | -0.01 – 0.00 | .086 | -0.00 | -0.00 – 0.00 | .273 | 0.00 | -0.00 – 0.00 | .223 | |||
polinterest (Low) | 0.79 | 0.76 – 0.82 | <.001 | |||||||||
polinterest (Medium) | 1.41 | 1.37 – 1.44 | <.001 | |||||||||
polinterest (High political interest) | 1.77 | 1.73 – 1.81 | <.001 | |||||||||
leaning (Left) | 0.24 | 0.22 – 0.27 | <.001 | |||||||||
leaning (Right) | 0.29 | 0.27 – 0.32 | <.001 | |||||||||
party (Left Party (V)) | -0.10 | -0.14 – -0.06 | <.001 | |||||||||
party (Centre Party (C)) | 0.20 | 0.16 – 0.25 | <.001 | |||||||||
party (Liberals (L)) | 0.11 | 0.07 – 0.15 | <.001 | |||||||||
party (Moderate Party (M)) | 0.02 | -0.00 – 0.05 | .060 | |||||||||
party (Christian Democrats (KD)) | 0.18 | 0.14 – 0.22 | <.001 | |||||||||
party (Green Party (MP)) | -0.32 | -0.35 – -0.28 | <.001 | |||||||||
party (Sweden Democrats (SD)) | -0.33 | -0.39 – -0.28 | <.001 | |||||||||
party (Feminist Initiative (FI)) | -0.30 | -0.43 – -0.17 | <.001 | |||||||||
party (Pirate Party (PP)) | -1.46 | -1.62 – -1.30 | <.001 | |||||||||
party (New Democracy (NyD)) | -0.25 | -0.40 – -0.10 | <.001 | |||||||||
party (Other) | -0.50 | -0.57 – -0.43 | <.001 | |||||||||
Random Parts | ||||||||||||
σ2 | 1.707 | 1.904 | 1.873 | |||||||||
τ00, time | 0.006 | 0.004 | 0.003 | |||||||||
Ntime | 30 | 30 | 30 | |||||||||
ICCtime | 0.003 | 0.002 | 0.002 | |||||||||
Observations | 87395 | 86051 | 81153 | |||||||||
R2 / Ω02 | .118 / .118 | .010 / .010 | .018 / .018 |
Year as random intercept + everything else as fixed slope.
library(sjPlot)
mlm3 <- lmer(psindex.rev ~ 1 + leaning + polinterest + sex + age4a + edu3 + time + (1 | time), data=supersom, REML=FALSE)
summary(mlm3)
## Linear mixed model fit by maximum likelihood ['lmerMod']
## Formula: psindex.rev ~ 1 + leaning + polinterest + sex + age4a + edu3 +
## time + (1 | time)
## Data: supersom
##
## AIC BIC logLik deviance df.resid
## 257320.9 257460.6 -128645.5 257290.9 81552
##
## Scaled residuals:
## Min 1Q Median 3Q Max
## -3.7732 -0.7192 -0.0749 0.7512 3.5876
##
## Random effects:
## Groups Name Variance Std.Dev.
## time (Intercept) 0.005162 0.07185
## Residual 1.371140 1.17096
## Number of obs: 81567, groups: time, 29
##
## Fixed effects:
## Estimate
## (Intercept) 2.140192
## leaningLeft 0.054251
## leaningRight 0.069055
## polinterestLow 0.518926
## polinterestMedium 0.949015
## polinterestHigh political interest 1.236534
## sexMale 0.145519
## age4a30-49 år 0.636826
## age4a50-64 år 1.218455
## age4a65-- 1.780546
## edu3Medel (allt över grundskola men ej högskola/universitet) 0.085248
## edu3Hög (studier/examen från högskola/universitet) 0.157586
## time -0.014551
## Std. Error
## (Intercept) 0.035961
## leaningLeft 0.010558
## leaningRight 0.010480
## polinterestLow 0.016903
## polinterestMedium 0.017216
## polinterestHigh political interest 0.020326
## sexMale 0.008378
## age4a30-49 år 0.011786
## age4a50-64 år 0.012808
## age4a65-- 0.014238
## edu3Medel (allt över grundskola men ej högskola/universitet) 0.011728
## edu3Hög (studier/examen från högskola/universitet) 0.012940
## time 0.001688
## t value
## (Intercept) 59.51
## leaningLeft 5.14
## leaningRight 6.59
## polinterestLow 30.70
## polinterestMedium 55.12
## polinterestHigh political interest 60.84
## sexMale 17.37
## age4a30-49 år 54.03
## age4a50-64 år 95.13
## age4a65-- 125.05
## edu3Medel (allt över grundskola men ej högskola/universitet) 7.27
## edu3Hög (studier/examen från högskola/universitet) 12.18
## time -8.62
##
## Correlation matrix not shown by default, as p = 13 > 12.
## Use print(x, correlation=TRUE) or
## vcov(x) if you need it
coefplot_mlm(mlm3, title="Public service news use", caption=NULL, sort=TRUE, nudge_y=0, nudge_x=0.2,
labels=c("(Intercept)", "Leaning left", "Leaning right", "Low political interest", "Medium political interest", "High political interest", "Male", "30-49 years", "50-64 years", "65 years or older", "Medium education", "High education", "Time (1–30)", "", ""))
## Warning: Ignoring unknown parameters: width
Correlation matrix.
print(mlm3, correlation=TRUE)
## Linear mixed model fit by maximum likelihood ['lmerMod']
## Formula: psindex.rev ~ 1 + leaning + polinterest + sex + age4a + edu3 +
## time + (1 | time)
## Data: supersom
## AIC BIC logLik deviance df.resid
## 257320.9 257460.6 -128645.5 257290.9 81552
## Random effects:
## Groups Name Std.Dev.
## time (Intercept) 0.07185
## Residual 1.17096
## Number of obs: 81567, groups: time, 29
## Fixed Effects:
## (Intercept)
## 2.14019
## leaningLeft
## 0.05425
## leaningRight
## 0.06906
## polinterestLow
## 0.51893
## polinterestMedium
## 0.94902
## polinterestHigh political interest
## 1.23653
## sexMale
## 0.14552
## age4a30-49 år
## 0.63683
## age4a50-64 år
## 1.21846
## age4a65--
## 1.78055
## edu3Medel (allt över grundskola men ej högskola/universitet)
## 0.08525
## edu3Hög (studier/examen från högskola/universitet)
## 0.15759
## time
## -0.01455
Add political party identity + party strength.
mlm4 <- lmer(psindex.rev ~ 1 + leaning + polinterest + party + partystrength + sex + age4a + edu3 + time + (1 | time), data=supersom, REML=FALSE)
summary(mlm4)
## Linear mixed model fit by maximum likelihood ['lmerMod']
## Formula:
## psindex.rev ~ 1 + leaning + polinterest + party + partystrength +
## sex + age4a + edu3 + time + (1 | time)
## Data: supersom
##
## AIC BIC logLik deviance df.resid
## 234816.6 235074.8 -117380.3 234760.6 74670
##
## Scaled residuals:
## Min 1Q Median 3Q Max
## -3.7590 -0.7184 -0.0743 0.7526 3.7371
##
## Random effects:
## Groups Name Variance Std.Dev.
## time (Intercept) 0.004758 0.06898
## Residual 1.355359 1.16420
## Number of obs: 74698, groups: time, 29
##
## Fixed effects:
## Estimate
## (Intercept) 2.128899
## leaningLeft 0.057692
## leaningRight 0.045924
## polinterestLow 0.505401
## polinterestMedium 0.927140
## polinterestHigh political interest 1.225968
## partyLeft Party (V) -0.039004
## partyCentre Party (C) 0.167363
## partyLiberals (L) 0.082587
## partyModerate Party (M) -0.023523
## partyChristian Democrats (KD) 0.038053
## partyGreen Party (MP) -0.084580
## partySweden Democrats (SD) -0.185225
## partyFeminist Initiative (FI) -0.110301
## partyPirate Party (PP) -0.634575
## partyNew Democracy (NyD) 0.063067
## partyOther -0.168087
## partystrengthWeak party supporter 0.038239
## partystrengthStrong party supporter -0.003369
## sexMale 0.156976
## age4a30-49 år 0.616969
## age4a50-64 år 1.191806
## age4a65-- 1.739679
## edu3Medel (allt över grundskola men ej högskola/universitet) 0.090296
## edu3Hög (studier/examen från högskola/universitet) 0.161666
## time -0.012355
## Std. Error
## (Intercept) 0.037122
## leaningLeft 0.012839
## leaningRight 0.013399
## polinterestLow 0.018553
## polinterestMedium 0.018878
## polinterestHigh political interest 0.022060
## partyLeft Party (V) 0.017533
## partyCentre Party (C) 0.020914
## partyLiberals (L) 0.019481
## partyModerate Party (M) 0.016541
## partyChristian Democrats (KD) 0.022057
## partyGreen Party (MP) 0.017331
## partySweden Democrats (SD) 0.025069
## partyFeminist Initiative (FI) 0.056629
## partyPirate Party (PP) 0.071132
## partyNew Democracy (NyD) 0.068928
## partyOther 0.033715
## partystrengthWeak party supporter 0.009777
## partystrengthStrong party supporter 0.013252
## sexMale 0.008773
## age4a30-49 år 0.012351
## age4a50-64 år 0.013436
## age4a65-- 0.015004
## edu3Medel (allt över grundskola men ej högskola/universitet) 0.012302
## edu3Hög (studier/examen från högskola/universitet) 0.013747
## time 0.001643
## t value
## (Intercept) 57.35
## leaningLeft 4.49
## leaningRight 3.43
## polinterestLow 27.24
## polinterestMedium 49.11
## polinterestHigh political interest 55.57
## partyLeft Party (V) -2.22
## partyCentre Party (C) 8.00
## partyLiberals (L) 4.24
## partyModerate Party (M) -1.42
## partyChristian Democrats (KD) 1.73
## partyGreen Party (MP) -4.88
## partySweden Democrats (SD) -7.39
## partyFeminist Initiative (FI) -1.95
## partyPirate Party (PP) -8.92
## partyNew Democracy (NyD) 0.91
## partyOther -4.99
## partystrengthWeak party supporter 3.91
## partystrengthStrong party supporter -0.25
## sexMale 17.89
## age4a30-49 år 49.95
## age4a50-64 år 88.70
## age4a65-- 115.95
## edu3Medel (allt över grundskola men ej högskola/universitet) 7.34
## edu3Hög (studier/examen från högskola/universitet) 11.76
## time -7.52
##
## Correlation matrix not shown by default, as p = 26 > 12.
## Use print(x, correlation=TRUE) or
## vcov(x) if you need it
coefplot_mlm(mlm4, title="Public service news use", intercept=FALSE, caption=NULL, sort=TRUE, nudge_y=0, nudge_x=0.3,
labels=c("(Intercept)", "Leaning left", "Leaning right", "Low political interest", "Medium political interest", "High political interest", "Left Party (V)", "Centre Party (C)", "Liberals (L)", "Moderate Party (M)", "Christian Democrats (KD)", "Green Party (MP)", "Sweden Democrats (SD)", "Feminist Initiative (FI)", "Pirate Party (PP)", "New Democracy (NyD)", "Other party", "Weak party strength", "Strong party strength", "Male", "30–49 years", "50–64 years", "65 years or older", "Medium education", "High education", "Time (1–30)", "", ""))
## Warning: Ignoring unknown parameters: width
Plot of random effects.
sjp.lmer(mlm4)
## Plotting random effects...
Correlation matrix of fixed effects.
sjp.lmer(mlm4, type = "fe.cor")
## Computing correlation using pearson-method with listwise-deletion...
qq-plot of random effects.
sjp.lmer(mlm4, type = "re.qq")
## Testing for normal distribution. Dots should be plotted along the line.
Add social networking site use + internet + internet news use.
mlm5 <- lmer(psindex.rev ~ 1 + time + sex + age4a + edu3 + polinterest + leaning + as.numeric(partystrength) + party + sns + internet + internetnews + trust.svt + trust.sr + (1 | time), data=supersom, REML=FALSE)
summary(mlm5)
## Linear mixed model fit by maximum likelihood ['lmerMod']
## Formula:
## psindex.rev ~ 1 + time + sex + age4a + edu3 + polinterest + leaning +
## as.numeric(partystrength) + party + sns + internet + internetnews +
## trust.svt + trust.sr + (1 | time)
## Data: supersom
##
## AIC BIC logLik deviance df.resid
## 11549.3 11755.2 -5741.6 11483.3 3755
##
## Scaled residuals:
## Min 1Q Median 3Q Max
## -3.4324 -0.7150 -0.0574 0.7134 3.5354
##
## Random effects:
## Groups Name Variance Std.Dev.
## time (Intercept) 1.048e-17 3.238e-09
## Residual 1.214e+00 1.102e+00
## Number of obs: 3788, groups: time, 4
##
## Fixed effects:
## Estimate
## (Intercept) 3.574576
## time -0.034688
## sexMale 0.048435
## age4a30-49 år 0.698895
## age4a50-64 år 1.360682
## age4a65-- 1.800277
## edu3Medel (allt över grundskola men ej högskola/universitet) 0.054175
## edu3Hög (studier/examen från högskola/universitet) 0.054741
## polinterestLow 0.165174
## polinterestMedium 0.619175
## polinterestHigh political interest 0.911360
## leaningLeft -0.098145
## leaningRight 0.006154
## as.numeric(partystrength) 0.021152
## partyLeft Party (V) 0.053214
## partyCentre Party (C) 0.009488
## partyLiberals (L) 0.001841
## partyModerate Party (M) -0.093322
## partyChristian Democrats (KD) -0.175104
## partyGreen Party (MP) -0.080703
## partySweden Democrats (SD) -0.123942
## partyFeminist Initiative (FI) 0.005009
## partyPirate Party (PP) -0.420252
## partyOther -0.359256
## sns -0.044574
## internet -0.057502
## internetnews 0.029489
## trust.svtNeither low nor high -0.117988
## trust.svtLow trust -0.031076
## trust.srNeither low nor high -0.391161
## trust.srLow trust -0.620942
## Std. Error
## (Intercept) 0.466663
## time 0.016361
## sexMale 0.037837
## age4a30-49 år 0.056108
## age4a50-64 år 0.061403
## age4a65-- 0.072492
## edu3Medel (allt över grundskola men ej högskola/universitet) 0.061973
## edu3Hög (studier/examen från högskola/universitet) 0.066750
## polinterestLow 0.090027
## polinterestMedium 0.091324
## polinterestHigh political interest 0.102140
## leaningLeft 0.058517
## leaningRight 0.056478
## as.numeric(partystrength) 0.027235
## partyLeft Party (V) 0.082037
## partyCentre Party (C) 0.100894
## partyLiberals (L) 0.089323
## partyModerate Party (M) 0.069152
## partyChristian Democrats (KD) 0.113260
## partyGreen Party (MP) 0.065418
## partySweden Democrats (SD) 0.093459
## partyFeminist Initiative (FI) 0.257026
## partyPirate Party (PP) 0.248583
## partyOther 0.207212
## sns 0.008267
## internet 0.035424
## internetnews 0.011137
## trust.svtNeither low nor high 0.072108
## trust.svtLow trust 0.152184
## trust.srNeither low nor high 0.069836
## trust.srLow trust 0.146988
## t value
## (Intercept) 7.660
## time -2.120
## sexMale 1.280
## age4a30-49 år 12.456
## age4a50-64 år 22.160
## age4a65-- 24.834
## edu3Medel (allt över grundskola men ej högskola/universitet) 0.874
## edu3Hög (studier/examen från högskola/universitet) 0.820
## polinterestLow 1.835
## polinterestMedium 6.780
## polinterestHigh political interest 8.923
## leaningLeft -1.677
## leaningRight 0.109
## as.numeric(partystrength) 0.777
## partyLeft Party (V) 0.649
## partyCentre Party (C) 0.094
## partyLiberals (L) 0.021
## partyModerate Party (M) -1.350
## partyChristian Democrats (KD) -1.546
## partyGreen Party (MP) -1.234
## partySweden Democrats (SD) -1.326
## partyFeminist Initiative (FI) 0.019
## partyPirate Party (PP) -1.691
## partyOther -1.734
## sns -5.392
## internet -1.623
## internetnews 2.648
## trust.svtNeither low nor high -1.636
## trust.svtLow trust -0.204
## trust.srNeither low nor high -5.601
## trust.srLow trust -4.224
##
## Correlation matrix not shown by default, as p = 31 > 12.
## Use print(x, correlation=TRUE) or
## vcov(x) if you need it
coefplot_mlm(mlm5, title="Public service news use", intercept=FALSE, caption=NULL, sort=TRUE, nudge_y=0, nudge_x=0.5)
## Warning: Ignoring unknown parameters: width
#labels=c("(Intercept)", "Male", "30–49 years", "50–64 years", "65 years or older", "Medium education", "High education", "Low political interest", "Medium political interest", "High political interest", "Leaning left", "Leaning right", "Party ID strength (1–3)", "Left Party (V)", "Centre Party (C)", "Liberals (L)", "Moderate Party (M)", "Christian Democrats (KD)", "Green Party (MP)", "Sweden Democrats (SD)", "Feminist Initiative (FI)", "Pirate Party (PP)", "New Democracy (NyD)", "Other party", "", ""))
sjt.lmer(mlm3, mlm4, p.kr = FALSE
#showHeaderStrings = TRUE,
#stringB = "B",
#stringCI = "95 % C.I.",
#stringP = "p"
#stringDependentVariables = "Response",
#stringPredictors = "Coefficients",
#stringIntercept = "Konstante",
#separateConfColumn = FALSE,
#showStdBeta = FALSE,
#pvaluesAsNumbers = FALSE
)
## Computing p-values via Wald-statistics approximation (treating t as Wald z).
## Computing p-values via Wald-statistics approximation (treating t as Wald z).
## Warning: This function will be removed in future versions of sjmisc and
## has been moved to package 'sjlabelled'. Please use sjlabelled::get_label()
## instead.
## Warning: This function will be removed in future versions of sjmisc and
## has been moved to package 'sjlabelled'. Please use sjlabelled::get_label()
## instead.
## Warning: This function will be removed in future versions of sjmisc and
## has been moved to package 'sjlabelled'. Please use sjlabelled::get_label()
## instead.
## Warning: This function will be removed in future versions of sjmisc and
## has been moved to package 'sjlabelled'. Please use sjlabelled::get_label()
## instead.
Public service index | Public service index | |||||||
B | CI | p | B | CI | p | |||
Fixed Parts | ||||||||
(Intercept) | 2.14 | 2.07 – 2.21 | <.001 | 2.13 | 2.06 – 2.20 | <.001 | ||
leaning (Left) | 0.05 | 0.03 – 0.07 | <.001 | 0.06 | 0.03 – 0.08 | <.001 | ||
leaning (Right) | 0.07 | 0.05 – 0.09 | <.001 | 0.05 | 0.02 – 0.07 | <.001 | ||
polinterest (Low) | 0.52 | 0.49 – 0.55 | <.001 | 0.51 | 0.47 – 0.54 | <.001 | ||
polinterest (Medium) | 0.95 | 0.92 – 0.98 | <.001 | 0.93 | 0.89 – 0.96 | <.001 | ||
polinterest (High political interest) | 1.24 | 1.20 – 1.28 | <.001 | 1.23 | 1.18 – 1.27 | <.001 | ||
sex (Male) | 0.15 | 0.13 – 0.16 | <.001 | 0.16 | 0.14 – 0.17 | <.001 | ||
age4a (30-49 Ã¥r) | 0.64 | 0.61 – 0.66 | <.001 | 0.62 | 0.59 – 0.64 | <.001 | ||
age4a (50-64 Ã¥r) | 1.22 | 1.19 – 1.24 | <.001 | 1.19 | 1.17 – 1.22 | <.001 | ||
age4a (65--) | 1.78 | 1.75 – 1.81 | <.001 | 1.74 | 1.71 – 1.77 | <.001 | ||
edu3 (Medel (allt över grundskola men ej högskola/universitet)) | 0.09 | 0.06 – 0.11 | <.001 | 0.09 | 0.07 – 0.11 | <.001 | ||
edu3 (Hög (studier/examen frÃ¥n högskola/universitet)) | 0.16 | 0.13 – 0.18 | <.001 | 0.16 | 0.13 – 0.19 | <.001 | ||
UndersökningsÃ¥r | -0.01 | -0.02 – -0.01 | <.001 | -0.01 | -0.02 – -0.01 | <.001 | ||
party (Left Party (V)) | -0.04 | -0.07 – -0.00 | .026 | |||||
party (Centre Party (C)) | 0.17 | 0.13 – 0.21 | <.001 | |||||
party (Liberals (L)) | 0.08 | 0.04 – 0.12 | <.001 | |||||
party (Moderate Party (M)) | -0.02 | -0.06 – 0.01 | .155 | |||||
party (Christian Democrats (KD)) | 0.04 | -0.01 – 0.08 | .084 | |||||
party (Green Party (MP)) | -0.08 | -0.12 – -0.05 | <.001 | |||||
party (Sweden Democrats (SD)) | -0.19 | -0.23 – -0.14 | <.001 | |||||
party (Feminist Initiative (FI)) | -0.11 | -0.22 – 0.00 | .051 | |||||
party (Pirate Party (PP)) | -0.63 | -0.77 – -0.50 | <.001 | |||||
party (New Democracy (NyD)) | 0.06 | -0.07 – 0.20 | .360 | |||||
party (Other) | -0.17 | -0.23 – -0.10 | <.001 | |||||
partystrength (Weak party supporter) | 0.04 | 0.02 – 0.06 | <.001 | |||||
partystrength (Strong party supporter) | -0.00 | -0.03 – 0.02 | .799 | |||||
Random Parts | ||||||||
σ2 | 1.371 | 1.355 | ||||||
τ00, time | 0.005 | 0.005 | ||||||
Ntime | 29 | 29 | ||||||
ICCtime | 0.004 | 0.003 | ||||||
Observations | 81567 | 74698 | ||||||
R2 / Ω02 | .286 / .286 | .285 / .285 |
Empty model: DV + year as random intercept.
DV + year as fixed effect & random intercept.
mlm6a <- lmer(affect.inparty ~ 1 + (1 | time), data=supersom, REML=FALSE)
mlm6b <- lmer(affect.inparty ~ 1 + time + (1 | time), data=supersom, REML=FALSE)
anova(mlm6a, mlm6b)
## Data: supersom
## Models:
## mlm6a: affect.inparty ~ 1 + (1 | time)
## mlm6b: affect.inparty ~ 1 + time + (1 | time)
## Df AIC BIC logLik deviance Chisq Chi Df Pr(>Chisq)
## mlm6a 3 159081 159107 -79538 159075
## mlm6b 4 159082 159117 -79537 159074 1.0854 1 0.2975
In-party affect.
mlm7a <- lmer(affect.inparty ~ 1 + psuse + time + (1 | time), data=supersom, REML=FALSE)
summary(mlm7a)
## Linear mixed model fit by maximum likelihood ['lmerMod']
## Formula: affect.inparty ~ 1 + psuse + time + (1 | time)
## Data: supersom
##
## AIC BIC logLik deviance df.resid
## 155038.3 155081.4 -77514.1 155028.3 41011
##
## Scaled residuals:
## Min 1Q Median 3Q Max
## -5.3780 -0.4957 0.1632 0.7422 1.5024
##
## Random effects:
## Groups Name Variance Std.Dev.
## time (Intercept) 0.06414 0.2533
## Residual 2.55799 1.5994
## Number of obs: 41016, groups: time, 30
##
## Fixed effects:
## Estimate Std. Error t value
## (Intercept) 2.971893 0.107825 27.562
## psusePS news at least 5 days/week 0.141814 0.048791 2.907
## time 0.006281 0.005424 1.158
##
## Correlation of Fixed Effects:
## (Intr) pnal5d
## pssPSnal5d/ -0.451
## time -0.786 0.015
coefplot_mlm(mlm7a, title="In-party affect", intercept=FALSE, caption=NULL, sort=TRUE, nudge_y=0, nudge_x=0.3)
## Warning: Ignoring unknown parameters: width
mlm7b <- lmer(affect.inparty ~ 1 + psuse + leaning + polinterest + party + partystrength + edu3 + age4a + sex + time + (1 | time), data=supersom, REML=FALSE)
summary(mlm7b)
## Linear mixed model fit by maximum likelihood ['lmerMod']
## Formula: affect.inparty ~ 1 + psuse + leaning + polinterest + party +
## partystrength + edu3 + age4a + sex + time + (1 | time)
## Data: supersom
##
## AIC BIC logLik deviance df.resid
## 126123.4 126327.8 -63037.7 126075.4 36945
##
## Scaled residuals:
## Min 1Q Median 3Q Max
## -7.4202 -0.4578 0.1557 0.5895 2.9640
##
## Random effects:
## Groups Name Variance Std.Dev.
## time (Intercept) 0.02967 0.1722
## Residual 1.76824 1.3298
## Number of obs: 36969, groups: time, 29
##
## Fixed effects:
## Estimate
## (Intercept) 1.555523
## psusePS news at least 5 days/week 0.016228
## leaningLeft 0.562125
## leaningRight 0.596942
## polinterestLow 0.267993
## polinterestMedium 0.409356
## polinterestHigh political interest 0.518405
## partyLeft Party (V) 0.225695
## partyCentre Party (C) 0.328038
## partyLiberals (L) 0.188059
## partyModerate Party (M) 0.204774
## partyChristian Democrats (KD) 0.406615
## partyGreen Party (MP) 0.423975
## partystrengthWeak party supporter 0.978599
## partystrengthStrong party supporter 1.998718
## edu3Medel (allt över grundskola men ej högskola/universitet) -0.023337
## edu3Hög (studier/examen från högskola/universitet) -0.001279
## age4a30-49 år -0.210280
## age4a50-64 år -0.250549
## age4a65-- -0.222227
## sexMale -0.189532
## time 0.011754
## Std. Error
## (Intercept) 0.088320
## psusePS news at least 5 days/week 0.043596
## leaningLeft 0.020506
## leaningRight 0.022156
## polinterestLow 0.032176
## polinterestMedium 0.032586
## polinterestHigh political interest 0.037998
## partyLeft Party (V) 0.027418
## partyCentre Party (C) 0.032026
## partyLiberals (L) 0.030112
## partyModerate Party (M) 0.026667
## partyChristian Democrats (KD) 0.034636
## partyGreen Party (MP) 0.028670
## partystrengthWeak party supporter 0.016100
## partystrengthStrong party supporter 0.021376
## edu3Medel (allt över grundskola men ej högskola/universitet) 0.019031
## edu3Hög (studier/examen från högskola/universitet) 0.021880
## age4a30-49 år 0.020043
## age4a50-64 år 0.022075
## age4a65-- 0.024697
## sexMale 0.014182
## time 0.003900
## t value
## (Intercept) 17.61
## psusePS news at least 5 days/week 0.37
## leaningLeft 27.41
## leaningRight 26.94
## polinterestLow 8.33
## polinterestMedium 12.56
## polinterestHigh political interest 13.64
## partyLeft Party (V) 8.23
## partyCentre Party (C) 10.24
## partyLiberals (L) 6.25
## partyModerate Party (M) 7.68
## partyChristian Democrats (KD) 11.74
## partyGreen Party (MP) 14.79
## partystrengthWeak party supporter 60.78
## partystrengthStrong party supporter 93.50
## edu3Medel (allt över grundskola men ej högskola/universitet) -1.23
## edu3Hög (studier/examen från högskola/universitet) -0.06
## age4a30-49 år -10.49
## age4a50-64 år -11.35
## age4a65-- -9.00
## sexMale -13.36
## time 3.01
##
## Correlation matrix not shown by default, as p = 22 > 12.
## Use print(x, correlation=TRUE) or
## vcov(x) if you need it
coefplot_mlm(mlm7b, title="In-party affect", intercept=FALSE, caption=NULL, sort=TRUE, nudge_y=0, nudge_x=0.2)
## Warning: Ignoring unknown parameters: width
Out-party affect.
mlm8a <- lmer(affect.outparty ~ 1 + psuse + time + (1 | time), data=supersom, REML=FALSE)
summary(mlm8a)
## Linear mixed model fit by maximum likelihood ['lmerMod']
## Formula: affect.outparty ~ 1 + psuse + time + (1 | time)
## Data: supersom
##
## AIC BIC logLik deviance df.resid
## 113300.3 113343.4 -56645.1 113290.3 41011
##
## Scaled residuals:
## Min 1Q Median 3Q Max
## -3.9574 -0.6279 0.0870 0.6709 5.0644
##
## Random effects:
## Groups Name Variance Std.Dev.
## time (Intercept) 0.01813 0.1347
## Residual 0.92477 0.9617
## Number of obs: 41016, groups: time, 30
##
## Fixed effects:
## Estimate Std. Error t value
## (Intercept) -0.548222 0.059112 -9.274
## psusePS news at least 5 days/week -0.029706 0.029337 -1.013
## time -0.004713 0.002896 -1.627
##
## Correlation of Fixed Effects:
## (Intr) pnal5d
## pssPSnal5d/ -0.495
## time -0.767 0.016
coefplot_mlm(mlm8a, title="Out-party affect", intercept=FALSE, caption=NULL, sort=TRUE, nudge_y=0, nudge_x=0.3)
## Warning: Ignoring unknown parameters: width
mlm8b <- lmer(affect.outparty ~ 1 + psuse + leaning + polinterest + party + partystrength + edu3 + age4a + sex + time + (1 | time), data=supersom, REML=FALSE)
summary(mlm8b)
## Linear mixed model fit by maximum likelihood ['lmerMod']
## Formula: affect.outparty ~ 1 + psuse + leaning + polinterest + party +
## partystrength + edu3 + age4a + sex + time + (1 | time)
## Data: supersom
##
## AIC BIC logLik deviance df.resid
## 99252.2 99456.6 -49602.1 99204.2 36945
##
## Scaled residuals:
## Min 1Q Median 3Q Max
## -4.2827 -0.6043 0.0747 0.6480 5.7315
##
## Random effects:
## Groups Name Variance Std.Dev.
## time (Intercept) 0.02016 0.1420
## Residual 0.85460 0.9244
## Number of obs: 36969, groups: time, 29
##
## Fixed effects:
## Estimate
## (Intercept) -0.377393
## psusePS news at least 5 days/week 0.035751
## leaningLeft -0.170996
## leaningRight -0.061757
## polinterestLow 0.083072
## polinterestMedium 0.013499
## polinterestHigh political interest -0.151339
## partyLeft Party (V) -0.186637
## partyCentre Party (C) 0.200278
## partyLiberals (L) 0.188838
## partyModerate Party (M) -0.082851
## partyChristian Democrats (KD) 0.208417
## partyGreen Party (MP) 0.076969
## partystrengthWeak party supporter 0.026964
## partystrengthStrong party supporter -0.188584
## edu3Medel (allt över grundskola men ej högskola/universitet) 0.010291
## edu3Hög (studier/examen från högskola/universitet) -0.005040
## age4a30-49 år -0.049480
## age4a50-64 år -0.133628
## age4a65-- -0.046609
## sexMale -0.236725
## time -0.003987
## Std. Error
## (Intercept) 0.068492
## psusePS news at least 5 days/week 0.030308
## leaningLeft 0.014256
## leaningRight 0.015403
## polinterestLow 0.022369
## polinterestMedium 0.022654
## polinterestHigh political interest 0.026416
## partyLeft Party (V) 0.019063
## partyCentre Party (C) 0.022265
## partyLiberals (L) 0.020935
## partyModerate Party (M) 0.018540
## partyChristian Democrats (KD) 0.024081
## partyGreen Party (MP) 0.019933
## partystrengthWeak party supporter 0.011194
## partystrengthStrong party supporter 0.014862
## edu3Medel (allt över grundskola men ej högskola/universitet) 0.013231
## edu3Hög (studier/examen från högskola/universitet) 0.015211
## age4a30-49 år 0.013934
## age4a50-64 år 0.015347
## age4a65-- 0.017169
## sexMale 0.009859
## time 0.003190
## t value
## (Intercept) -5.510
## psusePS news at least 5 days/week 1.180
## leaningLeft -11.995
## leaningRight -4.009
## polinterestLow 3.714
## polinterestMedium 0.596
## polinterestHigh political interest -5.729
## partyLeft Party (V) -9.790
## partyCentre Party (C) 8.995
## partyLiberals (L) 9.020
## partyModerate Party (M) -4.469
## partyChristian Democrats (KD) 8.655
## partyGreen Party (MP) 3.861
## partystrengthWeak party supporter 2.409
## partystrengthStrong party supporter -12.689
## edu3Medel (allt över grundskola men ej högskola/universitet) 0.778
## edu3Hög (studier/examen från högskola/universitet) -0.331
## age4a30-49 år -3.551
## age4a50-64 år -8.707
## age4a65-- -2.715
## sexMale -24.010
## time -1.250
##
## Correlation matrix not shown by default, as p = 22 > 12.
## Use print(x, correlation=TRUE) or
## vcov(x) if you need it
coefplot_mlm(mlm8b, title="Out-party affect", intercept=FALSE, caption=NULL, sort=TRUE, nudge_y=0, nudge_x=0.1)
## Warning: Ignoring unknown parameters: width
In-party + out-party.
sjt.lmer(mlm7b, mlm8b, p.kr = FALSE)
## Computing p-values via Wald-statistics approximation (treating t as Wald z).
## Computing p-values via Wald-statistics approximation (treating t as Wald z).
## Warning: This function will be removed in future versions of sjmisc and
## has been moved to package 'sjlabelled'. Please use sjlabelled::get_label()
## instead.
## Warning: This function will be removed in future versions of sjmisc and
## has been moved to package 'sjlabelled'. Please use sjlabelled::get_label()
## instead.
## Warning: This function will be removed in future versions of sjmisc and
## has been moved to package 'sjlabelled'. Please use sjlabelled::get_label()
## instead.
## Warning: This function will be removed in future versions of sjmisc and
## has been moved to package 'sjlabelled'. Please use sjlabelled::get_label()
## instead.
affect.inparty | affect.outparty | |||||||
B | CI | p | B | CI | p | |||
Fixed Parts | ||||||||
(Intercept) | 1.56 | 1.38 – 1.73 | <.001 | -0.38 | -0.51 – -0.24 | <.001 | ||
psuse (PS news at least 5 days/week) | 0.02 | -0.07 – 0.10 | .710 | 0.04 | -0.02 – 0.10 | .238 | ||
leaning (Left) | 0.56 | 0.52 – 0.60 | <.001 | -0.17 | -0.20 – -0.14 | <.001 | ||
leaning (Right) | 0.60 | 0.55 – 0.64 | <.001 | -0.06 | -0.09 – -0.03 | <.001 | ||
polinterest (Low) | 0.27 | 0.20 – 0.33 | <.001 | 0.08 | 0.04 – 0.13 | <.001 | ||
polinterest (Medium) | 0.41 | 0.35 – 0.47 | <.001 | 0.01 | -0.03 – 0.06 | .551 | ||
polinterest (High political interest) | 0.52 | 0.44 – 0.59 | <.001 | -0.15 | -0.20 – -0.10 | <.001 | ||
party (Left Party (V)) | 0.23 | 0.17 – 0.28 | <.001 | -0.19 | -0.22 – -0.15 | <.001 | ||
party (Centre Party (C)) | 0.33 | 0.27 – 0.39 | <.001 | 0.20 | 0.16 – 0.24 | <.001 | ||
party (Liberals (L)) | 0.19 | 0.13 – 0.25 | <.001 | 0.19 | 0.15 – 0.23 | <.001 | ||
party (Moderate Party (M)) | 0.20 | 0.15 – 0.26 | <.001 | -0.08 | -0.12 – -0.05 | <.001 | ||
party (Christian Democrats (KD)) | 0.41 | 0.34 – 0.47 | <.001 | 0.21 | 0.16 – 0.26 | <.001 | ||
party (Green Party (MP)) | 0.42 | 0.37 – 0.48 | <.001 | 0.08 | 0.04 – 0.12 | <.001 | ||
partystrength (Weak party supporter) | 0.98 | 0.95 – 1.01 | <.001 | 0.03 | 0.01 – 0.05 | .016 | ||
partystrength (Strong party supporter) | 2.00 | 1.96 – 2.04 | <.001 | -0.19 | -0.22 – -0.16 | <.001 | ||
edu3 (Medel (allt över grundskola men ej högskola/universitet)) | -0.02 | -0.06 – 0.01 | .220 | 0.01 | -0.02 – 0.04 | .437 | ||
edu3 (Hög (studier/examen frÃ¥n högskola/universitet)) | -0.00 | -0.04 – 0.04 | .953 | -0.01 | -0.03 – 0.02 | .740 | ||
age4a (30-49 Ã¥r) | -0.21 | -0.25 – -0.17 | <.001 | -0.05 | -0.08 – -0.02 | <.001 | ||
age4a (50-64 Ã¥r) | -0.25 | -0.29 – -0.21 | <.001 | -0.13 | -0.16 – -0.10 | <.001 | ||
age4a (65--) | -0.22 | -0.27 – -0.17 | <.001 | -0.05 | -0.08 – -0.01 | .007 | ||
sex (Male) | -0.19 | -0.22 – -0.16 | <.001 | -0.24 | -0.26 – -0.22 | <.001 | ||
UndersökningsÃ¥r | 0.01 | 0.00 – 0.02 | .003 | -0.00 | -0.01 – 0.00 | .211 | ||
Random Parts | ||||||||
σ2 | 1.768 | 0.855 | ||||||
τ00, time | 0.030 | 0.020 | ||||||
Ntime | 29 | 29 | ||||||
ICCtime | 0.016 | 0.023 | ||||||
Observations | 36969 | 36969 | ||||||
R2 / Ω02 | .306 / .306 | .089 / .089 |
Positions on three issues:
db900i
)ed900a
)da11c
)# Job: recode into 5-point scale -2 to +2 (bad to good)
supersom$jobmarket.num <- as.integer(supersom$db900i %>% recode("1"="2", "2"="1", "3"="0", "4"="-1", "5"="-2"))
mlm9a <- lmer(jobmarket.num ~ 1 + psuse + leaning + polinterest + party + partystrength + edu3 + age4a + sex + time + (1 | time), data=supersom, REML=FALSE)
summary(mlm9a)
## Linear mixed model fit by maximum likelihood ['lmerMod']
## Formula:
## jobmarket.num ~ 1 + psuse + leaning + polinterest + party + partystrength +
## edu3 + age4a + sex + time + (1 | time)
## Data: supersom
##
## AIC BIC logLik deviance df.resid
## 33493.7 33700.1 -16718.9 33437.7 11720
##
## Scaled residuals:
## Min 1Q Median 3Q Max
## -3.5509 -0.6968 0.0590 0.7678 2.7448
##
## Random effects:
## Groups Name Variance Std.Dev.
## time (Intercept) 0.0188 0.1371
## Residual 1.0059 1.0030
## Number of obs: 11748, groups: time, 9
##
## Fixed effects:
## Estimate
## (Intercept) 0.807621
## psusePS news at least 5 days/week 0.075538
## leaningLeft 0.212860
## leaningRight -0.409347
## polinterestLow -0.211864
## polinterestMedium -0.256861
## polinterestHigh political interest -0.214562
## partyLeft Party (V) 0.166297
## partyCentre Party (C) -0.491674
## partyLiberals (L) -0.421887
## partyModerate Party (M) -0.625917
## partyChristian Democrats (KD) -0.500302
## partyGreen Party (MP) -0.250203
## partySweden Democrats (SD) -0.337314
## partyFeminist Initiative (FI) 0.001846
## partyPirate Party (PP) -0.066745
## partyOther -0.212364
## partystrengthWeak party supporter 0.058057
## partystrengthStrong party supporter 0.106074
## edu3Medel (allt över grundskola men ej högskola/universitet) -0.112808
## edu3Hög (studier/examen från högskola/universitet) -0.328960
## age4a30-49 år 0.154320
## age4a50-64 år 0.318644
## age4a65-- 0.231326
## sexMale -0.121419
## time 0.005592
## Std. Error
## (Intercept) 0.475523
## psusePS news at least 5 days/week 0.043004
## leaningLeft 0.028304
## leaningRight 0.029512
## polinterestLow 0.041142
## polinterestMedium 0.041807
## polinterestHigh political interest 0.048233
## partyLeft Party (V) 0.043846
## partyCentre Party (C) 0.049920
## partyLiberals (L) 0.044998
## partyModerate Party (M) 0.035946
## partyChristian Democrats (KD) 0.054200
## partyGreen Party (MP) 0.035017
## partySweden Democrats (SD) 0.043663
## partyFeminist Initiative (FI) 0.101788
## partyPirate Party (PP) 0.107552
## partyOther 0.088171
## partystrengthWeak party supporter 0.021345
## partystrengthStrong party supporter 0.028609
## edu3Medel (allt över grundskola men ej högskola/universitet) 0.028276
## edu3Hög (studier/examen från högskola/universitet) 0.031037
## age4a30-49 år 0.029734
## age4a50-64 år 0.030868
## age4a65-- 0.033195
## sexMale 0.019135
## time 0.018074
## t value
## (Intercept) 1.698
## psusePS news at least 5 days/week 1.757
## leaningLeft 7.521
## leaningRight -13.870
## polinterestLow -5.150
## polinterestMedium -6.144
## polinterestHigh political interest -4.448
## partyLeft Party (V) 3.793
## partyCentre Party (C) -9.849
## partyLiberals (L) -9.376
## partyModerate Party (M) -17.413
## partyChristian Democrats (KD) -9.231
## partyGreen Party (MP) -7.145
## partySweden Democrats (SD) -7.725
## partyFeminist Initiative (FI) 0.018
## partyPirate Party (PP) -0.621
## partyOther -2.409
## partystrengthWeak party supporter 2.720
## partystrengthStrong party supporter 3.708
## edu3Medel (allt över grundskola men ej högskola/universitet) -3.989
## edu3Hög (studier/examen från högskola/universitet) -10.599
## age4a30-49 år 5.190
## age4a50-64 år 10.323
## age4a65-- 6.969
## sexMale -6.345
## time 0.309
##
## Correlation matrix not shown by default, as p = 26 > 12.
## Use print(x, correlation=TRUE) or
## vcov(x) if you need it
coefplot_mlm(mlm9a, title="Raise unemployment insurance", intercept=FALSE, caption=NULL, sort=TRUE, nudge_y=0, nudge_x=0.3)
## Warning: Ignoring unknown parameters: width
# Healthcare: recode into 5-point scale -2 to +2 (bad to good)
supersom$privatehealthcare.num <- as.integer(supersom$ed900a %>% recode("1"="2", "2"="1", "3"="0", "4"="-1", "5"="-2"))
mlm9b <- lmer(privatehealthcare.num ~ 1 + psuse + leaning + polinterest + party + partystrength + age4a + edu3 + sex + time + (1 | time), data=supersom, REML=FALSE)
summary(mlm9b)
## Linear mixed model fit by maximum likelihood ['lmerMod']
## Formula:
## privatehealthcare.num ~ 1 + psuse + leaning + polinterest + party +
## partystrength + age4a + edu3 + sex + time + (1 | time)
## Data: supersom
##
## AIC BIC logLik deviance df.resid
## 157210.2 157467.9 -78576.1 157152.2 53518
##
## Scaled residuals:
## Min 1Q Median 3Q Max
## -3.3083 -0.7537 -0.0071 0.6765 3.3965
##
## Random effects:
## Groups Name Variance Std.Dev.
## time (Intercept) 0.05137 0.2266
## Residual 1.09927 1.0485
## Number of obs: 53547, groups: time, 28
##
## Fixed effects:
## Estimate
## (Intercept) -0.035833
## psusePS news at least 5 days/week -0.063828
## leaningLeft -0.471339
## leaningRight 0.423148
## polinterestLow -0.118785
## polinterestMedium -0.195474
## polinterestHigh political interest -0.171690
## partyLeft Party (V) -0.151696
## partyCentre Party (C) 0.293112
## partyLiberals (L) 0.450753
## partyModerate Party (M) 0.641790
## partyChristian Democrats (KD) 0.429116
## partyGreen Party (MP) 0.140968
## partySweden Democrats (SD) 0.174678
## partyFeminist Initiative (FI) -0.199666
## partyPirate Party (PP) 0.123204
## partyNew Democracy (NyD) 0.457260
## partyOther 0.180391
## partystrengthWeak party supporter 0.092560
## partystrengthStrong party supporter 0.093354
## age4a30-49 år -0.057115
## age4a50-64 år -0.081691
## age4a65-- -0.134863
## edu3Medel (allt över grundskola men ej högskola/universitet) 0.064260
## edu3Hög (studier/examen från högskola/universitet) 0.133488
## sexMale -0.057926
## time -0.017892
## Std. Error
## (Intercept) 0.103463
## psusePS news at least 5 days/week 0.025985
## leaningLeft 0.013431
## leaningRight 0.014262
## polinterestLow 0.019947
## polinterestMedium 0.020283
## polinterestHigh political interest 0.023857
## partyLeft Party (V) 0.018102
## partyCentre Party (C) 0.022169
## partyLiberals (L) 0.020588
## partyModerate Party (M) 0.017521
## partyChristian Democrats (KD) 0.022222
## partyGreen Party (MP) 0.019129
## partySweden Democrats (SD) 0.032548
## partyFeminist Initiative (FI) 0.082069
## partyPirate Party (PP) 0.086143
## partyNew Democracy (NyD) 0.058453
## partyOther 0.034382
## partystrengthWeak party supporter 0.010456
## partystrengthStrong party supporter 0.014025
## age4a30-49 år 0.013232
## age4a50-64 år 0.014474
## age4a65-- 0.016184
## edu3Medel (allt över grundskola men ej högskola/universitet) 0.012536
## edu3Hög (studier/examen från högskola/universitet) 0.014357
## sexMale 0.009308
## time 0.005346
## t value
## (Intercept) -0.35
## psusePS news at least 5 days/week -2.46
## leaningLeft -35.09
## leaningRight 29.67
## polinterestLow -5.95
## polinterestMedium -9.64
## polinterestHigh political interest -7.20
## partyLeft Party (V) -8.38
## partyCentre Party (C) 13.22
## partyLiberals (L) 21.89
## partyModerate Party (M) 36.63
## partyChristian Democrats (KD) 19.31
## partyGreen Party (MP) 7.37
## partySweden Democrats (SD) 5.37
## partyFeminist Initiative (FI) -2.43
## partyPirate Party (PP) 1.43
## partyNew Democracy (NyD) 7.82
## partyOther 5.25
## partystrengthWeak party supporter 8.85
## partystrengthStrong party supporter 6.66
## age4a30-49 år -4.32
## age4a50-64 år -5.64
## age4a65-- -8.33
## edu3Medel (allt över grundskola men ej högskola/universitet) 5.13
## edu3Hög (studier/examen från högskola/universitet) 9.30
## sexMale -6.22
## time -3.35
##
## Correlation matrix not shown by default, as p = 27 > 12.
## Use print(x, correlation=TRUE) or
## vcov(x) if you need it
coefplot_mlm(mlm9b, title="More privatized healthcare", intercept=FALSE, caption=NULL, sort=TRUE, nudge_y=0, nudge_x=0.3)
## Warning: Ignoring unknown parameters: width
# Economy: recode into 5-point scale -2 to +2 (worse to better)
supersom$economy.change.num <- as.integer(supersom$da11c %>% recode("1"="2", "2"="1", "3"="0", "4"="-1", "5"="-2"))
mlm9c <- lmer(economy.change.num ~ 1 + psuse + leaning + polinterest + party + partystrength + age4a + edu3 + sex + time + (1 | time), data=supersom, REML=FALSE)
summary(mlm9c)
## Linear mixed model fit by maximum likelihood ['lmerMod']
## Formula: economy.change.num ~ 1 + psuse + leaning + polinterest + party +
## partystrength + age4a + edu3 + sex + time + (1 | time)
## Data: supersom
##
## AIC BIC logLik deviance df.resid
## 18675.2 18868.6 -9309.6 18619.2 7361
##
## Scaled residuals:
## Min 1Q Median 3Q Max
## -2.7392 -0.7317 0.1113 0.5809 3.4942
##
## Random effects:
## Groups Name Variance Std.Dev.
## time (Intercept) 0.02506 0.1583
## Residual 0.72566 0.8519
## Number of obs: 7389, groups: time, 5
##
## Fixed effects:
## Estimate
## (Intercept) -1.01808
## psusePS news at least 5 days/week 0.05393
## leaningLeft -0.03273
## leaningRight 0.09492
## polinterestLow -0.07492
## polinterestMedium -0.05371
## polinterestHigh political interest -0.07691
## partyLeft Party (V) -0.02734
## partyCentre Party (C) 0.12220
## partyLiberals (L) 0.12323
## partyModerate Party (M) 0.13494
## partyChristian Democrats (KD) 0.06422
## partyGreen Party (MP) 0.07891
## partySweden Democrats (SD) -0.35728
## partyFeminist Initiative (FI) 0.08429
## partyPirate Party (PP) -0.14827
## partyOther -0.27728
## partystrengthWeak party supporter 0.07204
## partystrengthStrong party supporter 0.05492
## age4a30-49 år -0.11032
## age4a50-64 år -0.12674
## age4a65-- -0.28358
## edu3Medel (allt över grundskola men ej högskola/universitet) -0.04682
## edu3Hög (studier/examen från högskola/universitet) -0.03419
## sexMale 0.14894
## time 0.02537
## Std. Error
## (Intercept) 1.41843
## psusePS news at least 5 days/week 0.04414
## leaningLeft 0.03064
## leaningRight 0.03147
## polinterestLow 0.04583
## polinterestMedium 0.04632
## polinterestHigh political interest 0.05230
## partyLeft Party (V) 0.04582
## partyCentre Party (C) 0.05344
## partyLiberals (L) 0.04962
## partyModerate Party (M) 0.03840
## partyChristian Democrats (KD) 0.06176
## partyGreen Party (MP) 0.03684
## partySweden Democrats (SD) 0.04403
## partyFeminist Initiative (FI) 0.10556
## partyPirate Party (PP) 0.16139
## partyOther 0.10905
## partystrengthWeak party supporter 0.02284
## partystrengthStrong party supporter 0.03085
## age4a30-49 år 0.03208
## age4a50-64 år 0.03331
## age4a65-- 0.03534
## edu3Medel (allt över grundskola men ej högskola/universitet) 0.03143
## edu3Hög (studier/examen från högskola/universitet) 0.03409
## sexMale 0.02045
## time 0.05056
## t value
## (Intercept) -0.718
## psusePS news at least 5 days/week 1.222
## leaningLeft -1.068
## leaningRight 3.016
## polinterestLow -1.635
## polinterestMedium -1.160
## polinterestHigh political interest -1.471
## partyLeft Party (V) -0.597
## partyCentre Party (C) 2.287
## partyLiberals (L) 2.483
## partyModerate Party (M) 3.514
## partyChristian Democrats (KD) 1.040
## partyGreen Party (MP) 2.142
## partySweden Democrats (SD) -8.114
## partyFeminist Initiative (FI) 0.798
## partyPirate Party (PP) -0.919
## partyOther -2.543
## partystrengthWeak party supporter 3.155
## partystrengthStrong party supporter 1.780
## age4a30-49 år -3.439
## age4a50-64 år -3.805
## age4a65-- -8.024
## edu3Medel (allt över grundskola men ej högskola/universitet) -1.490
## edu3Hög (studier/examen från högskola/universitet) -1.003
## sexMale 7.284
## time 0.502
##
## Correlation matrix not shown by default, as p = 26 > 12.
## Use print(x, correlation=TRUE) or
## vcov(x) if you need it
coefplot_mlm(mlm9c, title="Economy better (+) or worse (-) last 12 months", intercept=FALSE, caption=NULL, sort=TRUE, nudge_y=0, nudge_x=0.3)
## Warning: Ignoring unknown parameters: width
Bivariate: issue positions & public service news use.
mlm9a.bivar <- lmer(jobmarket.num ~ 1 + psuse + time + (1 | time), data=supersom, REML=FALSE)
mlm9b.bivar <- lmer(privatehealthcare.num ~ 1 + psuse + time + (1 | time), data=supersom, REML=FALSE)
mlm9c.bivar <- lmer(economy.change.num ~ 1 + psuse + time + (1 | time), data=supersom, REML=FALSE)
sjt.lmer(mlm9a.bivar, mlm9b.bivar, mlm9c.bivar, p.kr=FALSE)
## Computing p-values via Wald-statistics approximation (treating t as Wald z).
## Computing p-values via Wald-statistics approximation (treating t as Wald z).
## Computing p-values via Wald-statistics approximation (treating t as Wald z).
## Warning: This function will be removed in future versions of sjmisc and
## has been moved to package 'sjlabelled'. Please use sjlabelled::get_label()
## instead.
## Warning: This function will be removed in future versions of sjmisc and
## has been moved to package 'sjlabelled'. Please use sjlabelled::get_label()
## instead.
## Warning: This function will be removed in future versions of sjmisc and
## has been moved to package 'sjlabelled'. Please use sjlabelled::get_label()
## instead.
## Warning: This function will be removed in future versions of sjmisc and
## has been moved to package 'sjlabelled'. Please use sjlabelled::get_label()
## instead.
## Warning: This function will be removed in future versions of sjmisc and
## has been moved to package 'sjlabelled'. Please use sjlabelled::get_label()
## instead.
## Warning: This function will be removed in future versions of sjmisc and
## has been moved to package 'sjlabelled'. Please use sjlabelled::get_label()
## instead.
jobmarket.num | privatehealthcare.num | economy.change.num | ||||||||||
B | CI | p | B | CI | p | B | CI | p | ||||
Fixed Parts | ||||||||||||
(Intercept) | 0.40 | -0.42 – 1.22 | .340 | 0.12 | -0.07 – 0.32 | .223 | -0.73 | -3.59 – 2.12 | .615 | |||
psuse (PS news at least 5 days/week) | 0.08 | -0.01 – 0.16 | .069 | -0.11 | -0.16 – -0.06 | <.001 | 0.03 | -0.05 – 0.11 | .450 | |||
UndersökningsÃ¥r | -0.00 | -0.03 – 0.03 | .954 | -0.02 | -0.03 – -0.01 | .001 | 0.01 | -0.09 – 0.11 | .801 | |||
Random Parts | ||||||||||||
σ2 | 1.333 | 1.496 | 0.779 | |||||||||
τ00, time | 0.014 | 0.059 | 0.027 | |||||||||
Ntime | 9 | 29 | 5 | |||||||||
ICCtime | 0.011 | 0.038 | 0.033 | |||||||||
Observations | 13443 | 63408 | 8425 | |||||||||
R2 / Ω02 | .012 / .011 | .039 / .039 | .033 / .033 |
sjt.lmer(mlm9a, mlm9b, mlm9c, p.kr = FALSE)
## Computing p-values via Wald-statistics approximation (treating t as Wald z).
## Computing p-values via Wald-statistics approximation (treating t as Wald z).
## Computing p-values via Wald-statistics approximation (treating t as Wald z).
## Warning: This function will be removed in future versions of sjmisc and
## has been moved to package 'sjlabelled'. Please use sjlabelled::get_label()
## instead.
## Warning: This function will be removed in future versions of sjmisc and
## has been moved to package 'sjlabelled'. Please use sjlabelled::get_label()
## instead.
## Warning: This function will be removed in future versions of sjmisc and
## has been moved to package 'sjlabelled'. Please use sjlabelled::get_label()
## instead.
## Warning: This function will be removed in future versions of sjmisc and
## has been moved to package 'sjlabelled'. Please use sjlabelled::get_label()
## instead.
## Warning: This function will be removed in future versions of sjmisc and
## has been moved to package 'sjlabelled'. Please use sjlabelled::get_label()
## instead.
## Warning: This function will be removed in future versions of sjmisc and
## has been moved to package 'sjlabelled'. Please use sjlabelled::get_label()
## instead.
jobmarket.num | privatehealthcare.num | economy.change.num | ||||||||||
B | CI | p | B | CI | p | B | CI | p | ||||
Fixed Parts | ||||||||||||
(Intercept) | 0.81 | -0.12 – 1.74 | .089 | -0.04 | -0.24 – 0.17 | .729 | -1.02 | -3.80 – 1.76 | .473 | |||
psuse (PS news at least 5 days/week) | 0.08 | -0.01 – 0.16 | .079 | -0.06 | -0.11 – -0.01 | .014 | 0.05 | -0.03 – 0.14 | .222 | |||
leaning (Left) | 0.21 | 0.16 – 0.27 | <.001 | -0.47 | -0.50 – -0.45 | <.001 | -0.03 | -0.09 – 0.03 | .285 | |||
leaning (Right) | -0.41 | -0.47 – -0.35 | <.001 | 0.42 | 0.40 – 0.45 | <.001 | 0.09 | 0.03 – 0.16 | .003 | |||
polinterest (Low) | -0.21 | -0.29 – -0.13 | <.001 | -0.12 | -0.16 – -0.08 | <.001 | -0.07 | -0.16 – 0.01 | .102 | |||
polinterest (Medium) | -0.26 | -0.34 – -0.17 | <.001 | -0.20 | -0.24 – -0.16 | <.001 | -0.05 | -0.14 – 0.04 | .246 | |||
polinterest (High political interest) | -0.21 | -0.31 – -0.12 | <.001 | -0.17 | -0.22 – -0.12 | <.001 | -0.08 | -0.18 – 0.03 | .141 | |||
party (Left Party (V)) | 0.17 | 0.08 – 0.25 | <.001 | -0.15 | -0.19 – -0.12 | <.001 | -0.03 | -0.12 – 0.06 | .551 | |||
party (Centre Party (C)) | -0.49 | -0.59 – -0.39 | <.001 | 0.29 | 0.25 – 0.34 | <.001 | 0.12 | 0.02 – 0.23 | .022 | |||
party (Liberals (L)) | -0.42 | -0.51 – -0.33 | <.001 | 0.45 | 0.41 – 0.49 | <.001 | 0.12 | 0.03 – 0.22 | .013 | |||
party (Moderate Party (M)) | -0.63 | -0.70 – -0.56 | <.001 | 0.64 | 0.61 – 0.68 | <.001 | 0.13 | 0.06 – 0.21 | <.001 | |||
party (Christian Democrats (KD)) | -0.50 | -0.61 – -0.39 | <.001 | 0.43 | 0.39 – 0.47 | <.001 | 0.06 | -0.06 – 0.19 | .298 | |||
party (Green Party (MP)) | -0.25 | -0.32 – -0.18 | <.001 | 0.14 | 0.10 – 0.18 | <.001 | 0.08 | 0.01 – 0.15 | .032 | |||
party (Sweden Democrats (SD)) | -0.34 | -0.42 – -0.25 | <.001 | 0.17 | 0.11 – 0.24 | <.001 | -0.36 | -0.44 – -0.27 | <.001 | |||
party (Feminist Initiative (FI)) | 0.00 | -0.20 – 0.20 | .986 | -0.20 | -0.36 – -0.04 | .015 | 0.08 | -0.12 – 0.29 | .425 | |||
party (Pirate Party (PP)) | -0.07 | -0.28 – 0.14 | .535 | 0.12 | -0.05 – 0.29 | .153 | -0.15 | -0.46 – 0.17 | .358 | |||
party (Other) | -0.21 | -0.39 – -0.04 | .016 | 0.18 | 0.11 – 0.25 | <.001 | -0.28 | -0.49 – -0.06 | .011 | |||
partystrength (Weak party supporter) | 0.06 | 0.02 – 0.10 | .007 | 0.09 | 0.07 – 0.11 | <.001 | 0.07 | 0.03 – 0.12 | .002 | |||
partystrength (Strong party supporter) | 0.11 | 0.05 – 0.16 | <.001 | 0.09 | 0.07 – 0.12 | <.001 | 0.05 | -0.01 – 0.12 | .075 | |||
edu3 (Medel (allt över grundskola men ej högskola/universitet)) | -0.11 | -0.17 – -0.06 | <.001 | 0.06 | 0.04 – 0.09 | <.001 | -0.05 | -0.11 – 0.01 | .136 | |||
edu3 (Hög (studier/examen frÃ¥n högskola/universitet)) | -0.33 | -0.39 – -0.27 | <.001 | 0.13 | 0.11 – 0.16 | <.001 | -0.03 | -0.10 – 0.03 | .316 | |||
age4a (30-49 Ã¥r) | 0.15 | 0.10 – 0.21 | <.001 | -0.06 | -0.08 – -0.03 | <.001 | -0.11 | -0.17 – -0.05 | <.001 | |||
age4a (50-64 Ã¥r) | 0.32 | 0.26 – 0.38 | <.001 | -0.08 | -0.11 – -0.05 | <.001 | -0.13 | -0.19 – -0.06 | <.001 | |||
age4a (65--) | 0.23 | 0.17 – 0.30 | <.001 | -0.13 | -0.17 – -0.10 | <.001 | -0.28 | -0.35 – -0.21 | <.001 | |||
sex (Male) | -0.12 | -0.16 – -0.08 | <.001 | -0.06 | -0.08 – -0.04 | <.001 | 0.15 | 0.11 – 0.19 | <.001 | |||
UndersökningsÃ¥r | 0.01 | -0.03 – 0.04 | .757 | -0.02 | -0.03 – -0.01 | <.001 | 0.03 | -0.07 – 0.12 | .616 | |||
party (New Democracy (NyD)) | 0.46 | 0.34 – 0.57 | <.001 | |||||||||
Random Parts | ||||||||||||
σ2 | 1.006 | 1.099 | 0.726 | |||||||||
τ00, time | 0.019 | 0.051 | 0.025 | |||||||||
Ntime | 9 | 28 | 5 | |||||||||
ICCtime | 0.018 | 0.045 | 0.033 | |||||||||
Observations | 11748 | 53547 | 7389 | |||||||||
R2 / Ω02 | .254 / .254 | .292 / .292 | .078 / .078 |
Show locale and package versions for reproducibility.
sessionInfo()
## R version 3.4.1 (2017-06-30)
## Platform: x86_64-w64-mingw32/x64 (64-bit)
## Running under: Windows 10 x64 (build 15063)
##
## Matrix products: default
##
## locale:
## [1] LC_COLLATE=Swedish_Sweden.1252 LC_CTYPE=Swedish_Sweden.1252
## [3] LC_MONETARY=Swedish_Sweden.1252 LC_NUMERIC=C
## [5] LC_TIME=Swedish_Sweden.1252
##
## attached base packages:
## [1] stats graphics grDevices utils datasets methods base
##
## other attached packages:
## [1] sjPlot_2.3.1 lme4_1.1-13 Matrix_1.2-10
## [4] stargazer_5.2 broom_0.4.2 gridExtra_2.2.1
## [7] reshape2_1.4.2 lubridate_1.6.0 moments_0.14
## [10] sjlabelled_1.0.1 bindrcpp_0.2 purrr_0.2.2.2
## [13] readr_1.1.1 tidyr_0.6.3 tibble_1.3.3
## [16] tidyverse_1.1.1 RColorBrewer_1.1-2 ggplot2_2.2.1
## [19] rio_0.5.5 dplyr_0.7.1
##
## loaded via a namespace (and not attached):
## [1] nlme_3.1-131 pbkrtest_0.4-7 httr_1.2.1
## [4] rprojroot_1.2 TMB_1.7.10 tools_3.4.1
## [7] backports_1.1.0 R6_2.2.2 DT_0.2
## [10] lazyeval_0.2.0 colorspace_1.3-2 nnet_7.3-12
## [13] mnormt_1.5-5 curl_2.7 compiler_3.4.1
## [16] rvest_0.3.2 xml2_1.1.1 sandwich_2.3-4
## [19] labeling_0.3 effects_3.1-2 scales_0.4.1
## [22] lmtest_0.9-35 mvtnorm_1.0-6 psych_1.7.5
## [25] blme_1.0-4 stringr_1.2.0 digest_0.6.12
## [28] foreign_0.8-69 minqa_1.2.4 rmarkdown_1.6
## [31] stringdist_0.9.4.4 pkgconfig_2.0.1 htmltools_0.3.6
## [34] htmlwidgets_0.9 rlang_0.1.1 readxl_1.0.0
## [37] shiny_1.0.3 bindr_0.1 zoo_1.8-0
## [40] jsonlite_1.5 magrittr_1.5 modeltools_0.2-21
## [43] Rcpp_0.12.12 munsell_0.4.3 abind_1.4-5
## [46] stringi_1.1.5 multcomp_1.4-6 yaml_2.1.14
## [49] merTools_0.3.0 MASS_7.3-47 plyr_1.8.4
## [52] grid_3.4.1 parallel_3.4.1 sjmisc_2.5.0
## [55] forcats_0.2.0 lattice_0.20-35 haven_1.1.0
## [58] splines_3.4.1 sjstats_0.10.2 hms_0.3
## [61] knitr_1.16 codetools_0.2-15 stats4_3.4.1
## [64] glue_1.1.1 evaluate_0.10.1 data.table_1.10.4
## [67] modelr_0.1.0 nloptr_1.0.4 httpuv_1.3.5
## [70] cellranger_1.1.0 gtable_0.2.0 assertthat_0.2.0
## [73] openxlsx_4.0.17 mime_0.5 coin_1.2-1
## [76] xtable_1.8-2 coda_0.19-1 survival_2.41-3
## [79] arm_1.9-3 glmmTMB_0.1.1 TH.data_1.0-8
0.6 Social networking sites (SNS)
0.6.1 SNS & Extremity
Are social media users more extreme in their views?
0.6.2 SNS t-test
0.6.3 SNS & leaning
Note that the survey question changed in 2014.
0.6.4 SNS & party support
Note that the survey question changed in 2014.
0.6.5 SNS & political interest
Note that the survey question changed in 2014.
0.6.6 SNS & PS use
0.6.7 SNS + internet news
0.6.8 Twitter med
#aktuellt
trendTwitter trends collected every hour since 2014.
Same thing again, but relative to all trends that week.