baselineAdjustment: Perform Baseline Adjustment

View source: R/baselineAdjustment.R

baselineAdjustmentR Documentation

Perform Baseline Adjustment

Description

Create a new variable based on a time variable and a group variable where groups are constrained to be equal at specific timepoints.

Usage

baselineAdjustment(
  object,
  variable,
  repetition,
  constrain,
  new.level = NULL,
  collapse.time = NULL
)

Arguments

object

[data.frame] dataset

variable

[character] Column in the dataset to be constrained at specific timepoints.

repetition

[formula] Time and cluster structure, typically ~time|id. See examples below.

constrain

[vector] Levels of the time variable at which the variable is constained.

new.level

[character or numeric] Level used at the constraint. If NULL, then the first level of the variable argument is used.

collapse.time

[character] When not NULL character used to combine the time and argument variable into a new (interaction) variable.

Value

A vector of length the number of rows of the dataset.

Examples

data(ncgsL, package = "LMMstar")

## baseline adjustment 1
ncgsL$treat <- baselineAdjustment(ncgsL, variable = "group",
                 repetition= ~ visit|id, constrain = 1)
table(treat = ncgsL$treat, visit = ncgsL$visit, group = ncgsL$group)

ncgsL$treattime <- baselineAdjustment(ncgsL, variable = "group",
                   repetition= ~ visit|id, constrain = 1, collapse.time = ".")
table(treattime = ncgsL$treattime, visit = ncgsL$visit, group = ncgsL$group)

## baseline adjustment 2
ncgsL$treat2 <- baselineAdjustment(ncgsL, variable = "group",
                 new.level = "baseline",
                 repetition= ~ visit|id, constrain = 1)
table(treat = ncgsL$treat2, visit = ncgsL$visit, group = ncgsL$group)

ncgsL$treattime2 <- baselineAdjustment(ncgsL, variable = "group",
                   new.level = "baseline",
                   repetition= ~ visit|id, constrain = 1, collapse.time = ".")
table(treattime = ncgsL$treattime2, visit = ncgsL$visit, group = ncgsL$group)


LMMstar documentation built on Nov. 9, 2023, 1:06 a.m.