pim: Fit a PIM

Description Usage Arguments Details Value See Also Examples

Description

Fit a PIM

Usage

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
pim(formula, data, link = c("logit", "identity", "probit", "inverse",
  "1/mu^2", "log"), blocking.variables = character(), poset = noselfposet,
  leftsuffix = "_L", rightsuffix = "_R", interpretation = c("difference",
  "regular", "marginal", "symmetric"), na.action = na.fail,
  estimator = estimator.nleqslv(),
  varianceestimator = varianceestimator.sandwich(), lhs = c("PO", "<",
  "<="), keep.data = FALSE, verbosity = 0, nicenames = TRUE,
  interactions.difference = (interpretation != "marginal"),
  extra.nicenames = data.frame(org = character(), nice = character(),
  stringsAsFactors = FALSE), check.symmetric = (interpretation == "regular"),
  threshold = 1e-06, weights = NULL,
  pseudoweights = pseudoweights.default)

Arguments

formula

Original formula

data

Context where the formula formula is to be interpreted

link

Name of the link function (defaults to "logit")

blocking.variables

Character vector holding column names that hold blocking variables.

poset

Matrix of two columns indicating what the original observation number is for the left and right real observation in the pseudo-observation. Alternatively, can be a function like fullposet and similar.

leftsuffix, rightsuffix

Suffixes that will be added to the 'left' and 'right' observation's column name in the pseudo-observation. Note: no checking is done that these suffixes are safe, so the wrong suffixes may lead to unexpected behaviour.

interpretation

If "marginal" parts of the formula are converted to imply marginal pim modeling (see e.g. Mainreplacetext). If it is "difference" (the default), then the design matrix of the PIM is the difference of the design matrices of each part of the pseudo-observations. A popular option is "regular", which will interpret unaltered columns as differences. A new option is "symmetric", which works the same as "regular", but will enforce the symmetry condition by making the sign switch when changing the order (typically, this is achieved by subtracting the inverse for each dummy).

na.action

Defaults to na.fail: handles missing data in data.

estimator

Function like the result of estimator.nleqslv() (the default). See there to find the required form of this function or some provided alternatives.

varianceestimator

Function like the result of varianceestimator.sandwich() (the default). See there to find the required form of this function or some provided alternatives.

lhs

"PO", "<" or "<=": Unequality used for the lefthandside of the formula. The default ("PO") is the normal probabilistic index.

keep.data

If TRUE (not the default), the data and design matrices are maintained in the return value

verbosity

The higher this value, the more levels of progress and debug information is displayed (note: in R for Windows, turn off buffered output)

nicenames

Defaults to TRUE: try to make the column names more readable.

interactions.difference

If TRUE (note that the default is interpretation!="marginal") interaction terms will be interpreted as the differences of the onesided interaction terms (if this is possible at all). This is unsupported if unsupported if is "marginal". Some special interaction terms with calculated columns may lead to unexpected behaviour.

extra.nicenames

Should be a data.frame containing two character columns: org and nice. For each "constructed" column name, provide a nicer one, that will make the results more readable. You may also use parts of constructed column names. Note: make sure to use stringsAsFactor=FALSE when creating the data.frame.

check.symmetric

Defaults to TRUE for interpretation=="regular", FALSE otherwise: if the model does not support the symmetry condition, a warning is displayed. Note: this option is on by default for novice users, but it may be time- and resourceconsuming, so turn it off if you know what you are doing!

threshold

When checking the symmetry condition, how much digression is allowed.

weights

Defaults to NULL: vector of weights for every row of data, or NULL if no weighting is required.

pseudoweights

Defaults to pseudoweights.default: function that can convert weights by observation to weights per pseudo-observation. Should have the same signature and outcome as pseudoweights.default.

Details

Some of the items in the return value may be missing if parts of the estimation fail. See pim.fit for this.

If estimator was estimator.glmnet, The return value gets as an additional class "glmnetpim".

For more details on how to use this function and its parameters, we refer the reader to vignette("pim").

Value

An object of class pim,which is a list with items:

coefficients

Parameter estimates. See estimator.nleqslv

morefitinfo

Parameter estimation info. See estimator.nleqslv

vcov

Covariance estimates. See varianceestimator.sandwich

morevarfitinfo

Covariance estimation info. See varianceestimator.sandwich

varestimationerror

Only present if covariance estimation failed. See pim.fit

call

Call used when running this function.

formula

Passed in formula.

link

Name of the link function (defaults to "identity")

fitted.values

Predicted pseudo-observation values.

pfd

Object of class pimfitdata. If keep.data was TRUE, the X and Y items are set to NULL.

data

Passed in data (may be altered by poset). Only present if keep.data was TRUE

See Also

estimator.nleqslv varianceestimator.sandwich

Examples

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
set.seed(1)
iris$out<-factor(sample(2, nrow(iris), replace=TRUE))
iris$xord<-as.ordered(iris$Species)
pima<-pim(out~Sepal.Length, data=iris, link="logit", interpretation="regular")
pimb<-pim(out~I((R(Sepal.Length) - L(Sepal.Length))/sqrt(R(Sepal.Length) * L(Sepal.Length)) ), data=iris, 
	link="logit", interpretation="regular", extra.nicenames=data.frame(
		org="I((R(Sepal.Length) - L(Sepal.Length))/sqrt(R(Sepal.Length) * L(Sepal.Length)) )", 
		nice="Sepal.Length.WDiff", stringsAsFactors=FALSE))
pimc<-pim(out~O(xord), data=iris, link="logit", interpretation="regular")
##And an example with weighted fitting
iris50<-iris[sample.int(nrow(iris), 50),]
rwt50<-runif(50) #50 random weights
pimd<-pim(out~O(xord), data=iris50, link="logit", interpretation="regular",
		weights = rwt50)

pimold documentation built on May 2, 2019, 5:50 p.m.