-
-
Notifications
You must be signed in to change notification settings - Fork 23
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Add acf
(and maybe vignette with some plot
examples)
#371
Comments
acf
and corresponding plot
method
Just by the way (I didn't want to multiply threads), when we speak about the residuals, it would be beneficial IMO to implement some ready-to-use tools for the diagnostics. lm() + nlme + lmer and a few more have them - just type plot(model) and you obtain a set of plots. There are specialized packages dedicated to it, but like olsrr, but dedicated only to the general linear model via OLS (lm()). When dealing with the general linear model via GLS or GEE, the other types of residuals become essential for the assessment what happens / what helped. It's really cool mmrm now provides the basic types of residuals, so everyone can implement the needed plots ad hoc, but anyway, it's always better to have at least a basic set of tools ready to use, because it's consistent with the rest of the package. For example, the fitted vs residual plot
By the way, most tests from the lmtest package work here (I put them on the plot above), or need the lm class to be added (I mean |
acf
and corresponding plot
methodacf
(and maybe vignette with some plot
examples)
Check also this article: https://aosmith.rbind.io/2018/06/27/uneven-grouped-autocorrelation/ nlme::ACF will work well for balanced and equidistant observations. I had incomplete observations and took the naive approach from nlme;:ACF, and quickly run into nonsenses (here I used GLS for simplicity, but the same problem was with my adjusted mmrm version)
while it should be:
Oh man, how easy is to forget basic things...
|
In the ideal world the "unstructured" pattern of covariance should save us from complex, hard-to-guess-apriori considerations about the expected residual cov. structure. If only it always converged :)
If it fails to converge, there are some options to account for it in our SAPs:
we can pre-specify the path of "fallback", like: US -> ADH, -> AD -> AR1 H or Toeplitz (stationary-M-dependent(m)) or spatial -> CSH -> CS
guess the covariance structure a priori, based on some prior investigations, literature, common sense. People often assume just AR1 or SP(POW) [for unequal visits/timepoints].
follow the least-resistance line or not care by specifying CS. Seems legit :) Nobody will argue "hey, you ignored the within-subject covariance", easy to fit, easy to talk about, compliant with tons of literature. Only it can be far from reality and even farther from any reasonable scientific justification for the strong assumption that "all subjects' organisms respond with the same rate" (approximately translates to random-intercept LMM, if we enforce only non-negative covariances).
some specify automated selection methods, e.g. based on AIC/BIC/AICC (or QIC/AGPC/GHYC/etc. in GEE). BTW, I found
mmrm:::AIC.mmrm_tmb()
andmmrm:::BIC.mmrm_tmb()
but missed AICC.In either case, some people (including myself) are curious about the autocorrelation and look at ACF and/or (semi)variogram to check if and how each structure helped (or messed): 1)
acf(residuals(model, type="response"))
then 2)acf(residuals(model, type="normalized"))
For nlme::gls() we can use either:
acf(residuals(model, type="normalized"))
, but it loses the information about clusters (subjects)plot(ACF(ma, form=~1|PatientId, resType = "response"), grid = TRUE)
, which preserves the number of timepoints (visits)Optionally also:
For the mmrm we can still use
acf(residuals(model, type="normalized"))
, but, as mentioned previously, it loses the information about clusters (subjects). OK, if used just for some very rough exploration, it can be so. Some patterns will be visible anyway.For semi-variogram I can employ the nlme::gls() followed by its Variogram() function with appropriate type of residuals ("response" for the raw, "normalized" accounting for the covariance), which isn't very much convenient in terms of translating correlation + weight terms in gls() into mmrm's us/ar1/csh/cs, etc.
If it can be done better, than why not :)
For example, my assessments look like:
PS: just a very minor thing - for xIC comparisons it would be helpful to have "ind()" (independence) structure in mmrm. You know, something like nlme::gls(correlation = NULL, weights = varIdent(form =~1|Visit)). Just a technical "sugar". Just saying :)
The text was updated successfully, but these errors were encountered: