NewLISP Data Fitting and newlisp Data Fitting
Sometimes we need to fit the data. For example, if the data on a Friday cannot be generated for some reason, we can use the following algorithm for simple fitting.
Calculate the week-on-week ratio of the first two weeks and the week-on-week ratio. Calculate the two adjacent ratios by adding 1 after the average value and multiply the data of the week to obtain the data of the week.
Using newLISP to implement code is simple:
See the following example:
#!/usr/bin/newlisp(define (adjacent-div a b) (div (sub b a) a))(define (average a b) (div (add a b) 2))(define (fitting a b c d e) (int (mul (add (average (adjacent-div a b) (adjacent-div c d)) 1) e)) )(println (fitting 736500 743138 733101 720626 762747))(println (fitting 743138 801841 720626 756950 759694))(println (fitting 801841 914530 756950 895230 808846))(exit)
The final result is:
~$ ./b.lsp759694808846939562
Help me plot the data in excel and write the fitting curve and R value. Thank you!
Fit the trend line. Select a curve, right-click it, select "add trend line", and "type", and select the closest type of the curve, such as linear, logarithm, and polynomial (1) in the midpoint of the "add trend line" option box, select "formula" and "displayed" to determine the R squared value of the trend line. In this case, check whether the R value is close to 1, if R 1 or about 0.995 (Trend Line Plot curves basically overlap ). , Which means fitting the corresponding relationship between the data that can be expressed by the basic formula displayed by the trend line. If R differs (or the trend line produces a very different curve), you need to select "add trend line" type again. rebuild until the R value is close to 1 (Be sure to select the rising trend line and curve drawing which are basically the same for all the trend line types R ).
If you cannot find such a fitting trend line, you can only prove that the data is not suitable for regression curves (or the fitting is ineffective and can better reflect the changes in data ), this is because not all groups of data can find a perfect regression line.
Multiple methods make the fitting equation different, because: 1, the regularity of the data (that is, whether it is the above mentioned return), 2, each method is used properly (to find the most matching fitting equation ). If the regression using the data of each method is given an appropriate fitting equation, I think the differences between the same data fitting equations are smaller.
Of course there are some differences between various methods. Therefore, even if you meet the above two conditions, the fitting equations may not be exactly the same. As long as you find a simple and effective method that best suits you in practice, there is no need to do it each time, which is unnecessary and time-consuming. In addition, if the data itself is not directly derived from (in most cases it should not) The trend estimation derived from this function, equation or curve fitting (rather than a true value), in prediction, statistics play a greater role.
This is only my personal opinion and is for reference only.
Fitting Formula of experiment data
If you draw a scatter chart x1 and x2 based on the test data, you can create a function:
X2 = a * x1 + B
Then, Eviews or Excel software is used for fitting and linear regression analysis.