Supplemental computer code and data for: Caswell, H. and Song, X. 2021. The formal demography of kinship III: Kinship dynamics with time-varying demographic rates. Demographic Research 45:517-546. This Supplement contains Matlab code and data for the example presented in the paper, examining the kinship dynamics of Sweden combining historical (1891-2018) data and projections (2019-2021) of future mortality and fertility trends. The programs have been run under Matlab v. 2020a, and should be compatible with earlier versions. SWEhist_matrices.mat This is a Matlab data file containing the data for historical Sweden. It contains a 1x128 cell array, one cell for each year from 1891 to 2018. Each cell contains the following matrices: U = survival matrix F = fertility matrix popsize = vector containing female population size in each age class pi = vector containing the probability distribution of age of mothers at birth of offspring om = the maximum age (111 in this case) year = the year of the data The survival matrix is calculated from age-specific female mortality probabilities (q_x) from the Human Mortality Database (https://mortality.org). The fertility matrix is constructed from age-specific female fertilty rates, dividing by 2 to express fertility in terms of female offspring, from the Human Fertility Database (https://humanfertility.org). The female population size vector is used to calculate the distribution of ages of mothers at birth of offspring according to equation (14). This information was also obtained from the Human Mortality Database. SWEproj_matrices.mat This data file contains the same information as does SWEhist_matrices.mat, but for mortality, fertility, and population size projected by the Swedish Statistical Office, from 2019 to 2021. The mortality rates are available online at: https://www.statistikdatabasen.scb.se/pxweb/en/ssd/START__BE__BE0401__BE0401F/BefProgDodstal18/ The fertility rates are available online at: https://www.statistikdatabasen.scb.se/pxweb/en/ssd/START__BE__BE0401__BE0401F/BefProgFruktTot18/ sweden_analysis_5354.m This is a Matlab script that carries out the analysis for Sweden. It reads in the historical and the projected matrices, and calls the functions that return the kinship output. There are two programs for those functions. period_kin.m This function calculates the kinship structure for a time-invariant model subject to the demogaphic rates of a single period. It is used for the first year of the analysis (1891 in this case) because no previous demographic rates are availabe. timevarying_kin.m This function calculates the kinship structure at the next year, given the kin structure at the present year. It produces a structure array (called kout) with fields for each of the kin types (e.g., kout.A) and for all kin types combined (e.g., kout.allkin). The field kout.A contains a 2-dimensional array of daughters of Focal. Rows represent ages of daughters; columns represent ages of Focal. The field kout.allkin contains a 3-dimensional array of output for all kin. Rows represent ages of kin, columns represent ages of Focal, and pages represent types of kin (1,...,14). The field kout.allkin2 is similar, but some kin types are aggregated: younger and older sisters combined into sisters, nieces through older and younger sisters combined into nieces, aunts older and younger than mother combined into aunts, and cousins through older and younger aunts combined into cousins. Thus pages in kout.allkin2 represent types of kin (1,...,10).