Page 1 of 1

Log-transformation with a piecewise linearization

Posted: 31 Jul 2020, 21:27
by irinikalk
Hi there,
I am a very new user of Apollo and eventhough I have worked with R before I am still having some diffculties. For a project I have to estimate a binary choice model and then later perform different specifications to the model. One specification of my binary model is a log-transformation of my variables. So far so good. But then I have to estimate a model with a piecewise linearization to one of the log-transformed variables. With the model mlogit things are simple (look at file attached) but when I have to rewrite the code for apollo I have no clue how to proceed. I can't find any information on that topice so I am hoping for some help here.

Thank you very much
Irini

Re: Log-transformation with a piecewise linearization

Posted: 02 Aug 2020, 16:42
by stephanehess
Hi Irini

a piecewise linear specification is not difficult to specify. I am happy to help you but it would probably be easiest if you wrote down your specification for me and I'll show you how to do it in Apollo. The mlogit code isn't really helping me as I don't use mlogit

Stephane

Re: Log-transformation with a piecewise linearization

Posted: 02 Aug 2020, 16:42
by stephanehess
Hi Irini

a piecewise linear specification is not difficult to specify. I am happy to help you but it would probably be easiest if you wrote down your specification for me and I'll show you how to do it in Apollo. The mlogit code isn't really helping me as I don't use mlogit

Stephane

Re: Log-transformation with a piecewise linearization

Posted: 03 Aug 2020, 09:27
by irinikalk
Hi Stephane,

I have to make a piecewise linearization of the age variable with the specification of splitting the age into four parts (0-15, 16-30; 31-45 and the 45 until the end). My discrete utility functions for the binary model are in the picture attached.
Is that all the information you need or am I missing something?

Kind Regards
Irini

Re: Log-transformation with a piecewise linearization

Posted: 03 Aug 2020, 10:42
by stephanehess
Hi

So what you could easily write is something like this (I've tried to keep it as simple for you as possible to follow, so haven't used if else, etc)

V[["stay"]] = beta1 * log(NbEmpl) +
beta2a * ((age<=15)*age+(age>15)*15) +
beta2b * ((age>15)*(age<=30)*(age-15)+(age>30)*15) +
beta2c * ((age>30)*(age<=45)*(age-30)+(age>45)*15) +
beta2d * ((age>45)*(age-45))

Stephane