0

I want to solve a non linear function in R using a loop for 71 years of data.

The equation looks like this:

y(i) == -1/k*log(1-k(xi - beta/alpha))   

where xi is the value present in the dataset.

For the first data the equation looks like this:

y(1) ==  -1/k*log(1-k(95 - beta/alpha)) 

where 95 is the first value of the list.

The value of K, alpha and beta are already known.

Thank you!

I wrote a loop which will take the values from the list

for (i in list) {
  y(i) <- -1/k* log(1-k(xi - beta/alpha))
  print(y1)
}

Unfortunately its not working.

Rui Barradas
  • 70,273
  • 8
  • 34
  • 66
  • 1)In the loop do you want `xi` or `x[i]`? It seems like you want the latter. 2) `y(i)` should be `y[i]`. 3) There is a `*` missing in `k(95 - beta/alpha)` right after `k`. – Rui Barradas Mar 12 '23 at 14:26
  • Assuming the values shown `y <- 1:10; alpha <- beta <- k <- 1; beta/alpha - (exp(-(y * k)) - 1)/k` – G. Grothendieck Mar 12 '23 at 14:42

0 Answers0