Hi all
I would like to perform the Prais-Winsten estimation manually, i.e. do the iterations myself. I tried all day but failed..
I think I follow exactly what Wooldridge (and other sources I found) are proposing. But it does not seem to work...
In particular, I would like to reproduce the example in the Wooldridge textbook on the static Phillips curve. So for the model: inflation_t = b0 + b1 unemployment_t + u_t.
The steps I take in the program (you can find the program and the workfile with the relevant data attached):
1] Estimate the model: inflation_t = b0 + b1 unemployment_t + u_t
2] Obtain the residuals and regress: uhat_t = rho*uhat_{t-1} + e_t
3] Calculate the quasi-differenced data using the estimated rho from 2]
4] Estimate the model in 1] but with the estimated model
5] Obtain the residuals from the model in 4] and obtain a new rho by estimating the residual at time t on a lag.
6] Using the estimated rho from 5] to calculate the quasi-differenced data.
7] Estimate the model in 1] with the quasi-differenced data from 6]
8] Keep going until convergence.
Doing this we should find an estimated rho of 0.781 and the coefficient on unemployment should be -0.716.
In the program attached I get a value of rho 0.338 (you can find this estimate in the equation object "rho_est100") and a coefficient on unemployment of 0.163 (you can find this estimate in the equation object "model100").
I really hope somebody out there could point me in the good direction.. All the help is much appreciated!!
Regards
Prais-Winsten manually
Moderators: EViews Gareth, EViews Moderator
Prais-Winsten manually
- Attachments
-
- prais winston manually.prg
- Program of manual Prais-Winsten
- (2.24 KiB) Downloaded 761 times
-
- inf_unem.wf1
- Workfile: data on inflation and unemployment
- (9.52 KiB) Downloaded 595 times
-
EViews Glenn
- EViews Developer
- Posts: 2682
- Joined: Wed Oct 15, 2008 9:17 am
Re: Prais-Winsten manually
There are a number of problems with your computations. Most notably:
1. On subsequent calculations of the residuals, you can't use the weighted test equation to generate the residuals. You have to use the coefficient estimates, and the original data to compute the resids.
2. You need to be careful about which sample is used to do estimation and which sample is used to do the computation of the weighted series.
I've taken the liberty of correcting these issues and cleaning up the code somewhat. You were doing a fair bit more of initialization and copying of series than needed, and the extra series were making it difficult for me to see what was going on.
1. On subsequent calculations of the residuals, you can't use the weighted test equation to generate the residuals. You have to use the coefficient estimates, and the original data to compute the resids.
2. You need to be careful about which sample is used to do estimation and which sample is used to do the computation of the weighted series.
I've taken the liberty of correcting these issues and cleaning up the code somewhat. You were doing a fair bit more of initialization and copying of series than needed, and the extra series were making it difficult for me to see what was going on.
Code: Select all
' Open the workfil -> make sure you workfile is in the same folder as where you saved this program
wfopen .\inf_unem.wf1
' Vector to store the estimated rho's, so 100 is the number of iterations
vector(100) rho
' STEP1: Estimate the model
smpl @all
equation model0.ls inf c unem
' STEP 2: Get the residuals
model0.makeresids uhat1
' Estimate rho
equation rho_est1.ls uhat1 uhat1(-1)
' Store the first estimated rho in the vector
rho(1) = rho_est1.@coefs(1)
' STEP3: Generate the quasi-difference data
genr const_adj = 1 - rho(1)
genr inf_adj = inf - rho(1)*inf(-1)
genr unem_adj = unem - rho(1)*unem(-1)
' Fix the first observation -> transform
' The transformation of the first observation
smpl 1948 1948
const_adj = (1-rho(1)^2)^(1/2)
inf_adj = (1-rho(1)^2)^(1/2)*inf
unem_adj = (1-rho(1)^2)^(1/2)*unem
' STEP 4: Estimate the model with the quasi-differenced data
smpl @all ' note that you have to reset the sample here
equation model1.ls inf_adj const_adj unem_adj
' STEP 5: Make new set of residuals
series uhat2 = inf - model1.c(1) - model1.c(2)*unem
' START ITERATION
for !n=2 to 100
' Estimate a new rho
equation rho_est{!n}.ls uhat{!n} uhat{!n}(-1)
'Store it in the vector
rho(!n) = rho_est{!n}.@coefs(1)
' Generate the quasi-differenced data using the just estimated rho
genr const_adj = 1 - rho(!n)
genr inf_adj = inf - rho(!n)*inf(-1)
genr unem_adj = unem - rho(!n)*unem(-1)
' The transformation of the first observation
smpl 1948 1948
const_adj = (1-rho(!n)^2)^(1/2)
inf_adj = (1-rho(!n)^2)^(1/2)*inf
unem_adj = (1-rho(!n)^2)^(1/2)*unem
' Estimate the model with the quasi differenced data
smpl @all
equation model{!n}.ls inf_adj const_adj unem_adj
!s = !n+1
' get new residuals
series uhat{!s} = inf - model{!n}.c(1) - model{!n}.c(2)*unem
' next iteration
next
Re: Prais-Winsten manually
Thanks you so much for your help! And thanks for improving on the program!!
Re: Prais-Winsten manually
Thanks for sharing the code to get Prais-Winsten estimates
I have encountered an issue with the execution of the portion of the code stating:
STEP2: rho(1) = rho_est1.@coefs(1)
On executing this, I am getting an error message. Could you please look into it and resolve. Thanks
Secondly, could you please guide a way in which the "for" loop in the code could get executed ?
Thirdly,I am trying to execute the code given by you on step by step basis. Could you please let me know the way in which the entire code could be executed in one go ?
I have encountered an issue with the execution of the portion of the code stating:
STEP2: rho(1) = rho_est1.@coefs(1)
On executing this, I am getting an error message. Could you please look into it and resolve. Thanks
Secondly, could you please guide a way in which the "for" loop in the code could get executed ?
Thirdly,I am trying to execute the code given by you on step by step basis. Could you please let me know the way in which the entire code could be executed in one go ?
-
EViews Glenn
- EViews Developer
- Posts: 2682
- Joined: Wed Oct 15, 2008 9:17 am
Re: Prais-Winsten manually
First off, I just want to make certain that you understand that you do not need to do Prais-Winsten manually, as EViews AR estimation does the iterations for you.
Second, you'll have to tell me what the error message is. By the way, what version of EViews are you using?
Third, I don't understand the latter requests.
Second, you'll have to tell me what the error message is. By the way, what version of EViews are you using?
Third, I don't understand the latter requests.
Re: Prais-Winsten manually
hello i have follow the step on the code and try to modify the code to my own model and own database for one iteration ar(1)how can i do this. and when the programm is done how can get the regression windows or i just tap on command zone (accordind to the example) : ls inf_adj const_adj unem_adj thnx for response ps: am very novice
Who is online
Users browsing this forum: No registered users and 1 guest
