lm.phylog {PHYLOGR}R Documentation

Linear Models from Simulated Data Sets

Description

Fit a linear model to the data from a read.sim.data.

Usage

lm.phylog(formula, data, max.num=0, weights=NULL, exclude.tips=NULL,
          lapply.size=100)

Arguments

formula

a formula with the same syntax as for any other linear model in R (see help for lm: ?lm).

data

a data frame —with a particular structure— with the observations; it will often be the name of a data frame created using read.sim.data.

max.num

if different from 0, maximum number of simulations to analyze

weights

an optional vector of weights to perform weighted least squares; can be a column from the data frame or a vector in the parent environment (of same length as any column of data before the data is reduced, if appropriate, with exclude.tips and max.num arguments).

exclude.tips

an optional vector giving the names of tips to exclude from the analyses.

lapply.size

a tuning parameter that can affect the speed of calculations; see Details

Details

This function uses a loop over lapply calls (I got the idea from Venables and Ripley (2000), ”S programming”). By changing the lapply.size you can change the size of the block over which lapply is used. Changes can make a difference in speed; for instance, in my machine from about 1 sec per simulation for a set with 49 species to less than 0.5 sec. The default value worked well in my machine, but your mileage will vary.

Value

A list of class phylog.lm with components

call

the function call.

Fits

a data frame with the fitted coefficients for that model; the coefficients for the non-simulated (”real”) data correspond to sim.counter=0.

MarginalTests

a data frame with the F-tests. The first column is the overall F-test for the model, the rest are the marginal F-tests, respecting the marginality principle or hierarchy of terms included. The coefficients for the non-simulated (”real”) data correspond to sim.counter=0.

Note

The marginal F-tests returned are obtained from drop1, and thus respect the marginality principle. For instance, if your model is y \sim x1 + x2*x3 you will see an F for x1 and an F for x2:x3 but no F's for x2 or x3. Discussion can be found, for example, in Venables & Ripley, (1999), ch. 6; see also Searle, (1987), ch. 6, for the ANCOVA case.

Author(s)

Ramon Diaz-Uriarte and Theodore Garland, Jr.

References

Diaz-Uriarte, R., and Garland, T., Jr., in prep. PHYLOGR: an R package for the analysis of comparative data via Monte Carlo simulations and generalized least squares approaches.

Searle, S. R. (1987) Linear models for unbalanced data. Wiley

Venables, W. N. and Ripley, B. D. (1999) Modern applied statistics with S-Plus, 3rd ed. Springer-Verlag.

Venables, W. N. and Ripley, B. D. (2000) S programming. Springer-Verlag.

See Also

summary.phylog.lm, plot.phylog.lm,read.sim.data, drop1

Examples

data(SimulExample)
ex1.lm <- lm.phylog(y ~ x1+diet, weights=x2, max.num=20,
                    exclude.tips=c("La","Ls"), data=SimulExample)
ex1.lm
summary(ex1.lm)
par(mfrow=c(2,2))
plot(ex1.lm)



[Package PHYLOGR version 1.0.11 Index]