| SSharm1 | R Documentation |
Self starter for a harmonic regression
harm1(x, b0, b1, cos1, sin1) SSharm1(x, b0, b1, cos1, sin1)
x |
input vector |
b0 |
intercept of the harmonic regression |
b1 |
slope of the harmonic regression |
cos1 |
coefficient associated with the cosine of the harmonic regression |
sin1 |
coefficient associated with the sine of the harmonic regression |
Harmonic regression is actually a type of linear regression. Just adding it for convenience.
a numeric vector of the same length as x containing parameter estimates for equation specified
harm1: vector of the same length as x using a harmonic regression
require(ggplot2) set.seed(1234) x <- seq(0, 3, length.out = 100) y <- harm1(x, 0, 0, 0.05, 0) + rnorm(length(x), 0, 0.002) dat <- data.frame(x = x, y = y) fit <- nls(y ~ SSharm1(x, b0, b1, cos1, sin1), data = dat) ## plot ggplot(data = dat, aes(x = x, y = y)) + geom_point() + geom_line(aes(y = fitted(fit)))