lme_model: Fits a Linear Mixed Effects Model

View source: R/lme_model.R

lme_modelR Documentation

Fits a Linear Mixed Effects Model

Description

Fits a Linear Mixed Effects Model

Usage

lme_model(
  dataset,
  ry,
  rind,
  rtime = NULL,
  rmet = NULL,
  vecD = NULL,
  covar = NULL,
  rho = 0,
  int = FALSE,
  cl = 0.95,
  control.lme = list(),
  apVar = TRUE,
  ...
)

Arguments

dataset

an object of class data.frame.

ry

Character string. Name of the outcome in the data set.

rind

Character string. Name of the subject variable in the data set.

rtime

Character string. Name of the time variable in the data set.

rmet

Character string. Name of the method variable in the data set.

vecD

Vector of weights. The length of the vector must be the same as the number of repeated measures.

covar

Character vector. Name of covariates to include in the linear mixed model as fixed effects.

rho

Within subject correlation structure. A value of 0 (default option) stands for compound symmetry and 1 is used for autoregressive of order 1 structure.

int

Boolean indicating if the subject-method interaction has to be included in the model.

cl

Confidence level.

control.lme

A list of control values for the estimation algorithm used in lme function. For further details see lme help.

apVar

Logical. Should the asymptotic variance-covariance matrix of the variance components be estimated in the linear mixed model? (Defaults to TRUE).

...

To pass further arguments.

Value

an object of class lme.

Examples

# Reliability ICC
set.seed(2024)
df <- ccc_sim_data(b = NULL, g = NULL, mu = -0.25, sa = 1.5, se = 1)
mod1 <- lme_model(df,"y","id")
mod1

#Non-longitudinal Methods comparison data
set.seed(2024)
df2 <- ccc_sim_data(n=50,b = c(0,1), mu = -0.25, sa = 1.5, se = 1, nrep=2)
mod2 <- lme_model(df2,"y","id",rmet="met")
mod2

# Longitudinal Methods comparison data
set.seed(2024)
df3 <- ccc_sim_data(n=50, b = c(0,1), g=c(0,0.25,0.5), mu = -0.25, sa = 1.5, 
                    sab=0.25,sag=0.5,bg=c(0,0.5,0.75,0,1,1),se = 1, nrep=2)

mod3 <- lme_model(df3,"y","id","times","met",control.lme=nlme::lmeControl(opt = 'optim'))
mod3


cccrm documentation built on Oct. 19, 2024, 9:06 a.m.