Displaying 1 result from an estimated 1 matches for "ik1".
Did you mean:
i1
2008 Feb 21
0
extending code to handle more variables
...,x2,x3) and there could really be n variables (x1,...xn) if need be.
Below is code that works for two variables, I want to convert it to work for
any number of variables. Any ideas?
yk <- numeric(nrow(xk))
for (j in 1:nrow(xk)) {
w1 <- abs(x[,1] - xk$x1[j])
w2 <- abs(x[,2] - xk$x2[j])
Ik1 <- which(w1 <= h[1])
Ik2 <- which(w2 <= h[2])
Ik <- intersect(Ik1, Ik2)
YIk <- yvals[Ik]
yk[j] <- mean(YIk)
}
The result is the one-dimensional vector yk. Does anyone know how to extend
this code to cover any number of variables? Thanks in advance.
dxc13
--
View th...