indep_tf: Data Transformer

Description Usage Arguments Details Value Examples

View source: R/01_indep_transform.R

Description

Step One: Transforms the independent variables so it can be further used in mfit.

Usage

1
indep_tf(depname, data, group_df = NULL)

Arguments

depname

The name of the dependent variable in character form, e.g. "depvar".

data

A data.frame holding all relevant explanatory variables.

group_df

A data.frame object for grouping. One column, varnames depicts the explanatory variables in character form. The other one, called groups depicts the group each variable belongs to, with the dependent variable being in the group 0. See the examples section for an example.

Details

The existence of this function is based on the ability to provide groups for partitioning in ghp. If there were no groups given, this function essentially converts the dataframe to a list with one element per explanatory variable, then puts it into another list and attaches some useful information.

Value

A list with two elements:

  1. dep: A vector with the dependent variable.

  2. indep: A list with either one vector per variable (ungrouped) as elements, or one data.frame with all variables belonging to one group as elements.

Examples

1
2
3
4
5
6
# Ungrouped
indep_tf("Species", iris)

# Grouped
groupings <- data.frame(varnames = colnames(iris), groups = c("Sepal", "Sepal", "Petal", "Petal", "0"))
indep_tf("Species", iris, group_df = groupings)

Stan125/ghp documentation built on Feb. 1, 2020, 1:21 p.m.