[R] correlation with boot
Prof Brian Ripley
ripley at stats.ox.ac.uk
Tue Sep 2 09:26:33 CEST 2008
On Tue, 2 Sep 2008, ctu at bigred.unl.edu wrote:
> Hi Professor Ripley,
> (Thank you very much)^infinite for your response. I still have few questions
> 1. R shows that I have two column in nlaw data.
>  2
>  0.7763745
Since we don't have law, we don't know what nlaw is: you recomputed it
after listing it.
> 2. Why can't I use boot::corr? I check corr in boot package and it seems to
> be used for computing correlation coefficient,right?
You can, but you need to use it correctly. I gave you one suggestion that
most people find simpler to understand.
> 3. The last question, cor is for computed the correlation variance and
> covariance matrix. Would you give a explanation for cor(data[ind,])[1,2]
> I do not get it.
Try the pieces for yourself. What does cor(nlaw) give? cor(nlaw)[1,2]?
> Quoting Prof Brian Ripley <ripley at stats.ox.ac.uk>:
>> Please look at the help for boot, in particular what it says the form
>> of 'statistic' should be. Possibly what you want is
>> corr.t <- function(data, ind) cor(data[ind,])[1,2]
>> nlaw appears to be a single-column matrix: that will not work either.
>> On Mon, 1 Sep 2008, ctu at bigred.unl.edu wrote:
>>> Hi R users,
>>> I have one simple question but I really don't know why I can't get it
>>> The data was adopted from Efron's An introduction to the bootstrap book.
>>> LSAT GPA
>>> [1,] 576 3.39
>>> [2,] 635 3.30
>>> [3,] 558 2.81
>>> [4,] 578 3.03
>>> [5,] 666 3.44
>>> [6,] 580 3.07
>>> [7,] 555 3.00
>>> [8,] 661 3.43
>>> [9,] 651 3.36
>>> [10,] 605 3.13
>>> [11,] 653 3.12
>>> [12,] 575 2.74
>>> [13,] 545 2.76
>>> [14,] 572 2.88
>>> [15,] 594 2.96
>>> + return(boot::corr(data))
>>> + }
>>> Error in statistic(data, original, ...) : unused argument(s) (1:15)
>>> many thanks for the help
>>> R-help at r-project.org mailing list
>>> PLEASE do read the posting guide
>>> and provide commented, minimal, self-contained, reproducible code.
>> Brian D. Ripley, ripley at stats.ox.ac.uk
>> Professor of Applied Statistics, http://www.stats.ox.ac.uk/~ripley/
>> University of Oxford, Tel: +44 1865 272861 (self)
>> 1 South Parks Road, +44 1865 272866 (PA)
>> Oxford OX1 3TG, UK Fax: +44 1865 272595
Brian D. Ripley, ripley at stats.ox.ac.uk
Professor of Applied Statistics, http://www.stats.ox.ac.uk/~ripley/
University of Oxford, Tel: +44 1865 272861 (self)
1 South Parks Road, +44 1865 272866 (PA)
Oxford OX1 3TG, UK Fax: +44 1865 272595
More information about the R-help