tuneVars: Generate Variance parameters for proposal density

Description Usage Arguments Details Value See Also Examples

Description

tuneVars generates variance parameters dependent on the acceptance ratio of drawn parameters in the Metropolis algorithm used in indAggEi. The target acceptance rate will be given by parameter accRat

Usage

1
2
3
4
5
tuneVars(form, aggr, indi = NULL, IDCols = c("ID"), whichPriori = "gamma",
  prioriPars = list(shape = 4, rate = 2), accRat = c(0.4, 0.6),
  minProp = 0.7, maxiter = 20, sample = 10000, verbose = 10000,
  verboseTune = TRUE, improv = NULL, betaVars = NULL, alphaVars = NULL,
  startValsAlpha = NULL, startValsBeta = NULL, seed = NULL)

Arguments

form

formula in this format cbind(column_1,column_2, ...,column_c)~cbind(row_1,row_2,...,row_r))

aggr

data.frame with aggregate data. One district per line and one column giving one ID per district. (see Details)

indi

data.frame with individual data. One district per line and one column giving one ID per district. (see Details) If no individual data are present it defaults to NULL

IDCols

vector of length 2 (or 1) giving the columnnames or numbers of ID column

whichPriori

character string defining the hyperpriori. default="gamma"

prioriPars

vector giving the parameters of the hyperpriori

accRat

vector with two elements describing the wished range of the acceptance ratios

minProp

numeric between 0 and 1 describing the percentage of parameters to have the wished acceptance ratios (accRat). maxiter will be the maximum iteration

maxiter

numeric how many times the algorithm should run maximum. If NULL tuning will run until minProp is reached

sample

the sample size to be drawn each tuning run.

verbose

an integer specifying whether the progress of the sampler is printed to the screen (defaults to 0). If verbose is greater than 0, the iteration number is printed to the screen every verboseth iteration

verboseTune

logical if tuning iteration should be printed (default=TRUE)

improv

numeric vector with 2 elements c(a,b). standard deviation will be calculated with the last b percentages of parameters to have the wished acceptance ratio. If standard deviation is lower than a, than tuning is finished. Default is NULL

betaVars

array of dimensions (rows, columns, districts) giving variance of proposal density for betavalues

alphaVars

matrix of dimensions (rows, columns) giving variance of proposal density for alphavalues.

startValsAlpha

matrix with dimension=c(rows,columns) giving the starting values for alpha. If NULL random numbers of rdirichlet with prioriPars will be drawn

startValsBeta

array with dimension=c(rows,columns,districts) giving the starting values of beta If NULL random multinomial numbers with startValsAlpha or prioriPars will be draws

seed

Default is NULL. Can be given the "seed" attribute of an eiwild-object to reproduce an eiwild-object

Details

indi is a districts x [(r*c)+1] data.frame containing one district per line. One column gives the ID of the districts. This will we connected to the ID column in the aggr-data.frame. The rest of one line in indi is every row beside the nex row. For example a 2x3 ecological Inference problem with formula cbind(col1,col2,col3) ~ cbind(row1,row2) will have the row format : [ID, row1.col1, row1.col2, row1.col3, row2.col1, row2.col2, row2.col3]

It is important that the formula names correspond to the exact column number in the indi-data.frame.

The aggr data.frame can have more columns than the names given in formula as long as the colnames exist

Priorities for finishing of tuning are as follows: If improv isn't specified: minProp and maxiter are checked. If improv is specified: 1) improv is checked, 2) minProp and maxiter are checked.

Value

A list containing matrices of variance parameters for the proposal densities

See Also

convertEiData, runMBayes, mcmc tuneVars, indAggEi

Examples

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
## Not run: 
data(topleveldat)
out1 <- tuneVars(form=form, aggr=aggr, indi=indi, IDCols=c("ID","ID"),sample=10000, verbose=11000)
out2 <- tuneVars(form=form, aggr=aggr, indi=indi, IDCols=c("ID","ID"), sample=10000, verbose=11000,
                 maxiter=NULL, improv=c(0.01,5))
out3 <- tuneVars(form=form, aggr=aggr, indi=indi, IDCols=c("ID","ID"), sample=10000, verbose=11000,
                 maxiter=NULL, accRat=c(0.45,0.55), improv=c(0.01,5))
str(out3)
out4 <- indAggEi(form=form, aggr=aggr, indi=indi, IDCols=c("ID","ID"),
                 betaVars=out1$betaVars, alphaVars=out1$alphaVars,
                 sample=10000,thinning=1,burnin=100, verbose=1000)
out4

## End(Not run)

eiwild documentation built on May 2, 2019, 6:43 a.m.

Related to tuneVars in eiwild...