The DHS Program User Forum
Discussions regarding The DHS Program data and results
Home » Data » Dataset use in Stata » Applying weights to multilevel hazard analysis using Cox regression
Applying weights to multilevel hazard analysis using Cox regression [message #23946] Wed, 19 January 2022 16:18 Go to next message
Ugonna is currently offline  Ugonna
Messages: 26
Registered: June 2020
Member


Hello everyone,

I'm running a Stata code for frailty survival model (multilevel hazard analysis) using 2018 Nigeria Demographic and Health Survey Data.

I wrote the design code using the guide provided on this forum:
svyset v021, weight(wt2_1) strata(v022) , singleunit(centered) || _n, weight(wt1_1)

But when I applied the weight in the code below, it returned an error message that 'option shared() was not allowed with the svy prefix'
svy: stcox i.w_quintile elect i.anc i.v024 v025 poverty_prop sec_edu_prop, efron shared(v021) || v021:


Please how do I apply weight when running a multilevel hazard analysis using Cox regression?

Thank you.
Re: Applying weights to multilevel hazard analysis using Cox regression [message #23954 is a reply to message #23946] Thu, 20 January 2022 15:54 Go to previous messageGo to next message
Bridgette-DHS is currently offline  Bridgette-DHS
Messages: 3199
Registered: February 2013
Senior Member
Following is a response from DHS Research & Data Analysis Director, Tom Pullum:

We cannot provide support for this command. However, I'll say that there are probably just two possibilities. The first is that you have a problem with the svyset command. Please check it against the syntax in DHS Methodological Report #27 (https://www.dhsprogram.com/pubs/pdf/MR27/MR27.pdf). The other possibility is that the command (with the "shared" option) simply will not work (as it is currently programmed by Stata) with this multilevel svyset command. That sort of thing can happen. Many commands have become more flexible in successive releases of Stata.

If the command works without the shared option, then the syntax of svyset must be ok. If so, you will have to ask Stata or the Stata forum about the shared option.

Re: Applying weights to multilevel hazard analysis using Cox regression [message #23956 is a reply to message #23954] Thu, 20 January 2022 17:19 Go to previous messageGo to next message
Ugonna is currently offline  Ugonna
Messages: 26
Registered: June 2020
Member
Thanks Bridgette and Tom for the response.

The only difference from my syntax and the one in DHS methodological report #27 is the psu. I understand I can either use v001 or v021 as the psu. Correct me if I'm wrong please.

The svyset command executed and showed this result:

'Note: Stage 1 is sampled with replacement; further stages will be ignored for variance
estimation.

pweight: <none>
VCE: linearized
Single unit: centered
Strata 1: v022
SU 1: v021
FPC 1: <zero>
Weight 1: wt2_1
Strata 2: <one>
SU 2: <observations>
FPC 2: <zero>
Weight 2: wt1_1'

When I run the syntax "svy: stcox i.w_quintile elect i.anc i.v024 v025 poverty_prop sec_edu_prop || v021:" without the shared option it returns this error message:
'variable wt1_1*wt2_1 not found'.

And then when I run it without the svy option 'stcox i.w_quintile elect i.anc i.v024 v025 poverty_prop sec_edu_prop, efron shared(v021)' it executes successfully, even though it takes a long time to do that.

I also observed that I could run this 'svy: melogit inf_death i.w_quintile elect || v021:' successfully, although that is not what I'm using in my analysis.

Could it be that 'svy' is not needed when running a Cox multilevel regression?

I have also posted the question on Stata forum.


Re: Applying weights to multilevel hazard analysis using Cox regression [message #23957 is a reply to message #23956] Fri, 21 January 2022 08:05 Go to previous messageGo to next message
Bridgette-DHS is currently offline  Bridgette-DHS
Messages: 3199
Registered: February 2013
Senior Member

Following is a response from DHS Research & Data Analysis Director, Tom Pullum:

Yes, for the cluster ID you can use either v021 and v001. When you get a Stata error message such as "variable wt1_1*wt2_1 not found" it means you have tried to do some algebra that is not allowed within a command. You would just need a line such as "gen wt_1= wt1_1*wt2_1" and then insert "wt_1" where you may have had "wt1_1*wt2_1". However, there may be a bigger issue. There are some instances in Stata in which two options are incompatible with each other, and you don't get an error message telling you that's why the command will not work.

It's very important to include as much of svyset as you can. I would try simplifying svyset, and/or simplifying the cox options, until you get a combination that works. Then proceed with your analysis. You will want to get as close as possible to your ideal combination of svyset and cox, but you may not be able to get all the way there.

Re: Applying weights to multilevel hazard analysis using Cox regression [message #23964 is a reply to message #23957] Fri, 21 January 2022 15:17 Go to previous messageGo to next message
Ugonna is currently offline  Ugonna
Messages: 26
Registered: June 2020
Member

Thanks for the follow-up response.

But since I used this "svyset v021, weight(wt2_1) strata(v022) , singleunit(centered) || _n, weight(wt1_1)" to apply the survey design, I'm wondering where I'm supposed to apply this
"gen wt_1= wt1_1*wt2_1". Given that I don't have "wt1_1*wt2_1" anywhere in my command.
Re: Applying weights to multilevel hazard analysis using Cox regression [message #23979 is a reply to message #23964] Mon, 24 January 2022 08:53 Go to previous messageGo to next message
Bridgette-DHS is currently offline  Bridgette-DHS
Messages: 3199
Registered: February 2013
Senior Member

Following is another response from DHS Research & Data Analysis Director, Tom Pullum:

If you don't have "wt1_1*wt2_1" anywhere in your code, then I can't account for the error statement. The product of those two level-weights would be the net weight, proportional to v005. I will ask someone else to help -- I have no more suggestions.
Re: Applying weights to multilevel hazard analysis using Cox regression [message #23985 is a reply to message #23979] Mon, 24 January 2022 14:42 Go to previous message
Ugonna is currently offline  Ugonna
Messages: 26
Registered: June 2020
Member
Hello Tom,

Thank you for your suggestions so far. Much appreciated.
Previous Topic: SUEST
Next Topic: underfive children HW data: why missing a lot in IR files
Goto Forum:
  


Current Time: Sun Dec 1 18:19:25 Coordinated Universal Time 2024