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
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
The text was updated successfully, but these errors were encountered:
[1] "Reject the NULL hypothesis"
The text was updated successfully, but these errors were encountered: