TEglmem | R Documentation |
Fits a glmer
generalized linear mixed-effects model with the random effects of
timeVar
for each level of groupingVar
. Provides estimates of time-related change
(i.e., attempts to answer the question "how different was the start than the end?").
TEglmem(
formIn,
dat,
timeVar,
groupingVar,
family = gaussian,
startingOffset = T,
nRuns = 5,
silent = F
)
formIn |
model formula, as in |
dat |
model data, as in |
timeVar |
String. Indicates which variable in |
groupingVar |
String. Indicates which variable in |
family |
model family, as in |
startingOffset |
By default (if T) time is coded to start at 1 and saturate to 0. If startingOffset is F, time starts at 0 and saturates to 1. May assist in interpreting interactions with other variables, etc. |
nRuns |
Number of times to run optimization of the rate (i.e., fitting nonlinear transformations of |
silent |
Progress is printed by default. silent=T to suppress |
First uses TEglm
to find a rate parameter for each level of groupingVar
, with
the formula extracted using tef_getRanefForm
. These
rate parameters are used to transform the corresponding timeVar
into a exponentially
saturating variable (see TEglm
). After finding an initial set of
rate parameters using TEglm
,
TEglmem
attempts to optimize the vector of rate parameters in conjunction with the full
glmer
model.
May be used, with nRuns=0
, to simply
use rate estimates from independent groupingVar
-level TEglm
models, extracting the corresponding
transformed time variables and using them in a GLMEM.
A list including:
glmerMod
glmer
model fit with transformed time variable
rates
Named vector of rates [binary log of 50-percent-of-change time constants]
timeDat
Data frame with original and transformed time variable
groupMods
List of fit TEglm
models, and the corresponding transformed time variable and named vector of rates
Random effects and rate estimates may be unstable, and optimization may take
a very long time to run. The primary purpose of this function is to allow for by-groupingVar
detrending of time-related changes in data (i.e., to estimate and test fixed effects at asymptotic time,
or to estimate and test the magnitude of time-related effects).
If reliable by-groupingVar
parameters are desired, it is highly recommended to use
TEbrm
.
The formIn
must include a random effect of timeVar
by groupingVar
(e.g., (time_variable | grouping_variable)
).
Although the time variable is transformed to exponentially decay from one toward zero
(or, if startingOffset=F
, from zero toward one), this does not necessarily mean
that the model prediction involves an exponential change with time. The nonlinear change in time relates
to the time-associated model coefficients.
## Not run:
m_TEglmem <- TEglmem(resp ~ ratio + trialNum:ratio + (ratio + trialNum:ratio || subID),anstrain, timeVar = 'trialNum',groupingVar = 'subID',family=binomial)
# Typical glmer model:
summary(m_TEglmem$glmerMod)
# Participant-level rate parameters:
m_TEglmem$rates
## End(Not run)
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.