2013
play

2013 rockchalk 1 / 81 K.U. Introduction Data Outreg Plots - PowerPoint PPT Presentation

Introduction Data Outreg Plots Free Lunch Conclusions Guessing rockchalk package Paul E. Johnson 1 2 < pauljohn@ku.edu > 1 Department of Political Science 2 Center for Research Methods and Data Analysis, University of Kansas 2013


  1. Introduction Data Outreg Plots Free Lunch Conclusions Guessing rockchalk package Paul E. Johnson 1 2 < pauljohn@ku.edu > 1 Department of Political Science 2 Center for Research Methods and Data Analysis, University of Kansas 2013 rockchalk 1 / 81 K.U.

  2. Introduction Data Outreg Plots Free Lunch Conclusions Guessing Outline Introduction 1 Data 2 Outreg 3 Plots 4 Categorical modx Numeric moderator Free Lunch 5 Conclusions 6 Guessing 7 rockchalk 2 / 81 K.U.

  3. Introduction Data Outreg Plots Free Lunch Conclusions Guessing Outline Introduction 1 Data 2 Outreg 3 Plots 4 Categorical modx Numeric moderator Free Lunch 5 Conclusions 6 Guessing 7 rockchalk 3 / 81 K.U.

  4. Introduction Data Outreg Plots Free Lunch Conclusions Guessing Thanks for Joining Thanks to Ray DiGiacomo, Jr & OC RUG for organizing Downloads: http://pj.freefaculty.org/guides { all my lectures on anything } .../Rcourse/rockchalk-2013 { this lecture, source code, L YX doc, etc } http://pj.freefaculty.org/R : Rtips, links to other R stuff rockchalk 4 / 81 K.U.

  5. Introduction Data Outreg Plots Free Lunch Conclusions Guessing Why Make a Package? Avoid a riot after an influx of 40 MA-bound behavioral scientists into my regression class Honestly, I’d rather teach R programming, but I can understand the view that statistics exists apart from R Package has“convenience”functions for Me preparing lectures Them doing papers (with nice looking graphs!) I had distributed functions before, but never made a package rockchalk 5 / 81 K.U.

  6. Introduction Data Outreg Plots Free Lunch Conclusions Guessing What do you expect in rockchalk? Functions for difficult/tedious/hard-to-teach chores Verbose documentation, (too) many examples vignettes “rockchalk” : Dicussion & demonstration of package “Rchaeology” : Deep insights into R programming I accumulate while working on the package “ Rstyle” : The style manual I wish R Core would adopt Hidden value added: the examples folder in the package install directory includes some special educational R examples (look for noWords-001.R and centeredRegression.R ) rockchalk 6 / 81 K.U.

  7. Introduction Data Outreg Plots Free Lunch Conclusions Guessing Where is the hard work in version 1.8? predictOMatic() . Flexible way to demonstrate marginal effects of predictors. Goal: make it easy to understand regression as a translation of inputs into predicted values (and uncertainty) Scan fitted regressions, create newdata objects with possible predictor values ( “divider”algorithms to create focal values for consideration). rockchalk 7 / 81 K.U.

  8. Introduction Data Outreg Plots Free Lunch Conclusions Guessing Outline Introduction 1 Data 2 Outreg 3 Plots 4 Categorical modx Numeric moderator Free Lunch 5 Conclusions 6 Guessing 7 rockchalk 8 / 81 K.U.

  9. Introduction Data Outreg Plots Free Lunch Conclusions Guessing Make a Presentable Table Describing The Data Assignment: create a summary table for your research article R’s summary () does not include diversity estimates does not separate numeric from factor variables in the report does not provide output in a usable format rockchalk summarize() does rockchalk 9 / 81 K.U.

  10. Introduction Data Outreg Plots Free Lunch Conclusions Guessing Example ( datsum < − summary ( dat ) ) income educ age r e l i g i o n gender Min. : − 56816 Min. : 2 .00 Min. : 9 .00 cath :177 female :532 1 s t Qu. : − 2225 1 s t Qu. : 8 .00 1 s t Qu. :19 .00 j e w i s h : 87 male :468 Median : 10565 Median :10 .00 Median :22 .00 muslem : 94 Mean : 10473 Mean :10 .02 Mean :22 .04 other :294 3 rd Qu. : 23772 3 rd Qu. :12 .00 3 rd Qu. :25 .00 prot :169 Max. : 77189 Max. :21 .00 Max. :37 .00 roman :105 NA ✬ s :80 NA ✬ s :40 NA ✬ s : 74 Can you wrestle that into a paper? I can’t! It has text and values combined datsum [ , 1 ] ”Min. : − 56816 ” ”1 s t Qu. : − 2225 ” ”Median : 10565 ” ”Mean : 10473 ” ”3 rd Qu. : 23772 ” ”Max. : 77189 ” ”NA ✬ s :80 ” Default output from summarize separates numerics & factors, alphabetizes rockchalk 10 / 81 K.U.

  11. Introduction Data Outreg Plots Free Lunch Conclusions Guessing Example ... datsum2 < − summarize ( dat ) The result object datsum2 is a list with 2 parts, a numeric matrix part and a factor variable display. The numerics are a matrix, easy to take rows or columns to put into a paper datsum2$ numerics age educ income 0% 9 .000 2 .000 − 56820 25% 19 .000 8 .000 − 2225 50% 22 .000 10 .000 10570 75% 25 .000 12 .000 23770 100% 37 .000 21 .000 77190 mean 22 .040 10 .020 10470 sd 4 .556 3 .056 19630 var 20 .760 9 .337 385400000 NA ✬ s 0 .000 40 .000 80 N 1000 .000 1000 .000 1000 rockchalk 11 / 81 K.U.

  12. Introduction Data Outreg Plots Free Lunch Conclusions Guessing Example ... The factors are a separate list datsum2$ f a c t o r s gender r e l i g i o n female : 532 .000 other : 294 .0000 male : 468 .000 cath : 177 .0000 NA ✬ s : 0 .000 prot : 169 .0000 entropy : 0 .997 roman : 105 .0000 normedEntropy : 0 .997 ( A l l Others ) : 181 .0000 N :1000 .000 NA ✬ s : 74 .0000 entropy : 2 .4414 normedEntropy : 0 .9445 N :1000 .0000 Indicators of central tendency and dispersion are included in both displays Try summarizeNumerics() and summarizeFactors() to get just one or the other. rockchalk 12 / 81 K.U.

  13. Introduction Data Outreg Plots Free Lunch Conclusions Guessing Sidenote: recoding a factor Note the religion variable has levels“cath”and“roman” , which was a data entry error. Catholic and Roman Catholic represent the same idea Did you ever try to write R code to fix that (without killing yourself)? Try rockchalk::combineLevels() : dat $ r e l i g i o n 2 < − combineLevels ( dat $ r e l i g i o n , c ( ”cath ” , ”roman ”) , ”cath ”) The o r i g i n a l l e v e l s cath j e w i s h muslem other prot roman have been r e p l a c e d by j e w i s h muslem other prot cath rockchalk 13 / 81 K.U.

  14. Introduction Data Outreg Plots Free Lunch Conclusions Guessing Sidenote: recoding a factor ... t a b l e ( dat $ r e l i g i o n 2 , dat $ r e l i g i o n , dnn = c ( ” r e l i g i o n 2 ” , ” r e l i g i o n ”) ) r e l i g i o n r e l i g i o n 2 cath j e w i s h muslem other prot roman j e w i s h 0 87 0 0 0 0 muslem 0 0 94 0 0 0 other 0 0 0 294 0 0 prot 0 0 0 0 169 0 cath 177 0 0 0 0 105 rockchalk 14 / 81 K.U.

  15. Introduction Data Outreg Plots Free Lunch Conclusions Guessing Outline Introduction 1 Data 2 Outreg 3 Plots 4 Categorical modx Numeric moderator Free Lunch 5 Conclusions 6 Guessing 7 rockchalk 15 / 81 K.U.

  16. Introduction Data Outreg Plots Free Lunch Conclusions Guessing Need a Nice Looking Regression Table? Each student should not invent a unique report format for regressions. MS Word users especially tempted to“finger paint”with fonts and formats. Solution: provide usable L T EX tables (added benefit: bait to A get them to use L A T EX) rockchalk-1.8 provides HTML backend as well (compromise with reality) rockchalk 16 / 81 K.U.

  17. Introduction Data Outreg Plots Free Lunch Conclusions Guessing For many years, outreg was a function in search of a package Dave Armstrong (then at U. Maryland student) gave me the outreg idea 10 years ago I wrote up a function that more-or-less worked, distributed it, revised it as my R programming skills improved I didn’t know there was ” outreg”module for Stata . . . . rockchalk 17 / 81 K.U.

  18. Introduction Data Outreg Plots Free Lunch Conclusions Guessing outreg example usage I fit a regression using a subset of the American National Election Study 2004 (ICPSR), which I called“mydta1” mod1age < − lm ( t h . b u s h . k e r r y ∼ V043250 , data = mydta1 ) outreg ( mod1age , t i g h t = FALSE , modelLabels = c ( ”Age as P r e d i c t o r ”) ) rockchalk 18 / 81 K.U.

  19. Introduction Data Outreg Plots Free Lunch Conclusions Guessing Produces this LaTeX Markup \ begin { t a b u l a r }{ ✯ { 3 }{ l }} \ h l i n e & \ multicolumn { 2 }{ c }{ Age as P r e d i c t o r } \\ &Estimate &( S.E. ) \\ \ h l i n e \ h l i n e ( I n t e r c e p t ) & − 6.841 & (4 .596 ) \\ V043250 & 0 .184 ✯ & (0 .092 ) \\ \ h l i n e N &1191 & \\ RMSE &53 .885 & \\ $ R 2 $ &0 .003 & \\ \ h l i n e \ h l i n e \ multicolumn { 2 }{ l }{ $ { ✯ } p \ l e 0 .05 $ }\\ \ end { t a b u l a r } rockchalk 19 / 81 K.U.

  20. Introduction Data Outreg Plots Free Lunch Conclusions Guessing Which LaTeX Renders as Age as Predictor Estimate (S.E.) (Intercept) -6.841 (4.596) V043250 0.184* (0.092) N 1191 RMSE 53.885 R 2 0.003 ∗ p ≤ 0 . 05 My terminology: tight = FALSE ⇒ ˆ β and std . err (ˆ β ) are side by side tight = TRUE ⇒ ˆ β and std . err (ˆ β ) are vertically aligned. rockchalk 20 / 81 K.U.

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