Computer code and data Caswell, H. 2022. The formal demography of kinship IV: Two-sex models and their approximations. Demographic Research 47:359-396. The collection of code and data here contain XXX files. The Matlab source code files with extension .m are plain ASCII text files and can be read by any editor or word processor. The Matlab data files with extension .mat are binary files. They can be loaded in Matlab or, using the package Rmatlab, into R. kinship_function_2sex.m: This function takes as input the matrices for both sexes and the distributions of ages at maternity and paternity, and returns the age distributions of each of the types of kin, at each age of Focal. Symbols for the kin within this function correspond to the symbols in Figure 1 of the paper. twosex_analysis_program.m: This program reads in the data used in the examples in Section 4 of the paper and calls the two-sex kinship function. I have included in the program an analysis of total female and male kin numbers, as shown in Figure 6 of the paper, but the output is available to analyze as desired. UN_pxint.mat: A Matlab data file containing age-specific survival probabilities for males and females, obtained from the United Nations population prospects and interpolated to 1-year age intervals as described in Section 4.2. twosex_fxint.mat: A Matlab data file containing age-specific fertility rates for males and females, based on data provided by B. Schoumaker and interpolated to 1-year age intervals as described in Section 4.1 and shown in Figure 5. The survival data were obtained from: United Nations (2019). World population prospects 2019. Tech. Rep. Revision 2019, United Nations Department of Economic and Social Affairs, Population Division. And are available online at: https://population.un.org/wpp/Download/Archive/Standard/ The fertility data were provided by Dr. Bruno Schoumaker based on data reported in his paper: Schoumaker, B. (2019). Male fertility around the world and over time: How different is it from female fertility? Population and Development Review 45(3): 459Ð487. doi:10.1111/padr.12273. Analyses for this paper were carried out in Matlab R2020a, but the code should be compatible with any version, because it does not use any recently introduced capabilities.