Total Pageviews

Saturday, 22 July 2023

TESTING OF HYPOTHESES ( R Programming)

 

TESTING HYPOTHESES

a. Null hypothesis significance testing

b. Testing the mean of one sample

c. Testing two means

 

 

A. Null Hypothesis is Significance testing

TESTING HYPOTHESES

To validate a hypothesis, it will consider the entire population into account. But this is not possible practically. Hence, to validate a hypothesis, it will be used random samples from the population. Based on the result from testing over the sample data, it either selects or rejects the hypothesis.

Statistical Hypothesis Testing can be categorized into two types as follows:

 

1. Null Hypothesis – Hypothesis testing is carried out in order to test the validity of a claim or assumption that is made about the larger population. This claim that involves attributes to the trial is known as the Null Hypothesis. The null hypothesis testing is denoted by H0.

2. Alternative Hypothesis – An alternative hypothesis would be considered valid if the null hypothesis is fallacious. The evidence that is present in the trial is basically the data and the statistical computations that accompany it. The alternative hypothesis testing is denoted by H1or Ha.

 

Significance in statistics is a tricky subject. Put simply, significance is the threshold for helping you determine whether you should reject your null hypothesis. We usually express significance thresholds by setting an alpha-level. The alpha-level corresponds to the Type I one error rate, or the probability of rejecting the null when it is in fact true (the false positive rate). We typically compare the results from our experiments to our stated alpha-level by calculating a p-value.

 

 

 

A first glance seems to suggest there may be a real difference between our two groups. Let’s set up our null and alternative hypotheses and then conduct our test.

 

H0: There is no difference in the mean number of ants between groups.

 

Ha: There is a difference in the mean number of ants between groups.


B. One Sample Test



1.224674

Pvalue=2*pt(tstat, df=n-1, lower=FALSE)

> Pvalue

 0.2305533

P value id <0.5 


C. Two Sample t-test


 

library(ggplot2)

 

library(dplyr)

 

library(tidyr)

 

library(Stat2Data)

 

d= read.csv("SandwichAnts.csv")

 

View(d)

 

head(d)

 

ggplot(d, aes(x = Butter, y = Ants, fill = Butter)) +

 

  geom_boxplot() +

 

  scale_fill_manual(values = c("red", "gold2")) +

 

  theme_classic()

 

t.test(Ants ~ Butter, d) 

 Out Put: 

  

 


 

 

Welch Two Sample t-test

 

 

data:  Ants by Butter

 

t = -2.6051, df = 45.956, p-value = 0.01233

 

alternative hypothesis: true difference in means between group no and group yes is not equal to 0

 

95 percent confidence interval:

 

 -19.056335  -2.443665

 

sample estimates:

 

 mean in group no mean in group yes

 

           38.125            48.875


More :

Basics of R Programming 

Program EDA with R 

Shape of Data and Describing Data

Probability Distributions 




Previous

Next



No comments:

Post a Comment