Quantcast
Channel: Statalist
Viewing all articles
Browse latest Browse all 65051

Polynomial Regression Plots

$
0
0
I ran the following regression (sample data below):

Code:
xtreg lngdp i.iso3 tmean tmeansq pmean pmeansq lnpop
The results are the following (country fixed effects absorbed).

Code:
       tmean |   .0082621   .0023944     3.45   0.001     .0035691    .0129551
     tmeansq |  -.0004511   .0000862    -5.23   0.000    -.0006201   -.0002821
       pmean |    .081774   .0108711     7.52   0.000     .0604671     .103081
     pmeansq |  -.0093381   .0011375    -8.21   0.000    -.0115676   -.0071086
       lnpop |   .7900886   .0018756   421.25   0.000     .7864125    .7937646
       _cons |   2.043321   .0420113    48.64   0.000      1.96098    2.125662
I would like to plot functions tmean and pmean along with their squared terms. Something like the following:

Code:
twoway function y = _b[_cons] +_b[tmean]*x + _b[tmeansq]*x^2, range(-10 40)
Code:
twoway function y = _b[_cons] +_b[pmean]*x + _b[pmeansq]*x^2, range(0 15.04)
Is it possible to add confidence intervals for these plots? Thanks a lot.


Data
Code:
* Example generated by -dataex-. To install: ssc install dataex
clear
input long iso3 double(tmean pmean lngdp tmeansq pmeansq lnpop) float n
30                 .                  . -.10238007456064224                  .                 .   -3.59053098549622 1
30                 .                  . -2.3195972442626953                  .                 .  -6.004328534538948 2
30 4.558476775956307 2.4556989669799805 .012236329726874828  20.77971076965332 6.030457496643066  -2.725406532072661 3
 1 4.060157103825159 1.6384220123291016 -.48375624418258667  16.48487663269043 2.684426784515381 -3.2221001674784175 4
30 3.710102459016416  1.439255952835083  -6.297446250915527 13.764860153198242 2.071457624435425 -11.045147226737937 5
end
label values iso3 iso3
label def iso3 1 ".", modify
label def iso3 30 "CHL", modify
Thank you very much!

Viewing all articles
Browse latest Browse all 65051

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>