Wczytanie bibliotek

library(readr)
library(psych)

Wczytanie i eksploracja danych

## Rows: 67 Columns: 13
## ── Column specification ────────────────────────────────────────────────────────
## Delimiter: ","
## dbl (13): PublicationYears, BigSample, Method, AngloSaxon, USA, TimeSpan, Sa...
## 
## ℹ Use `spec()` to retrieve the full column specification for this data.
## ℹ Specify the column types or set `show_col_types = FALSE` to quiet this message.

Nadanie nazw zgodnie z indeksem papieru

rownames(DF) <- DF$Nr_Papieru

podgląd danych

head(DF)
##   PublicationYears BigSample Method AngloSaxon USA TimeSpan Sample
## 2               35         0      0          1   1        0    243
## 3               33         0      0          1   1        0    410
## 5               22         0      1          1   1        1     98
## 6               22         0      1          1   1        3    860
## 7               20         0      0          0   0        0    287
## 8               16         0      0          0   0        0   2428
##   BusinessSupport TC    TCYear EXCLUDED   PY Nr_Papieru
## 2               0  0 0.0000000        0 1980          2
## 3               0  4 0.1212121        0 1982          3
## 5               0 49 2.2272727        0 1993          5
## 6               0 35 1.5909091        0 1993          6
## 7               0  6 0.3000000        0 1995          7
## 8               0  7 0.4375000        0 1999          8

Generowanie statystyk opisowych danych

describe(DF)
##                  vars  n    mean      sd median trimmed    mad  min      max
## PublicationYears    1 67    8.52    8.16    7.0    7.05   5.93    0    36.00
## BigSample           2 67    0.27    0.45    0.0    0.22   0.00    0     1.00
## Method              3 67    0.70    0.46    1.0    0.75   0.00    0     1.00
## AngloSaxon          4 67    0.69    0.47    1.0    0.73   0.00    0     1.00
## USA                 5 67    0.45    0.50    0.0    0.44   0.00    0     1.00
## TimeSpan            6 67    3.87    7.57    1.0    2.20   1.48    0    40.00
## Sample              7 67 1755.17 6348.16  371.0  779.31 413.65    0 51755.00
## BusinessSupport     8 67    0.04    0.21    0.0    0.00   0.00    0     1.00
## TC                  9 67   22.52   46.55    3.0   10.87   4.45    0   227.00
## TCYear             10 67    2.17    3.95    0.5    1.19   0.74    0    18.92
## EXCLUDED           11 67    0.00    0.00    0.0    0.00   0.00    0     0.00
## PY                 12 67 2006.48    8.16 2008.0 2007.95   5.93 1979  2015.00
## Nr_Papieru         13 67   64.72   44.95   55.0   64.07  65.23    1   137.00
##                     range  skew kurtosis     se
## PublicationYears    36.00  1.80     3.10   1.00
## BigSample            1.00  1.02    -0.97   0.05
## Method               1.00 -0.86    -1.28   0.06
## AngloSaxon           1.00 -0.79    -1.40   0.06
## USA                  1.00  0.21    -1.99   0.06
## TimeSpan            40.00  3.67    13.88   0.92
## Sample           51755.00  7.29    54.45 775.55
## BusinessSupport      1.00  4.30    16.78   0.03
## TC                 227.00  2.65     6.79   5.69
## TCYear              18.92  2.48     5.70   0.48
## EXCLUDED             0.00   NaN      NaN   0.00
## PY                  36.00 -1.80     3.10   1.00
## Nr_Papieru         136.00  0.13    -1.49   5.49

Tworzenie modelu regresji liniowej

TCY <- lm(TCYear~PublicationYears + BigSample + Method + AngloSaxon + TimeSpan + Sample + BusinessSupport, DF)
summary(TCY)
## 
## Call:
## lm(formula = TCYear ~ PublicationYears + BigSample + Method + 
##     AngloSaxon + TimeSpan + Sample + BusinessSupport, data = DF)
## 
## Residuals:
##     Min      1Q  Median      3Q     Max 
## -4.6610 -1.4347 -0.4097  0.3778 13.8215 
## 
## Coefficients:
##                    Estimate Std. Error t value Pr(>|t|)   
## (Intercept)      -1.085e+00  1.206e+00  -0.900   0.3718   
## PublicationYears  1.019e-01  5.645e-02   1.806   0.0760 . 
## BigSample         3.583e+00  1.129e+00   3.173   0.0024 **
## Method            6.020e-01  1.069e+00   0.563   0.5755   
## AngloSaxon        8.287e-01  1.027e+00   0.807   0.4231   
## TimeSpan          1.106e-01  6.237e-02   1.773   0.0815 . 
## Sample           -5.256e-05  7.557e-05  -0.696   0.4895   
## BusinessSupport   2.185e+00  2.184e+00   1.001   0.3212   
## ---
## Signif. codes:  0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1
## 
## Residual standard error: 3.633 on 59 degrees of freedom
## Multiple R-squared:  0.2427, Adjusted R-squared:  0.1529 
## F-statistic: 2.701 on 7 and 59 DF,  p-value: 0.01693

Graficzne przedstawienie estymacji

plot(TCY)

## Warning in sqrt(crit * p * (1 - hh)/hh): NaNs produced

## Warning in sqrt(crit * p * (1 - hh)/hh): NaNs produced

Obserwacje dzwigniowe

obliczenie wartości lewara

values <- hatvalues(TCY)
hats <- data.frame(hat_values = values)

Wartości lewara:

hats
##     hat_values
## 2   0.21290798
## 3   0.19167812
## 5   0.07835187
## 6   0.07988768
## 7   0.10611081
## 8   0.09475865
## 9   0.04597844
## 10  0.04404193
## 11  0.07201387
## 12  0.07308525
## 15  0.13581008
## 19  0.07100794
## 20  0.06762549
## 21  0.04526655
## 22  0.37665168
## 23  0.09072711
## 24  0.08400364
## 29  0.04133848
## 30  0.06246831
## 35  0.34292671
## 36  0.08739606
## 37  0.04062334
## 38  0.18367009
## 43  0.07222597
## 44  0.39530021
## 45  0.06844399
## 46  0.04191017
## 51  0.04291890
## 52  0.08724704
## 53  0.04695298
## 54  0.06736653
## 55  0.06529267
## 62  0.04571295
## 63  0.04351669
## 64  0.97998610
## 67  0.04362519
## 68  0.07036614
## 77  0.09122794
## 78  0.06180910
## 88  0.34836347
## 90  0.07183608
## 91  0.04735230
## 101 0.07554022
## 102 0.37576933
## 103 0.10478660
## 104 0.05068387
## 105 0.13679124
## 106 0.07345583
## 107 0.13162536
## 108 0.05073110
## 117 0.06632617
## 118 0.12817979
## 119 0.09669277
## 120 0.08084825
## 121 0.07821484
## 122 0.09649332
## 123 0.07595300
## 124 0.07221547
## 127 0.05541486
## 128 0.09904922
## 129 0.06116892
## 130 0.07186645
## 131 0.06992124
## 136 0.06570245
## 137 0.11032187
## 1   0.25670894
## 4   0.19575441

Sortowanie wartości

# hats[order(-hats['hat_values']), ]

Lewary graficznie

plot(values, type = 'h')

Papiery do przeglądu opisowego

cutoff <- 2 * (8-1) / 67
z <- hats > cutoff
z
##     hat_values
## 2         TRUE
## 3        FALSE
## 5        FALSE
## 6        FALSE
## 7        FALSE
## 8        FALSE
## 9        FALSE
## 10       FALSE
## 11       FALSE
## 12       FALSE
## 15       FALSE
## 19       FALSE
## 20       FALSE
## 21       FALSE
## 22        TRUE
## 23       FALSE
## 24       FALSE
## 29       FALSE
## 30       FALSE
## 35        TRUE
## 36       FALSE
## 37       FALSE
## 38       FALSE
## 43       FALSE
## 44        TRUE
## 45       FALSE
## 46       FALSE
## 51       FALSE
## 52       FALSE
## 53       FALSE
## 54       FALSE
## 55       FALSE
## 62       FALSE
## 63       FALSE
## 64        TRUE
## 67       FALSE
## 68       FALSE
## 77       FALSE
## 78       FALSE
## 88        TRUE
## 90       FALSE
## 91       FALSE
## 101      FALSE
## 102       TRUE
## 103      FALSE
## 104      FALSE
## 105      FALSE
## 106      FALSE
## 107      FALSE
## 108      FALSE
## 117      FALSE
## 118      FALSE
## 119      FALSE
## 120      FALSE
## 121      FALSE
## 122      FALSE
## 123      FALSE
## 124      FALSE
## 127      FALSE
## 128      FALSE
## 129      FALSE
## 130      FALSE
## 131      FALSE
## 136      FALSE
## 137      FALSE
## 1         TRUE
## 4        FALSE

razem

sum(z, na.rm=FALSE)
## [1] 8