I dont understand why this function returns NaN for negative values of x.
lambda <- 2.77
alpha <- 0.88
# function
util <- function( x, a, l){
ifelse(x >=0, x^a, l * (x^a) )
}
for x I insert a number from a data frame. If the number is positive, I get the correct result. If it is negative though, it returns NaN
> util(-0.5,alpha,lambda)
[1] NaN
Can someone explain why or suggest a solution?