[R] Factors and Multinomial Logistic Regression

Lorenzo Isella lorenzo.isella at gmail.com
Wed May 1 15:48:46 CEST 2013


Dear All,
I am trying to reproduce the example that I found online here


http://bit.ly/11VG4ha


However, when I run my script (pasted at the end of the email), I notice  
that there is a factor 2 between the values for the coefficients for the  
categorical variable female calculated by my script and in the online  
example.
Any idea about where this difference comes from?
Besides, how can I extract the p-values for the calculated coefficients of  
my model and for the relative risk ratios?
Best Regards

Lorenzo

###########################################################################
library(ares)
library(foreign)

## See the Stata example at http://bit.ly/11VG4ha

mydata <- read.dta("http://www.ats.ucla.edu/stat/data/hsb2.dta")


## IMPORTANT: redefine the base line!!!

mydata$ses2 <- relevel(mydata$ses, ref = "middle")



mymodel <- multinom(ses2 ~ science+ socst+ female, data=mydata)

print(summary(mymodel))

print("The relative risk ratio (RRR) is, ")

print(exp(coef(mymodel)))



More information about the R-help mailing list