rt-testgrouped-table

R: One-Sided T-Test for grouped data


I have the following problem. My data-set contains 3 variables. The participant ID, the participant's sex and one measured value. The data-set looks something like this:

df <- read.table(text = 'ID sex value
01 m 0.0765
02 f 0.063
03 f 0.0773
04 m 0.0599
05 m 0.0679
06 m 0.067
07 f 0.0728
08 m 0.0589
09 f 0.0699', header=TRUE)

Value one is a list of correlations. So with a one-sample t-test I would like to test whether they are on average significant. Thus, my hypothesis would be μ < or = 0.1. The alternative hypothesis is of course that μ > 0.1.

Please don't try to discuss whether this is a statistically reasonable procedure. I am supposed to perform this exact procedure!

Thank you in advance!


Solution

  • Are you looking for

    t.test(df$value, mu = .1, alternative = "greater")
    #>  One Sample t-test
    #> 
    #> data:  df$value
    #> t = -14.258, df = 8, p-value = 1
    #> alternative hypothesis: true mean is greater than 0.1
    #> 95 percent confidence interval:
    #>  0.06397722        Inf
    #> sample estimates:
    #>  mean of x 
    #> 0.06813333
    

    Created on 2023-11-08 with reprex v2.0.2

    That is alternative hypothesis: true mean is greater than 0.1. Change to alternative = "less" if that's what you are after.

    Rule to remember:

    "If $p$ is low, $H_0$ must go."