HELP ASAP MATLAB
Post-Activity Matlab regression Engineering Background: In modeling an oil reservoir in petroleum engineering, it may be necessary to find a relationship between the equilibrium constant of a reaction and the pressure at a constant temperature. The data shown in the table below relates equilibrium constants K to pressure (measured in 1000 psia). 0.6 1 1.4 1.8 2.2 2.6 3 3.4 3.8 4.2 4.6 5 5.4 5.89 4.68 4.1 3.45 3.25 2.69 2.25 1.92 1.55 1.45 1.19 0.99 0.84 Theory says that the K-P relationship should be exponential: K = Aexp(BP) You can take the log-transform of both sides to get a linear form that will allow you to use linear regression to find A and B: logK = logA + BP so the slope of the regression is B, and A is equal to the exponential raised to the intercept. You want to compare this linear regression on the transformed data with a polynomial regression on the untransformed data. Specifically, you want to find what order of polynomial regression u need to do et a better fit in the mean-squared-error sense than the log-transformed linear regression. A step-by-step set of instructions on what to do is as follows: 1. Do a linear regression of P vs log(K) using polyfit 2. Transform the intercept value using the exponential function, and find Kfit = A exp (BP) where A and are the regression-estimated parameters. Find the MSE for this regression using measured K values and Kfit using polyfit. polyyal 3. 4. Now perform a linear regression (polynomial regression of order 1) on the untransformed data s. Using the results of polyfit, find the best fit line, Kfit. It may be easiest to calculate Kfit using 6. Find the MSE for this regression using measured K values and Kfit 7. Increase the order of the polynomial regression by 1 (use a loop), and repeat from step 4. Stop this loop when the MSE you find in step 6 is less than the MSE you found in step 3. This will tell you what order of polynomial regression gives a better fit than log-transformed linear regression