Dear Stata users,
I am a beginner in Stata and working on an econometric analysis in which I model
life satisfaction as a function of a set of explanatory variables in 6 selected countries.
Data is used from ESSround1.
I am trying to build a correct lineair, binary logit and ordered logit model.
Please have look at my do file.
Now I want to make a new logit model for ESSround5 so
I can compare it with ESSround1. Problem is that 2 variables have different names in ESSround5.
Here's the recoding for 'education' for round5.
There's a second problem for the marital status.
ESSround1: variables partner and marital (see do file)
ESSround5: variables icpart1 and marsts
How can I make my variables to be comparable with each other? How can I set up my new logit model for round5?
Please feel free to adjust my do file and/or give me some explanations.
Any corrections or suggestions are much appreciated!
Kind regards,
Steven Somers
I am a beginner in Stata and working on an econometric analysis in which I model
life satisfaction as a function of a set of explanatory variables in 6 selected countries.
Data is used from ESSround1.
I am trying to build a correct lineair, binary logit and ordered logit model.
Please have look at my do file.
Code:
*Selecting countries keep if cntry=="ES" | cntry=="DE" | cntry=="NL" | cntry=="SI" | cntry=="PL" | cntry=="BE" *Recoding tab tvtot replace tvtot =. if tvtot>7 recode tvtot (2 3 =2) (4 5 =3) (6 7 = 4), gen(tvtot_x) tab tvtot tvtot_x label define tvtot_x 0 "No TV at all" 1 "Less than 0,5 h TV" 2 "More than 1.5-2.5 h TV" 3 "More than 1.5-2.5 h TV" 4 "More than 2.5 h TV" label values tvtot_x tvtot_x fvset base 1 tvtot_x tab tvtot_x tab wkhtot replace wkhtot=. if wkhtot > 120 generate wkhtot_sq = wkhtot^2 tab wkhtot_sq label variable wkhtot "Working hours" label variable wkhtot_sq "Working hours, squared" lookfor "income" tab hinctnt, nolab replace hinctnt=. if hinctnt > 13 generate income = ln(hinctnt) label variable income "ln(household income, PPP)" tab income lookfor "age" tab agea replace agea=. if agea > 95 label variable agea "Age" generate agea_sq = agea^2 label variable agea_sq "Age, squared" tab agea_sq lookfor "gender" tab gndr, nolab replace gndr=. if gndr==9 lookfor "citizen" tab ctzcntr, nolab replace ctzcntr=. if ctzcntr > 2 recode ctzcntr (2 = 1) (1 = 2), gen(citizen) tab ctzcntr citizen label define citizen 1 "Foreigner" 2 "Citizen of country" label values citizen citizen label variable citizen "Citizen of the country" tab citizen lookfor "partner" tab partner marital tab partner marital, nolab replace partner=. if partner == 9 replace marital=. if marital > 5 tab marital partner generate living=. replace living=1 if partner==1 & marital ==1 replace living=2 if partner==2 & marital ==1 replace living=3 if partner==1 & marital ==2 replace living=4 if partner==2 & marital ==2 replace living=5 if partner==1 & marital ==3 replace living=6 if partner==2 & marital ==3 replace living=7 if partner==1 & marital ==4 replace living=8 if partner==2 & marital ==4 replace living=9 if partner==1 & marital ==5 replace living=10 if partner==2 & marital ==5 tab living label define living 1 "Married, living with partner" 2 "Married, not living with partner" 3 "Separated, living with partner" 4 "Separated, not living with partner" 5 "Dicorced, living with partner" /// 6 "Dicorced, not living with partner" 7 "Widowed, living with partner" 8 "Widowed, not living with partner" 9 "Never been married, living with partner" 10 "Never been married, not living with partner" label values living living tab living lookfor "children" tab chldhm, nolab replace chldhm=. if chldhm > 3 recode chldhm (2 = 1) (1 = 2), gen(child) tab chldhm child label define child 1 "No children at home" 2 "Children at home" label values child child label variable child "Are children living at home?" tab child lookfor "education" tab edulvla tab edulvla, nolab replace edulvla=. if edulvla > 6 tab edulvla lookfor "mainact" tab mainact tab mainact, nolab replace mainact=. if mainact >9 lookfor "domicil" tab domicil tab domicil, nolab replace domicil=. if domicil > 6 *lineair regression keep if essround==1 regress stflife i.tvtot_x wkhtot wkhtot_sq income agea agea_sq i.gndr i.citizen i.child i.edulvla i.mainact i.living i.domicil lookfor "life" tab stflife tab stflife, nolab replace stflife=. if stflife > 11 global ylist stflife global xlist i.tvtot_x wkhtot wkhtot_sq income agea agea_sq i.gndr i.citizen i.child i.edulvla i.mainact i.living i.domicil *logit model logit $ylist $xlist [pw=dweight*pweight] logit $ylist $xlist [pw=dweight*pweight], or *ordered logit model ologit $ylist $xlist [pw=dweight*pweight] ologit $ylist $xlist [pw=dweight*pweight], or
Now I want to make a new logit model for ESSround5 so
I can compare it with ESSround1. Problem is that 2 variables have different names in ESSround5.
Here's the recoding for 'education' for round5.
Code:
replace edulvla=1 if (edulvlb==0 | edulvlb==113) & essround==5 replace edulvla=2 if (edulvlb==129 | edulvlb==212 | edulvlb==213 | edulvlb==221 | edulvlb==222 | edulvlb==223) & essround==5 replace edulvla=3 if (edulvlb==229 | edulvlb==311 | edulvlb==312 | edulvlb==313 | edulvlb==321 | edulvlb==322 | edulvlb==323) & essround==5 replace edulvla=4 if (edulvlb==412 | edulvlb==413 | edulvlb==421 | edulvlb==422 | edulvlb==423) & essround==5 replace edulvla=5 if (edulvlb==510 | edulvlb==520 | edulvlb==610 | edulvlb==620 | edulvlb==710 | edulvlb==720 | edulvlb==800) & essround==5 replace edulvla=55 if edulvlb==5555 & essround==5 replace edulvla=77 if edulvlb==7777 & essround==5 replace edulvla=88 if edulvlb==8888 & essround==5 replace edulvla=99 if edulvlb==9999 & essround==5
ESSround1: variables partner and marital (see do file)
ESSround5: variables icpart1 and marsts
How can I make my variables to be comparable with each other? How can I set up my new logit model for round5?
Please feel free to adjust my do file and/or give me some explanations.
Any corrections or suggestions are much appreciated!
Kind regards,
Steven Somers
Comment