residualrwa: Nonlinear relative weight analysis with residualization

View source: R/residualrwa.R

residualrwaR Documentation

Nonlinear relative weight analysis with residualization

Description

Method to detecting influential variables in nonlinear model with residualized relative weight analysis.

Usage

residualrwa(
  response,
  control = NULL,
  fixed = NULL,
  free,
  data,
  family = "gaussian",
  include_interactions = FALSE,
  name_control = "Control",
  name_fixed = "Fixed",
  name_free = "Free",
  name_interactions = "Interactions",
  boot_ci = FALSE,
  n_boot = 100,
  mc_cores = 1
)

Arguments

response, free, fixed, control

Character or character vectors with names for each parameter. Used in residualrwa to determine how to treat each variable. response is the model output. free are variables that can be included or removed (even in interactions) in all the models without restrictions. fixed are persistent variables across all the models, however they can be included/removed on interactions. control they only act as main effects and never are used for interactions.

data

A data.frame.

family

A string with default "gaussian". It specifies the model link function. Accepted values are "gaussian" or "binomial".

include_interactions

A boolean with default FALSE. Determine if the model should calculate all the pairwise interactions between variables. It uses the names in the parameters free and fixed.

name_free, name_fixed, name_control, name_interactions

A string for type of variable with defaults "Free", "Fixed", "Control" and "Interaction". Names used to label the summary tables

boot_ci

A boolean with default FALSE. Determine if a bootstrap procedure should be used to estimate confidence intervals for the weights. Defaults to FALSE.

n_boot

A numeric with default 100. Number of bootstrap samples used to estimate the confidence intervals.

mc_cores

A numeric with default 1. Number of cores used when performing the bootstrap samples.

Value

A residualrwa object with this structure:

summary

a data.frame with the consolidated sum of relative weights according to each type of component; free, fixed, control and interactions.

data_frame

a data.frame with the individual relative weights for each variable. The data.frame has columns: variable, weight and type. If boot_ci = TRUE, two optional columns ci_low and ci_up indicating the lower and upper confidence intervals for each variable respectively.

model

a Glm object with the final model used to estimate the relative weights.

data

original data.frame.

variables

a list with character vectors free, fixed, control and interactions with the final variables used in the model.

boot_ci

a boolean indicating if the bootstrap procedure was used.

Examples


n <- 100
X1 <- rnorm(n)
X2 <- rnorm(n)
X3 <- rnorm(n)
Y <- X2^3 + 10 * X1 * X2
data <- as.data.frame(cbind(Y, X1, X2, X3))

ex <- residualrwa(
  response = "Y",
  control = NULL,
  fixed = NULL,
  free = c("X1", "X2", "X3"),
  data = data,
  include_interactions = TRUE,
  boot_ci = TRUE,
  n_boot = 5
)


maikol-solis/residualrwa documentation built on Oct. 24, 2022, 7:52 a.m.