generated from sta210-s22/website
-
Notifications
You must be signed in to change notification settings - Fork 2
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
modify week 3 content, change week 3 slides for Tuesday asynch class,…
… add R resource files
- Loading branch information
Showing
40 changed files
with
891 additions
and
94 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
14 changes: 14 additions & 0 deletions
14
_freeze/resources/week4_regression/execute-results/docx.json
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,14 @@ | ||
{ | ||
"hash": "8b7269d1df9a94d41b068ecb442db97f", | ||
"result": { | ||
"markdown": "---\ntitle: \"Regression Modeling in R\"\nformat: docx\neditor: visual\nexecute: \n eval: false\n---\n\n\n## Data Modeling\n\n- `lm()` -- fits a linear model to a dataset\n\n - You specify the variables as a formula (`y ~ x`), where `y` is your response variable and `x` is your explanatory variable\n - The second argument is the name of the dataset (`data = penguins`)\n\n\n ::: {.cell}\n \n ```{.r .cell-code}\n ## Two quantitative explanatory variables\n model1 <- lm(bill_length_mm ~ bill_depth_mm + body_mass_g, data = penguins)\n \n ## One quantitative and one categorical explanatory variable\n model2 <- lm(bill_length_mm ~ bill_depth_mm + sex, data = penguins)\n ```\n :::\n\n\n\\vspace{0.5cm}\n\n- `get_regression_table()` -- produces a tidy table output of a regression model\n - Output includes coefficients, standard errors, p-values, and confidence intervals\n\n\n::: {.cell}\n\n```{.r .cell-code}\nget_regression_table(model1)\n```\n:::\n\n\n\\vspace{0.5cm}\n\n- `summary()` -- produces a \"raw\" summary of a regression model\n - The \"untidy\" version of a regression summary.\n - Includes same information as `get_regression_table()`, but also includes $R^2$ and adjusted $R^2$.\n\n\n::: {.cell}\n\n```{.r .cell-code}\nsummary(model2)\n```\n:::\n\n\n\\newpage\n\n- `tidy()` -- takes untidy output and creates a nice table!\n\n - Similar to `get_regression_table()`, but doesn't output confidence intervals.\n - Lives in the **broom** package\n\n\n ::: {.cell}\n \n ```{.r .cell-code}\n tidy(model2)\n ```\n :::\n\n\n\\vspace{0.5cm}\n\n- `get_regression_points()` -- provides information on each observation used in a `lm()` in a tidy table format\n - Produces a table with the variables included in the regression, and the residual associated with each observation\n\n\n::: {.cell}\n\n```{.r .cell-code}\nget_regression_points(model1)\n```\n:::\n\n\n\\vspace{0.5cm}\n\n- `predict()` -- produces an untidy vector of the predicted y-values for each observation in the dataset\n - Can make predictions for new observations with the `newdata` argument.\n\n\n::: {.cell}\n\n```{.r .cell-code}\npredict(model1)\n\nnew_penguin <- data.frame(bill_depth_mm = 200, body_mass_g = 500)\npredict(model1, newdata = new_penguin)\n```\n:::\n\n\n\\vspace{0.5cm}\n\n- `augment()` -- produces a tidy table of data values from a regression model\n\n - Lives in the **broom** package\n - Produces a table with the variables included in the regression, and 6 additional columns:\n - including `.fitted` (predicted y-value for that observation), `.resid` (residual for that observation)\n - Can make predictions for new observations with the `newdata` argument.\n\n\n ::: {.cell}\n \n ```{.r .cell-code}\n augment(model2)\n \n new_penguin <- data.frame(bill_depth_mm = 15, sex = \"female\")\n augment(model2, newdata = new_penguin)\n ```\n :::\n", | ||
"supporting": [], | ||
"filters": [ | ||
"rmarkdown/pagebreak.lua" | ||
], | ||
"includes": {}, | ||
"engineDependencies": {}, | ||
"preserve": null, | ||
"postProcess": false | ||
} | ||
} |
Oops, something went wrong.