Anda di halaman 1dari 5

Eviews

commands used diring the lectures and tutorials

1. to do an OLS :
a. ls (y value) c list regressors
i. e.g. ls wage y school exper male
b. open: object > New object > Equation > choose ordinary least square and enter
i. e.g. wage = c(1) + c(2)*school + c(3)*exper + c(4)*male
c. open: quick menu > estimate equation: then same as b.

2. to do a time series OLS


a. e.g. estimate the following regression : yt= β1+ β2yt-1+ β3yt-2+ εt
i. ls y c y(-1) y(-2) (it tests whether the previous two periods affect the current
period)

3. To save data from one variable to another


a. use genr command
i. e.g. save and store residuals in a variable called e: genr e = resid
ii. series e = resid (command)
iii. Open: quick menu >type „e = resid”
b. dated dummies
i. command: series jan= (@month=1)
ii. command: series year= (@year=xy)

4. To save fitted values


a. open: Forecast: name it and save

5. To narrow down sample (time series):


a. e.g. Open: Sample and change the numbers and run the regression again
b. type smpl 1935:1 2015:4 in the command window and run the regression again

6. To make a scattered plots and graphs


a. e.g. tutorial 38: Make a scatter plot of the residuals against exper.
i. command: scat exper e, by specifying exper e or e exper, we specify the x
and y axises on the graph
b. to make a histogram:
i. open: View > descriptive statistics and tests > Histogram and stats
ii. enter command: hist e (e.g. residuals)
c. test for normality:
i. Jacque-Berra test for normality ( H0 = there is normality)
1,400

Series: E
1,200
Sample 1 3294
Observations 3294
1,000

Mean 2.36e-16
800
Median -0.456719
Maximum 34.19367
600
Minimum -7.653676
Std. Dev. 3.044755
400
Skewness 2.088627
Kurtosis 15.05237
200

Jarque-Bera 22331.81
0
Probability 0.000000
-10 -5 0 5 10 15 20 25 30 35

7. To open variables as a group


a. mark e.g. industries and right click > Open > as a Group > Name it

8. Hypotheses testing:
a. Open: View > Coefficient diagnostics > Wald test
i. e.g. Ho: Beta1 = 1, then enter: C(2) = 1 (tut39 example )
(for any number of coefficients) follows either F or T dist

9. to measure elasticity:
a. use loglinear function for y and particualr xs, ls log(y) c log(x), remember that count
and dummy variables are not good for elasticity being measured
i. e.g. housing prices (lecture 3)to see how the lot size affects price, if lot
increases by 10 %, then house price increases by 4 %: ls log(price) c
log(lotsize)

10. to test for function misspecification:


a. Open: View > Stability diagnostics > Ramsey reset Test: enter number of fitted terms
(housing prices nr. = 2, alpha2=alpha3=0, two alphas=2), in the case of
autocorrelation it was 1, Ramse follows F dis., H0= no misspecification

11. to test for heteroskedasticity:


a. Breush Pagan test (example from lecture 6-7 labour)
i. run the regression: ls labor c wage output capital
Save the residuals: genr e = resid.
Run auxiliary regression: e^2 c wage output capital.
ii. run the regression ls labor c wage output capital
Open: View > Residual Diagnostics > Heteroskedasticity tests: Breush- Pagan
b. White test
i. Open: View > Residual Diagnostics > Heteroskedasticity tests: White

12. to solve heteroskedasticity


a. Apply white standard errors for OLS
i. Open: Estimate > Options > Choose Covariance methods > either White or
Newey West
b. transform model into GLS (F or EGLS)
i. e.g. labour capital example lecture 7:
1. part I: Auxiliary regression multiplicative heteroskedasticity:
ls log(labor) c log(wage) log(output) log(capital)
genr e = resid
genr loge2 = log(e*e)
ls loge2 c log(wage) log(output) log(capital) or ls loge2 c coas medi
(example from 4.1 airqiality exercise)

2. part II: estimate the model (for economic interpretation):
genr h2 = exp(c(2)*log(wage)+c(3)*log(output)+c(4)*log(capital))
genr h = @sqrt(h2)
ls log(labor)/h 1/h log(wage)/h log(output)/h log(capital)/h
ii. the air quality example from lecture 9_
1. part I: Auxiliary multiplicative heteroskedasticity
ls airq c vala rain coas dens medi
genr e = resid
genr loge2 = log(e*e)
ls loge2 c coas medi

2. part II: estimate the model
genr h2 = exp(c(2)*coas+c(3)*medi)
genr h = @sqrt(h2)
ls airq/h 1/h vala/h rain/h coas/h dens/h medi/h


13. to solve autocorrelation
a. Apply Newey West standard errors
i. Open: Estimate > Options > Choose Covariance methods > choose Newey
West (HAC standard error)
b. transform model into GLS (F or EGLS)
c. include lagged dependent variable e.g. ice cream cons(-1)

14. to test for autocorrelation


a. Asymptotic tests:
i. e.g. icecream data:
ls cons c price income temp
genr e = resid
ls e e(-1) (to find rho, formulas are on slides autocorrelation)
b. Breusch -Godfrey test:
i. Open: > View > Residual diagnostics > Serial correlation test > first order
autocorrelation = one lag to include, it follows a Chi^2 distribution
second order autocorrelation = two lags and so on

c. Durbin Watson
i. just run the regression and see the standard regression output (coefficients,
R squared etc.), it is not appropriate in the case of lagged dependent variable
or when there is no intercept (only for first order autocorrelation)

15. To see the fitted values and the observations:


a. Open: View > Actual, fitted, residual > Actual, fitted, residual graph

16. To include lagged variable>


a. e.g. lagged consumption (dependent variable) in ice cream: ls cons c temp price
income cons(-1)

17. to do IV estimation:
a. manual in Eviews:
i. mark the variables (e.g. police, crime, election) and right click, open them as
a group, then Open: View > Covariance analysis, choose covariance
then ßIV = cov {yi , zi }/{xi , zi }e.g. police, -0,172311/0,198737= - 0,867
b. Two-stage least squares (TSLS estimation) in Eviews:
i. first example from the lecture 11:
1. type the command: tsls crime c police @ c election
general form: tsls y c x @ z (instrument)
2. type command: ls police c election, (ls x c z)
save the fitted values: open: Forecast >save policef
then regress ls crime c policef (y c fitted)
ii. second example with wage, problem set 3:
we have three endogeneos variables: exp, exp^2 and edu
so we need 3 instruments (age, age,^2 and lives near college)
1. run regressions for the ENDOGENOUS variables on all the
EXOGENEOUS ones (icuding the INSTRUMENTS)

LS ED76 C AGE76 AGE76^2 BLACK SMSA76 SOUTH76 NEARC4


LS EXP76 C AGE76 AGE76^2 BLACK SMSA76 SOUTH76 NEARC4
LS EXP762 C AGE76 AGE76^2 BLACK SMSA76 SOUTH76 NEARC4

Save the fitted values
ED76F, EXP76F, and EXP762F

Then run this regression

LS LOG(WAGE76) C ED76F EXP76F EXP762F BLACK SMSA76
SOUTH76

2. type the command:


tsls log(wage76) c ed76 exp76 exp76*exp76 black smsa76 south76
@ nearc4 age76 age76^2 black smsa76 south76
exogeneous and endogenous

18. Panel data model estimation:


a. Fixed effects:
i. command: ls(cx=f) rx(1) c fs fs*rec
(cx=f) new part of the command (currency example), no space between ls and
(cx=f)
remember, when you estimate it take the dummies out of the regression
otherwise it wont work (near singular matrix)
b. Pooled OLS:
i. command: ls rx(1) c fs fs*rec
OLS as alway (currency example)
c. Rendom effects:
i. command: ls(cx=r) rx(1) c fs fs*rec
(cx=r) new part of the command (currency example) no space between ls and
(cx=r)

19. Panel data: choosing robustWhite standard errors, period, cross sectional, diagonal:
a. Open: Estimate > Panel options > Coef Covariance Method > White xy

20. R^2s for panel models:


a. Within estimator (FE) R^2: 1 – (sum squared resid(ssr) only fixed model)/(ssr for full
FE model with regressor)
only fixed model: LS(cx=f) WAGE C
full FE model: LS(cx=f) WAGE C EXPER EXPER^2 UNION MAR
b.
21. Hausman test:
a. Open: View > Fixed > Ransom effects testing > Correlated random effects testing
Hausman Test, Hausman follows Chi^2
H0: cov(alphai, x,)=0, then both RE and FE are consistent

Anda mungkin juga menyukai