2
$\begingroup$

Suppose I have the following simplified distribution:

time | value
1    | 2
2    | 4
3    | 8
4    | 16

1    | 1
2    | 3
3    | 9
4    | 27

1    | 40
2    | 20
3    | 10
4    | 5

1    | 12
2    | 1
3    | 99
4    | 23423

These are all part of the same dataset (so one x can have multiple values here, eg. time = 1 corresponds with value = 2,1,40,12). I separated them because the first 3 have an obvious pattern within their slope (2, 3 and 0.5) and the last does not have a pattern in its slope. Time is in days, and the values represent a quantity.

Now, how do I use SPSS to find the elements of a distribution that together form a pattern (any kind of pattern) in their slope? And how can I make it also include elements that almost follow this pattern, but have slight variations (a variation that I can set)?

Any feedback is appreciated. Thanks.

Update:

It looks like SPSS is not the best tool for the task. I am interested in the R language however.

If anyone could recommend any books regarding this field of pattern recognition in R, that would be great.

$\endgroup$
6
  • $\begingroup$ @Tom, how did you uncover the obvious pattern? For 4 time periods and 4 different values for each period there are $4^4=256$ possible combinations, why did you post only 4 of them? I am asking because I suspect that there might be another variable which indicates how to group the values. $\endgroup$
    – mpiktas
    Commented Feb 7, 2011 at 15:11
  • $\begingroup$ @mpiktas, I probably missed a lot of patterns too in the above example. I just gave a simple example (it is not my actual data). I made them up while writing this question. I am trying to find patterns between individual fields in a dataset. $\endgroup$
    – Tom
    Commented Feb 7, 2011 at 18:44
  • $\begingroup$ @Tom, so what is your real data look like then? $\endgroup$
    – mpiktas
    Commented Feb 7, 2011 at 19:20
  • $\begingroup$ @mpiktas it's stock data by date, so basically multiple stocks with certain daily dates with stock prices of each date $\endgroup$
    – Tom
    Commented Feb 7, 2011 at 21:08
  • $\begingroup$ @Tom, so you want to see if stock price has any obvious time trend? $\endgroup$
    – mpiktas
    Commented Feb 8, 2011 at 3:59

1 Answer 1

1
$\begingroup$

I think I understand what you are after, but I might be wrong - just to clarify things in advance :)

If you want to find the "distribution" of your data, than R could do this easily, I have no idea about Spss. Though I am not sure about your are really after distributions, as those would only show the probabilities of certain values in your data series not dealing with the order, fitdistr from MASS and fitdist from fitdistrplus package will be your friend. Also, Vito Ricci's paper worths reading in the issue available on CRAN.

A small example assuming you have a data table (data) with your data, and would like to fit the first columns data to normal distribution:

library(fitdistrplus)
fitdist(data[,1],"norm")

If you would like to get the "slopes" of the pattern of a data in a row, as I suppose you are really after, than you need to set up some linear models based on your data. I am sure Spss can do the trick also, but in R look for lm and glm functions. See the manual of the lm to fit linear models.

A small example:

# make up a demo dataset from day 1 to day 10 with 10 values
data <- data.frame(time=1:10, data=c(4.17,5.58,5.18,6.11,4.50,4.61,5.17,4.53,5.33,5.14))

This would look like:

> data
   time data
1     1 4.17
2     2 5.58
3     3 5.18
4     4 6.11
5     5 4.50
6     6 4.61
7     7 5.17
8     8 4.53
9     9 5.33
10   10 5.14

And fit a simple model on it:

> lm(data)

Call:
lm(formula = data)

Coefficients:
(Intercept)         data  
     4.6613       0.1667  

Which shows the slope being around 0.16667.

$\endgroup$
3
  • $\begingroup$ It is clear to me I should learn R. Do you recommend any books that I could read to learn about pattern recognition in R? I am not just looking for a pattern in my distribution. I'm looking for all patterns that multiple fields of my distribution make up together. $\endgroup$
    – Tom
    Commented Feb 7, 2011 at 18:47
  • $\begingroup$ @Tom: you definitely should :) R has a really great potential if you plan to make complex computations in the future. To learn R, you can find a lot of great books and blogs also in the issue, just to pick up a free one, look for Statistics with R by Vincent Zoonekynd (zoonek2.free.fr/UNIX/48_R/all.html) and look for Ch. 11-12 for different kind of models. I have also made up a small collection of useful links in the subject, check it if you wish: r.snowl.net/interesting-urls-dealing-with-r $\endgroup$
    – daroczig
    Commented Feb 7, 2011 at 18:55
  • $\begingroup$ @Tom: a better approach could be reading through the answers of Books for learning the R language question on SO: stackoverflow.com/q/192369/564164 $\endgroup$
    – daroczig
    Commented Feb 7, 2011 at 18:57

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

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