On 11 Aug 2006 at 10:33, Simon Pickett wrote:

Date sent:              Fri, 11 Aug 2006 10:33:46 +0100 (BST)
From:                   "Simon Pickett" <[EMAIL PROTECTED]>
To:                     [email protected]
Subject:                [R] help: convert lmer.coef to matrix

> Hi all,
> I am trying to coerce the coeficients from a REML using lmer() to a
> matrix
> of numbers which I can then write into excel. I have looked in the
> archive
> and read around in the (Matrix) documentation but havent found
> anything of
> use.
> Any suggestions much appreciated,
> Thankyou, S.
> 

I would suggest something like this:

library(lme4)
data(sleepstudy)
(fm1 <- lmer(Reaction ~ Days + (Days|Subject), sleepstudy))
lmer.coef <- fixef(fm1)

# save coefficients columnwise
# keep in mind that dec="," is needed to fulfil the requirements of 
my German version of MS-Excel
lmer.out.mat<-matrix(lmer.coef,ncol=length(lmer.coef))
write.table(lmer.out.mat,file="d:/lmer_out.csv",sep=";",dec=",",col.na
mes=names(lmer.coef),row.names=F)

# save coefficients rowwise
lmer.out.df<-as.data.frame(lmer.coef)
write.table(lmer.out.df,file="d:/lmer_out.csv",sep=";",dec=",",row.nam
es=T,col.names=F)

Is that what you are looking for?       

Bernd

______________________________________________
[email protected] 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.

Reply via email to