search for: polyfit

Displaying 4 results from an estimated 4 matches for "polyfit".

2007 Aug 15
1
Polynomial fitting
Hi everybody! I'm looking some way to do in R a polynomial fit, say like polyfit function of Octave/MATLAB. For who don't know, c = polyfit(x,y,m) finds the coefficients of a polynomial p(x) of degree m that fits the data, p(x[i]) to y[i], in a least squares sense. The result c is a vector of length m+1 containing the polynomial coefficients in descending powers: p(x) = c[...
2012 Jan 24
1
problems with rollapply {zoo}
...;,"Low","Close") alpha$rel_t <- seq(1-nrow(alpha),0) # Just to check the code for the regression, apply the regression to the whole series (unless the series is realy short or has a strong slow pattern the regression result is not useful except to show that the code works) polyfit <- lm(Close ~ poly(rel_t,4),alpha) polyfit2 <- lm(Close ~ rel_t + I(rel_t^2) + I(rel_t^3) + I(rel_t^4), data=alpha) # This is the objective, where all the magic happens rollRegFun <- function(d,i) { # set up the relative time variable, so that the current record has rt = 0 d$rt <...
2009 Oct 17
0
More polyfit problems
Hi Everyone, I'm continuing to run into trouble with polyfit. I'm using the fitting function of the form; fit <- lm(y ~ poly(x,degree,raw=TRUE)) and I have found that in some cases a polynomial of certain degree can't be fit, the coefficient won't be calculated, because of a singularity. If I use orthogonal polynomials I can fit a polynomial...
2009 Nov 11
1
Polynomial fitting
Dear R helpers     Suppose I have a following data   y  <- c(9.21, 9.51, 9.73, 9.88, 10.12. 10.21)   t  <- c(0, 0.25, 1, 3, 6, 12)   I want to find out the polynomial which fits y in terms of t i.e. y = f(t) some function of t.   e.g.   y = bo + b1*t + (b2 * t^2) + (b3 * t^3) + ...... and so on.   In Excel I have defined y as independent variable, then defined t, t^2 and t^3 and using