Rmd

Einführendes Beispiel Angst und Persönlichkeit

Die Daten entstammen dem Paket Psych.

Kurzbeschreibung bzw. über help(epi.bfi) [http://rgm3.lab.nig.ac.jp/RGM/R_rdfile?f=psych/man/epi.bfi.Rd&d=R_CC]

Big Five Dimensions and Facet (and correlated trait adjective)

Extraversion vs. introversion * Gregariousness (sociable) * Assertiveness (forceful) * Activity (energetic) * Excitement-seeking (adventurous) * Positive emotions (enthusiastic) * Warmth (outgoing)

Agreeableness vs. antagonism * Trust (forgiving) * Straightforwardness (not demanding) * Altruism (warm) * Compliance (not stubborn) * Modesty (not show-off) * Tender-mindedness (sympathetic)

Conscientiousness vs. lack of direction * Competence (efficient) * Order (organized) * Dutifulness (not careless) * Achievement striving (thorough) * Self-discipline (not lazy) * Deliberation (not impulsive)

Neuroticism vs. emotional stability * Anxiety (tense) * Angry hostility (irritable) * Depression (not contented) * Self-consciousness (shy) * Impulsiveness (moody) * Vulnerability (not self-confident)

Openness vs. closedness to experience * Ideas (curious) * Fantasy (imaginative) * Aesthetics (artistic) * Actions (wide interests) * Feelings (excitable) * Values (unconventional)

Faktor schwach ausgeprägt stark ausgeprägt
Neurotizismus selbstsicher, ruhig emotional, verletzlich
Extraversion zurückhaltend, reserviert gesellig
Offenheit für Erfahrungen konsistent, vorsichtig erfinderisch, neugierig
Verträglichkeit kompetitiv, misstrauisch kooperativ, freundlich, mitfühlend
Gewissenhaftigkeit unbekümmert, nachlässig effektiv, organisiert

Fragestellung: Wie gut kann Trait-Angst durch die Big-Five-Skalen Neurotizismus und Offenheit für Erfahrungen erklärt werden.

Daten einlesen, deskriptive Daten, erster grafischer Eindruck. Die Skalen sind bereits gebildet, die Einzelitems sind nicht im Datensatz enthalten.

# we need package psych
require("psych")
## Loading required package: psych
# read data
ddf <- psychTools::epi.bfi
# get data into namespace
attach(ddf)
# psych package gives a nice, short description of the data
psych:::describe(ddf)
##          vars   n   mean    sd median trimmed   mad min max range  skew
## epiE        1 231  13.33  4.14     14   13.49  4.45   1  22    21 -0.33
## epiS        2 231   7.58  2.69      8    7.77  2.97   0  13    13 -0.57
## epiImp      3 231   4.37  1.88      4    4.36  1.48   0   9     9  0.06
## epilie      4 231   2.38  1.50      2    2.27  1.48   0   7     7  0.66
## epiNeur     5 231  10.41  4.90     10   10.39  4.45   0  23    23  0.06
## bfagree     6 231 125.00 18.14    126  125.26 17.79  74 167    93 -0.21
## bfcon       7 231 113.25 21.88    114  113.42 22.24  53 178   125 -0.02
## bfext       8 231 102.18 26.45    104  102.99 22.24   8 168   160 -0.41
## bfneur      9 231  87.97 23.34     90   87.70 23.72  34 152   118  0.07
## bfopen     10 231 123.43 20.51    125  123.78 20.76  73 173   100 -0.16
## bdi        11 231   6.78  5.78      6    5.97  4.45   0  27    27  1.29
## traitanx   12 231  39.01  9.52     38   38.36  8.90  22  71    49  0.67
## stateanx   13 231  39.85 11.48     38   38.92 10.38  21  79    58  0.72
##          kurtosis   se
## epiE        -0.06 0.27
## epiS        -0.02 0.18
## epiImp      -0.62 0.12
## epilie       0.24 0.10
## epiNeur     -0.50 0.32
## bfagree     -0.27 1.19
## bfcon        0.23 1.44
## bfext        0.51 1.74
## bfneur      -0.55 1.54
## bfopen      -0.16 1.35
## bdi          1.50 0.38
## traitanx     0.47 0.63
## stateanx    -0.01 0.76
# correlation matrix
cor(ddf)
##                epiE        epiS      epiImp      epilie     epiNeur     bfagree
## epiE      1.0000000  0.84791012  0.80149700 -0.22219097 -0.17673625  0.17594316
## epiS      0.8479101  1.00000000  0.42625103 -0.05175109 -0.21670706  0.20427259
## epiImp    0.8014970  0.42625103  1.00000000 -0.24242865 -0.07395424  0.07893713
## epilie   -0.2221910 -0.05175109 -0.24242865  1.00000000 -0.25089261  0.17185824
## epiNeur  -0.1767363 -0.21670706 -0.07395424 -0.25089261  1.00000000 -0.08219006
## bfagree   0.1759432  0.20427259  0.07893713  0.17185824 -0.08219006  1.00000000
## bfcon    -0.1141498  0.04621194 -0.24000238  0.22556543 -0.13347321  0.44989862
## bfext     0.5434974  0.57735132  0.34720618 -0.04413118 -0.17054999  0.47848190
## bfneur   -0.0944616 -0.06895418 -0.08947612 -0.21946993  0.62747180 -0.04461721
## bfopen    0.1375564  0.15364990  0.06817649 -0.02527999  0.08750596  0.39415383
## bdi      -0.1563745 -0.13363483 -0.10602555 -0.20178646  0.57860862 -0.14145278
## traitanx -0.2328380 -0.25516199 -0.11826051 -0.23262712  0.72868850 -0.30545039
## stateanx -0.1311297 -0.11865925 -0.08908171 -0.15490999  0.48974620 -0.19449579
##                bfcon       bfext      bfneur      bfopen         bdi   traitanx
## epiE     -0.11414984  0.54349742 -0.09446160  0.13755642 -0.15637447 -0.2328380
## epiS      0.04621194  0.57735132 -0.06895418  0.15364990 -0.13363483 -0.2551620
## epiImp   -0.24000238  0.34720618 -0.08947612  0.06817649 -0.10602555 -0.1182605
## epilie    0.22556543 -0.04413118 -0.21946993 -0.02527999 -0.20178646 -0.2326271
## epiNeur  -0.13347321 -0.17054999  0.62747180  0.08750596  0.57860862  0.7286885
## bfagree   0.44989862  0.47848190 -0.04461721  0.39415383 -0.14145278 -0.3054504
## bfcon     1.00000000  0.26675235  0.04450273  0.30518284 -0.17900732 -0.2918801
## bfext     0.26675235  1.00000000  0.03712981  0.45876070 -0.13940254 -0.3932522
## bfneur    0.04450273  0.03712981  1.00000000  0.29347850  0.46616629  0.5930101
## bfopen    0.30518284  0.45876070  0.29347850  1.00000000 -0.07651051 -0.1052987
## bdi      -0.17900732 -0.13940254  0.46616629 -0.07651051  1.00000000  0.6547648
## traitanx -0.29188008 -0.39325224  0.59301013 -0.10529872  0.65476479  1.0000000
## stateanx -0.13752551 -0.14809702  0.49205672 -0.04246252  0.60873997  0.5711474
##             stateanx
## epiE     -0.13112969
## epiS     -0.11865925
## epiImp   -0.08908171
## epilie   -0.15490999
## epiNeur   0.48974620
## bfagree  -0.19449579
## bfcon    -0.13752551
## bfext    -0.14809702
## bfneur    0.49205672
## bfopen   -0.04246252
## bdi       0.60873997
## traitanx  0.57114741
## stateanx  1.00000000
# an overview of relevant scales
pairs.panels(ddf[,c("traitanx", "bfneur", "bfopen")])

Wie gut kann Trait-Angst durch die Big-Five-Skalen Neurotizismus und Offenheit für Erfahrungen erklärt werden?

Gesamtmodell anpassen

require("psych")
ddf <- psychTools::epi.bfi

# adapt model with big five scale values as explanatory variables
m.no <- lm(traitanx ~ bfneur + bfopen, data=ddf)
# summary of model 
summary(m.no)
## 
## Call:
## lm(formula = traitanx ~ bfneur + bfopen, data = ddf)
## 
## Residuals:
##      Min       1Q   Median       3Q      Max 
## -13.7307  -5.3200  -0.9284   3.8739  28.8526 
## 
## Coefficients:
##             Estimate Std. Error t value Pr(>|t|)    
## (Intercept) 32.02119    3.05213   10.49  < 2e-16 ***
## bfneur       0.27856    0.02121   13.13  < 2e-16 ***
## bfopen      -0.14192    0.02413   -5.88 1.44e-08 ***
## ---
## Signif. codes:  0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1
## 
## Residual standard error: 7.175 on 228 degrees of freedom
## Multiple R-squared:  0.437,  Adjusted R-squared:  0.4321 
## F-statistic:  88.5 on 2 and 228 DF,  p-value: < 2.2e-16

Beispiel EPI BFI

Die Daten entstammen dem Paket Psych.

Kurzbeschreibung bzw. über help(epi.bfi) [http://rgm3.lab.nig.ac.jp/RGM/R_rdfile?f=psych/man/epi.bfi.Rd&d=R_CC]

Daten einlesen, deskriptive Daten, erster grafischer Eindruck

# we need package psych
require("psych")
# read data
ddf <- psychTools::epi.bfi
# psych package gives a nice, short description of the data
psych:::describe(ddf)
##          vars   n   mean    sd median trimmed   mad min max range  skew
## epiE        1 231  13.33  4.14     14   13.49  4.45   1  22    21 -0.33
## epiS        2 231   7.58  2.69      8    7.77  2.97   0  13    13 -0.57
## epiImp      3 231   4.37  1.88      4    4.36  1.48   0   9     9  0.06
## epilie      4 231   2.38  1.50      2    2.27  1.48   0   7     7  0.66
## epiNeur     5 231  10.41  4.90     10   10.39  4.45   0  23    23  0.06
## bfagree     6 231 125.00 18.14    126  125.26 17.79  74 167    93 -0.21
## bfcon       7 231 113.25 21.88    114  113.42 22.24  53 178   125 -0.02
## bfext       8 231 102.18 26.45    104  102.99 22.24   8 168   160 -0.41
## bfneur      9 231  87.97 23.34     90   87.70 23.72  34 152   118  0.07
## bfopen     10 231 123.43 20.51    125  123.78 20.76  73 173   100 -0.16
## bdi        11 231   6.78  5.78      6    5.97  4.45   0  27    27  1.29
## traitanx   12 231  39.01  9.52     38   38.36  8.90  22  71    49  0.67
## stateanx   13 231  39.85 11.48     38   38.92 10.38  21  79    58  0.72
##          kurtosis   se
## epiE        -0.06 0.27
## epiS        -0.02 0.18
## epiImp      -0.62 0.12
## epilie       0.24 0.10
## epiNeur     -0.50 0.32
## bfagree     -0.27 1.19
## bfcon        0.23 1.44
## bfext        0.51 1.74
## bfneur      -0.55 1.54
## bfopen      -0.16 1.35
## bdi          1.50 0.38
## traitanx     0.47 0.63
## stateanx    -0.01 0.76
# correlation matrix
cor(ddf)
##                epiE        epiS      epiImp      epilie     epiNeur     bfagree
## epiE      1.0000000  0.84791012  0.80149700 -0.22219097 -0.17673625  0.17594316
## epiS      0.8479101  1.00000000  0.42625103 -0.05175109 -0.21670706  0.20427259
## epiImp    0.8014970  0.42625103  1.00000000 -0.24242865 -0.07395424  0.07893713
## epilie   -0.2221910 -0.05175109 -0.24242865  1.00000000 -0.25089261  0.17185824
## epiNeur  -0.1767363 -0.21670706 -0.07395424 -0.25089261  1.00000000 -0.08219006
## bfagree   0.1759432  0.20427259  0.07893713  0.17185824 -0.08219006  1.00000000
## bfcon    -0.1141498  0.04621194 -0.24000238  0.22556543 -0.13347321  0.44989862
## bfext     0.5434974  0.57735132  0.34720618 -0.04413118 -0.17054999  0.47848190
## bfneur   -0.0944616 -0.06895418 -0.08947612 -0.21946993  0.62747180 -0.04461721
## bfopen    0.1375564  0.15364990  0.06817649 -0.02527999  0.08750596  0.39415383
## bdi      -0.1563745 -0.13363483 -0.10602555 -0.20178646  0.57860862 -0.14145278
## traitanx -0.2328380 -0.25516199 -0.11826051 -0.23262712  0.72868850 -0.30545039
## stateanx -0.1311297 -0.11865925 -0.08908171 -0.15490999  0.48974620 -0.19449579
##                bfcon       bfext      bfneur      bfopen         bdi   traitanx
## epiE     -0.11414984  0.54349742 -0.09446160  0.13755642 -0.15637447 -0.2328380
## epiS      0.04621194  0.57735132 -0.06895418  0.15364990 -0.13363483 -0.2551620
## epiImp   -0.24000238  0.34720618 -0.08947612  0.06817649 -0.10602555 -0.1182605
## epilie    0.22556543 -0.04413118 -0.21946993 -0.02527999 -0.20178646 -0.2326271
## epiNeur  -0.13347321 -0.17054999  0.62747180  0.08750596  0.57860862  0.7286885
## bfagree   0.44989862  0.47848190 -0.04461721  0.39415383 -0.14145278 -0.3054504
## bfcon     1.00000000  0.26675235  0.04450273  0.30518284 -0.17900732 -0.2918801
## bfext     0.26675235  1.00000000  0.03712981  0.45876070 -0.13940254 -0.3932522
## bfneur    0.04450273  0.03712981  1.00000000  0.29347850  0.46616629  0.5930101
## bfopen    0.30518284  0.45876070  0.29347850  1.00000000 -0.07651051 -0.1052987
## bdi      -0.17900732 -0.13940254  0.46616629 -0.07651051  1.00000000  0.6547648
## traitanx -0.29188008 -0.39325224  0.59301013 -0.10529872  0.65476479  1.0000000
## stateanx -0.13752551 -0.14809702  0.49205672 -0.04246252  0.60873997  0.5711474
##             stateanx
## epiE     -0.13112969
## epiS     -0.11865925
## epiImp   -0.08908171
## epilie   -0.15490999
## epiNeur   0.48974620
## bfagree  -0.19449579
## bfcon    -0.13752551
## bfext    -0.14809702
## bfneur    0.49205672
## bfopen   -0.04246252
## bdi       0.60873997
## traitanx  0.57114741
## stateanx  1.00000000
# an overview of EPI scales
pairs.panels(ddf[,1:5])

Gesamtmodell: Wie gut kann Trait-Angst durch die Big-Five-Skalen erklärt werden?

Wir schätzen die Trait-Angst aus einer Linearkombination der Big-Five-Skalen. Wir betrachten das summary()

require("psych")
ddf <- psychTools::epi.bfi

# adapt model with big five scale values as explanatory variables
m.bf <- lm(traitanx ~ bfagree + bfcon + bfext + bfneur + bfopen, data=ddf)
# summary of model 
summary(m.bf)
## 
## Call:
## lm(formula = traitanx ~ bfagree + bfcon + bfext + bfneur + bfopen, 
##     data = ddf)
## 
## Residuals:
##      Min       1Q   Median       3Q      Max 
## -16.2952  -4.2436  -0.7314   3.3558  21.2960 
## 
## Coefficients:
##             Estimate Std. Error t value Pr(>|t|)    
## (Intercept) 42.74134    3.55405  12.026  < 2e-16 ***
## bfagree      0.00325    0.02876   0.113    0.910    
## bfcon       -0.09197    0.02144  -4.290 2.66e-05 ***
## bfext       -0.11751    0.01893  -6.208 2.56e-09 ***
## bfneur       0.26054    0.01889  13.793  < 2e-16 ***
## bfopen      -0.03756    0.02494  -1.506    0.133    
## ---
## Signif. codes:  0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1
## 
## Residual standard error: 6.273 on 225 degrees of freedom
## Multiple R-squared:  0.5753, Adjusted R-squared:  0.5659 
## F-statistic: 60.97 on 5 and 225 DF,  p-value: < 2.2e-16

Standardisierte Gewichte, vergleichbar

Wir berechnen die standartisierten Gewichte, indem wir die Variablen im Spiel vorher standardisieren (z-transformieren).

require("psych")
ddf <- psychTools::epi.bfi
# do the same with standardized variables
ms.bf <- lm(scale(traitanx) ~ scale(bfagree) + scale(bfcon) + scale(bfext) + scale(bfneur) + scale(bfopen), data=ddf)
# compare the coefficients 
ms.bf$coefficients
##    (Intercept) scale(bfagree)   scale(bfcon)   scale(bfext)  scale(bfneur) 
##  -1.823477e-16   6.192817e-03  -2.113170e-01  -3.264464e-01   6.385508e-01 
##  scale(bfopen) 
##  -8.088944e-02
m.bf$coefficients
##  (Intercept)      bfagree        bfcon        bfext       bfneur       bfopen 
## 42.741336772  0.003249864 -0.091968547 -0.117513857  0.260540623 -0.037558314
# better to read
round(ms.bf$coefficients, digits=3)
##    (Intercept) scale(bfagree)   scale(bfcon)   scale(bfext)  scale(bfneur) 
##          0.000          0.006         -0.211         -0.326          0.639 
##  scale(bfopen) 
##         -0.081

Eine Streudiagramm-Matrix

require("psych")
ddf <- psychTools::epi.bfi

# scatterplot matrix 
pairs.panels(ddf[,c('traitanx', 'bfagree', 'bfcon', 'bfext', 'bfneur', 'bfopen')])

Qualität der Analyse: NV der Residuen, Residualanalyse

# again the model
require("psych")
ddf <- psychTools::epi.bfi
m.bf <- lm(traitanx ~ bfagree + bfcon + bfext + bfneur + bfopen, data=ddf)
# all, used by ggplot has to reside in one dataframe
# we prepare adequate dataframe
# fitted values and studentized.residuals in columns
#ddf.plot <- cbind(ddf[,c('traitanx', 'bfagree', 'bfcon', 'bfext', 'bfneur', 'bfopen')])
ddf.plot = data.frame(subj = 1:length(traitanx), ddf[,c('traitanx', 'bfagree', 'bfcon', 'bfext', 'bfneur', 'bfopen')])
ddf.plot['fitted.values']          <- m.bf$fitted.values
ddf.plot['studentized.residuals']  <- rstudent(m.bf)
ddf.plot['standardized.residuals'] <- rstandard(m.bf)
library(tidyverse)
## ── Attaching packages ───────────────────────────────────────────────────────────────────────────────────────────────── tidyverse 1.3.0 ──
## ✓ ggplot2 3.3.2     ✓ purrr   0.3.4
## ✓ tibble  3.0.1     ✓ dplyr   0.8.4
## ✓ tidyr   1.0.2     ✓ stringr 1.4.0
## ✓ readr   1.3.1     ✓ forcats 0.4.0
## Warning: package 'ggplot2' was built under R version 3.6.2
## Warning: package 'tibble' was built under R version 3.6.2
## Warning: package 'purrr' was built under R version 3.6.2
## ── Conflicts ──────────────────────────────────────────────────────────────────────────────────────────────────── tidyverse_conflicts() ──
## x ggplot2::%+%()   masks psych::%+%()
## x ggplot2::alpha() masks psych::alpha()
## x dplyr::filter()  masks stats::filter()
## x dplyr::lag()     masks stats::lag()
pplot <- ggplot(ddf.plot, aes(studentized.residuals)) +
  # {} opts(legend.position = 'none') + 
  geom_histogram(aes(y=..density..), solor = 'black', fill = 'white') +
  labs(x = "Studentized Residuals", y = "Density")
## Warning: Ignoring unknown parameters: solor
pplot + 
  stat_function(fun = dnorm, args = list(mean = mean(ddf.plot$studentized.residuals, na.rm=TRUE), sd=sd(ddf$studentized.residuals, na.rm=TRUE)), color = "red", size=1)
## `stat_bin()` using `bins = 30`. Pick better value with `binwidth`.
## Warning: Removed 101 row(s) containing missing values (geom_path).

# qq-plot studentized residuals
pplot <- ggplot(ddf.plot, aes(sample=ddf.plot$studentized.residuals)) + 
  stat_qq(color="firebrick2", alpha=1) + 
  geom_abline(intercept = mean(ddf.plot$studentized.residuals), slope = sd(ddf.plot$studentized.residuals))
# show it
pplot
## Warning: Use of `ddf.plot$studentized.residuals` is discouraged. Use
## `studentized.residuals` instead.

# get the extreme value subjects
extremes <- ddf.plot$subj[abs(ddf.plot$standardized.residuals) > 2]
extremes.exist <- ifelse(length(extremes), 1, 0)
if (length(extremes)){
  print(paste('extreme studentized values in observation: ', extremes))
  ddf.plot[extremes,]
} 
##  [1] "extreme studentized values in observation:  6"  
##  [2] "extreme studentized values in observation:  31" 
##  [3] "extreme studentized values in observation:  32" 
##  [4] "extreme studentized values in observation:  47" 
##  [5] "extreme studentized values in observation:  76" 
##  [6] "extreme studentized values in observation:  92" 
##  [7] "extreme studentized values in observation:  93" 
##  [8] "extreme studentized values in observation:  96" 
##  [9] "extreme studentized values in observation:  138"
## [10] "extreme studentized values in observation:  150"
##     subj traitanx bfagree bfcon bfext bfneur bfopen fitted.values
## 6      6       51     110   113    61     54    149      34.01104
## 31    31       23     112    90    87     77    143      39.29524
## 32    32       64     113   121    53    100     84      48.65131
## 47    47       60     112   102    83    105    125      46.63286
## 76    76       60     120   143   118    112    141      39.99801
## 92    92       36     120    98    54     97    118      48.61321
## 93    93       71     124   116    32     98    121      49.70395
## 96    96       71     100   103   121    152    158      53.04235
## 138  138       52     136   111   124     82    104      35.86136
## 150  150       53     134   120    68     69    112      37.92042
##     studentized.residuals standardized.residuals
## 6                2.838336               2.794851
## 31              -2.667954              -2.632405
## 32               2.522436               2.492903
## 47               2.159492               2.142123
## 76               3.294959               3.225074
## 92              -2.049586              -2.035161
## 93               3.568556               3.478987
## 96               3.003102               2.950978
## 138              2.631457               2.597481
## 150              2.456279               2.429258
# plot residuals against predicted values using ggplot
pplot <- ggplot(ddf.plot, aes(fitted.values, studentized.residuals))
pplot +
  geom_point() +
  geom_smooth(method="lm", color="Blue") +
  labs(x="Fitted Values", y="Studentized Residual")
## `geom_smooth()` using formula 'y ~ x'

Extremwerte und einflussreiche Fälle?

# again the model
m.bf <- lm(traitanx ~ bfagree + bfcon + bfext + bfneur + bfopen)
# we prepare adequate dataframe
ddf.plot = data.frame(subj = 1:length(traitanx), ddf[,c('traitanx', 'bfagree', 'bfcon', 'bfext', 'bfneur', 'bfopen')])
ddf.plot['fitted.values']         <- m.bf$fitted.values
ddf.plot['studentized.residuals'] <- rstudent(m.bf)
ddf.plot['cooks.distance']        <- cooks.distance(m.bf)
ddf.plot['dfbeta']                <- dfbeta(m.bf)
ddf.plot['dffits']                <- dffits(m.bf)
ddf.plot['hatvalues']             <- hatvalues(m.bf)
ddf.plot['covratio']              <- covratio(m.bf)
# example: plot cooks distance against subject number - you have to identify the person
pplot <- ggplot(ddf.plot, aes(subj, cooks.distance, ymin=0, ymax=cooks.distance), title="Cook's Distance") +
  geom_point() + 
  geom_linerange() +
  scale_x_continuous("Observation Number") +
  scale_y_continuous("Cook's distance") 
      #opts(title="Cook's Distance")
pplot

# get at persons above Cook's distance above 0.5
# find observations with cooks distance > 1
extremes <- ddf.plot$subj[cooks.distance(m.bf) > 0.5]
if(length(extremes)) {
  print(paste('extreme cooks distances in observation: ', extremes))
  ddf.plot[extremes,]
}

Voraussetzung Unabhängigkeit der Fehler

Daumenregel: Je näher an 2, desto besser. Werte unter 1 und über 3 sollten aufmerksam machen.

# again the model
m.bf <- lm(traitanx ~ bfagree + bfcon + bfext + bfneur + bfopen)
car::durbinWatsonTest(m.bf)
##  lag Autocorrelation D-W Statistic p-value
##    1      -0.1172569      2.234047   0.072
##  Alternative hypothesis: rho != 0
# or dwt(m.bf)
if (car::dwt(m.bf)[2] < 1 | car::dwt(m.bf)[2] > 3){
  message("Durbin Watson Test zur Unabhängigkeit der Residuen vom vorhergesagten Wert ist auffällig")
}

Multikollinearität

VIF (Variation Inflation Factor) oder tolerance. Sie sind ineinander überführbar: \(tolerance = \frac{1}{vif}\)

Empfehlungen bei VIF

  • Achtung wenn es VIF größer 10 gibt bzw. wenn es Toleranzwerte < 0.1 gibt
  • Achtung wenn der durchschnittliche VIF deutlich größer als 1 ist.
  • Toleranzwerte < 0.2 sollten Verdacht auf Multikollinearität wecken
library(car)
## Loading required package: carData
## 
## Attaching package: 'car'
## The following object is masked from 'package:dplyr':
## 
##     recode
## The following object is masked from 'package:purrr':
## 
##     some
## The following object is masked from 'package:psych':
## 
##     logit
# again the model
m.bf <- lm(traitanx ~ bfagree + bfcon + bfext + bfneur + bfopen)
# output vif
message(paste("vif: ", vif(m.bf)))
## vif:  1.5914495483492vif:  1.28584057965325vif:  1.46505293753843vif:  1.13562678127135vif:  1.52840419706987
# output tolerance
message(paste("tolerance: ", 1 / vif(m.bf)))
## tolerance:  0.628357965250793tolerance:  0.77770138524456tolerance:  0.682569192127753tolerance:  0.880570990832472tolerance:  0.654277187878126
# mean of vif
message(paste("mean tolerance: ", mean(vif(m.bf))))
## mean tolerance:  1.40127480877642
if (length(vif(m.bf)[vif(m.bf) > 5])) {
  message("suspicious:")
  vif(m.bf)[vif(m.bf) > 5]
}

# {} schräges Modell

Version: 26 Juni, 2020 21:58