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
Important: Read this before posting to this forum
- 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.
- 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
- Before asking a question on the forum, users are kindly requested to follow these steps:
- Check that the same issue has not already been addressed in the forum - there is a search tool.
- 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
- Check the frequently asked questions section on the Apollo website, which discusses some common issues/failures. Please see http://www.apollochoicemodelling.com/faq.html
- Make sure that R is using the latest official release of Apollo.
- Users can check which version they are running by entering packageVersion("apollo").
- Then check what is the latest full release (not development version) at http://www.ApolloChoiceModelling.com/code.html.
- To update to the latest official version, just enter install.packages("apollo"). To update to a development version, download the appropriate binary file from http://www.ApolloChoiceModelling.com/code.html, and install the package from file
- If the above steps do not resolve the issue, then users should follow these steps when posting a question:
- provide full details on the issue, including the entire code and output, including any error messages
- 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
Log-transformation with a piecewise linearization
- Attachments
-
- Log-transformation&Piecewise linearization.PNG (19.76 KiB) Viewed 5992 times
-
- Site Admin
- Posts: 1061
- Joined: 24 Apr 2020, 16:29
Re: Log-transformation with a piecewise linearization
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
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
-
- Site Admin
- Posts: 1061
- Joined: 24 Apr 2020, 16:29
Re: Log-transformation with a piecewise linearization
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
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
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
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 (4.53 KiB) Viewed 5982 times
-
- Site Admin
- Posts: 1061
- Joined: 24 Apr 2020, 16:29
Re: Log-transformation with a piecewise linearization
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
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