library(vcdExtra)
## Loading required package: vcd
## Loading required package: grid
## Loading required package: gnm
library(reshape)
library(nnet)
library(effects)
## Loading required package: carData
##
## Attaching package: 'carData'
## The following object is masked from 'package:vcdExtra':
##
## Burt
## lattice theme set by effectsTheme()
## See ?effectsTheme for details.
library(ca)
data("TV", package="vcdExtra")
TV.df <- as.data.frame.table(TV)
TV.twoway <- cast(TV.df,fun.aggregate = sum, Day ~ Network)
## Using Freq as value column. Use the value argument to cast to override this choice
TV.twoway
## Day ABC CBS NBC
## 1 Monday 2847 2923 2629
## 2 Tuesday 3110 2403 2568
## 3 Wednesday 2434 1283 2212
## 4 Thursday 1766 1335 5886
## 5 Friday 2737 1479 1998
TV.multinom <- multinom(Network ~ Day + Time, data = TV.df, weights = Freq, Hess = TRUE)
## # weights: 48 (30 variable)
## initial value 41318.808177
## iter 10 value 38935.947713
## iter 20 value 38818.222728
## iter 30 value 38756.956301
## final value 38752.186202
## converged
plot(Effect(c("Day", "Time"), TV.multinom), style= "lines", key.args= list(x= 0.05, y= .9))
TV.ca <- ca(TV.twoway)
plot(TV.ca)
Correspondence analysis for part(a) shows that People watch CBS on Mondays and Tuesdays, ABC on Wednesdays and Fridays, and NBC on Thursdays. Effect plot in part(c) shows a very simila result as for which day in the week people wathch which network.