[R-sig-ME] strategy to iterate over repeated measures/longitudinaldata
David Duffy
David.Duffy at qimr.edu.au
Tue Jul 21 23:35:01 CEST 2009
On Tue, 21 Jul 2009, Juliet Hannah wrote:
> Here is an example with inefficient, working code.
>
You could try using the jit compiler -- it does speed up looping
> for (predictor in predictor_names)
> {
> long_data <- make.univ( data.frame(wide_data$id,wide_data[,predictor]),
> data.frame(
> wide_data$measurement1,
> wide_data$measurement2
> )
> )
> names(long_data) <- c('id', 'predictor', 'time','measurement')
> myfit <- lmer(measurement ~ predictor + (1|id),data=long_data)
> mycoefs[predictor] <- myfit at fixef[2]
> }
>
Cheers, David Duffy.
--
| David Duffy (MBBS PhD) ,-_|\
| email: davidD at qimr.edu.au ph: INT+61+7+3362-0217 fax: -0101 / *
| Epidemiology Unit, Queensland Institute of Medical Research \_,-._/
| 300 Herston Rd, Brisbane, Queensland 4029, Australia GPG 4D0B994A v
More information about the R-sig-mixed-models
mailing list