Support #1375
openXTREG error: weight must be constant within pidp
100%
Description
Dear Olena,
As I mentioned in a separate issue weeks ago, I am analysing life satisfaction and GHQ (using indresp files) from 18 waves of the BHPS plus 8 waves of the UKHLS for a total of 16 waves. I have been referring to indin91_lw as the longitudinal weight. My problem/issue is that I have told Stata that the data has a panel structure via xtreg pidp wave. I wish to run: xtreg y x1 x2 [pw=indin91_lw], fe but I keep getting the error, "weight must be constant within pidp". What is the easiest workaround that I can implement for this analysis?
Thanks so much!
Updated by Alita Nandi over 4 years ago
- Assignee changed from Olena Kaminska to Abigail Dumalus
- % Done changed from 0 to 50
- Private changed from Yes to No
Hi Abigail,
You need to take i_indin91_lw (as Wave 9 is the last wave you are including) and then attach that to all prior waves, as this weight accounts for non-response and attrition across the waves until UKHLS Wave 9. The reason you are getting this error message is that the value of the weight variable changes within person. So, if you use i_indin91_lw for all waves, the value of the weight variable will not change within person and you will not get an error message.
Best wishes,
Alita
Updated by Abigail Dumalus over 4 years ago
Hello Alita,
I understand what you’re saying. but is there an extra step or specific code that I need to implement this attachment to all prior waves?I keep going in circles with using this weighting variable with the xtreg command on Stata. It works with other commands but not with xtreg regressions. Kindly advise. Thanks so much!
Updated by Alita Nandi over 4 years ago
Let's say your long file is, long.dta. Then you do this:
use long, clear
merge m:1 pidp using i_indresp, keepus(i_indin91_lw) nogen keep(3)
Is this clearer? If not, I could set up an online meeting with you, me and Olena. If you would like that, I will contact you via our usersupport email.
Best wishes,
Alita
Updated by Abigail Dumalus over 4 years ago
Hello Alita,
I apologise for not replying for almost a week. I have been ill. I currently have several weighting variables in the longitudinal dataset when I merged all indresp files from all 18 BHPS waves and waves 2-9 of the UKHLS. Would it help that I drop all of these current weighting variables and then merge as you have specified above? Or do I keep indin91_lw variable behind then run the xtreg command with this particular weighting variable? As I understand from what you are saying, the xtreg error (weight must be constant within pidp) is happening because the longitudinal dataset currently has all the weighting variables from merging all waves. Am I correct in this understanding?
Updated by Alita Nandi over 4 years ago
- % Done changed from 50 to 80
Yes drop all the weight variables, then merge i_indin91_lw from i_indrsp onto the entire long format file (many to one merge). Then for each person across different waves there will be one value of the weight variable.
Updated by Understanding Society User Support Team about 3 years ago
- Status changed from Feedback to Resolved
- Assignee deleted (
Abigail Dumalus) - % Done changed from 80 to 100
Updated by Lydia Palumbo 4 months ago
Hello,
I'm sorry if I'm jumping into this old thread. We are in the exact situation. We are analyzing subjects participating in all waves of BHPS and UKHLS from all the boosts, using the time-varying longitudinal weights. We are also in the presence of censoring.
I have a few questions.
1) Should use the weights up to the last wave available for each subject?
2) Do we need to change the types of weights once a boost is added (e.g. in wave 10 or so, change from indin91_lw to indin99_lw?)?
2) Given that we are using UKHLS and BHPS, do we still need to rescale the weights?
Thank you and best,
Lydia
Updated by Understanding Society User Support Team 4 months ago
Hi Lydia,
This issue has been resolved, and we typically do not reopen issues unless they are a direct continuation. May I suggest that you start a new issue, please?
Many thanks
UKHLS User Support