R2ucare: Error in Y[, i] : subscript out of bounds

questions concerning analysis/theory using programs M-SURGE, E-SURGE and U-CARE

R2ucare: Error in Y[, i] : subscript out of bounds

Postby tenan.simone » Wed Mar 13, 2024 7:13 am

Hi all,
Using function overall_JMV() I get "Error in Y[, i] : subscript out of bounds". It seems the error comes from the group_data_gen() function inside the overall_JMV() function, but I don't know why. Here is the reproducible example:

Code: Select all
library(R2ucare)

ch <- matrix(scan(text = "
0 0 0 0 0 3 0 0 0 0 0 0 0 0 0 0 0 0 0
0 0 0 0 0 0 0 0 0 0 0 0 0 4 0 0 0 0 0
0 0 0 0 0 0 0 0 3 0 4 0 0 0 0 0 0 4 0
0 0 3 0 0 0 0 0 0 0 0 0 0 0 0 0 0 3 0
0 3 0 0 0 0 0 0 0 0 4 0 0 0 4 0 4 0 0
0 0 3 4 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
3 0 0 0 0 4 0 0 0 4 0 0 0 0 0 4 0 4 4
1 1 1 0 0 0 0 0 0 3 3 0 0 0 0 0 0 0 0
3 0 0 0 0 0 0 0 0 0 0 0 0 0 0 3 0 0 0
0 3 3 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
0 4 4 0 4 0 4 0 0 0 4 4 4 4 0 4 0 4 0
0 4 4 0 0 0 0 0 0 0 0 0 4 0 4 4 4 0 0
0 3 3 3 0 0 0 0 0 3 3 0 0 4 4 4 0 4 4
0 3 0 0 0 0 0 0 0 0 0 0 3 0 0 0 0 4 0
0 0 0 0 0 0 0 0 0 1 0 1 0 0 2 0 0 0 0
0 4 0 0 4 0 0 0 0 0 4 0 0 0 0 0 0 0 0
0 1 0 1 1 0 0 0 0 2 2 0 0 0 0 3 0 3 0
0 4 0 0 0 0 0 0 0 0 0 0 4 0 4 0 0 4 4
0 3 3 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
0 3 0 0 0 0 0 0 0 0 0 0 0 0 0 3 0 3 0
0 0 3 0 0 0 0 0 4 0 0 4 0 0 0 0 0 4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 0 0
4 4 0 0 4 0 0 0 0 0 4 0 0 0 0 0 0 4 4
4 4 4 0 4 0 0 4 0 0 4 0 0 4 0 0 0 0 4"),nrow = 50,byrow = TRUE)

freq=rep(1,nrow(ch))

overall_JMV(ch,freq)

Many thanks in advance for your hints,
Simone
tenan.simone
 
Posts: 2
Joined: Thu Nov 13, 2014 12:04 pm

Re: R2ucare: Error in Y[, i] : subscript out of bounds

Postby simone77 » Thu Mar 14, 2024 12:57 pm

Hi Simone,

I have had a look at it and it seems something wrong happening with the test3Gsm() function that is one of the four functions (tests) run within the function overall_JMV().

Code: Select all
freq0 = rep(1,nrow(ch))

overall_JMV(ch,freq0)
test3Gsr(ch,freq0)
test3Gsm(ch,freq0)
testMitec(ch,freq0)
testMltec(ch,freq0)


Then, if you look at the test3Gsm() code you'll see that it something wrong is happening with your dataset because:

Code: Select all
  X = ch
  freq = freq0
  k = ncol(X)
  res = group_data(X, freq)
  dim(X)
  dim(res)


indicates that the function group_data() is changing the number of the rows (from 50 to 49), something that does not happen with the Geese dataset you may find in the example of the function test3Gsm(). I am sorry I had no time to deep further but I think the problem must be there...

Simone
simone77
 
Posts: 200
Joined: Mon Aug 10, 2009 2:52 pm


Return to analysis help

Who is online

Users browsing this forum: No registered users and 1 guest

cron