Important: Read this before posting to this forum

  1. This forum is for questions related to the use of Apollo. We will answer some general choice modelling questions too, where appropriate, and time permitting. We cannot answer questions about how to estimate choice models with other software packages.
  2. There is a very detailed manual for Apollo available at http://www.ApolloChoiceModelling.com/manual.html. This contains detailed descriptions of the various Apollo functions, and numerous examples are available at http://www.ApolloChoiceModelling.com/examples.html. In addition, help files are available for all functions, using e.g. ?apollo_mnl
  3. Before asking a question on the forum, users are kindly requested to follow these steps:
    1. Check that the same issue has not already been addressed in the forum - there is a search tool.
    2. Ensure that the correct syntax has been used. For any function, detailed instructions are available directly in Apollo, e.g. by using ?apollo_mnl for apollo_mnl
    3. Check the frequently asked questions section on the Apollo website, which discusses some common issues/failures. Please see http://www.apollochoicemodelling.com/faq.html
    4. Make sure that R is using the latest official release of Apollo.
  4. If the above steps do not resolve the issue, then users should follow these steps when posting a question:
    1. provide full details on the issue, including the entire code and output, including any error messages
    2. posts will not immediately appear on the forum, but will be checked by a moderator first. This may take a day or two at busy times. There is no need to submit the post multiple times.

Log-transformation with a piecewise linearization

Ask questions about model specifications. Ideally include a mathematical explanation of your proposed model.
Post Reply
irinikalk
Posts: 5
Joined: 31 Jul 2020, 21:14

Log-transformation with a piecewise linearization

Post 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
Attachments
Log-transformation&Piecewise linearization.PNG
Log-transformation&Piecewise linearization.PNG (19.76 KiB) Viewed 5992 times
stephanehess
Site Admin
Posts: 1061
Joined: 24 Apr 2020, 16:29

Re: Log-transformation with a piecewise linearization

Post 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
--------------------------------
Stephane Hess
www.stephanehess.me.uk
stephanehess
Site Admin
Posts: 1061
Joined: 24 Apr 2020, 16:29

Re: Log-transformation with a piecewise linearization

Post 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
--------------------------------
Stephane Hess
www.stephanehess.me.uk
irinikalk
Posts: 5
Joined: 31 Jul 2020, 21:14

Re: Log-transformation with a piecewise linearization

Post 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
Attachments
piecewiselinearization.PNG
piecewiselinearization.PNG (4.53 KiB) Viewed 5982 times
stephanehess
Site Admin
Posts: 1061
Joined: 24 Apr 2020, 16:29

Re: Log-transformation with a piecewise linearization

Post 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
--------------------------------
Stephane Hess
www.stephanehess.me.uk
Post Reply