0
おかげregarding the failure of stepwise variable selection in lmステップパッケージのしきい値を設定する方法は?その記事で説明したように、この記事へ
私は例のデータを持っているが、以下のように見える、私は必要なもの
set.seed(1) # for reproducible example
x <- sample(1:500,500) # need this so predictors are not perfectly correlated.
x <- matrix(x,nc=5) # 100 rows, 5 cols
y <- 1+ 3*x[,1]+2*x[,2]+4*x[,5]+rnorm(100) # y depends on variables 1, 2, 5 only
# you start here...
df <- data.frame(y,as.matrix(x))
full.model <- lm(y ~ ., df) # include all predictors
step(full.model,direction="backward")
は、これらのうちわずか5最高の変数と、その後6つの最良の変数を選択することです20、誰もこのcontarainsを作る方法を知っていますか?