R/polynomial.fit.R

polynomial.fit <- function (zoo, degree = 1) 
{
  # fit sea level
  h <- as.numeric(zoo)
  # use years since 1970
  years <- as.year(zoo)
  # the rest is rather basic
  if (degree == 1) {
    h.lm <- lm(h ~ years)
  }
  else if (degree == 2) {
    years2 <- years^2
    h.lm <- lm(h ~ years + years2)
  }
  return(h.lm)
}

Try the sealevel package in your browser

Any scripts or data that you put into this service are public.

sealevel documentation built on May 2, 2019, 6:51 p.m.