library(foreign)
speeddata <- read.arff("/Users/eneaprelaz/Desktop/IMB/MVA/Multivariate_Analysis/H4/speeddating.arff")
head(speeddata)
## has_null wave gender age age_o d_age d_d_age
## 1 0 1 female 21 27 6 [4-6]
## 2 0 1 female 21 22 1 [0-1]
## 3 1 1 female 21 22 1 [0-1]
## 4 0 1 female 21 23 2 [2-3]
## 5 0 1 female 21 24 3 [2-3]
## 6 0 1 female 21 25 4 [4-6]
## race race_o
## 1 Asian/Pacific Islander/Asian-American European/Caucasian-American
## 2 Asian/Pacific Islander/Asian-American European/Caucasian-American
## 3 Asian/Pacific Islander/Asian-American Asian/Pacific Islander/Asian-American
## 4 Asian/Pacific Islander/Asian-American European/Caucasian-American
## 5 Asian/Pacific Islander/Asian-American Latino/Hispanic American
## 6 Asian/Pacific Islander/Asian-American European/Caucasian-American
## samerace importance_same_race importance_same_religion d_importance_same_race
## 1 0 2 4 [2-5]
## 2 0 2 4 [2-5]
## 3 1 2 4 [2-5]
## 4 0 2 4 [2-5]
## 5 0 2 4 [2-5]
## 6 0 2 4 [2-5]
## d_importance_same_religion field pref_o_attractive pref_o_sincere
## 1 [2-5] Law 35 20
## 2 [2-5] Law 60 0
## 3 [2-5] Law 19 18
## 4 [2-5] Law 30 5
## 5 [2-5] Law 30 10
## 6 [2-5] Law 50 0
## pref_o_intelligence pref_o_funny pref_o_ambitious pref_o_shared_interests
## 1 20 20 0 5
## 2 0 40 0 0
## 3 19 18 14 12
## 4 15 40 5 5
## 5 20 10 10 20
## 6 30 10 0 10
## d_pref_o_attractive d_pref_o_sincere d_pref_o_intelligence d_pref_o_funny
## 1 [21-100] [16-20] [16-20] [16-20]
## 2 [21-100] [0-15] [0-15] [21-100]
## 3 [16-20] [16-20] [16-20] [16-20]
## 4 [21-100] [0-15] [0-15] [21-100]
## 5 [21-100] [0-15] [16-20] [0-15]
## 6 [21-100] [0-15] [21-100] [0-15]
## d_pref_o_ambitious d_pref_o_shared_interests attractive_o sinsere_o
## 1 [0-15] [0-15] 6 8
## 2 [0-15] [0-15] 7 8
## 3 [0-15] [0-15] 10 10
## 4 [0-15] [0-15] 7 8
## 5 [0-15] [16-20] 8 7
## 6 [0-15] [0-15] 7 7
## intelligence_o funny_o ambitous_o shared_interests_o d_attractive_o
## 1 8 8 8 6 [6-8]
## 2 10 7 7 5 [6-8]
## 3 10 10 10 10 [9-10]
## 4 9 8 9 8 [6-8]
## 5 9 6 9 7 [6-8]
## 6 8 8 7 7 [6-8]
## d_sinsere_o d_intelligence_o d_funny_o d_ambitous_o d_shared_interests_o
## 1 [6-8] [6-8] [6-8] [6-8] [6-8]
## 2 [6-8] [9-10] [6-8] [6-8] [0-5]
## 3 [9-10] [9-10] [9-10] [9-10] [9-10]
## 4 [6-8] [9-10] [6-8] [9-10] [6-8]
## 5 [6-8] [9-10] [6-8] [9-10] [6-8]
## 6 [6-8] [6-8] [6-8] [6-8] [6-8]
## attractive_important sincere_important intellicence_important funny_important
## 1 15 20 20 15
## 2 15 20 20 15
## 3 15 20 20 15
## 4 15 20 20 15
## 5 15 20 20 15
## 6 15 20 20 15
## ambtition_important shared_interests_important d_attractive_important
## 1 15 15 [0-15]
## 2 15 15 [0-15]
## 3 15 15 [0-15]
## 4 15 15 [0-15]
## 5 15 15 [0-15]
## 6 15 15 [0-15]
## d_sincere_important d_intellicence_important d_funny_important
## 1 [16-20] [16-20] [0-15]
## 2 [16-20] [16-20] [0-15]
## 3 [16-20] [16-20] [0-15]
## 4 [16-20] [16-20] [0-15]
## 5 [16-20] [16-20] [0-15]
## 6 [16-20] [16-20] [0-15]
## d_ambtition_important d_shared_interests_important attractive sincere
## 1 [0-15] [0-15] 6 8
## 2 [0-15] [0-15] 6 8
## 3 [0-15] [0-15] 6 8
## 4 [0-15] [0-15] 6 8
## 5 [0-15] [0-15] 6 8
## 6 [0-15] [0-15] 6 8
## intelligence funny ambition d_attractive d_sincere d_intelligence d_funny
## 1 8 8 7 [6-8] [6-8] [6-8] [6-8]
## 2 8 8 7 [6-8] [6-8] [6-8] [6-8]
## 3 8 8 7 [6-8] [6-8] [6-8] [6-8]
## 4 8 8 7 [6-8] [6-8] [6-8] [6-8]
## 5 8 8 7 [6-8] [6-8] [6-8] [6-8]
## 6 8 8 7 [6-8] [6-8] [6-8] [6-8]
## d_ambition attractive_partner sincere_partner intelligence_partner
## 1 [6-8] 6 9 7
## 2 [6-8] 7 8 7
## 3 [6-8] 5 8 9
## 4 [6-8] 7 6 8
## 5 [6-8] 5 6 7
## 6 [6-8] 4 9 7
## funny_partner ambition_partner shared_interests_partner d_attractive_partner
## 1 7 6 5 [6-8]
## 2 8 5 6 [6-8]
## 3 8 5 7 [0-5]
## 4 7 6 8 [6-8]
## 5 7 6 6 [0-5]
## 6 4 6 4 [0-5]
## d_sincere_partner d_intelligence_partner d_funny_partner d_ambition_partner
## 1 [9-10] [6-8] [6-8] [6-8]
## 2 [6-8] [6-8] [6-8] [0-5]
## 3 [6-8] [9-10] [6-8] [0-5]
## 4 [6-8] [6-8] [6-8] [6-8]
## 5 [6-8] [6-8] [6-8] [6-8]
## 6 [9-10] [6-8] [0-5] [6-8]
## d_shared_interests_partner sports tvsports exercise dining museums art hiking
## 1 [0-5] 9 2 8 9 1 1 5
## 2 [6-8] 9 2 8 9 1 1 5
## 3 [6-8] 9 2 8 9 1 1 5
## 4 [6-8] 9 2 8 9 1 1 5
## 5 [6-8] 9 2 8 9 1 1 5
## 6 [0-5] 9 2 8 9 1 1 5
## gaming clubbing reading tv theater movies concerts music shopping yoga
## 1 1 5 6 9 1 10 10 9 8 1
## 2 1 5 6 9 1 10 10 9 8 1
## 3 1 5 6 9 1 10 10 9 8 1
## 4 1 5 6 9 1 10 10 9 8 1
## 5 1 5 6 9 1 10 10 9 8 1
## 6 1 5 6 9 1 10 10 9 8 1
## d_sports d_tvsports d_exercise d_dining d_museums d_art d_hiking d_gaming
## 1 [9-10] [0-5] [6-8] [9-10] [0-5] [0-5] [0-5] [0-5]
## 2 [9-10] [0-5] [6-8] [9-10] [0-5] [0-5] [0-5] [0-5]
## 3 [9-10] [0-5] [6-8] [9-10] [0-5] [0-5] [0-5] [0-5]
## 4 [9-10] [0-5] [6-8] [9-10] [0-5] [0-5] [0-5] [0-5]
## 5 [9-10] [0-5] [6-8] [9-10] [0-5] [0-5] [0-5] [0-5]
## 6 [9-10] [0-5] [6-8] [9-10] [0-5] [0-5] [0-5] [0-5]
## d_clubbing d_reading d_tv d_theater d_movies d_concerts d_music d_shopping
## 1 [0-5] [6-8] [9-10] [0-5] [9-10] [9-10] [9-10] [6-8]
## 2 [0-5] [6-8] [9-10] [0-5] [9-10] [9-10] [9-10] [6-8]
## 3 [0-5] [6-8] [9-10] [0-5] [9-10] [9-10] [9-10] [6-8]
## 4 [0-5] [6-8] [9-10] [0-5] [9-10] [9-10] [9-10] [6-8]
## 5 [0-5] [6-8] [9-10] [0-5] [9-10] [9-10] [9-10] [6-8]
## 6 [0-5] [6-8] [9-10] [0-5] [9-10] [9-10] [9-10] [6-8]
## d_yoga interests_correlate d_interests_correlate
## 1 [0-5] 0.14 [0-0.33]
## 2 [0-5] 0.54 [0.33-1]
## 3 [0-5] 0.16 [0-0.33]
## 4 [0-5] 0.61 [0.33-1]
## 5 [0-5] 0.21 [0-0.33]
## 6 [0-5] 0.25 [0-0.33]
## expected_happy_with_sd_people expected_num_interested_in_me
## 1 3 2
## 2 3 2
## 3 3 2
## 4 3 2
## 5 3 2
## 6 3 2
## expected_num_matches d_expected_happy_with_sd_people
## 1 4 [0-4]
## 2 4 [0-4]
## 3 4 [0-4]
## 4 4 [0-4]
## 5 4 [0-4]
## 6 4 [0-4]
## d_expected_num_interested_in_me d_expected_num_matches like guess_prob_liked
## 1 [0-3] [3-5] 7 6
## 2 [0-3] [3-5] 7 5
## 3 [0-3] [3-5] 7 NA
## 4 [0-3] [3-5] 7 6
## 5 [0-3] [3-5] 6 6
## 6 [0-3] [3-5] 6 5
## d_like d_guess_prob_liked met decision decision_o match
## 1 [6-8] [5-6] 0 1 0 0
## 2 [6-8] [5-6] 1 1 0 0
## 3 [6-8] [0-4] 1 1 1 1
## 4 [6-8] [5-6] 0 1 1 1
## 5 [6-8] [5-6] 0 1 1 1
## 6 [6-8] [5-6] 0 0 1 0
I begin with importing the dataset into R and cleaning it from
observations with NA values, obtaining a sample size of 1048 then I
further reduce the sample size to 300. The next step is creating a new
dataset with just the relevant variables needed for my research
question.
set.seed(191)
speedNull <- speeddata[speeddata$has_null !='1', ] #removing rows with NA values
speed300 <- speedNull[sample(nrow(speedNull), 300), ] #scaling down the sample to 300 random people from the cleaned one
datingset <- speed300[ , !(names(speed300) %in% c("has_null", "wave", "age_o", "d_age", "d_d_age", "race", "race_o", "samerace", "d_importance_same_race", "d_importance_same_religion", "field", "pref_o_attractive", "pref_o_sincere", "pref_o_intelligence", "pref_o_funny", "pref_o_ambitious", "pref_o_shared_interests", "d_pref_o_attractive", "d_pref_o_sincere", "d_pref_o_intelligence", "d_pref_o_funny", "d_pref_o_ambitious", "d_pref_o_shared_interests", "attractive_o", "sinsere_o", "intelligence_o", "funny_o", "ambitous_o", "shared_interests_o", "d_attractive_o", "d_sinsere_o", "d_intelligence_o", "d_funny_o", "d_ambitous_o", "d_shared_interests_o", "d_attractive_important", "d_sincere_important", "d_intellicence_important", "d_funny_important", "d_ambtition_important", "d_shared_interests_important", "d_attractive", "d_sincere", "d_intelligence", "d_funny", "d_ambition", "importance_same_race", "importance_same_religion", "attractive_important", "sincere_important", "intellicence_important", "funny_important", "ambition_important", "shared_interest_important", "d_attractive_partner", "d_sincere_partner", "d_intelligence_partner", "d_funny_partner", "d_ambition_partner", "d_shared_interests_partner", "d_sports", "d_tvsports", "d_exercise", "d_dining", "d_museums", "d_art", "d_hiking", "d_gaming", "d_clubbing", "d_reading", "d_tv", "d_theater", "d_movies", "d_concerts", "d_music", "d_shopping", "d_yoga", "interests_correlate", "d_interests_correlate", "expected_happy_with_sd_people", "expected_num_interested_in_me", "expected_num_matches", "d_expected_happy_with_sd_people", "d_expected_num_interested_in_me", "d_expected_num_matches", "like", "guess_prob_liked", "d_like", "d_guess_prob_liked", "met", "decision", "decision_o", "match", "attractive", "sincere", "intelligence", "funny", "ambition", "sports", "tvsports", "exercise", "dining", "museums", "art", "hiking", "gaming", "clubbing", "reading", "tv", "theater", "movies", "concerts", "music", "shopping", "yoga", "ambtition_important", "shared_interests_important"))] #This was the cleaning made
colnames(datingset) <- c("gender", "age","Attractive", "Sincere", "Intelligence", "Funny", "Ambition", "Shared_Interest")#, "Self_Attractive", "Self_Sincere", "Self_Intelligence", "Self_Funny", "Self_Ambition", "Interest_Sports", "Interest_tvSports", "Interest_Exercise", "Interest_Dining", "Interest_Museums", "Interest_Art", "Interest_Hiking", "Interest_Gaming", "Interest_Clubbing", "Interest_Reading", "Interest_TV", "Interest_Theater", "Interest_Movies", "Interest_Concerts", "Interest_Music", "Interest_Shopping", "Interest_Yoga")
head(datingset)
## gender age Attractive Sincere Intelligence Funny Ambition Shared_Interest
## 174 male 27 6 7 8 6 6 5
## 1487 male 32 6 8 8 8 8 5
## 590 male 24 7 7 7 7 6 7
## 1342 male 28 7 7 7 7 7 5
## 1514 male 27 6 6 6 6 6 7
## 1800 male 22 7 3 7 10 7 8
library(psych)
describe(datingset[ ,-1])
## vars n mean sd median trimmed mad min max range skew
## age 1 300 25.00 3.16 25 24.77 2.97 18 35 17 0.60
## Attractive 2 300 6.17 1.85 6 6.27 1.48 0 10 10 -0.51
## Sincere 3 300 7.22 1.66 7 7.30 1.48 1 10 9 -0.74
## Intelligence 4 300 7.43 1.38 7 7.44 1.48 2 10 8 -0.34
## Funny 5 300 6.34 1.92 7 6.45 1.48 1 10 9 -0.60
## Ambition 6 300 6.78 1.72 7 6.80 1.48 1 10 9 -0.24
## Shared_Interest 7 300 5.44 2.10 6 5.52 1.48 0 10 10 -0.28
## kurtosis se
## age 0.04 0.18
## Attractive 0.29 0.11
## Sincere 1.54 0.10
## Intelligence 0.85 0.08
## Funny 0.44 0.11
## Ambition 0.13 0.10
## Shared_Interest -0.37 0.12
Dataset description:
This data was gathered from participants
in experimental speed dating events from 2002-2004. During the events,
the attendees would have a four-minute “first date” with every other
participant of the opposite sex. At the end of their four minutes,
participants were asked if they would like to see their date again. They
were also asked to rate their date on six attributes: Attractiveness,
Sincerity, Intelligence, Fun, Ambition, and Shared Interests. The
dataset also includes questionnaire data gathered from participants at
different points in the process. These fields include: demographics,
dating habits, self-perception across key attributes, beliefs on what
others find valuable in a mate, and lifestyle information.
For this
homework I decided to answering my RQ by analyzing the score each person
gave to their “partner”.
The first 2 variables represent the
individual characteristics such as: gender(male, female) and age.
attractive_partner: Rate your partner (0 to 10) - attractiveness
sincere_partner: Rate your partner (0 to 10) - sincerity
intelligence_partner: Rate your partner (0 to 10) - intelligence
funny_partner: Rate your partner (0 to 10) - funny
ambition_partner:
Rate your partner (0 to 10) - ambition
shared_interest_partner: Rate
your partner (0 to 10) - shared interest
unit of sample: 1
participant
size of sample: 300 participants
Author: Ray Fisman
and Sheena Iyengar
Source: Columbia Business School - 2004
Relevan paper: Raymond Fisman; Sheena S. Iyengar; Emir Kamenica; Itamar
Simonson. Gender Differences in Mate Selection: Evidence From a Speed
Dating Experiment. The Quarterly Journal of Economics, Volume 121, Issue
2, 1 May 2006, Pages 673–697, https://doi.org/10.1162/qjec.2006.121.2.673
We
can see from this sample that out of 300 participants the average age is
25 years old, with the youngest being 18 and the oldest 35. The score
for attractiveness is on average 6.17, and 50% of the sample has given a
score less than 6.
——————–
At this point I would transform the
gender values in factors, but in this data set it was already done.
fit <- lm(Attractive ~ Sincere + Intelligence + Funny + Ambition + Shared_Interest,
data = datingset)
I create a model just to check the multicolinearity:
library(car)
## Loading required package: carData
##
## Attaching package: 'car'
## The following object is masked from 'package:psych':
##
## logit
vif(fit)
## Sincere Intelligence Funny Ambition Shared_Interest
## 1.781954 1.932722 1.955213 1.649211 1.809901
mean(vif(fit))
## [1] 1.8258
Based on this results I would say that this model doesn’t have
too much multicolinearity, maybe intelligence should be dropped but I
don’t think it’s necessary, also the mean is almost 2, it’s not exactly
around 1 but also not excessively far away.
After this I will
combine the data and start PCA analysis:
datingsetPCA <- datingset[, c("Sincere","Intelligence","Funny","Ambition","Shared_Interest")]
library(pastecs)
round(stat.desc(datingsetPCA, basic = FALSE), 2)
## Sincere Intelligence Funny Ambition Shared_Interest
## median 7.00 7.00 7.00 7.00 6.00
## mean 7.22 7.43 6.34 6.78 5.44
## SE.mean 0.10 0.08 0.11 0.10 0.12
## CI.mean.0.95 0.19 0.16 0.22 0.20 0.24
## var 2.75 1.90 3.67 2.97 4.42
## std.dev 1.66 1.38 1.92 1.72 2.10
## coef.var 0.23 0.19 0.30 0.25 0.39
There are 3 checks for the PCA analysis: The first one is that
there must be sufficiently high correlations between the variables (the
threshold is |0.3|); the second one is that the KMO statistic, which is
a measure the general adequacy of data, needs its value to be above 0.5,
otherwise the dataset is loosing an unacceptable quantity of
information; the third one is a check with Barlett’s test of spericity.
I will begin with checking the correlation matrix and the results to
make sure that no value is smaller than |0.3|.
R <- cor(datingsetPCA)
round(R,3)
## Sincere Intelligence Funny Ambition Shared_Interest
## Sincere 1.000 0.623 0.456 0.422 0.405
## Intelligence 0.623 1.000 0.418 0.539 0.388
## Funny 0.456 0.418 1.000 0.495 0.643
## Ambition 0.422 0.539 0.495 1.000 0.458
## Shared_Interest 0.405 0.388 0.643 0.458 1.000
Based on the matrix it appears that no variables have a
r<|0.3|.
Next, I will check the KMO statistic and then the
Bartlett’s sphericity(H0: 𝐏=𝐈, H1: 𝐏≠𝐈):
library(psych)
KMO(R)
## Kaiser-Meyer-Olkin factor adequacy
## Call: KMO(r = R)
## Overall MSA = 0.78
## MSA for each item =
## Sincere Intelligence Funny Ambition Shared_Interest
## 0.78 0.74 0.76 0.84 0.77
cortest.bartlett(R, n = nrow(datingsetPCA))
## $chisq
## [1] 543.0701
##
## $p.value
## [1] 2.724889e-110
##
## $df
## [1] 10
Based on the results, the KMO shows that this data has a
“Middling” level of adequacy. I also can reject H0 for the test of
sphericity, based on p<0.001, and say that population correlation
matrix 𝐏 is different from the identity matrix 𝐈.
The degree of
freedom is calculated as follows: df=[p(p-1)]/2 -> (5*4)/2 = 10, with
p being the number of initial variables, in this case 5 (Sincere,
Intelligence, Funny, Ambition, Shared_Interest).
Next I will get
the eigenvalues, which are the variance of the PCs:
library(FactoMineR)
components <- PCA(datingsetPCA,
scale.unit = TRUE,
graph = FALSE)
library(factoextra)
## Loading required package: ggplot2
##
## Attaching package: 'ggplot2'
## The following objects are masked from 'package:psych':
##
## %+%, alpha
## Welcome! Want to learn more? See two factoextra-related books at https://goo.gl/ve3WBa
get_eigenvalue(components)
## eigenvalue variance.percent cumulative.variance.percent
## Dim.1 2.9388437 58.776873 58.77687
## Dim.2 0.8028058 16.056116 74.83299
## Dim.3 0.5631260 11.262521 86.09551
## Dim.4 0.3645918 7.291836 93.38735
## Dim.5 0.3306327 6.612653 100.00000
Based on this results, by making the sum of all the PCs eigenvalues I
get 5, which is p. Their standard variance is 1. All 5 together make the
total information. The 58.8%% of the information of the measured
variables is transferred to PC1. The variance percentage of each PC is
calculated as follows: λ/p, for PC1 is 2.9388437/5 = 0.5877687.
From
this data I can already see that I’m going to pick only PC1 because of
the Kaiser’s rule: λj > 1 → 2.9388437 > 1.
Now I will look at
the Scree plot:
fviz_eig(components,
choice = "eigenvalue",
main = "Scree plot",
ylab = "Eigenvalue",
xlab = "Principal component",
addlabels = TRUE)
From the graph I can see that the first break happen at PC2. Once again
based on n-1 I can see that I will only pick one component (PC1).
fa.parallel(datingsetPCA,
sim = FALSE,
fa = "pc")
## Parallel analysis suggests that the number of factors = NA and the number of components = 1
I’m going to do the parallel analysis where the λj
empirical(observed) should be > λj theoretical. Finally, this is the
last piece of evidence that confirms only PC1 is suitable for being
picked. Also, since these variables are soft data, the requirement for
70% of total variance explained by the number of components can be
reduced to 40%. The first component explains around 59%.
components <- PCA(datingsetPCA,
scale.unit = TRUE,
graph = FALSE,
ncp = 1)
components
## **Results for the Principal Component Analysis (PCA)**
## The analysis was performed on 300 individuals, described by 5 variables
## *The results are available in the following objects:
##
## name description
## 1 "$eig" "eigenvalues"
## 2 "$var" "results for the variables"
## 3 "$var$coord" "coord. for the variables"
## 4 "$var$cor" "correlations variables - dimensions"
## 5 "$var$cos2" "cos2 for the variables"
## 6 "$var$contrib" "contributions of the variables"
## 7 "$ind" "results for the individuals"
## 8 "$ind$coord" "coord. for the individuals"
## 9 "$ind$cos2" "cos2 for the individuals"
## 10 "$ind$contrib" "contributions of the individuals"
## 11 "$call" "summary statistics"
## 12 "$call$centre" "mean of the variables"
## 13 "$call$ecart.type" "standard error of the variables"
## 14 "$call$row.w" "weights for the individuals"
## 15 "$call$col.w" "weights for the variables"
print(components$var$cor)
## Dim.1
## Sincere 0.7569408
## Intelligence 0.7745160
## Funny 0.7885723
## Ambition 0.7592669
## Shared_Interest 0.7534432
Since I have a one-dimensional PCA it’s important to say that
negative loadings indicate the direction in which the values of the
initial variables contribute to PC1. If a variable has a negative
loading, it means that higher values of that variable are associated
with lower values of PC1, and viceversa. The linear relationship between
being sincere and PC1 is negative and strong.
print(components$var$contrib)
## Dim.1
## Sincere 19.49608
## Intelligence 20.41194
## Funny 21.15956
## Ambition 19.61609
## Shared_Interest 19.31633
Being sincere contributed to the 19.5% of information.
Being
intelligent contributed to the 20.4% of information.
The two
dimensional plots won’t work in one dimension.
head(components$ind$coord)
## Dim.1
## 174 -0.24561012
## 1487 1.01724904
## 590 0.08522881
## 1342 -0.07603027
## 1514 -0.75054436
## 1800 0.20681600
components$ind$coord[1, ]
## [1] -0.2456101
datingsetPCA_std <- scale(datingsetPCA)
datingsetPCA_std[1, ]
## Sincere Intelligence Funny Ambition Shared_Interest
## -0.1346925 0.4137291 -0.1757653 -0.4527421 -0.2076841
Assuming that all the variables have the same direction, I would imagine that this person has rated his partner in every variable below the average, but without a visual representation is a bit difficult to say.
datingset$PC1 <- components$ind$coord[ ,1]
head(datingset, 3)
## gender age Attractive Sincere Intelligence Funny Ambition Shared_Interest
## 174 male 27 6 7 8 6 6 5
## 1487 male 32 6 8 8 8 8 5
## 590 male 24 7 7 7 7 6 7
## PC1
## 174 -0.24561012
## 1487 1.01724904
## 590 0.08522881
Conclusions:
Principal component analysis was performed on 5
standardized variables (n=300). The KMO measure confirms the
appropriateness of the variables, KMO = 0.78, where the data falls into
the category “Middling”. The MSA statistics for the individual variables
are all above the 0.70. Based on the parallel analysis (and other rules
as well), it made sense to retain just one principal component, which
alone summarize almost 60% of the information in the 5 initial
variables.
Based on the component loadings, we conclude that PC1
(λ1 = 2.9388437) represent the partners’ general qualities.
fit <- lm(Attractive ~ PC1 + age + gender,
data = datingset)
vif(fit)
## PC1 age gender
## 1.003302 1.008663 1.005359
mean(vif(fit))
## [1] 1.005775
Nothing to say here about the multicolinearity.
datingset$StdRes <- rstandard(fit)
datingset$StdFit <- scale(fit$fitted.values)
hist(datingset$StdRes,
xlab = "Standardized Residuals",
ylab = "Frequency",
main = "Histogram of Standardized Residuals")
The standardized residuals apparently doesn’t show outliers, since
every value is between [-3, 3].
library(ggplot2)
ggplot(datingset, aes(y=StdRes, x=StdFit)) +
theme_classic() +
geom_point() +
ylab("Standardized Residuals") +
xlab("Standardized Fitted Values")
library(olsrr)
##
## Attaching package: 'olsrr'
## The following object is masked from 'package:datasets':
##
## rivers
ols_test_breusch_pagan(fit)
##
## Breusch Pagan Test for Heteroskedasticity
## -----------------------------------------
## Ho: the variance is constant
## Ha: the variance is not constant
##
## Data
## --------------------------------------
## Response : Attractive
## Variables: fitted values of Attractive
##
## Test Summary
## ----------------------------
## DF = 1
## Chi2 = 8.626431
## Prob > Chi2 = 0.0033132
Based on the result from this test we can confidently say we
reject H0 at p<0.001, and say that the data is Heteroskedastic.