poly_trend | R Documentation |
Fits a polynomial trend using specified order
poly_trend(x, y, degree, ci = 0.95, plot = TRUE, ...)
x |
Vector of x |
y |
Vector of y |
degree |
Polynomial order (default 3) |
ci |
+/- confidence interval (default 0.95) |
plot |
Plot results (TRUE/FALSE) |
... |
Additional arguments passed to plot |
A fit using a lm(y ~ x + I(X^2) + I(X^3)) form will be correlated which, can cause problems. The function avoids undue correlation using orthogonal polynomials
A poly.trend class (list) containing
trend data.frame of fit polynomial and upper/lower confidence intervals
model Class lm model object fit with poly term
prameterCI Intercept confidence intervals of Nth order polynomials
order Specified polynomial order
Jeffrey S. Evans jeffrey_evans@tnc.org
set.seed(42)
x <- seq(from=0, to=20, by=0.1)
y <- (500 + 0.4 * (x-10)^3)
noise <- y + rnorm(length(x), mean=10, sd=80)
p <- poly_trend(x, noise, degree = 3, ci = 0.95,
main="3rd degree polynomial")
dev.new(height=6, width=12)
layout(matrix(c(1,2), 1, 2, byrow = TRUE))
p <- poly_trend(x, noise, degree = 3,
main="3rd degree polynomial")
p <- poly_trend(x, noise, degree = 6,
main="6th degree polynomial")
cat("Confidence intervals for", "1 -", p$order, "polynomials", "\n")
p$prameterCI
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.