knitr::opts_chunk$set(echo = TRUE)
options(width=120)
#install.packages("car")
library(car)
## Loading required package: carData
#install.packages("ggplot2")
library(ggplot2)
#install.packages("reshape2")
library(reshape2)
#install.packages("paran")
library(paran)
## Loading required package: MASS
#install.packages("FactoMineR")
library(FactoMineR)
#install.packages("factoextra")
library(factoextra)
## Welcome! Want to learn more? See two factoextra-related books at https://goo.gl/ve3WBa
#install.packages("GPArotation")
library(GPArotation)
#install.packages("psych")
library(psych)
## 
## Attaching package: 'psych'
## The following objects are masked from 'package:GPArotation':
## 
##     equamax, varimin
## The following objects are masked from 'package:ggplot2':
## 
##     %+%, alpha
## The following object is masked from 'package:car':
## 
##     logit
#install.packages("psychTools")
library(psychTools)
## 
## Attaching package: 'psychTools'
## The following object is masked from 'package:car':
## 
##     recode
podatki <- read.csv("./SL_csv.csv")
brisanje = c(1,2,18)
podatki <- subset(podatki,select = - brisanje)
colnames(podatki)[1]="V1"
colnames(podatki)[2]="V2"
colnames(podatki)[3]="V3"
colnames(podatki)[4]="V4"
colnames(podatki)[5]="V5"
colnames(podatki)[6]="V6"
colnames(podatki)[7]="V7"
colnames(podatki)[8]="V8"
colnames(podatki)[9]="V9"
colnames(podatki)[10]="V10"
colnames(podatki)[11]="V11"
colnames(podatki)[12]="V12"
colnames(podatki)[13]="V13"
colnames(podatki)[14]="V14"
colnames(podatki)[15]="V15"
podatki <- cbind(ID=1:NROW(podatki),podatki)
head(podatki)
##   ID V1 V2 V3 V4 V5 V6 V7 V8 V9 V10 V11 V12 V13 V14 V15
## 1  1  3  3  4  3  2  4  3  3  2   3   4   2   2   3   3
## 2  2  5  4  4  4  3  3  2  4  3   4   3   4   3   4   4
## 3  3  3  4  3  3  4  2  4  3  2   2   3   2   3   3   3
## 4  4  1  3  3  4  4  2  2  2  2   2   4   4   4   4   5
## 5  5  4  4  4  5  5  4  4  3  4   4   5   5   5   3   3
## 6  6  2  3  2  3  3  3  1  4  3   5   1   2   4   1   2

Enota = oseba n = 1210

Opis spremenljivk: V1 - I learn better by reading what the teacher writes on the chalkboard. V2 - When I read instructions, I remember them better. V3 - I understand better when I read instructions. V4 - I learn better by reading than by listening to someone. V5 - I learn more by reading textbooks than by listening to lectures. V6 - When the teacher tells me the instructions I understand better V7 - When someone tells me how to do something in class, I learn it better. V8 - I remember things I have heard in class better than things I have read. V9 - I learn better in class when the teacher gives a lecture. V10 - I learn better in class when I listen to someone. V11 - I prefer to learn by doing something in class. V12- When I do things in class, I learn better. V13 - I enjoy learning in class by doing experiments. V14 - I understand things better in class when I participate in role-playing. V15 - I understand things better in class when I participate in role-playing.

library(pastecs)
round(stat.desc(podatki[-1], basic=FALSE),2) #aritmetična sredina med 1 in 5, največja variabilnost = 0,35 (najmanj enotni)
##                V1   V2   V3   V4   V5   V6   V7   V8   V9  V10  V11  V12  V13  V14  V15
## median       3.00 4.00 3.00 3.00 3.00 4.00 4.00 3.00 3.00 3.00 4.00 4.00 4.00 4.00 4.00
## mean         3.29 3.46 3.36 3.30 3.23 3.48 3.44 3.34 3.27 3.39 3.52 3.59 3.63 3.41 3.51
## SE.mean      0.03 0.03 0.03 0.03 0.03 0.03 0.03 0.03 0.03 0.03 0.03 0.03 0.03 0.03 0.03
## CI.mean.0.95 0.06 0.06 0.06 0.06 0.06 0.06 0.06 0.06 0.06 0.06 0.06 0.06 0.06 0.06 0.06
## var          1.25 0.97 1.02 1.12 1.25 1.02 1.05 1.17 1.12 1.09 1.27 1.09 1.26 1.08 0.98
## std.dev      1.12 0.98 1.01 1.06 1.12 1.01 1.03 1.08 1.06 1.04 1.13 1.04 1.12 1.04 0.99
## coef.var     0.34 0.28 0.30 0.32 0.35 0.29 0.30 0.32 0.32 0.31 0.32 0.29 0.31 0.30 0.28
sapply(podatki[-1], FUN = min) #Statistika MIN - preverimo, da ni katera izven 1-5, kar bi bila napaka (Likhartova lestica)
##  V1  V2  V3  V4  V5  V6  V7  V8  V9 V10 V11 V12 V13 V14 V15 
##   1   1   1   1   1   1   1   1   1   1   1   1   1   1   1
sapply(podatki[-1], FUN = max) #Statistika MAX -preverimo, da ni katera izven 1-5, kar bi bila napaka (Likhartova lestica)
##  V1  V2  V3  V4  V5  V6  V7  V8  V9 V10 V11 V12 V13 V14 V15 
##   5   5   5   5   5   5   5   5   5   5   5   5   5   5   5
Podatki_FA <- podatki[,c(-1)]
R <- cor(Podatki_FA)

library(psych) 
corPlot(R) #grafični prikaz korelacijske matrike

library(psych)
cortest.bartlett(R, n=nrow(podatki)) #preizkus sferičnosti, zavrnemo H0
## $chisq
## [1] 3294.656
## 
## $p.value
## [1] 0
## 
## $df
## [1] 105
det(R) #indikatorji niso preveč povezani (determinanta korelacijske matrike)
## [1] 0.06467889
library(psych) #KMO in MSA statistika = podatki so ustrezni
KMO(R)
## Kaiser-Meyer-Olkin factor adequacy
## Call: KMO(r = R)
## Overall MSA =  0.85
## MSA for each item = 
##   V1   V2   V3   V4   V5   V6   V7   V8   V9  V10  V11  V12  V13  V14  V15 
## 0.82 0.87 0.89 0.71 0.69 0.86 0.88 0.85 0.84 0.87 0.85 0.87 0.84 0.88 0.84
fa.parallel(Podatki_FA,
            sim = FALSE, #paralelna analiza
            fa = "fa")

## Parallel analysis suggests that the number of factors =  5  and the number of components =  NA
library(psych)
library(GPArotation)
faktorska <- fa(Podatki_FA,
                covar = FALSE, 
                fm = "minres",
                nfactors = 4, 
                rotate = "oblimin", 
                impute = "mean") 

print.psych(faktorska, 
            cut = 0.3, 
            sort = TRUE)
## Factor Analysis using method =  minres
## Call: fa(r = Podatki_FA, nfactors = 4, rotate = "oblimin", covar = FALSE, 
##     impute = "mean", fm = "minres")
## Standardized loadings (pattern matrix) based upon correlation matrix
##     item   MR1   MR3   MR4   MR2   h2   u2 com
## V13   13  0.72                   0.51 0.49 1.0
## V11   11  0.52                   0.37 0.63 1.2
## V15   15  0.51                   0.41 0.59 1.4
## V14   14                         0.22 0.78 2.0
## V6     6        0.56             0.42 0.58 1.1
## V9     9        0.52             0.34 0.66 1.2
## V1     1        0.50             0.22 0.78 1.1
## V2     2        0.31             0.26 0.74 2.8
## V7     7                         0.27 0.73 2.4
## V10   10              0.57       0.37 0.63 1.2
## V12   12              0.52       0.44 0.56 1.3
## V8     8        0.32  0.33       0.29 0.71 2.6
## V3     3                         0.23 0.77 3.7
## V5     5                    0.67 0.46 0.54 1.0
## V4     4                    0.43 0.28 0.72 1.8
## 
##                        MR1  MR3  MR4  MR2
## SS loadings           1.52 1.48 1.23 0.85
## Proportion Var        0.10 0.10 0.08 0.06
## Cumulative Var        0.10 0.20 0.28 0.34
## Proportion Explained  0.30 0.29 0.24 0.17
## Cumulative Proportion 0.30 0.59 0.83 1.00
## 
##  With factor correlations of 
##      MR1  MR3  MR4  MR2
## MR1 1.00 0.38 0.56 0.11
## MR3 0.38 1.00 0.42 0.18
## MR4 0.56 0.42 1.00 0.22
## MR2 0.11 0.18 0.22 1.00
## 
## Mean item complexity =  1.7
## Test of the hypothesis that 4 factors are sufficient.
## 
## df null model =  105  with the objective function =  2.74 with Chi Square =  3294.66
## df of  the model are 51  and the objective function was  0.17 
## 
## The root mean square of the residuals (RMSR) is  0.03 
## The df corrected root mean square of the residuals is  0.04 
## 
## The harmonic n.obs is  1210 with the empirical chi square  172.87  with prob <  3.7e-15 
## The total n.obs was  1210  with Likelihood Chi Square =  201.8  with prob <  8e-20 
## 
## Tucker Lewis Index of factoring reliability =  0.902
## RMSEA index =  0.049  and the 90 % confidence intervals are  0.042 0.057
## BIC =  -160.21
## Fit based upon off diagonal values = 0.99
## Measures of factor score adequacy             
##                                                    MR1  MR3  MR4  MR2
## Correlation of (regression) scores with factors   0.86 0.83 0.82 0.76
## Multiple R square of scores with factors          0.73 0.68 0.67 0.58
## Minimum correlation of possible factor scores     0.46 0.36 0.35 0.16

V8 problematična saj ne vemo h kateremu faktorju spada. V1 ima tudi najnižjo komunaliteto (izložimo) Spremenljivke zaradi visokega Hofmanovega indeksa kompleksnosti (<2) odstranimo (V2, V8, V3, V1)

Podatki_FA <- podatki[ , !colnames(podatki) %in% c("ID", "V8", "V3", "V2", "V1")]

library(psych)
library(GPArotation)
faktorska <- fa(Podatki_FA, 
                covar = FALSE, 
                fm = "minres",
                nfactors = 4, 
                rotate = "oblimin", 
                impute = "mean") 

print.psych(faktorska, 
            cut = 0.3, 
            sort = TRUE)
## Factor Analysis using method =  minres
## Call: fa(r = Podatki_FA, nfactors = 4, rotate = "oblimin", covar = FALSE, 
##     impute = "mean", fm = "minres")
## Standardized loadings (pattern matrix) based upon correlation matrix
##     item   MR4   MR1   MR3   MR2   h2   u2 com
## V12    8  0.73                   0.54 0.46 1.0
## V10    6  0.43                   0.29 0.71 1.6
## V15   11  0.35  0.33             0.37 0.63 2.0
## V14   10                         0.21 0.79 2.7
## V13    9        0.88             0.76 0.24 1.0
## V11    7        0.32             0.34 0.66 2.5
## V9     5              0.66       0.43 0.57 1.0
## V6     3              0.47       0.32 0.68 1.1
## V7     4              0.33       0.28 0.72 1.9
## V5     2                    0.66 0.43 0.57 1.0
## V4     1                    0.47 0.29 0.71 1.6
## 
##                        MR4  MR1  MR3  MR2
## SS loadings           1.25 1.17 1.06 0.78
## Proportion Var        0.11 0.11 0.10 0.07
## Cumulative Var        0.11 0.22 0.32 0.39
## Proportion Explained  0.29 0.27 0.25 0.18
## Cumulative Proportion 0.29 0.57 0.82 1.00
## 
##  With factor correlations of 
##      MR4  MR1  MR3  MR2
## MR4 1.00 0.51 0.46 0.20
## MR1 0.51 1.00 0.40 0.17
## MR3 0.46 0.40 1.00 0.26
## MR2 0.20 0.17 0.26 1.00
## 
## Mean item complexity =  1.6
## Test of the hypothesis that 4 factors are sufficient.
## 
## df null model =  55  with the objective function =  1.93 with Chi Square =  2326.4
## df of  the model are 17  and the objective function was  0.09 
## 
## The root mean square of the residuals (RMSR) is  0.03 
## The df corrected root mean square of the residuals is  0.05 
## 
## The harmonic n.obs is  1210 with the empirical chi square  92.23  with prob <  2.4e-12 
## The total n.obs was  1210  with Likelihood Chi Square =  108.56  with prob <  2.2e-15 
## 
## Tucker Lewis Index of factoring reliability =  0.869
## RMSEA index =  0.067  and the 90 % confidence intervals are  0.055 0.079
## BIC =  -12.11
## Fit based upon off diagonal values = 0.99
## Measures of factor score adequacy             
##                                                    MR4  MR1  MR3  MR2
## Correlation of (regression) scores with factors   0.84 0.89 0.80 0.75
## Multiple R square of scores with factors          0.70 0.80 0.64 0.56
## Minimum correlation of possible factor scores     0.41 0.60 0.28 0.12
fa.diagram(faktorska)

Matrika_ostankov <- faktorska$residual
Ostanki <- as.matrix(Matrika_ostankov[upper.tri(Matrika_ostankov)])
head(Ostanki)
##              [,1]
## [1,]  0.002823957
## [2,]  0.047982051
## [3,] -0.030453896
## [4,] -0.020532772
## [5,]  0.016032579
## [6,] -0.018988213
VisokiOstanki <- abs(Ostanki) > 0.05

head(VisokiOstanki)
##       [,1]
## [1,] FALSE
## [2,] FALSE
## [3,] FALSE
## [4,] FALSE
## [5,] FALSE
## [6,] FALSE
sum(VisokiOstanki)/nrow(VisokiOstanki) #ostanki sicer niso nižji od 0,05, vendar niso bistveno višji, to pomeni, da se model relativno dobro prilagaja podatkom
## [1] 0.05454545
head(faktorska$scores)
##              MR4        MR1        MR3        MR2
## [1,] -1.20152237 -1.2959483 -0.7003455 -0.9231587
## [2,]  0.16904427 -0.4511286 -0.4697241  0.2485474
## [3,] -1.38485000 -0.7286459 -1.3027838  0.0246111
## [4,]  0.06849661  0.4574573 -1.1289429  0.4348978
## [5,]  1.03368261  1.1586671  1.1640467  1.7184969
## [6,] -1.72323607 -0.4134509 -1.4586271 -0.1732887

Faktorska analiza je bila uporabljena, saj me je zanimalo na podlagi Likharove lestive ali se anketiranci lažje učijo/osvojijo snov, glede na tip učenja/predavanje in povezave med njimi. Omenjenjeno temo je težko konkretno izmeriti = meri latentne spremenljivke.

Raziskovalno vprašanje - Kako lahko na podlagi zbranih podatkov opišemo tipe učenja med anketiranci.

Fakorska analiza je bila izvedena na 1210 osebah (n=1210). KMO mera vzorčne ustreznosti zagotavlja uspešno izvedbo faktroske analize (KMO = 0,85). MSA statistike za posamezne indikatorje pa so vse nad 0,69. Na podlagi paralelne analize smo se odločili za rešitev s 4 faktorji, uporabili pa smo poševno rotacij, zaradi matrike korelacijskih koeficientov. Štiri indikatorje smo zaradi visokega indeksa kompleksnosti in nizke komunalitete odstranili iz analize. Na podlagi konfiguracijskih uteži smo poimenovali naslednje 4 faktorje:

  1. Faktor 1 / MR4 = Aktivni učni stil
  2. Faktor 2 / MR1 = Kinestetični / eksperimentalni učni stil
  3. Faktor 3 / MR3 = Avditivni učni stil
  4. Faktor 4 / MR2 = Vizualni učni stil