[R] Pseudodataset text file
Dan Janes
djanes at oeb.harvard.edu
Mon Jun 13 20:33:26 CEST 2005
Hi All,
Two weeks ago, I received instructions from the R list about creating
pseudodatasets by bootstrapping an existing dataset 1000 times. I received
code that bootstrapped my dataset and ran an ANOVA on each pseudodataset,
producing a histogram of F-values. Here is the code I received that
produces this F-histogram.
X <- data.frame(b=rnorm(2162),c =factor(rep(1:47,each=46)))
## linear fit with true values
lm0 <- lm(b~c,data=X)
Fvals <- numeric(1000)
for (i in 1:1000) {
X.boot <- X[sample(1:nrow(X),replace=TRUE),]
Fvals[i] <- anova(lm(b~c,data=X.boot))$"F value"[1]
}
hist(Fvals)
I am grateful for the assistance but the code does not provide what I
need. I need the 1000 pseudodatasets produced by the bootstrap in order to
work with them in a different context. Can you someone offer a suggestion
on how to produce the bootstrapped datasets as a text file?
Thank you.
-Dan
************************************************
Dan Janes, Ph.D.
Harvard University/OEB
26 Oxford St.
Cambridge, MA 02138
Office: 617-496-2375
Fax: 617-495-5667
Email: djanes at oeb.harvard.edu
More information about the R-help
mailing list