[R] How to find more about Covariance (in R)
Alaios
alaios at yahoo.com
Wed Jan 19 15:59:51 CET 2011
Dear Josh,
I would like to thank you for your reply.
I think that it is clear that I miss a lot of theory. I have tried in google to read and study more about covariance but I have this feeling that the term 'covariance' is used for many different things in different topics.
You mentioned for example population and sample (covariance) which are two words-terms that I can not distinguish between them.
Even though this is R list could you please provide me some differences to study more about covariance before trying to implement things in R.
(Even in R are some things that do not understand i.e pearson, kendal and spearman method)
I would like to thank you in advance for your patience.
Best Regards
Alex
--- On Wed, 1/19/11, Joshua Wiley <jwiley.psych at gmail.com> wrote:
> From: Joshua Wiley <jwiley.psych at gmail.com>
> Subject: Re: [R] How to find more about Covariance (in R)
> To: "Alaios" <alaios at yahoo.com>
> Cc: r-help at stat.math.ethz.ch
> Date: Wednesday, January 19, 2011, 2:36 PM
> Hi Alex,
>
> cov() uses the formula for a sample covariance. The
> denominator is N
> - 1 instead of N. However, the formula you used from
> Wikipedia is for
> a population covariance. To move between the two in
> this case:
>
> cov(sr, sr) * (4/5) # should equal E[XX] - E[x] * E[x]
>
> Cheers,
>
> Josh
>
> On Wed, Jan 19, 2011 at 6:29 AM, Alaios <alaios at yahoo.com>
> wrote:
> > Hello everyone,
> > I am trying to understand how covariance work. So I
> created a vector called sr<-c(2,5,7,5,2)
> >
> > so according to wikipedia Cov(X,X)=E[XX]-E[x]*E[x]
> which in R is
> >
> >
> > mean(sr*sr)-mean(sr)*mean(sr)
> > [1] 3.76
> >
> > but also
> >
> > cov(sr,sr)
> > [1] 4.7
> >
> > why is this difference between these two approaches?
> Where I am wrong?
> >
> > I would like to thank you in advance for your help
> >
> > Best Regards
> > Alex
> >
> > ______________________________________________
> > R-help at 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.
> >
>
>
>
> --
> Joshua Wiley
> Ph.D. Student, Health Psychology
> University of California, Los Angeles
> http://www.joshuawiley.com/
>
More information about the R-help
mailing list