exportWeightsfile: A function to export a csv file containing the weights file...

Description Usage Arguments Value Examples

Description

This function exports a csv file containing the names of the weights, coefficients and country name in a standardized format supported by geoDMS.

Usage

1
2
exportWeightsfile(model, originaldata, modeldata, coefnamelist, outdir,
  modelname, filename)

Arguments

model

The model object from which the estimated coefficients should be extracted.

originaldata

The complete dataset from which the model data has been extracted. Used by the function to determine which variables have a zero weight.

modeldata

The dataset on which the model is estimated. Used by the function to determine which variables have a zero weight.

coefnamelist

A character vector containing the weight names that should be printed in the weights file.

outdir

The directory to which the weightsfile should be exported.

modelname

A string containing the name of the country that should be printed in the weightsfile.

filename

The name of the exported weightsfile.

Value

Any messages that may be printed by file(), writeLines() or close().

Examples

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
20
21
22
logitpars <- c(-0.5, 0.4, -0.3, 0.2, -0.1, 0, 0, 0, 0, 0, 0, 0)
someData <- simulateLogit(nobs=2500, pars=logitpars)
useData <- someData[,c(1:6)]
someModel <- logit(UseData)

exportWeightsfile(model = someModel, originaldata = someData, modeldata = useData,
				coefnamelist = colnames(someData[-1,]), outdir = "C:\\Users\\",
					modelname = "ImportantModel", filename = "important_result.csv")

data(ITdata)
data(corinetable)
ITsample <- getSamples(data = ITdata, share = 0.25, confidence.alternative=0.85, max.iter =100)
sampledIT = ITdata[ITsample,]
reclIT <- reclassify(sampledIT,  reclasstable=corinetable)
trainY <- MLtoBinomData(reclIT[,1], class=0)
trainX = reclIT[,-1]
bestX <- selectX(trainY, trainX, share = 0.25, returntype="colnames")
# total accessibility and domestic accessibility are multicollinear.
bestlogit <- logit(cbind(trainY,trainX[,bestX]))
exportWeightsfile(model = bestlogit, originaldata = ITdata, modeldata = cbind(trainY,trainX),
	coefnamelist = colnames(trainX), outdir = "C:\\Users\\",
					modelname = "IT", filename = "Urban_weights.csv")

BPJandree/AutoGLM documentation built on May 5, 2019, 10:25 a.m.