Statalist The Stata Listserver


[Date Prev][Date Next][Thread Prev][Thread Next][Date index][Thread index]

st: RE: RE: Time series analysis by subsets within data set


From   "Scott Merryman" <[email protected]>
To   <[email protected]>
Subject   st: RE: RE: Time series analysis by subsets within data set
Date   Thu, 12 Apr 2007 21:34:56 -0500

"Say exactly what you typed and exactly what Stata typed (or did) in
response. N.B. exactly!" (Statalist FAQ
http://www.stata.com/support/faqs/res/statalist.html)

You do not have strictly time series date by panel data, so you will need to
-tsset name date-

Perhaps this example will help:

clear
input str6 week str5 name 
2003w1       name1              
2003w1       name2              
2003w1       name3              
2003w2       name1              
2003w2       name2              
2003w2       name3              
2003w3       name1              
2003w3       name2              
2003w3       name3 
2003w4       name1              
2003w4       name2              
2003w4       name3 
2003w5       name1              
2003w5       name2              
2003w5       name3 
2003w6       name1              
2003w6       name2              
2003w6       name3 
end
gen sales = uniform()
            
gen date = weekly(week, "yw")
format date %tw
encode name , gen(id)
tsset id date
levelsof name, local(levels)
foreach l of local levels {
	arima sales if name == "`l'", ar(1) nolog
}

Scott


> -----Original Message-----
> From: [email protected] [mailto:owner-
> [email protected]] On Behalf Of Michael Crain
> Sent: Thursday, April 12, 2007 8:56 PM
> To: [email protected]
> Subject: st: RE: Time series analysis by subsets within data set
> 
> Thank you, Scott, but I cannot get the TSSET set in the first place.  When
> I
> issue the TSSET command, I get an error message "repeated time values in
> sample."
> 
> An example of my data set (using weekly data) looks like this:
> 
> 2003w1       (customer name 1)              (amount)
> 2003w1       (customer name 2)              (amount)
> 2003w1       (customer name 3)              (amount)
> 2003w2       (customer name 1)              (amount)
> 2003w2       (customer name 2)              (amount)
> 2003w2       (customer name 3)              (amount)
> 2003w3       (customer name 1)              (amount)
> 2003w3       (customer name 2)              (amount)
> 2003w3       (customer name 3)              (amount)
> 



*
*   For searches and help try:
*   http://www.stata.com/support/faqs/res/findit.html
*   http://www.stata.com/support/statalist/faq
*   http://www.ats.ucla.edu/stat/stata/



© Copyright 1996–2024 StataCorp LLC   |   Terms of use   |   Privacy   |   Contact us   |   What's new   |   Site index