{"id":337064,"date":"2022-08-15T15:00:41","date_gmt":"2022-08-15T15:00:41","guid":{"rendered":"http:\/\/savepearlharbor.com\/?p=337064"},"modified":"-0001-11-30T00:00:00","modified_gmt":"-0001-11-29T21:00:00","slug":"","status":"publish","type":"post","link":"https:\/\/savepearlharbor.com\/?p=337064","title":{"rendered":"<span>\u041e\u0446\u0435\u043d\u043a\u0430 \u0434\u043e\u0432\u0435\u0440\u0438\u0442\u0435\u043b\u044c\u043d\u044b\u0445 \u0438\u043d\u0442\u0435\u0440\u0432\u0430\u043b\u043e\u0432 bootstrap \u043d\u0430 \u043f\u0440\u0438\u043c\u0435\u0440\u0435 \u0441\u0443\u043f\u0435\u0440\u043a\u0443\u0431\u043a\u0430 #TidyTuesday<\/span>"},"content":{"rendered":"<div><\/div>\n<div id=\"post-content-body\">\n<div>\n<div class=\"article-formatted-body article-formatted-body article-formatted-body_version-2\">\n<div xmlns=\"http:\/\/www.w3.org\/1999\/xhtml\">\n<p>\u0414\u0430\u043d\u043d\u0430\u044f \u0437\u0430\u043c\u0435\u0442\u043a\u0430 &#8212; \u044d\u0442\u043e \u043b\u044e\u0431\u0438\u0442\u0435\u043b\u044c\u0441\u043a\u0438\u0439 \u043f\u0435\u0440\u0435\u0432\u043e\u0434 \u0441\u0442\u0430\u0442\u044c\u0438 <a href=\"https:\/\/juliasilge.com\/blog\/superbowl-conf-int\/\" rel=\"noopener noreferrer nofollow\">Julia Silge.<\/a><\/p>\n<p>\u042d\u0442\u0430 \u0441\u0442\u0430\u0442\u044c\u044f \u0432\u0437\u044f\u0442\u0430 \u0438\u0437 \u0431\u043b\u043e\u0433\u0430 Julia Silge, \u043a\u043e\u0442\u043e\u0440\u0430\u044f \u0434\u0435\u043c\u043e\u043d\u0441\u0442\u0440\u0438\u0440\u0443\u0435\u0442 \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u043d\u0438\u0435 \u043f\u0430\u043a\u0435\u0442\u043e\u0432 tidymodels. \u0412 \u0441\u0435\u0433\u043e\u0434\u043d\u044f\u0448\u043d\u0435\u0439 \u0437\u0430\u043c\u0435\u0442\u043a\u0435 \u0431\u0443\u0434\u0435\u0442 \u043f\u043e\u043a\u0430\u0437\u0430\u043d\u0430 \u043e\u0442\u043d\u043e\u0441\u0438\u0442\u0435\u043b\u044c\u043d\u043e \u043d\u043e\u0432\u0430\u044f \u0444\u0443\u043d\u043a\u0446\u0438\u044f \u0438\u0437 \u043f\u0430\u043a\u0435\u0442\u0430 <em>rsample<\/em> &#8212; <em>reg_intervals<\/em>. \u0414\u0430\u043d\u043d\u0430\u044f \u0444\u0443\u043d\u043a\u0446\u0438\u044f \u0440\u0430\u0437\u0440\u0430\u0431\u043e\u0442\u0430\u043d\u0430 \u0434\u043b\u044f \u0431\u044b\u0441\u0442\u0440\u043e\u0433\u043e \u043f\u043e\u0438\u0441\u043a\u0430 \u0434\u043e\u0432\u0435\u0440\u0438\u0442\u0435\u043b\u044c\u043d\u044b\u0445 \u0438\u043d\u0442\u0435\u0440\u0432\u0430\u043b\u043e\u0432 bootstrap. <\/p>\n<p><strong>\u0414\u0430\u043d\u043d\u044b\u0435:<\/strong> \u043d\u0430\u0431\u043e\u0440 #TidyTuesday \u043e \u0440\u0435\u043a\u043b\u0430\u043c\u043d\u044b\u0445 \u0440\u043e\u043b\u0438\u043a\u0430\u0445 \u0441\u0443\u043f\u0435\u0440\u043a\u0443\u0431\u043a\u0430.<\/p>\n<h2>\u0417\u043d\u0430\u043a\u043e\u043c\u0438\u043c\u0441\u044f \u0441 \u0434\u0430\u043d\u043d\u044b\u043c\u0438<\/h2>\n<p>\u041d\u0430\u0448\u0430 \u0446\u0435\u043b\u044c \u0432\u044b\u044f\u0441\u043d\u0438\u0442\u044c, \u043a\u0430\u043a \u0441 \u0442\u0435\u0447\u0435\u043d\u0438\u0435\u043c \u0432\u0440\u0435\u043c\u0435\u043d\u0438 \u043c\u0435\u043d\u044f\u043b\u0438\u0441\u044c \u0445\u0430\u0440\u0430\u043a\u0442\u0435\u0440\u0438\u0441\u0442\u0438\u043a\u0438 \u0440\u0435\u043a\u043b\u0430\u043c\u043d\u044b\u0445 \u0440\u043e\u043b\u0438\u043a\u043e\u0432 \u0441\u0443\u043f\u0435\u0440\u043a\u0443\u0431\u043a\u0430. \u0412 \u043d\u0430\u0448\u0438\u0445 \u0434\u0430\u043d\u043d\u044b\u0445 \u043d\u0435 \u0442\u0430\u043a \u043c\u043d\u043e\u0433\u043e \u043d\u0430\u0431\u043b\u044e\u0434\u0435\u043d\u0438\u0439, \u0447\u0442\u043e \u043f\u043e\u0437\u0432\u043e\u043b\u044f\u0435\u0442 \u043d\u0430\u043c \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u0442\u044c \u043c\u0435\u0442\u043e\u0434 bootstrap \u0434\u043b\u044f \u0434\u0435\u043c\u043e\u043d\u0441\u0442\u0440\u0430\u0446\u0438\u0438.<\/p>\n<p>\u041f\u0440\u043e\u0447\u0438\u0442\u0430\u0435\u043c \u043d\u0430\u0448\u0438 \u0434\u0430\u043d\u043d\u044b\u0435:<\/p>\n<pre><code class=\"r\">library(tidyverse) youtube &lt;- read_csv(\"https:\/\/raw.githubusercontent.com\/rfordatascience\/tidytuesday\/master\/data\/2021\/2021-03-02\/youtube.csv\")<\/code><\/pre>\n<p>\u0414\u0430\u0432\u0430\u0439\u0442\u0435 \u0441\u0434\u0435\u043b\u0430\u0435\u043c \u043d\u0435\u043a\u043e\u0442\u043e\u0440\u044b\u0435 \u043f\u0440\u0435\u043e\u0431\u0440\u0430\u0437\u043e\u0432\u0430\u043d\u0438\u0435 \u0438 \u043f\u043e\u0441\u043c\u043e\u0442\u0440\u0438\u043c, \u043a\u0430\u043a \u0432\u0435\u0434\u0443\u0442 \u0441\u0435\u0431\u044f \u0434\u0430\u043d\u043d\u044b\u0435 \u0441 \u0442\u0435\u0447\u0435\u043d\u0438\u0435\u043c \u0432\u0440\u0435\u043c\u0435\u043d\u0438. <\/p>\n<pre><code class=\"r\">youtube %>%   select(year, funny:use_sex) %>%    pivot_longer(funny:use_sex) %>%    group_by(year, name) %>%   summarise(prop = mean(value)) %>%    ungroup() %>%   ggplot(aes(year, prop, color = name)) +   geom_line(size = 1.2, show.legend = FALSE) +   facet_wrap(~name) +   scale_y_continuous(labels = scales::percent) +   labs(x = NULL, y = \"% of commercials\")<\/code><\/pre>\n<figure class=\"full-width\"><img loading=\"lazy\" decoding=\"async\" src=\"https:\/\/habrastorage.org\/r\/w1560\/getpro\/habr\/upload_files\/5f6\/ae8\/e40\/5f6ae8e40197ca86c96cfe2813e8df18.png\" alt=\"\u0413\u0440\u0430\u0444\u0438\u043a \u21161\" title=\"\u0413\u0440\u0430\u0444\u0438\u043a \u21161\" width=\"5840\" height=\"4131\" data-src=\"https:\/\/habrastorage.org\/getpro\/habr\/upload_files\/5f6\/ae8\/e40\/5f6ae8e40197ca86c96cfe2813e8df18.png\"\/><figcaption>\u0413\u0440\u0430\u0444\u0438\u043a \u21161<\/figcaption><\/figure>\n<h2>\u0421\u0434\u0435\u043b\u0430\u0435\u043c \u043f\u0440\u043e\u0441\u0442\u0443\u044e \u043c\u043e\u0434\u0435\u043b\u044c<\/h2>\n<p>\u041d\u0435 \u0441\u043c\u043e\u0442\u0440\u044f \u043d\u0430 \u0442\u043e, \u0447\u0442\u043e \u0434\u0430\u043d\u043d\u044b\u0435 \u043d\u0435 \u0432\u044b\u0433\u043b\u044f\u0434\u044f\u0442 \u0438\u0434\u0435\u0430\u043b\u044c\u043d\u043e \u043b\u0438\u043d\u0435\u0439\u043d\u044b\u043c\u0438, \u043c\u044b \u043c\u043e\u0436\u0435\u043c \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u0442\u044c \u043b\u0438\u043d\u0435\u0439\u043d\u0443\u044e \u043c\u043e\u0434\u0435\u043b\u044c \u0434\u043b\u044f \u043e\u0446\u0435\u043d\u043a\u0438 \u043d\u0430\u0448\u0438\u0445 \u0445\u0430\u0440\u0430\u043a\u0442\u0435\u0440\u0438\u0441\u0442\u0438\u043a. <\/p>\n<pre><code class=\"r\">simple_mod &lt;- lm(year ~ funny + show_product_quickly + patriotic + celebrity + danger + animals + use_sex,                  data = youtube) summary(simple_mod)<\/code><\/pre>\n<pre><code>Call: lm(formula = year ~ funny + show_product_quickly + patriotic +      celebrity + danger + animals + use_sex, data = youtube)  Residuals:      Min       1Q   Median       3Q      Max  -12.5254  -4.1023   0.1456   3.9662  10.1727   Coefficients:                           Estimate Std. Error  t value Pr(>|t|)     (Intercept)              2011.0838     0.9312 2159.748  &lt; 2e-16 *** funnyTRUE                  -2.8979     0.8593   -3.372  0.00087 *** show_product_quicklyTRUE    0.7706     0.7443    1.035  0.30160     patrioticTRUE               2.0455     1.0140    2.017  0.04480 *   celebrityTRUE               2.4416     0.7767    3.144  0.00188 **  dangerTRUE                  0.4814     0.7846    0.614  0.54007     animalsTRUE                 0.1082     0.7330    0.148  0.88274     use_sexTRUE                -2.4041     0.8175   -2.941  0.00359 **  --- Signif. codes:  0 \u2018***\u2019 0.001 \u2018**\u2019 0.01 \u2018*\u2019 0.05 \u2018.\u2019 0.1 \u2018 \u2019 1  Residual standard error: 5.391 on 239 degrees of freedom Multiple R-squared:  0.178,Adjusted R-squared:  0.1539  F-statistic: 7.393 on 7 and 239 DF,  p-value: 4.824e-08<\/code><\/pre>\n<p>\u041c\u044b \u043f\u043e\u043b\u0443\u0447\u0438\u043b\u0438 \u0441\u0442\u0430\u0442\u0438\u0441\u0442\u0438\u0447\u0435\u0441\u043a\u0438\u0435 \u0441\u0432\u043e\u0439\u0441\u0442\u0432\u0430 \u043b\u0438\u043d\u0435\u0439\u043d\u043e\u0439 \u043c\u043e\u0434\u0435\u043b\u0438, \u043d\u043e \u043c\u044b \u043c\u043e\u0436\u0435\u043c \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u0442\u044c bootstrap \u0434\u043b\u044f \u0442\u043e\u0433\u043e, \u0447\u0442\u043e\u0431\u044b \u043e\u0446\u0435\u043d\u0438\u0442\u044c \u0434\u0438\u0441\u043f\u0435\u0440\u0441\u0438\u044e \u043d\u0430\u0448\u0438\u0445 \u0432\u0435\u043b\u0438\u0447\u0438\u043d. \u0412 \u044d\u0442\u043e\u043c \u043d\u0430\u043c \u043f\u043e\u043c\u043e\u0436\u0435\u0442 \u043f\u0430\u043a\u0435\u0442 <em>rsample.<\/em><\/p>\n<pre><code class=\"r\">library(rsample) bootstraps(youtube, times = 1000)<\/code><\/pre>\n<pre><code># Bootstrap sampling  # A tibble: 1,000 \u00d7 2    splits           id               &lt;list>           &lt;chr>          1 &lt;split [247\/87]> Bootstrap0001  2 &lt;split [247\/85]> Bootstrap0002  3 &lt;split [247\/88]> Bootstrap0003  4 &lt;split [247\/83]> Bootstrap0004  5 &lt;split [247\/87]> Bootstrap0005  6 &lt;split [247\/84]> Bootstrap0006  7 &lt;split [247\/92]> Bootstrap0007  8 &lt;split [247\/84]> Bootstrap0008  9 &lt;split [247\/91]> Bootstrap0009 10 &lt;split [247\/86]> Bootstrap0010 # \u2026 with 990 more rows<\/code><\/pre>\n<p>\u041d\u0430\u043c \u0431\u044b \u043f\u0440\u0438\u0448\u043b\u043e\u0441\u044c \u0432\u044b\u043f\u043e\u043b\u043d\u0438\u0442\u044c \u0434\u043e\u0441\u0442\u0430\u0442\u043e\u0447\u043d\u043e \u043c\u043d\u043e\u0433\u043e \u043f\u0440\u0435\u0434\u0432\u0430\u0440\u0438\u0442\u0435\u043b\u044c\u043d\u044b\u0445 \u0448\u0430\u0433\u043e\u0432, \u0447\u0442\u043e\u0431\u044b \u043d\u0430\u0439\u0442\u0438 \u0434\u043e\u0432\u0435\u0440\u0438\u0442\u0435\u043b\u044c\u043d\u044b\u0435 \u0438\u043d\u0442\u0435\u0440\u0432\u0430\u043b\u044b. \u041f\u043e\u044d\u0442\u043e\u043c\u0443 \u0432 \u043f\u0430\u043a\u0435\u0442\u0435 <em>rsample <\/em>\u043f\u0440\u0435\u0434\u0443\u0441\u043c\u043e\u0442\u0440\u0435\u043d\u0430 \u0444\u0443\u043d\u043a\u0446\u0438\u044f <em>reg_intervals()<\/em>, \u043a\u043e\u0442\u043e\u0440\u0430\u044f \u043d\u0430\u0445\u043e\u0434\u0438\u0442 \u0434\u043e\u0432\u0435\u0440\u0438\u0442\u0435\u043b\u044c\u043d\u044b\u0435 \u0438\u043d\u0442\u0435\u0440\u0432\u0430\u043b\u044b \u0434\u043b\u044f \u043c\u043e\u0434\u0435\u043b\u0435\u0439 \u0442\u0438\u043f\u0430: lm(), glm().<\/p>\n<pre><code class=\"r\">set.seed(123) youtube_intervals &lt;- reg_intervals(year ~ funny + show_product_quickly + patriotic + celebrity + danger + animals + use_sex,                                    data = youtube,                                    type = \"percentile\",                                    keep_reps = TRUE) youtube_intervals<\/code><\/pre>\n<pre><code># A tibble: 7 \u00d7 7   term                     .lower .estimate .upper .alpha .method      .replicates   &lt;chr>                     &lt;dbl>     &lt;dbl>  &lt;dbl>  &lt;dbl> &lt;chr>      &lt;list&lt;tibble> 1 animalsTRUE              -1.22      0.144  1.51    0.05 percentile   [2,001 \u00d7 2] 2 celebrityTRUE             0.828     2.46   4.06    0.05 percentile   [2,001 \u00d7 2] 3 dangerTRUE               -1.01      0.515  2.09    0.05 percentile   [2,001 \u00d7 2] 4 funnyTRUE                -4.58     -2.91  -1.26    0.05 percentile   [2,001 \u00d7 2] 5 patrioticTRUE             0.112     2.05   3.88    0.05 percentile   [2,001 \u00d7 2] 6 show_product_quicklyTRUE -0.839     0.740  2.23    0.05 percentile   [2,001 \u00d7 2] 7 use_sexTRUE              -4.04     -2.43  -0.952   0.05 percentile   [2,001 \u00d7 2]<\/code><\/pre>\n<h2>\u041f\u043e\u0441\u043c\u043e\u0442\u0440\u0438 \u043d\u0430 \u0440\u0435\u0437\u0443\u043b\u044c\u0442\u0430\u0442\u044b bootstrap<\/h2>\n<p>\u041c\u044b \u043c\u043e\u0436\u0435\u043c \u0432\u0438\u0437\u0443\u0430\u043b\u0438\u0437\u0438\u0440\u043e\u0432\u0430\u0442\u044c \u043d\u0430\u0448\u0438 \u0440\u0435\u0437\u0443\u043b\u044c\u0442\u0430\u0442\u044b. \u041e\u0431\u0440\u0430\u0442\u0438\u043c \u0432\u043d\u0438\u043c\u0430\u043d\u0438\u0435, \u0447\u0442\u043e \u0435\u0441\u043b\u0438 \u0431\u044b \u043c\u044b \u043d\u0435 \u0443\u0441\u0442\u0430\u043d\u043e\u0432\u0438\u043b \u043f\u0430\u0440\u0430\u043c\u0435\u0442\u0440 <em>keep_reps = TRUE, <\/em>\u0442\u043e \u0443 \u043d\u0430\u0441 \u0431\u044b\u043b\u0438 \u0431\u044b \u0442\u043e\u043b\u044c\u043a\u043e \u0438\u043d\u0442\u0435\u0440\u0432\u0430\u043b\u044b \u0438 \u043c\u044b \u0431\u044b \u043d\u0435 \u0441\u043c\u043e\u0433\u043b\u0438 \u043f\u043e\u0441\u0442\u0440\u043e\u0438\u0442\u044c \u0433\u0440\u0430\u0444\u0438\u043a \u21163.<\/p>\n<pre><code class=\"r\">youtube_intervals %>%   mutate(term = str_remove(term, \"TRUE\"),          term = fct_reorder(term, .estimate)) %>%   ggplot(aes(.estimate, term)) +   geom_vline(xintercept = 0, size = 1.5, lty = 2, color = \"gray80\") +   geom_errorbarh(aes(xmin = .lower, xmax = .upper),                  size = 1.5, alpha = 0.5, color = \"midnightblue\") +   geom_point(size = 3, color = \"midnightblue\") +   labs(x = \"Increase in year for each commercial characteristic\",        y = NULL)<\/code><\/pre>\n<figure class=\"full-width\"><img loading=\"lazy\" decoding=\"async\" src=\"https:\/\/habrastorage.org\/r\/w1560\/getpro\/habr\/upload_files\/d9f\/33d\/06b\/d9f33d06b3a158ca5d4d0cc6ab30e3ad.png\" alt=\"\u0413\u0440\u0430\u0444\u0438\u043a \u21162\" title=\"\u0413\u0440\u0430\u0444\u0438\u043a \u21162\" width=\"5840\" height=\"4131\" data-src=\"https:\/\/habrastorage.org\/getpro\/habr\/upload_files\/d9f\/33d\/06b\/d9f33d06b3a158ca5d4d0cc6ab30e3ad.png\"\/><figcaption>\u0413\u0440\u0430\u0444\u0438\u043a \u21162<\/figcaption><\/figure>\n<pre><code class=\"r\">outube_intervals %>%   mutate(term = str_remove(term, \"TRUE\"),          term = fct_reorder(term, .estimate)) %>%   unnest(.replicates) %>%    ggplot(aes(estimate, fill = term)) +   geom_vline(xintercept = 0, size = 1.5, lty = 2, color = \"gray50\") +   geom_histogram(alpha = 0.8, show.legend = FALSE) +   facet_wrap(vars(term))<\/code><\/pre>\n<figure class=\"full-width\"><img loading=\"lazy\" decoding=\"async\" src=\"https:\/\/habrastorage.org\/r\/w1560\/getpro\/habr\/upload_files\/572\/d1c\/865\/572d1c8656a5e71f182424fe91818f28.png\" alt=\"\u0413\u0440\u0430\u0444\u0438\u043a \u21163\" title=\"\u0413\u0440\u0430\u0444\u0438\u043a \u21163\" width=\"5840\" height=\"4131\" data-src=\"https:\/\/habrastorage.org\/getpro\/habr\/upload_files\/572\/d1c\/865\/572d1c8656a5e71f182424fe91818f28.png\"\/><figcaption>\u0413\u0440\u0430\u0444\u0438\u043a \u21163<\/figcaption><\/figure>\n<p>\u0422\u0430\u043a\u0438\u043c \u043e\u0431\u0440\u0430\u0437\u043e\u043c, \u043c\u044b \u0432\u0438\u0434\u0438\u043c, \u0447\u0442\u043e \u0440\u0435\u043a\u043b\u0430\u043c\u043d\u044b\u0435 \u0440\u043e\u043b\u0438\u043a\u0438 \u0441\u043e\u0434\u0435\u0440\u0436\u0430\u0442 \u043c\u0435\u043d\u044c\u0448\u0435 \u044e\u043c\u043e\u0440\u0430 \u0438 \u0441\u0435\u043a\u0441\u0443\u0430\u043b\u044c\u043d\u043e\u0433\u043e \u043a\u043e\u043d\u0442\u0435\u043d\u0442\u0430, \u0438 \u0431\u043e\u043b\u044c\u0448\u0435 \u0440\u0443\u0431\u0440\u0438\u043a \u0441\u0435\u043b\u0435\u0431\u0440\u0438\u0442\u0438 \u0438 \u043f\u0430\u0442\u0440\u0438\u043e\u0442\u0438\u0447\u0435\u0441\u043a\u0438\u0445 \u0442\u0435\u043c. <\/p>\n<\/p>\n<\/div>\n<\/div>\n<\/div>\n<div class=\"v-portal\" style=\"display:none;\"><\/div>\n<\/div>\n<p> <!----> <!----><br \/> \u0441\u0441\u044b\u043b\u043a\u0430 \u043d\u0430 \u043e\u0440\u0438\u0433\u0438\u043d\u0430\u043b \u0441\u0442\u0430\u0442\u044c\u0438 <a href=\"https:\/\/habr.com\/ru\/post\/682570\/\"> https:\/\/habr.com\/ru\/post\/682570\/<\/a><\/p>\n","protected":false},"excerpt":{"rendered":"<div><\/div>\n<div id=\"post-content-body\">\n<div>\n<div class=\"article-formatted-body article-formatted-body article-formatted-body_version-2\">\n<div xmlns=\"http:\/\/www.w3.org\/1999\/xhtml\">\n<p>\u0414\u0430\u043d\u043d\u0430\u044f \u0437\u0430\u043c\u0435\u0442\u043a\u0430 &#8212; \u044d\u0442\u043e \u043b\u044e\u0431\u0438\u0442\u0435\u043b\u044c\u0441\u043a\u0438\u0439 \u043f\u0435\u0440\u0435\u0432\u043e\u0434 \u0441\u0442\u0430\u0442\u044c\u0438 <a href=\"https:\/\/juliasilge.com\/blog\/superbowl-conf-int\/\" rel=\"noopener noreferrer nofollow\">Julia Silge.<\/a><\/p>\n<p>\u042d\u0442\u0430 \u0441\u0442\u0430\u0442\u044c\u044f \u0432\u0437\u044f\u0442\u0430 \u0438\u0437 \u0431\u043b\u043e\u0433\u0430 Julia Silge, \u043a\u043e\u0442\u043e\u0440\u0430\u044f \u0434\u0435\u043c\u043e\u043d\u0441\u0442\u0440\u0438\u0440\u0443\u0435\u0442 \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u043d\u0438\u0435 \u043f\u0430\u043a\u0435\u0442\u043e\u0432 tidymodels. \u0412 \u0441\u0435\u0433\u043e\u0434\u043d\u044f\u0448\u043d\u0435\u0439 \u0437\u0430\u043c\u0435\u0442\u043a\u0435 \u0431\u0443\u0434\u0435\u0442 \u043f\u043e\u043a\u0430\u0437\u0430\u043d\u0430 \u043e\u0442\u043d\u043e\u0441\u0438\u0442\u0435\u043b\u044c\u043d\u043e \u043d\u043e\u0432\u0430\u044f \u0444\u0443\u043d\u043a\u0446\u0438\u044f \u0438\u0437 \u043f\u0430\u043a\u0435\u0442\u0430 <em>rsample<\/em> &#8212; <em>reg_intervals<\/em>. \u0414\u0430\u043d\u043d\u0430\u044f \u0444\u0443\u043d\u043a\u0446\u0438\u044f \u0440\u0430\u0437\u0440\u0430\u0431\u043e\u0442\u0430\u043d\u0430 \u0434\u043b\u044f \u0431\u044b\u0441\u0442\u0440\u043e\u0433\u043e \u043f\u043e\u0438\u0441\u043a\u0430 \u0434\u043e\u0432\u0435\u0440\u0438\u0442\u0435\u043b\u044c\u043d\u044b\u0445 \u0438\u043d\u0442\u0435\u0440\u0432\u0430\u043b\u043e\u0432 bootstrap. <\/p>\n<p><strong>\u0414\u0430\u043d\u043d\u044b\u0435:<\/strong> \u043d\u0430\u0431\u043e\u0440 #TidyTuesday \u043e \u0440\u0435\u043a\u043b\u0430\u043c\u043d\u044b\u0445 \u0440\u043e\u043b\u0438\u043a\u0430\u0445 \u0441\u0443\u043f\u0435\u0440\u043a\u0443\u0431\u043a\u0430.<\/p>\n<h2>\u0417\u043d\u0430\u043a\u043e\u043c\u0438\u043c\u0441\u044f \u0441 \u0434\u0430\u043d\u043d\u044b\u043c\u0438<\/h2>\n<p>\u041d\u0430\u0448\u0430 \u0446\u0435\u043b\u044c \u0432\u044b\u044f\u0441\u043d\u0438\u0442\u044c, \u043a\u0430\u043a \u0441 \u0442\u0435\u0447\u0435\u043d\u0438\u0435\u043c \u0432\u0440\u0435\u043c\u0435\u043d\u0438 \u043c\u0435\u043d\u044f\u043b\u0438\u0441\u044c \u0445\u0430\u0440\u0430\u043a\u0442\u0435\u0440\u0438\u0441\u0442\u0438\u043a\u0438 \u0440\u0435\u043a\u043b\u0430\u043c\u043d\u044b\u0445 \u0440\u043e\u043b\u0438\u043a\u043e\u0432 \u0441\u0443\u043f\u0435\u0440\u043a\u0443\u0431\u043a\u0430. \u0412 \u043d\u0430\u0448\u0438\u0445 \u0434\u0430\u043d\u043d\u044b\u0445 \u043d\u0435 \u0442\u0430\u043a \u043c\u043d\u043e\u0433\u043e \u043d\u0430\u0431\u043b\u044e\u0434\u0435\u043d\u0438\u0439, \u0447\u0442\u043e \u043f\u043e\u0437\u0432\u043e\u043b\u044f\u0435\u0442 \u043d\u0430\u043c \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u0442\u044c \u043c\u0435\u0442\u043e\u0434 bootstrap \u0434\u043b\u044f \u0434\u0435\u043c\u043e\u043d\u0441\u0442\u0440\u0430\u0446\u0438\u0438.<\/p>\n<p>\u041f\u0440\u043e\u0447\u0438\u0442\u0430\u0435\u043c \u043d\u0430\u0448\u0438 \u0434\u0430\u043d\u043d\u044b\u0435:<\/p>\n<pre><code class=\"r\">library(tidyverse) youtube &lt;- read_csv(\"https:\/\/raw.githubusercontent.com\/rfordatascience\/tidytuesday\/master\/data\/2021\/2021-03-02\/youtube.csv\")<\/code><\/pre>\n<p>\u0414\u0430\u0432\u0430\u0439\u0442\u0435 \u0441\u0434\u0435\u043b\u0430\u0435\u043c \u043d\u0435\u043a\u043e\u0442\u043e\u0440\u044b\u0435 \u043f\u0440\u0435\u043e\u0431\u0440\u0430\u0437\u043e\u0432\u0430\u043d\u0438\u0435 \u0438 \u043f\u043e\u0441\u043c\u043e\u0442\u0440\u0438\u043c, \u043a\u0430\u043a \u0432\u0435\u0434\u0443\u0442 \u0441\u0435\u0431\u044f \u0434\u0430\u043d\u043d\u044b\u0435 \u0441 \u0442\u0435\u0447\u0435\u043d\u0438\u0435\u043c \u0432\u0440\u0435\u043c\u0435\u043d\u0438. <\/p>\n<pre><code class=\"r\">youtube %>%   select(year, funny:use_sex) %>%    pivot_longer(funny:use_sex) %>%    group_by(year, name) %>%   summarise(prop = mean(value)) %>%    ungroup() %>%   ggplot(aes(year, prop, color = name)) +   geom_line(size = 1.2, show.legend = FALSE) +   facet_wrap(~name) +   scale_y_continuous(labels = scales::percent) +   labs(x = NULL, y = \"% of commercials\")<\/code><\/pre>\n<figure class=\"full-width\"><figcaption>\u0413\u0440\u0430\u0444\u0438\u043a \u21161<\/figcaption><\/figure>\n<h2>\u0421\u0434\u0435\u043b\u0430\u0435\u043c \u043f\u0440\u043e\u0441\u0442\u0443\u044e \u043c\u043e\u0434\u0435\u043b\u044c<\/h2>\n<p>\u041d\u0435 \u0441\u043c\u043e\u0442\u0440\u044f \u043d\u0430 \u0442\u043e, \u0447\u0442\u043e \u0434\u0430\u043d\u043d\u044b\u0435 \u043d\u0435 \u0432\u044b\u0433\u043b\u044f\u0434\u044f\u0442 \u0438\u0434\u0435\u0430\u043b\u044c\u043d\u043e \u043b\u0438\u043d\u0435\u0439\u043d\u044b\u043c\u0438, \u043c\u044b \u043c\u043e\u0436\u0435\u043c \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u0442\u044c \u043b\u0438\u043d\u0435\u0439\u043d\u0443\u044e \u043c\u043e\u0434\u0435\u043b\u044c \u0434\u043b\u044f \u043e\u0446\u0435\u043d\u043a\u0438 \u043d\u0430\u0448\u0438\u0445 \u0445\u0430\u0440\u0430\u043a\u0442\u0435\u0440\u0438\u0441\u0442\u0438\u043a. <\/p>\n<pre><code class=\"r\">simple_mod &lt;- lm(year ~ funny + show_product_quickly + patriotic + celebrity + danger + animals + use_sex,                  data = youtube) summary(simple_mod)<\/code><\/pre>\n<pre><code>Call: lm(formula = year ~ funny + show_product_quickly + patriotic +      celebrity + danger + animals + use_sex, data = youtube)  Residuals:      Min       1Q   Median       3Q      Max  -12.5254  -4.1023   0.1456   3.9662  10.1727   Coefficients:                           Estimate Std. Error  t value Pr(>|t|)     (Intercept)              2011.0838     0.9312 2159.748  &lt; 2e-16 *** funnyTRUE                  -2.8979     0.8593   -3.372  0.00087 *** show_product_quicklyTRUE    0.7706     0.7443    1.035  0.30160     patrioticTRUE               2.0455     1.0140    2.017  0.04480 *   celebrityTRUE               2.4416     0.7767    3.144  0.00188 **  dangerTRUE                  0.4814     0.7846    0.614  0.54007     animalsTRUE                 0.1082     0.7330    0.148  0.88274     use_sexTRUE                -2.4041     0.8175   -2.941  0.00359 **  --- Signif. codes:  0 \u2018***\u2019 0.001 \u2018**\u2019 0.01 \u2018*\u2019 0.05 \u2018.\u2019 0.1 \u2018 \u2019 1  Residual standard error: 5.391 on 239 degrees of freedom Multiple R-squared:  0.178,Adjusted R-squared:  0.1539  F-statistic: 7.393 on 7 and 239 DF,  p-value: 4.824e-08<\/code><\/pre>\n<p>\u041c\u044b \u043f\u043e\u043b\u0443\u0447\u0438\u043b\u0438 \u0441\u0442\u0430\u0442\u0438\u0441\u0442\u0438\u0447\u0435\u0441\u043a\u0438\u0435 \u0441\u0432\u043e\u0439\u0441\u0442\u0432\u0430 \u043b\u0438\u043d\u0435\u0439\u043d\u043e\u0439 \u043c\u043e\u0434\u0435\u043b\u0438, \u043d\u043e \u043c\u044b \u043c\u043e\u0436\u0435\u043c \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u0442\u044c bootstrap \u0434\u043b\u044f \u0442\u043e\u0433\u043e, \u0447\u0442\u043e\u0431\u044b \u043e\u0446\u0435\u043d\u0438\u0442\u044c \u0434\u0438\u0441\u043f\u0435\u0440\u0441\u0438\u044e \u043d\u0430\u0448\u0438\u0445 \u0432\u0435\u043b\u0438\u0447\u0438\u043d. \u0412 \u044d\u0442\u043e\u043c \u043d\u0430\u043c \u043f\u043e\u043c\u043e\u0436\u0435\u0442 \u043f\u0430\u043a\u0435\u0442 <em>rsample.<\/em><\/p>\n<pre><code class=\"r\">library(rsample) bootstraps(youtube, times = 1000)<\/code><\/pre>\n<pre><code># Bootstrap sampling  # A tibble: 1,000 \u00d7 2    splits           id               &lt;list>           &lt;chr>          1 &lt;split [247\/87]> Bootstrap0001  2 &lt;split [247\/85]> Bootstrap0002  3 &lt;split [247\/88]> Bootstrap0003  4 &lt;split [247\/83]> Bootstrap0004  5 &lt;split [247\/87]> Bootstrap0005  6 &lt;split [247\/84]> Bootstrap0006  7 &lt;split [247\/92]> Bootstrap0007  8 &lt;split [247\/84]> Bootstrap0008  9 &lt;split [247\/91]> Bootstrap0009 10 &lt;split [247\/86]> Bootstrap0010 # \u2026 with 990 more rows<\/code><\/pre>\n<p>\u041d\u0430\u043c \u0431\u044b \u043f\u0440\u0438\u0448\u043b\u043e\u0441\u044c \u0432\u044b\u043f\u043e\u043b\u043d\u0438\u0442\u044c \u0434\u043e\u0441\u0442\u0430\u0442\u043e\u0447\u043d\u043e \u043c\u043d\u043e\u0433\u043e \u043f\u0440\u0435\u0434\u0432\u0430\u0440\u0438\u0442\u0435\u043b\u044c\u043d\u044b\u0445 \u0448\u0430\u0433\u043e\u0432, \u0447\u0442\u043e\u0431\u044b \u043d\u0430\u0439\u0442\u0438 \u0434\u043e\u0432\u0435\u0440\u0438\u0442\u0435\u043b\u044c\u043d\u044b\u0435 \u0438\u043d\u0442\u0435\u0440\u0432\u0430\u043b\u044b. \u041f\u043e\u044d\u0442\u043e\u043c\u0443 \u0432 \u043f\u0430\u043a\u0435\u0442\u0435 <em>rsample <\/em>\u043f\u0440\u0435\u0434\u0443\u0441\u043c\u043e\u0442\u0440\u0435\u043d\u0430 \u0444\u0443\u043d\u043a\u0446\u0438\u044f <em>reg_intervals()<\/em>, \u043a\u043e\u0442\u043e\u0440\u0430\u044f \u043d\u0430\u0445\u043e\u0434\u0438\u0442 \u0434\u043e\u0432\u0435\u0440\u0438\u0442\u0435\u043b\u044c\u043d\u044b\u0435 \u0438\u043d\u0442\u0435\u0440\u0432\u0430\u043b\u044b \u0434\u043b\u044f \u043c\u043e\u0434\u0435\u043b\u0435\u0439 \u0442\u0438\u043f\u0430: lm(), glm().<\/p>\n<pre><code class=\"r\">set.seed(123) youtube_intervals &lt;- reg_intervals(year ~ funny + show_product_quickly + patriotic + celebrity + danger + animals + use_sex,                                    data = youtube,                                    type = \"percentile\",                                    keep_reps = TRUE) youtube_intervals<\/code><\/pre>\n<pre><code># A tibble: 7 \u00d7 7   term                     .lower .estimate .upper .alpha .method      .replicates   &lt;chr>                     &lt;dbl>     &lt;dbl>  &lt;dbl>  &lt;dbl> &lt;chr>      &lt;list&lt;tibble> 1 animalsTRUE              -1.22      0.144  1.51    0.05 percentile   [2,001 \u00d7 2] 2 celebrityTRUE             0.828     2.46   4.06    0.05 percentile   [2,001 \u00d7 2] 3 dangerTRUE               -1.01      0.515  2.09    0.05 percentile   [2,001 \u00d7 2] 4 funnyTRUE                -4.58     -2.91  -1.26    0.05 percentile   [2,001 \u00d7 2] 5 patrioticTRUE             0.112     2.05   3.88    0.05 percentile   [2,001 \u00d7 2] 6 show_product_quicklyTRUE -0.839     0.740  2.23    0.05 percentile   [2,001 \u00d7 2] 7 use_sexTRUE              -4.04     -2.43  -0.952   0.05 percentile   [2,001 \u00d7 2]<\/code><\/pre>\n<h2>\u041f\u043e\u0441\u043c\u043e\u0442\u0440\u0438 \u043d\u0430 \u0440\u0435\u0437\u0443\u043b\u044c\u0442\u0430\u0442\u044b bootstrap<\/h2>\n<p>\u041c\u044b \u043c\u043e\u0436\u0435\u043c \u0432\u0438\u0437\u0443\u0430\u043b\u0438\u0437\u0438\u0440\u043e\u0432\u0430\u0442\u044c \u043d\u0430\u0448\u0438 \u0440\u0435\u0437\u0443\u043b\u044c\u0442\u0430\u0442\u044b. \u041e\u0431\u0440\u0430\u0442\u0438\u043c \u0432\u043d\u0438\u043c\u0430\u043d\u0438\u0435, \u0447\u0442\u043e \u0435\u0441\u043b\u0438 \u0431\u044b \u043c\u044b \u043d\u0435 \u0443\u0441\u0442\u0430\u043d\u043e\u0432\u0438\u043b \u043f\u0430\u0440\u0430\u043c\u0435\u0442\u0440 <em>keep_reps = TRUE, <\/em>\u0442\u043e \u0443 \u043d\u0430\u0441 \u0431\u044b\u043b\u0438 \u0431\u044b \u0442\u043e\u043b\u044c\u043a\u043e \u0438\u043d\u0442\u0435\u0440\u0432\u0430\u043b\u044b \u0438 \u043c\u044b \u0431\u044b \u043d\u0435 \u0441\u043c\u043e\u0433\u043b\u0438 \u043f\u043e\u0441\u0442\u0440\u043e\u0438\u0442\u044c \u0433\u0440\u0430\u0444\u0438\u043a \u21163.<\/p>\n<pre><code class=\"r\">youtube_intervals %>%   mutate(term = str_remove(term, \"TRUE\"),          term = fct_reorder(term, .estimate)) %>%   ggplot(aes(.estimate, term)) +   geom_vline(xintercept = 0, size = 1.5, lty = 2, color = \"gray80\") +   geom_errorbarh(aes(xmin = .lower, xmax = .upper),                  size = 1.5, alpha = 0.5, color = \"midnightblue\") +   geom_point(size = 3, color = \"midnightblue\") +   labs(x = \"Increase in year for each commercial characteristic\",        y = NULL)<\/code><\/pre>\n<figure class=\"full-width\"><figcaption>\u0413\u0440\u0430\u0444\u0438\u043a \u21162<\/figcaption><\/figure>\n<pre><code class=\"r\">outube_intervals %>%   mutate(term = str_remove(term, \"TRUE\"),          term = fct_reorder(term, .estimate)) %>%   unnest(.replicates) %>%    ggplot(aes(estimate, fill = term)) +   geom_vline(xintercept = 0, size = 1.5, lty = 2, color = \"gray50\") +   geom_histogram(alpha = 0.8, show.legend = FALSE) +   facet_wrap(vars(term))<\/code><\/pre>\n<figure class=\"full-width\"><figcaption>\u0413\u0440\u0430\u0444\u0438\u043a \u21163<\/figcaption><\/figure>\n<p>\u0422\u0430\u043a\u0438\u043c \u043e\u0431\u0440\u0430\u0437\u043e\u043c, \u043c\u044b \u0432\u0438\u0434\u0438\u043c, \u0447\u0442\u043e \u0440\u0435\u043a\u043b\u0430\u043c\u043d\u044b\u0435 \u0440\u043e\u043b\u0438\u043a\u0438 \u0441\u043e\u0434\u0435\u0440\u0436\u0430\u0442 \u043c\u0435\u043d\u044c\u0448\u0435 \u044e\u043c\u043e\u0440\u0430 \u0438 \u0441\u0435\u043a\u0441\u0443\u0430\u043b\u044c\u043d\u043e\u0433\u043e \u043a\u043e\u043d\u0442\u0435\u043d\u0442\u0430, \u0438 \u0431\u043e\u043b\u044c\u0448\u0435 \u0440\u0443\u0431\u0440\u0438\u043a \u0441\u0435\u043b\u0435\u0431\u0440\u0438\u0442\u0438 \u0438 \u043f\u0430\u0442\u0440\u0438\u043e\u0442\u0438\u0447\u0435\u0441\u043a\u0438\u0445 \u0442\u0435\u043c. <\/p>\n<\/p>\n<\/div>\n<\/div>\n<\/div>\n<div class=\"v-portal\" style=\"display:none;\"><\/div>\n<\/div>\n<p> <!----> <!----><br \/> \u0441\u0441\u044b\u043b\u043a\u0430 \u043d\u0430 \u043e\u0440\u0438\u0433\u0438\u043d\u0430\u043b \u0441\u0442\u0430\u0442\u044c\u0438 <a href=\"https:\/\/habr.com\/ru\/post\/682570\/\"> https:\/\/habr.com\/ru\/post\/682570\/<\/a><br \/><\/br><\/br><\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[],"tags":[],"class_list":["post-337064","post","type-post","status-publish","format-standard","hentry"],"_links":{"self":[{"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=\/wp\/v2\/posts\/337064","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=%2Fwp%2Fv2%2Fcomments&post=337064"}],"version-history":[{"count":0,"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=\/wp\/v2\/posts\/337064\/revisions"}],"wp:attachment":[{"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=%2Fwp%2Fv2%2Fmedia&parent=337064"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=%2Fwp%2Fv2%2Fcategories&post=337064"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=%2Fwp%2Fv2%2Ftags&post=337064"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}