data(car.all)
attach(car.all)
index = Country == "Germany" | Country == "USA" |
Country == "Japan" | Country == "Korea"
detach(car.all)
scar = car.all[index, ] # standardized car data
fcols = c(13,14,18:20,22:26,29:31,33,34,36) # These are factors
scar[,-fcols] = scale(scar[,-fcols]) # Standardize all numerical vars
ones = matrix(1, 3, 1)
cms = list("(Intercept)"=diag(3), Width=ones, Weight=ones,
Disp.=diag(3), Tank=diag(3), Price=diag(3),
Frt.Leg.Room=diag(3))
set.seed(111)
fit = rrvglm(Country ~ Width + Weight + Disp. + Tank + Price + Frt.Leg.Room,
multinomial, data = scar, Rank = 2, trace = TRUE,
constraints=cms, Norrr = ~ 1 + Width + Weight,
Uncor=TRUE, Corner=FALSE, Bestof=2)
fit@misc$deviance # A history of the fits
Coef(fit)
biplot(fit, chull=TRUE, scores=TRUE, clty=2, ccol="blue", scol="red",
Ccol="darkgreen", Clwd=2, Ccex=2,
main="1=Germany, 2=Japan, 3=Korea, 4=USA")
Run the code above in your browser using DataLab