Excel Interpolate with logarithmic prediction - excel

Is there a function within Excel to Interpolate while taking into account a logarithmic prediction?
At the moment I am using linear interpolation but would like to find a better way to fill in the blanks if possible.

There's no logarithmic regression or interpolation in Excel, even in the Anlaysis ToolPak. You'll need much more advanced software for that, such as MatLab.
If you're stuck working in Excel... here's a possible mathematical solution:
Rather than working with the raw data x and y, instead try plotting x and a^y, where a is the base. (Or plotting log(x,a) against y.) If you have the correct base a (and there's no vertical offset), you will then have a linear relationship from which you can perform a linear interpolation as normal, then convert the interpolated values back to actual values by taking the log of them.
If you don't know what a is, then you can instead calculate a line of best fit for an arbitrary a, calculate the standard residuals, and then use Problem Solver to modify a until you get the lowest possible standard residuals, at which point you have the best estimate of a.
Similarly if there is a vertical offset b, you'll need to test some variables there that also result in a linear relationship. Plot x against a^(y-b)

Related

Averaging many curves with different x and y values

I have several curves that contain many data points. The x-axis is time and let's say I have n curves with data points corresponding to times on the x-axis.
Is there a way to get an "average" of the n curves, despite the fact that the data points are located at different x-points?
I was thinking maybe something like using a histogram to bin the values, but I am not sure which code to start with that could accomplish something like this.
Can Excel or MATLAB do this?
I would also like to plot the standard deviation of the averaged curve.
One concern is: The distribution amongst the x-values is not uniform. There are many more values closer to t=0, but at t=5 (for example), the frequency of data points is much less.
Another concern. What happens if two values fall within 1 bin? I assume I would need the average of these values before calculating the averaged curve.
I hope this conveys what I would like to do.
Any ideas on what code I could use (MATLAB, EXCEL etc) to accomplish my goal?
Since your series' are not uniformly distributed, interpolating prior to computing the mean is one way to avoid biasing towards times where you have more frequent samples. Note that by definition, interpolation will likely reduce the range of your values, i.e. the interpolated points aren't likely to fall exactly at the times of your measured points. This has a greater effect on the extreme statistics (e.g. 5th and 95th percentiles) rather than the mean. If you plan on going this route, you'll need the interp1 and mean functions
An alternative is to do a weighted mean. This way you avoid truncating the range of your measured values. Assuming x is a vector of measured values and t is a vector of measurement times in seconds from some reference time then you can compute the weighted mean by:
timeStep = diff(t);
weightedMean = timeStep .* x(1:end-1) / sum(timeStep);
As mentioned in the comments above, a sample of your data would help a lot in suggesting the appropriate method for calculating the "average".

VBA EXCEL Fitting Curve with freely chosen function

As start situation, I have an xy-chart with some values on it whose progression resemble an exponential function. I need to write a code that draws a fitting curve on the chart, but I have to use a particular function which is not exponential (because I need to get some coefficients from it).
One of the functions i need to use is K(C-x)²/(1+x) whereby k and C are the parameters I need.(They are two and it makes it a lot more complicated) Obviously you can't find this kind of structure on the fitting curve tool in Excel. Is there any possibility to have a fitting curve to a chart where you can write yourself the structure of the function?
Sorry if I don't add any written code, but i just need a hint to start writing.
Thank you
I did something to similar to this a while ago. The approach I took was to use the solver (as gary's student suggests). I think it was fired from VBA but that's unimportant.
Basically you'd have two input cells per row of data with your variables K and C. Then you need to find the difference (errors) between the values the function produces with the values in the input cells compared to the actual values (I think using errors^2 gives quicker conversion). You then sum the differences in another cell. When running the solver, you ask it to minimise the sum of differences by changing K and C.
Does that makes sense...?

Excel Trend line (SLOPE() ) and CORREL() yields different coefficients

I'm trying to use excel to get the coefficient for two financial market spreads using two methods on data series Sprd1 against data series Sprd2:
1) I used scatter plot and simply added a trend line, showing R^2 (0.4052) and Coefficient (0.614). Trend line should be using SLOPE() to get the coefficient...
2) I used =CORREL(Sprd1, Sprd2), showing 0.637; =RSQ(Sprd1, Sprd2), yielding 0.4052.
I understand that the R-sq values should be pretty close. But why would the coefficents differ? I'm trying to look for any difference in terms of excel's embedded methods or assumptions on the trendline and the CORREL.
Thank you very much!
While both RSQ and CORREL work from the same equation
the value returned by RSQ is the square of that result.
i.e. RSQ()=CORREL()^2
SLOPE, on the other hand, does not use (y-MEAN(y))^2, nor does it take a square root of the denominator:
so will give slightly different results, depending on the mean of y

Interpolate off a standard curve in Excel

Most simple thing to do on paper, but somehow near impossible to work out in Excel.
I need to interpolate off a standard curve in Excel.
I have a standard curve and need to find an unknown concentration of a known absorbance.
Just like this;
http://class.fst.ohio-state.edu/fst601/Lectures/spectt/Image161.gif
My lecturer would not give us any more hints than to either use the, linear regression equation (which i think i worked out but couldn't get it to calculate the concentration) or use the point finding/picking option (no idea what this could mean)
If anyone could help me out with this I would really appreciate it, and so would my whole class!
In excel, you can do it two ways:
Method 1: Use a standard interpolation/extrapolation formula. (Bingle)
Method 2: Plot any existing data points that you have as an x-y(scatter) plot. Right-click on the data line in the chart and choose 'Add trendline'. Excel will calculate a best-fit line for your data (using linear regression) and display the line over the top of your existing data. If you right-click on this trendline, you can adjust its settings and display properties of it, including the equation used to draw it. Once you have that equation, you can plug in any value of x and get the corresponding value of y.

How to get points that intersect the trendline?

Basically I did the Cavendish experiment, and I have a damped sinusoidal wave plotted on Excel. With Position (mm) against Time (s).
My problem is that I have added a tread line through the wave function, and wish to calculate the points of which the wave function intersects the tread line. From this I will then be able to calculate the time period.
At the moment I'm just having difficulty getting the intersects..
Thanks
Excel is probably not the best tool to do what you want. In general, you want to fit your data to a damped Sin() function, e.g., F(x) = (A - B x) Sin(C x) or F(x) = A exp(-B x) Sin(C x), for linear or exponential dampening. Fitting the curve to the data will give you the values of the constants A, B, and C that fit the data best, and you can then proceed to simply solve F(x) == f_tread(x) to get the values x of intersection.
Programms like Mathematica, Matlab, or the free python based Sage are ideal for this and you can do it literally with two lines (well maybe three if you need to import the data first :-) ). I highly encourage you to give them a try if possible.
If you want/have to use Excel, then you can use it in a similar way for the data fitting part to get the constants A, B, C, etc. However, the part of finding intersections is trickier and unless you want to find the intersections by hand, you probably have to use an add-in like Solver and VBA script.
Finally a third way (since you seem to already have the formula for the damped sin wave) is to just plug the F==tread equation into WolframAlpha like so.

Resources