One sample analysis in R-In statistics, we can define the corresponding null hypothesis () as follow:
The corresponding alternative hypotheses () as follow:
column heading should be sample, variable, value
Check outlier detection based on above formula and remove if any
- Null hypothesis: the data are normally distributed.
- Alternative hypothesis: the data are not normally distributed
From the output, the p-value is greater than the significance level 0.05 implying that the distribution of the data is not significantly different from normal distribution. In other words, we can assume the normality.
one-sample t-test is used to compare the mean of one sample to a known standard (or theoretical/hypothetical) mean (μ). one-sample t-test can be used only, when the data are normally distributed.
One sample analysis in R
To perform one-sample t-test, the R function t.test() can be used as follow:
t.test(x, mu = 0, alternative = “two.sided”)
t.test(data$weight, mu = 2, alternative = “less”)
t.test(data$weight, mu = 2, alternative = “greater”)
Non Parametric Method:
The one-sample Wilcoxon signed rank test is a non-parametric alternative to one-sample t-test when the data cannot be assumed to be normally distributed. It’s used to determine whether the median of the sample is equal to a known standard value (i.e. theoretical value).
one-sample Wilcoxon test
To perform one-sample Wilcoxon-test, the R function wilcox.test() can be used as follow:
wilcox.test(x, mu = 0, alternative = “two.sided”)
wilcox.test(data$weight, mu = 2, alternative = “less”)
wilcox.test(data$weight, mu = 2, alternative = “greater”)
The p-value of the test which is less than the significance level alpha = 0.05. We can conclude that the mean weight is significantly different from 2g with a p-value x.