After using mvregress, how can I find the rsquared value, t-values, p-values, F-statistic, and standard errors?
4 次查看(过去 30 天)
显示 更早的评论
After using mvregress, how can I find the rsquared value, t-values, p-values, F-statistic, standard errors and residual sum of squares? I have run a fixed effect regression using panel data. I have gotten my values for the intercept and slope parametres, however, now I want more information about the model and I'm not sure how to go about it. Any help on this one?
0 个评论
回答(1 个)
Juan Zamora
2015-3-8
Y = ChangePriceSqft;
X = [OneOverSqft, Baths, Distance];
% print scatter plot matrix againt sales
[H,AX,BigAx,P,PAx] = plotmatrix([Y,X],[Y,X]);
% regression model
X = [ones(n,1), X];
%[b, bint, r, rint, stats] = regress(Y, X);
[beta,Sigma,E,CovB,logL] = mvregress(X,Y);
Hypothesis = beta(1) + beta(2) * OneOverSqft + beta(3) * Baths + ...
beta(4) * Distance;
% r-squared
r2 = sum((Hypothesis - mean(Y)).^2) / sum((Y - mean(Y)).^2);
% number of explanatory variables
k = 3;
% Data from the Regression Model
% beta(1); % intercept
% beta(2); % 1/sqft
% beta(3); % baths
% beta(4); % distance
% model Standard Error
Se2 = sum((Y - beta(1) - beta(2) * OneOverSqft - beta(3) * Baths + ...
beta(4) * Distance).^2) / (n-k-1);
Se = sqrt(Se2);
% Partial Slopes - Standard Errors Bx
PartialStdErr = diag(sqrt(CovB)); % mvregress
%t-statistics (Beta / PartialStdErr)
tRatio = beta ./ PartialStdErr;
%p-values
pVals = 2*(1-tcdf(abs(tRatio),n-2));
% Summary Table of the Regression Model
RegressionSummary = [beta, PartialStdErr, tRatio, pVals];
1 个评论
Juan Zamora
2015-3-11
You can find the entire code with the csv file at https://github.com/zamoradev/ML/tree/master/MRM_HomePrices
There are more samples at: https://github.com/zamoradev/ML
另请参阅
类别
在 Help Center 和 File Exchange 中查找有关 Linear Regression 的更多信息
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!