Using linear regression with binary and categorical variables.
up vote
1
down vote
favorite
I have a dataset with a binary variable: "Religious" with $0$ being "no" and $1$ being "yes". And a categorical variable "Contraceptive" having the values $1,2$ and $3$. Where $1$ = no use, $2$ = short term use and $3$ = long term use. The original dataset is something like this:
begin{align}
&text{Religious}::: text{Contraceptive}\
&1 hspace{42pt} 1 \
&1 hspace{42pt} 1 \
&0 hspace{42pt} 2 \
&0 hspace{42pt} 3 \
&vdots
end{align}
then I created three other columns and changed the contraceptive column to:
begin{align}
&text{no use} ::: text{short} ::: text{long}\
&1 hspace{28pt} 0 hspace{28pt} 0 \
&1 hspace{28pt} 0 hspace{28pt} 0 \
&0 hspace{28pt} 1 hspace{28pt} 0\
&0 hspace{28pt} 0 hspace{28pt} 1\
&vdots
end{align}
Is now possible to use a simple linear regression with these variables? How does one do that? I'm using R.
linear-algebra statistics regression
add a comment |
up vote
1
down vote
favorite
I have a dataset with a binary variable: "Religious" with $0$ being "no" and $1$ being "yes". And a categorical variable "Contraceptive" having the values $1,2$ and $3$. Where $1$ = no use, $2$ = short term use and $3$ = long term use. The original dataset is something like this:
begin{align}
&text{Religious}::: text{Contraceptive}\
&1 hspace{42pt} 1 \
&1 hspace{42pt} 1 \
&0 hspace{42pt} 2 \
&0 hspace{42pt} 3 \
&vdots
end{align}
then I created three other columns and changed the contraceptive column to:
begin{align}
&text{no use} ::: text{short} ::: text{long}\
&1 hspace{28pt} 0 hspace{28pt} 0 \
&1 hspace{28pt} 0 hspace{28pt} 0 \
&0 hspace{28pt} 1 hspace{28pt} 0\
&0 hspace{28pt} 0 hspace{28pt} 1\
&vdots
end{align}
Is now possible to use a simple linear regression with these variables? How does one do that? I'm using R.
linear-algebra statistics regression
add a comment |
up vote
1
down vote
favorite
up vote
1
down vote
favorite
I have a dataset with a binary variable: "Religious" with $0$ being "no" and $1$ being "yes". And a categorical variable "Contraceptive" having the values $1,2$ and $3$. Where $1$ = no use, $2$ = short term use and $3$ = long term use. The original dataset is something like this:
begin{align}
&text{Religious}::: text{Contraceptive}\
&1 hspace{42pt} 1 \
&1 hspace{42pt} 1 \
&0 hspace{42pt} 2 \
&0 hspace{42pt} 3 \
&vdots
end{align}
then I created three other columns and changed the contraceptive column to:
begin{align}
&text{no use} ::: text{short} ::: text{long}\
&1 hspace{28pt} 0 hspace{28pt} 0 \
&1 hspace{28pt} 0 hspace{28pt} 0 \
&0 hspace{28pt} 1 hspace{28pt} 0\
&0 hspace{28pt} 0 hspace{28pt} 1\
&vdots
end{align}
Is now possible to use a simple linear regression with these variables? How does one do that? I'm using R.
linear-algebra statistics regression
I have a dataset with a binary variable: "Religious" with $0$ being "no" and $1$ being "yes". And a categorical variable "Contraceptive" having the values $1,2$ and $3$. Where $1$ = no use, $2$ = short term use and $3$ = long term use. The original dataset is something like this:
begin{align}
&text{Religious}::: text{Contraceptive}\
&1 hspace{42pt} 1 \
&1 hspace{42pt} 1 \
&0 hspace{42pt} 2 \
&0 hspace{42pt} 3 \
&vdots
end{align}
then I created three other columns and changed the contraceptive column to:
begin{align}
&text{no use} ::: text{short} ::: text{long}\
&1 hspace{28pt} 0 hspace{28pt} 0 \
&1 hspace{28pt} 0 hspace{28pt} 0 \
&0 hspace{28pt} 1 hspace{28pt} 0\
&0 hspace{28pt} 0 hspace{28pt} 1\
&vdots
end{align}
Is now possible to use a simple linear regression with these variables? How does one do that? I'm using R.
linear-algebra statistics regression
linear-algebra statistics regression
asked Nov 18 at 19:08
Pinteco
629212
629212
add a comment |
add a comment |
1 Answer
1
active
oldest
votes
up vote
2
down vote
accepted
No. Your dependent variable is binary, i.e., ${0,1}$, hence a possible model is a logistic regression, i.e.,
$$
widehat{ mathbb{P}( Y_i = 1) } = frac{1}
{ 1 + exp{ -(beta_0 + beta_1text{short}
+
beta_1 text{short} )
}},
$$
in R
glm( formula = Religious ~ short + long,
family = binomial(link = "logit") )
What if the dependent variable is Contraceptive. I want to check how the religion impacts on the method of use in the contraceptive.
– Pinteco
Nov 18 at 19:57
Then multinomial logistic regression en.wikipedia.org/wiki/Multinomial_logistic_regression
– V. Vancak
Nov 18 at 19:58
If I had a categorical (contraceptive) with a numerical (age) then can I use a linear regression? What type of variables can I use linear regression, when the dependent variable is a categorical one (contraceptive) ? Maybe something like this exists in multiple linear regression, lm(short+long+noUse ~ age)
– Pinteco
Nov 18 at 20:10
Then you can use a multivariate regression. E.g., users.stat.umn.edu/~helwig/notes/mvlr-Notes.pdf slide 43 and on
– V. Vancak
Nov 18 at 20:13
add a comment |
1 Answer
1
active
oldest
votes
1 Answer
1
active
oldest
votes
active
oldest
votes
active
oldest
votes
up vote
2
down vote
accepted
No. Your dependent variable is binary, i.e., ${0,1}$, hence a possible model is a logistic regression, i.e.,
$$
widehat{ mathbb{P}( Y_i = 1) } = frac{1}
{ 1 + exp{ -(beta_0 + beta_1text{short}
+
beta_1 text{short} )
}},
$$
in R
glm( formula = Religious ~ short + long,
family = binomial(link = "logit") )
What if the dependent variable is Contraceptive. I want to check how the religion impacts on the method of use in the contraceptive.
– Pinteco
Nov 18 at 19:57
Then multinomial logistic regression en.wikipedia.org/wiki/Multinomial_logistic_regression
– V. Vancak
Nov 18 at 19:58
If I had a categorical (contraceptive) with a numerical (age) then can I use a linear regression? What type of variables can I use linear regression, when the dependent variable is a categorical one (contraceptive) ? Maybe something like this exists in multiple linear regression, lm(short+long+noUse ~ age)
– Pinteco
Nov 18 at 20:10
Then you can use a multivariate regression. E.g., users.stat.umn.edu/~helwig/notes/mvlr-Notes.pdf slide 43 and on
– V. Vancak
Nov 18 at 20:13
add a comment |
up vote
2
down vote
accepted
No. Your dependent variable is binary, i.e., ${0,1}$, hence a possible model is a logistic regression, i.e.,
$$
widehat{ mathbb{P}( Y_i = 1) } = frac{1}
{ 1 + exp{ -(beta_0 + beta_1text{short}
+
beta_1 text{short} )
}},
$$
in R
glm( formula = Religious ~ short + long,
family = binomial(link = "logit") )
What if the dependent variable is Contraceptive. I want to check how the religion impacts on the method of use in the contraceptive.
– Pinteco
Nov 18 at 19:57
Then multinomial logistic regression en.wikipedia.org/wiki/Multinomial_logistic_regression
– V. Vancak
Nov 18 at 19:58
If I had a categorical (contraceptive) with a numerical (age) then can I use a linear regression? What type of variables can I use linear regression, when the dependent variable is a categorical one (contraceptive) ? Maybe something like this exists in multiple linear regression, lm(short+long+noUse ~ age)
– Pinteco
Nov 18 at 20:10
Then you can use a multivariate regression. E.g., users.stat.umn.edu/~helwig/notes/mvlr-Notes.pdf slide 43 and on
– V. Vancak
Nov 18 at 20:13
add a comment |
up vote
2
down vote
accepted
up vote
2
down vote
accepted
No. Your dependent variable is binary, i.e., ${0,1}$, hence a possible model is a logistic regression, i.e.,
$$
widehat{ mathbb{P}( Y_i = 1) } = frac{1}
{ 1 + exp{ -(beta_0 + beta_1text{short}
+
beta_1 text{short} )
}},
$$
in R
glm( formula = Religious ~ short + long,
family = binomial(link = "logit") )
No. Your dependent variable is binary, i.e., ${0,1}$, hence a possible model is a logistic regression, i.e.,
$$
widehat{ mathbb{P}( Y_i = 1) } = frac{1}
{ 1 + exp{ -(beta_0 + beta_1text{short}
+
beta_1 text{short} )
}},
$$
in R
glm( formula = Religious ~ short + long,
family = binomial(link = "logit") )
answered Nov 18 at 19:54
V. Vancak
10.5k2926
10.5k2926
What if the dependent variable is Contraceptive. I want to check how the religion impacts on the method of use in the contraceptive.
– Pinteco
Nov 18 at 19:57
Then multinomial logistic regression en.wikipedia.org/wiki/Multinomial_logistic_regression
– V. Vancak
Nov 18 at 19:58
If I had a categorical (contraceptive) with a numerical (age) then can I use a linear regression? What type of variables can I use linear regression, when the dependent variable is a categorical one (contraceptive) ? Maybe something like this exists in multiple linear regression, lm(short+long+noUse ~ age)
– Pinteco
Nov 18 at 20:10
Then you can use a multivariate regression. E.g., users.stat.umn.edu/~helwig/notes/mvlr-Notes.pdf slide 43 and on
– V. Vancak
Nov 18 at 20:13
add a comment |
What if the dependent variable is Contraceptive. I want to check how the religion impacts on the method of use in the contraceptive.
– Pinteco
Nov 18 at 19:57
Then multinomial logistic regression en.wikipedia.org/wiki/Multinomial_logistic_regression
– V. Vancak
Nov 18 at 19:58
If I had a categorical (contraceptive) with a numerical (age) then can I use a linear regression? What type of variables can I use linear regression, when the dependent variable is a categorical one (contraceptive) ? Maybe something like this exists in multiple linear regression, lm(short+long+noUse ~ age)
– Pinteco
Nov 18 at 20:10
Then you can use a multivariate regression. E.g., users.stat.umn.edu/~helwig/notes/mvlr-Notes.pdf slide 43 and on
– V. Vancak
Nov 18 at 20:13
What if the dependent variable is Contraceptive. I want to check how the religion impacts on the method of use in the contraceptive.
– Pinteco
Nov 18 at 19:57
What if the dependent variable is Contraceptive. I want to check how the religion impacts on the method of use in the contraceptive.
– Pinteco
Nov 18 at 19:57
Then multinomial logistic regression en.wikipedia.org/wiki/Multinomial_logistic_regression
– V. Vancak
Nov 18 at 19:58
Then multinomial logistic regression en.wikipedia.org/wiki/Multinomial_logistic_regression
– V. Vancak
Nov 18 at 19:58
If I had a categorical (contraceptive) with a numerical (age) then can I use a linear regression? What type of variables can I use linear regression, when the dependent variable is a categorical one (contraceptive) ? Maybe something like this exists in multiple linear regression, lm(short+long+noUse ~ age)
– Pinteco
Nov 18 at 20:10
If I had a categorical (contraceptive) with a numerical (age) then can I use a linear regression? What type of variables can I use linear regression, when the dependent variable is a categorical one (contraceptive) ? Maybe something like this exists in multiple linear regression, lm(short+long+noUse ~ age)
– Pinteco
Nov 18 at 20:10
Then you can use a multivariate regression. E.g., users.stat.umn.edu/~helwig/notes/mvlr-Notes.pdf slide 43 and on
– V. Vancak
Nov 18 at 20:13
Then you can use a multivariate regression. E.g., users.stat.umn.edu/~helwig/notes/mvlr-Notes.pdf slide 43 and on
– V. Vancak
Nov 18 at 20:13
add a comment |
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%2fmath.stackexchange.com%2fquestions%2f3003988%2fusing-linear-regression-with-binary-and-categorical-variables%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