regression
play

Regression Thomas J. Leeper Department of Political Science and - PowerPoint PPT Presentation

Models Objects and Output Interactions Regression Thomas J. Leeper Department of Political Science and Government Aarhus University November 14, 2013 Models Objects and Output Interactions Models Objects and Output Interactions Models


  1. Models Objects and Output Interactions Regression Thomas J. Leeper Department of Political Science and Government Aarhus University November 14, 2013

  2. Models Objects and Output Interactions

  3. Models Objects and Output Interactions Models 1 2 Objects and Output Interactions 3

  4. Models Objects and Output Interactions Models 1 2 Objects and Output Interactions 3

  5. Models Objects and Output Interactions Model Formulæ Express relationships as a formula Typically: y x1 + x2 Interactions: y x1 * x2 y x1 + x2 + x1:x2 Formula is an object

  6. Models Objects and Output Interactions Try on your own Understand formulae: “Model Formulae”

  7. Models Objects and Output Interactions Questions so far?

  8. Models Objects and Output Interactions Running a regression We already ran regressions earlier Let’s understand what we did

  9. Models Objects and Output Interactions The regression from earlier lm3_1 <- lm(thresh~threat + fragdum, data = cis) lm3_2 <- lm(thresh~threat + fragdum, data=cis[cis$oursmpl==1,]) lm3_3 <- lm(thresh~threat13 + fragdum, data=cis[cis$oursmpl==1,]) lm3_4 <- lm(thresh~stthroct2 + fragdum, data=cis[cis$oursmpl==1,])

  10. Models Objects and Output Interactions Running a regression The linear regression function is lm Specify a formula and a place to look for data The result is an object of class “lm”

  11. Models Objects and Output Interactions The regression from earlier lm3_1 <- lm(thresh~threat + fragdum, data = cis) lm3_2 <- lm(thresh~threat + fragdum, data=cis[cis$oursmpl==1,]) lm3_3 <- lm(thresh~threat13 + fragdum, data=cis[cis$oursmpl==1,]) lm3_4 <- lm(thresh~stthroct2 + fragdum, data=cis[cis$oursmpl==1,])

  12. Models Objects and Output Interactions Models 1 2 Objects and Output Interactions 3

  13. Models Objects and Output Interactions Printing When we run a regression, we get some default output: lm(thresh~threat + fragdum, data = cis)

  14. Models Objects and Output Interactions Printing When we run a regression, we get some default output: lm(thresh~threat + fragdum, data = cis) This doesn’t print if we store the results: lm3_1 <- lm(thresh~threat + fragdum, data = cis)

  15. Models Objects and Output Interactions Printing When we run a regression, we get some default output: lm(thresh~threat + fragdum, data = cis) This doesn’t print if we store the results: lm3_1 <- lm(thresh~threat + fragdum, data = cis) But we can see the results again, once stored, by simply calling: lm3_1

  16. Models Objects and Output Interactions Structure and summary Structure: str(lm3_1) Names: names(lm3_1) Summary: summary(lm3_1)

  17. Models Objects and Output Interactions Coefficients Coefficients: coef(lm3_1) lm3_1$coef coef(summary(lm3_1)) summary(lm3_1)$coef

  18. Models Objects and Output Interactions Try on your own Understand OLS coefficient plotting: “OLS Coefficients”

  19. Models Objects and Output Interactions Questions so far?

  20. Models Objects and Output Interactions Fitted values and residuals lm3_1$fitted lm3_1$resduals predict(lm3_1)

  21. Models Objects and Output Interactions Try on your own Understand model fit: “OLS Diagnostic Plots” “Regression fit”

  22. Models Objects and Output Interactions Questions so far?

  23. Models Objects and Output Interactions Writing Output to Word Writing a CSV Using the rtf package: install.packages("rtf") library(rtf)

  24. Models Objects and Output Interactions Try on your own Output results to Word: “Word output”

  25. Models Objects and Output Interactions Questions so far?

  26. Models Objects and Output Interactions Models 1 2 Objects and Output Interactions 3

  27. Models Objects and Output Interactions Let’s work together “Binary interactions” “Continuous interactions”

Download Presentation
Download Policy: The content available on the website is offered to you 'AS IS' for your personal information and use only. It cannot be commercialized, licensed, or distributed on other websites without prior consent from the author. To download a presentation, simply click this link. If you encounter any difficulties during the download process, it's possible that the publisher has removed the file from their server.

Recommend


More recommend