Hello is that you are going to learn how to perform the binomial path in our test is used when our variable
of interest is dichotomous and it compares an observed distribution with a theoretical one and tell
us whether there are significant differences between the two distributions.
You probably know that already.
I'm going to use the data frame D-Mo. that contained information about a sample of car owners and I'm
going to check whether the male female proportion in the total population is 50 50.
OK so first of all I'm going to create a count table for the variable gender using the function table.
This table will be called my table.
So let's run this and let's pretend our table is very simple.
So we have two hundred and fifty female subject and two hundred and sixty male subjects.
Now let's round the binomial test using the function by non-test from the stats package.
First of all we have to specify our accounts table which is called My table then the theoretical proportion
which is that zero point fifty.
In our case I'm going to request an alternative test of a story and go to request a two sided test.
So the alternative option will be that two two sided and the confidence level will be at two point ninety
five which is the decolletage
OK let's clear the console first.
And now let's go around the binomial test.
OK.
So the probability of success for our situation is point forty nine 0 1.
You can see it here.
The probability is computed by dividing the number of paths that is two hundred and thirty then two
the total number of trials.
Five hundred and ten.
The number of subsystems is equal to the number of female in the data frame in the group.
Why.
Because remember female is the first category.
Let's check that a bit.
So if we divide the number of premade top just to Hardy then 50 to the total number of cases in the
data frame 5 rather than CAN WE GET point forty nine to 0 1 and we are going to compare the probability
of success with the 50 percent probability which is the theoretical probability the p value of the binomial
test.
Oh sorry First the hypothesis is that the true probability of success is equal to zero point B B.
And the alternative hypothesis shown here is that the true probability of success is not equal to zero
point fifty The value of the binomial test is zero point sixty nine.
It is greater than 5 percent.
So we have to accept the null hypothesis and say that the true probability of success is equal to zero
point fifty
or the program also shows the 95 percent confidence interval for the probability of success which in
our case is zero forty four zero point fifty three.
OK that clear the console and see what to do if we want to check whether the proportion of male subjects
is 60 percent.
In this case here is the option P of the binomial test.
We will put viro point forty white two point forty because if the proportion of the male subjects is
60 percent the proportion of the female subjects is 40 per cent and as you know the probability of success
here.
That the critical probability is equal to the probability of the male of the female subjects right.
So I'm going to run the binomial class in this conditions with the with a 40 percent theoretical proportion.
OK so in the case or the probability of success.
The real problem of success is the same 49 percent.
The number of successes divided by the number of trials but the p value of the binomial test is clearly
lower than 5 percent is very low.
It will lower than 1 percent.
OK so in this case we are going to reject the null hypothesis and say that the true probability of success
is not equal to 40 per cent so the proportion of male objects is not equal to 60 percent.
That's all.
Thank you.