Re: [Rd] NaN in R distribution functions

2005-12-29 Thread Gregor Gorjanc
Prof Brian Ripley wrote:
> On Wed, 28 Dec 2005, Gregor Gorjanc wrote:
> 
>> Dear R developers,
>>
>> I noticed that core R distribution functions return NaN, when parameter
>> values are out of parameter space. I have looked in source code and
>> found that warnings and return of NaN are done internally in C code. For
>> dgamma.c the line 49 is:
>>
>> if (shape <= 0 || scale <= 0) ML_ERR_return_NAN;
>>
>> OK. How should this be implemented if distribution functions are written
>> directly in R? I came up with this
>>
>> if (any(shape <= 0)) {
>> warning("shape must be positive")
>> return(NaN)
>> }
> 
> 
> As the R-level code is vectorized, NaN is unlikely to be the appropriate 
> return value. You will find that only the relevant entries are NaN, for 
> example
> 
>> dgamma(1, shape=-1:2)
> 
> [1]   NaN   NaN 0.3678794 0.3678794
> Warning message:
> NaNs produced in: dgamma(x, shape, scale, log)
>

Yes, you are right.

>> I think that it would be nice that returning NaN for undefined parameter
>> values in distribution functions would also be documented in Writing R
>> Extension.
> 
> It is purely a convention for use in the standalone libRmath with which 
> the code is shared.  Otherwise returning NA or giving an error would 
> seem more appropriate.
> 
> `Writing R Extensions' does not cover writing distribution functions, 
> and is certainly not intended to mandate how such extensions are written.

I understand, however it would be really nice to have some guideline so 
that developers would write more or less similar code. I had a problem 
with one such functions, since it stopped if parameters values were out 
of parameter space. I used that function in optim() and it was 
annoyingly stopping the optimization. It was not much to change the 
function to return NaN (this could be as well NA as you have pointed 
out), but it would be nice that this would be the default.

-- 
Lep pozdrav / With regards,
 Gregor Gorjanc

--
University of Ljubljana PhD student
Biotechnical Faculty
Zootechnical Department URI: http://www.bfro.uni-lj.si/MR/ggorjan
Groblje 3   mail: gregor.gorjanc  bfro.uni-lj.si 

SI-1230 Domzale tel: +386 (0)1 72 17 861
Slovenia, Europefax: +386 (0)1 72 17 888 

--
"One must learn by doing the thing; for though you think you know it,
  you have no certainty until you try." Sophocles ~ 450 B.C.

__
R-devel@r-project.org mailing list
https://stat.ethz.ch/mailman/listinfo/r-devel


[Rd] reinventing the wheel....

2005-12-29 Thread A.J. Rossini
> -- Forwarded message --
> From: Byron Ellis <[EMAIL PROTECTED]>

> If we wanted to be truly radical we'd just accept that graphics
> devices and event loops are just special cases of the connection and
> merge the whole thing, thus more-or-less reinventing CLIM. :-)

Eventually, all programming languages grow up and become Lisp.

(progress, progress, and more joyful progress on CLS).

best,
-tony

[EMAIL PROTECTED]
Muttenz, Switzerland.
"Commit early,commit often, and commit in a repository from which we can easily
roll-back your mistakes" (AJR, 4Jan05).

__
R-devel@r-project.org mailing list
https://stat.ethz.ch/mailman/listinfo/r-devel


[Rd] Problems with calloc function.

2005-12-29 Thread Marcelo Damasceno
Hi all,

I have a C code in Linux, it has 7 pointers and compile e run OK, but when I
run in R happens problems with calloc function, it returns NULL.
###
> int *temp1,*temp2,*temp3,*temp4;

 temp1 = (int *)calloc(col,sizeof(int));
if(temp1 == NULL){
 printf("\n\n No Memory1!");
 exit(1);
}

  temp2 = (int *)calloc(col,sizeof(int));
  if(temp2 == NULL){
>printf("\n\n No Memory2!");
>exit(1);
}

temp3 = (int *)calloc(col,sizeof(int));
if(temp3 == NULL){
>printf("\n\n No Memory3!");
>exit(1);
}

temp4 = (int *)calloc(col,sizeof(int));
if(temp4 == NULL){
printf("\n\n No Memory4!");
exit(1);
}

int *cvector;
cvector = (int *)calloc(col,sizeof(int));
if(cvector == NULL){
printf("\n\n No Memory5!");
exit(1);
}

tam=ntam;

int **matrix;
matrix=(int**)calloc(row,sizeof(int*));
if(matrix == NULL){
printf("\n\n No Memory6!");
exit(1);
}

temp=(int*)calloc(tam,sizeof(int));
if(temp == NULL){
printf("\n\n No Memory7!");
exit(1);
}

iia = (int *)calloc(row-1,sizeof(int));
if(iia == NULL){
printf("\n\n No Memory8!");
exit(1);
}

iib = (int *)calloc(row-1,sizeof(int));
if(iib == NULL){
printf("\n\n No Memory9!");
exit(1);
}

In output !
> No Memory5!
>[EMAIL PROTECTED] home] $

What's wrong?
Thanks!

--
Marcelo Damasceno de Melo
Graduando em Ciência da Computação
Departamento de Tecnologia da Informação - TCI
Universidade Federal de Alagoas - UFAL
Maceió - Alagoas - Brasil
Projeto CoCADa - Construção do Conhecimento por Agrupamento de dados
+55 82 8801-2119

[[alternative HTML version deleted]]

__
R-devel@r-project.org mailing list
https://stat.ethz.ch/mailman/listinfo/r-devel


Re: [Rd] Problems with calloc function.

2005-12-29 Thread Prof Brian Ripley
Rather than trying to reinvent the wheel, why not make use of the 
functions documented in Writing R Extensions, especially Calloc/Free?


And definitely do not call exit() from code linked into R: it is 
antisocial behaviour to terminate your host's process.


Your example is incomplete, and for some values of 'col' you will run out 
of memory.  (It is also not legal C as written, since you mix code and 
declarations.)


On Thu, 29 Dec 2005, Marcelo Damasceno wrote:


Hi all,

I have a C code in Linux, it has 7 pointers and compile e run OK, but when I
run in R happens problems with calloc function, it returns NULL.
###

int *temp1,*temp2,*temp3,*temp4;


temp1 = (int *)calloc(col,sizeof(int));
if(temp1 == NULL){
printf("\n\n No Memory1!");
exit(1);
}

 temp2 = (int *)calloc(col,sizeof(int));
 if(temp2 == NULL){
   >printf("\n\n No Memory2!");
   >exit(1);
   }

   temp3 = (int *)calloc(col,sizeof(int));
   if(temp3 == NULL){
   >printf("\n\n No Memory3!");
   >exit(1);
   }

   temp4 = (int *)calloc(col,sizeof(int));
   if(temp4 == NULL){
   printf("\n\n No Memory4!");
   exit(1);
   }

   int *cvector;
   cvector = (int *)calloc(col,sizeof(int));
   if(cvector == NULL){
   printf("\n\n No Memory5!");
   exit(1);
   }

   tam=ntam;

   int **matrix;
   matrix=(int**)calloc(row,sizeof(int*));
   if(matrix == NULL){
   printf("\n\n No Memory6!");
   exit(1);
   }

   temp=(int*)calloc(tam,sizeof(int));
   if(temp == NULL){
   printf("\n\n No Memory7!");
   exit(1);
   }

   iia = (int *)calloc(row-1,sizeof(int));
   if(iia == NULL){
   printf("\n\n No Memory8!");
   exit(1);
   }

   iib = (int *)calloc(row-1,sizeof(int));
   if(iib == NULL){
   printf("\n\n No Memory9!");
   exit(1);
   }

In output !

No Memory5!
[EMAIL PROTECTED] home] $


What's wrong?
Thanks!

--
Marcelo Damasceno de Melo
Graduando em Ciência da Computação
Departamento de Tecnologia da Informação - TCI
Universidade Federal de Alagoas - UFAL
Maceió - Alagoas - Brasil
Projeto CoCADa - Construção do Conhecimento por Agrupamento de dados
+55 82 8801-2119

[[alternative HTML version deleted]]




--
Brian D. Ripley,  [EMAIL PROTECTED]
Professor of Applied Statistics,  http://www.stats.ox.ac.uk/~ripley/
University of Oxford, Tel:  +44 1865 272861 (self)
1 South Parks Road, +44 1865 272866 (PA)
Oxford OX1 3TG, UKFax:  +44 1865 272595__
R-devel@r-project.org mailing list
https://stat.ethz.ch/mailman/listinfo/r-devel


Re: [Rd] 'sessionInfo()' instead of 'version'

2005-12-29 Thread roger koenker

In a private response to Tony Plate's suggestion to replace version()
output with sessionInfo() in R-help requests,

> roger koenker wrote:
>> Thanks for this, it would seem useful to have version numbers for
>> the packages too?

and Tony replied,
>
> Sounds sensible to me!  If I were you I'd send a message to R-devel  
> suggesting this.  AFAIK, some changes to sessionInfo() are already  
> being considered, so this is a good time to suggest that.

So, for what it is worth

Roger

PS  My notion is that it is sometimes useful to document the state of  
play
when a particular object was created, much like the recent thread on
date stamping of objects in R-help.

url:www.econ.uiuc.edu/~rogerRoger Koenker
email[EMAIL PROTECTED]Department of Economics
vox: 217-333-4558University of Illinois
fax:   217-244-6678Champaign, IL 61820

__
R-devel@r-project.org mailing list
https://stat.ethz.ch/mailman/listinfo/r-devel


Re: [Rd] 'sessionInfo()' instead of 'version'

2005-12-29 Thread Duncan Murdoch
On 12/29/2005 3:07 PM, roger koenker wrote:
> In a private response to Tony Plate's suggestion to replace version()
> output with sessionInfo() in R-help requests,
> 
> 
>>roger koenker wrote:
>>
>>>Thanks for this, it would seem useful to have version numbers for
>>>the packages too?
> 
> 
> and Tony replied,
> 
>>Sounds sensible to me!  If I were you I'd send a message to R-devel  
>>suggesting this.  AFAIK, some changes to sessionInfo() are already  
>>being considered, so this is a good time to suggest that.
> 
> 
> So, for what it is worth
> 
> Roger
> 
> PS  My notion is that it is sometimes useful to document the state of  
> play
> when a particular object was created, much like the recent thread on
> date stamping of objects in R-help.

I'm not sure what you're asking for.  This is what I see in R-patched; 
it's very similar to what 2.1.1 shows:

 > sessionInfo()
R version 2.2.1, 2005-12-27, i386-pc-mingw32

attached base packages:
[1] "splines"   "methods"   "stats" "graphics"  "grDevices" "utils"
[7] "datasets"  "base"

other attached packages:
multtest survival
  "1.8.0"   "2.20"

There's no point showing the versions of base packages, because they 
match the R version.  What other information would you like to see?

So far the following reasonable suggestions have been made.  I forget 
where they were posted, so you may not have seen them:

  - the Subversion revision number, at least for non-released versions
  - the version number of the GUI, at least for OS X (where it changes 
independently of R).

Duncan Murdoch

__
R-devel@r-project.org mailing list
https://stat.ethz.ch/mailman/listinfo/r-devel


[Rd] Inconsistent IEEE 754/IEC 60559 rounding behavior (PR#8452)

2005-12-29 Thread Micah_Altman
Full_Name: Micah Altman
Version: 2.2
OS: Windows/Linux (RHELv3)
Submission from: (NULL) (71.243.63.53)


Documentation for round()/signif() indicates that  IEC 60559 standard is used, 
"_go to the even digit_" is used for rounding off a 5. However, signif(),
round() and sprintf() do not behave consistently -- rounding using round()
follows this rule, signif() does not, and sprintf() follows the rule on Linux
but not on Windows(): 

> version
 _  
platform x86_64-redhat-linux-gnu
arch x86_64 
os   linux-gnu  
system   x86_64, linux-gnu  
status  
major2  
minor2.0
year 2005   
month10 
day  06 
svn rev  35749  
language R  
> sessionInfo()
R version 2.2.0, 2005-10-06, x86_64-redhat-linux-gnu 

attached base packages:
[1] "methods"   "stats" "graphics"  "grDevices" "utils" "datasets" 
[7] "base"

> sprintf("%#.1g",as.double(0.25))
[1] "0.2"
> round(.25,digits=1)
[1] 0.2
> signif(.25,digits=1)   
[1] 0.3


> version
 _  
platform i386-pc-mingw32
arch i386   
os   mingw32
system   i386, mingw32  
status  
major2  
minor2.0
year 2005   
month10 
day  06 
svn rev  35749  
language R  
> sessionInfo()
R version 2.2.0, 2005-10-06, i386-pc-mingw32 

attached base packages:
[1] "methods"   "stats" "graphics"  "grDevices" "utils" "datasets" 
"base" 
> sprintf("%#.1g",as.double(0.25))
[1] "0.3"
> round(.25,digits=1)
[1] 0.2
> signif(.25,digits=1) 
[1] 0.3
>

__
R-devel@r-project.org mailing list
https://stat.ethz.ch/mailman/listinfo/r-devel


Re: [Rd] 'sessionInfo()' instead of 'version'

2005-12-29 Thread roger koenker
My fault,  what you show is exactly what I wanted...

url:www.econ.uiuc.edu/~rogerRoger Koenker
email[EMAIL PROTECTED]Department of Economics
vox: 217-333-4558University of Illinois
fax:   217-244-6678Champaign, IL 61820


On Dec 29, 2005, at 3:09 PM, Duncan Murdoch wrote:

> On 12/29/2005 3:07 PM, roger koenker wrote:
>> In a private response to Tony Plate's suggestion to replace version()
>> output with sessionInfo() in R-help requests,
>>> roger koenker wrote:
>>>
 Thanks for this, it would seem useful to have version numbers for
 the packages too?
>> and Tony replied,
>>> Sounds sensible to me!  If I were you I'd send a message to R- 
>>> devel  suggesting this.  AFAIK, some changes to sessionInfo() are  
>>> already  being considered, so this is a good time to suggest that.
>> So, for what it is worth
>> Roger
>> PS  My notion is that it is sometimes useful to document the state  
>> of  play
>> when a particular object was created, much like the recent thread on
>> date stamping of objects in R-help.
>
> I'm not sure what you're asking for.  This is what I see in R- 
> patched; it's very similar to what 2.1.1 shows:
>
> > sessionInfo()
> R version 2.2.1, 2005-12-27, i386-pc-mingw32
>
> attached base packages:
> [1] "splines"   "methods"   "stats" "graphics"  "grDevices"  
> "utils"
> [7] "datasets"  "base"
>
> other attached packages:
> multtest survival
>  "1.8.0"   "2.20"
>
> There's no point showing the versions of base packages, because  
> they match the R version.  What other information would you like to  
> see?
>
> So far the following reasonable suggestions have been made.  I  
> forget where they were posted, so you may not have seen them:
>
>  - the Subversion revision number, at least for non-released versions
>  - the version number of the GUI, at least for OS X (where it  
> changes independently of R).
>
> Duncan Murdoch

__
R-devel@r-project.org mailing list
https://stat.ethz.ch/mailman/listinfo/r-devel


Re: [Rd] 'sessionInfo()' instead of 'version'

2005-12-29 Thread Martin Maechler
> "roger" == roger koenker <[EMAIL PROTECTED]>
> on Thu, 29 Dec 2005 14:07:19 -0600 writes:

roger> In a private response to Tony Plate's suggestion to
roger> replace version() output with sessionInfo() in R-help
roger> requests,

>> roger koenker wrote:
>>> Thanks for this, it would seem useful to have version
>>> numbers for the packages too?

roger> and Tony replied,
>>  Sounds sensible to me!  If I were you I'd send a message
>> to R-devel suggesting this.  AFAIK, some changes to
>> sessionInfo() are already being considered, so this is a
>> good time to suggest that.

roger> So, for what it is worth

but the version numbers of the non-standard packages are
*there* -- so what do you mean ?

  > sessionInfo()
  R version 2.2.1, 2005-12-20, x86_64-unknown-linux-gnu 

  attached base packages:
  [1] "graphics"  "grDevices" "datasets"  "utils" "methods"   "stats"
  [7] "base" 

  other attached packages:
   cluster fortunes  sfsmisc 
  "1.10.2"  "1.2-0" "0.95-2" 
  >

__
R-devel@r-project.org mailing list
https://stat.ethz.ch/mailman/listinfo/r-devel


Re: [Rd] 'sessionInfo()' instead of 'version'

2005-12-29 Thread Seth Falcon
On 29 Dec 2005, [EMAIL PROTECTED] wrote:
> So far the following reasonable suggestions have been made.  I
> forget where they were posted, so you may not have seen them:
>
> - the Subversion revision number, at least for non-released versions
> - the version number of the GUI, at least for OS X (where it changes
> independently of R).

Perhaps it doesn't count as reasonable, but another suggestion (made
by me) was:

 - Include output of loadedNamespaces().

+ seth

__
R-devel@r-project.org mailing list
https://stat.ethz.ch/mailman/listinfo/r-devel


Re: [Rd] 'sessionInfo()' instead of 'version'

2005-12-29 Thread Duncan Murdoch
On 12/29/2005 5:13 PM, Seth Falcon wrote:
> On 29 Dec 2005, [EMAIL PROTECTED] wrote:
> 
>>So far the following reasonable suggestions have been made.  I
>>forget where they were posted, so you may not have seen them:
>>
>>- the Subversion revision number, at least for non-released versions
>>- the version number of the GUI, at least for OS X (where it changes
>>independently of R).
> 
> 
> Perhaps it doesn't count as reasonable, but another suggestion (made
> by me) was:
> 
>  - Include output of loadedNamespaces().

I didn't see that one (or forgot I did), its omission wasn't an 
editorial judgement.

Duncan Murdoch

__
R-devel@r-project.org mailing list
https://stat.ethz.ch/mailman/listinfo/r-devel


[Rd] 'last.warning' problem at startup; package Matrix (PR#8453)

2005-12-29 Thread winjohn
On starting an R session, I get the messages:

  Fatal errir: unable to restore save data in .RData

  Error in fun(...): couldn't find function "assignInNamespace"

  Error: .onLoad failed in 'loadNamespace' for 'Matrix'

The only object in my .RData is last.warning, thus:

  > last.warning
  $"optim or nlminb returned message false convergence (8)"
  "LMEoptimize<-"(`*tmp*`, value = list(maxIter = 200, tolerance = 
1.49011611938477e-08,
  msMaxIter = 200, msVerbose = 0, niterEM = 15, EMverbose = FALSE,
  PQLmaxIt = 30, analyticGradient = TRUE, analyticHessian = FALSE))

This was generated by a call, in a previous session,to lmer()
There may be a problem with the package Matrix, but it seems a bit
extreme that this prevents restoration of the session.

John Maindonald
[EMAIL PROTECTED]

--please do not edit the information below--

Version:
 platform = i386-pc-mingw32
 arch = i386
 os = mingw32
 system = i386, mingw32
 status =
 major = 2
 minor = 2.1
 year = 2005
 month = 12
 day = 20
 svn rev = 36812
 language = R

Windows XP Home Edition (build 2600) Service Pack 2.0

Locale:
LC_COLLATE=English_Australia.1252;LC_CTYPE=English_Australia.1252;LC_MONETARY=English_Australia.1252;LC_NUMERIC=C;LC_TIME=English_Australia.1252

Search Path:
 .GlobalEnv, package:methods, package:stats, package:graphics, 
package:grDevices, package:utils, package:datasets, Autoloads, package:base

__
R-devel@r-project.org mailing list
https://stat.ethz.ch/mailman/listinfo/r-devel


Re: [Rd] 'sessionInfo()' instead of 'version'

2005-12-29 Thread Prof Brian Ripley
Are there known instances of this helping the diagnosis of a problem?

My impression is that more details of the OS/compilers used is the thing 
which is most commonly needed to help with remote diagnosis.

On Thu, 29 Dec 2005, Seth Falcon wrote:

> On 29 Dec 2005, [EMAIL PROTECTED] wrote:
>> So far the following reasonable suggestions have been made.  I
>> forget where they were posted, so you may not have seen them:
>>
>> - the Subversion revision number, at least for non-released versions
>> - the version number of the GUI, at least for OS X (where it changes
>> independently of R).
>
> Perhaps it doesn't count as reasonable, but another suggestion (made
> by me) was:
>
> - Include output of loadedNamespaces().
>
> + seth
>
> __
> R-devel@r-project.org mailing list
> https://stat.ethz.ch/mailman/listinfo/r-devel
>
>

-- 
Brian D. Ripley,  [EMAIL PROTECTED]
Professor of Applied Statistics,  http://www.stats.ox.ac.uk/~ripley/
University of Oxford, Tel:  +44 1865 272861 (self)
1 South Parks Road, +44 1865 272866 (PA)
Oxford OX1 3TG, UKFax:  +44 1865 272595

__
R-devel@r-project.org mailing list
https://stat.ethz.ch/mailman/listinfo/r-devel


Re: [Rd] 'last.warning' problem at startup; package Matrix (PR#8453)

2005-12-29 Thread ripley
This *is* a bug in package Matrix and yes, bugs in packages can be bad 
enough to stop a saved image (sic) being loaded.  You could have started R 
--no-restore and load()ed it later.

Matrix has several uses of assignInNamespace in .onLoad and .onUnload, and 
that is in package utils and so not necessarily loaded.  Try loading 
Matrix with R_DEFAULT_PACKAGES=NULL to reproduce this.

R-bugs was not the appropriate place to report this, as the FAQ makes 
quite clear.

On Thu, 29 Dec 2005 [EMAIL PROTECTED] wrote:

> On starting an R session, I get the messages:
>
>  Fatal errir: unable to restore save data in .RData
>
>  Error in fun(...): couldn't find function "assignInNamespace"
>
>  Error: .onLoad failed in 'loadNamespace' for 'Matrix'
>
> The only object in my .RData is last.warning, thus:
>
>  > last.warning
>  $"optim or nlminb returned message false convergence (8)"
>  "LMEoptimize<-"(`*tmp*`, value = list(maxIter = 200, tolerance =
> 1.49011611938477e-08,
>  msMaxIter = 200, msVerbose = 0, niterEM = 15, EMverbose = FALSE,
>  PQLmaxIt = 30, analyticGradient = TRUE, analyticHessian = FALSE))
>
> This was generated by a call, in a previous session,to lmer()
> There may be a problem with the package Matrix, but it seems a bit
> extreme that this prevents restoration of the session.
>
> John Maindonald
> [EMAIL PROTECTED]
>
> --please do not edit the information below--
>
> Version:
> platform = i386-pc-mingw32
> arch = i386
> os = mingw32
> system = i386, mingw32
> status =
> major = 2
> minor = 2.1
> year = 2005
> month = 12
> day = 20
> svn rev = 36812
> language = R
>
> Windows XP Home Edition (build 2600) Service Pack 2.0
>
> Locale:
> LC_COLLATE=English_Australia.1252;LC_CTYPE=English_Australia.1252;LC_MONETARY=English_Australia.1252;LC_NUMERIC=C;LC_TIME=English_Australia.1252
>
> Search Path:
> .GlobalEnv, package:methods, package:stats, package:graphics,
> package:grDevices, package:utils, package:datasets, Autoloads, package:base
>
> __
> R-devel@r-project.org mailing list
> https://stat.ethz.ch/mailman/listinfo/r-devel
>
>

-- 
Brian D. Ripley,  [EMAIL PROTECTED]
Professor of Applied Statistics,  http://www.stats.ox.ac.uk/~ripley/
University of Oxford, Tel:  +44 1865 272861 (self)
1 South Parks Road, +44 1865 272866 (PA)
Oxford OX1 3TG, UKFax:  +44 1865 272595

__
R-devel@r-project.org mailing list
https://stat.ethz.ch/mailman/listinfo/r-devel


[Rd] Acknowledgments in package documentation

2005-12-29 Thread Jeff Enos
R-devel,

I've received permission from a third party to incorporate some of
their data in a data set in my 'portfolio' package.  I'd like to
include an acknowledgment of the third party, and perhaps a "used with
permission" somewhere in the package documentation.

Where's the best spot in the package docs for such an acknowledgment?
Is there a place preferable to the \description or \source sections of
the data set's .Rd file?

Thanks in advance,

Jeff

__
R-devel@r-project.org mailing list
https://stat.ethz.ch/mailman/listinfo/r-devel