

Type the following into the Command box to create a scatterplot:

mpg so we can visualize the relationship between these two variables and check for any obvious outliers. We can see that there are 12 different variables in the dataset, but the only two that we care about are mpg and weight.īefore we perform simple linear regression, let’s first create a scatterplot of weight vs. Gain a quick understanding of the data you’re working with by typing the following into the Command box: Load the data by typing the following into the Command box: Perform the following steps in Stata to conduct a simple linear regression using the dataset called auto, which contains data on 74 different cars. Suppose we are interested in understanding the relationship between the weight of a car and its miles per gallon. To explore this relationship, we can perform simple linear regression using weight as an explanatory variable and miles per gallon as a response variable. Example: Simple Linear Regression in Stata This tutorial explains how to perform simple linear regression in Stata. Simple linear regressionis a method you can use to understand the relationship between an explanatory variable, x, and a response variable, y.
