Variable length & Stepwise regression

1 Ansicht (letzte 30 Tage)
Yaojiayin
Yaojiayin am 18 Sep. 2014
Kommentiert: Yaojiayin am 19 Sep. 2014
I want to create a dataset
A = dataset('File',Araa06.txt');
Matlab returens errors:
Misuse dataset/readFile (line 207) Variable lengths must all be the same.
Error dataset (line 351) a = readFile(a,fileArg,otherArgs)
What could be the problem?
If I want to use dataset A for stepwise regression
mdl=stepwiselm(A,'Predictor variables','DEM','grad','Response variable','Yield')
What is the different between this one and
stepwise
If I just want to do stepwise regression, do I really need to build a model?

Akzeptierte Antwort

Roger Wohlwend
Roger Wohlwend am 19 Sep. 2014
If you copy the contents of your txt-file and paste it into an Excel file, you see that not all numbers are separated by a tab. Some are separated by blanks. I guess that is why Matlab cannot read the txt file properly. It expects all numbers to be separated by tabs. So you have to fix the txt file first.
For stepwise regression you can use either stepwiselm or stepwise. They are basically the same. The latter offers you a GUI, the first is a class. I would recommend stepwiselm. You don't need a GUI. Just work with the class.
  1 Kommentar
Yaojiayin
Yaojiayin am 19 Sep. 2014
Thanks for your reply! I fixed the problem by just copy the first row(name of variables) in the original data file (in form of .txt) to Araa06, and it worked (for some reason). Then I did stepwiselm and wrote a report to my teacher.
Thanks again for answering my question!

Melden Sie sich an, um zu kommentieren.

Weitere Antworten (0)

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!

Translated by