Learn R Programming

PHYLOGR (version 1.0.11)

lm.phylog: 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

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.

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.

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

Run this code
# NOT RUN {
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)


# }

Run the code above in your browser using DataLab