You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
#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
The text was updated successfully, but these errors were encountered:
[1] "Fail to reject NULL hypothesis"
The text was updated successfully, but these errors were encountered: