rm(list = ls())
date()
## [1] "Tue May 21 00:07:14 2024"
sessionInfo()
## R version 4.3.2 (2023-10-31)
## Platform: x86_64-apple-darwin20 (64-bit)
## Running under: macOS Ventura 13.6.7
## 
## Matrix products: default
## BLAS:   /Library/Frameworks/R.framework/Versions/4.3-x86_64/Resources/lib/libRblas.0.dylib 
## LAPACK: /Library/Frameworks/R.framework/Versions/4.3-x86_64/Resources/lib/libRlapack.dylib;  LAPACK version 3.11.0
## 
## locale:
## [1] en_US.UTF-8/en_US.UTF-8/en_US.UTF-8/C/en_US.UTF-8/en_US.UTF-8
## 
## time zone: Europe/Moscow
## tzcode source: internal
## 
## attached base packages:
## [1] stats     graphics  grDevices utils     datasets  methods   base     
## 
## loaded via a namespace (and not attached):
##  [1] digest_0.6.34     R6_2.5.1          fastmap_1.1.1     xfun_0.41        
##  [5] cachem_1.0.8      knitr_1.45        htmltools_0.5.7   rmarkdown_2.25   
##  [9] lifecycle_1.0.4   cli_3.6.2         sass_0.4.8        jquerylib_0.1.4  
## [13] compiler_4.3.2    rstudioapi_0.16.0 tools_4.3.2       evaluate_0.23    
## [17] bslib_0.6.1       yaml_2.3.8        rlang_1.1.3       jsonlite_1.8.8
options(scipen = 999) # Убирает научную запись чисел

Библиотеки

library(ggplot2)
library(tidyr)
library(dplyr)
## 
## Attaching package: 'dplyr'
## The following objects are masked from 'package:stats':
## 
##     filter, lag
## The following objects are masked from 'package:base':
## 
##     intersect, setdiff, setequal, union
library(psych)
## 
## Attaching package: 'psych'
## The following objects are masked from 'package:ggplot2':
## 
##     %+%, alpha

Импорт таблицы

Список переменных

Nationality - Страна

Sex - Пол

Age - Возраст

ResidenceChild - Место жительства в детстве

ResidenceAdult - Текущее место жительства

Психологическое благополучие

W_PositiveRel
W_Autonomy
W_EnvMastery
W_PersGrowth
W_PurposeLife
W_SelfAcceptance WellBeing

EnvIdentity

Ценности:

V_Conformity
V_tradition V_benevolence
V_universalism
V_Selfdirection V_Stimulation
V_Hedonism
V_Achievement
V_Power V_Security

Data <- read.delim2("../thes_2.tsv")
Data$Nationality <- factor(Data$Nationality, levels = c(0, 1), labels = c("France", "Russia"), ordered = FALSE)
Data$Sex <- factor(Data$Sex, levels = c(0, 1), labels = c("Female", "Male"), ordered = FALSE)       
Data$ResidenceChild <- factor(Data$ResidenceChild, levels = c(1:4), ordered = TRUE, labels = c("BigCity"                                                          , "SmallTown"
                          , "Village"
                          , "SmallVillage"
                          )
)

Data$ResidenceAdult <- factor(Data$ResidenceAdult, levels = c(1:4), ordered = TRUE, labels = c("BigCity"
                       , "SmallTown"
                       , "Village"
                       , "SmallVillage"
                        )
)         

Проверка таблицы

head(Data) # Начало таблицы
##   Nationality    Sex Age ResidenceChild ResidenceAdult W_PositiveRel W_Autonomy
## 1      Russia Female  23        BigCity        BigCity            51         45
## 2      Russia   Male  22        BigCity        BigCity            47         60
## 3      Russia Female  21        BigCity        BigCity            64         57
## 4      Russia   Male  34        BigCity        BigCity            51         62
## 5      Russia   Male  25        BigCity        BigCity            66         54
## 6      Russia Female  23        BigCity        BigCity            54         55
##   W_EnvMastery W_PersGrowth W_PurposeLife W_SelfAcceptance WellBeing
## 1           54           60            53               45       308
## 2           55           59            54               64       339
## 3           56           62            65               62       366
## 4           56           59            43               50       321
## 5           67           64            66               66       383
## 6           61           65            60               57       352
##   EnvIdentity V_Conformity V_tradition V_benevolence V_universalism
## 1          41          2.4         1.6           2.0           2.63
## 2          59          2.0         1.4           3.2           2.75
## 3          64          2.0         2.6           4.2           4.50
## 4          47          3.0         3.0           4.0           4.13
## 5          53          1.6         1.0           4.0           3.38
## 6          64          2.4         3.2           4.4           5.88
##   V_Selfdirection V_Stimulation V_Hedonism V_Achievement V_Power V_Security
## 1             3.0          2.67       3.00          2.75    2.50        3.0
## 2             3.6          1.67       1.33          2.75    1.25        2.6
## 3             4.8          3.00       5.67          4.00    2.50        4.6
## 4             4.8          4.67       5.00          4.25    3.50        4.0
## 5             4.6          2.00       4.67          4.25    2.75        3.2
## 6             6.0          1.33       3.33          3.50    0.25        3.6
str(Data) # Структура данных
## 'data.frame':    109 obs. of  23 variables:
##  $ Nationality     : Factor w/ 2 levels "France","Russia": 2 2 2 2 2 2 2 2 2 2 ...
##  $ Sex             : Factor w/ 2 levels "Female","Male": 1 2 1 2 2 1 2 1 2 1 ...
##  $ Age             : int  23 22 21 34 25 23 33 30 25 23 ...
##  $ ResidenceChild  : Ord.factor w/ 4 levels "BigCity"<"SmallTown"<..: 1 1 1 1 1 1 1 2 1 1 ...
##  $ ResidenceAdult  : Ord.factor w/ 4 levels "BigCity"<"SmallTown"<..: 1 1 1 1 1 1 1 1 1 1 ...
##  $ W_PositiveRel   : int  51 47 64 51 66 54 63 65 59 43 ...
##  $ W_Autonomy      : int  45 60 57 62 54 55 60 45 58 47 ...
##  $ W_EnvMastery    : int  54 55 56 56 67 61 61 56 48 41 ...
##  $ W_PersGrowth    : int  60 59 62 59 64 65 69 62 58 56 ...
##  $ W_PurposeLife   : int  53 54 65 43 66 60 63 57 49 45 ...
##  $ W_SelfAcceptance: int  45 64 62 50 66 57 56 56 55 34 ...
##  $ WellBeing       : int  308 339 366 321 383 352 372 341 327 266 ...
##  $ EnvIdentity     : int  41 59 64 47 53 64 62 39 49 60 ...
##  $ V_Conformity    : num  2.4 2 2 3 1.6 2.4 2 3.6 3.2 1 ...
##  $ V_tradition     : num  1.6 1.4 2.6 3 1 3.2 2.8 3.6 2.8 0.4 ...
##  $ V_benevolence   : num  2 3.2 4.2 4 4 4.4 5 4.6 5 4.2 ...
##  $ V_universalism  : num  2.63 2.75 4.5 4.13 3.38 5.88 4.38 5.25 3.25 5.13 ...
##  $ V_Selfdirection : num  3 3.6 4.8 4.8 4.6 6 4.2 5.8 5.4 5.4 ...
##  $ V_Stimulation   : num  2.67 1.67 3 4.67 2 1.33 3.33 5.33 3.33 3.67 ...
##  $ V_Hedonism      : num  3 1.33 5.67 5 4.67 3.33 5.33 6 5.33 6.67 ...
##  $ V_Achievement   : num  2.75 2.75 4 4.25 4.25 3.5 3.25 5.75 2.25 2 ...
##  $ V_Power         : num  2.5 1.25 2.5 3.5 2.75 0.25 1.5 4.5 1 2 ...
##  $ V_Security      : num  3 2.6 4.6 4 3.2 3.6 2.8 5 3.8 3.6 ...
summary(Data) # Общая статистика по колонкам
##  Nationality     Sex          Age             ResidenceChild
##  France:62   Female:64   Min.   :19.00   BigCity     :49    
##  Russia:47   Male  :45   1st Qu.:22.00   SmallTown   :26    
##                          Median :24.00   Village     :20    
##                          Mean   :24.81   SmallVillage:14    
##                          3rd Qu.:27.00                      
##                          Max.   :34.00                      
##       ResidenceAdult W_PositiveRel     W_Autonomy     W_EnvMastery  
##  BigCity     :85     Min.   :41.00   Min.   :33.00   Min.   :34.00  
##  SmallTown   : 7     1st Qu.:52.00   1st Qu.:45.00   1st Qu.:43.00  
##  Village     :13     Median :56.00   Median :50.00   Median :49.00  
##  SmallVillage: 4     Mean   :56.29   Mean   :51.75   Mean   :49.54  
##                      3rd Qu.:60.00   3rd Qu.:55.00   3rd Qu.:55.00  
##                      Max.   :81.00   Max.   :82.00   Max.   :71.00  
##   W_PersGrowth   W_PurposeLife   W_SelfAcceptance   WellBeing    
##  Min.   :40.00   Min.   :41.00   Min.   :33.00    Min.   :258.0  
##  1st Qu.:48.00   1st Qu.:50.00   1st Qu.:48.00    1st Qu.:303.0  
##  Median :53.00   Median :58.00   Median :57.00    Median :326.0  
##  Mean   :55.88   Mean   :58.61   Mean   :56.64    Mean   :328.7  
##  3rd Qu.:64.00   3rd Qu.:66.00   3rd Qu.:65.00    3rd Qu.:343.0  
##  Max.   :80.00   Max.   :81.00   Max.   :83.00    Max.   :447.0  
##   EnvIdentity     V_Conformity    V_tradition    V_benevolence  
##  Min.   :26.00   Min.   :0.800   Min.   :0.000   Min.   :2.000  
##  1st Qu.:49.00   1st Qu.:2.400   1st Qu.:2.000   1st Qu.:4.400  
##  Median :61.00   Median :3.200   Median :3.000   Median :5.000  
##  Mean   :59.85   Mean   :3.167   Mean   :3.095   Mean   :4.985  
##  3rd Qu.:70.00   3rd Qu.:3.800   3rd Qu.:4.000   3rd Qu.:5.600  
##  Max.   :85.00   Max.   :5.600   Max.   :7.000   Max.   :7.000  
##  V_universalism  V_Selfdirection V_Stimulation     V_Hedonism   
##  Min.   :2.500   Min.   :2.800   Min.   :0.330   Min.   :0.330  
##  1st Qu.:4.130   1st Qu.:4.800   1st Qu.:3.330   1st Qu.:4.330  
##  Median :5.000   Median :5.400   Median :4.330   Median :5.000  
##  Mean   :4.962   Mean   :5.345   Mean   :4.339   Mean   :4.975  
##  3rd Qu.:5.880   3rd Qu.:6.000   3rd Qu.:5.330   3rd Qu.:6.000  
##  Max.   :7.000   Max.   :7.000   Max.   :7.000   Max.   :7.000  
##  V_Achievement      V_Power         V_Security   
##  Min.   :1.250   Min.   :-1.000   Min.   :1.200  
##  1st Qu.:3.250   1st Qu.: 1.500   1st Qu.:3.600  
##  Median :4.250   Median : 2.500   Median :4.400  
##  Mean   :4.266   Mean   : 2.711   Mean   :4.461  
##  3rd Qu.:5.250   3rd Qu.: 3.750   3rd Qu.:5.400  
##  Max.   :7.000   Max.   : 6.750   Max.   :7.000
table(Data$Nationality, Data$ResidenceChild)
##         
##          BigCity SmallTown Village SmallVillage
##   France      22        16      14           10
##   Russia      27        10       6            4
table(Data$Nationality, Data$ResidenceAdult)
##         
##          BigCity SmallTown Village SmallVillage
##   France      41         7      12            2
##   Russia      44         0       1            2

#Гистограммы

ggplot(Data, aes(x = W_Autonomy)) +
        geom_histogram(binwidth = 5) +
        facet_grid(rows = vars(Sex), cols = vars(Nationality)) +  
        labs(title = "Histogram of W_Autonomy by Nationality and Sex", x = "W_Autonomy", y = "Count") +  
        theme_light()

Data %>% 
        select(1:11) %>% #Берем только первые 11 колонок
        pivot_longer(cols = starts_with("W_"), names_to = "Variable", values_to = "Value") %>% # Колонки, которые начинаются с "W_"
        ggplot(., aes(x = Variable, y = Value, fill = Nationality)) +
        geom_boxplot() +
        labs(title = "Well-being", x = "Variable", y = "Value") +
        theme_light() +
        #  theme_minimal() +
        theme(axis.text.x = element_text(angle = 45, hjust = 1))

 ggplot(Data, aes(x = Nationality, y = WellBeing)) +
        geom_boxplot() +
        labs(title = "Well-being", x = "Nationality", y = "Value") +
        theme_light() +
        #  theme_minimal() +
  theme(axis.text.x = element_text(angle = 45, hjust = 1))

Тест Вилкоксона

W_variables <- c("W_PositiveRel", "W_Autonomy", "W_EnvMastery", "W_PersGrowth", "W_PurposeLife", "W_SelfAcceptance", "WellBeing")

# Проведение теста Манна-Уитни для каждой пары переменных
for (var in W_variables) {
  result <- wilcox.test(get(var) ~ Nationality, data = Data, alternative = "two.sided")
  print(paste("Test for", var))
  print(result)
}
## [1] "Test for W_PositiveRel"
## 
##  Wilcoxon rank sum test with continuity correction
## 
## data:  get(var) by Nationality
## W = 1111.5, p-value = 0.03455
## alternative hypothesis: true location shift is not equal to 0
## 
## [1] "Test for W_Autonomy"
## 
##  Wilcoxon rank sum test with continuity correction
## 
## data:  get(var) by Nationality
## W = 425, p-value = 0.0000000002584
## alternative hypothesis: true location shift is not equal to 0
## 
## [1] "Test for W_EnvMastery"
## 
##  Wilcoxon rank sum test with continuity correction
## 
## data:  get(var) by Nationality
## W = 322, p-value = 0.000000000003701
## alternative hypothesis: true location shift is not equal to 0
## 
## [1] "Test for W_PersGrowth"
## 
##  Wilcoxon rank sum test with continuity correction
## 
## data:  get(var) by Nationality
## W = 80, p-value < 0.00000000000000022
## alternative hypothesis: true location shift is not equal to 0
## 
## [1] "Test for W_PurposeLife"
## 
##  Wilcoxon rank sum test with continuity correction
## 
## data:  get(var) by Nationality
## W = 1405.5, p-value = 0.7548
## alternative hypothesis: true location shift is not equal to 0
## 
## [1] "Test for W_SelfAcceptance"
## 
##  Wilcoxon rank sum test with continuity correction
## 
## data:  get(var) by Nationality
## W = 1381, p-value = 0.6439
## alternative hypothesis: true location shift is not equal to 0
## 
## [1] "Test for WellBeing"
## 
##  Wilcoxon rank sum test with continuity correction
## 
## data:  get(var) by Nationality
## W = 511.5, p-value = 0.000000007344
## alternative hypothesis: true location shift is not equal to 0

Регрессия - графики

Data %>% 
        select(1:13) %>% #Берем только первые 13 колонок
        pivot_longer(cols = starts_with("W_"), names_to = "Variable", values_to = "Value") %>% # Колонки, которые начинаются с "W_"
        
        ggplot(., aes(x = Value, y = EnvIdentity, col = Nationality)) +
        geom_point() +
        geom_smooth(method = 'lm', se = FALSE) + # se -  убирает стандартную ошибку st. error
        facet_grid(cols = vars(Variable)) +
        labs(title = "Well-being", x = "Well-Being", y = "EnvIdentity") +
        theme_light() 
## `geom_smooth()` using formula = 'y ~ x'

Data %>% 
        select(1:13) %>% #Берем только первые 13 колонок
        pivot_longer(cols = starts_with("W_"), names_to = "Variable", values_to = "Value") %>% # Колонки, которые начинаются с "W_"
        
        ggplot(., aes(x = EnvIdentity
                      , y = Value
                      , col = Nationality)) +
        geom_point() +
        geom_smooth(method = 'lm') +
        facet_grid(cols = vars(Variable)) +
        labs(title = "Well-being"
             , x = "EnvIdentity"
             , y = "Well-Being") +
        theme_light() 
## `geom_smooth()` using formula = 'y ~ x'

 ggplot(Data, aes(x = EnvIdentity, y = WellBeing , col = Nationality)) +
        geom_point() +
        geom_smooth(method = 'lm') +
        labs(title = "Well-being", x = "EnvIdentity", y = "Well-being" ) +
        theme_light()
## `geom_smooth()` using formula = 'y ~ x'

Корреляционная матрица - график

Встроенная функция

pairs(Data[, 6:11])

pairs(Data[, 13:23])

С использованием пакета psych (хороший пакет для анализа именно психологических данных).

pairs.panels(Data[, 6:11], 
             method = "pearson", # correlation method
             lm = TRUE,
             stars = TRUE
             )

Но если нужно взять достаточно много переменных, то можно убать точки и оставить только элипсы, которые показывают разброс.

pairs.panels(Data[, 6:23] 
             , method = "pearson" # correlation method
             , ellipses = TRUE  # draws correlation ellipses
             , lm = TRUE
             , stars = TRUE
             , show.points = FALSE
             , pch = "."
             , gap = 0
             )

Корреляция Psych

corPlot(Data[,6:23], stars = TRUE)

# Регрессионная модель

lmCor(EnvIdentity ~ V_Conformity + V_tradition + V_benevolence + V_universalism + V_Selfdirection + V_Stimulation + V_Hedonism + V_Achievement + V_Power    + V_Security, data = Data)

## Call: lmCor(y = EnvIdentity ~ V_Conformity + V_tradition + V_benevolence + 
##     V_universalism + V_Selfdirection + V_Stimulation + V_Hedonism + 
##     V_Achievement + V_Power + V_Security, data = Data)
## 
## Multiple Regression from raw data 
## 
##  DV =  EnvIdentity 
##                 slope   se     t      p lower.ci upper.ci  VIF  Vy.x
## (Intercept)      0.00 0.09  0.00 1.0000    -0.18     0.18 1.00  0.00
## V_Conformity    -0.03 0.16 -0.20 0.8400    -0.35     0.28 3.26 -0.01
## V_tradition      0.08 0.13  0.57 0.5700    -0.19     0.34 2.30  0.02
## V_benevolence    0.13 0.14  0.91 0.3700    -0.15     0.40 2.50  0.04
## V_universalism   0.38 0.13  2.88 0.0049     0.12     0.64 2.23  0.17
## V_Selfdirection -0.13 0.13 -1.05 0.2900    -0.39     0.12 2.10 -0.03
## V_Stimulation   -0.08 0.12 -0.73 0.4700    -0.31     0.14 1.71 -0.01
## V_Hedonism       0.05 0.11  0.43 0.6700    -0.17     0.26 1.49  0.01
## V_Achievement    0.04 0.14  0.26 0.7900    -0.24     0.31 2.39  0.00
## V_Power         -0.12 0.12 -0.95 0.3400    -0.37     0.13 1.98  0.01
## V_Security       0.13 0.13  1.05 0.3000    -0.12     0.38 2.01  0.03
## 
## Residual Standard Error =  0.92  with  98  degrees of freedom
## 
##  Multiple Regression
##                R   R2  Ruw R2uw Shrunken R2 SE of R2 overall F df1 df2       p
## EnvIdentity 0.49 0.24 0.36 0.13        0.16     0.06      3.02  10  98 0.00228

Модель по полу

lm(EnvIdentity ~ Sex,  Data) %>%
        summary()
## 
## Call:
## lm(formula = EnvIdentity ~ Sex, data = Data)
## 
## Residuals:
##     Min      1Q  Median      3Q     Max 
## -33.984  -7.822   2.016   9.016  23.178 
## 
## Coefficients:
##             Estimate Std. Error t value            Pr(>|t|)    
## (Intercept)   61.984      1.553  39.906 <0.0000000000000002 ***
## SexMale       -5.162      2.417  -2.135               0.035 *  
## ---
## Signif. codes:  0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1
## 
## Residual standard error: 12.43 on 107 degrees of freedom
## Multiple R-squared:  0.04087,    Adjusted R-squared:  0.03191 
## F-statistic:  4.56 on 1 and 107 DF,  p-value: 0.03501

Страна

lm(EnvIdentity ~ Nationality,  Data) %>%
        summary()
## 
## Call:
## lm(formula = EnvIdentity ~ Nationality, data = Data)
## 
## Residuals:
##     Min      1Q  Median      3Q     Max 
## -33.839 -10.839   1.161  10.128  25.128 
## 
## Coefficients:
##                   Estimate Std. Error t value            Pr(>|t|)    
## (Intercept)       59.83871    1.61139  37.135 <0.0000000000000002 ***
## NationalityRussia  0.03363    2.45394   0.014               0.989    
## ---
## Signif. codes:  0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1
## 
## Residual standard error: 12.69 on 107 degrees of freedom
## Multiple R-squared:  1.755e-06,  Adjusted R-squared:  -0.009344 
## F-statistic: 0.0001878 on 1 and 107 DF,  p-value: 0.9891
lm(EnvIdentity ~ Sex + Nationality,  Data) %>%
        summary()
## 
## Call:
## lm(formula = EnvIdentity ~ Sex + Nationality, data = Data)
## 
## Residuals:
##     Min      1Q  Median      3Q     Max 
## -34.070  -7.905   1.930   8.930  23.244 
## 
## Coefficients:
##                   Estimate Std. Error t value            Pr(>|t|)    
## (Intercept)        61.9216     1.8637  33.225 <0.0000000000000002 ***
## SexMale            -5.1655     2.4294  -2.126              0.0358 *  
## NationalityRussia   0.1489     2.4151   0.062              0.9510    
## ---
## Signif. codes:  0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1
## 
## Residual standard error: 12.48 on 106 degrees of freedom
## Multiple R-squared:  0.04091,    Adjusted R-squared:  0.02281 
## F-statistic: 2.261 on 2 and 106 DF,  p-value: 0.1093

Взаимодействие пола и страны

lm(EnvIdentity ~ Sex*Nationality,  Data) %>%
        summary()
## 
## Call:
## lm(formula = EnvIdentity ~ Sex * Nationality, data = Data)
## 
## Residuals:
##    Min     1Q Median     3Q    Max 
## -33.11  -7.72   1.28   8.80  24.28 
## 
## Coefficients:
##                           Estimate Std. Error t value            Pr(>|t|)    
## (Intercept)                 62.622      2.056  30.462 <0.0000000000000002 ***
## SexMale                     -6.902      3.237  -2.132              0.0353 *  
## NationalityRussia           -1.511      3.165  -0.477              0.6342    
## SexMale:NationalityRussia    3.991      4.908   0.813              0.4180    
## ---
## Signif. codes:  0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1
## 
## Residual standard error: 12.5 on 105 degrees of freedom
## Multiple R-squared:  0.04691,    Adjusted R-squared:  0.01968 
## F-statistic: 1.723 on 3 and 105 DF,  p-value: 0.1668
lm(EnvIdentity ~ WellBeing,  Data) %>%
        summary()
## 
## Call:
## lm(formula = EnvIdentity ~ WellBeing, data = Data)
## 
## Residuals:
##     Min      1Q  Median      3Q     Max 
## -33.909 -10.546   1.380   9.957  25.091 
## 
## Coefficients:
##             Estimate Std. Error t value    Pr(>|t|)    
## (Intercept) 57.64420   10.65629   5.409 0.000000389 ***
## WellBeing    0.00672    0.03221   0.209       0.835    
## ---
## Signif. codes:  0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1
## 
## Residual standard error: 12.69 on 107 degrees of freedom
## Multiple R-squared:  0.0004067,  Adjusted R-squared:  -0.008935 
## F-statistic: 0.04354 on 1 and 107 DF,  p-value: 0.8351
lm(EnvIdentity ~ WellBeing*Nationality,  Data) %>%
        summary()
## 
## Call:
## lm(formula = EnvIdentity ~ WellBeing * Nationality, data = Data)
## 
## Residuals:
##     Min      1Q  Median      3Q     Max 
## -33.653 -10.436   1.584   9.813  25.396 
## 
## Coefficients:
##                             Estimate Std. Error t value Pr(>|t|)   
## (Intercept)                 61.98896   22.04007   2.813  0.00587 **
## WellBeing                   -0.00693    0.07084  -0.098  0.92226   
## NationalityRussia           -8.02263   27.69339  -0.290  0.77262   
## WellBeing:NationalityRussia  0.02366    0.08512   0.278  0.78161   
## ---
## Signif. codes:  0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1
## 
## Residual standard error: 12.8 on 105 degrees of freedom
## Multiple R-squared:  0.001288,   Adjusted R-squared:  -0.02725 
## F-statistic: 0.04512 on 3 and 105 DF,  p-value: 0.9872
lm(EnvIdentity ~ Nationality*WellBeing,  Data) %>%
        summary()
## 
## Call:
## lm(formula = EnvIdentity ~ Nationality * WellBeing, data = Data)
## 
## Residuals:
##     Min      1Q  Median      3Q     Max 
## -33.653 -10.436   1.584   9.813  25.396 
## 
## Coefficients:
##                             Estimate Std. Error t value Pr(>|t|)   
## (Intercept)                 61.98896   22.04007   2.813  0.00587 **
## NationalityRussia           -8.02263   27.69339  -0.290  0.77262   
## WellBeing                   -0.00693    0.07084  -0.098  0.92226   
## NationalityRussia:WellBeing  0.02366    0.08512   0.278  0.78161   
## ---
## Signif. codes:  0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1
## 
## Residual standard error: 12.8 on 105 degrees of freedom
## Multiple R-squared:  0.001288,   Adjusted R-squared:  -0.02725 
## F-statistic: 0.04512 on 3 and 105 DF,  p-value: 0.9872
lm(EnvIdentity ~ ResidenceChild,  Data) %>%
        summary()
## 
## Call:
## lm(formula = EnvIdentity ~ ResidenceChild, data = Data)
## 
## Residuals:
##     Min      1Q  Median      3Q     Max 
## -31.939  -8.231   2.061   8.769  27.769 
## 
## Coefficients:
##                  Estimate Std. Error t value             Pr(>|t|)    
## (Intercept)        61.317      1.306  46.943 < 0.0000000000000002 ***
## ResidenceChild.L    7.614      2.632   2.893              0.00464 ** 
## ResidenceChild.Q    2.804      2.612   1.073              0.28558    
## ResidenceChild.C   -1.464      2.593  -0.565              0.57356    
## ---
## Signif. codes:  0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1
## 
## Residual standard error: 12.3 on 105 degrees of freedom
## Multiple R-squared:  0.07709,    Adjusted R-squared:  0.05072 
## F-statistic: 2.924 on 3 and 105 DF,  p-value: 0.03735

Подбор моделей

lm(EnvIdentity ~ ., Data) %>% 
        step(direction = "both", steps = 1000000, trace = 0) %>% 
        summary()
## 
## Call:
## lm(formula = EnvIdentity ~ Nationality + ResidenceChild + W_Autonomy + 
##     V_Conformity + V_universalism + V_Power, data = Data)
## 
## Residuals:
##      Min       1Q   Median       3Q      Max 
## -29.0406  -6.4827   0.7083   7.0603  22.0603 
## 
## Coefficients:
##                   Estimate Std. Error t value    Pr(>|t|)    
## (Intercept)        46.7618     8.9102   5.248 0.000000864 ***
## NationalityRussia   8.5836     2.8800   2.980     0.00361 ** 
## ResidenceChild.L    6.1477     2.4138   2.547     0.01239 *  
## ResidenceChild.Q    2.1924     2.3193   0.945     0.34678    
## ResidenceChild.C   -1.3469     2.2798  -0.591     0.55598    
## W_Autonomy         -0.3045     0.1617  -1.883     0.06258 .  
## V_Conformity        2.1332     1.2659   1.685     0.09509 .  
## V_universalism      4.5640     1.0805   4.224 0.000053066 ***
## V_Power            -1.1326     0.7356  -1.540     0.12676    
## ---
## Signif. codes:  0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1
## 
## Residual standard error: 10.81 on 100 degrees of freedom
## Multiple R-squared:  0.3222, Adjusted R-squared:  0.2679 
## F-statistic: 5.941 on 8 and 100 DF,  p-value: 0.000003199
lm(EnvIdentity ~ Nationality *(W_PositiveRel 
                               + W_Autonomy 
                               + W_EnvMastery 
                               + W_PersGrowth 
                               + W_PurposeLife 
                               + W_SelfAcceptance 
                               + WellBeing 
                               + V_Conformity 
                               + V_tradition 
                               + V_benevolence 
                               + V_universalism 
                               + V_Selfdirection 
                               + V_Stimulation 
                               + V_Hedonism 
                               + V_Achievement 
                               + V_Power 
                               + V_Security)
, Data
) %>%
        summary()
## 
## Call:
## lm(formula = EnvIdentity ~ Nationality * (W_PositiveRel + W_Autonomy + 
##     W_EnvMastery + W_PersGrowth + W_PurposeLife + W_SelfAcceptance + 
##     WellBeing + V_Conformity + V_tradition + V_benevolence + 
##     V_universalism + V_Selfdirection + V_Stimulation + V_Hedonism + 
##     V_Achievement + V_Power + V_Security), data = Data)
## 
## Residuals:
##      Min       1Q   Median       3Q      Max 
## -29.5814  -4.7201  -0.6123   6.7881  25.5461 
## 
## Coefficients: (2 not defined because of singularities)
##                                       Estimate  Std. Error t value Pr(>|t|)  
## (Intercept)                         71.7972008  43.6441866   1.645   0.1041  
## NationalityRussia                  -43.9016091  49.5474665  -0.886   0.3784  
## W_PositiveRel                       -0.1679453   0.4335805  -0.387   0.6996  
## W_Autonomy                          -0.1525111   0.3641382  -0.419   0.6765  
## W_EnvMastery                        -0.5278506   0.3963133  -1.332   0.1869  
## W_PersGrowth                         0.0887066   0.4250689   0.209   0.8353  
## W_PurposeLife                       -0.1881714   0.3511546  -0.536   0.5936  
## W_SelfAcceptance                     0.1021562   0.2774401   0.368   0.7138  
## WellBeing                                   NA          NA      NA       NA  
## V_Conformity                         2.5642611   2.7825053   0.922   0.3597  
## V_tradition                          0.9675598   1.6353731   0.592   0.5559  
## V_benevolence                        3.5858447   3.0313175   1.183   0.2406  
## V_universalism                       4.6240959   2.1753168   2.126   0.0368 *
## V_Selfdirection                     -3.6379652   2.4729953  -1.471   0.1455  
## V_Stimulation                       -1.1542413   1.5969794  -0.723   0.4721  
## V_Hedonism                           0.1264883   2.0513366   0.062   0.9510  
## V_Achievement                        0.5634595   2.1040248   0.268   0.7896  
## V_Power                             -2.9560107   1.5931742  -1.855   0.0675 .
## V_Security                           0.7181213   1.7274560   0.416   0.6788  
## NationalityRussia:W_PositiveRel      0.0302011   0.5135918   0.059   0.9533  
## NationalityRussia:W_Autonomy        -0.2025224   0.4356237  -0.465   0.6433  
## NationalityRussia:W_EnvMastery      -0.0023517   0.5439472  -0.004   0.9966  
## NationalityRussia:W_PersGrowth       0.5514822   0.5866536   0.940   0.3502  
## NationalityRussia:W_PurposeLife      0.6089816   0.4894496   1.244   0.2173  
## NationalityRussia:W_SelfAcceptance  -0.0230141   0.4034051  -0.057   0.9547  
## NationalityRussia:WellBeing                 NA          NA      NA       NA  
## NationalityRussia:V_Conformity       0.0001367   4.6352586   0.000   1.0000  
## NationalityRussia:V_tradition        0.6693923   2.5956868   0.258   0.7972  
## NationalityRussia:V_benevolence     -5.5402175   4.0381042  -1.372   0.1742  
## NationalityRussia:V_universalism    -1.8579844   3.4960955  -0.531   0.5967  
## NationalityRussia:V_Selfdirection    0.9272871   3.9028306   0.238   0.8128  
## NationalityRussia:V_Stimulation      0.6789967   2.2877665   0.297   0.7674  
## NationalityRussia:V_Hedonism         2.4747061   2.6979726   0.917   0.3620  
## NationalityRussia:V_Achievement     -0.6292525   3.2232991  -0.195   0.8457  
## NationalityRussia:V_Power            2.3245429   2.3080444   1.007   0.3171  
## NationalityRussia:V_Security         1.7634870   3.3561817   0.525   0.6008  
## ---
## Signif. codes:  0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1
## 
## Residual standard error: 11.29 on 75 degrees of freedom
## Multiple R-squared:  0.4453, Adjusted R-squared:  0.2013 
## F-statistic: 1.825 on 33 and 75 DF,  p-value: 0.01652

Полная плюс страна

lm(EnvIdentity ~ Nationality *(W_PositiveRel 
                               + W_Autonomy 
                               + W_EnvMastery 
                               + W_PersGrowth 
                               + W_PurposeLife 
                               + W_SelfAcceptance 
                               + WellBeing 
                               + V_Conformity 
                               + V_tradition 
                               + V_benevolence 
                               + V_universalism 
                               + V_Selfdirection 
                               + V_Stimulation 
                               + V_Hedonism 
                               + V_Achievement 
                               + V_Power 
                               + V_Security)
, Data
) %>% 
        step(direction = "both", steps = 1000000, trace = 0) %>% 
        summary()
## 
## Call:
## lm(formula = EnvIdentity ~ Nationality + W_Autonomy + W_EnvMastery + 
##     W_PurposeLife + V_Conformity + V_benevolence + V_universalism + 
##     V_Selfdirection + V_Power + Nationality:W_PurposeLife + Nationality:V_benevolence + 
##     Nationality:V_Power, data = Data)
## 
## Residuals:
##      Min       1Q   Median       3Q      Max 
## -29.4666  -5.3423  -0.8143   8.5880  24.8622 
## 
## Coefficients:
##                                 Estimate Std. Error t value  Pr(>|t|)    
## (Intercept)                      74.2128    16.5068   4.496 0.0000194 ***
## NationalityRussia               -14.5153    16.3143  -0.890  0.375837    
## W_Autonomy                       -0.3645     0.1678  -2.172  0.032340 *  
## W_EnvMastery                     -0.3816     0.2097  -1.820  0.071856 .  
## W_PurposeLife                    -0.2244     0.1491  -1.505  0.135503    
## V_Conformity                      3.7794     1.5075   2.507  0.013852 *  
## V_benevolence                     3.3021     1.8372   1.797  0.075419 .  
## V_universalism                    4.4931     1.2926   3.476  0.000765 ***
## V_Selfdirection                  -2.5211     1.5695  -1.606  0.111500    
## V_Power                          -2.7308     1.0325  -2.645  0.009544 ** 
## NationalityRussia:W_PurposeLife   0.6906     0.2554   2.704  0.008104 ** 
## NationalityRussia:V_benevolence  -4.0136     2.1365  -1.879  0.063334 .  
## NationalityRussia:V_Power         2.8793     1.3900   2.071  0.040996 *  
## ---
## Signif. codes:  0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1
## 
## Residual standard error: 10.51 on 96 degrees of freedom
## Multiple R-squared:  0.384,  Adjusted R-squared:  0.307 
## F-statistic: 4.987 on 12 and 96 DF,  p-value: 0.00000226

Полная плюс пол

lm(EnvIdentity ~ Sex *(W_PositiveRel 
                               + W_Autonomy 
                               + W_EnvMastery 
                               + W_PersGrowth 
                               + W_PurposeLife 
                               + W_SelfAcceptance 
                               + WellBeing 
                               + V_Conformity 
                               + V_tradition 
                               + V_benevolence 
                               + V_universalism 
                               + V_Selfdirection 
                               + V_Stimulation 
                               + V_Hedonism 
                               + V_Achievement 
                               + V_Power 
                               + V_Security)
, Data
) %>% 
        step(direction = "both", steps = 1000000, trace = 0) %>% 
        summary()
## 
## Call:
## lm(formula = EnvIdentity ~ Sex + W_PositiveRel + W_PersGrowth + 
##     W_PurposeLife + V_Conformity + V_universalism + V_Selfdirection + 
##     V_Hedonism + V_Power + V_Security + Sex:W_PositiveRel + Sex:W_PurposeLife + 
##     Sex:V_Conformity + Sex:V_Power + Sex:V_Security, data = Data)
## 
## Residuals:
##      Min       1Q   Median       3Q      Max 
## -30.2273  -5.7729   0.2438   6.5063  22.3331 
## 
## Coefficients:
##                       Estimate Std. Error t value Pr(>|t|)   
## (Intercept)           26.16749   12.84793   2.037  0.04452 * 
## SexMale               -5.88066   19.98629  -0.294  0.76923   
## W_PositiveRel         -0.01276    0.21483  -0.059  0.95275   
## W_PersGrowth           0.46648    0.14407   3.238  0.00167 **
## W_PurposeLife         -0.24815    0.18085  -1.372  0.17332   
## V_Conformity           5.25385    1.91906   2.738  0.00741 **
## V_universalism         4.18801    1.36409   3.070  0.00280 **
## V_Selfdirection       -2.45399    1.64014  -1.496  0.13798   
## V_Hedonism             2.03501    1.10101   1.848  0.06774 . 
## V_Power               -3.69006    1.21771  -3.030  0.00316 **
## V_Security            -0.11671    1.49768  -0.078  0.93806   
## SexMale:W_PositiveRel -0.54353    0.37801  -1.438  0.15382   
## SexMale:W_PurposeLife  0.45606    0.26923   1.694  0.09363 . 
## SexMale:V_Conformity  -4.64094    2.76229  -1.680  0.09629 . 
## SexMale:V_Power        2.71642    1.65262   1.644  0.10361   
## SexMale:V_Security     3.23613    2.25785   1.433  0.15513   
## ---
## Signif. codes:  0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1
## 
## Residual standard error: 10.82 on 93 degrees of freedom
## Multiple R-squared:  0.3683, Adjusted R-squared:  0.2664 
## F-statistic: 3.615 on 15 and 93 DF,  p-value: 0.00006278

Сохранение объекта

save(Data, file = "Data.RData")
#load(file = "Data.RData")