Page 1 of 1

Estimating STVAR model

Posted: Wed Oct 16, 2024 4:39 am
by ndzama
Hi Eviews Experts,

I have tried to estimate the STVAR, using both the Maximum Likelihood Estimation and the NonLinear Least Squares (nls). I get an error message. Please see attached file.

Below is the system of equations that I have tried to estimate:

'================CREATING A SYSTEM OF EQUATIONS FOR A 2-variable STVAR(1)===========================================
system STVAR_{%c} 'The first line declares a system.

!c_start = 255 ' depends on what data you use.
!gamma_start = 1
param c(1) 0 c(2) 0.7 c(3) 0.1 c(4) !gamma_start c(5) !c_start c(6) 0 c(7) -0.3 c(8) -0.1 c(9) 0 c(10) 0.8 c(11) 0.2 c(12) -0.4 c(13) -0.2 c(14) -0.5

STVAR_{%c}.append CA_{%c} = c(1)+c(2)*CA_{%c}(-1)+c(3)*GDP_GROWTH_{%c}(-1)+(1-EXP( -c(4)*(CA_{%c}(-1)-c(5))^2))*(c(6)+c(7)*CA_{%c}(-1)+c(8)*GDP_GROWTH_{%c}(-1)) 'c(4) and c(5) are TRANSITION PARAMETERS
STVAR_{%c}.append GDP_GROWTH_{%c} = c(9)+c(10)*GDP_GROWTH_{%c}(-1)+c(11)*CA_{%c}(-1)+(1-EXP( -c(4)*(GDP_GROWTH_{%c}(-1)-c(5))^2))*(c(12)+c(13)*GDP_GROWTH_{%c}(-1)+c(14)*CA_{%c}(-1))
STVAR_{%c}.append CA_{%c}(-1) GDP_GROWTH_{%c}(-1) 'line appends the list of instruments to be used in estimation.
'STVAR.nls ' estimate the parameters of a model using nonlinear least squares.
STVAR_{%c}.ml(optmethod=Newton) ' estimate the parameters of a model using maximum likelihood estimation
'STVAR.estimate(method=nls)
show STVAR_{%c}.results 'display the estimation results.

Kindly assist,
Nwabisa Ndzama

Re: Estimating STVAR model

Posted: Wed Oct 16, 2024 8:41 am
by EViews Gareth
Systems (or any other estimation method in EViews) don't have an "NLS" method. Just use "LS" instead.

Re: Estimating STVAR model

Posted: Sat Oct 19, 2024 3:17 am
by ndzama
Systems (or any other estimation method in EViews) don't have an "NLS" method. Just use "LS" instead.

Dear Gareth,
Thank you for your timeous response. Much appreciated.
Please note that I was getting exactly the same error even if I use .ml (for maximum likelihood estimation).


I have since revised the code and estimated with .LS . But I Keep getting a syntax error. See attachment.

'======CREATING A SYSTEM OF EQUATIONS FOR A 2-variable STVAR(1): APPLYING LOGISTIC TRANSITION FUNCTION===========================================
system STVAR_{%c}

!c_start = 255
!gamma_start = 1
param c(1) 0 c(2) 0.7 c(3) 0.1 c(4) !gamma_start c(5) !c_start c(6) 0 c(7) -0.3 c(8) -0.1 c(9) 0 c(10) 0.8 c(11) 0.2 c(12) -0.4 c(13) -0.2 c(14) -0.5

' Equation for CA_{%c}
STVAR_{%c}.append CA_{%c} = c(1) + c(2)*CA_{%c}(-1) + c(3)*GDP_GROWTH_{%c}(-1) + (1 / (1 + EXP(-c(4)*(CA_{%c}(-1)-c(5))))) * (c(6) + c(7)*CA_{%c}(-1) + c(8)*GDP_GROWTH_{%c}(-1))

' Equation for GDP_GROWTH_{%c}
STVAR_{%c}.append GDP_GROWTH_{%c} = c(9) + c(10)*GDP_GROWTH_{%c}(-1) + c(11)*CA_{%c}(-1) + (1 / (1 + EXP(-c(4)*(GDP_GROWTH_{%c}(-1)-c(5))))) * (c(12) + c(13)*GDP_GROWTH_{%c}(-1) + c(14)*CA_{%c}(-1))

' Add instruments to be used in the estimation
STVAR_{%c}.append CA_{%c}(-1) GDP_GROWTH_{%c}(-1)

' Estimate using least squares (LS)
STVAR_{%c}.ls
show STVAR_{%c}


I can privately message you the data and full code.