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

Z Test #6

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

Z Test #6

aditbala99 opened this issue Mar 21, 2023 · 0 comments

Comments

@aditbala99
Copy link

#Z Test Hyp Testing
set.seed(123)
split = datan[sample(nrow(datan), size=45), ]
alpha = 0.05
u = mean(datan$median_house_value)
n = length(split)
xbar = mean(split$median_house_value)
s = sd(split$median_house_value)
z_val = abs((xbar - u)/(s/sqrt(n)))
?pnorm
p_val = 2 * pnorm(z_val, lower.tail = FALSE)
cat('The t-value for the distribution is ', z_val)
The t-value for the distribution is 0.4888526> cat('The p-value for the distribution is ', p_val)
The p-value for the distribution is 0.624946
if(p_val <= alpha){

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

z <- qnorm(0.975)
lower <- xbar-(z*(s/sqrt(n)))
upper <- xbar+(z*(s/sqrt(n)))
cat('The lower bound of confidence interval is ', lower)
The lower bound of confidence interval is 126338.2
cat('The upper bound of confidence interval is ', upper)
The upper bound of confidence interval is 255226.3

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