[R] Error logistic analysis

Marc Schwartz
Tue, 08 Apr 2014 17:29:30 -0000

On Apr 8, 2014, at 7:20 AM, lghansse <lise.hanssens at ugent.be> wrote:

> I'm trying to conduct a single level logistic analysis (as a beginning
step
> for a more advanced Multi-level analysis). However, when I try to run it, I
> get following error:
>
> Warning messages:
> 1: In model.response(mf, "numeric") :
>  using type = "numeric" with a factor response will be ignored
> 2: In Ops.factor(y, z$residuals) : - not meaningful for factors
>
> I haven't got a clue why I'm getting this because I used the exact
same
> syntax (same data preparation etc...) for a similar analysis (same
> datastructure, different country).
>
> Syntax:
> Single_model1 <- lm(openhrs1 ~ genhealt1 + age + sexpat1 + hhincome1 +
> edupat1
> + etniciteit1, data=Slovakije)
>
> My Missing data are coded as such, I already tried to run the analysis in a
> data frame without the missing cases, but that didn't work either.


You are using the lm() function above, which is a regular least squares linear
regression for a continuous response variable.

If you want to run a logistic regression, you need to use glm() with 'family
= binomial':

Single_model1 <- glm(openhrs1 ~ genhealt1 + age + sexpat1 + hhincome1 +
                     edupat1 + etniciteit1, family = binomial, data = Slovakije)


Regards,

Marc Schwartz