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 previous message
Messages: 4
Registered: September 2019
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
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!

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

Report message to a moderator

Read Message
Read Message
Read Message
Read Message
Read Message
Previous Topic: NFHS-4 Median Birth interval
Next Topic: B11 is actually missing or it represent first birth?
Goto Forum:

Current Time: Mon May 27 03:00:19 Coordinated Universal Time 2024