[R-sig-ME] Random effects in R vs SAS

Will Hopkins w|||thek|w| @end|ng |rom gm@||@com
Fri Aug 18 07:06:41 CEST 2023


I am a SAS user, and I have just finished a near-final draft of an article
about identifying and specifying fixed and random effects for mixed models
in SAS. At the moment, all I say about R is this: "To all users of the R
stats package, my apologies: a few years ago, I found the mixed model in R
too limiting, and I struggled with the coding. I hope someone with R smarts
will consider adapting my programs and publishing them here." I really would
like to know if the limitations (or at least, what I consider to be
limitations) have been addressed, so I can be more specific in my article.
Specifically can anyone answer these questions?

 

1. Can you specify negative variance for random effects in R? (That doesn't
apply to the variances representing residuals, which are never negative).

 

2. Can you get trustworthy estimates of standard errors for the
random-effect and residual variances in R? (By trustworthy, I guess I mean
the same as SAS's, but it could mean that someone has shown that the
confidence intervals derived with the SEs have good coverage, assuming
normality for the variances representing random effects and chi-squared for
variances representing residuals.) 

 

3. Does R have the equivalent of the repeated statement in SAS, whereby you
can specify a repeated measure with an unstructured or other covariance
matrix? (e.g., repeated Time/subject=SubjectID type=un. This statement works
more reliably than the random statement in SAS with small sample sizes, but
it doesn't produce residual variances, not directly anyway.)

 

4. Does R have the equivalent of the group= option in SAS, whereby you can
specify separate estimates of random-effect variances and covariances,
and/or separate estimates of residuals, for different groups? (e.g., random
SubjectID/group=Sex; repeated/group=Sex;)

 

The draft article is available at
https://sportsci.org/2023/EffectsModels.htm. It's not published yet (i.e.,
not linked to the Sportscience homepage yet). I would be grateful for any
feedback. I can incorporate more about R and would love someone to provide R
code for the programs I have published. See below for the title and
abstract.

 

Will

 

How to Identify and Specify Fixed and Random Effects for Linear Mixed Models
in the Statistical Analysis System

 

Most analyses require linear mixed modeling to properly account not only for
mean effects but also for sources of variability and error in the data. In
linear mixed models, means and their differences are specified with fixed
effects, while variabilities and errors are specified with random effects
(including residuals) and are summarized as standard deviations. In this
tutorial article, I explain how variables represent effects in linear mixed
models and how identifying clusters of observations in a dataset is the key
to identifying the fixed and random effects. I also provide programs written
in the language of the Statistical analysis system to simulate data and
analyze them with the general linear mixed model, Proc Mixed, which is used
when the dependent variable is continuous. The analyses include simple
linear regression, reliability and time series, controlled trials, and
combined within- and between-subject modeling. Finally, I explain how
dependent variables representing counts or proportions require generalized
linear mixed models, realized in SAS with Proc Glimmix, where the main
difference is the specification of the residuals.

 


	[[alternative HTML version deleted]]



More information about the R-sig-mixed-models mailing list