# Setup awal
knitr::opts_chunk$set(echo = TRUE)
options(repos = c(CRAN = "https://cloud.r-project.org"))
# Install & load packages
packages <- c("readr","dplyr","tidyr","psych","car","multcomp","biotools", "GGally", "rstatix" )
install.packages(setdiff(packages, rownames(installed.packages())), dependencies=TRUE)
lapply(packages, library, character.only = TRUE)
## Warning: package 'readr' was built under R version 4.4.3
## Warning: package 'dplyr' was built under R version 4.4.3
##
## Attaching package: 'dplyr'
## The following objects are masked from 'package:stats':
##
## filter, lag
## The following objects are masked from 'package:base':
##
## intersect, setdiff, setequal, union
## Warning: package 'tidyr' was built under R version 4.4.3
## Warning: package 'psych' was built under R version 4.4.3
## Warning: package 'car' was built under R version 4.4.3
## Loading required package: carData
## Warning: package 'carData' was built under R version 4.4.3
##
## Attaching package: 'car'
## The following object is masked from 'package:psych':
##
## logit
## The following object is masked from 'package:dplyr':
##
## recode
## Warning: package 'multcomp' was built under R version 4.4.3
## Loading required package: mvtnorm
## Warning: package 'mvtnorm' was built under R version 4.4.3
## Loading required package: survival
## Loading required package: TH.data
## Warning: package 'TH.data' was built under R version 4.4.3
## Loading required package: MASS
##
## Attaching package: 'MASS'
## The following object is masked from 'package:dplyr':
##
## select
##
## Attaching package: 'TH.data'
## The following object is masked from 'package:MASS':
##
## geyser
## Warning: package 'biotools' was built under R version 4.4.3
## ---
## biotools version 4.3
## Warning: package 'GGally' was built under R version 4.4.3
## Loading required package: ggplot2
## Warning: package 'ggplot2' was built under R version 4.4.3
##
## Attaching package: 'ggplot2'
## The following objects are masked from 'package:psych':
##
## %+%, alpha
## Warning: package 'rstatix' was built under R version 4.4.3
##
## Attaching package: 'rstatix'
## The following object is masked from 'package:MASS':
##
## select
## The following object is masked from 'package:stats':
##
## filter
## [[1]]
## [1] "readr" "stats" "graphics" "grDevices" "utils" "datasets"
## [7] "methods" "base"
##
## [[2]]
## [1] "dplyr" "readr" "stats" "graphics" "grDevices" "utils"
## [7] "datasets" "methods" "base"
##
## [[3]]
## [1] "tidyr" "dplyr" "readr" "stats" "graphics" "grDevices"
## [7] "utils" "datasets" "methods" "base"
##
## [[4]]
## [1] "psych" "tidyr" "dplyr" "readr" "stats" "graphics"
## [7] "grDevices" "utils" "datasets" "methods" "base"
##
## [[5]]
## [1] "car" "carData" "psych" "tidyr" "dplyr" "readr"
## [7] "stats" "graphics" "grDevices" "utils" "datasets" "methods"
## [13] "base"
##
## [[6]]
## [1] "multcomp" "TH.data" "MASS" "survival" "mvtnorm" "car"
## [7] "carData" "psych" "tidyr" "dplyr" "readr" "stats"
## [13] "graphics" "grDevices" "utils" "datasets" "methods" "base"
##
## [[7]]
## [1] "biotools" "multcomp" "TH.data" "MASS" "survival" "mvtnorm"
## [7] "car" "carData" "psych" "tidyr" "dplyr" "readr"
## [13] "stats" "graphics" "grDevices" "utils" "datasets" "methods"
## [19] "base"
##
## [[8]]
## [1] "GGally" "ggplot2" "biotools" "multcomp" "TH.data" "MASS"
## [7] "survival" "mvtnorm" "car" "carData" "psych" "tidyr"
## [13] "dplyr" "readr" "stats" "graphics" "grDevices" "utils"
## [19] "datasets" "methods" "base"
##
## [[9]]
## [1] "rstatix" "GGally" "ggplot2" "biotools" "multcomp" "TH.data"
## [7] "MASS" "survival" "mvtnorm" "car" "carData" "psych"
## [13] "tidyr" "dplyr" "readr" "stats" "graphics" "grDevices"
## [19] "utils" "datasets" "methods" "base"
data <- read.table("C:/Users/ella/Downloads/Anmul_Modul2/marketing_campaign.csv",
sep="\t", header=TRUE)
# Lihat data awal
head(data)
## ID Year_Birth Education Marital_Status Income Kidhome Teenhome Dt_Customer
## 1 5524 1957 Graduation Single 58138 0 0 04-09-2012
## 2 2174 1954 Graduation Single 46344 1 1 08-03-2014
## 3 4141 1965 Graduation Together 71613 0 0 21-08-2013
## 4 6182 1984 Graduation Together 26646 1 0 10-02-2014
## 5 5324 1981 PhD Married 58293 1 0 19-01-2014
## 6 7446 1967 Master Together 62513 0 1 09-09-2013
## Recency MntWines MntFruits MntMeatProducts MntFishProducts MntSweetProducts
## 1 58 635 88 546 172 88
## 2 38 11 1 6 2 1
## 3 26 426 49 127 111 21
## 4 26 11 4 20 10 3
## 5 94 173 43 118 46 27
## 6 16 520 42 98 0 42
## MntGoldProds NumDealsPurchases NumWebPurchases NumCatalogPurchases
## 1 88 3 8 10
## 2 6 2 1 1
## 3 42 1 8 2
## 4 5 2 2 0
## 5 15 5 5 3
## 6 14 2 6 4
## NumStorePurchases NumWebVisitsMonth AcceptedCmp3 AcceptedCmp4 AcceptedCmp5
## 1 4 7 0 0 0
## 2 2 5 0 0 0
## 3 10 4 0 0 0
## 4 4 6 0 0 0
## 5 6 5 0 0 0
## 6 10 6 0 0 0
## AcceptedCmp1 AcceptedCmp2 Complain Z_CostContact Z_Revenue Response
## 1 0 0 0 3 11 1
## 2 0 0 0 3 11 0
## 3 0 0 0 3 11 0
## 4 0 0 0 3 11 0
## 5 0 0 0 3 11 0
## 6 0 0 0 3 11 0
str(data)
## 'data.frame': 2240 obs. of 29 variables:
## $ ID : int 5524 2174 4141 6182 5324 7446 965 6177 4855 5899 ...
## $ Year_Birth : int 1957 1954 1965 1984 1981 1967 1971 1985 1974 1950 ...
## $ Education : chr "Graduation" "Graduation" "Graduation" "Graduation" ...
## $ Marital_Status : chr "Single" "Single" "Together" "Together" ...
## $ Income : int 58138 46344 71613 26646 58293 62513 55635 33454 30351 5648 ...
## $ Kidhome : int 0 1 0 1 1 0 0 1 1 1 ...
## $ Teenhome : int 0 1 0 0 0 1 1 0 0 1 ...
## $ Dt_Customer : chr "04-09-2012" "08-03-2014" "21-08-2013" "10-02-2014" ...
## $ Recency : int 58 38 26 26 94 16 34 32 19 68 ...
## $ MntWines : int 635 11 426 11 173 520 235 76 14 28 ...
## $ MntFruits : int 88 1 49 4 43 42 65 10 0 0 ...
## $ MntMeatProducts : int 546 6 127 20 118 98 164 56 24 6 ...
## $ MntFishProducts : int 172 2 111 10 46 0 50 3 3 1 ...
## $ MntSweetProducts : int 88 1 21 3 27 42 49 1 3 1 ...
## $ MntGoldProds : int 88 6 42 5 15 14 27 23 2 13 ...
## $ NumDealsPurchases : int 3 2 1 2 5 2 4 2 1 1 ...
## $ NumWebPurchases : int 8 1 8 2 5 6 7 4 3 1 ...
## $ NumCatalogPurchases: int 10 1 2 0 3 4 3 0 0 0 ...
## $ NumStorePurchases : int 4 2 10 4 6 10 7 4 2 0 ...
## $ NumWebVisitsMonth : int 7 5 4 6 5 6 6 8 9 20 ...
## $ AcceptedCmp3 : int 0 0 0 0 0 0 0 0 0 1 ...
## $ AcceptedCmp4 : int 0 0 0 0 0 0 0 0 0 0 ...
## $ AcceptedCmp5 : int 0 0 0 0 0 0 0 0 0 0 ...
## $ AcceptedCmp1 : int 0 0 0 0 0 0 0 0 0 0 ...
## $ AcceptedCmp2 : int 0 0 0 0 0 0 0 0 0 0 ...
## $ Complain : int 0 0 0 0 0 0 0 0 0 0 ...
## $ Z_CostContact : int 3 3 3 3 3 3 3 3 3 3 ...
## $ Z_Revenue : int 11 11 11 11 11 11 11 11 11 11 ...
## $ Response : int 1 0 0 0 0 0 0 0 1 0 ...
summary(data)
## ID Year_Birth Education Marital_Status
## Min. : 0 Min. :1893 Length:2240 Length:2240
## 1st Qu.: 2828 1st Qu.:1959 Class :character Class :character
## Median : 5458 Median :1970 Mode :character Mode :character
## Mean : 5592 Mean :1969
## 3rd Qu.: 8428 3rd Qu.:1977
## Max. :11191 Max. :1996
##
## Income Kidhome Teenhome Dt_Customer
## Min. : 1730 Min. :0.0000 Min. :0.0000 Length:2240
## 1st Qu.: 35303 1st Qu.:0.0000 1st Qu.:0.0000 Class :character
## Median : 51382 Median :0.0000 Median :0.0000 Mode :character
## Mean : 52247 Mean :0.4442 Mean :0.5062
## 3rd Qu.: 68522 3rd Qu.:1.0000 3rd Qu.:1.0000
## Max. :666666 Max. :2.0000 Max. :2.0000
## NA's :24
## Recency MntWines MntFruits MntMeatProducts
## Min. : 0.00 Min. : 0.00 Min. : 0.0 Min. : 0.0
## 1st Qu.:24.00 1st Qu.: 23.75 1st Qu.: 1.0 1st Qu.: 16.0
## Median :49.00 Median : 173.50 Median : 8.0 Median : 67.0
## Mean :49.11 Mean : 303.94 Mean : 26.3 Mean : 166.9
## 3rd Qu.:74.00 3rd Qu.: 504.25 3rd Qu.: 33.0 3rd Qu.: 232.0
## Max. :99.00 Max. :1493.00 Max. :199.0 Max. :1725.0
##
## MntFishProducts MntSweetProducts MntGoldProds NumDealsPurchases
## Min. : 0.00 Min. : 0.00 Min. : 0.00 Min. : 0.000
## 1st Qu.: 3.00 1st Qu.: 1.00 1st Qu.: 9.00 1st Qu.: 1.000
## Median : 12.00 Median : 8.00 Median : 24.00 Median : 2.000
## Mean : 37.53 Mean : 27.06 Mean : 44.02 Mean : 2.325
## 3rd Qu.: 50.00 3rd Qu.: 33.00 3rd Qu.: 56.00 3rd Qu.: 3.000
## Max. :259.00 Max. :263.00 Max. :362.00 Max. :15.000
##
## NumWebPurchases NumCatalogPurchases NumStorePurchases NumWebVisitsMonth
## Min. : 0.000 Min. : 0.000 Min. : 0.00 Min. : 0.000
## 1st Qu.: 2.000 1st Qu.: 0.000 1st Qu.: 3.00 1st Qu.: 3.000
## Median : 4.000 Median : 2.000 Median : 5.00 Median : 6.000
## Mean : 4.085 Mean : 2.662 Mean : 5.79 Mean : 5.317
## 3rd Qu.: 6.000 3rd Qu.: 4.000 3rd Qu.: 8.00 3rd Qu.: 7.000
## Max. :27.000 Max. :28.000 Max. :13.00 Max. :20.000
##
## AcceptedCmp3 AcceptedCmp4 AcceptedCmp5 AcceptedCmp1
## Min. :0.00000 Min. :0.00000 Min. :0.00000 Min. :0.00000
## 1st Qu.:0.00000 1st Qu.:0.00000 1st Qu.:0.00000 1st Qu.:0.00000
## Median :0.00000 Median :0.00000 Median :0.00000 Median :0.00000
## Mean :0.07277 Mean :0.07455 Mean :0.07277 Mean :0.06429
## 3rd Qu.:0.00000 3rd Qu.:0.00000 3rd Qu.:0.00000 3rd Qu.:0.00000
## Max. :1.00000 Max. :1.00000 Max. :1.00000 Max. :1.00000
##
## AcceptedCmp2 Complain Z_CostContact Z_Revenue
## Min. :0.00000 Min. :0.000000 Min. :3 Min. :11
## 1st Qu.:0.00000 1st Qu.:0.000000 1st Qu.:3 1st Qu.:11
## Median :0.00000 Median :0.000000 Median :3 Median :11
## Mean :0.01339 Mean :0.009375 Mean :3 Mean :11
## 3rd Qu.:0.00000 3rd Qu.:0.000000 3rd Qu.:3 3rd Qu.:11
## Max. :1.00000 Max. :1.000000 Max. :3 Max. :11
##
## Response
## Min. :0.0000
## 1st Qu.:0.0000
## Median :0.0000
## Mean :0.1491
## 3rd Qu.:0.0000
## Max. :1.0000
##
# Hapus missing values
data <- tidyr::drop_na(data, Income, MntWines, MntMeatProducts,
Education, Marital_Status, Kidhome)
# Hitung umur
data$Age <- 2024 - data$Year_Birth
# Pastikan faktor
data$Education <- as.factor(data$Education)
data$Marital_Status <- dplyr::recode(data$Marital_Status,
"Alone"="Single", "YOLO"="Single", "Absurd"="Single")
data$Marital_Status <- as.factor(data$Marital_Status)
data$Kidhome <- as.factor(data$Kidhome)
# Pilih kolom final
data_final <- dplyr::select(data,
MntWines, MntMeatProducts,
Education, Marital_Status, Kidhome,
Income, Age)
# Pastikan DV numeric
data_final$MntWines <- as.numeric(data_final$MntWines)
data_final$MntMeatProducts <- as.numeric(data_final$MntMeatProducts)
Indepedensi Observasi
cat("Independensi diasumsikan karena data berasal dari individu berbeda.\n")
## Independensi diasumsikan karena data berasal dari individu berbeda.
Normalitas
# Shapiro-Wilk per grup Education
data_final %>%
group_by(Education) %>%
shapiro_test(MntWines)
## # A tibble: 5 × 4
## Education variable statistic p
## <fct> <chr> <dbl> <dbl>
## 1 2n Cycle MntWines 0.773 2.62e-16
## 2 Basic MntWines 0.180 9.07e-16
## 3 Graduation MntWines 0.848 2.02e-31
## 4 Master MntWines 0.840 9.06e-19
## 5 PhD MntWines 0.880 6.99e-19
data_final %>%
group_by(Education) %>%
shapiro_test(MntMeatProducts)
## # A tibble: 5 × 4
## Education variable statistic p
## <fct> <chr> <dbl> <dbl>
## 1 2n Cycle MntMeatProducts 0.702 1.24e-18
## 2 Basic MntMeatProducts 0.432 3.79e-13
## 3 Graduation MntMeatProducts 0.757 1.31e-37
## 4 Master MntMeatProducts 0.712 1.40e-24
## 5 PhD MntMeatProducts 0.728 2.78e-27
Korelasi antar Variabel Dependen
cor(data_final[, c("MntWines","MntMeatProducts")])
## MntWines MntMeatProducts
## MntWines 1.00000 0.56886
## MntMeatProducts 0.56886 1.00000
Uji Linearitas (Scatterplot)
GGally::ggpairs(data_final, columns=c("MntWines","MntMeatProducts"),
mapping=ggplot2::aes(color=Education))
GGally::ggpairs(data_final, columns=c("MntWines","MntMeatProducts"),
mapping=ggplot2::aes(color=Marital_Status))
Homogenitas Varians (Levene Test)
leveneTest(MntWines ~ Education, data = data_final)
## Levene's Test for Homogeneity of Variance (center = median)
## Df F value Pr(>F)
## group 4 31.895 < 2.2e-16 ***
## 2211
## ---
## Signif. codes: 0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1
leveneTest(MntMeatProducts ~ Education, data = data_final)
## Levene's Test for Homogeneity of Variance (center = median)
## Df F value Pr(>F)
## group 4 8.3768 1.051e-06 ***
## 2211
## ---
## Signif. codes: 0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1
leveneTest(MntWines ~ Marital_Status, data = data_final)
## Levene's Test for Homogeneity of Variance (center = median)
## Df F value Pr(>F)
## group 4 0.2866 0.8868
## 2211
leveneTest(MntMeatProducts ~ Marital_Status, data = data_final)
## Levene's Test for Homogeneity of Variance (center = median)
## Df F value Pr(>F)
## group 4 1.6043 0.1705
## 2211
Uji Homogenitas Matriks Kovarians (Box’s M Test)
# Hapus NA dulu
data_box <- na.omit(data_final)
# Buat grup interaksi
data_box$group <- interaction(data_box$Education, data_box$Marital_Status)
# Cek jumlah tiap grup
group_count <- table(data_box$group)
# Ambil hanya grup dengan >= 3 data
valid_group <- names(group_count[group_count >= 3])
# Filter data
data_box_filtered <- data_box[data_box$group %in% valid_group, ]
# Jalankan Box's M
boxM(data_box_filtered[, c("MntWines","MntMeatProducts")],
data_box_filtered$group)
##
## Box's M-test for Homogeneity of Covariance Matrices
##
## data: data_box_filtered[, c("MntWines", "MntMeatProducts")]
## Chi-Sq (approx.) = 876.67, df = 66, p-value < 2.2e-16
manova_oneway <- manova(
cbind(MntWines, MntMeatProducts) ~ Education,
data = data_final
)
summary(manova_oneway, test="Pillai")
## Df Pillai approx F num Df den Df Pr(>F)
## Education 4 0.067682 19.361 8 4422 < 2.2e-16 ***
## Residuals 2211
## ---
## Signif. codes: 0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1
summary.aov(manova_oneway)
## Response MntWines :
## Df Sum Sq Mean Sq F value Pr(>F)
## Education 4 12713612 3178403 29.363 < 2.2e-16 ***
## Residuals 2211 239331517 108246
## ---
## Signif. codes: 0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1
##
## Response MntMeatProducts :
## Df Sum Sq Mean Sq F value Pr(>F)
## Education 4 1720315 430079 8.6682 6.113e-07 ***
## Residuals 2211 109700800 49616
## ---
## Signif. codes: 0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1
# Post-hoc jika >2 level
if(length(levels(data_final$Education)) > 2){
TukeyHSD(aov(MntWines ~ Education, data = data_final))
TukeyHSD(aov(MntMeatProducts ~ Education, data = data_final))
}
## Tukey multiple comparisons of means
## 95% family-wise confidence level
##
## Fit: aov(formula = MntMeatProducts ~ Education, data = data_final)
##
## $Education
## diff lwr upr p adj
## Basic-2n Cycle -123.635556 -216.892808 -30.37830 0.0027908
## Graduation-2n Cycle 45.313369 -1.380352 92.00709 0.0621274
## Master-2n Cycle 27.840548 -25.657807 81.33890 0.6143080
## PhD-2n Cycle 34.658046 -16.505856 85.82195 0.3454671
## Graduation-Basic 168.948925 84.218070 253.67978 0.0000006
## Master-Basic 151.476104 62.813326 240.13888 0.0000323
## PhD-Basic 158.293601 71.019556 245.56765 0.0000078
## Master-Graduation -17.472821 -54.139927 19.19428 0.6906790
## PhD-Graduation -10.655323 -43.823795 22.51315 0.9054020
## PhD-Master 6.817498 -35.395272 49.03027 0.9921696
manova_twoway <- manova(
cbind(MntWines, MntMeatProducts) ~ Education * Marital_Status,
data = data_final
)
summary(manova_twoway, test="Pillai")
## Df Pillai approx F num Df den Df Pr(>F)
## Education 4 0.068259 19.3551 8 4382 < 2e-16 ***
## Marital_Status 4 0.006703 1.8419 8 4382 0.06481 .
## Education:Marital_Status 16 0.011868 0.8175 32 4382 0.75604
## Residuals 2191
## ---
## Signif. codes: 0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1
summary.aov(manova_twoway)
## Response MntWines :
## Df Sum Sq Mean Sq F value Pr(>F)
## Education 4 12713612 3178403 29.3460 <2e-16 ***
## Marital_Status 4 299655 74914 0.6917 0.5977
## Education:Marital_Status 16 1729055 108066 0.9978 0.4560
## Residuals 2191 237302806 108308
## ---
## Signif. codes: 0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1
##
## Response MntMeatProducts :
## Df Sum Sq Mean Sq F value Pr(>F)
## Education 4 1720315 430079 8.6727 6.068e-07 ***
## Marital_Status 4 302606 75652 1.5255 0.1921
## Education:Marital_Status 16 747073 46692 0.9416 0.5201
## Residuals 2191 108651120 49590
## ---
## Signif. codes: 0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1
# Post-hoc Education
if(length(levels(data_final$Education)) > 2){
TukeyHSD(aov(MntWines ~ Education, data = data_final))
TukeyHSD(aov(MntMeatProducts ~ Education, data = data_final))
}
## Tukey multiple comparisons of means
## 95% family-wise confidence level
##
## Fit: aov(formula = MntMeatProducts ~ Education, data = data_final)
##
## $Education
## diff lwr upr p adj
## Basic-2n Cycle -123.635556 -216.892808 -30.37830 0.0027908
## Graduation-2n Cycle 45.313369 -1.380352 92.00709 0.0621274
## Master-2n Cycle 27.840548 -25.657807 81.33890 0.6143080
## PhD-2n Cycle 34.658046 -16.505856 85.82195 0.3454671
## Graduation-Basic 168.948925 84.218070 253.67978 0.0000006
## Master-Basic 151.476104 62.813326 240.13888 0.0000323
## PhD-Basic 158.293601 71.019556 245.56765 0.0000078
## Master-Graduation -17.472821 -54.139927 19.19428 0.6906790
## PhD-Graduation -10.655323 -43.823795 22.51315 0.9054020
## PhD-Master 6.817498 -35.395272 49.03027 0.9921696
# Post-hoc Marital_Status
if(length(levels(data_final$Marital_Status)) > 2){
TukeyHSD(aov(MntWines ~ Marital_Status, data = data_final))
TukeyHSD(aov(MntMeatProducts ~ Marital_Status, data = data_final))
}
## Tukey multiple comparisons of means
## 95% family-wise confidence level
##
## Fit: aov(formula = MntMeatProducts ~ Marital_Status, data = data_final)
##
## $Marital_Status
## diff lwr upr p adj
## Married-Divorced 10.689253 -34.61426 55.99277 0.9677481
## Single-Divorced 33.617371 -15.36317 82.59792 0.3318574
## Together-Divorced 16.239875 -31.39544 63.87519 0.8850233
## Widow-Divorced 35.122051 -45.78324 116.02735 0.7599723
## Single-Married 22.928118 -12.01717 57.87341 0.3789035
## Together-Married 5.550622 -27.48273 38.58398 0.9908923
## Widow-Married 24.432798 -48.83211 97.69770 0.8929918
## Together-Single -17.377496 -55.29699 20.54199 0.7212024
## Widow-Single 1.504680 -74.08918 77.09854 0.9999980
## Widow-Together 18.882176 -55.84707 93.61143 0.9587353
# Visualisasi interaksi
interaction.plot(data_final$Education, data_final$Marital_Status, data_final$MntWines)
interaction.plot(data_final$Education, data_final$Marital_Status, data_final$MntMeatProducts)
manova_threeway <- manova(
cbind(MntWines, MntMeatProducts) ~ Education * Marital_Status * Kidhome,
data = data_final
)
summary(manova_threeway, test="Pillai")
## Df Pillai approx F num Df den Df Pr(>F)
## Education 4 0.085334 24.034 8 4314 < 2.2e-16
## Marital_Status 4 0.007168 1.940 8 4314 0.05014
## Kidhome 2 0.305823 194.684 4 4314 < 2.2e-16
## Education:Marital_Status 16 0.016700 1.135 32 4314 0.27509
## Education:Kidhome 7 0.021226 3.305 14 4314 2.708e-05
## Marital_Status:Kidhome 7 0.004800 0.741 14 4314 0.73382
## Education:Marital_Status:Kidhome 18 0.015646 0.945 36 4314 0.56329
## Residuals 2157
##
## Education ***
## Marital_Status .
## Kidhome ***
## Education:Marital_Status
## Education:Kidhome ***
## Marital_Status:Kidhome
## Education:Marital_Status:Kidhome
## Residuals
## ---
## Signif. codes: 0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1
summary.aov(manova_threeway)
## Response MntWines :
## Df Sum Sq Mean Sq F value Pr(>F)
## Education 4 12713612 3178403 40.3991 < 2.2e-16 ***
## Marital_Status 4 299655 74914 0.9522 0.43273
## Kidhome 2 61953868 30976934 393.7328 < 2.2e-16 ***
## Education:Marital_Status 16 1910300 119394 1.5176 0.08474 .
## Education:Kidhome 7 3065066 437867 5.5655 2.273e-06 ***
## Marital_Status:Kidhome 7 377750 53964 0.6859 0.68416
## Education:Marital_Status:Kidhome 18 2022876 112382 1.4284 0.10793
## Residuals 2157 169702001 78675
## ---
## Signif. codes: 0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1
##
## Response MntMeatProducts :
## Df Sum Sq Mean Sq F value Pr(>F)
## Education 4 1720315 430079 10.9145 9.217e-09 ***
## Marital_Status 4 302606 75652 1.9199 0.10447
## Kidhome 2 22160961 11080480 281.2004 < 2.2e-16 ***
## Education:Marital_Status 16 792276 49517 1.2566 0.21672
## Education:Kidhome 7 478438 68348 1.7345 0.09662 .
## Marital_Status:Kidhome 7 273415 39059 0.9912 0.43561
## Education:Marital_Status:Kidhome 18 698205 38789 0.9844 0.47477
## Residuals 2157 84994899 39404
## ---
## Signif. codes: 0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1
Multikolinearitas Covariate
cor(data_final[, c("Age","Income")])
## Age Income
## Age 1.0000000 0.1617914
## Income 0.1617914 1.0000000
Homogenitas Regression Slope
anova(lm(MntWines ~ Education * Age, data = data_final))
## Analysis of Variance Table
##
## Response: MntWines
## Df Sum Sq Mean Sq F value Pr(>F)
## Education 4 12713612 3178403 29.8189 < 2.2e-16 ***
## Age 1 3586992 3586992 33.6521 7.539e-09 ***
## Education:Age 4 606366 151592 1.4222 0.224
## Residuals 2206 235138158 106590
## ---
## Signif. codes: 0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1
anova(lm(MntMeatProducts ~ Education * Age, data = data_final))
## Analysis of Variance Table
##
## Response: MntMeatProducts
## Df Sum Sq Mean Sq F value Pr(>F)
## Education 4 1720315 430079 8.6815 5.965e-07 ***
## Age 1 46127 46127 0.9311 0.3347
## Education:Age 4 369724 92431 1.8658 0.1138
## Residuals 2206 109284949 49540
## ---
## Signif. codes: 0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1
anova(lm(MntWines ~ Education * Income, data = data_final))
## Analysis of Variance Table
##
## Response: MntWines
## Df Sum Sq Mean Sq F value Pr(>F)
## Education 4 12713612 3178403 45.607 < 2.2e-16 ***
## Income 1 76113731 76113731 1092.160 < 2.2e-16 ***
## Education:Income 4 9479400 2369850 34.005 < 2.2e-16 ***
## Residuals 2206 153738386 69691
## ---
## Signif. codes: 0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1
anova(lm(MntMeatProducts ~ Education * Income, data = data_final))
## Analysis of Variance Table
##
## Response: MntMeatProducts
## Df Sum Sq Mean Sq F value Pr(>F)
## Education 4 1720315 430079 13.507 7.03e-11 ***
## Income 1 36685622 36685622 1152.103 < 2.2e-16 ***
## Education:Income 4 2771042 692760 21.756 < 2.2e-16 ***
## Residuals 2206 70244136 31842
## ---
## Signif. codes: 0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1
Validasi Interaksi Covariate
mancova_interaction <- manova(
cbind(MntWines, MntMeatProducts) ~ Education * Age + Education * Income,
data = data_final
)
summary(mancova_interaction)
## Df Pillai approx F num Df den Df Pr(>F)
## Education 4 0.09349 26.98 8 4402 < 2.2e-16 ***
## Age 1 0.02372 26.73 2 2200 3.396e-12 ***
## Income 1 0.43131 834.26 2 2200 < 2.2e-16 ***
## Education:Age 4 0.00577 1.59 8 4402 0.122
## Education:Income 4 0.07588 21.70 8 4402 < 2.2e-16 ***
## Residuals 2201
## ---
## Signif. codes: 0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1
mancova_model <- manova(
cbind(MntWines, MntMeatProducts) ~
Education * Marital_Status + Age + Income,
data = data_final
)
summary(mancova_model, test = "Pillai")
## Df Pillai approx F num Df den Df Pr(>F)
## Education 4 0.08919 25.54 8 4378 < 2.2e-16 ***
## Marital_Status 4 0.00752 2.06 8 4378 0.03579 *
## Age 1 0.02068 23.10 2 2188 1.179e-10 ***
## Income 1 0.41414 773.34 2 2188 < 2.2e-16 ***
## Education:Marital_Status 16 0.01014 0.70 32 4378 0.89827
## Residuals 2189
## ---
## Signif. codes: 0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1
summary.aov(mancova_model)
## Response MntWines :
## Df Sum Sq Mean Sq F value Pr(>F)
## Education 4 12713612 3178403 43.0144 < 2.2e-16 ***
## Marital_Status 4 299655 74914 1.0138 0.3988
## Age 1 3319275 3319275 44.9209 2.601e-11 ***
## Income 1 73090785 73090785 989.1628 < 2.2e-16 ***
## Education:Marital_Status 16 873175 54573 0.7386 0.7561
## Residuals 2189 161748627 73892
## ---
## Signif. codes: 0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1
##
## Response MntMeatProducts :
## Df Sum Sq Mean Sq F value Pr(>F)
## Education 4 1720315 430079 13.0837 1.561e-10 ***
## Marital_Status 4 302606 75652 2.3015 0.05651 .
## Age 1 64583 64583 1.9647 0.16115
## Income 1 36961361 36961361 1124.4294 < 2.2e-16 ***
## Education:Marital_Status 16 417161 26073 0.7932 0.69495
## Residuals 2189 71955089 32871
## ---
## Signif. codes: 0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1