library(stats)
library(ggplot2)
library(plot3D)
library(philentropy)
## Warning: paketas 'philentropy' buvo sukurtas pagal R versiją 4.1.3
library(factoextra)
## Warning: paketas 'factoextra' buvo sukurtas pagal R versiją 4.1.3
library(corrplot)
library(RColorBrewer)
library(PerformanceAnalytics)
## Warning: paketas 'PerformanceAnalytics' buvo sukurtas pagal R versiją 4.1.3
library(mlr)
library(tidyverse)
library(fastDummies)
## Warning: paketas 'fastDummies' buvo sukurtas pagal R versiją 4.1.3
library(e1071)
library(corrplot)
library(caTools)
library(class)
library(tree)
## Warning: paketas 'tree' buvo sukurtas pagal R versiją 4.1.3
library(readr)
library(tidyverse)
library(mlr)
library(scales)
library(HDclassif)
library(GGally)
library(purrr)
library(dplyr)
Nuskaitomas antrasis duomenų rinkinys
getwd()
## [1] "C:/Users/antanas.kaminskas/Desktop"
setwd("C:/Users/antanas.kaminskas/Desktop")
data2 <- read.csv2("C:/Users/antanas.kaminskas/Desktop/DG_OE.csv",
header = TRUE, sep = ";" ,dec = ".")
head(data2)
## date S1_Temp S2_Temp S3_Temp S4_Temp S1_Light S2_Light S3_Light S4_Light
## 1 2017 24.94 24.75 24.56 25.38 121 34 53 40
## 2 2017 24.94 24.75 24.56 25.44 121 33 53 40
## 3 2017 25.00 24.75 24.50 25.44 121 34 53 40
## 4 2017 25.00 24.75 24.56 25.44 121 34 53 40
## 5 2017 25.00 24.75 24.56 25.44 121 34 54 40
## 6 2017 25.00 24.81 24.56 25.44 121 34 54 40
## S1_Sound S2_Sound S3_Sound S4_Sound S5_CO2 S5_CO2_Slope S6_PIR S7_PIR
## 1 0.08 0.19 0.06 0.06 390 0.7692308 0 0
## 2 0.93 0.05 0.06 0.06 390 0.6461538 0 0
## 3 0.43 0.11 0.08 0.06 390 0.5192308 0 0
## 4 0.41 0.10 0.10 0.09 390 0.3884615 0 0
## 5 0.18 0.06 0.06 0.06 390 0.2538462 0 0
## 6 0.13 0.06 0.06 0.07 390 0.1653846 0 0
## Room_Occupancy_Count
## 1 1
## 2 1
## 3 1
## 4 1
## 5 1
## 6 1
min.max.norm <- function(x, x.max, x.min)
{
return((x-x.min)/(x.max-x.min))
}
for(i in c(1,2,4,5,6))
{
max <- max(data2[,i])
min <- min(data2[,i])
for(ii in 1:nrow(data2))
{
data2[ii,i] <- min.max.norm(data2[ii,i], max, min)
}
}
ggplot(data2, aes(x=Room_Occupancy_Count, fill=date)) +
geom_bar()
summary(data2)
## date S1_Temp S2_Temp S3_Temp
## Min. :0.0000 Min. :0.0000 Min. :24.75 Min. :0.0000
## 1st Qu.:0.0000 1st Qu.:0.1736 1st Qu.:25.19 1st Qu.:0.1429
## Median :0.0000 Median :0.3056 Median :25.38 Median :0.2857
## Mean :0.2019 Mean :0.3570 Mean :25.55 Mean :0.3524
## 3rd Qu.:0.0000 3rd Qu.:0.4792 3rd Qu.:25.63 3rd Qu.:0.5371
## Max. :1.0000 Max. :1.0000 Max. :29.00 Max. :1.0000
## S4_Temp S1_Light S2_Light S3_Light
## Min. :0.0000 Min. :0.00000 Min. : 0.00 Min. : 0.00
## 1st Qu.:0.3086 1st Qu.:0.00000 1st Qu.: 0.00 1st Qu.: 0.00
## Median :0.5000 Median :0.00000 Median : 0.00 Median : 0.00
## Mean :0.5025 Mean :0.15421 Mean : 26.02 Mean : 34.25
## 3rd Qu.:0.6543 3rd Qu.:0.07273 3rd Qu.: 14.00 3rd Qu.: 50.00
## Max. :1.0000 Max. :1.00000 Max. :258.00 Max. :280.00
## S4_Light S1_Sound S2_Sound S3_Sound
## Min. : 0.00 Min. :0.0600 Min. :0.0400 Min. :0.0400
## 1st Qu.: 0.00 1st Qu.:0.0700 1st Qu.:0.0500 1st Qu.:0.0600
## Median : 0.00 Median :0.0800 Median :0.0500 Median :0.0600
## Mean :13.22 Mean :0.1682 Mean :0.1201 Mean :0.1581
## 3rd Qu.:22.00 3rd Qu.:0.0800 3rd Qu.:0.0600 3rd Qu.:0.0700
## Max. :74.00 Max. :3.8800 Max. :3.4400 Max. :3.6700
## S4_Sound S5_CO2 S5_CO2_Slope S6_PIR
## Min. :0.0500 Min. : 345.0 Min. :-6.29615 Min. :0.00000
## 1st Qu.:0.0600 1st Qu.: 355.0 1st Qu.:-0.04615 1st Qu.:0.00000
## Median :0.0800 Median : 360.0 Median : 0.00000 Median :0.00000
## Mean :0.1038 Mean : 460.9 Mean :-0.00483 Mean :0.09014
## 3rd Qu.:0.1000 3rd Qu.: 465.0 3rd Qu.: 0.00000 3rd Qu.:0.00000
## Max. :3.4000 Max. :1270.0 Max. : 8.98077 Max. :1.00000
## S7_PIR Room_Occupancy_Count
## Min. :0.00000 Min. :0.0000
## 1st Qu.:0.00000 1st Qu.:0.0000
## Median :0.00000 Median :0.0000
## Mean :0.07957 Mean :0.3986
## 3rd Qu.:0.00000 3rd Qu.:0.0000
## Max. :1.00000 Max. :3.0000
corrplot(cor(data2[,-1]), method = "number", type = "upper")
ggplot(data2, aes(x=as.factor(date) )) +
geom_bar(color="red", fill=rgb(0.1,0.4,0.5,0.7) )+ ggtitle("Room_Occupancy_Count") +
xlab("Date") + ylab("Value")
str(data2)
## 'data.frame': 10129 obs. of 18 variables:
## $ date : num 0 0 0 0 0 0 0 0 0 0 ...
## $ S1_Temp : num 0 0 0.0417 0.0417 0.0417 ...
## $ S2_Temp : num 24.8 24.8 24.8 24.8 24.8 ...
## $ S3_Temp : num 0.0686 0.0686 0.0343 0.0686 0.0686 ...
## $ S4_Temp : num 0.272 0.309 0.309 0.309 0.309 ...
## $ S1_Light : num 0.733 0.733 0.733 0.733 0.733 ...
## $ S2_Light : int 34 33 34 34 34 34 34 34 35 34 ...
## $ S3_Light : int 53 53 53 53 54 54 54 54 56 57 ...
## $ S4_Light : int 40 40 40 40 40 40 40 41 43 43 ...
## $ S1_Sound : num 0.08 0.93 0.43 0.41 0.18 0.13 1.39 0.09 0.09 3.84 ...
## $ S2_Sound : num 0.19 0.05 0.11 0.1 0.06 0.06 0.32 0.06 0.05 0.64 ...
## $ S3_Sound : num 0.06 0.06 0.08 0.1 0.06 0.06 0.43 0.09 0.06 0.48 ...
## $ S4_Sound : num 0.06 0.06 0.06 0.09 0.06 0.07 0.06 0.05 0.13 0.39 ...
## $ S5_CO2 : int 390 390 390 390 390 390 390 390 390 390 ...
## $ S5_CO2_Slope : num 0.769 0.646 0.519 0.388 0.254 ...
## $ S6_PIR : int 0 0 0 0 0 0 1 0 0 1 ...
## $ S7_PIR : int 0 0 0 0 0 0 0 0 0 1 ...
## $ Room_Occupancy_Count: int 1 1 1 1 1 1 1 1 1 1 ...
data2[,1] <- as.factor(data2[,1])
data2_Task <- makeClassifTask(data = data2, target = "date")
lda <- makeLearner("classif.lda")
set.seed(50)
ldaModel <- train(lda, data2_Task)
ldaModelData <- getLearnerModel(ldaModel)
ldaPreds <- predict(ldaModelData)$x
head(ldaPreds)
## LD1
## 1 0.09049063
## 2 -0.59089163
## 3 -1.23787344
## 4 -0.63829960
## 5 -0.69076494
## 6 -0.67422475
df <- cbind(data2, ldaPreds)
ggplot(df, aes(x=LD1, fill=S1_Temp, color=date)) +
geom_histogram()
qda <- makeLearner("classif.qda")
set.seed(50)
qdaModel <- train(qda, data2_Task)
kFold <- makeResampleDesc(method = "RepCV", folds = 3, reps = 10,
stratify = TRUE)
set.seed(50)
ldaCV <- resample(learner = lda, task = data2_Task, resampling = kFold,
measures = list(mmce, acc))
qdaCV <- resample(learner = qda, task = data2_Task, resampling = kFold,
measures = list(mmce, acc))
set.seed(50)
ldaCV$aggr
## mmce.test.mean acc.test.mean
## 0.03994461 0.96005539
qdaCV$aggr
## mmce.test.mean acc.test.mean
## 0.05999599 0.94000401
calculateConfusionMatrix(ldaCV$pred, relative = TRUE)
## Relative confusion matrix (normalized by row/column):
## predicted
## true 0 1 -err.-
## 0 0.95/0.996 0.05/0.155 0.05
## 1 0.02/0.004 0.98/0.845 0.02
## -err.- 0.004 0.155 0.04
##
##
## Absolute confusion matrix:
## predicted
## true 0 1 -err.-
## 0 77141 3699 3699
## 1 347 20103 347
## -err.- 347 3699 4046
calculateConfusionMatrix(qdaCV$pred, relative = TRUE)
## Relative confusion matrix (normalized by row/column):
## predicted
## true 0 1 -err.-
## 0 0.93/0.997 0.07/0.224 0.07
## 1 0.01/0.003 0.99/0.776 0.01
## -err.- 0.003 0.224 0.06
##
##
## Absolute confusion matrix:
## predicted
## true 0 1 -err.-
## 0 75019 5821 5821
## 1 256 20194 256
## -err.- 256 5821 6077
kFold10 <- makeResampleDesc(method = "CV", iters = 10, stratify = TRUE)
set.seed(50)
ldaCVIA <- resample(learner = lda, task = data2_Task, resampling = kFold10, measures = list(mmce, acc))
ldaCVIA$aggr
## mmce.test.mean acc.test.mean
## 0.04027934 0.95972066
qdaCVIA <- resample(learner = qda, task = data2_Task, resampling = kFold10, measures = list(mmce, acc))
qdaCVIA$aggr
## mmce.test.mean acc.test.mean
## 0.06002105 0.93997895
LOO <- makeResampleDesc(method = "LOO")
set.seed(50)
lda_LOO <- resample(learner = lda, task = data2_Task, resampling = LOO,
measures = list(mmce, acc))
lda_LOO$aggr
## mmce.test.mean acc.test.mean
## 0.04018166 0.95981834
set.seed(50)
qda_LOO <- resample(learner = qda, task = data2_Task, resampling = LOO,
measures = list(mmce, acc))
qda_LOO$aggr
## mmce.test.mean acc.test.mean
## 0.06022312 0.93977688
set.seed(50)
dat.d <- sample(1:nrow(data2),size=nrow(data2)*0.7,replace = FALSE) #random selection of 70% data.
train.loan <- data2[dat.d,-1] # 70% training data
test.loan <- data2[-dat.d,-1] # remaining 30% test data
train.loan_labels <- data2[dat.d,1]
test.loan_labels <-data2[-dat.d,1]
i=1
k.optm=1
for (i in 1:16)
{
knn.mod <- knn(train=train.loan, test=test.loan, cl=train.loan_labels, k=i)
k.optm[i] <- 100 * sum(test.loan_labels == knn.mod)/NROW(test.loan_labels)
k=i
cat(k,'=',k.optm[i],''
)
}
## 1 = 98.51925 2 = 98.05857 3 = 97.76242 4 = 97.66371 5 = 97.49918 6 = 97.6308 7 = 97.69661 8 = 97.76242 9 = 97.49918 10 = 97.59789 11 = 97.46627 12 = 97.40046 13 = 97.17012 14 = 97.00559 15 = 96.80816 16 = 96.87397
plot(k.optm, type="b", xlab="K- Value",ylab="Accuracy level")
knn <- makeLearner("classif.knn", par.vals = list("k" = 1))
holdoutNoStrat <- makeResampleDesc(method = "Holdout", split = 0.9, stratify = FALSE)
kFoldCV <- resample(learner = knn, task = data2_Task, resampling = holdoutNoStrat, measures = list(mmce, acc))
## Resampling: holdout
## Measures: mmce acc
## [Resample] iter 1: 0.0078973 0.9921027
##
## Aggregated Result: mmce.test.mean=0.0078973,acc.test.mean=0.9921027
##
Confusion Matrix:
calculateConfusionMatrix(kFoldCV$pred, relative = TRUE)
## Relative confusion matrix (normalized by row/column):
## predicted
## true 0 1 -err.-
## 0 0.994/0.996 0.006/0.024 0.006
## 1 0.014/0.004 0.986/0.976 0.014
## -err.- 0.004 0.024 0.008
##
##
## Absolute confusion matrix:
## predicted
## true 0 1 -err.-
## 0 799 5 5
## 1 3 206 3
## -err.- 3 5 8
kFold10 <- makeResampleDesc(method = "CV", iters = 10, stratify = TRUE)
#IAModel <- train(IAda, IATask)
ldaCVIA <- resample(learner = knn, task = data2_Task, resampling = kFold10, measures = list(mmce, acc))
## Resampling: cross-validation
## Measures: mmce acc
## [Resample] iter 1: 0.0148075 0.9851925
## [Resample] iter 2: 0.0088757 0.9911243
## [Resample] iter 3: 0.0078973 0.9921027
## [Resample] iter 4: 0.0088933 0.9911067
## [Resample] iter 5: 0.0098717 0.9901283
## [Resample] iter 6: 0.0138203 0.9861797
## [Resample] iter 7: 0.0059230 0.9940770
## [Resample] iter 8: 0.0078973 0.9921027
## [Resample] iter 9: 0.0138340 0.9861660
## [Resample] iter 10: 0.0118460 0.9881540
##
## Aggregated Result: mmce.test.mean=0.0103666,acc.test.mean=0.9896334
##
ldaCVIA$aggr
## mmce.test.mean acc.test.mean
## 0.01036662 0.98963338
Statistikoje logistinis modelis yra statistinis modelis, modeliuojantis vieno įvykio tikimybę, kai įvykio log-odds yra tiesinis vieno ar kelių nepriklausomų kintamųjų derinys. Regresinėje analizėje logistinė regresija yra logistinio modelio parametrų įvertinimas.
data2_Task <- makeClassifTask(data = data2, target = "date")
logReg<-makeLearner("classif.logreg", predict.type="prob")
#logRegModel <- train(logReg, IA_Task)
logRegWrapper <- makeImputeWrapper("classif.logreg")
holdout <- makeResampleDesc(method = "Holdout", split = 0.9, stratify = TRUE)
irisLogReg <-resample(learner = logReg, task=data2_Task,
resampling = holdout,
measures = list(acc))
## Resampling: holdout
## Measures: acc
## Warning: glm.fit: fitted probabilities numerically 0 or 1 occurred
## [Resample] iter 1: 0.9684418
##
## Aggregated Result: acc.test.mean=0.9684418
##
calculateConfusionMatrix(irisLogReg$pred, relative = TRUE)
## Relative confusion matrix (normalized by row/column):
## predicted
## true 0 1 -err.-
## 0 0.98/0.98 0.02/0.08 0.02
## 1 0.07/0.02 0.93/0.92 0.07
## -err.- 0.02 0.08 0.03
##
##
## Absolute confusion matrix:
## predicted
## true 0 1 -err.-
## 0 792 17 17
## 1 15 190 15
## -err.- 15 17 32
kFold <- makeResampleDesc(method = "CV", iters = 10)
set.seed(50)
logRegwithImpute <- resample(logRegWrapper, data2_Task,
resampling = kFold,
measures = list(acc))
## Resampling: cross-validation
## Measures: acc
## Warning: glm.fit: fitted probabilities numerically 0 or 1 occurred
## [Resample] iter 1: 0.9753208
## Warning: glm.fit: fitted probabilities numerically 0 or 1 occurred
## [Resample] iter 2: 0.9772952
## Warning: glm.fit: fitted probabilities numerically 0 or 1 occurred
## [Resample] iter 3: 0.9684107
## Warning: glm.fit: fitted probabilities numerically 0 or 1 occurred
## [Resample] iter 4: 0.9703850
## Warning: glm.fit: fitted probabilities numerically 0 or 1 occurred
## [Resample] iter 5: 0.9733465
## Warning: glm.fit: fitted probabilities numerically 0 or 1 occurred
## [Resample] iter 6: 0.9772727
## Warning: glm.fit: fitted probabilities numerically 0 or 1 occurred
## [Resample] iter 7: 0.9733465
## Warning: glm.fit: fitted probabilities numerically 0 or 1 occurred
## [Resample] iter 8: 0.9723593
## Warning: glm.fit: fitted probabilities numerically 0 or 1 occurred
## [Resample] iter 9: 0.9644620
## Warning: glm.fit: fitted probabilities numerically 0 or 1 occurred
## [Resample] iter 10: 0.9654492
##
## Aggregated Result: acc.test.mean=0.9717648
##
calculateConfusionMatrix(logRegwithImpute$pred, relative = TRUE)
## Relative confusion matrix (normalized by row/column):
## predicted
## true 0 1 -err.-
## 0 0.98/0.99 0.02/0.08 0.02
## 1 0.05/0.01 0.95/0.92 0.05
## -err.- 0.01 0.08 0.03
##
##
## Absolute confusion matrix:
## predicted
## true 0 1 -err.-
## 0 7910 174 174
## 1 112 1933 112
## -err.- 112 174 286
PC1 <- prcomp(data2[,-1], scale = TRUE)
PC1
## Standard deviations (1, .., p=17):
## [1] 3.0255535 1.4273214 1.1014175 0.9413541 0.8036198 0.7339162 0.6929721
## [8] 0.6819199 0.6136272 0.5614540 0.5177702 0.4668393 0.3650900 0.3197866
## [15] 0.3018192 0.2334865 0.1445326
##
## Rotation (n x k) = (17 x 17):
## PC1 PC2 PC3 PC4
## S1_Temp 0.2742079 0.34736716 -0.11148448 0.092275739
## S2_Temp 0.2659329 0.22717372 0.01236737 -0.010343736
## S3_Temp 0.2622682 0.37899944 -0.06286919 0.001919714
## S4_Temp 0.2386580 0.36258992 0.03269723 -0.175548968
## S1_Light 0.2920273 -0.06422331 0.23693235 0.028416443
## S2_Light 0.2699898 -0.11023919 0.24508062 0.101458388
## S3_Light 0.2835648 -0.01784454 0.19762926 -0.068557477
## S4_Light 0.1562499 -0.06247556 0.54571793 -0.616308425
## S1_Sound 0.2227673 -0.20792981 -0.17848293 -0.216483717
## S2_Sound 0.2144931 -0.25845738 -0.18173004 -0.206599136
## S3_Sound 0.2194882 -0.19208348 -0.41517723 -0.139401630
## S4_Sound 0.1999217 -0.25422316 -0.41994629 -0.297787733
## S5_CO2 0.2541743 0.31468988 -0.15302068 0.170977223
## S5_CO2_Slope 0.1527626 -0.39412846 0.25334322 0.397910415
## S6_PIR 0.2240765 -0.17453821 0.03451669 0.101649944
## S7_PIR 0.2338486 -0.17047411 -0.11946801 0.293946643
## Room_Occupancy_Count 0.2978880 -0.08163773 0.11251076 0.288023555
## PC5 PC6 PC7 PC8
## S1_Temp 0.003066955 -0.11592985 0.008501971 -0.11692060
## S2_Temp -0.091681520 -0.08292085 -0.105892939 0.08630052
## S3_Temp 0.036079552 0.01934518 -0.054559538 -0.24557897
## S4_Temp 0.096528068 -0.09706740 -0.031350806 -0.47796412
## S1_Light 0.012193535 -0.15840520 0.153198784 0.19415307
## S2_Light -0.048838414 -0.18833149 -0.164090417 0.44668377
## S3_Light 0.318747096 0.24733285 0.146276701 0.17424407
## S4_Light 0.010866912 0.26022243 -0.082241102 -0.05138301
## S1_Sound -0.259584018 -0.35399963 0.591192824 -0.02656878
## S2_Sound -0.263501373 -0.35198352 -0.642047152 -0.01403554
## S3_Sound 0.323429344 0.27052895 0.121302395 0.11962104
## S4_Sound 0.265034222 0.00451093 -0.044275994 -0.06336762
## S5_CO2 0.005932830 0.03134716 0.043354480 0.37769427
## S5_CO2_Slope 0.381732920 -0.24982389 0.018526861 -0.43862675
## S6_PIR -0.635178321 0.31188626 0.227381468 -0.23054113
## S7_PIR -0.121433311 0.54316082 -0.271173907 -0.10488661
## Room_Occupancy_Count 0.033086744 -0.04829228 0.018170627 0.03841478
## PC9 PC10 PC11 PC12
## S1_Temp 0.01867027 -0.09755455 0.05364476 -0.01200132
## S2_Temp -0.32081801 0.61755597 -0.43277694 -0.09870030
## S3_Temp 0.06940333 -0.06473787 0.05985962 -0.06899260
## S4_Temp 0.01595423 -0.11179239 0.02867171 0.40676036
## S1_Light -0.01758121 -0.21967748 0.19399022 0.29176402
## S2_Light -0.14518975 0.10663377 0.08664594 0.49109507
## S3_Light 0.12144548 -0.22568054 0.11244776 -0.26104121
## S4_Light 0.07366733 0.11498321 -0.09487840 -0.17107181
## S1_Sound 0.46054898 0.20113284 -0.10918991 -0.01271076
## S2_Sound 0.12604058 -0.32518780 -0.11268230 -0.21484879
## S3_Sound -0.16788746 -0.28851520 -0.56399334 0.22503246
## S4_Sound -0.29330821 0.32098443 0.59750942 -0.05597480
## S5_CO2 0.03179105 -0.03986480 0.06058174 -0.41432660
## S5_CO2_Slope -0.11031401 0.08496781 -0.15821213 -0.18462285
## S6_PIR -0.48202753 -0.20158129 0.07512099 -0.07522877
## S7_PIR 0.50754942 0.29071343 0.04599870 0.21982271
## Room_Occupancy_Count 0.06889499 -0.04696604 0.04948719 -0.19069262
## PC13 PC14 PC15 PC16
## S1_Temp -0.1637332893 0.062069835 0.20455539 -0.340937185
## S2_Temp -0.2670151118 -0.273528995 -0.07795226 -0.010193128
## S3_Temp 0.0905472166 0.367025019 -0.18088789 -0.500943728
## S4_Temp 0.1700391966 -0.218184168 -0.08968090 0.517423452
## S1_Light -0.4638057826 -0.164953343 0.48855997 -0.066880817
## S2_Light 0.4270078775 0.163179657 -0.24135306 -0.125127433
## S3_Light -0.0023510059 -0.530899259 -0.45423515 -0.151021280
## S4_Light 0.0673012296 0.288074106 0.23978335 0.028909563
## S1_Sound 0.1178657148 -0.001294041 -0.07651677 -0.033036302
## S2_Sound -0.0221779582 -0.150031381 -0.02900063 -0.006173937
## S3_Sound -0.0009822329 0.179384183 0.06280998 0.004676269
## S4_Sound -0.0341922477 0.048070518 0.02520974 0.027023267
## S5_CO2 0.4371689096 -0.001341651 0.39470440 0.320351911
## S5_CO2_Slope 0.2575273317 -0.045892054 0.20692275 -0.090102824
## S6_PIR 0.1125691846 -0.058191923 -0.03782396 -0.012247534
## S7_PIR -0.0125287696 -0.099520465 0.13599704 -0.012393522
## Room_Occupancy_Count -0.4206847543 0.497936297 -0.34747485 0.456381501
## PC17
## S1_Temp 0.744567683
## S2_Temp -0.099179379
## S3_Temp -0.524151366
## S4_Temp -0.014019911
## S1_Light -0.332309781
## S2_Light 0.127609909
## S3_Light 0.059327244
## S4_Light 0.118480295
## S1_Sound 0.004487266
## S2_Sound -0.036952553
## S3_Sound 0.002466527
## S4_Sound 0.008550237
## S5_CO2 -0.103415794
## S5_CO2_Slope -0.008652032
## S6_PIR 0.017294343
## S7_PIR -0.001114086
## Room_Occupancy_Count 0.063600206
PC1$sdev
## [1] 3.0255535 1.4273214 1.1014175 0.9413541 0.8036198 0.7339162 0.6929721
## [8] 0.6819199 0.6136272 0.5614540 0.5177702 0.4668393 0.3650900 0.3197866
## [15] 0.3018192 0.2334865 0.1445326
PC1$rotation
## PC1 PC2 PC3 PC4
## S1_Temp 0.2742079 0.34736716 -0.11148448 0.092275739
## S2_Temp 0.2659329 0.22717372 0.01236737 -0.010343736
## S3_Temp 0.2622682 0.37899944 -0.06286919 0.001919714
## S4_Temp 0.2386580 0.36258992 0.03269723 -0.175548968
## S1_Light 0.2920273 -0.06422331 0.23693235 0.028416443
## S2_Light 0.2699898 -0.11023919 0.24508062 0.101458388
## S3_Light 0.2835648 -0.01784454 0.19762926 -0.068557477
## S4_Light 0.1562499 -0.06247556 0.54571793 -0.616308425
## S1_Sound 0.2227673 -0.20792981 -0.17848293 -0.216483717
## S2_Sound 0.2144931 -0.25845738 -0.18173004 -0.206599136
## S3_Sound 0.2194882 -0.19208348 -0.41517723 -0.139401630
## S4_Sound 0.1999217 -0.25422316 -0.41994629 -0.297787733
## S5_CO2 0.2541743 0.31468988 -0.15302068 0.170977223
## S5_CO2_Slope 0.1527626 -0.39412846 0.25334322 0.397910415
## S6_PIR 0.2240765 -0.17453821 0.03451669 0.101649944
## S7_PIR 0.2338486 -0.17047411 -0.11946801 0.293946643
## Room_Occupancy_Count 0.2978880 -0.08163773 0.11251076 0.288023555
## PC5 PC6 PC7 PC8
## S1_Temp 0.003066955 -0.11592985 0.008501971 -0.11692060
## S2_Temp -0.091681520 -0.08292085 -0.105892939 0.08630052
## S3_Temp 0.036079552 0.01934518 -0.054559538 -0.24557897
## S4_Temp 0.096528068 -0.09706740 -0.031350806 -0.47796412
## S1_Light 0.012193535 -0.15840520 0.153198784 0.19415307
## S2_Light -0.048838414 -0.18833149 -0.164090417 0.44668377
## S3_Light 0.318747096 0.24733285 0.146276701 0.17424407
## S4_Light 0.010866912 0.26022243 -0.082241102 -0.05138301
## S1_Sound -0.259584018 -0.35399963 0.591192824 -0.02656878
## S2_Sound -0.263501373 -0.35198352 -0.642047152 -0.01403554
## S3_Sound 0.323429344 0.27052895 0.121302395 0.11962104
## S4_Sound 0.265034222 0.00451093 -0.044275994 -0.06336762
## S5_CO2 0.005932830 0.03134716 0.043354480 0.37769427
## S5_CO2_Slope 0.381732920 -0.24982389 0.018526861 -0.43862675
## S6_PIR -0.635178321 0.31188626 0.227381468 -0.23054113
## S7_PIR -0.121433311 0.54316082 -0.271173907 -0.10488661
## Room_Occupancy_Count 0.033086744 -0.04829228 0.018170627 0.03841478
## PC9 PC10 PC11 PC12
## S1_Temp 0.01867027 -0.09755455 0.05364476 -0.01200132
## S2_Temp -0.32081801 0.61755597 -0.43277694 -0.09870030
## S3_Temp 0.06940333 -0.06473787 0.05985962 -0.06899260
## S4_Temp 0.01595423 -0.11179239 0.02867171 0.40676036
## S1_Light -0.01758121 -0.21967748 0.19399022 0.29176402
## S2_Light -0.14518975 0.10663377 0.08664594 0.49109507
## S3_Light 0.12144548 -0.22568054 0.11244776 -0.26104121
## S4_Light 0.07366733 0.11498321 -0.09487840 -0.17107181
## S1_Sound 0.46054898 0.20113284 -0.10918991 -0.01271076
## S2_Sound 0.12604058 -0.32518780 -0.11268230 -0.21484879
## S3_Sound -0.16788746 -0.28851520 -0.56399334 0.22503246
## S4_Sound -0.29330821 0.32098443 0.59750942 -0.05597480
## S5_CO2 0.03179105 -0.03986480 0.06058174 -0.41432660
## S5_CO2_Slope -0.11031401 0.08496781 -0.15821213 -0.18462285
## S6_PIR -0.48202753 -0.20158129 0.07512099 -0.07522877
## S7_PIR 0.50754942 0.29071343 0.04599870 0.21982271
## Room_Occupancy_Count 0.06889499 -0.04696604 0.04948719 -0.19069262
## PC13 PC14 PC15 PC16
## S1_Temp -0.1637332893 0.062069835 0.20455539 -0.340937185
## S2_Temp -0.2670151118 -0.273528995 -0.07795226 -0.010193128
## S3_Temp 0.0905472166 0.367025019 -0.18088789 -0.500943728
## S4_Temp 0.1700391966 -0.218184168 -0.08968090 0.517423452
## S1_Light -0.4638057826 -0.164953343 0.48855997 -0.066880817
## S2_Light 0.4270078775 0.163179657 -0.24135306 -0.125127433
## S3_Light -0.0023510059 -0.530899259 -0.45423515 -0.151021280
## S4_Light 0.0673012296 0.288074106 0.23978335 0.028909563
## S1_Sound 0.1178657148 -0.001294041 -0.07651677 -0.033036302
## S2_Sound -0.0221779582 -0.150031381 -0.02900063 -0.006173937
## S3_Sound -0.0009822329 0.179384183 0.06280998 0.004676269
## S4_Sound -0.0341922477 0.048070518 0.02520974 0.027023267
## S5_CO2 0.4371689096 -0.001341651 0.39470440 0.320351911
## S5_CO2_Slope 0.2575273317 -0.045892054 0.20692275 -0.090102824
## S6_PIR 0.1125691846 -0.058191923 -0.03782396 -0.012247534
## S7_PIR -0.0125287696 -0.099520465 0.13599704 -0.012393522
## Room_Occupancy_Count -0.4206847543 0.497936297 -0.34747485 0.456381501
## PC17
## S1_Temp 0.744567683
## S2_Temp -0.099179379
## S3_Temp -0.524151366
## S4_Temp -0.014019911
## S1_Light -0.332309781
## S2_Light 0.127609909
## S3_Light 0.059327244
## S4_Light 0.118480295
## S1_Sound 0.004487266
## S2_Sound -0.036952553
## S3_Sound 0.002466527
## S4_Sound 0.008550237
## S5_CO2 -0.103415794
## S5_CO2_Slope -0.008652032
## S6_PIR 0.017294343
## S7_PIR -0.001114086
## Room_Occupancy_Count 0.063600206
PC1$center
## S1_Temp S2_Temp S3_Temp
## 0.356952946 25.546058841 0.352354625
## S4_Temp S1_Light S2_Light
## 0.502546167 0.154212477 26.016289861
## S3_Light S4_Light S1_Sound
## 34.248494422 13.220258663 0.168177510
## S2_Sound S3_Sound S4_Sound
## 0.120066147 0.158119262 0.103840458
## S5_CO2 S5_CO2_Slope S6_PIR
## 460.860400829 -0.004830001 0.090137230
## S7_PIR Room_Occupancy_Count
## 0.079573502 0.398558594
PC1$scale
## S1_Temp S2_Temp S3_Temp
## 0.2439934 0.5863255 0.2441614
## S4_Temp S1_Light S2_Light
## 0.2200210 0.3091592 67.3041703
## S3_Light S4_Light S1_Sound
## 58.4007438 19.6022192 0.3167091
## S2_Sound S3_Sound S4_Sound
## 0.2665025 0.4136366 0.1206828
## S5_CO2 S5_CO2_Slope S6_PIR
## 199.9649398 1.1649896 0.2863924
## S7_PIR Room_Occupancy_Count
## 0.2706451 0.8936331
head(PC1$x)
## PC1 PC2 PC3 PC4 PC5 PC6 PC7
## [1,] -0.49176884 -2.057463 2.042530 -0.3111114 0.4505189 -0.04964022 0.1013454
## [2,] 0.01345097 -2.375430 1.634073 -0.8566862 -0.1310965 -0.80196580 2.0205045
## [3,] -0.28196998 -2.067239 1.820692 -0.5945250 0.1881748 -0.30735271 0.9531395
## [4,] -0.22409497 -2.019433 1.677049 -0.6982636 0.2581939 -0.22682942 0.9250154
## [5,] -0.50178564 -1.702631 1.952595 -0.4696866 0.3504462 0.08890175 0.5916867
## [6,] -0.50477508 -1.637695 1.928003 -0.4914579 0.3750207 0.15564721 0.4824411
## PC8 PC9 PC10 PC11 PC12 PC13 PC14
## [1,] 0.9457516 0.4158449 -0.9899429 0.4766940 -0.13896344 -0.7332880 0.2701110
## [2,] 0.8410630 1.6021748 -0.3086830 0.2630928 0.02046759 -0.4102313 0.3111490
## [3,] 0.9545745 0.8986524 -0.7286225 0.4021152 0.03809400 -0.6637389 0.2545731
## [4,] 0.9615613 0.8059382 -0.6819082 0.5606657 0.05496031 -0.6950894 0.3375974
## [5,] 1.0408145 0.5565351 -0.8447405 0.5830889 0.10545490 -0.7985600 0.3279713
## [6,] 1.0818959 0.4350690 -0.7931527 0.6175644 0.10674222 -0.8668803 0.3076527
## PC15 PC16 PC17
## [1,] 0.9045481 0.5405477 -0.7031799
## [2,] 0.6810523 0.5536047 -0.6750667
## [3,] 0.8325626 0.6246757 -0.4867604
## [4,] 0.7991589 0.5737076 -0.5560438
## [5,] 0.8150509 0.5992815 -0.5541046
## [6,] 0.8055304 0.6125350 -0.5635968
eig.val <- get_eigenvalue(PC1)
eig.val
## eigenvalue variance.percent cumulative.variance.percent
## Dim.1 9.15397426 53.8469074 53.84691
## Dim.2 2.03724651 11.9838030 65.83071
## Dim.3 1.21312053 7.1360031 72.96671
## Dim.4 0.88614758 5.2126328 78.17935
## Dim.5 0.64580474 3.7988514 81.97820
## Dim.6 0.53863294 3.1684291 85.14663
## Dim.7 0.48021032 2.8247666 87.97139
## Dim.8 0.46501470 2.7353806 90.70677
## Dim.9 0.37653831 2.2149313 92.92171
## Dim.10 0.31523057 1.8542975 94.77600
## Dim.11 0.26808601 1.5769765 96.35298
## Dim.12 0.21793890 1.2819936 97.63497
## Dim.13 0.13329072 0.7840630 98.41904
## Dim.14 0.10226348 0.6015499 99.02059
## Dim.15 0.09109481 0.5358518 99.55644
## Dim.16 0.05451594 0.3206820 99.87712
## Dim.17 0.02088966 0.1228803 100.00000
res.var <- get_pca_var(PC1)
res.var$coord
## Dim.1 Dim.2 Dim.3 Dim.4
## S1_Temp 0.8296307 0.49580460 -0.12279096 0.086864147
## S2_Temp 0.8045943 0.32424992 0.01362164 -0.009737119
## S3_Temp 0.7935066 0.54095403 -0.06924523 0.001807131
## S4_Temp 0.7220725 0.51753237 0.03601330 -0.165253745
## S1_Light 0.8835441 -0.09166731 0.26096144 0.026749936
## S2_Light 0.8168686 -0.15734676 0.26993609 0.095508272
## S3_Light 0.8579406 -0.02546990 0.21767233 -0.064536864
## S4_Light 0.4727423 -0.08917270 0.60106329 -0.580164474
## S1_Sound 0.6739943 -0.29678268 -0.19658422 -0.203787839
## S2_Sound 0.6489604 -0.36890177 -0.20016064 -0.194482948
## S3_Sound 0.6640732 -0.27416487 -0.45728347 -0.131226298
## S4_Sound 0.6048738 -0.36285816 -0.46253620 -0.280323709
## S5_CO2 0.7690180 0.44916362 -0.16853966 0.160950113
## S5_CO2_Slope 0.4621914 -0.56254801 0.27903666 0.374574608
## S6_PIR 0.6779553 -0.24912214 0.03801728 0.095688594
## S7_PIR 0.7075216 -0.24332135 -0.13158415 0.276707883
## Room_Occupancy_Count 0.9012761 -0.11652328 0.12392132 0.271132160
## Dim.5 Dim.6 Dim.7 Dim.8
## S1_Temp 0.002464666 -0.085082793 0.005891628 -0.079730481
## S2_Temp -0.073677082 -0.060856951 -0.073380852 0.058850041
## S3_Temp 0.028994242 0.014197739 -0.037808238 -0.167465176
## S4_Temp 0.077571864 -0.071239333 -0.021725234 -0.325933227
## S1_Light 0.009798966 -0.116256137 0.106162482 0.132396837
## S2_Light -0.039247515 -0.138219529 -0.113710080 0.304602537
## S3_Light 0.256151469 0.181521575 0.101365672 0.118820494
## S4_Light 0.008732866 0.190981452 -0.056990789 -0.035039093
## S1_Sound -0.208606850 -0.259806051 0.409680130 -0.018117778
## S2_Sound -0.211754914 -0.258326395 -0.444920760 -0.009571117
## S3_Sound 0.259914217 0.198545574 0.084059175 0.081571962
## S4_Sound 0.212986742 0.003310644 -0.030682029 -0.043211639
## S5_CO2 0.004767739 0.023006187 0.030043445 0.257557221
## S5_CO2_Slope 0.306768123 -0.183349792 0.012838598 -0.299108295
## S6_PIR -0.510441859 0.228898369 0.157569012 -0.157210577
## S7_PIR -0.097586210 0.398634509 -0.187915950 -0.071524259
## Room_Occupancy_Count 0.026589162 -0.035442484 0.012591737 0.026195798
## Dim.9 Dim.10 Dim.11 Dim.12
## S1_Temp 0.011456583 -0.05477239 0.02777566 -0.005602689
## S2_Temp -0.196862648 0.34672926 -0.22407901 -0.046077175
## S3_Temp 0.042587770 -0.03634734 0.03099353 -0.032208453
## S4_Temp 0.009789948 -0.06276628 0.01484536 0.189891711
## S1_Light -0.010788311 -0.12333880 0.10044236 0.136206903
## S2_Light -0.089092376 0.05986996 0.04486269 0.229262466
## S3_Light 0.074522247 -0.12670924 0.05822210 -0.121864287
## S4_Light 0.045204279 0.06455778 -0.04912521 -0.079863041
## S1_Sound 0.282605372 0.11292683 -0.05653528 -0.005933881
## S2_Sound 0.077341926 -0.18257799 -0.05834354 -0.100299851
## S3_Sound -0.103020311 -0.16198801 -0.29201896 0.105053990
## S4_Sound -0.179981890 0.18021799 0.30937259 -0.026131233
## S5_CO2 0.019507852 -0.02238225 0.03136742 -0.193423929
## S5_CO2_Slope -0.067691675 0.04770552 -0.08191753 -0.086189199
## S6_PIR -0.295785192 -0.11317862 0.03889541 -0.035119746
## S7_PIR 0.311446120 0.16322221 0.02381676 0.102621874
## Room_Occupancy_Count 0.042275839 -0.02636927 0.02562299 -0.089022806
## Dim.13 Dim.14 Dim.15 Dim.16
## S1_Temp -0.0597773889 0.019849103 0.061738736 -0.079604228
## S2_Temp -0.0974845509 -0.087470914 -0.023527485 -0.002379958
## S3_Temp 0.0330578846 0.117369692 -0.054595432 -0.116963594
## S4_Temp 0.0620796126 -0.069772379 -0.027067415 0.120811387
## S1_Light -0.1693308596 -0.052749873 0.147456760 -0.015615767
## S2_Light 0.1558963119 0.052182672 -0.072844977 -0.029215565
## S3_Light -0.0008583288 -0.169774482 -0.137096871 -0.035261429
## S4_Light 0.0245710068 0.092122246 0.072371208 0.006749992
## S1_Sound 0.0430315954 -0.000413817 -0.023094227 -0.007713530
## S2_Sound -0.0080969511 -0.047978029 -0.008752946 -0.001441531
## S3_Sound -0.0003586034 0.057364662 0.018957257 0.001091846
## S4_Sound -0.0124832482 0.015372309 0.007608783 0.006309568
## S5_CO2 0.1596060032 -0.000429042 0.119129349 0.074797844
## S5_CO2_Slope 0.0940206571 -0.014675665 0.062453249 -0.021037792
## S6_PIR 0.0410978852 -0.018608999 -0.011415997 -0.002859634
## S7_PIR -0.0045741287 -0.031825314 0.041046512 -0.002893720
## Room_Occupancy_Count -0.1535878028 0.159233367 -0.104874566 0.106558916
## Dim.17
## S1_Temp 0.1076142692
## S2_Temp -0.0143346491
## S3_Temp -0.0757569359
## S4_Temp -0.0020263336
## S1_Light -0.0480295816
## S2_Light 0.0184437861
## S3_Light 0.0085747182
## S4_Light 0.0171242597
## S1_Sound 0.0006485561
## S2_Sound -0.0053408469
## S3_Sound 0.0003564934
## S4_Sound 0.0012357876
## S5_CO2 -0.0149469489
## S5_CO2_Slope -0.0012505003
## S6_PIR 0.0024995955
## S7_PIR -0.0001610217
## Room_Occupancy_Count 0.0091923002
res.var$contrib
## Dim.1 Dim.2 Dim.3 Dim.4 Dim.5
## S1_Temp 7.518998 12.06639446 1.24287902 8.514812e-01 9.406214e-04
## S2_Temp 7.072032 5.16078974 0.01529519 1.069929e-02 8.405501e-01
## S3_Temp 6.878463 14.36405752 0.39525355 3.685301e-04 1.301734e-01
## S4_Temp 5.695763 13.14714511 0.10691086 3.081744e+00 9.317668e-01
## S1_Light 8.527993 0.41246335 5.61369396 8.074942e-02 1.486823e-02
## S2_Light 7.289450 1.21526792 6.00645114 1.029380e+00 2.385191e-01
## S3_Light 8.040901 0.03184277 3.90573256 4.700128e-01 1.015997e+01
## S4_Light 2.441402 0.39031950 29.78080617 3.798361e+01 1.180898e-02
## S1_Sound 4.962525 4.32348070 3.18561561 4.686520e+00 6.738386e+00
## S2_Sound 4.600730 6.68002193 3.30258057 4.268320e+00 6.943297e+00
## S3_Sound 4.817505 3.68960640 17.23721334 1.943281e+00 1.046065e+01
## S4_Sound 3.996868 6.46294127 17.63548873 8.867753e+00 7.024314e+00
## S5_CO2 6.460458 9.90297213 2.34153284 2.923321e+00 3.519847e-03
## S5_CO2_Slope 2.333641 15.53372442 6.41827874 1.583327e+01 1.457200e+01
## S6_PIR 5.021026 3.04635882 0.11914016 1.033271e+00 4.034515e+01
## S7_PIR 5.468518 2.90614205 1.42726047 8.640463e+00 1.474605e+00
## Room_Occupancy_Count 8.873726 0.66647191 1.26586709 8.295757e+00 1.094733e-01
## Dim.6 Dim.7 Dim.8 Dim.9
## S1_Temp 1.343973072 0.00722835 1.36704274 0.03485789
## S2_Temp 0.687586706 1.12133145 0.74477805 10.29241928
## S3_Temp 0.037423590 0.29767432 6.03090298 0.48168224
## S4_Temp 0.942207967 0.09828731 22.84497007 0.02545374
## S1_Light 2.509220709 2.34698674 3.76954159 0.03090991
## S2_Light 3.546875162 2.69256650 19.95263937 2.10800632
## S3_Light 6.117353675 2.13968733 3.03609971 1.47490043
## S4_Light 6.771571481 0.67635988 0.26402134 0.54268761
## S1_Sound 12.531573615 34.95089549 0.07059000 21.21053644
## S2_Sound 12.389239694 41.22245448 0.01969965 1.58862280
## S3_Sound 7.318591499 1.47142711 1.43091930 2.81862004
## S4_Sound 0.002034849 0.19603637 0.40154554 8.60297070
## S5_CO2 0.098264441 0.18796110 14.26529586 0.10106708
## S5_CO2_Slope 6.241197537 0.03432446 19.23934294 1.21691810
## S6_PIR 9.727303842 5.17023319 5.31492137 23.23505385
## S7_PIR 29.502367738 7.35352876 1.10011999 25.76064159
## Room_Occupancy_Count 0.233214421 0.03301717 0.14756949 0.47465199
## Dim.10 Dim.11 Dim.12 Dim.13
## S1_Temp 0.9516890 0.28777605 0.01440318 2.680859e+00
## S2_Temp 38.1375371 18.72958765 0.97417489 7.129707e+00
## S3_Temp 0.4190992 0.35831735 0.47599783 8.198798e-01
## S4_Temp 1.2497539 0.08220669 16.54539936 2.891333e+00
## S1_Light 4.8258195 3.76322050 8.51262446 2.151158e+01
## S2_Light 1.1370761 0.75075186 24.11743713 1.823357e+01
## S3_Light 5.0931707 1.26444992 6.81425124 5.527229e-04
## S4_Light 1.3221138 0.90019109 2.92655655 4.529456e-01
## S1_Sound 4.0454419 1.19224357 0.01615634 1.389233e+00
## S2_Sound 10.5747108 1.26973007 4.61600015 4.918618e-02
## S3_Sound 8.3241020 31.80884922 5.06396086 9.647815e-05
## S4_Sound 10.3031004 35.70175105 0.31331777 1.169110e-01
## S5_CO2 0.1589202 0.36701467 17.16665341 1.911167e+01
## S5_CO2_Slope 0.7219529 2.50310777 3.40855985 6.632033e+00
## S6_PIR 4.0635017 0.56431637 0.56593685 1.267182e+00
## S7_PIR 8.4514299 0.21158801 4.83220241 1.569701e-02
## Room_Occupancy_Count 0.2205809 0.24489816 3.63636772 1.769757e+01
## Dim.14 Dim.15 Dim.16 Dim.17
## S1_Temp 3.852664e-01 4.18429078 11.623816415 5.543810e+01
## S2_Temp 7.481811e+00 0.60765543 0.010389985 9.836549e-01
## S3_Temp 1.347074e+01 3.27204302 25.094461827 2.747347e+01
## S4_Temp 4.760433e+00 0.80426645 26.772702835 1.965579e-02
## S1_Light 2.720961e+00 23.86908460 0.447304373 1.104298e+01
## S2_Light 2.662760e+00 5.82512983 1.565687452 1.628429e+00
## S3_Light 2.818540e+01 20.63295696 2.280742693 3.519722e-01
## S4_Light 8.298669e+00 5.74960526 0.083576284 1.403758e+00
## S1_Sound 1.674542e-04 0.58548162 0.109139727 2.013556e-03
## S2_Sound 2.250942e+00 0.08410366 0.003811749 1.365491e-01
## S3_Sound 3.217868e+00 0.39450941 0.002186749 6.083755e-04
## S4_Sound 2.310775e-01 0.06355311 0.073025695 7.310655e-03
## S5_CO2 1.800027e-04 15.57915605 10.262534686 1.069483e+00
## S5_CO2_Slope 2.106081e-01 4.28170226 0.811851896 7.485765e-03
## S6_PIR 3.386300e-01 0.14306523 0.015000210 2.990943e-02
## S7_PIR 9.904323e-01 1.84951951 0.015359938 1.241188e-04
## Room_Occupancy_Count 2.479406e+01 12.07387684 20.828407486 4.044986e-01
res.var$cos2
## Dim.1 Dim.2 Dim.3 Dim.4
## S1_Temp 0.6882872 0.2458221997 0.0150776206 7.545380e-03
## S2_Temp 0.6473720 0.1051380087 0.0001855491 9.481148e-05
## S3_Temp 0.6296527 0.2926312601 0.0047949019 3.265721e-06
## S4_Temp 0.5213887 0.2678397546 0.0012969576 2.730880e-02
## S1_Light 0.7806503 0.0084028953 0.0681008741 7.155591e-04
## S2_Light 0.6672744 0.0247580032 0.0728654921 9.121830e-03
## S3_Light 0.7360620 0.0006487158 0.0473812436 4.165007e-03
## S4_Light 0.2234853 0.0079517703 0.3612770744 3.365908e-01
## S1_Sound 0.4542683 0.0880799595 0.0386453570 4.152948e-02
## S2_Sound 0.4211496 0.1360885135 0.0400642830 3.782362e-02
## S3_Sound 0.4409932 0.0751663775 0.2091081742 1.722034e-02
## S4_Sound 0.3658723 0.1316660453 0.2139397348 7.858138e-02
## S5_CO2 0.5913887 0.2017479539 0.0284056156 2.590494e-02
## S5_CO2_Slope 0.2136209 0.3164602581 0.0778614572 1.403061e-01
## S6_PIR 0.4596234 0.0620618386 0.0014453138 9.156307e-03
## S7_PIR 0.5005868 0.0592052774 0.0173143898 7.656725e-02
## Room_Occupancy_Count 0.8122986 0.0135776758 0.0153564936 7.351265e-02
## Dim.5 Dim.6 Dim.7 Dim.8
## S1_Temp 6.074578e-06 7.239082e-03 3.471129e-05 6.356950e-03
## S2_Temp 5.428312e-03 3.703569e-03 5.384749e-03 3.463327e-03
## S3_Temp 8.406661e-04 2.015758e-04 1.429463e-03 2.804459e-02
## S4_Temp 6.017394e-03 5.075043e-03 4.719858e-04 1.062325e-01
## S1_Light 9.601973e-05 1.351549e-02 1.127047e-02 1.752892e-02
## S2_Light 1.540367e-03 1.910464e-02 1.292998e-02 9.278271e-02
## S3_Light 6.561358e-02 3.295008e-02 1.027500e-02 1.411831e-02
## S4_Light 7.626294e-05 3.647391e-02 3.247950e-03 1.227738e-03
## S1_Sound 4.351682e-02 6.749918e-02 1.678378e-01 3.282539e-04
## S2_Sound 4.484014e-02 6.673253e-02 1.979545e-01 9.160628e-05
## S3_Sound 6.755540e-02 3.942034e-02 7.065945e-03 6.653985e-03
## S4_Sound 4.536335e-02 1.096037e-05 9.413869e-04 1.867246e-03
## S5_CO2 2.273134e-05 5.292847e-04 9.026086e-04 6.633572e-02
## S5_CO2_Slope 9.410668e-02 3.361715e-02 1.648296e-04 8.946577e-02
## S6_PIR 2.605509e-01 5.239446e-02 2.482799e-02 2.471517e-02
## S7_PIR 9.523068e-03 1.589095e-01 3.531240e-02 5.115720e-03
## Room_Occupancy_Count 7.069835e-04 1.256170e-03 1.585519e-04 6.862198e-04
## Dim.9 Dim.10 Dim.11 Dim.12
## S1_Temp 1.312533e-04 0.0030000147 0.0007714873 3.139012e-05
## S2_Temp 3.875490e-02 0.1202211773 0.0502114044 2.123106e-03
## S3_Temp 1.813718e-03 0.0013211288 0.0009605987 1.037384e-03
## S4_Temp 9.584308e-05 0.0039396063 0.0002203846 3.605886e-02
## S1_Light 1.163876e-04 0.0152124584 0.0100886677 1.855232e-02
## S2_Light 7.937451e-03 0.0035844116 0.0020126607 5.256128e-02
## S3_Light 5.553565e-03 0.0160552312 0.0033898133 1.485090e-02
## S4_Light 2.043427e-03 0.0041677069 0.0024132864 6.378105e-03
## S1_Sound 7.986580e-02 0.0127524697 0.0031962382 3.521094e-05
## S2_Sound 5.981774e-03 0.0333347217 0.0034039687 1.006006e-02
## S3_Sound 1.061318e-02 0.0262401146 0.0852750751 1.103634e-02
## S4_Sound 3.239348e-02 0.0324785227 0.0957114003 6.828413e-04
## S5_CO2 3.805563e-04 0.0005009650 0.0009839150 3.741282e-02
## S5_CO2_Slope 4.582163e-03 0.0022758162 0.0067104818 7.428578e-03
## S6_PIR 8.748888e-02 0.0128093996 0.0015128532 1.233397e-03
## S7_PIR 9.699869e-02 0.0266414912 0.0005672379 1.053125e-02
## Room_Occupancy_Count 1.787247e-03 0.0006953385 0.0006565377 7.925060e-03
## Dim.13 Dim.14 Dim.15 Dim.16
## S1_Temp 3.573336e-03 3.939869e-04 3.811672e-03 6.336833e-03
## S2_Temp 9.503238e-03 7.651161e-03 5.535425e-04 5.664198e-06
## S3_Temp 1.092824e-03 1.377564e-02 2.980661e-03 1.368048e-02
## S4_Temp 3.853878e-03 4.868185e-03 7.326450e-04 1.459539e-02
## S1_Light 2.867294e-02 2.782549e-03 2.174350e-02 2.438522e-04
## S2_Light 2.430366e-02 2.723031e-03 5.306391e-03 8.535493e-04
## S3_Light 7.367283e-07 2.882337e-02 1.879555e-02 1.243368e-03
## S4_Light 6.037344e-04 8.486508e-03 5.237592e-03 4.556240e-05
## S1_Sound 1.851718e-03 1.712445e-07 5.333433e-04 5.949855e-05
## S2_Sound 6.556062e-05 2.301891e-03 7.661407e-05 2.078011e-06
## S3_Sound 1.285964e-07 3.290704e-03 3.593776e-04 1.192127e-06
## S4_Sound 1.558315e-04 2.363079e-04 5.789358e-05 3.981065e-05
## S5_CO2 2.547408e-02 1.840770e-07 1.419180e-02 5.594717e-03
## S5_CO2_Slope 8.839884e-03 2.153751e-04 3.900408e-03 4.425887e-04
## S6_PIR 1.689036e-03 3.462948e-04 1.303250e-04 8.177506e-06
## S7_PIR 2.092265e-05 1.012851e-03 1.684816e-03 8.373615e-06
## Room_Occupancy_Count 2.358921e-02 2.535527e-02 1.099867e-02 1.135480e-02
## Dim.17
## S1_Temp 1.158083e-02
## S2_Temp 2.054822e-04
## S3_Temp 5.739113e-03
## S4_Temp 4.106028e-06
## S1_Light 2.306841e-03
## S2_Light 3.401732e-04
## S3_Light 7.352579e-05
## S4_Light 2.932403e-04
## S1_Sound 4.206250e-07
## S2_Sound 2.852465e-05
## S3_Sound 1.270876e-07
## S4_Sound 1.527171e-06
## S5_CO2 2.234113e-04
## S5_CO2_Slope 1.563751e-06
## S6_PIR 6.247978e-06
## S7_PIR 2.592798e-08
## Room_Occupancy_Count 8.449838e-05
res.ind <- get_pca_ind(PC1)
head(res.ind$coord)
## Dim.1 Dim.2 Dim.3 Dim.4 Dim.5 Dim.6 Dim.7
## 1 -0.49176884 -2.057463 2.042530 -0.3111114 0.4505189 -0.04964022 0.1013454
## 2 0.01345097 -2.375430 1.634073 -0.8566862 -0.1310965 -0.80196580 2.0205045
## 3 -0.28196998 -2.067239 1.820692 -0.5945250 0.1881748 -0.30735271 0.9531395
## 4 -0.22409497 -2.019433 1.677049 -0.6982636 0.2581939 -0.22682942 0.9250154
## 5 -0.50178564 -1.702631 1.952595 -0.4696866 0.3504462 0.08890175 0.5916867
## 6 -0.50477508 -1.637695 1.928003 -0.4914579 0.3750207 0.15564721 0.4824411
## Dim.8 Dim.9 Dim.10 Dim.11 Dim.12 Dim.13 Dim.14
## 1 0.9457516 0.4158449 -0.9899429 0.4766940 -0.13896344 -0.7332880 0.2701110
## 2 0.8410630 1.6021748 -0.3086830 0.2630928 0.02046759 -0.4102313 0.3111490
## 3 0.9545745 0.8986524 -0.7286225 0.4021152 0.03809400 -0.6637389 0.2545731
## 4 0.9615613 0.8059382 -0.6819082 0.5606657 0.05496031 -0.6950894 0.3375974
## 5 1.0408145 0.5565351 -0.8447405 0.5830889 0.10545490 -0.7985600 0.3279713
## 6 1.0818959 0.4350690 -0.7931527 0.6175644 0.10674222 -0.8668803 0.3076527
## Dim.15 Dim.16 Dim.17
## 1 0.9045481 0.5405477 -0.7031799
## 2 0.6810523 0.5536047 -0.6750667
## 3 0.8325626 0.6246757 -0.4867604
## 4 0.7991589 0.5737076 -0.5560438
## 5 0.8150509 0.5992815 -0.5541046
## 6 0.8055304 0.6125350 -0.5635968
head(res.ind$contrib)
## Dim.1 Dim.2 Dim.3 Dim.4 Dim.5 Dim.6
## 1 2.608229e-04 0.02051418 0.03395208 0.001078349 0.0031028319 4.516562e-05
## 2 1.951332e-07 0.02734477 0.02173064 0.008176565 0.0002627330 1.178833e-02
## 3 8.574908e-05 0.02070957 0.02697755 0.003937927 0.0005413213 1.731469e-03
## 4 5.416116e-05 0.01976281 0.02288870 0.005432080 0.0010191174 9.430599e-04
## 5 2.715565e-04 0.01404852 0.03102800 0.002457784 0.0018774788 1.448642e-04
## 6 2.748018e-04 0.01299738 0.03025137 0.002690915 0.0021500210 4.440411e-04
## Dim.7 Dim.8 Dim.9 Dim.10 Dim.11 Dim.12
## 1 0.0002111592 0.01898982 0.004534058 0.030692016 0.008368327 8.747818e-04
## 2 0.0839308421 0.01501841 0.067304491 0.002984218 0.002549043 1.897720e-05
## 3 0.0186773353 0.01934579 0.021174234 0.016626862 0.005954705 6.573729e-05
## 4 0.0175913798 0.01963002 0.017030512 0.014563203 0.011576233 1.368349e-04
## 5 0.0071975630 0.02299924 0.008120997 0.022348674 0.012520708 5.037699e-04
## 6 0.0047850939 0.02485065 0.004962957 0.019702383 0.014045067 5.161443e-04
## Dim.13 Dim.14 Dim.15 Dim.16 Dim.17
## 1 0.03982747 0.007043643 0.08867540 0.05291489 0.2336872
## 2 0.01246497 0.009346511 0.05026905 0.05550209 0.2153751
## 3 0.03263082 0.006256590 0.07512312 0.07066740 0.1119779
## 4 0.03578614 0.011002999 0.06921593 0.05960615 0.1461235
## 5 0.04723334 0.010384475 0.07199615 0.06503867 0.1451061
## 6 0.05566110 0.009137647 0.07032402 0.06794722 0.1501202
head(res.ind$cos2)
## Dim.1 Dim.2 Dim.3 Dim.4 Dim.5 Dim.6
## 1 1.795525e-02 0.3142922 0.3097464 0.007186232 0.0150693803 0.0001829518
## 2 9.664928e-06 0.3014224 0.1426377 0.039204385 0.0009180654 0.0343560176
## 3 5.978778e-03 0.3213572 0.2492756 0.026579511 0.0026627455 0.0071036382
## 4 3.975262e-03 0.3228200 0.2226349 0.038595818 0.0052770780 0.0040728672
## 5 2.064139e-02 0.2376530 0.3125552 0.018085012 0.0100680501 0.0006479227
## 6 2.147893e-02 0.2260906 0.3133519 0.020360545 0.0118557015 0.0020422054
## Dim.7 Dim.8 Dim.9 Dim.10 Dim.11 Dim.12
## 1 0.000762566 0.06640847 0.01283903 0.072759495 0.016871306 1.433740e-03
## 2 0.218077454 0.03778750 0.13712319 0.005089985 0.003697507 2.237817e-05
## 3 0.068315572 0.06852143 0.06072817 0.039921966 0.012159276 1.091239e-04
## 4 0.067732869 0.07319063 0.05141679 0.036808941 0.024883387 2.391111e-04
## 5 0.028700276 0.08880741 0.02539146 0.058499103 0.027872257 9.116666e-04
## 6 0.019620284 0.09867059 0.01595633 0.053031073 0.032150023 9.604820e-04
## Dim.13 Dim.14 Dim.15 Dim.16 Dim.17
## 1 0.039922576 0.005416938 0.06074810 0.02169389 0.03671151
## 2 0.008989774 0.005171634 0.02477719 0.01637158 0.02434358
## 3 0.033128459 0.004873395 0.05212433 0.02934377 0.01781710
## 4 0.038245724 0.009021936 0.05055542 0.02605450 0.02447482
## 5 0.052277840 0.008818084 0.05445929 0.02944180 0.02517016
## 6 0.063348306 0.007978813 0.05469916 0.03162850 0.02677650
fviz_eig(PC1)
fviz_pca_ind(PC1,
col.ind = "cos2", # Color by the quality of representation
gradient.cols = c("#00AFBB", "#E7B800", "#FC4E07"),
repel = TRUE # Avoid text overlapping
)
## Warning: ggrepel: 10113 unlabeled data points (too many overlaps). Consider
## increasing max.overlaps
fviz_pca_var(PC1,
col.var = "contrib", # Color by contributions to the PC
gradient.cols = c("#00AFBB", "#E7B800", "#FC4E07"),
repel = TRUE # Avoid text overlapping
)