3
$\begingroup$

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)?

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

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

| cite | improve this answer | |
$\endgroup$
2
$\begingroup$

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.

| cite | improve this answer | |
$\endgroup$
  • 2
    $\begingroup$ Is all this really necessary when the O.P. merely requests a set of descriptive statistics? $\endgroup$ – whuber Nov 27 '13 at 14:56
  • 1
    $\begingroup$ 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. $\endgroup$ – IrishStat Nov 27 '13 at 21:04
  • 1
    $\begingroup$ I agree that the question could be interpreted in different ways, but a comment to the question indicates that forecasting is not intended. $\endgroup$ – whuber Nov 27 '13 at 21:35
2
$\begingroup$

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.

Hope this is helpful.

| cite | improve this answer | |
$\endgroup$
  • 1
    $\begingroup$ Hi, thanks, I think I get the idea of this approach. Do you have some R code or a package that has this implemented? My skills are not sufficient to write my own package from the paper you provided. $\endgroup$ – user670186 Dec 10 '13 at 14:18
  • 1
    $\begingroup$ I used sas for my project $\endgroup$ – forecaster Dec 12 '13 at 4:35
  • 1
    $\begingroup$ is there any chance you could post a link to a paper to work approach 1? $\endgroup$ – ana coronel Apr 24 '18 at 17:30

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.