How Dummy Variables Should Be Modeled In A Linear Regression Model?
$begingroup$
I've a cross sectional model where I want predict number of users that take specific service, to make it I've many variables but have specifically two nominal: isWorkday(0 or 1) and weeday(1,2,3,...,7). When I make the model, taking into account the two variables, generates high multicollinearity. So I've delete one of them, so what's better have many dummies (weeday) or less dummies (isWorkday).
linear-regression prediction dummy-variables
New contributor
$endgroup$
add a comment |
$begingroup$
I've a cross sectional model where I want predict number of users that take specific service, to make it I've many variables but have specifically two nominal: isWorkday(0 or 1) and weeday(1,2,3,...,7). When I make the model, taking into account the two variables, generates high multicollinearity. So I've delete one of them, so what's better have many dummies (weeday) or less dummies (isWorkday).
linear-regression prediction dummy-variables
New contributor
$endgroup$
1
$begingroup$
Have you tried both? Usually when faced with this kind of dilema we perform tests with our available options, unless the amount of tests needed create a effort in which the experiment is not worth of.
$endgroup$
– Pedro Henrique Monforte
yesterday
$begingroup$
@PedroHenriqueMonforte you are right, see what I answered next, and I know that all possible models should be tried, but the question is addressed to multicollinearity.
$endgroup$
– David Salgado
8 hours ago
add a comment |
$begingroup$
I've a cross sectional model where I want predict number of users that take specific service, to make it I've many variables but have specifically two nominal: isWorkday(0 or 1) and weeday(1,2,3,...,7). When I make the model, taking into account the two variables, generates high multicollinearity. So I've delete one of them, so what's better have many dummies (weeday) or less dummies (isWorkday).
linear-regression prediction dummy-variables
New contributor
$endgroup$
I've a cross sectional model where I want predict number of users that take specific service, to make it I've many variables but have specifically two nominal: isWorkday(0 or 1) and weeday(1,2,3,...,7). When I make the model, taking into account the two variables, generates high multicollinearity. So I've delete one of them, so what's better have many dummies (weeday) or less dummies (isWorkday).
linear-regression prediction dummy-variables
linear-regression prediction dummy-variables
New contributor
New contributor
New contributor
asked yesterday
David SalgadoDavid Salgado
82
82
New contributor
New contributor
1
$begingroup$
Have you tried both? Usually when faced with this kind of dilema we perform tests with our available options, unless the amount of tests needed create a effort in which the experiment is not worth of.
$endgroup$
– Pedro Henrique Monforte
yesterday
$begingroup$
@PedroHenriqueMonforte you are right, see what I answered next, and I know that all possible models should be tried, but the question is addressed to multicollinearity.
$endgroup$
– David Salgado
8 hours ago
add a comment |
1
$begingroup$
Have you tried both? Usually when faced with this kind of dilema we perform tests with our available options, unless the amount of tests needed create a effort in which the experiment is not worth of.
$endgroup$
– Pedro Henrique Monforte
yesterday
$begingroup$
@PedroHenriqueMonforte you are right, see what I answered next, and I know that all possible models should be tried, but the question is addressed to multicollinearity.
$endgroup$
– David Salgado
8 hours ago
1
1
$begingroup$
Have you tried both? Usually when faced with this kind of dilema we perform tests with our available options, unless the amount of tests needed create a effort in which the experiment is not worth of.
$endgroup$
– Pedro Henrique Monforte
yesterday
$begingroup$
Have you tried both? Usually when faced with this kind of dilema we perform tests with our available options, unless the amount of tests needed create a effort in which the experiment is not worth of.
$endgroup$
– Pedro Henrique Monforte
yesterday
$begingroup$
@PedroHenriqueMonforte you are right, see what I answered next, and I know that all possible models should be tried, but the question is addressed to multicollinearity.
$endgroup$
– David Salgado
8 hours ago
$begingroup$
@PedroHenriqueMonforte you are right, see what I answered next, and I know that all possible models should be tried, but the question is addressed to multicollinearity.
$endgroup$
– David Salgado
8 hours ago
add a comment |
1 Answer
1
active
oldest
votes
$begingroup$
Since your task is to predict something, the better variable is the one that gives you a higher prediction accuracy. So you can simply test both and choose the one with which your model performs better.
However, I would suggest considering to engineer your own feature that incorporates information of both variables. For example, you could create three dummy variables: workday, weekend and holiday and include two of them into your model (to prevent falling into the dummy variable trap). Another option would be to only include the interaction terms between isWorkday and weekday.
$endgroup$
1
$begingroup$
I get it. But if it's the case where I've a dummy variable for isWorkday and six for the days of the weeks(isTuesday,isWednesday,isThurday, isFriday,isSaturday and isSunday) and both in the multicollinearity tests generate conflict , which dummy I should choose isWeekDay or the six dummies?. Remember that I can make a relationship with two variables (multicolineality): isTuesday,isWednesday,isThurday and isFriday mapped to isWorkday(1) and isSaturday and isSunday to isWorkday(0).
$endgroup$
– David Salgado
8 hours ago
$begingroup$
To make a decision, you first test both options. Case 1: If isWorkday gives you better prediction results, you choose isWorkday. Case 2: If the six weekday-variables give you better prediction results, you choose the six weekday-variables. Case 3: If the six weekday-variables perform equally good as isWorkday, you choose isWorkday, because in this case, you end up with a smaller model.
$endgroup$
– georg_un
8 hours ago
$begingroup$
Oh, I understand thanks, with that you tell me I'm also convinced that this would be the way to proceed.
$endgroup$
– David Salgado
7 hours ago
$begingroup$
Awesome, glad I could help.
$endgroup$
– georg_un
7 hours ago
add a comment |
Your Answer
StackExchange.ready(function() {
var channelOptions = {
tags: "".split(" "),
id: "557"
};
initTagRenderer("".split(" "), "".split(" "), channelOptions);
StackExchange.using("externalEditor", function() {
// Have to fire editor after snippets, if snippets enabled
if (StackExchange.settings.snippets.snippetsEnabled) {
StackExchange.using("snippets", function() {
createEditor();
});
}
else {
createEditor();
}
});
function createEditor() {
StackExchange.prepareEditor({
heartbeatType: 'answer',
autoActivateHeartbeat: false,
convertImagesToLinks: false,
noModals: true,
showLowRepImageUploadWarning: true,
reputationToPostImages: null,
bindNavPrevention: true,
postfix: "",
imageUploader: {
brandingHtml: "Powered by u003ca class="icon-imgur-white" href="https://imgur.com/"u003eu003c/au003e",
contentPolicyHtml: "User contributions licensed under u003ca href="https://creativecommons.org/licenses/by-sa/3.0/"u003ecc by-sa 3.0 with attribution requiredu003c/au003e u003ca href="https://stackoverflow.com/legal/content-policy"u003e(content policy)u003c/au003e",
allowUrls: true
},
onDemand: true,
discardSelector: ".discard-answer"
,immediatelyShowMarkdownHelp:true
});
}
});
David Salgado is a new contributor. Be nice, and check out our Code of Conduct.
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
StackExchange.ready(
function () {
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fdatascience.stackexchange.com%2fquestions%2f49223%2fhow-dummy-variables-should-be-modeled-in-a-linear-regression-model%23new-answer', 'question_page');
}
);
Post as a guest
Required, but never shown
1 Answer
1
active
oldest
votes
1 Answer
1
active
oldest
votes
active
oldest
votes
active
oldest
votes
$begingroup$
Since your task is to predict something, the better variable is the one that gives you a higher prediction accuracy. So you can simply test both and choose the one with which your model performs better.
However, I would suggest considering to engineer your own feature that incorporates information of both variables. For example, you could create three dummy variables: workday, weekend and holiday and include two of them into your model (to prevent falling into the dummy variable trap). Another option would be to only include the interaction terms between isWorkday and weekday.
$endgroup$
1
$begingroup$
I get it. But if it's the case where I've a dummy variable for isWorkday and six for the days of the weeks(isTuesday,isWednesday,isThurday, isFriday,isSaturday and isSunday) and both in the multicollinearity tests generate conflict , which dummy I should choose isWeekDay or the six dummies?. Remember that I can make a relationship with two variables (multicolineality): isTuesday,isWednesday,isThurday and isFriday mapped to isWorkday(1) and isSaturday and isSunday to isWorkday(0).
$endgroup$
– David Salgado
8 hours ago
$begingroup$
To make a decision, you first test both options. Case 1: If isWorkday gives you better prediction results, you choose isWorkday. Case 2: If the six weekday-variables give you better prediction results, you choose the six weekday-variables. Case 3: If the six weekday-variables perform equally good as isWorkday, you choose isWorkday, because in this case, you end up with a smaller model.
$endgroup$
– georg_un
8 hours ago
$begingroup$
Oh, I understand thanks, with that you tell me I'm also convinced that this would be the way to proceed.
$endgroup$
– David Salgado
7 hours ago
$begingroup$
Awesome, glad I could help.
$endgroup$
– georg_un
7 hours ago
add a comment |
$begingroup$
Since your task is to predict something, the better variable is the one that gives you a higher prediction accuracy. So you can simply test both and choose the one with which your model performs better.
However, I would suggest considering to engineer your own feature that incorporates information of both variables. For example, you could create three dummy variables: workday, weekend and holiday and include two of them into your model (to prevent falling into the dummy variable trap). Another option would be to only include the interaction terms between isWorkday and weekday.
$endgroup$
1
$begingroup$
I get it. But if it's the case where I've a dummy variable for isWorkday and six for the days of the weeks(isTuesday,isWednesday,isThurday, isFriday,isSaturday and isSunday) and both in the multicollinearity tests generate conflict , which dummy I should choose isWeekDay or the six dummies?. Remember that I can make a relationship with two variables (multicolineality): isTuesday,isWednesday,isThurday and isFriday mapped to isWorkday(1) and isSaturday and isSunday to isWorkday(0).
$endgroup$
– David Salgado
8 hours ago
$begingroup$
To make a decision, you first test both options. Case 1: If isWorkday gives you better prediction results, you choose isWorkday. Case 2: If the six weekday-variables give you better prediction results, you choose the six weekday-variables. Case 3: If the six weekday-variables perform equally good as isWorkday, you choose isWorkday, because in this case, you end up with a smaller model.
$endgroup$
– georg_un
8 hours ago
$begingroup$
Oh, I understand thanks, with that you tell me I'm also convinced that this would be the way to proceed.
$endgroup$
– David Salgado
7 hours ago
$begingroup$
Awesome, glad I could help.
$endgroup$
– georg_un
7 hours ago
add a comment |
$begingroup$
Since your task is to predict something, the better variable is the one that gives you a higher prediction accuracy. So you can simply test both and choose the one with which your model performs better.
However, I would suggest considering to engineer your own feature that incorporates information of both variables. For example, you could create three dummy variables: workday, weekend and holiday and include two of them into your model (to prevent falling into the dummy variable trap). Another option would be to only include the interaction terms between isWorkday and weekday.
$endgroup$
Since your task is to predict something, the better variable is the one that gives you a higher prediction accuracy. So you can simply test both and choose the one with which your model performs better.
However, I would suggest considering to engineer your own feature that incorporates information of both variables. For example, you could create three dummy variables: workday, weekend and holiday and include two of them into your model (to prevent falling into the dummy variable trap). Another option would be to only include the interaction terms between isWorkday and weekday.
answered 19 hours ago
georg_ungeorg_un
10818
10818
1
$begingroup$
I get it. But if it's the case where I've a dummy variable for isWorkday and six for the days of the weeks(isTuesday,isWednesday,isThurday, isFriday,isSaturday and isSunday) and both in the multicollinearity tests generate conflict , which dummy I should choose isWeekDay or the six dummies?. Remember that I can make a relationship with two variables (multicolineality): isTuesday,isWednesday,isThurday and isFriday mapped to isWorkday(1) and isSaturday and isSunday to isWorkday(0).
$endgroup$
– David Salgado
8 hours ago
$begingroup$
To make a decision, you first test both options. Case 1: If isWorkday gives you better prediction results, you choose isWorkday. Case 2: If the six weekday-variables give you better prediction results, you choose the six weekday-variables. Case 3: If the six weekday-variables perform equally good as isWorkday, you choose isWorkday, because in this case, you end up with a smaller model.
$endgroup$
– georg_un
8 hours ago
$begingroup$
Oh, I understand thanks, with that you tell me I'm also convinced that this would be the way to proceed.
$endgroup$
– David Salgado
7 hours ago
$begingroup$
Awesome, glad I could help.
$endgroup$
– georg_un
7 hours ago
add a comment |
1
$begingroup$
I get it. But if it's the case where I've a dummy variable for isWorkday and six for the days of the weeks(isTuesday,isWednesday,isThurday, isFriday,isSaturday and isSunday) and both in the multicollinearity tests generate conflict , which dummy I should choose isWeekDay or the six dummies?. Remember that I can make a relationship with two variables (multicolineality): isTuesday,isWednesday,isThurday and isFriday mapped to isWorkday(1) and isSaturday and isSunday to isWorkday(0).
$endgroup$
– David Salgado
8 hours ago
$begingroup$
To make a decision, you first test both options. Case 1: If isWorkday gives you better prediction results, you choose isWorkday. Case 2: If the six weekday-variables give you better prediction results, you choose the six weekday-variables. Case 3: If the six weekday-variables perform equally good as isWorkday, you choose isWorkday, because in this case, you end up with a smaller model.
$endgroup$
– georg_un
8 hours ago
$begingroup$
Oh, I understand thanks, with that you tell me I'm also convinced that this would be the way to proceed.
$endgroup$
– David Salgado
7 hours ago
$begingroup$
Awesome, glad I could help.
$endgroup$
– georg_un
7 hours ago
1
1
$begingroup$
I get it. But if it's the case where I've a dummy variable for isWorkday and six for the days of the weeks(isTuesday,isWednesday,isThurday, isFriday,isSaturday and isSunday) and both in the multicollinearity tests generate conflict , which dummy I should choose isWeekDay or the six dummies?. Remember that I can make a relationship with two variables (multicolineality): isTuesday,isWednesday,isThurday and isFriday mapped to isWorkday(1) and isSaturday and isSunday to isWorkday(0).
$endgroup$
– David Salgado
8 hours ago
$begingroup$
I get it. But if it's the case where I've a dummy variable for isWorkday and six for the days of the weeks(isTuesday,isWednesday,isThurday, isFriday,isSaturday and isSunday) and both in the multicollinearity tests generate conflict , which dummy I should choose isWeekDay or the six dummies?. Remember that I can make a relationship with two variables (multicolineality): isTuesday,isWednesday,isThurday and isFriday mapped to isWorkday(1) and isSaturday and isSunday to isWorkday(0).
$endgroup$
– David Salgado
8 hours ago
$begingroup$
To make a decision, you first test both options. Case 1: If isWorkday gives you better prediction results, you choose isWorkday. Case 2: If the six weekday-variables give you better prediction results, you choose the six weekday-variables. Case 3: If the six weekday-variables perform equally good as isWorkday, you choose isWorkday, because in this case, you end up with a smaller model.
$endgroup$
– georg_un
8 hours ago
$begingroup$
To make a decision, you first test both options. Case 1: If isWorkday gives you better prediction results, you choose isWorkday. Case 2: If the six weekday-variables give you better prediction results, you choose the six weekday-variables. Case 3: If the six weekday-variables perform equally good as isWorkday, you choose isWorkday, because in this case, you end up with a smaller model.
$endgroup$
– georg_un
8 hours ago
$begingroup$
Oh, I understand thanks, with that you tell me I'm also convinced that this would be the way to proceed.
$endgroup$
– David Salgado
7 hours ago
$begingroup$
Oh, I understand thanks, with that you tell me I'm also convinced that this would be the way to proceed.
$endgroup$
– David Salgado
7 hours ago
$begingroup$
Awesome, glad I could help.
$endgroup$
– georg_un
7 hours ago
$begingroup$
Awesome, glad I could help.
$endgroup$
– georg_un
7 hours ago
add a comment |
David Salgado is a new contributor. Be nice, and check out our Code of Conduct.
David Salgado is a new contributor. Be nice, and check out our Code of Conduct.
David Salgado is a new contributor. Be nice, and check out our Code of Conduct.
David Salgado is a new contributor. Be nice, and check out our Code of Conduct.
Thanks for contributing an answer to Data Science Stack Exchange!
- Please be sure to answer the question. Provide details and share your research!
But avoid …
- Asking for help, clarification, or responding to other answers.
- Making statements based on opinion; back them up with references or personal experience.
Use MathJax to format equations. MathJax reference.
To learn more, see our tips on writing great answers.
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
StackExchange.ready(
function () {
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fdatascience.stackexchange.com%2fquestions%2f49223%2fhow-dummy-variables-should-be-modeled-in-a-linear-regression-model%23new-answer', 'question_page');
}
);
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
1
$begingroup$
Have you tried both? Usually when faced with this kind of dilema we perform tests with our available options, unless the amount of tests needed create a effort in which the experiment is not worth of.
$endgroup$
– Pedro Henrique Monforte
yesterday
$begingroup$
@PedroHenriqueMonforte you are right, see what I answered next, and I know that all possible models should be tried, but the question is addressed to multicollinearity.
$endgroup$
– David Salgado
8 hours ago