From 41738aa5975f7f4fafc9c4b393172618fcc7c356 Mon Sep 17 00:00:00 2001 From: Vincent Arel-Bundock Date: Tue, 7 Sep 2021 15:52:24 -0400 Subject: [PATCH] stata tests --- .Rbuildignore | 1 + .here | 0 DESCRIPTION | 1 + tests/testthat/stata/clean.R | 50 ++++++++++++++++ tests/testthat/stata/data/MASS_polr_01.dta | Bin 0 -> 22670 bytes .../stata/data/betareg_betareg_01.dta | Bin 0 -> 6059 bytes .../testthat/stata/data/fixest_fixest_01.dta | Bin 0 -> 10411 bytes tests/testthat/stata/data/ivreg_ivreg_01.dta | Bin 0 -> 4475 bytes tests/testthat/stata/data/stats_glm_01.dta | Bin 0 -> 4475 bytes tests/testthat/stata/data/stats_lm_01.dta | Bin 0 -> 4875 bytes tests/testthat/stata/estimate.do | 41 +++++++++++++ tests/testthat/stata/generate.R | 54 ++++++++++++++++++ tests/testthat/stata/stata.rds | Bin 0 -> 597 bytes tests/testthat/test-dydx_MASS.R | 20 ++++++- tests/testthat/test-dydx_betareg.R | 14 +++++ tests/testthat/test-dydx_ivreg.R | 14 +++++ tests/testthat/test-dydx_stats.R | 28 ++++++++- 17 files changed, 218 insertions(+), 5 deletions(-) create mode 100644 .here create mode 100755 tests/testthat/stata/clean.R create mode 100755 tests/testthat/stata/data/MASS_polr_01.dta create mode 100755 tests/testthat/stata/data/betareg_betareg_01.dta create mode 100755 tests/testthat/stata/data/fixest_fixest_01.dta create mode 100755 tests/testthat/stata/data/ivreg_ivreg_01.dta create mode 100755 tests/testthat/stata/data/stats_glm_01.dta create mode 100755 tests/testthat/stata/data/stats_lm_01.dta create mode 100755 tests/testthat/stata/estimate.do create mode 100755 tests/testthat/stata/generate.R create mode 100755 tests/testthat/stata/stata.rds diff --git a/.Rbuildignore b/.Rbuildignore index b7287de76..dffa79a3b 100644 --- a/.Rbuildignore +++ b/.Rbuildignore @@ -2,3 +2,4 @@ ^README\.Rmd$ ^README\.html$ ^\.github$ +^\.here$ diff --git a/.here b/.here new file mode 100644 index 000000000..e69de29bb diff --git a/DESCRIPTION b/DESCRIPTION index 806c383ac..98eaa69df 100644 --- a/DESCRIPTION +++ b/DESCRIPTION @@ -27,6 +27,7 @@ Suggests: fixest, ggeffects, haven, + here, ivreg, lme4, MASS, diff --git a/tests/testthat/stata/clean.R b/tests/testthat/stata/clean.R new file mode 100755 index 000000000..df0ce49c7 --- /dev/null +++ b/tests/testthat/stata/clean.R @@ -0,0 +1,50 @@ +library(haven) +library(ivreg) +library(betareg) +library(MASS) +library(data.table) +library(testthat) +library(readxl) + +results <- list() + +# stats::glm +tmp <- read.table("results/stats_glm_01.txt", sep = "\t", skip = 4) |> + setNames(c("term", "dydxstata", "std.errorstata")) |> + head(2) +results[["stats_glm_01"]] <- tmp + +# stats::lm +tmp <- read.table("results/stats_lm_01.txt", sep = "\t", skip = 4) |> + setNames(c("term", "dydxstata", "std.errorstata")) |> + head(2) +results[["stats_lm_01"]] <- tmp + +# MASS::polr +tmp <- read.table("results/MASS_polr_01.txt", sep = "\t", skip = 4) |> + setNames(c("group", "dydxstata_x1", "std.errorstata_x1", "dydxstata_x2", "std.errorstata_x2")) |> + head(3) |> + transform(group = 2:4) |> + data.table() +cols <- names(tmp) +tmp[, (cols) := lapply(.SD, as.numeric)] +tmp <- melt(tmp, id.vars = "group") +tmp[, c("statistic", "term") := tstrsplit(variable, "_")] +tmp[, variable := NULL] +tmp <- dcast(tmp, group + term ~ statistic, value.var = "value") +results[["MASS_polr_01"]] <- tmp + +# ivreg::ivreg +tmp <- read.table("results/ivreg_ivreg_01.txt", sep = "\t", skip = 4) |> + setNames(c("term", "dydxstata", "std.errorstata")) |> + head(2) +results[["ivreg_ivreg_01"]] <- tmp + +# betareg::betareg +tmp <- read.table("results/betareg_betareg_01.txt", sep = "\t", skip = 4) |> + setNames(c("term", "dydxstata", "std.errorstata")) |> + head(1) +results[["betareg_betareg_01"]] <- tmp + +# save +saveRDS(results, file = "stata.rds") diff --git a/tests/testthat/stata/data/MASS_polr_01.dta b/tests/testthat/stata/data/MASS_polr_01.dta new file mode 100755 index 0000000000000000000000000000000000000000..be1ddefff4b21b0dee3c7c5db1d197695f9c84e8 GIT binary patch literal 22670 zcmeIacRbf$+&6BIlA>fq*(+Oij)b(RP)L-hBqJnAr9sNb2w9mCB2k1mWbeKA-h1zx zbGokUe%!zR?%yBR?{WX`9*^($)8}-~dCl{Djq`qgU zytT;#lUp_>3ZkOY^1}b|Mc(L%t%;@e?t}}Ps`A4B^;Q170x^NS@OcG!b%haP0`x~- zSY1K>!7U?`2MPo`|Azl2Z)<99vO~|@N`Xd1>X@d9)iE&@&@3`E9M<#~oOc`R|``?h@|F9+hpYXl^)hz#oA;?%Z|LKeWhbjO6it~Rp z@c$PL{7)Icze6p5``#_1`VYdEx)Zi1AL6r7+P~U{*CY0J}N(5OKTv=bt*m^MbOF{W%AA$1c{)KJHZM0tzt%GFoGe zV3%iu=HqI1G+Quj{B~u4%mCVtGyO()di^{k%#aEcb?-rAGiojj2fgP&=$7T-cV1a& zzYB3LS56(Y0Eu$i2a;Xp(L8-hmMJ&O-|&a7j2rivGBh^CQ83|~xdBF1BKKY+!Sg;c zk|a6sEJAVd-kKL~(_ojE75O@yI|;SWJMZJ0Y z_fFcG z4EpSSbxzHt70t_RDmay4GYl%O*SaQ?FC)6?<7dj(R0rX$oMsxLOIY^VOJoKt4zZK;i&mkv6Hj9ooW-gjMZAi~T|Gj@U0#edM0zfMT?8HD z9K`!`X3;zz#cP+ zUuFi4y_)5YOLCnDCw+Rkk0%Tuy?BE6>_^Q9;UE*c;A9l$@2FfzWr5y2q`WsrLT!Wn zfZO=}@l>N3AlmeW`7_f3S}R=FcQ{D1AEchyOI}Ef^&HUr{qH@oKG?6d_ku{f3Zm=% zoR-DYc>)@DWXB%k$NqBreUje`agy9hIleLv9+KQ$d5`ia>wK4?c`V*qB&xT*d@^PPIWNF2=ryeOUKw%`?WgyjP&&8{!4| z;2<>bOqj3$$E9>2%$>J38{3J-Ue8YOI&Dt_jc{Q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zKeSonQA@1e0EB|a>SLF&-&51Y z5h;+j0mg2vl_&~)Z(3INH_vP5otsjh{8uY&&WOgybbt*0zfo-zXDg~;OUFxs? zTrisl=?UAF*|Ni^A0g)7C)CvTh*YR*9-4Me5+o-`}Q@4y_5wq2SQT7vAOoR&U&wvb-VQhzx$mOKIL zu1k;{J&*f27uT*Ob6ng8HNKIVhwkHNFKfT1x2#F8!7G4bZf+Jo=XU3|arv{@CAcO) z^4q+60PLQHuzC3t6GsN%IJiQ3`V!7N@1-wL^e#<-MImb*|3U08q;--5!3m3yPM=OT z%mSac_eABCG;VDm#(_`k@~0xCtJtAOf#I(gq0kG91+96Uzxa~9-gBj;6!_5=u-6IU zSV49m?Cw#KUMO+wF8c-zz6-o_EXgcbU=a|~-Uy5}`bSrWN2ayDA093dubrl?Mn3f9 zu(2fnMi;nI`q|fDM+dw3a<(c<>qW^FIABmLLKTQ(t-LV$nK*eHTk8kAzasbV^MCre z&z;c+Mh_H3c0pn1zyIz(yDxZC{9|I*xp%*l?fkcEsNL_og6@uq5{MCq6G-g-5bzH7 SyT73KpTCre<@}GIApReJ)>>i! literal 0 HcmV?d00001 diff --git a/tests/testthat/stata/data/betareg_betareg_01.dta b/tests/testthat/stata/data/betareg_betareg_01.dta new file mode 100755 index 0000000000000000000000000000000000000000..67277b5340562cdf4c8a92fa6a57ca0b39f3f0e2 GIT binary patch literal 6059 zcmeI0e`p*<6vxN5##lnBwQ7HeoM4L}x_4<}TAl8V^o=It|q%>-5|B#|0Dx$>}e^sp1_vXzdHIflR;RJV% zy?3+o*?DijGxPR#xF1-7)t(A0lXu%z%Jxj|*^X`bwi%19; z=h;<@Ah0uTELt`9j9~y(bkA7Q3Oc*18G&3Nv>>?O=LJsM4<^BvW6$pC^6$ljw6$ljw6$lm3DR9=iw|Xw~&Th-IIs@B-w~TbBZ*t=wXHu}qVb<=r ze0}Q1_u?C5X%Q=Axl%}XF&qlM7O+R`3o_OOCJ^MsXvVJ$h z$MmdQknHA#Z{GZ6|1QNQC_Yw4R`e*lQOtsPPqlsZ>I?hIdUk$RvI9$uV^`IDq-RSx z$v*0Q`^VtPp*XmJk`ScbA|b1hjbw{GVm6!@dg;g4_qQI)w2Ty$@0(F zJ@!oRFzLHIq2}4eq}3M=*{CmYpX%p7$2WbqT#dza?1{W&_XJNZnsd9FXVbBzO_F{7 zIV|tQrClt>YCNK{Y3FbvI1N)HkK8&V0O3E&AR5{{r|$|B}=(vT+fy_OZJD`-oE0Y z@86%$m*)Izfv#Cu#c(1gaBmYP!@O&U4(Zuqzhp;#x%$q>hu@+YM&p9+^#i)MvM;cE z26KHbn5IW=>iBwWSkIR3mMknFSVaf)Y`I^u+>mLQ`+?_RmR9zxO$j*bBpovYK~(*n z5Mn?vE`b9JCRt1{xL|MsU|Ss=^WeaZ%*Tq;pTfrJw eBfFk8v6XBUgZ)a_C5Kzb$J@l4D2Y_rpZ^P~3tq1P literal 0 HcmV?d00001 diff --git a/tests/testthat/stata/data/fixest_fixest_01.dta b/tests/testthat/stata/data/fixest_fixest_01.dta new file mode 100755 index 0000000000000000000000000000000000000000..8eec33397697084c4a58e040c096b6a185f08e41 GIT binary patch literal 10411 zcmeHNPiP!f9DdQ7?3!e=r3o~L#yu!Rv7OyC)lgq&9|%@#sY!#0n9wl0J84#To6XE5 znzq6saxj-3mkOQ~^yE#_OD|Sf5Q_@_nVIkR+gZmhBOW@Jd4c@q&Aj)$ zZ@%B3_cj}8JBDMdR2)N>Yo<{#EnQk>%`|LNFBE2^#vNJOcFc9l8*qO9C8-5nc}^b` zQah*13wlnVN$r9zYevbe>B4=6E9q40rn_Ffp&!mapPM%uxvBhAAy=3_Jv}Y8;HlJ@ zO5JF<0B9eR9q+@%EZKHH`o{)fZ>C{i8-acC80;!pdlLQk$bLfhGqO_iR+U?ZRW(XA zbH&+in6`fZuLu1|Ei}xVcExaCQ?EBJW1YBum$z$iEsb?6Rl5-@gSB{<7ouVrPOJ*N z9q;l&Y}jTwRt2`~SeF;VsK-p;vT0bcQYaf%DOLi0l}1&T_PXWNsI7r))^vK z*R8tY*!ok2{E7VkDd)+=u)JOUM4T=$!k1Fx;B$`@wM}!yKSQk`io=7Gexg94K%zjR zz(ZHSJ6nXybMV>GFWPp`v&KVbn=F_pkSLHSkSLHSkSLHSkSLHSkSLHSkSOq973liL zk3QVV@|s~8WyiGKKPy+uwl1}Q-Kn@=veKu(QwmERC0l`QE~%4#8&UTsm*2nr%OTj! zJdMLFA=*V;W$8ZKXk5%2P&+@)-I{o;K=X0;LAc+1?X~AZ>nx$K78RanluOoS{D|^c zPkuB-JkO5K|9n5NZ+*KM2(;RSA4qIIc*>&LC@H$U#qvp;&_W{EGy zc{DEgM&m-?Jn5FhI&uU3<|_FsrCxTUV(%>bgL&}#vt_@f=)HJcZ(KJS+>97TT<-FC z#$y}cg6|21C%tj~G&_@_ajXO5u?=vM|4-6*j^B6Dzfq;U9iZo9>YA4*zen+9zlCsH z*MW2JCgG*j_@RZ&@h`^IMXykN7mW)Yj?;YRdky_oO+nYR^4(^Pse5jj+<7Y+7xAkI zm-v4^kA8C&{N}RcuRhd=cR1cTe%W$faGliuiF@xN^%vTz8`4f%c2tXB6<5 z?KxBzMe-Y9$E_&2Z!OWi9WpFe%Nn}GfFt@w;(SNzl(UTmKEY4 zqt-t7>3Z?huf&&e8INs%i~TGVXKnIZvk}S*-Z#0P2x?(m^4mW9jn5Ay@OAwLU5AKw zKkf_WL9m^31oP$dBgYNJ!?zaZw;ifGL!I*j;yH?Mj`AYNW1oTIJYJ%@o>kZ{`YErY d;z1~>`Nv>sJ66p*C6n#?{=~Z*>IVOx_&3w441WLs literal 0 HcmV?d00001 diff --git a/tests/testthat/stata/data/ivreg_ivreg_01.dta b/tests/testthat/stata/data/ivreg_ivreg_01.dta new file mode 100755 index 0000000000000000000000000000000000000000..46d2a378fe995ef2dc86a966dab13f3123285fe3 GIT binary patch literal 4475 zcmeHLYe*DP6ke^Y%ycUeEQ2M=f*!MLf?3z$m}bP5Wj=OhHd<$O%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38YC zz5>cNZYT<85Iw@^%1U#OkaC#(JbJovW*4$eSv-EGJxB=Y9!EOeMMG#FLlG}l#M#%u zsj1q~SvLn^rZsW~Ep`MJ9I#q;_M8%NIA5i#Fx#31G&VI=>1`+W)(M5o@|da@aLGm4 zoyK)&zWOZjti0P27;mX5hp$`tecpF!JZ7Duwx62-s%Q}$1R0FHiv&EfI`=mT+UOUn6g@b2V-cMUW z-skk(Pc<}Af7uc7akreK0Q?iKRjL%CHVo#?$VtHZ;7O%YHfH=3@y>Gf2z{t}2D@Uq z7Fre)^I%@EJuZ7P3Pl-l)Pxt>LUsLJ?Y+x4ijaU~uC0qjLqs3iDUfVv7`P9bS0?^C zt&TXOGIw6yUvW(YfA^hMNZL-+sgzo(lQ~ig4rZvtGY%4Y+32@aL0RKiqJ=0_j~h8_)f@TMCMAD!%_lL9Dse>ei~$ zHg!NRntG|lL5SAKnVh5j%&dy*_O&#Z^)9PBZUqJ~-x|L8zvT~o77io; literal 0 HcmV?d00001 diff --git a/tests/testthat/stata/data/stats_lm_01.dta b/tests/testthat/stata/data/stats_lm_01.dta new file mode 100755 index 0000000000000000000000000000000000000000..081ad3e5168d6a4542de6fbae672b7d4d7bb7591 GIT binary patch literal 4875 zcmeHLdpuRy7r#Ox@5)Fil&I9b^qd@bT_eO4CKWO0;wt4)?j2I2Obv-5r3Yy!J*Fr< zy^3{`S5uK!-dtRd^1R+e_orcMKJ)u;KJ%IRr+q%3^WAIhwfEY4t+n@F=MZcTlf!gy z<}m5RE*8_7BZB&wB)+8!QwZv}bi$18 zOqnPI)r?NKF&$ZMbjoQ04}>RZJJAU=5T8JoNi3G1pc^JpFp1M=Oz;Wn zN3Dc6)613V=*Dv3`0iz~=>vj~4?+D4`=gi#b9`C!{n``V|Fidgo&QYrgksUmXcO($lckRQ3s<-;8C5ny?)O$ zvd8=xXtGNBc6Z4c>AeP)Q>} z&G=~}nBUmfmDDCeE=;zoOD^t31HBARfSwj8Mi-wXY(8N3hCsy`;XPoeq^R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!t(;^nkX$XB$Y*s<=|SUT2u#;{b8>5uNxur8^?^V zg@hRzk6cgP){#W|9_JU!|PdrVFd?!X;72jN(e!dlA zx*i261~!1dN#nfyfevhyxRBkYoR3y%4eP7>Qh~cH`u^0)8oV%1WcV939`RN@`2E~K76y!k!ayY!dBX1^=*YiXx15MpttM;gqITOR(Cpp*LN)5>7X=Y z)uY0Ep^7)C*5^W3(B*?>t8lK0DGApXjAdNwXo9?({EI*ExyT!2T(y;W2U;r{OHb%j zf@BEoLcIZrZVc+O%egIJ9FXvIsq7$x9aC#pzgvZ#>#bYYeb<4uN~Y+Ai}B zhx>41YMt+mIb3k|k)V0@R^jt?Z${)3g-F?*tUI literal 0 HcmV?d00001 diff --git a/tests/testthat/stata/estimate.do b/tests/testthat/stata/estimate.do new file mode 100755 index 000000000..3caa228b6 --- /dev/null +++ b/tests/testthat/stata/estimate.do @@ -0,0 +1,41 @@ +cd ~/Dropbox/marginsxp_crosscheck + + +* stats::glm +clear +use data/stats_glm_01.dta +quiet logit y c.x1##c.x2 +quiet margins, dydx(x1 x2) post +outreg2 using "results/stats_glm_01.xls", dec(10) excel replace noaster sideway noparen stats(coef se) + + +* stats::lm +clear +use data/stats_lm_01.dta +quiet reg y c.x1##c.x2 +quiet margins, dydx(x1 x2) post +outreg2 using "results/stats_lm_01.xls", dec(10) excel replace noaster sideway noparen stats(coef se) + + +* betareg::betareg +clear +use data/betareg_betareg_01.dta +quiet betareg yield i.batch temp +quiet margins, dydx(temp) post +outreg2 using "results/betareg_betareg_01.xls", dec(10) excel replace noaster sideway noparen stats(coef se) + + +* MASS::polr +clear +use data/MASS_polr_01.dta +quiet ologit y x1 x2 +quiet margins, dydx(x1 x2) post +outreg2 using "results/MASS_polr_01.xls", dec(10) excel replace noaster sideway noparen stats(coef se) + + +* ivreg::ivreg +clear +use data/ivreg_ivreg_01.dta +quiet ivregress 2sls Q D (P = D F A) +quiet margins, dydx(P D) post +outreg2 using "results/ivreg_ivreg_01.xls", dec(10) excel replace noaster sideway noparen stats(coef se) diff --git a/tests/testthat/stata/generate.R b/tests/testthat/stata/generate.R new file mode 100755 index 000000000..008721b30 --- /dev/null +++ b/tests/testthat/stata/generate.R @@ -0,0 +1,54 @@ +library(haven) +library(ivreg) +library(betareg) + +################ +# stats::glm # +################ +set.seed(1024) +N <- 100 +dat <- data.frame(x1 = rnorm(N), x2 = rnorm(N)) +dat$y <- plogis(dat$x1 + dat$x2 + dat$x1 * dat$x2) +dat$y <- rbinom(N, 1, dat$y) +haven::write_dta(dat, path = "data/stats_glm_01.dta") + + +############### +# stats::lm # +############### +set.seed(1024) +N <- 100 +dat <- data.frame(x1 = rnorm(N), x2 = rnorm(N)) +dat$y <- dat$x1 + dat$x2 + dat$x1 * dat$x2 + rnorm(N) +haven::write_dta(dat, path = "data/stats_lm_01.dta") + + +################ +# MASS::polr # +################ +set.seed(1024) +N <- 1000 +dat <- data.frame(x1 = rnorm(N), x2 = rnorm(N)) +dat$y <- dat$x1 + dat$x2 + dat$x1 * dat$x2 + rnorm(N) +dat$y <- cut(dat$y, breaks = 4) +dat$y <- factor(as.numeric(dat$y)) +haven::write_dta(dat, path = "data/MASS_polr_01.dta") + + +################## +# ivreg::ivreg # +################## +haven::write_dta(ivreg::Kmenta, path = "data/ivreg_ivreg_01.dta") + + +###################### +# betareg::betareg # +###################### +data("GasolineYield", package = "betareg") +haven::write_dta(GasolineYield, path = "data/betareg_betareg_01.dta") + + +#################### +# fixest::fixest # +#################### +haven::write_dta(mtcars, path = "data/fixest_fixest_01.dta") diff --git a/tests/testthat/stata/stata.rds b/tests/testthat/stata/stata.rds new file mode 100755 index 0000000000000000000000000000000000000000..ed86d6f4b573c0db974111d29c88e0d16245e8bd GIT binary patch literal 597 zcmV-b0;>HViwFP!000001B>8dU|?WoU}0orU}gm}8CXL@+;lA%7?^}X9H5*qSOEir z01z`VurP3f=n6wP%LqvFfmrr?-OpZ~(7DJS%uOwZTEGkyWGP84%7wByQz}y`ic1np5}^Wo#U&|vsYONkMG#R` z^Eiw0%k^Mp@`4==k_6MJ7ANN<7Q-xt338{Sjl6m0l~?*dNZ0xb@(Aoc)B|BHQO3 zpJG2jwEO?dxX&uL)oH zddog9JlFnEe;Qh#v%u0odQpC90Tp7P0Z9D+|Nj?S3^1X@KuKa!PAaxIK}nZ_dYO4Z zm*gep=oP2tq!pzC9nT;J#s8p~ik^U5%vPLVRFay4=5#EkzGLk0i<)SMml literal 0 HcmV?d00001 diff --git a/tests/testthat/test-dydx_MASS.R b/tests/testthat/test-dydx_MASS.R index 7191103d1..bf66b8a67 100644 --- a/tests/testthat/test-dydx_MASS.R +++ b/tests/testthat/test-dydx_MASS.R @@ -1,19 +1,33 @@ skip_if_not_installed("MASS") library("margins") +library("haven") +library("data.table") -test_that("polr: test against margins", { +test_that("polr vs. margins", { skip("no idea why this fails") tmp <- data.frame(mtcars) tmp$carb <- as.factor(tmp$carb) mod <- MASS::polr(carb ~ hp + am + mpg, data = tmp) res <- marginsxp(mod, variance = NULL) mar <- margins(mod) - expect_s3_class(res, "data.frame") expect_equal(dim(res), c(480, 8)) - # TODO: not supported yet expect_error(marginsxp(mod, variance = NULL), regexp = "group_name") expect_error(marginsxp(mod, group_names = "1"), regexp = "not yet supported") }) + +test_that("polr vs. Stata", { + stata <- readRDS(test_path("stata/stata.rds"))[["MASS_polr_01"]] + dat <- read_dta(test_path("stata/data/MASS_polr_01.dta")) + mod <- MASS::polr(factor(y) ~ x1 + x2, data = dat) + mfx <- marginsxp(mod, + variance = NULL, + prediction_type = "probs") + mfx <- data.table(mfx) + ame <- mfx[, list(dydx = mean(dydx)), by = c("group", "term")][ + , group := as.numeric(group)] + ame <- merge(ame, stata, by = c("group", "term")) + expect_equal(ame$dydx, ame$dydxstata, tolerance = 0.001) +}) diff --git a/tests/testthat/test-dydx_betareg.R b/tests/testthat/test-dydx_betareg.R index 98705a12d..da4a111a5 100644 --- a/tests/testthat/test-dydx_betareg.R +++ b/tests/testthat/test-dydx_betareg.R @@ -1,6 +1,9 @@ skip_if_not_installed("betareg") library("margins") +library("haven") +library("betareg") +library("data.table") test_that("betareg", { data("GasolineYield", package = "betareg") @@ -11,3 +14,14 @@ test_that("betareg", { }) expect_true(cor(as.numeric(mar$temp), res$temp, use = "complete.obs") > .99999) }) + + +test_that("betareg vs. Stata", { + stata <- readRDS(test_path("stata/stata.rds"))[["betareg_betareg_01"]] + dat <- read_dta(test_path("stata/data/betareg_betareg_01.dta")) + mod <- betareg::betareg(yield ~ factor(batch) + temp, data = dat) + mfx <- suppressWarnings(data.table(marginsxp(mod, variance = NULL))) + ame <- mfx[, list(dydx = mean(dydx)), by = "term"] + ame <- merge(ame, stata) + expect_equal(ame$dydx, ame$dydxstata, tolerance = 0.00001) +}) diff --git a/tests/testthat/test-dydx_ivreg.R b/tests/testthat/test-dydx_ivreg.R index dd91e50e6..add523129 100644 --- a/tests/testthat/test-dydx_ivreg.R +++ b/tests/testthat/test-dydx_ivreg.R @@ -1,6 +1,9 @@ skip_if_not_installed("ivreg") library("margins") +library("haven") +library("data.table") +library("ivreg") test_that("ivreg: vs. margins", { data(Kmenta, package = "ivreg") @@ -9,3 +12,14 @@ test_that("ivreg: vs. margins", { mar <- data.frame(margins(mod, unit_ses = TRUE)) marginsxp:::test_against_margins(res, mar, tolerance = .01) }) + +test_that("ivreg: vs. Stata", { + dat <- read_dta(test_path("stata/data/ivreg_ivreg_01.dta")) + stata <- readRDS(test_path("stata/stata.rds"))[["ivreg_ivreg_01"]] + mod <- ivreg::ivreg(Q ~ P + D | D + F + A, data = dat) + mfx <- marginsxp(mod) + mfx <- data.table(mfx) + ame <- mfx[, list(dydx = mean(dydx), std.error = mean(std.error)), by = "term"] + ame <- merge(ame, stata, by = "term") + expect_equal(ame$dydx, ame$dydxstata, tolerance = 0.0001) +}) diff --git a/tests/testthat/test-dydx_stats.R b/tests/testthat/test-dydx_stats.R index cbfc52be6..98507f4ab 100644 --- a/tests/testthat/test-dydx_stats.R +++ b/tests/testthat/test-dydx_stats.R @@ -1,4 +1,6 @@ library("margins") +library("haven") +library("data.table") test_that("glm", { set.seed(1024) @@ -17,6 +19,28 @@ test_that("glm", { }) +test_that("glm vs. Stata", { + stata <- readRDS(test_path("stata/stata.rds"))[["stats_glm_01"]] + dat <- read_dta(test_path("stata/data/stats_glm_01.dta")) + mod <- glm(y ~ x1 * x2, family = binomial, data = dat) + mfx <- data.table(marginsxp(mod)) + ame <- mfx[, list(dydx = mean(dydx), std.error = mean(std.error)), by = "term"] + ame <- merge(ame, stata) + expect_equal(ame$dydx, ame$dydxstata, tolerance = 0.00001) +}) + + +test_that("lm vs. Stata", { + stata <- readRDS(test_path("stata/stata.rds"))[["stats_lm_01"]] + dat <- read_dta(test_path("stata/data/stats_lm_01.dta")) + mod <- lm(y ~ x1 * x2, data = dat) + mfx <- data.table(marginsxp(mod)) + ame <- mfx[, list(dydx = mean(dydx), std.error = mean(std.error)), by = "term"] + ame <- merge(ame, stata) + expect_equal(ame$dydx, ame$dydxstata, tolerance = 0.00001) +}) + + test_that("lm with interactions", { counterfactuals <- expand.grid(hp = 100, am = 0:1) mod <- lm(mpg ~ hp * am, data = mtcars) @@ -27,14 +51,14 @@ test_that("lm with interactions", { }) -test_that("TODO: loess vcov error is raised too early to catch", { +test_that("vcov(loess) does not exist", { mod <- loess(mpg ~ wt, data = mtcars) expect_error(marginsxp(mod), regexp = "not yet supported") }) test_that("loess error", { - skip("not sure why I get different results for loess") + skip("loess produces different results under margins and marginsxp") mod <- loess(mpg ~ wt, data = mtcars) res <- marginsxp(mod, variance = NULL) mar <- data.frame(margins(mod))