Learn R Programming

rstap (version 1.0.3)

example_model: Example model

Description

A model for use in rstap examples.

Arguments

Format

Calling example("example_model") will run the model in the Examples section, below, and the resulting stapreg object will then be available in the global environment. The chains and iter arguments are specified to make this example small in size. In practice, we recommend that they be left unspecified in order to use the default values (4 and 2000 respectively) or increased if there are convergence problems. The cores argument is optional and on a multicore system, the user may well want to set that equal to the number of chains being executed.

See Also

The Longituinal Vignette for stap_glmer.

Examples

Run this code
# NOT RUN {
 ## following lines make example run faster
distdata <- subset(homog_longitudinal_bef_data[,c("subj_ID","measure_ID","class","dist")],
                   subj_ID<=10)
timedata <- subset(homog_longitudinal_bef_data[,c("subj_ID","measure_ID","class","time")],
                   subj_ID<=10)
timedata$time <- as.numeric(timedata$time)
subjdata <- subset(homog_longitudinal_subject_data,subj_ID<=10)
example_model <- 
  stap_glmer(y_bern ~ centered_income +  sex + centered_age + stap(Coffee_Shop) + (1|subj_ID),
             family = gaussian(),
             subject_data = subjdata,
             distance_data = distdata,
             time_data = timedata,
             subject_ID = 'subj_ID',
             group_ID = 'measure_ID',
             prior_intercept = normal(location = 25, scale = 4, autoscale = FALSE),
             prior = normal(location = 0, scale = 4, autoscale = FALSE),
             prior_stap = normal(location = 0, scale = 4),
             prior_theta = list(Coffee_Shop = list(spatial = log_normal(location = 1,
                                                                             scale = 1),
                                                         temporal = log_normal(location = 1,
                                                                               scale = 1))),
             max_distance = 3, max_time = 50,
             # chains, cores, and iter set to make the example small and fast
             chains = 1, iter = 25, cores = 1)

# }

Run the code above in your browser using DataLab