Skip to content

R code to fit spatio-temporal models described in Adin et al. (2023, Statistical Modelling)

License

Notifications You must be signed in to change notification settings

spatialstatisticsupna/Confounding_article

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

53 Commits
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Alleviating confounding in spatio-temporal areal models

This repository contains the R code to fit with INLA the spatio-temporal models considered in the data analysis section of the paper "Alleviating confounding in spatio-temporal areal models with an application on crimes against women in India" (Adin et al., 2023). It also contains the necessary functions to reproduce all the figures and tables of the article.

Table of contents

Data

Dowry deaths and socio-demographic covariates in 70 districts of Uttar Pradesh, India, during the period 2001-2014. The data is publically available online without any form of restriction or copyright.

  • DowryDeaths_UttarPradesh.txt

    This .txt file contains a data set with the following variables:

    • dist: Districts.
    • year: Year (from 2001 to 2014).
    • state: Uttar Pradesh.
    • obs: Number of dowry deaths.
    • pop_linear: Female population between 15 and 49 years (linear interpolation).
    • x1: Sex ratio. Number of women per 1,000 men. Source: Office of the Registrar General and Census Commissioner, India (http://censusindia.gov.in).
    • x2: Population density (people/km2). Source: Office of the Registrar General and Census Commissioner, India (http://censusindia.gov.in).
    • x3: Female literacy rate. Office of the Registrar General and Census Commissioner, India (http://censusindia.gov.in).
    • x4: Per capita income referenced to year 2004. Source: Directorate of Economics and Statistics Government of Uttar Pradesh (http://updes.up.nic.in).
    • x5: Murder rate. Number of murders per 100,000 inhabitants. Source: Open Government Data Platform India (https://data.gov.in).
    • x6: Burglary rate. Number of burglaries per 100,000 inhabitants. Source: Open Government Data Platform India (https://data.gov.in).
  • Uttar_Pradesh_nb.graph

    An inla.graph object with the spatial neighborhood structure of the 70 districts of Uttar Pradesh.

  • carto_up.shp

    Shapefile containing the cartography of the 70 districts of Uttar Pradesh.

R code

R code to fit with INLA (http://www.r-inla.org/) the spatio-temporal models considered in the data analysis section of the present paper, and code to reproduce all the figures and tables. All the R files are written by the authors of the paper using R version 4.0.3 (2020-10-10).

  • DataAnalysis_INLA.R

    This R script contains the necessary functions to replicate with INLA the fit of the spatio-temporal models considered in the data analysis section of the paper. The code can be used with any other data sets with similar structure.

  • Figures_and_Tables.R

    This R script contains the necessary functions to reproduce all the figures and tables of the data analysis section of the present paper. The fitted models with INLA and PQL can be download from DataAnalysis_INLA.Rdata and DataAnalysis_PQL.Rdata, respectively.

Dealing with large datasets

When the number of small areas (denoted as S) and/or time periods (denoted as T) is large, fitting restricted regression models with INLA could be computationally very demanding due to the large and dense design matrices of the spatial, temporal and spatio-temporal random effects. The following code should be used in those cases where the posterior distributions of the fixed effects for the restricted regression models are estimated as a linear combination of the log-risks and the random effects of the models without accounting for confounding using the INLA::inla.make.lincombs() function.

Note that if we write the spatial model without accounting for confounding as

log(r)=Xβ + ξ

and the spatial restricted regression model as

log(r)=Xβ* + W-1/2LL′W-1/2ξ

the vector of fixed effects β* can be computed using the following expression:

β* = (XtX)-1Xt[log(r)-W-1/2LL′W-1/2ξ]

A similar approach is used to estimate the restricted regression spatio-temporal model described in Adin et al. (2021).

Acknowledgements

This work has been supported by the Spanish Ministry of Economy, Industry, and Competitiveness (project MTM2017-82553-R, AEI/FEDER, UE), and partially funded by la Caixa Foundation (ID 1000010434), Caja Navarra Foundation and UNED Pamplona, under agreement LCF/PR/PR15/51100007.

References

Adin, A., Goicoa, T., Hodges, J.S., Schnell, P., and Ugarte, M.D. (2023). Alleviating confounding in spatio-temporal areal models with an application on crimes against women in India. Statistical Modelling, 23(1), 9-30. DOI: 10.1177/1471082X211015452

About

R code to fit spatio-temporal models described in Adin et al. (2023, Statistical Modelling)

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Contributors 3

  •  
  •  
  •  

Languages