class_docstr: Markov switching regression model
  
  Parameters
  ----------
  endog : array_like
      The endogenous variable.
  k_regimes : int
      The number of regimes.
  order : int
      The order of the autoregressive lag polynomial.
  trend : {'n', 'c', 't', 'ct'}
      Whether or not to include a trend. To include an constant, time trend,
      or both, set `trend='c'`, `trend='t'`, or `trend='ct'`. For no trend,
      set `trend='n'`. Default is a constant.
  exog : array_like, optional
      Array of exogenous regressors, shaped nobs x k.
  exog_tvtp : array_like, optional
      Array of exogenous or lagged variables to use in calculating
      time-varying transition probabilities (TVTP). TVTP is only used if this
      variable is provided. If an intercept is desired, a column of ones must
      be explicitly included in this array.
  switching_ar : bool or iterable, optional
      If a boolean, sets whether or not all autoregressive coefficients are
      switching across regimes. If an iterable, should be of length equal
      to `order`, where each element is a boolean describing whether the
      corresponding coefficient is switching. Default is True.
  switching_trend : bool or iterable, optional
      If a boolean, sets whether or not all trend coefficients are
      switching across regimes. If an iterable, should be of length equal
      to the number of trend variables, where each element is
      a boolean describing whether the corresponding coefficient is
      switching. Default is True.
  switching_exog : bool or iterable, optional
      If a boolean, sets whether or not all regression coefficients are
      switching across regimes. If an iterable, should be of length equal
      to the number of exogenous variables, where each element is
      a boolean describing whether the corresponding coefficient is
      switching. Default is True.
  switching_variance : bool, optional
      Whether or not there is regime-specific heteroskedasticity, i.e.
      whether or not the error term has a switching variance. Default is
      False.
  
  Notes
  -----
  This model is new and API stability is not guaranteed, although changes
  will be made in a backwards compatible way if possible.
  
  The model can be written as:
  
  .. math::
  
      y_t = a_{S_t} + x_t' \beta_{S_t} + \phi_{1, S_t}
      (y_{t-1} - a_{S_{t-1}} - x_{t-1}' \beta_{S_{t-1}}) + \dots +
      \phi_{p, S_t} (y_{t-p} - a_{S_{t-p}} - x_{t-p}' \beta_{S_{t-p}}) +
      \varepsilon_t \\
      \varepsilon_t \sim N(0, \sigma_{S_t}^2)
  
  i.e. the model is an autoregression with where the autoregressive
  coefficients, the mean of the process (possibly including trend or
  regression effects) and the variance of the error term may be switching
  across regimes.
  
  The `trend` is accommodated by prepending columns to the `exog` array. Thus
  if `trend='c'`, the passed `exog` array should not already have a column of
  ones.
  
  See the notebook `Markov switching autoregression
  <../examples/notebooks/generated/markov_autoregression.html>`__
  for an overview.
  
  References
  ----------
  Kim, Chang-Jin, and Charles R. Nelson. 1999.
  "State-Space Models with Regime Switching:
  Classical and Gibbs-Sampling Approaches with Applications".
  MIT Press Books. The MIT Press.
class_docstr_tok: ["Markov","switching","regression","model","Parameters","--","--","--","--","--","endog",":","array_like","The","endogenous","variable",".","k_regimes",":","int","The","number","of","regimes",".","order",":","int","The","order","of","the","autoregressive","lag","polynomial",".","trend",":","{","'n","'",",","'","c","'",",","'t","'",",","'ct","'","}","Whether","or","not","to","include","a","trend",".","To","include","an","constant",",","time","trend",",","or","both",",","set","`","trend=","'","c","'","`",",","`","trend='t","'","`",",","or","`","trend='ct","'","`",".","For","no","trend",",","set","`","trend='n","'","`",".","Default","is","a","constant",".","exog",":","array_like",",","optional","Array","of","exogenous","regressors",",","shaped","nobs","x","k.","exog_tvtp",":","array_like",",","optional","Array","of","exogenous","or","lagged","variables","to","use","in","calculating","time-varying","transition","probabilities","(","TVTP",")",".","TVTP","is","only","used","if","this","variable","is","provided",".","If","an","intercept","is","desired",",","a","column","of","ones","must","be","explicitly","included","in","this","array",".","switching_ar",":","bool","or","iterable",",","optional","If","a","boolean",",","sets","whether","or","not","all","autoregressive","coefficients","are","switching","across","regimes",".","If","an","iterable",",","should","be","of","length","equal","to","`","order","`",",","where","each","element","is","a","boolean","describing","whether","the","corresponding","coefficient","is","switching",".","Default","is","True",".","switching_trend",":","bool","or","iterable",",","optional","If","a","boolean",",","sets","whether","or","not","all","trend","coefficients","are","switching","across","regimes",".","If","an","iterable",",","should","be","of","length","equal","to","the","number","of","trend","variables",",","where","each","element","is","a","boolean","describing","whether","the","corresponding","coefficient","is","switching",".","Default","is","True",".","switching_exog",":","bool","or","iterable",",","optional","If","a","boolean",",","sets","whether","or","not","all","regression","coefficients","are","switching","across","regimes",".","If","an","iterable",",","should","be","of","length","equal","to","the","number","of","exogenous","variables",",","where","each","element","is","a","boolean","describing","whether","the","corresponding","coefficient","is","switching",".","Default","is","True",".","switching_variance",":","bool",",","optional","Whether","or","not","there","is","regime-specific","heteroskedasticity",",","i.e",".","whether","or","not","the","error","term","has","a","switching","variance",".","Default","is","False",".","Notes","--","--","-","This","model","is","new","and","API","stability","is","not","guaranteed",",","although","changes","will","be","made","in","a","backwards","compatible","way","if","possible",".","The","model","can","be","written","as",":","..","math",":",":","y_t","=","a_","{","S_t","}","+","x_t","'","\\beta_","{","S_t","}","+","\\phi_","{","1",",","S_t","}","(","y_","{","t-1","}","-","a_","{","S_","{","t-1","}","}","-","x_","{","t-1","}","'","\\beta_","{","S_","{","t-1","}","}",")","+","\\dots","+","\\phi_","{","p",",","S_t","}","(","y_","{","t-p","}","-","a_","{","S_","{","t-p","}","}","-","x_","{","t-p","}","'","\\beta_","{","S_","{","t-p","}","}",")","+","\\varepsilon_t","\\\\","\\varepsilon_t","\\sim","N","(","0",",","\\sigma_","{","S_t","}","^2",")","i.e",".","the","model","is","an","autoregression","with","where","the","autoregressive","coefficients",",","the","mean","of","the","process","(","possibly","including","trend","or","regression","effects",")","and","the","variance","of","the","error","term","may","be","switching","across","regimes",".","The","`","trend","`","is","accommodated","by","prepending","columns","to","the","`","exog","`","array",".","Thus","if","`","trend=","'","c","'","`",",","the","passed","`","exog","`","array","should","not","already","have","a","column","of","ones",".","See","the","notebook","`","Markov","switching","autoregression","<","..","\/examples\/notebooks\/generated\/markov_autoregression.html",">","`","__","for","an","overview",".","References","--","--","--","--","--","Kim",",","Chang-Jin",",","and","Charles","R.","Nelson",".","1999",".","``","State-Space","Models","with","Regime","Switching",":","Classical","and","Gibbs-Sampling","Approaches","with","Applications","''",".","MIT","Press","Books",".","The","MIT","Press","."]
docstr: Transform constrained parameters used in likelihood evaluation
  to unconstrained parameters used by the optimizer
  
  Parameters
  ----------
  constrained : array_like
      Array of constrained parameters used in likelihood evaluation, to
      be transformed.
  
  Returns
  -------
  unconstrained : array_like
      Array of unconstrained parameters used by the optimizer.
docstr_tok: ["Transform","constrained","parameters","used","in","likelihood","evaluation","to","unconstrained","parameters","used","by","the","optimizer","Parameters","--","--","--","--","--","constrained",":","array_like","Array","of","constrained","parameters","used","in","likelihood","evaluation",",","to","be","transformed",".","Returns","--","--","--","-","unconstrained",":","array_like","Array","of","unconstrained","parameters","used","by","the","optimizer","."]
code: def untransform_params(self, constrained):
      """
      Transform constrained parameters used in likelihood evaluation
      to unconstrained parameters used by the optimizer
  
      Parameters
      ----------
      constrained : array_like
          Array of constrained parameters used in likelihood evaluation, to
          be transformed.
  
      Returns
      -------
      unconstrained : array_like
          Array of unconstrained parameters used by the optimizer.
      """
      # Inherited parameters
      unconstrained = super().untransform_params(constrained)
  
      # Autoregressive
      # TODO may provide unexpected results when some coefficients are not
      # switching
      for i in range(self.k_regimes):
          s = self.parameters[i, "autoregressive"]
          unconstrained[s] = unconstrain_stationary_univariate(
              constrained[s]
          )
  
      return unconstrained
  
imports: import numpy
  import statsmodels.base.wrapper
  from statsmodels.tsa.tsatools import lagmat
  from statsmodels.tsa.regime_switching import markov_switching, markov_regression
  from statsmodels.tsa.statespace.tools import constrain_stationary_univariate, unconstrain_stationary_univariate
label_desc: Use image node_id 11 for calling the MarkovAutoregression obj's underlying member method code with example usage: obj.untransform_params(constrained) and returns: unconstrained