Hello All!
I am working with sectoral employment data pulled from the FRED using "import fred". After initially creating a time series plot with the raw data, I decided graphing sectoral employment as a year to date change would be a more helpful visual. When I lag my variables, the chart axis shift completely (I've attached a picture of the graph error - data set is from 2016-current).
Could someone tell me where my error is? All variables are collected monthly. The weirdest thing is that when I rerun the code with a different daterange chosen when importing data the axis changes how shifted it is (two pictures one created with the import daterange starting at 2016 and one at 2018.
************************************************** ************************************************** ************************************************** ************************************************** ********
import fred v1 v 2 v3, daterange(2016-01-01 .)
replace daten = mofd(daten)
gen lag = daten[_n-12]
tsset lag
***************Percent Change Lag**********
generate v1_lag = ((v1[_n] - v1[_n-12])/ v1[_n-12])*100
generate v2_lag = ((v2[_n] - v2[_n-12])/ v2[_n-12])*100
generate v3_lag = ((v3[_n] - v3[_n-12])/ v3[_n-12])*100
graph twoway (tsline v1_lag) (tsline v2_lag) (tsline v3_lag), ytitle("Percent Change from Last Year" "") xtitle("" "") title("Percent Change in Number of People Employed by Sector") subtitle("January 2016-June 2020") note("Source: Federal Reserve Bank of St Louis ") tlabel(, format(%tmCCYY))]
************************************************** ************************************************** ************************************************** ************************************************** ********
[ATTACH]temp_18885_1594309031634_989[/ATTACH]
I followed this code but for ease of reading I renamed the variables - removed one variable from sample code since it is occurring in all of them on the graph
Related Posts with Error in Time Series Plot when lagged
Regarding error message “ fpc for all observations within a stratum must be the same” with PPS sampling design, how to handle it ?Dear Statalists, I am running analysis on a survey dataset which use multi-stage stratified systemat…
'No observations' errorDear all, I'm trying to conduct a unit root test to my variables using the following code: Code: …
Problem with esttab and estpost, exporting to latexHello all, I am trying to export my tabstat table to Latex, however, my code only generates an almo…
multiple regression - r(2000) error messageHi everyone, I am new here and quite new to Stata (student) so thank you upfront for your help. I …
multiple regression - r(2000) error messageHi everyone, I am new here and quite new to Stata (student) so thank you upfront for your help. I …
Subscribe to:
Post Comments (Atom)
0 Response to Error in Time Series Plot when lagged
Post a Comment