On Tue, May 15, 2012 at 9:57 PM, Bert Gunter wrote:
> Hmmm... So you want to fit a nonlinear model with 24 parameters??!!
>
> I would bet that you'll need to sacrifice some chickens to the
> nonlinear optimization gods to get something meaningful from that
> exercise.
Nominated for a fortune.
>
c
>> derivatives to make it sing. For 5 parameters, use NM, or better the nmk
>> from dfoptim package.
>>
>> Best, JN
>>
>>
>> On 05/15/2012 06:00 AM, r-help-request@ wrote:
>>> Message: 13
>>> Date: Mon, 14 May 2012 04:21:57 -0700 (PDT)
>
optim package.
>
> Best, JN
>
>
> On 05/15/2012 06:00 AM, r-help-request@ wrote:
>> Message: 13
>> Date: Mon, 14 May 2012 04:21:57 -0700 (PDT)
>> From: infinitehorizon <barisvardar@>
>> To: r-help@
>> Subject: Re: [R] Discrete choice model m
Best, JN
On 05/15/2012 06:00 AM, r-help-requ...@r-project.org wrote:
> Message: 13
> Date: Mon, 14 May 2012 04:21:57 -0700 (PDT)
> From: infinitehorizon
> To: r-help@r-project.org
> Subject: Re: [R] Discrete choice model maximum likelihood estimation
> Message-ID: <13369945170
See below.
On 14-05-2012, at 13:21, infinitehorizon wrote:
> Hello again,
>
> I changed the name to tt.
> and for a and tt actually I was getting them from data, I didn't put them
> here in the question. Now I restructured my code and below I copy the full
> code, I tried many things but still
Of course, that was the trick! It works now. Thank you very much Rui, I am
very grateful.
I hope this thread will help others as well.
Best,
Rui Barradas wrote
>
> Once again, sorry.
> I had a different llfn in my R session and it messed with yours.
>
> llfn <- function(param, a, tt) {
>
>
Once again, sorry.
I had a different llfn in my R session and it messed with yours.
llfn <- function(param, a, tt) {
llfn <- sum((a==1)*lL1+(a==2)*lL2+(a==3)*lL3) # sum of logs, it's a
log-likelihood.
return(-llfn)
}
Rui Barradas
infinitehorizon wrote
>
> Hello again,
>
> You are absolutely
Hello, again.
Bug report:
1. Your densities can return negative values, 1 - exp(...) < 0.
Shouldn't those be 1 PLUS exp()?
P3 <- function(bx,b3,b,tt) {
P <- exp(bx*x+b3+b*(tt == 1))/(1+exp(bx*x+b3+b*(tt == 1)))
return(P)
}
And the same for P2 and P1?
2. Include 'a' and 'tt'
Hello again,
You are absolutely right about probabilities.. Thanks for reminding me about
that.
I did exactly how you said but in the end I receive the error : "objective
function in optim evaluates to length 12 not 1".
I checked how llfn give a vector instead of scalar, but couldn't figure it
o
By the way, in my last post I forgot to return negative of llfn, hence the
llfn will be as follows:
llfn <- function(param) {
bx <- param[1]
b1 <- param[2]
b2 <- param[3]
b3 <- param[4]
b <- param[5]
lL1 <- log(L1(bx,b1,b2,b,tt))
lL2 <- log(L2(bx,b1,b2,b3,b,tt))
lL3 <- log(L3(bx,b1,b2,b3
Hello again,
I changed the name to tt.
and for a and tt actually I was getting them from data, I didn't put them
here in the question. Now I restructured my code and below I copy the full
code, I tried many things but still getting the same error, I don't
understand where is the mistake.
I also
Ok, I forgot to say that 't' is also an R function, the matrix transpose.
Sorry, but after 'par' I thought (in my mind) I had said it when in fact I
even talked about 't'!
Use 'tt'.
If 'tt' is a vector you must first define it, in your code it doesn't exist.
That's why R searches for and finds an o
Hello Rui,
First of all, thanks a lot!
1. I changed par to param,
2. t is a variable too, a binary one, b is the parameter associated to it,
4. Yes, this is where I am stuck actually.
I fixed the code for likelihood functions as follows, but still getting the
same error:
L3 <- function(b1,
Hello,
There are several issues with your code.
1. The error message. Don't use 'par' as a variable name, it's already an R
function, tyo get or set graphics parameters.
Call it something else, say, 'param'.
This is what causes the error. You must pass initial values to optim, but
the variable yo
Hello,
I am new to R and I am trying to estimate a discrete model with three
choices. I am stuck at a point and cannot find a solution.
I have probability functions for occurrence of these choices, and then I
build the likelihood functions associated to these choices and finally I
build the gener
15 matches
Mail list logo