Visualizing categorical-continuous interactions

R ile Genelleştirilmiş Katkılı Modeller (GAM'ler) ile Doğrusal Olmayan Modelle

Noam Ross

Senior Research Scientist, EcoHealth Alliance

Categorical-continuous interactions

model4b <- gam(hw.mpg ~ s(weight, by = fuel) + fuel, 
              data = mpg, 
              method = "REML")

R ile Genelleştirilmiş Katkılı Modeller (GAM'ler) ile Doğrusal Olmayan Modelle

Factor-smooths

model4c <- gam(hw.mpg ~ s(weight, fuel, bs = "fs"),
               data = mpg,
               method = "REML")
R ile Genelleştirilmiş Katkılı Modeller (GAM'ler) ile Doğrusal Olmayan Modelle
summary(model4c)
Family: gaussian 
Link function: identity 
Formula:
hw.mpg ~ s(weight, fuel, bs = "fs")

Parametric coefficients:
            Estimate Std. Error t value Pr(>|t|)    
(Intercept)   28.644      7.615   3.761 0.000223 ***
 ---
Signif. codes:  0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1

Approximate significance of smooth terms:
                edf Ref.df     F p-value    
s(weight,fuel) 7.71     19 53.12  <2e-16 ***
 ---
Signif. codes:  0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1

R-sq.(adj) =  0.832   Deviance explained = 83.8%
-REML = 518.54  Scale est. = 7.9735    n = 205
R ile Genelleştirilmiş Katkılı Modeller (GAM'ler) ile Doğrusal Olmayan Modelle

Plotting factor-smooths

plot(model4c)
vis.gam(model4c, theta = 125, plot.type = "persp")

R ile Genelleştirilmiş Katkılı Modeller (GAM'ler) ile Doğrusal Olmayan Modelle

Let's practice!

R ile Genelleştirilmiş Katkılı Modeller (GAM'ler) ile Doğrusal Olmayan Modelle

Preparing Video For Download...