{"id":16571356,"url":"https://github.com/aariq/holodeck","last_synced_at":"2025-03-21T11:33:46.523Z","repository":{"id":56936280,"uuid":"167047376","full_name":"Aariq/holodeck","owner":"Aariq","description":"A Tidy Interface for Simulating Multivariate Data","archived":false,"fork":false,"pushed_at":"2023-08-27T16:19:38.000Z","size":691,"stargazers_count":12,"open_issues_count":7,"forks_count":0,"subscribers_count":1,"default_branch":"master","last_synced_at":"2025-03-01T06:09:22.780Z","etag":null,"topics":["multivariate-data","simulated-data","simulating-multivariate-data","tidy-interface"],"latest_commit_sha":null,"homepage":null,"language":"R","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"other","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/Aariq.png","metadata":{"files":{"readme":"README.Rmd","changelog":"NEWS.md","contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null}},"created_at":"2019-01-22T18:41:47.000Z","updated_at":"2025-02-21T15:49:40.000Z","dependencies_parsed_at":"2024-10-28T17:18:14.943Z","dependency_job_id":null,"html_url":"https://github.com/Aariq/holodeck","commit_stats":{"total_commits":93,"total_committers":1,"mean_commits":93.0,"dds":0.0,"last_synced_commit":"638f46e6c7d6726837f7ec4df2380238f7c5cf7f"},"previous_names":[],"tags_count":4,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/Aariq%2Fholodeck","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/Aariq%2Fholodeck/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/Aariq%2Fholodeck/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/Aariq%2Fholodeck/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/Aariq","download_url":"https://codeload.github.com/Aariq/holodeck/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":244135908,"owners_count":20403798,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["multivariate-data","simulated-data","simulating-multivariate-data","tidy-interface"],"created_at":"2024-10-11T21:22:16.005Z","updated_at":"2025-03-21T11:33:46.210Z","avatar_url":"https://github.com/Aariq.png","language":"R","funding_links":[],"categories":[],"sub_categories":[],"readme":"---\noutput: github_document\n---\n\n\u003c!-- README.md is generated from README.Rmd. Please edit that file --\u003e\n\n\u003c!-- badges: start --\u003e\n[![R-CMD-check](https://github.com/Aariq/holodeck/actions/workflows/R-CMD-check.yaml/badge.svg)](https://github.com/Aariq/holodeck/actions/workflows/R-CMD-check.yaml)\n[![CRAN](https://www.r-pkg.org/badges/version/holodeck)]( https://CRAN.R-project.org/package=holodeck) ![downloads](http://cranlogs.r-pkg.org/badges/grand-total/holodeck)\n[![Codecov test coverage](https://codecov.io/gh/Aariq/holodeck/branch/master/graph/badge.svg)](https://app.codecov.io/gh/Aariq/holodeck?branch=master)\n[![DOI](https://zenodo.org/badge/167047376.svg)](https://zenodo.org/badge/latestdoi/167047376)\n\u003c!-- badges: end --\u003e\n\n```{r setup, include = FALSE}\nknitr::opts_chunk$set(\n  collapse = TRUE,\n  comment = \"#\u003e\",\n  fig.path = \"man/figures/README-\",\n  out.width = \"100%\"\n)\n```\n\n\n\n\n# holodeck: A Tidy Interface For Simulating Multivariate Data\n\n`holodeck` allows quick and simple creation of simulated multivariate data with variables that co-vary or discriminate between levels of a categorical variable.  The resulting simulated multivariate dataframes are useful for testing the performance of multivariate statistical techniques under different scenarios, power analysis, or just doing a sanity check when trying out a new multivariate method.\n\n## Installation\n\nFrom CRAN:\n``` r\ninstall.packages(\"holodeck)\n```\n\nDevelopment version from r-universe:\n``` r\ninstall.packages('holodeck', repos = c('https://aariq.r-universe.dev', 'https://cloud.r-project.org'))\n```\n\n## Load packages\n\n`holodeck` is built to work with `dplyr` functions, including `group_by()` and the pipe (` %\u003e% `). `purrr` is helpful for iterating simulated data.  For these examples I'll use `ropls` for PCA and PLS-DA.\n\n```{r example, message=FALSE, warning=FALSE}\nlibrary(holodeck)\nlibrary(dplyr)\nlibrary(tibble)\nlibrary(purrr)\nlibrary(ropls)\n```\n\n## Example 1: Investigating PCA and PLS-DA\n\nLet's say we want to learn more about how principal component analysis (PCA) works.  Specifically, what matters more in terms of creating a principal component---variance or covariance of variables? To this end, you might create a dataframe with a few variables with high covariance and low variance and another set of variables with low covariance and high variance\n\n### Generate data\n\n```{R}\nset.seed(925)\ndf1 \u003c- \n  sim_covar(n_obs = 20, n_vars = 5, cov = 0.9, var = 1, name = \"high_cov\") %\u003e%\n  sim_covar(n_vars = 5, cov = 0.1, var = 2, name = \"high_var\") \n```\n\nExplore covariance structure visually.  The diagonal is variance.\n\n```{r}\ndf1 %\u003e% \n  cov() %\u003e%\n  heatmap(Rowv = NA, Colv = NA, symm = TRUE, margins = c(6,6), main = \"Covariance\")\n```\n\nNow let's make this dataset a little more complex. We can add a factor variable, some variables that discriminate between the levels of that factor, and add some missing values.\n\n```{r}\nset.seed(501)\ndf2 \u003c-\n  df1 %\u003e% \n  sim_cat(n_groups = 3, name = \"factor\") %\u003e% \n  group_by(factor) %\u003e% \n  sim_discr(n_vars = 5, var = 1, cov = 0, group_means = c(-1.3, 0, 1.3), name = \"discr\") %\u003e% \n  sim_discr(n_vars = 5, var = 1, cov = 0, group_means = c(0, 0.5, 1), name = \"discr2\") %\u003e% \n  sim_missing(prop = 0.1) %\u003e% \n  ungroup()\ndf2\n```\n\n\n### PCA\n\n```{r}\npca \u003c- opls(select(df2, -factor), fig.pdfC = \"none\", info.txtC = \"none\")\n  \nplot(pca, parAsColFcVn = df2$factor, typeVc = \"x-score\")\n\ngetLoadingMN(pca) %\u003e%\n  as_tibble(rownames = \"variable\") %\u003e% \n  arrange(desc(abs(p1)))\n```\n\nIt looks like PCA mostly picks up on the variables with high covariance, **not** the variables that discriminate among levels of `factor`.  This makes sense, as PCA is an unsupervised analysis.\n\n### PLS-DA\n\n```{r}\nplsda \u003c- opls(select(df2, -factor), df2$factor, predI = 2, permI = 10, fig.pdfC = \"none\", info.txtC = \"none\")\n\nplot(plsda, typeVc = \"x-score\")\n\ngetVipVn(plsda) %\u003e% \n  tibble::enframe(name = \"variable\", value = \"VIP\") %\u003e% \n  arrange(desc(VIP))\n```\n\nPLS-DA, a supervised analysis, finds discrimination among groups and finds that the discriminating variables we generated are most responsible for those differences.\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Faariq%2Fholodeck","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Faariq%2Fholodeck","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Faariq%2Fholodeck/lists"}