[英]Hide Stepwise Regression in R
我試圖隱藏逐步回歸的結果,以便它不會出現在終端上,但似乎看不見的功能將不起作用。 有沒有辦法隱藏逐步回歸結果? 請參考下面的數據集
library(MASS)
all_df <- data.frame(x1=c(sample(rep(c(4:5),length.out=60)),sample(rep(c(1:3),length.out=40)),sample(rep(c(1:5),length.out=100))),
y1=c(sample(c(0,1), 30,replace=T,prob=c(.3,.7)),c(sample(c(0,1), 30,replace=T)),sample(c(0,1), 40,replace=T,prob=c(.7,.3))),
y2=c(sample(c(0,1), 30,replace=T,prob=c(.3,.7)),c(sample(c(0,1), 30,replace=T)),sample(c(0,1), 40,replace=T,prob=c(.7,.3))))
invisible(result_srk<- as.data.frame(summary( stepAIC(lm(x1~y1*y2
,data=all_df), direction="both"))$coef))
標准方法是使用sink():
sink(tempfile())
result_srk<- as.data.frame(summary( stepAIC(lm(x1~y1*y2,
data=all_df), direction="both"))$coef)
sink()
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.