linear regression on excel dataset
古いコメントを表示
I am new in MATLAB and have tried to do a linear regression with the code:
>> filename = 'C:\Users\Troels\Dropbox\Analyse & Resultater\MATLAB\Danmark OX.xls';
>> ds = xlsread(filename) // the dataset "Danmark OX.xls" is printet
>> mdl = LinearModel.fit(ds)
Error using classreg.regr.TermsRegression/handleDataArgs (line 629) Y argument is required unless X is a dataset.
Error in LinearModel.fit (line 891) [X,y,haveDataset,otherArgs] = LinearModel.handleDataArgs(X,varargin{:});
Have also tried the code:
>> ds = dataset('XLSFile','C:\Users\Troels\Dropbox\Analyse & Resultater\MATLAB\Danmark OX.xls','ReadObsNames',true);
Warning: Variable names were modified to make them valid MATLAB identifiers.
> In @dataset\private\genvalidnames at 56
In @dataset\private\setvarnames at 40
In dataset.readXLSFile at 49
In dataset.dataset>dataset.dataset at 352
>> mdl = LinearModel.fit(ds);
Warning: Regression design matrix is rank deficient to within machine precision.
> In TermsRegression>TermsRegression.checkDesignRank at 98
In LinearModel.LinearModel>LinearModel.fit at 944
Am I on the right track in any of my 2 attempts? And can anyone tell me from the above what I do wrong?
1 件のコメント
dpb
2013 年 7 月 28 日
Please reformat the code and remove the excess lines for legibility...
But, the first fails because the LinearModel requires a dataset and the result of xlsread() isn't one...
Second effort is ok from that standpoint but the error/warning indicates your data are poorly scaled -- lookfor "rank deficiency" in the online documentation for what that is if you don't know and possible workarounds.
Better would be to fix that problem w/ better design matrix but sometimes that's not possible.
採用された回答
その他の回答 (1 件)
T27667
2013 年 7 月 28 日
1 件のコメント
Shashank Prasanna
2013 年 7 月 28 日
編集済み: Shashank Prasanna
2013 年 7 月 28 日
I've never used OxMetrics, but you may want to check the documentation of LinearModel.fit for all the calculated goodness of fit statistics. If you don't find a specific one it may be available separately in the Statistics Toolbox.
カテゴリ
ヘルプ センター および File Exchange で Linear Predictive Coding についてさらに検索
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!