Add Banking-the-Unbanked-through-Cryptocurrency

This commit is contained in:
Rucknium 2024-11-15 16:03:56 +00:00
parent d962be7a9a
commit 22ffd837d8
20 changed files with 2367 additions and 0 deletions

View file

@ -0,0 +1,33 @@
## Hard Data on Banking the Unbanked through Cryptocurrency
### Instructions
Install the necessary R packages:
```R
install.packages(c("data.table", "readstata13", "ggplot2", "stargazer",
"huxtable", "rvest", "ggcorrplot", "grid", "remotes"))
remotes::install_github("dracula/ggplot2")
```
Download the survey data files and unpack them into the appropriate directories in the `raw-data` directory:
- [SHED 2021-2023 STATA files](https://doi.org/10.17016/datasets.002)
- [SPACE 2022](https://web.archive.org/web/20230922180752/https://www.ecb.europa.eu/stats/ecb_surveys/space/html/index.en.html#dd)
- [SDCPC 2015 R data file](https://www.atlantafed.org/banking-and-payments/consumer-payments/survey-of-consumer-payment-choice/2015-survey)
- [SDCPC 2016 R data file](https://www.atlantafed.org/banking-and-payments/consumer-payments/survey-of-consumer-payment-choice/2016-survey)
- [SDCPC 2017 R data file](https://www.atlantafed.org/banking-and-payments/consumer-payments/survey-of-consumer-payment-choice/2017-survey)
- [SDCPC 2018 R data file](https://www.atlantafed.org/banking-and-payments/consumer-payments/survey-of-consumer-payment-choice/2018-survey#Tab3)
- [SDCPC 2019 R data file](https://www.atlantafed.org/banking-and-payments/consumer-payments/survey-of-consumer-payment-choice/2019-survey#Tab3)
- [SDCPC 2020 R data file](https://www.atlantafed.org/banking-and-payments/consumer-payments/survey-of-consumer-payment-choice/2020-survey#Tab3)
- [SDCPC 2021 R data file](https://www.atlantafed.org/banking-and-payments/consumer-payments/survey-and-diary-of-consumer-payment-choice/2021-survey-and-diary#Tab3)
- [SDCPC 2022 individual-level R data file](https://www.atlantafed.org/banking-and-payments/consumer-payments/survey-and-diary-of-consumer-payment-choice/2022-survey-and-diary#Tab3)
- [SDCPC 2023 individual-level R data file](https://www.atlantafed.org/banking-and-payments/consumer-payments/survey-and-diary-of-consumer-payment-choice/2023-survey-and-diary#Tab3)
Run `SHED-data-prep.R`, `SPACE-data-prep.R`, and `SDCPC-data-prep.R` to produce the processed data files and save them in the `processed-data` directory.
Then run `Banking-the-Unbanked-through-Cryptocurrency.Rmd` in RStudio to produce the PDF. You may have to install some LaTeX packages.

View file

@ -0,0 +1,85 @@
library(data.table)
S_DCPC.2023 <- readRDS("raw-data/S-DCPC_2023/dcpc_2023_indlevel_public_rds.rds")
S_DCPC.2022 <- readRDS("raw-data/S-DCPC_2022/dcpc_2022_indlevel_public_rds.rds")
S_DCPC.2021 <- readRDS("raw-data/S-DCPC_2021/dcpc_2021_indlevel_public_rds.rds")
S_DCPC.2020 <- readRDS("raw-data/S-DCPC_2020/scpc_2020_public_rds.rds")
S_DCPC.2019 <- readRDS("raw-data/S-DCPC_2019/scpc_2019_public_rds.rds")
S_DCPC.2018 <- readRDS("raw-data/S-DCPC_2018/scpc_2018_rds.rds")
S_DCPC.2017 <- readRDS("raw-data/S-DCPC_2017/scpc_2017_rds.rds")
S_DCPC.2016 <- readRDS("raw-data/S-DCPC_2016/scpc_2016_rds.rds")
S_DCPC.2015 <- readRDS("raw-data/S-DCPC_2015/scpc_2015_rds.rds")
for (i in 2015:2023) {
print(nrow(get(paste0("S_DCPC.", i))))
}
reason <- do.call(rbind, list(
data.frame(year = 2023, reason = S_DCPC.2023$pa126_a, weight = S_DCPC.2023$ind_weight_all),
data.frame(year = 2022, reason = S_DCPC.2022$pa126_a, weight = S_DCPC.2022$ind_weight_all),
data.frame(year = 2021, reason = S_DCPC.2021$pa126_a, weight = S_DCPC.2021$ind_weight_all),
data.frame(year = 2020, reason = S_DCPC.2020$pa126_a, weight = S_DCPC.2020$r_weight),
data.frame(year = 2019, reason = S_DCPC.2019$pa126_a, weight = S_DCPC.2019$r_weight),
data.frame(year = 2018, reason = S_DCPC.2018$pa126_a, weight = S_DCPC.2018$r_weight),
data.frame(year = 2017, reason = S_DCPC.2017$pa126_a, weight = S_DCPC.2017$r_weight),
data.frame(year = 2016, reason = S_DCPC.2016$pa126_a, weight = S_DCPC.2016$r_weight),
data.frame(year = 2015, reason = S_DCPC.2015$pa126_a, weight = S_DCPC.2015$r_weight)
))
setDT(reason)
owns.crypto <- reason
owns.crypto[, owns.crypto := ! is.na(reason)]
reason <- reason[ ! is.na(reason), ]
reason[, reason := as.character(reason)]
reason[reason %in% c(1, 2, 4), reason := "Payments"]
reason[reason %in% c(3), reason := "Investment"]
reason[reason %in% c(5, 9), reason := "Other"]
reason[reason %in% c(6), reason := "Interest in new tech"]
reason[reason %in% c(7, 8), reason := "Don't trust banks/government/USD"]
reason[, reason := factor(reason, levels =
c("Investment", "Payments", "Interest in new tech", "Don't trust banks/government/USD", "Other"))]
reason <- aggregate(weight ~ reason + year, data = reason, FUN = sum, drop = FALSE)
setDT(reason)
reason[is.na(weight), weight := 0]
reason <- reason[, .(reason = reason, share = 100 * weight / sum(weight)), by = "year"]
owns.crypto <- aggregate(weight ~ owns.crypto + year, data = owns.crypto, FUN = sum, drop = FALSE)
setDT(owns.crypto)
owns.crypto[is.na(weight), weight := 0]
owns.crypto <- owns.crypto[, .(owns.crypto = owns.crypto, share = 100 * weight / sum(weight)), by = "year"]
owns.crypto <- owns.crypto[ (owns.crypto), ]
setnames(owns.crypto, "owns.crypto", "reason")
owns.crypto$reason <- NULL
owns.crypto$reason <- "Owns crypto"
owns.crypto[, panel := "Owns crypto"]
reason[, panel := "Primary reason"]
reason.owns.crypto <- rbind(reason, owns.crypto)
reason.owns.crypto[, panel := factor(panel, levels = c("Owns crypto", "Primary reason"))]
reason.owns.crypto[, year := factor(year)]
saveRDS(reason.owns.crypto, file = "processed-data/reason-owns-crypto.rds")

View file

@ -0,0 +1,413 @@
library(data.table)
library(readstata13)
library(survey)
SHED <- list()
SHED[["2021"]] <- readstata13::read.dta13("raw-data/SHED_2021/public2021.dta", generate.factors = TRUE, nonint.factors = TRUE)
SHED[["2022"]] <- readstata13::read.dta13("raw-data/SHED_2022/public2022.dta", generate.factors = TRUE, nonint.factors = TRUE)
SHED[["2023"]] <- readstata13::read.dta13("raw-data/SHED_2023/public2023.dta", generate.factors = TRUE, nonint.factors = TRUE)
crypto.used.as.payment_annual.trend <- c()
for (i in names(SHED)) {
SHED[[i]]$crypto.used.as.payment <- SHED[[i]]$S16_b == "Yes"
SHED[[i]] <- svydesign(ids = ~0, data = SHED[[i]], weights = SHED[[i]]$weight)
crypto.used.as.payment_annual.trend[[i]] <-
round(100 * as.data.frame(svymean(~ crypto.used.as.payment, design = SHED[[i]], na.rm = TRUE))[2, 1], 1)
}
saveRDS(crypto.used.as.payment_annual.trend, file = "processed-data/SHED-annual-trend.rds")
# Then re-do it for the pooled dataset
SHED <- list()
SHED[["2021"]] <- readstata13::read.dta13("raw-data/SHED_2021/public2021.dta", generate.factors = TRUE, nonint.factors = TRUE)
SHED[["2022"]] <- readstata13::read.dta13("raw-data/SHED_2022/public2022.dta", generate.factors = TRUE, nonint.factors = TRUE)
SHED[["2023"]] <- readstata13::read.dta13("raw-data/SHED_2023/public2023.dta", generate.factors = TRUE, nonint.factors = TRUE)
colnames(SHED[["2021"]]) <- paste0(colnames(SHED[["2021"]]), ".2021")
colnames(SHED[["2022"]]) <- paste0(colnames(SHED[["2022"]]), ".2022")
colnames(SHED[["2023"]]) <- paste0(colnames(SHED[["2023"]]), ".2023")
SHED.panel <- merge(SHED[["2021"]], SHED[["2022"]], by.x = "CaseID.2021", by.y = "caseid2021.2022",
all = TRUE)
SHED.panel <- merge(SHED.panel, SHED[["2023"]], by.x = "CaseID.2022", by.y = "caseid2022.2023",
all = TRUE, incomparables = NA)
# NOTE: merge.data.frame() and merge.data.table() have different behaviors with incomparables = NA
pooled.vars <- c(
"S16_a",
"S16_b",
"S16_c",
"S18", "S19_a", "S19_b", "S19_c", "S20_a", "S20_b", "S20_c", "S20_d",
"BK1",
"C2A",
"ppgender",
"race_5cat",
"ED0",
"ED1",
"pppa_lgb",
"ppp20197",
"I40",
"B2",
"I41_b",
"FL0",
"B10",
"ppage",
"ppcmdate",
"ind1",
"ppcm0160",
"ppcm1301",
"ppmsacat",
"ppfs0596",
"A1_a",
"BK2_a",
"BK2_b",
"BK2_c",
"BK2_d",
"BK2_e",
"BNPL1",
"ppfs1482",
"GE2A",
"GE1A",
"E7",
"E8_b",
"xlaptop",
"devicetype2",
"S21"
)
for (pooled.var in pooled.vars) {
# if (pooled.var == "S19_b") {stop()}
SHED.panel[, paste0(pooled.var, ".pooled")] <- NA
valid.var.col.name <- intersect(colnames(SHED.panel), paste0(pooled.var, ".", 2021:2023))[1]
var.transform <- ifelse(is.factor(SHED.panel[, valid.var.col.name]), as.character, identity)
for (i in as.character(2021:2023)) {
if ( ! (paste0(pooled.var, ".", i) %in% colnames(SHED.panel) ) ) {
next
}
SHED.panel[is.na(SHED.panel[, paste0(pooled.var, ".pooled")]), paste0(pooled.var, ".pooled")] <-
var.transform(SHED.panel[is.na(SHED.panel[, paste0(pooled.var, ".pooled")]), paste0(pooled.var, ".", i)])
}
if (is.factor(SHED.panel[, valid.var.col.name])) {
SHED.panel[, paste0(pooled.var, ".pooled")] <- factor(SHED.panel[, paste0(pooled.var, ".pooled")])
}
}
SHED.panel$panel_weight.common <- apply(
SHED.panel[, c("panel_weight.2021", "panel_weight.2022", "panel_weight.2023")], MARGIN = 1,
FUN = function(x) {
y <- unique(na.omit(x))
if (length(y) == 0) { return(0) }
return(mean(y))
})
SHED.panel$panel_weight.common[SHED.panel$panel_weight.common == 0 & !is.na(SHED.panel$weight.2021)] <-
SHED.panel$weight.2021[SHED.panel$panel_weight.common == 0 & !is.na(SHED.panel$weight.2021)]
SHED.panel$panel_weight.common[SHED.panel$panel_weight.common == 0 & !is.na(SHED.panel$weight.2022)] <-
SHED.panel$weight.2022[SHED.panel$panel_weight.common == 0 & !is.na(SHED.panel$weight.2022)]
SHED.panel$panel_weight.common[SHED.panel$panel_weight.common == 0 & !is.na(SHED.panel$weight.2023)] <-
SHED.panel$weight.2023[SHED.panel$panel_weight.common == 0 & !is.na(SHED.panel$weight.2023)]
# Weighting is a little improvised
# S16_a
# Bought cryptocurrency or held as an
# investment - In the past year, have you done
# the following with cryptocurrency, such as
# Bitcoin or Ethereum?
SHED.panel$crypto.used.as.investment <- SHED.panel$S16_a.pooled == "Yes"
# S16_b
# In the past year, have you done the following
# with cryptocurrency, such as Bitcoin or Ethereum?
# - Used to buy something or make a payment
SHED.panel$crypto.used.as.payment <- SHED.panel$S16_b.pooled == "Yes"
# S16_c
# Used cryptocurrency to send money to friends
# or family - In the past year, have you done
# the following with cryptocurrency, such as
# Bitcoin or Ethereum?
SHED.panel$crypto.used.to.send.money <- SHED.panel$S16_c.pooled == "Yes"
# S18
# Were any of the family or friends you sent
# cryptocurrency to living outside of the
# United States?
SHED.panel$crypto.used.to.send.money.outside.us <- SHED.panel$S18.pooled == "Yes"
# S19_a
# Buy something in-person - Have you used
# cryptocurrency to do each of the following?
SHED.panel$crypto.used.as.payment.in.person <- SHED.panel$S19_a.pooled == "Yes"
# S19_b
# Buy something online - Have you used
# cryptocurrency to do each of the following?
SHED.panel$crypto.used.as.payment.online <- SHED.panel$S19_b.pooled == "Yes"
# S19_c
# Pay a bill online - Have you used
# cryptocurrency to do each of the following?
SHED.panel$crypto.used.as.payment.online.bill.pay <- SHED.panel$S19_c.pooled == "Yes"
# S20_a
# Convert cash into cryptocurrency - Have you
# used a cryptocurrency ATM/kiosk to do each of
# the following?
SHED.panel$crypto.atm.convert.cash.to.crypto <- SHED.panel$S20_a.pooled == "Yes"
# S20_b
# Withdraw cash - Have you used a cryptocurrency
# ATM/kiosk to do each of the following?
SHED.panel$crypto.atm.withdraw.cash <- SHED.panel$S20_b.pooled == "Yes"
# S20_c
# Make a payment - Have you used a
# cryptocurrency ATM/kiosk to do each of the
# following?
SHED.panel$crypto.atm.make.payment <- SHED.panel$S20_c.pooled == "Yes"
# S20_d
# Send money to family or friends - Have you
# used a cryptocurrency ATM/kiosk to do each of
# the following?
SHED.panel$crypto.atm.send.money <- SHED.panel$S20_d.pooled == "Yes"
# BK1
# Do you and/or your spouse or partner
# currently have a checking, savings or money
# market account?
SHED.panel$lacks.bank.account <- SHED.panel$BK1.pooled == "No"
# C2A
# Do you currently have at least one credit card?
SHED.panel$lacks.credit.card <- SHED.panel$C2A.pooled == "No"
# ppgender
# Gender [Ipsos source]
SHED.panel$is.male <- SHED.panel$ppgender.pooled == "Male"
# race_5cat Race 5 categories
SHED.panel$race <- SHED.panel$race_5cat.pooled
# ED0
# What is the highest level of school you have
# completed or the highest degree you have
# received?
SHED.panel$education.level <- relevel(SHED.panel$ED0.pooled, "High school degree or GED")
# ED1
# Which one of the following broad categories
# best describes your (current/most recent)
# educational program?
SHED.panel$education.subject <- relevel(SHED.panel$ED1.pooled, "Business/management")
# pppa_lgb [Ipsos source]
# Q230: Which of the following best describes how you think of yourself?
SHED.panel$lgbtq <- relevel(SHED.panel$pppa_lgb.pooled, "Straight, that is, not gay")
# ppp20197 [Ipsos source]
# QEG22: Are you a citizen of the United States?
SHED.panel$is.noncitizen <- SHED.panel$ppp20197.pooled == "No"
# I40
# Which of the following categories best
# describes the total income that you and/or
# your spouse or partner received from all
# sources, before taxes and deductions, in the
# past 12 months?
SHED.panel$income.category <- SHED.panel$I40.pooled
# B2
# Overall, which one of the following best
# describes how well you are managing
# financially these days?
SHED.panel$overall.financial.wellbeing <- SHED.panel$B2.pooled
# I41_b
# Supplemental Nutrition Assistance Program
# (SNAP or food stamps) - In the past 12
# months, have you received any of the
# following?
SHED.panel$received.food.stamps <- SHED.panel$I41_b.pooled
# FL0
# On a scale from zero to ten, where zero is
# not at all willing to take risks and ten is
# very willing to take risks, what number would
# you be on the scale?
SHED.panel$risk.tolerance <- as.numeric(SHED.panel$FL0.pooled) - 1
# B10
# Overall, on a scale from zero to ten, where
# zero is not at all satisfied and ten is
# completely satisfied, how satisfied are you
# with life as a whole these days?
SHED.panel$life.satisfaction <- as.numeric(SHED.panel$B10.pooled) - 1
# ppage
# Age [Ipsos source]
# ppcmdate
# Date member completed Core survey
# Must correct age variable for time of initial Ipsos survey
SHED.panel$age <- SHED.panel$ppage.pooled + (2021 - as.numeric(substr(SHED.panel$ppcmdate.pooled, 1, 4)))
# ind1
# IND1: Industry (tight scale) in current or main job
SHED.panel$job.industry <- relevel(SHED.panel$ind1.pooled, "Retail/Stores/Shopping (including Online Retail)")
# ppcm0160 [Ipsos source]
# Q26: Occupation (detailed) in current or main job
SHED.panel$job.occupation <- relevel(SHED.panel$ppcm0160.pooled, "Food Preparation and Serving")
# ppcm1301 [Ipsos source]
# GOVEMP1: Employer type
SHED.panel$employer.type <- relevel(SHED.panel$ppcm1301.pooled, "Private-for-profit company")
# ppmsacat
# MSA Status [Ipsos source]
SHED.panel$resides.in.metro.statistical.area <- SHED.panel$ppmsacat.pooled == "Metro"
# ppfs0596 [Ipsos source]
# Q22: What is the approximate total amount of
# your household's savings and investments?
SHED.panel$total.household.savings <- relevel(SHED.panel$ppfs0596.pooled, "$100,000 - $249,999")
# A1_a
# In the past 12 months, has each of the following happened to you:
# - Turned down for credit
SHED.panel$rejected.for.credit <- SHED.panel$A1_a.pooled == "Yes"
# BK2_a
# In the past 12 months, did you and/or spouse or partner:
# - Purchase a money order from a place other than a bank
SHED.panel$purchase.non.bank.money.order <- SHED.panel$BK2_a.pooled == "Yes"
# BK2_b
# In the past 12 months, did you and/or spouse or partner:
# - Cash a check at a place other than a bank
SHED.panel$cash.check.non.bank <- SHED.panel$BK2_b.pooled == "Yes"
# BK2_c
# In the past 12 months, did you and/or spouse or partner:
# - Take out a payday loan or payday advance
SHED.panel$take.payday.loan <- SHED.panel$BK2_c.pooled == "Yes"
# BK2_d
# In the past 12 months, did you and/or spouse or partner:
# - Take out a pawn shop loan or an auto title loan
SHED.panel$take.auto.or.pawn.shop.loan <- SHED.panel$BK2_d.pooled == "Yes"
# BK2_e
# In the past 12 months, did you and/or spouse or partner:
# - Obtain a tax refund advance to receive your refund faster
SHED.panel$take.tax.refund.advance <- SHED.panel$BK2_e.pooled == "Yes"
# BNPL1
# In the past year, have you used a “Buy Now
# Pay Later” service to buy something?
SHED.panel$used.buy.now.pay.later <- SHED.panel$BNPL1.pooled == "Yes"
# ppfs1482 [Ipsos source]
# Q108: Where do you think your credit score falls
SHED.panel$perceived.credit.score <- factor(SHED.panel$ppfs1482.pooled, levels = c("Fair", "Excellent", "Good", "Poor", "Very poor", "Dont know"))
# Note "Dont know" has a curved apostrophe
# GE2A
# Some people earn money by selling items at
# places like flea markets and garage sales or
# through online marketplaces like eBay or
# Etsy. In the past month, have you made money
# by selling items in any of these ways?
SHED.panel$informal.selling.of.goods <- SHED.panel$GE2A.pooled == "Yes"
# GE1A
# In the past month, have you done any
# freelance or gig-work, either to supplement
# your income or as your main job?
SHED.panel$freelance.or.gig.work <- SHED.panel$GE1A.pooled == "Yes"
# E7
# During the past 12 months, have you
# personally experienced discrimination or
# unfair treatment because of your race,
# ethnicity, age, religion, disability status,
# sexual orientation, gender, or gender
# identity?
SHED.panel$experienced.discrimination <- SHED.panel$E7.pooled == "Yes"
# E8_b
# In the past 12 months, did you personally experience
# discrimination or unfair treatment while
# doing any of the following?
# - Banking or applying for a loan
SHED.panel$experienced.discrimination.in.banking <- SHED.panel$E8_b.pooled == "Yes"
# xlaptop
# Is R a KP laptop user?
SHED.panel$is.kp.laptop.user <- SHED.panel$xlaptop.pooled == "Yes"
# devicetype2
# DOV: Device Type - at the end of survey
SHED.panel$respondent.device.type <- relevel(SHED.panel$devicetype2.pooled, "WinPC")
# S21
# What was the main reason you used
# cryptocurrency to buy something, make a
# payment, or send money?
SHED.panel$why.used.crypto.as.payment <- SHED.panel$S21.pooled
SHED.panel.survey <- svydesign(ids = ~0, data = SHED.panel, weights = SHED.panel$panel_weight.common)
SHED.survey <- SHED.panel.survey
saveRDS(SHED.survey, file = "processed-data/SHED.rds")

View file

@ -0,0 +1,197 @@
library(data.table)
library(survey)
library(stargazer)
library(huxtable)
library(rvest)
SPACE <- read.csv("raw-data/SPACE_2022/SPACE_wide_2022.csv", stringsAsFactors = FALSE)
country.names <- matrix(c(
"CY", "Cyprus",
"MT", "Malta",
"BE", "Belgium",
"IT", "Italy",
"ES", "Spain",
"GR", "Greece",
"AT", "Austria",
"EE", "Estonia",
"FI", "Finland",
"IE", "Ireland",
"LT", "Lithuania",
"LU", "Luxembourg",
"LV", "Latvia",
"PT", "Portugal",
"SI", "Slovenia",
"SK", "Slovakia",
"FR", "France"
), ncol = 2, byrow = TRUE)
colnames(country.names) <- c("COUNTRY", "COUNTRY.name")
country.names <- as.data.frame(country.names)
SPACE <- merge(SPACE, country.names)
continuous.age <- matrix(c(
1, median(c(18, 24)),
2, median(c(25, 29)),
3, median(c(30, 34)),
4, median(c(35, 39)),
5, median(c(40, 44)),
6, median(c(45, 49)),
7, median(c(50, 54)),
8, median(c(55, 59)),
9, median(c(60, 64)),
10, median(c(64, 69)),
11, median(c(70, 74)),
12, 85),
ncol = 2, byrow = TRUE)
colnames(continuous.age) <- c("AGE", "Age")
continuous.age <- as.data.frame(continuous.age)
SPACE <- merge(SPACE, continuous.age)
colnames(continuous.age) <- c("AGE", "Age")
continuous.age <- as.data.frame(continuous.age)
SPACE <- merge(SPACE, continuous.age)
SPACE$Gender <- factor(SPACE$D1, level = 1:3, labels = c("Male", "Female", "Other, non-binary"))
SPACE$Gender <- relevel(SPACE$Gender, "Female")
cash.reserves.amount <- c(
"Less than €100",
"€100 - €250",
"€250 - €500",
"€500 - €1,000",
"€1,000 - €5,000",
"€5,000 - €10,000",
"More than €10,000"
)
SPACE$cash.reserves.amount <- factor(SPACE$QQ10, level = 1:7, labels = cash.reserves.amount)
SPACE$cash.reserves.any <- factor(SPACE$QQ9, level = 0:1, labels = c("No", "Yes"))
SPACE$cash.reserves <- ifelse(SPACE$cash.reserves.any == "Yes",
as.character(SPACE$cash.reserves.amount), "€0")
SPACE$cash.reserves <- as.factor(SPACE$cash.reserves)
setDT(SPACE)
SPACE[, has.crypto := factor(QQ1A_3, levels = 0:1, labels = c("No", "Yes"))]
SPACE[, crypto.use := factor(QQ1B, levels = 0:3, labels = c("None", "Investment", "Payment", "Both"))]
SPACE[is.na(crypto.use), crypto.use := "None"]
table(SPACE$crypto.use)
table(SPACE$has.crypto)
SPACE[, has.payment.account := factor(QQ1A_1, labels = c("No", "Yes"))]
SPACE[, has.card := factor(QQ1A_2, labels = c("No", "Yes"))]
SPACE[, has.financial.investments := factor(D10_6, labels = c("No", "Yes"))]
SPACE[, has.savings.account := factor(D10_3, labels = c("No", "Yes"))]
SPACE[, PaymentPreference := factor(QQ3, levels = c(3, 1:2), labels = c("No preference", "Cash", "Cashless"))]
# Put no preference first so it is the contrast level
SPACE[, "cash.wide.acceptance" := factor(QQ13A_1, labels = c("No", "Yes"))]
SPACE[, "cash.faster" := factor(QQ13A_2, labels = c("No", "Yes"))]
SPACE[, "cash.privacy" := factor(QQ13A_3, labels = c("No", "Yes"))]
SPACE[, "cash.easier" := factor(QQ13A_4, labels = c("No", "Yes"))]
SPACE[, "cash.safer" := factor(QQ13A_5, labels = c("No", "Yes"))]
SPACE[, "cash.immediately.settled" := factor(QQ13A_6, labels = c("No", "Yes"))]
SPACE[, "cash.spending.awareness" := factor(QQ13A_7, labels = c("No", "Yes"))]
SPACE[, "cash.other" := factor(QQ13A_8, labels = c("No", "Yes"))]
SPACE[, "cash.no.use" := factor(QQ13A_9, labels = c("No", "Yes"))]
SPACE[, "cash.none" := factor(QQ13A_10, labels = c("No", "Yes"))]
SPACE.survey <- svydesign(ids = ~ID, data = SPACE, weights = SPACE$Gross_weight)
saveRDS(SPACE.survey, file = "processed-data/SPACE.rds")
# Load the data again to get the diary data
space <- read.csv("raw-data/SPACE_2022/SPACE_wide_2022.csv", stringsAsFactors = FALSE)
setDT(space)
space.diary <- melt(space[, c("ID", "D1", "AGE", "WEEKDAY", "COUNTRY", "Gross_weight", colnames(space)[grepl("^QB", colnames(space))]), with = FALSE],
measure.vars = patterns(purpose = "^QB1", value = "^QB3", instrument = "^QB4"))
SPACE.diary <- melt(SPACE[, c("ID", "D1", "AGE", "WEEKDAY", "COUNTRY", "Gross_weight", colnames(SPACE)[grepl("^QB", colnames(SPACE))]), with = FALSE],
measure.vars = patterns(purpose = "^QB1", value = "^QB3", instrument = "^QB4"))
purpose.label <- c("Clothes/sportswear",
"Electronic goods/household appliances",
"Food/daily supplies",
"Medicine/cosmetics/drugstore products",
"Media/games/entertainment",
"Charitable donations",
"Travel/accommodation",
"Furniture/other household items",
"Tickets for events/attractions",
"Luxury goods",
"Financial: insurance, investment, crypto-assets",
"Household related services",
"Other")
SPACE.diary <- SPACE.diary[complete.cases(SPACE.diary), ]
SPACE.diary[purpose == 999999, purpose := NA]
SPACE.diary[value == 999999, value := NA]
SPACE.diary[instrument == 999999, instrument := NA]
SPACE.diary[, D1 := factor(D1)]
SPACE.diary[, AGE := factor(AGE)]
SPACE.diary[, WEEKDAY := factor(WEEKDAY)]
SPACE.diary[, COUNTRY := factor(COUNTRY)]
SPACE.diary[, purpose := factor(purpose, levels = seq_along(purpose.label), labels = purpose.label)]
SPACE.diary[, instrument := factor(instrument)]
SPACE.diary[, `Paid with crypto` := instrument == 10]
SPACE.diary.survey <- svydesign(ids = ~ID, data = SPACE.diary, weights = SPACE.diary$Gross_weight)
saveRDS(SPACE.diary.survey, file = "processed-data/SPACE_diary.rds")
# This computation takes a while
aggregate.crypto.spending.clustered <- as.data.frame(svyby(~I(365*value/1e+09), ~`Paid with crypto`,
design = as.svrepdesign(subset(SPACE.diary.survey,
purpose != "Financial: insurance, investment, crypto-assets")), svytotal))
aggregate.crypto.spending.clustered.CI <- aggregate.crypto.spending.clustered[2, 3] * 1.645
aggregate.crypto.spending.clustered[2, 2]
aggregate.crypto.spending.clustered[2, 2] + c(-1 * aggregate.crypto.spending.clustered.CI, aggregate.crypto.spending.clustered.CI)
aggregate.crypto.spending.clustered <- list(
point.estimate = aggregate.crypto.spending.clustered[2, 2],
CI.90.percent = aggregate.crypto.spending.clustered[2, 2] +
c(-1 * aggregate.crypto.spending.clustered.CI, aggregate.crypto.spending.clustered.CI)
)
saveRDS(aggregate.crypto.spending.clustered, file = "processed-data/EU-aggregate-crypto-spending.rds")