install.packages(c("car","ggplot2","dplyr","ggcorrplot","lsr","MVN","biotools","tidyr","moments", "heplots","reshape2","gridExtra","moments","psych","scales","viridis","ggpubr","patchwork","nortest"))
## Installing packages into '/cloud/lib/x86_64-pc-linux-gnu-library/4.5'
## (as 'lib' is unspecified)
library(car)
## Loading required package: carData
library(ggplot2)
library(dplyr)
##
## Attaching package: 'dplyr'
## The following object is masked from 'package:car':
##
## recode
## The following objects are masked from 'package:stats':
##
## filter, lag
## The following objects are masked from 'package:base':
##
## intersect, setdiff, setequal, union
library(lsr)
library(MVN)
## Registered S3 method overwritten by 'lme4':
## method from
## na.action.merMod car
library(tidyr)
library(reshape2)
##
## Attaching package: 'reshape2'
## The following object is masked from 'package:tidyr':
##
## smiths
library(gridExtra)
##
## Attaching package: 'gridExtra'
## The following object is masked from 'package:dplyr':
##
## combine
library(moments)
library(psych)
##
## Attaching package: 'psych'
## The following object is masked from 'package:MVN':
##
## mardia
## The following objects are masked from 'package:ggplot2':
##
## %+%, alpha
## The following object is masked from 'package:car':
##
## logit
library(ggcorrplot)
library(scales)
##
## Attaching package: 'scales'
## The following objects are masked from 'package:psych':
##
## alpha, rescale
library(viridis)
## Loading required package: viridisLite
##
## Attaching package: 'viridis'
## The following object is masked from 'package:scales':
##
## viridis_pal
library(ggpubr)
library(patchwork)
library(nortest)
library(heplots)
## Loading required package: broom
## Warning in rgl.init(initValue, onlyNULL): RGL: unable to open X11 display
## Warning: 'rgl.init' failed, will use the null device.
## See '?rgl.useNULL' for ways to avoid this warning.
df <- read.csv("product_positioning.csv")
colnames(df) <- c("Product_ID", "Product_Position", "Price",
"Competitor_Price", "Promotion", "Foot_Traffic",
"Consumer_Demographics", "Product_Category",
"Seasonal", "Sales_Volume")
Nama kolom diubah agar lebih rapi dan konsisten sehingga memudahkan pemanggilan variabel serta menghindari kesalahan akibat penamaan yang tidak standar.
head(df)
## Product_ID Product_Position Price Competitor_Price Promotion Foot_Traffic
## 1 185102 Aisle 17.07 16.16 No Medium
## 2 188771 Aisle 17.41 13.13 No Low
## 3 180176 End-cap 43.16 38.37 Yes Medium
## 4 112917 Aisle 42.26 38.98 Yes Low
## 5 192936 End-cap 47.94 45.59 No Medium
## 6 117590 End-cap 34.50 34.34 No Medium
## Consumer_Demographics Product_Category Seasonal Sales_Volume
## 1 Families Clothing No 2823
## 2 Seniors Clothing No 654
## 3 Young adults Electronics Yes 2220
## 4 Families Clothing Yes 1568
## 5 College students Clothing Yes 2942
## 6 Seniors Clothing No 2968
df$Product_Position <- as.factor(df$Product_Position)
df$Product_Category <- as.factor(df$Product_Category)
df$Sales_Volume <- as.numeric(df$Sales_Volume)
str(df)
## 'data.frame': 1000 obs. of 10 variables:
## $ Product_ID : int 185102 188771 180176 112917 192936 117590 189118 182157 141861 137121 ...
## $ Product_Position : Factor w/ 3 levels "Aisle","End-cap",..: 1 1 2 1 2 2 3 1 1 1 ...
## $ Price : num 17.1 17.4 43.2 42.3 47.9 ...
## $ Competitor_Price : num 16.2 13.1 38.4 39 45.6 ...
## $ Promotion : chr "No" "No" "Yes" "Yes" ...
## $ Foot_Traffic : chr "Medium" "Low" "Medium" "Low" ...
## $ Consumer_Demographics: chr "Families" "Seniors" "Young adults" "Families" ...
## $ Product_Category : Factor w/ 3 levels "Clothing","Electronics",..: 1 1 2 1 1 1 1 1 2 2 ...
## $ Seasonal : chr "No" "No" "Yes" "Yes" ...
## $ Sales_Volume : num 2823 654 2220 1568 2942 ...
summary(df)
## Product_ID Product_Position Price Competitor_Price
## Min. :110033 Aisle :340 Min. : 5.06 Min. : 0.72
## 1st Qu.:133164 End-cap :342 1st Qu.:16.92 1st Qu.:14.28
## Median :154694 Front of Store:318 Median :28.68 Median :26.14
## Mean :154900 Mean :28.02 Mean :25.55
## 3rd Qu.:176954 3rd Qu.:39.33 3rd Qu.:37.12
## Max. :199976 Max. :49.98 Max. :49.85
## Promotion Foot_Traffic Consumer_Demographics
## Length:1000 Length:1000 Length:1000
## Class :character Class :character Class :character
## Mode :character Mode :character Mode :character
##
##
##
## Product_Category Seasonal Sales_Volume
## Clothing :338 Length:1000 Min. : 507
## Electronics:336 Class :character 1st Qu.:1136
## Food :326 Mode :character Median :1792
## Mean :1769
## 3rd Qu.:2364
## Max. :2999
dim(df)
## [1] 1000 10
colSums(is.na(df))
## Product_ID Product_Position Price
## 0 0 0
## Competitor_Price Promotion Foot_Traffic
## 0 0 0
## Consumer_Demographics Product_Category Seasonal
## 0 0 0
## Sales_Volume
## 0
Variabel kategorikal diubah menjadi tipe faktor agar sesuai untuk analisis ANCOVA, sedangkan variabel numerik dikonversi agar dapat digunakan sebagai kovariat. Fungsi tambahan digunakan untuk melihat struktur data, ringkasan statistik, ukuran data, serta memastikan tidak terdapat missing value.
# Palet warna
col_position <- c("Aisle" = "#4E79A7", "End-cap" = "#F28E2B",
"Front of Store" = "#59A14F")
col_category <- c("Clothing" = "#E15759", "Electronics" = "#76B7B2",
"Food" = "#EDC948")
summary(df[, c("Price", "Competitor_Price", "Sales_Volume")])
## Price Competitor_Price Sales_Volume
## Min. : 5.06 Min. : 0.72 Min. : 507
## 1st Qu.:16.92 1st Qu.:14.28 1st Qu.:1136
## Median :28.68 Median :26.14 Median :1792
## Mean :28.02 Mean :25.55 Mean :1769
## 3rd Qu.:39.33 3rd Qu.:37.12 3rd Qu.:2364
## Max. :49.98 Max. :49.85 Max. :2999
dv_vars <- c("Price", "Competitor_Price")
par(mfrow = c(1, 2), mar = c(5, 4, 4, 2))
for (v in dv_vars) {
x <- df[[v]]
hist(x,
breaks = 30,
freq = TRUE,
main = paste(v),
xlab = "Nilai",
ylab = "Frekuensi",
col = "#AFA9EC",
border = "white")
}
par(mfrow = c(1, 1))
Distribusi data variabel Price dan Competitor Price menunjukkan bahwa sebaran data tampak merata dan tidak membentuk distribusi normal. Dari segi visual, distribusi ini tampaknya tidak memenuhi normalitas univariat karena frekuensi tertinggi tidak terjadi di tengah namun tidak sampai membentuk distribusi bimodal. Tidak ditemukan adanya skewness yang signifikan sehingga data cenderung tersebar secara seimbang di seluruh rentang nilai. Hal ini mengindikasikan bahwa tidak terdapat konsentrasi nilai tertentu yang dominan sehingga variasi harga dalam dataset cukup tinggi dan tidak menunjukkan pola distribusi yang menyimpang.
bp1 <- ggplot(df, aes(x = Product_Position, y = Price,
fill = Product_Position)) +
geom_boxplot(outlier.shape = 21, outlier.size = 1.5,
outlier.fill = "white", outlier.color = "gray40",
alpha = 0.8, width = 0.5) +
geom_jitter(width = 0.12, alpha = 0.15, size = 0.7, color = "gray30") +
stat_summary(fun = mean, geom = "point", shape = 23,
size = 3, fill = "white", color = "black") +
scale_fill_manual(values = col_position, guide = "none") +
labs(title = "Price",
x = "Product Position", y = "Price (IDR)") +
theme(axis.text.x = element_text(angle = 15, hjust = 1))
bp2 <- ggplot(df, aes(x = Product_Position, y = Competitor_Price,
fill = Product_Position)) +
geom_boxplot(outlier.shape = 21, outlier.size = 1.5,
outlier.fill = "white", outlier.color = "gray40",
alpha = 0.8, width = 0.5) +
geom_jitter(width = 0.12, alpha = 0.15, size = 0.7, color = "gray30") +
stat_summary(fun = mean, geom = "point", shape = 23,
size = 3, fill = "white", color = "black") +
scale_fill_manual(values = col_position, guide = "none") +
labs(title = "Competitor Price",
x = "Product Position", y = "Competitor Price") +
theme(axis.text.x = element_text(angle = 15, hjust = 1))
grid.arrange(bp1, bp2, ncol = 2)
Berdasarkan boxplot diatas yang menampilkan distribusi berdasarkan product position, terdapat beberapa nilai yang berada di luar whisker yang artinya berpotensi outlier. Namun, hal tersebut tidak serta merta menganggu pemodelan tergantung kasus outliernya. Didapati bahwa jumlah outlier relatif banyak namun variasinya tersebar merata di setiap kelompok sehingga kemungkinan itu variasi alami data dan tidak perlu dilakukan penanganan outlier.
bp3 <- ggplot(df, aes(x = Product_Category, y = Price,
fill = Product_Category)) +
geom_boxplot(outlier.shape = 21, outlier.size = 1.5,
outlier.fill = "white", outlier.color = "gray40",
alpha = 0.8, width = 0.5) +
geom_jitter(width = 0.12, alpha = 0.15, size = 0.7, color = "gray30") +
stat_summary(fun = mean, geom = "point", shape = 23,
size = 3, fill = "white", color = "black") +
scale_fill_manual(values = col_category, guide = "none") +
labs(title = "Price",
x = "Product Category", y = "Price")
bp4 <- ggplot(df, aes(x = Product_Category, y = Competitor_Price,
fill = Product_Category)) +
geom_boxplot(outlier.shape = 21, outlier.size = 1.5,
outlier.fill = "white", outlier.color = "gray40",
alpha = 0.8, width = 0.5) +
geom_jitter(width = 0.12, alpha = 0.15, size = 0.7, color = "gray30") +
stat_summary(fun = mean, geom = "point", shape = 23,
size = 3, fill = "white", color = "black") +
scale_fill_manual(values = col_category, guide = "none") +
labs(title = "Competitor Price",
x = "Product Category", y = "Competitor Price")
grid.arrange(bp3, bp4, ncol = 2)
Tidak berbeda jauh dengan distribusi berdasarkan Product Position dimana pola data memiliki distribusi yang overlap dan mengindikasikan bahwa faktor ini tidak memberikan perbedaan yang jelas antara variabel Price dan Competitor Price.
num_var <- c("Price", "Competitor_Price", "Sales_Volume")
cor_matrix <- cor(df[, num_var], use = "complete.obs", method = "pearson")
cat("\n>> Matriks Korelasi Pearson (semua variabel numerik):\n")
##
## >> Matriks Korelasi Pearson (semua variabel numerik):
print(round(cor_matrix, 4))
## Price Competitor_Price Sales_Volume
## Price 1.0000 0.9939 0.0460
## Competitor_Price 0.9939 1.0000 0.0486
## Sales_Volume 0.0460 0.0486 1.0000
p_heatmap <- ggcorrplot(
cor_matrix,
method = "square",
type = "full",
lab = TRUE,
lab_size = 5,
colors = c("#D73027", "white", "#1A9850"),
outline.color = "white",
ggtheme = theme_minimal(),
title = "Correlation Heatmap"
) +
theme(
plot.title = element_text(face = "bold", hjust = 0.5, size = 13),
axis.text.x = element_text(angle = 15, hjust = 1, face = "bold", size = 10),
axis.text.y = element_text(face = "bold", size = 10)
)
## Warning: `aes_string()` was deprecated in ggplot2 3.0.0.
## ℹ Please use tidy evaluation idioms with `aes()`.
## ℹ See also `vignette("ggplot2-in-packages")` for more information.
## ℹ The deprecated feature was likely used in the ggcorrplot package.
## Please report the issue at <https://github.com/kassambara/ggcorrplot/issues>.
## This warning is displayed once per session.
## Call `lifecycle::last_lifecycle_warnings()` to see where this warning was
## generated.
print(p_heatmap)
Berdasarkan heatmap, korelasi antara variabel Price dengan Competitor Price sangat tinggi yang mengindikasikan kedua variabel membawa informasi yang hampir sama (multikolinearitas). Adapun variabel Sales Volume memiliki korelasi yang sangat rendah dengan variabel lainnya. Hal ini menunjukkan bahwa volume penjualan ternyata tidak dipengaruhi langsung oleh harga.
dv <- c("Price", "Competitor_Price")
Y <- as.matrix(df[, dv])
mardia_result <- mvn(data = Y,
mvn_test = "mardia",
descriptives = FALSE,
tidy = TRUE)
mardia_result
## $multivariate_normality
## Test Statistic p.value Method MVN
## 1 Mardia Skewness 2.559 0.634 asymptotic ✓ Normal
## 2 Mardia Kurtosis -9.806 <0.001 asymptotic ✗ Not normal
##
## $univariate_normality
## Test Variable Statistic p.value Normality
## 1 Anderson-Darling Price 12.29 <0.001 ✗ Not normal
## 2 Anderson-Darling Competitor_Price 11.44 <0.001 ✗ Not normal
##
## $data
## Price Competitor_Price
## [1,] 17.07 16.16
## [2,] 17.41 13.13
## [3,] 43.16 38.37
## [4,] 42.26 38.98
## [5,] 47.94 45.59
## [6,] 34.50 34.34
## [7,] 41.11 40.15
## [8,] 15.75 12.30
## [9,] 30.07 26.75
## [10,] 38.00 33.38
## [11,] 27.42 22.82
## [12,] 12.15 9.39
## [13,] 31.45 28.93
## [14,] 19.81 17.04
## [15,] 15.74 12.80
## [16,] 13.16 12.94
## [17,] 14.58 14.49
## [18,] 21.03 18.54
## [19,] 19.92 14.93
## [20,] 36.20 32.49
## [21,] 27.36 23.03
## [22,] 42.74 40.29
## [23,] 22.16 20.85
## [24,] 48.51 47.56
## [25,] 39.32 37.12
## [26,] 27.81 23.40
## [27,] 49.95 45.65
## [28,] 39.27 35.55
## [29,] 16.92 14.44
## [30,] 35.91 34.74
## [31,] 46.81 43.04
## [32,] 6.10 5.37
## [33,] 37.03 34.90
## [34,] 19.01 18.27
## [35,] 12.30 10.30
## [36,] 11.64 7.89
## [37,] 18.20 16.18
## [38,] 23.93 19.71
## [39,] 21.76 21.09
## [40,] 15.89 12.07
## [41,] 36.13 31.33
## [42,] 34.02 32.31
## [43,] 7.38 3.97
## [44,] 19.30 17.41
## [45,] 7.10 6.84
## [46,] 43.43 38.54
## [47,] 46.72 42.48
## [48,] 36.32 32.95
## [49,] 17.76 16.84
## [50,] 47.78 43.18
## [51,] 34.12 32.94
## [52,] 45.91 42.91
## [53,] 29.30 26.06
## [54,] 39.96 36.05
## [55,] 39.46 35.10
## [56,] 45.07 44.26
## [57,] 13.67 13.18
## [58,] 19.95 19.19
## [59,] 48.71 46.44
## [60,] 34.67 32.60
## [61,] 47.63 42.99
## [62,] 12.03 7.97
## [63,] 36.04 35.59
## [64,] 47.39 47.31
## [65,] 24.71 24.08
## [66,] 36.18 34.02
## [67,] 12.01 10.23
## [68,] 46.04 42.05
## [69,] 10.00 5.63
## [70,] 14.10 13.51
## [71,] 40.15 35.86
## [72,] 30.65 30.08
## [73,] 46.74 46.32
## [74,] 19.16 18.62
## [75,] 31.93 27.22
## [76,] 18.30 14.19
## [77,] 18.72 17.29
## [78,] 21.79 18.92
## [79,] 18.75 17.42
## [80,] 44.20 42.72
## [81,] 42.55 40.35
## [82,] 34.15 30.46
## [83,] 19.24 15.64
## [84,] 8.01 5.34
## [85,] 19.25 17.13
## [86,] 47.16 43.78
## [87,] 38.75 35.22
## [88,] 44.16 42.34
## [89,] 32.35 28.97
## [90,] 40.77 39.73
## [91,] 18.36 15.23
## [92,] 37.40 37.29
## [93,] 10.04 7.54
## [94,] 47.50 46.74
## [95,] 46.56 43.71
## [96,] 40.44 37.89
## [97,] 31.98 27.82
## [98,] 15.92 13.41
## [99,] 48.34 45.21
## [100,] 38.21 37.69
## [101,] 44.97 42.24
## [102,] 19.55 15.77
## [103,] 13.10 8.47
## [104,] 36.73 31.98
## [105,] 42.96 41.45
## [106,] 37.74 34.99
## [107,] 14.80 14.51
## [108,] 5.93 5.84
## [109,] 23.91 21.10
## [110,] 41.46 37.69
## [111,] 10.78 6.39
## [112,] 22.69 21.79
## [113,] 23.25 22.71
## [114,] 16.24 11.33
## [115,] 19.91 16.77
## [116,] 5.41 2.73
## [117,] 13.39 12.76
## [118,] 40.27 37.16
## [119,] 23.84 21.61
## [120,] 20.04 16.05
## [121,] 33.00 29.46
## [122,] 22.25 21.68
## [123,] 17.07 16.29
## [124,] 40.64 36.61
## [125,] 25.47 25.19
## [126,] 42.70 40.51
## [127,] 33.28 31.57
## [128,] 31.59 28.91
## [129,] 24.20 21.33
## [130,] 31.52 28.79
## [131,] 12.31 8.65
## [132,] 28.13 25.72
## [133,] 48.12 43.56
## [134,] 9.52 6.43
## [135,] 18.78 17.11
## [136,] 19.49 16.80
## [137,] 9.07 6.59
## [138,] 5.06 4.51
## [139,] 36.48 36.14
## [140,] 38.63 35.08
## [141,] 36.43 34.91
## [142,] 43.93 41.71
## [143,] 25.07 21.60
## [144,] 39.37 36.12
## [145,] 7.88 6.55
## [146,] 13.94 11.06
## [147,] 44.85 39.96
## [148,] 47.79 45.05
## [149,] 13.34 11.51
## [150,] 21.28 19.52
## [151,] 37.15 35.98
## [152,] 18.58 16.19
## [153,] 37.86 33.73
## [154,] 20.34 17.62
## [155,] 37.62 37.33
## [156,] 16.74 14.22
## [157,] 44.11 43.31
## [158,] 12.89 10.18
## [159,] 37.73 36.70
## [160,] 14.38 11.45
## [161,] 16.99 16.98
## [162,] 39.26 37.80
## [163,] 36.52 31.90
## [164,] 31.39 28.18
## [165,] 46.10 42.07
## [166,] 19.28 17.22
## [167,] 6.22 3.38
## [168,] 40.06 39.41
## [169,] 46.91 46.85
## [170,] 42.42 40.60
## [171,] 30.55 26.84
## [172,] 39.07 37.81
## [173,] 47.47 43.47
## [174,] 10.83 8.48
## [175,] 7.27 4.93
## [176,] 16.91 14.52
## [177,] 41.95 40.42
## [178,] 49.98 45.42
## [179,] 30.53 30.01
## [180,] 5.38 1.63
## [181,] 47.30 46.34
## [182,] 30.02 28.02
## [183,] 31.05 27.10
## [184,] 48.14 47.60
## [185,] 43.99 39.08
## [186,] 48.63 46.11
## [187,] 25.95 21.98
## [188,] 21.73 16.98
## [189,] 19.00 14.94
## [190,] 41.40 39.95
## [191,] 31.62 27.60
## [192,] 36.11 34.17
## [193,] 14.50 13.62
## [194,] 15.27 14.61
## [195,] 16.59 13.03
## [196,] 26.04 23.26
## [197,] 6.25 2.86
## [198,] 10.57 8.54
## [199,] 20.09 19.82
## [200,] 25.15 20.84
## [201,] 23.27 19.05
## [202,] 38.94 37.62
## [203,] 28.87 28.36
## [204,] 34.06 31.39
## [205,] 40.01 37.93
## [206,] 14.36 12.26
## [207,] 28.47 25.90
## [208,] 40.47 39.26
## [209,] 18.03 13.40
## [210,] 21.75 17.58
## [211,] 21.70 18.91
## [212,] 34.72 32.73
## [213,] 23.29 22.91
## [214,] 10.33 6.98
## [215,] 14.58 12.26
## [216,] 35.78 35.35
## [217,] 32.92 31.62
## [218,] 35.29 31.65
## [219,] 34.76 31.95
## [220,] 8.86 3.91
## [221,] 24.95 20.84
## [222,] 46.10 45.49
## [223,] 5.62 2.52
## [224,] 45.12 42.21
## [225,] 36.02 34.82
## [226,] 20.14 16.60
## [227,] 24.71 23.07
## [228,] 17.30 15.83
## [229,] 8.90 4.06
## [230,] 28.70 24.82
## [231,] 49.58 47.36
## [232,] 36.67 32.79
## [233,] 32.06 29.00
## [234,] 17.20 12.21
## [235,] 7.33 2.63
## [236,] 31.45 31.40
## [237,] 41.79 41.50
## [238,] 9.88 6.03
## [239,] 16.27 13.48
## [240,] 43.18 39.47
## [241,] 25.54 20.91
## [242,] 17.09 14.13
## [243,] 37.72 36.32
## [244,] 33.93 30.50
## [245,] 49.12 48.16
## [246,] 14.02 10.78
## [247,] 6.72 3.47
## [248,] 8.55 4.44
## [249,] 13.99 13.20
## [250,] 46.20 45.42
## [251,] 9.28 7.91
## [252,] 46.60 45.81
## [253,] 47.38 42.54
## [254,] 33.26 32.47
## [255,] 23.04 20.07
## [256,] 45.45 41.12
## [257,] 39.56 36.33
## [258,] 41.98 41.17
## [259,] 28.62 27.00
## [260,] 44.16 40.38
## [261,] 17.98 16.78
## [262,] 34.49 31.14
## [263,] 14.56 11.40
## [264,] 44.71 42.78
## [265,] 19.47 14.60
## [266,] 42.69 38.51
## [267,] 33.20 32.63
## [268,] 29.04 27.70
## [269,] 38.60 38.23
## [270,] 15.44 13.43
## [271,] 21.52 19.80
## [272,] 18.39 13.66
## [273,] 19.87 19.74
## [274,] 22.87 19.29
## [275,] 17.82 17.31
## [276,] 44.19 40.88
## [277,] 20.88 17.54
## [278,] 14.83 14.72
## [279,] 20.76 20.72
## [280,] 16.41 11.61
## [281,] 23.22 20.60
## [282,] 11.53 9.07
## [283,] 27.06 22.66
## [284,] 16.63 12.63
## [285,] 37.29 36.95
## [286,] 43.59 39.42
## [287,] 16.63 15.78
## [288,] 25.99 24.45
## [289,] 20.06 16.58
## [290,] 26.67 25.10
## [291,] 31.79 28.82
## [292,] 41.24 36.64
## [293,] 47.84 44.86
## [294,] 12.65 12.61
## [295,] 46.20 45.85
## [296,] 34.97 31.08
## [297,] 29.23 26.88
## [298,] 43.26 40.82
## [299,] 10.16 6.72
## [300,] 10.82 6.80
## [301,] 45.34 41.26
## [302,] 5.58 3.41
## [303,] 26.86 22.38
## [304,] 35.27 33.42
## [305,] 8.84 8.82
## [306,] 36.42 31.86
## [307,] 15.04 10.96
## [308,] 46.48 43.92
## [309,] 44.00 42.40
## [310,] 12.79 11.24
## [311,] 25.99 23.59
## [312,] 19.26 15.59
## [313,] 46.46 43.44
## [314,] 30.51 25.84
## [315,] 5.08 3.54
## [316,] 30.11 26.52
## [317,] 35.69 31.05
## [318,] 33.67 30.14
## [319,] 43.43 41.70
## [320,] 31.14 28.57
## [321,] 47.65 46.81
## [322,] 35.18 34.52
## [323,] 17.24 16.93
## [324,] 17.29 12.32
## [325,] 41.89 38.32
## [326,] 32.26 32.14
## [327,] 7.35 4.09
## [328,] 38.17 36.06
## [329,] 19.12 16.50
## [330,] 31.77 30.30
## [331,] 15.93 14.41
## [332,] 13.33 11.80
## [333,] 17.48 13.88
## [334,] 17.05 12.61
## [335,] 49.80 48.64
## [336,] 28.16 23.86
## [337,] 44.21 43.36
## [338,] 21.33 18.04
## [339,] 11.29 10.38
## [340,] 35.43 33.80
## [341,] 44.35 44.32
## [342,] 13.89 10.90
## [343,] 29.60 25.68
## [344,] 40.96 37.77
## [345,] 41.34 38.01
## [346,] 20.15 15.96
## [347,] 5.80 2.21
## [348,] 23.10 22.97
## [349,] 41.72 41.70
## [350,] 24.04 19.71
## [351,] 5.55 3.40
## [352,] 39.00 34.90
## [353,] 29.75 28.24
## [354,] 32.25 29.15
## [355,] 44.51 43.38
## [356,] 11.85 11.00
## [357,] 33.11 29.20
## [358,] 24.67 21.83
## [359,] 8.90 5.40
## [360,] 37.72 37.14
## [361,] 30.44 28.74
## [362,] 23.18 19.44
## [363,] 9.48 8.56
## [364,] 45.89 42.27
## [365,] 13.57 13.42
## [366,] 44.95 44.81
## [367,] 29.79 28.21
## [368,] 41.01 39.78
## [369,] 49.94 48.76
## [370,] 6.23 4.53
## [371,] 46.45 45.65
## [372,] 29.76 29.19
## [373,] 21.80 21.43
## [374,] 25.49 24.92
## [375,] 14.04 11.23
## [376,] 29.68 28.94
## [377,] 25.92 23.68
## [378,] 36.88 35.72
## [379,] 40.15 39.38
## [380,] 41.60 38.19
## [381,] 42.47 41.94
## [382,] 35.95 31.23
## [383,] 32.37 28.91
## [384,] 13.73 10.09
## [385,] 34.86 33.16
## [386,] 22.20 18.07
## [387,] 32.09 28.27
## [388,] 33.95 33.43
## [389,] 22.29 17.88
## [390,] 30.33 30.04
## [391,] 32.20 31.52
## [392,] 31.86 27.95
## [393,] 13.82 9.57
## [394,] 6.38 5.80
## [395,] 7.24 4.30
## [396,] 6.99 4.25
## [397,] 13.03 9.96
## [398,] 31.46 28.87
## [399,] 37.16 32.19
## [400,] 29.56 29.41
## [401,] 43.14 38.22
## [402,] 6.98 3.65
## [403,] 22.04 18.39
## [404,] 5.25 4.12
## [405,] 7.93 4.75
## [406,] 45.23 43.36
## [407,] 46.61 41.87
## [408,] 25.91 21.37
## [409,] 23.53 22.66
## [410,] 33.88 32.20
## [411,] 29.88 26.09
## [412,] 5.18 1.25
## [413,] 29.65 25.39
## [414,] 5.49 3.93
## [415,] 46.83 43.95
## [416,] 47.21 43.50
## [417,] 30.79 28.50
## [418,] 42.17 41.97
## [419,] 23.26 19.02
## [420,] 38.84 37.74
## [421,] 5.84 1.86
## [422,] 44.13 43.27
## [423,] 40.14 36.20
## [424,] 27.34 22.81
## [425,] 46.23 41.51
## [426,] 33.23 30.17
## [427,] 27.65 27.47
## [428,] 22.42 20.12
## [429,] 30.63 26.41
## [430,] 29.87 25.64
## [431,] 27.54 27.44
## [432,] 6.20 4.47
## [433,] 11.57 8.19
## [434,] 12.44 9.74
## [435,] 49.70 47.27
## [436,] 36.55 31.66
## [437,] 25.44 21.24
## [438,] 27.67 22.78
## [439,] 11.00 6.91
## [440,] 11.03 10.21
## [441,] 30.97 26.40
## [442,] 21.68 19.10
## [443,] 47.46 42.76
## [444,] 34.49 32.89
## [445,] 39.72 36.86
## [446,] 5.85 2.03
## [447,] 26.07 25.02
## [448,] 40.62 37.68
## [449,] 10.30 6.83
## [450,] 31.39 26.78
## [451,] 5.14 3.62
## [452,] 25.89 22.26
## [453,] 43.29 42.64
## [454,] 29.18 28.36
## [455,] 5.90 1.50
## [456,] 44.43 43.93
## [457,] 22.40 19.66
## [458,] 16.36 15.03
## [459,] 26.30 24.58
## [460,] 47.71 46.97
## [461,] 32.67 30.34
## [462,] 34.75 30.57
## [463,] 8.72 5.39
## [464,] 13.15 12.98
## [465,] 10.27 7.41
## [466,] 17.35 17.17
## [467,] 12.05 9.59
## [468,] 7.01 4.71
## [469,] 26.69 22.29
## [470,] 41.92 37.02
## [471,] 43.89 39.28
## [472,] 40.24 37.90
## [473,] 8.71 6.89
## [474,] 14.48 11.50
## [475,] 19.24 16.55
## [476,] 43.91 42.82
## [477,] 39.19 35.94
## [478,] 5.45 4.89
## [479,] 44.39 43.57
## [480,] 23.14 18.42
## [481,] 32.10 27.11
## [482,] 32.33 29.90
## [483,] 43.33 38.66
## [484,] 40.36 39.26
## [485,] 49.25 44.43
## [486,] 43.94 43.83
## [487,] 34.13 34.11
## [488,] 37.02 33.37
## [489,] 35.56 30.73
## [490,] 7.33 6.04
## [491,] 42.63 41.03
## [492,] 24.41 21.22
## [493,] 21.22 19.82
## [494,] 14.59 13.38
## [495,] 14.78 10.60
## [496,] 40.43 35.86
## [497,] 17.43 16.25
## [498,] 9.26 6.45
## [499,] 7.44 5.40
## [500,] 44.09 40.32
## [501,] 37.75 34.49
## [502,] 17.28 14.40
## [503,] 6.81 5.61
## [504,] 32.97 30.24
## [505,] 6.05 1.11
## [506,] 42.95 42.62
## [507,] 17.23 13.46
## [508,] 39.66 39.05
## [509,] 35.63 31.26
## [510,] 31.78 31.35
## [511,] 6.61 5.61
## [512,] 49.74 46.30
## [513,] 21.18 18.05
## [514,] 36.95 34.30
## [515,] 34.22 31.38
## [516,] 26.14 24.73
## [517,] 24.53 23.54
## [518,] 11.77 8.42
## [519,] 28.83 24.60
## [520,] 42.21 38.19
## [521,] 31.74 30.41
## [522,] 13.29 10.20
## [523,] 45.45 42.33
## [524,] 30.48 27.39
## [525,] 17.79 17.61
## [526,] 30.06 29.48
## [527,] 24.79 21.25
## [528,] 16.47 13.41
## [529,] 8.20 4.13
## [530,] 34.36 33.24
## [531,] 22.69 20.50
## [532,] 25.51 22.38
## [533,] 42.31 41.34
## [534,] 35.35 34.40
## [535,] 6.32 5.20
## [536,] 23.16 22.01
## [537,] 45.95 41.25
## [538,] 42.89 38.76
## [539,] 49.98 47.60
## [540,] 33.76 33.19
## [541,] 29.98 28.14
## [542,] 38.80 35.71
## [543,] 8.34 7.22
## [544,] 47.77 44.38
## [545,] 27.09 25.32
## [546,] 26.16 24.53
## [547,] 15.32 13.21
## [548,] 39.87 39.54
## [549,] 31.69 31.54
## [550,] 16.27 15.54
## [551,] 28.08 25.81
## [552,] 11.95 11.03
## [553,] 18.48 17.43
## [554,] 31.72 28.87
## [555,] 29.45 26.60
## [556,] 7.32 7.08
## [557,] 44.47 40.07
## [558,] 13.33 11.68
## [559,] 24.10 19.13
## [560,] 12.05 9.14
## [561,] 25.90 25.70
## [562,] 12.65 11.97
## [563,] 17.79 12.86
## [564,] 23.94 19.70
## [565,] 17.48 12.55
## [566,] 41.60 38.31
## [567,] 49.64 48.84
## [568,] 15.09 12.43
## [569,] 41.97 40.32
## [570,] 33.48 28.94
## [571,] 49.55 49.10
## [572,] 24.64 23.91
## [573,] 40.28 38.37
## [574,] 10.09 5.60
## [575,] 36.71 34.55
## [576,] 18.91 17.76
## [577,] 35.65 31.08
## [578,] 46.97 46.34
## [579,] 17.05 14.80
## [580,] 18.93 18.41
## [581,] 43.59 39.89
## [582,] 34.88 34.60
## [583,] 14.18 13.19
## [584,] 45.50 43.19
## [585,] 47.99 47.59
## [586,] 49.21 48.05
## [587,] 38.69 37.01
## [588,] 42.98 41.61
## [589,] 25.20 22.09
## [590,] 22.22 21.56
## [591,] 36.40 34.38
## [592,] 43.32 39.63
## [593,] 24.39 20.92
## [594,] 16.48 14.74
## [595,] 38.36 35.33
## [596,] 25.94 24.83
## [597,] 15.65 14.23
## [598,] 45.68 45.58
## [599,] 24.17 19.74
## [600,] 24.06 23.01
## [601,] 30.07 29.26
## [602,] 48.21 43.42
## [603,] 18.24 16.68
## [604,] 6.24 2.06
## [605,] 44.32 39.33
## [606,] 38.92 38.34
## [607,] 37.28 36.19
## [608,] 32.51 31.52
## [609,] 46.68 44.47
## [610,] 7.09 5.73
## [611,] 23.22 21.78
## [612,] 28.77 27.43
## [613,] 33.95 29.32
## [614,] 33.32 32.96
## [615,] 27.33 25.41
## [616,] 24.22 23.04
## [617,] 9.78 4.93
## [618,] 19.57 18.88
## [619,] 15.85 14.41
## [620,] 47.72 44.03
## [621,] 18.93 17.81
## [622,] 15.38 12.41
## [623,] 6.39 5.77
## [624,] 47.60 45.10
## [625,] 41.53 37.25
## [626,] 24.30 23.86
## [627,] 37.84 37.37
## [628,] 41.39 39.60
## [629,] 11.47 7.46
## [630,] 6.39 3.99
## [631,] 40.99 37.67
## [632,] 40.07 39.77
## [633,] 47.20 44.38
## [634,] 44.42 43.37
## [635,] 9.29 5.86
## [636,] 38.26 38.26
## [637,] 36.45 32.20
## [638,] 42.68 42.34
## [639,] 37.76 36.64
## [640,] 47.47 45.66
## [641,] 30.28 27.84
## [642,] 15.48 10.95
## [643,] 30.51 26.82
## [644,] 13.38 11.17
## [645,] 40.39 36.59
## [646,] 36.30 33.01
## [647,] 42.19 38.49
## [648,] 19.15 14.29
## [649,] 9.07 4.34
## [650,] 6.71 4.23
## [651,] 9.99 6.10
## [652,] 16.46 15.04
## [653,] 21.67 19.04
## [654,] 14.09 10.27
## [655,] 22.48 20.50
## [656,] 17.06 12.21
## [657,] 20.21 19.05
## [658,] 19.14 14.98
## [659,] 43.33 39.35
## [660,] 24.47 20.48
## [661,] 9.47 6.10
## [662,] 16.68 16.44
## [663,] 28.83 25.50
## [664,] 35.54 33.58
## [665,] 42.47 40.12
## [666,] 49.97 45.21
## [667,] 11.43 8.77
## [668,] 10.54 5.99
## [669,] 40.75 37.55
## [670,] 38.57 34.84
## [671,] 32.42 27.95
## [672,] 43.81 39.96
## [673,] 5.15 5.01
## [674,] 36.87 34.47
## [675,] 27.14 23.32
## [676,] 46.16 42.84
## [677,] 44.95 43.96
## [678,] 44.38 40.68
## [679,] 25.59 24.27
## [680,] 11.02 10.23
## [681,] 39.31 37.18
## [682,] 20.50 17.08
## [683,] 13.49 10.10
## [684,] 15.50 13.36
## [685,] 5.66 1.62
## [686,] 9.71 5.57
## [687,] 17.05 16.01
## [688,] 33.53 28.67
## [689,] 11.42 8.54
## [690,] 44.88 41.36
## [691,] 15.84 11.45
## [692,] 16.46 13.91
## [693,] 22.29 21.55
## [694,] 30.90 29.78
## [695,] 20.54 17.99
## [696,] 34.96 34.77
## [697,] 28.81 24.72
## [698,] 45.28 42.69
## [699,] 15.14 11.49
## [700,] 41.12 39.94
## [701,] 40.01 38.86
## [702,] 5.11 1.28
## [703,] 45.47 41.47
## [704,] 25.20 20.82
## [705,] 41.00 40.35
## [706,] 6.66 3.09
## [707,] 28.09 26.00
## [708,] 33.94 32.88
## [709,] 42.48 42.36
## [710,] 46.95 46.69
## [711,] 15.37 13.64
## [712,] 18.25 14.38
## [713,] 42.43 41.76
## [714,] 43.83 42.62
## [715,] 47.98 44.05
## [716,] 36.29 33.69
## [717,] 19.87 19.65
## [718,] 42.94 39.98
## [719,] 34.32 30.13
## [720,] 36.86 35.27
## [721,] 34.07 30.82
## [722,] 23.99 22.54
## [723,] 11.38 8.60
## [724,] 24.18 21.23
## [725,] 30.37 26.67
## [726,] 38.81 36.77
## [727,] 8.52 5.11
## [728,] 10.78 8.58
## [729,] 18.90 18.48
## [730,] 36.26 34.24
## [731,] 46.72 45.02
## [732,] 7.28 6.56
## [733,] 41.85 37.04
## [734,] 28.57 26.47
## [735,] 10.66 6.87
## [736,] 11.75 9.84
## [737,] 49.77 49.66
## [738,] 38.90 35.38
## [739,] 15.86 11.57
## [740,] 45.15 42.00
## [741,] 46.06 43.67
## [742,] 37.69 36.14
## [743,] 47.81 46.20
## [744,] 36.15 31.58
## [745,] 28.97 24.67
## [746,] 40.65 36.48
## [747,] 13.60 8.67
## [748,] 5.76 3.84
## [749,] 9.26 5.65
## [750,] 48.35 47.10
## [751,] 33.86 31.90
## [752,] 40.56 38.99
## [753,] 45.61 43.04
## [754,] 11.29 9.86
## [755,] 13.49 11.04
## [756,] 41.44 39.26
## [757,] 18.65 15.73
## [758,] 25.36 24.79
## [759,] 49.98 49.85
## [760,] 37.43 33.22
## [761,] 30.93 30.15
## [762,] 20.40 15.70
## [763,] 25.47 22.73
## [764,] 38.68 35.89
## [765,] 37.79 34.04
## [766,] 8.52 4.55
## [767,] 30.51 27.48
## [768,] 11.04 9.15
## [769,] 36.36 31.41
## [770,] 11.48 10.41
## [771,] 10.77 9.98
## [772,] 5.73 3.94
## [773,] 33.16 28.80
## [774,] 25.65 25.20
## [775,] 10.28 7.76
## [776,] 8.31 5.35
## [777,] 27.54 24.56
## [778,] 5.17 0.72
## [779,] 33.05 31.73
## [780,] 19.66 18.89
## [781,] 15.42 13.77
## [782,] 19.49 16.81
## [783,] 47.92 44.15
## [784,] 14.85 12.52
## [785,] 36.77 35.21
## [786,] 37.13 35.06
## [787,] 9.26 9.07
## [788,] 27.59 26.89
## [789,] 47.41 45.53
## [790,] 36.75 36.09
## [791,] 12.09 10.47
## [792,] 37.37 32.70
## [793,] 27.39 27.22
## [794,] 37.53 35.46
## [795,] 11.36 6.76
## [796,] 36.21 33.76
## [797,] 43.02 42.63
## [798,] 47.18 46.66
## [799,] 5.08 3.34
## [800,] 32.98 28.94
## [801,] 12.65 9.75
## [802,] 38.10 34.70
## [803,] 21.92 18.00
## [804,] 30.31 29.05
## [805,] 49.34 46.31
## [806,] 22.05 19.73
## [807,] 49.94 48.09
## [808,] 41.17 37.58
## [809,] 33.65 32.64
## [810,] 17.03 15.52
## [811,] 45.44 41.87
## [812,] 16.88 13.12
## [813,] 10.49 8.45
## [814,] 7.95 3.06
## [815,] 29.00 26.10
## [816,] 33.24 29.24
## [817,] 39.23 37.69
## [818,] 9.89 8.88
## [819,] 24.97 22.33
## [820,] 43.12 40.43
## [821,] 29.88 26.59
## [822,] 19.11 16.40
## [823,] 49.36 45.93
## [824,] 9.85 8.59
## [825,] 27.05 26.24
## [826,] 6.75 4.72
## [827,] 32.22 31.89
## [828,] 20.90 19.20
## [829,] 47.20 44.69
## [830,] 29.92 29.86
## [831,] 18.70 16.64
## [832,] 20.70 19.35
## [833,] 16.97 16.54
## [834,] 36.75 34.84
## [835,] 8.58 4.65
## [836,] 30.46 26.95
## [837,] 39.97 39.71
## [838,] 31.79 26.83
## [839,] 40.59 35.65
## [840,] 20.24 20.18
## [841,] 18.50 15.38
## [842,] 46.36 42.96
## [843,] 11.15 8.08
## [844,] 47.99 43.86
## [845,] 21.67 18.77
## [846,] 30.83 30.37
## [847,] 37.72 33.07
## [848,] 28.37 27.34
## [849,] 49.66 46.66
## [850,] 22.04 19.16
## [851,] 14.30 11.08
## [852,] 13.52 9.50
## [853,] 17.99 14.93
## [854,] 26.07 24.32
## [855,] 27.16 23.47
## [856,] 7.32 4.86
## [857,] 12.80 11.34
## [858,] 16.93 16.87
## [859,] 9.03 7.30
## [860,] 11.00 9.72
## [861,] 10.27 10.14
## [862,] 30.99 27.34
## [863,] 37.72 37.04
## [864,] 32.67 29.65
## [865,] 40.78 40.35
## [866,] 13.33 9.52
## [867,] 7.73 5.13
## [868,] 28.43 27.71
## [869,] 41.90 40.31
## [870,] 23.70 19.85
## [871,] 45.03 44.13
## [872,] 31.89 27.80
## [873,] 37.83 33.08
## [874,] 26.98 25.17
## [875,] 24.73 21.68
## [876,] 28.66 27.62
## [877,] 35.55 34.13
## [878,] 18.36 16.02
## [879,] 31.14 30.98
## [880,] 16.58 15.92
## [881,] 48.73 48.41
## [882,] 29.39 26.88
## [883,] 26.63 24.16
## [884,] 25.61 21.23
## [885,] 48.91 43.95
## [886,] 23.64 18.82
## [887,] 45.30 43.21
## [888,] 22.95 20.73
## [889,] 41.51 41.39
## [890,] 43.26 39.55
## [891,] 44.53 40.86
## [892,] 6.35 3.89
## [893,] 28.45 24.96
## [894,] 9.19 4.71
## [895,] 31.30 27.14
## [896,] 49.50 45.77
## [897,] 28.11 27.36
## [898,] 30.59 30.00
## [899,] 19.25 18.54
## [900,] 15.21 13.53
## [901,] 24.90 24.44
## [902,] 26.75 22.76
## [903,] 13.58 11.21
## [904,] 10.60 7.52
## [905,] 9.81 9.53
## [906,] 36.90 33.72
## [907,] 35.44 30.67
## [908,] 7.65 4.84
## [909,] 49.31 44.80
## [910,] 33.41 28.67
## [911,] 47.79 46.97
## [912,] 44.54 42.20
## [913,] 21.79 17.46
## [914,] 34.69 31.14
## [915,] 46.84 43.80
## [916,] 13.34 8.91
## [917,] 47.74 45.16
## [918,] 42.50 41.13
## [919,] 20.39 18.04
## [920,] 38.87 37.28
## [921,] 49.14 45.02
## [922,] 19.84 19.13
## [923,] 21.81 17.49
## [924,] 27.90 25.48
## [925,] 6.77 5.62
## [926,] 39.44 38.08
## [927,] 49.52 45.71
## [928,] 6.11 1.77
## [929,] 39.47 39.39
## [930,] 29.39 26.11
## [931,] 8.01 5.23
## [932,] 22.74 19.43
## [933,] 20.56 17.87
## [934,] 11.90 9.17
## [935,] 20.45 19.41
## [936,] 29.28 26.59
## [937,] 47.67 43.00
## [938,] 32.84 32.42
## [939,] 11.54 9.37
## [940,] 37.09 33.18
## [941,] 39.47 36.13
## [942,] 37.07 36.38
## [943,] 27.36 25.74
## [944,] 47.39 44.90
## [945,] 47.12 46.00
## [946,] 29.53 26.18
## [947,] 15.70 11.02
## [948,] 40.19 38.73
## [949,] 17.49 13.30
## [950,] 38.45 38.05
## [951,] 17.03 13.40
## [952,] 38.82 34.28
## [953,] 27.63 26.37
## [954,] 16.49 13.55
## [955,] 36.43 33.60
## [956,] 33.00 29.31
## [957,] 20.81 18.58
## [958,] 20.89 17.37
## [959,] 29.43 28.15
## [960,] 11.51 6.97
## [961,] 22.77 22.64
## [962,] 47.52 43.76
## [963,] 46.55 44.71
## [964,] 26.66 26.54
## [965,] 9.68 4.75
## [966,] 8.74 5.79
## [967,] 37.42 36.79
## [968,] 28.38 24.05
## [969,] 43.32 42.81
## [970,] 48.11 44.43
## [971,] 19.87 18.07
## [972,] 7.09 2.82
## [973,] 24.07 19.86
## [974,] 20.04 15.24
## [975,] 46.12 43.68
## [976,] 23.24 19.35
## [977,] 9.14 8.68
## [978,] 35.40 33.28
## [979,] 49.68 46.58
## [980,] 13.10 13.00
## [981,] 16.18 15.84
## [982,] 41.83 37.17
## [983,] 20.40 18.71
## [984,] 19.63 17.77
## [985,] 31.27 28.47
## [986,] 14.36 12.58
## [987,] 13.36 12.36
## [988,] 39.11 35.48
## [989,] 12.72 11.72
## [990,] 14.70 14.24
## [991,] 33.32 32.90
## [992,] 44.99 44.48
## [993,] 34.75 31.60
## [994,] 43.05 41.66
## [995,] 24.35 23.42
## [996,] 11.56 8.61
## [997,] 47.72 46.78
## [998,] 21.30 18.71
## [999,] 22.82 19.13
## [1000,] 6.38 5.25
##
## $subset
## NULL
##
## $outlierMethod
## [1] "none"
##
## attr(,"class")
## [1] "mvn"
boxM_position <- biotools::boxM(
data = df[, c("Price", "Competitor_Price")],
grouping = df$Product_Position
)
boxM_position
##
## Box's M-test for Homogeneity of Covariance Matrices
##
## data: df[, c("Price", "Competitor_Price")]
## Chi-Sq (approx.) = 0.53555, df = 6, p-value = 0.9974
boxM_category <- biotools::boxM(
data = df[, c("Price", "Competitor_Price")],
grouping = df$Product_Category
)
boxM_category
##
## Box's M-test for Homogeneity of Covariance Matrices
##
## data: df[, c("Price", "Competitor_Price")]
## Chi-Sq (approx.) = 3.0362, df = 6, p-value = 0.8043
df$Interaction_Group <- interaction(df$Product_Position, df$Product_Category)
group_counts <- table(df$Interaction_Group)
valid_groups <- names(group_counts[group_counts > 5])
df_valid <- df[df$Interaction_Group %in% valid_groups, ]
df_valid$Interaction_Group <- droplevels(df_valid$Interaction_Group)
boxM_interaction <- biotools::boxM(
data = df_valid[, c("Price", "Competitor_Price")],
grouping = df_valid$Interaction_Group
)
boxM_interaction
##
## Box's M-test for Homogeneity of Covariance Matrices
##
## data: df_valid[, c("Price", "Competitor_Price")]
## Chi-Sq (approx.) = 11.62, df = 24, p-value = 0.9839
dv <- c("Price", "Competitor_Price")
Y <- as.matrix(df[, dv])
cor_matrix <- cor(Y)
bartlett_sphericity <- function(mat) {
n <- nrow(mat)
p <- ncol(mat)
cor_m <- cor(mat)
stat <- -(n - 1 - (2 * p + 5) / 6) * log(det(cor_m))
df_b <- p * (p - 1) / 2
p_val <- pchisq(stat, df = df_b, lower.tail = FALSE)
list(
Approx_ChiSquare = round(stat, 3),
Df = df_b,
Sig = round(p_val, 3)
)
}
r_price <- bartlett_sphericity(as.matrix(df[, "Price", drop = FALSE]))
r_comp <- bartlett_sphericity(as.matrix(df[, "Competitor_Price", drop = FALSE]))
r_combined <- bartlett_sphericity(as.matrix(df[, dv]))
tabel <- data.frame(
Statistik = c("Approx. Chi-Square", "Df", "Sig."),
Price = c(r_price$Approx_ChiSquare, r_price$Df, r_price$Sig),
Competitor_Price = c(r_comp$Approx_ChiSquare, r_comp$Df, r_comp$Sig),
Price_CompPrice = c(r_combined$Approx_ChiSquare, r_combined$Df, r_combined$Sig),
stringsAsFactors = FALSE
)
cat("Tabel Hasil Uji Dependensi Bartlett Test\n")
## Tabel Hasil Uji Dependensi Bartlett Test
cat(sprintf("%-22s %10s %18s %20s\n",
"", "Price", "Competitor_Price", "Price & Competitor_Price"))
## Price Competitor_Price Price & Competitor_Price
for (i in 1:nrow(tabel)) {
cat(sprintf("%-22s %10s %18s %20s\n",
tabel$Statistik[i],
tabel$Price[i],
tabel$Competitor_Price[i],
tabel$Price_CompPrice[i]))
}
## Approx. Chi-Square 0 0 4398.819
## Df 0 0 1
## Sig. 1 1 0
Hasil uji asumsi terpenuhi semua kecuali normalitas multivariat tepatnya pada mardia kurtosis. Penelitian oleh Can Ateş dkk. menunjukkan bahwa Pillai’s Trace cenderung memberikan tingkat kesalahan tipe I yang lebih mendekati nilai nominal dibanding metode statistik lainnya, baik pada kondisi sampel seimbang maupun tidak seimbang. Maka dari itu, analisis tetap dilanjutkan dengan menggunakan metode statistik Pillai’s Trace yang dinilai robust terhadap pelanggaran asumsi normalitas.
dv <- c("Price", "Competitor_Price")
Y <- as.matrix(df[, dv])
model_manova <- manova(Y ~ Product_Position * Product_Category, data = df)
hasil <- summary(model_manova, test = "Pillai")
tabel_raw <- hasil$stats
faktor_labels <- c(
"Product_Position",
"Product_Category",
"Product_Position:Product_Category",
"Residuals"
)
fmt_p <- function(p) {
if (is.na(p)) return("-")
stars <- ifelse(p < 0.001, "***",
ifelse(p < 0.01, "**",
ifelse(p < 0.05, "*",
ifelse(p < 0.1, ".", ""))))
paste0(formatC(p, format = "f", digits = 4), stars)
}
cat("Tabel Hasil Uji Two-Way MANOVA (Pillai's Trace)\n")
## Tabel Hasil Uji Two-Way MANOVA (Pillai's Trace)
cat(sprintf("%-36s %7s %10s %7s %7s %s\n",
"Faktor", "Pillai", "Approx F", "df num", "df den", "p-value"))
## Faktor Pillai Approx F df num df den p-value
for (faktor in faktor_labels) {
if (faktor == "Residuals") next
pillai <- round(tabel_raw[faktor, "Pillai"], 4)
approx_f <- round(tabel_raw[faktor, "approx F"], 4)
df_num <- tabel_raw[faktor, "num Df"]
df_den <- tabel_raw[faktor, "den Df"]
p_val <- tabel_raw[faktor, "Pr(>F)"]
cat(sprintf("%-36s %7.4f %10.4f %7.0f %7.0f %s\n",
faktor, pillai, approx_f, df_num, df_den, fmt_p(p_val)))
}
## Product_Position 0.0016 0.3934 4 1982 0.8135
## Product_Category 0.0017 0.4237 4 1982 0.7916
## Product_Position:Product_Category 0.0069 0.8527 8 1982 0.5562
Pada tabel hasil Two-Way MANOVA di atas, statistik uji yang digunakan adalah Pillai’s Trace (bernilai antara 0 dan 1 ). Nilai Pillai mendekati 1 menunjukkan efek yang kuat (menolak hipotesis nol), sedangkan mendekati 0 menunjukkan efek sangat lemah. Untuk setiap faktor dan interaksinya, diperoleh nilai Pillai yang sangat dekat dengan nol (0.0016, 0.0017, 0.0069) dan p-value yang jauh di atas 0.05 (0.8135, 0.7916, 0.5562). Menurut kaidah umum uji statistik, p-value > 0.05 berarti gagal menolak hipotesis nol . Artinya, tidak ada perbedaan signifikan secara multivariat pada Price dan Competitor Price antar tingkat Product Position, antar tingkat Product Category, maupun pada interaksi antara keduanya. Dengan demikian, dapat disimpulkan bahwa harga-harga produk tidak bergantung pada kategori produk dan bagaimana atau di mana produknya diletakkan di toko.
plot(df$Sales_Volume, df$Price)
abline(lm(Price ~ Sales_Volume, data=df), col="red")
plot(df$Sales_Volume, df$Competitor_Price)
abline(lm(Competitor_Price ~ Sales_Volume, data=df), col="blue")
Scatter plot menunjukkan hubungan antara Sales Volume dan Competitor Price. Titik data tersebar acak dan garis regresi cenderung datar, sehingga hubungan keduanya sangat lemah. Meskipun demikian, pola linear masih terpenuhi sehingga asumsi linearitas dalam ANCOVA dapat diterima.
cor_matrix <- cor(df[,c("Price","Competitor_Price","Sales_Volume")])
ggcorrplot(cor_matrix, lab=TRUE)
Heatmap korelasi menunjukkan hubungan antar variabel Price, Competitor Price, dan Sales Volume. Terlihat bahwa Price dan Competitor Price memiliki korelasi sangat tinggi (0.99), yang berarti keduanya bergerak hampir searah. Sementara itu, Sales Volume memiliki korelasi sangat lemah (0.05) terhadap kedua variabel tersebut. Hasil ini menunjukkan bahwa Sales Volume tidak memiliki hubungan kuat dengan variabel dependen, sehingga pengaruhnya sebagai kovariat dalam model kemungkinan kecil.
leveneTest(Price ~ Product_Position * Product_Category, data=df)
## Levene's Test for Homogeneity of Variance (center = median)
## Df F value Pr(>F)
## group 8 1.0431 0.4015
## 991
leveneTest(Competitor_Price ~ Product_Position * Product_Category, data=df)
## Levene's Test for Homogeneity of Variance (center = median)
## Df F value Pr(>F)
## group 8 1.0448 0.4002
## 991
Hasil uji Levene menunjukkan nilai p-value sebesar 0.4015 untuk Price dan 0.4002 untuk Competitor Price, yang keduanya lebih besar dari 0.05. Hal ini menunjukkan bahwa varians antar kelompok adalah homogen, sehingga asumsi homogenitas varians dalam ANCOVA terpenuhi.
model_price <- lm(Price ~ Sales_Volume * Product_Position * Product_Category, data=df)
anova(model_price)
## Analysis of Variance Table
##
## Response: Price
## Df Sum Sq Mean Sq F value
## Sales_Volume 1 361 361.01 2.1030
## Product_Position 2 258 128.95 0.7512
## Product_Category 2 143 71.57 0.4169
## Sales_Volume:Product_Position 2 395 197.28 1.1493
## Sales_Volume:Product_Category 2 351 175.26 1.0210
## Product_Position:Product_Category 4 338 84.45 0.4920
## Sales_Volume:Product_Position:Product_Category 4 183 45.73 0.2664
## Residuals 982 168571 171.66
## Pr(>F)
## Sales_Volume 0.1473
## Product_Position 0.4721
## Product_Category 0.6592
## Sales_Volume:Product_Position 0.3173
## Sales_Volume:Product_Category 0.3606
## Product_Position:Product_Category 0.7417
## Sales_Volume:Product_Position:Product_Category 0.8996
## Residuals
Hasil uji homogenitas kemiringan regresi menunjukkan bahwa seluruh interaksi antara Sales Volume dengan Product Position dan Product Category memiliki p-value lebih besar dari 0.05. Hal ini menunjukkan bahwa tidak terdapat perbedaan kemiringan regresi antar kelompok, sehingga asumsi homogeneity of regression slopes dalam ANCOVA terpenuhi.
res_model <- lm(Price ~ Sales_Volume + Product_Position + Product_Category, data=df)
shapiro.test(residuals(res_model))
##
## Shapiro-Wilk normality test
##
## data: residuals(res_model)
## W = 0.95561, p-value < 2.2e-16
Hasil uji Shapiro-Wilk menunjukkan nilai p-value < 0.05, sehingga residual tidak berdistribusi normal. Namun, dengan jumlah sampel yang besar, pelanggaran asumsi normalitas ini masih dapat ditoleransi dalam analisis ANCOVA.
vif(res_model)
## GVIF Df GVIF^(1/(2*Df))
## Sales_Volume 1.004146 1 1.002071
## Product_Position 1.004153 2 1.001037
## Product_Category 1.007734 2 1.001928
Hasil uji multikolinearitas menunjukkan bahwa seluruh nilai GVIF yang telah disesuaikan berada mendekati 1. Hal ini mengindikasikan tidak terdapat multikolinearitas antar variabel independen, sehingga asumsi bebas multikolinearitas dalam ANCOVA terpenuhi.
ancova_price <- aov(Price ~ Product_Position * Product_Category + Sales_Volume, data=df)
summary(ancova_price)
## Df Sum Sq Mean Sq F value Pr(>F)
## Product_Position 2 250 125.1 0.731 0.482
## Product_Category 2 122 60.8 0.355 0.701
## Sales_Volume 1 390 390.1 2.279 0.131
## Product_Position:Product_Category 4 395 98.7 0.577 0.680
## Residuals 990 169442 171.2
ancova_comp <- aov(Competitor_Price ~ Product_Position * Product_Category + Sales_Volume, data=df)
Hasil analisis ANCOVA menunjukkan bahwa Product Position (p = 0.482), Product Category (p = 0.701), dan Sales Volume (p = 0.131) tidak berpengaruh signifikan terhadap Price karena seluruh p-value lebih besar dari 0.05. Selain itu, interaksi antara Product Position dan Product Category juga tidak signifikan (p = 0.680). Hal ini menunjukkan bahwa tidak terdapat pengaruh yang signifikan dari variabel independen maupun kovariat terhadap Price dalam model yang digunakan.
etaSquared(ancova_price)
## eta.sq eta.sq.part
## Product_Position 0.0016430709 0.0016515567
## Product_Category 0.0008390868 0.0008441025
## Sales_Volume 0.0020103853 0.0020200224
## Product_Position:Product_Category 0.0023142919 0.0023246759
etaSquared(ancova_comp)
## eta.sq eta.sq.part
## Product_Position 0.0015261276 0.0015344740
## Product_Category 0.0006485119 0.0006526346
## Sales_Volume 0.0022154865 0.0022260602
## Product_Position:Product_Category 0.0025444813 0.0025557803
Hasil ukuran efek (eta squared) menunjukkan bahwa seluruh variabel memiliki nilai yang sangat kecil (mendekati 0). Hal ini mengindikasikan bahwa Product Position, Product Category, Sales Volume, serta interaksinya memiliki pengaruh yang sangat lemah terhadap baik Price maupun Competitor Price, sehingga kontribusi masing-masing variabel dalam model tergolong rendah.
ancova_tab <- summary(ancova_price)[[1]]
format_p <- function(p){
if(p < 0.001) return(paste0(round(p,4),"***"))
else if(p < 0.01) return(paste0(round(p,4),"**"))
else if(p < 0.05) return(paste0(round(p,4),"*"))
else return(round(p,4))
}
cat("\n=== ANCOVA PRICE ===\n")
##
## === ANCOVA PRICE ===
for(i in 1:nrow(ancova_tab)){
if(!is.na(ancova_tab[i,"Pr(>F)"])){
cat(sprintf("%-30s %-5.0f %-10.4f %-10s\n",
rownames(ancova_tab)[i],
ancova_tab[i,"Df"],
ancova_tab[i,"F value"],
format_p(ancova_tab[i,"Pr(>F)"])))
}
}
## Product_Position 2 0.7311 0.4816
## Product_Category 2 0.3554 0.701
## Sales_Volume 1 2.2794 0.1314
## Product_Position:Product_Category 4 0.5767 0.6796
summary(ancova_comp)
## Df Sum Sq Mean Sq F value Pr(>F)
## Product_Position 2 237 118.5 0.683 0.505
## Product_Category 2 92 46.0 0.265 0.767
## Sales_Volume 1 436 435.5 2.511 0.113
## Product_Position:Product_Category 4 440 110.0 0.634 0.638
## Residuals 990 171715 173.4
Hasil ANCOVA menunjukkan bahwa seluruh variabel, yaitu Product Position (p = 0.505), Product Category (p = 0.767), dan Sales Volume (p = 0.113), serta interaksi antara Product Position dan Product Category (p = 0.638), memiliki nilai p-value lebih besar dari 0.05. Hal ini menunjukkan bahwa tidak terdapat pengaruh yang signifikan terhadap Price, sehingga variabel independen maupun kovariat dalam model tidak berkontribusi secara signifikan.
#Standarisasi Kovariate
df$Sales_Volume_scaled <- scale(df$Sales_Volume)
Standarisasi variabel kovariat dilakukan untuk menyamakan skala data.
Sebelum dilakukan analisis utama MANCOVA, terlebih dahulu diuji asumsi homogenitas kemiringan regresi (homogeneity of regression slopes). Asumsi ini digunakan untuk memastikan bahwa hubungan antara variabel kovariat (Sales Volume) dan variabel dependen (Price dan Competitors Price) adalah sama pada setiap kelompok variabel independen (Product Position dan Product Category).
Pengujian dilakukan dengan melihat signifikansi interaksi antara variabel faktor dan kovariat. Jika nilai p-value < 0.05, maka terdapat interaksi yang signifikan sehingga asumsi homogenitas tidak terpenuhi. Sebaliknya, jika p-value > 0.05 maka asumsi homogenitas terpenuhi dan analisis MANCOVA dapat dilanjutkan.
model_price <- lm(
Price ~ Product_Position * Sales_Volume_scaled +
Product_Category * Sales_Volume_scaled,
data = df
)
anova_price <- anova(model_price)
model_comp <- lm(
Competitor_Price ~ Product_Position * Sales_Volume_scaled +
Product_Category * Sales_Volume_scaled,
data = df
)
anova_comp <- anova(model_comp)
p1 <- anova_price["Product_Position:Sales_Volume_scaled", "Pr(>F)"]
p2 <- anova_price["Sales_Volume_scaled:Product_Category", "Pr(>F)"]
p3 <- anova_comp["Product_Position:Sales_Volume_scaled", "Pr(>F)"]
p4 <- anova_comp["Sales_Volume_scaled:Product_Category", "Pr(>F)"]
hasil_homogen <- data.frame(
Variabel_Dependen = c("Price", "Price", "Competitor Price", "Competitor Price"),
Faktor_x_Kovariat = c(
"Product Position × Sales Volume",
"Product Category × Sales Volume",
"Product Position × Sales Volume",
"Product Category × Sales Volume"
),
p_value = round(c(p1, p2, p3, p4), 4),
Keputusan = ifelse(
c(p1, p2, p3, p4) > 0.05,
"Homogen (tidak signifikan)",
"Tidak homogen (signifikan)"
)
)
print(hasil_homogen)
## Variabel_Dependen Faktor_x_Kovariat p_value
## 1 Price Product Position × Sales Volume 0.3155
## 2 Price Product Category × Sales Volume 0.3588
## 3 Competitor Price Product Position × Sales Volume 0.2818
## 4 Competitor Price Product Category × Sales Volume 0.3281
## Keputusan
## 1 Homogen (tidak signifikan)
## 2 Homogen (tidak signifikan)
## 3 Homogen (tidak signifikan)
## 4 Homogen (tidak signifikan)
Hasil uji homogenitas menunjukkan bahwa seluruh interaksi antara variabel faktor (Product Position dan Product Category) dengan kovariat (Sales Volume) memiliki nilai p-value lebih besar dari 0.05.
Hal ini mengindikasikan bahwa tidak terdapat interaksi yang signifikan antara faktor dan kovariat. Dengan demikian, asumsi homogenitas kemiringan regresi pada MANCOVA/ANCOVA terpenuhi.
Artinya, hubungan antara Sales Volume dan variabel dependen (Price dan Competitor’s Price) bersifat konsisten pada setiap kelompok, sehingga analisis MANCOVA dapat dilanjutkan ke tahap interpretasi model utama.
MANCOVA digunakan untuk menguji pengaruh simultan variabel independen terhadap beberapa variabel dependen dengan mengontrol kovariat.
# MANCOVA (Pillai's Trace)
model_mancova <- manova(
cbind(Price, Competitor_Price) ~
Product_Position * Product_Category + Sales_Volume_scaled,
data = df
)
summary_mancova <- summary(model_mancova, test = "Pillai")
summary_mancova
## Df Pillai approx F num Df den Df Pr(>F)
## Product_Position 2 0.0015888 0.39353 4 1980 0.8134
## Product_Category 2 0.0017089 0.42332 4 1980 0.7919
## Sales_Volume_scaled 1 0.0028800 1.42827 2 989 0.2402
## Product_Position:Product_Category 4 0.0065288 0.81058 8 1980 0.5932
## Residuals 990
Untuk menentukan signifikansi, digunakan nilai p-value dari hasil Pillai’s Trace.
res <- summary_mancova$stats
ifelse(res[, "Pr(>F)"] < 0.05,
"Signifikan",
"Tidak Signifikan")
## Product_Position Product_Category
## "Tidak Signifikan" "Tidak Signifikan"
## Sales_Volume_scaled Product_Position:Product_Category
## "Tidak Signifikan" "Tidak Signifikan"
## Residuals
## NA
Hasil pengujian MANCOVA menunjukkan bahwa seluruh variabel utama yang diuji, yaitu Product Position, Product Category, Sales Volume (kovariat), serta interaksi antara Product Position dan Product Category, memiliki nilai p-value yang lebih besar dari 0.05 sehingga seluruhnya dikategorikan tidak signifikan.
Secara rinci, hasil tersebut menunjukkan bahwa: - Product Position tidak memiliki pengaruh signifikan terhadap kombinasi variabel dependen (Price dan Competitor’s Price). - Product Category juga tidak memberikan pengaruh signifikan terhadap variabel dependen. - Sales Volume sebagai kovariat tidak berpengaruh signifikan dalam model. - Interaksi antara Product Position dan Product Category tidak menunjukkan efek gabungan yang signifikan.
Dengan demikian, dapat disimpulkan bahwa tidak terdapat pengaruh simultan yang signifikan dari variabel independen maupun kovariat terhadap variabel dependen yang dianalisis.
Hal ini mengindikasikan bahwa variasi pada Price dan Competitor’s Price tidak dapat dijelaskan secara signifikan oleh model MANCOVA yang digunakan dalam penelitian ini.