I'm trying to perform a one sample t test with given mean and sd.
Sample mean is 100.5 population mean is 100 population standard deviation is 2.19 and sample size is 50.
although it is relatively simple to perfrom a t-test with a datasheet, I don't know how to perform a t test with given data.
What could be the easiest way to write this code?
I would like to get my t test value, df value and my p-value just like what the code t.test() gives you.
I saw another post similar to this. but it didn't have any solutions.
I couldn't find any explanation for performing one sample t test with given mean and sd.
Since the parameters of the population is known (mu=100, sigma=2.19) and your sample size is greater than 30 (n=50), it is possible to perform either z-test or t-test. However, the base R doesn't have any function to do z-test. There is a z.test() function in the package BSDA (Arnholt and Evans, 2017):
library(BSDA)
z.test (
x = sample_data # a vector of your sample values
,y= NULL # since you are performing one-sample test
,alternative = "two.sided"
,mu = 100 # specified in the null hypothesis
,sigma.x = 2.19
)
Similarly the t.test can be performed using base R function t.test():
t.test(sample_data
, mu=100
, alternative = "two-sided"
)
The question is that which test we might consider to interpret our result?
Hope this could helps.