How do I run the program below in Matlab? b) How do I extend this program to calculate the R2 of this regression? How do I calculate the covariance matrix of the OLS estimator
2 ビュー (過去 30 日間)
古いコメントを表示
n=100;
alpha=1;
beta=1.5;
e = randn(n,1);
x=rand(n,1);
y=alpha + x*beta + e;
x=[ones(n,1), x];
bhat = inv(x'*x)*x'*y;
disp 'The OLS estimate of beta is';
disp(bhat);
resids = y - x*bhat;
s2 = resids'*resids/(n-2);
disp 'The OLS estimator of the error variance is';
disp(s2);
a) Run the above program in Matlab and describe what each line of this program does.
b) Extend this program to calculate the R2 of this regression and print out the result.
c) Extend this program to calculate the covariance matrix of the OLS estimators
0 件のコメント
回答 (0 件)
参考
カテゴリ
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!