Announcement

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

  • Plotting Graph

    Good day,
    Please.!!! I need help with regard to the following;
    1. How to plot a U-shape graph and
    2. How to plot a scatter graph and compute the R and R-square value.

    I look forward for your help.

    Thanks

  • #2
    I find it hard to know where to start answering this question. What have you tried thus far? What has Stata given you, and why does that not meet your requirements?

    The U-shaped graph has to come from somewhere. Is it a polynomial maybe? Can it be any polynomial, or do you need it to fit some data? If yes, can you give us an extract of that data (help dataex)?

    If you want a scatter graph, then the first thing to do is to type in Stata help scatter

    If you want the correlation between two variables then you type in Stata help correlate

    If you want the r-squared then you can either just square the correlation coefficient (assuming a bivariate regression) or you can type help regress
    ---------------------------------
    Maarten L. Buis
    University of Konstanz
    Department of history and sociology
    box 40
    78457 Konstanz
    Germany
    http://www.maartenbuis.nl
    ---------------------------------

    Comment


    • #3
      Sorry if my questions seems confusing,
      I am doing a preliminary test of variables (Conflict and Natural resources) trying to know the correlation using scatter plot.
      My question is how to get the R and R-square for the graph and also how to plot a graph to show U-shape between this variables using stata.
      Attached Files

      Comment


      • #4
        Now I am even more confused: you asked about how to plot a scatter graph in #1, and now you apparently already have a scatter graph.

        This is a technical forum. This means that if we ask "What have you tried thus far?", we would like to see the exact steps you have taken (preferably the code). I assume the graph is the result of one of the steps you have taken, but we should not have to guess, you should tell us because we may guess wrong. You haven't told us how you created the graph. Moreover, you haven't told us why that does not meet your requirements. Do you want some text added that gives the correlation or R-squared? Do you want the line to be U-shaped? What kind of U-shape do you want? Can you give us an extract of your data? See help dataex and section 12.2 of the Statalist FAQ: https://www.statalist.org/forums/help#stata . Getting exact code and exact data really helps us pin down what your problem is. Without knowing what the problem is, we obviously cannot help you. I told you to type help correlate and help regress. Did you do that? If so, then apparently that did not solve your problem. Why not? (The answer to this question is important as it can get us closer to finding out what your real problem is)

        I realize that asking questions on a forum like this can be hard. I have asked these return questions in #2 and here, not to annoy you, but to help you ask an answerable question. The best thing you can do is systematically go through and answer all these questions.

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

        Comment


        • #5
          I'm not sure whether I understood your query right, but:

          a) Using - regress yvar xvar - will provide the R and R-squared. After having the plot, you may click on "T" and add the text wherever you wish.

          b) The U-shaped curve may - or may not, depending on the regression model - appear when we add quadratic terms. For example: regress yvar c.xvar##c.xvar - may sometimes produce the U - or inverted U - shaped curve.

          Actually, we won't "get the R and R-squared for the graph", but we may get this under a regression model, then plot it.

          On second thought, if you only have the graph under .gph extension, and you wish to recover the data, you may deal with sersets for that matter. Just type - help serset - and take a look at the examples.
          Best regards,

          Marcos

          Comment


          • #6
            Good all,
            I was able to get a command to plot a graph I needed for the U-shape and inverted U-shape using the cpommand "twoway (qfit VariableY VariableX) (scatter VariableY VariableX)"

            Now I used an interaction term in a linear regression model i.e. Y= c + X1 + X2 + X1*X2, where X2 is a governance variable (e.g. -2.5 to 2.5) that condition the impact of X1 on Y. However, i tried using the mfx command, but not giving me the result as i want. I would need someone to help me other STATA commands that can easily allow me to compute :
            1. Marginal effect =
            2. Standard error =

            thanks in anticipation

            Comment


            • #7
              Quite a delay in #6 (6 years) for the reply ...

              Unless you are using a quite old Stata version, please use - margins - instead of - mfx - command.

              This text written by Richard Williams will be helpful.
              Best regards,

              Marcos

              Comment

              Working...
              X