请问下面Matlab程序哪里有问题?运行不出来啊!clear;clc;load('data');n=size(X,1);k=size(X,2);X=[ones(n,1) X];beta_hat=(X'*X)\(X'*y);y_hat=X*beta_hat;variance_matrix=n*inv(X'*X)*(X'*D_hat*X)*inv(X'*X);

来源:学生作业帮助网 编辑:六六作业网 时间:2024/12/24 08:44:29
请问下面Matlab程序哪里有问题?运行不出来啊!clear;clc;load(''data'');n=size(X,1);k=size(X,2);X=[ones(n,1)X];beta_hat=(X''*

请问下面Matlab程序哪里有问题?运行不出来啊!clear;clc;load('data');n=size(X,1);k=size(X,2);X=[ones(n,1) X];beta_hat=(X'*X)\(X'*y);y_hat=X*beta_hat;variance_matrix=n*inv(X'*X)*(X'*D_hat*X)*inv(X'*X);
请问下面Matlab程序哪里有问题?运行不出来啊!
clear;
clc;
load('data');
n=size(X,1);
k=size(X,2);
X=[ones(n,1) X];
beta_hat=(X'*X)\(X'*y);
y_hat=X*beta_hat;
variance_matrix=n*inv(X'*X)*(X'*D_hat*X)*inv(X'*X);

请问下面Matlab程序哪里有问题?运行不出来啊!clear;clc;load('data');n=size(X,1);k=size(X,2);X=[ones(n,1) X];beta_hat=(X'*X)\(X'*y);y_hat=X*beta_hat;variance_matrix=n*inv(X'*X)*(X'*D_hat*X)*inv(X'*X);
有几段缺了,给你重新写了下,请仔细研读.
clear;
clc;
load('data');
n=size(X,1);
k=size(X,2);
X=[ones(n,1) X];
beta_hat=(X'*X)\(X'*y);
y_hat=X*beta_hat;
e_hat=y-y_hat;
D_hat=diag(e_hat.^2);
variance_matrix=n*inv(X'*X)*(X'*D_hat*X)*inv(X'*X);