englianhu/ali-zonghui

Statistical Computing with R (2nd Edition).pdf

Opened this issue · 7 comments

#9 (comment) here i tried to build random effects while noticed doesn't enhance my model.

#degree = 2
mm000 = lm(Profit ~ Date * 
              poly(Bettor, degree = 2, raw = FALSE) * 
              poly(Won, degree = 2, raw = FALSE) * 
              poly(Cancelled, degree = 2, raw = FALSE) * 
              poly(Rebates, degree = 2, raw = FALSE) * 
              (1 + Won * Cancelled | Bettor) * (Type / Date), smp2) %>% 
    extractAIC

mm001 = lm(Profit ~ Date * 
               poly(Bettor, degree = 2, raw = FALSE) * 
               poly(Won, degree = 2, raw = FALSE) * 
               poly(Cancelled, degree = 2, raw = FALSE) * 
               poly(Rebates, degree = 2, raw = FALSE) * 
               (1 + Won * Cancelled / Bettor) * (Type / Date), smp2) %>% 
    extractAIC
#degree = 3
mm002 = lm(Profit ~ Date * 
              poly(Bettor, degree = 3, raw = FALSE) * 
              poly(Won, degree = 3, raw = FALSE) * 
              poly(Cancelled, degree = 3, raw = FALSE) * 
              poly(Rebates, degree = 3, raw = FALSE) * 
              (1 + Won * Cancelled | Bettor) * (Type / Date), smp2) %>% 
    extractAIC

mm003 = lm(Profit ~ Date * 
               poly(Bettor, degree = 3, raw = FALSE) * 
               poly(Won, degree = 3, raw = FALSE) * 
               poly(Cancelled, degree = 3, raw = FALSE) * 
               poly(Rebates, degree = 3, raw = FALSE) * 
               (1 + Won * Cancelled / Bettor) * (Type / Date), smp2) %>% 
    extractAIC

Explanation on random effects & nested lm via randomeffs2.pdf
lm - random effects & nested model.jpg