initialize | R Documentation |
Create a new Palytic Object
Palytic$new(data, ids, dv, time)
data |
A |
ids |
A character string giving the name of the id variable in |
dv |
A character string giving the name of the dependent variable in |
time |
A character string giving the name of the time variable in |
phase |
A character string giving the name of the phase variable in |
ivs |
A |
interactions |
List of vector pairs of variable names for which interaction
terms should be specified, e.g., |
time_power |
The polynomial for |
correlation |
See |
correlation0 |
Other options such as |
family |
The |
fixed |
The |
random |
The |
formula |
The |
method |
See |
standardize |
Named logical list. Which variables should be standardized? The default
is |
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 |
corStructs |
Vector. A |
time_powers |
Vector. A |
alignPhase |
Character. Options include
a. 'none', no changes are made to the time or phase variable.
b. 'align', align the time variable to be zero at the transition between
the first and second phase (see |
ismonotone |
Logical. Is the |
datac |
data.frame. Cleaned data. Cleaning involves the following steps:
1. Check that the variables in |
debugforeach |
Logical flag for testing error handling in parallelized runs. |
try_silent |
Logical flag for testing error handling in |
The fields data
, ids
, dv
, and time
are required.
Using these, the default model dv=time
with random intercepts for ids
and random intercepts for time
is constructed. See the example. If
phase
is provided, the default model is dv=time+phase+phase*time
, and if
ivs
are provided they are included in the model.
A new 'Palytic' object
Stephen Tueller stueller@rti.org
## Not run:
# construct a new Payltic object and examine the default formulae#'
t1 <- Palytic$new(data = OvaryICT, ids='Mare', dv='follicles',
time='Time', phase='Phase', autoSelect=list())
# summary, descriptive, and plot methods
t1$summary()
t1$describe()
t1$plot()
# check the formulae creation
t1$fixed
t1$random
t1$formula
t1$correlation
# Compare gamlss and lme output, in which the models of the default formulae
# are fit. Note that the estimates are the same (within rounding) but that
# the gamlss SE are much smaller. This is due to gamlss modeling the variance
# which reduces the redisudual variance
t1.gamlss <- t1$gamlss()
t1.lme <- t1$lme()
t1.gamlss$tTable
t1.lme$tTable
# now change the correlation structure and compare gamlss and lme output,
# noting that the intercepts are very different now
t1$correlation <- "corARMA(p=1, q=0)"
t1$gamlss()$tTable
t1$lme()$tTable
# fit the model only to the first mare with ML instead of REML
t1$method <- 'ML'
t1$gamlss(OvaryICT$Mare==1)$tTable
# change the formula
t2 <- t1$clone()
t2$formula <- formula(follicles ~ Time * Phase +
re(random = ~Time + I(Time^2) | Mare, method = "ML",
correlation = corARMA(p=1,q=0)))
t2$formula
# random intercept only model
t2 <- t1$clone()
t2$random <- formula(~1|Mare)
t2$random
t2$formula
# random slope only model
t2$random <- formula(~0+Time|Mare)
t2$random
t2$formula
# note that prior examples set
# `autoSelect=list()`, here we use the default, which is to autoselect
# the correlation structure (AR), the polynomial order of time (TO) and
# the distribution
t1 <- Palytic$new(data = OvaryICT, ids='Mare',
dv='follicles', time='Time', phase='Phase',
autoSelect=list(AR=list(P=3, Q=3) ,
TO=list(polyMax=3) ,
DIST=list()) )
# automatically select the polynomial order of time with getTO
t1$getTO()
t1$time_powers
# automatically select the ARMA model for residual correlation getAR
t1$GroupAR()
t1$correlation
t1$corStructs
# automatically select the distribution, noting that calling $dist() updates $family
t1$dist()
t1$family
# automatically select all three which follows the order
# 1. DIST (which will switch package to gamlss for TO and AR)
# 2. TO (which can subsequently impact AR)
# 3. AR
t1$detect()
# construct a new Payltic object with no phase variable
t1 <- Palytic$new(data = OvaryICT, ids='Mare', dv='follicles',
time='Time', phase=NULL)
t1$plot()
# piecewise example
OvaryICT$TimeP <- round(30*OvaryICT$Time)
t1 <- Palytic$new(data = OvaryICT, ids = 'Mare',
dv = 'follicles', time = 'TimeP', phase = 'Phase',
alignPhase = 'piecewise', autoSelect=list())
t1$time
t1$lme()
# piecewise with finite population correction for a population of N=200
t1$lme()$tTable
t1$lme(fpc = TRUE, popsize2 = 200)$FPCtTable
## End(Not run)
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.