1
I am trying to reproduce the results that are in the book An Introduction to Generalized Linear Models third Edition of Dobson and Barnett, on page 161. The adjustment is an ordinal regression applied to the data set (link to download). My big confusion is that the numerical results are the same but the signal is opposite, I think it has to see the reparametrization, but I’m not sure. Follow the code I used and also leave the images of the estimates presented in the book and the estimates I obtained. I appreciate the possible comments of what is happening.
library(readxl) #para usar la función "read_excel"
car_pref <- read_excel('car.xls')
car_pref <- car_pref[-1,]
car_pref <- car_pref[-1,]
colnames(car_pref) <- c("sex","age","response","frequency")
car_pref$frequency <- as.numeric(car_pref$frequency)
car_pref$sex <- factor(car_pref$sex)
car_pref$age <- factor(car_pref$age)
car_pref$response <- factor(car_pref$response)
car_pref$sex <- relevel(car_pref$sex, ref="women")
car_pref$age <- relevel(car_pref$age, ref="24-40")
car_pref$age <- relevel(car_pref$age, ref="18-23")
car_pref$response <- relevel(car_pref$response, ref="very important")
library(MASS)
res.polr <- polr(factor(response)~factor(age) + factor(sex), weights=frequency,data=car_pref)
summary(res.polr)
My results
Note that the estimates are numerically the same plus the sign is opposite.
The code the book presents is
res.polr <- polr(factor(response)~factor(age) + factor(sex), weights=frequency,data=car_pref)
more using this I do not get the output that presents the book.
I don’t have a definitive answer to give you, but some suggestions of where to look for ways to try and find out what’s going on. I took a look at the book here and, on this very page 161, the authors also provide the model adjustment code for STATA. In the table with the coefficients they did not report the output of STATA instead of R? Another hypothesis to be considered is the verisimilitude function itself to be maximized. Maybe it’s a difference in signal between R and STATA function?
– Marcus Nunes
Thank you so much for the suggestion @Marcusnunes.
– lbenitesanchez
I already understood that this happening, it happens that the book is not making use of the parameterization that makes the R, ie the parameterized ordinal model considered the opposite sign, such as link. In the book Agresti 2010, Analysis of Ordinal Categorical Data pag. 49 the author talks about said parameterization.
– lbenitesanchez