Re: [R] Using optim() function to find MLE

2024-07-28 Thread Ivan Krylov via R-help
В Mon, 29 Jul 2024 09:52:22 +0530 Christofer Bogaso пишет: > LL = function(b0, b1) help(optim) documents that the function to be optimised takes a single argument, a vector containing the parameters. Here's how your LL function can be adapted to this interface: LL <- function(par) { b0 <- par[

[R] Using optim() function to find MLE

2024-07-28 Thread Christofer Bogaso
Hi, I am trying to fit a GLM on below data. While R does provide direct estimation, I wanted to go with manual calculation as below dat = structure(list(PurchasedProb = c(0.37212389963679, 0.572853363351896, 0.908207789994776, 0.201681931037456, 0.898389684967697, 0.944675268605351, 0.66079779248

Re: [R] Using optim with parameters that are factors (instead of continuous parameters)

2011-10-27 Thread Lucas Merrill Brown
Ben, Thank you for the incredibly helpful suggestions and links. I've been exploring each over the past few days, and for anyone else's future reference, here's what I've found. (1) I was able to use SANN to specify how to choose new candidate solutions, but I wasn't able to easily use SANN for a

Re: [R] Using optim with parameters that are factors (instead of continuous parameters)

2011-10-22 Thread Ben Bolker
Lucas Merrill Brown gmail.com> writes: > > I've been programming maximum likelihood estimation models using the > function "optim." My current research requires modeling a particular > parameter as a categorical variable (what R calls a "factor"), not as a > continuous parameter. > > (The resea

[R] Using optim with parameters that are factors (instead of continuous parameters)

2011-10-22 Thread Lucas Merrill Brown
I've been programming maximum likelihood estimation models using the function "optim." My current research requires modeling a particular parameter as a categorical variable (what R calls a "factor"), not as a continuous parameter. (The research question is, at what level of X does a subject in ou

Re: [R] Using optim function for logistic model simulation

2010-04-26 Thread Charlotte Chang
Great! Thank you for your help! -Charlotte >> >> On Mon, Apr 26, 2010 at 1:12 AM, Tal Galili wrote: >>> >>> mm... >>> I also noticed the function you wrote didn't use parenthesis, mixed b and c >>> and used different names for K. >>> Your code is a great exercise in debugging  (no offense inte

Re: [R] Using optim function for logistic model simulation

2010-04-26 Thread Tal Galili
mm... I also noticed the function you wrote didn't use parenthesis, mixed b and c and used different names for K. Your code is a great exercise in debugging (no offense intended :) ) Try using: bird<-bird.density[0] # I assume this exists eqn<- function(K1, b1 = 1.22, c1 = .55) {

Re: [R] Using optim function for logistic model simulation

2010-04-26 Thread Tal Galili
Hi Charlotte , I can't reproduce your code, but skimming through it - It would appear that: 1) in eqn1<- function(K1, bird) you didn't define "bird" (you did define it before the function, so I'd suggest just removing it from the function call like this: eqn1<- function(K1) 2) you didn't "return"

[R] Using optim function for logistic model simulation

2010-04-25 Thread Charlotte Chang
Hello! I'm a college undergrad desperately trying to finish up my thesis. I have a dataset on the distribution of a grassland bird from the Breeding Bird Survey. I have a very straightforward and simple version of the logistic growth model to describe changes in this bird's abundance over time. Th

Re: [R] using optim

2010-01-02 Thread Uwe Ligges
Duncan Murdoch wrote: On 01/01/2010 11:45 PM, Erin Hodgess wrote: Dear R People: I know that you can use "optim" for a function with several parameters. Is there an equivalent for 2 functions, please? Or should I put together a finite difference type of matrix, etc., please? What is the g

Re: [R] using optim

2010-01-02 Thread Duncan Murdoch
On 01/01/2010 11:45 PM, Erin Hodgess wrote: Dear R People: I know that you can use "optim" for a function with several parameters. Is there an equivalent for 2 functions, please? Or should I put together a finite difference type of matrix, etc., please? What is the goal? optim optimizes a s

[R] using optim

2010-01-01 Thread Erin Hodgess
Dear R People: I know that you can use "optim" for a function with several parameters. Is there an equivalent for 2 functions, please? Or should I put together a finite difference type of matrix, etc., please? Thanks, Happy New Year, Erin -- Erin Hodgess Associate Professor Department of Com

Re: [R] Using "optim" with exponential power distribution

2009-01-16 Thread Stefan Evert
I know "optim" should do a minimisation, therefor I used as the optimisation function opt.power <- function(val, x, y) { a <- val[1]; b <- val[2]; sum(y - b/(2*pi*a^2*gamma(2/b))*exp(-(x/a)^b)); } I call: (with xm and ym the data from the table) a1 <- c(0.2, 100) opt <- optim(a1, opt.powe

[R] Using "optim" with exponential power distribution

2009-01-16 Thread Ronald Bialozyt
Hello, I am trying to fit a exponential power distribution y = b/(2*pi*a^2*gamma(2/b))*exp(-(x/a)^b) to a bunch of data for x and y I have in a table. > data x y 1 2527 2 7559 3125 219 ... 25912925 1 26012975