'm'という名前の'lm'オブジェクトからR^2値を抽出します
summary(m)$r.squared
str()
関数を使用すると、Rのオブジェクトの構造をいつでも表示できます。この状況ではあなたが望むstr(summary(m))
ただし、ここで何を達成しようとしているのかは明確ではありません。lm()
指定した関数 の数式引数でselectionArray ~ 0
、これは2つの理由で意味がありません。1)前に示唆したように、数式の右側の0は、予測変数がゼロのベクトルであるモデルに対応します。この予測子に対応するベータ係数は定義できません。2)結果のselectionArrayは行列です。私の知る限り、lm()
複数の結果をもたらすように設定されていません。
selectionArrayの各列が0と異なることの有意性をテストしようとしていますか?その場合、少なくとも1つの成功(1)が含まれる列は、0列とは大幅に異なります。各列の成功確率の信頼区間に関心がある場合は、次のコードを使用してください。これは多重比較を調整しないことに注意してください。
まず、おもちゃの例から始めて、コンセプトを示しましょう
v1 <- rbinom(100,size=1,p=.25)
#create a vector, length 100,
#where each entry corresponds to the
#result of a bernoulli trial with probability p
binom.test(sum(v1), n=length(v1), p = 0)
##let's pretend we didn't just generate v1 ourselves,
##we can use binom.test to determine the 95% CI for p
#now in terms of what you want to do...
#here's a dataset that might be something like yours:
selectionArray <- sapply(runif(10), FUN=function(.p) rbinom(100,size=1,p=.p))
#I'm just generating 10 vectors from a binomial distribution
#where each entry corresponds to 1 trial and each column
#has a randomly generated p between 0 and 1
#using a for loop
#run a binomial test on each column, store the results in binom.test.results
binom.test.results <- list()
for(i in 1:ncol(selectionArray)){
binom.test.results[[i]] <- binom.test(sum(selectionArray[,i]),
n=nrow(selectionArray), p=0)
}
#for loops are considered bad programming in r, so here's the "right" way to do it:
binom.test.results1 <- lapply(as.data.frame(selectionArray), function(.v){
binom.test(sum(.v), n=nrow(selectionArray), p = 0)
})
#using str() on a single element of binom.test.result will help you
#identify what results you'd like to extract from each test