(힌트. 두 집단 평균 차이 검정)
1) 데이터셋: twomethod.csv
2) 변수: method(교육방법), score(시험성적)
3) 모델: 교육방법(명목) -> 시험성적(비율)
4) 전처리, 결측치 제거
# 1번
data <- read.csv("C:/Rwork/dataset2/twomethod.csv", header = TRUE)
head(data)
summary(data)
result <- subset(data, !is.na(score), c(method, score))
a <- subset(result, method == 1)
b <- subset(result, method == 2)
a1 <- a$score
b1 <- b$score
length(a1)
length(b1)
mean(a1)
mean(b1)
var.test(a1, b1)
t.test(a1, b1, altr = "two.sided",
conf.int = TRUE, conf.level = 0.95)
# 양측검정 결과 p-value < 0.05 이므로 귀무가설 기각
# 시험성적에 차이가 있음.
(힌트. 두 집단 비율 차이 검정)
1) 데이터셋: two_sample.csv
2) 변수: gender(1,2), survey(0, 1)
setwd("C:/Rwork/ ")
data <- read.csv("dataset2/two_sample.csv", header = TRUE)
head(data)
x <- data$gender
y <- data$survey
table(x)
table(y)
table(x, y, useNA = "ifany")
prop.test(c(138, 107), c(174, 126),
alternative = "two.sided", conf.level = 0.95)
prop.test(c(138, 107), c(174, 126),
alter = "greater", conf.level = 0.95)
prop.test(c(138, 107), c(174, 126),
alter = "less", conf.level = 0.95)
# p-value > 0.05 이므로 귀무가설 채택
# 만족도에 차이가 없음
1) 데이터셋: student_height,csv
2) height <- stheight$height
3) 기술통계량 평균 계산
4) 정규성 검정
5) 가설 검정
# 1)
setwd("C:/Rwork/ ")
stheight <- read.csv("dataset2/student_height.csv", header = TRUE)
head(stheight)
# 2)
height <- stheight$height
# 3)
mean(height, na.rm = T)
x1 <- na.omit(height)
mean(x1)
귀무가설(H0):
연구가설(H1):
1) 구매여부 변수: buy (1: 구매하지 않음, 2: 구매)
2) 데이터셋: hdtv.csv
3) 빈도수와 비율 계산
4) 가설 검정
# 귀무가설: 기존 HDTV 판매율과 프로모션 후 HDTV 판매율에 차이가 없다.
# 연구가설: 기존 HDTV 판매율과 프로모션 후 HDTV 판매율에 차이가 있다.
setwd("C:/Rwork/ ")
data <- read.csv("dataset2/hdtv.csv", header = TRUE)
head(data)
x <- data$buy
summary(x)
length(x)
table(x)
library(prettyR)
freq(x)
binom.test(10, 50, p = 0.15)
binom.test(c(10, 50), p = 0.15,
alternative = "greater", conf.level = 0.95)
binom.test(c(10, 50), p = 0.15,
alternative = "less", conf.level = 0.95)
# p value가 0.05 이상이므로 귀무가설 채택
# 판매율에 차이가 없다