Announcement

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

  • "No observation" error after running "var" (Vector Autoregression) command

    Hi there. So bacically, i get the "no observation r(2000)" error when I try running "var" (which is the command for Vector Autorregression). I know there are some posts already talking about the issue, but none of them solved my problem. So here we go.

    I'm working with macroeconomic time series. More specifically I'm trying to run var for central bank policy rate and inflation rate with two lags. The range of my dataset goes from 1999-june to 2018-december in monthly periods.

    You can see below the commands I've used step-by-step, where "IPCA_L" is my variable for inflation rate, "SELIC" is by variable for central bank policy rate and "MES" is date. I've also run "describe" and "summarize" in case you need it.

    Code:
    . tsset MES, monthly delta(1)
    
    Variable MES had been formatted %tdMon-YY (a daily period),
    and you asked for a monthly period.  Are you sure that is
    what you want?  It has been done; MES is now formatted %tm.
    
            time variable:  MES, 3159m9 to 3753m4, but with gaps
                    delta:  1 month
    . var IPCA_L SELIC, lags(3) small level(95)
    no observations
    r(2000);
    
    end of do-file
    
    r(2000);
    
    . describe
    
    Contains data
      obs:           235                          
     vars:             6                          
     size:         8,930                          
    -------------------------------------------------------------------------------------------------------------------------------------------------------------
                  storage   display    value
    variable name   type    format     label      variable label
    -------------------------------------------------------------------------------------------------------------------------------------------------------------
    MES             int     %tm                  
    SELIC           double  %10.0g                
    IPCA_L          double  %10.0g                
    IPCA_A          double  %10.0g                
    IPCA_L12        double  %10.0g                
    d_SELIC         float   %9.0g                
    -------------------------------------------------------------------------------------------------------------------------------------------------------------
    Sorted by: MES
         Note: Dataset has changed since last saved.
    
    . summarize
    
        Variable |        Obs        Mean    Std. Dev.       Min        Max
    -------------+---------------------------------------------------------
             MES |        235    17957.81    2069.232      14396      21519
           SELIC |        235    13.68617    4.580613        6.5       26.5
          IPCA_L |        235    .4819574     .372651       -.35       2.53
          IPCA_A |        235    6.497617    2.686038       2.46      17.24
        IPCA_L12 |        235    5.815702    2.432967        .97       14.4
    -------------+---------------------------------------------------------
         d_SELIC |        234   -.0619658    .5625146       -2.5          3
    So, does anyone know what I'm doing wrong?
    Thanks in advantage
    Last edited by Pedro Cardoso; 12 Nov 2019, 14:21.

  • #2
    Welcome to Statalist.

    Notice the following warning message from Stata in your output.

    . tsset MES, monthly delta(1)

    Variable MES had been formatted %tdMon-YY (a daily period),
    and you asked for a monthly period. Are you sure that is
    what you want? It has been done; MES is now formatted %tm.

    time variable: MES, 3159m9 to 3753m4, but with gaps
    delta: 1 month
    It now is treating your dates as running from September 3159 to April 3753.

    You rmonthly dates are actually Stata daily dates like 1jun1999 1jul1999 ... as this code shows.
    Code:
    . display %td td(1jun1999)
    01jun1999
    
    . display %9.0g td(1jun1999)
        14396
    
    . display %tm 14396
     3159m9
    You need to convert your dates to Stata monthly dates, and that is not done by giving it a %tdMon-YY format that hides the day of the month. Instead, you need code something like the following untested code.
    Code:
    rename MES dailyMES
    generate MES = mofd(dailyMES)
    format MES %tm
    tsset MES
    But before leaping in and trying that code, you need a better understanding of Stata's "date and time" variables, which are complicated and there is a lot to learn. If you have not already read the very detailed Chapter 24 (Working with dates and times) of the Stata User's Guide PDF, do so now. If you have, it's time for a refresher. After that, the help datetime documentation will usually be enough to point the way. You can't remember everything; even the most experienced users end up referring to the help datetime documentation or back to the manual for details. But at least you will get a good understanding of the basics and the underlying principles. An investment of time that will be amply repaid.

    All Stata manuals are included as PDFs in the Stata installation (since version 11) and are accessible from within Stata - for example, through the PDF Documentation section of Stata's Help menu.

    Last edited by William Lisowski; 13 Nov 2019, 09:20.

    Comment

    Working...
    X