Last data update: 2014.03.03

R: Model II regression
lmodel2R Documentation

Model II regression

Description

This function computes model II simple linear regression using the following methods: ordinary least squares (OLS), major axis (MA), standard major axis (SMA), and ranged major axis (RMA). The model only accepts one response and one explanatory variable.

Usage

lmodel2(formula, data = NULL, range.y=NULL, range.x=NULL, nperm=0)

Arguments

formula

A formula specifying the bivariate model, as in lm and aov.

data

A data frame containing the two variables specified in the formula.

range.y, range.x

Parametres for ranged major axis regression (RMA). If range.y = NULL and range.x = NULL, RMA will not be computed. If only one of them is NULL, the program will stop. If range.y = "relative": variable y has a true zero (relative-scale variable). If range.y = "interval": variable y possibly includes negative values (interval-scale variable). If range.x = "relative": variable x has a true zero (relative-scale variable). If range.x = "interval": variable x possibly includes negative values (interval-scale variable)

nperm

Number of permutations for the tests. If nperm = 0, tests will not be computed.

Details

Model II regression should be used when the two variables in the regression equation are random, i.e. not controlled by the researcher. Model I regression using least squares underestimates the slope of the linear relationship between the variables when they both contain error. Ordinary least squares (OLS) is, however, appropriate in some cases as a model II regression model; see the “Model II User's guide, R edition” which you can read using command vignette("mod2user").

The model II regression methods of ordinary least squares (OLS), major axis (MA), standard major axis (SMA), and ranged major axis (RMA) are described in Legendre and Legendre (1998, Section 10.3.2). OLS, MA, and SMA are also described in Sokal and Rohlf (1995). The PDF document “Model II User's guide, R edition” provided with this function contains a tutorial for model II regression, and can be read with command vignette("mod2user").

The plot function plots the data points together with one of the regression lines, specified by method="OLS", method="MA" (default), method="SMA", or method="RMA", and its 95 percent confidence interval.

Value

The default output provides the regression output. It draws information from a list, produced by function lmodel2, which contains the following elements:

y

The response variable.

x

The explanatory variable.

regression.results

A table with rows corresponding to the four regression methods. Column 1 gives the method name, followed by the intercept and slope estimates, the angle between the regression line and the abscissa, and the permutational probability (one-tailed, for the tail corresponding to the sign of the slope estimate).

confidence.intervals

A table with rows corresponding to the four regression methods. The method name is followed by the parametric 95 the intercept and slope estimates.

eigenvalues

Eigenvalues of the bivariate dispersion, computed during major axis regression.

H

The H statistic used for computing the confidence interval of the major axis slope. Notation following Sokal and Rohlf (1995).

n

Number of objects.

r

Correlation coefficient.

rsquare

Coefficient of determination (R-square) of the OLS regression.

P.param

2-tailed parametric P-value for the test of r and the OLS slope.

theta

Angle between the two OLS regression lines, lm(y ~ x) and lm(x ~ y).

nperm

Number of permutations for the permutation tests.

epsilon

Any value smaller than epsilon is considered to be zero.

info.slope

Information about the slope notation when r = 0.

info.CI

Information about the confidence limits notation when the slope is infinite.

call

Call of the function.

Note

The package exports only the main functions lmodel2, plot.lmodel2 and lines.lmodel2. Much of the work is done by internal functions which are not directly visible, but you can use triple colon to see or directly use these functions (e.g., lmodel2:::print.lmodel2). Internal functions that perform essential parts of the analysis are MA.reg, SMA.reg, CLma, CLsma and permutest.lmodel2.

Author(s)

Pierre Legendre, Departement de Sciences Biologiques, Universite de Montreal

References

Legendre, P. and L. Legendre. 1998. Numerical ecology, 2nd English edition. Elsevier Science BV, Amsterdam.

Sokal, R. R. and F. J. Rohlf. 1995. Biometry – The principles and practice of statistics in biological research. 3rd edition. W. H. Freeman, New York.

See Also

A tutorial (file “Model II User's guide, R edition”) is provided with this function, and can be read within R session using command vignette("mod2user", package="lmodel2").

Examples

## The example data files are described in more detail in the
## dQuote{Model II User's guide, R edition} tutorial. 

## Example 1 (surgical unit data)
data(mod2ex1)
Ex1.res <- lmodel2(Predicted_by_model ~ Survival, data=mod2ex1, nperm=99)
Ex1.res
plot(Ex1.res) 

## Example 2 (eagle rays and Macomona)
data(mod2ex2)
Ex2.res <- lmodel2(Prey ~ Predators, data=mod2ex2, "relative", "relative", 99)
Ex2.res
op <- par(mfrow = c(1,2))
plot(Ex2.res, "SMA")
plot(Ex2.res, "RMA")
par(op)

## Example 3 (cabezon spawning)
op <- par(mfrow = c(1,2))
data(mod2ex3)
Ex3.res <- lmodel2(No_eggs ~ Mass, data=mod2ex3, "relative", "relative", 99)
Ex3.res
plot(Ex3.res, "SMA")
plot(Ex3.res, "RMA")
par(op)

## Example 4 (highly correlated random variables)
op <- par(mfrow=c(1,2))
data(mod2ex4)
Ex4.res <- lmodel2(y ~ x, data=mod2ex4, "interval", "interval", 99)
Ex4.res
plot(Ex4.res, "OLS")
plot(Ex4.res, "MA")
par(op)

# Example 5 (uncorrelated random variables)
data(mod2ex5)
Ex5.res <- lmodel2(random_y ~ random_x, data=mod2ex5, "interval", "interval", 99)
Ex5.res
op <- par(mfrow = c(2,2))
plot(Ex5.res, "OLS")
plot(Ex5.res, "MA")
plot(Ex5.res, "SMA")
plot(Ex5.res, "RMA")
par(op)

## Example 6 where cor(y,x) = 0 by construct (square grid of points)

y0 = rep(c(1,2,3,4,5),5)
x0 = c(rep(1,5),rep(2,5),rep(3,5),rep(4,5),rep(5,5))
plot(x0, y0)
Ex6 = as.data.frame(cbind(x0,y0))
zero.res = lmodel2(y0 ~ x0, data=Ex6, "relative", "relative")
print(zero.res)
op <- par(mfrow = c(1,2))
plot(zero.res, "OLS")
plot(zero.res, "MA")
par(op)

Results