當使用mshapiro錯誤。測試:U[]不是一個包含3到5000個列(樣本大小)的矩陣。

[英]Error when using mshapiro.test: “U[] is not a matrix with number of columns (sample size) between 3 and 5000”


I am trying to perform a multivariate test for normality on some density data from five sites, using mshapiro.test from the mvnormtest package. Each site is a column, and densities are below. It is 5 columns and 5 rows, with the top row as the header (site names). Here is how I loaded my data:

我正在嘗試用mshapiro對5個地點的密度數據進行正態多變量檢驗。來自mvnormtest包的測試。每個點都是一列,密度在下面。它是5列5行,第一行作為標題(站點名)。以下是我如何加載我的數據:

datafilename="/Users/megsiesiple/Documents/Lisa/lisadensities.csv"
data.nc5=read.csv(datafilename,header=T)
attach(data.nc5)` 

The data look like this:

數據如下:

       B07      B08      B09      B10        M  
1 72571.43 17714.29  3142.86 22571.43  8000.00
2 44571.43 46857.14 49142.86 16857.14  7142.86
3 54571.43 44000.00 26571.43  6571.43 17714.29
4 57714.29 38857.14 32571.43  2000.00  5428.57

When I call mshapiro.test() for data.nc5 I get this message: Error in mshapiro.test(data.nc5) : U[] is not a matrix with number of columns (sample size) between 3 and 5000

當我調用mshapilo .test()獲取數據時。我得到了這樣的消息:mshapilo .test(data.nc5)中的錯誤:U[]不是一個列數(樣本大小)在3到5000之間的矩陣

I know that to perform a Shapiro-Wilk test using mshapiro.test(), the data has to be in a numeric matrix, with a number of columns between 3 and 5000. However, even when I make the .csv a matrix with only numbers (i.e., when I omit the Site names), I still get the error. Do I need to set up the matrix differently? Has anyone else had this problem? Thanks!

我知道要使用mshapiro.test()執行Shapiro-Wilk測試,數據必須在數字矩陣中,列數在3到5000之間。然而,即使我把。csv設置為一個只有數字的矩陣(例如。,當我省略網站名稱時),我仍然會得到錯誤。我需要以不同的方式建立矩陣嗎?還有人有這個問題嗎?謝謝!

1 个解决方案

#1


2  

If you read the numeric matrix into R via read.csv() using similar code to that you do show, it will be read in as a data frame, and that is not a matrix.

如果您通過read.csv()將數字矩陣讀入R,並使用與您所顯示的代碼類似的代碼,那么它將作為數據幀讀取,而不是矩陣。

Try

試一試

mat <- data.matrix(data.nc5)
mshapiro.test(mat)

(Not tested as you don't give a reproducible example and it is late-ish in my time zone now ;-)

(沒有經過測試,因為你沒有給出一個可重復的例子,而且現在我的時區有點晚;)


注意!

本站翻译的文章,版权归属于本站,未经许可禁止转摘,转摘请注明本文地址:https://www.itdaan.com/blog/2011/07/27/eadc865c6c7b530239fc428c16364798.html



 
粤ICP备14056181号  © 2014-2020 ITdaan.com