Announcement

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

  • Mixed AR Residuals

    Hi Folks, I am using Mixed in Stata/SE 15..

    I have a dataset where I have weekly sales from a farmers market (there many gaps in the data, especially as the market is closed several months each year). Then, I have sales by individual vendor types. I have one time series analysis that looks at aggregated sales (of all vendor types), and it is clear there is an autoregressive process that must be included. With the multilevel analysis, I want to consider the random effects of the vendor type. When I do this, and include the residual structure, the conversion is very slow (in fact I have not been able to see any results from the analysis). Here is the code for that, followed by sample data. Does anybody have any suggestions for improving the convergence? Maybe there is something I am overlooking.

    Thank you!

    -Steve

    Code:
    tsset vend_id date3
     mixed lnsales_type10v lnspec_index   ///
    ||vend_type: , mle residuals(ar 1, by(vend_type) t(date3))
    Code:
    * Example generated by -dataex-. To install: ssc install dataex
    clear
    input float(lnsales_type10v lnspec_index) str9 vend_type float date3
     3.505557 1.6897603 "spec"      19230
     3.987673 1.6897603 "nonedible" 19230
    4.1076307 1.6897603 "plants"    19230
     4.795667  1.776106 "plants"    19181
     4.824479  1.609438 "nonedible" 19811
     4.922168  1.670123 "nonedible" 19573
     4.928991 1.7769105 "nonedible" 19552
     5.108971  1.684198 "nonedible" 19608
     5.161642 1.7881165 "plants"    19972
     5.166727  1.609438 "produce"   19811
     5.192368 1.5377253 "produce"   19762
     5.200264 1.8057457 "nonedible" 19895
     5.201256 1.7337543 "produce"   19321
      5.20396  1.609438 "plants"    19811
     5.228194  1.764295 "plants"    19209
     5.232668 1.7796197 "plants"    19202
     5.232712 1.5377253 "nonedible" 19762
     5.236389 1.7176515 "produce"   19790
     5.243749 1.6897603 "value"     19230
     5.296916  1.609438 "spec"      19811
     5.327488 1.5145186 "produce"   19398
     5.336576 1.6397433 "produce"   19426
     5.339828  1.789192 "plants"    19216
     5.380818 1.7403235 "nonedible" 19615
     5.400657  1.764015 "plants"    19272
     5.414137 1.7466246 "plants"    19188
     5.414655 1.7120484 "nonedible" 19937
      5.43238  1.728827 "plants"    19223
     5.452424   1.79868 "nonedible" 19916
     5.457228 1.7917595 "plants"    19195
     5.487449  1.670238 "nonedible" 19601
     5.488313 1.6897603 "meat"      19230
     5.498344 1.8590926 "plants"    19545
      5.50289 1.7026595 "produce"   19447
     5.505159  1.771281 "nonedible" 19174
     5.510217 1.7940716 "nonedible" 19517
     5.514417  1.754488 "plants"    19643
     5.521911 1.7149657 "nonedible" 19496
     5.530543 1.7574022 "nonedible" 19559
     5.544161  1.628456 "produce"   19454
     5.547513 1.7149657 "plants"    19496
     5.570927   1.78413 "plants"    19251
     5.574079  1.688008 "produce"   19818
     5.577326   1.74204 "plants"    19958
     5.579881 1.8174162 "nonedible" 19888
     5.588661 1.7403235 "plants"    19615
     5.596269 1.7881165 "nonedible" 19972
     5.600256 1.7897793 "plants"    19944
     5.618566  1.655423 "plants"    19657
     5.626764  1.628456 "nonedible" 19454
       5.6287  1.704262 "nonedible" 19587
     5.645447  1.686756 "nonedible" 19489
     5.646227  1.684198 "plants"    19608
     5.658646  1.776106 "nonedible" 19181
     5.663717 1.7120484 "plants"    19937
     5.677672  1.704262 "plants"    19587
     5.677943  1.754019 "plants"    19930
     5.678123 1.6464264 "nonedible" 19580
     5.683178 1.6945958 "nonedible" 19909
     5.686351 1.7278557 "nonedible" 19244
     5.691782 1.7412496 "plants"    19951
     5.709225 1.7013754 "plants"    19636
     5.710659  1.754019 "nonedible" 19930
     5.714527  1.609438 "meat"      19811
     5.721739 1.7721362 "plants"    19650
     5.721868 1.7278557 "nonedible" 19265
     5.744672 1.5377253 "plants"    19762
     5.746185 1.7796197 "nonedible" 19202
     5.747989  1.762772 "plants"    19279
     5.748619 1.6945958 "plants"    19909
     5.760365  1.688008 "plants"    19293
     5.762837 1.7574022 "plants"    19559
     5.765787  1.754488 "nonedible" 19643
     5.766636  1.699146 "plants"    19160
     5.767956 1.6897603 "produce"   19230
     5.770072  1.789192 "nonedible" 19216
     5.771064  1.727043 "plants"    19622
     5.778542 1.7562047 "nonedible" 19860
     5.786503  1.781418 "nonedible" 19146
     5.789114  1.764295 "nonedible" 19209
     5.792663  1.670123 "plants"    19573
     5.793485 1.7769105 "plants"    19552
     5.800488  1.670238 "nonedible" 19461
     5.805037 1.7512915 "nonedible" 19139
     5.806499 1.6028227 "nonedible" 19965
     5.812849  1.776106 "plants"    19566
     5.821338 1.7647308 "spec"      19832
     5.827877 1.4319825 "nonedible" 19797
     5.831261 1.6464264 "plants"    19580
     5.844341 1.6846718 "plants"    19629
     5.845448  1.670238 "plants"    19601
     5.846124 1.7466246 "nonedible" 19188
     5.857612 1.6479865 "plants"    19034
     5.861122 1.7104533 "nonedible" 19104
     5.869641   1.79868 "plants"    19916
     5.870623  1.720624 "plants"    19111
     5.872681 1.6672574 "produce"   19825
     5.876374 1.7647308 "nonedible" 19832
     5.891682 1.7940716 "plants"    19517
     5.892911 1.7278557 "plants"    19265
    end

  • #2
    Okay, it doesn't seem like this post got much traction. But, one clarification is that the model can't find starting values. I think I know what one problem might be, weekly data. The date has breaks of 7 in-between. I grouped weekly dates over the 15 years of my data (780 weeks), and renumbered them (using -egen- group()). This seems to help a lot with getting the model going.

    Comment

    Working...
    X