Learn R Programming

sparsegl (version 1.1.1)

trust_experts: Trust in scientific experts during the Covid-19 pandemic

Description

A dataset containing a measurement of "trust" in experts along with other metrics collected through the Delphi Group at Carnegie Mellon University U.S. COVID-19 Trends and Impact Survey, in partnership with Facebook. This particular dataset is created from one of the public contingency tables, specifically, the breakdown by state, age, gender, and race/ethnicity published on 05 February 2022.

Usage

trust_experts

Arguments

Format

A data.frame with 9759 rows and 8 columns

trust_experts

Real-valued. This is the average of pct_trust_covid_info_* where * is each of doctors, experts, cdc, and govt_health.

period

Factor. Start date of data collection period. There are 13 monthly periods

region

Factor. State abbreviation.

age

Factor. Self-reported age bucket.

gender

Factor. Self-reported gender.

raceethnicity

Factor. Self-reported race or ethnicity.

cli

Real-valued. This is the wcli indicator measuring the percent of circulating Covid-like illness in a particular region. See the Delphi Epidata API for a complete description.

hh_cmnty_cli

Real-valued. This is the whh_cmnty_cli indicator measuring the percent of people reporting illness in their local community and household.

Examples

Run this code
if (FALSE) {
library(splines)
library(dplyr)
library(magrittr)
df <- 10

trust_experts <- trust_experts %>%
  mutate(across(
    where(is.factor),
    ~ set_attr(.x, "contrasts", contr.sum(nlevels(.x), FALSE, TRUE))
  ))

x <- Matrix::sparse.model.matrix(
  ~ 0 + region + age + gender + raceethnicity + period +
    bs(cli, df = df) + bs(hh_cmnty_cli, df = df),
  data = trust_experts, drop.unused.levels = TRUE
)

gr <- sapply(trust_experts, function(x) ifelse(is.factor(x), nlevels(x), NA))
gr <- rep(seq(ncol(trust_experts) - 1), times = c(gr[!is.na(gr)], df, df))
fit <- cv.sparsegl(x, trust_experts$trust_experts, gr)
}

Run the code above in your browser using DataLab