baselineAdjustment: Perform Baseline Adjustment

Description Usage Arguments Value Examples

View source: R/baselineAdjustment.R

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

1
baselineAdjustment(object, variable, repetition, constrain, new.level = 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.

Value

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

Examples

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
20
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)

e1.lmm <- suppressWarnings(lmm(cholest~visit*treat,
             data=ncgsL, repetition= ~ visit|id,
             structure = "CS"))


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

e2.lmm <- suppressWarnings(lmm(cholest~visit*treat2,
             data=ncgsL, repetition= ~ visit|id,
             structure = "CS"))

LMMstar documentation built on Nov. 5, 2021, 1:07 a.m.