product {mlmpower}R Documentation

Create a Product Term in a Model

Description

Creates a product term between two variables that can be added to a mp_model.

Usage

product(name1, name2, weight = 1)

Arguments

name1

a character string that references the first variable's name

name2

a character string that references the second variable's name

weight

a single numeric value specifying the variable's contribution to the variance explained metric. Weights are normalized across all variables of the same level.

Details

Currently the product term is only limited to cross-level interactions between a level-1 centered within cluster variable (icc = 0) and level-2 variable.

Value

A mp_action that can be added to a mp_model.

Examples

# Create Model
model <- (
    outcome('Y')
    + within_predictor('X', icc = 0.0)
    + between_predictor('Z')
)
# Add random slope to the model
model + product('X', 'Z')

[Package mlmpower version 1.0.8 Index]