Community Tip - You can Bookmark boards, posts or articles that you'd like to access again easily! X
I have created a MathCAD sheet that performs linear regression. I would like to have a function file or something similar that performs this process but with different inputs. This way I can just stick this function file into another sheet, put in the inputs and perform the regression without having to copy the whole thing into the new sheet.
I would appreciate it if anyone can help me do this.
Thanks.
Solved! Go to Solution.
In case you are not familiar with find attached three different ways for getting the quadratic regression using built-in functions.
At the end of the file you find your "manual" made regression written as a function.
Message was edited by: Werner Exinger
Is there a specific reason you are not using the built-in functions "regress" or "polyfit" (if for some reason you need to know the coefficients of your polynomial function)?
To do what you demand you have to put all your calculations into one function, the parameter of which would be the two data vectors and possibly the order if you don't want to be of second order all the time. The output would be the vector a of coefficients.
But unless you have a very good reason not to do so I would suggest using regress or polyfit.
In case you are not familiar with find attached three different ways for getting the quadratic regression using built-in functions.
At the end of the file you find your "manual" made regression written as a function.
Message was edited by: Werner Exinger
It is one problem for Mathcad Prime!
But I think 3 last coefficients of the vector k must be (better) with units:
k is correct with units with the linfit function:
Oh yes, I forgot that we can see the coefficients with regress, too.
Your pic shows that Prime does a bit better with units than MC15 but isn't perfect. I agree that the output of regress should include units. And unfortunately we can not change the units of the elements in a vector with mixed units singly (which would be nice for your k1) as the placeholder is after the vector or matrix and will affect all the elements. Hopefully this will be fixed in Prime3!?
Don't know if Leopoldo has access to Prime so I include your suggestions (getting the coefficients with regress and using linfit as yet another method) in the attached MC15 file. We could use genfit, too, but enough is enough, I think.