Announcement

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

  • Regression with only the last 80 lines

    Hello, i´m not sure if it possible or how i programm it. Here is my problem: The dataset includes 200 lines. Is it possible to use the latest 80 to estiamte the next one? For example: to estimate the line 141 the regression should use only lines 61 to 140. If this question in at the wrong place, be friendly with me it´s my first question her. I hope one of you can help me.
    Lars

  • #2
    Dear Lars,

    I am not sure I understood correctly what your question is, but when you say "200 lines", you meant 200 rows/observations?
    Could you post a sketch of your actual code?

    From that I get, probably something like the following could be helpful for you, at least to select the last n observation of a matrix.

    Code:
    mata:
    X= (1,2,3,4,5,6,7,8,9,10)'
    
    X
             1
         +------+
       1 |   1  |
       2 |   2  |
       3 |   3  |
       4 |   4  |
       5 |   5  |
       6 |   6  |
       7 |   7  |
       8 |   8  |
       9 |   9  |
      10 |  10  |
         +------+
    
    n = 3
    X_last_n = X[(rows(X)-n+1::rows(X)), .]
    X_last_n
            1
        +------+
      1 |   8  |
      2 |   9  |
      3 |  10  |
        +------+
    end
    Best regards,
    Álvaro
    Stata 16.1 MP
    Win10/Linux Mint 19.1

    https://alvarogutyerrez.github.io/

    Comment


    • #3
      I think that you should post your question in the General forum and not here in the Mata forum. The Mata forum is dedicated to questions about Stata's matrix language, Mata.
      That being said.
      It is possible to do what you want but without further context, I doubt that it is what you really want to achieve.
      Code:
      regress <dependent variable> <independent variable> in 61/140
      predict <predict variable name> in 141, xb

      Comment

      Working...
      X