[R] Stopping criterion in option control of BBsolve( )

2011-08-15 Thread Tingting Zhan
Dear Dr. Gilbert, Dr. Varadhan and all R-help list members,

I'm using the function BBsolve( ) and I have some questions on the stopping
criterion maxit and noimp specified in the option control. Here
are two such examples I'm having problem with.In these two examples, the
function BBsolve( ) always stops at iteration 100, overlooking the values I
specified in control.

Any advise are greatly appreciated!

Sincerely yours,
Tingting Zhan




Example 1:

The equation tst.fn() returns vector-0 after 2 seconds of running.   I think
I should have the BBsolve() function run about 2 seconds and then
successfully converge.   I specified maxit and noimp as large as 1.
 However, the BBsolve function returns nonconvergence only after 0.25
seconds and after 100 iterations.

 tst.fn = function(x)
  {
if((proc.time() - R.ptm)[3]  2) { cat(overtime.\n); return(c(0,0));
}
else { return(c(2,2)); }
  }

 system.time( { R.ptm = proc.time();   tst = BBsolve(par=c(1,1), fn =
tst.fn , control = list(maxit = 1, noimp=1)) } )

Unsuccessful convergence.
   user  system elapsed
   0.250.000.25

 tst
$par
[1] 0.5 0.6
$residual
[1] 2
$fn.reduction
[1] 0
$feval
[1] 186
$iter
[1] 100
$convergence
[1] 5
$message
[1] Lack of improvement in objective function
$cpar
method  M NM
 2 50  1







Example 2:

The equation tst.fn() returns a constant vector c(2,2), thus it will never
converge.   I specified maxit = 1000 and noimp=10, however the BBsolve()
function stops at iteration 100, as I'm unclear where does the number 100
comes from.

 tst.fn = function(x) { c(2,2) }

 system.time( { tst = BBsolve(par=c(1,1), fn = tst.fn , control =
list(maxit = 1000, noimp=20)) } )

  Unsuccessful convergence.
   user  system elapsed
   0.160.000.15

 tst
$par
[1] 1 1
$residual
[1] 2
$fn.reduction
[1] 0
$feval
[1] 186
$iter
[1] 100
$convergence
[1] 5
$message
[1] Lack of improvement in objective function
$cpar
method  M NM
 2 50  1

abc

[[alternative HTML version deleted]]

__
R-help@r-project.org mailing list
https://stat.ethz.ch/mailman/listinfo/r-help
PLEASE do read the posting guide http://www.R-project.org/posting-guide.html
and provide commented, minimal, self-contained, reproducible code.


[R] [R-lme] Extract estimated variances from output of lme?

2010-12-01 Thread Tingting Zhan
Hi all,

I have the output of summary() of an lme object called lme.exp1, for
example

#
 summary(lme.exp1)

Linear mixed-effects model fit by REML
  Data: DATA
  Log-restricted-likelihood: -430.8981
  Fixed: fixed.exp1


Random effects:
 Formula: ~-1 + mu1 + log.sig1 | animID
 Structure: Diagonal
 mu1  log.sig1 Residual
StdDev: 2.605223 0.1013134 3.876431

Correlation Structure: General
 Formula: ~1 | animID/fieldN
 Parameter estimate(s):
 Correlation:
  1
2 0.612
Variance function:
 Structure: Different standard deviations per stratum
 Formula: ~1 | type
 Parameter estimates:
   mu1   log.sig1
1. 0.03722675
Number of Observations: 376
Number of Groups: 32
##

If I want to reuse these estimates, I can use

 summary(lme.exp1)$coefficients$fixed;

to extract fixed effect estimates, and

  summary(lme.exp1)$sigma

for the common variance parameter sigma.   But if I need the covariance
estimates 0.612 and 0.0372, do I have a function to extract these numbers
too?   I'm looking for something similar to function ranef() [of course
ranef() does not serve my purpose].  Any advice appreciated!

Tingting

[[alternative HTML version deleted]]

__
R-help@r-project.org mailing list
https://stat.ethz.ch/mailman/listinfo/r-help
PLEASE do read the posting guide http://www.R-project.org/posting-guide.html
and provide commented, minimal, self-contained, reproducible code.