Tugas Multivariat - Evan Susandi
-
Upload
evan-susandi -
Category
Documents
-
view
16 -
download
1
description
Transcript of Tugas Multivariat - Evan Susandi
Tugas – Mata Kuliah Analisis Multivariat – Evan Susandi
Nama : Evan Susandi
NPM : 140720130003
1. Sebuah percobaan untuk membandingkan dua metode mengajar fisika yang berbeda yang
dilakukan pada “Morning” (pagi), “Afternoon” (siang), dan “Evening” (malam) menggunakan
pendekatan kuliah “Traditional” dan “Discovery”. Tabel berikut menyajikan nilai skor yang
diperoleh dari bidang “mechanical” (M), “heat” (H), “the sound” (S) untuk 24 siswa dalam
penelitian ini.
a. Menganalisis data, pengujian untuk (1) efek dari faktor, (2) pengaruh waktu, dan (3) efek
interaksi. Sertakan dalam analisis Anda tes kesetaraan matriks varians-kovarians dan
normalitas.
Analisis MANOVA dengan menggunakan R software:
#INPUT DATA VARIABEL DEPENDEN
M<-c(30,26,32,31,41,44,40,42,30,32,29,28,51,44,52,50,57,68,58,62,52,50,
50,53)
H<-c(131,126,134,137,104,105,102,102,74,71,69,67,140,145,141,142,120,
130,125,150,91,89,90,95)
S<-c(34,28,33,31,36,31,33,27,35,30,27,29,36,37,30,33,31,35,34,39,33,28,
28,41)
#INPUT DATA VARIABEL FAKTOR
METHOD<-factor(gl(2,12), labels=c("Traditional", "Discovery"))
TIME<-factor(gl(3, 4, len=24), labels=c("Morning", "Afternoon","Evening"))
D<-data.frame(M,H,S,METHOD,TIME)
Tugas – Analisis Multivariat
1. MANOVA 2. MULTIVARIAT REGRESSION
Tugas – Mata Kuliah Analisis Multivariat – Evan Susandi
D
M H S METHOD TIME
1 30 131 34 Traditional Morning
2 26 126 28 Traditional Morning
3 32 134 33 Traditional Morning
4 31 137 31 Traditional Morning
5 41 104 36 Traditional Afternoon
6 44 105 31 Traditional Afternoon
7 40 102 33 Traditional Afternoon
8 42 102 27 Traditional Afternoon
9 30 74 35 Traditional Evening
10 32 71 30 Traditional Evening
11 29 69 27 Traditional Evening
12 28 67 29 Traditional Evening
13 51 140 36 Discovery Morning
14 44 145 37 Discovery Morning
15 52 141 30 Discovery Morning
16 50 142 33 Discovery Morning
17 57 120 31 Discovery Afternoon
18 68 130 35 Discovery Afternoon
19 58 125 34 Discovery Afternoon
20 62 150 39 Discovery Afternoon
21 52 91 33 Discovery Evening
22 50 89 28 Discovery Evening
23 50 90 28 Discovery Evening
24 53 95 41 Discovery Evening
#MEMBUAT MATRIKS VARIABEL DEPENDEN
Y<-cbind(M,H,S)
Y
M H S
[1,] 30 131 34
[2,] 26 126 28
[3,] 32 134 33
[4,] 31 137 31
[5,] 41 104 36
[6,] 44 105 31
[7,] 40 102 33
[8,] 42 102 27
[9,] 30 74 35
[10,] 32 71 30
[11,] 29 69 27
[12,] 28 67 29
[13,] 51 140 36
[14,] 44 145 37
[15,] 52 141 30
[16,] 50 142 33
[17,] 57 120 31
[18,] 68 130 35
[19,] 58 125 34
[20,] 62 150 39
[21,] 52 91 33
[22,] 50 89 28
[23,] 50 90 28
[24,] 53 95 41
#TABEL MANOVA
manova(Y~METHOD*TIME)
Call:
manova(Y ~ METHOD * TIME)
Tugas – Mata Kuliah Analisis Multivariat – Evan Susandi
Terms:
METHOD TIME METHOD:TIME Residuals
resp 1 2440.167 709.333 5.333 158.500
resp 2 2320.667 13030.333 329.333 653.000
resp 3 40.042 15.083 0.583 274.250
Deg. of Freedom 1 2 2 18
Residual standard error: 2.9674166.0231043.903346
Estimated effects may be unbalanced
#UJI MANOVA
summary(manova(Y~METHOD*TIME))
Df Pillai approx F num Df den Df Pr(>F)
METHOD 1 0.94237 87.206 3 16 3.958e-10 ***
TIME 2 1.78667 47.459 6 34 4.141e-15 ***
METHOD:TIME 2 0.46699 1.726 6 34 0.1449
Residuals 18
---
Signif. codes: 0 ‘***’ 0.001 ‘**’ 0.01 ‘*’ 0.05 ‘.’ 0.1 ‘ ’ 1
summary(manova(Y~METHOD*TIME),test="W")
Df Wilks approx F num Df den Df Pr(>F)
METHOD 1 0.05763 87.206 3 16 3.958e-10 ***
TIME 2 0.00585 64.385 6 32 < 2.2e-16 ***
METHOD:TIME 2 0.54903 1.864 6 32 0.1178
Residuals 18
---
Signif. codes: 0 ‘***’ 0.001 ‘**’ 0.01 ‘*’ 0.05 ‘.’ 0.1 ‘ ’ 1
summary(manova(Y~METHOD*TIME),test="H")
Df Hotelling-Lawley approx F num Df den Df Pr(>F)
METHOD 1 16.351 87.206 3 16 3.958e-10 ***
TIME 2 34.455 86.136 6 30 < 2.2e-16 ***
METHOD:TIME 2 0.792 1.981 6 30 0.09997 .
Residuals 18
---
Signif. codes: 0 ‘***’ 0.001 ‘**’ 0.01 ‘*’ 0.05 ‘.’ 0.1 ‘ ’ 1
summary(manova(Y~METHOD*TIME),test="R")
Df Roy approx F num Df den Df Pr(>F)
METHOD 1 16.3510 87.206 3 16 3.958e-10 ***
TIME 2 29.9296 169.601 3 17 7.262e-13 ***
METHOD:TIME 2 0.7535 4.270 3 17 0.02027 *
Residuals 18
---
Signif. codes: 0 ‘***’ 0.001 ‘**’ 0.01 ‘*’ 0.05 ‘.’ 0.1 ‘ ’ 1
#Profile Plots
interaction.plot(TIME,METHOD,M)
interaction.plot(TIME,METHOD,H)
interaction.plot(TIME,METHOD,S)
Tugas – Mata Kuliah Analisis Multivariat – Evan Susandi
#UJI NORMAL MULTIVARIAT
library(mvnormtest)
C <- t(D[1:3])
mshapiro.test(C)
Shapiro-Wilk normality test
data: Z
W = 0.956, p-value = 0.3642
#GRAFIK NORMAL MULTIVARIAT
center <- colMeans(Y) # centroid
n <- nrow(Y); p <- ncol(Y); cov <- cov(Y);
d <- mahalanobis(Y,center,cov) # distances
qqplot(qchisq(ppoints(n),df=p),d,
+ main="QQ Plot Assessing Multivariate Normality",
+ ylab="Mahalanobis D2")
abline(a=0,b=1)
30
35
40
45
50
55
60
TIME
me
an
of M
Morning Afternoon Evening
METHOD
Discovery
Traditional
70
80
90
10
01
10
12
01
30
14
0
TIME
me
an
of H
Morning Afternoon Evening
METHOD
Discovery
Traditional
31
32
33
34
TIME
me
an
of S
Morning Afternoon Evening
METHOD
Discovery
Traditional
Tugas – Mata Kuliah Analisis Multivariat – Evan Susandi
b. Tidak mungkin dilakukan trend analysis, karena tidak terdapat autocorrelation antar waktu.
c. Multivariat Analisis Varians dilakukan untuk membandingkan dua metode mengajar fisika
yang berbeda yang dilakukan pada “Morning” (pagi), “Afternoon” (siang), dan “Evening”
(malam) menggunakan pendekatan kuliah “Traditional” dan “Discovery”. Dengan melakukan
uji asumsi yaitu uji normalitas multivariate dan homogeneity of variances dan covariance.
Terdapat perbedaan yang signifikan dua metode mengajar fisika menggunakan pendekatan
kuliah “Traditional” dan “Discovery” terhadap nilai skor yang diperoleh dari bidang
“mechanical” (M), “heat” (H), “the sound” (S) untuk 24 siswa dalam penelitian ini,
F(3,16)=87.206, p<0.001. Dan juga terdapat perbedaan yang signifikan mengajar yang
dilakukan pada “Morning” (pagi), “Afternoon” (siang), dan “Evening” (malam);
F(6,32)=47.459, p<0.001. Tetapi interaksi antara kedua faktor tidak mempengaruhi variabel
dependennya.
2. Multivariat Regresi
PPVT<-c(68,82,82,91,82,100,100,96,63,91,87,105,87,76,66,74,68,98,63,94,82,
89,80,64,102,71,102,96,55,96,74,78)
RPMT<-c(15,11,13,18,13,15,13,12,10,18,10,21,14,16,14,15,13,16,15,16,18,
15,19,11,20,12,16,13,16,18,15,19)
SAT<-c(24,8,88,82,90,77,58,14,1,98,8,88,4,14,38,4,64,88,14,99,50,36,88,14,
24,24,24,50,8,98,98,50)
0 2 4 6 8 10
02
46
8
QQ Plot Assessing Multivariate Normality
qchisq(ppoints(n), df = p)
Ma
ha
lan
ob
is D
2
Tugas – Mata Kuliah Analisis Multivariat – Evan Susandi
Gr<-c(1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1)
N<-c(0,7,7,6,20,4,6,5,3,16,5,2,1,11,0,5,1,1,0,4,4,1,5,4,5,9,4,5,4,4,2,5)
S<-c(10,3,9,11,7,11,7,2,5,12,3,11,4,5,0,8,6,9,13,6,5,6,8,5,7,4,17,8,7,
7,6,10)
NS<-c(8,21,17,16,21,18,17,11,14,16,17,10,14,18,3,11,19,12,13,14,16,15,14,
11,17,8,21,20,19,10,14,18)
NT<-c(21,28,31,27,28,32,26,22,24,27,25,26,25,27,16,12,28,30,19,27,21,23,
25,16,26,16,27,28,20,23,25,27)
SS<-c(22,21,30,25,16,29,23,23,20,30,24,22,19,22,11,15,23,18,16,19,24,28,
24,22,15,14,31,26,13,19,17,26)
D<-data.frame(PPVT,RPMT,SAT,Gr,N,S,NS,NT,SS)
D
PPVT RPMT SAT Gr N S NS NT SS
1 68 15 24 1 0 10 8 21 22
2 82 11 8 1 7 3 21 28 21
3 82 13 88 1 7 9 17 31 30
4 91 18 82 1 6 11 16 27 25
5 82 13 90 1 20 7 21 28 16
6 100 15 77 1 4 11 18 32 29
7 100 13 58 1 6 7 17 26 23
8 96 12 14 1 5 2 11 22 23
9 63 10 1 1 3 5 14 24 20
10 91 18 98 1 16 12 16 27 30
11 87 10 8 1 5 3 17 25 24
12 105 21 88 1 2 11 10 26 22
13 87 14 4 1 1 4 14 25 19
14 76 16 14 1 11 5 18 27 22
15 66 14 38 1 0 0 3 16 11
16 74 15 4 1 5 8 11 12 15
17 68 13 64 1 1 6 19 28 23
18 98 16 88 1 1 9 12 30 18
19 63 15 14 1 0 13 13 19 16
20 94 16 99 1 4 6 14 27 19
21 82 18 50 1 4 5 16 21 24
22 89 15 36 1 1 6 15 23 28
23 80 19 88 1 5 8 14 25 24
24 64 11 14 1 4 5 11 16 22
25 102 20 24 1 5 7 17 26 15
26 71 12 24 1 9 4 8 16 14
27 102 16 24 1 4 17 21 27 31
28 96 13 50 1 5 8 20 28 26
29 55 16 8 1 4 7 19 20 13
30 96 18 98 1 4 7 10 23 19
31 74 15 98 1 2 6 14 25 17
32 78 19 50 1 5 10 18 27 26
a. R2y1,y3 ~ x1+x2+x3
# Multivariat Linear Regression
fit_a <- lm(cbind(PPVT,SAT)~Gr+N+S, data=D)
summary(fit_a) # show results
Response PPVT :
Call:
lm(formula = PPVT ~ Gr + N + S, data = D)
Tugas – Mata Kuliah Analisis Multivariat – Evan Susandi
Residuals:
Min 1Q Median 3Q Max
-27.6164 -8.7124 0.2078 12.0739 19.0511
Coefficients: (1 not defined because of singularities)
Estimate Std. Error t value Pr(>|t|)
(Intercept) 73.4419 6.1473 11.947 1.01e-12 ***
Gr NA NA NA NA
N 0.3325 0.5669 0.587 0.562
S 1.1207 0.6976 1.606 0.119
---
Signif. codes: 0 ‘***’ 0.001 ‘**’ 0.01 ‘*’ 0.05 ‘.’ 0.1 ‘ ’ 1
Residual standard error: 13.59 on 29 degrees of freedom
Multiple R-squared: 0.09405, Adjusted R-squared: 0.03157
F-statistic: 1.505 on 2 and 29 DF, p-value: 0.2388
Response SAT :
Call:
lm(formula = SAT ~ Gr + N + S, data = D)
Residuals:
Min 1Q Median 3Q Max
-51.997 -26.904 -0.661 22.414 59.123
Coefficients: (1 not defined because of singularities)
Estimate Std. Error t value Pr(>|t|)
(Intercept) 17.064 15.309 1.115 0.2742
Gr NA NA NA NA
N 1.723 1.412 1.220 0.2322
S 3.061 1.737 1.762 0.0886 .
---
Signif. codes: 0 ‘***’ 0.001 ‘**’ 0.01 ‘*’ 0.05 ‘.’ 0.1 ‘ ’ 1
Residual standard error: 33.83 on 29 degrees of freedom
Multiple R-squared: 0.1417, Adjusted R-squared: 0.08248
F-statistic: 2.393 on 2 and 29 DF, p-value: 0.1091
b. R2y1,y2 ~ x1+x3+x4
fit_b <- lm(cbind(PPVT,RPMT)~Gr+S+NS, data=D)
summary(fit_a) # show results
Response PPVT :
Call:
lm(formula = PPVT ~ Gr + N + S, data = D)
Residuals:
Min 1Q Median 3Q Max
-27.6164 -8.7124 0.2078 12.0739 19.0511
Coefficients: (1 not defined because of singularities)
Estimate Std. Error t value Pr(>|t|)
(Intercept) 73.4419 6.1473 11.947 1.01e-12 ***
Gr NA NA NA NA
N 0.3325 0.5669 0.587 0.562
S 1.1207 0.6976 1.606 0.119
---
Tugas – Mata Kuliah Analisis Multivariat – Evan Susandi
Signif. codes: 0 ‘***’ 0.001 ‘**’ 0.01 ‘*’ 0.05 ‘.’ 0.1 ‘ ’ 1
Residual standard error: 13.59 on 29 degrees of freedom
Multiple R-squared: 0.09405, Adjusted R-squared: 0.03157
F-statistic: 1.505 on 2 and 29 DF, p-value: 0.2388
Response SAT :
Call:
lm(formula = SAT ~ Gr + N + S, data = D)
Residuals:
Min 1Q Median 3Q Max
-51.997 -26.904 -0.661 22.414 59.123
Coefficients: (1 not defined because of singularities)
Estimate Std. Error t value Pr(>|t|)
(Intercept) 17.064 15.309 1.115 0.2742
Gr NA NA NA NA
N 1.723 1.412 1.220 0.2322
S 3.061 1.737 1.762 0.0886 .
---
Signif. codes: 0 ‘***’ 0.001 ‘**’ 0.01 ‘*’ 0.05 ‘.’ 0.1 ‘ ’ 1
Residual standard error: 33.83 on 29 degrees of freedom
Multiple R-squared: 0.1417, Adjusted R-squared: 0.08248
F-statistic: 2.393 on 2 and 29 DF, p-value: 0.1091
c. R2y1,y3 ~ x1+x2+x3+x4+x5+x6
fit_c <- lm(cbind(PPVT,SAT)~Gr+N+S+NS+NT+SS, data=D)
summary(fit_a) # show results
Response PPVT :
Call:
lm(formula = PPVT ~ Gr + N + S, data = D)
Residuals:
Min 1Q Median 3Q Max
-27.6164 -8.7124 0.2078 12.0739 19.0511
Coefficients: (1 not defined because of singularities)
Estimate Std. Error t value Pr(>|t|)
(Intercept) 73.4419 6.1473 11.947 1.01e-12 ***
Gr NA NA NA NA
N 0.3325 0.5669 0.587 0.562
S 1.1207 0.6976 1.606 0.119
---
Signif. codes: 0 ‘***’ 0.001 ‘**’ 0.01 ‘*’ 0.05 ‘.’ 0.1 ‘ ’ 1
Residual standard error: 13.59 on 29 degrees of freedom
Multiple R-squared: 0.09405, Adjusted R-squared: 0.03157
F-statistic: 1.505 on 2 and 29 DF, p-value: 0.2388
Response SAT :
Call:
lm(formula = SAT ~ Gr + N + S, data = D)
Residuals:
Tugas – Mata Kuliah Analisis Multivariat – Evan Susandi
Min 1Q Median 3Q Max
-51.997 -26.904 -0.661 22.414 59.123
Coefficients: (1 not defined because of singularities)
Estimate Std. Error t value Pr(>|t|)
(Intercept) 17.064 15.309 1.115 0.2742
Gr NA NA NA NA
N 1.723 1.412 1.220 0.2322
S 3.061 1.737 1.762 0.0886 .
---
Signif. codes: 0 ‘***’ 0.001 ‘**’ 0.01 ‘*’ 0.05 ‘.’ 0.1 ‘ ’ 1
Residual standard error: 33.83 on 29 degrees of freedom
Multiple R-squared: 0.1417, Adjusted R-squared: 0.08248
F-statistic: 2.393 on 2 and 29 DF, p-value: 0.1091