[R-sig-ME] Unexpected text-output using BY to plot random effects.
Dimitris Rizopoulos
d.rizopoulos at erasmusmc.nl
Tue Sep 16 15:27:36 CEST 2008
abline() does not return anything, it justs adds lines to the existing
plot; this is why you obtain NULL from the by() statement. One option to
avoid printing is to use invisible(), e.g.,
invisible(by(sleep, sleep$resp, function(x) abline(coef=x)))
I hope it helps.
Best,
Dimitris
Rense Nieuwenhuis wrote:
> Dear Helpers,
>
> I have been trying to visualise the random effects of a mixed effects
> model which was fitted with the lmer function from the lme4 package.
> Extracting the fixed and random effects works rather well with
> 'coef', but when plotting this with 'by' and 'abline', something
> strange happens.
>
> I use the following syntax (example):
>
> fm1 <- lmer(Reaction ~ Days + (Days|Subject), sleepstudy)
>
> sleep <- coef(fm1)$Subject
> sleep$resp <- 1:18
>
> plot(c(0,10), c(200,400), type="n")
>
> by(sleep, resp, function(x) abline(coef=x))
>
> This results in a basic, but acceptable, plot. However, it also
> results in quite some output at the R-Prompt. A portion of it looks
> like this:
>
> resp: 308
> NULL
> -----------------------------------------------------
> resp: 309
> NULL
> -----------------------------------------------------
> resp: 310
> NULL
> -----------------------------------------------------
> resp: 330
> NULL
> -----------------------------------------------------
> resp: 331
> NULL
> -----------------------------------------------------
> resp: 332
> NULL
>
>
> What is happening? I suspect it has something to do with my use of
> the 'by' function, but is there a way to prevent all the unwanted
> text-output?
>
> Thanks in advance
>
> Rense
>
>
>
>
>
> - - -- --- ----- --------
> Rense Nieuwenhuis
> +31 6 481 05 683
>
> www.rensenieuwenhuis.nl
>
>
> [[alternative HTML version deleted]]
>
> _______________________________________________
> R-sig-mixed-models at r-project.org mailing list
> https://stat.ethz.ch/mailman/listinfo/r-sig-mixed-models
>
--
Dimitris Rizopoulos
Assistant Professor
Department of Biostatistics
Erasmus University Medical Center
Address: PO Box 2040, 3000 CA Rotterdam, the Netherlands
Tel: +31/(0)10/7043478
Fax: +31/(0)10/7043014
More information about the R-sig-mixed-models
mailing list