[R] stop criteria when L-BFGS-B needs finite values of 'fn' in optim

2007-07-30 Thread Dae-Jin Lee
Hi all!

I'm running some simulations and I need to estimate some paramaters with
optim( ),
 in some cases optim stops with the next message:

   L-BFGS-B needs finite values of 'fn' 

I would like to know how to include and if condition when this happen,
could it be something like:

myfun - optim() #   run my function


if(myfun == ERROR) . #   when the error message is L-BFGS-B needs
finite values of 'fn'


I've succesfully achieved when, for example convergence is not reached,

if(myfun$convergence != 0)

but I don't know how to do it in the other case

Any help??


Thanks in advance,

Dae-Jin



-- 
__

Dae-Jin Lee
Despacho: 7.3.J04
Tlfno: 91 624 9175
Fax:  91 624 9430
Departamento de Estadística
Av. Universidad 30, Ed. Juan Benet
28911 Leganés (Madrid)
Universidad Carlos III de Madrid

e-mail: [EMAIL PROTECTED]
   web: http://www.est.uc3m.es/daejin
__

[[alternative HTML version deleted]]

__
R-help@stat.math.ethz.ch 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] optim(), nlminb() and starting values

2007-03-06 Thread Dae-Jin Lee
Hi all !

I've been trying to maximize a likelihood using optim( ) function, but it
seems that the function has several local maxima. I've tried in my algorithm
with different starting values and depending on them optim obtains
different results...

I use the L-BFGS-B method setting the lower values as 1e-06, because my
parameters must be strictly positive. Also tried a log() transformation to
ensure that my parameters are positive. Don't know if this is useful in this
case... (also with notLog and notExp functions of mgcv package)

the function nlminb( ) also have the same problems.


¿Is there any thing I'm not considering? I mean other methods instead of
L-BFGS-B?

How can I do to take a strategy to begin with good starting values?


Thanks in advance

Dae-Jin

PS: I'm trying to fit a mixed model with REML and several random effects, so
I maximize over several parameters...

[[alternative HTML version deleted]]

__
R-help@stat.math.ethz.ch 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.


Re: [R] R2WinBugs and Compare DIC versus BIC or AIC

2007-01-15 Thread Dae-Jin Lee
Thanks for your answer !

But If I have understood correctly, the procedure is correct and this only
means that I have already generated the initial values

From R. I define a function to generate the initial values as:

inits. - function(){list(sdesp=runif(1),sdhet=runif(1),beta0=runif(1),
beta1=runif(1), b=rnorm(n), phi=rnorm(n))}


then It is not necessary to generate initial values, that why gen.inits() is
greyed out
, is it ok?

Here is what Winbugs show

==

display(log)
check(D:/model.txt)
model is syntactically correct
data(D://data.txt)
data loaded
compile(3)
model compiled
inits(1,D:/inits1.txt)
chain initialized but other chain(s) contain uninitialized variables
inits(2,D:/inits2.txt)
chain initialized but other chain(s) contain uninitialized variables
inits(3,D:/inits3.txt)
model is initialized
gen.inits()
command #Bugs:gen.inits cannot be executed (is greyed out)
thin.updater(1)
update(5000)

==

Thank again in advance

Dae-Jin

2007/1/13, Uwe Ligges [EMAIL PROTECTED] :



 Dae-Jin Lee wrote:
  Dear All
 
  1)
 
  I'm fitting spatial CAR models
 
  using R2Winbugs and although everything seems to go reasonably well (or
 I
  think so)
 
  the next message appears from WINBUGS 1.4 window:
 
  gen.inits()
  Command #Bugs: gen.inits cannot be executed (is greyed out)

 greyed out refers to the corresponding GUI. In this case it could mean
 that either your preparations before were not successful or you have
 already specified all initial values and no further have to be
 generated. But this is a WinBUGS question and not R related.

 Perhaps you have transposed some matrix? This is always extremely
 confusing ...


  The question is if this message means that something is wrong and the
  results are consequently wrong, or Can I assume it as a simple warning
  message???...
 
  I've tried to fit the model using just WinBugs (not calling form R) and
  gen.inits command is available and the results obtain are practically
 the
  same...
 
  2)
 
  The other question is, once several bayesian CAR models are fitted I use
 DIC
  to model selection
 
  How can I compare DIC with AIC or BIC obtain for a spatial glm? I mean
 for
  example:
 
  - DIC of 300 and Pd of 32
 
  versus
 
  - BIC of 220 and Effective dimension (measured of trace of hat matrix)
 equal
  to 14
 
  * I've read that DIC is intended as a generalisation of Akaike's
 Information
  Criterion (AIC), but is it possible to compare them simply looking which
 is
  the lowest???


 Well they are intended to be compared (DIC with DIC, AIC with AIC, but
 do not mix them!) that way given you are comparing within the same class
 of models. And then, there is a bit of fortunetelling with all these
 information criterion, at least in my personal opinion (and I know that
 others disagree).

 Uwe Ligges


 
  Thanks,
 
  Dae-Jin Lee
 
[[alternative HTML version deleted]]
 
  __
  R-help@stat.math.ethz.ch 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.


[[alternative HTML version deleted]]

__
R-help@stat.math.ethz.ch 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] R2WinBugs and Compare DIC versus BIC or AIC

2007-01-12 Thread Dae-Jin Lee
Dear All

1)

I'm fitting spatial CAR models

using R2Winbugs and although everything seems to go reasonably well (or I
think so)

the next message appears from WINBUGS 1.4 window:

gen.inits()
Command #Bugs: gen.inits cannot be executed (is greyed out)

The question is if this message means that something is wrong and the
results are consequently wrong, or Can I assume it as a simple warning
message???...

I've tried to fit the model using just WinBugs (not calling form R) and
gen.inits command is available and the results obtain are practically the
same...

2)

The other question is, once several bayesian CAR models are fitted I use DIC
to model selection

How can I compare DIC with AIC or BIC obtain for a spatial glm? I mean for
example:

- DIC of 300 and Pd of 32

versus

- BIC of 220 and Effective dimension (measured of trace of hat matrix) equal
to 14

* I've read that DIC is intended as a generalisation of Akaike's Information
Criterion (AIC), but is it possible to compare them simply looking which is
the lowest???


Thanks,

Dae-Jin Lee

[[alternative HTML version deleted]]

__
R-help@stat.math.ethz.ch 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.