[R] help: trouble using lines()
Petr Pikal
petr.pikal at precheza.cz
Thu Aug 24 17:46:38 CEST 2006
Hi
I have no experience with lmer and its plotting method. However If it
uses plain (not grid) graphics you maybe shall consult abline and/or
segments.
If it uses grid, you shall consult panel.abline from lattice package.
BTW. Better to copy your answer every time to the list as somebody
from BigBoys can definitely be able to answer questions with more
intuition than myself.
HTH
Petr
On 24 Aug 2006 at 16:34, Simon Pickett wrote:
Date sent: Thu, 24 Aug 2006 16:34:57 +0100 (BST)
Subject: Re: [R] help: trouble using lines()
From: "Simon Pickett" <S.Pickett at exeter.ac.uk>
To: "Petr Pikal" <petr.pikal at precheza.cz>
> Hi,
> I have a model with a three way interaction
> f2<- lmer(late.growth ~ mtf+year+treat+hatch.day+ hatch.day:year+
> hatch.day:treat+ mtf:treat+ treat:year+ year:treat:mtf+(1|fybrood),
> data = A) (one continuous and two factors) and so I wanted to plot the
> fitted values of the model for each of the two factor levels. Copying
> the technique of the pdf I mentioned "Linear mixed models in R" by
> Sřren Feodor Nielsen 20003.
> http://cran.r-project.org/doc/contrib/Fox-Companion/appendix-mixed-mod
> els.pdf#search=%22Linear%20mixed%20models%20in%20R%22. I plotted the
> fitted values against the continuous variable. Now I plan to put lines
> on the existing plot for each of the combinations of the factors I
> have. where tmp[1] and tmp[2] are coefficients from the model... I was
> under the impression that lines(y,exp(tmp[1]+tmp[2])) would give me a
> line, but it doesnt work... thanks again
>
>
> > Hi
> >
> > from lines help page
> >
> > x, y coordinate vectors of points to join.
> >
> > and lines or points simply adds lines or points to existing plot.
> > What do you want to plot with lines?
> >
> > HTH
> > Petr
> >
> >
> >
> > On 24 Aug 2006 at 14:52, Simon Pickett wrote:
> >
> > Date sent: Thu, 24 Aug 2006 14:52:09 +0100 (BST)
> > From: "Simon Pickett" <S.Pickett at exeter.ac.uk>
> > To: "Petr Pikal" <petr.pikal at precheza.cz>
> > Copies to: r-help at stat.math.ethz.ch, Simon Pickett
> > <s.pickett at exeter.ac.uk>
> > Subject: Re: [R] help: trouble using lines()
> >
> >> Hi, thanks for replying.
> >> No, there arent any NA's in the original data set....
> >> I think I must be mis-interpreting the use of lines()?
> >> in the example what exactly is "y"?
> >> lines(y,exp(tmp[1]+tmp[2]))
> >> In my case tmp[1] and tmp[2] are coeficients from the model so just
> >> one number (not a vector) and I havent specified y.... Thanks
> >> everyone, Simon
> >>
> >>
> >> > Hi
> >> >
> >> > not sure but are there some NA values in your data?
> >> >
> >> > what
> >> >
> >> > length(mtf)
> >> > and
> >> > length(fitted(f2))
> >> >
> >> > tells you?
> >> >
> >> > And you need not to use assignment
> >> >
> >> > graph1 <- plot(....)
> >> >
> >> > to output a plot on screen.
> >> >
> >> >
> >> > HTH
> >> > Petr
> >> >
> >> >
> >> > On 24 Aug 2006 at 13:43, Simon Pickett wrote:
> >> >
> >> > Date sent: Thu, 24 Aug 2006 13:43:18 +0100 (BST)
> >> > From: "Simon Pickett" <S.Pickett at exeter.ac.uk>
> >> > To: R-help at stat.math.ethz.ch
> >> > Subject: [R] help: trouble using lines()
> >> >
> >> >> Hi R experts,
> >> >> I have been using ReML as follows...
> >> >> model<-lmer(late.growth~mtf+year+treat+hatch.day+hatch.day:year+
> >> >> hat ch. day:treat+ mtf:treat+ treat:year+
> >> >> year:treat:mtf+(1|fybrood), data > A) then I wanted to plot the
> >> >> results of the three way interaction using lines() as follows...
> >> >>
> >> >> tmp<-as.vector(fixef(model))
> >> >> graph1<-plot(mtf,fitted(f2), xlab=list("Brood Size"),
> >> >> ylab=list("Early growth rate"), pch=16, col="darkgrey",
> >> >> bg="yellow") lines(y,exp(tmp[1]+tmp[2]))
> >> >>
> >> >> but no matter what I try I always get the error message
> >> >> "Error in xy.coords(x, y) : 'x' and 'y' lengths differ"
> >> >>
> >> >> Can anyone shed some light please?
> >> >> I am basically copying the methods of the pdf entitled "Linear
> >> >> mixed models in R" by Sřren Feodor Nielsen 20003.
> >> >> http://cran.r-project.org/doc/contrib/Fox-Companion/appendix-mix
> >> >> ed- mod els.pdf#search=%22Linear%20mixed%20models%20in%20R%22
> >> >>
> >> >>
> >> >>
> >> >>
> >> >>
> >> >> Simon Pickett
> >> >> PhD student
> >> >> Centre For Ecology and Conservation
> >> >> Tremough Campus
> >> >> University of Exeter in Cornwall
> >> >> TR109EZ
> >> >> Tel 01326371852
> >> >>
> >> >> ______________________________________________
> >> >> R-help at stat.math.ethz.ch 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.
> >> >
> >> > Petr Pikal
> >> > petr.pikal at precheza.cz
> >> >
> >> >
> >>
> >>
> >> Simon Pickett
> >> PhD student
> >> Centre For Ecology and Conservation
> >> Tremough Campus
> >> University of Exeter in Cornwall
> >> TR109EZ
> >> Tel 01326371852
> >>
> >> ______________________________________________
> >> R-help at stat.math.ethz.ch 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.
> >
> > Petr Pikal
> > petr.pikal at precheza.cz
> >
> >
>
>
> Simon Pickett
> PhD student
> Centre For Ecology and Conservation
> Tremough Campus
> University of Exeter in Cornwall
> TR109EZ
> Tel 01326371852
>
Petr Pikal
petr.pikal at precheza.cz
More information about the R-help
mailing list