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
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

 
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: Tue Nov 5 23:39:36 Coordinated Universal Time 2024