vadis_line2: Calculate the second line of evidence for the VADIS method

View source: R/vadis_line2.R

vadis_line2R Documentation

Calculate the second line of evidence for the VADIS method

Description

Calculate the second line of evidence for the VADIS method

Usage

vadis_line2(
  mod_list,
  path = NULL,
  weight = 1,
  scale = c("abs", "mean", "minmax", "none"),
  overwrite = c("no", "yes", "reload"),
  verbose = FALSE
)

Arguments

mod_list

A list of regression model objects.

path

Path in which to save the output as an R data file (.rds). If NULL, defaults to the current working directory. Set path = FALSE if you do not wish to save to file.

weight

A numeric value indicating the size of the "effects" used for approximating the maximal reasonable distance. Default is 1.

scale

How should the distance matrix be scaled? See details

overwrite

Should the function overwrite data to location in path? Default is 'no', which will run the analysis if no file exists. If file in path exists, user with be prompted to set new path or allow file to be overwritten. Set to 'yes' to automatically overwrite existing file, and 'reload' to automatically reload existing file.

verbose

Should messages be printed? Default is FALSE

Details

The function loops through a list of model objects, extracts the coefficient estimates, and compiles them in a single dataframe.

For scaling, there are four options. The default, "abs" (absolute), scales by a constant term based on the maximum reasonable distance, and values are bounded between 0 and 1 (see Szmrecsanyi et al. 2019). "minmax" uses minmax normalization, defined as

x' = \frac{x - min(x)}{max(x) - min(x)}

Minmax scaling bound values between 0 and 1. "mean" uses mean normalization, defined as

x' = \frac{x - mean(x)}{max(x) - min(x)}

If scale = "none" no scaling is applied.

Value

A list of length 3.

coef.table

A dataframe of P predictors by M models, containing the pointwise estimated coefficients (for glm and glmer models) or the mean posterior \beta estimates (for brmsfit models) for each predictor in each model.

distance.matrix

An M by M distance matrix of class dist, derived from coef.table. Values are (normalized) Euclidean distances.

similarity.scores

A dataframe of similarity scores derive from distance.matrix. See Szmrecsanyi et al. (2019) for details.

Author(s)

Jason Grafmiller

References

Szmrecsanyi, Benedikt, Jason Grafmiller & Laura Rosseel. 2019. Variation-Based Distance and Similarity Modeling: A Case Study in World Englishes. Frontiers in Artificial Intelligence 2. https://doi.org/10.3389/frai.2019.00023.

Examples

## Not run: 
data_list <- split(particle_verbs_short, particle_verbs_short$Variety, drop = TRUE)

fmla <- Response ~ DirObjWordLength + DirObjDefiniteness + DirObjGivenness + DirObjConcreteness + DirObjThematicity + DirectionalPP + PrimeType + Semantics + Surprisal.P + Surprisal.V + Register

glm_func <- function(x) glm(fmla, data = x, family = binomial)

glm_list <- lapply(data_list, glm_func)
names(glm_list) <- names(data_list)

line2 <- vadis_line2(glm_list, path = FALSE)

## End(Not run)

jasongraf1/VADIS documentation built on July 19, 2023, 10:26 p.m.