[R] matrix multivariate bootstrap: order of results in $t component
Michael Friendly
friendly at yorku.ca
Wed Dec 21 20:16:37 CET 2011
[This question is hopefully straight-forward, but difficult to provide
reproducible code.]
I'm doing a multivariate bootstrap, using boot::boot(),
where the output of the basic computation is a k x p matrix of coefficients,
representing a tuning constant x variable, as shown in the $t0 component
from my run, giving a 3 x 6 matrix
> lboot$t0
GNP Unemployed Armed.Forces Population Year GNP.deflator
0.00 -3.4472 -1.828 -0.6962 -0.34420 8.432 0.15738
0.01 -0.1798 -1.361 -0.5881 -1.00317 5.656 -0.02612
0.08 1.0907 -1.086 -0.4583 -0.08596 2.642 0.57025
>
?boot doesn't say how these are strung out to give the 1 x 18 vector in
each row of lboot$t, but I believe
it is done columnwise -- is this correct?
That is, I think that the column names for the bootstrap results,
lboot$t, should vary most quickly down
the columns:
> c(t(outer(colnames(lboot$t0), rownames(lboot$t0), paste, sep=':')))
[1] "GNP:0.00" "GNP:0.01" "GNP:0.08"
[4] "Unemployed:0.00" "Unemployed:0.01" "Unemployed:0.08"
[7] "Armed.Forces:0.00" "Armed.Forces:0.01" "Armed.Forces:0.08"
[10] "Population:0.00" "Population:0.01" "Population:0.08"
[13] "Year:0.00" "Year:0.01" "Year:0.08"
[16] "GNP.deflator:0.00" "GNP.deflator:0.01" "GNP.deflator:0.08"
>
So, the first bootstrap resample would correspond to
> lboot$t[1,]
GNP:0.00 GNP:0.01 GNP:0.08 Unemployed:0.00
-10.1495 -0.8622 1.0566 -2.6131
Unemployed:0.01 Unemployed:0.08 Armed.Forces:0.00 Armed.Forces:0.01
-1.5316 -1.1988 -0.9279 -0.7141
Armed.Forces:0.08 Population:0.00 Population:0.01 Population:0.08
-0.5748 1.8401 -0.9989 -0.3155
Year:0.00 Year:0.01 Year:0.08 GNP.deflator:0.00
12.8984 6.4378 2.7761 0.9417
GNP.deflator:0.01 GNP.deflator:0.08
0.1871 0.9797
Or, as a matrix:
> matrix(lboot$t[1,], nrow=3)
[,1] [,2] [,3] [,4] [,5] [,6]
[1,] -10.1495 -2.613 -0.9279 1.8401 12.898 0.9417
[2,] -0.8622 -1.532 -0.7141 -0.9989 6.438 0.1871
[3,] 1.0566 -1.199 -0.5748 -0.3155 2.776 0.9797
>
Finally, if the above is correct, how can I easily take my R=800
bootstrap estimates in
the 800 x 18 matrix lboot$t and restructure them in a (2400=800x3) x 6
matrix or data.frame
corresponding to stacking the matrices like the above for each bootstrap
sample?
thanks,
-Michael
--
Michael Friendly Email: friendly AT yorku DOT ca
Professor, Psychology Dept.
York University Voice: 416 736-5115 x66249 Fax: 416 736-5814
4700 Keele Street Web: http://www.datavis.ca
Toronto, ONT M3J 1P3 CANADA
More information about the R-help
mailing list