Learn R Programming

pim (version 2.0.2)

estimators: Estimator functions for probabilistic index models

Description

This page documents different possibilities for solving the score function of a probabilistic index model or pim. All functions mentioned on this page, are essentially wrappers around different solver functions.

Usage

estimator.nleqslv(
  x,
  y,
  start = rep(0, ncol(x)),
  link = "logit",
  construct = NULL,
  ...
)

estimator.glm(x, y, start = rep(0, ncol(x)), link = "logit", ...)

estimator.BB( x, y, start = rep(0, ncol(x)), link = "logit", construct = NULL, method = c(1, 2, 3), control = list(NM = c(FALSE, TRUE)), ... )

Arguments

x

a model matrix for the respective pim model. See also model.matrix.

y

a vector with the response for the respective pim model.

start

a vector as long as there are columns in x, containing the starting values for the algorithm

link

a character vector describing the link function. This link function is used to adapt the calculation depending on the link used in the fitting process.

construct

a function that creates the score function used by either nleqslv or BBsolve for numerical optimization. See Details. The estimator estimator.glm doesn't allow for specification of your own score function.

...

extra arguments passed down to the actual solver function. See details.

method

A vector of integers specifying which Barzilai-Borwein steplengths should be used in a consecutive manner. The methods will be used in the order specified. More information on the help page of BBsolve.

control

a list with extra controlling parameters for BBsolve. See the help page of BBsolve for more information.

Value

a list with following elements:

coef

the estimated coefficients

WARNING

If you specify your own score function without changing the estimators for the variance-covariance matrix, this vcov matrix will be blatantly wrong!!!!!

Details

All functions share the same three arguments, being the design matrix x, the response vector y and the start values for the estimating function. If you follow the same principles, you can write your own wrapper function for any solver function of your choice.

The solvers estimator.nleqslv and estimator.BBsolve allow for specification of your own score function as well. For this, you have the possibility to provide a constructor function that takes three arguments

x

The model matrix

y

the vector with pseudo-observations

link

a character vector specifying the link

The function should return a function that can be used in either nleqslv or BBsolve. If you don't specify this constructor function, the package will use the constructor function CreateScoreFun to provide the score function.

See Also

nleqslv, glm.fit, BBsolve for more information on the fitting algorithms.

vcov.estimators, pim.fit and pim for more information on the fitting process

Examples

Run this code
# NOT RUN {
# This is a reimplementation of the identity link
myconstruct <- function(x,y,link){
  # this function is returned
 function(beta){
   xb <- as.vector(x %*% beta)
   colSums(x * (y - xb))
  }
}

data(ChickWeight)
themodel <- pim(weight ~ Diet, data = ChickWeight,
construct = myconstruct)

# compare coefficients to
themodel2 <- pim(weight ~ Diet, data = ChickWeight,
                link = "identity")
coef(themodel)
coef(themodel2)

# Note that this example uses a wrong estimate for the variance-covariance matrix
# You have to specify the correct vcov estimator as well
# }

Run the code above in your browser using DataLab