CCR Mandatory Project.
Julia Chicheł 114574
Julia Modrzyńska 114739
Barbara Dworakowska 114598
# Install and load the necessary packageslibrary(ggplot2)
library(gridExtra)
# Generate the dataset.seed(42)
# For reproducibilityy <- runif(100, min = 0, max = 50) z <- runif(100, min = 1, max = 12) x <- 2 * y + z
# Fit the linear regression modelmodel <- lm(y ~ x)
# Create the data framesdf1 <- data.frame(x, z)
df <- data.frame(x, y)
df2 <- rbind(df, c(75, 0.5))
df3 <- rbind(df1, c(75, 0.5))
# Create the plotsplot1 <- ggplot(df1, aes(z, y)) + + geom_point() + + theme_bw() + + labs(x = ‘Independent variables’, y = ‘Yearly number of citations’) + + ggtitle(“Panel A”)
plot2 <- ggplot(df, aes(x, y)) + + geom_point() + + theme_bw() + + labs(x = ‘Independent variables’, y = ‘Yearly number of citations’) + + ggtitle(“Panel B”)
plot1a <- ggplot(df1, aes(z, y)) + + geom_point() + + geom_smooth(method = lm) + + theme_bw() + + labs(x = ‘Independent variables’, y = ‘Yearly number of citations’) + + ggtitle(“Panel C”)
plot2a <- ggplot(df, aes(x, y)) + + geom_point() + + geom_smooth(method = lm) + + theme_bw() + + labs(x = ‘Independent variables’, y = ‘Yearly number of citations’) + + ggtitle(“Panel D”) coeff <- coefficients(model) intercept <- coeff[1] slope <- coeff[2]
plot3 <- ggplot(df3, aes(x, z)) + + geom_point() + + geom_smooth(method = lm) + + theme_bw() + + labs(x = ‘Independent variables’, y = ‘Yearly number of citations’) + + annotate(“point”, x = 10, y = 0.5, colour = “red”) + + geom_abline(intercept = intercept, slope = slope, color = “red”, linetype = “solid”, size = 1.5) + + ggtitle(“Panel E”)
Warning message: Using
sizeaesthetic for lines was deprecated in ggplot2 3.4.0. ℹ Please uselinewidthinstead. This warning is displayed once every 8 hours. Calllifecycle::last_lifecycle_warnings()to see where this warning was generated.plot4 <- ggplot(df2, aes(x, y)) + + geom_point() + + geom_smooth(method = lm) + + geom_smooth() + + theme_bw() + + labs(x = ‘Independent variables’, y = ‘Yearly number of citations’) + + annotate(“point”, x = 75, y = 0.5, colour = “red”) + + geom_abline(intercept = intercept, slope = 0.2, color = “red”, linetype = “solid”, size = 1.5) + + ggtitle(“Panel F”)
ggsave(“plot1.png”, plot1, dpi = 300) Saving 7 x 7 in image
ggsave(“plot2.png”, plot2, dpi = 300) Saving 7 x 7 in image
ggsave(“plot1a.png”, plot1a, dpi = 300) Saving 7 x 7 in image
geom_smooth()using formula = ‘y ~ x’ggsave(“plot2a.png”, plot2a, dpi = 300) Saving 7 x 7 in image
geom_smooth()using formula = ‘y ~ x’ggsave(“plot3.png”, plot3, dpi = 300) Saving 7 x 7 in image
geom_smooth()using formula = ‘y ~ x’ggsave(“plot4.png”, plot4, dpi = 300) Saving 7 x 7 in image
geom_smooth()using formula = ‘y ~ x’geom_smooth()using method = ‘loess’ and formula = ‘y ~ x’knitr::include_graphics(“plot1.png”) Error in loadNamespace(x) : there is no package called ‘knitr’ install.packages(“knitr”) Installing package into ‘/cloud/lib/x86_64-pc-linux-gnu-library/4.3’ (as ‘lib’ is unspecified) also installing the dependencies ‘evaluate’, ‘highr’, ‘xfun’, ‘yaml’
trying URL ‘http://rspm/default/__linux__/focal/latest/src/contrib/evaluate_0.23.tar.gz’ Content type ‘application/x-gzip’ length 82039 bytes (80 KB) ================================================== downloaded 80 KB
trying URL ‘http://rspm/default/__linux__/focal/latest/src/contrib/highr_0.10.tar.gz’ Content type ‘application/x-gzip’ length 38964 bytes (38 KB) ================================================== downloaded 38 KB
trying URL ‘http://rspm/default/__linux__/focal/latest/src/contrib/xfun_0.41.tar.gz’ Content type ‘application/x-gzip’ length 428557 bytes (418 KB) ================================================== downloaded 418 KB
trying URL ‘http://rspm/default/__linux__/focal/latest/src/contrib/yaml_2.3.8.tar.gz’ Content type ‘application/x-gzip’ length 114044 bytes (111 KB) ================================================== downloaded 111 KB
trying URL ‘http://rspm/default/__linux__/focal/latest/src/contrib/knitr_1.45.tar.gz’ Content type ‘application/x-gzip’ length 1469109 bytes (1.4 MB) ================================================== downloaded 1.4 MB
The downloaded source packages are in
‘/tmp/Rtmp0l8MCj/downloaded_packages’ >
knitr::include_graphics(“plot1.png”) [1] “plot1.png” attr(,“class”) [1]
“knit_image_paths” “knit_asis”
> knitr::include_graphics(“plot2.png”) [1] “plot2.png” attr(,“class”)
[1] “knit_image_paths” “knit_asis”
> knitr::include_graphics(“plot1a.png”) [1] “plot1a.png”
attr(,“class”) [1] “knit_image_paths” “knit_asis”
> knitr::include_graphics(“plot2a.png”) [1] “plot2a.png”
attr(,“class”) [1] “knit_image_paths” “knit_asis”
> knitr::include_graphics(“plot3.png”) [1] “plot3.png” attr(,“class”)
[1] “knit_image_paths” “knit_asis”
> knitr::include_graphics(“plot4.png”) [1] “plot4.png” attr(,“class”)
[1] “knit_image_paths” “knit_asis”
> install.packages(c(“readr”, “readxl”, “psych”)) Installing packages
into ‘/cloud/lib/x86_64-pc-linux-gnu-library/4.3’ (as ‘lib’ is
unspecified) also installing the dependencies ‘rematch’,
‘cellranger’
trying URL ‘http://rspm/default/__linux__/focal/latest/src/contrib/rematch_2.0.0.tar.gz’ Content type ‘application/x-gzip’ length 15945 bytes (15 KB) ================================================== downloaded 15 KB
trying URL ‘http://rspm/default/__linux__/focal/latest/src/contrib/cellranger_1.1.0.tar.gz’ Content type ‘application/x-gzip’ length 101037 bytes (98 KB) ================================================== downloaded 98 KB
trying URL ‘http://rspm/default/__linux__/focal/latest/src/contrib/readr_2.1.4.tar.gz’ Content type ‘application/x-gzip’ length 884244 bytes (863 KB) ================================================== downloaded 863 KB
trying URL ‘http://rspm/default/__linux__/focal/latest/src/contrib/readxl_1.4.3.tar.gz’ Content type ‘application/x-gzip’ length 871762 bytes (851 KB) ================================================== downloaded 851 KB
trying URL ‘http://rspm/default/__linux__/focal/latest/src/contrib/psych_2.3.12.tar.gz’ Content type ‘application/x-gzip’ length 4039922 bytes (3.9 MB) ================================================== downloaded 3.9 MB
The downloaded source packages are in ‘/tmp/Rtmp0l8MCj/downloaded_packages’ > library(readxl) > library(psych)
Attaching package: ‘psych’
The following objects are masked from ‘package:ggplot2’:
%+%, alpha
scopus <- read_excel(“scopus.xlsx”) Error:
pathdoes not exist: ‘scopus.xlsx’ describe(DF) Error: object ‘DF’ not found TCY<- lm(TCYear ~ PublicationYears +BigSample+ Method+AngloSaxon+TimeSpan +Sample+BusinessSupport,DF) Error in eval(mf, parent.frame()) : object ‘DF’ not found import requests Error: unexpected symbol in “import requests” import requests Error: unexpected symbol in “import requests” scopus <- read_excel(“scopus.xlsx”) Error:pathdoes not exist: ‘scopus.xlsx’ library(readr) DF <- read_csv(file.choose()) Rows: 67 Columns: 13 gdt.csv [] 179.85MB/s, eta: 0s ── Column specification ──────────────────────────── Delimiter: “,” dbl (13): PublicationYears, BigSample, Method, A…
ℹ 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. > DF<-
as.data.frame(DF) > rownames(DF)<-DF$Nr_Papieru > scopus <-
read_excel(“scopus.xlsx”) Error: path does not exist:
‘scopus.xlsx’ > library(readxl) > Scopus <-
read_excel(“Scopus.xlsx”) > View(Scopus)
> > DF <- read_csv(file.choose(Scopus)) Error: unexpected
‘>’ in “>” > colnames(scopus) Error: object ‘scopus’ not found
> colnames(Scopus) [1] “PublicationYears” “BigSample”
[3] “Method” “AngloSaxon”
[5] “USA” “TimeSpan”
[7] “Sample” “BusinessSupport” [9] “TC” “TCYear”
[11] “EXCLUDED” “PY”
[13] “Nr_Papieru”
> library(knitr) > kable(scopus) Error: object ‘scopus’ not found
> kable(Scopus)
| PublicationYears | BigSample | Method | AngloSaxon | USA | TimeSpan | Sample | BusinessSupport | TC | TCYear | EXCLUDED | PY | Nr_Papieru |
|---|---|---|---|---|---|---|---|---|---|---|---|---|
| 35 | 0 | 0 | 1 | 1 | 0 | 243.000 | 0 | 0 | 0.0000000 | 0 | 1980 | 2 |
| 33 | 0 | 0 | 1 | 1 | 0 | 410.000 | 0 | 4 | 0.1212121 | 0 | 1982 | 3 |
| 22 | 0 | 1 | 1 | 1 | 1 | 98.000 | 0 | 49 | 2.2272727 | 0 | 1993 | 5 |
| 22 | 0 | 1 | 1 | 1 | 3 | 860.000 | 0 | 35 | 1.5909091 | 0 | 1993 | 6 |
| 20 | 0 | 0 | 0 | 0 | 0 | 287.000 | 0 | 6 | 0.3000000 | 0 | 1995 | 7 |
| 16 | 0 | 0 | 0 | 0 | 0 | 2428.000 | 0 | 7 | 0.4375000 | 0 | 1999 | 8 |
| 14 | 0 | 1 | 1 | 0 | 1 | 132.000 | 0 | 6 | 0.4285714 | 0 | 2001 | 9 |
| 13 | 0 | 1 | 1 | 1 | 1 | 287.000 | 0 | 86 | 6.6153846 | 0 | 2002 | 10 |
| 13 | 1 | 1 | 1 | 1 | 1 | 2428.000 | 0 | 194 | 14.9230769 | 0 | 2002 | 11 |
| 13 | 1 | 1 | 1 | 0 | 2 | 2107.000 | 0 | 62 | 4.7692308 | 0 | 2002 | 12 |
| 12 | 1 | 0 | 1 | 1 | 1 | 2666.000 | 0 | 89 | 7.4166667 | 0 | 2003 | 15 |
| 12 | 1 | 1 | 1 | 1 | 1 | 1871.000 | 0 | 129 | 10.7500000 | 0 | 2003 | 19 |
| 12 | 1 | 1 | 1 | 1 | 1 | 3170.000 | 0 | 227 | 18.9166667 | 0 | 2003 | 20 |
| 11 | 0 | 1 | 1 | 1 | 6 | 979.000 | 0 | 132 | 12.0000000 | 0 | 2004 | 21 |
| 11 | 1 | 1 | 1 | 1 | 2 | 5103.000 | 1 | 108 | 9.8181818 | 0 | 2004 | 22 |
| 11 | 0 | 0 | 1 | 1 | 0 | 3746.000 | 0 | 3 | 0.2727273 | 0 | 2004 | 23 |
| 11 | 0 | 0 | 0 | 0 | 0 | 43.000 | 0 | 9 | 0.8181818 | 0 | 2004 | 24 |
| 10 | 0 | 1 | 1 | 1 | 1 | 248.000 | 0 | 10 | 1.0000000 | 0 | 2005 | 29 |
| 10 | 0 | 1 | 1 | 0 | 11 | 290.000 | 0 | 0 | 0.0000000 | 0 | 2005 | 30 |
| 9 | 0 | 1 | 1 | 1 | 1 | 100.000 | 1 | 14 | 1.5555556 | 0 | 2006 | 35 |
| 9 | 0 | 0 | 1 | 1 | 0 | 3.483 | 0 | 8 | 0.8888889 | 0 | 2006 | 36 |
| 9 | 0 | 1 | 1 | 0 | 3 | 624.000 | 0 | 12 | 1.3333333 | 0 | 2006 | 37 |
| 9 | 0 | 0 | 0 | 0 | 27 | 147.000 | 0 | 121 | 13.4444444 | 0 | 2006 | 38 |
| 9 | 1 | 1 | 1 | 0 | 8 | 3746.000 | 0 | 37 | 4.1111111 | 0 | 2006 | 43 |
| 9 | 0 | 0 | 1 | 1 | 40 | 43.000 | 0 | 23 | 2.5555556 | 0 | 2006 | 44 |
| 8 | 0 | 1 | 0 | 0 | 2 | 254.000 | 0 | 3 | 0.3750000 | 0 | 2007 | 45 |
| 8 | 0 | 1 | 1 | 1 | 1 | 335.000 | 0 | 3 | 0.3750000 | 0 | 2007 | 46 |
| 7 | 0 | 1 | 1 | 0 | 1 | 392.000 | 0 | 11 | 1.5714286 | 0 | 2008 | 51 |
| 7 | 0 | 0 | 1 | 0 | 1 | 283.000 | 0 | 1 | 0.1428571 | 0 | 2008 | 52 |
| 7 | 0 | 1 | 1 | 0 | 7 | 237.000 | 0 | 6 | 0.8571429 | 0 | 2008 | 53 |
| 7 | 1 | 1 | 1 | 1 | 2 | 1117.000 | 0 | 1 | 0.1428571 | 0 | 2008 | 54 |
| 7 | 1 | 1 | 1 | 1 | 2 | 1692.000 | 0 | 37 | 5.2857143 | 0 | 2008 | 55 |
| 6 | 0 | 1 | 1 | 0 | 6 | 653.000 | 0 | 5 | 0.8333333 | 0 | 2009 | 62 |
| 6 | 0 | 1 | 1 | 1 | 2 | 408.000 | 0 | 3 | 0.5000000 | 0 | 2009 | 63 |
| 6 | 1 | 1 | 1 | 1 | 6 | 51755.000 | 0 | 12 | 2.0000000 | 0 | 2009 | 64 |
| 6 | 0 | 1 | 1 | 1 | 4 | 92.000 | 0 | 9 | 1.5000000 | 0 | 2009 | 67 |
| 6 | 0 | 1 | 0 | 0 | 1 | 135.000 | 0 | 1 | 0.1666667 | 0 | 2009 | 68 |
| 5 | 0 | 0 | 0 | 0 | 0 | 349.000 | 0 | 1 | 0.2000000 | 0 | 2010 | 77 |
| 5 | 1 | 1 | 1 | 1 | 2 | 3313.000 | 0 | 1 | 0.2000000 | 0 | 2010 | 78 |
| 4 | 0 | 1 | 1 | 1 | 2 | 497.000 | 1 | 10 | 2.5000000 | 0 | 2011 | 88 |
| 4 | 0 | 1 | 0 | 0 | 5 | 565.000 | 0 | 2 | 0.5000000 | 0 | 2011 | 90 |
| 4 | 0 | 1 | 1 | 0 | 4 | 540.000 | 0 | 6 | 1.5000000 | 0 | 2011 | 91 |
| 3 | 0 | 1 | 0 | 0 | 1 | 249.000 | 0 | 0 | 0.0000000 | 0 | 2012 | 101 |
| 3 | 0 | 0 | 0 | 0 | 40 | 40.000 | 0 | 3 | 1.0000000 | 0 | 2012 | 102 |
| 3 | 0 | 0 | 1 | 1 | 0 | 0.000 | 0 | 0 | 0.0000000 | 0 | 2012 | 103 |
| 3 | 0 | 1 | 1 | 1 | 2 | 350.000 | 0 | 0 | 0.0000000 | 0 | 2012 | 104 |
| 3 | 1 | 0 | 1 | 0 | 8 | 1157.000 | 0 | 0 | 0.0000000 | 0 | 2012 | 105 |
| 3 | 0 | 1 | 0 | 0 | 3 | 512.000 | 0 | 0 | 0.0000000 | 0 | 2012 | 106 |
| 3 | 1 | 1 | 0 | 0 | 6 | 1114.000 | 0 | 0 | 0.0000000 | 0 | 2012 | 107 |
| 3 | 0 | 1 | 1 | 0 | 2 | 230.000 | 0 | 2 | 0.6666667 | 0 | 2012 | 108 |
| 2 | 1 | 1 | 1 | 0 | 1 | 4067.000 | 0 | 0 | 0.0000000 | 0 | 2013 | 117 |
| 2 | 1 | 1 | 0 | 0 | 5 | 2154.000 | 0 | 0 | 0.0000000 | 0 | 2013 | 118 |
| 2 | 0 | 0 | 0 | 0 | 1 | 420.000 | 0 | 1 | 0.5000000 | 0 | 2013 | 119 |
| 2 | 0 | 0 | 0 | 0 | 8 | 607.000 | 0 | 0 | 0.0000000 | 0 | 2013 | 120 |
| 2 | 0 | 1 | 0 | 0 | 1 | 131.000 | 0 | 0 | 0.0000000 | 0 | 2013 | 121 |
| 2 | 0 | 0 | 0 | 0 | 1 | 0.000 | 0 | 0 | 0.0000000 | 0 | 2013 | 122 |
| 2 | 0 | 1 | 0 | 0 | 5 | 50.000 | 0 | 3 | 1.5000000 | 0 | 2013 | 123 |
| 2 | 1 | 1 | 1 | 1 | 3 | 1281.000 | 0 | 3 | 1.5000000 | 0 | 2013 | 124 |
| 2 | 0 | 1 | 1 | 1 | 1 | 86.000 | 0 | 0 | 0.0000000 | 0 | 2013 | 127 |
| 1 | 0 | 0 | 1 | 0 | 12 | 0.000 | 0 | 0 | 0.0000000 | 0 | 2014 | 128 |
| 1 | 0 | 1 | 1 | 0 | 0 | 371.000 | 0 | 2 | 2.0000000 | 0 | 2014 | 129 |
| 1 | 1 | 1 | 1 | 1 | 0 | 3261.000 | 0 | 0 | 0.0000000 | 0 | 2014 | 130 |
| 1 | 1 | 1 | 1 | 0 | 0 | 6274.000 | 0 | 3 | 3.0000000 | 0 | 2014 | 131 |
| 0 | 0 | 1 | 1 | 1 | 0 | 256.000 | 0 | 0 | 0.0000000 | 0 | 2015 | 136 |
| 0 | 0 | 0 | 0 | 0 | 0 | 212.000 | 0 | 0 | 0.0000000 | 0 | 2015 | 137 |
| 36 | 0 | 1 | 0 | 0 | 0 | 0.000 | 0 | 1 | 0.0277778 | 0 | 1979 | 1 |
| 31 | 0 | 1 | 0 | 0 | 0 | 98.000 | 0 | 8 | 0.2580645 | 0 | 1984 | 4 |
TCY <- lm(Citedby ~ Year + Citedby + BusinessSupport + UnitedState + PublicationYear + CitationbyYear, data = scopus) Error in eval(mf, parent.frame()) : object ‘scopus’ not found TCY <- lm(Citedby ~ Year + Citedby + BusinessSupport + UnitedState + PublicationYear + CitationbyYear, data = Scopus) Error in eval(predvars, data, env) : object ‘Citedby’ not found library(psych) describe(DF) vars n mean sd median PublicationYears 1 67 8.52 8.16 7.0 BigSample 2 67 0.27 0.45 0.0 Method 3 67 0.70 0.46 1.0 AngloSaxon 4 67 0.69 0.47 1.0 USA 5 67 0.45 0.50 0.0 TimeSpan 6 67 3.87 7.57 1.0 Sample 7 67 1755.17 6348.16 371.0 BusinessSupport 8 67 0.04 0.21 0.0 TC 9 67 22.52 46.55 3.0 TCYear 10 67 2.17 3.95 0.5 EXCLUDED 11 67 0.00 0.00 0.0 PY 12 67 2006.48 8.16 2008.0 Nr_Papieru 13 67 64.72 44.95 55.0 trimmed mad min max PublicationYears 7.05 5.93 0 36.00 BigSample 0.22 0.00 0 1.00 Method 0.75 0.00 0 1.00 AngloSaxon 0.73 0.00 0 1.00 USA 0.44 0.00 0 1.00 TimeSpan 2.20 1.48 0 40.00 Sample 779.31 413.65 0 51755.00 BusinessSupport 0.00 0.00 0 1.00 TC 10.87 4.45 0 227.00 TCYear 1.19 0.74 0 18.92 EXCLUDED 0.00 0.00 0 0.00 PY 2007.95 5.93 1979 2015.00 Nr_Papieru 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 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 (Intercept) -1.085e+00
1.206e+00 -0.900 PublicationYears 1.019e-01 5.645e-02 1.806 BigSample
3.583e+00 1.129e+00 3.173 Method 6.020e-01 1.069e+00 0.563 AngloSaxon
8.287e-01 1.027e+00 0.807 TimeSpan 1.106e-01 6.237e-02 1.773 Sample
-5.256e-05 7.557e-05 -0.696 BusinessSupport 2.185e+00 2.184e+00 1.001
Pr(>|t|)
(Intercept) 0.3718
PublicationYears 0.0760 . BigSample 0.0024 ** Method 0.5755
AngloSaxon 0.4231
TimeSpan 0.0815 . Sample 0.4895
BusinessSupport 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
plot(TCY) Hit
to see next plot: Hit to see next plot: Hit to see next plot: Hit to see next plot: Warning messages: 1: In sqrt(crit * p * (1 - hh)/hh) : NaNs produced 2: In sqrt(crit * p * (1 - hh)/hh) : NaNs produced hats <- as.data.frame(hatvalues(TCY)) hats hatvalues(TCY) 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 hats[order(-hats[‘hatvalues(TCY)’]), ] Error in xtfrm.data.frame(x) : cannot xtfrm data frames hats <- hatvalues(TCY) plot(hats, type = ‘h’) Connected to your session in progress, last started 2024-Jan-08 19:12:09 UTC (1 hour ago) cutoff <- 2 * (length(coef(TCY)) - 1) / length(hats) z <- hats > cutoff sum(z, na.rm = FALSE) [1] 8 cutoff <- 2*(6-1)/20 z <- hats > cutoff z 2 3 5 6 7 8 9 10 FALSE FALSE FALSE FALSE FALSE FALSE FALSE FALSE 11 12 15 19 20 21 22 23 FALSE FALSE FALSE FALSE FALSE FALSE FALSE FALSE 24 29 30 35 36 37 38 43 FALSE FALSE FALSE FALSE FALSE FALSE FALSE FALSE 44 45 46 51 52 53 54 55 FALSE FALSE FALSE FALSE FALSE FALSE FALSE FALSE 62 63 64 67 68 77 78 88 FALSE FALSE TRUE FALSE FALSE FALSE FALSE FALSE 90 91 101 102 103 104 105 106 FALSE FALSE FALSE FALSE FALSE FALSE FALSE FALSE 107 108 117 118 119 120 121 122 FALSE FALSE FALSE FALSE FALSE FALSE FALSE FALSE 123 124 127 128 129 130 131 136 FALSE FALSE FALSE FALSE FALSE FALSE FALSE FALSE 137 1 4 FALSE FALSE FALSE sum(z, na.rm = FALSE)