##########

#Analysis

##########

 

#Clear workspace (run if desired) 

rm(list = ls())

 

# #List of project directories

# dirs <- list(

#   data = "...",

#   analysis = "...")

 

#Load required packages

if (!require(psych))  { install.packages("psych") } ; library(psych)

if (!require(car)) { install.packages("car") } ; library(car)

 

#Load dataset

load(paste0(dirs$data, "L1.rda"))

 

#########################################################################

 

#####################

#Step 1: Scale value

#####################

 

#Split dataset between countries

L1_D <- subset(L1, subset = (COUN == "1"))

L1_UK <- subset(L1, subset = (COUN == "2"))

 

##Germany

 

attach(L1_D)

 

describe(LISA1)

 

detach(L1_D)

 

#########################################################################

 

##UK

 

attach(L1_UK)

 

describe(LISA1)

 

detach(L1_UK)

 

#########################################################################

 

#####################

#Step 2: Reliability

#####################

 

#########################################################################

 

##Retest reliability for Germany

 

attach(L1_D)

 

cor.test(LISA1, LISA1rt, use = "pairwise.complete.obs")

 

detach(L1_D)

 

#########################################################################

 

##Retest reliability for the UK

 

attach(L1_UK)

 

cor.test(LISA1, LISA1rt, use = "pairwise.complete.obs")

 

detach(L1_UK)

 

#########################################################################

 

############################

#Step 3: Construct validity

############################

 

##Germany

 

attach(L1_D)

 

#BFI-2-XS

EXTR <- EXTR1R+EXTR2+EXTR3

AGRE <- AGRE1+AGRE2R+AGRE3

CONS <- CONS1R+CONS2R+CONS3

NEGA <- NEGA1+NEGA2+NEGA3R

OPEN <- OPEN1+OPEN2R+OPEN3

cor.test(LISA1, EXTR, use = "pairwise.complete.obs")

cor.test(LISA1, AGRE, use = "pairwise.complete.obs")

cor.test(LISA1, CONS, use = "pairwise.complete.obs")

cor.test(LISA1, NEGA, use = "pairwise.complete.obs")

cor.test(LISA1, OPEN, use = "pairwise.complete.obs")

 

#RSES

RSES <- RSES1+RSES2R+RSES3+RSES4+RSES5R+RSES6R+RSES7+RSES8R+RSES9R+RSES10

cor.test(LISA1, RSES, use = "pairwise.complete.obs")

 

#Health

cor.test(LISA1, HEAL, use = "pairwise.complete.obs")

 

#Employment status

#1) employed

#2) self-employed

#3) out of work and looking for work

#4) out of work but not currently looking for work

#5) doing housework

#6) pupil/student

#7) apprentice/internship

#8) retired

#[9) none of what is mentioned above]

EMPL.selfempl <- recode(EMPL, "2 = 2; 1 = 1; else = NA")

EMPL.unempl <- recode(EMPL, "3:4 = 2; 1:2 = 1; else = NA")

EMPL.retired <- recode(EMPL, "5 = 2; 8 = 2; 1:2 = 1; else = NA")

EMPL.student <- recode(EMPL, "6:7 = 2; 1:2 = 1; else = NA")

cor.test(LISA1, EMPL.unempl, use = "pairwise.complete.obs")

cor.test(LISA1, EMPL.selfempl, use = "pairwise.complete.obs")

cor.test(LISA1, EMPL.retired, use = "pairwise.complete.obs")

cor.test(LISA1, EMPL.student, use = "pairwise.complete.obs")

 

#Income

cor.test(LISA1, INCO, use = "pairwise.complete.obs")

 

#Education

cor.test(LISA1, SCHO, use = "pairwise.complete.obs")

 

#Age

cor.test(LISA1, AGE, use = "pairwise.complete.obs")

 

#Gender

cor.test(LISA1, SEX, use = "pairwise.complete.obs")

 

#ASKU

ASKU <- ASKU1+ASKU2+ASKU3

cor.test(LISA1, ASKU, use = "pairwise.complete.obs")

 

#I-8

URGE <- URGE1+URGE2

PREM <- PREM1+PREM2

PERS <- PERS1+PERS2

SENS <- SENS1+SENS2

cor.test(LISA1, URGE, use = "pairwise.complete.obs")

cor.test(LISA1, PREM, use = "pairwise.complete.obs")

cor.test(LISA1, PERS, use = "pairwise.complete.obs")

cor.test(LISA1, SENS, use = "pairwise.complete.obs")

 

#IE-4

ILOC <- ILOC1+ILOC2

ELOC <- ELOC1+ELOC2

cor.test(LISA1, ILOC, use = "pairwise.complete.obs")

cor.test(LISA1, ELOC, use = "pairwise.complete.obs")

 

#KUSIV3

KUSIV <- KUSI1+KUSI2R+KUSI3

cor.test(LISA1, KUSIV, use = "pairwise.complete.obs")

 

#R-1

cor.test(LISA1, RISK1, use = "pairwise.complete.obs")

 

#PEKS

IPEF <- IPEF1+IPEF2

EPEF <- EPEF1+EPEF2

cor.test(LISA1, IPEF, use = "pairwise.complete.obs")

cor.test(LISA1, EPEF, use = "pairwise.complete.obs")

 

#SOP2

SOP <- PESS1R+OPTI1

cor.test(LISA1, SOP, use = "pairwise.complete.obs")

 

#KSE-G

SDPQ <- SDPQ1+SDPQ2+SDPQ3

SDNQ <- SDNQ1+SDNQ2+SDNQ3

cor.test(LISA1, SDPQ, use = "pairwise.complete.obs")

cor.test(LISA1, SDNQ, use = "pairwise.complete.obs")

 

#USS-8

VICT <- VICT1+VICT2

OBSE <- OBSE1+OBSE2

BENE <- BENE1+BENE2

OFFE <- OFFE1+OFFE2

cor.test(LISA1, VICT, use = "pairwise.complete.obs")

cor.test(LISA1, OBSE, use = "pairwise.complete.obs")

cor.test(LISA1, BENE, use = "pairwise.complete.obs")

cor.test(LISA1, OFFE, use = "pairwise.complete.obs")

 

detach(L1_D)

 

#########################################################################

 

##UK

 

attach(L1_UK)

 

#BFI-2-XS

EXTR <- EXTR1R+EXTR2+EXTR3

AGRE <- AGRE1+AGRE2R+AGRE3

CONS <- CONS1R+CONS2R+CONS3

NEGA <- NEGA1+NEGA2+NEGA3R

OPEN <- OPEN1+OPEN2R+OPEN3

cor.test(LISA1, EXTR, use = "pairwise.complete.obs")

cor.test(LISA1, AGRE, use = "pairwise.complete.obs")

cor.test(LISA1, CONS, use = "pairwise.complete.obs")

cor.test(LISA1, NEGA, use = "pairwise.complete.obs")

cor.test(LISA1, OPEN, use = "pairwise.complete.obs")

 

#RSES

RSES <- RSES1+RSES2R+RSES3+RSES4+RSES5R+RSES6R+RSES7+RSES8R+RSES9R+RSES10

cor.test(LISA1, RSES, use = "pairwise.complete.obs")

 

#Health

cor.test(LISA1, HEAL, use = "pairwise.complete.obs")

 

#Employment status

#1) employed

#2) self-employed

#3) out of work and looking for work

#4) out of work but not currently looking for work

#5) doing housework

#6) pupil/student

#7) apprentice/internship

#8) retired

#[9) none of what is mentioned above]

EMPL.selfempl <- recode(EMPL, "2 = 2; 1 = 1; else = NA")

EMPL.unempl <- recode(EMPL, "3:4 = 2; 1:2 = 1; else = NA")

EMPL.retired <- recode(EMPL, "5 = 2; 8 = 2; 1:2 = 1; else = NA")

EMPL.student <- recode(EMPL, "6:7 = 2; 1:2 = 1; else = NA")

cor.test(LISA1, EMPL.unempl, use = "pairwise.complete.obs")

cor.test(LISA1, EMPL.selfempl, use = "pairwise.complete.obs")

cor.test(LISA1, EMPL.retired, use = "pairwise.complete.obs")

cor.test(LISA1, EMPL.student, use = "pairwise.complete.obs")

 

#Income

cor.test(LISA1, INCO, use = "pairwise.complete.obs")

 

#Education

cor.test(LISA1, SCHO, use = "pairwise.complete.obs")

 

#Age

cor.test(LISA1, AGE, use = "pairwise.complete.obs")

 

#Gender

cor.test(LISA1, SEX, use = "pairwise.complete.obs")

 

#ASKU

ASKU <- ASKU1+ASKU2+ASKU3

cor.test(LISA1, ASKU, use = "pairwise.complete.obs")

 

#I-8

URGE <- URGE1+URGE2

PREM <- PREM1+PREM2

PERS <- PERS1+PERS2

SENS <- SENS1+SENS2

cor.test(LISA1, URGE, use = "pairwise.complete.obs")

cor.test(LISA1, PREM, use = "pairwise.complete.obs")

cor.test(LISA1, PERS, use = "pairwise.complete.obs")

cor.test(LISA1, SENS, use = "pairwise.complete.obs")

 

#IE-4

ILOC <- ILOC1+ILOC2

ELOC <- ELOC1+ELOC2

cor.test(LISA1, ILOC, use = "pairwise.complete.obs")

cor.test(LISA1, ELOC, use = "pairwise.complete.obs")

 

#KUSIV3

KUSIV <- KUSI1+KUSI2R+KUSI3

cor.test(LISA1, KUSIV, use = "pairwise.complete.obs")

 

#R-1

cor.test(LISA1, RISK1, use = "pairwise.complete.obs")

 

#PEKS

IPEF <- IPEF1+IPEF2

EPEF <- EPEF1+EPEF2

cor.test(LISA1, IPEF, use = "pairwise.complete.obs")

cor.test(LISA1, EPEF, use = "pairwise.complete.obs")

 

#SOP2

SOP <- PESS1R+OPTI1

cor.test(LISA1, SOP, use = "pairwise.complete.obs")

 

#KSE-G

SDPQ <- SDPQ1+SDPQ2+SDPQ3

SDNQ <- SDNQ1+SDNQ2+SDNQ3

cor.test(LISA1, SDPQ, use = "pairwise.complete.obs")

cor.test(LISA1, SDNQ, use = "pairwise.complete.obs")

 

#USS-8

VICT <- VICT1+VICT2

OBSE <- OBSE1+OBSE2

BENE <- BENE1+BENE2

OFFE <- OFFE1+OFFE2

cor.test(LISA1, VICT, use = "pairwise.complete.obs")

cor.test(LISA1, OBSE, use = "pairwise.complete.obs")

cor.test(LISA1, BENE, use = "pairwise.complete.obs")

cor.test(LISA1, OFFE, use = "pairwise.complete.obs")

 

detach(L1_UK)

 

#########################################################################

 

##########################

#Step 4: Reference values

##########################

 

#Quote 1: male, lower education, 18-29

#Quote 2: male, lower education, 30-49

#Quote 3: male, lower education, 50-69

#Quote 4: male, middle education, 18-29

#Quote 5: male, middle education, 30-49

#Quote 6: male, middle education, 50-69

#Quote 7: male, upper education, 18-29

#Quote 8: male, upper education, 30-49

#Quote 9: male, upper education, 50-69

#Quote 10: female, lower education, 18-29

#Quote 11: female, lower education, 30-49

#Quote 12: female, lower education, 50-69

#Quote 13: female, middle education, 18-29

#Quote 14: female, middle education, 30-49

#Quote 15: female, middle education, 50-69

#Quote 16: female, upper education, 18-29

#Quote 17: female, upper education, 30-49

#Quote 18: female, upper education, 50-69

 

##Germany

 

attach(L1_D)

 

tapply(LISA1, SEX, describe)

AGE1 <- subset(L1_D, AGE == 18 | AGE == 19 | AGE == 20 | AGE == 21 | AGE == 22 | AGE == 23 | AGE == 24 | AGE == 25 | AGE == 26

               | AGE == 27 | AGE == 28 | AGE == 29)

AGE2 <- subset(L1_D, AGE == 30 | AGE == 31 | AGE == 32 | AGE == 33 | AGE == 34 | AGE == 35 | AGE == 36 | AGE == 37 | AGE == 38

               | AGE == 39 | AGE == 40 | AGE == 41 | AGE == 42 | AGE == 43 | AGE == 44 | AGE == 45 | AGE == 46 | AGE == 47

               | AGE == 48 | AGE == 49)

AGE3 <- subset(L1_D, AGE == 50 | AGE == 51 | AGE == 52 | AGE == 53 | AGE == 54 | AGE == 55 | AGE == 56 | AGE == 57 | AGE == 58

               | AGE == 59 | AGE == 60 | AGE == 61 | AGE == 62 | AGE == 63 | AGE == 64 | AGE == 65 | AGE == 66 | AGE == 67

               | AGE == 68 | AGE == 69)

detach(L1_D)

attach(AGE1)

describe(LISA1)

detach(AGE1)

attach(AGE2)

describe(LISA1)

detach(AGE2)

attach(AGE3)

describe(LISA1)

detach(AGE3)

attach(L1_D)

 

#########################################################################

 

##UK

 

attach(L1_UK)

 

tapply(LISA1, SEX, describe)

AGE1 <- subset(L1_UK, AGE == 18 | AGE == 19 | AGE == 20 | AGE == 21 | AGE == 22 | AGE == 23 | AGE == 24 | AGE == 25 | AGE == 26

               | AGE == 27 | AGE == 28 | AGE == 29)

AGE2 <- subset(L1_UK, AGE == 30 | AGE == 31 | AGE == 32 | AGE == 33 | AGE == 34 | AGE == 35 | AGE == 36 | AGE == 37 | AGE == 38

               | AGE == 39 | AGE == 40 | AGE == 41 | AGE == 42 | AGE == 43 | AGE == 44 | AGE == 45 | AGE == 46 | AGE == 47

               | AGE == 48 | AGE == 49)

AGE3 <- subset(L1_UK, AGE == 50 | AGE == 51 | AGE == 52 | AGE == 53 | AGE == 54 | AGE == 55 | AGE == 56 | AGE == 57 | AGE == 58

               | AGE == 59 | AGE == 60 | AGE == 61 | AGE == 62 | AGE == 63 | AGE == 64 | AGE == 65 | AGE == 66 | AGE == 67

               | AGE == 68 | AGE == 69)

detach(L1_UK)

attach(AGE1)

describe(LISA1)

detach(AGE1)

attach(AGE2)

describe(LISA1)

detach(AGE2)

attach(AGE3)

describe(LISA1)

detach(AGE3)

attach(L1_UK)

 

#########################################################################

 

################################

#Step 5: Descriptive statistics

################################

 

##Germany

 

attach(L1_D)

 

#Age

summary(AGE)

sd(AGE)

 

#Proportion women

table(SEX)

 

#Educational level

table(QUOT)

 

detach(L1_D)

 

#########################################################################

 

##UK

 

attach(L1_UK)

 

#Age

summary(AGE)

sd(AGE)

 

#Proportion women

table(SEX)

 

#Educational level

table(QUOT)

 

detach(L1_UK)