mc_ma: Moving Average Model Structure

View source: R/mc_ma.R

mc_maR Documentation

Moving Average Model Structure

Description

Builds components of the matrix linear predictor associated with moving average (MA) covariance structures. This function is mainly intended for longitudinal data analysis, but can also be used for time series data

Usage

mc_ma(id, time, data, order = 1)

Arguments

id

name of the column (string) containing the subject index. Note that this structure was designed to deal with longitudinal data. For times series data use the same id for all observations (one unit sample).

time

name of the column (string) containing the index indicating the time.

data

data set.

order

An integer specifying the order of the moving average process.

Details

This function was primarily designed for longitudinal data, but it can also be used for time series analysis. In this case, the id argument should contain a single identifier, representing one observational unit. Internally, the function constructs block-diagonal band matrices using bandSparse.

Value

A list with the following component:

Z1

A sparse matrix of class nsCMatrix representing the moving average component of the matrix linear predictor. The matrix has dimension equal to the total number of observations and is constructed as a block-diagonal matrix, with one block per subject (or time series), each block encoding a moving average structure of the specified order.

Author(s)

Wagner Hugo Bonat, wbonat@ufpr.br

Source

Bonat, W. H. (2018). Multiple Response Variables Regression Models in R: The mcglm Package. Journal of Statistical Software, 84(4):1–30.

See Also

mc_id, mc_dist, mc_car, mc_rw and mc_mixed.

Examples

id <- rep(1:2, each = 4)
time <- rep(1:4, 2)
data <- data.frame("id" = id, "time" = time)
mc_ma(id = "id", time = "time", data = data, order = 1)
mc_ma(id = "id", time = "time", data = data, order = 2)


mcglm documentation built on Jan. 9, 2026, 1:07 a.m.