LinearModel

class LinearModel(val mainEffects: Set<String>, type: LinearModel.Type = Type.FirstOrder)

This class provides the ability to specify a linear model (for use in regression and design of experiments). This is only a string specification of the model. The terms are specified by the names of the factors.

Example: A model with 3 main effects, "A", "B", "C", with full model = "A B C AB AC BC ABC". // y = b0 + b1A + b2B + b3C + b12AB + b13AC + b23BC + b123ABC val m3 = LinearModel(setOf("A", "B", "C")) m3.specifyAllTerms()

The properties termsAsMap and termsAsList provide access to the specification.

Parameters

mainEffects

the names of the factors (regressors) in a set

type

the type of model to start with. The default is first order terms (main effects) as define by the provided set of main effects.

Constructors

Link copied to clipboard
constructor(mainEffects: Set<String>, type: LinearModel.Type = Type.FirstOrder)

Types

Link copied to clipboard
object Companion
Link copied to clipboard

Properties

Link copied to clipboard

By default, we assume an intercept term

Link copied to clipboard
Link copied to clipboard

Returns the terms of the model as a list of lists

Link copied to clipboard

Returns the terms of the model as a map. The key to the map is the string join of the elements in the associated list with the elements separated by '*'.

Functions

Link copied to clipboard
Link copied to clipboard

Shorthand for adding a cubic term.

Link copied to clipboard

Every string in the list must be within the main effects set to be valid.

Link copied to clipboard

Shorthand for adding an n-way interaction term.

Link copied to clipboard

Assumes a parsable string and converts it to a list of terms for specifying the model from the string.

Link copied to clipboard

Shorthand for adding a quadratic term.

Link copied to clipboard

Repeatedly calls term() with the elements in the list to specify an entire model.

Link copied to clipboard

Specifies a model with all terms (main effects, first order interactions, 2nd order interactions, etc.

Link copied to clipboard

Add a term to the model. It is assumed that the list of strings represents a product term. Thus, listOf("A", "B") is the interaction term "A*B". The elements of the list must be valid single (main) effect term names.

Link copied to clipboard
fun threeWay(name1: String, name2: String, name3: String): LinearModel

Shorthand for adding a three-way interaction term. The names must be different.

Link copied to clipboard
open override fun toString(): String
Link copied to clipboard
fun twoWay(name1: String, name2: String): LinearModel

Shorthand for adding a two-way interaction term. The names must be different.