simulate_data: Simulate data from the model's data-generating process

View source: R/simulate_dgp.R

simulate_dataR Documentation

Simulate data from the model's data-generating process

Description

simulate_data simulates data according to the data-generating process defined by the model.

Usage

simulate_data(
  n_users = 200,
  n_domains = 500,
  n_groups = 2,
  group_prob = c(0.4, 0.6),
  user_variance = FALSE,
  params = list(alpha_mu = 2, alpha_sigma = 0.5, gamma_sigma = 0.75, theta_mu = c(-0.75,
    0.5), theta_sigma = c(0.25, 0.25), omega_user_shape = 5, omega_user_rate = 5,
    omega_domain_shape = 5, omega_domain_rate = 5)
)

Arguments

n_users

int, number of users in the data

n_domains

int, number of domains that users can share

n_groups

int, number of groups users can belong to

group_prob

numeric vector of length n_groups specifying the probability of a user belonging to each of the groups

user_variance

logical, whether to fit the model with an additional variance parameter per user (i.e. omega_user)

params

list containing complete (or partial) list of parameter values of the model. See Details section for more information.

Value

Returns a list with elements:

  • 'Y': A matrix (n_users x n_domains) of simulated counts of times each user shared a domain

  • 'group': Vector of length n_users indicating group membership of each user

  • 'anchors': Index position (column in 'shares_data') with the most extreme domains (minimum, maximum on latent scale)

  • 'parameters': Simulated parameters:

    • 'alpha': Numeric vector of length n_users, user-level intercepts

    • 'gamma': Numeric vector of length n_domains, domain-level intercepts

    • 'theta': Numeric vector of length n_users, ideology of each user

    • 'zeta': Numeric vector of length n_domains, ideology of each domain

    • 'omega_domain': Numeric vector of length n_domains, variance parameter for domain

    • 'omega_user': Numeric vector of length n_users, variance parameter for each user

Model details

The data-generating process is defined as the following:

NegBin(\pi_{img}, \omega_i\omega_m)

\pi_{img} = \alpha_i + \gamma_m - ||\vartheta_i - \zeta_m||^2,

where \alpha_i denotes a user-level intercept; \gamma_m, a news media domain intercept; \vartheta_i the sharing-ideology of user i; zeta_m the ideology of news media domain m; and \omega_i and \omega_m, user- and domain-level variance parameters. Further details regarding can be found in the library's vignette.

Examples

simulated_data <- simulate_data() 


SMAPPNYU/mediascores documentation built on June 28, 2024, 8:17 a.m.