Learn R Programming

cwm (version 0.0.3)

cwrEm: Function to estimate Cluster Weighted Regression (CWR) models

Description

This function estimates CWR models via EM algoritms. An object of class cwrObj is returned containing posterior probabilities and group parameters.

Usage

cwrEm(X, Y, nc, max_iter = 1000, thresh = 0.01, cov_typeX = "full", cov_typeY = "full", clamp_weights = FALSE, create_init_params = TRUE, cwrStart = NULL, cov_priorX = NULL, cov_priorY = NULL, verbose = TRUE, regress = TRUE, clamp_covX = FALSE, clamp_covY = FALSE)

Arguments

X
X data matrix
Y
Y data matrix
nc
Number of clusters
max_iter
Max iterations. Default 1000
thresh
threshold to assess numerical convergence. Default 0.01
cov_typeX
Type of covariance of groups in X space. May be: "full" (default), "spherical", "diagonal"
cov_typeY
Type of covariance of groups in Y space. May be: "full" (default), "spherical", "diagonal"
clamp_weights
Fixed weights
create_init_params
Creates initial parameters
cwrStart
cwrObj to initialize. If autostart -> NULL
cov_priorX
Prior X covariance if not autostart. See cov_typeX
cov_priorY
Prior Y covariance if not autostart. See cov_typeY
verbose
Prints details of estimation process
regress
Regression model. Default TRUE
clamp_covX
Fixed covX matrix.
clamp_covY
Fixed covY matrix.

Value

A CWR object with the following component:
muX
Means matrix of X component
muY
Means matrix of X component
aic
AIC of model
X
X matrix
Y
Y matrix
SigmaY
Array containing Y Variances
SigmaX
Array containing X Variances
weightsY
Matrix containing posterior probabilities

Warning

Estimation can be slow. Convergence is not guaranteeted.

Details

This is the main function to estimate CWR models

References

Murphy

See Also

stepCwr

Examples

Run this code
##using Geyser dataset from package MASS
library(MASS)
data(geyser)
x=geyser[,1]
y=geyser[,2]                            
cwrEmExample=cwrEm(x,y,nc=2)
print(cwrEmExample) 

Run the code above in your browser using DataLab