2
$\begingroup$

Quick rundown of my data: I have depth measurements from fish with implanted transmitters from two sites (reference and hypoxic) and two seasons (spring and summer). All data is in an Excel spreadsheet. I separated the depths into 1-m bins (0, 1, 2,…6) and then counted the number of detections at each depth range. I have histograms of the depth distribution for each site during each season. How do I statistically compare histograms together to determine if the depth distributions differ with site and/or season (I need comparisons for Ref-Spring x Hyp-Spring, Ref-Summer x Hyp-Summer, Ref-Spring x Ref-Summer, Hyp-Spring x Hyp-Summer)? From my research I’m leaning toward the Kolmogorov-Smirnov test. My problem is that I’m uncertain how to input this data into R and run the actual test.

Partial Depth data table:

enter image description here

There are 56 fish total. The depth values are averages for each fish at that site and season. I used the Wilcoxon test because it was non-normally distributed. I created subsets of the main dataset which grouped depth by site and season and then compared depth between the subsets.

$\endgroup$
4
  • $\begingroup$ Why don't you compare actual depths without binning and making histograms? Why not paired t-test (or Wilcox test) for each season comparing depths from each transmitter? Converting a continuous variable to discrete variable leads to loss of some information. $\endgroup$
    – rnso
    Mar 18, 2015 at 5:47
  • $\begingroup$ I have an uneven number of data points between the seasons. I believe the paired test needs an equal number. I'm not certain if that test will answer the question. Won't that just give me the average depth occupied overall as opposed to how the fish are distributed throughout the depths? $\endgroup$
    – Amaroq
    Mar 18, 2015 at 14:04
  • $\begingroup$ You can find mean or median depth for each transmitter for each season. Then you can apply paired t-test to find if depth differs in different seasons. You can proceed similarly with site. It may be better if you give some sample data to make things clear. $\endgroup$
    – rnso
    Mar 18, 2015 at 14:19
  • $\begingroup$ Ah, sorry. I misunderstood what you said. I have the average depths for each transmitter already so I'll put them in the same sheet and try running the paired-t-test. Thanks. $\endgroup$
    – Amaroq
    Mar 18, 2015 at 14:55

2 Answers 2

1
$\begingroup$

It may better to use quantitative data as it is and use paired t-test (or Wilcoxan test) rather than converting it into categorical data (a process in which some information will be lost). If you have unequal number of readings, you can use mean or median of readings in each transmitter in each season and then use paired t-test to compare between different different seasons.

Edit: If data is not from same fish, unpaired t-test or Wilcoxan test can easily be used to compare 2 value sets of different sites and/or seasons (eg ref_summer vs hyp_summer).

If datadf is the dataframe having your data, then R code to compare depth at 2 sites during summer can be:

with(datadf[datadf$Season=='Summer',], wilcox.test(Depth~Site))

#OR: to compare summer-normoxic vs spring-hypoxic:

wilcox.test(datadf[datadf$Season=='Summer' & datadf$Site=='Normoxic',]$Depth,  
            datadf[datadf$Season=='Spring' & datadf$Site=='Hypoxic',]$Depth   )

Unpaired=FALSE is the default.

$\endgroup$
4
  • $\begingroup$ I'll switch back to the actual depth data but I don't think I can used the paired test. The set of tagged fish at the same site across the seasons are not the same individuals. There was a different set of fish tagged at each site for each season. $\endgroup$
    – Amaroq
    Mar 18, 2015 at 16:32
  • $\begingroup$ It will greatly help if you can post some summary data (as a table) in your question. $\endgroup$
    – rnso
    Mar 18, 2015 at 16:46
  • $\begingroup$ Thanks. I wanted to clarify something. The Wilcoxon rank sum test is the non-parametric equivalent of the two-sample t-test? And it is the equivalent of the Mann-Whitney U-test? I want to make sure I have my terminology straight. $\endgroup$
    – Amaroq
    Mar 18, 2015 at 17:33
  • $\begingroup$ According to help in R: Wilcoxon Rank Sum and Signed Rank Tests: Performs one- and two-sample Wilcoxon tests on vectors of data; the latter is also known as ‘Mann-Whitney’ test. The code is wilcox.test(vector1, vector2, paired=TRUE) or paired=FALSE. Also you should tick my answer as accepted :) $\endgroup$
    – rnso
    Mar 18, 2015 at 17:38
1
$\begingroup$

The problem with the Kolmogorov-Smirnov is you have discretized data. If you use the usual null distribution, it needs continuous data. Binning it makes the test conservative, often to a surprising degree.

However, you can still do a Kolmogorov-Smirnov, by performing a permutation test on the actual discrete CDFs.

There are a variety of ways to get your data into R. If it was me, I'd put just the data (depth bin, and the 4 sets of counts) into a sheet by itself, write as a .csv file and read that in, then use R to turn that back into 4 sets of individual binned depth measurements so that it's suitable for a permutation/randomization test (you can actually do it direct from the bin-counts, but it's conceptually much easier this way).

Whether the K-S is particularly suitable depends on what the alternatives of interest are.

It looks to me like you might need some form of GLM, but the interval censoring (caused by binning) will be a nuisance. (You could treat it as ordered categorical, perhaps.)

$\endgroup$
5
  • $\begingroup$ Hmm, I was looking at some different tests. I did some research but couldn't find a consensus. The Kruskal-Wallis, Mann-Whitney, and even Chi-squared test showed up. I didn't think any of them would be appropriate. $\endgroup$
    – Amaroq
    Mar 18, 2015 at 4:35
  • $\begingroup$ Don't start with tests. Start with what your questions are. What are you trying to find out, exactly? (This question is not answered by a sentence starting with 'compare'.) $\endgroup$
    – Glen_b
    Mar 18, 2015 at 4:39
  • $\begingroup$ I want to see if the depth distributions are different across site and season. The fish I'm researching like deep water. Most of the histograms have 85%+ in the deepest depth bin but the summer hypoxic distribution is more left-skewed. My question is: Is there a significant change in depth distribution across site and season? $\endgroup$
    – Amaroq
    Mar 18, 2015 at 5:08
  • $\begingroup$ The issue you need to get at is that distributions can be different in many ways. If you're interest is primarily on greater depth you may want to focus more on power against that. If it's completely general -- any difference at all is important -- then you may well be fine with a K-S (as long as you don't rely on the usual null distribution, which assumes continuity). If you're more interested in whether some are typically deeper/shallower, that might be better done via something like a Mann-Whitney (which deals with stochastic dominance -- but again you can't treat it as continuous). ... ctd $\endgroup$
    – Glen_b
    Mar 18, 2015 at 5:11
  • $\begingroup$ ctd ... a permutation test can be done in the MW case as well. $\endgroup$
    – Glen_b
    Mar 18, 2015 at 5:14

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.