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

Description Usage Arguments Details Value Warning Note Author(s) References See Also Examples

Description

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

Usage

1
2
3
4
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.

Details

This is the main function to estimate CWR models

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.

Note

This is the main function. X and Y may be vectors or matrices. cwrObj objects containing parameters and posterior probabilities are returned.

Author(s)

Giorgio Spedicato

References

Murphy

See Also

stepCwr

Examples

1
2
3
4
5
6
7
##using Geyser dataset from package MASS
library(MASS)
data(geyser)
x=geyser[,1]
y=geyser[,2]                            
cwrEmExample=cwrEm(x,y,nc=2)
print(cwrEmExample) 

Example output

Loading required package: MASS
iteration  1  logLik  -3201.346 
iteration  2  logLik  -1419.224 
iteration  3  logLik  -1404.442 
iteration  4  logLik  -1401.795 
cwrObj :  cwrEmExample 
------------- 
 
Number of groups:  2 
Relative weights (priors):  0.6603206 0.3396794 
------------- 
 
logLik :  -1401.795 
AIC :  2827.59 
BIC :  2871.995 
------------- 
 
computation time :  0.653 

cwm documentation built on May 1, 2019, 9:19 p.m.