The p value is calculated using statistical tests such as the t-test, ANOVA, or chi-square test, depending on the type of data and the research question. These tests compare the observed data to what would be expected under the null hypothesis and compute the probability of obtaining the observed results if the null hypothesis were true.