Introduction Data Outreg Plots Free Lunch Conclusions Guessing
rockchalk package
Paul E. Johnson1
2
<pauljohn@ku.edu>
1Department of Political Science 2Center for Research Methods and Data Analysis, University of Kansas
2013
rockchalk 1 / 81 K.U.
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
Introduction Data Outreg Plots Free Lunch Conclusions Guessing
2
1Department of Political Science 2Center for Research Methods and Data Analysis, University of Kansas
rockchalk 1 / 81 K.U.
Introduction Data Outreg Plots Free Lunch Conclusions Guessing
1
2
3
4
5
6
7
rockchalk 2 / 81 K.U.
Introduction Data Outreg Plots Free Lunch Conclusions Guessing
1
2
3
4
5
6
7
rockchalk 3 / 81 K.U.
Introduction Data Outreg Plots Free Lunch Conclusions Guessing
rockchalk 4 / 81 K.U.
Introduction Data Outreg Plots Free Lunch Conclusions Guessing
Honestly, I’d rather teach R programming, but I can understand the view that statistics exists apart from R
rockchalk 5 / 81 K.U.
Introduction Data Outreg Plots Free Lunch Conclusions Guessing
“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
rockchalk 6 / 81 K.U.
Introduction Data Outreg Plots Free Lunch Conclusions Guessing
rockchalk 7 / 81 K.U.
Introduction Data Outreg Plots Free Lunch Conclusions Guessing
1
2
3
4
5
6
7
rockchalk 8 / 81 K.U.
Introduction Data Outreg Plots Free Lunch Conclusions Guessing
does not include diversity estimates does not separate numeric from factor variables in the report does not provide output in a usable format
does
rockchalk 9 / 81 K.U.
Introduction Data Outreg Plots Free Lunch Conclusions Guessing
( 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
−2225 1 s t
8 .00 1 s t
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
:294 3 rd
23772 3 rd
3 rd
prot :169 Max. : 77189 Max. :21 .00 Max. :37 .00 roman :105 NA✬ s :80 NA✬ s :40 NA✬ s : 74
datsum [ , 1 ] ”Min. : −56816 ” ”1 s t
−2225 ” ”Median : 10565 ” ”Mean : 10473 ” ”3 rd
23772 ” ”Max. : 77189 ” ”NA✬ s :80 ”
rockchalk 10 / 81 K.U.
Introduction Data Outreg Plots Free Lunch Conclusions Guessing
datsum2 < − summarize ( dat )
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.
Introduction Data Outreg Plots Free Lunch Conclusions Guessing
datsum2$ f a c t o r s gender r e l i g i o n female : 532 .000
: 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
rockchalk 12 / 81 K.U.
Introduction Data Outreg Plots Free Lunch Conclusions Guessing
rockchalk 13 / 81 K.U.
Introduction Data Outreg Plots Free Lunch Conclusions Guessing
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
prot roman j e w i s h 87 muslem 94
294 prot 169 cath 177 105
rockchalk 14 / 81 K.U.
Introduction Data Outreg Plots Free Lunch Conclusions Guessing
1
2
3
4
5
6
7
rockchalk 15 / 81 K.U.
Introduction Data Outreg Plots Free Lunch Conclusions Guessing
A
A
rockchalk 16 / 81 K.U.
Introduction Data Outreg Plots Free Lunch Conclusions Guessing
rockchalk 17 / 81 K.U.
Introduction Data Outreg Plots Free Lunch Conclusions Guessing
rockchalk 18 / 81 K.U.
Introduction Data Outreg Plots Free Lunch Conclusions Guessing
\ 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 & \\ $R2$ &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.
Introduction Data Outreg Plots Free Lunch Conclusions Guessing
rockchalk 20 / 81 K.U.
Introduction Data Outreg Plots Free Lunch Conclusions Guessing
rockchalk 21 / 81 K.U.
Introduction Data Outreg Plots Free Lunch Conclusions Guessing
rockchalk 22 / 81 K.U.
Introduction Data Outreg Plots Free Lunch Conclusions Guessing
rockchalk 23 / 81 K.U.
Introduction Data Outreg Plots Free Lunch Conclusions Guessing
rockchalk 24 / 81 K.U.
Introduction Data Outreg Plots Free Lunch Conclusions Guessing
rockchalk 25 / 81 K.U.
Introduction Data Outreg Plots Free Lunch Conclusions Guessing
rockchalk 26 / 81 K.U.
Introduction Data Outreg Plots Free Lunch Conclusions Guessing
rockchalk 27 / 81 K.U.
Introduction Data Outreg Plots Free Lunch Conclusions Guessing
http://pj.freefaculty.org/R/gloating/test2 http://pj.freefaculty.org/guides/stat/Regression/ Multicollinearity/Multicollinearity-1-lecture.pdf
rockchalk 28 / 81 K.U.
Introduction Data Outreg Plots Free Lunch Conclusions Guessing
model“header”labels and variable names the selection of“goodness of fit”indicators in the bottom of the table choice of alpha levels (Previously, I first refused p-values, then insisted only 0.05). HTML output (next slide)
rockchalk 29 / 81 K.U.
Introduction Data Outreg Plots Free Lunch Conclusions Guessing
markup. Wrestle that into Word however you like.
view the html document in a web browser, copy & paste manually into word (use paste Special HTML).
Not as nice looking or as automatic as L
A
T EX, but I may try harder in future
rockchalk 30 / 81 K.U.
Introduction Data Outreg Plots Free Lunch Conclusions Guessing
rockchalk 31 / 81 K.U.
Introduction Data Outreg Plots Free Lunch Conclusions Guessing
1
2
3
4
5
6
7
rockchalk 32 / 81 K.U.
Introduction Data Outreg Plots Free Lunch Conclusions Guessing
rockchalk 33 / 81 K.U.
Introduction Data Outreg Plots Free Lunch Conclusions Guessing
rockchalk 34 / 81 K.U.
Introduction Data Outreg Plots Free Lunch Conclusions Guessing
rockchalk 35 / 81 K.U.
Introduction Data Outreg Plots Free Lunch Conclusions Guessing
1 2 3 4 5 6 7 550 600 650 700 750 800 x1 y
rockchalk 36 / 81 K.U.
Introduction Data Outreg Plots Free Lunch Conclusions Guessing
1 2 3 4 5 6 7 550 650 750 850 x1 y Regression analysis Predicted values 95% confidence interval
rockchalk 37 / 81 K.U.
Introduction Data Outreg Plots Free Lunch Conclusions Guessing
rockchalk 38 / 81 K.U.
Introduction Data Outreg Plots Free Lunch Conclusions Guessing
rockchalk 39 / 81 K.U.
Introduction Data Outreg Plots Free Lunch Conclusions Guessing
rockchalk 40 / 81 K.U.
Introduction Data Outreg Plots Free Lunch Conclusions Guessing
rockchalk 41 / 81 K.U.
Introduction Data Outreg Plots Free Lunch Conclusions Guessing
Allows interactions (unlike termplot()) Output object can be passed to rockchalk function testSlopes()
Complete drop-in replacement for plotSlopes() Nonlinear formulae in the predictors (succeeds where termplot fails) Does not create object suitable for testSlopes()
rockchalk 42 / 81 K.U.
Introduction Data Outreg Plots Free Lunch Conclusions Guessing
rockchalk 43 / 81 K.U.
Introduction Data Outreg Plots Free Lunch Conclusions Guessing
rockchalk 44 / 81 K.U.
Introduction Data Outreg Plots Free Lunch Conclusions Guessing
1 2 3 4 5 6 7 −10 10 20 30 40 50 60 x1 y2 Moderator: x3 right (60%) left (40%)
rockchalk 45 / 81 K.U.
Introduction Data Outreg Plots Free Lunch Conclusions Guessing
rockchalk 46 / 81 K.U.
Introduction Data Outreg Plots Free Lunch Conclusions Guessing
1 2 3 4 5 6 7 −10 10 20 30 40 50 60 x1 y2 Moderator: x3 right (60%) left (40%)
rockchalk 47 / 81 K.U.
Introduction Data Outreg Plots Free Lunch Conclusions Guessing
rockchalk 48 / 81 K.U.
Introduction Data Outreg Plots Free Lunch Conclusions Guessing
1 2 3 4 5 6 7 −10 10 20 30 40 50 60 x1 y2 Moderator: x3 left
rockchalk 49 / 81 K.U.
Introduction Data Outreg Plots Free Lunch Conclusions Guessing
rockchalk 50 / 81 K.U.
Introduction Data Outreg Plots Free Lunch Conclusions Guessing
1 2 3 4 5 6 7 −10 10 20 30 40 50 60 x1 y2 Moderator: x3 right
rockchalk 51 / 81 K.U.
Introduction Data Outreg Plots Free Lunch Conclusions Guessing
rockchalk 52 / 81 K.U.
Introduction Data Outreg Plots Free Lunch Conclusions Guessing
rockchalk 53 / 81 K.U.
Introduction Data Outreg Plots Free Lunch Conclusions Guessing
rockchalk 54 / 81 K.U.
Introduction Data Outreg Plots Free Lunch Conclusions Guessing
1 2 3 4 5 6 7 550 650 750 850 x1 y Moderator: x2 25% 50% 75%
rockchalk 55 / 81 K.U.
Introduction Data Outreg Plots Free Lunch Conclusions Guessing
rockchalk 56 / 81 K.U.
Introduction Data Outreg Plots Free Lunch Conclusions Guessing
1 2 3 4 5 6 7 550 650 750 850 x1 y Moderator: x2 25% 50% 75%
rockchalk 57 / 81 K.U.
Introduction Data Outreg Plots Free Lunch Conclusions Guessing
rockchalk 58 / 81 K.U.
Introduction Data Outreg Plots Free Lunch Conclusions Guessing
1 2 3 4 5 6 7 550 650 750 850 x1 y Moderator: x2 (m−sd) (m) (m+sd)
rockchalk 59 / 81 K.U.
Introduction Data Outreg Plots Free Lunch Conclusions Guessing
rockchalk 60 / 81 K.U.
Introduction Data Outreg Plots Free Lunch Conclusions Guessing
1 2 3 4 5 6 7 550 650 750 850 x1 y Moderator: x2 (m−2sd) (m−sd) (m) (m+sd) (m+2sd)
rockchalk 61 / 81 K.U.
Introduction Data Outreg Plots Free Lunch Conclusions Guessing
package writers are inconsistent, don’t provide predict methods.
rockchalk 62 / 81 K.U.
Introduction Data Outreg Plots Free Lunch Conclusions Guessing
rockchalk 63 / 81 K.U.
Introduction Data Outreg Plots Free Lunch Conclusions Guessing
J-N: if the fitted model is ˆ yi = ˆ β0 + (ˆ β1 + ˆ β3x2i)x1i, for which values of x2i is (ˆ β1 + ˆ β3x2i) statistically significantly different from 0?
rockchalk 64 / 81 K.U.
Introduction Data Outreg Plots Free Lunch Conclusions Guessing
rockchalk 65 / 81 K.U.
Introduction Data Outreg Plots Free Lunch Conclusions Guessing
rockchalk 66 / 81 K.U.
Introduction Data Outreg Plots Free Lunch Conclusions Guessing
44 46 48 50 52 54 −10 10 20 30 40 The Moderator: x2 Marginal Effect of x1 : (b ^
x1 + b
^
x2:x1x2i)
45.87 Marginal Effect 95% Conf. Int. Shaded Region: Null Hypothesis bx1 + bx2:x1x2i = 0 rejected
rockchalk 67 / 81 K.U.
Introduction Data Outreg Plots Free Lunch Conclusions Guessing
1
2
3
4
5
6
7
rockchalk 68 / 81 K.U.
Introduction Data Outreg Plots Free Lunch Conclusions Guessing
mean centered values, x1c = (x1 - mean(x1)) by fitting lm(y ˜ x1c + x2 + x1c:x2 + x3, data = dat)
“residual centered”value of the interaction term, which is the residual from this regresision? lm( (x1*x2) ˜ x1 + x2, data = dat)
rockchalk 69 / 81 K.U.
Introduction Data Outreg Plots Free Lunch Conclusions Guessing
rockchalk 70 / 81 K.U.
Introduction Data Outreg Plots Free Lunch Conclusions Guessing
rockchalk 71 / 81 K.U.
Introduction Data Outreg Plots Free Lunch Conclusions Guessing
rockchalk 72 / 81 K.U.
Introduction Data Outreg Plots Free Lunch Conclusions Guessing
rockchalk 73 / 81 K.U.
Introduction Data Outreg Plots Free Lunch Conclusions Guessing
Slope same, standard error of slope same Intercept is“bigger” Predicted value at Y axis is more precise, due to hour-glass shape of CI
x1 y5 2 4 6 500 550 600 650 700 750 800 850 rockchalk 74 / 81 K.U.
Introduction Data Outreg Plots Free Lunch Conclusions Guessing
rockchalk 75 / 81 K.U.
Introduction Data Outreg Plots Free Lunch Conclusions Guessing
rockchalk 76 / 81 K.U.
Introduction Data Outreg Plots Free Lunch Conclusions Guessing
1
2
3
4
5
6
7
rockchalk 77 / 81 K.U.
Introduction Data Outreg Plots Free Lunch Conclusions Guessing
rockchalk 78 / 81 K.U.
Introduction Data Outreg Plots Free Lunch Conclusions Guessing
1
2
3
4
5
6
7
rockchalk 79 / 81 K.U.
Introduction Data Outreg Plots Free Lunch Conclusions Guessing
rockchalk 80 / 81 K.U.
Introduction Data Outreg Plots Free Lunch Conclusions Guessing
I’m filling in perceived gaps to create convenience
jargon is difficult (tough for me = ⇒impossible for students) their functions are clumsy, or I think their source code is not clear
rockchalk 81 / 81 K.U.