Sie sind auf Seite 1von 6

R version 3.3.

0 (2016-05-03) -- "Supposedly Educational"


Copyright (C) 2016 The R Foundation for Statistical Computing
Platform: i386-w64-mingw32/i386 (32-bit)
R is free software and comes with ABSOLUTELY NO WARRANTY.
You are welcome to redistribute it under certain conditions.
Type 'license()' or 'licence()' for distribution details.
R is a collaborative project with many contributors.
Type 'contributors()' for more information and
'citation()' on how to cite R or R packages in publications.
Type 'demo()' for some demos, 'help()' for on-line help, or
'help.start()' for an HTML browser interface to help.
Type 'q()' to quit R.
> A=read.table("C:/Users/user/Desktop/R1.txt",header=T)
> A
himpunan nilai
1 X 18
2 X 9
3 X 16
4 X 20
5 X 15
6 X 12
7 Y 6
8 Y 14
9 Y 13
10 Y 8
11 Y 9
12 Y 8
13 Y 12
> var.test(A$nilai~A$himpunan,data=A)
F test to compare two variances
data: A$nilai by A$himpunan
F = 1.7778, num df = 5, denom df = 6, p-value = 0.503
alternative hypothesis: true ratio of variances is not equal to 1
95 percent confidence interval:
0.2969116 12.4048033
sample estimates:
ratio of variances
1.777778
> #kesimpulan : varians homogen
> t.test(A$nilai~A$himpunan,var.equal=T,alternative=c("greater"),data=A)
Two Sample t-test
data: A$nilai by A$himpunan
t = 2.5749, df = 11, p-value = 0.01291
alternative hypothesis: true difference in means is greater than 0
95 percent confidence interval:
1.512762 Inf
sample estimates:
mean in group X mean in group Y
15 10
> #kesimpulan : myu1>myu2
> sebelum<-c(10,3,4,7,8,5,8,4,5)
> sesudah<-c(11,15,18,17,11,9,4,15,8)
> t.test(sesudah,sebelum,paired=T,alternative=c("greater"))
Paired t-test
data: sesudah and sebelum
t = 3, df = 8, p-value = 0.008536
alternative hypothesis: true difference in means is greater than 0
95 percent confidence interval:
2.280904 Inf
sample estimates:
mean of the differences
6
> C=read.table("C:/Users/user/Desktop/R3.txt",header=T)
> C
test nilai
1 pretest 2
2 pretest 3
3 pretest 3
4 pretest 2
5 pretest 3
6 pretest 3
7 pretest 4
8 pretest 2
9 pretest 4
10 pretest 2
11 posttest 1
12 posttest 1
13 posttest 4
14 posttest 3
15 posttest 4
16 posttest 3
17 posttest 3
18 posttest 3
19 posttest 4
20 posttest 4
>
> t.test(C$nilai~C$test,paired=T,mu=-1,alternative=c("greater"),data=C)
Paired t-test
data: C$nilai by C$test
t = 3.087, df = 9, p-value = 0.006496
alternative hypothesis: true difference in means is greater than -1
95 percent confidence interval:
-0.5125862 Inf
sample estimates:
mean of the differences
0.2
> pretest<-c(2,3,3,2,,3,3,,4,2,4,2)
Error in c(2, 3, 3, 2, , 3, 3, , 4, 2, 4, 2) : argument 5 is empty
> pretest<-c(2,3,3,2,3,3,4,2,4,2)
> posttest<-c(1,1,4,3,4,3,3,3,4,4)
> t.test(C$nilai~C$test,paired=T,mu=-1,alternative=c("less"),data=C)
Paired t-test
data: C$nilai by C$test
t = 3.087, df = 9, p-value = 0.9935
alternative hypothesis: true difference in means is less than -1
95 percent confidence interval:
-Inf 0.9125862
sample estimates:
mean of the differences
0.2
> #kesimpulan : tidak menurunkan
> D=read.table("C:/Users/user/Desktop/R4.txt",header=T)
> D
Y X
1 13 6
2 5 1
3 7 3
4 12 6
5 10 6
6 7 0
7 6 6
8 6 10
9 5 0
10 13 6
11 4 1
> D=read.table("clipboard",header=T)
> D
Y X
1 13 6
2 5 1
3 7 3
4 12 6
5 10 6
6 7 0
7 6 6
8 6 10
9 5 0
10 13 6
11 4 1
> E=read.table("clipboard",header=T)
> E
Y X
1 13 6
2 5 1
3 7 3
4 12 6
5 10 6
6 7 0
7 6 6
8 6 10
9 5 0
10 13 6
11 4 1
> D=read.table("C:/Users/user/Desktop/R4.txt",header=T)
> E
Y X
1 13 6
2 5 1
3 7 3
4 12 6
5 10 6
6 7 0
7 6 6
8 6 10
9 5 0
10 13 6
11 4 1
> cor.test(E$X,E$Y,method="pearson")
Pearson's product-moment correlation
data: E$X and E$Y
t = 1.6824, df = 9, p-value = 0.1268
alternative hypothesis: true correlation is not equal to 0
95 percent confidence interval:
-0.1567191 0.8419640
sample estimates:
cor
0.4891409
> #kesimpulan : h0 diterima
> reg=lm(Y~X,data=E)
> summary(reg)
Call:
lm(formula = Y ~ X, data = E)
Residuals:
Min 1Q Median 3Q Max
-4.985 -1.939 -0.449 2.051 4.036
Coefficients:
Estimate Std. Error t value Pr(>|t|)
(Intercept) 5.9337 1.5442 3.843 0.00395 **
X 0.5051 0.3002 1.682 0.12678
---
Signif. codes: 0 *** 0.001 ** 0.01 * 0.05 . 0.1 1
Residual standard error: 3.104 on 9 degrees of freedom
Multiple R-squared: 0.2393, Adjusted R-squared: 0.1547
F-statistic: 2.831 on 1 and 9 DF, p-value: 0.1268
> #kesimpulan : h0 diterima, tidak berpengaruh nyata
> E=read.table("C:/Users/user/Desktop/R5.txt",header=T)
> E
olahraga merokok
1 candu sering
2 candu sering
3 candu sering
4 tidakpernah sering
5 tidakpernah sering
6 tidakpernah sering
7 tidakpernah sering
8 terkadang sering
9 terkadang sering
10 rutin sering
11 rutin sering
12 rutin sering
13 candu tidakpernah
14 tidakpernah tidakpernah
15 tidakpernah tidakpernah
16 tidakpernah tidakpernah
17 tidakpernah tidakpernah
18 tidakpernah tidakpernah
19 terkadang tidakpernah
20 terkadang tidakpernah
21 terkadang tidakpernah
22 rutin tidakpernah
23 candu terkadang
24 candu terkadang
25 candu terkadang
26 tidakpernah terkadang
27 tidakpernah terkadang
28 terkadang terkadang
29 rutin terkadang
30 rutin terkadang
31 rutin terkadang
32 rutin terkadang
> hubungan=table(E$olahraga,E$merokok)
> hubungan
sering terkadang tidakpernah
candu 3 3 1
rutin 3 4 1
terkadang 2 1 3
tidakpernah 4 2 5
> margin.table(hubungan,1)
candu rutin terkadang tidakpernah
7 8 6 11
> margin.table(hubungan,2)
sering terkadang tidakpernah
12 10 10
> chisq.test(hubungan)
Pearson's Chi-squared test
data: hubungan
X-squared = 5.2263, df = 6, p-value = 0.5151
Warning message:
In chisq.test(hubungan) : Chi-squared approximation may be incorrect
> BMI<-c(27,30,20,27,22,27,24,28,28,32,22,23,21,25,28,29,20,26,29,27,20,27,28,25
,19,24,28,22,23,25)
> KGD<-c(150,178,132,167,140,145,150,146,150,178,148,139,133,142,168,178,132,144
,149,137,130,144,150,168,134,140,145,143,141,140)
> cor.test(KGD,BMI,method="pearson")
Pearson's product-moment correlation
data: KGD and BMI
t = 5.7244, df = 28, p-value = 3.851e-06
alternative hypothesis: true correlation is not equal to 0
95 percent confidence interval:
0.5086165 0.8655984
sample estimates:
cor
0.7343283
> kesimpulan : korelasinya nyata
Error: unexpected symbol in "kesimpulan : korelasinya nyata"
> #kesimpulan : korelasinya nyata
> reg=lm(KGD~BMI)
> summary(reg)
Call:
lm(formula = KGD ~ BMI)
Residuals:
Min 1Q Median 3Q Max
-16.484 -6.512 -2.301 5.386 20.572
Coefficients:
Estimate Std. Error t value Pr(>|t|)
(Intercept) 71.726 13.447 5.334 1.11e-05 ***
BMI 3.028 0.529 5.724 3.85e-06 ***
---
Signif. codes: 0 *** 0.001 ** 0.01 * 0.05 . 0.1 1
Residual standard error: 9.679 on 28 degrees of freedom
Multiple R-squared: 0.5392, Adjusted R-squared: 0.5228
F-statistic: 32.77 on 1 and 28 DF, p-value: 3.851e-06
> reg=lm(BMI~KGD)
> summary(reg)
Call:
lm(formula = BMI ~ KGD)
Residuals:
Min 1Q Median 3Q Max
-3.7557 -1.7215 -0.5639 2.1347 3.7648
Coefficients:
Estimate Std. Error t value Pr(>|t|)
(Intercept) -1.16168 4.62503 -0.251 0.804
KGD 0.17808 0.03111 5.724 3.85e-06 ***
---
Signif. codes: 0 *** 0.001 ** 0.01 * 0.05 . 0.1 1
Residual standard error: 2.347 on 28 degrees of freedom
Multiple R-squared: 0.5392, Adjusted R-squared: 0.5228
F-statistic: 32.77 on 1 and 28 DF, p-value: 3.851e-06
> #kesimpulan : regresi nyata
> #kesimpulan : intercept signifikan
>

Das könnte Ihnen auch gefallen