R : Copyright 2005, The R Foundation for Statistical Computing Version 2.1.1 (2005-06-20), ISBN 3-900051-07-0 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. 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 a HTML browser interface to help. Type 'q()' to quit R. > ### *
> ### > attach(NULL, name = "CheckExEnv") > assign(".CheckExEnv", as.environment(2), pos = length(search())) # base > ## add some hooks to label plot pages for base and grid graphics > setHook("plot.new", ".newplot.hook") > setHook("persp", ".newplot.hook") > setHook("grid.newpage", ".gridplot.hook") > > assign("cleanEx", + function(env = .GlobalEnv) { + rm(list = ls(envir = env, all.names = TRUE), envir = env) + RNGkind("default", "default") + set.seed(1) + options(warn = 1) + delayedAssign("T", stop("T used instead of TRUE"), + assign.env = .CheckExEnv) + delayedAssign("F", stop("F used instead of FALSE"), + assign.env = .CheckExEnv) + sch <- search() + newitems <- sch[! sch %in% .oldSearch] + for(item in rev(newitems)) + eval(substitute(detach(item), list(item=item))) + missitems <- .oldSearch[! .oldSearch %in% sch] + if(length(missitems)) + warning("items ", paste(missitems, collapse=", "), + " have been removed from the search path") + }, + env = .CheckExEnv) > assign("..nameEx", "__{must remake R-ex/*.R}__", env = .CheckExEnv) # for now > assign("ptime", proc.time(), env = .CheckExEnv) > grDevices::postscript("sampling-Examples.ps") > assign("par.postscript", graphics::par(no.readonly = TRUE), env = .CheckExEnv) > options(contrasts = c(unordered = "contr.treatment", ordered = "contr.poly")) > options(warn = 1) > library('sampling') Loading required package: MASS Loading required package: lpSolve > > assign(".oldSearch", search(), env = .CheckExEnv) > assign(".oldNS", loadedNamespaces(), env = .CheckExEnv) > cleanEx(); ..nameEx <- "MU284" > > ### * MU284 > > flush(stderr()); flush(stdout()) > > ### Encoding: latin1 > > ### Name: MU284 > ### Title: The MU284 population > ### Aliases: MU284 > ### Keywords: datasets > > ### ** Examples > > data(MU284) > hist(MU284$RMT85) > > > > cleanEx(); ..nameEx <- "UPbrewer" > > ### * UPbrewer > > flush(stderr()); flush(stdout()) > > ### Name: UPbrewer > ### Title: Brewer sampling > ### Aliases: UPbrewer > ### Keywords: survey > > ### ** Examples > > #define the prescribed inclusion probabilities > pik=c(0.2,0.7,0.8,0.5,0.4,0.4) > #select a sample > UPbrewer(pik) [1] 0 1 1 0 1 0 > > > > cleanEx(); ..nameEx <- "UPmaxentropy" > > ### * UPmaxentropy > > flush(stderr()); flush(stdout()) > > ### Encoding: latin1 > > ### Name: UPmaxentropy > ### Title: Maximum entropy sampling with fixed sample size and unequal > ### probabilities > ### Aliases: UPmaxentropy UPmaxentropypi2 UPMEqfromw UPMEpikfromq > ### UPMEpiktildefrompik UPMEsfromq UPMEpik2frompikw > ### Keywords: survey > > ### ** Examples > > ############ > ## Example 1 > ############ > # Simple example. Selection of a sample. > pik=c(0.07,0.17,0.41,0.61,0.83,0.91) > # First method > UPmaxentropy(pik) [1] 0 0 0 1 1 1 > # Second method by using the intermediate procedures. > n=sum(pik) > pikt=UPMEpiktildefrompik(pik) > w=pikt/(1-pikt) > q=UPMEqfromw(w,n) > UPMEsfromq(q) [1] 0 0 0 1 1 1 > # The matrix of inclusion probabilities > # First method: direct computation from pik > UPmaxentropypi2(pik) [,1] [,2] [,3] [,4] [,5] [,6] [1,] 0.070000000 0.004917094 0.01295391 0.02147743 0.0447256 0.05592596 [2,] 0.004917094 0.170000000 0.03238322 0.05365082 0.1113288 0.13772003 [3,] 0.012953914 0.032383224 0.41000000 0.14068550 0.2887534 0.34522394 [4,] 0.021477427 0.053650824 0.14068550 0.61000000 0.4691242 0.53506204 [5,] 0.044725602 0.111328826 0.28875338 0.46912417 0.8300000 0.74606802 [6,] 0.055925963 0.137720032 0.34522394 0.53506204 0.7460680 0.91000000 > # Second method: computation from pik and w > UPMEpik2frompikw(pik,w) [,1] [,2] [,3] [,4] [,5] [,6] [1,] 0.070000000 0.004917094 0.01295391 0.02147743 0.0447256 0.05592596 [2,] 0.004917094 0.170000000 0.03238322 0.05365082 0.1113288 0.13772003 [3,] 0.012953914 0.032383224 0.41000000 0.14068550 0.2887534 0.34522394 [4,] 0.021477427 0.053650824 0.14068550 0.61000000 0.4691242 0.53506204 [5,] 0.044725602 0.111328826 0.28875338 0.46912417 0.8300000 0.74606802 [6,] 0.055925963 0.137720032 0.34522394 0.53506204 0.7460680 0.91000000 > ############ > ## Example 2 > ############ > # Selection of a sample of Belgian municipalities. > data(belgianmunicipalities) > attach(belgianmunicipalities) > n=200 > pik=inclusionprobabilities(averageincome,n) > s=UPmaxentropy(pik) > as.character(Commune[s==1]) [1] "Hemiksem" "Kalmthout" "Kapellen" [4] "Kontich" "Lint" "Ranst" [7] "Schoten" "Wuustwezel" "Zoersel" [10] "Heist-op-den-Berg" "Sint-Katelijne-Waver" "Willebroek" [13] "Arendonk" "Baerle-Duc" "Grobbendonk" [16] "Herenthout" "Hoogstraten" "Lille" [19] "Merksplas" "Olen" "Oud-Turnhout" [22] "Auderghem" "Bruxelles" "Evere" [25] "Forest" "Ganshoren" "Ixelles" [28] "Jette" "Asse" "Beersel" [31] "Gammerages" "Gooik" "Kapelle-op-den-Bos" [34] "Londerzeel" "Machelen" "Merchtem" [37] "Ternat" "Roosdaal" "Drogenbos" [40] "Rhode-Saint-Gen\350se" "Wemmel" "Boutersem" [43] "Diest" "Herent" "Holsbeek" [46] "Kortenberg" "Lubbeek" "Rotselaar" [49] "Tervuren" "Tirlemont" "Tremelo" [52] "Beauvechain" "Braine-lAlleud" "Chaumont-Gistoux" [55] "Ittre" "Rixensart" "Tubize" [58] "Chastre" "Walhain" "Blankenberge" [61] "Damme" "Oostkamp" "Zedelgem" [64] "Zuienkerke" "Dixmude" "Houthulst" [67] "Lo-Reninge" "Ypres" "Wervik" [70] "Vleteren" "Courtrai" "Kuurne" [73] "Lendelede" "Zwevegem" "Espierres-Helchin" [76] "Middelkerke" "Moorslede" "Dentergem" [79] "Oostrozebeke" "Ruiselede" "Nieuport" [82] "Furnes" "Herzele" "Lede" [85] "Zottegem" "Erpe-Mere" "Termonde" [88] "Hamme" "Laarne" "Waasmunster" [91] "Wetteren" "Wichelen" "Zele" [94] "Assenede" "Maldegem" "Aalter" [97] "Deinze" "De Pinte" "Destelbergen" [100] "Evergem" "Gavere" "Gand" [103] "Knesselare" "Lochristi" "Melle" [106] "Nazareth" "Nevele" "Oosterzele" [109] "Wachtebeke" "Renaix" "Brakel" [112] "Wortegem-Petegem" "Horebeke" "Zwalm" [115] "Kruibeke" "Tamise" "Flobecq" [118] "Farciennes" "Gerpinnes" "Seneffe" [121] "Hensies" "Quaregnon" "Honnelles" [124] "Mouscron" "Enghien" "Le Roeulx" [127] "Ecaussinnes" "Lobbes" "Merbes-le-Ch\342teau" [130] "Ham-sur-Heure-Nalinnes" "Pecq" "P\351ruwelz" [133] "Brunehaut" "Mont-de-lEnclus" "Amay" [136] "Ferri\350res" "Modave" "Ouffet" [139] "Ans" "Fl\351ron" "Seraing" [142] "Soumagne" "Vis\351" "Trooz" [145] "Baelen" "Dison" "Jalhay" [148] "La Calamine" "Lontzen" "Olne" [151] "Raeren" "Saint-Vith" "Theux" [154] "Verviers" "Plombi\350res" "Thimister-Clermont" [157] "Braives" "Donceel" "Hannut" [160] "Faimes" "As" "Hasselt" [163] "Opglabbeek" "Saint-Trond" "Zonhoven" [166] "Zutendaal" "Heusden-Zolder" "Bocholt" [169] "Overpelt" "Kortessem" "Tongres" [172] "Fourons" "Messancy" "Sainte-Ode" [175] "Erez\351e" "Hotton" "La Roche-en-Ardenne" [178] "Nassogne" "Rendeux" "Herbeumont" [181] "L\351glise" "Libramont-Chevigny" "Meix-devant-Virton" [184] "Musson" "Habay" "Rouvroy" [187] "Ciney" "Gedinne" "Havelange" [190] "Onhaye" "Rochefort" "Eghez\351e" [193] "Gesves" "Namur" "Ohey" [196] "Jemeppe-sur-Sambre" "Couvin" "Doische" [199] "Florennes" "Walcourt" > pi2=UPmaxentropypi2(pik) > rowSums(pi2)/pik/n [1] 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 [38] 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 [75] 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 [112] 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 [149] 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 [186] 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 [223] 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 [260] 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 [297] 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 [334] 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 [371] 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 [408] 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 [445] 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 [482] 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 [519] 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 [556] 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 > ############ > ## Example 3 > ############ > # Selection of 200 samples of Belgian municipalities. > # Once matrix q is computed, the selection of a sample is very quick. > # Simulations are thus possible. > data(belgianmunicipalities) > attach(belgianmunicipalities) > pik=inclusionprobabilities(averageincome,200) > pik=pik[pik!=1] > n=sum(pik) > pikt=UPMEpiktildefrompik(pik) > w=pikt/(1-pikt) > q=UPMEqfromw(w,n) > N=length(pik) > tt=rep(0,times=N) > sim=200 > for(i in 1:sim) tt = tt+UPMEsfromq(q) > tt=tt/sim > sum(abs(tt-pik)) [1] 15.72224 > > > > cleanEx(); ..nameEx <- "UPmidzuno" > > ### * UPmidzuno > > flush(stderr()); flush(stdout()) > > ### Encoding: latin1 > > ### Name: UPmidzuno > ### Title: Midzuno sampling > ### Aliases: UPmidzuno > ### Keywords: survey > > ### ** Examples > > #define the prescribed inclusion probabilities > pik=c(0.2,0.7,0.8,0.5,0.4,0.4) > #select a sample > UPmidzuno(pik) [1] 0 1 0 1 1 0 > > > > cleanEx(); ..nameEx <- "UPmidzunopi2" > > ### * UPmidzunopi2 > > flush(stderr()); flush(stdout()) > > ### Name: UPmidzunopi2 > ### Title: Joint inclusion probabilities for Midzuno sampling > ### Aliases: UPmidzunopi2 > ### Keywords: survey > > ### ** Examples > > #define the prescribed inclusion probabilities > pik=c(0.2,0.7,0.8,0.5,0.4,0.4) > #select a sample > UPmidzunopi2(pik) [,1] [,2] [,3] [,4] [,5] [,6] [1,] 0.20000000 0.1181818 0.1454545 0.06363636 0.03636364 0.03636364 [2,] 0.11818182 0.7000000 0.5000000 0.30181818 0.24000000 0.24000000 [3,] 0.14545455 0.5000000 0.8000000 0.36787879 0.29333333 0.29333333 [4,] 0.06363636 0.3018182 0.3678788 0.50000000 0.13333333 0.13333333 [5,] 0.03636364 0.2400000 0.2933333 0.13333333 0.40000000 0.09696970 [6,] 0.03636364 0.2400000 0.2933333 0.13333333 0.09696970 0.40000000 > > > > cleanEx(); ..nameEx <- "UPmultinomial" > > ### * UPmultinomial > > flush(stderr()); flush(stdout()) > > ### Name: UPmultinomial > ### Title: Multinomial sampling > ### Aliases: UPmultinomial > ### Keywords: survey > > ### ** Examples > > #define the prescribed inclusion probabilities > pik=c(0.2,0.7,0.8,0.5,0.4,0.4) > #select a sample > UPmultinomial(pik) [1] 0 0 1 2 0 0 > > > > cleanEx(); ..nameEx <- "UPpivotal" > > ### * UPpivotal > > flush(stderr()); flush(stdout()) > > ### Encoding: latin1 > > ### Name: UPpivotal > ### Title: Pivotal sampling > ### Aliases: UPpivotal > ### Keywords: survey > > ### ** Examples > > #define the prescribed inclusion probabilities > pik=c(0.2,0.7,0.8,0.5,0.4,0.4) > #select a sample > UPpivotal(pik) [1] 0 1 1 0 0 1 > > > > cleanEx(); ..nameEx <- "UPpoisson" > > ### * UPpoisson > > flush(stderr()); flush(stdout()) > > ### Name: UPpoisson > ### Title: Poisson sampling > ### Aliases: UPpoisson > ### Keywords: survey > > ### ** Examples > > ############ > ## Example 1 > ############ > # definition of pik > pik=c(1/3,1/3,1/3) > # select a sample > UPpoisson(pik) [1] 1 0 0 > ############ > ## Example 2 > ############ > data(belgianmunicipalities) > Tot=belgianmunicipalities$Tot04 > name=belgianmunicipalities$Commune > n=200 > pik=inclusionprobabilities(Tot,n) > # select a sample > s=UPpoisson(pik) > as.vector(name[s==1]) [1] "Anvers" "Brasschaat" [3] "Brecht" "Edegem" [5] "Essen" "Kapellen" [7] "Mortsel" "Rumst" [9] "Schilde" "Schoten" [11] "Stabroek" "Wijnegem" [13] "Berlaar" "Heist-op-den-Berg" [15] "Lierre" "Malines" [17] "Arendonk" "Herentals" [19] "Herenthout" "Herselt" [21] "Hoogstraten" "Mol" [23] "Ravels" "Turnhout" [25] "Anderlecht" "Auderghem" [27] "Bruxelles" "Etterbeek" [29] "Forest" "Ganshoren" [31] "Ixelles" "Jette" [33] "Koekelberg" "Molenbeek-Saint-Jean" [35] "Saint-Gilles" "Schaerbeek" [37] "Uccle" "Watermael-Boitsfort" [39] "Woluwe-Saint-Lambert" "Woluwe-Saint-Pierre" [41] "Asse" "Dilbeek" [43] "Hal" "Londerzeel" [45] "Machelen" "Sint-Pieters-Leeuw" [47] "Ternat" "Vilvorde" [49] "Zemst" "Wemmel" [51] "Aarschot" "Bierbeek" [53] "Boortmeerbeek" "Kortenberg" [55] "Louvain" "Lubbeek" [57] "Rotselaar" "Tirlemont" [59] "Montaigu-Zichem" "Tielt-Winge" [61] "Beauvechain" "Braine-lAlleud" [63] "Braine-le-Ch\342teau" "Jodoigne" [65] "Nivelles" "Waterloo" [67] "Ottignies-Louvain-la-Neuve" "Blankenberge" [69] "Bruges" "Zedelgem" [71] "Dixmude" "Koekelare" [73] "Ypres" "Poperinge" [75] "Heuvelland" "Anzegem" [77] "Courtrai" "Waregem" [79] "Wevelgem" "Bredene" [81] "Ichtegem" "Middelkerke" [83] "Ostende" "Ingelmunster" [85] "Izegem" "Moorslede" [87] "Roulers" "Koksijde" [89] "Furnes" "Alost" [91] "Ninove" "Sint-Lievens-Houtem" [93] "Zottegem" "Termonde" [95] "Hamme" "Wetteren" [97] "Wichelen" "Eeklo" [99] "Kaprijke" "Maldegem" [101] "Zelzate" "Aalter" [103] "Deinze" "Destelbergen" [105] "Evergem" "Gand" [107] "Melle" "Merelbeke" [109] "Nazareth" "Nevele" [111] "Oosterzele" "Waarschoot" [113] "Audenarde" "Renaix" [115] "Zingem" "Wortegem-Petegem" [117] "Beveren" "Lokeren" [119] "Sint-Gillis-Waas" "Saint-Nicolas" [121] "Stekene" "Beloeil" [123] "Chapelle-lez-Herlaimont" "Charleroi" [125] "Gerpinnes" "Pont-\340-Celles" [127] "Les Bons Villers" "Boussu" [129] "Frameries" "Mons" [131] "Colfontaine" "Qu\351vy" [133] "Mouscron" "Enghien" [135] "La Louvi\350re" "Ecaussinnes" [137] "Binche" "Momignies" [139] "P\351ruwelz" "Tournai" [141] "Huy" "Ans" [143] "Aywaille" "Fl\351ron" [145] "Li\350ge" "Seraing" [147] "Vis\351" "Fl\351malle" [149] "Bullange" "Jalhay" [151] "Limbourg" "Olne" [153] "Saint-Vith" "Theux" [155] "Verviers" "Burg-Reuland" [157] "Crisn\351e" "Lincent" [159] "Saint-Georges-sur-Meuse" "Beringen" [161] "Genk" "Hasselt" [163] "Bourg-L\351opold" "Lummen" [165] "Saint-Trond" "Zutendaal" [167] "Kinrooi" "Lommel" [169] "Neerpelt" "Overpelt" [171] "Hamont-Achel" "Hechtel-Eksel" [173] "Houthalen-Helchteren" "Dilsen-Stokkem" [175] "Looz" "Lanaken" [177] "Tongres" "Maasmechelen" [179] "Aubange" "Bastogne" [181] "Durbuy" "Manhay" [183] "Etalle" "Habay" [185] "Ciney" "Fosses-la-Ville" [187] "Namur" "Sambreville" [189] "La Bruy\350re" "Couvin" > > > > cleanEx(); ..nameEx <- "UPrandompivotal" > > ### * UPrandompivotal > > flush(stderr()); flush(stdout()) > > ### Encoding: latin1 > > ### Name: UPrandompivotal > ### Title: Random pivotal sampling > ### Aliases: UPrandompivotal > ### Keywords: survey > > ### ** Examples > > #define the prescribed inclusion probabilities > pik=c(0.2,0.7,0.8,0.5,0.4,0.4) > #select a sample > UPrandompivotal(pik) [1] 1 0 1 0 0 1 > > > > cleanEx(); ..nameEx <- "UPrandomsystematic" > > ### * UPrandomsystematic > > flush(stderr()); flush(stdout()) > > ### Name: UPrandomsystematic > ### Title: Random systematic sampling > ### Aliases: UPrandomsystematic > ### Keywords: survey > > ### ** Examples > > #define the prescribed inclusion probabilities > pik=c(0.2,0.7,0.8,0.5,0.4,0.4) > #select a sample > UPrandomsystematic(pik) [1] 0 0 0 1 1 1 > > > > cleanEx(); ..nameEx <- "UPsampford" > > ### * UPsampford > > flush(stderr()); flush(stdout()) > > ### Name: UPsampford > ### Title: Sampford sampling > ### Aliases: UPsampford > ### Keywords: survey > > ### ** Examples > > #define the prescribed inclusion probabilities > pik=c(0.2,0.7,0.8,0.5,0.4,0.4) > UPsampford(pik) [1] 0 1 1 0 0 1 > > > > cleanEx(); ..nameEx <- "UPsystematic" > > ### * UPsystematic > > flush(stderr()); flush(stdout()) > > ### Name: UPsystematic > ### Title: Systematic sampling > ### Aliases: UPsystematic > ### Keywords: survey > > ### ** Examples > > ############ > ## Example 1 > ############ > #define the prescribed inclusion probabilities > pik=c(0.2,0.7,0.8,0.5,0.4,0.4) > #select a sample > UPsystematic(pik) [1] 0 1 1 0 1 0 > ############ > ## Example 2 > ############ > data(belgianmunicipalities) > Tot=belgianmunicipalities$Tot04 > name=belgianmunicipalities$Commune > pik=inclusionprobabilities(Tot,200) > #select a sample > s=UPsystematic(pik) > as.vector(name[s==1]) [1] "Anvers" "Boechout" [3] "Brasschaat" "Brecht" [5] "Essen" "Kapellen" [7] "Kontich" "Niel" [9] "Schilde" "Schoten" [11] "Wommelgem" "Zoersel" [13] "Berlaar" "Duffel" [15] "Heist-op-den-Berg" "Malines" [17] "Nijlen" "Puurs" [19] "Willebroek" "Balen" [21] "Geel" "Herentals" [23] "Hoogstraten" "Lille" [25] "Mol" "Ravels" [27] "Turnhout" "Vosselaar" [29] "Anderlecht" "Auderghem" [31] "Berchem-Sainte-Agathe" "Bruxelles" [33] "Etterbeek" "Forest" [35] "Ganshoren" "Ixelles" [37] "Jette" "Molenbeek-Saint-Jean" [39] "Saint-Gilles" "Saint-Josse-ten-Noode" [41] "Schaerbeek" "Uccle" [43] "Woluwe-Saint-Lambert" "Woluwe-Saint-Pierre" [45] "Asse" "Dilbeek" [47] "Gooik" "Hal" [49] "Hoeilaart" "Londerzeel" [51] "Merchtem" "Overijse" [53] "Steenokkerzeel" "Vilvorde" [55] "Zemst" "Kraainem" [57] "Wezembeek-Oppem" "Aarschot" [59] "Bierbeek" "Diest" [61] "Herent" "Kortenaken" [63] "Louvain" "Lubbeek" [65] "Tervuren" "Tremelo" [67] "Montaigu-Zichem" "Braine-lAlleud" [69] "Court-Saint-Etienne" "Jodoigne" [71] "Nivelles" "Tubize" [73] "Waterloo" "Chastre" [75] "Ottignies-Louvain-la-Neuve" "Beernem" [77] "Bruges" "Jabbeke" [79] "Torhout" "Knokke-Heist" [81] "Koekelare" "Ypres" [83] "Wervik" "Anzegem" [85] "Harelbeke" "Courtrai" [87] "Menin" "Waregem" [89] "Wevelgem" "Gistel" [91] "Ostende" "Oudenburg" [93] "Izegem" "Moorslede" [95] "Roulers" "Pittem" [97] "Wingene" "Koksijde" [99] "Alost" "Denderleeuw" [101] "Haaltert" "Lede" [103] "Sint-Lievens-Houtem" "Erpe-Mere" [105] "Termonde" "Hamme" [107] "Waasmunster" "Zele" [109] "Eeklo" "Zelzate" [111] "Deinze" "Evergem" [113] "Gand" "Knesselare" [115] "Melle" "Nevele" [117] "Wachtebeke" "Audenarde" [119] "Zingem" "Maarkedal" [121] "Beveren" "Lokeren" [123] "Saint-Nicolas" "Stekene" [125] "Ath" "Bernissart" [127] "Chapelle-lez-Herlaimont" "Charleroi" [129] "Courcelles" "Fleurus" [131] "Manage" "Pont-\340-Celles" [133] "Boussu" "Frameries" [135] "Mons" "Qui\351vrain" [137] "Colfontaine" "Mouscron" [139] "Braine-le-Comte" "La Louvi\350re" [141] "Le Roeulx" "Ecaussinnes" [143] "Binche" "Merbes-le-Ch\342teau" [145] "Morlanwelz" "Estaimpuis" [147] "Tournai" "Leuze-en-Hainaut" [149] "Huy" "Villers-Le-Bouillet" [151] "Ans" "Beyne-Heusay" [153] "Esneux" "Herstal" [155] "Li\350ge" "Oupeye" [157] "Seraing" "Soumagne" [159] "Gr\342ce-Hollogne" "Fl\351malle" [161] "Butgenbach" "Herve" [163] "Malmedy" "Spa" [165] "Verviers" "Trois-Ponts" [167] "Hannut" "Wasseiges" [169] "Beringen" "Genk" [171] "Halen" "Hasselt" [173] "Nieuwerkerken" "Saint-Trond" [175] "Zonhoven" "Heusden-Zolder" [177] "Lommel" "Maaseik" [179] "Peer" "Houthalen-Helchteren" [181] "Dilsen-Stokkem" "Bilzen" [183] "Kortessem" "Tongres" [185] "Maasmechelen" "Arlon" [187] "Bastogne" "Durbuy" [189] "Rendeux" "Saint-Hubert" [191] "Saint-L\351ger" "Bi\350vre" [193] "Havelange" "Andenne" [195] "Floreffe" "Namur" [197] "Profondeville" "Fernelmont" [199] "Gembloux" "Philippeville" > > > > cleanEx(); ..nameEx <- "UPsystematicpi2" > > ### * UPsystematicpi2 > > flush(stderr()); flush(stdout()) > > ### Name: UPsystematicpi2 > ### Title: Joint inclusion probabilities for systematic sampling > ### Aliases: UPsystematicpi2 > ### Keywords: survey > > ### ** Examples > > #define the prescribed inclusion probabilities > pik=c(0.2,0.7,0.8,0.5,0.4,0.4) > UPsystematicpi2(pik) [,1] [,2] [,3] [,4] [,5] [,6] [1,] 0.2 0.0 0.2 0.2 0.0 0.0 [2,] 0.0 0.7 0.5 0.2 0.4 0.3 [3,] 0.2 0.5 0.8 0.3 0.4 0.2 [4,] 0.2 0.2 0.3 0.5 0.0 0.3 [5,] 0.0 0.4 0.4 0.0 0.4 0.0 [6,] 0.0 0.3 0.2 0.3 0.0 0.4 > > > > cleanEx(); ..nameEx <- "UPtille" > > ### * UPtille > > flush(stderr()); flush(stdout()) > > ### Encoding: latin1 > > ### Name: UPtille > ### Title: Tillé sampling > ### Aliases: UPtille > ### Keywords: survey > > ### ** Examples > > ############ > ## Example 1 > ############ > #define the prescribed inclusion probabilities > pik=c(0.2,0.7,0.8,0.5,0.4,0.4) > #select a sample > UPtille(pik) [1] 0 1 1 0 0 1 > ############ > ## Example 2 > ############ > # Selection of samples of municipalities > # with equal or unequal probabilities. > # Comparison of the accuracy by a boxplot. > b=data(belgianmunicipalities) > pik=inclusionprobabilities(belgianmunicipalities$Tot04,200) > N=length(pik) > n=sum(pik) > sim=10 > ss=array(0,c(sim,9)) > # the interest variable > y=belgianmunicipalities$TaxableIncome > # simulation and computation of the Horvitz-Thompson estimator > for(i in 1:sim) + { + cat("Step ",i,"\n") + ss[i,]=ss[i,]+c( + c(crossprod(y,UPpoisson(pik)/pik)), + c(crossprod(y,UPrandomsystematic(pik)/pik)), + c(crossprod(y,UPrandompivotal(pik)/pik)), + c(crossprod(y,UPtille(pik)/pik)), + c(crossprod(y,UPmidzuno(pik)/pik)), + c(crossprod(y,UPsystematic(pik)/pik)), + c(crossprod(y,UPpivotal(pik)/pik)), + c(crossprod(y,UPmultinomial(pik)/pik)) , + c(crossprod(y,srswor(n,N)*N/n))) + } Step 1 Step 2 Step 3 Step 4 Step 5 Step 6 Step 7 Step 8 Step 9 Step 10 > # boxplot of the estimators > colnames(ss) <- + c("poisson","rsyst","rpivotal","tille","midzuno","syst","pivotal","multinom","srswor") > boxplot(data.frame(ss), las=3) > # The results of the simulations can be interpreted. > # Simple random sampling, multinomial sampling, > # and Poisson sampling are not accurate. > # All the methods of unequal probability sampling seem > # to have the same accuracy, except systematic sampling and pivotal sampling > # that have variances which depend on the order of the file. > > > > cleanEx(); ..nameEx <- "UPtillepi2" > > ### * UPtillepi2 > > flush(stderr()); flush(stdout()) > > ### Encoding: latin1 > > ### Name: UPtillepi2 > ### Title: Joint inclusion probabilties for Tillé sampling > ### Aliases: UPtillepi2 > ### Keywords: survey > > ### ** Examples > > #define the prescribed inclusion probabilities > pik=c(0.2,0.7,0.8,0.5,0.4,0.4) > UPtillepi2(pik) [,1] [,2] [,3] [,4] [,5] [,6] [1,] 0.20000000 0.1187879 0.1454545 0.06787879 0.03393939 0.03393939 [2,] 0.11878788 0.7000000 0.5090909 0.29696970 0.23757576 0.23757576 [3,] 0.14545455 0.5090909 0.8000000 0.36363636 0.29090909 0.29090909 [4,] 0.06787879 0.2969697 0.3636364 0.50000000 0.13575758 0.13575758 [5,] 0.03393939 0.2375758 0.2909091 0.13575758 0.40000000 0.10181818 [6,] 0.03393939 0.2375758 0.2909091 0.13575758 0.10181818 0.40000000 > > > > cleanEx(); ..nameEx <- "balancedcluster" > > ### * balancedcluster > > flush(stderr()); flush(stdout()) > > ### Name: balancedcluster > ### Title: Balanced cluster > ### Aliases: balancedcluster > ### Keywords: survey > > ### ** Examples > > ############ > ## Example 1 > ############ > # definition of the clusters (3 clusters) > cluster=c(1,1,1,1,1,2,2,2,2,2,3,3,3,3,3) > # Matrix of balancing variables > X=cbind(c(1,2,3,4,5,6,7,8,9,10,11,12,13,14,15)) > # Selection of 2 clusters > s=balancedcluster(X,2,cluster,2,TRUE) SELECTION OF A SAMPLE OF CLUSTERS BEGINNING OF THE FLIGHT PHASE The matrix of balanced variable has 2 variables and 3 units The size of the inclusion probability vector is 3 The sum of the inclusion probability vector is 2 The inclusion probability vector has 3 non-integer elements Step 1 NO LANDING PHASE QUALITY OF BALANCING TOTALS HorvitzThompson_estimators Relative_deviation pik 2 2 0 2 120 120 0 > # The sample of clusters with the inclusion probabilities of the clusters > s [,1] [,2] [1,] 1 0.6666667 [2,] 1 0.6666667 [3,] 1 0.6666667 [4,] 1 0.6666667 [5,] 1 0.6666667 [6,] 0 0.6666667 [7,] 0 0.6666667 [8,] 0 0.6666667 [9,] 0 0.6666667 [10,] 0 0.6666667 [11,] 1 0.6666667 [12,] 1 0.6666667 [13,] 1 0.6666667 [14,] 1 0.6666667 [15,] 1 0.6666667 > ############ > ## Example 2 > ############ > data(MU284) > X=cbind(MU284$P75,MU284$CS82,MU284$SS82,MU284$S82,MU284$ME84) > b=balancedcluster(X,10,MU284$CL,1,TRUE) SELECTION OF A SAMPLE OF CLUSTERS BEGINNING OF THE FLIGHT PHASE The matrix of balanced variable has 6 variables and 50 units The size of the inclusion probability vector is 50 The sum of the inclusion probability vector is 10 The inclusion probability vector has 50 non-integer elements Step 1 BEGINNING OF THE LANDING PHASE At the end of the flight phase, there remain 6 non integer probabilities The sum of these probabilities is 3 This sum is integer The linear program will consider 20 possible samples Error in landingcube(X, pikstar, pik, comment) : couldn't find function "lp" Execution halted