Displaying 20 results from an estimated 4000 matches similar to: "Error in optim function."
2001 Apr 09
4
fastest R platform
Hello, everyone! I picked up R several months ago and have adopted it
as my choice for statistical programming. Coming from a Java
background, I can honestly say that R is not only free, it is better
tha S-plus: the lexical scope in R makes it very simple to simulate
Java's object model. For this, I encourage everyone to read the artcle:
Robert Gentleman and Ross Ihaka (2000) "Lexical
2011 Jun 14
1
Using MLE Method to Estimate Regression Coefficients
Good Afternoon,
I am relatively new to R and have been trying to figure out how to estimate regression coefficients using the MLE method. Some background: I am trying to examine scenarios in which certain estimators might be preferred to others, starting with MLE. I understand that MLE will (should) produce the same results as Ordinary Least Squares if the assumption of normality holds. That
2009 Apr 21
4
My surprising experience in trying out REvolution's R
I care a lot about R's speed. So I decided to give REvolution's R
(http://revolution-computing.com/) a try, which bills itself as an
optimized R. Note that I used the free version.
My machine is a Intel core 2 duo under Windows XP professional. The code
I run is in the end of this post.
First, the regular R 1.9. It takes 2 minutes and 6 seconds, CPU usage
50%
Next, REvolution's R.
2008 Oct 09
2
Help MLE
Dear,
I'm starting on R language. I would like some help to implement a MLE
function.
I wish to obtain the variables values (alpha12, w_g12, w_u12) that maximize
the function LL = Y*ln(alpha12 + g*w_g12 + u*w_u12).
Following the code:
rm(list=ls())
ls()
library(stats4)
Model = function(alpha12,w_g12,w_u12)
{
Y = 1
u = 0.5
g = -1
Y*log(alpha12 + g*w_g12 + u*w_u12)
}
res =
2008 Mar 23
2
scaling problems in "optim"
Dear R users,
I am trying to figure out the control parameter in "optim," especially,
"fnscale" and "parscale."
In the R docu.,
------------------------------------------------------
fnscale
An overall scaling to be applied to the value of fn and gr during
optimization. If negative, turns the problem into a maximization problem.
Optimization is performed on
2010 Oct 01
3
maximum likelihood problem
I am trying to figure out how to run maximum likelihood in R. Here is my
situation:
I have the following equation:
equation<-(1/LR-(exp(-k*T)*LM)*(1-exp(-k)))
LR, T, and LM are vectors of data. I want to R to change the value of k
to maximize the value of equation.
My attempts at optim and optimize have been unsuccessful. Are these the
recommended functions that I should use to maximize
2010 Sep 02
1
Help on glm and optim
Dear all,
I'm trying to use the "optim" function to replicate the results from the "glm" using an example from the help page of "glm", but I could not get the "optim" function to work. Would you please point out where I did wrong? Thanks a lot.
The following is the code:
# Step 1: fit the glm
clotting <- data.frame(
u =
2019 Feb 19
1
mle (stat4) crashing due to singular Hessian in covariance matrix calculation
Hi, R developers.
when running mle inside a loop I found a nasty behavior. From time to
time, my model had a degenerate minimum and the loop just crashed. I
tracked it down to "vcov <- if (length(coef)) solve(oout$hessian)" line,
being the hessian singular.
Note that the minimum reached was good, it just did not make sense to
calculate the covariance matrix as the inverse of a
2018 May 28
2
to R Core T: mle function in 32bits not respecting the constrain
I have an issue using mle in versions of 32 bits.
I am writing a package which I want to submit to the CRAN.
When doing the check, there is an example that has an error running in the
32 bits version.
The problem comes from the mle function, using it with a lower constrain.
In 64 bits version it works fine but when I put it in the R 32 bits it
fails. (same numbers, all equal!)
The call is:
2010 Aug 02
1
Confidence Bands in nonlinear regression using optim and maximum likelihood
Hello,
I am trying to plot confidence bands on the mean and prediction bands for the following
nonlinear regression, using maximum likelihood via optim. A toy example with data and
code of what I am trying to accomplish is:
VOL<-c(0.01591475, 1.19147935 ,6.34102460, 53.68809287, 91.90143074, 116.21397007,
146.41843056, 215.64535337, 256.53149673, 315.73609232)
Age <-c(1.622222, 2.833333
2008 Apr 05
2
How to improve the "OPTIM" results
Dear R users,
I used to "OPTIM" to minimize the obj. function below. Even though I used
the true parameter values as initial values, the results are not very good.
How could I improve my results? Any suggestion will be greatly appreciated.
Regards,
Kathryn Lord
#------------------------------------------------------------------------------------------
x = c(0.35938587,
2008 Apr 05
2
How to improve the "OPTIM" results
Dear R users,
I used to "OPTIM" to minimize the obj. function below. Even though I used
the true parameter values as initial values, the results are not very good.
How could I improve my results? Any suggestion will be greatly appreciated.
Regards,
Kathryn Lord
#------------------------------------------------------------------------------------------
x = c(0.35938587,
2007 Jul 02
2
how to use mle with a defined function
Hi all,
I am trying to use mle() to find a self-defined function. Here is my
function:
test <- function(a=0.1, b=0.1, c=0.001, e=0.2){
# omega is the known covariance matrix, Y is the response vector, X is the
explanatory matrix
odet = unlist(determinant(omega))[1]
# do cholesky decomposition
C = chol(omega)
# transform data
U = t(C)%*%Y
WW=t(C)%*%X
beta = lm(U~W)$coef
Z=Y-X%*%beta
2018 May 28
0
to R Core T: mle function in 32bits not respecting the constrain
> On May 27, 2018, at 10:31 PM, francesc badia roca <fbr600 at gmail.com> wrote:
>
> I have an issue using mle in versions of 32 bits.
>
> I am writing a package which I want to submit to the CRAN.
> When doing the check, there is an example that has an error running in the
> 32 bits version.
>
> The problem comes from the mle function, using it with a lower
2005 Sep 06
2
fitting distributions with R
Dear all
I've got the dataset
data:2743;4678;21427;6194;10286;1505;12811;2161;6853;2625;14542;694;11491;
?? ?? ?? ?? ?? 14924;28640;17097;2136;5308;3477;91301;11488;3860;64114;14334
I know from other testing that it should be possible to fit the data with the
exponentialdistribution. I tried to get parameterestimates for the
exponentialdistribution with R, but as the values
of the parameter
2008 Aug 13
2
messing with ...
I'm looking for advice on manipulating parameters that
are going to be passed through to another function.
Specifically, I am working on my version of "mle",
which is a wrapper for optim (among other optimizers).
I would prefer not to replicate the entire argument
list of optim(), so I'm using ... to pass extra arguments
through.
However:
the starting values are
2006 Feb 02
2
how to use mle?
>Y
[,1] [,2] [,3]
[1,] 0 1 0
[2,] 0 1 0
[3,] 0 0 1
[4,] 1 0 0
[5,] 0 0 1
[6,] 0 0 1
[7,] 1 0 0
[8,] 1 0 0
[9,] 0 0 1
[10,] 1 0 0
>X
pri82 pan82
1 0 0
2 0 0
3 1 0
4 1 0
5 0 1
6 0 0
7 1 0
8 1 0
9 0 0
10
2009 Apr 08
3
MLE for bimodal distribution
Hello everyone,
I'm trying to use mle from package stats4 to fit a bi/multi-modal
distribution to some data, but I have some problems with it.
Here's what I'm doing (for a bimodal distribution):
# Build some fake binormally distributed data, the procedure fails also with
real data, so the problem isn't here
data = c(rnorm(1000, 3, 0.5), rnorm(500, 5, 0.3))
# Just to check
2007 Apr 09
1
R:Maximum likelihood estimation using BHHH and BFGS
Dear R users,
I am new to R. I would like to find *maximum likelihood estimators for psi
and alpha* based on the following *log likelihood function*, c is
consumption data comprising 148 entries:
fn<-function(c,psi,alpha)
{
s1<-sum(for(i in 1:n){(c[i]-(psi^(-1/alpha)*(lag(c[i],-1))))^2*
(lag(c[i],-1)^((-2)*(alpha+1))
)});
s2<- sum(for(m in 1:n){log(lag(c[m],-1)^(((2)*alpha)+2))});
2006 Mar 21
1
Hessian from optim()
Hello!
Looking on how people use optim to get MLE I also noticed that one can
use returned Hessian to get corresponding standard errors i.e. something
like
result <- optim(<< snip >>, hessian=T)
result$par # point estimates
vc <- solve(result$hessian) # var-cov matrix
se <- sqrt(diag(vc)) # standard errors
What is actually Hessian representing here?