Description Usage Arguments Details Value Author(s) See Also Examples
View source: R/functions_predict.R
Predicts cluster membership using either multinomial logistic regression or SVMs.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 | ## S3 method for class 'predkmeans'
predictML(
object = NULL,
centers = object$centers,
K = nrow(centers),
R,
Rstar,
Xstar = NULL,
tr.assign = object$cluster,
muStart = "random",
maxitMlogit = 500,
verbose = 1,
nMlogitStarts = 1,
mlogit.control = list(suppressFittedWarning = TRUE),
...
)
## S3 method for class 'predkmeans'
predictSVM(
object = NULL,
centers = object$centers,
R,
Rstar,
K = nrow(centers),
Xstar = NULL,
tr.assign = object$cluster,
svm.control = list(gamma = c(1/(2:1), 2), cost = seq(20, 100, by = 20)),
...
)
## S3 method for class 'predkmeans'
predictMixExp(object, R, Rstar = NULL, ...)
|
object |
A predkmeans object, from which the cluster centers will be extracted. |
centers |
Matrix of cluster centers, assumed to be K-by-p |
K |
Number of clusters |
R |
matrix of covariates for observations to be predicted at. |
Rstar |
matrix of covariates at training locations |
Xstar |
matrix of observation at training locations. Either this or |
tr.assign |
vector of cluster assignments at training locations. By default, extracted from |
muStart |
starting value for cluster centers in mlogit optimization (IDEA: change to pull from predkmeans object?). If not provided, starting values are selected randomly. |
maxitMlogit |
Maximum number of iterations for |
verbose |
integer indicating amount of output to be displayed |
nMlogitStarts |
number of mlogit starts to use in estimation of parameters |
mlogit.control |
list of control parameters to be passes to |
... |
Unused additional arguments |
svm.control |
list of options for |
Function for predicting cluster membership in clusters identified by k-means or predictive k-means using multinomial logistic regression or support vector machines (SVMs). For multinomial logitic regression, parameter estimation is handled by mlogit
. The SVMs are fit using best.svm
from e1071
package.
Because this prediction includes return information about cluster assignment
and prediction model parameters, this method is deliberately distinct from
the generic predict
functions.
The predictMixExp
funciton provides predictions from
the 'working' cluster assignments created as part of the
mixture of experts algorithm from predkmeans
.
A list containing some or all of the following elements:
tr.assign |
Cluster assignments at training locations |
mlfit |
A subset of the mlogit object returned by the function of that name |
beta |
Estimated model parameters |
test.pred |
Predicted cluster assignments at test locations |
Joshua Keller
mlogit
, predkmeans
, predictionMetrics
Other methods for predkmeans objects:
relevel.predkmeans()
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 | n <- 200
r1 <- rnorm(n)
r2 <- rnorm(n)
u1 <- rbinom(n, size=1,prob=0)
cluster <- ifelse(r1<0, ifelse(u1, "A", "B"), ifelse(r2<0, "C", "D"))
mu1 <- c(A=2, B=2, C=-2, D=-2)
mu2 <- c(A=1, B=-1, C=-1, D=-1)
x1 <- rnorm(n, mu1[cluster], 4)
x2 <- rnorm(n, mu2[cluster], 4)
R <- cbind(1, r1, r2)
X <- cbind(x1, x2)
pkm <- predkmeans(X=cbind(x1, x2), R=R, K=4)
n_pred <- 50
Rnew <- cbind(1, r1=rnorm(n_pred), r2=rnorm(n_pred))
pkmPred <- predictML(pkm, R=Rnew, Rstar=R)
pkmPred$test.pred
|
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.