Dear Seyit,
You might consider the boot package in this situation. Here is an example:

require(boot)

DF<-data.frame(Xvar,Yvar)

temp <- boot(DF, function(DF,d){
                  S <- DF[d,]
                  cor(S$Xvar,S$Yvar)
                   },
                  R = 5000)
temp$t0
# [1] 0.617422
max(temp$t)
# [1] 0.7783784
hist(temp$t)

Once you load the boot package, take a look at ?boot.

HTH,

Jorge


On Tue, Apr 21, 2009 at 4:53 AM, Seyit Ali Kayis <s_a_ka...@hotmail.com>wrote:

>
> Dear R users,
>
> I need to do sampling without replacement (bootstraps). I have two
> variables (Xvar, Yvar).
> I have a correlation from original data set cor(Xvar, Yvar)=0.6174221. I am
> doing 50000 sampling,
> and in each sampling  calculating correlations, saving, sorting and
>  getting 95% cutt off point (0.1351877).
> I am getting maximum value as 0.3507219 (much smaller than correlation of
> my original data).
> I repeated the sampling a  couple of time and none of them produced a
> correlation
> coefficient higher than my original data set. However, if I sort out my
> Xvar and Yvar and
> obtain correlation it is 0.9657125 which is much higher than correlation
> for my original data.
> I am doing sampling in another program and getting at least 1% higher
> correlation than mine.
> Now I am getting confused with sampling(random data) in R. My data and
> codes for the scenario above are
> in the attached file. I want to understand where I am making a mistake. Any
> comment is deeply appreciated.
>
> Kind Regards
>
> Seyit Ali
>
>
>
> ------------------------------------------------------------------------------------------------------------------
> Dr. Seyit Ali KAYIS
> Selcuk University
> Faculty of Agriculture
> Kampus, Konya, TURKEY
>
>            s_a_ka...@yahoo.com,    s_a_ka...@hotmail.com
> Tell: +90 332 223 2830  Mobile: +90 535 587 1139  Fax: +90 332 241 0108
>
>                   Greetings from Konya, TURKEY
>                http://www.ziraat.selcuk.edu.tr/skayis/
>
> ----------------------------------------------------------------------------------------------------------------------
>
>
>
>
>
>
> _________________________________________________________________
> No-one wants to be lonely this Autumn Find someone to snuggle up with
>
>
> Fchannel%2Findex%2Easpx%3Ftrackingid%3D1048628&_t=773568480&_r=nzWINDOWSliveMAILemailTAGLINES&_m=EXT
> ______________________________________________
> R-help@r-project.org mailing list
> https://stat.ethz.ch/mailman/listinfo/r-help
> PLEASE do read the posting guide
> http://www.R-project.org/posting-guide.html
> and provide commented, minimal, self-contained, reproducible code.
>
>

        [[alternative HTML version deleted]]

______________________________________________
R-help@r-project.org mailing list
https://stat.ethz.ch/mailman/listinfo/r-help
PLEASE do read the posting guide http://www.R-project.org/posting-guide.html
and provide commented, minimal, self-contained, reproducible code.

Reply via email to