I'm using R studio to analyse my data: I have a dataset of zebrafish with independent variables: treatment and sex as in this attached graph. I'm testing the percentage of 600s that the fish spend in the half of the tank containing conspecifics.

I have performed a 2-way anova to test the difference between the variables and the interaction, but I cant work out how to test each variable against the null hypothesis that the fish spend 50% of their time with the conspecifics.

I performed my anova using this script:

sp1 <- lm(percent ~ treatment + sex + treatment*sex, social.prefss)

I'm sorry if I've explained this poorly, I'm only an undergrad and havent got a great grasp of statistics!

EDIT: I've just tried to do a one sample t-test by using this script:


and this is what came out:

One Sample t-test

data: x

t = 9.2808, df = 39, p-value = 2.028e-11

alternative hypothesis: true mean is not equal to 50

95 percent confidence interval:

65.36873 73.93460

sample estimates:

mean of x


  • $\begingroup$ I've flagged this for migration to Stats because it doesn't appear to be about any specific programming language. $\endgroup$
    – underscore_d
    Apr 21, 2016 at 13:21
  • $\begingroup$ sorry, i forgot to say I'm using R $\endgroup$
    – Confused about stats
    Apr 21, 2016 at 13:25
  • $\begingroup$ Please edit to add this tag. I'm still not sure this is a programming Q, possibly more just general stats. Did you have some problem that is specific to R? $\endgroup$
    – underscore_d
    Apr 21, 2016 at 13:27
  • $\begingroup$ I think its both really - I dont know whether its a particular statistical test that I'm looking for, or just a way to add specific parameters to the test I've done? $\endgroup$
    – Confused about stats
    Apr 21, 2016 at 13:29
  • 1
    $\begingroup$ Sadly I've forgotten most of what I ever learned about stats... I think this is less specific to any particular language, and more about the general theory. So, I suspect you'd get a more useful response on the Stats subsite, but hey, I might be wrong. $\endgroup$
    – underscore_d
    Apr 21, 2016 at 13:40

1 Answer 1


Your approach makes a lot of sense and I think you are using the appropriate statistical tests. Really what you are doing is testing a few different research questions, which is why you need a few statistical tests. These are the questions I think you are trying to answer:

1) Does each group of fish spend more time with the conspecific than would be expected by chance? You could conduct a one sample t-test (as you have done). I would do a separate one sample t-test for each cell in your 2 by 2 (Female- Control, Male – Control, Female – Schreckstoff, Male - Schreckstoff). From your graph it looks like you would reject the null hypothesis in most of the cells, but maybe not for the Female – Schreckstoff cell.

2) Is there an interaction between sex and condition? Is there a main effect of sex? Is there a main effect of condition? You can answer these questions by examining the results of your ANOVA test.

Then you would be able to address how sex and condition effect time spent with conspecifics and for each group whether they spend more time than you would expect by chance.


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.