Learn R Programming

morpheus (version 1.0-4)

optimParams: optimParams

Description

Wrapper function for OptimParams class

Usage

optimParams(X, Y, K, link = c("logit", "probit"), M = NULL, nc = 0)

Value

An object 'op' of class OptimParams, initialized so that

op$run(theta0) outputs the list of optimized parameters

  • p: proportions, size K

  • beta: regression matrix, size dxK

  • b: intercepts, size K

theta0 is a list containing the initial parameters. Only beta is required (p would be set to (1/K,...,1/K) and b to (0,...0)).

Arguments

X

Data matrix of covariables

Y

Output as a binary vector

K

Number of populations.

link

The link type, 'logit' or 'probit'.

M

the empirical cross-moments between X and Y (optional)

nc

Number of cores (default: 0 to use all)

See Also

multiRun to estimate statistics based on beta, and generateSampleIO for I/O random generation.

Examples

Run this code
# Optimize parameters from estimated mu
io <- generateSampleIO(100,
  1/2, matrix(c(1,-2,3,1),ncol=2), c(0,0), "logit")
mu <- computeMu(io$X, io$Y, list(K=2))
o <- optimParams(io$X, io$Y, 2, "logit")
if (FALSE) {
theta0 <- list(p=1/2, beta=mu, b=c(0,0))
par0 <- o$run(theta0)
# Compare with another starting point
theta1 <- list(p=1/2, beta=2*mu, b=c(0,0))
par1 <- o$run(theta1)
# Look at the function values at par0 and par1:
o$f( o$linArgs(par0) )
o$f( o$linArgs(par1) )}

Run the code above in your browser using DataLab