Statalist The Stata Listserver


[Date Prev][Date Next][Thread Prev][Thread Next][Date index][Thread index]

st: SETAR program


From   Dirk Nachbar <[email protected]>
To   statalist <[email protected]>
Subject   st: SETAR program
Date   02 Jun 2006 14:05:08 +0100

All

I am working on an estimation program for SETAR models. The DGP is shown and should be picked up by the program. I want to sort all models by ascending variance and then choose the one with the minimum. Maybe someone can show how that can be done with the matrix `var'.

Thanks a lot

/*

Program for Self-Exciting Threshold AutoRegressive model

*/

clear

set obs 100

gen time=_n

tsset time

gen y=0

replace y=(1+0.3*l.y)*(y>0)+(0+0.5*l.y)*(y<=0)+0.5*invnorm(uniform()) if time>1

line y time

capture program drop setar

program define setar

    version 8.2

    syntax varlist [if] [in], ar(int 1) steps(int 10)

    marksample touse

    qui count if `touse'

    if r(N) ==0 {

            error 2000

            }

    if `ar'<1     {

            di as error "the AR component must be bigger than 1"

            exit 198

            }

   

    if `steps'<5 {

            di as error "you should have at least 5 steps"

            exit 198

            }

    qui sum `1'

    local min r(min)

    local max r(max)

    local y `1'

    forval i=1/`steps' {

                    tempvar y`i' y`i'inv

                    gen y`i'=l.(y>`min'+`i'*(`max'-`min')/`steps')

                    gen y`i'inv=1-y`i'

                    forval j=1/`ar' {

                                    tempvar y`i'`j' y`i'inv`j'

                                    gen y`i'`j'=l`j'.y*y`i'

                                    gen y`i'inv`j'=l`j'.y*y`i'inv

                                    }

                    qui reg y y`i' y`i'1-y`i'`ar' y`i'inv y`i'inv1-y`i'inv`ar'

                    *store the variance and threshold

                    mat var[`i',1]=(e(rmse)*e(rmse)*e(df_r)/e(N))

                    mat var[`i',2]=`min'+`i'*(`max'-`min')/`steps'

                    }

end

Dirk Nachbar

Assistant Economist

Pensim2

Department for Work and Pensions

Level 4, The Adelphi

1-11 John Adam St

WC2N 6HT London

020 796 28531 ********************************************************************** This document is strictly confidential and is intended only for use by the addressee. If you are not the intended recipient, any disclosure, copying, distribution or other action taken in reliance of the information contained in this e-mail is strictly prohibited. Any views expressed by the sender of this message are not necessarily those of the Department for Work and Pensions. If you have received this transmission in error, please use the reply function to tell us and then permanently delete what you have received. Please note: Incoming and outgoing e-mail messages are routinely monitored for compliance with our policy on the use of electronic communications. **********************************************************************
The original of this email was scanned for viruses by Government Secure Intranet (GSi) virus scanning service supplied exclusively by Cable & Wireless in partnership with MessageLabs.
On leaving the GSI this email was certified virus free.
The MessageLabs Anti Virus Service is the first managed service to achieve the CSIA Claims Tested Mark (CCTM Certificate Number 2006/04/0007), the UK Government quality mark initiative for information security products and services. For more information about this please visit www.cctmark.gov.uk




© Copyright 1996–2024 StataCorp LLC   |   Terms of use   |   Privacy   |   Contact us   |   What's new   |   Site index