How to get non interger numbers in Wilkinson notation using fitlm
조회 수: 2 (최근 30일)
이전 댓글 표시
Hello,
I am building a linear regression model with fitlm using Wilkinson notation like y ~ x1*(x2^exp+x3^exp) .
Model and notation are working fine as long exp is an integer. Is there a chance to implement numbers like exp=1.5,3.33 etc.?
Thanks
댓글 수: 0
답변 (1개)
dpb
2021년 8월 20일
Can't be done with Wilkinson notation -- it only includes integral powers. In this regard, note that "The * operator (for interactions) and the ^ operator (for power and exponents) automatically include all lower-order terms. For example, if you specify x^3, the model will automatically include x3, x2, and x. If you want to exclude certain variables from the model, use the – operator to remove the unwanted terms." which goes to explain why.
You'll have to use the terms matrix form although if it will allow the non-integral value (and I'm not sure whether it will or not) or, if the exponent is fixed, transform the variable and fit the transformed variable.
Otherwise, you'll have to use the fit function from the Curve Fitting TB instead of fitlm or build the model X'*X matrix and use the backslash operator in base MATLAB.
댓글 수: 0
참고 항목
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!