Announcement

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

  • How to do recursive estimation while estimating autoregressive probit model

    Hello,
    I want to forecast market states, and for the same I am using autoregressive and dynamic autoregressive probit. I want to know if there is any way of estimating such time series model?

  • #2
    Predicting Canadian recessions using dynamic probit modelling approaches
    Lili Hao, Eric C. Y. Ng
    The Canadian Journal of Economics / Revue canadienne d'Economique, Vol. 44, No. 4 (November / novembre 2011), pp. 1297-1330 (34 pages)

    Comment


    • #3
      Thankyou for the reference, but I am facing difficulty while estimating the model. The else condition in the below loop is not working, and I am not able to figure out how to take the mean value of x variable as the first value of lagged index.

      // Step 1: Set up the dataset
      gen id = _n // Create an ID variable for tracking observations
      tsset id // Declare the dataset as time series

      // Step 2: Initialize variables for storing results
      gen predicted_prob = . // To store predicted probabilities
      gen lagged_index = . // To store lagged index values

      // Step 3: Recursive Estimation Loop
      forvalues i = 2/`=_N' { // Loop over each time period (2 to T)
      display "Running iteration `i'"

      // Step 3.1: Fit the Logit model for the first time period
      if `i' == 2 {
      logit y x // Estimate only for the first period
      predict xb_initial if id == 2, xb // Get initial index
      replace lagged_index = xb_initial if id == 2 // Store initial lagged value
      }
      else { // For subsequent iterations with lagged index
      logit y x lagged_index if id <= `i' // Fit logit model up to t = i
      predict xb_updated if id == `i', xb // Get new predicted index
      replace lagged_index = xb_updated if id == `i'-1 // Store updated lagged value
      }

      // Step 3.2: Compute Lagged Index for Current Observation
      replace lagged_index = _b[_cons] + _b[x] * x+ ///
      (cond(`i' > 1, _b[lagged_index] * lagged_index[_n-1], 0)) if id == `i'

      // Step 3.3: Predict probability for the current observation
      quietly logit y x lagged_index if id <= `i'
      predict predicted_prob if id == `i', pr // Store probability forecast
      }

      Comment

      Working...
      X