###############################################################################
# Clear memory and set the working directory and the seed ############################################################################### rm(list = ls()) setwd("/Dropbox/LMER/R ") set.seed(7010) ############################################################################### # Load up needed packages and do a require ############################################################################### # install.packages("gdata") library(nlme) library(lme4) nsample = 1000 # Number of subjects n.longitudinal.observations = 5 # number of observations per subject ############################################################################### # Set the other parameters ############################################################################### id.pat = rep(seq(1:nsample), each =n.longitudinal.observations) time = rep(seq(1:n.longitudinal.observations)-1, nsample) age = rnorm(nsample, mean = 36, sd = .8) id.age = rep(seq(1: n.longitudinal.observations), each =age) ############################################################################### MODEL WITHOUT AGE boldBeta_individual_blup = coef(lmer(yy~1+time+(time|id.pat) ))$id.pat #mixed model ############################################################################### MODEL WITH AGE boldBeta_individual_blup = coef(lmer(yy~1+age+time+(time|id.pat) ))$id.pat #mixed model Dear all, I’m trying to use LMER in my simulation problem, and I’m having problems ate the very begging L I’m new in LMER. Can you please help me? 1st problem: how do I generate age so I can use it as a fixed factor? 2nd problem: how do I insert age as a fixed factor? 3rd problem: what if I wanted to insert a 2nd random effect based on age? Best, RO Atenciosamente, Rosa Oliveira -- ____________________________________________________________________________ Rosa Celeste dos Santos Oliveira, E-mail: rosit...@gmail.com Tlm: +351 939355143 Linkedin: https://pt.linkedin.com/in/rosacsoliveira ____________________________________________________________________________ "Many admire, few know" Hippocrates ______________________________________________ R-help@r-project.org mailing list -- To UNSUBSCRIBE and more, see https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.