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
조회 수: 1 (최근 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!