การสร้างโมเดลผลผลิตธัญพืช

Introduction to Writing Functions in R

Richie Cotton

Data Evangelist at DataCamp

กราฟอนุกรมเวลาแบบ faceted ของผลผลิตข้าวโพดที่สร้างในแบบฝึกหัดก่อนหน้า มี 9 แผง แต่ละแผงแทนหนึ่งภูมิภาค ผลผลิตเพิ่มขึ้นช้าๆ จนถึงราวปี 1950 แล้วเพิ่มขึ้นอย่างรวดเร็วหลังจากนั้น

Introduction to Writing Functions in R

Linear model vs. Generalized additive model

Linear model


lm(
  response_var ~ explanatory_var1 + explanatory_var2, 
  data = dataset
)

Generalized additive model

library(mgcv)
gam(
  response_var ~ s(explanatory_var1) + explanatory_var2, 
  data = dataset
)
Introduction to Writing Functions in R

การพยากรณ์ด้วย GAM

predict_this <- data.frame(
  explanatory_var1 = c("some", "values"),
  explanatory_var2 = c("more", "values")
)
predicted_responses <- predict(model, predict_this, type = "response")
predict_this %>%
  mutate(predicted_responses = predicted_responses)
Introduction to Writing Functions in R

มาฝึกกันเถอะ!

Introduction to Writing Functions in R

Preparing Video For Download...