Download as txt, pdf, or txt
Download as txt, pdf, or txt
You are on page 1of 4

R version 4.3.

1 (2023-06-16 ucrt) -- "Beagle Scouts"


Copyright (C) 2023 The R Foundation for Statistical Computing
Platform: x86_64-w64-mingw32/x64 (64-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.

[Workspace loaded from ~/.RData]

> install.packages("matrixcalc")
WARNING: Rtools is required to build R packages but is not currently installed.
Please download and install the appropriate version of Rtools before proceeding:

https://cran.rstudio.com/bin/windows/Rtools/
Installing package into ‘C:/Users/HP/AppData/Local/R/win-library/4.3’
(as ‘lib’ is unspecified)
trying URL 'https://cran.rstudio.com/bin/windows/contrib/4.3/matrixcalc_1.0-6.zip'
Content type 'application/zip' length 202605 bytes (197 KB)
downloaded 197 KB

package ‘matrixcalc’ successfully unpacked and MD5 sums checked

The downloaded binary packages are in


C:\Users\HP\AppData\Local\Temp\RtmpyYknfZ\downloaded_packages
> install.packages("mvtnorm")
WARNING: Rtools is required to build R packages but is not currently installed.
Please download and install the appropriate version of Rtools before proceeding:

https://cran.rstudio.com/bin/windows/Rtools/
Installing package into ‘C:/Users/HP/AppData/Local/R/win-library/4.3’
(as ‘lib’ is unspecified)
trying URL 'https://cran.rstudio.com/bin/windows/contrib/4.3/mvtnorm_1.2-3.zip'
Content type 'application/zip' length 753582 bytes (735 KB)
downloaded 735 KB

package ‘mvtnorm’ successfully unpacked and MD5 sums checked

The downloaded binary packages are in


C:\Users\HP\AppData\Local\Temp\RtmpyYknfZ\downloaded_packages
> library(matrixcalc)
> library(mvtnorm)
> data_matrix <- matrix(c( c(25, 12), c(30, 14), c(28, 11), c(35, 16), c(32,
+ 13), c(28,
13), c(31, 15), c(29, 12), c(37, 17), c(34, 14) ), nrow = 10,
+ byrow = TRUE)
> data_A <- data_matrix[1:5, ] data_B <- data_matrix[6:10, ]
Error: unexpected symbol in "data_A <- data_matrix[1:5, ] data_B"
> data_matrix <- matrix(c(
+ c(25, 12),
+ c(30, 14),
+ c(28, 11),
+ c(35, 16),
+ c(32, 13),
+ c(28, 13),
+ c(31, 15),
+ c(29, 12),
+ c(37, 17),
+ c(34, 14)
+ ), nrow = 10, byrow = TRUE)
> # Menyimpan data dalam matriks data Cabang A dan Cabang B
> data_A <- data_matrix[1:5, ]
> data_B <- data_matrix[6:10, ]
> # Menyimpan data dalam matriks data Cabang A dan Cabang B
> data_A <- data_matrix[1:5,]
> data_B <- data_matrix[6:10,]
> # Membuat matriks data
> data_matrix <- matrix(c(
+ c(25, 12),
+ c(30, 14),
+ c(28, 11),
+ c(35, 16),
+ c(32, 13),
+ c(28, 13),
+ c(31, 15),
+ c(29, 12),
+ c(37, 17),
+ c(34, 14)
+ ), nrow = 10, byrow = TRUE)
>
> # Menyimpan data dalam matriks data Cabang A dan Cabang B
> data_A <- data_matrix[1:5, ]
> data_B <- data_matrix[6:10, ]
>
> data.matrix()
Error in data.matrix() : argument "frame" is missing, with no default
> data_matrix <- matrix(c(
+ c(25, 12),
+ c(30, 14),
+ c(28, 11),
+ c(35, 16),
+ c(32, 13),
+ c(28, 13),
+ c(31, 15),
+ c(29, 12),
+ c(37, 17),
+ c(34, 14)
+ ), nrow = 10, byrow = TRUE)
> data.matrix()
Error in data.matrix() : argument "frame" is missing, with no default
> data_matrix
[,1] [,2]
[1,] 25 12
[2,] 30 14
[3,] 28 11
[4,] 35 16
[5,] 32 13
[6,] 28 13
[7,] 31 15
[8,] 29 12
[9,] 37 17
[10,] 34 14
> data_A <- data_matrix[1:5, ]
> > data_B <- data_matrix[6:10, ]
Error: unexpected '>' in ">"
> data_A
[,1] [,2]
[1,] 25 12
[2,] 30 14
[3,] 28 11
[4,] 35 16
[5,] 32 13
> data_B
[,1] [,2]
[1,] 28 13
[2,] 31 15
[3,] 29 12
[4,] 37 17
[5,] 34 14
> print(result)
Error: object 'result' not found
> print(data_matrix)
[,1] [,2]
[1,] 25 12
[2,] 30 14
[3,] 28 11
[4,] 35 16
[5,] 32 13
[6,] 28 13
[7,] 31 15
[8,] 29 12
[9,] 37 17
[10,] 34 14
> mean_A <- colMeans(data_A)
> mean_B <- colMeans(data_B)
> mean_A
[1] 30.0 13.2
> mean_B
[1] 31.8 14.2
> S <- cov(data_matrix)
> cov()
Error in cov() : argument "x" is missing, with no default
> cov(data_matrix)
[,1] [,2]
[1,] 13.433333 5.855556
[2,] 5.855556 3.566667
> n_A <- nrow(data_A)
> • n_B <- nrow(data_B)
Error: unexpected input in "•"
> n_A <- nrow(data_A)
> n_B <- nrow(data_B)
> p <- ncol(data_A) # Jumlah variabel
> nrow(data_A)
[1] 5
> nrow(data_B)
[1] 5
> ncol(data_A)
[1] 2
> T_squared <- (n_A * n_B / (n_A + n_B)) * t(mean_A - mean_B) %*% solve(S) %*%
(mean_A - mean_B)
> P-value
Error: object 'P' not found
> T_squared <- (n_A * n_B / (n_A + n_B)) * t(mean_A - mean_B) %*% solve(S) %*%
(mean_A - mean_B)
> P-value
Error: object 'P' not found
> T_squared <- (n_A * n_B / (n_A + n_B)) * t(mean_A - mean_B) %*% solve(S) %*%
(mean_A - mean_B)
> • # Menghitung derajat kebebasan
Error: unexpected input in "•"
> T_squared <- (n_A * n_B / (n_A + n_B)) * t(mean_A - mean_B) %*% solve(S) %*%
(mean_A - mean_B)
> # Menghitung derajat kebebasan
> df1 <- p
> df2 <- n_A + n_B - p - 1
> T_squared
[,1]
[1,] 0.7173251
> p_value <- 1 - pf(T_squared, df1, df2)
> p_value
[,1]
[1,] 0.5207249
> cat("Statistik Uji T Kuadrat Hotelling:", T_squared, "\n")
Statistik Uji T Kuadrat Hotelling: 0.7173251
> cat("Derajat Kebebasan:", df1, df2, "\n")
Derajat Kebebasan: 2 7
> cat("Nilai-p:", p_value, "\n")
Nilai-p: 0.5207249
> if (p_value < 0.05) {
+ cat("Terdapat perbedaan signifikan antara dua kelompok.\n")
+ } else {
+ cat("Tidak terdapat perbedaan signifikan antara dua kelompok.\n")
+ }
Tidak terdapat perbedaan signifikan antara dua kelompok.

You might also like