Skip to content
Prev 197066 / 398500 Next

Solving an equation in R (and using a loop)

Thank you both for your help.
I'll ask my advisor for help on the issue tomorrow as perhaps I've
made a specification error or I'm taking the wrong approach entirely. I'm a
master's student in economics; the equation is a CARA utility function, and
the
r represents the corresponding individual's coefficient of risk aversion.

Perhaps I just have a selection bias since I am choosing
from observations that only have x1 and x2, when I have some observations
that
go all the way up to x20. (so the part of f which follows the negative sign
would be
(1/n)(sum(1-exp(-rx(i)). I am solving for r when that equation equals 0, so,
yes, I'm looking for the root. I'll try with a few more observations that
have
more xs.

cheers
Laura
leohearn wrote: