Skip to content

Resume terminated lmer fit if verbose=TRUE?

3 messages · Michael Lawrence, Hans Ekbrand

#
On Wed, Jul 27, 2011 at 03:39:59PM -0300, Mike Lawrence wrote:
Hi Mike,

I am just about to restart an interation that did not converge on 300
iterations. I have saved both the fit-object and the output of
glmer(verbose=TRUE). I don't really get how to format the input to the
start value parameter. Does it suffice to provide the last iteration
as a character string? Here is what I got for the last iteration:

300:     83537.084: 0.519965 0.143416 0.510886 0.390266 0.0253851 0.228085  0.00000  0.00000 0.175437 0.167589 0.000151413 0.257648  0.00000  0.00000  0.00000  0.00000  0.00000  0.00000  0.00000 0.662743 0.697672 0.0943584 0.238029 0.465242 0.264901 0.177211 -0.255314 0.297930 -0.0908047 0.234670 0.232733 0.0640540 0.0191507 -0.207110 0.370959 0.639145 0.275867 -1.61519  1.14158 -0.519320 -0.0995158 -0.00705858 -0.495069 -0.995847 -0.259104 -0.751779 -0.613690 -0.281145 -0.633951 -0.128201 -2.07103  2.11410 0.817327  1.09840 0.287138 -0.699452 0.511890 -0.227955 0.293735 0.443935 -0.107533 -0.159424 -0.380081 -0.0856487 0.271927 -0.419327 0.200206 0.0556932 -0.373988 0.219712  1.11540 -0.204753 -0.250565 0.227195 0.338191 0.0638902 0.381680 0.347678 0.656791 0.610805 0.286053 0.387693 0.0700578 0.311415 0.216640 -1.43990  8.21723 -0.0677624 -1.82260  1.98123  8.53073 -1.47762  4.62704  9.22425  16.0583  9.00298 0.610718  6.34499 0.114604 -0.268301 0.659427 0.0675373 0.223978 -0.314364 0.242165 -0.0398588 0.00348154 0.390582 0.205796 0.314690 -0.0210720 0.359508 0.0102215 0.0133513 -0.0249899 0.00303007 0.00104005 -0.00199693 -0.0162271 -0.00910787 -0.000721493 -0.00571186 -0.0221484 0.00132736 -0.00938054 -0.0559509 0.000625754 -0.0151419 -0.0342182 -0.0301707 -0.00874410 -0.0166841 -0.0118311 -0.0150344 -0.0455952 0.334382  1.62474 0.592823 -0.0838088 -0.0622300 -0.0477605 0.568942 -0.379506 -0.957889 -0.671352 -0.158491 -0.330145 0.269097 -0.316426 -1.04228 0.196337 -0.639169 -0.646029 -0.246746  1.11005  1.86385 0.428263  3.28910 0.565427 -0.285010 0.206211 -0.353546 0.913265 -0.534973 0.445224 -1.18672 -0.372053 -0.804367 -0.418456 -0.681271 0.0606201 0.0683290 0.685260 0.201087 -0.736270 -0.444255 -0.509914 -0.286142 -0.484370 -0.395121 -0.482115 0.300839 -0.444407 -0.444848 -0.0528026 -0.751176 0.670575 -0.0569850 -0.0616133 0.343210 -3.71098  1.26284  1.37018  1.13882  1.86587  1.14523  1.35873  1.81718  2.69451  2.54993  1.81382  1.97416  2.14052  1.94535 0.989847  2.04325  3.65850  1.65551  3.04955

Or do you have to format it in any way? How did you do it?

Kind regards,

Hans Ekbrand
#
I think you want something like:

from_verbose = "0.519965 0.143416 0.510886 0.390266 0.0253851 0.228085
 0.00000  0.00000 0.175437 0.167589 0.000151413 0.257648  0.00000
0.00000  0.00000  0.00000  0.00000  0.00000  0.00000 0.662743 0.697672
0.0943584 0.238029 0.465242 0.264901 0.177211 -0.255314 0.297930
-0.0908047 0.234670 0.232733 0.0640540 0.0191507 -0.207110 0.370959
0.639145 0.275867 -1.61519  1.14158 -0.519320 -0.0995158 -0.00705858
-0.495069 -0.995847 -0.259104 -0.751779 -0.613690 -0.281145 -0.633951
-0.128201 -2.07103  2.11410 0.817327  1.09840 0.287138 -0.699452
0.511890 -0.227955 0.293735 0.443935 -0.107533 -0.159424 -0.380081
-0.0856487 0.271927 -0.419327 0.200206 0.0556932 -0.373988 0.219712
1.11540 -0.204753 -0.250565 0.227195 0.338191 0.0638902 0.381680
0.347678 0.656791 0.610805 0.286053 0.387693 0.0700578 0.311415
0.216640 -1.43990  8.21723 -0.0677624 -1.82260  1.98123  8.53073
-1.47762  4.62704  9.22425  16.0583  9.00298 0.610718  6.34499
0.114604 -0.268301 0.659427"
from_verbose = strsplit(from_verbose,' ')[[1]]
from_verbose = as.numeric(from_verbose[from_verbose!=''])
to_start = list(
    ST = list(
        matrix(from_verbose[1],1,1)
    )
     , fixef = from_verbose[2:length(from_verbose)]
)
dimnames(to_start$ST[[1]]) = list('(Intercept)','(Intercept)')

my_new_fit = lmer(
    ...#your data, formula, family, etc., here
    , start = to_start
)
On Tue, Aug 30, 2011 at 5:07 AM, Hans Ekbrand <hans at sociologi.cjb.net> wrote:
#
I can't get lmer to use the start values I supply to it. I've tried three versions:

1. fit at ST
2. the output of VERBOSE = TRUE as a numerical vector (minus the iteration index and the REML value)
3. A list like this: (kindly suggested by Mike L, but probably not suited for my kind of model)

to_start
$ST
$ST[[1]]
 (Intercept)
(Intercept) "0.519965"


$fixef
 [1] "0.143416" "0.510886" "0.390266" "0.0253851" "0.228085" "0.00000" "0.00000" "0.175437" "0.167589"
[...]
[208] "3.04955"

1 and 2 SEEM to be ignored while 3 gives an error message. From
reading ?lmer I think I understand why 3 does not work ("setting start
values for fixef has no effect for a linear mixed model..."), but why
1 or 2 seem to be ignored bothers me.

Here is a reproducible example:

print(load(url("http://code.cjb.net/temp/pov.temp.RData")))
new.fit <- glmer(poverty.third.year ~ cluster.new + (0 + cluster.new | country), family = binomial("logit"), data = my.clean, verbose=TRUE, start = fit at ST, control = list(maxIter = 1))
## next version is without any the START parameter, gives the same results
same.fit <- glmer(poverty.third.year ~ cluster.new + (0 + cluster.new | country), family = binomial("logit"), data = my.clean, verbose=TRUE, control = list(maxIter = 1))

0:     84640.129: 0.0333944 0.0606318 0.127188 0.187698 0.208167 0.127188 0.136374 0.132420 0.0548662 0.0820451 0.0359463 0.0790974 0.103937 0.0831006 0.141804 0.0908405 0.202908 0.166600 0.0922003 0.00000 0.00000 0.00000 0.00000 0.00000 0.00000 0.00000 0.00000 0.00000 0.00000 0.00000 0.00000 0.00000 0.00000 0.00000 0.00000 0.00000 0.00000 0.00000 0.00000 0.00000 0.00000 0.00000 0.00000 0.00000 0.00000 0.00000 0.00000 0.00000 0.00000 0.00000 0.00000 0.00000 0.00000 0.00000 0.00000 0.00000 0.00000 0.00000 0.00000 0.00000 0.00000 0.00000 0.00000 0.00000 0.00000 0.00000 0.00000 0.00000 0.00000 0.00000 0.00000 0.00000 0.00000 0.00000 0.00000 0.00000 0.00000 0.00000 0.00000 0.00000 0.00000 0.00000 0.00000 0.00000 0.00000 0.00000 0.00000 0.00000 0.00000 0.00000 0.00000 0.00000 0.00000 0.00000 0.00000 0.00000 0.00000 0.00000 0.00000 0.00000 0.00000 0.00000 0.00000 0.00000 0.00000 0.00000 0.00000 0.00000 0.00000 0.00000 0.00000 0.00000 0.00000 0.00000 0.00000 0.00000 0.00000 0.00000 0.00000 0.00000 0.00000 0.00000 0.00000 0.00000 0.00000 0.00000 0.00000 0.00000 0.00000 0.00000 0.00000 0.00000 0.00000 0.00000 0.00000 0.00000 0.00000 0.00000 0.00000 0.00000 0.00000 0.00000 0.00000 0.00000 0.00000 0.00000 0.00000 0.00000 0.00000 0.00000 0.00000 0.00000 0.00000 0.00000 0.00000 0.00000 0.00000 0.00000 0.00000 0.00000 0.00000 0.00000 0.00000 0.00000 0.00000 0.00000 0.00000 0.00000 0.00000 0.00000 0.00000 0.00000 0.00000 0.00000 0.00000 0.00000 0.00000 0.00000 0.00000 0.00000 0.00000 0.00000 0.00000 0.00000 0.00000 0.00000 0.00000 0.00000 0.00000 0.00000 -3.41236 1.10942 1.26444 0.858302 1.75413 0.803890 1.13893 1.50687 2.32667 2.32665 1.54532 1.75338 1.95685 1.56899 0.783202 1.89733 3.27437 1.54379 2.75832

[...]

Warning messages:
1: In is.na(x) : is.na() applied to non-(list or vector) of type 'NULL'
2: In mer_finalize(ans) : iteration limit reached without convergence (9)

The REML value of the first iteration 84640.129 is much higher than
the REML value of iteration 300 that gave the fit, used as input:

300:     83537.084: 0.519965 0.143416 0.510886 0.390266 0.0253851 0.228085  0.00000  0.00000 0.175437 0.167589 0.000151413 0.257648  0.00000  0.00000  0.00000  0.00000  0.00000  0.00000  0.00000 0.662743 0.697672 0.0943584 0.238029 0.465242 0.264901 0.177211 -0.255314 0.297930 -0.0908047 0.234670 0.232733 0.0640540 0.0191507 -0.207110 0.370959 0.639145 0.275867 -1.61519  1.14158 -0.519320 -0.0995158 -0.00705858 -0.495069 -0.995847 -0.259104 -0.751779 -0.613690 -0.281145 -0.633951 -0.128201 -2.07103  2.11410 0.817327  1.09840 0.287138 -0.699452 0.511890 -0.227955 0.293735 0.443935 -0.107533 -0.159424 -0.380081 -0.0856487 0.271927 -0.419327 0.200206 0.0556932 -0.373988 0.219712  1.11540 -0.204753 -0.250565 0.227195 0.338191 0.0638902 0.381680 0.347678 0.656791 0.610805 0.286053 0.387693 0.0700578 0.311415 0.216640 -1.43990  8.21723 -0.0677624 -1.82260  1.98123  8.53073 -1.47762  4.62704  9.22425  16.0583  9.00298 0.610718  6.34499 0.114604 -0.268301 0.659427 0.0675373 0.223978 -0.314364 0.242165 -0.0398588 0.00348154 0.390582 0.205796 0.314690 -0.0210720 0.359508 0.0102215 0.0133513 -0.0249899 0.00303007 0.00104005 -0.00199693 -0.0162271 -0.00910787 -0.000721493 -0.00571186 -0.0221484 0.00132736 -0.00938054 -0.0559509 0.000625754 -0.0151419 -0.0342182 -0.0301707 -0.00874410 -0.0166841 -0.0118311 -0.0150344 -0.0455952 0.334382  1.62474 0.592823 -0.0838088 -0.0622300 -0.0477605 0.568942 -0.379506 -0.957889 -0.671352 -0.158491 -0.330145 0.269097 -0.316426 -1.04228 0.196337 -0.639169 -0.646029 -0.246746  1.11005  1.86385 0.428263  3.28910 0.565427 -0.285010 0.206211 -0.353546 0.913265 -0.534973 0.445224 -1.18672 -0.372053 -0.804367 -0.418456 -0.681271 0.0606201 0.0683290 0.685260 0.201087 -0.736270 -0.444255 -0.509914 -0.286142 -0.484370 -0.395121 -0.482115 0.300839 -0.444407 -0.444848 -0.0528026 -0.751176 0.670575 -0.0569850 -0.0616133 0.343210 -3.71098  1.26284  1.37018  1.13882  1.86587  1.14523  1.35873  1.81718  2.69451  2.54993  1.81382  1.97416  2.14052  1.94535 0.989847  2.04325  3.65850  1.65551  3.04955

reference, the relevant part of ?lmer:

start a named list of starting values for the parameters in the model.
 If the list is of the same form as the ST slot, it is becomes
 the starting values of the ST slot. If the list contains
 components named fixef and/or ST, these are used as the starting
 values for those slots. (Setting starting values for fixef has
 no effect for a linear mixed model because the fixed-effects
 parameters do not appear in the profiled deviance.) In lmer and
 glmer a numeric start argument of the appropriate length is used
 as the starting value of the parameter vector that determines
 the ST slot. In nlmer a numeric start argument is used as the
 starting values of the fixef slot.