Announcement

Collapse
No announcement yet.
X
  • Filter
  • Time
  • Show
Clear All
new posts

  • Estimation of Markov Switching models

    Hi,
    I am estimating a Markov Switching models using the mswitch command.
    This code runs for country 1 but not for country 2. It shows "initial values not feasible". Not able to figure out.
    Any help will be greatly appreciated.

    The code and data are given below.

    Code:
    keep if id==2
    tsset year, yearly
    mswitch dr x, switch(y) states(2) varswitch

    Code:
    * Example generated by -dataex-. To install: ssc install dataex
    clear
    input str52 country int year float(x y id)
    "Argentina" 1990 10.359536 4.6313224 1
    "Argentina" 1991  7.675044  6.078011 1
    "Argentina" 1992  6.598187  8.132793 1
    "Argentina" 1993  6.909351    9.3138 1
    "Argentina" 1994  7.529949 10.604397 1
    "Argentina" 1995   9.68041 10.091013 1
    "Argentina" 1996 10.428596  11.07787 1
    "Argentina" 1997  10.56085  12.77533 1
    "Argentina" 1998 10.415582 12.934446 1
    "Argentina" 1999  9.827174  11.55557 1
    "Argentina" 2000 10.986375  11.63607 1
    "Argentina" 2001 11.579008 10.273248 1
    "Argentina" 2002 28.382597 13.370128 1
    "Argentina" 2003  25.93094 14.713805 1
    "Argentina" 2004  23.84762 16.845026 1
    "Argentina" 2005 23.245876 17.305395 1
    "Argentina" 2006 23.026695 17.406786 1
    "Argentina" 2007  22.66275 18.282421 1
    "Argentina" 2008   22.0609 18.341772 1
    "Argentina" 2009 19.560986 14.496141 1
    "Argentina" 2010 18.933823  16.03719 1
    "Argentina" 2011  18.44921 16.756947 1
    "Argentina" 2012  16.23786 14.288683 1
    "Argentina" 2013 14.617173 14.716756 1
    "Argentina" 2014 14.405478 14.001315 1
    "Argentina" 2015 10.705652 11.780574 1
    "Argentina" 2016 12.527095 13.566792 1
    "Argentina" 2017 11.242722  13.98061 1
    "Argentina" 2018 14.280518 16.419928 1
    "Australia" 1990 15.146525 17.073702 2
    "Australia" 1991 16.061407 16.194105 2
    "Australia" 1992 16.691364   16.4189 2
    "Australia" 1993 17.572792 17.893728 2
    "Australia" 1994 18.005312 18.520817 2
    "Australia" 1995 17.916885 19.884666 2
    "Australia" 1996 18.939194 19.393137 2
    "Australia" 1997  19.17481      18.9 2
    "Australia" 1998  19.59558 20.474854 2
    "Australia" 1999 18.343893 20.790756 2
    "Australia" 2000  19.43466  21.59435 2
    "Australia" 2001  22.22572  22.13949 2
    "Australia" 2002 20.774593  20.78268 2
    "Australia" 2003 19.095085  21.20106 2
    "Australia" 2004 17.203285  19.91745 2
    "Australia" 2005 18.265102  21.00608 2
    "Australia" 2006  19.89392 21.710306 2
    "Australia" 2007  20.20361  21.84783 2
    "Australia" 2008  20.16167  22.70866 2
    "Australia" 2009  23.00481  22.79309 2
    "Australia" 2010 19.810007 20.839664 2
    "Australia" 2011 21.436417 20.470316 2
    "Australia" 2012  21.48083  21.72952 2
    "Australia" 2013  19.95617  21.25226 2
    "Australia" 2014 21.039455 21.467035 2
    "Australia" 2015 19.984846  21.50953 2
    "Australia" 2016 19.251057 21.526585 2
    "Australia" 2017   21.1932   20.5768 2
    "Australia" 2018 21.804657 21.387604 2
    end
    Thank you.

  • #2
    Use the values of -mswitch- with constant variance as initial values in model with varswitch. Note, need to repeat the estimated sigma value since number of values in the row vector has to be equal to the number of coefficient.

    Code:
    . qui mswitch dr x, switch(y) states(2) 
    
    . mat a = e(b)
    
    . mat b = a[1,1..5], a[1,5], a[1,6..7]
    
    . mswitch dr x, switch(y) states(2) varswitch from(b)
    
    Performing EM optimization:
    
    Performing gradient-based optimization:
    
    Iteration 0:   log likelihood = -38.034123  
    Iteration 1:   log likelihood = -37.953811  
    Iteration 2:   log likelihood = -37.953524  
    Iteration 3:   log likelihood = -37.953524  
    
    Markov-switching dynamic regression
    
    Sample: 1990 - 2018                             Number of obs     =         29
    Number of states =    2                         AIC               =     3.1692
    Unconditional probabilities: transition         HQIC              =     3.2873
                                                    SBIC              =     3.5464
    Log likelihood = -37.953524
    
    ------------------------------------------------------------------------------
               x |      Coef.   Std. Err.      z    P>|z|     [95% Conf. Interval]
    -------------+----------------------------------------------------------------
    State1       |
               y |   .9910902   .0841593    11.78   0.000      .826141    1.156039
           _cons |  -1.967371   1.756962    -1.12   0.263    -5.410953    1.476212
    -------------+----------------------------------------------------------------
    State2       |
               y |   .9857649   .0824833    11.95   0.000     .8241006    1.147429
           _cons |   .1279167   1.645175     0.08   0.938    -3.096567    3.352401
    -------------+----------------------------------------------------------------
          sigma1 |   .3936652   .0944904                      .2459322    .6301424
    -------------+----------------------------------------------------------------
          sigma2 |   .5965819   .1280166                      .3917566    .9084976
    -------------+----------------------------------------------------------------
             p11 |   .5956878   .1482876                      .3059291    .8312174
    -------------+----------------------------------------------------------------
             p21 |   .2844205    .118963                      .1122202     .555516
    ------------------------------------------------------------------------------

    Comment


    • #3

      Scott Merryman Thank you a lot. For country Argentina (id=1), I could run the mswitch package allowing for varswitch without any problem. Then I ran your code to see if the coefficients and sigmas in two regimes are the same for country Argentina (id=1). I noticed that they are different. So, while using initial values for the maximization process solves the problem of estimation, it alters the coefficient estimates.
      Last edited by Santosh Dash; 20 May 2020, 22:27.

      Comment


      • #4
        If different starting values result in different estimated coefficients you may not be at a global optima.

        Comment

        Working...
        X