Note that there are some explanatory texts on larger screens.

plurals
  1. POp-value matrix of x and y variables from anova output
    primarykey
    data
    text
    <p>I have many X and Y variables (something like, 500 x 500). The following just small data: </p> <pre><code>yvars &lt;- data.frame (Yv1 = rnorm(100, 5, 3), Y2 = rnorm (100, 6, 4), Yv3 = rnorm (100, 14, 3)) xvars &lt;- data.frame (Xv1 = sample (c(1,0, -1), 100, replace = T), X2 = sample (c(1,0, -1), 100, replace = T), Xv3 = sample (c(1,0, -1), 100, replace = T), D = sample (c(1,0, -1), 100, replace = T)) </code></pre> <p>I want to extact p-values and make a matrix like this: </p> <pre><code> Yv1 Y2 Yv3 Xv1 X2 Xv3 D </code></pre> <p>Here is my attempt to loop the process:</p> <pre><code>prob = NULL anova.pmat &lt;- function (x) { mydata &lt;- data.frame(yvar = yvars[, x], xvars) for (i in seq(length(xvars))) { prob[[i]] &lt;- anova(lm(yvar ~ mydata[, i + 1], data = mydata))$`Pr(&gt;F)`[1] } } sapply (yvars,anova.pmat) Error in .subset(x, j) : only 0's may be mixed with negative subscripts What could be the solution ? </code></pre> <p><strong>Edit:</strong></p> <p>For the first Y variable:</p> <p>For first Y variable: </p> <pre><code>prob &lt;- NULL mydata &lt;- data.frame(yvar = yvars[, 1], xvars) for (i in seq(length(xvars))) { prob[[i]] &lt;- anova(lm(yvar ~ mydata[, i + 1], data = mydata))$`Pr(&gt;F)`[1] } prob [1] 0.4995179 0.4067040 0.4181571 0.6291167 </code></pre> <p>Edit again:</p> <pre><code>for (j in seq(length (yvars))){ prob &lt;- NULL mydata &lt;- data.frame(yvar = yvars[, j], xvars) for (i in seq(length(xvars))) { prob[[i]] &lt;- anova(lm(yvar ~ mydata[, i + 1], data = mydata))$`Pr(&gt;F)`[1] } } Gives the same result as above !!! </code></pre>
    singulars
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload