#Hypothesis testing
data1 <- read.csv(file.choose(),header=T)
attach(data1)
boxplot(Underweight)
sampleU=152
sd=10.9328
meanU=13.50305
alpha=0.05
mew=8
z=(meanU-mew)/(sd/sqrt(sampleU))
z
z.alpha=qnorm(1-(alpha/2))
c(-z.alpha,z.alpha)
pval=2*pnorm(z)
pval
#recheck
t.test(Underweight,mu=8,alternative="two.sided",conf.level=0.99)
test <-t.test(Underweight,mu=8,alternative="two.sided",conf.level=0.99)

#correlation
class(Income.Classification)
class (Wasting)
model <- lm(Wasting~Income.Classification)
attributes(model)
model$coefficients
abline(model,col=2,lwd=3)
plot(Income.Classification,Wasting,main="Scatterplot",las=1)
cor(Income.Classification,Wasting,method="pearson")
cor.test(Income.Classification,Wasting,method="pearson",alt="two.sided")

#regression
mod <- lm(Overweight~Severe.Wasting)
attributes(mod)
mod$coefficients
plot(Overweight,Severe.Wasting,main="Scatterplot")
abline(mod,col=2,lwd=3)
confint(mod,level=0.99)
summary(mod)

#anova
boxplot(Overweight~Underweight)
aov(Overweight~Underweight)
Anova1<-aov(Overweight~Underweight)
summary(Anova1)
attributes(Anova1)
Anova1$coefficients
summary(Anova1)

#Goodness-of-fit test
table(Income.Classification)
tab=table(Income.Classification)
barplot(tab, beside=T,legend=T,xlab="Income Classification",ylab="Frequency")
alpha<- 0.05
qchisq(alpha,df=3,lower.tail=FALSE)
chisq.test(tab,correct=F)
