0
$\begingroup$

My project is on the behavioural responses of anemonefish to a camera flash at different depths.

I only had two weeks and no internet to collect my data, please don't judge me too hard!

My behaviours are categorised as :

  • 0 = Freeze
  • 1 = Hide
  • 2 = Come out of anemone

The presence or absence of a response to both camera alone and camera with flash, and what type (if any) it displayed was recorded, alongside what depth they were found at.

Here are the things I would like to find out:

  • If the same species of anemonefish has different response types and lengths at different depths
  • If there is a statistical significance for each species reacting to a camera flash (my control was camera, no flash)
  • If each species is significantly different to each other at certain depths

Please could I have some suggestions to what the CSVs should look like and what statistical tests would be best?

$\endgroup$
0

1 Answer 1

2
$\begingroup$

You have several questions, let's look at one of them to start. At a given depth, does a particular species react differently to Flash and No flash? If you had 100 fish under these conditions, your tabulated real data might look somewhat as follows:

              F   H   C       Total
-----------------------------------
Flash        20  10  20        50
No flash     10  30  10        50
-----------------------------------
Total        30  40  30       100

Then you could do a simple chi-squared test of the independence of the two categorical variables Stimulus (flash or not) and Response (freeze, hide, come out).

DTA = matrix(c(20,10,20,  10,30,10), nrow=2, byrow=T)
chi.out = chisq.test(DTA);  chi.out

        Pearson's Chi-squared test

data:  DTA
X-squared = 16.667, df = 2, p-value = 0.0002404

For my fake data, there is strong evidence, P-value = 0.0024, that the categorical variables are not independent.

The formula for the so-called chi-squared statistic is

$$Q = \sum_{i=1}^r \sum_{j=1}^c \frac{(X_{ij} = E_{ij})^2}{E_{ij}},$$ where $E_i = R_iC_i/G,$ with $R_i = \sum_j X_{ij}$ are row totals of the data matrix, $C_j = \sum_i X_{ij}$ are column totals, and $G = \sum_{i,j} X_{ij}$ is the total number of subjects in the table ($G=100$ above).

In our example the $r \times c$ matrix of expected counts $E_{ij}$ is as follows:

chi.out$exp
     [,1] [,2] [,3]
[1,]   15   20   15
[2,]   15   20   15

If the null hypothesis is true then the test statistic $Q \stackrel{aprx}{\sim} \mathsf{Chisq}(\nu = (r-1)(c-1)),$ provided that the $E_{ij}$ are sufficiently large. (Many authors say something like 'mostly greater than 5 and all greater than 3'). Thus, for our data $\nu = 2,$ and under $H_0$ we have $Q \stackrel{aprx}{\sim} \mathsf{Chisq}(2),$ and P-value $P(Q > 16.667) = 0.00024.$

1 - pchisq(16.667, 2)
[1] 0.0002403294

In R, if some of the $E_{ij}$ are too small, you can request a simulated P-value that does not depend on the chi-squared approximation.


If you are not already familiar with it, you can read about this 'chi-squared test for independence' in many elementary and intermediate-level textbooks.

If you have significant results at this basic first step, some of us might have ideas how best to handle several depths and species. It would be good to know approximate number of fish at each depth-by-species combination, how many depths, and how many species. Please edit results of chi-squared tests and sample sizes into your Question as an Addendum, so everyone can see clearly the current status of your question.

$\endgroup$
3
  • $\begingroup$ Hello, the code for the chi-squared test isn't working for me? Comes up with Error: unexpected numeric constant in "DTA = matrix(c(0,30,7 0" . $\endgroup$ Commented Jul 31, 2018 at 14:50
  • $\begingroup$ Sorry. Missing comma supplied. $\endgroup$
    – BruceET
    Commented Jul 31, 2018 at 15:34
  • $\begingroup$ An attempted edit with different data had all 0's in one column. In that case, leave out that column. $\endgroup$
    – BruceET
    Commented Jul 31, 2018 at 15:39

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.