powerFit: Power fit

Description Usage Arguments Details Value Author(s) See Also Examples

View source: R/turb.R

Description

Calculates the log fit of a set of points using lm.

Usage

1
powerFit(x, y)

Arguments

x

Vector containing x coordinates of the points.

y

Vector containing y coordinates of the points.

Details

This function returns the coefficients that best approximate the set of points according to the equation

y = a_1 x^a_2

The function returns the vector c(a1, a2).

Value

Vector with fit coefficients.

Author(s)

Paulo José Saiz Jabardo.

See Also

lm predict.lm

Examples

1
2
3
4
5
6
7
x <- 1:10
y <- 2.5 * x^0.3 + rnorm(10, sd=0.2)

fit <- powerFit(x, y)
plot(x, y, xlab='x', ylab='y')
lines(x, fit[1]*x^fit[2])
print(fit)

tunelipt/wutils documentation built on Nov. 5, 2019, 11:01 a.m.