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

Wave 1 CoMix yields all NA matrix #120

Closed
sbfnk opened this issue Apr 26, 2024 · 1 comment · Fixed by #127
Closed

Wave 1 CoMix yields all NA matrix #120

sbfnk opened this issue Apr 26, 2024 · 1 comment · Fixed by #127

Comments

@sbfnk
Copy link
Collaborator

sbfnk commented Apr 26, 2024

          A follow up question I had was how to stratify on survey wave, e.g. subset on wave 1 participants in CoMix, and generate the corresponding social contact matrix -  at the moment it's returning NA entries (see below), but there's probably something simple I'm not getting.

Full draft walkthrough is here.

# get UK CoMix data from 2020-22 - note this is slow to load
comix_uk <- get_survey("https://zenodo.org/doi/10.5281/zenodo.4905745")

# subset on 1st wave of surveys in April/May 2020
comix_uk_wave_1 <- comix_uk
comix_uk_wave_1$participants <- comix_uk$participants |> filter(wave==1)

contact_data_comix <- socialmixr::contact_matrix(
  comix_uk_wave_1,
  countries = "United Kingdom",
  age.limits = c(0, 5, 18, 40, 65),
  symmetric = TRUE
)
> contact_data_comix
$matrix
      contact.age.group
       [0,5) [5,18) [18,40) [40,65) 65+
  [1,]    NA     NA      NA      NA  NA
  [2,]    NA     NA      NA      NA  NA
  [3,]    NA     NA      NA      NA  NA
  [4,]    NA     NA      NA      NA  NA
  [5,]    NA     NA      NA      NA  NA

$demography
   age.group population proportion  year
      <char>      <num>      <num> <int>
1:     [0,5)    4370647         NA  1950
2:    [5,18)    8910009         NA  1950
3:   [18,40)   15997248         NA  1950
4:   [40,65)   15855240         NA  1950
5:       65+         NA         NA  1950

$participants
   age.group participants   proportion
      <char>        <int>        <num>
1:     [0,5)          192 0.1594684385
2:    [5,18)          998 0.8289036545
3:   [18,40)            1 0.0008305648
4:   [40,65)           11 0.0091362126
5:       65+            2 0.0016611296

Originally posted by @adamkucharski in #108 (comment)

@sbfnk
Copy link
Collaborator Author

sbfnk commented Sep 11, 2024

This is caused by a combination of issues:

  1. the COMIX data has the year column set to 20. The package takes the nearest population data which is from 1950.
  2. wpp_age returns some age groups as having NA population size if they were not represented in a given census.

We can fix (2) but (1) would have to be fixed by updating the raw data, I think.

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

Successfully merging a pull request may close this issue.

1 participant