Skip to content
Back to formatted view

Raw Message

Message-ID: <5086A654.5090409@yorku.ca>
Date: 2012-10-23T14:14:44Z
From: Michael Friendly
Subject: Help with applying a function to all possible 2x2 submatrices
In-Reply-To: <1350925826268-4647048.post@n4.nabble.com>

On 10/22/2012 1:10 PM, CMB123 wrote:
> Hi all,
>
> I'm working with a large data set (on the order of 300X300) and trying to
> apply a function which compares the elements of all possible 2x2
> submatrices. There are rc(r-1)(c-1) such submatrices, so obviously the naive
> method of looping through the rows and columns is computationally unfeasible
> for my data set:
>
>    for(i in 1:(nrow(data)-1)) {
>      for(j in (i+1):nrow(data)) {
>        for (m in 1:(ncol(data)-1)) {
>          for (n in (m+1):ncol(data)) {
>
> I have tried using the outer and apply functions to vectorize the task, but
> I can't seem to figure out the best method (or any method, for that matter)
> to help with what I'm trying to do.
>

See the function vcdExtra::loddsratio for something similar


-- 
Michael Friendly     Email: friendly AT yorku DOT ca
Professor, Psychology Dept.
York University      Voice: 416 736-2100 x66249 Fax: 416 736-5814
4700 Keele Street    Web:   http://www.datavis.ca
Toronto, ONT  M3J 1P3 CANADA