Binary logistic regression contrasts help

Basically, on Rstudio I'm trying to perform a binary logistic regression. I've downloaded the data and recoded the factors to categorical variables however when I perform the contrasts with the code contrasts() it comes out as: contrasts(dogs$dog)
[,1]
no 1
yes -1
which isn't right as it should be 0,1. Hence when I perform the binary logistic regression I get the error: Error in eval(family$initialize) : y values must be 0 <= y <= 1.
Can someone help me fix this, please?

THe code ive downloaded
library(psyntur)
library(tidyverse)
library(modelr)

dogs <- read.csv("dogs.csv")

dogs
str(dogs)

dogs$dog<-as.factor(dogs$dog)
str(dogs)

contrasts(dogs$dog)

m2 <- glm(like_cats ~ dog, data = dogs, family = binomial)
summary(m1)```

Hello.
Thanks for providing code , but you could take further steps to make it more convenient for other forum users to help you.

Share some representative data that will enable your code to run and show the problematic behaviour.

You might use tools such as the library datapasta, or the base function dput() to share a portion of data in code form, i.e. that can be copied from forum and pasted to R session.

sorry this doesnt help

Help us, to help you...

copying that code should work in r, it gives the data and what I've done

dogs <- read.csv("dogs.csv")
Error in file(file, "rt") : cannot open the connection
In addition: Warning message:
In file(file, "rt") :
cannot open file 'dogs.csv': No such file or directory

"dogs.csv" is your private data that you have not shared with the forum. I have sent you information on how you might share it.

I cant figure it out so I'll just leave it thanks

This topic was automatically closed 7 days after the last reply. New replies are no longer allowed.

If you have a query related to it or one of the replies, start a new topic and refer back with a link.