[R-sig-eco] Ancova Plot R

Philippi, Tom tom_philippi at nps.gov
Tue Mar 17 06:37:43 CET 2015


Luis--
I assume that especie is a factor, else it would be multiple regression.
You do not give much information on what you want your graph to look like.
If you want the linear regression line for each especie, with confidence
bands around those lines, you can use ggplot2 (untested code):
library(ggplot2)
a$lPeso <- log(Peso)
p <- gplot(a,aes(x=Radio,y=lPeso)) + geom_point(aes(color=especie))
p + geom_smooth(aes(group=especie),method='lm')

I hope that this gets you started in the right direction.

Tom 2

On Mon, Mar 16, 2015 at 9:38 PM, Luis Fernando García <luysgarcia at gmail.com>
wrote:

> Dear R users.
>
> I have an urgent question to make you, hopefully you can help me.
>
> This is my first time making an ancova test in R. I have finished the model
> design and now I need to plot it. I have found several online sources where
> the mechanics for plotting data is explained, nevertheless all of these
> explain the mechanics for plotting the data when there is no interacion
> which is not my case. I was thinking to subset the data following this
> example (
>
> http://r-eco-evo.blogspot.com/2011/08/comparing-two-regression-slopes-by.html
> ),
> but I do not know if it will be the best choice.
>
> If some of you could suggest me a document which explains this in detail or
> may be help me with the data set,
>
> > a<-read.table ("test1ancova.txt", header=T)
> > attach(a)
> > names(a)
> > fit3<-lm(log(Peso) ~ especie * Radio)
> > summary(fit2)
>
> Call:
> lm(formula = log(Peso) ~ especie * Radio)
>
> Residuals:
>      Min       1Q   Median       3Q      Max
> -1.15349 -0.29033  0.04444  0.39277  1.41267
>
> Coefficients:
>                   Estimate Std. Error t value Pr(>|t|)
> (Intercept)         2.0610     0.2050  10.054 5.84e-11 ***
> especieNops         1.8253     0.3002   6.080 1.28e-06 ***
> Radio               0.3827     0.1414   2.707   0.0113 *
> especieNops:Radio  -0.3749     0.1438  -2.608   0.0142 *
> ---
> Signif. codes:  0 ‘***’ 0.001 ‘**’ 0.01 ‘*’ 0.05 ‘.’ 0.1 ‘ ’ 1
>
> Residual standard error: 0.5418 on 29 degrees of freedom
> Multiple R-squared:  0.7005,    Adjusted R-squared:  0.6695
> F-statistic: 22.61 on 3 and 29 DF,  p-value: 9.578e-08
>
>
> >  plot(a$Radio,a$Peso, type="n",xlab="Ratio", ylab="Weight")
> >  points(a$Radio[1:15], a$Peso[1:15], col="red")
> >  points(a$Radio[16:30], a$Peso[16:30], col="blue")
>
> Any help will be really appreciated!
>
> Thanks in advance
>
> _______________________________________________
> R-sig-ecology mailing list
> R-sig-ecology at r-project.org
> https://stat.ethz.ch/mailman/listinfo/r-sig-ecology
>

	[[alternative HTML version deleted]]



More information about the R-sig-ecology mailing list