[R-sig-ME] Data Redux -- Re: Computational speed - MCMCglmm/lmer

Douglas Bates bates at stat.wisc.edu
Thu Jun 24 00:13:25 CEST 2010


Thanks for sending the cleaned up version of the data, Dave.

First, it seems to me that the model should include the fratsor
variable and perhaps an interaction with gender.  This will make it
difficult to fit (because it has even more fixed-effects parameters)
and I would suggest replacing weekday by a factor with three levels
"Sun-Wed", "Thu" and "Fri-Sat".  See the enclosed plot for why I would
suggest that.  Alternatively you could consider a binary variable of
Sun-Wed and Thu-Sat.
There definitely does seem to be a peak at Friday, especially in the
Frat/Sor group and a drop-off to Saturday.  Interestingly Thursday
seems to have heavier consumption by the Frat/Sor group than Saturday
(I was wondering why attendance seems a little thin for my 8:00 a.m.
Intro Engineering Statistics class on Fridays).

Second, there is a good news/bad news situation regarding the
development version of glmer.  I have introduced a coarser method of
getting estimates selected with the optional argument nAGQ = 0.  It is
more complicated to explain than I would like to embark on here but
suffice to say it is much faster and gets good estimates but not
the best.  At this point the output will look suspicious because I needed to
turn off the system.time in the batch run, probably because of a
memory protection issue that I will need to resolve.

Timing this fit works interactively for me but not in a batch run

> system.time(
+ drk0.glmer <- glmer(drinks ~ weekday*gender + (1 | id),
+                                        data = drink.df, family = poisson,
+                                        verbose = TRUE, nAGQ=0L)
+ )
npt = 3 , n =  1
rhobeg =  0.2 , rhoend =  2e-07
  0.020:   3:      146545.; 1.00000
 0.0020:   3:      146545.; 1.00000
 0.00020:  10:      146543.;0.960752
 2.0e-05:  12:      146543.;0.960984
 2.0e-06:  15:      146543.;0.960974
 2.0e-07:  15:      146543.;0.960974
At return
 17:     146542.78: 0.960974
  user  system elapsed
 16.870   0.080  17.029

So 17 seconds elapsed time is pretty good.  The full Laplacian fit
took about 300 seconds and gave only a slightly better deviance.
Regrettably I have seen situations where the full Laplacian fit is
considerably better so I can't recommend avoiding the full Laplacian
fit entirely.  I do think that the fit with nAGQ = 0 is okay for coarse model
building where you need rough comparisons of several different models.


On Wed, Jun 23, 2010 at 1:40 PM, David Atkins <datkins at u.washington.edu> wrote:
>
> First, my apologies for not providing clean data in my initial posting,
> which was clearly an oversight on my part.  I have an email in to the PI but
> haven't gotten a response yet.
>
> I have attached an updated dataset, that pulls out the 2 suspect
> participants as well as those with gender coded 2.  In addition, it includes
> two more variables:
>
> weekday - 7 level factor for day of week (new variable weekend now has the
> binary version)
> fratsor - a binary factor indicating whether individual is part of a
> fraternity or sorority (or not)
>
> I have an updated script below that shows (descriptively) how drinking
> varies over these factors.  Moreover, including weekday as either fixed or
> random, really ratchets up the time for glmer.  Again, my original purpose
> is definitely *not* to criticize lme4 (or Doug), but simply to get some
> feedback about computational speed, and whether or not it's possible to
> speed up runs via hardware, OS, or software.
>
> Finally, in providing some data, I was trying to provide a brief subset of
> data that has certain realistic qualities (and it is real data) but is not a
> "full" data set.  In trying to be simple and straightforward, I may have
> raised more questions.
>
> So, in response to a few questions raised:
>
> The data come from a study of problematic drinking focused on high-risk
> events, and this particular data focused on 21st birthdays (here in the US,
> that is the legal drinking age).  The present data are from a survey (ie,
> non-intervention), which then informed a later intervention study.  Thus,
> the (up to) 90 days of retrospective drinking, will cover the individual's
> 21st birthday.
>
> Doug asks about someone reporting 45 drinks.  Because we are capturing 21st
> birthdays, we are definitely getting some extreme drinking, but we also are
> relying on self-report.  Clearly, there will be some errors and possible
> bravado about feats of drinking.  Moreover, the study has a protocol for
> addressing potentially dangerous levels of drinking with participants (when
> blood-alcohol content passes a certain cutoff).
>
> Hadley asks about the repeated data.  Part of the study involves friends of
> the main participant (as one intervention condition includes friends input
> as part of the intervention).  Some of the friend's data were included in a
> larger version of this dataset, which then led to replicates of the
> participant's data.  Thus, we knew individuals with friend's data had
> replicates, but this version was supposed to have that cleaned up.
>
> Finally, this particular data was collected on a rolling basis, and thus the
> 90 day recounting of drinking covers a large swath of the calendar year.  We
> are currently working on a paper that examines student drinking on typical
> weekdays vs. weekends vs. 21st birthday vs. holidays (including St.
> Patrick's Day, though July 4th and New Year's Eve are much heavier drinking
> days...).
>
> Hopefully this clarifies certain aspects of the data, and I definitely
> appreciate folks input on the computational aspects -- I'm certainly
> learning.
>
> [BTW, I'm currently fitting a second model to the one reported below, with a
> random effect for weekday -- currently at 30 minutes and counting.]
-------------- next part --------------

R version 2.11.1 (2010-05-31)
Copyright (C) 2010 The R Foundation for Statistical Computing
ISBN 3-900051-07-0

R is free software and comes with ABSOLUTELY NO WARRANTY.
You are welcome to redistribute it under certain conditions.
Type 'license()' or 'licence()' for distribution details.

  Natural language support but running in an English locale

R is a collaborative project with many contributors.
Type 'contributors()' for more information and
'citation()' on how to cite R or R packages in publications.

Type 'demo()' for some demos, 'help()' for on-line help, or
'help.start()' for an HTML browser interface to help.
Type 'q()' to quit R.

> #
> ### read in *updated* drinking data
> drink.df <- within(read.delim("~/tests/drinksUPDATED.txt"), id <- factor(id))
> str(drink.df) # 57K rows
'data.frame':	56199 obs. of  6 variables:
 $ id     : Factor w/ 980 levels "1014503","1017782",..: 1 1 1 2 2 2 2 2 2 2 ...
 $ gender : Factor w/ 2 levels "F","M": 1 1 1 2 2 2 2 2 2 2 ...
 $ fratsor: Factor w/ 2 levels "Frat/Sor","Not Frat/Sor": 2 2 2 2 2 2 2 2 2 2 ...
 $ weekday: Factor w/ 7 levels "Friday   ","Monday   ",..: 4 3 1 4 3 1 5 7 6 2 ...
 $ weekend: Factor w/ 2 levels "Weekday","Weekend": 1 2 2 1 2 2 1 1 1 1 ...
 $ drinks : int  0 0 5 8 5 10 0 0 0 0 ...
> 
> ### NOTE: slight variable changes since last iteration
> ### id is id variable (shocking)
> ### gender is binary factor
> ### fratsor is binary factor (in fraternity or sorority vs. not)
> ### weekday now has day of week
> ### weekend is now weekday (Sun - Thurs) vs. weekend (Fri - Sat)
> ### drinks has number of drinks consumed
> 
> ### trim trailing white spaces
> levels(drink.df$weekday) <- sub('[[:space:]]+$', '', levels(drink.df$weekday))
> ### re-order factor
> drink.df <- within(drink.df,
+                    weekday <- factor(weekday, levels = levels(weekday)[c(4,2,6,7,5,1,3)]))
> summary(drink.df)
       id        gender            fratsor           weekday    
 1028078:   90   F:31599   Frat/Sor    :11639   Sunday   :8112  
 1325095:   90   M:24600   Not Frat/Sor:44560   Monday   :7999  
 1365806:   90                                  Tuesday  :7949  
 1411092:   90                                  Wednesday:7903  
 1472245:   90                                  Thursday :7928  
 1518480:   90                                  Friday   :8091  
 (Other):55659                                  Saturday :8217  
    weekend          drinks      
 Weekday:39891   Min.   : 0.000  
 Weekend:16308   1st Qu.: 0.000  
                 Median : 0.000  
                 Mean   : 1.001  
                 3rd Qu.: 0.000  
                 Max.   :45.000  
                                 
> 
> ### distribution of outcome
> table(drink.df$drinks)

    0     1     2     3     4     5     6     7     8     9    10    11    12 
44818  1787  1831  1482  1337  1261   864   495   673   189   634    44   248 
   13    14    15    16    17    18    19    20    21    22    23    24    25 
   46    61   183    44    19    45     4    39    28    15     8    13    13 
   26    27    28    30    32    34    45 
    3     2     3     7     1     1     1 
> plot(table(drink.df$drinks), lwd=2) # zero-inflated
> 
> ### how many people?
> length(unique(drink.df$id)) # 980
[1] 980
> sort(table(drink.df$id)) # max of 90 drinks

1319941 4212130 8015105 8603120 9835536 2875902 5283938 6538318 1014503 1275277 
      1       1       1       1       1       2       2       2       3       3 
2973838 3817648 3852450 5023034 6086263 6659737 7921706 9844380 1236528 1399161 
      3       3       3       3       3       3       3       3       4       4 
1407847 1420474 1958097 2041854 2077901 2085569 2263898 2278280 2324119 2361365 
      4       4       4       4       4       4       4       4       4       4 
2491080 2643739 2781746 2845433 2971385 3015995 3496488 3559269 3728091 4393986 
      4       4       4       4       4       4       4       4       4       4 
4591080 4837581 5014416 5049844 5590582 5961753 6333650 6463057 6488182 6539097 
      4       4       4       4       4       4       4       4       4       4 
6659123 6890432 6962360 6993756 7980552 8096007 8613583 8812345 8891232 9416540 
      4       4       4       4       4       4       4       4       4       4 
9434405 9525137 9876487 9877492 9921013 1189810 1388664 1527755 1839258 2113919 
      4       4       4       4       4       5       5       5       5       5 
2319518 2369091 2525656 2544519 2619796 3103486 3231339 3391214 3825014 3854175 
      5       5       5       5       5       5       5       5       5       5 
3896152 3914774 4030284 4050701 4316326 4460349 4830580 5098079 5204524 5372808 
      5       5       5       5       5       5       5       5       5       5 
5548610 5731826 6254008 6255413 6536013 6611692 6863222 7201642 7590309 8155947 
      5       5       5       5       5       5       5       5       5       5 
8843022 9343822 1344463 1616364 2101965 2737711 3132946 3649336 4170641 4212525 
      5       5       6       6       6       6       6       6       6       6 
4326702 4532354 4591237 5303660 5827251 6216133 6480774 6575532 6711978 6833640 
      6       6       6       6       6       6       6       6       6       6 
7157691 7281220 8214282 8540069 9041756 9430688 9965510 1263864 1736059 2189596 
      6       6       6       6       6       6       6       7       7       7 
3773611 3838167 3949720 4393579 4865975 5530455 5534759 5777541 6352488 6952025 
      7       7       7       7       7       7       7       7       7       7 
7754746 7992618 8201208 8268278 8761577 1124709 1200968 1559244 1935294 2228747 
      7       7       7       7       7       8       8       8       8       8 
4737932 5095385 5622687 7172505 7458973 7631251 7887629 8075124 9516066 9939608 
      8       8       8       8       8       8       8       8       8       8 
1400561 2760380 4140447 5944406 6483868 6558815 7528954 8045277 8583302 9023183 
      9       9       9       9       9       9       9       9       9       9 
9179082 2334460 2681159 2881046 3013308 3503828 3559980 6144342 6603388 7380815 
      9      10      10      10      10      10      10      10      10      10 
7529009 7966676 8082059 8556613 8596599 8700467 1194733 1202025 1548596 1936396 
     10      10      10      10      10      10      11      11      11      11 
3371613 3523351 4722623 6658047 6847647 7663735 8430686 8944029 9971653 3001944 
     11      11      11      11      11      11      11      11      11      12 
3370505 3587272 5340980 7731005 8843600 9021560 9546257 1149205 4055666 5119167 
     12      12      12      12      12      12      12      13      13      13 
5251847 5878758 8226137 2738000 3240450 8933334 2035575 7284638 8515671 2318278 
     14      14      14      15      15      15      16      16      16      17 
3551696 5233134 7258209 4123960 6471323 8883864 1612271 2285751 2922474 3076020 
     17      17      17      18      18      18      19      19      19      19 
4234749 2624602 4977586 1283972 3026303 5024081 5270748 1432309 1726095 3499615 
     19      20      21      22      22      22      22      23      23      23 
3716970 4351947 4766409 6317417 7522203 7951118 1111222 3055242 1542736 3972120 
     23      23      23      23      23      23      24      24      25      25 
4245213 5695022 5330042 1017782 2904857 7572151 1565477 1824717 4411256 6400138 
     25      25      26      27      27      27      28      28      28      29 
8373776 2132369 4269915 7478885 9179169 6686464 8254827 8370884 8962932 9544612 
     29      30      30      30      30      31      31      31      31      31 
9816970 1049490 4668787 7494674 8037577 9587610 1740479 5538680 8354486 4931091 
     31      32      32      32      32      32      33      33      33      34 
7968119 9130847 4034626 5056981 5852393 8226859 2586445 2953918 6568163 6773971 
     34      34      35      35      35      35      36      36      36      36 
7391718 8039498 1084348 1334031 9529321 1119763 3607705 3767381 8228497 3063500 
     36      36      37      37      37      38      38      38      38      39 
6197215 7817663 8812679 1670770 2036242 3927226 9450062 9797059 2262819 2606374 
     39      39      39      40      40      40      40      40      41      41 
6810115 9522634 6761002 8335986 9218397 1701786 6012467 7285261 7390966 9700659 
     41      41      42      42      42      43      43      43      43      43 
1752166 5756629 7821357 8499519 9084692 9902893 7534646 7841156 8871670 3173554 
     44      44      44      44      44      44      45      45      45      46 
3618145 4903956 6812321 6814520 8973400 9565738 3012589 3790128 7234962 7978339 
     46      46      46      46      46      46      47      47      47      47 
8546289 1090548 2797750 4789463 6030867 6577914 6754613 8312313 6577580 2343179 
     47      48      48      48      48      48      48      48      49      50 
3791562 1153586 4898306 6724498 7420735 7716703 7732578 8418926 5261553 7593175 
     50      51      51      51      51      51      51      51      52      52 
7798623 1831240 2190753 3318244 4433082 6527360 1026066 4184204 4274077 2351479 
     52      53      53      53      53      53      54      54      54      55 
4588702 5685719 4941227 5591227 6006241 2392265 5869946 6243698 8961338 9642276 
     55      55      56      56      56      57      57      57      57      57 
2050263 2069149 5083578 6853929 8454287 8890689 8953595 2050221 2158552 3458758 
     58      58      58      58      58      58      58      59      59      59 
3522382 5641747 5997701 9128379 1182230 2413733 2535813 3331699 4339133 4450695 
     59      59      59      59      60      60      60      60      60      60 
6810803 7630900 7943059 8873348 9700900 2105448 3012259 3827576 7189737 8416507 
     60      60      60      60      60      61      61      61      61      61 
1317485 1505208 2350411 4620203 4736431 4963162 6055972 6264065 8842582 9207550 
     62      62      62      62      62      62      62      62      62      62 
9578508 9656757 9799794 2607767 4739249 5599093 1147135 1554725 2235706 2750601 
     62      62      62      63      63      63      64      64      64      64 
3128066 3294040 4641961 7142254 7840065 9200728 3371565 4107771 5887960 6314102 
     64      64      64      64      64      64      65      65      65      65 
7146040 9922543 2646375 2930620 4418596 4528211 4617143 6343663 7446665 1272677 
     65      65      66      66      66      66      66      66      66      67 
2399193 3553766 3629994 4010491 5711642 7452512 7650803 8553285 1117617 1301598 
     67      67      67      67      67      67      67      67      68      68 
1505319 2570427 2929328 3408926 4873580 5350307 5968724 7334474 7789100 9527960 
     68      68      68      68      68      68      68      68      68      68 
3387469 4024391 4595134 4609073 4945815 5356055 7299896 7737387 8961776 1766542 
     69      69      69      69      69      69      69      69      69      70 
1906887 5175402 5314655 6837568 6976189 7182350 8532893 3293350 7416680 8423955 
     70      70      70      70      70      70      70      71      71      71 
1384884 4514791 7229999 7270645 7456963 7742042 2678061 3647332 3733652 4747381 
     72      72      72      72      72      72      73      73      73      73 
4795840 5087112 5446166 6577484 6878267 8381261 8916650 9616935 1384034 1388948 
     73      73      73      73      73      73      73      73      74      74 
1399735 2340467 3023513 4921437 5553430 6350154 7718953 7741538 7918428 8039756 
     74      74      74      74      74      74      74      74      74      74 
8369132 8913920 2419425 2605267 2967863 3374000 3850222 4804293 5431687 6154621 
     74      74      75      75      75      75      75      75      75      75 
9772394 1996278 2152434 2397856 2841562 3129354 5241710 5692737 6032653 9587463 
     75      76      76      76      76      76      76      76      76      76 
2333659 2384771 3574470 4609920 5825759 6107071 6146448 7755304 9103794 9565154 
     77      77      77      77      77      77      77      77      77      77 
1861175 2690918 2854882 3106424 3416432 6336288 6507821 8357406 8519282 8702886 
     78      78      78      78      78      78      78      78      78      78 
9045606 9424169 9741259 1369777 1604781 2702553 3433746 3949484 4298020 4429340 
     78      78      78      79      79      79      79      79      79      79 
4661052 5377253 5476874 6223586 6605590 9784649 9991046 1041305 2768589 4199368 
     79      79      79      79      79      79      79      80      80      80 
4800597 5978910 6744147 8090873 8148478 8202008 9398903 9989437 1438856 2587909 
     80      80      80      80      80      80      80      80      81      81 
2777473 3045211 3283541 3413108 4049379 4184536 4633747 4704308 5106933 5136888 
     81      81      81      81      81      81      81      81      81      81 
6318117 7500044 8016393 8192947 9238014 9513072 9895677 1094090 2212851 3895865 
     81      81      81      81      81      81      81      82      82      82 
4620085 5709481 6081672 6183521 6307233 6427909 7275518 7768940 8117150 8292490 
     82      82      82      82      82      82      82      82      82      82 
8475230 8554640 8883466 9581589 1678506 2587475 3353997 3515965 4893926 4996850 
     82      82      82      82      83      83      83      83      83      83 
5250988 6544739 9373978 1382196 1890481 2669757 2864117 3178560 4389909 4578617 
     83      83      83      84      84      84      84      84      84      84 
4594967 4735247 4943866 5884100 6100969 7945975 8328398 8498254 8932468 9260484 
     84      84      84      84      84      84      84      84      84      84 
9326824 9413535 9465826 9668847 9728227 9735231 9753192 1036230 1051413 1260586 
     84      84      84      84      84      84      84      85      85      85 
1305494 1414681 1767157 2120749 2482707 2485802 3018266 3101640 3160683 3286662 
     85      85      85      85      85      85      85      85      85      85 
3353992 3548288 3926161 3935922 3986444 4687346 4784436 4806947 4890780 5210585 
     85      85      85      85      85      85      85      85      85      85 
5698410 5869573 5880239 6388293 6389512 6415510 6746544 6926473 6933118 7359086 
     85      85      85      85      85      85      85      85      85      85 
8275585 8716706 8968760 9240111 9710092 1231849 1621401 1923000 2200655 2421711 
     85      85      85      85      85      86      86      86      86      86 
2587227 2853104 2991236 3256411 3344508 3428038 3866174 3884389 4209867 4271676 
     86      86      86      86      86      86      86      86      86      86 
4425827 4774968 5042867 5239893 5591873 5724112 5857791 6015473 6158972 6176690 
     86      86      86      86      86      86      86      86      86      86 
6458602 6805254 7323564 7432112 7494869 7540968 7883047 8169294 8215045 8278127 
     86      86      86      86      86      86      86      86      86      86 
8600629 8877853 9033780 9266671 9312950 9438722 9510451 9619923 9810771 1055518 
     86      86      86      86      86      86      86      86      86      87 
1137483 1365297 1561984 1564925 1575328 1808816 1816247 2007755 2509906 2576361 
     87      87      87      87      87      87      87      87      87      87 
3261394 3325217 3343960 3381532 3443817 3783180 3787936 4284261 4345533 4488394 
     87      87      87      87      87      87      87      87      87      87 
4617546 4726620 4765320 4992047 5224005 5466615 5595838 6024689 6085143 6571288 
     87      87      87      87      87      87      87      87      87      87 
6587909 6684602 6708037 6877474 7206889 7243481 7288167 7459578 7468356 7659363 
     87      87      87      87      87      87      87      87      87      87 
7915938 8508927 8672882 8695411 8780163 8920438 9037135 9115186 9120269 9208791 
     87      87      87      87      87      87      87      87      87      87 
9220180 9354798 9366076 9437047 9542564 9657810 9981229 1097170 1457609 1692855 
     87      87      87      87      87      87      87      88      88      88 
1810902 2250326 2618792 2897495 3093021 3480548 3534464 3704884 3920567 3955444 
     88      88      88      88      88      88      88      88      88      88 
4059039 4433206 4611007 4839703 5041333 5068838 5084692 5134654 5201522 5222523 
     88      88      88      88      88      88      88      88      88      88 
5233868 5489568 5776328 5792758 5992977 6043463 6208455 6806650 6813814 6823221 
     88      88      88      88      88      88      88      88      88      88 
6936798 6981594 6985816 7039783 7547535 8123200 8145763 8312450 8316822 8701514 
     88      88      88      88      88      88      88      88      88      88 
9019769 9190078 9324488 9422387 9570269 9604624 1018311 1090450 1429568 1496511 
     88      88      88      88      88      88      89      89      89      89 
1528467 1678666 2145671 2363344 2405236 2442143 2960794 2963673 3088601 3121625 
     89      89      89      89      89      89      89      89      89      89 
3242908 3316233 3331169 3399691 3521621 3561331 3781407 3789272 3812146 3970715 
     89      89      89      89      89      89      89      89      89      89 
4243453 4536638 4665414 4847893 4902781 5145482 5296793 5969776 6781377 6835229 
     89      89      89      89      89      89      89      89      89      89 
6934677 6984514 7057236 7095917 7588390 7665148 7741332 7857601 7870097 8013659 
     89      89      89      89      89      89      89      89      89      89 
8040899 8578096 8690859 8743762 9002871 9011395 9076490 9135181 9187303 9737625 
     89      89      89      89      89      89      89      89      89      89 
1028078 1325095 1365806 1411092 1472245 1518480 1612755 1623484 1709091 1712310 
     90      90      90      90      90      90      90      90      90      90 
1717093 2006062 2197700 2274268 2312415 2317039 2340830 2371406 2373969 2562107 
     90      90      90      90      90      90      90      90      90      90 
2740118 2776673 2928270 2929024 3001617 3121973 3337422 3425845 3520950 3637606 
     90      90      90      90      90      90      90      90      90      90 
3690177 3740782 4180489 4253149 4518861 4571593 4864922 4914398 5051738 5060642 
     90      90      90      90      90      90      90      90      90      90 
5276247 5558779 5575437 5878137 6074463 6178916 6293584 6352030 6384195 6625594 
     90      90      90      90      90      90      90      90      90      90 
6978483 7046422 7231071 7231469 7396509 7435632 7515183 7746665 7875916 7879710 
     90      90      90      90      90      90      90      90      90      90 
7905511 7923832 8268380 8310625 8419023 8539279 8654166 8704823 9073782 9182202 
     90      90      90      90      90      90      90      90      90      90 
9214537 9237022 9281036 9319098 9335478 9590420 9614550 9782207 9799571 9809027 
     90      90      90      90      90      90      90      90      90      90 
> 
> ### how do drinks vary across days of week and also gender and fratsor?
> #
> with(drink.df, tapply(drinks, list(gender, fratsor), mean))
   Frat/Sor Not Frat/Sor
F 0.9248277    0.6265573
M 2.3757664    1.0561690
> ### not surprising, but men in fraternities drink notably more
> 
> with(drink.df, tapply(drinks, list(gender, weekday, fratsor), mean))
, , Frat/Sor

     Sunday    Monday   Tuesday Wednesday Thursday   Friday Saturday
F 0.4729136 0.5565476 0.6992593 0.6315007 1.300872 1.583691 1.191702
M 1.0111336 1.6358025 1.7236705 1.7907950 3.285861 4.103518 3.017928

, , Not Frat/Sor

     Sunday    Monday   Tuesday Wednesday  Thursday   Friday Saturday
F 0.3888029 0.3678161 0.3602419 0.3539073 0.5484897 1.189956 1.159294
M 0.4557505 0.5734072 0.4944268 0.5014006 0.9024096 2.311668 2.106416

> ### general peak on friday and/or saturday, but differences in rest
> ### of week for fraternity/sorority crowd...
> 
> ### speed tests
> #
> ### fit random intercept and random slope for weekday
> ### fixed effects for gender and weekday and interaction
> #
> ### Poisson GLMM with glmer()
> library(lme4a)
Loading required package: Matrix
Loading required package: lattice

Attaching package: 'Matrix'

The following object(s) are masked from 'package:base':

    det

Loading required package: minqa
Loading required package: Rcpp

Attaching package: 'lme4a'

The following object(s) are masked from 'package:stats':

    AIC

> xyplot(drinks ~ as.integer(weekday)|fratsor, drink.df, groups = gender,
+        type = c("g","a"), ylim=c(-0.1, 5),
+        auto.key = list(columns = 2, points = FALSE, lines = TRUE))
> ### NOTE: weekday is different from last set of code; last time it was
> ###                     binary, this time it is 7 level factor
> #
> ### random intercept
> #system.time(
> drk0.glmer <- glmer(drinks ~ weekday*gender + (1 | id),
+                                        data = drink.df, family = poisson,
+                                        verbose = TRUE, nAGQ=0L)
npt = 3 , n =  1 
rhobeg =  0.2 , rhoend =  2e-07 
   0.020:   3:      146545.; 1.00000 
  0.0020:   3:      146545.; 1.00000 
 0.00020:  10:      146543.;0.960752 
 2.0e-05:  12:      146543.;0.960984 
 2.0e-06:  15:      146543.;0.960974 
 2.0e-07:  15:      146543.;0.960974 
At return
 17:     146542.78: 0.960974
> #)
> print(drk0.glmer, corr = FALSE)
Generalized linear mixed model fit by maximum likelihood ['merMod']
 Family: poisson 
Formula: drinks ~ weekday * gender + (1 | id) 
   Data: drink.df 
      AIC       BIC    logLik  deviance 
146572.78 146706.83 -73271.39 146542.78 

Random effects:
 Groups Name        Variance Std.Dev.
 id     (Intercept) 0.9235   0.961   
Number of obs: 56199, groups: id, 980

Fixed effects:
                         Estimate Std. Error z value
(Intercept)              -1.20139    0.04862  -24.71
weekdayMonday            -0.01034    0.03329   -0.31
weekdayTuesday            0.02582    0.03302    0.78
weekdayWednesday         -0.01160    0.03340   -0.35
weekdayThursday           0.50043    0.02975   16.82
weekdayFriday             1.12674    0.02690   41.89
weekdaySaturday           1.05958    0.02708   39.13
genderM                   0.29031    0.07098    4.09
weekdayMonday:genderM     0.36965    0.04358    8.48
weekdayTuesday:genderM    0.29549    0.04356    6.78
weekdayWednesday:genderM  0.36294    0.04376    8.29
weekdayThursday:genderM   0.45316    0.03912   11.58
weekdayFriday:genderM     0.40287    0.03586   11.24
weekdaySaturday:genderM   0.29769    0.03623    8.22
> 
> system.time(
+ drk.glmer <- glmer(drinks ~ weekday*gender + (1 | id),
+                    data = drink.df, family = poisson,
+                    verbose = TRUE)
+ )
npt = 3 , n =  1 
rhobeg =  0.2 , rhoend =  2e-07 
   0.020:   3:      146545.; 1.00000 
  0.0020:   3:      146545.; 1.00000 
 0.00020:  10:      146543.;0.960752 
 2.0e-05:  12:      146543.;0.960984 
 2.0e-06:  15:      146543.;0.960974 
 2.0e-07:  15:      146543.;0.960974 
At return
 17:     146542.78: 0.960974
npt = 21 , n =  15 
rhobeg =  0.2402773 , rhoend =  2.402773e-07 
   0.024:  22:      146543.;0.960974 -1.20139 -0.0103437 0.0258154 -0.0116047 0.500429  1.12674  1.05958 0.290308 0.369654 0.295491 0.362936 0.453156 0.402868 0.297695 
  0.0024:  25:      146543.;0.960974 -1.20139 -0.0103437 0.0258154 -0.0116047 0.500429  1.12674  1.05958 0.290308 0.369654 0.295491 0.362936 0.453156 0.402868 0.297695 
 0.00024:  55:      146542.;0.963295 -1.20556 -0.0147872 0.0209361 -0.0160586 0.496082  1.12355  1.05572 0.291643 0.369540 0.297302 0.363591 0.453500 0.400996 0.296965 
 2.4e-05:  77:      146542.;0.963244 -1.20602 -0.0145060 0.0217739 -0.0169666 0.496343  1.12370  1.05553 0.291640 0.369878 0.297602 0.363590 0.453817 0.401563 0.297064 
 2.4e-06:  97:      146542.;0.963253 -1.20604 -0.0145030 0.0217623 -0.0169737 0.496334  1.12371  1.05551 0.291631 0.369875 0.297614 0.363567 0.453827 0.401556 0.297047 
 2.4e-07: 116:      146542.;0.963253 -1.20604 -0.0145012 0.0217604 -0.0169719 0.496334  1.12370  1.05551 0.291631 0.369876 0.297614 0.363567 0.453827 0.401554 0.297047 
At return
137:     146542.06: 0.963254 -1.20604 -0.0145012 0.0217604 -0.0169719 0.496334  1.12370  1.05551 0.291631 0.369876 0.297614 0.363567 0.453827 0.401554 0.297047
   user  system elapsed 
360.240   0.710 368.761 
> print(drk.glmer, corr = FALSE)
Generalized linear mixed model fit by maximum likelihood ['merMod']
 Family: poisson 
Formula: drinks ~ weekday * gender + (1 | id) 
   Data: drink.df 
      AIC       BIC    logLik  deviance 
146572.06 146706.11 -73271.03 146542.06 

Random effects:
 Groups Name        Variance Std.Dev.
 id     (Intercept) 0.9279   0.9633  
Number of obs: 56199, groups: id, 980

Fixed effects:
                         Estimate Std. Error z value
(Intercept)              -1.20604    0.04870  -24.77
weekdayMonday            -0.01450    0.03328   -0.44
weekdayTuesday            0.02176    0.03301    0.66
weekdayWednesday         -0.01697    0.03340   -0.51
weekdayThursday           0.49633    0.02973   16.69
weekdayFriday             1.12370    0.02688   41.81
weekdaySaturday           1.05551    0.02706   39.01
genderM                   0.29163    0.07110    4.10
weekdayMonday:genderM     0.36988    0.04356    8.49
weekdayTuesday:genderM    0.29761    0.04354    6.84
weekdayWednesday:genderM  0.36357    0.04376    8.31
weekdayThursday:genderM   0.45383    0.03910   11.61
weekdayFriday:genderM     0.40155    0.03582   11.21
weekdaySaturday:genderM   0.29705    0.03620    8.21
> 
> ### timing
> #
> ###    user  system elapsed
> ### 257.268  39.115 295.754
> 
> proc.time()
   user  system elapsed 
388.650   1.230 399.061 
-------------- next part --------------
A non-text attachment was scrubbed...
Name: Rplots.pdf
Type: application/pdf
Size: 11088 bytes
Desc: not available
URL: <https://stat.ethz.ch/pipermail/r-sig-mixed-models/attachments/20100623/9619f98d/attachment.pdf>


More information about the R-sig-mixed-models mailing list