Reputation: 109
I am trying to run the following function but I get NaNs
I don't understand my mistake... any ideas?
preg<-seq(0.15,0.42,length=100)
sigma<-seq(0.01,0.1, length=100)
y <- c(0.1851852,0.4210526,0.3243243)
lf <- function(preg, sigma) prod(dunif(y, preg, sigma))
lf(0.3, 0.02)
Thaks!
Upvotes: 1
Views: 67
Reputation: 887951
With dunif
, the arguments are x
, min
, max
. According to ?dunif
dunif(x, min = 0, max = 1, log = FALSE)
Here, 'preg' is starting as a higher value (for min
) when compared to sigma
dunif(y, preg[1], sigma[1])
#[1] NaN NaN NaN
dunif(y, 0.02, 0.3)
#[1] 3.571429 0.000000 0.000000
Upvotes: 1