[R] R Package: mmlcr and/or flexmix

Friedrich.Leisch@tuwien.ac.at Friedrich.Leisch at tuwien.ac.at
Tue Apr 12 09:25:04 CEST 2005


>>>>> On Tue, 12 Apr 2005 00:44:17 -0400,
>>>>> Geller, Scott (IHG) (GS() wrote:

  > Greetings 
  > I'm a relatively new R user and I'm trying to build a latent class model.
  > I've used the 'R Site Search' and it appears there's not much dialogue on
  > these packages

[...]


  > libray(flexmix)

  > m1<-flexmix(nts ~ first_brand_HOLIDAY+ perc_zone1+ perc_Group_nights+
  > perc_num_asian+  DaysBetweenStays+ CROStays+ DaysSinceLastStay+
  > wghtmean_median_age_pop100+ perc_num_white+ perc_num_hispanic+
  > perc_CROStays+ numMonthsActive+ WEBStays+ property_loyalty+ perc_NoZone+
  > rho+ PCR_Dummy_class+ ltgold1+ ltgold3+ p_hat_PCR, data = data, k = 2, model
  > = FLXglm(family = "poisson"))

  > rm1<-refit(m1)

  > summary(rm1)

 

[ Scott sent me in private a subset of the data ]

For me this seems to work fine:

R> set.seed(123)
R> m1<-flexmix(nts ~ first_brand_HOLIDAY+ perc_zone1+ perc_Group_nights+
+ perc_num_asian+  DaysBetweenStays+ CROStays+ DaysSinceLastStay+
+ wghtmean_median_age_pop100+ perc_num_white+ perc_num_hispanic+
+ perc_CROStays+ numMonthsActive+ WEBStays+ property_loyalty+ perc_NoZone+
+ rho+ PCR_Dummy_class+ ltgold1+ ltgold3+ p_hat_PCR, data = data, k = 2, model
+ = FLXglm(family = "poisson"))
R> m1

Call:
flexmix(formula = nts ~ first_brand_HOLIDAY + perc_zone1 + perc_Group_nights +
    perc_num_asian + DaysBetweenStays + CROStays + DaysSinceLastStay +
    wghtmean_median_age_pop100 + perc_num_white + perc_num_hispanic +
    perc_CROStays + numMonthsActive + WEBStays + property_loyalty +
    perc_NoZone + rho + PCR_Dummy_class + ltgold1 + ltgold3 +
    p_hat_PCR, data = data, k = 2, model = FLXglm(family = "poisson"))

Cluster sizes:
  1   2
 93 906

convergence after 49 iterations


R> rm1<-refit(m1)
R>
R> summary(rm1)

Call:
refit(m1)

Component 1 :
                              Estimate  Std. Error z value  Pr(>|z|)
(Intercept)                 1.0108e+00  6.4399e-01  1.5696 0.1164971
first_brand_HOLIDAY        -9.3504e-01  4.6151e-01 -2.0261 0.0427594
perc_zone1                  1.3936e-01  7.4383e-01  0.1874 0.8513845
...

-------------
Component 2 :
                              Estimate  Std. Error z value  Pr(>|z|)
(Intercept)                 1.00799714  0.39133294  2.5758   0.01000
first_brand_HOLIDAY        -0.07928984  0.15935997 -0.4976   0.61880
perc_zone1                  0.01208886  0.42596711  0.0284   0.97736
...


So I cannot reproduce the problem. Is maybo one cluster in your
solution empty? The EM algorithm can end up in a local optimum with
one cluster empty ... either run flexmix() several times by hand or
use stepFlexmix() to do so automatically.

HTH,

-- 
-------------------------------------------------------------------
                        Friedrich Leisch 
Institut für Statistik                     Tel: (+43 1) 58801 10715
Technische Universität Wien                Fax: (+43 1) 58801 10798
Wiedner Hauptstraße 8-10/1071
A-1040 Wien, Austria             http://www.ci.tuwien.ac.at/~leisch




More information about the R-help mailing list