### Install and Load the easystats/report R Package Source: https://easystats.github.io/see/report/articles/report Instructions for installing the `report` package from GitHub using `remotes` and then loading it into your R session. This setup is required before using any `report` package functions. ```R install.packages("remotes") remotes::install_github("easystats/report") # You only need to do that once ``` ```R library("report") # Load the package every time you start R ``` -------------------------------- ### R Examples for `install_latest` Function Usage Source: https://easystats.github.io/see/easystats/reference/install_latest Illustrates how to use the `install_latest` function to install easystats packages, including installing only newer versions and forcing installation of all packages. ```R if (FALSE) { # install latest development-version of easystats packages from # the r-universe repository, but only those packages that have newer # versions available install_latest() # install all latest development-version of easystats packages from # the r-universe repository, no matter whether local installations # are up to date or not. install_latest(force = TRUE) } ``` -------------------------------- ### Practical Examples for easystats Suggested Package Installation and Listing in R Source: https://easystats.github.io/see/easystats/reference/install_suggested This example demonstrates how to use `install_suggested` to download all necessary 'soft dependencies' for the `easystats` ecosystem and how `show_reverse_dependencies` can be used to list all packages that depend on `easystats` components. The `if (FALSE)` block indicates code that might not be run directly but shows the intended usage. ```R # download all suggested packages if (FALSE) { install_suggested("easystats") } # listing all reverse dependencies of easystats packages show_reverse_dependencies() #> bayestestR #> ---------- #> BaHZING, bayesMeanScale, brmsmargins, clinicalsignificance, correlation, #> easystats, eDNAjoint, effectsize, fbst, modelbased, multifear, #> multilevelcoda, neatStats, parameters, pcvr, performance, psycho, #> report, rstanbdp, see, sjPlot, snSMART, SSVS, statsExpressions, #> survregVB #> #> correlation #> ----------- #> easystats, ggstatsplot, multitool, popstudy, see, statsExpressions, #> TangledFeatures #> #> datawizard #> ---------- #> bayestestR, correlation, easystats, effectsize, ggeffects, ggstatsplot, #> modelbased, parameters, performance, report, see, sjlabelled, sjmisc, #> sjPlot, sjstats, statsExpressions #> #> effectsize #> ---------- #> bruceR, easystats, multifear, psycho, report, see, sjstats, statdecideR, #> statsExpressions, visvow, volker #> #> insight #> ------- #> aggreCAT, ale, bayestestR, bsitar, clarify, clinicalsignificance, #> correlation, cv, datawizard, DImodelsVis, easystats, EcoMetrics, #> effects, effectsize, ggDoE, ggeffects, ggstatsplot, insurancerating, #> lavaanExtra, marginaleffects, modelbased, modelsummary, MuMIn, mvgam, #> ordbetareg, parameters, performance, pminternal, psycho, psycModel, #> randomizeR, regressinator, report, see, SimplyAgree, sjlabelled, sjmisc, #> sjPlot, sjstats, statsExpressions, tidygam, tinyVAST #> #> modelbased #> ---------- #> easystats, see #> #> parameters #> ---------- #> clintools, correlation, cvms, dotwhisker, easystats, effectsize, #> ggstatsplot, glmglrt, MCM, modelbased, modelsummary, multitool, peramo, #> psycho, psycModel, regport, report, see, sjPlot, sjstats, #> statsExpressions, StroupGLMM #> #> performance #> ----------- #> bruceR, CR2, dotwhisker, easystats, effectsize, ggstatsplot, MDMA, #> MLMusingR, modelsummary, multitool, piecewiseSEM, PLSDAbatch, psycModel, #> pubh, report, SCDA, see, sjPlot, sjstats, statsExpressions, #> steppedwedge, SynergyLMM, ZLAvian #> #> report #> ------ #> easystats, SqueakR #> #> see #> --- #> easystats, jsmodule #> ``` -------------------------------- ### R Examples: Using check_if_installed for Package Verification Source: https://easystats.github.io/see/insight/reference/check_if_installed Illustrates practical applications of the `check_if_installed` function in R. Examples cover checking for single and multiple package installations, handling cases with non-existent packages, specifying minimum version requirements, and demonstrating both successful checks and scenarios that trigger warnings or errors. ```R # \donttest{ check_if_installed("insight") try(check_if_installed("datawizard", stop = FALSE)) try(check_if_installed("rstanarm", stop = FALSE)) try(check_if_installed("nonexistent_package", stop = FALSE)) #> Warning: Package `nonexistent_package` required for this function to work. #> Please install it by running `install.packages("nonexistent_package")`. try(check_if_installed("insight", minimum_version = "99.8.7")) #> Error : Package `insight` is installed, but package version `99.8.7` is #> required. #> Please update it by running `install.packages("insight")`. try(check_if_installed(c("nonexistent", "also_not_here"), stop = FALSE)) #> Warning: Packages `nonexistent` and `also_not_here` required for this function to #> work. #> Please install them by running `install.packages("nonexistent", #> "also_not_here")`. try(check_if_installed(c("datawizard", "rstanarm"), stop = FALSE)) try(check_if_installed(c("datawizard", "rstanarm"), minimum_version = c(NA, "2.21.1"), stop = FALSE )) # } ``` -------------------------------- ### R: Example of sensitivity_to_prior with rstanarm models Source: https://easystats.github.io/see/bayestestR/reference/sensitivity_to_prior Provides an initial R code example demonstrating the setup for using `sensitivity_to_prior` with `rstanarm` models, including loading the `bayestestR` library. The example is marked with `\donttest{}`. ```R # \donttest{ library(bayestestR) # rstanarm models ``` -------------------------------- ### R Example: Plotting Compared Model Performances Source: https://easystats.github.io/see/see/reference/plot.see_compare_performance This comprehensive R example demonstrates how to compare multiple linear models using `performance::compare_performance` and then visualize the comparison results using the `plot` method from the `see` package. It includes model setup, performance comparison, and the final plotting call with example output. ```R library(performance) data(iris) lm1 <- lm(Sepal.Length ~ Species, data = iris) lm2 <- lm(Sepal.Length ~ Species + Petal.Length, data = iris) lm3 <- lm(Sepal.Length ~ Species * Petal.Length, data = iris) result <- compare_performance(lm1, lm2, lm3) result #> # Comparison of Model Performance Indices #> #> Name | Model | AIC (weights) | AICc (weights) | BIC (weights) | R2 #> --------------------------------------------------------------------- #> lm1 | lm | 231.5 (<.001) | 231.7 (<.001) | 243.5 (<.001) | 0.619 #> lm2 | lm | 106.2 (0.566) | 106.6 (0.611) | 121.3 (0.964) | 0.837 #> lm3 | lm | 106.8 (0.434) | 107.6 (0.389) | 127.8 (0.036) | 0.840 #> #> Name | R2 (adj.) | RMSE | Sigma #> -------------------------------- #> lm1 | 0.614 | 0.510 | 0.515 #> lm2 | 0.833 | 0.333 | 0.338 #> lm3 | 0.835 | 0.330 | 0.336 plot(result) ``` -------------------------------- ### Example Usage of describe_prior with rstanarm models Source: https://easystats.github.io/see/bayestestR/reference/describe_prior Demonstrates an initial setup for using the `describe_prior` function, specifically mentioning its application with `rstanarm` models. ```R # \donttest{ library(bayestestR) # rstanarm models ``` -------------------------------- ### Example Datasets Source: https://easystats.github.io/see/insight/reference/index Datasets used in examples or for testing. ```APIDOC efc_insight: Sample dataset from the EFC Survey fish: Sample data set for count models ``` -------------------------------- ### APIDOC: Example Data Sets Source: https://easystats.github.io/see/parameters/reference/index Provides access to sample data sets for demonstration and testing purposes. ```APIDOC qol_cancer: Sample data set ``` ```APIDOC fish: Sample data set ``` -------------------------------- ### API Documentation for easystats Dependency Management Functions Source: https://easystats.github.io/see/easystats/reference/install_suggested This section details the arguments and return values for the `install_suggested`, `show_suggested`, and `show_reverse_dependencies` functions. It explains the `package` parameter's role in specifying which easystats packages to target for dependency installation or listing, and clarifies that the functions are primarily used for their side effects. ```APIDOC install_suggested(package = "easystats") show_suggested(package = "easystats") show_reverse_dependencies(package = "easystats") Arguments: package: Type: string | NULL Description: If NULL or "easystats" (the default), all suggested packages for all 'easystats' packages will be installed. If specific packages are specified, only suggested packages for those packages will be installed. Value: Description: Useful only for its side-effect of installing the needed packages. ``` -------------------------------- ### easystats Package Installation and Update Functions Source: https://easystats.github.io/see/easystats/reference/index This section details functions for managing the installation, updates, and dependencies of the easystats R package suite. Functions allow installation from R-universe/GitHub or CRAN, listing all packages, and updating existing installations. ```APIDOC easystats_packages(): List all packages in the easystats ecosystem ``` ```APIDOC install_latest(): Install the easystats suite from R-universe (GitHub) or CRAN ``` ```APIDOC install_suggested(), show_suggested(), show_reverse_dependencies(): Download all suggested packages ``` ```APIDOC easystats_update(): Update easystats-packages and its dependencies from CRAN, if necessary. ``` -------------------------------- ### Install easystats and bayestestR from GitHub Source: https://easystats.github.io/see/bayestestR/articles/bayestestR Instructions to install the entire easystats suite, which includes bayestestR, directly from GitHub using the 'remotes' package. This ensures access to the latest development versions of the packages. ```R install.packages("remotes") remotes::install_github("easystats/easystats") ``` -------------------------------- ### Example of clm2_1 Model Creation in R Source: https://easystats.github.io/see/circus/reference/clm2_1 Provides an example of how the `clm2_1` model might be created using the `clm2` function with `rating`, `temp`, and `contact` variables from the `wine` dataset. The example is commented out, suggesting it's for illustrative purposes or requires specific setup. ```R if (FALSE) { clm2_1 <- clm2(rating ~ temp * contact, data = wine) } ``` -------------------------------- ### R Function Signature for easystats Installation Source: https://easystats.github.io/see/easystats/reference/install_latest Defines the `install_latest` function signature, showing its parameters and default values for installing easystats packages. ```R install_latest( source = "development", packages = "all", force = FALSE, verbose = TRUE ) ``` -------------------------------- ### R Example: Get Dispersion from GLM using `get_auxiliary` Source: https://easystats.github.io/see/insight/reference/get_auxiliary This R code example demonstrates how to calculate the dispersion parameter from a Generalized Linear Model (GLM) using the `get_auxiliary` function. It initializes a sample dataset, fits a Gamma GLM, and then retrieves the dispersion value, showing it matches the `summary(model)$dispersion` output. ```R # from ?glm clotting <- data.frame( u = c(5, 10, 15, 20, 30, 40, 60, 80, 100), lot1 = c(118, 58, 42, 35, 27, 25, 21, 19, 18), lot2 = c(69, 35, 26, 21, 18, 16, 13, 12, 12) ) model <- glm(lot1 ~ log(u), data = clotting, family = Gamma()) get_auxiliary(model, type = "dispersion") # same as summary(model)$dispersion #> [1] 0.002446059 ``` -------------------------------- ### APIDOC: `install_latest` Function Parameters and Return Value Source: https://easystats.github.io/see/easystats/reference/install_latest Detailed documentation for the parameters of the `install_latest` function, including their types, possible values, and descriptions, along with the function's return value. ```APIDOC Function: install_latest Parameters: source: Type: Character Description: Either "development", "cran" or "github". If "cran", packages will be installed from the default CRAN mirror returned by getOption("repos")['CRAN']. If "development" (the default), packages are installed from the R-universe repository (). "github" installs the latest version from the GitHub-repositories main-branch. However, this option is usually not needed, because R-universe provides latest binaries. Use the "github" option only when R-universe servers are unavailable. packages: Type: Character vector Description: Indicating which packages to be installed. By default, the option "all" will install all easystats packages. force: Type: Logical Description: If FALSE, only those packages with a newer version number will be installed. Use TRUE to force installation of all packages, even if the version number for the locally installed packages is identical to the latest development-versions. Only applies when source="development". verbose: Type: Logical Description: Toggle messages. Return Value: Type: Invisible NULL Description: The function invisibly returns NULL. ``` -------------------------------- ### Install and Load rstanarm and bayestestR Source: https://easystats.github.io/see/bayestestR/articles/bayestestR This snippet provides the necessary R commands to install the 'rstanarm' package, which is used for fitting Bayesian models, and then load both 'rstanarm' and 'bayestestR' into the R session for use in statistical analysis. ```R install.packages("rstanarm") library(rstanarm) ``` -------------------------------- ### Install and Load circus R Package Source: https://easystats.github.io/see/circus/index Instructions to install the `circus` package from GitHub using `remotes` and then load it into an R session. This is the standard way to get the package ready for use. ```R install.packages("remotes") remotes::install_github("easystats/circus") library("circus") ``` -------------------------------- ### Examples for updating easystats packages in R Source: https://easystats.github.io/see/easystats/reference/easystats_update These examples demonstrate how to use `easystats_update` to check and install updates for all easystats packages and their dependencies, as well as how to update only the core easystats packages. ```R if (FALSE) { # check which local easystats-packages (and their dependencies) # are out of date and install updates from CRAN easystats_update() # update only easystats core-packages easystats_update("core") } ``` -------------------------------- ### Install easystats R Package Source: https://easystats.github.io/see/easystats/index Instructions for installing the easystats R package from CRAN, r-universe, or GitHub, including a command to install all suggested dependencies for a full experience. ```R install.packages("easystats") ``` ```R install.packages("easystats", repos = "https://easystats.r-universe.dev") ``` ```R remotes::install_github("easystats/easystats") ``` ```R easystats::install_suggested() ``` -------------------------------- ### Install 'parameters' R package from CRAN Source: https://easystats.github.io/see/parameters Installs the stable release version of the 'parameters' package from the Comprehensive R Archive Network (CRAN). This is the standard and recommended method for most users to get the latest stable version. ```R install.packages("parameters") ``` -------------------------------- ### Install and Load R `insight` Package Source: https://easystats.github.io/see/blog/posts/insight_presentation Demonstrates how to install the `insight` package from CRAN and load it into an R session, making its functions available for use. ```R install.packages("insight") library(insight) ``` -------------------------------- ### R n_obs Function Usage Examples Source: https://easystats.github.io/see/insight/reference/n_obs Provides practical examples of using `n_obs` with `lm` and `glm` models in R, demonstrating how to retrieve the number of observations and how to use the `disaggregate` option for binomial models. ```R data(mtcars) m <- lm(mpg ~ wt + cyl + vs, data = mtcars) n_obs(m) #> [1] 32 data(cbpp, package = "lme4") m <- glm( cbind(incidence, size - incidence) ~ period, data = cbpp, family = binomial(link = "logit") ) n_obs(m) #> [1] 56 n_obs(m, disaggregate = TRUE) #> [1] 842 ``` -------------------------------- ### Initializing Mixed Models with lme4 in R Source: https://easystats.github.io/see/parameters/index This R code snippet shows the initial setup for analyzing mixed models using the `lme4` package. It demonstrates loading the `lme4` library and defining a linear mixed-effects model using `lmer`. ```R library(lme4) model <- lmer(Sepal.Width ~ Petal.Length + (1 | Species), data = iris) ``` -------------------------------- ### Install stable 'effectsize' R package from CRAN Source: https://easystats.github.io/see/effectsize Installs the stable release version of the 'effectsize' package directly from CRAN, the Comprehensive R Archive Network. This is the recommended method for most users to get the latest stable features. ```R install.packages("effectsize") ``` -------------------------------- ### Install and Load bayestestR Package in R Source: https://easystats.github.io/see/blog/posts/bayestestr_presentation This R code demonstrates the standard procedure for installing the bayestestR package from CRAN and subsequently loading it into the R environment, making its functions available for use. ```R install.packages("bayestestR") # Install the package library(bayestestR) # Load it ``` -------------------------------- ### Install effectsize R Package from CRAN Source: https://easystats.github.io/see/effectsize/index This R code snippet installs the stable release of the `effectsize` package from CRAN, the official R package repository. This is the recommended method for most users to get the latest stable version. ```R install.packages("effectsize") ``` -------------------------------- ### Load R Libraries and Sample Data for datawizard Source: https://easystats.github.io/see/datawizard/articles/tidyverse_translation This R snippet loads the necessary packages ('dplyr', 'tidyr', 'datawizard') and a sample dataset ('efc'). It then reduces the dataset to its first few rows, preparing the environment for subsequent data wrangling demonstrations and comparisons. ```R library(dplyr) library(tidyr) library(datawizard) data(efc) efc <- head(efc) ``` -------------------------------- ### R: Example of LOO-adjusted R2 calculation with rstanarm Source: https://easystats.github.io/see/performance/reference/r2_loo This example demonstrates how to compute the LOO-adjusted R2 for a `stan_glm` model from the `rstanarm` package, showing the model setup, the call to `r2_loo`, and the resulting output including the conditional R2 and its confidence interval. ```R model <- suppressWarnings(rstanarm::stan_glm( mpg ~ wt + cyl, data = mtcars, chains = 1, iter = 500, refresh = 0, show_messages = FALSE )) r2_loo(model) #> Warning: Some Pareto k diagnostic values are too high. See help('pareto-k-diagnostic') for details. #> # LOO-adjusted R2 with Compatibility Interval #> #> Conditional R2: 0.786 (95% CI [0.684, 0.880]) ``` -------------------------------- ### Initialize Model for Contrast Analysis in R Source: https://easystats.github.io/see/modelbased/index Sets up a linear model in R using `lm()` for subsequent contrast analysis with the 'modelbased' package. This model will be used to estimate differences between factor levels. ```R # 1. The model model <- lm(Sepal.Width ~ Species, data = iris) ``` -------------------------------- ### R: Example of `r2_efron` with Poisson GLM Source: https://easystats.github.io/see/performance/reference/r2_efron Provides a practical R example demonstrating the application of `r2_efron` to a generalized linear model (GLM) with a Poisson family, including data setup, model fitting, and the function call with its output. ```R ## Dobson (1990) Page 93: Randomized Controlled Trial: counts <- c(18, 17, 15, 20, 10, 20, 25, 13, 12) # outcome <- gl(3, 1, 9) treatment <- gl(3, 3) model <- glm(counts ~ outcome + treatment, family = poisson()) r2_efron(model) #> [1] 0.5265152 ``` -------------------------------- ### Create a Simple Linear Regression Model in R Source: https://easystats.github.io/see/blog/posts/insight_presentation Illustrates how to create a basic linear regression model using the `lm` function with the `iris` dataset. This model serves as an example for subsequent `insight` package demonstrations. ```R model <- lm(Sepal.Length ~ Species, data=iris) ``` -------------------------------- ### R: Examples for model_name function usage Source: https://easystats.github.io/see/insight/reference/model_name These examples demonstrate the practical application of the `model_name` function with various model types, including `lm` and `lmer`. They show how to retrieve the basic model name and how to use `include_formula` and `include_call` to get more detailed naming conventions. ```R m <- lm(Sepal.Length ~ Petal.Width, data = iris) model_name(m) #> [1] "lm" model_name(m, include_formula = TRUE) #> [1] "lm(Sepal.Length ~ Petal.Width)" model_name(m, include_call = TRUE) #> [1] "lm(formula = Sepal.Length ~ Petal.Width, data = iris)" model_name(lme4::lmer(Sepal.Length ~ Sepal.Width + (1 | Species), data = iris)) #> [1] "lmerMod" ``` -------------------------------- ### Install and Load the performance R Package Source: https://easystats.github.io/see/blog/posts/performance_presentation Instructions to install the `performance` package from CRAN and load it into the R session for use in statistical modeling. ```R install.packages("performance") library(performance) ``` -------------------------------- ### R: Example Usage of get_sigma with Linear Model Source: https://easystats.github.io/see/insight/reference/get_sigma This R code example demonstrates how to apply the `get_sigma` function to a linear model (`lm`) fitted using the `mtcars` dataset, showing the extracted residual standard deviation and its attributes. ```R data(mtcars) m <- lm(mpg ~ wt + cyl + vs, data = mtcars) get_sigma(m) #> [1] 2.608133 #> attr(,"class") #> [1] "insight_aux" "numeric" ``` -------------------------------- ### Load Example Datasets from effectsize Package in R Source: https://easystats.github.io/see/effectsize/news/index Illustrates the R command to list and load datasets that are included within the `effectsize` R package. These datasets are primarily used in the package's examples and vignettes for demonstration purposes. ```R data(package = "effectsize") ``` -------------------------------- ### Practical Examples of Interpreting Cohen's d in R Source: https://easystats.github.io/see/effectsize/reference/interpret_cohens_d Provides executable R code examples demonstrating how to use `interpret_cohens_d` with single and multiple effect size values, and how to apply specific rule sets like 'lovakov2021' to get different interpretations. ```R interpret_cohens_d(.02) #> [1] "very small" #> (Rules: cohen1988) #> interpret_cohens_d(c(.5, .02)) #> [1] "medium" "very small" #> (Rules: cohen1988) #> interpret_cohens_d(.3, rules = "lovakov2021") #> [1] "small" #> (Rules: lovakov2021) #> ``` -------------------------------- ### Install the performance R package Source: https://easystats.github.io/see/performance Instructions for installing the `performance` R package. Users can choose between the stable release from CRAN or the latest development version from the R-universe repository. ```R install.packages("performance") ``` ```R install.packages("performance", repos = "https://easystats.r-universe.dev") ``` -------------------------------- ### R: Example of displaying model performance with display() Source: https://easystats.github.io/see/performance/reference/display.performance_model This example demonstrates how to use the `display()` function from the `performance` package to format and print the performance metrics of a linear model. It shows the R code to create a model, calculate its performance, and then display it in a markdown-like table format. ```R model <- lm(mpg ~ wt + cyl, data = mtcars) mp <- model_performance(model) display(mp) #> #> #> |AIC | AICc | BIC | R2 | R2 (adj.) | RMSE | Sigma | #> |:------|:------:|:------:|:----:|:---------:|:----:|:-----:| #> |156.01 | 157.49 | 161.87 | 0.83 | 0.82 | 2.44 | 2.57 | ``` -------------------------------- ### Get Weights from Quasibinomial GLM in R Source: https://easystats.github.io/see/insight/reference/get_weights Demonstrates how to fit a Generalized Linear Model (GLM) with a quasibinomial family and then extract the observation-level weights using the `get_weights` function. The example uses the `mtcars` dataset to model `vs` based on `disp` and `mpg`. ```R m <- glm(vs ~ disp + mpg, data = mtcars, weights = weight, family = quasibinomial) get_weights(m) ``` -------------------------------- ### R Usage Example for Dominance Analysis Source: https://easystats.github.io/see/parameters/reference/dominance_analysis Illustrates the basic syntax for calling the `dominance_analysis` function in R, showing all available parameters and their default values for computing dominance analysis statistics. ```R dominance_analysis( model, sets = NULL, all = NULL, conditional = TRUE, complete = TRUE, quote_args = NULL, contrasts = model$contrasts, ... ) ``` -------------------------------- ### Example Usage of golden_ratio function in R Source: https://easystats.github.io/see/see/reference/golden_ratio Demonstrates how to use the `golden_ratio` function in R to get the golden ratio itself or a value scaled by it. ```R golden_ratio() #> [1] 1.618034 golden_ratio(10) #> [1] 16.18034 ``` -------------------------------- ### install_suggested (easystats) API Reference Source: https://easystats.github.io/see/easystats/articles/list_of_functions API documentation for the `install_suggested` function, part of the `easystats` R package. It provides a link to its detailed documentation. ```APIDOC Function: install_suggested Package: easystats Documentation: https://easystats.github.io/easystats/reference/install_suggested.html ``` -------------------------------- ### Example of get_weights with LM models in R Source: https://easystats.github.io/see/insight/reference/get_weights This R code demonstrates how to use the `get_weights` function to extract weighting variables from `lm` models. It shows an example with explicitly specified weights and another where `null_as_ones` is used to return a vector of ones when no weights are present. ```R data(mtcars) set.seed(123) mtcars$weight <- rnorm(nrow(mtcars), 1, .3) # LMs m <- lm(mpg ~ wt + cyl + vs, data = mtcars, weights = weight) get_weights(m) #> [1] 0.8318573 0.9309468 1.4676125 1.0211525 1.0387863 1.5145195 1.1382749 #> [8] 0.6204816 0.7939441 0.8663014 1.3672245 1.1079441 1.1202314 1.0332048 #> [15] 0.8332477 1.5360739 1.1493551 0.4100149 1.2104068 0.8581626 0.6796529 #> [22] 0.9346075 0.6921987 0.7813326 0.8124882 0.4939920 1.2513361 1.0460119 #> [29] 0.6585589 1.3761445 1.1279393 0.9114786 get_weights(lm(mpg ~ wt, data = mtcars), null_as_ones = TRUE) #> [1] 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 ``` -------------------------------- ### Get Weights from Binomial GLM with Cbind Response in R Source: https://easystats.github.io/see/insight/reference/get_weights Illustrates fitting a Generalized Linear Model (GLM) with a binomial family and a `cbind` response, then retrieving the observation-level weights using `get_weights`. This example models `cyl` and `gear` based on `mpg` from the `mtcars` dataset. ```R m <- glm(cbind(cyl, gear) ~ mpg, data = mtcars, weights = weight, family = binomial) get_weights(m) ``` -------------------------------- ### API Documentation for simulate_parameters Function Source: https://easystats.github.io/see/parameters/reference/simulate_parameters Comprehensive API documentation for the `simulate_parameters` function, detailing its parameters, return values, technical implementation, and specific considerations for models with zero-inflation components. ```APIDOC Function: simulate_parameters Description: Compute simulated draws of parameters and their related indices such as Confidence Intervals (CI) and p-values. Simulating parameter draws can be seen as a (computationally faster) alternative to bootstrapping. Usage: simulate_parameters(model, ...) simulate_parameters(model, iterations = 1000, centrality = "median", ci = 0.95, ci_method = "quantile", test = "p-value", ...) Arguments: model (Statistical model): No Bayesian models. ... (Any): Arguments passed to insight::get_varcov(), e.g. to allow simulated draws to be based on heteroscedasticity consistent variance covariance matrices. iterations (numeric, default: 1000): The number of draws to simulate/bootstrap. centrality (character/list, default: "median"): The point-estimates (centrality indices) to compute. Options: "median", "mean", "MAP" (see map_estimate()), "trimmed" (mean(x, trim = threshold)), "mode", "all". ci (numeric, default: 0.95): Value or vector of probability of the CI (between 0 and 1) to be estimated. ci_method (character, default: "quantile"): The type of index used for Credible Interval. Options: "ETI" (default, see eti()), "HDI" (see hdi()), "BCI" (see bci()), "SPI" (see spi()), or "SI" (see si()). test (character/list, default: "p-value"): The indices of effect existence to compute. Options: "p_direction" ("pd"), "rope", "p_map", "p_significance" ("ps"), "p_rope", "equivalence_test" ("equitest"), "bayesfactor" ("bf"), "all". Calls corresponding bayestestR function. Returns: (data.frame): A data frame with simulated parameters. Details: Technical Details: - simulate_parameters() is a computationally faster alternative to bootstrap_parameters(). - Simulated draws for coefficients are based on a multivariate normal distribution (MASS::mvrnorm()) with mean mu = coef(model) and variance Sigma = vcov(model). Models with Zero-Inflation Component: - For models from packages glmmTMB, pscl, GLMMadaptive and countreg, the component argument can be used to specify which parameters should be simulated. - For all other models, parameters from the conditional component (fixed effects) are simulated. This may include smooth terms, but not random effects. ``` -------------------------------- ### R link_function Example with GLM Source: https://easystats.github.io/see/insight/reference/link_function This example demonstrates the use of `link_function` with a `glm` model (Poisson family) in R. It shows how to retrieve the link function from the fitted model and apply it to a value, verifying the result against a direct `log` transformation, which is the link function for Poisson models. ```R # example from ?stats::glm counts <- c(18, 17, 15, 20, 10, 20, 25, 13, 12) outcome <- gl(3, 1, 9) treatment <- gl(3, 3) m <- glm(counts ~ outcome + treatment, family = poisson()) link_function(m)(0.3) #> [1] -1.203973 # same as log(0.3) #> [1] -1.203973 ``` -------------------------------- ### Parameter and Model Sampling Techniques Source: https://easystats.github.io/see/parameters/reference/index Functions for bootstrapping and simulating parameters or entire models to understand variability and uncertainty in statistical estimates. ```APIDOC Function: bootstrap_model() Description: Model bootstrapping ``` ```APIDOC Function: bootstrap_parameters() Description: Parameters bootstrapping ``` ```APIDOC Function: simulate_model() Description: Simulated draws from model coefficients ``` ```APIDOC Function: simulate_parameters() Description: Simulate Model Parameters ``` -------------------------------- ### R link_inverse Function Example with GLM Source: https://easystats.github.io/see/insight/reference/link_inverse Demonstrates the practical application of the `link_inverse` function using a `glm` model with a Poisson family. The example illustrates how to obtain the inverse-link transformation of a value and confirms its equivalence to directly applying the `exp()` function, which is the inverse link for a Poisson regression. ```R # example from ?stats::glm counts <- c(18, 17, 15, 20, 10, 20, 25, 13, 12) outcome <- gl(3, 1, 9) treatment <- gl(3, 3) m <- glm(counts ~ outcome + treatment, family = poisson()) link_inverse(m)(0.3) #> [1] 1.349859 # same as exp(0.3) #> [1] 1.349859 ``` -------------------------------- ### Combine Table Formatting and Exporting (R) Source: https://easystats.github.io/see/insight/articles/display This example shows how to chain `format_table()` and `export_table()` to first format a table (e.g., using symbols for column names) and then export the result. This creates a nicely formatted output ready for display or further use. ```R export_table(format_table(x, use_symbols = TRUE)) ``` -------------------------------- ### Install easystats R Package Source: https://easystats.github.io/see/easystats This snippet provides commands to install the easystats R package from different sources: CRAN for stable releases, r-universe for development versions, and GitHub for the latest development builds. Choose the appropriate command based on your installation preference. ```R install.packages("easystats") ``` ```R install.packages("easystats", repos = "https://easystats.r-universe.dev") ``` ```R remotes::install_github("easystats/easystats") ``` -------------------------------- ### R Example: Extracting Response from Linear Model Source: https://easystats.github.io/see/insight/reference/get_response Illustrates the use of `get_response` with a standard linear model (`lm`) to retrieve the response variable values. ```R data(mtcars) m <- lm(mpg ~ wt + cyl + vs, data = mtcars) get_response(m) ``` -------------------------------- ### install_latest (easystats) API Reference Source: https://easystats.github.io/see/easystats/articles/list_of_functions API documentation for the `install_latest` function, part of the `easystats` R package. It provides a link to its detailed documentation. ```APIDOC Function: install_latest Package: easystats Documentation: https://easystats.github.io/easystats/reference/install_latest.html ``` -------------------------------- ### Extract parameters from R t-test object using `get_parameters` Source: https://easystats.github.io/see/insight/reference/get_parameters.htest Example demonstrating the usage of the `get_parameters` function to extract estimated parameters from the result of an R `t.test`. ```R get_parameters(t.test(1:10, y = c(7:20))) ``` -------------------------------- ### Example: Extracting random effects data from an lmer model in R Source: https://easystats.github.io/see/insight/reference/get_random This example demonstrates how to use the `get_random` function with a linear mixed-effects model (`lmer`) from the `lme4` package. It includes data preparation, fitting a model with nested random effects, and then using `get_random` to retrieve and display the first few rows of the extracted random effects data. ```R data(sleepstudy) # prepare some data... sleepstudy$mygrp <- sample(1:5, size = 180, replace = TRUE) sleepstudy$mysubgrp <- NA for (i in 1:5) { filter_group <- sleepstudy$mygrp == i sleepstudy$mysubgrp[filter_group] <- sample(1:30, size = sum(filter_group), replace = TRUE) } m <- lmer( Reaction ~ Days + (1 | mygrp / mysubgrp) + (1 | Subject), data = sleepstudy ) #> boundary (singular) fit: see help('isSingular') head(get_random(m)) ``` -------------------------------- ### Install 'see' R Package Source: https://easystats.github.io/see/see Instructions for installing the 'see' package in R from different sources: CRAN (stable release), r-universe (latest development), and GitHub (development version via 'remotes'). ```R install.packages("see") ``` ```R install.packages("see", repos = "https://easystats.r-universe.dev") ``` ```R remotes::install_github("easystats/see") ``` -------------------------------- ### R Examples for get_intercept Function Source: https://easystats.github.io/see/insight/reference/get_intercept Demonstrates how to use the `get_intercept` function with various R model types, including `lm`, `lmer`, and `gamm4`, showing cases with and without an intercept. ```R get_intercept(lm(Sepal.Length ~ Petal.Width, data = iris)) #> [1] 4.777629 get_intercept(lm(Sepal.Length ~ 0 + Petal.Width, data = iris)) #> [1] NA get_intercept(lme4::lmer(Sepal.Length ~ Sepal.Width + (1 | Species), data = iris)) #> [1] 3.406167 get_intercept(gamm4::gamm4(Sepal.Length ~ s(Petal.Width), data = iris)) #> [1] 5.843333 ``` -------------------------------- ### Example Usage of get_call in R Source: https://easystats.github.io/see/insight/reference/get_call Demonstrates how to use the `get_call` function with `lm` and `lmer` models in R, showing the extracted function calls from fitted models. ```R data(mtcars) m <- lm(mpg ~ wt + cyl + vs, data = mtcars) get_call(m) #> lm(formula = mpg ~ wt + cyl + vs, data = mtcars) m <- lme4::lmer(Sepal.Length ~ Sepal.Width + (1 | Species), data = iris) get_call(m) #> lme4::lmer(formula = Sepal.Length ~ Sepal.Width + (1 | Species), #> data = iris) ``` -------------------------------- ### Install and Load R Package Source: https://easystats.github.io/see/blog This R code snippet demonstrates how to install a new package from CRAN and then load it into the R session for use. This is a common first step when using new R packages to make their functions available. ```R install.packages("correlation") library(correlation) ``` -------------------------------- ### R Example: Calculating Component Sum Scores from PCA Source: https://easystats.github.io/see/parameters/reference/get_scores Illustrates the practical application of `get_scores()` in R. The example first performs a Principal Component Analysis using `principal_components()` on the `mtcars` dataset, then uses `closest_component()` to assign items, and finally applies `get_scores()` to derive and display the average sum scores for the extracted components. ```R pca <- principal_components(mtcars[, 1:7], n = 2, rotation = "varimax") # PCA extracted two components pca #> # Rotated loadings from Principal Component Analysis (varimax-rotation) #> #> Variable | RC1 | RC2 | Complexity | Uniqueness | MSA #> --------------------------------------------------------- #> mpg | -0.84 | -0.42 | 1.47 | 0.13 | 0.87 #> cyl | 0.77 | 0.58 | 1.86 | 0.08 | 0.87 #> disp | 0.85 | 0.43 | 1.48 | 0.08 | 0.85 #> hp | 0.55 | 0.77 | 1.81 | 0.10 | 0.90 #> drat | -0.89 | 0.01 | 1.00 | 0.21 | 0.85 #> wt | 0.93 | 0.17 | 1.07 | 0.10 | 0.77 #> qsec | -0.03 | -0.97 | 1.00 | 0.06 | 0.61 #> #> The 2 principal components (varimax rotation) accounted for 89.18% of the total variance of the original data (RC1 = 56.82%, RC2 = 32.36%). #> # assignment of items to each component closest_component(pca) #> mpg cyl disp hp drat wt qsec #> 1 1 1 2 1 1 2 # now we want to have sum scores for each component get_scores(pca) #> Component_1 Component_2 #> Mazda RX4 38.7040 63.230 #> Mazda RX4 Wag 38.7550 63.510 #> Datsun 710 28.1940 55.805 #> Hornet 4 Drive 58.3390 64.720 #> Hornet Sportabout 78.6580 96.010 #> Valiant 51.0640 62.610 #> Duster 360 77.8160 130.420 #> Merc 240D 36.3960 41.000 #> Merc 230 34.9340 58.950 #> Merc 280 40.0320 70.650 #> Merc 280C 39.7520 70.950 #> Merc 450SE 61.4680 98.700 #> Merc 450SL 61.5800 98.800 #> Merc 450SLC 61.1700 99.000 #> Cadillac Fleetwood 99.7160 111.490 #> Lincoln Continental 97.3648 116.410 #> Chrysler Imperial 94.2550 123.710 #> Fiat 128 24.2760 42.735 #> Honda Civic 23.3290 35.260 #> Toyota Corolla 23.0110 42.450 #> Toyota Corona 30.3530 58.505 #> Dodge Challenger 69.5560 83.435 #> AMC Javelin 66.7570 83.650 #> Camaro Z28 75.7740 130.205 #> Pontiac Firebird 86.8250 96.025 #> Fiat X1-9 23.2630 42.450 #> Porsche 914-2 31.3740 53.850 #> Lotus Europa 26.9566 64.950 #> Ford Pantera L 76.4380 139.250 #> Ferrari Dino 35.4180 95.250 #> Maserati Bora 66.2220 174.800 #> Volvo 142E 30.6580 63.800 ``` -------------------------------- ### Install 'see' R Package from CRAN, R-universe, or GitHub Source: https://easystats.github.io/see/see/index Instructions for installing the 'see' package in R from various sources: CRAN for stable releases, R-universe for the latest development version, and GitHub for direct access to the main development branch. ```R install.packages("see") ``` ```R install.packages("see", repos = "https://easystats.r-universe.dev") ``` ```R remotes::install_github("easystats/see") ``` -------------------------------- ### R: Get Hex Codes from Blue-Brown Palette Source: https://easystats.github.io/see/see/reference/bluebrown_colors Examples demonstrating how to use the `bluebrown_colors` function to retrieve hex codes for the entire blue-brown palette or specific colors. ```R bluebrown_colors() #> lightblue blue darkblue grey lightbrown brown darkbrown #> "#6DC0E0" "#5B93AE" "#1F4454" "#dbdbdb" "#92673C" "#61381A" "#391D07" ``` ```R bluebrown_colors("blue", "brown") #> blue brown #> "#5B93AE" "#61381A" ``` -------------------------------- ### Load the performance R package Source: https://easystats.github.io/see/performance Demonstrates how to load the `performance` package into an R session. It also provides a tip to load the entire `easystats` ecosystem for broader functionality and a command to update to the latest versions. ```R library("performance") ``` ```R library(easystats) ``` ```R easystats::install_latest() ```