Announcement

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

  • calculating a formula in stata

    Hello everyone
    I have a sample of 100 rnormal() in stata, am going to calculate this formula in stata
    [IMG]file:///C:\Users\ben\AppData\Local\Temp\msohtmlclip1\01\cl ip_image001.png[/IMG]
    Where r2k is squared autocorrelation up to k lag, h the maximum lag, n sample size, In my case, n=100, h=10 (I want to calculate 10 autocorrelation)
    The purpose of this formula is to do monte carlo simulation with 1000 replication and derive the critical values (1%, 5%, 10%) for the Q*statistics for every 100 sample drawn
    Attached Files
    Last edited by lindsy ben; 19 May 2020, 17:40.

  • #2
    Welcome to Stata list. You will increase your chances of useful answer by following the FAQ on asking questions-provide Stata code in code delimiters, readable Stata output, and sample data using dataex.

    If you have all of these variables (and I assume the variables) then you can readily calculate the things that in the summary using a generate statement and a egen summation – something like
    g a=n*(n+2)
    g b=(1/(n-k)) * r * r
    bysort k: egen suma=total(b)
    g q= a * suma

    Now, if these are not variables, then you have a different problem. It can still probably be done with local macros. But it really depends a lot on how your data is set up.

    Comment


    • #3
      thanks phil Bromiley for your time, lets say i have 10 autocorrelations as shown in the bicture below ,how do i calculate the formula mentioned previously, k stands for the 10 lags n sample size, r autocorrelation, the calculation require generating new variables after corrgram command i dont know how to do it
      Attached Files

      Comment

      Working...
      X