2016-01-18 60 views
2

運行雙向列聯表對應分析它不會出現在這個表上工作,名爲MyTable:不能使用FactoMineR

   0  1  2  3  4  5  7 
Click_No 242854 91661 102  21  65  51 291 
Click_Yes 48274 20785  14  2  19  4 146 

但是,它適用於該表:

  0  1  2  3  4  5  7 
Row1  4  0  0  0  0  0  11 
Row2  35  2  0  0  0  0  0 
Row3 18364  14  0  0  0  0  0 
Row4  13  0  0  0  0  0  7 
Row5 1497 1521  6  0  0  0  0 
Row6 686  2  0  0  0  0 393 
Row7 270167 110512 110  23  84  54  0 
Row8  1  0  0  0  0  0  26 
Row9 361 395  0  0  0  1  0 

我用了FactoMineR功能:

res.ca <- CA(mytable) 

是否CA不規範工作各種類型的應急表?我沒有讀過任何文獻中的建議,除非是非常大的尺寸。

Error generated when running summary(res.ca): 

Call: 
CA(X = mytable) 

The chi square of independence between the two variables is equal to 297.3778 (p-value = 2.982623e-61). 

Eigenvalues 
        Dim.1 
Variance    1e-03 
% of var.   1e+02 
Cumulative % of var. 1e+02 

Rows 
Error in if (nrow(res$row$coord) > nbelements) cat(paste(" (the ", nbelements, : 
    argument is of length zero 
In addition: Warning message: 
In max(nchar(rownames(res[aux[1]][[1]]$coord))) : 
    no non-missing arguments to max; returning -Inf 

編輯:

dput(mytable)輸出:

mytable <- structure(c(242854L, 48274L, 91661L, 20785L, 102L, 14L, 21L, 
2L, 65L, 19L, 51L, 4L, 291L, 146L), .Dim = c(2L, 7L), .Dimnames = structure(list(
    c("0", "1"), c("0", "1", "2", "3", "4", "5", "7")), .Names = c("", 
"")), class = "table") 
+0

當然'res.ca < - CA(* tableordataframename *)'是不是一個正確的語法。請修復。另外,發佈'dput(mytable)'。 –

+0

當然可以。謝謝。 – iuppiter

+0

我有一個不同的錯誤,但它是一個錯誤。 –

回答

2

我認爲這個問題是統計和計算不是。對應分析產生了最大的min(j-1; i-1)維度,其中i是行數,j是列數(即兩個變量的模態數)。您正試圖執行j = 2; i = 8列聯表的CA。它只能輸出一個軸。這就是爲什麼你會得到這個錯誤:你不應該使用CA與雙模態變量。

有這個p的數學解釋。例如Benzecry的Correspondance Analysis Handbook。如果您在CV上提出關於此問題,您可能會得到更好的解釋。

這裏是與children數據在FactoMineR設置一個例子:

library(FactoMineR) 
data("children") 
## Example from help("CA"), works fine 
summary(CA(children, row.sup = 15:18, col.sup = 6:8)) 
## Example when we restrict the contingency table to the first two rows. 
## Produces an error 
summary(CA(children, row.sup = 3:18, col.sup = 6:8))