knitr::opts_chunk$set(fig.width=12, fig.height=8, fig.path='Figs/',
                      echo=FALSE, warning=FALSE, message=FALSE, error = FALSE)

Problem 1

Using regression modelling, find out how interest in politics, marital status, and age relate to trust in parliament.

  1. Show how you create your models and choose the best of them.
  2. Explore models with and without moderation.
##     pol_int            marit          age           trstparl     
##  Min.   :0.0000   Divorced: 97   Min.   :16.00   Min.   : 1.000  
##  1st Qu.:0.3300   Married : 52   1st Qu.:47.25   1st Qu.: 3.000  
##  Median :0.6600   Single  :154   Median :67.50   Median : 6.000  
##  Mean   :0.5036   Widowed :171   Mean   :61.41   Mean   : 5.249  
##  3rd Qu.:0.6600                  3rd Qu.:76.00   3rd Qu.: 7.000  
##  Max.   :1.0000                  Max.   :94.00   Max.   :11.000
## 
## Call:
## lm(formula = trstparl ~ pol_int, data = df1)
## 
## Residuals:
##     Min      1Q  Median      3Q     Max 
## -4.9639 -1.9639  0.5258  2.0011  6.4764 
## 
## Coefficients:
##             Estimate Std. Error t value Pr(>|t|)    
## (Intercept)   4.5236     0.2112   21.41  < 2e-16 ***
## pol_int       1.4403     0.3496    4.12 4.48e-05 ***
## ---
## Signif. codes:  0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1
## 
## Residual standard error: 2.542 on 472 degrees of freedom
## Multiple R-squared:  0.03471,    Adjusted R-squared:  0.03267 
## F-statistic: 16.97 on 1 and 472 DF,  p-value: 4.478e-05
## 
## Call:
## lm(formula = trstparl ~ pol_int + marit, data = df1)
## 
## Residuals:
##     Min      1Q  Median      3Q     Max 
## -5.2467 -1.9655  0.2474  1.9752  6.4548 
## 
## Coefficients:
##              Estimate Std. Error t value Pr(>|t|)    
## (Intercept)    4.0136     0.3175  12.643  < 2e-16 ***
## pol_int        1.4532     0.3511   4.139 4.13e-05 ***
## maritMarried   0.4505     0.4356   1.034   0.3016    
## maritSingle    0.5316     0.3297   1.612   0.1076    
## maritWidowed   0.7799     0.3221   2.421   0.0158 *  
## ---
## Signif. codes:  0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1
## 
## Residual standard error: 2.534 on 469 degrees of freedom
## Multiple R-squared:  0.04672,    Adjusted R-squared:  0.03858 
## F-statistic: 5.746 on 4 and 469 DF,  p-value: 0.0001604
## 
## Call:
## lm(formula = trstparl ~ pol_int + marit + age, data = df1)
## 
## Residuals:
##     Min      1Q  Median      3Q     Max 
## -5.2716 -1.9593  0.2536  1.9124  6.4593 
## 
## Coefficients:
##               Estimate Std. Error t value Pr(>|t|)    
## (Intercept)   4.222583   0.598617   7.054 6.29e-12 ***
## pol_int       1.470600   0.353931   4.155 3.87e-05 ***
## maritMarried  0.426773   0.439748   0.970   0.3323    
## maritSingle   0.459031   0.374103   1.227   0.2204    
## maritWidowed  0.819944   0.336702   2.435   0.0153 *  
## age          -0.003355   0.008145  -0.412   0.6806    
## ---
## Signif. codes:  0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1
## 
## Residual standard error: 2.536 on 468 degrees of freedom
## Multiple R-squared:  0.04706,    Adjusted R-squared:  0.03688 
## F-statistic: 4.622 on 5 and 468 DF,  p-value: 0.000397

As for the additive models, the first one is the best (trstparl ~ pol_int), significance in interest in politics only.

Then I’ve tried to add interaction:

## 
## Call:
## lm(formula = trstparl ~ pol_int * marit, data = df1)
## 
## Residuals:
##     Min      1Q  Median      3Q     Max 
## -5.1390 -1.8298  0.4323  1.8560  6.7438 
## 
## Coefficients:
##                      Estimate Std. Error t value Pr(>|t|)    
## (Intercept)            3.2562     0.4496   7.242 1.84e-12 ***
## pol_int                2.8827     0.6982   4.129 4.32e-05 ***
## maritMarried           1.1170     0.8530   1.309 0.191022    
## maritSingle            1.2101     0.5609   2.157 0.031479 *  
## maritWidowed           2.2522     0.5872   3.836 0.000142 ***
## pol_int:maritMarried  -1.2656     1.3426  -0.943 0.346335    
## pol_int:maritSingle   -1.2532     0.9189  -1.364 0.173268    
## pol_int:maritWidowed  -2.7929     0.9335  -2.992 0.002919 ** 
## ---
## Signif. codes:  0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1
## 
## Residual standard error: 2.517 on 466 degrees of freedom
## Multiple R-squared:  0.06506,    Adjusted R-squared:  0.05101 
## F-statistic: 4.632 on 7 and 466 DF,  p-value: 4.996e-05
## 
## Call:
## lm(formula = trstparl ~ pol_int * age, data = df1)
## 
## Residuals:
##     Min      1Q  Median      3Q     Max 
## -5.0369 -1.9416  0.5048  1.9560  6.5515 
## 
## Coefficients:
##              Estimate Std. Error t value Pr(>|t|)    
## (Intercept)  4.251108   0.606276   7.012 8.23e-12 ***
## pol_int      1.941057   1.113137   1.744   0.0819 .  
## age          0.004699   0.009838   0.478   0.6332    
## pol_int:age -0.008395   0.017406  -0.482   0.6298    
## ---
## Signif. codes:  0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1
## 
## Residual standard error: 2.546 on 470 degrees of freedom
## Multiple R-squared:  0.03524,    Adjusted R-squared:  0.02908 
## F-statistic: 5.722 on 3 and 470 DF,  p-value: 0.0007489
## 
## Call:
## lm(formula = trstparl ~ pol_int * age + marit, data = df1)
## 
## Residuals:
##     Min      1Q  Median      3Q     Max 
## -5.2238 -1.9573  0.2782  1.9528  6.5389 
## 
## Coefficients:
##               Estimate Std. Error t value Pr(>|t|)    
## (Intercept)   3.947331   0.748313   5.275 2.04e-07 ***
## pol_int       2.119641   1.115287   1.901   0.0580 .  
## age           0.001326   0.011162   0.119   0.9055    
## maritMarried  0.415902   0.440398   0.944   0.3455    
## maritSingle   0.458095   0.374355   1.224   0.2217    
## maritWidowed  0.830716   0.337383   2.462   0.0142 *  
## pol_int:age  -0.010685   0.017410  -0.614   0.5397    
## ---
## Signif. codes:  0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1
## 
## Residual standard error: 2.538 on 467 degrees of freedom
## Multiple R-squared:  0.04783,    Adjusted R-squared:  0.03559 
## F-statistic:  3.91 on 6 and 467 DF,  p-value: 0.0008015

INTERPRETATION :

wider with pol_int=1: \(predicted value = 3.26 + 2.25 + 2.88 - 2.79\) \(pred trust = 3.26 + 2.25*Widowed + 2.88*pol - 2.79*Widowed*pol\)

PLOT:

NB:

важно обратить внимание на отрезок графика 0-0.5 interest in politics - там, где фиолетовое и красные области не пересекаются - атм значимое различие в поведении двух групп.

Standartized values:

## 
## Call:
## lm(formula = trstparl ~ pol_int * marit, data = df1)
## 
## Standardized Coefficients::
##          (Intercept)              pol_int         maritMarried 
##           0.00000000           0.37290156           0.13523258 
##          maritSingle         maritWidowed pol_int:maritMarried 
##           0.21954913           0.41897406          -0.09823463 
##  pol_int:maritSingle pol_int:maritWidowed 
##          -0.13841937          -0.33911387

Then, work with the best-fitting model by answering the following questions:

  1. How much variance in trust in parliament can your best model explain?
  2. What are the relationships between the predictors and the outcome variables? Interpret the coefficients.
  3. Which continuous predictor is most tightly related to the outcome?