==6437== Memcheck, a memory error detector ==6437== Copyright (C) 2002-2017, and GNU GPL'd, by Julian Seward et al. ==6437== Using Valgrind-3.13.0 and LibVEX; rerun with -h for copyright info ==6437== Command: /data/blackswan/ripley/R/R-devel-vg/bin/exec/R --vanilla ==6437== R Under development (unstable) (2018-03-09 r74376) -- "Unsuffered Consequences" Copyright (C) 2018 The R Foundation for Statistical Computing Platform: x86_64-pc-linux-gnu (64-bit) R is free software and comes with ABSOLUTELY NO WARRANTY. You are welcome to redistribute it under certain conditions. Type 'license()' or 'licence()' for distribution details. Natural language support but running in an English locale R is a collaborative project with many contributors. Type 'contributors()' for more information and 'citation()' on how to cite R or R packages in publications. Type 'demo()' for some demos, 'help()' for on-line help, or 'help.start()' for an HTML browser interface to help. Type 'q()' to quit R. > pkgname <- "spatcounts" > source(file.path(R.home("share"), "R", "examples-header.R")) > options(warn = 1) > library('spatcounts') > > base::assign(".oldSearch", base::search(), pos = 'CheckExEnv') > base::assign(".old_wd", base::getwd(), pos = 'CheckExEnv') > cleanEx() > nameEx("Clarketest") > ### * Clarketest > > flush(stderr()); flush(stdout()) > > ### Name: Clarketest > ### Title: Clarke's test for non-nested model comparison > ### Aliases: Clarketest > > ### ** Examples > > data(sim.Yin) > data(sim.fm.X) > data(sim.region) > data(sim.gmat) > data(sim.nmat) > > poi <- est.sc(sim.Yin, ~1+sim.fm.X[,1]+sim.fm.X[,2], sim.region, + model="Poi", sim.gmat, sim.nmat, 3) ==6437== Conditional jump or move depends on uninitialised value(s) ==6437== at 0x4D1E55: FIND_ON_STACK (svn/R-devel/src/main/eval.c:6179) ==6437== by 0x4D1E55: bcEval (svn/R-devel/src/main/eval.c:6850) ==6437== by 0x4DA52F: Rf_eval (svn/R-devel/src/main/eval.c:624) ==6437== by 0x4DBE1E: R_execClosure (svn/R-devel/src/main/eval.c:1764) ==6437== by 0x4C7CC2: Rf_DispatchGroup (svn/R-devel/src/main/eval.c:3673) ==6437== by 0x4DB25F: cmp_arith2.isra.25 (svn/R-devel/src/main/eval.c:4241) ==6437== by 0x4CED32: bcEval (svn/R-devel/src/main/eval.c:6817) ==6437== by 0x4DA52F: Rf_eval (svn/R-devel/src/main/eval.c:624) ==6437== by 0x4DAD00: forcePromise (svn/R-devel/src/main/eval.c:520) ==6437== by 0x4DB127: FORCE_PROMISE (svn/R-devel/src/main/eval.c:4966) ==6437== by 0x4DB127: getvar (svn/R-devel/src/main/eval.c:5008) ==6437== by 0x4D07A1: bcEval (svn/R-devel/src/main/eval.c:6503) ==6437== by 0x4DA52F: Rf_eval (svn/R-devel/src/main/eval.c:624) ==6437== by 0x4DAD00: forcePromise (svn/R-devel/src/main/eval.c:520) ==6437== Uninitialised value was created by a stack allocation ==6437== at 0x4D3648: bcEval (svn/R-devel/src/main/eval.c:6402) ==6437== ==6437== Conditional jump or move depends on uninitialised value(s) ==6437== at 0x154A05CE: psimhbarbayern (packages/tests-vg/spatcounts/src/psimhbarbayern.c:49) ==6437== by 0x49AFE3: do_dotCode (svn/R-devel/src/main/dotcode.c:1772) ==6437== by 0x4CC001: bcEval (svn/R-devel/src/main/eval.c:6771) ==6437== by 0x4DA52F: Rf_eval (svn/R-devel/src/main/eval.c:624) ==6437== by 0x4DBE1E: R_execClosure (svn/R-devel/src/main/eval.c:1764) ==6437== by 0x4D15EA: bcEval (svn/R-devel/src/main/eval.c:6739) ==6437== by 0x4DA52F: Rf_eval (svn/R-devel/src/main/eval.c:624) ==6437== by 0x4DBE1E: R_execClosure (svn/R-devel/src/main/eval.c:1764) ==6437== by 0x4DA6BC: Rf_eval (svn/R-devel/src/main/eval.c:747) ==6437== by 0x4DE69F: do_set (svn/R-devel/src/main/eval.c:2774) ==6437== by 0x4DA8DB: Rf_eval (svn/R-devel/src/main/eval.c:699) ==6437== by 0x5060BC: Rf_ReplIteration (svn/R-devel/src/main/main.c:258) ==6437== Uninitialised value was created by a stack allocation ==6437== at 0x154A0430: psimhbarbayern (packages/tests-vg/spatcounts/src/psimhbarbayern.c:7) ==6437== ==6437== Conditional jump or move depends on uninitialised value(s) ==6437== at 0x154A05ED: psimhbarbayern (packages/tests-vg/spatcounts/src/psimhbarbayern.c:51) ==6437== by 0x49AFE3: do_dotCode (svn/R-devel/src/main/dotcode.c:1772) ==6437== by 0x4CC001: bcEval (svn/R-devel/src/main/eval.c:6771) ==6437== by 0x4DA52F: Rf_eval (svn/R-devel/src/main/eval.c:624) ==6437== by 0x4DBE1E: R_execClosure (svn/R-devel/src/main/eval.c:1764) ==6437== by 0x4D15EA: bcEval (svn/R-devel/src/main/eval.c:6739) ==6437== by 0x4DA52F: Rf_eval (svn/R-devel/src/main/eval.c:624) ==6437== by 0x4DBE1E: R_execClosure (svn/R-devel/src/main/eval.c:1764) ==6437== by 0x4DA6BC: Rf_eval (svn/R-devel/src/main/eval.c:747) ==6437== by 0x4DE69F: do_set (svn/R-devel/src/main/eval.c:2774) ==6437== by 0x4DA8DB: Rf_eval (svn/R-devel/src/main/eval.c:699) ==6437== by 0x5060BC: Rf_ReplIteration (svn/R-devel/src/main/main.c:258) ==6437== Uninitialised value was created by a stack allocation ==6437== at 0x154A0430: psimhbarbayern (packages/tests-vg/spatcounts/src/psimhbarbayern.c:7) ==6437== ==6437== Conditional jump or move depends on uninitialised value(s) ==6437== at 0x154A05F7: psimhbarbayern (packages/tests-vg/spatcounts/src/psimhbarbayern.c:51) ==6437== by 0x49AFE3: do_dotCode (svn/R-devel/src/main/dotcode.c:1772) ==6437== by 0x4CC001: bcEval (svn/R-devel/src/main/eval.c:6771) ==6437== by 0x4DA52F: Rf_eval (svn/R-devel/src/main/eval.c:624) ==6437== by 0x4DBE1E: R_execClosure (svn/R-devel/src/main/eval.c:1764) ==6437== by 0x4D15EA: bcEval (svn/R-devel/src/main/eval.c:6739) ==6437== by 0x4DA52F: Rf_eval (svn/R-devel/src/main/eval.c:624) ==6437== by 0x4DBE1E: R_execClosure (svn/R-devel/src/main/eval.c:1764) ==6437== by 0x4DA6BC: Rf_eval (svn/R-devel/src/main/eval.c:747) ==6437== by 0x4DE69F: do_set (svn/R-devel/src/main/eval.c:2774) ==6437== by 0x4DA8DB: Rf_eval (svn/R-devel/src/main/eval.c:699) ==6437== by 0x5060BC: Rf_ReplIteration (svn/R-devel/src/main/main.c:258) ==6437== Uninitialised value was created by a stack allocation ==6437== at 0x154A0430: psimhbarbayern (packages/tests-vg/spatcounts/src/psimhbarbayern.c:7) ==6437== acceptb/(i+1) 0.8 0.8 0.8 acceptga1/i acceptga2/(i+1) 0.6 0.8 acceptpsi/(i+1) 0 > nb <- est.sc(sim.Yin, ~1+sim.fm.X[,1]+sim.fm.X[,2], sim.region, + model="NB", sim.gmat, sim.nmat, 3) acceptb/(i+1) 0.8 0.8 0.8 acceptga1/i acceptga2/(i+1) 0.6 0.8 acceptr/(i+1) 0.2 acceptpsi/(i+1) 0 > > DIC.poi <- DIC(sim.Yin, ~1+sim.fm.X[,1]+sim.fm.X[,2], sim.region, poi) DIC 9446.043 mean deviance 9043.533 p.D 402.5101 > DIC.nb <- DIC(sim.Yin, ~1+sim.fm.X[,1]+sim.fm.X[,2], sim.region, nb) DIC 9354.367 mean deviance 9117.069 p.D 237.2979 > > ll.poi <- LogLike(sim.Yin, ~1+sim.fm.X[,1]+sim.fm.X[,2], sim.region, poi) > ll.nb <- LogLike(sim.Yin, ~1+sim.fm.X[,1]+sim.fm.X[,2], sim.region, nb) > > Clarke.poi.nb <- Clarketest(ll.poi, ll.nb, alpha = 0.05, p = DIC.poi$p.D, + q = DIC.nb$p.D, correction = TRUE) Favour model 1 0 No decision 0 Favour model 2 1 > > > > cleanEx() > nameEx("DIC") > ### * DIC > > flush(stderr()); flush(stdout()) > > ### Name: DIC > ### Title: Deviance information criterion > ### Aliases: DIC > > ### ** Examples > > data(sim.Yin) > data(sim.fm.X) > data(sim.region) > data(sim.gmat) > data(sim.nmat) > > poi <- est.sc(sim.Yin, ~1+sim.fm.X[,1]+sim.fm.X[,2], sim.region, + model="Poi", sim.gmat, sim.nmat, 3) acceptb/(i+1) 0.8 0.8 0.8 acceptga1/i acceptga2/(i+1) 0.6 0.8 acceptpsi/(i+1) 0 > DIC.poi <- DIC(sim.Yin, ~1+sim.fm.X[,1]+sim.fm.X[,2], sim.region, poi) DIC 9446.043 mean deviance 9043.533 p.D 402.5101 > > > > cleanEx() > nameEx("LogLike") > ### * LogLike > > flush(stderr()); flush(stdout()) > > ### Name: LogLike > ### Title: Individual log-likelihood > ### Aliases: LogLike > > ### ** Examples > > data(sim.Yin) > data(sim.fm.X) > data(sim.region) > data(sim.gmat) > data(sim.nmat) > > poi <- est.sc(sim.Yin, ~1+sim.fm.X[,1]+sim.fm.X[,2], sim.region, + model="Poi", sim.gmat, sim.nmat, 3) acceptb/(i+1) 0.8 0.8 0.8 acceptga1/i acceptga2/(i+1) 0.6 0.8 acceptpsi/(i+1) 0 > > ll.poi <- LogLike(sim.Yin, ~1+sim.fm.X[,1]+sim.fm.X[,2], sim.region, poi) > > # log likelihood for the single iterations > apply(ll.poi$ll,2,sum) [1] -5413.499 -4310.108 -4288.478 -4301.497 -4295.249 > > > > cleanEx() > nameEx("Vuongtest") > ### * Vuongtest > > flush(stderr()); flush(stdout()) > > ### Name: Vuongtest > ### Title: Vuong's test for non-nested model comparison > ### Aliases: Vuongtest > > ### ** Examples > > data(sim.Yin) > data(sim.fm.X) > data(sim.region) > data(sim.gmat) > data(sim.nmat) > > poi <- est.sc(sim.Yin, ~1+sim.fm.X[,1]+sim.fm.X[,2], sim.region, + model="Poi", sim.gmat, sim.nmat, 3) acceptb/(i+1) 0.8 0.8 0.8 acceptga1/i acceptga2/(i+1) 0.6 0.8 acceptpsi/(i+1) 0 > nb <- est.sc(sim.Yin, ~1+sim.fm.X[,1]+sim.fm.X[,2], sim.region, + model="NB", sim.gmat, sim.nmat, 3) acceptb/(i+1) 0.8 0.8 0.8 acceptga1/i acceptga2/(i+1) 0.6 0.8 acceptr/(i+1) 0.2 acceptpsi/(i+1) 0 > > DIC.poi <- DIC(sim.Yin, ~1+sim.fm.X[,1]+sim.fm.X[,2], sim.region, poi) DIC 9446.043 mean deviance 9043.533 p.D 402.5101 > DIC.nb <- DIC(sim.Yin, ~1+sim.fm.X[,1]+sim.fm.X[,2], sim.region, nb) DIC 9354.367 mean deviance 9117.069 p.D 237.2979 > > ll.poi <- LogLike(sim.Yin, ~1+sim.fm.X[,1]+sim.fm.X[,2], sim.region, poi) > ll.nb <- LogLike(sim.Yin, ~1+sim.fm.X[,1]+sim.fm.X[,2], sim.region, nb) > > Vuong.poi.nb <- Vuongtest(ll.poi, ll.nb, alpha = 0.05, p = DIC.poi$p.D, + q = DIC.nb$p.D, correction = TRUE) Favour model 1 0 No decision 0 Favour model 2 1 > > > > cleanEx() > nameEx("est.sc") > ### * est.sc > > flush(stderr()); flush(stdout()) > > ### Name: est.sc > ### Title: Fitting spatial count regression models > ### Aliases: est.sc > > ### ** Examples > > data(sim.Yin) > data(sim.fm.X) > data(sim.region) > data(sim.gmat) > data(sim.nmat) > # true parameters for generating this data: > # beta.true = c(-1, 0.4, 1.5) > # gamma.true = vector of spatial effects according to the CAR model with mean 0, psi = 3 and sigma = 1 > # range of gamma.true = c(-0.851, 0.8405) > > # run all examples with higher number of iterations if you want to approximate the true parameters > # properly > > poi <- est.sc(sim.Yin, ~1+sim.fm.X[,1]+sim.fm.X[,2], sim.region, + model="Poi", sim.gmat, sim.nmat, totalit=10) acceptb/(i+1) 0.9166667 0.8333333 0.8333333 acceptga1/i acceptga2/(i+1) 0.6666667 0.9166667 acceptpsi/(i+1) 0.1666667 > > # posterior means not considering a burn-in or thinning of iterations > apply(poi$beta,1,mean) [1] -0.7985307 0.3839060 1.3137557 > apply(poi$gamma,1,mean) [1] -0.334703681 -0.342766716 -0.188041507 0.261982581 0.636944756 [6] 0.038943705 -0.565468874 -0.299485031 0.161775827 -0.166974655 [11] -0.529935166 -0.735166726 -0.300578830 0.173419651 0.254534375 [16] -0.123247372 -0.549093050 -0.057527266 -0.012448938 -0.401108252 [21] -0.020464927 -0.325566114 -0.608639418 -0.001703991 0.021587892 [26] -0.152974228 0.139766302 0.269434393 0.007906486 -0.331041068 [31] -0.680391748 -0.333742718 -0.036893506 0.143410544 -0.006886459 [36] -0.325474903 -0.344212630 -0.124074415 -0.198536392 -0.325444626 [41] -0.037838688 -0.492266254 -0.234888175 -0.020422315 0.108312538 [46] -0.219472567 -0.012762513 -0.004764227 -0.329510448 -0.043695851 [51] -0.224262529 -0.120634526 -0.458087980 -0.466928119 -0.365948384 [56] -0.418757358 -0.238750175 0.057019668 -0.512344499 -0.018312119 [61] -0.327935735 -0.710331155 -0.236033084 -0.262103144 -0.265513540 [66] -0.352389759 -0.166142623 -0.021944027 -0.328920302 -0.223558799 [71] -0.608581750 -0.487428442 0.058167524 -0.170685664 0.275313452 [76] -0.144355707 -0.334089344 0.210048182 -0.223345562 -0.282052359 [81] -0.353038929 -0.333509459 -0.506585614 0.224603515 0.017965302 [86] -0.070967201 0.035133642 0.190391484 0.314445217 0.111541805 [91] -0.135747339 -0.322339350 -0.503161399 -0.430929829 -0.121469341 [96] -0.341488970 0.041517605 0.253493938 0.243501059 0.192569226 > > > # Compare Poisson to different model classes > nb <- est.sc(sim.Yin, ~1+sim.fm.X[,1]+sim.fm.X[,2], sim.region, model="NB", sim.gmat, sim.nmat, totalit=10) acceptb/(i+1) 0.9166667 0.8333333 0.9166667 acceptga1/i acceptga2/(i+1) 0.75 0.9166667 acceptr/(i+1) 0.6666667 acceptpsi/(i+1) 0.3333333 > > gp <- est.sc(sim.Yin, ~1+sim.fm.X[,1]+sim.fm.X[,2], sim.region, model="GP", sim.gmat, sim.nmat, totalit=10) acceptb/(i+1) 0.9166667 0.8333333 0.9166667 acceptga1/i acceptga2/(i+1) 0.75 0.9166667 acceptphi/(i+1) 0.9166667 acceptpsi/(i+1) 0.25 > > zip <- est.sc(sim.Yin, ~1+sim.fm.X[,1]+sim.fm.X[,2], sim.region, model="ZIP", sim.gmat, sim.nmat, totalit=10) acceptb/(i+1) 0.9166667 0.9166667 0.8333333 acceptga1/i acceptga2/(i+1) 0.25 0.9166667 acceptomega/(i+1) 0.8333333 acceptpsi/(i+1) 0.4166667 > > zigp <- est.sc(sim.Yin, ~1+sim.fm.X[,1]+sim.fm.X[,2], sim.region, model="ZIGP", sim.gmat, sim.nmat, totalit=10) acceptb/(i+1) 0.9166667 0.9166667 0.75 acceptga1/i acceptga2/(i+1) 0.3333333 0.9166667 acceptphi/(i+1) 0.9166667 acceptomega/(i+1) 0.8333333 acceptpsi/(i+1) 0.5 > > DIC.poi <- DIC(sim.Yin, ~1+sim.fm.X[,1]+sim.fm.X[,2], sim.region, poi) DIC 9007.787 mean deviance 8777.963 p.D 229.8245 > DIC.nb <- DIC(sim.Yin, ~1+sim.fm.X[,1]+sim.fm.X[,2], sim.region, nb) DIC 9048.08 mean deviance 8889.772 p.D 158.3073 > DIC.gp <- DIC(sim.Yin, ~1+sim.fm.X[,1]+sim.fm.X[,2], sim.region, gp) DIC 9121.895 mean deviance 8857.882 p.D 264.0127 > DIC.zip <- DIC(sim.Yin, ~1+sim.fm.X[,1]+sim.fm.X[,2], sim.region, zip) DIC 9010.388 mean deviance 8782.946 p.D 227.4419 > DIC.zigp <- DIC(sim.Yin, ~1+sim.fm.X[,1]+sim.fm.X[,2], sim.region, zigp) DIC 9025.942 mean deviance 8797.356 p.D 228.5857 > > ll.poi <- LogLike(sim.Yin, ~1+sim.fm.X[,1]+sim.fm.X[,2], sim.region, poi) > ll.nb <- LogLike(sim.Yin, ~1+sim.fm.X[,1]+sim.fm.X[,2], sim.region, nb) > ll.gp <- LogLike(sim.Yin, ~1+sim.fm.X[,1]+sim.fm.X[,2], sim.region, gp) > ll.zip <- LogLike(sim.Yin, ~1+sim.fm.X[,1]+sim.fm.X[,2], sim.region, zip) > ll.zigp <- LogLike(sim.Yin, ~1+sim.fm.X[,1]+sim.fm.X[,2], sim.region, zigp) > > Vuong.poi.nb <- Vuongtest(ll.poi, ll.nb, alpha = 0.05, p = DIC.poi$p.D, q = DIC.nb$p.D, correction = TRUE) Favour model 1 0 No decision 0 Favour model 2 1 > Vuong.poi.gp <- Vuongtest(ll.poi, ll.gp, alpha = 0.05, p = DIC.poi$p.D, q = DIC.gp$p.D, correction = TRUE) Favour model 1 1 No decision 0 Favour model 2 0 > Vuong.poi.zip <- Vuongtest(ll.poi, ll.zip, alpha = 0.05, p = DIC.poi$p.D, q = DIC.zip$p.D, correction = TRUE) Favour model 1 0 No decision 0.8333333 Favour model 2 0.1666667 > Vuong.poi.zigp <- Vuongtest(ll.poi, ll.zigp, alpha = 0.05, p = DIC.poi$p.D, q = DIC.zigp$p.D, correction = TRUE) Favour model 1 0 No decision 0.9166667 Favour model 2 0.08333333 > > Clarke.poi.nb <- Clarketest(ll.poi, ll.nb, alpha = 0.05, p = DIC.poi$p.D, q = DIC.nb$p.D, correction = TRUE) Favour model 1 0 No decision 0 Favour model 2 1 > Clarke.poi.gp <- Clarketest(ll.poi, ll.gp, alpha = 0.05, p = DIC.poi$p.D, q = DIC.gp$p.D, correction = TRUE) Favour model 1 1 No decision 0 Favour model 2 0 > Clarke.poi.zip <- Clarketest(ll.poi, ll.zip, alpha = 0.05, p = DIC.poi$p.D, q = DIC.zip$p.D, correction = TRUE) Favour model 1 0.1666667 No decision 0.5833333 Favour model 2 0.25 > Clarke.poi.zigp <- Clarketest(ll.poi, ll.zigp, alpha = 0.05, p = DIC.poi$p.D, q = DIC.zigp$p.D, correction = TRUE) Favour model 1 0.6666667 No decision 0.1666667 Favour model 2 0.1666667 > > > > cleanEx() > nameEx("sim.Yin") > ### * sim.Yin > > flush(stderr()); flush(stdout()) > > ### Name: sim.Yin > ### Title: Response vector > ### Aliases: sim.Yin > ### Keywords: datasets > > ### ** Examples > > data(sim.Yin) > ## maybe str(sim.Yin) ; plot(sim.Yin) ... > > > > cleanEx() > nameEx("sim.fm.X") > ### * sim.fm.X > > flush(stderr()); flush(stdout()) > > ### Name: sim.fm.X > ### Title: Design matrix > ### Aliases: sim.fm.X > ### Keywords: datasets > > ### ** Examples > > data(sim.fm.X) > ## maybe str(sim.fm.X) ; plot(sim.fm.X) ... > > > > cleanEx() > nameEx("sim.gmat") > ### * sim.gmat > > flush(stderr()); flush(stdout()) > > ### Name: sim.gmat > ### Title: Spatial adjacency matrix > ### Aliases: sim.gmat > ### Keywords: datasets > > ### ** Examples > > data(sim.gmat) > ## maybe str(sim.gmat) ; plot(sim.gmat) ... > > > > cleanEx() > nameEx("sim.nmat") > ### * sim.nmat > > flush(stderr()); flush(stdout()) > > ### Name: sim.nmat > ### Title: Matrix of neighbours > ### Aliases: sim.nmat > ### Keywords: datasets > > ### ** Examples > > data(sim.nmat) > ## maybe str(sim.nmat) ; plot(sim.nmat) ... > > > > cleanEx() > nameEx("sim.region") > ### * sim.region > > flush(stderr()); flush(stdout()) > > ### Name: sim.region > ### Title: Region vector > ### Aliases: sim.region > ### Keywords: datasets > > ### ** Examples > > data(sim.region) > ## maybe str(sim.region) ; plot(sim.region) ... > > > > ### *