puppykrot.blogg.se

Twoway scatter stata
Twoway scatter stata








twoway scatter stata
  1. #Twoway scatter stata how to#
  2. #Twoway scatter stata code#

Within that you give a list of plot numbers and associated labels much like a list of value labels. You can do so with the legend option, which then contains the order option. Unfortunately, the default legend at the bottom is now completely useless, so you'll need to specify what it should say. Scatter weight height if sex=1 || scatter weight height if sex=2

#Twoway scatter stata code#

You can use similar code to plot subsamples in different colors: Scatter weight height || lfit weight height To add a linear fit plot to a scatterplot, first specify the scatterplot, then put two "pipe" characters (what you get when you press shift-Backslash) to tell Stata you're now going to add another plot, and then specify the linear fit. You can plot a regression line or "linear fit" with the lfit command followed, as with scatter, by the variables involved. Regression attempts to find the line that best fits these points.

twoway scatter stata

The distribution of the points suggests a positive relationship between height and weight (i.e. The first variable you list will be the Y variable and the second will be the X variable. To create a scatterplot, use the scatter command, then list the variables you want to plot. If you plan on applying what you learn directly to your homework, create a similar do file but have it load the data set used for your assignment. Then create a do file called scatter.do in that folder that loads the GSS sample as described in Doing Your Work Using Do Files. If you plan to carry out the examples in this article, make sure you've downloaded the GSS sample to your U:\SFS folder as described in Managing Stata Files.

#Twoway scatter stata how to#

This section will teach you how to make scatterplots Using Graphs discusses what you can do with a graph once you've made it, such as printing it, adding it to a Word document, etc. If you believe there is a causal relationship between the two variables, convention suggests you make the cause X and the effect Y, but a scatterplot is useful even if there is no such relationship. One variable is designated as the Y variable and one as the X variable, and a point is placed on the graph for each observation at the location corresponding to its values of those variables. If you are new to Stata we strongly recommend reading all the articles in the Stata Basics section.Ī scatterplot is an excellent tool for examining the relationship between two quantitative variables. This article is part of the Stata for Students series.










Twoway scatter stata