# What statistical tests should I use on my data?

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?

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.