]> git.donarmstrong.com Git - ape.git/blob - man/lmorigin.Rd
9ed8b855fd77e5f902ac05857513d191c452a5e0
[ape.git] / man / lmorigin.Rd
1 \name{lmorigin}
2 \alias{lmorigin}
3 \alias{print.lmorigin}
4 \alias{lmorigin.ex1}
5 \alias{lmorigin.ex2}
6 \title{ Multiple regression through the origin }
7 \description{
8 Function \code{\link{lmorigin}} computes a multiple linear regression and performs tests of significance of the equation parameters (F-test of R-square and t-tests of regression coefficients) using permutations.
9
10 The regression line can be forced through the origin. Testing the significance in that case requires a special permutation procedure. This option was developed for the analysis of independent contrasts, which requires regression through the origin. A permutation test, described by Legendre & Desdevises (2009), is needed to analyze contrasts that are not normally distributed.
11 }
12 \usage{
13 lmorigin(formula, data, origin=TRUE, nperm=999, method=NULL, silent=FALSE)
14 }
15
16 \arguments{
17   \item{formula }{ A formula specifying the bivariate model, as in
18   \code{\link{lm}} and \code{\link{aov}}. }
19   \item{data}{ A data frame containing the two variables specified in the formula. }
20   \item{origin}{ \code{origin = TRUE} (default) to compute regression through the origin; \code{origin = FALSE} to compute multiple regression with estimation of the intercept. }
21   \item{nperm}{ Number of permutations for the tests. If \code{nperm =
22    0}, permutation tests will not be computed. The default value is \code{nperm = 999}. For large data files, the permutation test is rather slow since the permutation procedure is not compiled. }
23   \item{method}{ \code{method = "raw"} computes t-tests of the regression coefficients by permutation of the raw data. \code{method = "residuals"} computes t-tests of the regression coefficients by permutation of the residuals of the full model. If \code{method = NULL}, permutation of the raw data is used to test the regression coefficients in regression through the origin; permutation of the residuals of the full model is used to test the regression coefficients in ordinary multiple regression. }
24   \item{silent}{ Informative messages and the time to compute the tests will not be written to the R console if silent=TRUE. Useful when the function is called by a numerical simulation function. }
25 }
26
27 \details{
28 The permutation F-test of R-square is always done by permutation of the raw data. When there is a single explanatory variable, permutation of the raw data is used for the t-test of the single regression coefficient, whatever the method chosen by the user. The rationale is found in Anderson & Legendre (1999).
29
30 The \code{print.lmorigin} function prints out the results of the parametric tests (in all cases) and the results of the permutational tests (when nperm > 0).
31 }
32
33 \value{
34
35   \item{reg }{The regression output object produced by function \code{lm}. }
36   \item{p.param.t.2tail }{Parametric probabilities for 2-tailed tests of the regression coefficients. }
37   \item{p.param.t.1tail }{Parametric probabilities for 1-tailed tests of the regression coefficients. Each test is carried out in the direction of the sign of the coefficient. }
38   \item{p.perm.t.2tail }{Permutational probabilities for 2-tailed tests of the regression coefficients. }
39   \item{p.perm.t.1tail }{Permutational probabilities for 1-tailed tests of the regression coefficients. Each test is carried out in the direction of the sign of the coefficient. }
40   \item{p.perm.F }{Permutational probability for the F-test of R-square. }
41   \item{origin }{TRUE is regression through the origin has been computed, FALSE if multiple regression with estimation of the intercept has been used. }
42   \item{nperm }{Number of permutations used in the permutation tests. }
43   \item{method }{Permutation method for the t-tests of the regression coefficients: \code{method = "raw"} or \code{method = "residuals"}.  }
44   \item{var.names }{Vector containing the names of the variables used in the regression. }
45   \item{call }{The function call.}
46 }
47
48 \author{ Pierre Legendre, Universite de Montreal }
49
50 \references{
51 Anderson, M. J. and Legendre, P. (1999) An empirical comparison of permutation methods for tests of partial regression coefficients in a linear model. \emph{Journal of Statistical Computation and Simulation}, \bold{62}, 271--303.
52
53 Legendre, P. and Desdevises, Y. (2009) Independent contrasts and regression through the origin. \emph{Journal of Theoretical Biology}, \bold{259}, 727--743.
54
55 Sokal, R. R. and Rohlf, F. J. (1995) \emph{Biometry - The principles and
56   practice of statistics in biological research. Third edition.} New
57   York: W. H. Freeman.
58 }
59
60 \examples{
61 ## Example 1 from Sokal & Rohlf (1995) Table 16.1
62 ## SO2 air pollution in 41 cities of the USA
63 data(lmorigin.ex1)
64 out <- lmorigin(SO2 ~ ., data=lmorigin.ex1, origin=FALSE, nperm=99)
65 out
66
67 ## Example 2: Contrasts computed on the phylogenetic tree of Lamellodiscus
68 ## parasites. Response variable: non-specificity index (NSI); explanatory
69 ## variable: maximum host size. Data from Table 1 of Legendre & Desdevises
70 ## (2009).
71 data(lmorigin.ex2)
72 out <- lmorigin(NSI ~ MaxHostSize, data=lmorigin.ex2, origin=TRUE, nperm=99)
73 out
74
75 ## Example 3: random numbers
76 y <- rnorm(50)
77 X <- as.data.frame(matrix(rnorm(250),50,5))
78 out <- lmorigin(y ~ ., data=X, origin=FALSE, nperm=99)
79 out
80
81 }
82
83 \keyword{ multivariate }