The p value is calculated using statistical tests such as the t-test, ANOVA, or chi-square test. These tests compare observed data with what would be expected under the null hypothesis. The exact calculation depends on the type of data and the specific test used, but it generally involves comparing the test statistic to a theoretical distribution.