restimation

Test the hypothesis whether the passing percentage of this year is significant lower than 0.5 in R?


I have a vector that contains the grades of this year. And I need to test hypothesis using a 1% significance level and using the p-value.

I tried something like this:

t.test(length(x[x >= 6])/length(x), mu = 0.5, alternative = "less" )

But this gives the error: not enough 'x' observations, I understand this error but I have no idea to solve this differently.


Solution

  • The error comes from the fact that you are not testing the right argument. length(x[x >= 6])/length(x) is a scalar: you are therefore testing if a number is equal to 0.5, which does not make sense. To use a Student's t test you have to give a vector as input.

    If I understand your objective correctly, you seem to want to test if the proportion of grades above 6 is significantly different from 50%. So you don't need a Student's t test, but rather a binomial test. In fact you want to count how many grades are higher than 6 compared to the total number of grades (n). If this is what you are looking for, the following code should allow you to answer your problem.

    prop.test(x = length(x[x>6]), n= length(x), alternative = "less")