- The matrix used to fit a linear model by will become rank deficient. When we try to fit a linear model with the above mentioned fields, MATLAB will throw a warning that the Regression design matrix is rank deficient.
- Also, the above mentioned fields do not add any value to the model fitting. If some property is same at all data samples, its value has no importance in deciding the output of the model for any sample. It is a constant property.
Scatterplot and Correlation of table variables
조회 수: 7 (최근 30일)
이전 댓글 표시
Hello there
Q = readtable("DA.xlsx")
x=[Q.Tam,Q.Az,Q.Clp,Q.Dp,Q.DH,Q.DN,Q.EB, Q.Pw ,Q.Sd,Q.Prs,Q.WD,Q.WV,Q.AD, Q.ZT, Q.La, Q.Lo, Q.Al];
y=[Q.GH];
mdl=fitlm(x,y)
corrplot(Q)
Please why does the pvalue for X9, X13, X15, X16 return NaN and not X17 even though X17 have the same values all through.?
Also how do I get how do I get scatter plot and how can I fix the correlation of Input variables with output GH?
댓글 수: 0
채택된 답변
Pratyush
2023년 6월 16일
Hi Mbunya.
It is my understanding that you are trying to fit a linear model to the data stored in x with y as the ground truth. However, you are getting NaN as the value of some weights after fittting a linear model. I have analysed your data and I feel the problem seems to be occuring because of the following reason.
Some columns in your data - Sd, AD, La, Lo and Al have the same value at all data samples. There are two problems that will occur because of this while fitting a linear model.
I retrained the model using your data after removing the above mentioned constant properties as shown below.
x=[Q.Tam,Q.Az,Q.Clp,Q.Dp,Q.DH,Q.DN,Q.EB, Q.Pw ,Q.Prs,Q.WD,Q.WV, Q.ZT];
y=[Q.GH];
mdl=fitlm(x,y)
This time no NaN vaues were observed for any weights or the intercepts in the linear model as shown in the image below. Hope this resolves your problem.
Here are some additional resources to help you with linear regression.
추가 답변 (0개)
참고 항목
카테고리
Help Center 및 File Exchange에서 Regression에 대해 자세히 알아보기
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!