Slide 1

Slide 1 text

3DQQGPSFWFSZPOF ௡ବ@teuder

Slide 2

Slide 2 text

"CPVUNF ௡ాਅथ .BTBLJ&5TVEB 1I% -JGFTDJFODFT #VTJOFTT$POTVMUBOU XJUI %BUB4DJFODF

Slide 3

Slide 3 text

3DQQ 3DQQJTBQBDLBHFUIBUFOBCMFTZPV UPJNQMFNFOU3GVODUJPOTJO$ #ZVTJOH3DQQ ZPVDBOXSJUF$DPEFJOBTUZMFTJNJMBSUP3

Slide 4

Slide 4 text

No content

Slide 5

Slide 5 text

%JSL&EEFMCVFUUFM

Slide 6

Slide 6 text

5PEBZ *EPOPUUBMLBCPVUIPXUPVTF3DQQ CVUJOUSPEVDFZPVTPNFVTFGVMSFTPVSDFT XIFOZPVXBOUUPMFBSO3DQQ

Slide 7

Slide 7 text

5IFNBKPSSFTPVSDFTGPS MFBSOJOH3DQQ "EWBODFE3 3DQQ(BMMFSZ 3DQQ/PUF 7JHOFUUFT

Slide 8

Slide 8 text

"EWBODFE3 (SFBUJOUSPEVDUJPOUP3DQQ #VUJUMBDLTTPNFEFUBJMT )PXDBO*NPWFUPUIFOFYUTUFQ

Slide 9

Slide 9 text

3DQQ(BMMFSZ (SFBUDPNQJMBUJPOPGHPPEFYBNQMFT #VUUIFJOGPSNBUJPOJTGSBHNFOUFE )PXDBO*HFUUJEZLOPXMFEHFBCPVU3DQQ

Slide 10

Slide 10 text

3DQQ/PUF (SFBU$TUZMFSFGFSFODFEPDVNFOU #VUJUPOMZQSPWJEFMJNJUFEJOGPSNBUJPO )PXDBO*HFUNPSFQSBDUJDBM BOENPSFTZTUFNBUJDBMLOPXMFEHF

Slide 11

Slide 11 text

*OUIFTFEBZT *DPVMEOPUpOEBEPDVNFOUMJLFUIBU*XBOU #VUPOFEBZ *SFNFNCFSFEBQISBTF *`WFTFFOPOUIFJOUFSOFU

Slide 12

Slide 12 text

If there does not exist what you want, just create it. That should have been the oath of HOXO-M ! ͳ͚Ε͹࡞Δɻ ͦΕ͕ϗΫιΤϜͷ੤͍ͩͬͨ͸ͣʂ

Slide 13

Slide 13 text

IUUQTXXXHJUCPPLDPNCPPLUFVEFSJOUSPEVDUJPOUPSDQQEFUBJMT *XSPUFB3DQQ8FC#PPL

Slide 14

Slide 14 text

&OHMJTIWFSTJPOJTBMTPBWBJMBCMF IUUQTXXXHJUCPPLDPNCPPLUFVEFSJOUSPEVDUJPOUPSDQQEFUBJMT

Slide 15

Slide 15 text

$POUFOUTPGUIFCPPL 7FDUPS .BUSJY -JTU %BUB'SBNF 4 3MJLFGVODUJPOT 1SPCBCJMJUZEJTUSJCVUJPOT 6TJOH3GVODUJPOTGSPN3DQQ "UUSJCVUFT /"/BO*OG &OWJSPONFOU &SSPSIBOEMJOH BOENPSFʜ

Slide 16

Slide 16 text

4JODFUIF&OHMJTIWFSTJPO XBTSFMFBTFE 1BHFWJFXTEPVCMFEBOEJTTUJMMHSPXJOH 3FMFBTFPG&OHWFS /PW 5JNFTFSJFTPGQBHFWJFXTJOUIFMBTUNPOUIT

Slide 17

Slide 17 text

1BHFWJFXTCZDPVOUSJFT (FSNBOZJTUIFSEQMBDF #VUMBSHFMZCFIJOEGSPN64BOE+BQBO 1BHFWJFXTJOUIFMBTUNPOUIT

Slide 18

Slide 18 text

8IBUXPVMECF UIFHPPETJUVBUJPOUPVTF3DQQ w -PPQTJOXIJDIMBUFSJUFSBUJPOEFQFOETPOUIF QSFWJPVTJUFSBUJPO w 3FDVSSFOUDBMMTPGGVODUJPOJOMPPQ w "DDFTTJOHFBDIFMFNFOUTPGWFDUPSEBUBGSBNF w $IBOHJOHTJ[FPGBWFDUPSBUSVOUJNF w 0QFSBUJPOUIBUOFFEBEWBODFEEBUBTUSVDUVSF BOEBMHPSJUIN

Slide 19

Slide 19 text

#FDBVTF3DQQSFRVJSFTZPVBOFYUSBDPTU :PVNJHIUCFBCMFUPNBYJNJ[FZPVSRVBMJUZPGMJGF XIFOZPVVTFJUUPCSFBLCPUUMFOFDLPGZPVSDPEF 8IBUXPVMECF UIFHPPETJUVBUJPOUPVTF3DQQ

Slide 20

Slide 20 text

*ONZDBTF $POWFSUJOHEBUBGSBNFUPTQBSTFNBUSJY df %>% as.matrix %>% Matrix::Matrix(sparse = TRUE) #VUDPOWFSUJOHNBUSJYGBJMTXIFOUIFEBUBJT SFMBUJWFMZMBSHF BCPVUTFWFSBMUFOTPG(# df %>% asSparseMatrix 4P*DSFBUFB3DQQGVODUJPODPOWFSUJOHUIFEBUB EJSFDUMZUPTQBSTFNBUSJY

Slide 21

Slide 21 text

#include using namespace Rcpp; %FpOJOHBGVODUJPO // [[Rcpp::export]] S4 asSparseMatrix( DataFrame df ){ // prerequisite : // all the elements DataFrame is numeric/integer // and not containing NAs. // number of rows and columns int nrow = df.nrows(); int ncol = df.length();

Slide 22

Slide 22 text

6TJOHTUEWFDUPSJOTUFBEPG3DQQ7FDUPS #FDBVTFDIBOHJOHTJ[FPGWFDUPSBUSVOUJNF JTOPUFGpDJFOUJO3DQQ7FDUPS std::vector rows; std::vector cols; std::vector vals; 4UPSJOHUIFQPTJUJPOTBOEWBMVFTPG OPO[FSPFMFNFOUTJOUIF%BUB'SBNF for(R_xlen_t col=0; col

Slide 23

Slide 23 text

$BMMJOH.BUSJYTQBSTF.BUSJY Environment env = Environment::namespace_env("Matrix"); Function sparseMatrix = env["sparseMatrix"]; $POWFSUJOHTUEWFDUPSUP/VNFSJD7FDUPS S4 sm = sparseMatrix( Named("i") = wrap(rows), Named("j") = wrap(cols), Named("x") = wrap(vals), Named("dims") = NumericVector::create(nrow,ncol)); 4FUUJOHSPXOBNFTBOEDPMOBNFT List dimnames = List::create(R_NilValue, df.names()); sm.attr("Dimnames") = dimnames; 3FUVSOJOHUIFTQBSTFNBUSJY return sm; }

Slide 24

Slide 24 text

$PODMVTJPO w :PVDBOJNQMFNFOU3GVODUJPOJO$XJUI3DQQ w 5IFSFBSFTV⒏DJFOUSFTPVSDFTGPSMFBSOJOH3DQQ w 3DQQJTTVJUBCMFUPCSFBLCPUUMFOFDLTPGZPVSDPEF *IPQFNZl*OUSPEVDUJPOUP3DQQz XPVMEBJECSPBESBOHFPGQFPQMF &OKPZ

Slide 25

Slide 25 text

"EWFSUJTJOH 605 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 24 ষɹɹRcpp Rcpp Rcpp͸Rͷؔ਺ΛC++Ͱ࣮૷Ͱ͖ΔύοέʔδͰ͢ɻRͱྨࣅͨ͠ελΠϧͰهड़Ͱ͖ ΔΑ͏ʹ࣮૷͞Ε͍ͯΔͨΊɺC++ʹਂ͍஌͕ࣝͳͯ͘΋ར༻͠΍͘͢ͳ͍ͬͯ·͢ɻ͠ ͔΋ɺͦͷͨΊͷ࣮ߦ଎౓͸٘ਜ਼ʹ͞Ε͍ͯͳ͍ͷͰɺ୭Ͱ΋ϋΠύϑΥʔϚϯεͳ݁ՌΛ ಘΔ͜ͱ͕Ͱ͖·͢ɻ 24-1 Rcppͷ׆༻γʔϯ ࣍ͷΑ͏ͳέʔε͸C++Ͱ࣮૷͢Δ͜ͱʹΑΓɺRͱൺ΂ͯߴ଎Խ͕ݟࠐΊ·͢ɻ ɾ ܁Γฦ͠ॲཧɺಛʹ࣍ͷॲཧ͕લͷॲཧʹґଘ͓ͯ͠ΓฒྻԽͰ͖ͳ͍ ɾ ϕΫ τϧ΍ߦྻͷݸʑͷཁૉ΁ΞΫηε͢Δඞཁ͕͋Δ ɾ ϕΫ τϧͷαΠζΛಈతʹมߋ͍ͨ͠ ɾ ߴ౓ͳσʔλߏ଄΍ΞϧΰϦζϜΛ༻͍ͨॲཧΛߦ͍͍ͨ RcppͷύϑΥʔϚϯεΛࣔͨ͢Ίɺ܁Γฦ͠ॲཧͷྫͱͯ͠MCMCΞϧΰϦζϜͷҰछͰ͋ ΔΪϒεαϯϓϥʔ ʢ஫1ʣ ͷ࣮૷ྫΛࣔ͠·͢ɻ͜ͷྫͰ͸ɺΪϒεαϯϓϥʔʹΑΓඪ४2ม਺ ਖ਼ن෼෍͔Βn఺αϯϓϦϯά͍ͯ͠·͢ɻ ·ͣ͸ൺֱͷͨΊRΛ༻͍࣮ͨ૷ྫΛࣔ͠·͢ ʢϦετ24.1ʣ ɻ Ϧε τ24.1ɹGibbs.R GibbsR <- function(b, n, t){ # 2ม਺ඪ४ਖ਼ن෼෍͔Βn఺αϯϓϦ ϯά # b : 2ม਺ͷڞ෼ࢄ # n : αϯϓϧ਺ # t : αϯϓϦ ϯάࣺͤͣͯΔִؒ X <- matrix(0, nrow = n, ncol = 2) x1 <- x2 <- 0 sd <- sqrt(1-b^2) for(i in 1:n){ for(j in 1:t){ x1 <- rnorm(1, b*x2, sd) x2 <- rnorm(1, b*x1, sd) ʢ஫1ʣ ߴ࣍ݩͷෳࡶͳ֬཰෼෍ʹै͏ཚ਺Λੜ੒͢ΔϚϧίϑ࿈࠯ϞϯςΧϧϩ๏ͱݺ͹ΕΔΞϧΰϦζϜͷҰछͰ͢ɻ 24-1 24 ষ ٕज़ධ࿦ࣾɹ੫ࠐԁ