Project

General

Profile

Support #1375

XTREG error: weight must be constant within pidp

Added by Abigail Dumalus over 3 years ago. Updated over 2 years ago.

Status:
Resolved
Priority:
High
Assignee:
-
Category:
Weights
Start date:
07/07/2020
% Done:

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!

#1

Updated by Alita Nandi over 3 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

#2

Updated by Abigail Dumalus over 3 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!

#3

Updated by Alita Nandi over 3 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

#4

Updated by Alita Nandi over 3 years ago

  • Status changed from New to Feedback
#5

Updated by Abigail Dumalus over 3 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?

#6

Updated by Alita Nandi over 3 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.

#7

Updated by Understanding Society User Support Team over 2 years ago

  • Status changed from Feedback to Resolved
  • Assignee deleted (Abigail Dumalus)
  • % Done changed from 80 to 100

Also available in: Atom PDF