Announcement

Collapse
No announcement yet.
X
  • Filter
  • Time
  • Show
Clear All
new posts

  • A simple question for margins plot

    I am running margins and margins plot, for a maximization of my cap variable to u variable

    My code is
    marginsplot, noci xline(`=-_b[cap]/(2*_b[cap1#cap])')
    where cap is my variable of interest

    I have two simple questions.
    How can be shown in the figure the real value of the coefficient in both xx and yy line, where on xx is my cab variable and on yy my depended variable, say u?

    What is the option I need to add in my code?
    Last edited by Giorgio Di Stefano; 22 Feb 2022, 01:45.

  • #2
    Code:
    // open example data
    sysuse auto, clear
    
    // estimate a model
    reg price c.weight##c.weight i.foreign i.rep78 mpg
    
    // get the x where the minimum occurs
    local x =  - _b[weight]/(2*_b[c.weight#c.weight])
    
    // get the y for that minimim
    margins, at(weight = `x' foreign=0 rep78=3 mpg=20)
    // the predictions are stored in the matrix r(b)
    // el(r(b),1,1) extracts the cell 1,1 from the matrix r(b)
    local y = el(r(b),1,1)
    
    // to display those values we don't want all the decimal places
    // : display allows you to control how a number is displayed
    // it adds some spaces before the number, which strtrim() removes
    local ylab : display %9.0fc `y'
    local ylab = strtrim("`ylab'")
    local xlab : display %9.0fc `x'
    local xlab = strtrim("`xlab'")
    
    // prepare for our plot
    margins, at(weight=(1760(20)4840) foreign=0 rep78=3 mpg=20)
    
    // with scatteri we can add a point and a label to our graph
    marginsplot, noci plotopts(msymbol(i)) legend(off) ///
       addplot(scatteri `y' `x' (12) "(`xlab'; `ylab')") ///
       ylab(,format(%9.0fc) angle(0)) ytitle("predicted price")
    Click image for larger version

Name:	Graph.png
Views:	1
Size:	75.5 KB
ID:	1651274
    ---------------------------------
    Maarten L. Buis
    University of Konstanz
    Department of history and sociology
    box 40
    78457 Konstanz
    Germany
    http://www.maartenbuis.nl
    ---------------------------------

    Comment


    • #3
      Originally posted by Maarten Buis View Post
      Code:
      // open example data
      sysuse auto, clear
      
      // estimate a model
      reg price c.weight##c.weight i.foreign i.rep78 mpg
      
      // get the x where the minimum occurs
      local x = - _b[weight]/(2*_b[c.weight#c.weight])
      
      // get the y for that minimim
      margins, at(weight = `x' foreign=0 rep78=3 mpg=20)
      // the predictions are stored in the matrix r(b)
      // el(r(b),1,1) extracts the cell 1,1 from the matrix r(b)
      local y = el(r(b),1,1)
      
      // to display those values we don't want all the decimal places
      // : display allows you to control how a number is displayed
      // it adds some spaces before the number, which strtrim() removes
      local ylab : display %9.0fc `y'
      local ylab = strtrim("`ylab'")
      local xlab : display %9.0fc `x'
      local xlab = strtrim("`xlab'")
      
      // prepare for our plot
      margins, at(weight=(1760(20)4840) foreign=0 rep78=3 mpg=20)
      
      // with scatteri we can add a point and a label to our graph
      marginsplot, noci plotopts(msymbol(i)) legend(off) ///
      addplot(scatteri `y' `x' (12) "(`xlab'; `ylab')") ///
      ylab(,format(%9.0fc) angle(0)) ytitle("predicted price")
      [ATTACH=CONFIG]n1651274[/ATTACH]
      Thank you very much Maarten!

      Comment


      • #4
        Originally posted by Maarten Buis View Post
        Code:
        // open example data
        sysuse auto, clear
        
        // estimate a model
        reg price c.weight##c.weight i.foreign i.rep78 mpg
        
        // get the x where the minimum occurs
        local x = - _b[weight]/(2*_b[c.weight#c.weight])
        
        // get the y for that minimim
        margins, at(weight = `x' foreign=0 rep78=3 mpg=20)
        // the predictions are stored in the matrix r(b)
        // el(r(b),1,1) extracts the cell 1,1 from the matrix r(b)
        local y = el(r(b),1,1)
        
        // to display those values we don't want all the decimal places
        // : display allows you to control how a number is displayed
        // it adds some spaces before the number, which strtrim() removes
        local ylab : display %9.0fc `y'
        local ylab = strtrim("`ylab'")
        local xlab : display %9.0fc `x'
        local xlab = strtrim("`xlab'")
        
        // prepare for our plot
        margins, at(weight=(1760(20)4840) foreign=0 rep78=3 mpg=20)
        
        // with scatteri we can add a point and a label to our graph
        marginsplot, noci plotopts(msymbol(i)) legend(off) ///
        addplot(scatteri `y' `x' (12) "(`xlab'; `ylab')") ///
        ylab(,format(%9.0fc) angle(0)) ytitle("predicted price")
        [ATTACH=CONFIG]n1651274[/ATTACH]

        That worked like a charm!
        I hate to bother you again, Maarten Buis, but how could I generate the values created for Y and X in the plot as real variables in the dataset?

        Comment


        • #5
          Originally posted by Giorgio Di Stefano View Post
          I hate to bother you again, Maarten Buis, but how could I generate the values created for Y and X in the plot as real variables in the dataset?
          I cannot imagine a single situation where this is not a mistake. So can you tell us why you want to do that? That way we can give you a more sensible way to attain your goals.

          ---------------------------------
          Maarten L. Buis
          University of Konstanz
          Department of history and sociology
          box 40
          78457 Konstanz
          Germany
          http://www.maartenbuis.nl
          ---------------------------------

          Comment


          • #6
            Originally posted by Maarten Buis View Post

            I cannot imagine a single situation where this is not a mistake. So can you tell us why you want to do that? That way we can give you a more sensible way to attain your goals.
            First, because based on the two values derived from margins for X and Y I want to generate another variable. Something like DX/DY. So I need them in my data set.

            Second, I came across the margins generate and margins saving commands (both are among the undocumented commands( help undocumented to access)) and was wondering if I could generate a continuous margins variable for each year in my data . I am trying to understand how those two commands work, because they do allow to generate margins values.

            In my case I have a panel, so I would like to generate real separete margins values for each year and for each id, corrispondented for each x and for each y in my data , that will allow me then to generate new variables in my real dataset.
            Last edited by Giorgio Di Stefano; 04 Mar 2022, 05:47.

            Comment


            • #7
              So your real problem is more complicated that what you have written. If you give us an example of your data, and tell us exactly what your real problem is, then we can try to solve it. Right now we know some bits, but not enough.
              ---------------------------------
              Maarten L. Buis
              University of Konstanz
              Department of history and sociology
              box 40
              78457 Konstanz
              Germany
              http://www.maartenbuis.nl
              ---------------------------------

              Comment


              • #8
                Originally posted by Maarten Buis View Post
                So your real problem is more complicated that what you have written. If you give us an example of your data, and tell us exactly what your real problem is, then we can try to solve it. Right now we know some bits, but not enough.
                I am having a panel for a period of years and for a number of ID (countries) with the solid macro variables, dummies and some custom quality indicators, A sample is provided below. I have a quadratic function so I used for the estimation the code below , which in part came from you

                Code:
                 qui  xtregar Dgdp  cpi u industry ka gw   dummy1 dummy2 dummy3 c.indicator1##c.indicator1, fe
                
                  // get the x where the minimum occurs
                local x = -_b[indicator1]/(2*_b[indicator1#indicator1])
                
                
                // get the y for that minimim
                qui margins, at(indicator1 = `x'   cpi=0  u=2  industry=35 ka=0  gw=-1 dummy)
                // the predictions are stored in the matrix r(b)
                // el(r(b),1,1) extracts the cell 1,1 from the matrix r(b)
                
                local y = el(r(b),1,1)

                That worked like a charm for the panel estimation!

                I need , however, two things:

                - To generate real separete margins values for both X and Y in my real data from which I can then generate another variable at panel level. Something like DX/DY.

                - Then I need to generate and getting margins values for both X and Y for each year and for each id, corrispondented for each x and for each y in my data , that will allow me then to generate new variables in my real dataset. Again something like DX/DY in a continiouw way


                I came across the margins, generate() and margins, saving() commands (both are among the undocumented commands, help undocumented to access) and was wondering if I could generate a continuous margins variable for each year in my data . I am trying to understand how those two commands work, because they do allow to generate margins values ,and If I use then will be able to solve my problem. I could put it in a more complicate way but that will not help.

                In any case, I hope it is clear and you can somehow help me out.


                Code:
                * Example generated by -dataex-. To install: ssc install dataex
                clear
                input float(id ts indicator1 gdp cpi u industry ka gw dummy gdp_hp gdp_trend gdp_gain gdp_fre)
                1 1981  20.613514  4.540717e+11  9.487666  5.78 43.42793 .41687185   .20370182 0   24607873024  4.294638e+11 .49240965 .15707964
                1 1982  20.613514  4.691852e+11  11.35182  7.16 43.09072 .41687185  -.15889087 0   20692293632  4.484929e+11  .9387667  .3141593
                1 1983   6.500914  4.587671e+11  10.03891  9.96 41.44292 .41687185  .027918227 1   -8770313216  4.675374e+11  .9870179  .4712389
                1 1984  3.3282194  4.797846e+11  3.960396  8.99 44.21151 .47684005   1.4786447 1   -6840991232  4.866255e+11  .9957345  .6283185
                1 1985        5.8    5.0497e+11  6.734694  8.26 46.74982  .8200954   -.4968416 0    -810234688  5.057802e+11  .9981819  .7853982
                1 1986        5.8  5.253583e+11   9.05035  8.08 46.31632  .8800636  -.23686917 0     338305568    5.2502e+11  .9990813  .9424778
                1 1987   6.556594  5.387611e+11  8.533022  8.11 49.62373  .9400318   .18794964 1   -5601797632  5.443629e+11  .9994762 1.0995574
                1 1988        7.5  569704251392   7.21594  7.23 53.17501         1    .4695499 0    5877027840  563827245056  .9996728  1.256637
                1 1989        7.5  5.917015e+11  7.533903  6.18 54.96535         1   .03558734 0    8273810944  5.834277e+11  .9997805 1.4137167
                1 1990  10.999176  612831133696  7.333022  6.93 56.63783         1   .06843487 1    9648447488  603182661632  .9998438 1.5707964
                1 1991       12.2  6.103932e+11  3.176675  9.58 56.07949         1    1.616588 0  -12722698240  6.231159e+11  .9998832  1.727876
                1 1992       12.2  6.129091e+11 1.0122311 10.73 56.31247         1      1.9267 0  -30347796480  643256942592  .9999088 1.8849556
                1 1993  17.553352  6.376088e+11 1.7536534 10.87 58.00952         1  -.55177194 1  -26018656256  6.636274e+11  .9999261 2.0420353
                1 1994      19.11  6.630105e+11 1.9696348  9.72 60.82281         1  .007553967 0  -21219708928  6.842302e+11   .999938 2.1991148
                1 1995      19.11  6.884552e+11 4.6277666  8.47 62.44015         1   -.5324481 0  -16596442112  7.050516e+11  .9999464 2.3561945
                1 1996  15.414823  7.151575e+11 2.6153846  8.51 64.93562  .9400318     .980418 1  -10907398144  7.260649e+11  .9999523  2.513274
                1 1997     14.538  7.435245e+11 .22488755  8.36 65.80802  .8800636   10.272155 0   -3708353024  7.472328e+11  .9999563  2.670354
                1 1998  17.287497  7.775533e+11  .8601346  7.68  67.9767  .8200954   -.7689896 1    9041863680  7.685114e+11  .9999589  2.827433
                1 1999  28.634005  8.170032e+11 1.4831294  6.87 68.75488  .7601272   -.3804706 0   27148789760  7.898544e+11  .9999605  2.984513
                1 2000     28.634  8.491371e+11  4.457435  6.28 72.54832   .700159   -.6822261 0   37915975680  8.112211e+11   .999961  3.141593
                2 1981          2  2.080323e+11  6.803042  2.06 36.20454   .700159    -.200444 0    7238820352  200793473024 .49240965 .15707964
                2 1982          2  212216348672  5.436031  3.35 35.98919   .700159   .20921445 0    5037281280  207179071488  .9387667  .3141593
                2 1983  1.0946958  218525728768 3.3391645  4.11 36.29808   .700159    .5968089 1    4956550656  2.135692e+11  .9870179  .4712389
                2 1984   .5089108  2.186378e+11  5.663186   3.8 38.19626   .700159  -.44796655 0   -1333707008  2.199715e+11  .9957345  .6283185
                2 1985   .5089108  224100843520  3.189517   3.6 39.99393   .700159     .823105 0   -2295917312  226396766208  .9981819  .7853982
                2 1986    .561659  2.292583e+11 1.7054446  3.12 40.40985   .700159    1.638252 0   -3596658944  232854945792  .9990813  .9424778
                2 1987   12.24376  2.323697e+11 1.4019527  3.79 40.80097   .700159   .50470144 0   -6984823808  239354527744  .9994762 1.0995574
                2 1988  12.920382  2.400283e+11  1.915717  3.55 42.56515   .700159  -.23894365 0   -5873449984  245901770752  .9996728  1.256637
                2 1989  12.920382  2.493584e+11 2.5683484  3.14 45.09982   .700159  -.26313263 0   -3140161536  252498558976  .9997805 1.4137167
                2 1990  12.619598  260194631680  3.261872  3.25 48.31841   .700159 -.008617969 1    1051509312  2.591431e+11  .9998438 1.5707964
                2 1991        5.1  269149552640  3.337427  3.42 49.15068  .7601272  .012651701 0    3317850112  2.658317e+11  .9998832  1.727876
                2 1992        5.1  274784272384  4.020848  3.59 48.56378  .8200954  -.10854957 0    2223056640  2.725612e+11  .9999088 1.8849556
                2 1993        5.1  276231847936  3.631785  4.25  47.7724  .8800636   .03468369 0   -3.0988e+09  279330652160  .9999261 2.0420353
                2 1994   5.248024  282867269632 2.9534094  3.54 49.68189  .9400318   .26526877 1   -3273104640  286140366848   .999938 2.1991148
                2 1995   7.179246  290414133248 2.2433662  4.35 52.20742         1    .7674453 1   -2.5747e+09  292988846080  .9999464 2.3561945
                2 1996  17.413164  2.972375e+11 1.8609712  5.28  52.7208         1   .16558754 0   -2634905344  299872419840  .9999523  2.513274
                2 1997  17.166555  303460483072 1.3059785  5.15 56.07532         1   .13704391 0   -3325427456  3.067859e+11  .9999563  2.670354
                2 1998  17.155384  314328678400  .9224672  5.52  60.6142         1    .4728145 0     606228928  313722437632  .9999589  2.827433
                2 1999   13.81384  325507252224 .56899375   4.7 64.24256         1    .5897323 1    4834159616  3.206731e+11  .9999605  2.984513
                2 2000   3.427717  3.364955e+11  2.344863  4.69 70.08217         1   -.7848026 0    8.8662e+09  327629275136   .999961  3.141593
                3 1981  1.6382614 1.4984657e+12 13.314405  7.54 79.29216 .41687185   -.9999912 1   27841386496 1.4706243e+12 .49240965 .15707964
                3 1982  -4.953055 1.5360083e+12 11.978472   8.2 78.65401 .16434518    .0278443 0   24426692608 1.5115815e+12  .9387667  .3141593
                3 1983  -4.953055  1.555068e+12  9.459548  7.92 78.70774 .41687185   .17290956 0    2511742976 1.5525562e+12  .9870179  .4712389
                3 1984 -4.7091045 1.5786074e+12  7.673803  9.53 80.06466 .41687185   .13435355 0  -14973496320  1.593581e+12  .9957345  .6283185
                3 1985       -4.4  1.604225e+12    5.8311 10.26 80.26139 .41687185   .34410325 0  -30465157120   1.63469e+12  .9981819  .7853982
                3 1986   17.15525   1.64172e+12  2.538526 10.23 82.29907 .41687185   305361.44 1  -34188257280 1.6759082e+12  .9990813  .9424778
                3 1987  23.033955 1.6837792e+12  3.288898 10.74 83.73698 .41687185  -.09669671 0  -33462192128 1.7172414e+12  .9994762 1.0995574
                3 1988   9.400383 1.7636432e+12  2.700815 10.18 86.72044 .41687185   .26424965 1    4969083392  1.758674e+12  .9996728  1.256637
                3 1989        1.6 1.8402534e+12  3.498302  9.62 89.72697 .41687185   -.2393705 0   40083447808   1.80017e+12  .9997805 1.4137167
                3 1990        1.6  1.894061e+12 3.1942835  9.36 91.03416 .47684005  -.08574203 0   52365762560 1.8416954e+12  .9998438 1.5707964
                3 1991        1.6 1.9139143e+12  3.213407  9.13 90.95167 .53680825    -.999992 0   30671927296 1.8832424e+12  .9998832  1.727876
                3 1992        1.6 1.9445244e+12 2.3637605 10.21 90.21667  .5967765       .4548 0   1.96893e+10  1.924835e+12  .9999088 1.8849556
                3 1993   6.996447    1.9323e+12 2.1044629 11.32    86.85  .9400318  .022043044 1  -34217535488 1.9665174e+12  .9999261 2.0420353
                3 1994    8.69136   1.97787e+12 1.6555153 12.59 90.03333         1    .2997584 0  -30475014144  2.008345e+12   .999938 2.1991148
                3 1995    8.69136 2.0195377e+12 1.7964814 11.84 92.69833         1   .05559472 0  -30814965760 2.0503527e+12  .9999464 2.3561945
                3 1996    8.69136 2.0480737e+12 1.9828837 12.37    93.46         1   118525.52 0  -44482052096 2.0925557e+12  .9999523  2.513274
                3 1997   5.041234  2.095923e+12  1.203943 12.57 97.54333         1    .4296218 1  -39027585024 2.1349504e+12  .9999563  2.670354
                3 1998   2.364474 2.1711383e+12  .6511269 12.07 101.5933         1    .8784832 0   -6366802432  2.177505e+12  .9999589  2.827433
                3 1999   2.364474  2.245421e+12  .5371416 11.98  104.295         1    .1964599 0   2.52569e+10  2.220164e+12  .9999605  2.984513
                3 2000   2.364474 2.3335238e+12   1.67596 10.22 108.6008         1   -.9999971 0   70656811008  2.262867e+12   .999961  3.141593
                4 1981       18.6 1.2182697e+12 11.876627  10.4 77.52663  .8800636    .3102416 0    8643661824  1.209626e+12 .49240965 .15707964
                4 1982       18.6 1.2425728e+12  8.598864  10.9  77.7118  .9400318     .230822 0  -10718431232 1.2532912e+12  .9387667  .3141593
                4 1983  18.766483 1.2950324e+12 4.6093035 11.09 79.73109         1    .6651978 1   -1929432320 1.2969618e+12  .9870179  .4712389
                4 1984       18.9  1.324418e+12  4.960711  10.9 80.24253         1  -.12341004 0  -16218454016 1.3406365e+12  .9957345  .6283185
                4 1985       18.9 1.3793472e+12  6.071394 11.49 84.36929         1  -.16183244 0   -4965636608  1.384313e+12  .9981819  .7853982
                4 1986       18.9 1.4228014e+12 3.4276094 11.51 86.21222         1   1.1283993 0   -5176743424  1.427978e+12  .9990813  .9424778
                4 1987  17.745354 1.4995292e+12 4.1489224 11.02 89.77464         1 -.015180643 1   27912605696 1.4716166e+12  .9994762 1.0995574
                4 1988     16.809 1.5854885e+12 4.1553516  9.01 94.41283         1   .18605655 0   70279110656 1.5152094e+12  .9996728  1.256637
                4 1989     16.809  1.626356e+12  5.760249  7.41 96.38803         1  -.27347788 0   67601256448 1.5587548e+12  .9997805 1.4137167
                4 1990     16.809 1.6382895e+12  8.063461  6.97 96.41448         1    83413.91 0   35994152960 1.6022953e+12  .9998438 1.5707964
                4 1991     16.809 1.6202173e+12  7.461783  8.55  93.1948         1   .09337864 0  -25698349056 1.6459157e+12  .9998832  1.727876
                4 1992  13.403038 1.6267156e+12 4.5915494  9.78 93.60826         1    .6429237 1  -63007240192  1.689723e+12  .9999088 1.8849556
                4 1993       12.1  1.667218e+12  2.558578 10.35 95.62276         1   -.9999845 0  -66589822976  1.733808e+12  .9999261 2.0420353
                4 1994       12.1 1.7313395e+12 2.2190125  9.65  100.681         1   123614.65 0  -46883278848 1.7782228e+12   .999938 2.1991148
                4 1995       12.1 1.7751713e+12  2.697495  8.69 102.4492         1  -.13095939 0  -47806025728 1.8229773e+12  .9999464 2.3561945
                4 1996       12.1 1.8194017e+12  2.851782  8.19 103.8479         1 -.033561174 0  -4.86507e+10 1.8680523e+12  .9999523  2.513274
                4 1997   5.227907 1.9099222e+12  2.201143  7.07 106.6101         1    .4296572 1   -3476611584 1.9133988e+12  .9999563  2.670354
                4 1998      1.806 1.9807378e+12 1.8205616   6.2 107.4667         1   .27417862 0   2.18006e+10 1.9589372e+12  .9999589  2.827433
                4 1999      1.806  2.046007e+12 1.7529508  6.04  108.652         1  .024280345 0   41421279232  2.004586e+12  .9999605  2.984513
                4 2000      1.806 2.1177446e+12 1.1829562  5.56 110.4949         1    .3995405 0   67468062720 2.0502766e+12   .999961  3.141593
                5 1981   7.720604  6.661146e+12 10.334715   7.6 50.72995         1    .4146612 0  301238255616  6.359908e+12 .49240965 .15707964
                5 1982        8.3  6.541054e+12  6.131427   9.7 48.11071         1    .6862257 1 -109358833664  6.650412e+12  .9387667  .3141593
                5 1983        8.3  6.840891e+12  3.212435   9.6 49.41756         1    .9804647 0 -100214685696  6.941105e+12  .9870179  .4712389
                5 1984        8.3   7.33594e+12 4.3005357   7.5 53.80223         1   -.1878409 1  103833616384  7.232107e+12  .9957345  .6283185
                5 1985   16.16676  7.641824e+12  3.545644   7.2 54.46311         1   -.8751099 0  118350176256  7.523474e+12  .9981819  .7853982
                5 1986       16.6  7.906433e+12 1.8980477     7 55.01276         1   17.963144 1   91105533952  7.815328e+12  .9990813  .9424778
                5 1987       16.6  8.179962e+12  3.664563   6.2 57.87624         1     -.44877 0   72096243712  8.107866e+12  .9994762 1.0995574
                5 1988       16.6  8.521643e+12  4.077741   5.5 60.88547         1  -.05447189 1  1.203017e+11  8.401341e+12  .9996728  1.256637
                5 1989  14.988736  8.834614e+12  4.827003   5.3 61.43758         1   -.1320547 0  138562060288  8.696052e+12  .9997805 1.4137167
                5 1990       14.9  9.001231e+12  5.397956   5.6 62.05701         1  -.08746292 1    8861103104   8.99237e+12  .9998438 1.5707964
                5 1991       14.9  8.991487e+12  4.234964   6.8 61.15007         1    .2589748 0 -299270340608  9.290757e+12  .9998832  1.727876
                5 1992       14.9  9.308206e+12 3.0288196   7.5 62.92408         1   13.807285 1 -283471970304  9.591678e+12  .9999088 1.8849556
                5 1993   .0375137  9.564447e+12  2.951657   6.9 64.99349         1   .04719354 0 -3.309646e+11  9.895411e+12  .9999261 2.0420353
                5 1994      -.781  9.949782e+12  2.607442  6.12 68.42391         1   .17382646 1 -252275425280 1.0202058e+13   .999938 2.1991148
                5 1995      -.781 1.0216863e+13   2.80542  5.65 71.58787         1 -.032830253 0 -294649462784 1.0511513e+13  .9999464 2.3561945
                5 1996      -.781 1.0602295e+13  2.931204  5.45 74.84686         1  -.02388202 1 -221217554432  1.082351e+13  .9999523  2.513274
                5 1997  1.3458682 1.1073802e+13 2.3376899     5 80.20259         1   .29131374 0  -63806414848  1.113761e+13  .9999563  2.670354
                5 1998      1.463 1.1570064e+13  1.552279  4.51 84.89986         1   .55129653 1  1.168468e+11 1.1453217e+13  .9999589  2.827433
                5 1999      1.463 1.2120017e+13 2.1880271  4.22 88.64145         1   -.9274685 0  3.503052e+11 1.1769712e+13  .9999605  2.984513
                5 2000      1.463  1.262027e+13  3.376857  3.99 92.05371         1    5.664342 1  5.337286e+11  1.208654e+13   .999961  3.141593
                end

                Comment


                • #9
                  I think we are having an xy problem: https://xyproblem.info/

                  You are telling us about various mechanical steps you think you want to take, but not what you want to achieve with those steps. The problem is that the steps you think you want to take are in all likelihood wrong. Anyhow, it is weekend now, and the coming weeks I will be busy, so it will take a while before I can answer. Maybe somebody else can take this over Nick Cox Clyde Schechter ?
                  ---------------------------------
                  Maarten L. Buis
                  University of Konstanz
                  Department of history and sociology
                  box 40
                  78457 Konstanz
                  Germany
                  http://www.maartenbuis.nl
                  ---------------------------------

                  Comment


                  • #10
                    Originally posted by Maarten Buis View Post
                    I think we are having an xy problem: https://xyproblem.info/

                    You are telling us about various mechanical steps you think you want to take, but not what you want to achieve with those steps. The problem is that the steps you think you want to take are in all likelihood wrong. Anyhow, it is weekend now, and the coming weeks I will be busy, so it will take a while before I can answer. Maybe somebody else can take this over Nick Cox Clyde Schechter ?
                    I think it is simple. I want to find the optimal, create margins if get it right , I call them the optimal values , for which the indicator maximizes and it's corresponding level of output under the maximum value.. That needs to be done at panel level and for every single year and Id.
                    You have snow me how to do than in the margins plot. figure. I need to produce those data in the panel but also for each single period and year. Once done that I can generate other kinds of variables and graphs.

                    Will that margins, generate() command work here or do margins accepts by Id and year option? I am trying to figure out how to get them.

                    My function is a quadratic shown in #1. It works well for panel estimates. I can write it in a more mathematical way if that is the case.
                    ​​​​I just need to produce those values in my real data as well for each single year and id

                    Comment


                    • #11
                      I am sorry, but you still haven't answered my question. Creating a variable is not your goal, it is a step you think you need to achieve your goal. There are some vague referencr s to some graph, but that is nowhere near enough for us to work with.
                      ---------------------------------
                      Maarten L. Buis
                      University of Konstanz
                      Department of history and sociology
                      box 40
                      78457 Konstanz
                      Germany
                      http://www.maartenbuis.nl
                      ---------------------------------

                      Comment


                      • #12
                        Originally posted by Maarten Buis View Post
                        I am sorry, but you still haven't answered my question. Creating a variable is not your goal, it is a step you think you need to achieve your goal. There are some vague referencr s to some graph, but that is nowhere near enough for us to work with.
                        I need to estimate the gaps between the actual and the optimal values, which then will allow me to study some other types of relations and to create some new variables.

                        On #2 what will be the way to produce in the dataset the pair of the margin values in the plot? That will be a way to study at panel level the relations I am having.

                        Comment


                        • #13
                          You have to admit that "some other types of relations and to create some new variables" is pretty vague. The problem with working with computers is that computers don't do vague. So in order to help you we need the details you seem to be unwilling to give. So I give up.
                          ---------------------------------
                          Maarten L. Buis
                          University of Konstanz
                          Department of history and sociology
                          box 40
                          78457 Konstanz
                          Germany
                          http://www.maartenbuis.nl
                          ---------------------------------

                          Comment


                          • #14
                            Originally posted by Maarten Buis View Post
                            You have to admit that "some other types of relations and to create some new variables" is pretty vague. The problem with working with computers is that computers don't do vague. So in order to help you we need the details you seem to be unwilling to give. So I give up.

                            I gave those relations earlier above, i.e. in # 6 and talked about gaps in #12 . `Gaps are defined as actual -optimal

                            Dindicator/Dgdp is my relation .

                            Actual(indicator)-optimal (indicator)/ Actual(GDP)-optimal (GDP).

                            Same pattern I will need to apply for my other variables. The optimal values I need to estimate.

                            To start with on #2 what will be the way to produce in the dataset the pair of the margin values in the plot? That will be a way to study at panel level the relations I am having.
                            Last edited by Giorgio Di Stefano; 04 Mar 2022, 16:50.

                            Comment

                            Working...
                            X