rsmsn.lmm: Generate data from SMSN-LMM

View source: R/mainfunctions.R

rsmsn.lmmR Documentation

Generate data from SMSN-LMM

Description

It creates a simulated data set from SMSN-LMM (or from SMN-LMM, if lambda = 0) with several possible dependence structures, for one subject.

Usage

rsmsn.lmm(time1, x1, z1, sigma2, D1, beta, lambda, depStruct = "UNC",
          phi = NULL, distr = "sn", nu = NULL)

Arguments

time1

Vector containing times that should be used in data generation.

x1

Design matrix for fixed effects.

z1

Design matrix for random effects.

sigma2

Common variance parameter, such that \Sigma=\sigma^2*R.

D1

Variance matrix for random effects.

beta

Vector of fixed effects parameter.

lambda

Skewness parameter of random effects.

depStruct

Dependence structure. "UNC" for conditionally uncorrelated ("CI" is also accepted), "ARp" for AR(p) – p is length(phi)–, "CS" for compound symmetry, "DEC" for DEC, and "CAR1" for continuous-time AR(1).

phi

Parameter vector indexing the dependence structure.

distr

Distribution that should be used. "sn" for skew-normal, "st" for skew-t, "ss" for skew-slash, and "scn" for skew-contaminated normal.

nu

Parameter vector indexing distr. Should be NULL for "sn", be a vector of length 1 for "st" and "ss", and of length 2 for "scn".

Value

A data frame containing time, the generated response variable (y), and possible covariates.

Author(s)

Fernanda L. Schumacher, Larissa A. Matos and Victor H. Lachos

References

Lachos, V. H., P. Ghosh, and R. B. Arellano-Valle (2010). Likelihood based inference for skew-normal independent linear mixed models. Statistica Sinica 20, 303-322.

Schumacher, F. L., Lachos, V. H., and Matos, L. A. (2021). Scale mixture of skew-normal linear mixed models with within-subject serial dependence. Statistics in Medicine 40(7), 1790-1810.

See Also

smsn.lmm

Examples

# Generating a sample for 1 individual at 5 times
nj1 = 5
rsmsn.lmm(1:nj1, cbind(1, 1:nj1), rep(1, nj1), sigma2=.25, D1=diag(1),
          beta=c(1, 2), lambda=2, depStruct="ARp", phi=.5,
          distr="st", nu=5)

# Generating a sample for m=25 individuals with 5 times
library(dplyr)
library(purrr)
library(ggplot2)
nj1 = 5
m = 25
gendatList = map(rep(nj1, m),
                 function(nj) rsmsn.lmm(1:nj, cbind(1, 1:nj), rep(1, nj),
                                        sigma2=.25, D1=.5*diag(1), beta=c(1, 2),
                                        lambda=2, depStruct="ARp", phi=.5))
gendat = bind_rows(gendatList, .id="ind")
ggplot(gendat, aes(x=x, y=y, group=ind)) + geom_line() +
  stat_summary(aes(group=1), geom="line", fun=mean, col="blue", size=2)
#
fm1 = smsn.lmm(y ~ x, data=gendat, groupVar="ind", depStruct="ARp",
                pAR=1)
summary(fm1)


skewlmm documentation built on July 9, 2023, 7:29 p.m.