TEglm | R Documentation |
Fit a generalized linear model with time as a covariate,
while estimating the shape of the nonlinear interpolation between starting and ending time.
First resamples data with replacement 200 times, and each time estimates the best-shaped curve to interpolate
between initial time-related offset and asymptotic time (i.e., rate at which effect of time saturates at zero).
Then uses the mean estimated rate to transform the timeVar
predictor into an exponentially decaying variable
interpolating between initial time (time offset magnitude of 1) and arbitrarily large time values (time
offset magnitude 0). Last uses this transformed time variable in a glm
model
(i.e., attempts to answer the question "how different was the start than the end?").
TEglm(
formIn,
dat,
timeVar,
family = gaussian,
startingOffset = T,
fixRate = NA
)
formIn |
model formula, as in glm() |
dat |
model data, as in glm() |
timeVar |
String. Indicates which model predictor is time (i.e., should be transformed) |
family |
passed to glm() |
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. |
fixRate |
If numeric, use this as a rate parameter [binary-log of 50 percent time constant] rather than estimating it (e.g., to improve reproducibility) |
Rate is parameterized as a time constant, or the amount of time it takes for half of change to occur. The value of rate has a lower bound of the .0333 quantile of the time variable (i.e., 87.5% of change happens in the first 10% of time) and an upper bound of the .333 quantile of the time variable (i.e., 87.5% of change takes 100% of the time to happen). These bounds provide some robustness in estimates of asympototic effects (i.e., "controlling for time") as well as initial effects (i.e., "time-related starting offset").
Mean estimated rate is calculated after trimming the upper 25% and lower 25% of bootstrapped rate estimates, for robustness to extremes in resampling.
Although the time variable is transformed to exponentially decay toward zero, 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.
The TEglm
approach to including a nonlinear time function in regression is quite different than the
TEfit
approach. TEglm
utilizes a point estimate for the rate parameter in order to
coerce the model into a generalized linear format; TEfit
simultaneously finds the best
combination of rate, start, and asympote parameters. In effect, TEglm
treats magnitude
of change as being of theoretical interest, while TEfit
treats the starting value, rate, and
the asymptotic value as each being of theoretical interest.
TEglmem
for mixed-effects extension of TEglm
;
TElm
for a linear model version of TEglm
dat <- data.frame(trialNum = 1:200, resp = rbinom(200,1,log(11:210)/log(300)))
m_glm <- TEglm(resp ~ trialNum,dat,'trialNum',family=binomial)
summary(m_glm)
m_glm$rate # estimated half-of-change time constant
summary(m_glm$bootRate) # bootstrapped parameter distributions
cor(m_glm$bootRate) # bootstrapped parameter correlations
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.