R Tutorial : Basic lm() functions with glm()
Key Takeaways
The video demonstrates the application of lm() functions to Generalized Linear Models (GLMs) in R, using functions like print, summary, tidy, coef, confint, and predict to understand and use GLM outputs.
Full Transcript
welcome back during the previous exercises you learned about Poisson regressions now you will learn how L M functions can be applied to GL ends these functions help us understand and use GLM outputs besar has many functions for interacting with linear models and by extension GL ends in fact both lms and GLM's form a back one of our and its predecessor s the original authors of these languages often use LM s these functions allow us to easily access some parts of models thus rather than needing to manually interrogate an extract model outputs are gives helpful shortcuts these shortcuts allow us to see model outputs with functions like print and also makes statistical inferences with functions like summary when we were running at G L M model outputs automatically appear just like an LM alternatively we can explicitly print model outputs using the print function this output tells us several useful things including what model was fit or called the estimated coefficients the degrees of freedom which can be thought of as how many extra observations we have the null deviance and residual deviance which is the GLM version of residuals and the AIC score for the model in contrast to print summary provides more detail the first part of a summary output is the same as print and I did not include it here to save space the next portion of the GLM summary includes the Assembly of the deviance residuals which can be helpful for understanding a model fit next summary displays coefficients as well as your standard errors z-scores and p-values these can tell us if coefficients explain more variability than will be expected by chance alone next summary tells us about dispersion although not covered in this course some data can be over dispersed and neither have more variants or zeros than the model suggests these models require special over dispersion parameters next the model provides us similar deviance and degree of freedom information as the output last summary provides us with the Fischer scoring iterations which can be helpful if R has trouble fitting a model the tidy version also provides a standardized model output the tidy function in the broom package if we only want to look at the regression coefficients we can extract them using the couette function this provides us with the coefficient estimates for a model we might want to extract coefficients to either plot them or use them in future analysis similar to the coefficient function we can also estimate and display coefficient intervals using the confident function this function could take a while to run an R for larger models we can also change which intervals we estimate using the level option and only estimate the confidence interval for select parameters using the param option as a data scientist we often want to use models to predict future events like linear models the predict function can be used with g lms to use a fitted model with new data and make predictions if no new data file is specified then the predict function returns predictions based on the data used to fit the model if new data is specified the data from the prediction function is a vector that corresponds to the new data data frame you will get to apply these functions on GL and outputs that examine daily civilian non firefighter injuries this data is from Louisville Kentucky the data needs to be modeled using a Poisson distribution because it is count data with many zeros now let's look at the fire data and learn how to explore Geo
Original Description
Want to learn more? Take the full course at https://learn.datacamp.com/courses/generalized-linear-models-in-r at your own pace. More than a video, you'll learn hands-on coding & quickly apply skills to your daily work.
---
Welcome back. During the previous exercises, you learned about Poisson regressions. Now, you will learn how lm() functions can be applied to glm()s. These functions help to understand and use GLM outputs.
Base R has many functions for interacting with linear models, and by extensions GLMs. In fact, both LMs and GLMs form a backbone of R and its predecessor S. The original authors of these languages often used LMs. These functions allow us to easily access some parts of models. Thus, rather than needing to manually interrogate and extract model outputs, R gives helpful shortcuts. These shortcuts allows us to see the model outputs with function like print() and also make statistical inferences with function like summary().
When we run a GLM, model output automatically appears, just like a LM.
Alternatively, we can explicitly print model output using the print function.
This output tells us several useful things including what model was fit or "call"ed; the estimated coefficients; the degrees of freedom (which can be thought of as how many "extra" observations we have); the null deviance and residual deviance (which is the GLM version of residuals); and the AIC score for the model.
In contrast to print(), summary() provides more details.
The first part of a summary output is the same as print and I did not include it to save space.
The next portion of the glm() summary() includes a summary of the deviance residuals, which can be helpful for understanding a model fit.
Next, summary displays coefficients as well as their standard errors, z-scores, and p-values.
These can tell us if coefficient explains more variability than would be expected by chance alone.
Next, summary() tells us about dispersion.
Although not covered in this cour
Watch on YouTube ↗
(saves to browser)
Sign in to unlock AI tutor explanation · ⚡30
Playlist
Uploads from DataCamp · DataCamp · 0 of 60
← Previous
Next →
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
SQL Server Tutorial: Date manipulation
DataCamp
R Tutorial: Intermediate Interactive Data Visualization with plotly in R
DataCamp
R Tutorial: Adding aesthetics to represent a variable
DataCamp
R Tutorial: Moving Beyond Simple Interactivity
DataCamp
Python Tutorial: Why use ML for marketing? Strategies and use cases
DataCamp
Python Tutorial: Preparation for modeling
DataCamp
Python Tutorial: Machine Learning modeling steps
DataCamp
R Tutorial: The prior model
DataCamp
R Tutorial: Data & the likelihood
DataCamp
R Tutorial: The posterior model
DataCamp
R Tutorial: An Introduction to plotly
DataCamp
R Tutorial: Plotting a single variable
DataCamp
R Tutorial: Bivariate graphics
DataCamp
Python Tutorial: Customer Segmentation in Python
DataCamp
Python Tutorial: Time cohorts
DataCamp
Python Tutorial: Calculate cohort metrics
DataCamp
Python Tutorial: Cohort analysis visualization
DataCamp
R Tutorial: Building Dashboards with flexdashboard
DataCamp
R Tutorial: Anatomy of a flexdashboard
DataCamp
R Tutorial: Layout basics
DataCamp
R Tutorial: Advanced layouts
DataCamp
Python Tutorial: Time Series Analysis in Python
DataCamp
Python Tutorial: Correlation of Two Time Series
DataCamp
Python Tutorial: Simple Linear Regressions
DataCamp
Python Tutorial: Autocorrelation
DataCamp
R Tutorial: The gapminder dataset
DataCamp
R Tutorial: The filter verb
DataCamp
R Tutorial: The arrange verb
DataCamp
R Tutorial: The mutate verb
DataCamp
R Tutorial: What is cluster analysis?
DataCamp
R Tutorial: Distance between two observations
DataCamp
R Tutorial: The importance of scale
DataCamp
R Tutorial: Measuring distance for categorical data
DataCamp
Python Tutorial: Plotting multiple graphs
DataCamp
Python Tutorial: Customizing axes
DataCamp
Python Tutorial: Legends, annotations, & styles
DataCamp
Python Tutorial: Introduction to iterators
DataCamp
Python Tutorial: Playing with iterators
DataCamp
Python Tutorial: Using iterators to load large files into memory
DataCamp
SQL Tutorial: Introduction to Relational Databases in SQL
DataCamp
SQL Tutorial: Tables: At the core of every database
DataCamp
SQL Tutorial: Update your database as the structure changes
DataCamp
Python Tutorial: Classification-Tree Learning
DataCamp
Python Tutorial: Decision-Tree for Classification
DataCamp
Python Tutorial: Decision-Tree for Regression
DataCamp
Python Tutorial: Census Subject Tables
DataCamp
Python Tutorial: Census Geography
DataCamp
Python Tutorial: Using the Census API
DataCamp
R Tutorial: A/B Testing in R
DataCamp
R Tutorial: Baseline Conversion Rates
DataCamp
R Tutorial: Designing an Experiment - Power Analysis
DataCamp
R Tutorial: Introduction to qualitative data
DataCamp
R Tutorial: Understanding your qualitative variables
DataCamp
R Tutorial: Making Better Plots
DataCamp
SQL Tutorial: OLTP and OLAP
DataCamp
SQL Tutorial: Storing data
DataCamp
SQL Tutorial: Database design
DataCamp
Python Tutorial: Introduction to spaCy
DataCamp
Python Tutorial: Statistical Models
DataCamp
Python Tutorial: Rule-based Matching
DataCamp
🎓
Tutor Explanation
DeepCamp AI