I am having trouble extracting residuals from Major Axis and  
Standardized Major Axis fits, using the smatr package. I wish to  
understand the relationship between density of wood in twigs and  
trunks, and how the slope of their relationship varies among sites,  
among families, and with tree size. These variance-partitioning  
desires push the analysis toward a mixed model framework. However, I  
am not interested in predicting twig density from trunk density, nor  
vice-versa. Rather, I'm interested in the slope of their allometric  
relationship. This makes a Major Axis fit highly desirable. However,  
slope.com() in the smatr package accepts only one grouping variable at  
a time (and no continuous covariates). Therefore, I've decided to fit  
the twig-trunk relationship with line.cis() and extract the residuals  
for a mixed model analysis in lm().

Which brings me to the problem: residuals calculated perpendicular to  
the best fit line (as are minimized in MA) are not well behaved. They  
have a mean of 0, but they are biased with respect to the variable  
used as X (see example below). if X and Y are positively correlated,  
they have negative slope.

How then should I proceed? How can I extract unbiased residuals from a  
MA or SMA fit?  It may not be possible, and I may have to revert to  
doing the entire analysis in a predictive lm() framework, but I'd  
prefer not to have to do that.

Any advice would be appreciated!
--tim


Sample code illustrating the situation follows:
library(smatr)
par(mfrow  = c(1, 3), pty = "s")
x <- 1:100 + 50 * runif(100)
y <- 1:100 + 50 * runif(100)
z <- data.frame(x = x, y = y)
plot(z)
lm_xy <- lm(z$y ~ z$x)
abline(lm_xy, col = "blue")
z$lm_resid <- z$y - (z$x * coef(lm_xy)[2])  - coef(lm_xy)[1]

ma_xy <- line.cis(y = z$y, x = z$x, method = 2)
abline(ma_xy[1,1], ma_xy[2,1], col = "red")
z$ma_resid <- (z$y - (ma_xy[2,1] * z$x) - ma_xy[1,1])/ 
sqrt((ma_xy[2,1])^2 + 1)

plot(z$x, z$lm_resid)
abline(lm(z$lm_resid ~ z$x), col = "blue")
plot(z$x, z$ma_resid)
abline(lm(z$ma_resid ~ z$x), col = "red")
abline(h = 0, col = "gray")


______________________
C. E. Timothy Paine
Postdoctoral Researcher
UMR Ecologie des FĂ´rets de Guyane - EcoFoG
Kourou, French Guiana
[EMAIL PROTECTED]
(+594) 594 32 92 71
Skype: cetimothypaine
968 species of rainforest trees... manuplants.org


        [[alternative HTML version deleted]]

______________________________________________
R-help@r-project.org 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