Calculated specified trend line of x,y

trend.line(x, y, type = "linear", plot = TRUE, ...)

Arguments

x

Vector of x

y

Vector of y

type

Trend line types are: 'linear', 'exponential', 'logarithmic', 'polynomial'

plot

plot results (TRUE/FALSE)

...

Additional arguments passed to plot

Value

A list class object with the following components:

  • for type = 'linear' x is slope and y is intercept

  • for type = 'exponential', 'logarithmic', or 'polynomial' x is original x variable and y is vector of fit regression line

Author

Jeffrey S. Evans jeffrey_evans@tnc.org

Examples

x <- 1:10 y <- jitter(x^2) opar <- par(no.readonly=TRUE) par(mfcol=c(2,2)) trend.line(x,y,type='linear',plot=TRUE,pch=20,main='Linear')
#> $x #> [1] -21.9637 #> #> $y #> [1] 10.99748 #>
trend.line(x,y,type='exponential',plot=TRUE,pch=20,main='Exponential')
#> $x #> [1] 1 2 3 4 5 6 7 8 9 10 #> #> $y #> [1] 7.923561 10.557305 14.066489 18.742105 24.971866 33.272363 #> [7] 44.331894 59.067546 78.701239 104.861052 #>
trend.line(x,y,type='logarithmic',plot=TRUE,pch=20,main='Logarithmic')
#> $x #> [1] 1 2 3 4 5 6 7 8 9 10 #> #> $y #> [1] -22.355830 5.581428 21.923676 33.518686 42.512474 49.860934 #> [7] 56.073968 61.455943 66.203182 70.449731 #>
trend.line(x,y,type='polynomial',plot=TRUE,pch=20,main='Polynomial')
#> $x #> [1] 1 2 3 4 5 6 7 8 9 10 #> #> $y #> [1] 0.7344235 3.9314696 9.0786230 16.1758838 25.2232519 36.2207274 #> [7] 49.1683102 64.0660003 80.9137978 99.7117026 #>
par(opar)