is_intercept: Intercept checks

View source: R/hypr.R

add_interceptR Documentation

Intercept checks

Description

Non-centered contrasts require an intercept for correct specification of experimental hypotheses. These functions enable the user to check for existance of intercepts and to add or remove intercept columns as needed.

Usage

add_intercept(x)

remove_intercept(x)

is_intercept(x)

which_intercept(x)

has_intercept(x)

Arguments

x

A hypr object

Details

There are functions available to check whether a hypr object contains an intercept (has_intercept) or which contrast is the intercept (is_intercept, which_intercept). Moreover, if needed, the user can add (add_intercept) or remove (remove_intercept) an intercept column to/from a hypr object. add_intercept and remove_intercept do not throw an error if the user attempts to remove a non-existing intercept or add an intercept if there already is one.

Value

A single logical value (has_intercept), a logical vector (is_intercept), an integer index vector (which_intercept), or a modified hypr object (add_intercept, remove_intercept)

Functions

  • add_intercept(): Add an intercept column if there is none

  • remove_intercept(): Remove the intercept column if there is one

  • which_intercept(): Return indices, not a logical vector of intercept columns

  • has_intercept(): Check whether any of the contrasts is an intercept

Examples


h1 <- hypr(mu1~0, mu2~mu1)
h2 <- hypr(mu2~mu1, mu3~mu1)

stopifnot(has_intercept(h1))
stopifnot(!has_intercept(h2))
stopifnot(which_intercept(h1) == 1)
stopifnot(is_intercept(h1) == c(TRUE,FALSE))


hypr documentation built on Nov. 9, 2023, 5:06 p.m.