[R-sig-eco] Random factor and MANOVA (Aitor Larranaga)
Dear all, I have an experimental design with two fixed factors and a blocking factor (random) and I have data on several response variables for which I want to perform a MANOVA. After creating a matrix with the variables I want to be included in the MANOVA with Y-cbind(variableA, variableB... variableN), I ask for the linear model model-manova(lme(Y~factor1*factor2,random=~1|Block)) What creates an output that seems to be correct for a MANOVA. Df Wilks approx Fnum Df den DfPr(F) factor1 1 0.61909 7.2808 6 71 4.393e-06 *** factor2 1 0.92156 1.0072 6 71 0.4277 factor1:factor2 1 0.90012 1.3131 6 71 0.2627 Residuals 76 --- Signif. codes: 0 ?***? 0.001 ?**? 0.01 ?*? 0.05 ?.? 0.1 ? ? 1 Nevertheless. I've been told that random factors cannot be included in a Manova models. Is this true? And if it is, what is the reason and what does R do with the model I've written then? Many thanks, Aitor ___ R-sig-ecology mailing list R-sig-ecology@r-project.org https://stat.ethz.ch/mailman/listinfo/r-sig-ecology
[R-sig-eco] lines() adds extra line
I'm trying a bit of an experiment with polynomial curve fitting (don't worry, I wouldn't do this to actual data -- it's just a toy model for a specific question). When I generate a linear model of the data and plot it using plot(), everything works fine. But when I use plot(..., type=l) or lines(), I get an extra line connecting two points. How do I stop this from happening? Here's the code: x = seq(-10, 10, by=0.1) data1poly - 0.1*x + 0.2*x^2 + 0.3*x^3 + 0.4*x^4 + 0.5*x^5 + 0.6*x^6 + 0.7 + rnorm(length(x),1E-3, 1E-4) data2poly - 0.1*x + 0.2*x^2 + 0.3*x^3 + 0.4*x^4 + 0.5*x^5 + 0.6*x^6 - 1 + rnorm(length(x), 1E-3, 1E-4) dataBoth.poly - c(data1poly, data2poly) #Works well plot(c(x,x), predict(lm(dataBoth.poly ~ c(x,x) + I(c(x,x)^2)+I(c(x,x)^3)+I(c(x,x)^4)+I(c(x,x)^5)+I(c(x,x)^6 #Adds extra line plot(c(x,x), predict(lm(dataBoth.poly ~ c(x,x) + I(c(x,x)^2)+I(c(x,x)^3)+I(c(x,x)^4)+I(c(x,x)^5)+I(c(x,x)^6))), type=l) #or lines(c(x,x), predict(lm(dataBoth.poly ~ c(x,x) + I(c(x,x)^2)+I(c(x,x)^3)+I(c(x,x)^4)+I(c(x,x)^5)+I(c(x,x)^6 Thanks, Jane -- - Jane Shevtsov Ecology Ph.D. candidate, University of Georgia co-founder, www.worldbeyondborders.org Check out my blog, http://perceivingwholes.blogspot.comPerceiving Wholes The whole person must have both the humility to nurture the Earth and the pride to go to Mars. --Wyn Wachhorst, The Dream of Spaceflight ___ R-sig-ecology mailing list R-sig-ecology@r-project.org https://stat.ethz.ch/mailman/listinfo/r-sig-ecology
Re: [R-sig-eco] lines() adds extra line
R is doing just as you asked. If you look at the middle of c(x, x) the x values jump from 10 to -10 and R draws the line segment connecting them, as it's been told. c(x,x)[195:205] [1] 9.4 9.5 9.6 9.7 9.8 9.9 10.0 -10.0 -9.9 -9.8 -9.7 You might rather have: x2.rev - c(x, rev(x)) x.rev.pred - predict(lm(dataBoth.poly ~ x2.rev + I(x2.rev^2)+I(x2.rev^3)+I(x2.rev^4)+I(x2.rev^5)+I(x2.rev^6))) plot(x2.rev, x.rev.pred, type=l) Sarah On Mon, Jan 24, 2011 at 1:04 PM, Jane Shevtsov jane@gmail.com wrote: I'm trying a bit of an experiment with polynomial curve fitting (don't worry, I wouldn't do this to actual data -- it's just a toy model for a specific question). When I generate a linear model of the data and plot it using plot(), everything works fine. But when I use plot(..., type=l) or lines(), I get an extra line connecting two points. How do I stop this from happening? Here's the code: x = seq(-10, 10, by=0.1) data1poly - 0.1*x + 0.2*x^2 + 0.3*x^3 + 0.4*x^4 + 0.5*x^5 + 0.6*x^6 + 0.7 + rnorm(length(x),1E-3, 1E-4) data2poly - 0.1*x + 0.2*x^2 + 0.3*x^3 + 0.4*x^4 + 0.5*x^5 + 0.6*x^6 - 1 + rnorm(length(x), 1E-3, 1E-4) dataBoth.poly - c(data1poly, data2poly) #Works well plot(c(x,x), predict(lm(dataBoth.poly ~ c(x,x) + I(c(x,x)^2)+I(c(x,x)^3)+I(c(x,x)^4)+I(c(x,x)^5)+I(c(x,x)^6 #Adds extra line plot(c(x,x), predict(lm(dataBoth.poly ~ c(x,x) + I(c(x,x)^2)+I(c(x,x)^3)+I(c(x,x)^4)+I(c(x,x)^5)+I(c(x,x)^6))), type=l) #or lines(c(x,x), predict(lm(dataBoth.poly ~ c(x,x) + I(c(x,x)^2)+I(c(x,x)^3)+I(c(x,x)^4)+I(c(x,x)^5)+I(c(x,x)^6 Thanks, Jane -- -- Sarah Goslee http://www.functionaldiversity.org ___ R-sig-ecology mailing list R-sig-ecology@r-project.org https://stat.ethz.ch/mailman/listinfo/r-sig-ecology