Hi:
Does this work?
df <- data.frame(x = rnorm(49, mean = 1), y = rnorm(49, mean = 2))
# Generate matrix of bootstrap indices
idx <- matrix(sample(1:nrow(df), 50 * nrow(df), replace = TRUE),
nrow = nrow(df))
dim(idx)
# [1] 49 50
# Generate the corresponding x, y, bootstrap samples by
I have a similar question.
I want to generate list of 50 bootstrap samples,
it can be done by:
lapply(1:50,function(i){data[sample(nrow(data),size=nrow(data),replace=TRUE),]})
>From these bootstrap samples, I want to work out the Bootstrap estimates,
which is E[y]/E[x].
How can I do it?
'>> da
If I read your question now, I think, that I didn't understand you
correctly, but...
My code generates 50 bootstrap samples (50 tables) and for each
calculates mean of column x and mean of column y, so the final result
is matrix with means.
If you don't want to calculate means, code below generat
Hi there,
This seems to 'simple' for that. ( I mean the codes are too good)
Can I ask for a bit explaination? or some simplier (maybe few more line
codes) to archieve that goal?
And the codes you gave here,
first line give a table with x and y , random normal values,
but the second line, what d
data<-data.frame(x=rnorm(49), y=rnorm(49))
t(sapply(1:50,function(i){colMeans(data[sample(nrow(data),size=nrow(data),replace=TRUE),])}))
r-help@r-project.org
2009/12/7 casperyc :
>
> Hi there,
>
> i think that's not what i was aiming for...
>
> i was aked to
>
> Generate 50 Bootstrap samples and
Hi there,
i think that's not what i was aiming for...
i was aked to
Generate 50 Bootstrap samples and corresponding estimates
if i do data[sample(nrow(data),size=50,replace=TRUE),]
it will give me a table of 50 rows ( 50 sets of x and y)
then how do i estimate the mean? ( mean was esitmated b
casperyc hotmail.co.uk> writes:
> I have 49 pairs in my data.frame 'data'
>
> x y
> 7680
> ... ...
>
> how do I get a bootstrap sample of size n=50?
>
data[sample(nrow(data),size=50,replace=TRUE),]
__
R-help@r-project.org mailing list
http
7 matches
Mail list logo