这段代码将返回系数:intercept,slop1,slop2
set.seed(1)
n=10
y=rnorm(n)
x1=rnorm(n)
x2=rnorm(n)
lm.ft=function(y,x1,x2)
return(lm(y~x1+x2)$coef)
res=list();
for(i in 1:n){
x1.bar=x1-x1[i]
x2.bar=x2-x2[i]
res[[i]]=lm.ft(y,x1.bar,x2.bar)
}
Run Code Online (Sandbox Code Playgroud)
如果我输入:
> res[[1]]
Run Code Online (Sandbox Code Playgroud)
我明白了:
(Intercept) x1 x2
-0.44803887 0.06398476 -0.62798646
Run Code Online (Sandbox Code Playgroud)
我们如何返回预测值,残差,R square,..等?
我需要一些通用的东西从摘要中提取我需要的东西?