  PURPOSE: Gonzalez, Terascirta and Van Dijk (2004), "Panel Smooth Transition Regression Model 
  and An Application to Investment Under Credit Constraint", Stockholm School of Economics
 
  -------------------------------------------------------
  Usage:   Estimate a Panel Smooth Threshold Panel
  
  -------------------------------------------------------
   Function : STAR_Panel(data,N,m,rmax,condini_user)
 
  Where: 
  data : is a matrix which contains the panel data (Yit Qit Xit) with
             Yit : the dependant variable,  size : vector (N*T,1)
             Qit : the transition variable, size : vector (N*T,1)
             Xit : the regressor,           size : matrix (N*T,K)
 
  N            : number of individuals
  m            : number of location parameters 
  rmax         : maximum number of transition functions authorised (r<=rmax)
  condini_user : initial conditions given by the user 
 
 --------------------------------------------------------------------------------------------------
 RETURNS:
 
            
  --------------------------------------------------------------------------------------------------
 
  C. Hurlin, May 2005
  LEO, University of Orléans
 

 
 WARNING: The sample is not balanced
 
 
 ***********************
 *** LINEARITY Tests ***
 ***********************
 
 H0: Linear Model H1: PSTR model with at least one Threshold Variable (r=1) 
 
     Wald Tests (LM):         W = 4.054    pvalue = 0.044
 
     Fisher Tests (LMF):      F = 3.591    pvalue = 0.060
 
     LRT Tests (LRT):         LRT = 4.094    pvalue = 0.045
 
 
 
 **************************************************************************
 *** TESTING THE NUMBER OF REGIMES: TESTS OF NO REMAINING NON-LINEARITY ***
 **************************************************************************
 
  Initial Conditions : Assumed Number of Thresholds r = 1   Number of Regressions = 270 
 Initial Conditions on (c,gamma)
     5   121

  Estimation of the Model with r = 1 and m = 1 : Convergence = 1   RSS = 26.002 
  RSS under H1 = 25.962 
 
 H0: PSTR with r = 1  against  H1: PSTR with at least r = 2 
 
     Wald Tests (LM):         W = 0.315    pvalue = 0.574
 
     Fisher Tests (LMF):      F = 0.271    pvalue = 0.603
 
     LRT Tests (LRT):         LRT = 0.316    pvalue = 0.574
 
 
 Given the choices of rmax = 1 and m = 1, the OPTIMAL (LMF criterion) NUMBER OF THRESHOLD FUNCTIONS is r = 1
 
 
 **************************************
 *** FINAL ESTIMATION OF PSTR MODEL ***
 **************************************
 
   Final Estimation of the Model with r = 1 and m = 1 by NLS ***
   Initial Conditions on (gamma,c) :
   94.0811  120.4771

 WARNING: at least one explicative variable is used as threshold variable 
 
 
  RSS = 26.002      Convergence = 1   
 
 Estimated Slope Parameters (for each transition function) 
   94.0811

 
 Estimated Location Parameters (per column for each transition function) 
  120.4771

 
 Estimated Parameters (per column for each transition function) 
    0.0073   -0.0055

 
 Standard Errors of Estimated Parameters Corrected fo Heteroskedasticity (per column for each transition function) 
    0.0029    0.0022

 
 T-statistics based on Corrected Standard Errors (per column for each transition function) 
    2.5067   -2.4866


res = 

  struct with fields:

         balanced: ' Unbalanced Sample'
                N: 26
                T: [26×1 double]
                m: 1
                r: 1
              gam: 94.0811
                c: 120.4771
             beta: [0.0073 -0.0055]
         beta_std: [0.0029 0.0022]
       beta_tstat: [2.5067 -2.4866]
      beta_std_nc: [0.0029 0.0012]
              rss: 26.0017
            fixed: [26×1 double]
            resid: [8×26 double]
                g: [208×1 double]
     LM_linearity: [4.0537 2.7055 3.8415 6.6349 0.0441]
      F_linearity: [3.5908 2.7339 3.8942 6.7794 0.0597]
    LRT_linearity: [4.0943 2.7339 3.8942 6.7794 0.0445]
               LM: [0.3153 2.7055 3.8415 6.6349 3.8415 0.5744]
                F: [0.2711 2.7343 3.8948 6.7811 3.8948 0.6032]
              LRT: [0.3155 2.7055 3.8415 6.6349 3.8415 0.5743]
         exitflag: 1
           output: [1×1 struct]
        coef_indi: [208×1 double]
          nbparam: 4
              AIC: -2.0166
              BIC: -1.9524

>> 