Documente Academic
Documente Profesional
Documente Cultură
Analysis
For the purpose of this assignment, a subset of the data collected by Roberts and Lattin,
reflecting the evaluations of the 12 most frequently cirted cereal brands in the sample (in
the original study, a total of 40 different brands were evaluated by 121 respondents, but
the majority of brands were rated by only a small number of consumers). The 25
attributes and 12 brands are listed below
In total 116 respondents provided 235 observations of the 12 selected brands. How do you
characterize the consideration behavior of the 12 selected brands? Analyze and interpret
yoru results using factor analysis.
Solution:
setwd("F:/Stats")
getwd()
Reading Data:
Mydata=read.csv("Dataset_Cereal.csv", header=TRUE)
summary(Mydata)
rm(list=ls(all=T))
gc()
library(readxl)
str(cerealdata)
summary(cerealdata)
sapply(cerealdata,function(x){sum(is.na(x))})
summary(cerealdata)
cerealdata[cerealdata==6]<-5
summary(cerealdata)
cerealdata[,c(12,25)]<-6-cerealdata[,c(12,25)]
summary(cerealdata)
library(psych)
require(psych)
cerealKMO
cereal_Bartlett
library(psych)
require(psych)
cor(cereal_fa)
library(corrplot)
require(corrplot)
A Scree Plot is a simple line segment plot that shows the fraction of total variance in the data as
explained or represented by each PC.
library(car)
require(car)
fa_model1$loadings
Loadings:
Factor1 Factor2 Factor3 Factor4
Filling 0.697 0.218 0.121
Natural 0.765 -0.127
Fibre 0.759 -0.156 0.254 0.149
Sweet 0.718 0.351
Easy 0.290 0.209 -0.139
Salt -0.260 0.452 0.274 0.376
Satisfying 0.679 0.303
Energy 0.673 0.221 0.100
Fun 0.289 0.562 -0.100 -0.248
Kids 0.165 0.473 -0.710 0.125
Soggy 0.161 0.181 -0.409
Economical 0.181 -0.112 -0.464 0.124
Health 0.855 -0.191
Family 0.261 0.404 -0.648
Calories -0.242 0.498 0.281 0.153
Plain -0.232 -0.332 -0.253 0.469
Crisp 0.202 0.476 -0.210
Regular 0.609 0.177
Sugar -0.349 0.642 0.403 0.205
Fruit 0.328 0.201 0.491 -0.215
Process -0.333 0.211 0.213
Quality 0.748
Treat 0.370 0.598 -0.293
Boring 0.320 0.308 -0.361
Nutritious 0.834 0.121 0.105
Loadings:
Factor1 Factor2 Factor3 Factor4
Filling 0.697
Natural 0.765
Fibre 0.759
Satisfying 0.679
Energy 0.673
Health 0.855
Regular 0.609
Quality 0.748
Nutritious 0.834
Sweet 0.718
Fun
Sugar 0.642
Treat
Kids -0.710
Family -0.648
Easy
Salt
Soggy
Economical
Calories
Plain
Crisp
Fruit
Process
Boring
load<-fa_promax$loadings[,1:2]
Loadings:
Factor1 Factor2 Factor3 Factor4
Filling 0.692
Natural 0.779
Fibre 0.896
Satisfying 0.574
Energy 0.625
Health 0.859
Regular 0.674
Quality 0.614
Nutritious 0.874
Fun 0.542
Soggy 0.549
Plain -0.724
Treat 0.635
Boring 0.563
Sweet 0.695
Salt 0.732
Calories 0.601
Sugar 0.805
Kids 0.899
Family 0.796
Easy
Economical 0.417
Crisp 0.452
Fruit 0.428
Process
Load
require(GPArotation)
modelGPArotation$loadings
Loadings:
ML1 ML2 ML3 ML4
Filling 0.701 0.173 0.135
Natural 0.763 -0.106
Fibre 0.856 -0.165
Sweet 0.714 0.221
Easy 0.248 0.270
Salt 0.732 -0.223
Satisfying 0.607 0.125 0.315
Energy 0.641 0.133 0.105 0.136
Fun 0.111 0.319 0.501
Kids 0.883
Soggy -0.151 -0.174 0.522
Economical 0.102 -0.242 0.408 -0.211
Health 0.839 -0.170
Family 0.788
Calories 0.609
Plain 0.151 -0.686
Crisp 0.273 0.417
Regular 0.654
Sugar -0.135 0.815
Fruit 0.306 0.179 -0.350 0.410
Process -0.179 0.368 -0.179
Quality 0.629 -0.178 0.106 0.148
Treat 0.130 0.162 0.209 0.590
Boring -0.119 0.145 0.533
Nutritious 0.854
Loadings:
ML1 ML2 ML3 ML4
Filling 0.701
Natural 0.763
Fibre 0.856
Satisfying 0.607
Energy 0.641
Health 0.839
Regular 0.654
Quality 0.629
Nutritious 0.854
Sweet 0.714
Salt 0.732
Calories 0.609
Sugar 0.815
Kids 0.883
Family 0.788
Fun 0.501
Soggy 0.522
Plain -0.686
Treat 0.590
Boring 0.533
Easy
Economical 0.408
Crisp 0.417
Fruit 0.410
Process
load<-modelGPArotation$loadings[,1:2]
load
ML1 ML2
Filling 0.701309046 0.17322694
Natural 0.762630232 -0.10595635
Fibre 0.855949168 0.01858967
Sweet 0.067773891 0.71424553
Easy 0.247638121 0.08834512
Salt 0.018487003 0.73211631
Satisfying 0.607278616 0.12478236
Energy 0.641198914 0.13328900
Fun 0.042685902 0.11102035
Kids -0.037378842 0.02764293
Soggy -0.151059001 -0.09341945
Economical 0.102188330 -0.24153339
Health 0.838844472 -0.17020388
Family 0.016740114 -0.07086225
Calories -0.090872130 0.60912744
Plain 0.004911829 0.01336992
Crisp -0.005560806 0.09520097
Regular 0.653515781 0.02391396
Sugar -0.135032147 0.81512934
Fruit 0.306033868 0.17938139
Process -0.178563912 0.36792347
Quality 0.628917125 -0.17809305
Treat 0.130110153 0.16203962
Boring 0.042978937 -0.11926946
Nutritious 0.853919890 -0.05081306
Creating Factors
colnames(cerealdata[,c(2,3,4,8,9,14,19,23,26)])
[1] "Filling" "Natural" "Fibre" "Satisfying" "Energy"
"Health" "Regular" "Quality" "Nutritious"
Sweet Salt Calories Sugar Process as majority of these column names related to Taste, it can be
named as "Taste"
colnames(cerealdata[,c(5,7,16,20,22)])
[1] "Sweet" "Salt" "Calories" "Sugar" "Process"
Kids Economical Family as majority of these column names related to family, it can be named as
"Family"
colnames(cerealdata[,c(11,13,15)])
[1] "Kids" "Economical" "Family"
Soggy Plain Crisp Treat Boring as majority of these column names related to feelings, it can be
named as "Feeling"
colnames(cerealdata[,c(12,17,18,24,25)])
[1] "Soggy" "Plain" "Crisp" "Treat" "Boring"
cerealdata$factor1score <-apply(cerealdata[,factor1],1,mean)
cerealdata$factor2score <-apply(cerealdata[,factor2],1,mean)
cerealdata$factor3score <-apply(cerealdata[,factor3],1,mean)
cerealdata$factor4score <-apply(cerealdata[,factor4],1,mean)
creating the new columns in the dataset and deducing the 12 brands aggregrate behavior for
interpretation
format(agg.fa.cereal, digits = 2)