mle

MLE error in R: non-finite finite-difference value/ value in 'vmmin' is not finite

醉酒当歌 提交于 2019-12-25 07:59:16
问题 I am working on a loss aversion model in R (beginner) and want to estimate some parameters, from a dataset with 3 columns (loss/gain values (both continous and a column with decisions coded as 0 or 1 (binary)) dropbox.com/s/fpw3obrqcx8ld1q/GrandAverage.RData?dl=0 The part of the code if have to use for this I am using is given below: set <- GrandAverage[, 5:7]; Beh.Parameters <- function (lambda, alpha, temp) { u = 0.5 * set$Gain^alpha + 0.5 * lambda * set$Loss^alpha GambleProbability <- 1 /

MLE issues in R

牧云@^-^@ 提交于 2019-12-24 12:33:13
问题 I am new to R and taught myself what I know of R based on the other languages i know. I am in a student research position currently and must use R to find the maximum likelihood estimate of the given likelihood function: Where g, m_i, x_ij, n_ij, and mu_i are known. I have to maximize theta_i, but i am not sure how since i am mostly self taught. I do know that i should have six estimated values of theta, however. I have tried doing research online about using mle but I am not far into

Error with custom density function definition for mle2 formula call

泄露秘密 提交于 2019-12-23 00:25:14
问题 I want to define my own density function to be used in the formula call to mle2 from R 's bbmle package. The parameters of the model are estimated but I cannot apply functions like residuals or predict on the returned mle2 object. This is an example in which I define a function for a simple Poisson model. library(bbmle) set.seed(1) hpoisson <- rpois(1000, 10) myf <- function(x, lambda, log = FALSE) { pmf <- (lambda^x)*exp(-lambda)/factorial(x) if (log) log(pmf) else pmf } myfit <- mle2

Errors running Maximum Likelihood Estimation on a three parameter Weibull cdf

一曲冷凌霜 提交于 2019-12-22 14:57:12
问题 I am working with the cumulative emergence of flies over time (taken at irregular intervals) over many summers (though first I am just trying to make one year work). The cumulative emergence follows a sigmoid pattern and I want to create a maximum likelihood estimation of a 3-parameter Weibull cumulative distribution function. The three-parameter models I've been trying to use in the fitdistrplus package keep giving me an error. I think this must have something to do with how my data is

Maximum Likelihood Estimation for three-parameter Weibull distribution in r

时光怂恿深爱的人放手 提交于 2019-12-21 20:44:30
问题 I want to estimate the scale, shape and threshold parameters of a 3p Weibull distribution. What I've done so far is the following: Refering to this post, Fitting a 3 parameter Weibull distribution in R I've used the functions EPS = sqrt(.Machine$double.eps) # "epsilon" for very small numbers llik.weibull <- function(shape, scale, thres, x) { sum(dweibull(x - thres, shape, scale, log=T)) } thetahat.weibull <- function(x) { if(any(x <= 0)) stop("x values must be positive") toptim <- function

NaN errors with bbmle

不问归期 提交于 2019-12-14 03:54:33
问题 This question relates to my previous question here and the data set presented in the paper A New Generalization of Linear Exponential Distribution: Theory and Application. For this data, adapting the code proposed by Ben Bolker, we have library(stats4) library(bbmle) x <- scan(textConnection("115 181 255 418 441 461 516 739 743 789 807 865 924 983 1024 1062 1063 1165 1191 1222 1222 1251 1277 1290 1357 1369 1408 1455 1478 1549 1578 1578 1599 1603 1605 1696 1735 1799 1815 1852")) dd <- data

Error in using optim to maximise the likelihood in r

。_饼干妹妹 提交于 2019-12-13 21:14:54
问题 So, I have these functions: funk1 <- function(a,x,l,r) { x^2*exp(-(l*(1-exp(-r*a))/r))} funk2 <- function(x,l,r) { sapply(x, function (s) { integrate(funk1, lower = 0, upper = s, x=s, l=l, r=r)$value })} which are used to explain the data y in, z <- data.frame(ts = 1:100, y = funk2(1:100, l = 1, r = 1) + rpois(100, 1:100)) I wish to use optim to maximise the likelihood, so I defined a likelihood function: LL_funk <- function(l,r) { n=nrow(z) R = sum((funk2(ts,l,r) - y)^2) logl = -((n/2)*log(R

Writing a proper normal log-likelihood in R

落爺英雄遲暮 提交于 2019-12-13 20:27:38
问题 I have a problem regarding the following model, where I want to make inference on μ and tau, u is a known vector and x is the data vector. The log-likelihood is I have a problem writing a log-likelihood in R. x <- c(3.3569,1.9247,3.6156,1.8446,2.2196,6.8194,2.0820,4.1293,0.3609,2.6197) mu <- seq(0,10,length=1000) normal.lik1<-function(theta,x){ u <- c(1,3,0.5,0.2,2,1.7,0.4,1.2,1.1,0.7) mu<-theta[1] tau<-theta[2] n<-length(x) logl <- sapply(c(mu,tau),function(mu,tau){logl<- -0.5*n*log(2*pi) -0

mle2 from package bbmle gives non-sensical answers with custom function

喜夏-厌秋 提交于 2019-12-13 18:46:38
问题 I want to fit some field data with a custom-made negative exponential probability density function. (Motivation- I eventually want to fit the field data to many of the distributions in table 3 of Bullock Shea and Skarpaas 2006). First I defined a dnegexp function according to this post: Error with custom density function definition for mle2 formula call dnegexp <- function(x, mya, myb, log=FALSE){ logne <- log(mya)-myb*x if(log) return(logne) else return(exp(logne)) } Then I made an rnegexp

Data fitting by the method of maximum likelihood for a new distribution

流过昼夜 提交于 2019-12-13 04:24:42
问题 I would like to know how one is able to fit any distribution to a given set of data using the method of MLEs. As a particular example, could anyone suggest a working code that would give the correct results for the MLEs for $\theta$ and $\beta$ when the generalised Lindley distribution described in https://rivista-statistica.unibo.it/article/viewFile/6836/7039 is applied to the data: 5.1, 6.3, 10.8, 12.1, 18.5, 19.7, 22.2, 23, 30.6, 37.3, 46.3, 53.9, 59.8, 66.2 on pg. 156? How can this then