On 10/3/08, hadley wickham <[EMAIL PROTECTED]> wrote: > On Fri, Oct 3, 2008 at 8:04 AM, eugen pircalabelu > <[EMAIL PROTECTED]> wrote: > > Hi List, > > > > > > I have the following problem: I am using the multilevel package and > make.univ function for available in the package and then xyplot from lattice > and I want to know how could I be able to use the "coefficient" for the > straight line that passes the data ? > > > > Example from help: > > > > library(multilevel) > > data(univbct) #a data set already in univariate or stacked form for job > satisfaction > > TEMP<-univbct[3*1:495,c(22,1:17)] #converting it back to multivariate form > > TEMP2<-make.univ(x=TEMP,dvs=TEMP[,c(10,13,16)]) #transforming it to > univariate form again > > > > > xyplot(MULTDV~TIME|as.factor(SUBNUM),data=TEMP2,type=c("p","r","g"),col="blue",col.line="black",xlab="Time",ylab="SAT") > # taken from Bliese Paul – Multilevel Modeling in R > > > > Now I want to be able to identify those SUBNUM that have a downwards trend > like (for eg SUBNUM 7) without picking them by inspecting the plot. Is there > some way how I could access these coefficients for this apparently regression > line? > > > You'll need to fit the models yourself, and then inspect the > coefficients of the results. Here's one way using the plyr package:
Another option is 'lmList()' in the nlme (or lme4) package: fm <- nlme::lmList(MULTDV~TIME|as.factor(SUBNUM), data=TEMP2, na.action=na.omit) neg <- names(which(sapply(fm, coef)["TIME", ] < 0)) xyplot(MULTDV~TIME|factor(SUBNUM), data=TEMP2, type=c("p","r","g"), col.line="black",subset = (factor(SUBNUM) %in% neg)) -Deepayan > [...] ______________________________________________ R-help@r-project.org mailing list 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.