Modelování výnosů obilovin

Introduction to Writing Functions in R

Richie Cotton

Data Evangelist at DataCamp

Fazetovaná časová řada výnosů kukuřice z předchozího cvičení. Devět panelů, jeden pro každý region. V každém panelu výnosy pomalu rostou do roku 1950, poté rychle stoupají.

Introduction to Writing Functions in R

Lineární modely vs. zobecněné aditivní modely

Lineární model


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

Zobecněný aditivní model

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

Predikce pomocí 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

Pojďme si procvičit!

Introduction to Writing Functions in R

Preparing Video For Download...