Fitting synthetic data
Siliang Zhang edited this page Aug 16, 2022
·
6 revisions
This is an example of fitting pseudo data for the paper
Kuha, J., Zhang, S., & Steele, F. (2021). Latent variable models for multivariate dyadic data with zero inflation: Analysis of intergenerational exchanges of family support.
##############################################
## Load synthetic data
rm(list = ls())
load(url("https://github.com/slzhang-fd/jsem-ukhls/blob/main/inst/UKHLS_synthetic.rda?raw=true"))
##############################################
## Load jsem package
library(jsem)
##############################################
## Fit full model
mod_f <- formula(~ female + partnerinhh + emp_unemployed + emp_inactive +
cany + cy_2to4 + cy_5to10 + cy_11to16 + cy_gt16 + age40 +
parmaxage70 + palone + distlong + nsibs12 + nsibs3plus + logincome)
##############################################
## It takes about 3 hrs for the following MCMC length settings
## A shorter length may be chosen to save some time
pseudo_data_res <-
dylanie_model_simple(mod_f, data = pseudo_data, mcmc_len = 1000)
pseudo_data_res <-
dylanie_model_update(pseudo_data_res, mcmc_len = 9000)