Introduction
When working with time-series data, especially in economics, you will often need to graph data as they change over time. In this blog, we’ll show you how to use Stata to create a time-series line.
Entering Your Data
Let’s create some mock quarterly data in Stata that we can use to create a time-series line. Let’s (a) create 84 sequential quarters, running from 2001q3 to 2022q2; (b) generate a variable, x, that fluctuates randomly from 1 to 100; and (c) plot x as a function of quarter. Try the following code:
set obs 84
gen quarter = tq(2001q3) + _n-1
format %tq quarter
tsset quarter
label variable quarter "Quarter"
gen x = runiform(1,100)
tsline x
The Time-Series Line
Here’s what results:
In future blog entries, we’ll dive into time-series analysis in greater detail.
BridgeText can help you with all of your statistical analysis needs.