# Tag Info

## Hot answers tagged curve-fitting

14

It sounds like you want to perform multiple changepoint detection followed by independent smoothing within each segment. (Detection can be online or not, but your application is not likely to be online.) There's a lot of literature on this; Internet searches are fruitful. DA Stephens wrote a useful introduction to Bayesian changepoint detection in 1994 ...

13

See the nls() function. It has a self starting logistic curve model function via SSlogis(). E.g. from the ?nls help page > library("nls") > DNase1 <- subset(DNase, Run == 1) > > ## using a selfStart model > fm1DNase1 <- nls(density ~ SSlogis(log(conc), Asym, xmid, scal), + DNase1) I suggest you read the help ...

11

To solve your problem, a good approach is to define a probabilistic model that matches the assumptions about your dataset. In your case, you probably want a mixture of linear regression models. You can create a "mixture of regressors" model similar to a gaussian mixture model by associating different data points with different mixture components. I have ...

10

There are many ways to smooth. Depending on how much effort you're prepared to go to, any of can be done in matlab (and probably already exist somewhere) and Excel (but you might have to do them yourself). [If you were asking about R I'd show you three or four ways you might smooth data.] That "smooth approximation" in the image just looks quadratic to me, ...

9

It would be possible to create a dataset in such a way that the residuals from the linear model are orthogonal to the quadratic and cubic terms and in that case adding the terms would not change the fit to the model. However the probability of getting such a dataset in the real world is close enough to 0 that you will not likely ever see this happen with a ...

8

Yes and no. At the theoretical level, both cases can use similar techniques and frameworks (an excellent example being Gaussian process regression). The critical difference is the assumptions used to prevent overfitting (regularization): In the functional case, there is usually some assumption of smoothness, in other words, values occurring close to each ...

8

Since you know the density, you can just use fitdistr. # Sample data library(LaplacesDemon) x <- rinvgamma(1000, 1,2) library(MASS) f <- function(x, rho, a, s) 1/(a*gamma(rho)) * (a / (x-s))^(rho+1) * exp( - a/(x-s) ) fitdistr( x, f, list(rho=1, a=1, s=0) )

8

Elsewhere in this thread, user1149913 provides great advice (define a probabilistic model) and code for a powerful approach (EM estimation). Two issues remain to be addressed: How to cope with departures from the probabilistic model (which are very evident in the 2011-2012 data and somewhat evident in the undulations of the less-sloped points). How to ...

8

The methods we would use to fit this manually (that is, of Exploratory Data Analysis) can work remarkably well with such data. I wish to reparameterize the model slightly in order to make its parameters positive: $$y = a x - b / \sqrt{x}.$$ For a given $y$, let's assume there is a unique real $x$ satisfying this equation; call this $f(y; a,b)$ or, for ...

7

RMS stands for the root mean square error. It's calculated in the following way. First we calculate the residuals: -96.72, 265.77, -169.05 Next we calculate the squared residuals: -96.72$^2$, 265.77$^2$, -169.05$^2$ Then we sum and divide by $n-2=1$ Take the square root. Further info A residual is simply the $observed - fitted$. So when x = 35, the ...

7

Functional Data often involves different question. I've been reading Functional Data Analysis, Ramsey and Silverman, and they spend a lot of times discussing curve registration, warping functions, and estimating derivatives of curves. These tend to be very different questions than those asked by people interested in studying high-dimensional data.

7

I will assume the values of all the variables and constants are such that there won't be problems with obtaining square roots of negative numbers. Then $$\frac{\sqrt{c_1 x + c_2 \exp(x)^y}}{\sqrt{\exp(x)^y}} + c_3 =\sqrt{c_2 + c_1 x \exp(-y x)} + c_3.$$ When $y \gt 0$ then eventually, for sufficiently large $x$, $\frac{c_1}{c_2} x \exp(-y x)$ gets small ...

7

You might want to check out the free software called Eureqa. It has the specific aim of automating the process of finding both the functional form and the parameters of a given functional relationship. If you are comparing models, with different numbers of parameters, you will generally want to use a measure of fit that penalises models with more ...

7

The root mean squared error and the likelihood are actually closely related. Say you have a dataset of $\lbrace x_i, z_i \rbrace$ pairs and you want to model their relationship using the model $f$. You decide to minimize the quadratic error $$\sum_i \left(f(x_i) - z_i\right)^2$$ Isn't this choice totally arbitrary? Sure, you want to penalize estimates ...

7

Not sure if there'll be any other "ranty" responses, but heres mine. Cross Validation is in no way "new". Additionally, Cross Validation is not used when analytic solutions are found. For example you don't use cross validation to estimate the betas, you use OLS or IRLS or some other "optimal" solution. What I see as a glaringly obvious gap in the quote is ...

6

The periodogram will estimate the periods. It will also handle noisy data and pick out multiple sinusoidal components of different period. A quick and dirty Mathematica calculation is data = N[Table[Sin[3.17*2*Pi*x/200], {x, 1, n}]]; welch = 1 - (2 (Range[n] - (n - 1)/2)/(n + 1))^2; fData = Append[Abs[Fourier[welch data]]^2 / (Plus @@ (welch^2)), 0]; ...

6

A normal probability plot is an excellent way to compare an empirical distribution to a normal distribution. Its merits are that it clearly displays the nature of any deviations from normality: ideally, the points lie along the diagonal; vertical deviations from the diagonal depict deviations from normality. Its disadvantages are that many people do not ...

6

(As others have pointed out, a Weibull distribution is not likely to be an appropriate approximation when the data are integers only. The following is intended just to help you determine what that previous researcher did, rightly or wrongly.) There are several alternative methods that are not affected by zeros in the data, such as using various method-of ...

6

do it with koencker's broken line regression, see page 18 of this vignette http://cran.r-project.org/web/packages/quantreg/vignettes/rq.pdf In response to Whuber last comment: This estimator is defined like this. $x\in\mathbb{R}$, $x_{(i)}\geq x_{(i-1)}\;\forall i$, $e_i:=y_{i}-\beta_{i}x_{(i)}-\beta_0$, $z^+=\max(z,0)$, $z^-=\max(-z,0)$, $\tau \in ... 6 It's not a good idea to rescale the data in this ad hoc way, because it can result in an inferior fit (and ruins any chance of estimating the sampling variance of the scale parameter): just fit a scaled Beta distribution to the data themselves. You do have to assign percentage points to the data; below I have used$p(i) = (i-1/2)/n$for the$i^\text{th}$... 6 Here are some methods and associated R packages to solve this problem Wavelet thresolding estimation in regression allows for discontonuities. You may use the package wavethresh in R. A lot of tree based methods (not far from the idea of wavelet) are usefull when you have disconitnuities. Hence package treethresh, package tree ! In the familly of ... 6 That's the root mean square error (RMSE) of the regression. $$RMSE = \sqrt{\frac{1}{n-k}\sum{(y_i-\hat{y_i})^2}},$$ where$y_i$is the observed and$\hat{y_i}$the fitted value for observation$i$,$n$is the number of observations, and$k$is the number of parameters fitted (including the constant). I just tried fitting a straight line by simple linear ... 6 Here is a quick and dirty idea based on @alex's suggestion. #simulated data set.seed(100) x <- sort(exp(rnorm(1000, sd=0.6))) y <- ecdf(x)(x) It looks a little bit like your data. The idea is now to look at the derivative and try to see where it is biggest. This should be the part of your curve where it is straightest, because of it being an ... 5 Does this make any sense? Partly. What does he mean? Please ask him. Do you have a clue - or perhaps even a name for the proposed method and some references? Cross Validation. http://en.wikipedia.org/wiki/Cross-validation_(statistics) Or did this guy find the holy grail nobody else understands? No. He even says in this interview that his method ... 5 It seems to me you are actually looking for a regression models with re-descending loss function ("far away points are weighted less than close ones") loss function. Such loss functions --for example the Tukey biweight-- lead to highly non-convex optimization problems, meaning that there are, potentially, a finite but factorial-order increasing number of ... 5 The difference is basically the difference in the assumed distribution of the random component, and how the random component interacts with the underlying mean relationship. Using nonlinear least squares effectively assumes the noise is additive, with constant variance (and LS is ML for normal errors). The other two assume that the noise is multiplicative, ... 5 Everything can be done with polyfit function only. Read about its optional output parameters in http://www.mathworks.nl/help/matlab/ref/polyfit.html For instance: [p,S,mu] = polyfit(x,y,n) where mu is the two-element vector [μ1,μ2], where μ1=mean(x), μ2=std(x) To compute error, you have to use another function taking output of polyfit: [y,delta] = ... 5 Because brightness is a response with independent random error and it is expected to taper off with distance from the optimal point according to a Gaussian function, a quick nonlinear regression ought to do a good job. The model is $$y = b + a \exp\left(-\frac{1}{2}\left(\frac{x-m}{s}\right)^2\right) + \varepsilon$$ where$\varepsilon\$ represents the ...

Only top voted, non community-wiki answers of a minimum length are eligible