How to program tsls in order to save the coefficients?

For questions regarding programming in the EViews programming language.

Moderators: EViews Gareth, EViews Moderator, EViews Jason, EViews Matt

vasilika
Posts: 12
Joined: Thu Aug 05, 2010 4:32 am

How to program tsls in order to save the coefficients?

Postby vasilika » Wed Aug 11, 2010 2:04 am

hello

I would like to use bootstrap in a tsls equation, therefore I will have to save the coefficients to use them for bootstraping.

If the equation was an OLS, I would write it as follows:

equation ols_reg.ls loan_boot = c(1)* (1/inf_boot-1/thold)+c(2)*do+c(3)*fs

how do I add the instrumental variables in this case and estimate a TSLS ?

thank you for your time.

trubador
Did you use forum search?
Posts: 1520
Joined: Thu Nov 20, 2008 12:04 pm

Re: How to program tsls in order to save the coefficients?

Postby trubador » Wed Aug 11, 2010 4:32 am

Suppose that you have two instrumental variables called inst1 and inst2. Then you can estimate a tsls as follows:

equation ols_reg.tsls loan_boot = c(1)* (1/inf_boot-1/thold)+c(2)*do+c(3)*fs @ inst1 inst2

Please see the users guide for more details...

vasilika
Posts: 12
Joined: Thu Aug 05, 2010 4:32 am

Re: How to program tsls in order to save the coefficients?

Postby vasilika » Wed Aug 11, 2010 4:43 am

This works

thank you for your reply

vasilika
Posts: 12
Joined: Thu Aug 05, 2010 4:32 am

Re: How to program tsls in order to save the coefficients?

Postby vasilika » Wed Aug 11, 2010 6:21 am

however now I have a new problem

this is part of the program for bootstraping

for i = 1 to numobs

inf_boot(i) = inf(infdraws(i))

loan_boot(i) = slope_c1*(1/inf_boot(i)-1/thold)+slope_c2*do(i)+slope_c3*fs(i) @ inf(-1) do(-1) fs(-1)

in Bold are the instruments,
but the program won't run due to syntax errors, i believe because of the instruments.
If I refer to the instruments as inf(i-1) it won't work either. or should I just refer to them as just inf(i) as they are bootstrap values?
do you have any idea?
thank you

trubador
Did you use forum search?
Posts: 1520
Joined: Thu Nov 20, 2008 12:04 pm

Re: How to program tsls in order to save the coefficients?

Postby trubador » Wed Aug 11, 2010 6:51 am

Programming errors arise from numerous reasons, and therefore it is very difficult to identify the problem just looking at a small portion of the code. For instance, control variables require an exclamation mark on the left:

Code: Select all

for !i = 1 to numobs ..... next

vasilika
Posts: 12
Joined: Thu Aug 05, 2010 4:32 am

Re: How to program tsls in order to save the coefficients?

Postby vasilika » Wed Aug 11, 2010 7:30 am

Actually the program runs, if I remove instruments and the equation is an OLS
the only problem is I want to add instruments,
i is defined as a scalar which takes the values I determine therefore it works.

EViews Gareth
Fe ddaethom, fe welon, fe amcangyfrifon
Posts: 13603
Joined: Tue Sep 16, 2008 5:38 pm

Re: How to program tsls in order to save the coefficients?

Postby EViews Gareth » Wed Aug 11, 2010 7:35 am

You appear to be missing a TSLS command.

vasilika
Posts: 12
Joined: Thu Aug 05, 2010 4:32 am

Re: How to program tsls in order to save the coefficients?

Postby vasilika » Thu Aug 12, 2010 12:23 am

Let me clarify this further

I estimate a TSLS equation
then I save the coefficients which I estimated in the first step
I use these coefficients to generate a bootstrap of the dependent variable
here is the program

equation ols_reg_orig.tsls loan = c(1)* (1/inf-1/thold)+c(2)*do +c(3)*fs @ inf(-1) do(-1) fs(-1)

slope_c1 = c(1)
slope_c2 = c(2)
slope_c3 = c(3)

for i = 1 to numobs

inf_boot(i) = inf(infdraws(i))

loan_boot(i) = slope_c1*(1/inf_boot(i)-1/thold)+slope_c2*do(i)+slope_c3*fs(i) @ inf(-1) do(-1) fs(-1)

next

My question is:
How to save the coefficients of the instruments so that I can use them in last step?
the last step (In bold) works if I remove the instruments.

Thank you for any suggestion.

trubador
Did you use forum search?
Posts: 1520
Joined: Thu Nov 20, 2008 12:04 pm

Re: How to program tsls in order to save the coefficients?

Postby trubador » Thu Aug 12, 2010 2:03 am

I think you do not need that information. EViews simultaneously estimates the two stages and the resulting coefficients will directly give you TSLS estimates. So, indeed you should remove the instruments...

vasilika
Posts: 12
Joined: Thu Aug 05, 2010 4:32 am

Re: How to program tsls in order to save the coefficients?

Postby vasilika » Thu Aug 12, 2010 2:12 am

so how do I get loan_boot(i) then?

trubador
Did you use forum search?
Posts: 1520
Joined: Thu Nov 20, 2008 12:04 pm

Re: How to program tsls in order to save the coefficients?

Postby trubador » Thu Aug 12, 2010 2:34 am

I am not sure if this is the correct way of bootstrapping. If you are interested, EViews has useful commands to ease the bootstrapping procedure. You can directly generate loan_boot series through the following equation:

Code: Select all

loan_boot = slope_c1*(1/inf_boot-1/thold)+slope_c2*do+slope_c3*fs
Of couse, you need to generate inf_boot series beforehand...

vasilika
Posts: 12
Joined: Thu Aug 05, 2010 4:32 am

Re: How to program tsls in order to save the coefficients?

Postby vasilika » Thu Aug 12, 2010 2:42 am

which I have already done.

So, you are saying that as long as I use bootstraped values of inf, than I don't need to use instruments in order to get the bootstraped values of loan_boot?


Return to “Programming”

Who is online

Users browsing this forum: No registered users and 1 guest