Take the 2-minute tour ×
Cross Validated is a question and answer site for people interested in statistics, machine learning, data analysis, data mining, and data visualization. It's 100% free, no registration required.

First of all, sorry for the strange title, I had no idea how to describe my problem better. My issue is the following, I think it is pretty much limited to geosciences.

I have several properties for every sample, which are divided by depth.

For instance:

(ID var1_0-20cm, var1_20-50cm, var1_50-100cm, var2_0-20cm, var2_20-50, ....)

(1, 2.3, 2.1, 2.6, 10.5, 10.9, 15.0,...)
(2, 2.0, 1.1, 1.1, 5.5, 5.9, 5.0,...)
(3, 1.0, 0.0, 0.0, 3.5, 1.9, 1.0,...)

Basically these are geological layers going from surface down to 100 cm depth. I am trying to decrease the number of variables, either with PCA or factor analysis. The issue is, that I would like to handle properties together, no matter what the depth is.

(For instance I do not want to get rid of a layer in between the surface and the bottom layer.)

Is there any way to handle them together, or group them for PCA or whatever. I tried to find some relevant information, but I think the problem is limited to a small portion of the science (maybe I am wrong), so I could not find anything useful.

share|improve this question
How, exactly, are the samples obtained and measured? This matters because if the samples represent averages within each layer at their locations, then the varying layer thickness will change the distributions of the values and thereby suggest one set of approaches. Otherwise, if the results are from subsampling each layer (which often happens in the lab), then another set of approaches might be favored. –  whuber Nov 13 '12 at 22:43
Thanks @whuber for the fast reply: Layers are (re)calculated with weighted average, from sampling layers. So they do not represent the actual sampling and lab measured samples (every profile has a different layer divison for sampling). And after recalculating the layering is uniform for every sample for every property. –  user1775772 Nov 13 '12 at 22:49
You may have a hard time, then, interpreting the results: they could tell you more about your interpolation (averaging) method than about what's really going on. Is there a reason not to do the PCA with the original data? –  whuber Nov 13 '12 at 22:50
Sampling is really diverse for every single point. It means sometimes the first layer is 0-1cm sometimes 0-100cms. The goal would be clustering, on a uniform layering, but I'd like to get rid of correlating properties. –  user1775772 Nov 13 '12 at 22:54
@whuber I was considering also splines, not weighted average but in some cases it would have result to misleading values if NAs are present in a profile. –  user1775772 Nov 13 '12 at 23:05
show 2 more comments

3 Answers

If I understand you correctly, you want to use

Variable1 :=  var1_0-20cm + var1_20-50cm + var1_50-100cm
Variable2 :=  var2_0-20cm + var2_20-50cm + var2_50-100cm

(i.e. "independent of depth"; depending on how your data was generated you might want to use the mean or a weighted average instead of the sum. e.g. 0.20 times the first, 0.30 the second and 0.50 the third) instead of the full data space? What exactly is the problem with doing this? A key benefit is that this way you can control what happens quite well.

Then in the end you can e.g. use PCA on these non-divided variables. You can however try to use the PCA result to project the original data, too - do the same mapping for the "divided" attributes that you got by PCA for the non-divided variables.

share|improve this answer
Could you please explain how this answer is connected to PCA? Indeed, what do your two equations mean? –  whuber Nov 14 '12 at 13:31
As I understand his question, he might want to run PCA on these new variables instead of the "divided" attributes. To cite the question: "any way to handle them together, or group them for PCA" –  Anony-Mousse Nov 14 '12 at 15:05
I see now: you are summing values, so that the PCA is tantamount to using vertically averaged variable values. (At first the "Var" looked like you were taking variances somehow.) There's an ecological fallacy lurking here: that's the problem with your recommendation. –  whuber Nov 14 '12 at 15:53
Summing would not work, the variables would loose their meaning. The depth is an important point in the data, where one of the variables starts to increase or decrease is the key in the study. I was wondering about it a lot, reading literature etc, and i came up with the idea to fit splines into the variables and cluster the groups based on their splines. –  user1775772 Nov 14 '12 at 18:14
Drop it for PCA, but work with the full data later on maybe? –  Anony-Mousse Nov 14 '12 at 18:15
show 1 more comment

A data driven (and thus probably not so very good) approach

Calculate four correlation matrices: One for each layer and one for the pooled data (three lines per sample). If they all look quite similar, run a PCA based on the correlation matrix of the pooled sample and go on with the first few PCs.

Instead of comparing the four correlation matrices, you could also consider the four loading matrices of the corresponding PCAs and compare the loadings of the first few PCs. This is much easier if you have lots of variables.

share|improve this answer
add comment

I am not sure I understand the question correctly. Here is what I understand: you have some number $N$ of soil samples, and for each there are measurements of $D$ variables (like, e.g., pH or density), and each measurement is done at $K=3$ depth layers. You want to do PCA to decrease the number of variables, but you want all layers to be somehow represented "equally".

Note that there are two ways to view these data: as $3N$ points in $D$-dimensional space, or as $N$ points in $3D$-dimensional space. From what you say ("For instance I do not want to get rid of a layer") it seems to me that you rather have the second view, i.e. you want to do the PCA on $3D$ variables and use only leading PCs for whatever purpose you have. However, you want "to handle properties together, no matter what the depth is". One way to interpret it is to say that you want the coefficients (loadings) of each variable be exactly the same for each layer. This means that you effectively consider only $D$-dimensional space (instead of $3D$-dimensional), and the problem becomes mathematically equivalent to pooling your samples across layers (i.e. taking $3N$ data points) and doing a single PCA in $D$ dimensions. It is as easy as that.

If you do not want to be so restrictive, and are happy to allow loadings to differ across layers, then you need to formulate more precisely what you mean by "handling layers together".

share|improve this answer
add comment

Your Answer


By posting your answer, you agree to the privacy policy and terms of service.

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