Hi folks, I'm trying to draw a Lowess curve that takes the regression results into consideration. For example, the direct correlation between the dependent variable "voted" and independent variable "ldhighschool" is positive. However, when you run a regression, taking into consideration the relevant control variables, the relationship between the two variables turns negative. I want the Lowess curve to reflect this relationship, that is, display the negative relationship between the 2 variables in light of the control variables. Here are my commands:
logit voted ldmission ldcatho i.gender age age2 education i.urbrur living_cond i.catholic_now i.protestant_now i.muslim_now religiosity lslave_region ldcity1800 lpopd_history ldcoast ldrail ldexplorer ldprint dhospital dbig30 i.Country i.Wave
twoway (lowess voted ldhighschool)
twoway (lowess voted ldhighschool) if dhighschool <= 200 //restricting sample to less than 200km
In case a Lowess curve is not feasible, what do you suggest for a smooth non-linear curve for a regression output?
logit voted ldmission ldcatho i.gender age age2 education i.urbrur living_cond i.catholic_now i.protestant_now i.muslim_now religiosity lslave_region ldcity1800 lpopd_history ldcoast ldrail ldexplorer ldprint dhospital dbig30 i.Country i.Wave
twoway (lowess voted ldhighschool)
twoway (lowess voted ldhighschool) if dhighschool <= 200 //restricting sample to less than 200km
In case a Lowess curve is not feasible, what do you suggest for a smooth non-linear curve for a regression output?
Code:
* Example generated by -dataex-. For more info, type help dataex clear input int voted float(ldmission ldcatho) byte gender float(age age2 education) byte(urbrur living_cond) float(catholic_now protestant_now muslim_now) byte religiosity float(lslave_region ldcity1800 lpopd_history ldcoast ldrail ldexplorer) 0 3.295524 5.278751 1 38 1444 2 2 3 0 0 0 . 0 7.87927 -2.3335783 5.335011 2.8296525 6.235664 1 2.3980975 5.266923 2 44 1936 2 2 4 0 1 0 . .0414872 7.875816 -.4836141 4.501336 3.578553 6.419692 1 2.698109 5.303064 2 32 1024 4 2 2 0 1 0 . 0 7.883979 -2.7848964 5.199777 2.0107641 6.26287 1 2.3980975 5.266923 1 35 1225 3 2 1 0 0 0 . .0414872 7.875816 -.4836141 4.501336 3.578553 6.419692 1 2.3062606 5.319501 1 29 841 6 2 4 0 1 0 . .0110842 7.878821 -2.1216297 5.076782 2.4652176 6.309267 0 2.607949 5.201148 2 18 324 4 2 3 0 0 0 . .0414872 7.880152 -.4478247 4.4526176 3.111101 6.416393 1 2.698109 5.303064 2 56 3136 5 2 4 1 0 0 . 0 7.883979 -2.7848964 5.199777 2.0107641 6.26287 1 2.3062606 5.319501 1 35 1225 6 2 3 0 1 0 . .0110842 7.878821 -2.1216297 5.076782 2.4652176 6.309267 1 1.565786 5.094637 2 41 1681 3 2 4 0 1 0 4 .0110842 7.889965 -1.0224912 4.829137 .27682942 6.336033 1 2.715725 5.266022 1 63 3969 3 2 4 0 0 0 . .0414872 7.876982 .1900905 2.852911 3.001267 6.516592 1 2.607949 5.201148 2 36 1296 4 2 2 0 0 0 . .0414872 7.880152 -.4478247 4.4526176 3.111101 6.416393 1 2.922326 5.375945 1 46 2116 4 1 4 0 1 0 4 .0110842 7.869832 -.8232641 4.851454 2.52834 6.384627 1 1.3604553 5.305167 2 40 1600 3 2 2 0 0 0 3 .0110842 7.871657 -2.21953 5.178858 3.3497784 6.30704 1 2.1648827 5.224882 2 63 3969 2 2 2 0 0 0 . 0 7.868877 -2.2268767 5.270321 2.344725 6.28016 1 2.1648827 5.224882 1 71 5041 0 2 4 0 0 0 . 0 7.868877 -2.2268767 5.270321 2.344725 6.28016 1 1.3604553 5.305167 2 36 1296 2 2 3 0 0 0 4 .0110842 7.871657 -2.21953 5.178858 3.3497784 6.30704 1 2.7004294 5.314059 1 34 1156 4 2 4 0 0 0 . .0110842 7.875434 -1.3918134 4.882874 .694196 6.360759 1 1.8030276 5.449199 1 36 1296 3 2 1 0 0 0 . .0414872 7.861428 .27351195 3.87441 -2.041556 6.515626 1 3.100268 5.421429 2 67 4489 4 2 2 0 1 0 . .0110842 7.865902 -.7141312 4.898818 3.142304 6.389922 0 2.69352 5.392028 2 21 441 4 1 3 0 1 0 . .0110842 7.86753 -.4040432 4.7681637 3.230331 6.407392 1 2.3980975 5.266923 2 40 1600 2 2 3 1 0 0 . .0414872 7.875816 -.4836141 4.501336 3.578553 6.419692 1 2.1882062 5.368993 1 24 576 2 2 3 0 0 0 . .0110842 7.875336 -2.3926494 5.106799 3.145118 6.312551 0 2.7004294 5.314059 2 21 441 4 2 3 0 0 0 . .0110842 7.875434 -1.3918134 4.882874 .694196 6.360759 0 2.2233977 5.439286 2 18 324 4 2 4 0 1 0 3 .0414872 7.863587 .3202788 3.042645 3.332175 6.545421 0 1.565786 5.094637 2 27 729 4 2 4 0 1 0 3 .0110842 7.889965 -1.0224912 4.829137 .27682942 6.336033 1 2.3062606 5.319501 2 64 4096 2 2 3 0 1 0 . .0110842 7.878821 -2.1216297 5.076782 2.4652176 6.309267 0 3.100268 5.421429 1 23 529 4 2 5 0 0 0 . .0110842 7.865902 -.7141312 4.898818 3.142304 6.389922 1 1.7892542 5.448228 2 41 1681 4 2 1 0 1 0 4 .0414872 7.861521 .27351195 3.867405 -.665479 6.515837 1 2.922326 5.375945 2 28 784 5 1 4 0 1 0 3 .0110842 7.869832 -.8232641 4.851454 2.52834 6.384627 1 1.7892542 5.448228 1 45 2025 2 1 5 0 1 0 4 .0414872 7.861521 .27351195 3.867405 -.665479 6.515837 1 1.7892542 5.448228 2 40 1600 3 1 1 0 1 0 4 .0414872 7.861521 .27351195 3.867405 -.665479 6.515837 1 2.724901 5.312489 2 69 4761 3 2 3 0 1 0 3 .0110842 7.875522 -1.3918134 4.880302 .8792688 6.360994 1 2.3062606 5.319501 2 46 2116 6 2 3 0 1 0 . .0110842 7.878821 -2.1216297 5.076782 2.4652176 6.309267 1 2.724901 5.312489 2 54 2916 3 2 2 0 1 0 4 .0110842 7.875522 -1.3918134 4.880302 .8792688 6.360994 0 2.3980975 5.266923 1 53 2809 0 2 3 1 0 0 . .0414872 7.875816 -.4836141 4.501336 3.578553 6.419692 1 2.3980975 5.266923 2 67 4489 2 2 3 1 0 0 . .0414872 7.875816 -.4836141 4.501336 3.578553 6.419692 0 2.56769 5.310072 1 43 1849 5 2 2 0 1 0 . .0110842 7.880227 -2.457079 5.100284 2.525655 6.299569 0 2.607949 5.201148 1 19 361 4 2 3 0 0 0 . .0414872 7.880152 -.4478247 4.4526176 3.111101 6.416393 1 2.7004294 5.314059 1 25 625 5 2 3 0 1 0 . .0110842 7.875434 -1.3918134 4.882874 .694196 6.360759 1 2.56769 5.310072 1 73 5329 3 2 4 0 1 0 . .0110842 7.880227 -2.457079 5.100284 2.525655 6.299569 0 2.1882062 5.368993 2 20 400 5 2 3 0 1 0 . .0110842 7.875336 -2.3926494 5.106799 3.145118 6.312551 1 3.100268 5.421429 1 67 4489 4 2 3 0 0 0 . .0110842 7.865902 -.7141312 4.898818 3.142304 6.389922 1 2.922326 5.375945 2 67 4489 5 1 3 0 1 0 4 .0110842 7.869832 -.8232641 4.851454 2.52834 6.384627 0 3.100268 5.421429 2 18 324 5 2 3 0 0 0 . .0110842 7.865902 -.7141312 4.898818 3.142304 6.389922 0 2.607949 5.201148 1 19 361 3 2 2 0 0 0 . .0414872 7.880152 -.4478247 4.4526176 3.111101 6.416393 1 2.162259 5.271806 1 58 3364 6 1 4 0 1 0 3 0 7.886971 -3.016906 5.211175 -.8600179 6.251809 1 2.1961772 5.272246 1 41 1681 2 1 4 1 0 0 . 0 7.886878 -3.016906 5.209903 -.662611 6.252479 1 3.295524 5.278751 2 59 3481 3 2 3 0 0 0 . 0 7.87927 -2.3335783 5.335011 2.8296525 6.235664 0 1.3604553 5.305167 1 20 400 4 2 4 0 1 0 3 .0110842 7.871657 -2.21953 5.178858 3.3497784 6.30704 0 2.1648827 5.224882 2 19 361 4 2 4 0 0 0 . 0 7.868877 -2.2268767 5.270321 2.344725 6.28016 1 2.7004294 5.314059 2 56 3136 3 2 4 0 0 0 . .0110842 7.875434 -1.3918134 4.882874 .694196 6.360759 1 1.8030276 5.449199 2 46 2116 5 2 3 0 1 0 . .0414872 7.861428 .27351195 3.87441 -2.041556 6.515626 1 2.3980975 5.266923 1 55 3025 2 2 3 1 0 0 . .0414872 7.875816 -.4836141 4.501336 3.578553 6.419692 1 2.715725 5.266022 2 64 4096 2 2 3 0 1 0 . .0414872 7.876982 .1900905 2.852911 3.001267 6.516592 1 1.7892542 5.448228 2 63 3969 0 2 3 0 0 0 1 .0414872 7.861521 .27351195 3.867405 -.665479 6.515837 1 2.69352 5.392028 1 36 1296 5 1 2 0 1 0 . .0110842 7.86753 -.4040432 4.7681637 3.230331 6.407392 1 1.8030276 5.449199 1 67 4489 4 2 2 0 1 0 . .0414872 7.861428 .27351195 3.87441 -2.041556 6.515626 1 1.7892542 5.448228 1 45 2025 5 1 4 0 1 0 3 .0414872 7.861521 .27351195 3.867405 -.665479 6.515837 1 2.56769 5.310072 2 60 3600 4 2 3 0 1 0 . .0110842 7.880227 -2.457079 5.100284 2.525655 6.299569 0 2.3980975 5.266923 1 22 484 4 2 3 0 1 0 . .0414872 7.875816 -.4836141 4.501336 3.578553 6.419692 1 1.8030276 5.449199 2 20 400 5 2 3 0 0 0 . .0414872 7.861428 .27351195 3.87441 -2.041556 6.515626 1 1.7892542 5.448228 1 28 784 3 2 3 0 0 0 1 .0414872 7.861521 .27351195 3.867405 -.665479 6.515837 1 2.724901 5.312489 1 80 6400 0 2 4 0 0 0 3 .0110842 7.875522 -1.3918134 4.880302 .8792688 6.360994 1 2.1961772 5.272246 1 43 1849 9 1 3 0 1 0 . 0 7.886878 -3.016906 5.209903 -.662611 6.252479 1 2.1882062 5.368993 2 88 7744 6 2 4 1 0 0 . .0110842 7.875336 -2.3926494 5.106799 3.145118 6.312551 1 2.724901 5.312489 1 68 4624 2 2 2 0 1 0 4 .0110842 7.875522 -1.3918134 4.880302 .8792688 6.360994 1 1.565786 5.094637 1 53 2809 3 2 4 0 0 0 1 .0110842 7.889965 -1.0224912 4.829137 .27682942 6.336033 1 2.162259 5.271806 1 51 2601 2 1 4 0 0 0 4 0 7.886971 -3.016906 5.211175 -.8600179 6.251809 0 2.2233977 5.439286 2 50 2500 2 2 2 0 1 0 4 .0414872 7.863587 .3202788 3.042645 3.332175 6.545421 1 2.698109 5.303064 1 66 4356 0 2 3 0 1 0 . 0 7.883979 -2.7848964 5.199777 2.0107641 6.26287 1 2.2233977 5.439286 1 60 3600 3 2 4 0 1 0 4 .0414872 7.863587 .3202788 3.042645 3.332175 6.545421 1 2.162259 5.271806 2 58 3364 4 1 4 0 1 0 4 0 7.886971 -3.016906 5.211175 -.8600179 6.251809 1 2.2233977 5.439286 1 51 2601 2 2 3 0 1 0 4 .0414872 7.863587 .3202788 3.042645 3.332175 6.545421 0 2.162259 5.271806 2 58 3364 2 1 3 0 1 0 4 0 7.886971 -3.016906 5.211175 -.8600179 6.251809 0 1.565786 5.094637 1 49 2401 4 2 4 0 1 0 4 .0110842 7.889965 -1.0224912 4.829137 .27682942 6.336033 1 2.715725 5.266022 1 60 3600 2 2 4 1 0 0 . .0414872 7.876982 .1900905 2.852911 3.001267 6.516592 1 3.295524 5.278751 2 38 1444 4 2 3 0 0 0 . 0 7.87927 -2.3335783 5.335011 2.8296525 6.235664 0 2.3980975 5.266923 2 25 625 4 2 3 0 1 0 . .0414872 7.875816 -.4836141 4.501336 3.578553 6.419692 1 2.69352 5.392028 1 40 1600 4 1 4 0 1 0 . .0110842 7.86753 -.4040432 4.7681637 3.230331 6.407392 0 2.1648827 5.224882 1 20 400 4 2 4 0 0 0 . 0 7.868877 -2.2268767 5.270321 2.344725 6.28016 1 2.1882062 5.368993 1 43 1849 2 2 3 0 0 0 . .0110842 7.875336 -2.3926494 5.106799 3.145118 6.312551 1 2.698109 5.303064 1 35 1225 4 2 3 0 1 0 . 0 7.883979 -2.7848964 5.199777 2.0107641 6.26287 1 1.7892542 5.448228 2 53 2809 2 1 2 0 1 0 4 .0414872 7.861521 .27351195 3.867405 -.665479 6.515837 0 1.7892542 5.448228 1 23 529 4 2 3 0 0 0 1 .0414872 7.861521 .27351195 3.867405 -.665479 6.515837 1 2.715725 5.266022 2 66 4356 0 2 4 0 0 0 . .0414872 7.876982 .1900905 2.852911 3.001267 6.516592 0 1.3604553 5.305167 1 22 484 4 2 4 0 1 0 3 .0110842 7.871657 -2.21953 5.178858 3.3497784 6.30704 0 2.922326 5.375945 1 19 361 4 1 3 1 0 0 1 .0110842 7.869832 -.8232641 4.851454 2.52834 6.384627 1 2.893201 5.572906 1 37 1369 6 2 4 1 0 0 . 0 6.949109 .8024116 6.779335 4.65407 4.243682 1 2.893201 5.572906 1 35 1225 5 2 3 0 0 0 . 0 6.949109 .8024116 6.779335 4.65407 4.243682 0 5.929426 6.401748 2 27 729 2 1 2 0 1 0 . .006176145 7.374372 1.277963 6.912721 2.776455 3.892235 1 5.7953 6.491528 1 37 1369 8 1 2 0 0 0 . .006176145 7.356306 1.4355373 6.973181 2.0239494 2.3196228 1 5.7953 6.491528 2 25 625 5 1 3 0 1 0 . .006176145 7.356306 1.4355373 6.973181 2.0239494 2.3196228 1 5.822277 6.439603 2 47 2209 3 1 3 0 0 0 4 .006176145 7.352237 1.3103262 6.94321 1.1207204 3.288597 1 5.509483 6.256178 2 35 1225 6 1 2 0 1 0 . .05874606 7.217021 -.8412846 6.837308 -1.7101828 4.400976 1 5.228532 5.490892 1 33 1089 3 2 4 0 1 0 4 .024133626 6.486318 1.2556896 6.863665 4.2363124 3.768964 0 5.798994 6.498509 2 19 361 4 1 3 0 0 0 . .006176145 7.359316 1.4023328 6.976499 -2.1516492 2.7370315 0 3.3108175 5.600432 2 33 1089 0 2 4 0 1 0 4 0 6.974121 -.05471601 6.821652 4.702282 3.9432604 1 2.3856585 5.953181 1 36 1296 3 2 3 1 0 0 1 .11234131 6.872132 1.3845606 6.104233 3.2692494 5.069411 1 5.046294 4.404323 1 49 2401 3 1 1 0 0 1 4 .5012888 6.479287 -3.929461 6.439437 3.5002224 1.867002 0 4.090047 4.0036874 1 25 625 3 2 4 0 0 0 . .5012888 6.297227 -2.6095774 6.54797 3.063382 3.202182 end label values voted voted label def voted 0 "No", modify label def voted 1 "Yes", modify label values gender LABAR label def LABAR 1 "male", modify label def LABAR 2 "female", modify label values urbrur urbrur label def urbrur 1 "urban", modify label def urbrur 2 "rural", modify label values living_cond LABI label def LABI 1 "much worse", modify label def LABI 2 "worse", modify label def LABI 3 "same", modify label def LABI 4 "better", modify label def LABI 5 "much better", modify label values religiosity q91 label def q91 1 "not at all important", modify label def q91 3 "somewhat important", modify label def q91 4 "very important", modify
Comment