cubic spline regression and plot
조회 수: 9 (최근 30일)
이전 댓글 표시
Dear all,
I have two variables X and Y.
X and Y are both vectors of dimension 8561X1
For example:
X=[ 1
1
1
1
1
5
1];
Y=[ 34200
34201
34202
34203
34204
34205
34210]
I want to regress X on Y using a cubic spline specification and then take the ratio X/
, where
, is the fitted values obtained from the cubic spline regression
![](https://www.mathworks.com/matlabcentral/answers/uploaded_files/201759/image.png)
![](https://www.mathworks.com/matlabcentral/answers/uploaded_files/201759/image.png)
And I want to place the knots at specific positions, eg, 2nd and 5th position.
I found the rcspline package and I did something like
[bhat f sse knots]=rcspline(X,y,knots);
but I am not sure how to address the knots's position.
Any help is greatly appreciated.
Thanks,
댓글 수: 0
채택된 답변
Image Analyst
2019년 1월 28일
I don't know about the ratio stuff but you can adapt my cubic spline demo (attached).
댓글 수: 0
추가 답변 (1개)
참고 항목
카테고리
Help Center 및 File Exchange에서 Splines에 대해 자세히 알아보기
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!