PersonAlytic | R Documentation |
A simplified user interface for longitudinal linear mixed
effects models (also known as growth models or hierarchical linear models) using
nlme
and generalized linear mixed effects models using
gamlss
(not currently implemented).
The basic mixed effects model is dv=time+phase+phase*time
with random intercepts and random slopes for time. The phase variable is optional.
Additional independent variables (or covariates) can be included.
High throughput capabilities are invoked when the model is to be fit to multiple individuals, multiple dependent variables, iterated over multiple target independent variables, or any combination of these three.
The residual correlation structure ARMA(p,q)
is automatically selected
among p=1,...,P
and q=1,...,Q
where P
and Q
are selected by the user. Model selection is done
by comparing fit indices using either the BIC
or AIC
(ARMA models
are not generally nested, precluding the use of likelihood ratio tests).
The functional form of the relationship between time and the dependent variable
is automatically selected up to time^time_power
where time_power
is
selected by the user. Model selection is done using likelihood
ratio tests (LRT) with maximum likelihood estimators. For example,
if time_power=3
(implying a maximum of a cubic growth model), linear,
quadratic and cubic models will be fit. If the best fitting model is a quadratic
growth model, then there will be random and fixed effects for time
and
time^2
.
When there are multiple dependent variables and multiple target independent
variables, Type I error corrections or false discovery rate corrections are
made across target independent variables within each dependent variable (and
within each person if individual models are being fit to the data). Correction
options are given in p.adjust
.
PersonAlytic(
output = NULL,
data,
ids,
dvs,
time,
phase = NULL,
ivs = NULL,
target_ivs = NULL,
interactions = NULL,
time_power = 1,
correlation = NULL,
family = gamlss.dist::NO(),
subgroup = NULL,
standardize = list(dv = FALSE, iv = FALSE, byids = FALSE),
method = "REML",
package = "nlme",
individual_mods = FALSE,
PalyticObj = NULL,
autoSelect = list(AR = list(P = 3, Q = 3), TO = list(polyMax = 3), DIST = list()),
whichIC = c("BIC", "AIC"),
charSub = NULL,
sigma.formula = ~1,
p.method = "BY",
alpha = 0.05,
nbest = NULL,
alignPhase = "none",
fpc = 0,
debugforeach = FALSE,
cores = parallel::detectCores() - 1,
userFormula = NULL,
...
)
output |
Character. The default is A character string that will be used to name a file for saving
output. If left If |
data |
A
|
ids |
Character. The name of the ID variable. The ID variable must be a variable in |
dvs |
Character list. A list of one or more character dependent variable names in |
time |
Character. The name of the time variable. The time variable must be a variable in |
phase |
Character. The default value is Name of the phase or treatment variable. For model fitting,
|
ivs |
Character list. The default value is A list of names of covariates, e.g., |
target_ivs |
Character list. The default value is Independent variables that are iterated over (see |
interactions |
Character list. The default value is List of pairs of variable names for interactions
to include in the model, e.g., |
time_power |
Numeric. The default is Power of the time variable (e.g., |
correlation |
Character. The default value is See |
family |
See A list of the same length as |
subgroup |
Logical vector. The default is A vector where |
standardize |
Named logical vector. The default is
Which variables should be standardized?
(i.e., rescaled to have 0 mean and unit variance; see
|
method |
character. The default is Which likelihood methods should be used to fit the models? Options are
|
package |
Character. The default is Which package should be used to fit the models?
Options are |
individual_mods |
Logical. The default is Should individual models be fit for each ID in |
PalyticObj |
See If |
autoSelect |
List. The default is
If no automated model selection for the residual covariance structure ( If If If |
whichIC |
Character. The default is Either the Akaike Information Criterion ( If the Residual autocorrelation structure is detected separately for each individual
in |
charSub |
Character list. The default in A list of paired character strings for character substitution
in the output. If the names of the target predictors
in |
sigma.formula |
Not currently implemented. A formula for the variance under |
p.method |
See |
alpha |
Numeric value in the (0,1) interval. The Type I error rate for adjusting p-values. |
nbest |
Numeric integer value. The number of best |
alignPhase |
Character. The default is Other options are Should the time variable be realigned at the phase?
If |
fpc |
Numeric. The default is 0. If the value of fpc is greater than the number of individuals in the data set, fpc is taken as the size of the finite population from which the data were sampled, and a finite population correction is made for the fixed effects standard errors, t-tests, and p-values. |
debugforeach |
Logical. The default is |
cores |
Integer. The defaults is |
userFormula |
List of formulae used to override default model
construction. Items in the list must include |
... |
Not currently used. |
## Not run:
# full sample model
t0 <- PersonAlytic(output = 'Test0' ,
data = OvaryICT ,
ids = "Mare" ,
dvs = "follicles" ,
phase = "Phase" ,
time = "Time" ,
package = "nlme" )
# individual models
t1 <- PersonAlytic(output = 'Test1' ,
data = OvaryICT ,
ids = "Mare" ,
dvs = "follicles" ,
phase = "Phase" ,
time = "Time" ,
package = "arma" ,
individual_mods = TRUE )
summary(t0)
summary(t1)
# full sample model with a finite population correction (FPC)
t0fpc <- PersonAlytic(output = 'Test0FPC' ,
data = OvaryICT ,
ids = "Mare" ,
dvs = "follicles" ,
phase = "Phase" ,
time = "Time" ,
package = "nlme" ,
fpc = 100 )
# gamlss with two distributions - features not implemented
#OvaryICT$follicles01 <- to01(OvaryICT$follicles)
#t2 <- PersonAlytic(data=OvaryICT,
# ids="Mare",
# dvs=list("follicles", "follicles01"),
# phase="Phase",
# time="Time",
# family=c(NO(), BEINF()),
# package='gamlss')
# individual models with target variables
t3 <- PersonAlytic(output = 'TargetIVStest' ,
data = OvaryICT ,
ids = "Mare" ,
dvs = "follicles" ,
phase = "Phase" ,
time = "Time" ,
package = "arma" ,
individual_mods = TRUE ,
target_ivs = names(OvaryICT)[6:11] )
# multiple DVs with no target_ivs and group models
t4 <- PersonAlytic(output = 'MultiDVnoIDnoIV' ,
data = OvaryICT ,
ids = "Mare" ,
dvs = names(OvaryICT)[c(3,9:11)] ,
phase = "Phase" ,
time = "Time" ,
package = "lme" ,
individual_mods = FALSE ,
target_ivs = NULL ,
autoSelect = list() )
# repeat t4 with finite population correction
t5 <- PersonAlytic(output = 'MultiDVnoIDnoIVFPC' ,
data = OvaryICT ,
ids = "Mare" ,
dvs = names(OvaryICT)[c(3,9:11)] ,
phase = "Phase" ,
time = "Time" ,
package = "lme" ,
individual_mods = FALSE ,
target_ivs = NULL ,
autoSelect = list() ,
fpc = 200 )
# repeat t5 with piecewise model, first making time an integer (required for piecewise)
OvaryICT$TimeP <- round(30*OvaryICT$Time)
t6 <- PersonAlytic(output = 'PiecewiseExample' ,
data = OvaryICT ,
ids = "Mare" ,
dvs = names(OvaryICT)[c(3,9:11)] ,
phase = "Phase" ,
time = "TimeP" ,
package = "lme" ,
individual_mods = FALSE ,
target_ivs = NULL ,
autoSelect = list() ,
fpc = 200 ,
alignPhase = "piecewise" )
# clean up
file.remove( 'PiecewiseExample_PersonAlytic.csv' )
file.remove( 'REMLlme.txt' )
file.remove( 'MultiDVnoIDnoIVFPC_PersonAlytic.csv' )
file.remove( 'MultiDVnoIDnoIV_PersonAlytic.csv' )
file.remove( 'TargetIVStest_PersonAlytic.csv' )
file.remove( 'NotREMLarma.txt' )
file.remove( 'Test0FPC.txt' )
file.remove( 'Test1_PersonAlytic.csv' )
file.remove( 'Test0.txt' )
## End(Not run)
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.