# Tagged Questions

Questions on the use of Mathematica to construct models for approximating empirical data.

2answers
289 views

### FindFit “is not a real number” error when fitting a parametric function to the data

I am using Mathematica's FindFit function to fit a parametric solution to my data and I am getting the error ...
2answers
330 views

### RSquared: LinearModelFit vs NonlinearModelFit

I'm trying to understand the differences between LinearModelFit and NonlinearModelFit. One thing I notice is that the computation of AdjustedRSquared seems to be different, even when the model results ...
0answers
54 views

### NonlinearModelFit not hunting for good values

I have the following data which come from complex values but I have turned them into a 3D list ...
1answer
747 views

### Fit convoluted Gaussian and Lorentzian functions to a peak profile [duplicate]

I have a peak profile data like this: ...
2answers
234 views

### Unable to fit function convolved with NIntegrate with FindFit even with NumericQ

I am attempting to fit to the convolution of a simple function with a Gaussian. (I realize this could be done with Convolve also, but I thought I could make it go faster this way). I am able to ...
0answers
51 views

### How do I add custom deviation when using LinearModelFit?

I have a set of data in the form a list S1={{x,y},{x,y}} etc. I also have a function that calculates a corrected standard deviation in the y direction for ...
0answers
83 views

### Expand a fitting using FindFit[]

I need to implement multidimensional optimization using FindFit[]. But it's essential to exclude some parameters from the main procedure of optimization and to move on from direct optimization in ...
1answer
159 views

### How to derive SinglePredictionBands from a NonlinearModelFit model

I have found NonlinearModelFit to be extremely useful in my work. Here I have fit 4 points to a function and am being asked to explain how the 95% SinglePredictionBands associated with the plot below ...
1answer
110 views

### LinearModelFit - Number of unique basis functions & Invalid variable errors

I'm having trouble with a simple linear fit model. Here is my code ...
0answers
113 views

### How well does my function fit data? [duplicate]

Oleksandr Karsten suggested me to mark the difference between this question and the one that is already answered: in the other question it is calculated a ...
1answer
179 views

### Fitting an imported .txt data

I have some data in a .txt file, and I'm trying to import it to Mathematica and fit it with a function. The data is a 647x647 matrix of values. This seems like it ...
2answers
123 views

### How to fit points in a picture using locators

I've got a problem doing some analysis work on some of my spectra. I am basically looking for features that look like parabolas. In need of a tool to quickly find two parabolas in a spectrum (they are ...
1answer
132 views

### How to make a diagnostic plot for the regression?

Context I am interested in LinearModelFit, and would like to make diagnostic plots using Mathematica. I cannot find them in Mathematica document center. For example, the following R program makes ...
0answers
112 views

### Plots to check all assumptions of linear regression

I'm running a linear regression with LinearModelFit and would like to plot graphs to check the assumptions of linear regression: linearity, independence of the ...
1answer
189 views

### NonlinearModelFit - “Encountered a gradient that is effectively zero”, all variables are 1, 1, 1 [duplicate]

I have data of the form {149.45, 0.371093}, {149.362, 0.375976}, {149.277, 0.380858}, ... }, where each element of the list is {x, y}. The plot of this, using ListPlot, gives an approximate Gaussian. ...
1answer
99 views

### Ordinary Least Squares (OLS) with RLink

I need to calculate the parameters b0, b1 and b2 in: ...
1answer
79 views

### Regression with 3 variables

I'm trying to find a function starting from its values but I can't find anything related to functions with 2 variables and I don't know how to go on. So, given this sample data, I'd like to know how ...
1answer
64 views

### How to fit this data to be used in NIntegrate later?

I have a list of data points that resemble a chi-squared distribution (long tailed gaussian) that I am having trouble fitting or finding an equation with. The goal is to use the fitted equation in an ...
1answer
59 views

### Why does my Dynamic NonliearModelFit keep running?

I have complex data and which I am fitting to a complex formula. In order to use NonlinearModelFit I split the formula and the data into real and imaginary parts. ...
1answer
155 views

### FindFit::nrlnum: error with FindFit

I am trying to write a code to fit actual data of the orbit of a star with Mathematica 8. First I tried to write a code to fit a mock orbit, using the Application with differential equations (the ...
2answers
162 views

### FindFit working with Integrate but not NIntegrate - I am using “?NumericQ”

I'm having some syntax problems with finding a fit to an equation that doesn't have an analytical expression for it's integral. Because I think the problem is one of syntax, I am substituting a ...
1answer
345 views

### Test Goodness of fit for FindFit

Is there any way to get an estimate of the goodness of fit from FindFit, for instance getting the final error? The documentation doesn't provide any hints, and a quick Google search didn't return any ...
0answers
60 views

### Is there a way to produce a FittedModel object as the solution to a regularized regression?

I can get the Ridge or Tikhonov regression solution to Y = \[Beta].X easily enough as ...
0answers
122 views

### Fitting curves with NonLinearModelFit not working with charge and discharge like data

I'm trying to get a reasonable fit out of mathematica, but i'm not very practical with it. I'm not that good with mathematica at all actually(like cleaniness of the code...). btw, here's my problem: ...
0answers
46 views

### Troubles with FindFit for ODE (elaboration)

I have asked a question Troubles with FindFit for ODE and get a good-working answer from @belisarius. Nevertheless I need to clarify is it possible to define the same model with ...
2answers
143 views

### Remove redundant parameters from equation

I have random expressions like (b1 x + b2 x)/(b3 + b4/b5 x) + Sin[b6 x] where $x$ is a variable and {b1, ..., b6} are parameters to be fitted. This expression is ...
1answer
143 views

### How do I find out what a Mathematica function is doing (which numerical method it uses and how)?

Long story short, I am working on a project which entails fixing a bug I have found in Mathematica (8 and 10). In general, I would like to know what a specific Mathematica function is actually doing ...
1answer
142 views

### Find Numerical Derivatives (With Errors) given some data

I have a question. Suposse I have some data with their respective errors: ...
1answer
187 views

### Find GeometricTransform from 3D object external surfaces to a positional point cloud data

I am looking for another way to approach this problem. Any suggestion on how to optimize the computing speed is welcome. I have a BSplineFunction which accurately ...
1answer
155 views

### Applying LinearModelFit[] to data obtained with WeatherData[]

I am trying to perform a linear regression on some weather data, but I can't seem to figure out how to perform the operation. What I have right now is this: ...
1answer
144 views

### Mixture coefficients and Parameter estimation for moving Normal distributions

I am searching for a way to do the following steps below. I am stumped and I have stumped a few profs too. Any help would be appreciated. I would like to import data from, say, excel or a .txt file ...
2answers
68 views

### Handling msg for fitting

I have a trivial question: I do Monte Carlo with some curve fitting. Now always when a random run creates a complex fitting solution it should write 1 in a Matrix. How can I handle such msgs in a ...
1answer
111 views

### Mystifying failure of NonlinearModelFit

Fitting the following two time-series (two repeats of the same exponential growth process) ...
1answer
46 views

### Fit inside a module [closed]

I have here a MMA NB which works fine outside the MODULE. BUt in the module routine there comes up an warning that the solution is not real. Can anyone here help please? ...
1answer
148 views

### Troubles with FindFit for ODE

I need to use FindFit for ODE with arbitary number of parameters. This code (from documentation) works: ...
1answer
110 views

### Fitting data with inclusion of constraints

How do I find a fit for the dataS (see below) with the constraint that the parameter np is an integer, and that the parameters la+lc = 100. A weak attempt at this is provided below for a specific ...
1answer
225 views

### Forcing NonLinearModelFit through a point

Like the title says, is there a way to make an NLM fit pass through a specific point.
1answer
62 views

### Is there a way to show some “weighted” residuals after LinearModelFit?

I am fitting some functions to some data and then I want to analyze the residuals of that fit. I'd like to see how those residuals compare to the values of the original data, hence my "weighted" in ...
2answers
125 views

...
2answers
373 views

### Best fit equation from a scanned image

I am trying to extract a curve from a scanned graph and find a best fit equation. For example, starting from: How could one find an equation starting from the image file ?
0answers
116 views

### Error associated with parameters in Minimize (or NMinimize) in discrete fitting

my problem goes as follows: I need to a discrete fit of a discrete function. Say I have the following made up data points, which are generated by the parabola ...
0answers
248 views

### Multi-peak fitting

Suppose we have a data set that looks like this: I have to fit this data to 9 peaks knowing μ and σ beforehand & have to ...
1answer
584 views

### Fitting parameters of user defined function returning discrete values

So, I'm fairly new to Mathematica (apologies in advance for the noobiness), and I'm having some problems regarding fitting the parameters of a user defined function to data. I'll give a representative ...
0answers
78 views

### Updating procedural fitting algorithm to more efficient style?

For some time now, I have used this procedural programming approach to fit data in my research that is too cumbersome for the built in Mathematica functions. (Although this simple example works fine ...
1answer
169 views

### Equation of line from loglog plot

Given some data that looks linear on a ListLogLogPlot, how can I find the correct equation (and particularly, the correct slope of the line)? I have a sample code here ...
0answers
101 views

### How to perform a distribution fit test to censored data

With following code I will get an error: ...
0answers
71 views

### Using FindFit to return a list of possible best fits

Can I use some variant of FindFit that will return a list of the best fit and some worse fits, not just the best fit? This is for a function where the residual function can have several local ...
1answer
144 views

### Non linear model fit

I need to fit this, but for some reason I cannot... data = {{0.617,0.8}, {0.605,0.6}, {0.5997,0.4}, {0.5972,0.2}, {0.5985,0.1}}; soln = NonlinearModelFit[data, {y - 2478.82*wlog[kc + 1]}, {y,w,k}, ...
0answers
220 views

### PenaltyFunction Option in NMinimize

I am curious if anybody has some experience in using the built-in Option "PenaltyFunction" in any of the numerical optimization functions like NMinimize. According to the documentation the user ...
0answers
103 views

### Findfit doesn't provide reasonable results when fitting a complex function [closed]

I am trying to fit some data using the function which contains two parameters (a, b) as described below. Hope to determine the a, b that best fit the data. My input is: ...