I like using a logical response in cases like this, but put its
construction in the formula so it is unambiguous when I look at the
results later.
> d <- data.frame(Covid=c("Pos","Pos","Neg","Pos","Neg","Neg"), Age=41:46)
> glm(family=binomial, data=d, Covid=="Pos"~Age)
Call: glm(formula = Covid
Hello,
Inline.
Às 20:01 de 01/08/2020, John Fox escreveu:
Dear Paul,
I think that this thread has gotten unnecessarily complicated. The
answer, as is easily demonstrated, is that a binary response for a
binomial GLM in glm() may be a factor, a numeric variable, or a
logical variable, with i
I didn't mean to imply that was the only time that it was required, only
that it's not universal in R.
On Sat, Aug 1, 2020 at 2:22 PM Bert Gunter wrote:
> ... yes, but so does lm() for a categorical **INdependent** variable with
> more than 2 numerically labeled levels. n levels = (n-1) df for
Hello,
From the documentation, help('glm'):
Details
A typical predictor has the form|response ~ terms|where|response|is the
(numeric) response vector and|terms|is a series of terms which specifies
a linear predictor for|response|.
For|binomial|and|quasibinomial|families the response ca
Dear Paul,
I think that this thread has gotten unnecessarily complicated. The
answer, as is easily demonstrated, is that a binary response for a
binomial GLM in glm() may be a factor, a numeric variable, or a logical
variable, with identical results; for example:
--- snip ---
You appear to be confusing a binomial **response** with categorical
"dependent variables." glm() of course fits continuous or categorical
dependent variables. If a continuous dependent variable has only 2 values,
the results for glm() will be the same whether or not it is considered to
be continuou
No, R does not. glm() does in order to do logistic regression.
On Sat, Aug 1, 2020 at 2:11 PM Paul Bernal wrote:
> Hi Bert,
>
> Thank you for the kind reply.
>
> But what if I don't turn the variable into a factor. Let's say that in
> excel I just coded the variable as 1s and 0s and just importe
... and further:
" If a continuous independent variable has only 2 values,..."
Bert Gunter
"The trouble with having an open mind is that people keep coming along and
sticking things into it."
-- Opus (aka Berkeley Breathed in his "Bloom County" comic strip )
On Sat, Aug 1, 2020 at 11:11 AM Bert
Sorry, typo.My first sentences should read:
"You appear to be confusing a binomial **response** with categorical
"independent variables." glm() of course fits continuous or categorical
independent variables."
Bert Gunter
"The trouble with having an open mind is that people keep coming along and
Dear friend,
I am aware that I have a binomial dependent variable, which is covid status
(1 if covid positive, and 0 otherwise).
My question was if R requires to turn a binomial response variable into a
factor or not, that's all.
Cheers,
Paul
El sáb., 1 de agosto de 2020 1:22 p. m., Bert Gunte
... yes, but so does lm() for a categorical **INdependent** variable with
more than 2 numerically labeled levels. n levels = (n-1) df for a
categorical covariate, but 1 for a continuous one (unless more complex
models are explicitly specified of course). As I said, the OP seems
confused about whet
Hi Bert,
Thank you for the kind reply.
But what if I don't turn the variable into a factor. Let's say that in
excel I just coded the variable as 1s and 0s and just imported the dataset
into R and fitted the logistic regression without turning any categorical
variable or dummy variable into a fact
On Sat, 1 Aug 2020, Paul Bernal wrote:
Hope you are doing great. I want to fit a logistic regression in R, where
the dependent variable is the covid status (I used 1 for covid positives,
and 0 for covid negatives), but when I ran the glm, R complains that I
should make the dependent variable a f
x <- factor(0:1)
x <- factor("yes","no")
will produce identical results up to labeling.
Bert Gunter
"The trouble with having an open mind is that people keep coming along and
sticking things into it."
-- Opus (aka Berkeley Breathed in his "Bloom County" comic strip )
On Sat, Aug 1, 2020 at 10
Dear friends,
Hope you are doing great. I want to fit a logistic regression in R, where
the dependent variable is the covid status (I used 1 for covid positives,
and 0 for covid negatives), but when I ran the glm, R complains that I
should make the dependent variable a factor.
What would be more
15 matches
Mail list logo