generateCircGLMData: Generate data that follows the circular GLM model

View source: R/generateCircGLMData.R

generateCircGLMDataR Documentation

Generate data that follows the circular GLM model

Description

This function samples data according to the circular GLM model. A set of true values for the parameters can be entered, and a dataset is returned that is drawn from the corresponding model. The link function can also be selected.

Usage

generateCircGLMData(
  n = 30,
  residkappa = 5,
  nconpred = 2,
  ncatpred = 2,
  truebeta0 = pi/2,
  truebeta = rep(0.25, nconpred),
  truedelta = rep(1, ncatpred),
  linkfun = function(x) 2 * atan(x)
)

Arguments

n

Integer; the sample size to be generated.

residkappa

A non-negative numeric; the residual concentration parameter. This is the κ of the von Mises distribution that the residuals follow.

nconpred

Integer; The number of continuous (linear) predictors to be generated.

ncatpred

Integer; The number of categorical predictors to be generated.

truebeta0

An angle in radians representing beta_0, which functions as the intercept.

truebeta

A numeric vector containing the values for the regression coefficients of the continuous predictors.

truedelta

A numeric vector containing angles in radians that represent the group differences for each of the categorical predictors.

linkfun

Function; The link function to use. The default is the canonical arctangent link.

Details

This function can also be used as a wrapper for sampling von Mises data, if nconpred = 0, ncatpred = 0. Then, beta_0 is the mean of the von Mises distribution and residkappa is the concentration parameter κ.

In order to make this function more useful in simulations, the true parameters are also added to the data set that is returned as attributes.

Value

A numeric matrix containing a dataset sampled according to the circular GLM model. The first column th represents the circular outcome in radians. The following columns represent the linear predictors and are named l1, l2, ... . The following columns represent the categorical predictors and are named c1, c2, ... . The matrix also has attributes containing the true values of the parameters, the used link function, and a proportion u showing the proportion of the data that is on the semicircle closest to beta_0.

Examples


# Von Mises data with mean 2, kappa 3.
generateCircGLMData(truebeta0 = 2, residkappa = 3,
                    nconpred = 0, ncatpred = 0)

# circGLM data
generateCircGLMData(n = 20, nconpred = 4, truebeta = c(0, 0.4, 0.2, 0.05))


keesmulder/circglmbayes documentation built on July 24, 2022, 6:39 a.m.