[R-sig-ME] Fwd: Error using nlme; Malformed factors

Wong Yoke Yong yokeyong.wong at gmail.com
Thu Dec 22 02:09:05 CET 2016

Hi all,

Please refer to the attached message.

Yoke Yong

---------- Forwarded message ----------
From: Wong Yoke Yong <yokeyong.wong at gmail.com>
Date: Wed, Dec 21, 2016 at 10:24 AM
Subject: Error using nlme; Malformed factors
To: r-help at r-project.org

HI all,

I am using the nlme package to learn multilevel models, and following
examples from the textbook "Discovering Statistics Using R" when it

[Mixed Models Code][1]

The data set is Honeymoon Period.dat, also downloadable under their
companion website.

[Data Set - Multilevel Models][2]

    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",


    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 =
    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%
  [2]: https://studysites.uk.sagepub.com/dsur/study/articles.htm

Yoke Yong

	[[alternative HTML version deleted]]

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