epiforecasts / socialmixr

R package for deriving social mixing matrices from survey data.
http://epiforecasts.io/socialmixr/
Other
38 stars 10 forks source link

Splitting contact matrices by sex #89

Open NaomiWaterlow opened 1 year ago

NaomiWaterlow commented 1 year ago

I am trying to create contact matrices split by sex. I think I can do this (using polymod data) by filtering the survey participants and contact matrices by sex, and creating the split matrices (i.e. m-m contact rates, m-f contact rates, etc.) However to get a symmetric contact matrix I think I have to assume that there is an equal age-distribution by gender in the population, (which is not the case, especially in older ages). Is there a way to do this taking the actual age-sex distributions in the population?

sbfnk commented 4 months ago

This is not currently possible (you can do it for m-m and f-f but not m-f or f-m) but it might not be tricky to add. Just to make sure I understand correctly though, you want to create a matrix that is something like the one below but scaled somehow such that $C_{ij}N^fi=C{ji}N^m_j$?

library("socialmixr")
#> 
#> Attaching package: 'socialmixr'
#> The following object is masked from 'package:utils':
#> 
#>     cite
data(polymod)
C <- contact_matrix(
  survey = polymod,
  filter = list("part_gender" = "F", cnt_gender = "M"),
  age.limits = seq(0, 20, by = 5),
  countries = "United Kingdom"
)
#> Removing participants that have contacts without age information. To change this behaviour, set the 'missing.contact.age' option
C$matrix
#>          contact.age.group
#> age.group     [0,5)    [5,10)   [10,15)   [15,20)      20+
#>   [0,5)   0.8979592 0.3877551 0.2244898 0.1836735 1.612245
#>   [5,10)  0.3207547 2.4150943 0.4339623 0.1509434 1.924528
#>   [10,15) 0.2115385 0.6346154 2.0961538 0.4615385 2.211538
#>   [15,20) 0.1153846 0.3076923 0.6730769 2.3076923 2.673077
#>   20+     0.2798742 0.3364780 0.2735849 0.3836478 3.446541

Created on 2024-05-03 with reprex v2.1.0

NaomiWaterlow commented 4 months ago

Yes. I want to create symetric contact matrixes for f-f, f-m, m-f and m-m, so that I can track the transmission between / across sexes, that I can use with different populations. Thanks!

sbfnk commented 1 week ago

Sorry, I realise this is quite late but in this case could you not just use the command as above and assume that age demographics are the same for male and female parts of the population (which presumably they pretty much are in all cases)? If happy with this you could set symmetric = TRUE and get a symmetric matrix.

The general case I think could be solved by adding a contacts.pop argument and allowing the user to specify different populations for survey participants and contacts. That would be a nice addition.

NaomiWaterlow commented 1 week ago

Thanks. Yes, this is the assumption I've gone with. I just ideally didn't want to assume that the age demographhics are the same across sexes, as for example in older ages you get more women than men (e.g. aged 90+ the population is only 30% male).