The DHS Program User Forum
Discussions regarding The DHS Program data and results
Home » Topics » Fertility » Adolescent Fertility Rate(FE_FERT.do File)-Nigeria (Chapter 5.1 Code(Fertility))
Adolescent Fertility Rate(FE_FERT.do File)-Nigeria [message #19766] Wed, 12 August 2020 19:52 Go to next message
placidplus is currently offline  placidplus
Messages: 31
Registered: August 2020
Member
Hello Trevor!
I am estimating adolescent fertility rate using the "FE_FERT.do" file. When it comes the stage of generating "Completed fertility - Mean number of CEB to women age 40-49"(fe_ceb_comp). It gives me an "invalid syntax
r(198);" error prompt. I need help to get past this stage. Thank you.

Kind Regards,
Placid.
Re: Adolescent Fertility Rate(FE_FERT.do File)-Nigeria [message #19771 is a reply to message #19766] Thu, 13 August 2020 12:12 Go to previous messageGo to next message
Courtney-DHS is currently offline  Courtney-DHS
Messages: 6
Registered: June 2018
Location: Rockville, Maryland
Member
Hello Placid,

I'm wondering if the error prompt is due to the version of Stata. However this code should work for most recent versions of Stata.
The estimate that you are trying to calculate for fe_ceb_comp is the mean shown in the results you attached (=6.315).

I would suggest turning the result into a 'normal' matrix first, for example:

mat mat1 = e(b)
gen fe_ceb_comp= mat1[1,1]


Let us know what version of Stata you have and if this works for you.
Re: Adolescent Fertility Rate(FE_FERT.do File)-Nigeria [message #19772 is a reply to message #19771] Thu, 13 August 2020 20:36 Go to previous messageGo to next message
placidplus is currently offline  placidplus
Messages: 31
Registered: August 2020
Member
Thanks Courtney for your response. The modification you provided made the program run smoothly. I am actually interested in estimating Adolescent birth rate (aged 10-14 and 15-19) per 1,000. That is Adolescent birth rates in the profiles of 10-14 and 15-19. After running the "FE_TFR.do" code, it produced a dataset referred as final_file_save file with rates(I had to save"final_file_save" instead). I was having difficulty in finding estimates for the profiles of interest. I also observed that "final_file_save"
is suppose to be a program to produce tables and not to be saved as a file. However when I ran it as the program( final_file_save) prompted an error "unknown function ustrtitle()"(Please find attached snapshot). I also observed that "FE_ASFR_10_14.do"
is supposed to provided age specific fertility rates for 10-14 year old only. This program runs perfectly well until when it gets to the stage of running the following programs "save_IRtemp(error=variable caseid not found), calc_fert_rates_10to14(error=variable caseid not found) and final_file_save(error= variable EMW_survey not found). The snapshots of the errors are attached. Please I need help in extracting adolescent birth rates in the profiles of 10-14 and 15-19. Please also find the attached summary dataset referred as "final_file_save.dta" and "partial_results.dta". Thank you for your help.

Best Regards,
Placid Ugoagwu.
Re: Adolescent Fertility Rate(FE_FERT.do File)-Nigeria [message #19834 is a reply to message #19766] Wed, 19 August 2020 11:02 Go to previous messageGo to next message
placidplus is currently offline  placidplus
Messages: 31
Registered: August 2020
Member
Hello Courtney/DHS Program User Forum,
I am still hanging on for a response on the previous post. Thank you in anticipation for your assistance.

Kind Regards,
Placid.
Re: Adolescent Fertility Rate(FE_FERT.do File)-Nigeria [message #19849 is a reply to message #19834] Thu, 20 August 2020 07:27 Go to previous messageGo to next message
Bridgette-DHS is currently offline  Bridgette-DHS
Messages: 3017
Registered: February 2013
Senior Member

Following is a response from DHS Senior Analysis & Research Manager, Shireen Assaf:

We have just tested the Chapter 5 GitHub code for the Nigeria 2018 survey and it runs smoothly. You may be running the files separately, rather than just running the main file for the chapter. You need to run the code from the FEmain.do file. Also read the readme file that gives more instructions on how to run the GitHub code correctly.

Re: Adolescent Fertility Rate(FE_FERT.do File)-Nigeria [message #19863 is a reply to message #19849] Sat, 22 August 2020 11:12 Go to previous messageGo to next message
placidplus is currently offline  placidplus
Messages: 31
Registered: August 2020
Member
Thanks for your reply. I have actually being running the codes from the "!FEmain.do". However, when it about to execute the "final_file_save" in the "FE_TFR.do", the program ends the attached error.

Re: Adolescent Fertility Rate(FE_FERT.do File)-Nigeria [message #19871 is a reply to message #19863] Mon, 24 August 2020 09:04 Go to previous messageGo to next message
Bridgette-DHS is currently offline  Bridgette-DHS
Messages: 3017
Registered: February 2013
Senior Member

Following is another response from DHS Senior Analysis & Research Manager, Shireen Assaf:

It is possible you are using an older version of Stata that does not have this package installed. Please try using "findit ustrtitle" or "search ustrtitle" to find it and install it.

Re: Adolescent Fertility Rate(FE_FERT.do File)-Nigeria [message #19886 is a reply to message #19871] Tue, 25 August 2020 10:17 Go to previous messageGo to next message
placidplus is currently offline  placidplus
Messages: 31
Registered: August 2020
Member
Thanks for this direction. After installing the "ustrtitle" package, the program "final_file_save" is now working. However, appears that it dis-enabled the functioning of the code referred to as "main" used with the scalar function. The command line that previously worked now complains of syntax issues. Please see the attach snapshot for demonstration. Once this is resolved, I think I would have gotten my work completed on this. This help is highly appreciated.
Re: Adolescent Fertility Rate(FE_FERT.do File)-Nigeria [message #19889 is a reply to message #19886] Tue, 25 August 2020 10:33 Go to previous messageGo to next message
Bridgette-DHS is currently offline  Bridgette-DHS
Messages: 3017
Registered: February 2013
Senior Member

Following is another response from DHS Senior Analysis & Research Manager, Shireen Assaf:

"main" is a program defined on line 661 of the FE_TFR.do file. So if you ran that program, Stata should recognize what "main" is.

Please try to run everything from the beginning using the FEmain.do file. Make sure you have the correct paths and define your survey. Please also make sure that you have not removed anything or commented anything out that is required for the files to run. I ran the FEmain.do file from GitHub using the Nigeria survey and it all runs smoothly.

Re: Adolescent Fertility Rate(FE_FERT.do File)-Nigeria [message #19890 is a reply to message #19889] Tue, 25 August 2020 10:41 Go to previous messageGo to next message
placidplus is currently offline  placidplus
Messages: 31
Registered: August 2020
Member
Thanks for the information. I only added 2 additional covariates to the code. Like "State Category" and Age group in years.
replace covariatelabel="Age group in years" if regexm(covariate,"v013")==1
replace covariatelabel="State Category" if regexm(covariate,"StateCategory")==1

I am also attaching the overall code and the modification I did. Thank you for your help

  • Attachment: FE_TFR_2.do
    (Size: 21.07KB, Downloaded 324 times)
Re: Adolescent Fertility Rate(FE_FERT.do File)-Nigeria [message #19893 is a reply to message #19890] Tue, 25 August 2020 10:47 Go to previous messageGo to next message
placidplus is currently offline  placidplus
Messages: 31
Registered: August 2020
Member
I also ran the attached code on the background to create the state categories I wanted.
Re: Adolescent Fertility Rate(FE_FERT.do File)-Nigeria [message #19896 is a reply to message #19893] Tue, 25 August 2020 14:07 Go to previous messageGo to next message
Bridgette-DHS is currently offline  Bridgette-DHS
Messages: 3017
Registered: February 2013
Senior Member

Following is another response from DHS Senior Analysis & Research Manager, Shireen Assaf:

It appears to me that you have added the covariates correctly but I believe you may need to add changes to line 840.
It would be difficult to identify your problem. I suggest running the original FE_TFR.do file first and see if that runs ok. Again you need to run these files from the main file, that is where the globals are defined such as the global $irdata. Then after you make sure the original do files run ok, try with your revised FE_TFR2.do file. This means you would need to rename FE_TFR.do in the main file to FE_TFR2.do

Hope you can identify the error. Good luck.
Re: Adolescent Fertility Rate(FE_FERT.do File)-Nigeria [message #19899 is a reply to message #19896] Tue, 25 August 2020 18:40 Go to previous message
placidplus is currently offline  placidplus
Messages: 31
Registered: August 2020
Member
Thanks very much for your response. I got the modified script to work but the covariates I created in the script would not show on the newly generated dataset with the Total Fertility Rates. Thanks again.
Previous Topic: I need Stata codes to compute parameters (Cm, Cc, Ci and Ca) of the Bongaarts' model using DHS data.
Next Topic: Table on Fertility Planning Status from NFHS-4 data
Goto Forum:
  


Current Time: Thu Mar 28 14:23:27 Coordinated Universal Time 2024