acmisc

Miscellaneous R functions to streamline certain analyses

https://github.com/akcochrane/acmisc

Science Score: 67.0%

This score indicates how likely this project is to be science-related based on various indicators:

  • CITATION.cff file
    Found CITATION.cff file
  • codemeta.json file
    Found codemeta.json file
  • .zenodo.json file
    Found .zenodo.json file
  • DOI references
    Found 2 DOI reference(s) in README
  • Academic publication links
    Links to: zenodo.org
  • Academic email domains
  • Institutional organization owner
  • JOSS paper metadata
  • Scientific vocabulary similarity
    Low similarity (15.8%) to scientific vocabulary
Last synced: 10 months ago · JSON representation ·

Repository

Miscellaneous R functions to streamline certain analyses

Basic Info
  • Host: GitHub
  • Owner: akcochrane
  • License: mit
  • Language: R
  • Default Branch: main
  • Size: 178 KB
Statistics
  • Stars: 0
  • Watchers: 1
  • Forks: 0
  • Open Issues: 0
  • Releases: 1
Created over 4 years ago · Last pushed 11 months ago
Metadata Files
Readme License Citation

README.Rmd

---
output:
  md_document:
    variant: markdown_github
---





# ACmisc
```{r setup,echo=F}
library(ACmisc)
```

[![License: MIT](https://img.shields.io/badge/License-MIT-yellow.svg)](https://opensource.org/licenses/MIT)
[![DOI](https://zenodo.org/badge/425863127.svg)](https://zenodo.org/badge/latestdoi/425863127)

## Overview to ACmisc

Various functions used by Aaron Cochrane, and encouraged for collaborators to use. Please don't hesitate to branch, submit pull requests, etc., or to contact Aaron directly. And if you use the functions in published work, it would be wonderful if you cited this package using the [Zenodo DOI 10.5281/zenodo.5773069](10.5281/zenodo.5773069). Thanks!

## Installing the package

The R package `devtools` includes a very easy way to install packages from Github.

```
devtools::install_github('akcochrane/ACmisc', build_vignettes = TRUE)
```

## A handful of example functions

### `BICBF()` -- Bayes Factors for common models

Calculates BIC for an entire `lm()`, `rlm()`, `glm()`, `lmer()`, or `glmer()` model, and for the entire set of models dropping each fixed effect one at a time. Uses the change in BIC between models to approximate Bayes Factors (essentially penalized Likelihood Ratios, or evidence for one model over another). Follows the recommendations of Wagenmakers (2007; PBR).

```{r BICBF_glmer, warning=F, message=F}
library(lme4)
mod <- lmer(mot ~ nback * ravens + (1|isAdult),dat_cochraneEtAl_2019_PLOSOne)

BF_table <- BICBF(mod)
knitr::kable(BF_table,digits=3)
```

### `d1iso()`

Extracts scores from a single isotonic [think: rank-based] underlying dimension from multivariate data. Very useful for extracting the common variation in data when other methods (e.g., PCA) would struggle due to different variables' lack of Gaussian-ness.

### `ddm_dr_lm()` -- Drift Diffusion Linear Model

Essentially fits a generalized linear model for a Wiener process, using the density estimation function from the `RWiener` package. First fits a standard 4-parameter Wiener model to an entire vector of RTs and response-categories. Then uses the boundary separation, bias, and non-decision time from this overall model, and finds the best set of parameters to create a drift rate vector as a linear function of the right-hand side of the model formula. __Only numeric predictors have been tested.__ 

### `findLowerRT()`

Follows the procedure of Ratcliff & Tuerlinckx (2002) to find the lowest RT at which accuracy is below chance.

### `getTime()` 

Returns a string with a formatted date and time, to the nearest minute.

### `isOutlier()`

Uses robust covariance estimation of Mahalanobis distances to identify multivariate outliers within a dataset; follows the procedure outlined by Leys and colleagues (2018; JESP).

### `resetSeed()`

Re-"randomizes" the seed for random generation.

### `robustLM_bayes()`

Implements a very robust linear model, with mixed-effects terms possible. Uses median regression within the `brms` package to fit the specified model and sub-models, and uses the `bridgesampling` package to estimate Bayes Factors supporting the model _with_ the predictor compared to the model _without_ that predictor.

### `sourceIfChanged()`

Useful when scripts may take a long time to run. Runs a file, just like `source()`. But the resulting namespace is saved (in an `.RData`), as well as a plain-text copy. The next time that `sourceIfChanged` is run, it simply loads the `.RData` file if there haven't been any changes, and it re-`source`s the `.R` file if there has been changes.

### `YeoJohn()`

Applies a Yeo-Johnson univariate power transformation to a variable, after optimizing the Yeo-Johnson parameter to minimize the variable's skew.

Owner

  • Name: Aaron Cochrane
  • Login: akcochrane
  • Kind: user

Researcher of visual cognition and learning at the University of Geneva.

Citation (CITATION.cff)

cff-version: 00.00.10
message: "If you use this software, please cite it as below."
authors:
  - family-names: Cochrane
    given-names: Aaron
    orcid: https://orcid.org/0000-0001-6691-9149
title: akcochrane/ACmisc
version: 00.00.10
date-released: 2021-12-10

GitHub Events

Total
  • Push event: 4
Last Year
  • Push event: 4