Questions tagged [optim]
32 questions
4
votes
0 answers
"optim" function fails to converge for maximum likelihood estimation in a random-effect model
I have a longitudinal dataset for plant growth that includes repeated measurements in different seasons. I am trying to estimate the parameters for a growth equation using this dataset. The growth equation is as follows:
Lt = 150*((1 +…

TKH_9
- 105
- 1
- 7
4
votes
1 answer
Optim Julia parameter meaning
I'm trying to use Optim in Julia to solve a two variable minimization problem, similar to the following
x = [1.0, 2.0, 3.0]
y = 1.0 .+ 2.0 .* x .+ [-0.3, 0.3, -0.1]
function sqerror(betas, X, Y)
err = 0.0
for i in 1:length(X)
pred_i…

jgr
- 125
- 4
2
votes
1 answer
Use OPTIM() to MUTATE an additional column to an existing dataframe or tibble
I would like to add an additional column to an existing dataframe by mutating the optimized result from the OPTIM() function. The code works when I strip the dataframe down to 1 row, but gives the following error when there are 2 rows:
Caused by…

Mel Sorrell
- 23
- 3
1
vote
1 answer
Minimize the L1-Norm between [a*A(x1,x2)-b] by finding unknown coefficients/probabilities x1 and x2
I have the following problem: I am trying to write an optimisation routine in Julia that calculates the potentially unknown coefficients of a transition probability matrix that guarantees me I get from state vector a to new state vector b. As A is a…

HeroldEcon
- 11
- 1
1
vote
1 answer
R programmable fixing of parameters in `optim`
I am using optim to fit various probability distributions to two given tertiles t1 and t2. The following function works, where qfun is the quantile function of the distribution and par_start gives the initial values of the parameters of the…

JeremyC
- 445
- 2
- 14
1
vote
2 answers
Adding model-fitting constraints to a subset of parameters using FME::modFit or optim
I am attempting to fit a differential equation model by minimizing least squares, where three of the four parameters to be optimized over can't fall below zero. Other than that restriction, I would prefer not apply any further constraints.
Here is…

e-stred
- 13
- 5
1
vote
1 answer
Estimate a global load reduction using optimization
I am trying to find a global reduction (global_reduct) for a timeseries of monthly loads.
The goal is make sure that only 50% (or any other taget) of all loads exceed a specific reference load.
global_reduct <- c(50) ## initial value
load_ref <-…

AMSS
- 23
- 4
1
vote
1 answer
Optimization of piecewise functions in Julia
Extremely new to Julia, so please pardon any obvious oversights on my end
I am trying to estimate a piecewise likelihood function through optimization. I have the code functional in R, but have begun translating it to Julia in the hopes of faster…

Zachary Porreca
- 13
- 3
1
vote
1 answer
Error when fitting complex data with leasqr algorithm in Octave
I have data as real and imaginary parts of complex number, and I want to fit them according to a complex function. More in detail, they are data from electrochemical impedance spectroscopy (EIS) experiments, and the function comes from an equivalent…

Corrado Locati
- 11
- 4
1
vote
0 answers
How to determine which starting values result in optimr() error message: L-BFGS-B needs finite values of 'fn'
I am using optimr to minimize a function that calculates the negative log likelihood for choice behavior. On some iterations, I receive the error message:
`
Error in optim(par = par, fn = efn, gr = egr, lower = lower, upper = upper, :
L-BFGS-B…

chester108
- 11
- 3
0
votes
0 answers
Strangely different results doing Box Cox transform with R Optim and with MASS package
using optim in R, We don't uderstand why We have not the same result than lambda Box Cox in Mass package ? Is the problem whith the linear model ?
Please find the code below.
Do you have any idea?
Thanks a lot for your help.
Have a nice…

user3619937
- 85
- 2
- 6
0
votes
1 answer
R defining a function using optim
I wish to write a function in R that fits a quantile function to two given tertiles, t1, t2. If I know what the quantile function is, qgamma, say, then I can write:
gapfn <- function(par, t1, t2) {
a <- t1 - qgamma(1 / 3, shape = par[1], rate =…

JeremyC
- 445
- 2
- 14
0
votes
0 answers
R script to plot and update optim() values after each iteration
I am trying to write a R script to plot the values of the optim() function against the number of iterations. However, I don't know the number of iterations that the function will run for, as the function I am optimizing is complex. I want to see how…

DiTe
- 1
0
votes
0 answers
Error: initial value in 'vmmin' is not finite - Maximum Likelihood Estimation of an Ordered Probit Model
I am currently trying to write a code in R that estimates an ordered probit model via the maximum likelihood estimation. The dependent variable has three categories. There are several independent variables that are continuous as well as binomial.…
0
votes
0 answers
Is it necessary to estimate the dispersion parameter before estimating the regression coefficients in negative binomial regression using mle?
I am trying to build a negative binomial regression model in R by using the optim() function over the Log-Liklihood function to estimate the parameters. The Log-Lilihood function is:
Negative Binomial Log-Liklihood Function
Here, alpha is the…

Ranadeep Datta
- 1
- 1