Sociolog preučuje, kateri dejavniki povzročajo stres v času študija. V vzorec je vključil 239 študentov, ki so se opredelili do 18 trditev, merjenih na Likertovi lestvici. Ali lahko sociolog na podlagi rezultatov analize definira manjše število dejavnikov, ki povzročajo proučevan stres?
podatki <- read.table("./Stres.csv", header=TRUE, sep=";", dec=",")
head(podatki, 3)
## ID q1 q2 q3 q4 q5 q6 q7 q8 q9 q10 q11 q12 q13 q14 q15 q16 q17 q18
## 1 1 4 5 6 3 5 6 5 6 3 3 4 5 6 5 4 7 4 5
## 2 2 6 5 6 4 5 5 5 6 6 4 5 4 6 5 4 6 4 5
## 3 3 6 2 2 2 4 2 2 2 2 2 2 2 1 2 2 1 2 2
Vse spremenljivke merjene na Likertovi lestvici (1: Sploh se ne strinjam, 7: Popolnoma se strinjam)
podatki_FA <- podatki[!colnames(podatki) %in% c("ID")]
R <- cor(podatki_FA)
library(psych)
corPlot(R)
#### FA: želimo si koleracijo med faktorji med 0,3 in 0,8. izogibamo se
zelo visokim koleracijam, ni nič narobe če je katera pod 0,3. Korelirati
morajo tisti indikatorji, tisti, ki merijo isti faktor. izračunati moraš
determinanto.
det(R)
## [1] 0.0004671319
library(psych)
cortest.bartlett(R, n = nrow(podatki_FA))
## $chisq
## [1] 1772.794
##
## $p.value
## [1] 1.963153e-273
##
## $df
## [1] 153
library(psych)
KMO(R)
## Kaiser-Meyer-Olkin factor adequacy
## Call: KMO(r = R)
## Overall MSA = 0.87
## MSA for each item =
## Deja Varn Hrup Obre Podp Preh Span Misl Depr Glav Zdra Prev Zrak Tesn
## 0.74 0.88 0.84 0.82 0.67 0.85 0.92 0.93 0.88 0.92 0.91 0.83 0.88 0.88
## Uspe Pogo Ogre Opre
## 0.85 0.85 0.84 0.87
library(psych)
fa.parallel(podatki_FA,
sim = FALSE,
fa = "fa")
## Parallel analysis suggests that the number of factors = 4 and the number of components = NA
library(psych)
library(GPArotation)
##
## Attaching package: 'GPArotation'
## The following objects are masked from 'package:psych':
##
## equamax, varimin
faktorska <- fa(podatki_FA,
covar = FALSE,
nfactors = 4,
fm = "minres",
rotate = "oblimin")
print.psych(faktorska,
cut = 0.4,
sort = TRUE)
## Factor Analysis using method = minres
## Call: fa(r = podatki_FA, nfactors = 4, rotate = "oblimin", covar = FALSE,
## fm = "minres")
## Standardized loadings (pattern matrix) based upon correlation matrix
## item MR1 MR2 MR3 MR4 h2 u2 com
## Tesn 14 0.80 0.76 0.24 1.1
## Depr 9 0.77 0.59 0.41 1.3
## Glav 10 0.76 0.58 0.42 1.1
## Zdra 11 0.74 0.68 0.32 1.1
## Span 7 0.54 0.66 0.34 1.8
## Misl 8 0.51 0.45 0.55 1.5
## Hrup 3 0.64 0.51 0.49 1.1
## Pogo 16 0.63 0.48 0.52 1.1
## Varn 2 0.59 0.39 0.61 1.1
## Preh 6 0.59 0.41 0.59 1.2
## Prev 12 0.45 0.24 0.76 1.2
## Ogre 17 0.41 0.45 0.55 2.5
## Zrak 13 0.41 0.46 0.54 2.0
## Uspe 15 0.68 0.52 0.48 1.2
## Obre 4 0.65 0.48 0.52 1.1
## Opre 18 0.53 0.35 0.65 1.1
## Podp 5 0.67 0.47 0.53 1.0
## Deja 1 0.66 0.51 0.49 1.1
##
## MR1 MR2 MR3 MR4
## SS loadings 3.53 2.74 1.60 1.12
## Proportion Var 0.20 0.15 0.09 0.06
## Cumulative Var 0.20 0.35 0.44 0.50
## Proportion Explained 0.39 0.30 0.18 0.12
## Cumulative Proportion 0.39 0.70 0.88 1.00
##
## With factor correlations of
## MR1 MR2 MR3 MR4
## MR1 1.00 0.50 0.37 0.21
## MR2 0.50 1.00 0.26 0.15
## MR3 0.37 0.26 1.00 0.14
## MR4 0.21 0.15 0.14 1.00
##
## Mean item complexity = 1.3
## Test of the hypothesis that 4 factors are sufficient.
##
## df null model = 153 with the objective function = 7.67 with Chi Square = 1772.79
## df of the model are 87 and the objective function was 0.75
##
## 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 239 with the empirical chi square 84.7 with prob < 0.55
## The total n.obs was 239 with Likelihood Chi Square = 170.37 with prob < 2.4e-07
##
## Tucker Lewis Index of factoring reliability = 0.908
## RMSEA index = 0.063 and the 90 % confidence intervals are 0.049 0.078
## BIC = -306.08
## Fit based upon off diagonal values = 0.99
## Measures of factor score adequacy
## MR1 MR2 MR3 MR4
## Correlation of (regression) scores with factors 0.95 0.91 0.86 0.83
## Multiple R square of scores with factors 0.90 0.82 0.74 0.69
## Minimum correlation of possible factor scores 0.80 0.65 0.48 0.38
Ostanki <- faktorska$residual
Ostanki <- as.matrix(Ostanki[upper.tri(Ostanki)])
VisokiOstanki <- abs(Ostanki) > 0.05
sum(VisokiOstanki)/nrow(Ostanki)
## [1] 0.1372549
podatki$F1 <- faktorska$scores[ , 1]
podatki$F2 <- faktorska$scores[ , 2]
podatki$F3 <- faktorska$scores[ , 3]
podatki$F4 <- faktorska$scores[ , 4]
podatki[48 , c(1, 20, 21, 22, 23)]
## ID F1 F2 F3 F4
## 48 48 -1.68385 -2.577348 -0.09284441 1.306588
Faktor <- podatki[, c("Hrup", "Pogo", "Varn", "Preh", "Prev", "Ogre", "Zrak")]
library(psych)
alpha(Faktor,
check.keys = TRUE)
##
## Reliability analysis
## Call: alpha(x = Faktor, check.keys = TRUE)
##
## raw_alpha std.alpha G6(smc) average_r S/N ase mean sd median_r
## 0.81 0.81 0.8 0.37 4.2 0.019 4.8 0.84 0.37
##
## 95% confidence boundaries
## lower alpha upper
## Feldt 0.76 0.81 0.84
## Duhachek 0.77 0.81 0.84
##
## Reliability if an item is dropped:
## raw_alpha std.alpha G6(smc) average_r S/N alpha se var.r med.r
## Hrup 0.77 0.77 0.75 0.36 3.4 0.023 0.0067 0.36
## Pogo 0.77 0.77 0.75 0.36 3.3 0.023 0.0051 0.37
## Varn 0.78 0.79 0.77 0.38 3.7 0.022 0.0059 0.37
## Preh 0.78 0.78 0.76 0.37 3.5 0.022 0.0085 0.37
## Prev 0.80 0.80 0.78 0.40 4.0 0.020 0.0052 0.39
## Ogre 0.79 0.79 0.77 0.38 3.7 0.021 0.0090 0.37
## Zrak 0.78 0.78 0.76 0.37 3.5 0.022 0.0079 0.36
##
## Item statistics
## n raw.r std.r r.cor r.drop mean sd
## Hrup 239 0.72 0.72 0.67 0.59 4.8 1.2
## Pogo 239 0.74 0.73 0.69 0.60 4.8 1.3
## Varn 239 0.66 0.66 0.58 0.52 4.9 1.2
## Preh 239 0.69 0.70 0.64 0.57 5.0 1.1
## Prev 239 0.60 0.60 0.49 0.44 4.9 1.3
## Ogre 239 0.66 0.65 0.56 0.50 4.1 1.3
## Zrak 239 0.69 0.69 0.62 0.55 5.4 1.2
##
## Non missing response frequency for each item
## 1 2 3 4 5 6 7 miss
## Hrup 0.01 0.03 0.08 0.28 0.28 0.27 0.05 0
## Pogo 0.02 0.04 0.10 0.21 0.28 0.30 0.05 0
## Varn 0.00 0.02 0.12 0.16 0.35 0.30 0.05 0
## Preh 0.01 0.02 0.04 0.22 0.38 0.27 0.06 0
## Prev 0.00 0.03 0.09 0.22 0.29 0.26 0.10 0
## Ogre 0.03 0.11 0.15 0.42 0.12 0.15 0.03 0
## Zrak 0.01 0.02 0.07 0.10 0.23 0.42 0.15 0