r - -- How to start a loop with a first guess? -


This is Compact 101 stuff, but I did not get an answer applied to R (or MATAB).

I have the loop that I want to start with the first guess (all but zero here, but maybe some later), but I want to update with each move. I work below, but it is very crappy and embarrassing.

I want to avoid a walking before for loop. I can do this with a ifelse inside the loop, but it is disabled. Thanks!

  alpha & lt; - 0.3beta & lt; - 0.6 m & lt; - 5 # elements in kn1; - 10 # iterations k.prime & lt; - v & lt; - Matrix (0, K colnames (v) & lt; - colnames (k.prime) & lt; - round (k, k, numerals = 2) First loop; i & lt; - 1 for (j: 1: m) {temp.v <- log (k [j] ^ alpha-k) + beta * representative (0, time = m) v [i, j]  

input v [1,] , first loop and fix i index i + 1 elsewhere.
It should look like this:

  alpha & lt; -0.3 beta <-0.6 m <- 5 #elements in kn & lt; -10 # rating k.prime & lt; -matrix (0, n, m); matrix (0, n + 1, m); k colnames (v) & lt ; -colnames (k.prime) & lt; -round (k, numeral = 2) for #pin the value of k & lt; -seq (= 0.04 to, = 0.2, length.out = m), V [1,] of the & lt; -rep (0, m); # For the remaining ends (i 1: n) {for (j: 1: m) {temp.v  

Comments