[R] (no subject)

2004-09-27 Thread YiYao_Jiang
***
On Tue, 28 Sep 2004, YiYao_Jiang wrote:

I can't setup a library for some functions.
Can anybody kindly give me an example about setup a library. From build a package to 
library.
***

Actually I have read " Writing R Extensions", I tried many command: build, check, 
INSTALL, library , package.skeleton. But I still can't compile a package, Can anybody 
kindly give me an example about it?
Thanks.



Best Regards

YiYao Jiang  

Product Division/ product Testing Department
Semiconductor Manufacturing International Corporation
18 ZhangJiang Road, PuDong New Area, Shanghai  ZIP: 201203
Tel:86-21-5080-2000 Ext. 15173

__
[EMAIL PROTECTED] mailing list
https://stat.ethz.ch/mailman/listinfo/r-help
PLEASE do read the posting guide! http://www.R-project.org/posting-guide.html


Re: [R] memory increase for large r simulation

2004-09-27 Thread Prof Brian Ripley
Please read the appropriate FAQ (rw-FAQ), as the posting guide asks.
  ^
  2.7 There seems to be a limit on the memory it uses!

lokks relevant, and is.  (So was some more info given with that error 
message.)

On Tue, 28 Sep 2004, shane stanton wrote:

> Hi,
> 
> I am running R from windows 95. I have a large
> simulation, which R does not get very far through
> before telling me:
> 
> "error  cannot allocate vector of size 871875 Kb"
> 
> and warning message "reached total allocation of 127
> Mb"
> 
> I have been trying to increase the memory allocation
> to R from my computer, using various commands at the R
> prompt, such as memory.limit(size=..) to which R
> responds "NULL" or "cannot decrease memory limit" (no
> matter how large I try to make the argument of
> memory.limit. 
> 
> Does anybody have any ideas re how I can get this
> simulation to run?
> 
> Many thanks,
> 
> Shane Stanton
> 
> __
> [EMAIL PROTECTED] mailing list
> https://stat.ethz.ch/mailman/listinfo/r-help
> PLEASE do read the posting guide! http://www.R-project.org/posting-guide.html
> 
> 

-- 
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

__
[EMAIL PROTECTED] mailing list
https://stat.ethz.ch/mailman/listinfo/r-help
PLEASE do read the posting guide! http://www.R-project.org/posting-guide.html


RE: [R] sapply behavior

2004-09-27 Thread Prof Brian Ripley
On Mon, 27 Sep 2004, Liaw, Andy wrote:

> The problem is that temp2 is a data frame, and the function you are
> sapply()ing to returns a row from a data frame.  A data frame is really a
> list, with each variable corresponding to a component.  If you extract a row
> of a data frame, you get another data frame, not a vector, even if all
> variables are the same type.  sapply() can really `simplify' the right way
> if it's given a vector (or matrix).  Consider:
> 
> > str(temp2)
> `data.frame':   6 obs. of  4 variables:
>  $ A1: int  5 2 4 6 1 3
>  $ A2: int  5 2 4 6 1 3
>  $ A3: int  5 2 4 6 1 3
>  $ A4: int  5 2 4 6 1 3
> > temp2 <- as.matrix(temp2)
> > str(temp2)
>  int [1:6, 1:4] 5 2 4 6 1 3 5 2 4 6 ...
>  - attr(*, "dimnames")=List of 2
>   ..$ : chr [1:6] "1" "2" "3" "4" ...
>   ..$ : chr [1:4] "A1" "A2" "A3" "A4"
> > str(sapply(1:6,function(x){xmat<-temp2[temp2[,1]==x,,drop=F]; xmat[1,]}))
>  int [1:4, 1:6] 1 1 1 1 2 2 2 2 3 3 ...
>  - attr(*, "dimnames")=List of 2
>   ..$ : chr [1:4] "A1" "A2" "A3" "A4"
>   ..$ : NULL
> 
> (The is.matrix() function probably just check whether the dim attribute is a
> vector of length 2, and not a data frame (as it says in ?is.matrix).  The
> newtemp2 object you get is a list with 24 components, each component is a
> vector of one integer, and has a dim attribute of c(4, 6).  Not what I would
> call a matrix.)

That *is* a matrix, though, and is useful for lists of length greater than
one.  A matrix in R is just a vector with a dim attribute (and length the
product of the dims's), so as well as any of the atomic vectors it can be
a generic vector aka list.

-- 
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

__
[EMAIL PROTECTED] mailing list
https://stat.ethz.ch/mailman/listinfo/r-help
PLEASE do read the posting guide! http://www.R-project.org/posting-guide.html


[R] memory increase for large r simulation

2004-09-27 Thread shane stanton
Hi,

I am running R from windows 95. I have a large
simulation, which R does not get very far through
before telling me:

"error  cannot allocate vector of size 871875 Kb"

and warning message "reached total allocation of 127
Mb"

I have been trying to increase the memory allocation
to R from my computer, using various commands at the R
prompt, such as memory.limit(size=..) to which R
responds "NULL" or "cannot decrease memory limit" (no
matter how large I try to make the argument of
memory.limit. 

Does anybody have any ideas re how I can get this
simulation to run?

Many thanks,

Shane Stanton

__
[EMAIL PROTECTED] mailing list
https://stat.ethz.ch/mailman/listinfo/r-help
PLEASE do read the posting guide! http://www.R-project.org/posting-guide.html


Re: [R] (no subject)

2004-09-27 Thread Kevin Wang
Hi,

On Tue, 28 Sep 2004, YiYao_Jiang wrote:

> Hello everybody:
>
> I can't setup a library for some functions.
> Can anybody kindly give me an example about setup a library. From build a package to 
> library.

I am guessing you meant you want to compile a package from source?  Have
you looked at Writing R Extensions?

HTH,

Kevin



Ko-Kang Kevin Wang
PhD Student
Centre for Mathematics and its Applications
Building 27, Room 1004
Mathematical Sciences Institute (MSI)
Australian National University
Canberra, ACT 0200
Australia

Homepage: http://wwwmaths.anu.edu.au/~wangk/
Ph (W): +61-2-6125-2431
Ph (H): +61-2-6125-7407
Ph (M): +61-40-451-8301

__
[EMAIL PROTECTED] mailing list
https://stat.ethz.ch/mailman/listinfo/r-help
PLEASE do read the posting guide! http://www.R-project.org/posting-guide.html


[Hmisc] proposal for change in latex.summary.formula.reverse (was: [R] Sweave: superfluous newline (`\\') in tex file)

2004-09-27 Thread Patrick Drechsler
Hi,

well, it wasn't a Sweave problem after all. Seems to have
something to do with the function
`latex.summary.formula.reverse' in the package Hmisc.

Following change seems to help (at least for my purpose):

--88---
*** /usr/local/lib/R/library/Hmisc/R/Hmisc  2004-09-28 07:37:26.0 +0200
--- /usr/local/lib/R/library/Hmisc/R/Hmisc.original 2004-09-28 07:38:28.0 
+0200
***
*** 16156,16162 
'Numbers after percents are frequencies.',
sep="\n")
if(length(testUsed))
! legend <-paste(legend,'\n\n',
 if(length(testUsed)==1)'Test used:' else 'Tests used:',
 if(length(testUsed)==1) paste(testUsed,'test') else
 paste(paste('$^{',1:length(testUsed),'}$',testUsed,
--- 16156,16162 
'Numbers after percents are frequencies.',
sep="\n")
if(length(testUsed))
! legend <-paste(legend,'\n','\n\n',
 if(length(testUsed)==1)'Test used:' else 'Tests used:',
 if(length(testUsed)==1) paste(testUsed,'test') else
 paste(paste('$^{',1:length(testUsed),'}$',testUsed,
--88---

But since my knowledge of R is rather small I have no idea if
these has any other drawbacks.

Any comments?

How would I go about changing this for my setup only? Is
renaming Hmisc to something like pdHmisc ok?

Patrick
-- 
Do you remember when you only had to pay
for windows when *you* broke them?

__
[EMAIL PROTECTED] mailing list
https://stat.ethz.ch/mailman/listinfo/r-help
PLEASE do read the posting guide! http://www.R-project.org/posting-guide.html


[R] (no subject)

2004-09-27 Thread YiYao_Jiang
Hello everybody:

I can't setup a library for some functions.
Can anybody kindly give me an example about setup a library. From build a package to 
library.

Thanks!


Best Regards

YiYao Jiang

__
[EMAIL PROTECTED] mailing list
https://stat.ethz.ch/mailman/listinfo/r-help
PLEASE do read the posting guide! http://www.R-project.org/posting-guide.html


[R] Re: tseries Package for R

2004-09-27 Thread Adrian Trapletti
Wizon wrote:
I am using Mac OSX.  I am first starting to use R and have not 
installed any packages yet.  I searched through the CRAN site for a 
Mac OSX version, but did not find one.  I downloaded the tar.gz 
package.  Will this work on the Mac?  Is there a way to get a package 
that I don't have to compile?  Thanks in advance for your help.

Adam

Dear Adam
Sorry, I can't help you since I never used R under MacOS. However, I cc 
your mail to R-help. Maybe you get some feedback from there.

Best regards
Adrian
__
[EMAIL PROTECTED] mailing list
https://stat.ethz.ch/mailman/listinfo/r-help
PLEASE do read the posting guide! http://www.R-project.org/posting-guide.html


Re: [R] An index of all possible combinations of variables in a data fram e

2004-09-27 Thread Gabor Grothendieck
Alan Simpson  robertsresearch.com.au> writes:

: Does anybody know of any way to create an index of all the possible
: combinations of variables (factors) in a data frame? ie for 3 factors A, B &
: C we have 
: 
: A
: B
: C
: AB
: AC
: BC
: ABC
:  
: which equates to columns 1, 2, 3, 1:2, (1,3), 2:3 and 1:3.
: 
: I realise that a function like model.matrix does this, but how to get the
: seqence of the index?
: 

Is this what you are looking for?

R> attributes(terms(~ a * b * c))$term.labels
[1] "a" "b" "c" "a:b"   "a:c"   "b:c"   "a:b:c"

__
[EMAIL PROTECTED] mailing list
https://stat.ethz.ch/mailman/listinfo/r-help
PLEASE do read the posting guide! http://www.R-project.org/posting-guide.html


Re: [R] KS test

2004-09-27 Thread Vaidotas Zemlys
Hi,


> I have a sample, and I want to test if its distribution is normal. So I
> would like to perform a one sample KS test but I cannot find the "y"
> argument representing  the "character string naming a distribution
> function" according to the ?ks.test help page.
> It is impossible forme to have a list of these character strings naming a
> distribution function.
> 
> I think it is "pnorm" for a normal distribution, bu I would like to be sure...
> 

>From examples in ks.test manual:
# Does x come from a shifted gamma distribution with shape 3 and scale 2?
 ks.test(x+2, "pgamma", 3, 2) # two-sided
 ks.test(x+2, "pgamma", 3, 2, alternative = "gr")

So you can be sure, that it will be "pnorm" for normal distribution.

Vaidotas

__
[EMAIL PROTECTED] mailing list
https://stat.ethz.ch/mailman/listinfo/r-help
PLEASE do read the posting guide! http://www.R-project.org/posting-guide.html


[R] An index of all possible combinations of variables in a data fram e

2004-09-27 Thread Alan Simpson
Hello list
 
Does anybody know of any way to create an index of all the possible
combinations of variables (factors) in a data frame? ie for 3 factors A, B &
C we have 
 
A
B
C
AB
AC
BC
ABC
 
which equates to columns 1, 2, 3, 1:2, (1,3), 2:3 and 1:3.
 
I realise that a function like model.matrix does this, but how to get the
seqence of the index?
 
Any help would be greatly appreciated.
 
Regards
 
Alan Simpson
Roberts Research Group
 

[[alternative HTML version deleted]]

__
[EMAIL PROTECTED] mailing list
https://stat.ethz.ch/mailman/listinfo/r-help
PLEASE do read the posting guide! http://www.R-project.org/posting-guide.html


Re: [R] optim error in arima

2004-09-27 Thread Vaidotas Zemlys
Hi,


On Mon, 27 Sep 2004 09:02:39 -0700 (PDT), Nathaniel B. Derby
<[EMAIL PROTECTED]> wrote:
> Hello,
> 
> I'm fitting a series of ARIMA models to a data set to compare fits.  After 
> taking the logs of the data and then differencing them to induce stationarity,
> I execute
> 
> arima( y, order=c( p, 0, q ), seasonal=list( order=c( P, 0, Q ), period=7 ) )
> 
> for various values of p, q, P and Q.  For one set of these values, I get
> 
> Error in optim(init[mask], armafn, method = "BFGS", hessian = TRUE ... :
>  non-finite finite-difference value [0]
> 
> which tells me that when computing derivatives of the objective function 
> (armafn) by finite differencing, one of the values is NA, +Inf or -Inf.  Any 
> ideas?  I would like to print some values of armafn, but how do I get that 
> from my data set, and what would I look for?

This probably means, that for your values of p, q, P, Q the arima
model is not valid arima model, i.e. it is not stationary.

Vaidotas

__
[EMAIL PROTECTED] mailing list
https://stat.ethz.ch/mailman/listinfo/r-help
PLEASE do read the posting guide! http://www.R-project.org/posting-guide.html


[R] Course***Splus/R: Complementing and Extending Statistical Computing for SAS Users

2004-09-27 Thread elvis
XLSolutions Corporation (www.xlsolutions-corp.com) is pleased to 
announce a two-day course, "Splus/R: Complementing and Extending
Statistical Computing for SAS Users" www.xlsolutions-corp.com/Rsas.htm

Dates/City: October 28-29  Raleigh, NC
 November 4-5  Boston, MA


This course is designed for SAS users who want to learn how to
complement 
and extend statistical computing with Splus and/or R system. 
The course will give participants a strong foundation for becoming 
a versatile programmer. 

Course Description:

This two-day course focuses on a broad spectrum of topics:

*Data manipulations in S and R (data frame and matrix operations) 
and SAS (the data step) -- issues of importing, formatting,
transformation,
cataloging, exporting 
*Splus/R Functions vs macros in SAS for programming repetitive
processes. 
*The iteration models of SAS vs whole-object modeling 
*Specific comparison: linear modeling, glms, gees, lmes.
*etc

Complete course description: www.xlsolutions-corp.com/Rsas.htm


Earlybird ends October 10th. 

Ask for group discount!

Registration: 

Email Sue Turner: [EMAIL PROTECTED]
Phone: 206-686-1578




Share Your Thoughts:

Are there any additional topics you would like for this course to
address?
Would you like for this course to be offered in another city? 

Please let us know by contributing to our recommendation list: 
[EMAIL PROTECTED]


Elvis Miller, PhD
Manager Training and Technical Support
North American Division
XLSolutions Corporation
Email: [EMAIL PROTECTED]
Phone: 206-686-1578
Web: www.xlsolutions-corp.com

__
[EMAIL PROTECTED] mailing list
https://stat.ethz.ch/mailman/listinfo/r-help
PLEASE do read the posting guide! http://www.R-project.org/posting-guide.html


RE: [R] smoothing noisy data with a twist

2004-09-27 Thread Liaw, Andy
One thing I would try is to supply 1/sd(y) as the weights to smoothers that
can accept them; e.g., loess().

Andy

> From: Matt Gibbs
> 
> Hi,
> 
> I have a set of observations (x,y), derived from a previous 
> estimation. 
> For each observation I also have an estimated variance s(y) 
> derived from 
> the first stage.
> 
> The problem is that I need to smooth the data (x,y) while taking into 
> account the fact that the y's have been estimated at a previous stage 
> and thus already come with a variance. So, if I smooth the data I 
> somehow need to take into account *two errors*, one from the 
> smoothing 
> and the other from the already noisy data that I start off with.
> 
> Does anyone have any idea how to do this?
> 
> thanks, matt.
> 
> __
> [EMAIL PROTECTED] mailing list
> https://stat.ethz.ch/mailman/listinfo/r-help
> PLEASE do read the posting guide! 
> http://www.R-project.org/posting-guide.html
> 
>

__
[EMAIL PROTECTED] mailing list
https://stat.ethz.ch/mailman/listinfo/r-help
PLEASE do read the posting guide! http://www.R-project.org/posting-guide.html


[R] private on site R training solicited

2004-09-27 Thread Vadim Ogranovich
Hi,
 
R is catching up even with the hardest Excelists. At our company we are
exploring the possibility of having some of the R&D staff introduced to
R during a short on site class in San-Francisco, California. The number
of people in the group will be about 5 - 7. If you are interested in
delivering the class please e-mail me the info for consideration.
 
Thanks,
Vadim Ogranovich
Evnine & Vaughan Assoc.

[[alternative HTML version deleted]]

__
[EMAIL PROTECTED] mailing list
https://stat.ethz.ch/mailman/listinfo/r-help
PLEASE do read the posting guide! http://www.R-project.org/posting-guide.html


[R] smoothing noisy data with a twist

2004-09-27 Thread Matt Gibbs
Hi,
I have a set of observations (x,y), derived from a previous estimation. 
For each observation I also have an estimated variance s(y) derived from 
the first stage.

The problem is that I need to smooth the data (x,y) while taking into 
account the fact that the y's have been estimated at a previous stage 
and thus already come with a variance. So, if I smooth the data I 
somehow need to take into account *two errors*, one from the smoothing 
and the other from the already noisy data that I start off with.

Does anyone have any idea how to do this?
thanks, matt.
__
[EMAIL PROTECTED] mailing list
https://stat.ethz.ch/mailman/listinfo/r-help
PLEASE do read the posting guide! http://www.R-project.org/posting-guide.html


Re: [R] passing formula arg to mgcv::gam

2004-09-27 Thread Gabor Grothendieck

How about

   environment(formula) <- environment()


Vadim Ogranovich  evafunds.com> writes:

: 
: This is a self-response .
: 
: It was indeed a problem with environments. One way to get around is 
to "reset" the environment, e.g. inside
: callGam do
: formula <- as.formula(unclass(formula)) 
: 
: Not too aesthetic, but works. Is there a less kludgy way to do this?
: 
: BTW, forgot to mention. This is R-1.9.1 on RH-7.3.
: 
: Thanks,
: Vadim
: 
: > -Original Message-
: > From: r-help-bounces  stat.math.ethz.ch 
: > [mailto:r-help-bounces  stat.math.ethz.ch] On Behalf Of Vadim 
: > Ogranovich
: > Sent: Monday, September 27, 2004 3:24 PM
: > To: r-help  stat.math.ethz.ch
: > Subject: [R] passing formula arg to mgcv::gam 
: > 
: > Hi,
: > 
: > I have a function, callGam, that fits a gam model to a subset 
: > of a dataframe. The argument to callGam is a formula, the 
: > subset is determined inside the function itself. My naÃve 
: > approach generates and error, see below. I guess this is 
: > because 'idx' is loocked up in the environment of 'formula', 
: > but I am too ignorant about environments to be able to tell 
: > for sure. Could someone please suggest a way around?
: > 
: > Thanks,
: > Vadim
: > 
: > > library("mgcv")
: > > 
: > > callGam <- function(formula) {
: > +   idx <- seq(10)
: > +   gam(formula, data=data.frame(x=rnorm(100), y=rnorm(100)), 
: > + subset=idx) }
: > > 
: > > gam.fit <- callGam(y ~ x)
: > Error in eval(expr, envir, enclos) : Object "idx" not found

__
[EMAIL PROTECTED] mailing list
https://stat.ethz.ch/mailman/listinfo/r-help
PLEASE do read the posting guide! http://www.R-project.org/posting-guide.html


Re: [R] sapply behavior

2004-09-27 Thread Gabor Grothendieck
Elizabeth Purdom  stanford.edu> writes:

: 
: Hi,
: 
: I use sapply very frequently, but I have recently noticed a behavior of 
: sapply which I don't understand and have never seen before. Basically, 
: sapply returns what looks like a matrix,  says it a matrix, and appears to 
: let me do matrix things (like transpose). But it is also a list and behaves 
: like a list when I subset it, not a vector (so I can't sort a row for 
: instance). I don't know where this is coming from so as to avoid it, nor 
: how to handle the beast that sapply is returning. I double checked my old 
: version of R and apparently this same thing happens in 1.8.0, though I 
: never experienced it. I had a hard time reproducing it, and I don't know 
: what's setting it off, but the code below seems to do it for me. (I'm using 
: R on Windows XP, either 1.8.0 or 1.9.1)
: 
: Thanks for any help,
: Elizabeth Purdom
: 
: 
:  > temp2<-matrix(sample(1:6,6,replace=F),byrow=F,nrow=6,ncol=4)
:  > colnames(temp2)<-paste("A",as.character(1:4),sep="")
:  > temp2<-as.data.frame(temp2)
:  > 
: newtemp2<-sapply((1:6),function(x){xmat<-temp2[temp2[,1]==x,,drop=F];return
(xmat[1,])})
:  > print(newtemp2) #looks like matrix
: [,1] [,2] [,3] [,4] [,5] [,6]
: A1 123456
: A2 123456
: A3 123456
: A4 123456
:  > is.matrix(newtemp2) #says it's matrix
: [1] TRUE
:  > class(newtemp2)
: [1] "matrix"
:  > is.list(newtemp2) #but also list
: [1] TRUE
:  > newtemp2[,1] #can't subset and get a vector back; same thing happens for 
: rows.
: $A1
: [1] 1
: 
: $A2
: [1] 1
: 
: $A3
: [1] 1
: 
: $A4
: [1] 1
: #other things about it:
:  > names(newtemp2)
: NULL
:  > dimnames(newtemp2)
: [[1]]
: [1] "A1" "A2" "A3" "A4"
: 
: [[2]]
: NULL
:  > dim(newtemp2)
: [1] 4 6
:  > length(newtemp2)
: [1] 24


The problem is that your function is returning a one row data frame
and when sapply tries to simplify the resulting list of 6 data frames 
that gives a list with dimensions rather what you were expecting
which is a vector with dimensions.

Let us call the original anonymous function in your post (i.e. the one
passed to sapply there), f.  We can modify it to produce f2 which is like
f except that we wrap the return expression in c() to turn it into a
vector:

  f2 <- function(x){xmat<-temp2[temp2[,1]==x,,drop=F];return(c(xmat[1,]))}
  sapply(1:6, f2)

If you really do want to return a one row data frame then
use rbind to bind the data frames together rather than sapply:

   do.call("rbind", lapply(1:6, f))

__
[EMAIL PROTECTED] mailing list
https://stat.ethz.ch/mailman/listinfo/r-help
PLEASE do read the posting guide! http://www.R-project.org/posting-guide.html


Re: [R] sapply behavior

2004-09-27 Thread Douglas Bates
Elizabeth Purdom wrote:
I use sapply very frequently, but I have recently noticed a behavior of 
sapply which I don't understand and have never seen before. Basically, 
sapply returns what looks like a matrix,  says it a matrix, and appears 
to let me do matrix things (like transpose). But it is also a list and 
behaves like a list when I subset it, not a vector (so I can't sort a 
row for instance). I don't know where this is coming from so as to avoid 
it, nor how to handle the beast that sapply is returning. I double 
checked my old version of R and apparently this same thing happens in 
1.8.0, though I never experienced it. I had a hard time reproducing it, 
and I don't know what's setting it off, but the code below seems to do 
it for me. (I'm using R on Windows XP, either 1.8.0 or 1.9.1)

Thanks for any help,
Elizabeth Purdom
 > temp2<-matrix(sample(1:6,6,replace=F),byrow=F,nrow=6,ncol=4)
 > colnames(temp2)<-paste("A",as.character(1:4),sep="")
 > temp2<-as.data.frame(temp2)
It is this coercion to the data frame that is injecting a list-like 
property into the result.  Try your script without that line and it will 
work as you expect.

 > newtemp2<-sapply((1:6),function(x){xmat<-temp2[temp2[,1]==x,,drop=F];return(xmat[1,])}) 
 > print(newtemp2) #looks like matrix
   [,1] [,2] [,3] [,4] [,5] [,6]
A1 123456
A2 123456
A3 123456
A4 123456
The best thing to do in a situation like this is to use the str function 
to see the details of the structure of the object.

__
[EMAIL PROTECTED] mailing list
https://stat.ethz.ch/mailman/listinfo/r-help
PLEASE do read the posting guide! http://www.R-project.org/posting-guide.html


RE: [R] sapply behavior

2004-09-27 Thread Liaw, Andy
The problem is that temp2 is a data frame, and the function you are
sapply()ing to returns a row from a data frame.  A data frame is really a
list, with each variable corresponding to a component.  If you extract a row
of a data frame, you get another data frame, not a vector, even if all
variables are the same type.  sapply() can really `simplify' the right way
if it's given a vector (or matrix).  Consider:

> str(temp2)
`data.frame':   6 obs. of  4 variables:
 $ A1: int  5 2 4 6 1 3
 $ A2: int  5 2 4 6 1 3
 $ A3: int  5 2 4 6 1 3
 $ A4: int  5 2 4 6 1 3
> temp2 <- as.matrix(temp2)
> str(temp2)
 int [1:6, 1:4] 5 2 4 6 1 3 5 2 4 6 ...
 - attr(*, "dimnames")=List of 2
  ..$ : chr [1:6] "1" "2" "3" "4" ...
  ..$ : chr [1:4] "A1" "A2" "A3" "A4"
> str(sapply(1:6,function(x){xmat<-temp2[temp2[,1]==x,,drop=F]; xmat[1,]}))
 int [1:4, 1:6] 1 1 1 1 2 2 2 2 3 3 ...
 - attr(*, "dimnames")=List of 2
  ..$ : chr [1:4] "A1" "A2" "A3" "A4"
  ..$ : NULL

(The is.matrix() function probably just check whether the dim attribute is a
vector of length 2, and not a data frame (as it says in ?is.matrix).  The
newtemp2 object you get is a list with 24 components, each component is a
vector of one integer, and has a dim attribute of c(4, 6).  Not what I would
call a matrix.)

HTH,
Andy


> From: Elizabeth Purdom
> 
> Hi,
> 
> I use sapply very frequently, but I have recently noticed a 
> behavior of 
> sapply which I don't understand and have never seen before. 
> Basically, 
> sapply returns what looks like a matrix,  says it a matrix, 
> and appears to 
> let me do matrix things (like transpose). But it is also a 
> list and behaves 
> like a list when I subset it, not a vector (so I can't sort a row for 
> instance). I don't know where this is coming from so as to 
> avoid it, nor 
> how to handle the beast that sapply is returning. I double 
> checked my old 
> version of R and apparently this same thing happens in 1.8.0, 
> though I 
> never experienced it. I had a hard time reproducing it, and I 
> don't know 
> what's setting it off, but the code below seems to do it for 
> me. (I'm using 
> R on Windows XP, either 1.8.0 or 1.9.1)
> 
> Thanks for any help,
> Elizabeth Purdom
> 
> 
>  > temp2<-matrix(sample(1:6,6,replace=F),byrow=F,nrow=6,ncol=4)
>  > colnames(temp2)<-paste("A",as.character(1:4),sep="")
>  > temp2<-as.data.frame(temp2)
>  > 
> newtemp2<-sapply((1:6),function(x){xmat<-temp2[temp2[,1]==x,,d
> rop=F];return(xmat[1,])})
>  > print(newtemp2) #looks like matrix
> [,1] [,2] [,3] [,4] [,5] [,6]
> A1 123456
> A2 123456
> A3 123456
> A4 123456
>  > is.matrix(newtemp2) #says it's matrix
> [1] TRUE
>  > class(newtemp2)
> [1] "matrix"
>  > is.list(newtemp2) #but also list
> [1] TRUE
>  > newtemp2[,1] #can't subset and get a vector back; same 
> thing happens for 
> rows.
> $A1
> [1] 1
> 
> $A2
> [1] 1
> 
> $A3
> [1] 1
> 
> $A4
> [1] 1
> #other things about it:
>  > names(newtemp2)
> NULL
>  > dimnames(newtemp2)
> [[1]]
> [1] "A1" "A2" "A3" "A4"
> 
> [[2]]
> NULL
>  > dim(newtemp2)
> [1] 4 6
>  > length(newtemp2)
> [1] 24
> 
> __
> [EMAIL PROTECTED] mailing list
> https://stat.ethz.ch/mailman/listinfo/r-help
> PLEASE do read the posting guide! 
> http://www.R-project.org/posting-guide.html
> 
>

__
[EMAIL PROTECTED] mailing list
https://stat.ethz.ch/mailman/listinfo/r-help
PLEASE do read the posting guide! http://www.R-project.org/posting-guide.html


RE: [R] using tcltk in R under ESS/XEmacs on Windows

2004-09-27 Thread Shawn Boles
Tony:

It is indeed most amazing that you have been able to get ESS/Emacs
running under Windows.  And much appreciated by those of us who have to
moil around 
with MessySoft machines.

Thanks to all who have contributed to the effort.

Cheers,

Shawn Boles




-Original Message-
From: A.J. Rossini [mailto:[EMAIL PROTECTED] 
Sent: Saturday, September 25, 2004 8:04 PM
To: Liaw, Andy
Cc: R-Help; [EMAIL PROTECTED]; ESS (Help list)
Subject: Re: [R] using tcltk in R under ESS/XEmacs on Windows

It most likely is Windows specific.  It's most amazing that we
actually have ESS/(X)Emacs working under windows in the first place.

Unfortunately, I'm in transit for the next few weeks, but I'll
probably have a windows machine on my desk sometime after that.  Argh.

best,
-tony


On Fri, 24 Sep 2004 17:48:18 -0400, Liaw, Andy <[EMAIL PROTECTED]>
wrote:
> > From: Marc Schwartz
> >
> > On Fri, 2004-09-24 at 15:02, Liaw, Andy wrote:
> > > Sorry for the cross-post.  Not sure where the problem is...
> > >
> > > A while back I posted an R function to R-help:
> > >
> > > cd <- function (dir = tclvalue(tkchooseDirectory()),
> > saveOld = FALSE,
> > > loadNew = TRUE) {
> > > stopifnot(require(tcltk))
> > > if (saveOld)
> > > save.image(compress = TRUE)
> > > setwd(dir)
> > > rm(list = ls(all = TRUE, envir = .GlobalEnv), envir =
> > .GlobalEnv)
> > > if (loadNew && file.exists(".RData")) {
> > > loaded <- load(".RData", envir = .GlobalEnv)
> > > return(invisible(loaded))
> > > }
> > >
> > > where the default value for the `dir' argument is to run
> > the tcltk directory
> > > chooser and get the directory name chosen.  (Thanks to
> > Prof. John Fox for
> > > the tcltk part!!)  While this function works fine under
> > Rgui on Windows, it
> > > doesn't work when running R within ESS (5.2.3) and XEmacs
> > (21.4.13).  The
> > > directory chooser never shows up, and dir just gets the
> > empty string.  Does
> > > anyone have any idea what could be the problem?  I'd very
> > much appreciate
> > > any pointers.
> > >
> > > Best,
> > > Andy
> >
> > Andy,
> >
> > This works under FC2 using ESS 5.2.3 with XEmacs version 21.4.15, so
> > presumably there is something specific to the Windows
implementation?
> 
> Given Prof. Fox's follow-up and your obvservation, I guess the problem
_is_
> Windows-specific. 8-(
> 
> > Also, two things:
> >
> > 1. You are missing a closing brace above, which I presume may be a
> > simple copy and paste issue.
> 
> Yes.  My apologies.
> 
> > 2. If you successfully change the directory, the cd()
> > function itself is
> > deleted from the global environment via your rm(...), as you
currently
> > have it implemented. I am not sure if this is intentional or not.
> 
> Well, sort of.  I've placed it in a small package along with other
handy
> stuff, so that won't be a problem.
> 
> Best,
> Andy
> 
> 
> 
> > HTH,
> >
> > Marc
> >
> >
> >
> >
> 
> __
> [EMAIL PROTECTED] mailing list
> https://stat.ethz.ch/mailman/listinfo/r-help
> PLEASE do read the posting guide!
http://www.R-project.org/posting-guide.html
> 



-- 
A.J. Rossini
[EMAIL PROTECTED]

__
[EMAIL PROTECTED] mailing list
https://stat.ethz.ch/mailman/listinfo/ess-help

__
[EMAIL PROTECTED] mailing list
https://stat.ethz.ch/mailman/listinfo/r-help
PLEASE do read the posting guide! http://www.R-project.org/posting-guide.html


[R] sapply behavior

2004-09-27 Thread Elizabeth Purdom
Hi,
I use sapply very frequently, but I have recently noticed a behavior of 
sapply which I don't understand and have never seen before. Basically, 
sapply returns what looks like a matrix,  says it a matrix, and appears to 
let me do matrix things (like transpose). But it is also a list and behaves 
like a list when I subset it, not a vector (so I can't sort a row for 
instance). I don't know where this is coming from so as to avoid it, nor 
how to handle the beast that sapply is returning. I double checked my old 
version of R and apparently this same thing happens in 1.8.0, though I 
never experienced it. I had a hard time reproducing it, and I don't know 
what's setting it off, but the code below seems to do it for me. (I'm using 
R on Windows XP, either 1.8.0 or 1.9.1)

Thanks for any help,
Elizabeth Purdom
> temp2<-matrix(sample(1:6,6,replace=F),byrow=F,nrow=6,ncol=4)
> colnames(temp2)<-paste("A",as.character(1:4),sep="")
> temp2<-as.data.frame(temp2)
> 
newtemp2<-sapply((1:6),function(x){xmat<-temp2[temp2[,1]==x,,drop=F];return(xmat[1,])})
> print(newtemp2) #looks like matrix
   [,1] [,2] [,3] [,4] [,5] [,6]
A1 123456
A2 123456
A3 123456
A4 123456
> is.matrix(newtemp2) #says it's matrix
[1] TRUE
> class(newtemp2)
[1] "matrix"
> is.list(newtemp2) #but also list
[1] TRUE
> newtemp2[,1] #can't subset and get a vector back; same thing happens for 
rows.
$A1
[1] 1

$A2
[1] 1
$A3
[1] 1
$A4
[1] 1
#other things about it:
> names(newtemp2)
NULL
> dimnames(newtemp2)
[[1]]
[1] "A1" "A2" "A3" "A4"
[[2]]
NULL
> dim(newtemp2)
[1] 4 6
> length(newtemp2)
[1] 24
__
[EMAIL PROTECTED] mailing list
https://stat.ethz.ch/mailman/listinfo/r-help
PLEASE do read the posting guide! http://www.R-project.org/posting-guide.html


RE: [R] passing formula arg to mgcv::gam

2004-09-27 Thread Vadim Ogranovich
This is a self-response :-).

It was indeed a problem with environments. One way to get around is to "reset" the 
environment, e.g. inside callGam do
formula <- as.formula(unclass(formula)) 


Not too aesthetic, but works. Is there a less kludgy way to do this?

BTW, forgot to mention. This is R-1.9.1 on RH-7.3.

Thanks,
Vadim

> -Original Message-
> From: [EMAIL PROTECTED] 
> [mailto:[EMAIL PROTECTED] On Behalf Of Vadim 
> Ogranovich
> Sent: Monday, September 27, 2004 3:24 PM
> To: [EMAIL PROTECTED]
> Subject: [R] passing formula arg to mgcv::gam 
> 
> Hi,
> 
> I have a function, callGam, that fits a gam model to a subset 
> of a dataframe. The argument to callGam is a formula, the 
> subset is determined inside the function itself. My naïve 
> approach generates and error, see below. I guess this is 
> because 'idx' is loocked up in the environment of 'formula', 
> but I am too ignorant about environments to be able to tell 
> for sure. Could someone please suggest a way around?
> 
> Thanks,
> Vadim
> 
> > library("mgcv")
> > 
> > callGam <- function(formula) {
> +   idx <- seq(10)
> +   gam(formula, data=data.frame(x=rnorm(100), y=rnorm(100)), 
> + subset=idx) }
> > 
> > gam.fit <- callGam(y ~ x)
> Error in eval(expr, envir, enclos) : Object "idx" not found
> >
> 
> __
> [EMAIL PROTECTED] mailing list
> https://stat.ethz.ch/mailman/listinfo/r-help
> PLEASE do read the posting guide! 
> http://www.R-project.org/posting-guide.html
>

__
[EMAIL PROTECTED] mailing list
https://stat.ethz.ch/mailman/listinfo/r-help
PLEASE do read the posting guide! http://www.R-project.org/posting-guide.html


[R] passing formula arg to mgcv::gam

2004-09-27 Thread Vadim Ogranovich
Hi,

I have a function, callGam, that fits a gam model to a subset of a dataframe. The 
argument to callGam is a formula, the subset is determined inside the function itself. 
My naïve approach generates and error, see below. I guess this is because 'idx' is 
loocked up in the environment of 'formula', but I am too ignorant about environments 
to be able to tell for sure. Could someone please suggest a way around?

Thanks,
Vadim

> library("mgcv")
> 
> callGam <- function(formula) {
+   idx <- seq(10)
+   gam(formula, data=data.frame(x=rnorm(100), y=rnorm(100)), subset=idx)
+ }
> 
> gam.fit <- callGam(y ~ x)
Error in eval(expr, envir, enclos) : Object "idx" not found
>

__
[EMAIL PROTECTED] mailing list
https://stat.ethz.ch/mailman/listinfo/r-help
PLEASE do read the posting guide! http://www.R-project.org/posting-guide.html


Re: [R] Gridbase basic question

2004-09-27 Thread Paul Murrell
Hi
Sean Davis wrote:
All,
I have a simple plot(x,y) and I would like to then insert rectangles of  
some length (in native coordinates) and height fixed to 0.5 in native  
coordinates.  I can't quite get the code right to do this.  Can anyone  
give me a quick example of how to do this?  I looked the gridBase index  
and the tutorial (from R-news?) but just haven't gotten it down yet.

 > plot(1:10,1:10)
 > par(new=T);vps <- baseViewports()
 > pushViewport(vps$inner,vps$figure,vps$plot)
viewport[GRID.VP.28]

At this point you are within a viewport which has x- and y-scales 
corresponding to the plot(1:10, 1:10).


 > pushViewport(viewport(x=unit(1,"native"),y=unit(2,"native")))
viewport[GRID.VP.29]

You have just created a new viewport at location (1, 2) in the plot, but 
 the scales on this new viewport are the default (0, 1).  i.e., you are 
now in a completely different coordinate system.  Also, this new 
viewport is as wide and as high as the plot region -- for example, it 
extends well beyong the left edge of the window/page.


grid.rect(height=unit(0.5,"native"),width=unit(1.5,"native"),just='botto 
m')

This draws a rectangle half as high as the current viewport and 1.5 
times as wide (the native scale in the current viewport is (0, 1) in 
both dimensions).  Importantly, the "native" coordinate systems you are 
referring to no longer correspond to the scales on the plot.


This draws a very large rectangle going from 2 to 7 (y) and to 8 (x).

Three things:
(i) If drawing rectangles relative to the current "native" (or user) 
coordinates is all you want to do then you could just use rect() and 
ignore gridBase altogether.  For example, ...

x <- sample(1:10, 10)
y <- 1:10
w <- runif(10)
h <- 0.5
plot(1:10,1:10)
rect(x - w/2, y - h/2, x + w/2, y + h/2)
(ii) Using grid and gridBase, the above example becomes ...
plot(1:10,1:10)
par(new=T);vps <- baseViewports()
pushViewport(vps$inner,vps$figure,vps$plot)
grid.rect(x=x, y=y, width=w, height=h, default.units="native")
popViewport(3)
... but as mentioned, this is like using a sledge hammer to kill a cat 
or whatever the expression is.

(iii) There would be justification in using grid and gridBase if you 
want to draw more than just a rectangle, especially if you want to use 
coordinates other than native.  Here's a trivial example (adds fixed 
size "whiskers" to the corners of the rectangles) ...

plot(1:10,1:10)
par(new=T);vps <- baseViewports()
pushViewport(vps$inner,vps$figure,vps$plot)
for (i in 1:10) {
  pushViewport(viewport(x=x[i], y=y[i], width=w[i], height=h,
default.units="native"))
  grid.rect()
  grid.segments(0, 0, unit(-1, "mm"), unit(-1, "mm"))
  grid.segments(0, 1, unit(-1, "mm"),
unit(1, "npc") + unit(1, "mm"))
  grid.segments(1, 1,
unit(1, "npc") + unit(1, "mm"),
unit(1, "npc") + unit(1, "mm"))
  grid.segments(1, 0,
unit(1, "npc") + unit(1, "mm"),
unit(-1, "mm"))
  popViewport()
}
... (but pushing a viewport per data point like this is a LOT slower).
Hope that helps
Paul
--
Dr Paul Murrell
Department of Statistics
The University of Auckland
Private Bag 92019
Auckland
New Zealand
64 9 3737599 x85392
[EMAIL PROTECTED]
http://www.stat.auckland.ac.nz/~paul/
__
[EMAIL PROTECTED] mailing list
https://stat.ethz.ch/mailman/listinfo/r-help
PLEASE do read the posting guide! http://www.R-project.org/posting-guide.html


Re: [R] Looking for .Call functions

2004-09-27 Thread Douglas Bates
Nathaniel B. Derby wrote:
Hi,
In my ongoing quest to track down the source of an error (see message 
"[R] optim error in arima" above), I find in the cource code for arima0 
the following:

arma0f <- function(p) {
par <- as.double(fixed)
par[mask] <- p
.Call("arma0fa", G, par, PACKAGE = "stats")
}
I would like to know what the function "arma0f" does.  Does the above 
mean that there is a function called "arma0fa" somewhere in R?  Where is 
it?  I couldn't find anything in Rinternals.h.
It means that in one of the .c source files in 
$RSRC/src/library/stats/src there will be a C function declared as

SEXP arma0fa(SEXP, SEXP);
(In fact it is declared in ts.h and defined in pacf.c in that directory)
__
[EMAIL PROTECTED] mailing list
https://stat.ethz.ch/mailman/listinfo/r-help
PLEASE do read the posting guide! http://www.R-project.org/posting-guide.html


Re: [R] multinom object :way of plotting??

2004-09-27 Thread John Fox
Dear Camille,

You might be interested in a paper (available at
http://socserv.socsci.mcmaster.ca/jfox/logit-effect-displays.pdf) that
Bob Andersen and I wrote on this topic. The paper deals with graphing
multinomial-logit and proportional-odds models.

Regards,
 John

On 27 Sep 2004 18:16:53 +0100
 Camille Szmaragd <[EMAIL PROTECTED]> wrote:
> Dear all,
> 
> I'm fitting a multinom function to my dataset
> (multinom(outcome~age+K+D)) and I need to present my results on a
> poster. Does someone know a nice way of doing that? I think I saw in
> an archive that you cannot plot a multinom.object, is it true?
> 
> Thank you by advance for your help,
> 
> Cheers
> 
> Camille
> 
> __
> [EMAIL PROTECTED] mailing list
> https://stat.ethz.ch/mailman/listinfo/r-help
> PLEASE do read the posting guide!
> http://www.R-project.org/posting-guide.html


John Fox
Department of Sociology
McMaster University
Hamilton, Ontario, Canada
http://socserv.mcmaster.ca/jfox/

__
[EMAIL PROTECTED] mailing list
https://stat.ethz.ch/mailman/listinfo/r-help
PLEASE do read the posting guide! http://www.R-project.org/posting-guide.html


[R] Looking for .Call functions

2004-09-27 Thread Nathaniel B. Derby
Hi,
In my ongoing quest to track down the source of an error (see message "[R] optim error in 
arima" above), I find in the cource code for arima0 the following:
arma0f <- function(p) {
par <- as.double(fixed)
par[mask] <- p
.Call("arma0fa", G, par, PACKAGE = "stats")
}
I would like to know what the function "arma0f" does.  Does the above mean that there is a 
function called "arma0fa" somewhere in R?  Where is it?  I couldn't find anything in 
Rinternals.h.
Thanks,
Nate
__
[EMAIL PROTECTED] mailing list
https://stat.ethz.ch/mailman/listinfo/r-help
PLEASE do read the posting guide! http://www.R-project.org/posting-guide.html


Re: [R] Re: cannot assign dimnames

2004-09-27 Thread Peter Dalgaard
"Dan Bebber" <[EMAIL PROTECTED]> writes:

> Dear list,
> 
> Please ignore my earlier message on this topic. I was under the mistaken
> impression that dimnames() named the dimensions themselves, rather than the
> indices within the dimensions.

The dimnames list can be named though:

> matrix(1:4,2,dimnames=list(foo=1:2,bar=c(10,20)))
   bar
foo 10 20
  1  1  3
  2  2  4


-- 
   O__   Peter Dalgaard Blegdamsvej 3  
  c/ /'_ --- Dept. of Biostatistics 2200 Cph. N   
 (*) \(*) -- University of Copenhagen   Denmark  Ph: (+45) 35327918
~~ - ([EMAIL PROTECTED]) FAX: (+45) 35327907

__
[EMAIL PROTECTED] mailing list
https://stat.ethz.ch/mailman/listinfo/r-help
PLEASE do read the posting guide! http://www.R-project.org/posting-guide.html


Re: [R] Re: cannot assign dimnames

2004-09-27 Thread Gabor Grothendieck
Gabor Grothendieck  myway.com> writes:

: 
: Dan Bebber  forestecology.co.uk> writes:
: 
: : Please ignore my earlier message on this topic. I was under the mistaken
: : impression that dimnames() named the dimensions themselves, rather than the
: : indices within the dimensions.
: 
: What you are referring to is done in R by referring to the names of
: the dimnames, as opposed to the dimnames, themselves.  Here is an
: example:
: 
: R> mat <- matrix(1:12,4, dimnames = list(letters[1:4],LETTERS[1:3]))
: R> names(dimnames(mat)) <- c("FirstDim", "SecondDim")
: R> mat
: SecondDim
: FirstDim A B  C
:a 1 5  9
:b 2 6 10
:c 3 7 11
:d 4 8 12

Perhaps I should have also mentioned that the above could be done
in a single line like this:

R> mat <- matrix(1:12,4, dimnames = list(FirstDim = letters[1:4], SecondDim = 
LETTERS[1:3]))
R> mat
SecondDim
FirstDim A B  C
   a 1 5  9
   b 2 6 10
   c 3 7 11
   d 4 8 12

__
[EMAIL PROTECTED] mailing list
https://stat.ethz.ch/mailman/listinfo/r-help
PLEASE do read the posting guide! http://www.R-project.org/posting-guide.html


Re: [R] Re: cannot assign dimnames

2004-09-27 Thread Gabor Grothendieck
Dan Bebber  forestecology.co.uk> writes:


: Please ignore my earlier message on this topic. I was under the mistaken
: impression that dimnames() named the dimensions themselves, rather than the
: indices within the dimensions.

What you are referring to is done in R by referring to the names of
the dimnames, as opposed to the dimnames, themselves.  Here is an
example:

R> mat <- matrix(1:12,4, dimnames = list(letters[1:4],LETTERS[1:3]))
R> names(dimnames(mat)) <- c("FirstDim", "SecondDim")
R> mat
SecondDim
FirstDim A B  C
   a 1 5  9
   b 2 6 10
   c 3 7 11
   d 4 8 12

__
[EMAIL PROTECTED] mailing list
https://stat.ethz.ch/mailman/listinfo/r-help
PLEASE do read the posting guide! http://www.R-project.org/posting-guide.html


[R] [R-pkgs] new version of package "distr" available

2004-09-27 Thread Peter Ruckdeschel
We would like to announce the availability on CRAN of a new version (1.4)
of our package "distr" .
-
Changes from 1.3 to 1.4
-To avoid name collisions with short forms for TRUE and FALSE: classes T
 and F (T- and F-distributions) renamed to Td and Fd
-The package is now loaded as a binary => considerable speed gain
-Using subsititute, the bodies of the r,d,p,q-function-slots
 distributions show the parameter values with which they were 
 generated
-Convolutions and applications of the math group may now be traced in
 r-slot of a distribution object, compare
  r(sin(Norm()) + cos(Unif() * 3 + 2))
-Parameters of a distribution (mean, sd, etc) are now tested on length 1
  *we see the objects as implementations of univariate distributions, so
   vectors  make  no sense here; rather one could gather several objects 
   with possibly different parameters to a vector of distributions.
   Of course, the original R-functions rnorm etc remain unchanged and
   still allow for vector-valued parameters.
  *
-Classes "Parameter" , "Distribution" , "UnivariateDistribution" are no
 longer VIRTUAL
-"AbscontParameter" and "DiscreteParameter" are replaced by "Parameter"
-Type of slots d,p,q  and param is changed to "OptionalFunction" and
 "OptionalParameter" respectively

-
Short Description of "distr":
"distr" is to provide a conceptual treatment of random variables
(r.v.'s) by means of S4--classes. A virtual mother class "Distribution" 
is introduced.
All distributions of the "base" package are implemented as subclasses of
either "AbscontDistribution" or "DiscreteDistribution".

Using these classes, we also provide (default) methods to automatically
generate the image distributions under unary mathematical operations as
well as a general convolution algorithm.

Additionally, we also provide classes for a standardized treatment of
simulations (also under contaminations) and evaluations of statistical
procedures on such simulations.
-


DESCRIPTION:

Package: distr
Version: 1.4
Date: 2004/09/23
Title: distr
Authors: Peter Ruckdeschel <[EMAIL PROTECTED]>,
Matthias Kohl <[EMAIL PROTECTED]>,
Thomas Stabla <[EMAIL PROTECTED]>,
Florian Camphausen <[EMAIL PROTECTED]>
Maintainer: Peter Ruckdeschel <[EMAIL PROTECTED]>
Description: S4 Classes for Distributions
Depends: R (>= 1.9.0),  (versions for <=1.8.x, on URL cited below),
setRNG (>= 2004.3-1)
License: GPL version 2 or later
URL: http://www.uni-bayreuth.de/departments/math/org/mathe7/DISTR/

Reference:  
http://www.uni-bayreuth.de/departments/math/org/mathe7/DISTR/distr.pdf

We look forward to receiving questions, comments and suggestions

Peter Ruckdeschel
Matthias Kohl
Thomas Stabla
Florian Camphausen

___
R-packages mailing list
[EMAIL PROTECTED]
https://stat.ethz.ch/mailman/listinfo/r-packages

__
[EMAIL PROTECTED] mailing list
https://stat.ethz.ch/mailman/listinfo/r-help
PLEASE do read the posting guide! http://www.R-project.org/posting-guide.html


Re: [R] exponential correlation?

2004-09-27 Thread TRAMIER Blaise
On Sat, Sep 25, 2004 at 01:21:34PM -0700, Spencer Graves wrote:
>  The "nlme" package has "corExp" for estimating the nuggett effect 
> n and the range d for an exponential spatial correlation structure = n + 
> (1-n)*exp(-r/d), where r = distance between two observations.  See 
> library(nlme);  ?corExp, plus Pinheiro and Bates (2000) Mixed-Effects 
> Models for S and S-Plus (Springer). 
>  Is this what you want? 
> 
Thanks, for your answer.
I'm afraid I was'nt very clear on what I needed.

In fact, I have a set of paired quantitatve values. When I plot them,
it looks like if the values where following a 1/exp(x) equation. 

I would like to make a regression on this dataset to find the equation and
eventually find the x-value where the slope becomes more tough (I'm not
sure it's the appropriate word, I hope you'll understand anyway). In
fact I need to find the cutoff value.

I'm not sure of what method to use to achieve that.

Here is a subset of the dataset (Y are RR):
X Y
82.0  1.00
72.0  2.45
53.0  3.88
45.0  8.76
71.0  1.00
60.0  2.00
40.0  4.76
20.0  12.05
8.0   11.62
87.0  1.00
78.0  1.03
65.0  1.21
41.0  2.78
75.0  1.00
67.5  1.53
45.0  1.81
30.0  3.76
75.0  1.00
62.0  1.90
42.0  4.10
17.0  5.40
86.0  1.00

so far I tried to do a non linear regression (nls):
> fm1<-nls(rrm ~ a/(exp(clr*c)),start=list(a=1,c=0.033),trace=T)
437.4397 :  1.000 0.033
120.0999 :  7.78174860 0.01381373
70.89977 :  13.15418549  0.03034625
67.18951 :  14.63044976  0.03070568
67.18892 :  14.62649511  0.03066069
67.18892 :  14.6270777  0.0306623
>summary(fm1)
Formula: rrm ~ a/(exp(clr * c))
Parameters:
   Estimate Std. Error t value Pr(>|t|)
a 14.627078   2.217950   6.595 2.01e-06 ***
c  0.030662   0.004876   6.288 3.87e-06 ***
---
Signif. codes:  0 `***' 0.001 `**' 0.01 `*' 0.05 `.' 0.1 ` ' 1

Residual standard error: 1.833 on 20 degrees of freedom

Correlation of Parameter Estimates:
   a
c 0.8091

But I'm not sure I'm going the right way. If somebody could give me an
advice on the way to proceed, it would be great.

To find the cutoff value for x, should try to use the equation
obtained by the regression or should I use the residuals between
original data and the fitted values?

Best Regards

Blaise

PS: I hope I've been more explicit this time and that my english is
readable.

__
[EMAIL PROTECTED] mailing list
https://stat.ethz.ch/mailman/listinfo/r-help
PLEASE do read the posting guide! http://www.R-project.org/posting-guide.html