HI all, I am using the nlme package to learn multilevel models, and following examples from the textbook "Discovering Statistics Using R" when it happened.
[Mixed Models Code][1] The data set is Honeymoon Period.dat, also downloadable under their companion website. [Data Set - Multilevel Models][2] require(nlme) require(reshape2) satisfactionData = read.delim("Honeymoon Period.dat", header = TRUE) restructuredData<-melt(satisfactionData, id = c("Person", "Gender"), measured = c("Satisfaction_Base", "Satisfaction_6_Months", "Satisfaction_12_Months", "Satisfaction_18_Months")) names(restructuredData)<-c("Person", "Gender", "Time", "Life_Satisfaction") #print(restructuredData) #restructuredData.sorted<-restructuredData[order(Person),] intercept <-gls(Life_Satisfaction~1, data = restructuredData, method = "ML", na.action = na.exclude) randomIntercept <-lme(Life_Satisfaction ~1, data = restructuredData, random = ~1|Person, method = "ML", na.action = na.exclude, control = list(opt="optim")) anova(intercept, randomIntercept) timeRI<-update(randomIntercept, .~. + Time) timeRS<-update(timeRI, random = ~Time|Person) ARModel<-update(timeRS, correlation = corAR1(0, form = ~Time|Person)) The error occured at this moment, when I am trying to update "timeRS" model. The error is as follows: Error in as.character.factor(X[[i]], ...) : malformed factor Help would be appreciated. Thanks! [1]: https://studysites.uk.sagepub.com/dsur/study/DSUR%20R%20Script%20Files/Chapter%2019%20DSUR%20Mixed%20Models.R [2]: https://studysites.uk.sagepub.com/dsur/study/articles.htm Regards, Yoke Yong [[alternative HTML version deleted]] ______________________________________________ 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.