Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fitting stan model to 1 wave #3

Open
joshuategegne1 opened this issue Dec 7, 2022 · 1 comment
Open

Fitting stan model to 1 wave #3

joshuategegne1 opened this issue Dec 7, 2022 · 1 comment

Comments

@joshuategegne1
Copy link
Contributor

Hi Shozen,

We have tried to use the run-stan-single.R script to fit the model in hsgp-eq-cd.stan to 1 wave of the covimod data, and have had a few issues (mainly with some of the helper functions) that may be of your interest.

On line 71, there is an error when applying add_contact_vector, this is because the third argument specifies if you're working with 1 wave, so single must be set to TRUE. So dt.offsets is not necessary

On line 77, when running add_row_major_idx, I found that dt.offsets didn't have all the variables required but dt.cnt did, so we changed the 2nd argument. I also noticed that the u column (index for waves and repetition) was missing but I can see you have made a note of this in stan-utility.R.

On line 80, when using add_part_offsets the second argument is contacts, so rather than being set to dt.offsets, this should be set to dt.cnt

On line 95, when applying add_hsgp_parms, args$hsgp_m needs to be specified as the 4th argument, the second dimension of the HSGP basis approximation

After changing this, I was able to compile the model but then get an error when fitting the stan_data:
Error: Missing input data for the following data variables: N_MM, N_FF, N_MF, N_FM, ROW_MAJOR_IDX_MM, ROW_MAJOR_IDX_FF, ROW_MAJOR_IDX_MF, ROW_MAJOR_IDX_FM, log_N_M, log_N_F, log_S_M, log_S_F, log_P_M, log_P_F.

With these constants and offsets that are missing, you can ensure that they are added to stan_data by changing survey = "COVIMOD" to survey = "POLYMOD" in the helper functions from stan-utility.R. After making these changes, I got a new error that there was a dimension mismatch in log_N_M (it is meant to be length 85 but is actually smaller)

Thanks,
Joshua

@ssl219
Copy link

ssl219 commented Dec 7, 2022

Dear Shozen,

I hope you are well.

Following Joshua’s issue, just two more things to add:

  1. On line 71 of the run-stan-single.R script, for a single wave on the COVIMOD study, the dt.offsets argument was not needed as outlined in the definition of the add_contact_vector function in the file stan-utility.R :

instead of:
stan_data <- add_contact_vector(stan_data, dt.cnt, dt.offsets)

we used:
stan_data <- add_contact_vector(stan_data, dt.cnt, single=TRUE)

  1. We have also tried fitting the hsgp-eq-lrd-a65 model and we cannot seem to find the required helpers.stan file in the Github repository? The helpers.stan file is mentioned in line 4 of the hsgp-eq-lrd-a65.stan file.

Thank you for your time and help,
Selena Linden

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants