[Rd] documentation bug for isoreg example (PR#10352)

2007-10-18 Thread btyner
Full_Name: Benjamin Tyner
Version: 2.6.0 (43063)
OS: WinXP
Submission from: (NULL) (171.161.224.10)


At the end of the examples for isoreg, there is

   cat("R^2 =", formatC(sum(residuals(ir4)^2) / (9*var(y4)), digits=2),"\n")

I think this should be

   cat("R^2 =", formatC(1 - sum(residuals(ir4)^2) / (9*var(y4)), digits=2),"\n"

Thanks
Ben

platform   i386-pc-mingw32 
arch   i386
os mingw32 
system i386, mingw32   
status 
major  2   
minor  6.0 
year   2007
month  10  
day03  
svn rev43063   
language   R   
version.string R version 2.6.0 (2007-10-03)

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


[Rd] nmle: gnls freezes on difficult case

2007-10-18 Thread Nicholas Lewin-Koh
Hi,
Following up on my own post, if in gnlsControl I specify
opt='optim' gnls exits quite nicely, with an error, which
is what I would expect. Is this a bug in nlminb?

Nicholas


tt<-gnls(response~SSllogis(conc,A,B,xmid,scal),tdat,start=start,weights=varPower(),verbose=TRUE,control=gnlsControl(opt='optim'))
**Iteration 1
GLS step: Objective: 29.04254varStruct  parameters:
power 
0.3373206 

NLS step: RSS =  0 
 model parameters:-0.799941  8.99983  -0.522623  212.314  
 iterations: 2 

Convergence:
   params varStruct 
 1.172208  1.00 
Error in optim(c(coef(gnlsSt)), function(gnlsPars) -logLik(gnlsSt,
gnlsPars),  : 
  initial value in 'vmmin' is not finite
In addition: Warning messages:
1: In log(xmid) : NaNs produced
2: In log(xmid) : NaNs produced
3: In log(xmid) : NaNs produced

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


Re: [Rd] nmle: gnls freezes on difficult case

2007-10-18 Thread Prof Brian Ripley
On Thu, 18 Oct 2007, Nicholas Lewin-Koh wrote:

> Hi,
> Following up on my own post, if in gnlsControl I specify
> opt='optim' gnls exits quite nicely, with an error, which
> is what I would expect. Is this a bug in nlminb?

Possibly, but complex algorithms can loop for non-bug reasons.  I don't 
feel motivated to explore it in detail, but if you want/are able to, 
please let us know what you find.

I have always found optim to work better in package nlme than nlminb (and 
I know others who have the same experience).

>
> Nicholas
>
>
> tt<-gnls(response~SSllogis(conc,A,B,xmid,scal),tdat,start=start,weights=varPower(),verbose=TRUE,control=gnlsControl(opt='optim'))
> **Iteration 1
> GLS step: Objective: 29.04254varStruct  parameters:
>power
> 0.3373206
>
> NLS step: RSS =  0
> model parameters:-0.799941  8.99983  -0.522623  212.314
> iterations: 2
>
> Convergence:
>   params varStruct
> 1.172208  1.00
> Error in optim(c(coef(gnlsSt)), function(gnlsPars) -logLik(gnlsSt,
> gnlsPars),  :
>  initial value in 'vmmin' is not finite
> In addition: Warning messages:
> 1: In log(xmid) : NaNs produced
> 2: In log(xmid) : NaNs produced
> 3: In log(xmid) : NaNs produced
>
> __
> 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] nmle: gnls freezes on difficult case

2007-10-18 Thread Nicholas Lewin-Koh
Hi,
I was just able to try this on a windows xp machine
using R-2.5.1. gnls exits gracefully with an error 
so maybe this is a problem with my R installation. If 
so sorry to bother everyone. Does anyone have an idea
which installation parameters to tweek that might cure
this?

Thanks
Nicholas

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


Re: [Rd] nmle: gnls freezes on difficult case

2007-10-18 Thread Nicholas Lewin-Koh
Hi,
Thank you for the pointer, I will make the default in my code optim.
As I specified in my last post it may be my installation. In this
case the problem is that the third parameter (xmid) goes negative and 
the log(xmid) fails in the parameterization I am using. For some
reason nlminb is not exiting gracefully. I can look more into this
later if I get time.

Ideally I should constrain xmid to be strictly positive, how would
I use L-BFGS-B in gnls? gnls does not accept a ... argument. In the 
gnlsControl documentation it says

optimMethod: character - the optimization method to be used with the
  'optim' optimizer. The default is '"BFGS"'.  An alternative
  is '"L-BFGS-B"'.

but there is no obvious way to specify lower and upper. Either an
example if there is some scoping trick to do it would be nice,
or change that sentence to "optim method 'L-BFGS-B' will not work
since there is way to specify the upper and lower constraints"

Thanks

Nicholas


Nicholas

On Thu, 18 Oct 2007 15:46:01 +0100 (BST), "Prof Brian Ripley"
<[EMAIL PROTECTED]> said:
> On Thu, 18 Oct 2007, Nicholas Lewin-Koh wrote:
> 
> > Hi,
> > Following up on my own post, if in gnlsControl I specify
> > opt='optim' gnls exits quite nicely, with an error, which
> > is what I would expect. Is this a bug in nlminb?
> 
> Possibly, but complex algorithms can loop for non-bug reasons.  I don't 
> feel motivated to explore it in detail, but if you want/are able to, 
> please let us know what you find.
> 
> I have always found optim to work better in package nlme than nlminb (and 
> I know others who have the same experience).
> 
> >
> > Nicholas
> >
> >
> > tt<-gnls(response~SSllogis(conc,A,B,xmid,scal),tdat,start=start,weights=varPower(),verbose=TRUE,control=gnlsControl(opt='optim'))
> > **Iteration 1
> > GLS step: Objective: 29.04254varStruct  parameters:
> >power
> > 0.3373206
> >
> > NLS step: RSS =  0
> > model parameters:-0.799941  8.99983  -0.522623  212.314
> > iterations: 2
> >
> > Convergence:
> >   params varStruct
> > 1.172208  1.00
> > Error in optim(c(coef(gnlsSt)), function(gnlsPars) -logLik(gnlsSt,
> > gnlsPars),  :
> >  initial value in 'vmmin' is not finite
> > In addition: Warning messages:
> > 1: In log(xmid) : NaNs produced
> > 2: In log(xmid) : NaNs produced
> > 3: In log(xmid) : NaNs produced
> >
> > __
> > 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] Sweave wish items

2007-10-18 Thread Gabor Grothendieck
A scanario I have is spawning a Sweave job from another program (not
necessarily written in R).  That program needs to pass some information
to the Sweave program including what the file name is of the report to
produce.

Currently it calls a shell script which calls R CMD Sweave but it would
be nice if R CMD Sweave were powerful enough to do that itself.  These
are the features that would be desirable:

- support --args or some other method of passing arguments from
  R CMD Sweave line to the Sweave script

- have a facility whereby R CMD Sweave can directly generate the
.pdf file and an argument which allows the caller to define the name
of the resulting pdf file. e.g. --pdf

- -o or some way to define the name of the output file.  I need to
have many different outputs from the same Rnw file so its
important to name them differently.

- an -x argument similar to Perl/Python/Ruby such that if one calls
R CMD Sweave -x abc myfile.Rnw then all lines up to the first one
matching the indicated regexp are skipped.  This facilitates combining
the script with a shell or batch file if the previous is not enough.

Thus one could spawn this from their program:

R CMD Sweave --pdf myfile.Rnw -o myfile-123.pdf --args 23

and it would generate a pdf file from myfile.Rnw of the indicated
ame passing 23 as arg1 to the R code embedded in the Sweave file.

Also it would be possible to place Windows batch commands and
the Sweave file in the same file and the batch commands would
look like this:

-
... various Windows batch commands ...
R CMD Sweave -x "^.EOF" --pdf -o %1 %0 --args %2
 maybe more commands 
exit
% EOF
... Sweave code goes here ...

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


[Rd] Underlying representation for rownames

2007-10-18 Thread hadley wickham
Is it possible to get at the underlying representation of row names -
ie. what you see in the output from dput:

> df <- data.frame(1:4)
> dput(df)
structure(list(X1.4 = 1:4), .Names = "X1.4", row.names = c(NA,
-4L), class = "data.frame")

I would like to be able to tell if a data frame has the default row
names, or if they have been changed by the user.  I need this for
rggobi because in GGobi row names should be unique across all data
frames, unless explicitly set by the user.

Thanks,

Hadley


-- 
http://had.co.nz/

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


Re: [Rd] Underlying representation for rownames

2007-10-18 Thread Prof Brian Ripley
I think ?.row_names_info is what you are looking for (although data frames 
have row.names and matrices have rownames, pace the subject line).

On Thu, 18 Oct 2007, hadley wickham wrote:

> Is it possible to get at the underlying representation of row names -
> ie. what you see in the output from dput:
>
>> df <- data.frame(1:4)
>> dput(df)
> structure(list(X1.4 = 1:4), .Names = "X1.4", row.names = c(NA,
> -4L), class = "data.frame")
>
> I would like to be able to tell if a data frame has the default row
> names, or if they have been changed by the user.  I need this for
> rggobi because in GGobi row names should be unique across all data
> frames, unless explicitly set by the user.
>
> Thanks,
>
> Hadley
>
>
>

-- 
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] append/concatenate an element to a list in C-language

2007-10-18 Thread Robert Castelo
dear people,

i need to code a function in C working in R and receives two R SEXP
objects as parameters, where one is a list and another is a vector of
integers:

void f(SEXP list, SEXP vector) {

  ...

  return list;
}


and it should return the given list with the integer vector concatenated
at the end (as the last element of the list). the list can be really big
so i would not like to create a new list from scratch and copy all the
elements, including the additional one. i'm also interested in knowing
how should i properly handle protections of the SEXP objects when doing
this.

i've been looking at the R source code for everything that has to do
with CAR, CDR, CONS, and even found functions with promising names like
listAppend or GrowList but i have not been able to figure this out nor i
haven't been able to find any reference on how to do this by googling
all around, so any help will be very much appreciated.


thanks a lot!!!

robert.

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


Re: [Rd] append/concatenate an element to a list in C-language

2007-10-18 Thread Tony Plate
This sounds like it could be dangerous, but if you're sure it's 
necessary and you know what you are doing, you could investigate whether 
the "pairlist" internal structure might enable you to do this (AFAIK, a 
"pairlist" is a traditional linked-list data structure).  In general, 
pairlists seem to be used very little, and I've never seen their use 
encouraged, so I would be very cautious.  You can read more about 
"pairlists" under ?pairlist, in the R-internals manual, and in the 
source starting at src/include/Rinternals.h (look for "LISTSXP").

-- Tony Plate

Robert Castelo wrote:
> dear people,
>
> i need to code a function in C working in R and receives two R SEXP
> objects as parameters, where one is a list and another is a vector of
> integers:
>
> void f(SEXP list, SEXP vector) {
>
>   ...
>
>   return list;
> }
>
>
> and it should return the given list with the integer vector concatenated
> at the end (as the last element of the list). the list can be really big
> so i would not like to create a new list from scratch and copy all the
> elements, including the additional one. i'm also interested in knowing
> how should i properly handle protections of the SEXP objects when doing
> this.
>
> i've been looking at the R source code for everything that has to do
> with CAR, CDR, CONS, and even found functions with promising names like
> listAppend or GrowList but i have not been able to figure this out nor i
> haven't been able to find any reference on how to do this by googling
> all around, so any help will be very much appreciated.
>
>
> thanks a lot!!!
>
> robert.
>
> __
> R-devel@r-project.org mailing list
> https://stat.ethz.ch/mailman/listinfo/r-devel
>
>

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


Re: [Rd] append/concatenate an element to a list in C-language

2007-10-18 Thread Oleg Sklyar
Hi.

I believe it is virtually impossible, maybe even not virtually: if you
manage to do so somehow, please report it as a bug because such things
must be impossible as they break the integrity of R and data.

Forget about changing size in place: it is C and 'realloc' would be
about the only way to do it, which would not be smart even if you can
find a pointer to what you want to change. However, consider you want to
copy (after all it is a list, which is an array of pointers and you
might think you only need to copy pointers, which is cheap even for a
huge list). Consider a simple example:
you allocVector(VECSXP,n+1); then either memcpy n elements (if you
manage to get a pointer say with DATAPTR, and R-API is smart not to
allow you to get it that simple) or you simply SET_VECTOR_ELT(new, i,
VECTOR_ELT(old, i)) and then add the last one. You know what would be
wrong about this idea? You cannot be sure that pointers to elements of
the old list are not modified/deleted elsewhere, thus affecting your new
list! Even if you overwrite the list in place, providing such software
to users is error prone as users do not know about your ideas of keeping
everything tidy.

The only right way to replicate (if you want to do it in C) is copy and
copy duplicating each element of the list, i.e.:

SEXP f(SEXP old, SEXP v) {
SEXP new; int i,nprotect=0;
PROTECT(new=allocVector(VECSXP,n+1)); nprotect++;
for(i=0;i dear people,
> 
> i need to code a function in C working in R and receives two R SEXP
> objects as parameters, where one is a list and another is a vector of
> integers:
> 
> void f(SEXP list, SEXP vector) {
> 
>   ...
> 
>   return list;
> }
> 
> 
> and it should return the given list with the integer vector concatenated
> at the end (as the last element of the list). the list can be really big
> so i would not like to create a new list from scratch and copy all the
> elements, including the additional one. i'm also interested in knowing
> how should i properly handle protections of the SEXP objects when doing
> this.
> 
> i've been looking at the R source code for everything that has to do
> with CAR, CDR, CONS, and even found functions with promising names like
> listAppend or GrowList but i have not been able to figure this out nor i
> haven't been able to find any reference on how to do this by googling
> all around, so any help will be very much appreciated.
> 
> 
> thanks a lot!!!
> 
> robert.
> 
> __
> R-devel@r-project.org mailing list
> https://stat.ethz.ch/mailman/listinfo/r-devel

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