Upload
others
View
33
Download
1
Embed Size (px)
Citation preview
Introduction to Eviews
Introduction to Eviews
1. Workfile
Overview of a workfile
i. A workfile is a container for Eviews objects similar to an excel sheet. It may
contain time series, graphs, tables, models, equations, matrices.
ii. A workfile is object orientated. Meaning you tell the workfile what type of
object you want to create and then it is listed in the workfile
Overview of Databases
i. Databases are eviews files that can be used to store large amounts of data of
various frequencies.
ii. They are protected and can not be easily corrupted.
Creating a workfile
i. Create an annual workfile
ii. Walk class on how to fetch data through an excel sheet and database or
through creating empty group
1. Use Indonesian trade SCtrade
a. Fetch imports and exports into monthly file
2. Fetch pmm and pxx from database
Working with the data
i. Viewing the data
ii. Editing the data
iii. Graph the data
iv. Graphing options
v. sample
vi. Descriptive statistics
vii. Correlations
viii. Tabs with different frequencies
ix. Linking tabs
x. Groups
xi. Numeric expressions
1. @movav
2. @mean
xii. Dated Data Tables
Assignment 1
Estimating a regression 1. Testing stationarity of time series using a unit root test (Augmented Dickey Fuller)
a. Example of unit root test for log(CAD/USD exchange rate); b. Exercise: Test for stationarity of log(Rupiah/USD exchange rate).
2. Estimating a basic regression in Eviews - Example: CAD/USD exchange rate (number of Canadian
dollars needed to buy one U.S. dollar) a. Dependent variable of the equation is the exchange rate. That’s the variable we want to
explain. b. Now, we want to identify which variables we could use to help us predict exchange rate
movements. c. Movements in the exchange rate between two currencies can depend on a number of
factors 3. Interpretation using different tests (R2, P-values, Durbin Watson, Breusch-Godfrey, etc).
a. R2 interpretation and issues
b. T-Statistics and p-value interpretation.
c. F-statistics – We are testing if the coefficients of a set of independent variables are jointly
significant.
d. When estimating a regression, we must also check whether there is autocorrelation in the
residuals of the equation.
i. There are two different tests that can be used to detect the presence of
autocorrelation: the Durbin Watson statistic and the Breusch-Godfrey test.
e. Wald Test example
f. Exercise: Estimate an equation for the USD/IDR exchange rate (number of Rupiahs needed to buy one U.S. dollar): Hint: you may have a look at the mnemonic reference sheet.
i. What Indonesian data is available in the workfile? What can we use? We have short-
term interest rates for both Indonesia and the U.S., we have the consumer price index for the two countries. We can also try to use the GDP ratio of the two countries.
g. Next exercise: Let’s estimate the equation for the CAD/IDR exchange rate.
Creating a model (Part 1) 1. Theory of Model
a. A model consists of a set of equations that describe the relationships between a set of
variables.
b. The variables in a model can be divided into two categories: the endogenous variables are
determined inside the model and the exogenous variables are determined outside the
model.
c. Models are used to solve for values of the endogenous variables, given information on other
variables in the model.
d. For the model to have a unique solution, there should typically be as many equations as
there are endogenous variables.
Example using exchange rate equation and Canadian exports of machinery and equipment
Assessing the model over history
Using a static solution
Using a dynamic solution
Using the model to Forecast
A first step in producing a forecast, we need to decide on the values for our exogenous variables during
the forecast period.
Repeat this exercise but by producing a (very general) model for forecasting Indonesian exports (See
database for data of potential variables to use in the equations).
Simple programming and important commands (Julie) Recall the advantages of a program:
Good way to remember methodology
Can redo/change work quickly
Eliminate repetitive tasks
Easy to go back and source any errors
Can allow you to treat and analyse huge amounts of data
May take more time initially (learning curve)
1. Importing and exporting data;
a. Example
b. Exercise
2. Seasonal adjustments;
a. Example
b. Exercise
3. Subroutines;
a. Example
b. Exercise
4. Charts;
a. Example
b. Exercise
5. The FOR loop;
a. Example
b. Exercise
6. The IF statement;
Section 2: Creating a program
With the mouse open up a new program FILE, NEW, PROGRAM. Save it right away as C:\COUREV\PROGRAM\EX2P.PRG
What is a program? Execute a series of commands. Everything we do with the mouse can be done with commands!
Advantages of a program:
Good way to remember methodology
Can redo/change work quickly
Eliminate repetitive tasks
Easy to go back and source any errors
Can allow you to treat and analyse huge amounts of data
May take more time initially (learning curve)
CLOSE TEST2.WF1 WORKFILE C:\COUREV\WORKFILE\TEST2.WF1 Q 1970:1 2001:4 SERIES X = 1 SERIES Y = 10 PROGRAM REGRESS
LS Y C TIME %0 %1 %2 %3 %4 %5 %6 %7 %8
RUN REGRESS X X(-1) X(-2)
Loops and conditional statements
FOR, WHILE loops.
Most common is the FOR loop.
!COUNTER = 0
FOR !i = 1 TO 10 STEP 1
!COUNTER = !COUNTER+!i
NEXT
Or
FOR %i SER1 SER2 SER3 SER4
{%i}.X11M {%i}_SA
NEXT
GROUP DATA SER1 SER2 SER3 SER4
FOR !i = 1 TO DATA.@COUNT
%i = DATA.@SERIESNAME(!I)
{%i}.X11M {%i}_SA
NEXT
Conditional Statements
IF condition THEN
ELSE
ENDIF
IF %VAR = "SALESK" THEN
…..
ELSE
….
ENDIF
Or
IF !APC > 0.05 AND !AVL > 0.001 THEN
PRINT….
ENDIF
Exercise
Create a program to compare two time series. If the level difference and percentage difference are greater than a critical value, print them out.
The program has already been started for you in C:\COUREV\PROGRAM\CHECKD.PRG
Two functions that you will need are @MAX and @ABS. The full program is available as C_ORG.PRG
Estimate equation, ' ========================================================================= ' C:\COURSEEV\PROGRAM\CHECKD.PRG ' ' Created: 03/2001. ' Last change: 02/2016. ' Author of last change: CBoC ' ' Source file: C:\COURSEEV\DATABASE\FIN154B.DB ' ' Results file: C:\COURSEEV\WORKFILE\TEST7.WF1 ' ' DESCRIPTION: ' ' This program check the difference (error) between two series. If the difference is greater than a critical value, we take note in a table. ' ========================================================================= ' ---------------------------------------------------------------------------------------------- ' -------------------- PROGRAM STARTS ------------------------- ' ---------------------------------------------------------------------------------------------- ' ***** New workfile ***** CLOSE TEST7.WF1 WORKFILE C:\COURSEEV\WORKFILE\TEST7.WF1 Q 1961:1 2015:3 ' ***** Fetch data from database ***** FETCH(D=C:\COURSEEV\DATABASE\FIN154B.EDB) CHK HP15 HP RPRIME PCER YHDIK ' ***** Estimate equation and generate forecast ***** SMPL 1981:1 2015:3 EQUATION CHK_EQ.LS LOG(CHK/HP) C LOG(YHDIK/HP) (RPRIME-PCER) SMPL 1990:1 2015:3 CHK_EQ.FORECAST CHK_F ' ***** We generate a table named VALMAX, we check the differences (or errors over history) in table VALMAX***** SMPL 1990:1 2015:3 TABLE VALMAX VALMAX(1,1) = "Check errors" VALMAX(3,1) = "Series" VALMAX(2,2) = "Error Max"
VALMAX(2,3) = "Error Max" VALMAX(3,2) = "in levels" VALMAX(3,3) = "in percent" !COUNTER = 4 FOR %i CHK GENR {%i}_ER = {%i}_F-{%i} GENR {%i}_ERP = ({%i}_ER/{%i})*100 !EEE = @MAX(@ABS({%i}_ER)) !PPP = @MAX(@ABS({%i}_ERP)) IF !EEE>2000 OR !PPP>1.00 THEN !COUNTER = !COUNTER +1 VALMAX(!COUNTER,1) = %i VALMAX(!COUNTER,2) = !EEE VALMAX(!COUNTER,3) = !PPP ENDIF NEXT SHOW VALMAX STOP
Subroutines Set of commands that allows you to execute a task repeatedly. By default subroutines are defined as global, but you can also define them as local. Declare a subroutine at the beginning of a program. Nothing gets executed until you call the subroutine with a CALL statement.
Eg.
SUBROUTINE SQUARE(SERIES SSS, SERIES SSS_2)
SERIES SSS_2 = (SSS^2)
ENDSUB
SERIES X = 4
SERIES Y
CALL SQUARE(X,Y)
The following program contains a useful example of subroutine use.
' ========================================================================= ' C:\COUREV\PROGRAM\MFIND.PRG ' ' Created: 03/2001. ' Last change: 02/2016. ' Author of last change: CBoC ' ' Source file: None ' ' Results file: C:\COUREV\WORKFILE\TEST8.WF1 ' ' DESCRIPTION: ' ' This program uses a subroutine to determine if series contain NA values (missing values). ' ========================================================================= ' ---------------------------------------------------------------------------------------------- ' ----------------------------- SUBROUTINES --------------------------------- ' ---------------------------------------------------------------------------------------------- ' Check data reads in series and sample object and returns ' a string object ie. %CNA. SUBROUTINE CHECKDATA(SERIES X, SAMPLE SSS) SMPL SSS GENR T=X<>NA SCALAR CCC
CCC = @MIN(T) IF CCC=0 THEN %CNA= "NA DATA FOUND" ELSE %CNA = "NO MISSING DATA" ENDIF ENDSUB ' ---------------------------------------------------------------------------------------------- ' -------------------- PROGRAM STARTS------------------------- ' ---------------------------------------------------------------------------------------------- ' ***** New workfile ***** CLOSE TEST8.WF1 WORKFILE C:\COURSEEV\WORKFILE\TEST8.WF1 Q 1961:1 2015:2 ' ***** Fetch data from database ***** FETCH(D=C:\COURSEEV\DATABASE\FIN154B.EDB) CHCFOK CHFBEK YGDPK IBNSK IBRNK SMPL 1981:1 2015:3 ' ***** Create NA to test subroutine ***** CHCFOK.FILL(O=1998:3) NA CHFBEK.FILL(O=1985:1) NA YGDPK.FILL(O=2002:4) NA ' ***** Check NAs ***** SAMPLE RANGE 1981:1 2015:3 TABLE RESULTS SETCOLWIDTH(RESULTS,1,20) !COUNTER = 0 FOR %i CHCFOK CHFBEK YGDPK IBNSK IBRNK CALL CHECKDATA({%i},RANGE) IF CCC = 0 THEN !COUNTER = !COUNTER+1 RESULTS(!COUNTER,1) = %i RESULTS(!COUNTER,2) = %CNA ENDIF NEXT SHOW RESULTS STOP
Section 3: Importing/Exporting Data
Eviews can import data from many sources: Excel, TSD to name a few. Or we can simply copy and paste into EViews.
TSD files, need to be careful not to mix frequencies, otherwise very simple commands TSDFETCH or TSDLOAD.
READ and WRITE commands in following program.
' ========================================================================= ' C:\COURSEEV\PROGRAM\IMPEXP.PRG ' ' Created: 03/2001. ' Last change: 02/2016. ' Author of last change: CBoC ' ' Source File: C:\COURSEEV\EXCEL\CANDATA.XLS ' ' Results File: C:\COURSEEV\WORKFILE\TEST3.WF1 ' ' DESCRIPTION: ' ' This program import data from an Excel spreadsheet. The program then modifies the data and send them to another Excel spreadsheet in a formatted table. ' ========================================================================= ' ---------------------------------------------------------------------------------------------- ' -------------------- PROGRAM STARTS ------------------------- ' ---------------------------------------------------------------------------------------------- ' ***** New workfile ***** CLOSE TEST3.WF1 WORKFILE C:\COUREV\WORKFILE\TEST3.WF1 Q 1981:1 2015:3 ' ***** Read data in an Excel spreadsheet ***** SMPL 1981:1 @LAST READ(B2,T=XLS,T) C:\COURSEEV\EXCEL\CANDATA.XLS YGDPK CHK E YHDIK BPROF PFX XK MK XAGK XENK XMFK XCGK XCMK XPMK XCHK XPAK RBANK IBNK IBRK IGK GROUP CANADA ' ***** Calculate annualized growth rates ***** FOR %i YGDPK CHK E YHDIK BPROF PFX XK MK XAGK XENK XMFK XCGK XCMK XPMK XCHK XPAK RBANK IBNK IBRK IGK GENR {%i}_CA = ((({%i}/({%i}(-1)+0.00000000000001))^4)-1)*100 CANADA.APPEND {%i} {%i}_CA NEXT SMPL 1998:1 2015:3
WRITE(DATES,T) C:\COURSEEV\EXCEL\TAB1.XLS CANADA GROUP TABEV YGDPK CHK E YHDIK BPROF PFX XK MK XAGK XENK XMFK XCGK XCMK XPMK XCHK XPAK RBANK IBNK IBRK IGK SHOW TABEV STOP
Section 4: Automated Graphs and Copying to Word
Note that the graphs, once created can be copied <control><ins> to word or other windows based applications. Open C:\COUREV\WORD\GRAPHIQUES.DOC.
Direct links to graphics objects can be done using metafile options (rather cumbersome).
' ========================================================================= ' C:\COUREV\PROGRAM\GRAPHS.PRG ' ' Created: 03/2001. ' Last change: 02/2016. ' Author of last change: CBoC ' ' Source file: C:\COURSEEV\EXCEL\CANDATA2.XLS ' ' Result file: C:\COURSEEV\WORKFILE\TEST4.WF1 ' ' DESCRIPTION: ' ' This program creates many charts ready for a Word document. ' ========================================================================= ' ***** New workfile ***** CLOSE TEST4.WF1 WORKFILE C:\COURSEEV\WORKFILE\TEST4.WF1 Q 1981:1 2015:3 ' ***** Read data from an Excel spreadsheet ***** SMPL 1981:1 @LAST READ(B2,T=XLS,T) C:\COURSEEV\EXCEL\CANDATA_CONS.XLS CHK CHNDK CHFBEK CHABTK CHMFLK CHELEK CHONDK CHSDK CHCFOK CHHSDK CHREPK CHDUK CHVEPK CHFHAK CHODUK CHSEK CHCRCK CHEHPK CHIFLK CHTRAK CHAFOK CHDWRK CHNEAK GROUP CONSUM CHK CHNDK CHFBEK CHABTK CHMFLK CHELEK CHONDK CHSDK CHCFOK CHHSDK CHREPK CHDUK CHVEPK CHFHAK CHODUK CHSEK CHCRCK CHEHPK CHIFLK CHTRAK CHAFOK CHDWRK CHNEAK FOR !i = 1 TO CONSUM.@COUNT
%i = CONSUM.@SERIESNAME(!i) {%i}.HPF(LAMBDA=1600) TREND COPY {%i} LEVEL GRAPH {%i}_G.LINE(A) LEVEL TREND {%i}_G.DRAW(SHADE, BOTTOM) 1980:1 1982:4 {%i}_G.DRAW(SHADE, BOTTOM) 1990:1 1992:4 {%i}_G.DRAW(SHADE, BOTTOM) 2008:4 2009:2 {%i}_G.DRAW(SHADE, BOTTOM) 2015:1 2015:2 {%i}_G.ADDTEXT(0.5,0.3) Millions de $2007, (1981:1-2015:3) {%i}_G.ADDTEXT(-0.06,1.1) Recession {%i}_G.ADDTEXT(1.2,2.2) Recession {%i}_G.ADDTEXT(3.8,2) Recession {%i}_G.ADDTEXT(4.6,1.8) Recession {%i}_G.LEGEND(3.0,1.1,S) DELETE LEVEL TREND NEXT CHK_G.ADDTEXT(0.44,0.1) Household spending: Total CHDUK_G.ADDTEXT(0.23,0.1) Household spending: Durable goods CHNDK_G.ADDTEXT(0.10,0.1) Household spending: Non-Durable goods CHSDK_G.ADDTEXT(0.10,0.1) Household spending: Semi-Durable goods CHSEK_G.ADDTEXT(0.34,0.1) Household spending: Services GRAPH GOODS.MERGE CHFBEK CHABTK CHMFLK CHELEK CHONDK CHCFOK CHHSDK CHREPK CHVEPK CHFHAK CHODUK GRAPH SERVICES.MERGE CHCRCK CHEHPK CHIFLK CHTRAK CHAFOK CHDWRK CHNEAK STOP
Section 5: EViews Databases and Frequency Conversion
In EViews, run the program IMPEXP.PRG.
With the mouse open up a new database FILE, NEW, DATABASE, use BROWSE to give it the path C:\COUREV\DATABASE\QUEBEC.
High frequency to low frequency:
c=an, c=na high to low frequency conversion by taking the average, propagating missing values.
c=sn, c=ns high to low frequency conversion by taking the sum, propagating missing values.
Create new monthly workfile.
Low frequency to high frequency:
c=r low to high frequency conversion by constant match average.
c=d low to high frequency conversion by constant match sum.
c=q low to high frequency conversion by quadratic match average.
c=t low to high frequency conversion by quadratic match sum.
c=i low to high frequency conversion by linear match last.
c=c low to high frequency conversion by cubic match last.
A description of these is:
Constant-match average: This simply repeats the low value for each of the high observations. i.e. each quarter in 2009 will have the same value as the annual value for 2009.
Constant-match sum: This simply repeats the low value divided by the number of observations in the high page. i.e. each quarter in 2009 will have the annual value for 2009 divided by 4 (since there are 4 quarters in a year).
Quadratic-match average: This performs a proprietary local quadratic interpolation of the low frequency data to fill in the high observations.
Quadratic-match sum: This performs the same proprietary local quadratic interpolation, but this time the low frequency data is divided by the number of observations first.
Linear-match last: This inserts the low observation value into the last period of the high frequency data, then performs linear interpolation on the missing values. i.e. 2009Q4 will be given the annual 2009 value, 2010Q4 will be given the annual 2010 value, then linear interpolation will fill in 2010Q1, 2010Q2, 2010Q3.
Cubic-match last: This is the same as linear-match last, but rather than linear interpolation, a cubic spline is used for the interpolation.
All of this can be done with a program. The importance here is that we specify all of the options on the FETCH command to be sure of the conversion method.
' ========================================================================= ' C:\COUREV\PROGRAM\FETCH.PRG ' ' Created: 03/2001. ' Last change: 02/2016. ' Author of last change: CBoC ' ' Source file: C:\COURSEEV\DATABASE\FIN154.EDB ' ' Result file: C:\COURSEEV\WORKFILE\TEST5A.WF1 ' C:\COURSEEV\WORKFILE\TEST5M.WF1 ' ' DESCRIPTION: ' ' This program converts quarterly data into annual and monthly data. ' ========================================================================= ' **************************************** ' ****** New annual workfile****** ' **************************************** CLOSE TEST5A WORKFILE C:\COURSEEV\WORKFILE\TEST5A A 1980 2014 ' ***** Conversion of quarterly data into annual data***** ' ***** Average of quarters ***** FETCH(D=C:\COURSEEV\DATABASE\FIN154B.EDB,C=AN,C=NA) YGDPK 'high to low frequency conversion by taking the average, propagating missing values. RENAME YGDPK YGDPK_M ' ***** Sum of quarters ***** FETCH(D=C:\COURSEEV\DATABASE\FIN154B.EDB,C=SN,C=NS) YGDPK 'high to low frequency conversion by taking the sum, propagating missing values. RENAME YGDPK YGDPK_S ' ***** Maximum values of quarters ***** FETCH(D=C:\COURSEEV\DATABASE\FIN154B.EDB,C=XN,C=NX) YGDPK RENAME YGDPK YGDPK_X ' **************************************** ' ***** New monthly workfile ***** ' **************************************** CLOSE TEST5M WORKFILE C:\COUREV\WORKFILE\TEST5M M 1980:01 2015:3 ' ***** Conversion of quarterly data ***** ' ***** constant – average equals to quarter *****
FETCH(D=C:\COURSEEV\DATABASE\FIN154B.EDB,C=R) YGDPK 'low to high frequency conversion by constant match average. RENAME YGDPK YGDPK_K ' ***** quadratic – average equals to quarter ***** FETCH(D=C:\COURSEEV\DATABASE\FIN154B.EDB,C=Q) YGDPK RENAME YGDPK YGDPK_Q ' ***** cubic – the last value equals to quarter ***** FETCH(D=C:\COURSEEV\DATABASE\FIN154B.EDB,C=C) YGDPK RENAME YGDPK YGDPK_C SMPL 1999:01 2014:12 STOP
http://www.parisschoolofeconomics.eu/docs/yin-remi/coefficient-interpretation.pdf
http://www.eviews.com/StructModel/structmodel.pdf
Section 6: Filters, Estimations and Forecasts
Go over following program. Insert bugs at specific points to get participants familiar with programming and options.
' ========================================================================= ' C:\COURSEEV\PROGRAM\PREVISION.PRG ' ' Create: 03/2001. ' Last change: 02/2016. ' Author of last change: CBoC ' ' Source file: C:\COURSEEV\EXCEL\DBRUT.XLS ' ' Result file: C:\COURSEEV\WORKFILE\TEST6M.WF1 ' C:\COURSEEV\WORKFILE\TEST6Q.WF1 ' ' DESCRIPTION: ' ' This program seasonally adjust time series, applies description (label) and forecast using different approaches. ' ========================================================================= ' ****Year and month, end of historical data**** %FHIST = "2015:12" ' ****Year and month, end of forecast period**** %FFOR = "2016:12" ' ------------------------------------------------------------------------------------------------- ' ----------- Read raw data and seasonal adjustment ---------------- ' ------------------------------------------------------------------------------------------------- ' ***** New workfile ***** CLOSE TEST6M
WORKFILE C:\COURSEEV\WORKFILE\TEST6M M 1976:01 %FFOR ' ***** Read raw data in an Excel spreadsheet ***** SMPL 1976:01 %FFOR READ(S=EMPL_RAW, B2, T=XLS, T) C:\COURSEEV\EXCEL\EMPL_RAW.XLS ECRO EOPR EUTI ECON EMAN EWRT ETSC EIFI EPRO EADW EEDU EHEA ECUR EACC EOSE EPAD RENAME ECRO ECRO_NA'****Agriculture RENAME EOPR EOPR_NA'****Natural resources RENAME EUTI EUTI_NA'****Utilities RENAME ECON ECON_NA'****Construction RENAME EMAN EMAN_NA'****Manufacturing RENAME EWRT EWRT_NA'****Wholesale and retail trade RENAME ETSC ETSC_NA'****Transportation and warehousing RENAME EIFI EIFI_NA'****Insurance, Finance and real estate services RENAME EPRO EPRO_NA'****Professional, scientific and technical services RENAME EADW EADW_NA'****Business, building and other support services RENAME EEDU EEDU_NA'****Educational services RENAME EHEA EHEA_NA'****Health care and social Assistance RENAME ECUR ECUR_NA'****Information, recreation and culture RENAME EACC EACC_NA'****Accommodation and food services RENAME EOSE EOSE_NA'****Other services RENAME EPAD EPAD_NA'****Public administration SERIES E_NA=ECRO_NA+EOPR_NA+EUTI_NA+ECON_NA+EMAN_NA+EWRT_NA+ETSC_NA+EIFI_NA+EPRO_NA+EADW_NA+EEDU_NA+EHEA_NA+ECUR_NA+EACC_NA+EOSE_NA+EPAD_NA ESER_NA= EWRT_NA+ETSC_NA+EIFI_NA+EPRO_NA+EADW_NA+EEDU_NA+EHEA_NA+ECUR_NA+EACC_NA+EOSE_NA+EPAD_NA ' ***** Seasonal adjustment ***** FOR %i E ECRO EOPR EUTI ECON EMAN EWRT ETSC EIFI EPRO EADW EEDU EHEA ECUR EACC EOSE EPAD {%i}_NA.SEAS(M) {%i} {%i}_FAC NEXT SERIES E = ECRO+EOPR+EUTI+ECON+EMAN+EWRT+ETSC+EIFI+EPRO+EADW+EEDU+EHEA+ECUR+EACC+EOSE+EPAD SERIES ESER = EWRT+ETSC+EIFI+EPRO+EADW+EEDU+EHEA+ECUR+EACC+EOSE+EPAD ' ***** Creating a Group MM, Dummy variables with monthly effects and trend ***** GROUP MM FOR %i 2 3 4 5 6 7 8 9 10 11 12
SMPL 1987:1 %FFOR SERIES D{%i} = 0 SMPL 1987:{%i} 1987:{%i} SERIES D{%i} = 1 SMPL 1988:1 %FFOR SERIES D{%i} = D{%i}(-12) MM.APPEND D{%i} NEXT SMPL 1987:01 {%FFOR} SERIES TREND = @TREND(1987:01) ' ------------------------------------------------------------------------------------------------- ' ---------------------------- Labelling series ---------------------------------- ' ------------------------------------------------------------------------------------------------- E_NA.DISPLAYNAME Total Employment, na ECRO_NA.DISPLAYNAME Employment, Agriculture, na EOPR_NA.DISPLAYNAME Employment, Natural resources, na EUTI_NA.DISPLAYNAME Employment, Utilities, na ECON_NA.DISPLAYNAME Employment, Construction, na EMAN_NA.DISPLAYNAME Employment, Manufacturing, na EWRT_NA.DISPLAYNAME Employment, Wholesale and retail trade, na ETSC_NA.DISPLAYNAME Employment, Transportation and warehousing, na EIFI_NA.DISPLAYNAME Employment, Insurance, Finance and real estate services, na EPRO_NA.DISPLAYNAME Employment, Professional, scientific and technical services, na EADW_NA.DISPLAYNAME Employment, Business, building and other support services, na EEDU_NA.DISPLAYNAME Employment, Educational services, na EHEA_NA.DISPLAYNAME Employment, Health care and social Assistance, na ECUR_NA.DISPLAYNAME Employment, Information, recreation and culture, na EACC_NA.DISPLAYNAME Employment, Accommodation and food services, na EOSE_NA.DISPLAYNAME Employment, Other services, na EPAD_NA.DISPLAYNAME Employment, Public administration, na FOR %i E ECRO EOPR EUTI ECON EMAN EWRT ETSC EIFI EPRO EADW EEDU EHEA ECUR EACC EOSE EPAD {%i}_NA.LABEL(S) Statistics Canada {%i}_NA.LABEL(U) Thousands, unajusted CLOSE {%i}_NA NEXT E.DISPLAYNAME Total Employment ECRO.DISPLAYNAME Employment, Agriculture EOPR.DISPLAYNAME Employment, Natural resources EUTI.DISPLAYNAME Employment, Utilities ECON.DISPLAYNAME Employment, Construction EMAN.DISPLAYNAME Employment, Manufacturing EWRT.DISPLAYNAME Employment, Wholesale and retail trade ETSC.DISPLAYNAME Employment, Transportation and warehousing EIFI.DISPLAYNAME Employment, Insurance, Finance and real estate services EPRO.DISPLAYNAME Employment, Professional, scientific and technical services
EADW.DISPLAYNAME Employment, Business, building and other support services EEDU.DISPLAYNAME Employment, Educational services EHEA.DISPLAYNAME Employment, Health care and social Assistance ECUR.DISPLAYNAME Employment, Information, recreation and culture EACC.DISPLAYNAME Employment, Accommodation and food services EOSE_NA.DISPLAYNAME Employment, Other services EPAD_NA.DISPLAYNAME Employment, Public administration FOR %i E ECRO EOPR EUTI ECON EMAN EWRT ETSC EIFI EPRO EADW EEDU EHEA ECUR EACC EOSE EPAD {%i}.LABEL(S) Statistics Canada {%i}.LABEL(U) Thousands, seasonally adjusted CLOSE {%i} NEXT ' ------------------------------------------------------------------------------------------------- ' ---------- Forecasting Methods 1 et 2 :Trend of log and dlog -------------- ' ------------------------------------------------------------------------------------------------- ' ***** With seasonality **** FOR %i ECRO_NA EUTI_NA EOPR_NA EPAD_NA ECON_NA EMAN_NA ESER_NA SMPL 1976:01 {%FHIST} EQUATION {%i}_EQ1.LS LOG({%i}) C TREND MM EQUATION {%i}_EQ2.LS DLOG({%i}) C MM SMPL {%FHIST}+1 {%FFOR} {%i}_EQ1.FORECAST {%i}_F1 {%i}_EQ2.FORECAST {%i}_F2 NEXT ' *****Seasonally adjusted**** FOR %i ECRO EUTI EOPR EPAD ECON EMAN ESER SMPL 1976:01 {%FHIST} EQUATION {%i}_EQ1.LS LOG({%i}) C TREND MM EQUATION {%i}_EQ2.LS DLOG({%i}) C MM SMPL {%FHIST}+1 {%FFOR} {%i}_EQ1.FORECAST {%i}_F1 {%i}_EQ2.FORECAST {%i}_F2 NEXT ' ------------------------------------------------------------------------------------------------- ' --------------------------- Forecasting method 3: VAR --------------------------------- ' ------------------------------------------------------------------------------------------------- ' ***** With seasonality **** SMPL 1976:01 {%FHIST}
VAR LS3_NA.LS 1 4 ECRO_NA EUTI_NA EOPR_NA EPAD_NA ECON_NA EMAN_NA ESER_NA @TREND MM LS3_NA.MAKEMODEL(LS3M_NA) @ALL _F3 SMPL {%FHIST}+1 {%FFOR} SOLVE(C=0.000000001) LS3M_NA ' ***** Seasonally adjusted **** SMPL 1987:01 {%FHIST} VAR LS3.LS 1 4 ECRO EUTI EOPR EPAD ECON EMAN ESER @TREND LS3.MAKEMODEL(LS3M) @ALL _F3 SMPL {%FHIST}+1 {%FFOR} SOLVE(C=0.000000001) LS3M ' ***** Charts comparing forecasting approaches ***** SMPL 1993:01 {%FFOR} FOR %i ECRO EUTI EOPR EPAD ECON EMAN ESER GRAPH A_{%i}.LINE {%i} {%i}_F1 {%i}_F2 {%i}_F3 NEXT SMPL 1993:01 {%FFOR} FOR %i ECRO_NA EUTI_NA EOPR_NA EPAD_NA ECON_NA EMAN_NA ESER_NA GRAPH A_{%i}.LINE {%i} {%i}_F1 {%i}_F2 {%i}_F3 NEXT ' ------------------------------------------------------------------------------------------------- ' ------ Forecast total employment and convert to quarterly data -------- ' ------------------------------------------------------------------------------------------------- SMPL 1976:01 {%FFOR} FOR %i _F1 _F2 _F3 SERIES E{%i} = ECRO{%i} + EUTI{%i} + EOPR{%i} + EPAD{%i} + ECON{%i} + EMAN{%i} + ESER{%i} SERIES E_NA{%i} = ECRO_NA{%i}+ EUTI_NA{%i} + EOPR_NA{%i} + EPAD_NA{%i} + ECON_NA{%i} + EMAN_NA{%i} + ESER_NA{%i} NEXT SMPL 1993:01 {%FFOR} GRAPH A_E.LINE E E_F1 E_F2 E_F3 GRAPH A_E_NA.LINE E_NA E_NA_F1 E_NA_F2 E_NA_F3 GRAPH AVNAF1.LINE E_F1 E_NA_F1/E_FAC GRAPH AVNAF2.LINE E_F2 E_NA_F2/E_FAC GRAPH AVNAF3.LINE E_F3 E_NA_F3/E_FAC GRAPH AVNA.MERGE A_E AVNAF1 AVNAF2 AVNAF3 ' **** We store results in a database for conversion *****
GROUP GGG E E_F1 E_F2 E_F3 DBDELETE C:\COURSEEV\DATABASE\EMPLOYMENT.EDB DBCREATE C:\COURSEEV\DATABASE\EMPLOYMENT.EDB STORE(D= C:\COURSEEV\DATABASE\EMPLOYMENT.EDB, O, G=S) GGG E_NA 'STORE(DB=C:\COURSEEV\DATABASE\EMPLOYMENT.EDB,O,G=S) GGG eq_na ' ***** Save monthly file ***** SAVE C:\COURSEEV\WORKFILE\TEST6M.WF1 ' ***** New annual workfile ***** CLOSE TEST6A WORKFILE C:\COURSEEV\WORKFILE\TEST6A A 1987 2014 FETCH(DB=C:\COURSEEV\DATABASE\EMPLOYMENT.EDB,G=B,C=AN,C=NA) GGG E_NA FETCH(DB=C:\COURSEEV\DATABASE\FIN154B.EDB,G=B,C=AN,C=NA) E SMPL 1990 2014 GRAPH A_E.BAR @PCH(E)*100 @PCH(E_F1)*100 @PCH(E_F2)*100 @PCH(E_F3)*100 STOP
'basic for loop for %1 ygdp cons ck series {%1}=0 next 'basic for loop with multiple variables for %1 %2 ygdp ygdp_tar cons cons_tar ck ck_tar series {%1}={%2} next 'for loop on step for !j=5 to 1 step -1 series x = !j next for !j=0 to 10 series x = !j next 'basic for loop on program group For !i=1 to gov.@count %name=gov.@seriesname(!i) SERIES R_{%name}=({%name})
next 'stacking for loops with control variables !X=4 !Y=27 !Z=50 FOR %1 01 02 03 04 05 06 07 08 09 10 11 12 13 14 FOR %2 %3 B E!X M E!Y F E!Z READ({%3},S=POPHIS,T=XLS) "c:\POPHIS.XLS" popl{%1}S{%2}TO NEXT !X=!X+69 !Y=!Y+69 !Z=!Z+69 NEXT 'basic while loop !Y=1 WHILE !Y<4 READ(G!X,S=SURVEYRES,T=XLS) "c:\RES.XLS" PCTCIRS!Y wend 'basic if statement IF 1=2THEN endif 'if with else statement IF 1=2THEN else endif
Reference Sheet of Mnemonics
Regressions
Example: USD/CAD Exchange rate equation
USD_CAD : USD/CAD exchange rate (number of Canadian dollars needed to buy one U.S. dollar)
CPI_CA: Consumer price Index Canada
CPI_US: Consumer price index U.S.
MOILK: Canadian imports of oil, real terms
POILUS: Price of crude oil
STRATE_US: Short-term interest rate, U.S.
STRATE_CA, Short-term interest rate, Canada
Exercise: USD/IDR rate equation
IDN_RXD: U.S./Indonesia exchange rate
IDN_GDP: Indonesia GDP, real terms
CPI_IN: Consumer price index Indonesia
STRATE_IN: Short-term interest rate, Indonesia
CPI_US: Consumer price index U.S.
Exercise: CAD/IDR Exchange rate equation
CAD_IDR: CAD/IDR exchange rate, represents the number of rupiahs needed to buy one Canadian dollar.
What data do we need?
Models
Example: Canadian Exports of machinery and equipment and USD/CAD exchange rate
XINDK : exports of machinery and equipment (endogenous)
USD_CAD : USD/CAD exchange rate (endogenous)
PXIND: Deflator of Export Industrial machinery, equipment (exogenous)
USPPME : U.S. Imports Equipment (exogenous)
ASNGDP: Asia GDP/Asia demand (exogenous)
USIMEK: U.S. investment in equipment (exogenous)
Exercise: Indonesian Exports and USD/Rupiah exchange rate
EXPORTS_IN: Indonesian Exports, goods & services, real, LCU (Rupiah, Billions, 2000) (endogenous)
IDN_RXD: U.S./Indonesia exchange rate (endogenous)
USGDPK: U.S GDP in real terms (exogenous, CBoC forecast)
CHN_GDP: China GDP in real terms (exogenous, Oxford forecast)
JPN_GDP: Japanese GDP in real terms (exogenous, Oxford forecast)
VAR Analysis
STRATE_US: Short-term interest rate, U.S.
STRATE_CA, Short-term interest rate, Canada
STRATE_FR , Short-term interest rate, France
STRATE_GE, Short-term interest rate, Germany
STRATE_KO: Short-term interest rate, Korea
STRATE_IN: Short-term interest rate, Indonesia
Other:
USPGDP: US GDP deflator
CPI_CH: Consumer price index China
CPI_JA: Consumer price index Japan
JPN_PGDP: Japanese price deflator
JPN_RXD: US/JPN exchange rate
CHN_PGDP: China GDP deflator
CHN_RXD: China/U.S. exchange rate