Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

T Test #7

Open
aditbala99 opened this issue Mar 21, 2023 · 0 comments
Open

T Test #7

aditbala99 opened this issue Mar 21, 2023 · 0 comments

Comments

@aditbala99
Copy link

library(caTools)
set.seed(123)
split = datan[sample(nrow(datan), size=20), ]
alpha = 0.05
u = mean(datan$median_house_value)
n = length(split$median_house_value)
xbar = mean(split$median_house_value)
s = sd(split$median_house_value)
t_val = abs((xbar - u)/(s/sqrt(n)))
p_val = 2 * pt(t_val, df = (n - 1), lower.tail = FALSE)
cat('The t-value for the distribution is ', t_val)
The t-value for the distribution is 2.248966
cat('The p-value for the distribution is ', p_val)
The p-value for the distribution is 0.03657011
if(p_val <= alpha){

  • print('Reject the NULL hypothesis')
  • } else{
  • print('Not able to reject NULL hypothesis')
  • }
    [1] "Reject the NULL hypothesis"

ci = 0.9
alpha = 1 - ci
aplha = alpha/2
mu = mean(datan$median_house_value)
n = length(split$median_house_value)
xbar = mean(split$median_house_value)
s = sd(split$median_house_value)
#t_val = abs((xbar - mu)/(s/sqrt(n)))
t_val = qt(0.95,df=(n-1))
lower <- xbar-(t_val*(s/sqrt(n)))
upper <- xbar+(t_val*(s/sqrt(n)))
cat('The lower bound of confidence interval is ', lower)
The lower bound of confidence interval is 114856.1
cat('The upper bound of confidence interval is ', upper)
The upper bound of confidence interval is 194833.9

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant