Thanks, Jeff. I had some misunderstanding.
So, I want to calculate the squared exponential of vector v
v = c(700, 800, 1029)
formula is:
k(x_i, x_j)=sigma^2 * exp(-1/(2*l^2) * (x_i - x_j) ^2)
where,
sigma=7, l=100
I used,
v <- c(700, 800, 1029)
corr.matrix(cbind(v),scales=0.5)
[,1] [,2] [,3]
[1,] 1 0 0
[2,] 0 1 0
[3,] 0 0 1
the output should be covariance matrix = [49, 29.7, 0.02; 29.7, 49,
3.6;
0.2, 3.6, 49]
On Sun, Nov 2, 2014 at 7:04 PM, Jeff Newmiller
<jdnewmil at dcn.davis.ca.us>
wrote:
What is your question? The matrix form is probably what you are
for, but you put the same vector in three times so if course it is
ones. I don't know what you expected to happen when you entered
since there is nothing to correlate if you only have one vector.
Please post in plain text as the footer and Posting Guide request.
---------------------------------------------------------------------------
Jeff Newmiller The ..... ..... Go
DCN:<jdnewmil at dcn.davis.ca.us> Basics: ##.#. ##.#. Live
Go...
Live: OO#.. Dead: OO#..
Research Engineer (Solar/Batteries O.O#. #.O#. with
/Software/Embedded Controllers) .OO#. .OO#.
---------------------------------------------------------------------------
Sent from my phone. Please excuse my brevity.
On November 2, 2014 3:30:14 PM PST, C W <tmrsg11 at gmail.com> wrote:
Hi list,
I have trying to calculate the covariance/correlation of three
elements. I
have vector say,
v <- c(700, 800, 1000)
I want to have a 3 by 3 correlation matrix, meaning cor(v1, c2),
cor(v1,
c3), cor(v2, v3), etc...
So far I get,
Error in cor(v) : supply both 'x' and 'y' or a matrix-like 'x'
vvv <- cbind(v, v, v)
cor(vvv)