Announcement

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

  • Help with replication STATA command

    Hi
    I am constructing an index with Panel data using Dynamic factor model (DFM).
    I found this paper which I am following for the methodology: https://www.stata.com/meeting/2italian/Federici.pdf


    Please help me with trouble shooting this issue I am facing and have already reached out for help from long time.

    The commands were working till I got an error in page 11 (see below).
    Code:
    local t=1
    matrix ST=J(24,24,0)
    forvalues i=1(27)2052 {
        matrix num = J(1,1,0)
        matrix C=A[`i'..(`i'+27-1),1...]
        svmat C
        matrix accum cov = C1-C24, deviations noconstant
        matrix cov=cov/(r(N)-1)
        matrix ST=ST+cov
        drop C1-C24
        forvalues k = 1/24 {
            mat num = num + (`e`k''*cov*e`k')
        }
        mat I_`t' = num/trace(cov)
        mat list I_`t'
        local t = `t'+1
    }
    Two things:
    First, it there something like e`k" (double quotes)? Someone whom I asked (statistician, without STATA knowledge) said it might mean the multiplication of three matrices like 3X1), (3X3), (1X3), where e`k" could mean transpose of eigenvector matrix, cov is covariance matrix, and e`k' is eigenvector matrix.

    I wanted to know if this is correct?
    When I run this, I get
    Code:
    . local t=1
    
    . matrix ST=J(24,24,0)
    
    . forvalues i=1(27)2052 {
      2.         matrix num = J(1,1,0)
      3.         matrix C=A[`i'..(`i'+27-1),1...]
      4.         svmat C
      5.         matrix accum cov = C1-C24, deviations noconstant
      6.         matrix cov=cov/(r(N)-1)
      7.         matrix ST=ST+cov
      8.         drop C1-C24
      9.         forvalues k = 1/24 {
     10.                 mat num = num + (e`k"*cov*e`k')
     11.         }
     12.         mat I_`t' = num/trace(cov)
     13.         mat list I_`t'
     14.         local t = `t'+1
     15. }
    (obs=27)
    too few quotes
    r(132);
    Secondly, i thought maybe it should be `e`k''
    Code:
    . local t=1
    
    . matrix ST=J(24,24,0)
    
    . forvalues i=1(27)2052 {
      2.         matrix num = J(1,1,0)
      3.         matrix C=A[`i'..(`i'+27-1),1...]
      4.         svmat C
      5.         matrix accum cov = C1-C24, deviations noconstant
      6.         matrix cov=cov/(r(N)-1)
      7.         matrix ST=ST+cov
      8.         drop C1-C24
      9.         forvalues k = 1/24 {
     10.                 mat num = num + (`e`''*cov*e`k')
     11.         }
     12.         mat I_`t' = num/trace(cov)
     13.         mat list I_`t'
     14.         local t = `t'+1
     15. }
    (obs=27)
    *cov not found
    r(111);
    Third, I tried the following with this error popping up:
    Code:
    . local t=1
    
    . matrix ST=J(24,24,0)
    
    . forvalues i=1(27)2052 {
      2.         matrix num = J(1,1,0)
      3.         matrix C=A[`i'..(`i'+27-1),1...]
      4.         svmat C
      5.         matrix accum cov = C1-C24, deviations noconstant
      6.         matrix cov=cov/(r(N)-1)
      7.         matrix ST=ST+cov
      8.         drop C1-C24
      9.         forvalues k = 1/24 {
     10.                 mat num = num + (e`k'*cov*e`k')
     11.         }
     12.         mat I_`t' = num/trace(cov)
     13.         mat list I_`t'
     14.         local t = `t'+1
     15. }
    (obs=27)
    conformability error
    r(503);
    Because similar code is being used in page no. 12 again.

    Any and all help is needed.
    P.S. I am new to STATA. I am doing this research as part of my internship and the organization has provided me with STATA v13

    Please please desperately need help in figuring this out

  • #2
    You may find more informative error messages by typing
    Code:
    set trace on
    .

    NB! You should provide your full example. And - if possible - a subset of the dataset you are using. I get an error saying matrix A not found.

    Comment

    Working...
    X