범주형-연속형 상호작용 시각화

R로 배우는 Generalized Additive Models (GAMs): 비선형 모델링

Noam Ross

Senior Research Scientist, EcoHealth Alliance

범주형-연속형 상호작용

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

R로 배우는 Generalized Additive Models (GAMs): 비선형 모델링

팩터 스무스

model4c <- gam(hw.mpg ~ s(weight, fuel, bs = "fs"),
               data = mpg,
               method = "REML")
R로 배우는 Generalized Additive Models (GAMs): 비선형 모델링
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로 배우는 Generalized Additive Models (GAMs): 비선형 모델링

팩터 스무스 시각화

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

R로 배우는 Generalized Additive Models (GAMs): 비선형 모델링

연습해 봅시다!

R로 배우는 Generalized Additive Models (GAMs): 비선형 모델링

Preparing Video For Download...