I am working with an unbalanced panel dataset that has multiple weights for different years i.e. those observed in year 2/year 3 will have a different individual pweight from those observed from year 3/year 4.
I need to weight my fixed effects analysis so that its representative of the population, but I am also using the entire sample (those who appear in year 2/year 3 + year 3/year 4 + year 2/year 4). I am thinking I need to create a variable and insert the weight value depending on which years people were observed but not sure how to achieve this. I have the ID variable, year variable, and pweights. For example, if someone was observed in year 2/year 3 then that new variable should take the value from the pweight_2_3 etc.
I am not sure if this is the correct way to go about my weights or how to create a variable with the weight values.
I need to weight my fixed effects analysis so that its representative of the population, but I am also using the entire sample (those who appear in year 2/year 3 + year 3/year 4 + year 2/year 4). I am thinking I need to create a variable and insert the weight value depending on which years people were observed but not sure how to achieve this. I have the ID variable, year variable, and pweights. For example, if someone was observed in year 2/year 3 then that new variable should take the value from the pweight_2_3 etc.
I am not sure if this is the correct way to go about my weights or how to create a variable with the weight values.
Code:
* Example generated by -dataex-. To install: ssc install dataex clear input str14 pid byte year float(pweight_1_2 pweight_2_3 pweight_2_4 pweight_3_4 pweight_0_1 pweight_0_2 pweight_0_3 pweight_0_4) "10504000000002" 1 1.490955 . . . .6457067 .6328818 . . "10504000000002" 2 1.490955 . . . .6457067 .6328818 . . "10504000000043" 1 .08279315 .08726926 . . .067046076 .0351441 .04371072 . "10504000000043" 2 .08279315 .08726926 . . .067046076 .0351441 .04371072 . "10504000000043" 3 .08279315 .08726926 . . .067046076 .0351441 .04371072 . "10504000000113" 1 .2084662 .10988873 . .1261204 .1829129 .0884899 .05504018 .063364215 "10504000000113" 2 .2084662 .10988873 . .1261204 .1829129 .0884899 .05504018 .063364215 "10504000000113" 3 .2084662 .10988873 . .1261204 .1829129 .0884899 .05504018 .063364215 "10504000000113" 4 .2084662 .10988873 . .1261204 .1829129 .0884899 .05504018 .063364215 "10504000000231" 1 .7224439 . . . .6305851 .3066635 . . "10504000000231" 2 .7224439 . . . .6305851 .3066635 . . "10504000000444" 1 .3334551 .2599969 . . .27753603 .14154527 .13022514 . "10504000000444" 2 .3334551 .2599969 . . .27753603 .14154527 .13022514 . "10504000000444" 3 .3334551 .2599969 . . .27753603 .14154527 .13022514 . "10504000000482" 1 .8814541 . . . .6066914 .3741603 . . "10504000000482" 2 .8814541 . . . .6066914 .3741603 . . "10504000000535" 1 2.3087964 3.087281 . 2.207173 1.2818545 .9800397 1.5463324 1.108907 "10504000000535" 2 2.3087964 3.087281 . 2.207173 1.2818545 .9800397 1.5463324 1.108907 "10504000000535" 3 2.3087964 3.087281 . 2.207173 1.2818545 .9800397 1.5463324 1.108907 "10504000000535" 4 2.3087964 3.087281 . 2.207173 1.2818545 .9800397 1.5463324 1.108907 "10504000000644" 1 .19044358 .2114035 . . .08974714 .08083964 .10588606 . "10504000000644" 2 .19044358 .2114035 . . .08974714 .08083964 .10588606 . "10504000000644" 3 .19044358 .2114035 . . .08974714 .08083964 .10588606 . "10504000000696" 1 1.0545716 .7806799 . .8841602 .6043471 .4476454 .3910206 .4442114 "10504000000696" 2 1.0545716 .7806799 . .8841602 .6043471 .4476454 .3910206 .4442114 "10504000000696" 3 1.0545716 .7806799 . .8841602 .6043471 .4476454 .3910206 .4442114 "10504000000696" 4 1.0545716 .7806799 . .8841602 .6043471 .4476454 .3910206 .4442114 "10504000000748" 1 .2346767 . . . .0780693 .09961575 . . "10504000000748" 2 .2346767 . . . .0780693 .09961575 . . "10504000000821" 1 .841764 1.859564 . . .56911165 .35731265 .9314033 . "10504000000821" 2 .841764 1.859564 . . .56911165 .35731265 .9314033 . "10504000000821" 3 .841764 1.859564 . . .56911165 .35731265 .9314033 . "10504000000978" 1 1.7148002 . . . 1.0236369 .7278997 . . "10504000000978" 2 1.7148002 . . . 1.0236369 .7278997 . . "10504000000991" 1 1.3015234 . . . .7617443 .5524717 . . "10504000000991" 2 1.3015234 . . . .7617443 .5524717 . . "10504000001036" 1 1.1885023 .7966713 . .7638084 .6857872 .5044964 .3990302 .3837454 "10504000001036" 2 1.1885023 .7966713 . .7638084 .6857872 .5044964 .3990302 .3837454 "10504000001036" 3 1.1885023 .7966713 . .7638084 .6857872 .5044964 .3990302 .3837454 "10504000001036" 4 1.1885023 .7966713 . .7638084 .6857872 .5044964 .3990302 .3837454 "10504000001052" 1 .6436029 . . . .14144504 .27319705 . . "10504000001052" 2 .6436029 . . . .14144504 .27319705 . . "10504000001073" 1 .59565854 .503918 . . .23114826 .25284562 .25239834 . "10504000001073" 2 .59565854 .503918 . . .23114826 .25284562 .25239834 . "10504000001073" 3 .59565854 .503918 . . .23114826 .25284562 .25239834 . "10504000001102" 1 2.7555804 1.4897894 . 1.0611426 1.8835448 1.169691 .7461936 .53312916 "10504000001102" 2 2.7555804 1.4897894 . 1.0611426 1.8835448 1.169691 .7461936 .53312916 "10504000001102" 3 2.7555804 1.4897894 . 1.0611426 1.8835448 1.169691 .7461936 .53312916 "10504000001102" 4 2.7555804 1.4897894 . 1.0611426 1.8835448 1.169691 .7461936 .53312916 "10504000001142" 1 1.283015 1.5643878 . . .6290835 .54461527 .7835578 . "10504000001142" 2 1.283015 1.5643878 . . .6290835 .54461527 .7835578 . "10504000001142" 3 1.283015 1.5643878 . . .6290835 .54461527 .7835578 . "10504000001236" 1 .019867826 .010032974 . .00591379 .01723533 .008433511 .005025235 .0029711504 "10504000001236" 2 .019867826 .010032974 . .00591379 .01723533 .008433511 .005025235 .0029711504 "10504000001236" 3 .019867826 .010032974 . .00591379 .01723533 .008433511 .005025235 .0029711504 "10504000001236" 4 .019867826 .010032974 . .00591379 .01723533 .008433511 .005025235 .0029711504 "10504000001239" 1 6.788955 4.928476 . 6.00945 3.379382 2.881781 2.468535 3.019211 "10504000001239" 2 6.788955 4.928476 . 6.00945 3.379382 2.881781 2.468535 3.019211 "10504000001239" 3 6.788955 4.928476 . 6.00945 3.379382 2.881781 2.468535 3.019211 "10504000001239" 4 6.788955 4.928476 . 6.00945 3.379382 2.881781 2.468535 3.019211 "10504000001244" 1 3.1544614 2.757738 . 3.039934 1.781709 1.3390082 1.3812734 1.5272946 "10504000001244" 2 3.1544614 2.757738 . 3.039934 1.781709 1.3390082 1.3812734 1.5272946 "10504000001244" 3 3.1544614 2.757738 . 3.039934 1.781709 1.3390082 1.3812734 1.5272946 "10504000001244" 4 3.1544614 2.757738 . 3.039934 1.781709 1.3390082 1.3812734 1.5272946 "10504000001261" 1 1.7766047 . . . 1.4723096 .7541345 . . "10504000001261" 2 1.7766047 . . . 1.4723096 .7541345 . . "10504000001304" 1 2.494851 . . . 1.8168298 1.0590163 . . "10504000001304" 2 2.494851 . . . 1.8168298 1.0590163 . . "10504000001470" 1 .6377417 .36795035 . .2189666 .30983785 .2707091 .184296 .11001112 "10504000001470" 2 .6377417 .36795035 . .2189666 .30983785 .2707091 .184296 .11001112 "10504000001470" 3 .6377417 .36795035 . .2189666 .30983785 .2707091 .184296 .11001112 "10504000001470" 4 .6377417 .36795035 . .2189666 .30983785 .2707091 .184296 .11001112 "10504000001471" 1 1.085661 . . . .5050978 .46084225 . . "10504000001471" 2 1.085661 . . . .5050978 .46084225 . . "10504000001499" 1 .5347577 . . . .21337213 .22699435 . . "10504000001499" 2 .5347577 . . . .21337213 .22699435 . . "10504000001510" 1 2.2353597 . . . .8362384 .9488672 . . "10504000001510" 2 2.2353597 . . . .8362384 .9488672 . . "10504000001523" 1 2.672552 1.945924 . 1.519244 1.1455297 1.1344469 .9746586 .7632841 "10504000001523" 2 2.672552 1.945924 . 1.519244 1.1455297 1.1344469 .9746586 .7632841 "10504000001523" 3 2.672552 1.945924 . 1.519244 1.1455297 1.1344469 .9746586 .7632841 "10504000001523" 4 2.672552 1.945924 . 1.519244 1.1455297 1.1344469 .9746586 .7632841 "10504000001624" 1 4.685592 . . . .8901938 1.9889438 . . "10504000001624" 2 4.685592 . . . .8901938 1.9889438 . . "10504000001632" 1 1.5687544 . . . .3257745 .6659061 . . "10504000001632" 2 1.5687544 . . . .3257745 .6659061 . . "10504000001704" 1 1.4932137 . . . .9505457 .6338405 . . "10504000001704" 2 1.4932137 . . . .9505457 .6338405 . . "10504000001779" 1 1.725323 1.0782269 . .9625489 .8725213 .7323664 .54005355 .4835947 "10504000001779" 2 1.725323 1.0782269 . .9625489 .8725213 .7323664 .54005355 .4835947 "10504000001779" 3 1.725323 1.0782269 . .9625489 .8725213 .7323664 .54005355 .4835947 "10504000001779" 4 1.725323 1.0782269 . .9625489 .8725213 .7323664 .54005355 .4835947 "10504000001832" 1 3.237572 2.0984976 . 1.5902475 .662653 1.374287 1.0510784 .798957 "10504000001832" 2 3.237572 2.0984976 . 1.5902475 .662653 1.374287 1.0510784 .798957 "10504000001832" 3 3.237572 2.0984976 . 1.5902475 .662653 1.374287 1.0510784 .798957 "10504000001832" 4 3.237572 2.0984976 . 1.5902475 .662653 1.374287 1.0510784 .798957 "10504000001834" 1 .0690879 .04548496 . .06430935 .05402521 .029326485 .022782136 .032309692 "10504000001834" 2 .0690879 .04548496 . .06430935 .05402521 .029326485 .022782136 .032309692 "10504000001834" 3 .0690879 .04548496 . .06430935 .05402521 .029326485 .022782136 .032309692 "10504000001834" 4 .0690879 .04548496 . .06430935 .05402521 .029326485 .022782136 .032309692 end label values year year label def year 1 "2000", modify label def year 2 "2002", modify label def year 3 "2004", modify label def year 4 "2006", modify