library(Design) # Logistic regression for an arbitrary two-valued variable # by default it uses alphabetical order to assign 0 and 1 to categories in outcome (so in this case NP is 0 and PP is 1) lrm(RealizationOfRecipient ~ LengthOfTheme,data=dative) # You can reverse this by converting to a number using as.numeric and then creating coding yourself lrm(abs(as.numeric(RealizationOfRecipient) - 2) ~ LengthOfTheme,data=dative) # Binary valued predictor # Again... by default it uses alphabetical order to assign 0 and 1 to categories summary(lm(RTlexdec ~ WordCategory,data=english)) lrm(RealizationOfRecipient ~ AnimacyOfRec,data=dative) #Many valued categorical predictors lrm(RealizationOfRecipient ~ SemanticClass,data=dative) # R uses dummy coding to put this into model. You don't need to do anything to have this happen, but it is useful to understand what is going on. A categorical predictor with three values "hat", "coat" and "umbrella" would be transformed into 2 columns or 1 and 0s as follows: contr.treatment(c("hat","coat","umbrella")) # Commands for example Multinomial Logit example (when there are multiple non-ordered outcome variables) install.packages("mlogit") library(mlogit) #Converting data to appropriate format etymology.mlogit = mlogit.data(etymology,shape="wide",choice="EtymAge") # A (not terribly informative) model giving the log odds ratio for each outcome relative to Dutch (the default reference class) summary(mlogit(EtymAge ~ 1, data=etymology.mlogit)) # A model giving the log odds ratio for each outcome relative to IndoEuropean summary(mlogit(EtymAge ~ 1, data=etymology.mlogit,reflevel="IndoEuropean")) # A model showing how the log odds of each outcome decreases as the number of words with a shared stem increases summary(mlogit(EtymAge ~ 1|NcountStem, data=etymology.mlogit)) # Commands for example Ordinal Logit example (when there are multiple ordered outcome variables) library(Design) #specifying ordering of variables etymology$EtymAge = ordered(etymology$EtymAge, levels = c("Dutch","DutchGerman", "WestGermanic", "Germanic", "IndoEuropean")) etymology.dd = datadist(etymology) lrm(EtymAge ~ NcountStem,data=etymology) #Interactions summary(lm(RTlexdec ~ WrittenFrequency + WordCategory,data=english)) summary(lm(RTlexdec ~ WrittenFrequency*WordCategory,data=english)) |