domingo, 13 de septiembre de 2009

regresion lineal

smooth relationships (Bolker 2007_ Ecological Models and Data in R)

  • ˆ R incorporates two slightly different versions of robust locally weightedregression (lowess and loess). This algorithm runs linear or quadratic regressions on successive chunks of the data to produce a smooth curve. lowess has an adjustable smoothness parameter (in this case the proportion of points included in the “neighborhood” of each point when smoothing) that lets you choose curves ranging from smooth lines that ignore a lot of the variation in the data to wiggly lines that pass through every point: in Figure 2.8a, I used the default value (lines(lowess(Initial,Killed))).
  • ˆ Figure 2.8a also shows a spline fit to the data which uses a series of cubic curves to fit the data. Splines also have a smoothing parameter, the degrees of freedom or number of different piecewise curves fitted to the data; in this case I set the degrees of freedom to 5 (the default here would be 2) to get a slightly more wiggly curve (smooth.spline(Initial, Killed,df = 5)).
  • ˆ Simpler possibilities include just drawing a straight line between the mean values for each initial density (using tapply(Killed,Initial,mean) to calculate the means and unique(Initial) to get the non-repeated values of the initial density), or plotting the results of a linear or quadratic regression of the data (not shown: see the R supplement). I plotted straight lines between the means in Figure 2.8b because local robust regression and splines worked poorly.

No hay comentarios:

Publicar un comentario

Libros para descargar (gratis) sobre Diseño y Análisis Experimental