[R] apply
Richard O'Keefe
r@oknz @end|ng |rom gm@||@com
Sat Oct 5 02:03:22 CEST 2024
> x <- runif(10)
> y <- runif(10)
> cov(cbind(x,y))
x y
x 0.1205034 0.02642830
y 0.0264283 0.09945432
I understand wanting to calculate covariance matrices.
What I DON'T understand is wanting to do it using apply().
(And that's what looked like a homework problem, it's so artificial.)
On Sat, 5 Oct 2024 at 01:41, Ivan Krylov via R-help
<r-help using r-project.org> wrote:
>
> В Fri, 4 Oct 2024 20:28:01 +0800
> Steven Yen <styen using ntu.edu.tw> пишет:
>
> > Suppose I have two vectors, x and y. Is there a way
> > to do the covariance matrix with “apply”.
>
> There is no covariance matrix for just two samples (vectors) 'x' and
> 'y'. You can only get one covariance value for these.
>
> If you had a pair of vectors of _random variates_, the situation would
> be different, but those are more abstract mathematical concepts. You
> would need to sample every random variate, producing two matrices 'x'
> and 'y' in order to calculate a covariance matrix for them.
>
> --
> Best regards,
> Ivan
>
> ______________________________________________
> R-help using r-project.org mailing list -- To UNSUBSCRIBE and more, see
> https://stat.ethz.ch/mailman/listinfo/r-help
> PLEASE do read the posting guide https://www.R-project.org/posting-guide.html
> and provide commented, minimal, self-contained, reproducible code.
More information about the R-help
mailing list