structure_vectors: Structure Vector S3 Generic

View source: R/generics.R

structure_vectorsR Documentation

Structure Vector S3 Generic

Description

Generic function to compute structure vectors from different types of inputs.

Method for structure_vectors when the input is a formula and data frame.

Usage

structure_vectors(x, ...)

## Default S3 method:
structure_vectors(
  x,
  X,
  model = c("b", "bcl", "acl", "os", "sl", "cl"),
  label = TRUE,
  rational = FALSE,
  ...
)

## S3 method for class 'formula'
structure_vectors(
  x,
  data,
  contrasts = NULL,
  model = NULL,
  label = TRUE,
  rational = FALSE,
  ...
)

Arguments

x

input object. Supported inputs:

  • Pre-fit (default): a vector of type factor, character, logical, numeric or integer. In this case one also needs to supply the argument X and, optionally but recommended, a model.

  • Pre-fit (formula): an object of class "formula" (or one that can be coerced to that class): a symbolic description of the model to be fitted. The details of model specification are given under ‘Details’ in glm. In this case one needs to supply data, with an optional model argument as well.

...

Additional arguments.

X

a design matrix, e.g. generated via a call to model.matrix. X is expected to already contain the desired contrasts for factors (e.g., dummies) and any other expanded columns (e.g., for polynomials).

model

character string specifying the model class to be fitted. One of:

  • "b" – binary

  • "bcl" – baseline-category link

  • "cl" – cumulative link

  • "acl" – adjacent-category link

  • "sl" – sequential link

  • "os" – ordered stereotype model

If missing or NULL, defaults to "cl" for ordinal y and "bcl" otherwise.

label

Should the columns and rows be labeled?

rational

Should the matrix be returned in rational form (as per rcdd definition)?

data

either a standard data frame, list or environment (or object coercible by as.data.frame to a data frame) containing the variables in the model. If not found in data, the variables are taken from environment(formula), typically the environment from which the function is called.

Alternatively, data can be a data frame or matrix containing rational numbers as per the definition in rcdd (i.e. columns are characters, entries are either integer numbers or ratios of integer numbers, e.g. "1" or "-234/19008"). This is checked internally; see ‘Details’ for what happens when this structure is discovered.

contrasts

an optional list. See the contrasts.arg of model.matrix.default. Only effective for standard data frames.

Details

structure_vectors is an S3 generic function.

The formula method is for standard data frames and formulas that work the same way as when used with glm. It does not support extended formulas, and may not work for functions that do formula processing differently.

For a data frame or matrix given as rational numbers in the rcdd definition, this is recognized but the formula does not get expanded and is taken literally. Consequently:

  • variables in formula must match exactly with the column names in data;

  • factors need to be converted to dummies beforehand (which would not be possible in the rational format in any other way anyway).

Value

A structure vector matrix with or without labeled rows and columns. For model = "sl", a list of structure vector matrices, where each list element corresponds sequentially to the categories of y, starting with the lowest and ending with the (K-1)-th category. At each category k, we consider all observations with category k or higher for the structure vector matrix.

Examples


data(qcsepdato)
yo<-qcsepdato$y
Xo<-qcsepdato[,2:ncol(qcsepdato)]

# Sequential link (default method and no labelling) 
structure_vectors(yo, Xo, model = "sl", label = FALSE)

# Ordered stereotype (formula method)
structure_vectors(y ~ x1 + x2, data = qcsepdato, model = "os")


divoRce documentation built on Oct. 18, 2026, 5:08 p.m.