2024-03-20

Hypothesis Testing

  • A hypothesis is a suggested explanation for a question or problem that could be tested

  • Hypothesis testing is the act of testing whether the hypothesis is true

Null Hypothesis and Alternative Hypothesis

  • A null Hypothesis (\(H_0\)) is a hypothesis that states there is no differences or relationship between two groups or variables

  • A alternative hypothesis (\(H_a\)) is a hypothesis that states the prediction propsed to the research question

Example

We have a database of NBA players statistics since 1980 on Kaggle

##   X          Player height weight                         collage born
## 1 0 Curly Armstrong    180     77              Indiana University 1918
## 2 1    Cliff Barker    188     83          University of Kentucky 1921
## 3 2   Leo Barnhorst    193     86        University of Notre Dame 1924
## 4 3      Ed Bartels    196     88 North Carolina State University 1925
## 5 4     Ralph Beard    178     79          University of Kentucky 1927
## 6 5      Gene Berce    180     79            Marquette University 1926
##    birth_city birth_state
## 1                        
## 2    Yorktown     Indiana
## 3                        
## 4                        
## 5 Hardinsburg    Kentucky
## 6
## [1] 3

Hypothesis

\(H_0: \text{There is no relationship between height and weight}\) \(H_a: \text{Weight and Height positively correlate }\)

Interpret the example

  • To answer the question, Data about weight and heights of a population could be collect and we could propose a linear regression between weight and height to test our hypothesis

  • Use plotply to plot a scatter plot and add a line to see linear relationship between height and weight

Plotly code in R

fig<-plot_ly(data=NBA,x=~weight,y=~height,
        type="scatter",
        mode="markers") %>%
  layout(title="Weight vs. Height",xaxis=list(title="Weight(kg)"),
         yaxis=list(title="Height(cm)")) %>%
  add_lines(x=~weight,
            y=lm(height~weight,
                 data=NBA)$fitted.values,line=list(color="red"))

Result

Conclusion

  • From the graph, it could be observed that height likely increases as weight increases. It could be concluded that we can reject the null hypothesis.

Application in Biology

  • By posing a question and seeking for the answer and explanation for it, biologist study the living world around us.

  • The scientific process typically start with a observation which leads to the question then testable hypothesises. Then, experiments will be design to test the hypothesis

Fertilizer and Tomatoes example

Scenerio: Brand A advertise that their fertilizer will help to produce twice as many tomtoes as usual. Should we use brand A ?

Experiment

  • Purchase 10 tomatoes and divide it into two groups

  • Control group: no fertilizer

  • Experimental group: fertilize with brand A

  • After 10 weeks, calculate the number of tomatoes produced

Hypothesis

Hypothesis: Brand A will produce more tomatoes

Result

Conclusion

  • Brand A produce 20 tomatoes while group with no fertilizer produce 30 tomatoes. This is a sufficient evidence to reject the hypothesis

  • Action: Using fertilizer may not produce larger yield.Future experiment could be conducted with more fertilizer brands and larger sample size to have a more valid conlusion

Disclaimer

Disclaimer: This is just a basis example to go over the concept of hypothesis testing. In fact, to decide whether to reject the null hypothesis or not, a statistic test such as t-test, z-test, chi square test …. may be conducted. At the end, there will be a value called p-value will help to make the decision

Chi-Square test example in biology

  • The Chi-Square test is use to determine the result of an experiment that having expection and observation
  • Formula for Chi- Square test : \[\chi^2 = \sum{\frac{{(\text{Observed Value} - \text{Expected Value})^2}}{\text{Expected Value}}}\]

Example of using Chi-Square test in biology

Context: A experiment was conducted to test if the cross of two plants follow the thereotical proprtion

##          Phenotype Observed Expected
## 1    Round, Yellow      315   312.75
## 2     Round, Green      108   104.25
## 3 Wrinkled, Yellow      101   104.25
## 4  Wrinkled, Green       32    34.75

Hypothesis and Calculate Chi-Square value

Hypothesis: The cross follow the theoretical proportion 9:3:3:1

\(\chi^2=\frac{(315-312.75)^2}{312.75} + \frac{(108-104.25)^2}{104.25}+\frac{(101-104.25)^2}{104.25}+\frac{(32-34.75)^2}{34.75}=0.47\)

P-value

  • After having Chi-Square value, we will use chi-square table to find p-value and compare with 0.05. If it is greater than 0.05, we accept the hypothesis

  • Result: p-value > 0.9 -> do not reject the hypothesis

  • By visualizing the data, we could also observe that the expected values and observed values are really close to each other

Visualize the data

## Using Phenotype as id variables