Fit a linear model to the data from a read.sim.data.
lm.phylog(formula, data, max.num=0, weights=NULL, exclude.tips=NULL,
lapply.size=100)
a formula with the same syntax as for any other linear model in R (see help for lm: ?lm).
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.
if different from 0, maximum number of simulations to analyze
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).
an optional vector giving the names of tips to exclude from the analyses.
a tuning parameter that can affect the speed of calculations; see Details
A list of class phylog.lm with components
the function call.
a data frame with the fitted coefficients for that model; the coefficients for the non-simulated (''real'') data correspond to sim.counter=0.
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.
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.
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.
# 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