The DHS Program User Forum
Discussions regarding The DHS Program data and results
Home » Topics » Fertility » cannot reproduce TFR using R-package DHS.rates
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 previous 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!

 
Read Message
Read Message
Read Message
Read Message
Read Message
Previous Topic: Calculating fertility rates
Next Topic: Using tfr2 to Calculate age specific marital fertility rate
Goto Forum:
  


Current Time: Fri Dec 3 23:51:00 Coordinated Universal Time 2021