### GitBook Configuration and Startup Script Source: https://github.com/statsthinking21/statsthinking21-core/blob/master/_book/hypothesis-testing.html This JavaScript code initializes the GitBook plugin with configurations for sharing options (enabling Facebook and Twitter), font settings (white theme, sans family, size 2), an edit link to the GitHub repository for the R Markdown source, download options for PDF and EPUB, Fuse search engine, and a collapsible table of contents at subsection level. It requires the GitBook module and starts the book interface. No inputs or outputs beyond DOM manipulation; depends on GitBook being loaded. Limitations: hardcoded links and options may not adapt to different environments. ```javascript gitbook.require(["gitbook"], function(gitbook) { gitbook.start({ "sharing": { "github": false, "facebook": true, "twitter": true, "linkedin": false, "weibo": false, "instapaper": false, "vk": false, "whatsapp": false, "all": ["facebook", "twitter", "linkedin", "weibo", "instapaper"] }, "fontsettings": { "theme": "white", "family": "sans", "size": 2 }, "edit": { "link": "https://github.com/statsthinking21/statsthinking21-core/edit/master/09-HypothesisTesting.Rmd", "text": "Edit" }, "history": { "link": null, "text": null }, "view": { "link": null, "text": null }, "download": ["StatsThinking21.pdf", "StatsThinking21.epub"], "search": { "engine": "fuse", "options": null }, "toc": { "collapse": "subsection" } }); }); ``` -------------------------------- ### Basic R for Statistical Analysis Source: https://github.com/statsthinking21/statsthinking21-core/blob/master/_book/ci-effect-size-power.html This snippet demonstrates fundamental R commands used for statistical analysis, including data import, manipulation, and basic plotting. It serves as a foundational example for users new to R in a statistical context. ```r library(tidyverse) # Load data data <- read_csv("my_data.csv") # Data manipulation summary_data <- data %>% group_by(group) %>% summarise(mean_value = mean(value), sd_value = sd(value)) # Plotting ggplot(summary_data, aes(x = group, y = mean_value)) + geom_bar(stat = "identity") + geom_error_bar(aes(ymin = mean_value - sd_value, ymax = mean_value + sd_value)) ``` -------------------------------- ### Python for Statistical Analysis with Pandas and Matplotlib Source: https://github.com/statsthinking21/statsthinking21-core/blob/master/_book/ci-effect-size-power.html This Python snippet showcases essential libraries like Pandas for data manipulation and Matplotlib for visualization. It provides a practical example of how to perform basic statistical analyses and create plots in Python. ```python import pandas as pd import matplotlib.pyplot as plt # Load data data = pd.read_csv("my_data.csv") # Data manipulation summary_data = data.groupby('group')['value'].agg(['mean', 'std']) # Plotting plt.bar(summary_data.index, summary_data['mean']) plt.errorbar(summary_data.index, summary_data['mean'], yerr=summary_data['std'], fmt='none', ecolor='black') plt.xlabel('Group') plt.ylabel('Mean Value') plt.title('Mean Value by Group with Standard Deviation') plt.show() ``` -------------------------------- ### Initialize Gitbook Source: https://github.com/statsthinking21/statsthinking21-core/blob/master/_book/bayesian-statistics.html Initializes the Gitbook environment with specified configurations for sharing, font settings, editing, history, view, downloads, search, and table of contents. ```javascript gitbook.require(["gitbook"], function(gitbook) { gitbook.start({ "sharing": { "github": false, "facebook": true, "twitter": true, "linkedin": false, "weibo": false, "instapaper": false, "vk": false, "whatsapp": false, "all": ["facebook", "twitter", "linkedin", "weibo", "instapaper"] }, "fontsettings": { "theme": "white", "family": "sans", "size": 2 }, "edit": { "link": "https://github.com/statsthinking21/statsthinking21-core/edit/master/11-BayesianStatistics.Rmd", "text": "Edit" }, "history": { "link": null, "text": null }, "view": { "link": null, "text": null }, "download": ["StatsThinking21.pdf", "StatsThinking21.epub"], "search": { "engine": "fuse", "options": null }, "toc": { "collapse": "subsection" } }); }); ``` -------------------------------- ### Initialize GitBook with Sharing and Font Settings Source: https://github.com/statsthinking21/statsthinking21-core/blob/master/_book/resampling-and-simulation.html Initializes the GitBook environment with specified sharing options (e.g., Facebook, Twitter) and font settings (theme, family, size). This code controls the visual presentation and interactivity of the GitBook documentation. ```javascript gitbook.require(["gitbook"], function(gitbook) { gitbook.start({ "sharing": { "github": false, "facebook": true, "twitter": true, "linkedin": false, "weibo": false, "instapaper": false, "vk": false, "whatsapp": false, "all": ["facebook", "twitter", "linkedin", "weibo", "instapaper"] }, "fontsettings": { "theme": "white", "family": "sans", "size": 2 }, "edit": { "link": "https://github.com/statsthinking21/statsthinking21-core/edit/master/08-Resampling.Rmd", "text": "Edit" }, "history": { "link": null, "text": null }, "view": { "link": null, "text": null }, "download": ["StatsThinking21.pdf", "StatsThinking21.epub"], "search": { "engine": "fuse", "options": null }, "toc": { "collapse": "subsection" } }); }); ``` -------------------------------- ### R: Linear Regression Analysis Source: https://github.com/statsthinking21/statsthinking21-core/blob/master/_book/the-general-linear-model.html This snippet shows the output of a linear regression analysis performed in R. It demonstrates the estimated coefficients, standard errors, t-values, p-values, residual standard error, and R-squared values for the model. The example shows the assessment of significance. ```R ## ## Call: ## lm(formula = grade ~ studyTime, data = df) ## ## Residuals: ## Min 1Q Median 3Q Max ## -10.656 -2.719 0.125 4.703 7.469 ## ## Coefficients: ## Estimate Std. Error t value Pr(>|t|) ## (Intercept) 76.16 5.16 14.76 6.1e-06 *** ## studyTime 4.31 2.14 2.01 0.091 . ## --- ## Signif. codes: 0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1 ## ## Residual standard error: 6.4 on 6 degrees of freedom ## Multiple R-squared: 0.403, Adjusted R-squared: 0.304 ## F-statistic: 4.05 on 1 and 6 DF, p-value: 0.0907 ``` -------------------------------- ### Initialize GitBook - statsthinking21-core Source: https://github.com/statsthinking21/statsthinking21-core/blob/master/_book/fitting-models.html JavaScript code snippet used to initialize GitBook with specific configurations for sharing, font settings, editing links, history, view, downloads, search, and table of contents. ```javascript gitbook.require(["gitbook"], function(gitbook) { gitbook.start({ "sharing": { "github": false, "facebook": true, "twitter": true, "linkedin": false, "weibo": false, "instapaper": false, "vk": false, "whatsapp": false, "all": ["facebook", "twitter", "linkedin", "weibo", "instapaper"] }, "fontsettings": { "theme": "white", "family": "sans", "size": 2 }, "edit": { "link": "https://github.com/statsthinking21/statsthinking21-core/edit/master/05-FittingModels.Rmd", "text": "Edit" }, "history": { "link": null, "text": null }, "view": { "link": null, "text": null }, "download": ["StatsThinking21.pdf", "StatsThinking21.epub"], "search": { "engine": "fuse", "options": null }, "toc": { "collapse": "subsection" } }); }); ``` -------------------------------- ### Initialize GitBook with sharing and font settings Source: https://github.com/statsthinking21/statsthinking21-core/blob/master/_book/index.html Configures GitBook platform settings including social sharing buttons, font preferences, edit links, downloadable formats, search engine, and table of contents behavior. Defines UI components and their properties for the statistics textbook interface. Requires GitBook framework to function. ```javascript gitbook.require(\["gitbook"\], function(gitbook) { gitbook.start({ "sharing": { "github": false, "facebook": true, "twitter": true, "linkedin": false, "weibo": false, "instapaper": false, "vk": false, "whatsapp": false, "all": \["facebook", "twitter", "linkedin", "weibo", "instapaper"\] }, "fontsettings": { "theme": "white", "family": "sans", "size": 2 }, "edit": { "link": "https://github.com/statsthinking21/statsthinking21-core/edit/master/index.Rmd", "text": "Edit" }, "history": { "link": null, "text": null }, "view": { "link": null, "text": null }, "download": \["StatsThinking21.pdf", "StatsThinking21.epub"\], "search": { "engine": "fuse", "options": null }, "toc": { "collapse": "subsection" } }); }); ``` -------------------------------- ### Initialize GitBook configuration and load MathJax in JavaScript Source: https://github.com/statsthinking21/statsthinking21-core/blob/master/_book/comparing-means.html Configures GitBook documentation platform with sharing options, font settings, and edit links. Dynamically loads MathJax library for mathematical rendering by injecting a script tag into the document head. Used for interactive statistical documentation websites. Requires GitBook environment and internet access for MathJax CDN. ```javascript gitbook.require(["gitbook"], function(gitbook) { gitbook.start({ "sharing": { "github": false, "facebook": true, "twitter": true, "linkedin": false, "weibo": false, "instapaper": false, "vk": false, "whatsapp": false, "all": ["facebook", "twitter", "linkedin", "weibo", "instapaper"] }, "fontsettings": { "theme": "white", "family": "sans", "size": 2 }, "edit": { "link": "https://github.com/statsthinking21/statsthinking21-core/edit/master/15-ComparingMeans.Rmd", "text": "Edit" }, "history": { "link": null, "text": null }, "view": { "link": null, "text": null }, "download": ["StatsThinking21.pdf", "StatsThinking21.epub"], "search": { "engine": "fuse", "options": null }, "toc": { "collapse": "subsection" } }); }); (function () { var script = document.createElement("script"); script.type = "text/javascript"; var src = "true"; if (src === "" || src === "true") src = "https://cdnjs.cloudflare.com/ajax/libs/mathjax/2.7.9/latest.js?config=TeX-MML-AM_CHTML"; if (location.protocol !== "file:") if (/^https?:/.test(src)) src = src.replace(/^https?:/, ''); script.src = src; document.getElementsByTagName("head")[0].appendChild(script); })(); ``` -------------------------------- ### GitBook Initialization and Configuration Source: https://github.com/statsthinking21/statsthinking21-core/blob/master/_book/references.html This JavaScript code initializes and configures the GitBook environment for the STATS THINKING 21 project. It sets up sharing options, font settings, editing links, download options, search functionality, and table of contents behavior. ```javascript gitbook.require(["gitbook"], function(gitbook) { gitbook.start({ "sharing": { "github": false, "facebook": true, "twitter": true, "linkedin": false, "weibo": false, "instapaper": false, "vk": false, "whatsapp": false, "all": ["facebook", "twitter", "linkedin", "weibo", "instapaper"] }, "fontsettings": { "theme": "white", "family": "sans", "size": 2 }, "edit": { "link": "https://github.com/statsthinking21/statsthinking21-core/edit/master/99-References.Rmd", "text": "Edit" }, "history": { "link": null, "text": null }, "view": { "link": null, "text": null }, "download": ["StatsThinking21.pdf", "StatsThinking21.epub"], "search": { "engine": "fuse", "options": null }, "toc": { "collapse": "subsection" } }); }); ``` -------------------------------- ### Google Analytics Initialization JavaScript Source: https://github.com/statsthinking21/statsthinking21-core/blob/master/_book/index.html Sets up Google Analytics tracking using gtag for the book website. Initializes dataLayer and configures the tracker with UA-129414074-1. No inputs required; outputs event tracking to Google Analytics. ```javascript window.dataLayer = window.dataLayer || []; function gtag(){dataLayer.push(arguments);} gtag('js', new Date()); gtag('config', 'UA-129414074-1'); ``` -------------------------------- ### Initialize GitBook Settings in JavaScript Source: https://github.com/statsthinking21/statsthinking21-core/blob/master/_book/the-general-linear-model.html This code configures the GitBook environment with options for sharing, font settings, editing, navigation, and search functionality. It requires the GitBook library to be loaded via its require function. Inputs are configuration objects specifying enabled features and links, with no direct outputs but modifies the GitBook instance. Limitations include hardcoded values that may not adapt to dynamic content and reliance on the GitBook plugin ecosystem. ```javascript gitbook.require(["gitbook"], function(gitbook) { gitbook.start({ "sharing": { "github": false, "facebook": true, "twitter": true, "linkedin": false, "weibo": false, "instapaper": false, "vk": false, "whatsapp": false, "all": ["facebook", "twitter", "linkedin", "weibo", "instapaper"] }, "fontsettings": { "theme": "white", "family": "sans", "size": 2 }, "edit": { "link": "https://github.com/statsthinking21/statsthinking21-core/edit/master/14-GeneralLinearModel.Rmd", "text": "Edit" }, "history": { "link": null, "text": null }, "view": { "link": null, "text": null }, "download": ["StatsThinking21.pdf", "StatsThinking21.epub"], "search": { "engine": "fuse", "options": null }, "toc": { "collapse": "subsection" } }); }); ```