The DHS Program User Forum
Discussions regarding The DHS Program data and results
Home » Topics » Fertility » cannot reproduce TFR using R-package DHS.rates
cannot reproduce TFR using R-package DHS.rates [message #18058] Mon, 02 September 2019 03:27 Go to next message
cfq
Messages: 4
Registered: September 2019
Member
Hi all,

I am trying to reproduce the TFR by India states with the data set IAIR23SV. I am using the R-package DHS.rates and the function fert(). But the TFR values I got are very different from the STATcompiler.

My R code:
##-------------------------------
# read in DHS data. I resave the SPSS file into csv format, nothing else is changed
data.full <- read.csv("IAIR23SV.csv", header = TRUE, stringsAsFactors = FALSE, strip.white = TRUE)

# clean the column names of the data file to fit to the fert() function
new.names <- names(data.full)
new.names <- tolower(new.names)
new.names <- gsub(".", "_", new.names, fixed = TRUE)
names(data.full) <- new.names

# ger TFR
library(DHS.rates)
res.t <- fert(data.full, Indicator = "tfr", JK = "Yes", Class = "v024")
res.t[order(res.t$Class), ] #show results
##-------------------------------

Attached are the screen shot of my R code output, and the STATcompiler. You can see none of the TFR values are the same.

There is no error message when I run my R code. Could any one let me know what cause the difference and how can I change my R code in order to get the same results as the STATcompiler? Thanks!
/index.php?t=getfile&id=1463&private=0
/index.php?t=getfile&id=1464&private=0

[Updated on: Mon, 02 September 2019 03:27]

Report message to a moderator

Re: cannot reproduce TFR using R-package DHS.rates [message #18072 is a reply to message #18058] Thu, 05 September 2019 03:47 Go to previous messageGo to next message
cfq
Messages: 4
Registered: September 2019
Member
Appreciated if someone can let me know what went wrong. Thank you all!
Re: cannot reproduce TFR using R-package DHS.rates [message #18073 is a reply to message #18058] Thu, 05 September 2019 03:58 Go to previous messageGo to next message
schoumaker is currently offline  schoumaker
Messages: 40
Registered: May 2013
Location: Belgium
Member
It seems this is related to the all woman factor, which should be used to inflate exposure when the survey is conducted among ever married women only. This is possible with the R package.
I do not see the all woman factor for the states in the data set, but you could compute them yourself (it is explained p 1.40 in the guide to DHS Statistics -
https://dhsprogram.com/pubs/pdf/DHSG1/Guide_to_DHS_Statistic s_DHS-7.pdf).
Best,
Bruno


Bruno Schoumaker
Centre for Demographic Research
Université catholique de Louvain
Re: cannot reproduce TFR using R-package DHS.rates [message #18074 is a reply to message #18073] Thu, 05 September 2019 07:08 Go to previous messageGo to next message
cfq
Messages: 4
Registered: September 2019
Member
Hi Bruno,

Thanks for the helpful reply! I post my updated R code here:

My R code:
##-------------------------------
# read in DHS data. I resave the SPSS file into csv format, nothing else is changed
data.full <- read.csv("IAIR23SV.csv", header = TRUE, stringsAsFactors = FALSE, strip.white = TRUE)

# clean the column names of the data file to fit to the fert() function
new.names <- names(data.full)
new.names <- tolower(new.names)
new.names <- gsub(".", "_", new.names, fixed = TRUE)
names(data.full) <- new.names

# ger TFR
library(DHS.rates)
res.t <- fert(data.full, Indicator = "tfr", JK = "Yes", Class = "v024",
# this is the new line to indicate the data is for ever-married women and the adjustment vector name is awfactr
EverMW = "Yes", AWFact = "awfactr")
res.t[order(res.t$Class), ] #show results
##-------------------------------

Unfortunately, the awfactr (all-women factor for region) is empty. But otherwise it should be able to reproduce the results. Thanks!

Re: cannot reproduce TFR using R-package DHS.rates [message #18075 is a reply to message #18074] Thu, 05 September 2019 10:04 Go to previous message
cfq
Messages: 4
Registered: September 2019
Member
I am able to recompute the all-women factors by region from the PR file after all. The pdf that Bruno shared is very useful.
Previous Topic: Using tfr2 to Calculate age specific marital fertility rate
Goto Forum:
  


Current Time: Sun Sep 22 17:12:20 Eastern Daylight Time 2019