# Find curve pattern of simple time series

I have time series data of credit card transaction volumes for different companies. For example:

week1: \$5000 week2: \$6000
week3: \$6200 week4: \$7000
week5: \\$9000
...


Is there a simple method in R to determine if the number series has a linear trend upwards, downwards or like a normal distribution (rising first then dropping)?

• Plotting the data is one answer. Presumably you know that, so please be more precise about the kind of method you seek. – Nick Cox Nov 27 '13 at 10:37
• A method that takes a vector of time series data and gives me as output: "linear trend up", "linear trend down", "rise-then-fall". – user670186 Nov 27 '13 at 13:19
• That's clearer. Good luck on finding it! I don't think people write programs like that, but being wrong is very possible. – Nick Cox Nov 27 '13 at 13:35

You should first try and remove any seasonal effects from your data, otherwise the trend might be misleading, especially if your data include transcations from several years. For processing and plotting, the R package stl should be a good point to start: http://stat.ethz.ch/R-manual/R-devel/library/stats/html/stl.html

For general time series analysis issues, you should also see what CRAN has to suggest: http://cran.r-project.org/web/views/TimeSeries.html

You should studiously avoid any attempt to deseasonalize or to detrend as eventually that structure potentially has to be re-inserted at the end in order to make forecasts in the observational space. It is a good idea to form a useful equation that incorporates 1) weekly factors 2) holiday effects 3) trends 4) level shifts 5) changes in parameters over time and/or 6) changs in error variance over time without any unwarranted transformations.

• Is all this really necessary when the O.P. merely requests a set of descriptive statistics? – whuber Nov 27 '13 at 14:56
• The op sked for a method to determine if the series was upwards trending or downwards trending. To me this a request for an inferential analysis not a descriptive analysis. – IrishStat Nov 27 '13 at 21:04
• I agree that the question could be interpreted in different ways, but a comment to the question indicates that forecasting is not intended. – whuber Nov 27 '13 at 21:35

Sure, This is possible with some programming effort. I work with transaction data a lot. There are two approaches that i have used. Unfortunately there is no standard procedures that is available.

Approach 1 (Pattern known a priori):

If you interested in finding a priori pattern like trend up trend down, then you could use a similarity analysis or a classification problem, click here for an example implementation in SAS with Proc Similarity. There are 6 types of pattern that you can notice in the transnational data sets and I have used in the past:

1. Increasing trend
2. Decreasing trend
3. Level Shift up
4. Level shift down
5. Spike Up or Down
6. no pattern

You could also use neural network to train the 6 patterns and then apply the trained network to your transnational data. See below for these patterns.

Approach 2 (Pattern not known a priori)

If you do not have a priori pattern, then you would want to use AI techniques based on clustering such as neural networks, kohonen networks etc. to let the method automatically find and cluster similar patterns such as trend increase/down etc.

Based on my experience, approach 1 is better than approach 2. If you are intrested in a worked out example, I can post a link to a paper.