Dear all,

I use Stata16 and I humbly seek help. I have 2 cases where the parabolic curves are inverting WRONGLY. I did everything right (or so I think).

**First Case: I should have an INVERTED U-shaped curve. But the curve keeps showing an upward trend.
Please see the code I executed and the output.

Code:
twoway qfit lnco2 enu
xtpcse lnco2 enu enusq lnpc popgr renew rq, rhotype(freg) np1
di -_b[enu]/(2 * _b[enusq])
local tp = -_b[enu]/(2 * _b[enusq])
twoway qfit lnco2 enu, xli(`tp')

Code:
. twoway qfit lnco2 enu

. xtpcse lnco2 enu enusq lnpc popgr renew rq, rhotype(freg) np1
(note: the number of observations per panel, e(n_sigma) = 4,
       used to compute the disturbance of covariance matrix e(Sigma)
       is less than half of the average number of observations per panel,
       e(n_avg) = 14.714286; you may want to consider the pairwise option)

Linear regression, correlated panels corrected standard errors (PCSEs)

Group variable:   c_id                          Number of obs     =        103
Time variable:    year                          Number of groups  =          7
Panels:           correlated (unbalanced)       Obs per group:
Autocorrelation:  no autocorrelation                          min =          4
Sigma computed by casewise selection                          avg =  14.714286
                                                              max =         19
Estimated covariances      =        28          R-squared         =     0.8832
Estimated autocorrelations =         0          Wald chi2(6)      =    3176.03
Estimated coefficients     =         7          Prob > chi2       =     0.0000

------------------------------------------------------------------------------
             |           Panel-corrected
       lnco2 |      Coef.   Std. Err.      z    P>|z|     [95% Conf. Interval]
-------------+----------------------------------------------------------------
         enu |   .0083711   .0007237    11.57   0.000     .0069527    .0097895
       enusq |  -8.44e-06   1.11e-06    -7.60   0.000    -.0000106   -6.26e-06
        lnpc |   .5700028   .1329954     4.29   0.000     .3093366     .830669
       popgr |   .1243389   .0564481     2.20   0.028     .0137027     .234975
       renew |  -.0256073   .0027666    -9.26   0.000    -.0310297   -.0201848
          rq |  -.4014216   .1457195    -2.75   0.006    -.6870265   -.1158167
       _cons |  -5.346004   1.147205    -4.66   0.000    -7.594484   -3.097524
------------------------------------------------------------------------------

. di -_b[enu]/(2 * _b[enusq])
496.0271

. local tp = -_b[enu]/(2 * _b[enusq])

. twoway qfit lnco2 enu, xli(`tp')
**Second Case: I should have a U-shaped curve. But what I got is an INVERTED U-shaped curve.
Please see the code I used:
Code:
twoway qfit lnco2 kofgi
xtpcse lnco2 lnpc popgr renew rq kofgi kofgi2, rhotype(freg) np1
di -_b[kofgi]/(2 * _b[kofgi2])
local tp = -_b[kofgi/(2 * _b[kofgi2])
twoway qfit lnco2 kofgi, xli(`tp')
The output:
Code:
. twoway qfit lnco2 kofgi

. xtpcse lnco2 lnpc popgr renew rq kofgi kofgi2, rhotype(freg) np1

Linear regression, correlated panels corrected standard errors (PCSEs)

Group variable:   c_id                          Number of obs     =        140
Time variable:    year                          Number of groups  =          7
Panels:           correlated (balanced)         Obs per group:
Autocorrelation:  no autocorrelation                          min =         20
                                                              avg =         20
                                                              max =         20
Estimated covariances      =        28          R-squared         =     0.7736
Estimated autocorrelations =         0          Wald chi2(6)      =    1891.41
Estimated coefficients     =         7          Prob > chi2       =     0.0000

------------------------------------------------------------------------------
             |           Panel-corrected
       lnco2 |      Coef.   Std. Err.      z    P>|z|     [95% Conf. Interval]
-------------+----------------------------------------------------------------
        lnpc |   .6572758   .0212834    30.88   0.000      .615561    .6989906
       popgr |   .2181154   .0488538     4.46   0.000     .1223638     .313867
       renew |   -.006806   .0013833    -4.92   0.000    -.0095171   -.0040948
          rq |  -.2882291   .0664838    -4.34   0.000    -.4185349   -.1579234
       kofgi |   -.116146   .0327807    -3.54   0.000     -.180395    -.051897
      kofgi2 |   .0014956    .000385     3.88   0.000      .000741    .0022503
       _cons |  -3.270156   .6360434    -5.14   0.000    -4.516778   -2.023533
------------------------------------------------------------------------------

. di -_b[kofgi]/(2 * _b[kofgi2])
38.827971

. local tp = -_b[kofgi]/(2 * _b[kofgi2])

. twoway qfit lnco2 kofgi, xli(`tp')
I have checked and re-checked the codes and cannot seem to place where the problem lies.
I will appreciate every assistance.
Thanks in advance.
Ngozi