[R] Discriminant analysis

2005-08-04 Thread C NL
Hi,

  I'm a newbie in R and don't much aobut all the
modules and their capabilities, but I'm interested in
solving a problem about a discriminant analysis done
with SPSS tool. The thing is that I would like to make
a discrimant analysis similar to the one done with
SPSS, but I can't find the way to solve it.

  I've been playing with R and I can handle more or
less my data, the point is that I need to know what
kind of discriminant analysis should I use to obtain
the same results as I obtain with SPSS. Should I use
"qda" or "lda"?? If not, what else could I use??

  Can anybody help me to find out a light in my way?
I've been searching all over the web to fetch any help
or example but I couldn't get anything.

  I would apreciate any help greatly.

Thanks

  Carlos Niharra López
  Software Engineer
  Madrid (Spain)



__ 

Nuevos servicios, más seguridad

__
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


[R] Problem

2005-08-04 Thread Ramesh Kolluru
  
Hi,
   I am a Equity Research Analyst & i have a task to do. "Ranking of Pair 
Trades" i.e.i have so many parameters like share price, Technical 
indicators(like Stochastic Indicator, Relative Strength Index, Directional 
Movement Indicator, Moving Acerage Convergence Divergence) and so on. Now i am 
looking for the trading opportunities in pair on the basis of all the above 
parameters. I want to give ranks to all the pairs to get in which pair i have 
more opportunity to play and earn...
 I have already started with using Principal Component Analysis(PCA) basically 
to reduce the dimension of the parameters on the basis of which i have to give 
the rank to the pairs. And after that i will go for the skewness in all the 
pair with respect to the reduced parameters.Where the skewness is more that 
will be rank 1 pair & so on.Because where the skewness is more there we will 
have more opportunities to play.
 But i am not confident with this appraoch. So, can you please help me with 
some other good method to solve this problem

Thanks in Advance

Regards,
Ramesh

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

Re: [R] Contour plot crest line

2005-08-04 Thread Spencer Graves
  Have you studied the examples on the help pages for "contour" and 
"persp"?  Also, if my memory is correct, there is some useful 
information this on Venables and Ripley, Modern Applied Statistics with 
S, 4th ed. (Springer).

  spencer graves

Michael Kubovy wrote:

> Any suggestions about drawing the ridge line on a response surface  
> represented as a contour plot?
> 
> _
> Professor Michael Kubovy
> University of Virginia
> Department of Psychology
> USPS: P.O.Box 400400Charlottesville, VA 22904-4400
> Parcels:Room 102Gilmer Hall
>  McCormick RoadCharlottesville, VA 22903
> Office:B011+1-434-982-4729
> Lab:B019+1-434-982-4751
> Fax:+1-434-982-4766
> WWW:http://www.people.virginia.edu/~mk9y/
> 
> __
> 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

-- 
Spencer Graves, PhD
Senior Development Engineer
PDF Solutions, Inc.
333 West San Carlos Street Suite 700
San Jose, CA 95110, USA

[EMAIL PROTECTED]
www.pdf.com 
Tel:  408-938-4420
Fax: 408-280-7915

__
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


Re: [R] Problem configuring R-patched

2005-08-04 Thread Kevin E. Thorpe
Duncan Murdoch wrote:
> Kevin E. Thorpe wrote:
> 
>> Gavin Simpson wrote:
>>
>>> On Thu, 2005-08-04 at 14:57 -0400, Kevin E. Thorpe wrote:
>>>
>>>
 I downloaded R-patched (2005-08-04) from CRAN today.
 I ran ./configure --enable-R-shlib

 I received the error message:

 checking for recommended packages... no
 configure: error: Some of the recommended packages are missing
  Use --without-recommended-packages if this was intentional
>>>
>>>
>>> ^^
>>> So was this intentional?
>>
>>
>>
>> No, it wasn't.
>>
>>
 I built a previous version of R-patched successfully on my system
 which is running the SuSE 9,2 Pro Linux distribution.  I untarred the
 tar ball into the same directory I did my last build on in case that's
 important.

 The only other differences between this attempt and my successful build
 are:

 1. I did not use --enable-R-shlib last time.
 2. I found and installed the blas libraries for this build.

 Have I messed up or made an erroneous assumption along the way?
>>>
>>>
>>>
>>> Yes and No. You obviously haven't compiled R recently. If you haven't
>>> got the recommended packages in the source you are compiling, configure
>>> now gives an error, which quite clearly states (and you've quoted it in
>>> your email!) that it cannot find (some of) the recommended packages.
>>
>>
>>
>> Actually, I compiled it about a week ago.  Here is my current version.
>>
>>  > version
>>   _
>> platform i686-pc-linux-gnu
>> arch i686
>> os   linux-gnu
>> system   i686, linux-gnu
>> status   Patched
>> major2
>> minor1.1
>> year 2005
>> month07
>> day  28
>> language R
>>
>> When I compiled that version, I did my "tar xzf" to a clean directory
>> and did not receive that error.
>>
>>
>>> A solution - again given by the error message you quote! - is:
>>>
>>> ./configure --enable-R-shlib --without-recommended-packages
>>>  ^
>>>
>>> That should clear things up.
>>
>>
>>
>> I realise that would clear it up.  I was puzzled why I got this message
>> in the first place, given I didn't get it last week.
> 
> 
> I believe there are two kinds of tar files.  The daily snapshots don't 
> include the recommended packages, the releases do.
> 
> Or perhaps the test is a recent addition.

Both versions were R-patched.tar.gz as opposed to the devel sets which
looks like it's actually a link to the most recent.  Maybe I incorrectly
assumed that the patched tarballs contained the recommended packages.

> Duncan Murdoch
> 
>>
>>
>>> Other wise you need to cd to the R directory (where you have the source
>>> code), and then execute ./tools/rsync-recommended and then run your
>>> configure command.
>>>
>>> HTH
>>>
>>> G
>>
>>
>>
>> Thanks for the rsync tip.

Anyway, running rsync-recommended did the trick.

Thanks

-- 
Kevin E. Thorpe
Biostatistician/Trialist, Knowledge Translation Program
Assistant Professor, Department of Public Health Sciences
Faculty of Medicine, University of Toronto
email: [EMAIL PROTECTED]  Tel: 416.946.8081  Fax: 416.971.2462

__
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


Re: [R] Avoiding for loop

2005-08-04 Thread Gabor Grothendieck
On 8/4/05, Matt Crawford <[EMAIL PROTECTED]> wrote:
> I understand that in R, for loops are not used as often as other
> languages, and am trying to learn how to avoid them.  I am wondering
> if there is a more efficient way to write a certain piece of code,
> which right now I can only envision as a for loop.  I have a data file
> that basically looks like:
> 1,55
> 1,23
> 2,12
> ...
> that defines a matrix.  Each row of the data file corresponds to a row
> of the matrix, where each number in the row tells me what column a "1"
> or "-1" should go into.  So the first row in the data snippet above
> means that the first row of my matrix needs to have a 1 in the 1st
> column, and a -1 in the 55nd column.  (And 0 elsewhere, which is
> already there as I've created the matrix filled with 0s beforehand.)
> 
> So my current code looks like:
>if(nrow(rawdata) >= 1) for(i in 1:nrow(rawdata)) {
>X[i, rawdata[i, 1]] <- 1
>X[i, rawdata[i, 2]] <- -1
>}
> 
> where rawdata is the original data file.
> This sort of assignment happens many times in my program so any
> improvement would be much appreciated.  Thanks.


idx <- seq(length = max(rawdata, 0))
X <- outer(rawdata[,1], idx, "==") - outer(rawdata[,2], idx, "==")

Note that we did not have to predefine X and it also works if rawdata
has zero rows:

   rawdata <- matrix(0, nr = 0, nc = 2) 

in which case it gives a 0 by 0 matrix.

__
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


Re: [R] An small suggestion for the R team

2005-08-04 Thread Jose Claudio Faria
Ok Duncan,

Thank you very much for the tip!
I will to remove all these identifiers.

Regards,
--
Jose Claudio Faria

Duncan Murdoch wrote:
> Jose Claudio Faria wrote:
> 
>> Hi all,
>>
>> I would like to suggest that all R functions/etc like:
>>codes-deprecated
>>grid-internal
>>ns-alt
>>ns-dblcolon
>>ns-hooks
>>ns-internals
>>ns-lowlev
>>ns-reflect.Rd
>>tools-internal
>>ts-defunct
>>utils-deprecated
>>utils-internal
>>... and another
>>
>> i.e, function/word separate for '-'
>>
>> were all substituted by
>>codes_deprecated
>>grid_internal
>>ns_alt
>>ns_dblcolon
>>ns_hooks
>>ns_internals
>>ns_lowlev
>>ns_reflect.Rd
>>tools_internal
>>ts_defunct
>>utils_deprecated
>>utils_internal
>>... and another
>>
>> i.e, by '_'
>>
>> Because it is impossible to make a good highlighter with the first one.
> 
> 
> Your suggested names are all valid identifiers.  The "-" gives strings 
> that are not.  That's intentional; the help system relies on it.  You 
> find "utils-deprecated" using deprecated?utils.
> 
> If your highlighter has problems with the "-", then don't bother 
> highlighting.  Those names aren't very common.  Or...
> 
>>
>> How to differentiating myValue:
>>
>> varOne = 100
>> varTwo = 50
>> myValue = varOne-varTwo
>>
>> from codes-deprecated, or ns-alt, for example.
> 
> 
> ...you could do it by context.  codes-deprecated will only show up in 
> *.Rd files as a possible search term:  an alias, or a name.
> 
> Duncan Murdoch
>

__
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


Re: [R] Problem configuring R-patched

2005-08-04 Thread Duncan Murdoch
Kevin E. Thorpe wrote:
> Gavin Simpson wrote:
> 
>>On Thu, 2005-08-04 at 14:57 -0400, Kevin E. Thorpe wrote:
>>
>>
>>>I downloaded R-patched (2005-08-04) from CRAN today.
>>>I ran ./configure --enable-R-shlib
>>>
>>>I received the error message:
>>>
>>>checking for recommended packages... no
>>>configure: error: Some of the recommended packages are missing
>>>  Use --without-recommended-packages if this was intentional
>>
>> ^^
>>So was this intentional?
> 
> 
> No, it wasn't.
> 
> 
>>>I built a previous version of R-patched successfully on my system
>>>which is running the SuSE 9,2 Pro Linux distribution.  I untarred the
>>>tar ball into the same directory I did my last build on in case that's
>>>important.
>>>
>>>The only other differences between this attempt and my successful build
>>>are:
>>>
>>>1. I did not use --enable-R-shlib last time.
>>>2. I found and installed the blas libraries for this build.
>>>
>>>Have I messed up or made an erroneous assumption along the way?
>>
>>
>>Yes and No. You obviously haven't compiled R recently. If you haven't
>>got the recommended packages in the source you are compiling, configure
>>now gives an error, which quite clearly states (and you've quoted it in
>>your email!) that it cannot find (some of) the recommended packages.
> 
> 
> Actually, I compiled it about a week ago.  Here is my current version.
> 
>  > version
>   _
> platform i686-pc-linux-gnu
> arch i686
> os   linux-gnu
> system   i686, linux-gnu
> status   Patched
> major2
> minor1.1
> year 2005
> month07
> day  28
> language R
> 
> When I compiled that version, I did my "tar xzf" to a clean directory
> and did not receive that error.
> 
> 
>>A solution - again given by the error message you quote! - is:
>>
>>./configure --enable-R-shlib --without-recommended-packages
>>  ^
>>
>>That should clear things up.
> 
> 
> I realise that would clear it up.  I was puzzled why I got this message
> in the first place, given I didn't get it last week.

I believe there are two kinds of tar files.  The daily snapshots don't 
include the recommended packages, the releases do.

Or perhaps the test is a recent addition.

Duncan Murdoch

> 
> 
>>Other wise you need to cd to the R directory (where you have the source
>>code), and then execute ./tools/rsync-recommended and then run your
>>configure command.
>>
>>HTH
>>
>>G
> 
> 
> Thanks for the rsync tip.
>

__
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


Re: [R] An small suggestion for the R team

2005-08-04 Thread Jose Claudio Faria
Hi THomas,

This is very a good information: thanks very much!
So, I will just now to remove all from the highlighters.
BTW, do you know if the signal minus is used in some function or reserved word?

TIA,

Jose Claudio Faria

Thomas Lumley wrote:
> On Thu, 4 Aug 2005, Jose Claudio Faria wrote:
> 
> I would like to suggest that all R functions/etc like:
>  codes-deprecated
>  grid-internal
>  ns-alt
>  ns-dblcolon
>  ns-hooks
>  ns-internals
>  ns-lowlev
>  ns-reflect.Rd
>  tools-internal
>  ts-defunct
>  utils-deprecated
>  utils-internal
>  ... and another
>
> 
> These are not R functions or reserved works. They are just the names of 
> help pages.  They should not occur in code (except in double-quoted 
> strings).
> 
> -thomas

__
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


Re: [R] An small suggestion for the R team

2005-08-04 Thread Duncan Murdoch
Jose Claudio Faria wrote:
> Hi all,
> 
> I would like to suggest that all R functions/etc like:
>codes-deprecated
>grid-internal
>ns-alt
>ns-dblcolon
>ns-hooks
>ns-internals
>ns-lowlev
>ns-reflect.Rd
>tools-internal
>ts-defunct
>utils-deprecated
>utils-internal
>... and another
> 
> i.e, function/word separate for '-'
> 
> were all substituted by
>codes_deprecated
>grid_internal
>ns_alt
>ns_dblcolon
>ns_hooks
>ns_internals
>ns_lowlev
>ns_reflect.Rd
>tools_internal
>ts_defunct
>utils_deprecated
>utils_internal
>... and another
> 
> i.e, by '_'
> 
> Because it is impossible to make a good highlighter with the first one.

Your suggested names are all valid identifiers.  The "-" gives strings 
that are not.  That's intentional; the help system relies on it.  You 
find "utils-deprecated" using deprecated?utils.

If your highlighter has problems with the "-", then don't bother 
highlighting.  Those names aren't very common.  Or...
> 
> How to differentiating myValue:
> 
> varOne = 100
> varTwo = 50
> myValue = varOne-varTwo
> 
> from codes-deprecated, or ns-alt, for example.

...you could do it by context.  codes-deprecated will only show up in 
*.Rd files as a possible search term:  an alias, or a name.

Duncan Murdoch

__
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


Re: [R] Avoiding for loop

2005-08-04 Thread Thomas Lumley
On Thu, 4 Aug 2005, Matt Crawford wrote:

> I understand that in R, for loops are not used as often as other
> languages, and am trying to learn how to avoid them.  I am wondering
> if there is a more efficient way to write a certain piece of code,
> which right now I can only envision as a for loop.  I have a data file
> that basically looks like:
> 1,55
> 1,23
> 2,12
> ...
> that defines a matrix.  Each row of the data file corresponds to a row
> of the matrix, where each number in the row tells me what column a "1"
> or "-1" should go into.  So the first row in the data snippet above
> means that the first row of my matrix needs to have a 1 in the 1st
> column, and a -1 in the 55nd column.  (And 0 elsewhere, which is
> already there as I've created the matrix filled with 0s beforehand.)
>

This may be a job for matrix indexes

ii<-1:nrow(rawdata)
X[cbind(ii,rawdata[,1])] <- 1
X[cbind(ii,rawdata[,2])] <- -1


-thomas

__
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


Re: [R] An small suggestion for the R team

2005-08-04 Thread Thomas Lumley
On Thu, 4 Aug 2005, Jose Claudio Faria wrote:
 I would like to suggest that all R functions/etc like:
  codes-deprecated
  grid-internal
  ns-alt
  ns-dblcolon
  ns-hooks
  ns-internals
  ns-lowlev
  ns-reflect.Rd
  tools-internal
  ts-defunct
  utils-deprecated
  utils-internal
  ... and another


These are not R functions or reserved works. They are just the names of 
help pages.  They should not occur in code (except in double-quoted 
strings).

-thomas

__
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


[R] Avoiding for loop

2005-08-04 Thread Matt Crawford
I understand that in R, for loops are not used as often as other
languages, and am trying to learn how to avoid them.  I am wondering
if there is a more efficient way to write a certain piece of code,
which right now I can only envision as a for loop.  I have a data file
that basically looks like:
1,55
1,23
2,12
...
that defines a matrix.  Each row of the data file corresponds to a row
of the matrix, where each number in the row tells me what column a "1"
or "-1" should go into.  So the first row in the data snippet above
means that the first row of my matrix needs to have a 1 in the 1st
column, and a -1 in the 55nd column.  (And 0 elsewhere, which is
already there as I've created the matrix filled with 0s beforehand.)

So my current code looks like:
if(nrow(rawdata) >= 1) for(i in 1:nrow(rawdata)) {
X[i, rawdata[i, 1]] <- 1
X[i, rawdata[i, 2]] <- -1
} 

where rawdata is the original data file.
This sort of assignment happens many times in my program so any
improvement would be much appreciated.  Thanks.

__
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


[R] Where the error message comes from?

2005-08-04 Thread Mohammad A. Chaudhary
Hi all:

I get the following error message that I am not able to resolve.

 

Error in if (const(t, min(1e-08, mean(t)/1e+06))) { : 

missing value where TRUE/FALSE needed

 

It appears right before the last data.frame statement. 

 

Below is the program that simulates data from one way random effects
model and then computes normality and bootstrap confidence interval for
Cost-Effectiveness Ratio. 

 

I have pasted the message in blue.

 

I appreciate any guidance in figuring it out.

Ashraf

 

 SIMULATING DATA #

SimClust <- function(k,m,mu,sb2,sw2,r,z)  {

#set.seed(1234)

 

# k   = Number of groups

# m   = Group size

# mu  = Group mean, same for all groups

# sb2 = Between group variance

# sw2 = Within group variance 

# r   = Corelation coefficient

# z   = standard normal variate cutoff value for binomial rv

  

# Simulate the random effects

   A = rnorm(n=k, mean=0, sd=sqrt(sb2))

 

# Work out the mean of each group of data

   means = matrix(mu, nrow=k,ncol=1)

   for(row in 1:k){

 means[row] = means[row,1] + A[row]}

 

# Initializing the data vectors

  g=c=c1=mu1=numeric(k*m)

 

# Now generate the data one group at a time.

ind=0   

for(u in 1:k){

   for(replicate in 1:m){

 ind = ind + 1

   x=rnorm(1);y=rnorm(1)

   c[ind] = sqrt(sw2)*x+means[u]

   c1[ind] <- sqrt(sw2)*(x*r+y*sqrt(1-r**2))+means[u] 

   g[ind] = u

   mu1[ind] =means[u]

 }}  

 

data.frame(g=factor(g),c,e=(c1 > mean(c1)+z*sd(c1))+0)

}

 

#

sk1=sk2=sk11=sk21=skR=k1=m1=R2=R1=n10=f10=nb10=b10=s10=p10=bca10=NULL

n.cp=f.cp=nb.cp=b.cp=s.cp=p.cp=bca.cp=NULL

   

for (k in c(12,24,48)) {

for (m in c(25,50,100)) {

for (j in 1:1000) {

 

 PREPARING CLUSTER LEVEL DATA ##

 d1=SimClust(k,m,mu=30,sb2=25,sw2=75,r=0.5,z=0.841621)  # for p=0.2

 d2=SimClust(k,m,mu=20,sb2=25,sw2=75,r=0.5,z=1.281552)  # for p=0.1

 

## TREATMENT ##

r1 <- cor(d1[,2:3])[1,2]

# COST #

  ac1 <- anova(lm(c~g,d1))

  rc1 <- (ac1[1,3]-ac1[2,3])/(ac1[1,3]+(m-1)*ac1[2,3])

if (rc1 < 0) rc1 <- 0 

  vc1 <- var(d1[,2])

  mc1 <- as.vector(by(d1[,2],as.numeric(d1[,1]),mean))

  vc1m <- vc1*(1+(m-1)*rc1)/(k*m)

# EFFECT #

  ae1 <- anova(lm(e~g,d1))

  re1 <- (ae1[1,3]-ae1[2,3])/(ae1[1,3]+(m-1)*ae1[2,3])

if (re1 < 0) re1 <- 0 

  ve1 <- var(d1[,3])

  me1 <- as.vector(by(d1[,3],as.numeric(d1[,1]),mean))

  re1p <- 1- m*sum(me1*(1-me1))/(k*(m-1)*mean(me1)*(1-mean(me1)))

  ve1m <- ve1*(1+(m-1)*re1)/(k*m)

## CONTROL ##

r2 <- cor(d2[,2:3])[1,2]

# COST #

  ac2 <- anova(lm(c~g,d2))

  rc2 <- (ac2[1,3]-ac2[2,3])/(ac2[1,3]+(m-1)*ac2[2,3])

if (rc2 < 0) rc2 <- 0 

  vc2 <- var(d2[,2])

  mc2 <- as.vector(by(d2[,2],as.numeric(d2[,1]),mean))

  vc2m <- vc2*(1+(m-1)*rc2)/(k*m)

#  EFECT #

  ae2 <- anova(lm(e~g,d2))

  re2 <- (ae2[1,3]-ae2[2,3])/(ae2[1,3]+(m-1)*ae2[2,3])

if (re2 < 0) re2 <- 0 

  ve2 <- var(d2[,3])

  me2 <- as.vector(by(d2[,3],as.numeric(d2[,1]),mean))

  re2p <- 1- m*sum(me2*(1-me2))/(k*(m-1)*mean(me2)*(1-mean(me2)))

  ve2m <- ve2*(1+(m-1)*re2)/(k*m)

 

## Combining and Computing ICER ##

d <- data.frame(s = c(rep(1,k),rep(2,k)),

i = c(1:k,1:k),  n =rep(m,2*k),
mc=c(mc1,mc2),me=c(me1,me2)) 

 

 mmc1   <- mean(d[1:k,4])

 mmc2   <- mean(d[(k+1):(2*k),4])

 mme1   <- mean(d[1:k,5])

 mme2   <- mean(d[(k+1):(2*k),5])

 

 cnn <- (vc1m+vc2m)/(mmc1-mmc2)^2

 cdd <- (ve1m+ve2m)/(mme1-mme2)^2

 cnd <-
(r1*(vc1m*ve1m)^0.5+r2*(vc2m*ve2m)^0.5)/((mmc1-mmc2)*(mme1-mme2))

 

 R  <- (mmc1-mmc2)/(mme1-mme2)

 seR  <- R*(cnn+cdd-2*cnd)^0.5

f1 <-
R*((1-3.8416*cnd)-1.96*((cnn+cdd-2*cnd)-3.8416*(cnn*cdd-cnd^2))^0.5)/(1-
3.8416*cdd)

f2 <-
R*((1-3.8416*cnd)+1.96*((cnn+cdd-2*cnd)-3.8416*(cnn*cdd-cnd^2))^0.5)/(1-
3.8416*cdd)

 

 BOOTSTRAPPING AND PRINTING ##   

icer<-function(d0,f)  {

 

 mmc1 <- mean(d0[1:k,4]*f[1:k])

 mmc2 <- mean(d0[(k+1):(2*k),4]*f[(k+1):(2*k)])

 mme1 <- mean(d0[1:k,5]*f[1:k])

 mme2 <- mean(d0[(k+1):(2*k),5]*f[(k+1):(2*k)])

 

 c((mmc1-mmc2)/(mme1-mme2),seR^2)

}

 

bout <- boot(d,icer, R=999, stype="f", strata=d[,1])

bci <- boot.ci(bout, conf = 0.95,  type =
c("norm","basic","stud","perc","bca")) 

 

sk1[j] <- 3*(mean(d1[,2])-median(d1[,2]))/sd(d1[,2])

sk2[j] <- 3*(mean(d2[,2])-median(d2[,2]))/sd(d2[,2])

 

 

R2[j]  <- R

   n10[j]  <- (100 < R-1.96*seR|| R+1.96*seR > 100)+0

   f10[j]  <- (100 < f1 || f2 > 100)+0

  nb10[j]  <- (100 < bci$norm[,2]  || bci$norm[,3]  > 100)+0

   b10[j]  <- (100 < bci$basic[,4] || bci$basic[,5] > 100)+0

   s10[j]  <- (100 < bci$stud[,4]  || bci$stud[,5]  > 100)+0

   p10[j]  <- (100 < bci$perc[,4]  || bci$perc[,5]  > 100)+0

 bca10[j]  <- (100 < bci$bca[,4]   || bci$bca[,5]   > 100)+0

}

 

k1=c(k1,k); m1=c(m1,m); R1=c(R1,mean(R2)); sk11=c(sk11,mean(sk1));
sk21=c(sk21,mean(sk2));skR=c(skR,3*(mean(R2)-median(R2))/sd(R2));

n.cp=c(n.cp,mean(n10)); f.cp=c(f.cp,mean(f10));
nb.cp=c(nb.cp,mean(n

Re: [R] An small suggestion for the R team

2005-08-04 Thread Jose Claudio Faria
Gabor Grothendieck wrote:
> On 8/4/05, Gabor Grothendieck <[EMAIL PROTECTED]> wrote:
> 
>>On 8/4/05, Jose Claudio Faria <[EMAIL PROTECTED]> wrote:
>>
>>>Hi all,
>>>
>>>I would like to suggest that all R functions/etc like:
>>>  codes-deprecated
>>>  grid-internal
>>>  ns-alt
>>>  ns-dblcolon
>>>  ns-hooks
>>>  ns-internals
>>>  ns-lowlev
>>>  ns-reflect.Rd
>>>  tools-internal
>>>  ts-defunct
>>>  utils-deprecated
>>>  utils-internal
>>>  ... and another
>>>
>>>i.e, function/word separate for '-'
>>>
>>>were all substituted by
>>>  codes_deprecated
>>>  grid_internal
>>>  ns_alt
>>>  ns_dblcolon
>>>  ns_hooks
>>>  ns_internals
>>>  ns_lowlev
>>>  ns_reflect.Rd
>>>  tools_internal
>>>  ts_defunct
>>>  utils_deprecated
>>>  utils_internal
>>>  ... and another
>>>
>>>i.e, by '_'
>>>
>>>Because it is impossible to make a good highlighter with the first one.
>>>
>>>How to differentiating myValue:
>>>
>>>varOne = 100
>>>varTwo = 50
>>>myValue = varOne-varTwo
>>>
>>>from codes-deprecated, or ns-alt, for example.
>>
>>One can create a variable with a minus in it by using
>>backquotes:
>>
>>
>>>`a-b` <- 3
>>>a <- 10
>>>b <- 4
>>>`a-b` + a-b
>>
>>[1] 9  # 3 + 10 - 4
>>
> 
> 
> One other point.  The help system, i.e. ?, accommodates minus
> signs like this where the last two statements below give
> the same result:
> 
> library(survival)
> ?"survival-internal"
> internal?survival
> 
> Another example is,
> 
> library(dyn)
> package?dyn

Indeed, the above are very good examples of how to contour the original problem 
Gabor!
But the central problem is to make Good R highlighter, as I'm trying to do
for the programs Tinn-R and jEdit with this functions.

Is not possible differentiate the signal minus as a simple character 
(word-word) from
the mathematical operator minus (object-object).

I think that is more easy to remove all this functions/reserved words.

TIA,
-- 
Jose Claudio Faria
Brasil/Bahia/UESC/DCET
Estatistica Experimental/Prof. Adjunto
mails:
  [EMAIL PROTECTED]
  [EMAIL PROTECTED]
  [EMAIL PROTECTED]
tel: 73-3634.2779

__
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


Re: [R] An small suggestion for the R team

2005-08-04 Thread Gabor Grothendieck
On 8/4/05, Gabor Grothendieck <[EMAIL PROTECTED]> wrote:
> On 8/4/05, Jose Claudio Faria <[EMAIL PROTECTED]> wrote:
> > Hi all,
> >
> > I would like to suggest that all R functions/etc like:
> >   codes-deprecated
> >   grid-internal
> >   ns-alt
> >   ns-dblcolon
> >   ns-hooks
> >   ns-internals
> >   ns-lowlev
> >   ns-reflect.Rd
> >   tools-internal
> >   ts-defunct
> >   utils-deprecated
> >   utils-internal
> >   ... and another
> >
> > i.e, function/word separate for '-'
> >
> > were all substituted by
> >   codes_deprecated
> >   grid_internal
> >   ns_alt
> >   ns_dblcolon
> >   ns_hooks
> >   ns_internals
> >   ns_lowlev
> >   ns_reflect.Rd
> >   tools_internal
> >   ts_defunct
> >   utils_deprecated
> >   utils_internal
> >   ... and another
> >
> > i.e, by '_'
> >
> > Because it is impossible to make a good highlighter with the first one.
> >
> > How to differentiating myValue:
> >
> > varOne = 100
> > varTwo = 50
> > myValue = varOne-varTwo
> >
> > from codes-deprecated, or ns-alt, for example.
> 
> One can create a variable with a minus in it by using
> backquotes:
> 
> > `a-b` <- 3
> > a <- 10
> > b <- 4
> > `a-b` + a-b
> [1] 9  # 3 + 10 - 4
> 

One other point.  The help system, i.e. ?, accommodates minus
signs like this where the last two statements below give
the same result:

library(survival)
?"survival-internal"
internal?survival

Another example is,

library(dyn)
package?dyn

__
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


Re: [R] An small suggestion for the R team

2005-08-04 Thread Gabor Grothendieck
On 8/4/05, Jose Claudio Faria <[EMAIL PROTECTED]> wrote:
> Hi all,
> 
> I would like to suggest that all R functions/etc like:
>   codes-deprecated
>   grid-internal
>   ns-alt
>   ns-dblcolon
>   ns-hooks
>   ns-internals
>   ns-lowlev
>   ns-reflect.Rd
>   tools-internal
>   ts-defunct
>   utils-deprecated
>   utils-internal
>   ... and another
> 
> i.e, function/word separate for '-'
> 
> were all substituted by
>   codes_deprecated
>   grid_internal
>   ns_alt
>   ns_dblcolon
>   ns_hooks
>   ns_internals
>   ns_lowlev
>   ns_reflect.Rd
>   tools_internal
>   ts_defunct
>   utils_deprecated
>   utils_internal
>   ... and another
> 
> i.e, by '_'
> 
> Because it is impossible to make a good highlighter with the first one.
> 
> How to differentiating myValue:
> 
> varOne = 100
> varTwo = 50
> myValue = varOne-varTwo
> 
> from codes-deprecated, or ns-alt, for example.

One can create a variable with a minus in it by using
backquotes:

> `a-b` <- 3
> a <- 10
> b <- 4
> `a-b` + a-b
[1] 9  # 3 + 10 - 4

__
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


Re: [R] Problem configuring R-patched

2005-08-04 Thread Kevin E. Thorpe
Gavin Simpson wrote:
> On Thu, 2005-08-04 at 14:57 -0400, Kevin E. Thorpe wrote:
> 
>>I downloaded R-patched (2005-08-04) from CRAN today.
>>I ran ./configure --enable-R-shlib
>>
>>I received the error message:
>>
>>checking for recommended packages... no
>>configure: error: Some of the recommended packages are missing
>>   Use --without-recommended-packages if this was intentional
> 
>  ^^
> So was this intentional?

No, it wasn't.

> 
>>I built a previous version of R-patched successfully on my system
>>which is running the SuSE 9,2 Pro Linux distribution.  I untarred the
>>tar ball into the same directory I did my last build on in case that's
>>important.
>>
>>The only other differences between this attempt and my successful build
>>are:
>>
>>1. I did not use --enable-R-shlib last time.
>>2. I found and installed the blas libraries for this build.
>>
>>Have I messed up or made an erroneous assumption along the way?
> 
> 
> Yes and No. You obviously haven't compiled R recently. If you haven't
> got the recommended packages in the source you are compiling, configure
> now gives an error, which quite clearly states (and you've quoted it in
> your email!) that it cannot find (some of) the recommended packages.

Actually, I compiled it about a week ago.  Here is my current version.

 > version
  _
platform i686-pc-linux-gnu
arch i686
os   linux-gnu
system   i686, linux-gnu
status   Patched
major2
minor1.1
year 2005
month07
day  28
language R

When I compiled that version, I did my "tar xzf" to a clean directory
and did not receive that error.

> A solution - again given by the error message you quote! - is:
> 
> ./configure --enable-R-shlib --without-recommended-packages
>   ^
> 
> That should clear things up.

I realise that would clear it up.  I was puzzled why I got this message
in the first place, given I didn't get it last week.

> Other wise you need to cd to the R directory (where you have the source
> code), and then execute ./tools/rsync-recommended and then run your
> configure command.
> 
> HTH
> 
> G

Thanks for the rsync tip.

-- 
Kevin E. Thorpe
Biostatistician/Trialist, Knowledge Translation Program
Assistant Professor, Department of Public Health Sciences
Faculty of Medicine, University of Toronto
email: [EMAIL PROTECTED]  Tel: 416.946.8081  Fax: 416.971.2462

__
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


[R] An small suggestion for the R team

2005-08-04 Thread Jose Claudio Faria
Hi all,

I would like to suggest that all R functions/etc like:
   codes-deprecated
   grid-internal
   ns-alt
   ns-dblcolon
   ns-hooks
   ns-internals
   ns-lowlev
   ns-reflect.Rd
   tools-internal
   ts-defunct
   utils-deprecated
   utils-internal
   ... and another

i.e, function/word separate for '-'

were all substituted by
   codes_deprecated
   grid_internal
   ns_alt
   ns_dblcolon
   ns_hooks
   ns_internals
   ns_lowlev
   ns_reflect.Rd
   tools_internal
   ts_defunct
   utils_deprecated
   utils_internal
   ... and another

i.e, by '_'

Because it is impossible to make a good highlighter with the first one.

How to differentiating myValue:

varOne = 100
varTwo = 50
myValue = varOne-varTwo

from codes-deprecated, or ns-alt, for example.

TIA,
-- 
Jose Claudio Faria
Brasil/Bahia/UESC/DCET
Estatistica Experimental/Prof. Adjunto
mails:
  [EMAIL PROTECTED]
  [EMAIL PROTECTED]
  [EMAIL PROTECTED]
tel: 73-3634.2779

__
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


[R] p-values

2005-08-04 Thread Peter Ho
HI R-users,

I am trying to repeat an example from Rayner and Best "A contingency 
table approach to nonparametric testing (Chapter 7, Ice cream example).

In their book they calculate Durbin's statistic, D1, a dispersion 
statistics, D2, and a residual. P-values for each statistic is 
calculated from a chi-square distribution and also Monte Carlo p-values.

I have found similar p-values based on the chi-square distribution by 
using:

 > pchisq(12, df= 6, lower.tail=F)
[1] 0.0619688
 > pchisq(5.1, df= 6, lower.tail=F)
[1] 0.5310529

Is there a way to calculate the equivalent Monte Carlo p-values?

The values were 0.02 and 0.138 respectively.

The use of the approximate chi-square probabilities for Durbin's test 
are considered not good enough according to Van der Laan (The American 
Statistician 1988,42,165-166).


Peter

ESTG-IPVC

__
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


[R] exact goodness-of-fit test

2005-08-04 Thread Christine Adrion
Hello,

I have a question concerning the R-function chisq.test. 

For example, I have some count data which can be categorized as follows
class1: 15 observations
class2:  0 observations
class3:  3 observations
class4:  4 observations

I would like to test the hypothesis whether the population probabilities are 
all equal (=> Test for discrete uniform distribution)
If you have a small sample size and therefore a sparse (1xr)-table, then 
assumptions for chisquare-goodness-of-fit test are violated (the numbers 
expected are less than 5 in more than 75% of the entries.)

###  R-Program: Chisquare-Test :#

mydata <- c(15,0,3,4)
chisq.test(mydata, correct=TRUE, rescale.p = TRUE, simulate.p.value = TRUE, B = 
2000)


As you cannot ignore the small sample size, I use 'simulate.p.value' is 'TRUE'  
and therefore the p-value is computed by Monte Carlo simulation with 'B' 
replicates.
But is it also the possible to use an EXACT version of a chisquare 
goodness-of-fit test without a Monte-Carlo-simulation? How can I calculate this 
in R?



Any hint would be appreciated,
Regards,
Christine Adrion
[[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


Re: [R] Problem configuring R-patched

2005-08-04 Thread Gavin Simpson
On Thu, 2005-08-04 at 14:57 -0400, Kevin E. Thorpe wrote:
> I downloaded R-patched (2005-08-04) from CRAN today.
> I ran ./configure --enable-R-shlib
> 
> I received the error message:
> 
> checking for recommended packages... no
> configure: error: Some of the recommended packages are missing
>Use --without-recommended-packages if this was intentional
 ^^
So was this intentional?

> I built a previous version of R-patched successfully on my system
> which is running the SuSE 9,2 Pro Linux distribution.  I untarred the
> tar ball into the same directory I did my last build on in case that's
> important.
> 
> The only other differences between this attempt and my successful build
> are:
> 
> 1. I did not use --enable-R-shlib last time.
> 2. I found and installed the blas libraries for this build.
> 
> Have I messed up or made an erroneous assumption along the way?

Yes and No. You obviously haven't compiled R recently. If you haven't
got the recommended packages in the source you are compiling, configure
now gives an error, which quite clearly states (and you've quoted it in
your email!) that it cannot find (some of) the recommended packages.

A solution - again given by the error message you quote! - is:

./configure --enable-R-shlib --without-recommended-packages
  ^

That should clear things up.

Other wise you need to cd to the R directory (where you have the source
code), and then execute ./tools/rsync-recommended and then run your
configure command.

HTH

G
-- 
%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%
Gavin Simpson [T] +44 (0)20 7679 5522
ENSIS Research Fellow [F] +44 (0)20 7679 7565
ENSIS Ltd. & ECRC [E] gavin.simpsonATNOSPAMucl.ac.uk
UCL Department of Geography   [W] http://www.ucl.ac.uk/~ucfagls/cv/
26 Bedford Way[W] http://www.ucl.ac.uk/~ucfagls/
London.  WC1H 0AP.
%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%

__
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


Re: [R] how to read individual values from a pixmap object

2005-08-04 Thread Ben Bolker
Ben Bolker  ufl.edu> writes:

> 
> Tony Gill  uq.edu.au> writes:
> 
> > 
> > Hi All,
> > 
> > I have a greyscale image ...
> library(pixmap)

> x <- read.pnm("graypic.pnm")
> str(x)
> x  grey[1,1]
> 

  just in case there's any confusion ... that  should
be an at-symbol!

__
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


Re: [R] alaska map? - answers

2005-08-04 Thread Caitlin Burgess

Thanks very much to Roger Bivand and Greg Snow who wrote, respectively:

>map("world2", "USA:alaska")
>
>
>gives the low resolution, using the "world" database is split on the date
>line. The mapdata package has better resolution.


and


>Look at:
>
>http://www.census.gov/geo/www/cob/bdy_files.html
>
>There are shapefiles of the 50 states there, outlines, counties, and
>others.






> On Mon, 25 Jul 2005, Caitlin Burgess wrote:
>
>> Hello,
>>
>> I've installed the Becker and Wilks maps, mapdata, and mapproj packages
>> so I can begin
>> to try these out for some work I need to do on a map of
>> Alaska but I don't know where to find a map of Alaska. Has anyone solved
>> this already and could help?
>>
>> Thanks very much in advance,
>>
>> Caitlin
>>
>> __
>> 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
>>

__
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


Re: [R] how to read individual values from a pixmap object

2005-08-04 Thread Ben Bolker
Tony Gill  uq.edu.au> writes:

> 
> Hi All,
> 
> I have a greyscale image that I am reading in through RGDAL and placing in a
> pixmap object.
> 

> 

library(pixmap)
x <- read.pnm("graypic.pnm")
str(x)
[EMAIL PROTECTED],1]

__
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


Re: [R] interpolation function in R

2005-08-04 Thread Sundar Dorai-Raj


吴 昊 wrote:
> Hi
> does R provide some interpolation fucntions?
> thank
> 
> 
> 
> 
> __
> 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

PLEASE do read the posting guide!

help.search("interpolation")

returns

interpSpline(splines)   Create an Interpolation Spline
periodicSpline(splines)
Create a Periodic Interpolation Spline
NLSstClosestX(stats)Inverse Interpolation
approx(stats)   Interpolation Functions
spline(stats)   Interpolating Splines

for example. There may be others in packages I don't have installed as well.

HTH,

--sundar

__
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

Re: [R] interpolation function in R

2005-08-04 Thread Rolf Turner

?approx

?splinefun

__
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


[R] FW: color palette

2005-08-04 Thread Tuszynski, Jaroslaw W.

Try:

n   = 100;
x   = matrix(seq(-10, 30, length.out=500), ncol=1)
col = colorRampPalette( c("green", "white", "red"), space="rgb")(n) breaks =
c(seq(-10, 0, length.out=n/2)-0.5, 0, seq(0, 30, length.out=n/2)+0.5)
image(x, col=col, breaks=breaks)

See also today's discussion on R-Help about "red-black-green color palette",
since most of the code above came from Earl Glyn post.

Jarek
\===

 Jarek Tuszynski, PhD.   o / \ 
 Science Applications International Corporation  <\__,|  
 (703) 676-4192   ">   \
 [EMAIL PROTECTED] `\



-Original Message-
From: [EMAIL PROTECTED]
[mailto:[EMAIL PROTECTED] On Behalf Of array chip
Sent: Thursday, August 04, 2005 12:31 PM
To: Thomas Lumley
Cc: r-help@stat.math.ethz.ch
Subject: Re: [R] color palette

Thanks for the suggestion. I still could not figure out how to use the
function to do my job. What's important in my job is that I have to map
white color to value 0, and then form a bue gradient for negative values,
and red gradient for positive values. The data matrix I have is not
symmetric aound 0, say 0 is at the 18 percentile, and values range from -10
to 30.
How exactly I could do my job? Bear with me, I am new to color, I don't
quite understand how the image function map the number is the data matrix to
the colors defined in the col argument.

Thanks


--- Thomas Lumley <[EMAIL PROTECTED]> wrote:

> On Wed, 3 Aug 2005, array chip wrote:
> 
> > Hi, I have a matrix with both positive and
> negative
> > numbers, I would like to use image() to draw a heatmap. How can I 
> > can design a palette (or is
> there a
> > function already available) that treat negative numbers in a blue 
> > gradient and positive numbers in
> a
> > red gradient and treat 0 as white?
> >
> 
> ?colorRampPalette
> 
>   -thomas
>

__
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

__
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


[R] interpolation function in R

2005-08-04 Thread 吴 昊

Hi
does R provide some interpolation fucntions?
thank

__
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

[R] some thoughts on outlier detection, need help!

2005-08-04 Thread Weiwei Shi
Dear listers:
I have an idea to do the outlier detection and I need to use R to
implement it first. Here I hope I can get some input from all the
guru's here.

I select distance-based approach---
step 1:
calculate the distance of any two rows for a dataframe. considering
the scaling among different variables, I choose mahalanobis, using
variance as scaler.

step 2:
Let k be the number of points in one "cluster". K is decided by
answering the following question: how many neighbors a point needs for
not being an outlier.

for each point, get the smallest (k-1) distances from step1.  Among
the (k-1) distances of each point, get the max for the point.

step 3:
get the distribution of those max for all the points. Thus, the
multivariate problem becomes a univariate one. Then the outlier in
those max's will define the outlier of the point.

My question is:
1. I don't know if using mahalanobis is proper or not since most
clustering algorithms implemented in R (like pam or clara) use
euclidean or mahattan.
2. Is there a way to get the mahalanobis distance matrix for any two
rows of a dataframe or matrix?
3. My approach does allow a point belonging to more than one
k-cluster. Is there similar algorithm in R or published?

Thanks for any suggestions,

weiwei
-- 
Weiwei Shi, Ph.D

"Did you always know?"
"No, I did not. But I believed..."
---Matrix III

__
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


Re: [R] Adding "sum" to derivatives table

2005-08-04 Thread Rolf Turner
Martin C. Martin wrote:

> Rolf Turner wrote:
> 
> >> deriv(expression(sum(x)), "x")
> >>
> >>
> >
> > does not make any sense.
> >  
> >
> Good point.  But this does:
> 
> deriv(expression(sum(log(a*x))), "a")
> 
> where a is a scalar.

Okay --- I see what you're getting at now.

But I think that to get deriv() to handle expressions
of that sort, i.e for

 deriv(expression(sum(log(a*x))), "a")

not to fall over, requires more than ``putting sum in the
derivatives table''.  The problem is that ``sum'' is not the
``right sort of function''.  Functions that appear in the
derivatives table are (I think --- I am not knowledgable
about this) functions of a single variable, like sin and cos
and log, u.s.w.  Whereas sum is a function of arbitrarily
many variables.

What is needed is for deriv() to know the rule that ``the
derivative of a sum is the sum of the derivatives''.  This
would require rewriting the code of deriv().  Whether the
required rule could be built into deriv() safely and sensibly
is not clear to me.  It might be do-able; I wouldn't want to
try it, but!

cheers,

Rolf Turner
[EMAIL PROTECTED]

__
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


[R] Problem configuring R-patched

2005-08-04 Thread Kevin E. Thorpe
I downloaded R-patched (2005-08-04) from CRAN today.
I ran ./configure --enable-R-shlib

I received the error message:

checking for recommended packages... no
configure: error: Some of the recommended packages are missing
   Use --without-recommended-packages if this was intentional

I built a previous version of R-patched successfully on my system
which is running the SuSE 9,2 Pro Linux distribution.  I untarred the
tar ball into the same directory I did my last build on in case that's
important.

The only other differences between this attempt and my successful build
are:

1. I did not use --enable-R-shlib last time.
2. I found and installed the blas libraries for this build.

Have I messed up or made an erroneous assumption along the way?

Thanks

-- 
Kevin E. Thorpe
Biostatistician/Trialist, Knowledge Translation Program
Assistant Professor, Department of Public Health Sciences
Faculty of Medicine, University of Toronto
email: [EMAIL PROTECTED]  Tel: 416.946.8081  Fax: 416.971.2462

__
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


Re: [R] Eclipse, R, plug-in?

2005-08-04 Thread Robert Citek

On Aug 4, 2005, at 2:35 AM, Uwe Ligges wrote:
> Robert Citek wrote:
>> Has any developed or is anyone developing a plug-in[1] for using R
>> with Eclipse[2]?
>
> Stephan Wahlbrink made a Plug-In available at
> http://www.walware.de/goto/statet

Fantastic.  I started dabbling in R a few months ago and then got  
pulled into other projects.  Hopefully, I'll be able to devote a bit  
more time to R, again.

Regards,
- Robert
http://www.cwelug.org/downloads
Help others get OpenSource software.  Distribute FLOSS
for Windows, Linux, *BSD, and MacOS X with BitTorrent

__
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


Re: [R] Help: how to stop the process when there is a mishandling

2005-08-04 Thread Duncan Murdoch
On 8/4/2005 2:25 PM, Spencer Graves wrote:
> If you are using XEmacs, it's not that easy.  I'm not completely 
> clear on the protocol in that case, but I think you have to first click 
> in the R window, then  +  + .  Perhaps an Emacs 
> wizard will enlighten us.
> 
> spencer graves

Yes, I was talking about Rgui.exe.  ESC doesn't stop Rterm.exe, which is 
what XEmacs is running.

Duncan Murdoch

> 
> Duncan Murdoch wrote:
> 
>> On 8/4/2005 11:39 AM, Shengzhe Wu wrote:
>> 
>>>and how about R on windows system? since I am currently using R of
>>>windows version.
>> 
>> 
>> Hit "ESC" in the console.  If that doesn't work, there's a bug.  Report 
>> it to the package maintainer if you're running package code, or here if 
>> it's base code.  Be sure to give enough details that others can see 
>> things freeze.
>> 
>> And if it really is frozen, you can use Ctrl-Alt-Del to open the Windows 
>>   Task Manager, select the Rgui application, and "End task".  Assuming 
>> you have permission, etc.
>> 
>> Duncan Murdoch
>> 
>>>Thank you,
>>>Shengzhe
>>>
>>>On 8/4/05, Roger D. Peng <[EMAIL PROTECTED]> wrote:
>>>
On Unix you can send one of the 'USR' signals to 'kill'.  See
?Signals.

-roger

Shengzhe Wu wrote:

>Hello,
>
>How to stop the process when there is a mishandling making R system
>frozen? If there is a way other than quitting the system when frozen
>occurs?
>
>Thank you,
>Shengzhe
>
>__
>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
>

--
Roger D. Peng
http://www.biostat.jhsph.edu/~rpeng/

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

__
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


Re: [R] Help: how to stop the process when there is a mishandling

2005-08-04 Thread Martin C. Martin
The R for Windows FAQ has many useful tips, including this one:

http://cran.r-project.org/bin/windows/base/rw-FAQ.html

It's well worth at least reading the contents, so you know what 
questions it can answer.

- Martin

Duncan Murdoch wrote:

>On 8/4/2005 11:39 AM, Shengzhe Wu wrote:
>  
>
>>and how about R on windows system? since I am currently using R of
>>windows version.
>>
>>
>
>Hit "ESC" in the console.  If that doesn't work, there's a bug.  Report 
>it to the package maintainer if you're running package code, or here if 
>it's base code.  Be sure to give enough details that others can see 
>things freeze.
>
>And if it really is frozen, you can use Ctrl-Alt-Del to open the Windows 
>  Task Manager, select the Rgui application, and "End task".  Assuming 
>you have permission, etc.
>
>Duncan Murdoch
>  
>
>>Thank you,
>>Shengzhe
>>
>>On 8/4/05, Roger D. Peng <[EMAIL PROTECTED]> wrote:
>>
>>
>>>On Unix you can send one of the 'USR' signals to 'kill'.  See
>>>?Signals.
>>>
>>>-roger
>>>
>>>Shengzhe Wu wrote:
>>>  
>>>
Hello,

How to stop the process when there is a mishandling making R system
frozen? If there is a way other than quitting the system when frozen
occurs?

Thank you,
Shengzhe

__
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



>>>--
>>>Roger D. Peng
>>>http://www.biostat.jhsph.edu/~rpeng/
>>>
>>>  
>>>
>>__
>>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
>>
>>
>
>__
>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
>  
>

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


Re: [R] Help: how to stop the process when there is a mishandling

2005-08-04 Thread Spencer Graves
  If you are using XEmacs, it's not that easy.  I'm not completely 
clear on the protocol in that case, but I think you have to first click 
in the R window, then  +  + .  Perhaps an Emacs 
wizard will enlighten us.

  spencer graves

Duncan Murdoch wrote:

> On 8/4/2005 11:39 AM, Shengzhe Wu wrote:
> 
>>and how about R on windows system? since I am currently using R of
>>windows version.
> 
> 
> Hit "ESC" in the console.  If that doesn't work, there's a bug.  Report 
> it to the package maintainer if you're running package code, or here if 
> it's base code.  Be sure to give enough details that others can see 
> things freeze.
> 
> And if it really is frozen, you can use Ctrl-Alt-Del to open the Windows 
>   Task Manager, select the Rgui application, and "End task".  Assuming 
> you have permission, etc.
> 
> Duncan Murdoch
> 
>>Thank you,
>>Shengzhe
>>
>>On 8/4/05, Roger D. Peng <[EMAIL PROTECTED]> wrote:
>>
>>>On Unix you can send one of the 'USR' signals to 'kill'.  See
>>>?Signals.
>>>
>>>-roger
>>>
>>>Shengzhe Wu wrote:
>>>
Hello,

How to stop the process when there is a mishandling making R system
frozen? If there is a way other than quitting the system when frozen
occurs?

Thank you,
Shengzhe

__
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

>>>
>>>--
>>>Roger D. Peng
>>>http://www.biostat.jhsph.edu/~rpeng/
>>>
>>
>>__
>>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
> 
> 
> __
> 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

-- 
Spencer Graves, PhD
Senior Development Engineer
PDF Solutions, Inc.
333 West San Carlos Street Suite 700
San Jose, CA 95110, USA

[EMAIL PROTECTED]
www.pdf.com 
Tel:  408-938-4420
Fax: 408-280-7915

__
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


Re: [R] Adding "sum" to derivatives table

2005-08-04 Thread Martin C. Martin


Rolf Turner wrote:

>> deriv(expression(sum(x)), "x")
>>
>>
>
>   does not make any sense.
>  
>
Good point.  But this does:

deriv(expression(sum(log(a*x))), "a")

where a is a scalar.

- Martin

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


Re: [R] Help: how to hide the buttons of a new opening device

2005-08-04 Thread Duncan Murdoch
On 8/4/2005 1:03 PM, Shengzhe Wu wrote:
> Hello,
> 
> When I open a new device by "windows()", how to hide the 3 buttons on
> the top-right corner of this window, since I want to make these
> buttons not work, and the window can be closed only by "dev.off()" or
> "graphics.off()".

There are no exposed functions to do that.  You're going to have to look 
at the R source code, and add something.

Duncan Murdoch

__
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


Re: [R] Help: how to stop the process when there is a mishandling

2005-08-04 Thread Duncan Murdoch
On 8/4/2005 11:39 AM, Shengzhe Wu wrote:
> and how about R on windows system? since I am currently using R of
> windows version.

Hit "ESC" in the console.  If that doesn't work, there's a bug.  Report 
it to the package maintainer if you're running package code, or here if 
it's base code.  Be sure to give enough details that others can see 
things freeze.

And if it really is frozen, you can use Ctrl-Alt-Del to open the Windows 
  Task Manager, select the Rgui application, and "End task".  Assuming 
you have permission, etc.

Duncan Murdoch
> 
> Thank you,
> Shengzhe
> 
> On 8/4/05, Roger D. Peng <[EMAIL PROTECTED]> wrote:
>> On Unix you can send one of the 'USR' signals to 'kill'.  See
>> ?Signals.
>> 
>> -roger
>> 
>> Shengzhe Wu wrote:
>> > Hello,
>> >
>> > How to stop the process when there is a mishandling making R system
>> > frozen? If there is a way other than quitting the system when frozen
>> > occurs?
>> >
>> > Thank you,
>> > Shengzhe
>> >
>> > __
>> > 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
>> >
>> 
>> --
>> Roger D. Peng
>> http://www.biostat.jhsph.edu/~rpeng/
>>
> 
> __
> 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

__
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


Re: [R] Counterintuitive Simulation Results

2005-08-04 Thread Spencer Graves
Hi, Robert:

  Yes, I understand now.  Thanks very much for your insight.

  Best Wishes,
  Spencer Graves

McGehee, Robert wrote:

> Spencer,
> On the first iteration of your simulation, all of the Qp.t + z.t < 0, so
> you're adding a vector of rep(4.5, 2) to a random distribution with
> mean -0.1. So one would expect on iteration 2, your mean would have
> dropped by about 0.1 (which it does). This process continues until about
> the 20th iteration when we start seeing that a large number of our
> initial starting points are floored at zero (because of the pmax). For
> points greater than zero, we continue to subtract an average of 0.1
> (actually less than this), but for those points already at zero, we're
> actually adding a mean of 0.348 (since we can never subtract from a zero
> number in this case), which starts the trajectory moving upward towards
> its asymptote.
> 
> #That is, for those paths far above 0.1, we are subtracting
> 
>>mean(rnorm(1, mean = -0.1))
> 
> [1] -0.1059246
> 
> #And for those paths already at zero, we are adding
> 
>>mean(pmax(0, rnorm(1, mean = -0.1)))
> 
> [1] 0.3482376
> 
> To see a simulation a bit closer to what you were expecting, replace the
> starting values with a random distribution with mean Qp0.
> 
> i.e. replace
> 
>>Qp.t <- rep(Qp0, nSims)
> 
> with
> 
>>Qp.t <- rnorm(nSims, Qp0, sd = 3.7)
> 
> 
> Robert
> 
> 
> -Original Message-
> From: Spencer Graves [mailto:[EMAIL PROTECTED] 
> Sent: Thursday, August 04, 2005 12:16 PM
> To: r-help@stat.math.ethz.ch
> Subject: [R] Counterintuitive Simulation Results
> 
> 
> I wonder if someone can help me understand some
> counterintuitive 
> simulation results.  Below please find 12 lines of R code that 
> theoretically, to the best of my understanding, should produce 
> essentially a flat line with no discernable pattern.  Instead, I see an 
> initial dramatic drop followed by a slow rise to an asymptote.
> 
> The simulation computes the mean of 20,000 simulated
> trajectories of 
> 400 observations each of a one-sided Cusum of independent normal 
> increments with mean EZ[t] = (-0.1) and unit variance.  Started with any
> 
> initial value, the mean of the Cusum should approach an asymptote as the
> 
> number of observations increases;  when started at that asymptote, it 
> should theoretically stay flat, unlike what we see here.
> 
> I would think this could be an artifact of the simulation 
> methodology, but I've gotten essentially this image with several 
> independently programmed simulations in S-Plus 6.1, with all six 
> different random number generators in R 1.9.1 and 2.1.1 and with MS 
> Excel.  For modest changes in EZ[t] < 0, I get a different asymptote but
> 
> pretty much the same image.
> 
> #
> simCus5 <- function(mu=-0.1, Qp0=4.5, maxTime=400, nSims=2){
>Qp.mean <- rep(NA, maxTime)
>Qp.t <- rep(Qp0, nSims)
>for(i in 1:maxTime){
>  z.t <- (mu + rnorm(nSims))
>  Qp.t <- pmax(0, Qp.t+z.t)
>  Qp.mean[i] <- mean(Qp.t)
>}
>Qp.mean
> }
> set.seed(1)
> plot(simCus5(Qp0=4.5))
> #
> 
> Thanks for your time in reading this.
> Best Wishes,
> Spencer Graves
> 
> Spencer Graves, PhD
> Senior Development Engineer
> PDF Solutions, Inc.
> 333 West San Carlos Street Suite 700
> San Jose, CA 95110, USA
> 
> [EMAIL PROTECTED]
> www.pdf.com 
> Tel:  408-938-4420
> Fax: 408-280-7915
> 
> __
> 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
> 

-- 
Spencer Graves, PhD
Senior Development Engineer
PDF Solutions, Inc.
333 West San Carlos Street Suite 700
San Jose, CA 95110, USA

[EMAIL PROTECTED]
www.pdf.com 
Tel:  408-938-4420
Fax: 408-280-7915

__
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


Re: [R] Graphics on MacOSX

2005-08-04 Thread Stephen D. Weigand
Dear Dirk and Hank,

On Aug 4, 2005, at 9:13 AM, Martin Henry H. Stevens wrote:

> This is a big issue for me, causing many days of angst. I finally
> stumbled on the following solution. I create a device save an image
> with postscript(). I then open it in Adobe Acrobat, select the area I
> want, enlarge to at least 400%, then copy, then paste into PowerPoint
> or Word. Alternatively, you can simply save a graphics image through
> the gui and it saves it as pdf. Then go through the steps of selecting,
> enlarging and copying in Acrobat. I am guessing real graphics programs
> would work as well (Photoshop or Illustrator), but I don't have those.
>
> Hank Stevens
>
>
> On Aug 4, 2005, at 8:03 AM, Weismann_D wrote:
>
>> Ist there a possibility on MacOSX to import Graphics into MSOffice
>> Applications and resize them there without decreased quality? When I
>> import
>> via copy&paste I get low quality bitmaps and via import pictures (pdf)
>> it is
>> all the same. In the Windows versions of R there is the convienient
>> way to
>> use metafile format which can easily be resized in ppt and word. What
>> is the
>> equivalent way on MacOSX?
>> Thanks, Dirk.

You could try creating a PNG with bitmap() using a high resolution, 
e.g.,

bitmap("test.png", type = "png256", res = 1200)
plot(1:10, rnorm(10))
dev.off()

Preview can read the resulting PNG file just fine and the Windows 
version of Office can insert PNGs, displays them well, and allows 
resizing. (I don't have an OS X version of Office so can't test that 
the OS X version would handle the PNGs equally well but I would have to 
assume it does.)

bitmap() requires Ghostscript which I have installed on my system in 
/usr/local/bin. I'm not sure whether Ghostscript came with OS X or if I 
installed it myself but it's freely available.

Hope this helps,

Stephen

PS I am using the out-of-the-box R.app:

platform powerpc-apple-darwin7.9.0
arch powerpc
os   darwin7.9.0
system   powerpc, darwin7.9.0
status   Patched
major2
minor1.0
year 2005
month05
day  12

and Ghostscript 8.13 (2003-12-31)

__
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


Re: [R] Adding "sum" to derivatives table

2005-08-04 Thread Rolf Turner
>  deriv(expression(sum(x)), "x")

does not make any sense.

cheers,

Rolf Turner
[EMAIL PROTECTED]

__
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


Re: [R] R config question

2005-08-04 Thread Uwe Ligges
William Fennell wrote:

> Hi FOlks,
> 
> I tried to configure  R 2.1.1 prior to making R on Solaris 8 and get this 
> error.
> configure: error: --with-readline=yes (default) and headers/libs are
> not available
> 
> Any ideas what this means?

... maybe that configure cannot find the readline headers/libs?
Either install them (highly recommended) or configure without readline 
support.

Uwe Ligges


> Thanks,
> 
> Bill
> 
> __
> 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

__
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


Re: [R] Help: how to hide the buttons of a new opening device

2005-08-04 Thread Uwe Ligges
Shengzhe Wu wrote:

> Hello,
> 
> When I open a new device by "windows()", how to hide the 3 buttons on
> the top-right corner of this window, since I want to make these
> buttons not work, and the window can be closed only by "dev.off()" or
> "graphics.off()".

You cannot.

Uwe Ligges

> 
> Thank you,
> Shengzhe
> 
> __
> 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

__
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


[R] Adding "sum" to derivatives table

2005-08-04 Thread Martin C. Martin
Hi,

Trying this:

deriv(expression(sum(x)), "x")

Gives the error message:

Function 'sum' is not in the derivatives table

I'd like to add it, is this difficult?  If not, where is the derivatives 
table?

However, give how basic "sum" is, I suspect it would have been added if 
it were straightforward.  Do functions in the derivatives table need to 
be vectorized?  i.e. given a vector of length n, they need to produce a 
vector of length n?  Or is there some other restriction?

Thanks,
Martin

__
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


[R] linkage disequilibrium

2005-08-04 Thread Cristian
Dear all, 

I'm using the package "Genetics", and I'm interested in the computation of D'
statistics for Linkage Disequilibrium, for which the LD() command has been
realised. Unfortunately I don't find any reference on "how" the D' is computed
by the LD() function. In the package documentation it is generally referred as
"MLE" estimation, but references are not provided. Does anybody knows how it is
obtained or, at least, some references?

Are there any other R package performing the D' computation both for phased and
unphased genotype?

Thanks!
Cristian




Cristian Pattaro
Unit of Epidemiology & Medical Statistics
Department of Medicine and Public Health
University of Verona, Italy


-
Biometria - biometria.univr.it

__
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


[R] R config question

2005-08-04 Thread William Fennell
Hi FOlks,

I tried to configure  R 2.1.1 prior to making R on Solaris 8 and get this error.
configure: error: --with-readline=yes (default) and headers/libs are
not available

Any ideas what this means?

Thanks,

Bill

__
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


Re: [R] Counterintuitive Simulation Results

2005-08-04 Thread McGehee, Robert
Spencer,
On the first iteration of your simulation, all of the Qp.t + z.t < 0, so
you're adding a vector of rep(4.5, 2) to a random distribution with
mean -0.1. So one would expect on iteration 2, your mean would have
dropped by about 0.1 (which it does). This process continues until about
the 20th iteration when we start seeing that a large number of our
initial starting points are floored at zero (because of the pmax). For
points greater than zero, we continue to subtract an average of 0.1
(actually less than this), but for those points already at zero, we're
actually adding a mean of 0.348 (since we can never subtract from a zero
number in this case), which starts the trajectory moving upward towards
its asymptote.

#That is, for those paths far above 0.1, we are subtracting
> mean(rnorm(1, mean = -0.1))
[1] -0.1059246

#And for those paths already at zero, we are adding
> mean(pmax(0, rnorm(1, mean = -0.1)))
[1] 0.3482376

To see a simulation a bit closer to what you were expecting, replace the
starting values with a random distribution with mean Qp0.

i.e. replace
> Qp.t <- rep(Qp0, nSims)
with
> Qp.t <- rnorm(nSims, Qp0, sd = 3.7)

Robert


-Original Message-
From: Spencer Graves [mailto:[EMAIL PROTECTED] 
Sent: Thursday, August 04, 2005 12:16 PM
To: r-help@stat.math.ethz.ch
Subject: [R] Counterintuitive Simulation Results


  I wonder if someone can help me understand some
counterintuitive 
simulation results.  Below please find 12 lines of R code that 
theoretically, to the best of my understanding, should produce 
essentially a flat line with no discernable pattern.  Instead, I see an 
initial dramatic drop followed by a slow rise to an asymptote.

  The simulation computes the mean of 20,000 simulated
trajectories of 
400 observations each of a one-sided Cusum of independent normal 
increments with mean EZ[t] = (-0.1) and unit variance.  Started with any

initial value, the mean of the Cusum should approach an asymptote as the

number of observations increases;  when started at that asymptote, it 
should theoretically stay flat, unlike what we see here.

  I would think this could be an artifact of the simulation 
methodology, but I've gotten essentially this image with several 
independently programmed simulations in S-Plus 6.1, with all six 
different random number generators in R 1.9.1 and 2.1.1 and with MS 
Excel.  For modest changes in EZ[t] < 0, I get a different asymptote but

pretty much the same image.

#
simCus5 <- function(mu=-0.1, Qp0=4.5, maxTime=400, nSims=2){
   Qp.mean <- rep(NA, maxTime)
   Qp.t <- rep(Qp0, nSims)
   for(i in 1:maxTime){
 z.t <- (mu + rnorm(nSims))
 Qp.t <- pmax(0, Qp.t+z.t)
 Qp.mean[i] <- mean(Qp.t)
   }
   Qp.mean
}
set.seed(1)
plot(simCus5(Qp0=4.5))
#

  Thanks for your time in reading this.
  Best Wishes,
  Spencer Graves

Spencer Graves, PhD
Senior Development Engineer
PDF Solutions, Inc.
333 West San Carlos Street Suite 700
San Jose, CA 95110, USA

[EMAIL PROTECTED]
www.pdf.com 
Tel:  408-938-4420
Fax: 408-280-7915

__
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

__
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


[R] Help: how to hide the buttons of a new opening device

2005-08-04 Thread Shengzhe Wu
Hello,

When I open a new device by "windows()", how to hide the 3 buttons on
the top-right corner of this window, since I want to make these
buttons not work, and the window can be closed only by "dev.off()" or
"graphics.off()".

Thank you,
Shengzhe

__
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


[R] visualizing/summarizing a large, sparse logistic regression

2005-08-04 Thread Michael Friendly
I have data on ~34 cases where it is desired to predict
binary outcome, Withdrawn, using up to 8, A:H, predictors in
a 3 x 2^7 design, but where the frequencies in these 168
cells vary enormously (1--108000).  As well, there are
two additional variables, Agency and Office, and it is
desired, among other things, to determine if the rates
vary with Agency and Office controlling for A - H.

I fit an initial model
   Withdrawn ~ A + B + C + D + E + F + G + H

giving all main effects significant, and am trying to find
a compact way to summarize and visualize the fitted rates
under this model, or a more complex model involving
Agency and Office plus potential interactions among A-H.

Can someone point me in some useful directions or to some
similar examples?

thanks,
-Michael

-- 
Michael Friendly Email: [EMAIL PROTECTED]
Professor, Psychology Dept.
York University  Voice: 416 736-5115 x66249 Fax: 416 736-5814
4700 Keele Streethttp://www.math.yorku.ca/SCS/friendly.html
Toronto, ONT  M3J 1P3 CANADA

__
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


Re: [R] one more minor and small bug in lattice in R

2005-08-04 Thread Deepayan Sarkar
On 8/3/05, Wladimir Eremeev <[EMAIL PROTECTED]> wrote:
> Dear all.
> 
>  I have found one more minor bug in the Lattice package.
> 
>  When xyplot plots several curves on each panel with the default panel
>  function panel.xyplot, and when it is called with "g" %in% type
> (that is,
> xyplot(y1+y2+y3~x|cond,allow.multiple=TRUE,type=c("o","g"),)
>  ), it draws grid lines several times (for each curve), and it appears,
>  that they overlay all curves plotted, except the last one.
> 
>  I think there is a need to establish some kind of flag, showing, that
>  the grid is already drawn, and other runs of the panel.xyplot for the
>  same panel must not draw it again.

This has been fixed in the latest version (which has been uploaded,
but not on CRAN yet), by making panel.superpose handle 'g' in type.

Deepayan

__
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


[R] Course *** R/Splus Advanced Programming *** September 2005 @ 2 locations

2005-08-04 Thread elvis
XSolutions Corp (www.xlsolutions-corp.com) is proud to announce
our  September 2005 "Advanced R/Splus programming" course taught by R
Development
Core Team Guru!

www.xlsolutions-corp.com/Radv.htm

*Atlanta --- September 1-2
*New York --- September 1-2
*Boston --- TBD
*Washington, DC ---TBD, please email if interested.

Ask for group discount and reserve your seat Now  (payment due after
the class)

Email Sue Turner:  [EMAIL PROTECTED]

Course Outline:

- Overview of R/S fundamentals: Syntax and Semantics
- Class and Inheritance in R/S-Plus
- Concepts, Construction and good use of language objects
- Coercion and efficiency
- Object-oriented programming in R and S-Plus
- Advanced manipulation tools: Parse, Deparse, Substitute, etc.
- How to fully take advantage of Vectorization
- Generic and Method Functions; S4 (S-Plus 6)
- Search path, databases and frames Visibility
- Working with large objects
- Handling Properly Recursion and iterative calculations
- Managing loops; For (S-Plus) and for() loops
- Consequences of Lazy Evaluation
- Efficient Code practices for large computations
- Memory management and Resource monitoring
- Writing R/S-Plus functions to call compiled code
- Writing and debugging compiled code for R/S-Plus system
- Connecting R/S-Plus to External Data Sources
- Understanding the structure of model fitting functions in R/S-Plus
- Designing and Packaging efficiently a new model function

It'll also deal with lots of S-Plus efficiency issues and any special
topics
from participants is welcome.

Please let us know if you and your colleagues are interested in this
class
to take advantage of group discount. Over half of the seats in this
class
are currently reserved.  Register now to secure your seat in this
course!

Cheers,

Elvis Miller, PhD
Manager Training.
XLSolutions Corporation
206 686 1578
www.xlsolutions-corp.com

__
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


Re: [R] color palette

2005-08-04 Thread array chip
Thanks for the suggestion. I still could not figure
out how to use the function to do my job. What's
important in my job is that I have to map white color
to value 0, and then form a bue gradient for negative
values, and red gradient for positive values. The data
matrix I have is not symmetric aound 0, say 0 is at
the 18 percentile, and values range from -10 to 30.
How exactly I could do my job? Bear with me, I am new
to color, I don't quite understand how the image
function map the number is the data matrix to the
colors defined in the col argument.

Thanks


--- Thomas Lumley <[EMAIL PROTECTED]> wrote:

> On Wed, 3 Aug 2005, array chip wrote:
> 
> > Hi, I have a matrix with both positive and
> negative
> > numbers, I would like to use image() to draw a
> > heatmap. How can I can design a palette (or is
> there a
> > function already available) that treat negative
> > numbers in a blue gradient and positive numbers in
> a
> > red gradient and treat 0 as white?
> >
> 
> ?colorRampPalette
> 
>   -thomas
>

__
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


[R] Counterintuitive Simulation Results

2005-08-04 Thread Spencer Graves
  I wonder if someone can help me understand some counterintuitive 
simulation results.  Below please find 12 lines of R code that 
theoretically, to the best of my understanding, should produce 
essentially a flat line with no discernable pattern.  Instead, I see an 
initial dramatic drop followed by a slow rise to an asymptote.

  The simulation computes the mean of 20,000 simulated trajectories of 
400 observations each of a one-sided Cusum of independent normal 
increments with mean EZ[t] = (-0.1) and unit variance.  Started with any 
initial value, the mean of the Cusum should approach an asymptote as the 
number of observations increases;  when started at that asymptote, it 
should theoretically stay flat, unlike what we see here.

  I would think this could be an artifact of the simulation 
methodology, but I've gotten essentially this image with several 
independently programmed simulations in S-Plus 6.1, with all six 
different random number generators in R 1.9.1 and 2.1.1 and with MS 
Excel.  For modest changes in EZ[t] < 0, I get a different asymptote but 
pretty much the same image.

#
simCus5 <- function(mu=-0.1, Qp0=4.5, maxTime=400, nSims=2){
   Qp.mean <- rep(NA, maxTime)
   Qp.t <- rep(Qp0, nSims)
   for(i in 1:maxTime){
 z.t <- (mu + rnorm(nSims))
 Qp.t <- pmax(0, Qp.t+z.t)
 Qp.mean[i] <- mean(Qp.t)
   }
   Qp.mean
}
set.seed(1)
plot(simCus5(Qp0=4.5))
#

  Thanks for your time in reading this.
  Best Wishes,
  Spencer Graves

Spencer Graves, PhD
Senior Development Engineer
PDF Solutions, Inc.
333 West San Carlos Street Suite 700
San Jose, CA 95110, USA

[EMAIL PROTECTED]
www.pdf.com 
Tel:  408-938-4420
Fax: 408-280-7915

__
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


Re: [R] Problem when pasting from Winedit into Rgui

2005-08-04 Thread Uwe Ligges
[EMAIL PROTECTED] wrote:

> After upgrading to R 2.1.1, the usual paste-and-go from Winedit seems to
> not work anymore.
> I try installing the last 'RWinEdt_1.7-3' edition, but with no more result.
> After selecting the program lines to submit, I  click on the 'paste' icon
> and nothing happens in the R gui (a subliminal, flashing move in the
> edition menu...). Idem for 'source' and 'R-history'.
> Downgrading to 2.0.1 solves the trouble.
> 
> Do I forget something ?
> Thanks for any help.

You might want to conatct the RWinEdt maintainer. He would tell you that 
you should read the output of RWinEdt appearaing when you say
   library(RWinEdt)

I guess you have a french localized version of RGui running in mdi mode? 
In this case, switch to sdi mode and adjust the RWinEdt setting.
It's all explained in much more detail in the ReadMe of RWinEdt.

Uwe Ligges


> I am working with :
> 
>>version
> 
>  _
> platform i386-pc-mingw32
> arch i386
> os   mingw32
> system   i386, mingw32
> status
> major2
> minor1.1
> year 2005
> month06
> day  20
> language R
> 
> __
> 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

__
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


[R] Problem when pasting from Winedit into Rgui

2005-08-04 Thread jean.vidal
After upgrading to R 2.1.1, the usual paste-and-go from Winedit seems to
not work anymore.
I try installing the last 'RWinEdt_1.7-3' edition, but with no more result.
After selecting the program lines to submit, I  click on the 'paste' icon
and nothing happens in the R gui (a subliminal, flashing move in the
edition menu...). Idem for 'source' and 'R-history'.
Downgrading to 2.0.1 solves the trouble.

Do I forget something ?
Thanks for any help.

I am working with :
> version
 _
platform i386-pc-mingw32
arch i386
os   mingw32
system   i386, mingw32
status
major2
minor1.1
year 2005
month06
day  20
language R

__
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


Re: [R] Help: how to stop the process when there is a mishandling

2005-08-04 Thread Shengzhe Wu
and how about R on windows system? since I am currently using R of
windows version.

Thank you,
Shengzhe

On 8/4/05, Roger D. Peng <[EMAIL PROTECTED]> wrote:
> On Unix you can send one of the 'USR' signals to 'kill'.  See
> ?Signals.
> 
> -roger
> 
> Shengzhe Wu wrote:
> > Hello,
> >
> > How to stop the process when there is a mishandling making R system
> > frozen? If there is a way other than quitting the system when frozen
> > occurs?
> >
> > Thank you,
> > Shengzhe
> >
> > __
> > 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
> >
> 
> --
> Roger D. Peng
> http://www.biostat.jhsph.edu/~rpeng/
>

__
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


Re: [R] red-black-green color palette?

2005-08-04 Thread Earl F. Glynn
"Jake Michaelson" <[EMAIL PROTECTED]> wrote in message
news:[EMAIL PROTECTED]
> I'm working on some heatmaps, and the person I'm working with would
> prefer a red-black-green color palette (red denoting gene induction and
> green denoting gene repression).  Does such a palette exist already?
> If not, is there an easy way to create one?

Here are four ways:

showpanel <- function(Colors)
{
  image(matrix(1:length(Colors), ncol=1), col=Colors, xaxt="n", yaxt="n" )
}

oldpar <- par(mfrow=c(4,2))

# Method 1 (colorRampPalette was new in R 2.1.0) in grDevices
# Same as function with same name in dichromat package?
showpanel(colorRampPalette( c("green", "black", "red"), space="rgb")(32))
showpanel(colorRampPalette( c("green", "black", "red"), space="rgb")(64))

# Method 2
library(gplots)
showpanel(greenred(32))
showpanel(redgreen(64))

# Method 3
library(geneplotter)
showpanel(greenred.colors(32))
showpanel(greenred.colors(64))

# Method 4
library("marray")
pal <- maPalette(low="green", high="red",mid="black")
maColorBar(seq(-2,2, 0.2), col=pal, horizontal=TRUE, k=0)
maColorBar(seq(-2,2, 0.1), col=pal, horizontal=TRUE, k=0)


efg
--
Earl F. Glynn
Scientific Programmer
Stowers Institute for Medical Research

__
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


Re: [R] Help: how to stop the process when there is a mishandling

2005-08-04 Thread Roger D. Peng
On Unix you can send one of the 'USR' signals to 'kill'.  See 
?Signals.

-roger

Shengzhe Wu wrote:
> Hello,
> 
> How to stop the process when there is a mishandling making R system
> frozen? If there is a way other than quitting the system when frozen
> occurs?
> 
> Thank you,
> Shengzhe
> 
> __
> 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
> 

-- 
Roger D. Peng
http://www.biostat.jhsph.edu/~rpeng/

__
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


Re: [R] Modifying the parameters for a function

2005-08-04 Thread Duncan Murdoch
Philip Bermingham wrote:
> I have modified the parameters for a function (for my own use) in the
> stats package, but I assume I need to update the parameter set in
> another file as I'm getting the following error when I  run R:
> 
>  
> 
> The compile works fine so I assume there is a configuration file in the
> base package of R that needs modification.
> 
>  
> 
> Error in parse(file, n, text, prompt) : syntax error on line 11102
> 
> Error: unable to load R code in package 'stats'

This means that you've introduced a syntax error when you did your 
edits.  The line number information is fairly useless:  R has 
concatenated all of the files together, you don't see the original line 
number.  Your best strategy is to look at where you made changes.

I'm hoping to improve the error reporting on parse errors in R 2.2, but 
time is flying by...

Duncan Murdoch
> 
> During startup - Warning message:
> 
> package stats in options("defaultPackages") was not found
> 
>  
> 
> Philip.
> 
> 
>   [[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

__
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


[R] Help: how to stop the process when there is a mishandling

2005-08-04 Thread Shengzhe Wu
Hello,

How to stop the process when there is a mishandling making R system
frozen? If there is a way other than quitting the system when frozen
occurs?

Thank you,
Shengzhe

__
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


Re: [R] Graphics on MacOSX

2005-08-04 Thread Martin Henry H. Stevens
This is a big issue for me, causing many days of angst. I finally 
stumbled on the following solution. I create a device save an image 
with postscript(). I then open it in Adobe Acrobat, select the area I 
want, enlarge to at least 400%, then copy, then paste into PowerPoint 
or Word. Alternatively, you can simply save a graphics image through 
the gui and it saves it as pdf. Then go through the steps of selecting, 
enlarging and copying in Acrobat. I am guessing real graphics programs 
would work as well (Photoshop or Illustrator), but I don't have those.

Hank Stevens


On Aug 4, 2005, at 8:03 AM, Weismann_D wrote:

> Ist there a possibility on MacOSX to import Graphics into MSOffice
> Applications and resize them there without decreased quality? When I 
> import
> via copy&paste I get low quality bitmaps and via import pictures (pdf) 
> it is
> all the same. In the Windows versions of R there is the convienient 
> way to
> use metafile format which can easily be resized in ppt and word. What 
> is the
> equivalent way on MacOSX?
> Thanks, Dirk.
>
> __
> 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
>
>
Dr. Martin Henry H. Stevens, Assistant Professor
338 Pearson Hall
Botany Department
Miami University
Oxford, OH 45056

Office: (513) 529-4206
Lab: (513) 529-4262
FAX: (513) 529-4243
http://www.cas.muohio.edu/botany/bot/henry.html
http://www.muohio.edu/ecology/
http://www.muohio.edu/botany/
"E Pluribus Unum"

__
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


[R] prediction from glm

2005-08-04 Thread hugues santin janin
Hello r-help, 

I try to fit birds counts over years using glm. I have done (with Estate
and year as factors):

Model1 <- glm(Females~Estate+Year+offset = log(area)), family =
quasipoisson(link = log), na.action = "na.exclude") 

After I have calculated the prediction using:

Pred1 <- predict(Model1, type = "response", na.action = "na.exclude")

 

My question is: How can I obtain predictions for Females in each year
that are standardized by averaging over the levels of Estate?

I have been advised to use log(area) as an offset because we are
actually interested in density of birds but would appreciate any good
comparisons between offset and weight.

 

Thanks in advance for any help you can give.

 

Hugues SANTIN-JANIN

[EMAIL PROTECTED]

"Game Conservancy Trust"




-


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


Re: [R] Modifying the parameters for a function

2005-08-04 Thread Philip Bermingham
When I compile the package I modified.

-Original Message-
From: Roger D. Peng [mailto:[EMAIL PROTECTED] 
Sent: Thursday, August 04, 2005 9:00 AM
To: Philip Bermingham
Cc: R-help@stat.math.ethz.ch
Subject: Re: [R] Modifying the parameters for a function

What exactly do you mean by "compile"?  What compile works fine?

-roger

Philip Bermingham wrote:
> I have modified the parameters for a function (for my own use) in the
> stats package, but I assume I need to update the parameter set in
> another file as I'm getting the following error when I  run R:
> 
>  
> 
> The compile works fine so I assume there is a configuration file in
the
> base package of R that needs modification.
> 
>  
> 
> Error in parse(file, n, text, prompt) : syntax error on line 11102
> 
> Error: unable to load R code in package 'stats'
> 
> During startup - Warning message:
> 
> package stats in options("defaultPackages") was not found
> 
>  
> 
> Philip.
> 
> 
>   [[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
> 

-- 
Roger D. Peng
http://www.biostat.jhsph.edu/~rpeng/

__
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


Re: [R] drawing a network digraph

2005-08-04 Thread Seth Falcon
On  4 Aug 2005, [EMAIL PROTECTED] wrote:

> Dear R users, I have a matrix with 2 columns with the variables:
> "daughter index", "mother index". I would like to draw a network
> digraph using this data, where each daughter is connected to a
> mother and between the connections inlcude a circle with the
> information on the indices ("daughter index", "mother index"):
> i.e. something similar to graphs produced by graphviz.  I am
> clueless. I have looked at the libraries SEM and SNA but it looks
> like they can't help my cause.  Hope you help.  Vumani

You want the Rgraphviz package from Bioconductor.  To use Rgraphviz,
you will need to first install graphviz.  

To install Rgraphviz:

  If you are on a Linux type system with R-2.1.x:
  source("http://bioconductor.org/biocLite.R";)
  biocLite("Rgraphviz")

  If you use Windows, you need to use an R-devel snapshot in order to
  (easily) access Bioconductor development packages (Rgraphviz was
  only recently ported to Windows).  But the commands to install are
  the same as above.

HTH,

+ seth

__
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


Re: [R] drawing a network digraph

2005-08-04 Thread Sean Davis
On 8/4/05 8:33 AM, "Vumani Dlamini" <[EMAIL PROTECTED]> wrote:

> Dear R users,
> I have a matrix with 2 columns with the variables: "daughter index", "mother
> index". I would like to draw a network digraph using this data, where each
> daughter is connected to a mother and between the connections inlcude a
> circle with the information on the indices ("daughter index", "mother
> index"): i.e. something similar to graphs produced by graphviz.
> I am clueless. I have looked at the libraries SEM and SNA but it looks like
> they can't help my cause.

Since you mention graphviz, why not use Rgraphviz available from
BioConductor?  There are other packages available for doing graphing.  A
search of the r-help archives will turn up some discussion in the past 1-2
weeks.

Sean

__
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


Re: [R] Modifying the parameters for a function

2005-08-04 Thread Roger D. Peng
What exactly do you mean by "compile"?  What compile works fine?

-roger

Philip Bermingham wrote:
> I have modified the parameters for a function (for my own use) in the
> stats package, but I assume I need to update the parameter set in
> another file as I'm getting the following error when I  run R:
> 
>  
> 
> The compile works fine so I assume there is a configuration file in the
> base package of R that needs modification.
> 
>  
> 
> Error in parse(file, n, text, prompt) : syntax error on line 11102
> 
> Error: unable to load R code in package 'stats'
> 
> During startup - Warning message:
> 
> package stats in options("defaultPackages") was not found
> 
>  
> 
> Philip.
> 
> 
>   [[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
> 

-- 
Roger D. Peng
http://www.biostat.jhsph.edu/~rpeng/

__
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


Re: [R] Modifying the parameters for a function

2005-08-04 Thread Uwe Ligges
Philip Bermingham wrote:

> I have modified the parameters for a function (for my own use) in the
> stats package, but I assume I need to update the parameter set in
> another file as I'm getting the following error when I  run R:
> 
>  
> 
> The compile works fine so I assume there is a configuration file in the
> base package of R that needs modification.
> 
>  
> 
> Error in parse(file, n, text, prompt) : syntax error on line 11102

No, you have introduced an error, obviously.

Uwe Ligges

> Error: unable to load R code in package 'stats'
> 
> During startup - Warning message:
> 
> package stats in options("defaultPackages") was not found
> 
>  
> 
> Philip.
> 
> 
>   [[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

__
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


[R] Modifying the parameters for a function

2005-08-04 Thread Philip Bermingham
I have modified the parameters for a function (for my own use) in the
stats package, but I assume I need to update the parameter set in
another file as I'm getting the following error when I  run R:

 

The compile works fine so I assume there is a configuration file in the
base package of R that needs modification.

 

Error in parse(file, n, text, prompt) : syntax error on line 11102

Error: unable to load R code in package 'stats'

During startup - Warning message:

package stats in options("defaultPackages") was not found

 

Philip.


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


[R] drawing a network digraph

2005-08-04 Thread Vumani Dlamini
Dear R users,
I have a matrix with 2 columns with the variables: "daughter index", "mother 
index". I would like to draw a network digraph using this data, where each 
daughter is connected to a mother and between the connections inlcude a 
circle with the information on the indices ("daughter index", "mother 
index"): i.e. something similar to graphs produced by graphviz.
I am clueless. I have looked at the libraries SEM and SNA but it looks like 
they can't help my cause.
Hope you help.
Vumani

__
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


Re: [R] problem with for()

2005-08-04 Thread Achim Zeileis
On Thu, 04 Aug 2005 22:01:59 + Jim Lemon wrote:

> Simone Gabbriellini wrote:
> 
>  > it was simple, but you know, it's always simple when you've done it
>  > :)
> 
> Surely this homage to experience deserves nomination for the fortunes 
> package.

Thanks for the pointer, included in the package now. I've also
just submitted a new version (1.1-2) to CRAN, binary versions should be
available from the mirrors in the next days.
Z

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

__
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


Re: [R] how to read individual values from a pixmap object

2005-08-04 Thread Friedrich . Leisch
> On Thu, 4 Aug 2005 18:02:55 +1000,
> Tony Gill (TG) wrote:

[...]

  > Now I would like to read individual pixel values and store them in a
  > separate vector. However I have not found a straight-forward way to do this.
 
  > I thought that something like:
 
  > x <- xGrey[1,1]
 
  > would return the pixel value, but it seems to return a pixmap object with
  > dimension 1x1 (i.e. only one pixel in size)
 
  > xGrey[1,1]
  > Pixmap image
  >   Type  : pixmapGrey 
  >   Size  : 1x1 
  >   Resolution: 1x1 
  >   Bounding box  : 1 0 2 1
 
  > Any ideas on how to get the actual pixel value from a pixmap? (Note I could
  > output to an ascii file and then read the file back in as text - but not
  > nice!)


getChannels(xGrey) will get you the matrix of pixel values.

HTH,

-- 
---
Friedrich Leisch 
Institut für Statistik Tel: (+43 1) 58801 10715
Technische Universität WienFax: (+43 1) 58801 10798
Wiedner Hauptstraße 8-10/1071
A-1040 Wien, Austria http://www.ci.tuwien.ac.at/~leisch

__
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


[R] Graphics on MacOSX

2005-08-04 Thread Weismann_D
Ist there a possibility on MacOSX to import Graphics into MSOffice
Applications and resize them there without decreased quality? When I import
via copy&paste I get low quality bitmaps and via import pictures (pdf) it is
all the same. In the Windows versions of R there is the convienient way to
use metafile format which can easily be resized in ppt and word. What is the
equivalent way on MacOSX?
Thanks, Dirk.

__
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


Re: [R] problem with for()

2005-08-04 Thread Jim Lemon
Simone Gabbriellini wrote:

 > it was simple, but you know, it's always simple when you've done it :)

Surely this homage to experience deserves nomination for the fortunes 
package.

Jim

__
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


Re: [R] additional graphical parameters in contour function

2005-08-04 Thread Uwe Ligges
Abdou ALI wrote:

> 
>>> Do you know why additional graphical parameters (like "type","pch", 
>>> ...) do not work in the R contour fonction. For example the command 
>>> 'contour(..., type="o",pch=16)' gives nothing, just simple contour 
>>> lines.
>>
>>
>> Please, can you explain why you think it does make sense here?
>>
> The reason is that I want to add on a same graphic several contour plot, 
> and I want to give different line types for each contour. I thus thought 
> that these options of the contour function made it possible to do it.

But these arguments do not refer to line types at all!

Use "lty" instead as in:

  x <- -6:16
  op <- par(mfrow = c(2, 1))
  contour(outer(x, x), method = "edge", lty=1)
  contour(outer(x, x), method = "edge", lty=2)

Uwe Ligges




> Thank.
> 
> 
>>
>> Uwe Ligges
>>
>>
>>> Thank you for your response.
>>>
>>> Abdou. [[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
>>
>>

__
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


Re: [R] additional graphical parameters in contour function

2005-08-04 Thread Sundar Dorai-Raj


Abdou ALI wrote:
>>>Do you know why additional graphical parameters (like "type","pch", ...) 
>>>do not work in the R contour fonction. For example the command 
>>>'contour(..., type="o",pch=16)' gives nothing, just simple contour lines.
>>
>>Please, can you explain why you think it does make sense here?
>>
> 
> The reason is that I want to add on a same graphic several contour plot, and 
> I want to give different line types for each contour. I thus thought that 
> these options of the contour function made it possible to do it.
> 
> Thank.
> 
> 
Hi, Abdou,

Then use "lty", not "type", as is shown in ?contour.

--sundar

__
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


[R] prediction from glm

2005-08-04 Thread Hugues Santin-Janin
Hello r-help,

 

I try to fit birds counts over years using glm. I have done (with Estate
and year as factors):

Model1 <- glm(Females~Estate+Year+offset = log(area)), family =
quasipoisson(link = log), na.action = "na.exclude") 

After I have calculated the prediction using:

Pred1 <- predict(Model1, type = "response", na.action = "na.exclude")

 

My question is: How can I obtain predictions for Females in each year
that are standardized by averaging over the levels of Estate?

I have been advised to use log(area) as an offset because we are
actually interested in density of birds but would appreciate any good
comparisons between offset and weight.

 

Thanks in advance for any help you can give.

 

Hugues SANTIN-JANIN

[EMAIL PROTECTED]

"Game Conservancy Trust"


**Win some fantastic prizes in our 2005 prize draw. Visit www.gct.org.uk, click 
on the membership menu and choose 2005 Prize Draw and purchase your draw 
tickets.**

E-mail Disclaimer
This communication from Hugues Santin-Janin contains information which is 
CONFIDENTIAL and may also be privileged.  It is for the exclusive use of the 
addressee.  If you are not the addressee please note that any distribution, 
copying or use of this communication or the information in it is prohibited.  
If you have received this communication in error, please telephone us 
immediately to arrange for its return.


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


Re: [R] color palette

2005-08-04 Thread Tuszynski, Jaroslaw W.
'Tim.colors' in 'fields' package goes from blue to red, and passes through
the colors cyan, yellow, and orange. Also known as Jet color-map in Matlab.
You can also easily design your own color map using 'rgb' function from
'gdDevices'.

Jarek
\===

 Jarek Tuszynski, PhD.   o / \ 
 Science Applications International Corporation  <\__,|  
 (703) 676-4192   ">   \
 [EMAIL PROTECTED] `\



-Original Message-
From: [EMAIL PROTECTED]
[mailto:[EMAIL PROTECTED] On Behalf Of array chip
Sent: Wednesday, August 03, 2005 8:03 PM
To: r-help@stat.math.ethz.ch
Subject: [R] color palette

Hi, I have a matrix with both positive and negative numbers, I would like to
use image() to draw a heatmap. How can I can design a palette (or is there a
function already available) that treat negative numbers in a blue gradient
and positive numbers in a red gradient and treat 0 as white?

Thanks

__
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

__
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


Re: [R] additional graphical parameters in contour function

2005-08-04 Thread Abdou ALI

>> Do you know why additional graphical parameters (like "type","pch", ...) 
>> do not work in the R contour fonction. For example the command 
>> 'contour(..., type="o",pch=16)' gives nothing, just simple contour lines.
>
> Please, can you explain why you think it does make sense here?
>
The reason is that I want to add on a same graphic several contour plot, and 
I want to give different line types for each contour. I thus thought that 
these options of the contour function made it possible to do it.

Thank.


>
> Uwe Ligges
>
>
>> Thank you for your response.
>>
>> Abdou. [[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
>

__
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


Re: [R] optim

2005-08-04 Thread Gabor Grothendieck
Check out:

http://finzi.psych.upenn.edu/R/Rhelp02a/archive/18289.html

On 8/4/05, nwew <[EMAIL PROTECTED]> wrote:
> Dear R-helpers,
> 
> The function optim implements algorithms that I would like to use.
> 
> 
> I have function implemented in R, which given the parameters of which
> minimization is to take place returns a scalar as well as the gradient.
> 
> Unfortunately optim requires two function _fn_ and _gr_ where fn returns the
> function value and gr the gradient. Splitting my function in two functions
> would be easy, however I am wondering if evaluating both is not doubling the
> the very high computational costs. Most of the computational intensive
> operations are identical if computing the function value and gradient.
> 
> Question: is there a way to tweek optim that only one function evaluation is
> necessary? Are ther other implementations of the algorithm, which do assume
> that the function to be minimized returns the function value and the gradient
> as well?
> 
> Thanks
> Eryk.
> 
> __
> 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
>

__
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


Re: [R] additional graphical parameters in contour function

2005-08-04 Thread Uwe Ligges
Abdou ALI wrote:

> Hello,
> Do you know why additional graphical parameters (like "type","pch", ...) do 
> not work in the R contour fonction. For example the command 'contour(..., 
> type="o",pch=16)' gives nothing, just simple contour lines.

Please, can you explain why you think it does make sense here?

Uwe Ligges


> Thank you for your response.
> 
> Abdou. 
>   [[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

__
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


[R] Using nonlinear regression

2005-08-04 Thread Mark Miller
Hi, I have been trying to figure out how to use the nonlinear regression to 
fit the cumulative lognormal distribution to a number of data points I have 
but I am a new R user and I cant quite decipher the notes on nonlinear 
regression.  Any help in this regard will be greatly appreciated, my email 
address is [EMAIL PROTECTED]

__
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


Re: [R] Eclipse, R, plug-in?

2005-08-04 Thread A.J. Rossini
On 04 Aug 2005 10:26:40 +0200, Peter Dalgaard <[EMAIL PROTECTED]> wrote:

> I seem to recall that there is an S-PLUS plugin in the latest version,
> but we haven't received it yet.

I believe it's in the "enterprise edition" (which is the version with
"large datasets", etc), not the more common and less expensive
professional version.

best,
-tony

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

A.J. Rossini
[EMAIL PROTECTED]

__
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


Re: [R] how to read individual values from a pixmap object

2005-08-04 Thread Roger Bivand
On Thu, 4 Aug 2005, Tony Gill wrote:

> Hi All,
>  
> I have a greyscale image that I am reading in through RGDAL and placing in a
> pixmap object.
>  
> As an example use the logo.jpg file that comes with the RGDAL package:
>  
> #Read the file
> logo <- system.file("pictures/logo.jpg", package="rgdal")[1]
> x <- new("GDALReadOnlyDataset", logo)
>  
> #Create the pixmap object
> xGrey <- getPixmapGDAL(x)
>  
> Now I would like to read individual pixel values and store them in a
> separate vector. However I have not found a straight-forward way to do this.
>  
> I thought that something like:
>  
> x <- xGrey[1,1]
>  
> would return the pixel value, but it seems to return a pixmap object with
> dimension 1x1 (i.e. only one pixel in size)
>  
> xGrey[1,1]
> Pixmap image
>   Type  : pixmapGrey 
>   Size  : 1x1 
>   Resolution: 1x1 
>   Bounding box  : 1 0 2 1
>  
> Any ideas on how to get the actual pixel value from a pixmap? (Note I could
> output to an ascii file and then read the file back in as text - but not
> nice!)
>  

There are lots of ideas in the S4 Classes and Methods useR! 04 keynote
talk given by pixmap maintainer Friedrich Leisch at:  

http://www.ci.tuwien.ac.at/Conferences/useR-2004/Keynotes/Leisch.pdf

but the easiest one is:

> setAs("pixmapGrey", "matrix", function(from, to) [EMAIL PROTECTED])
> x
Pixmap image
  Type  : pixmapGrey 
  Size  : 1x1 
  Resolution: 1x1 
  Bounding box  : 0 0 1 1 

> as(x, "matrix")
 [,1]
[1,]1

unless you use a hammer and chisel:

> str(x)
Formal class 'pixmapGrey' [package "pixmap"] with 6 slots
  ..@ grey: num [1, 1] 1
  ..@ channels: chr "grey"
  ..@ size: int [1:2] 1 1
  ..@ cellres : num [1:2] 1 1
  ..@ bbox: num [1:4] 0 0 1 1
  ..@ bbcent  : logi FALSE
> [EMAIL PROTECTED]
 [,1]
[1,]1



> Thanks in advance
>  
> Tony
>  
> **
> Tony Gill - PhD Candidate
> Centre for Remote Sensing & Spatial Information Science
> School of Geography, Planning & Architecture
> University of Queensland
> Brisbane, Queensland, AUSTRALIA, 4072
> Ph: 61-7-3365-7027
> email: [EMAIL PROTECTED]
> 
>   [[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
> 

-- 
Roger Bivand
Economic Geography Section, Department of Economics, Norwegian School of
Economics and Business Administration, Helleveien 30, N-5045 Bergen,
Norway. voice: +47 55 95 93 55; fax +47 55 95 95 43
e-mail: [EMAIL PROTECTED]

__
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


Re: [R] optim

2005-08-04 Thread Sundar Dorai-Raj


nwew wrote:
> Dear R-helpers,
> 
> The function optim implements algorithms that I would like to use.
> 
> 
> I have function implemented in R, which given the parameters of which 
> minimization is to take place returns a scalar as well as the gradient.
> 
> Unfortunately optim requires two function _fn_ and _gr_ where fn returns the 
> function value and gr the gradient. Splitting my function in two functions 
> would be easy, however I am wondering if evaluating both is not doubling the 
> the very high computational costs. Most of the computational intensive 
> operations are identical if computing the function value and gradient.
> 
> Question: is there a way to tweek optim that only one function evaluation is 
> necessary? Are ther other implementations of the algorithm, which do assume 
> that the function to be minimized returns the function value and the gradient 
> as well?
> 
> Thanks
> Eryk.
> 

Hi, Eryk,

?optim does not *require* the "gr" argument. If one is not supplied, 
numerical gradients are used for which optim evaluates "fn" twice. 
However, in many cases analytical gradients can both improve numerical 
accuracy and computational speed.

Trivial example:

fn <- function(beta) {
   sum((y - x %*% beta)^2)
}

gr <- function(beta) {
   colSums(-2 * x * drop((y - x %*% beta)))
}

set.seed(1)
n <- 1
p <- 5
g <- factor(rep(LETTERS[1:p], each = n/p))
x <- model.matrix(~g)
beta <- rnorm(p)
y <- drop(x %*% beta + rnorm(n))
start <- rep(0, p)

system.time(f1 <- optim(start, fn, gr, hessian = TRUE))
# [1] 0.47 0.00 0.48   NA   NA

system.time(f2 <- optim(start, fn, hessian = TRUE))
# [1] 0.54 0.00 0.53   NA   NA

f1$par
#[1] -0.6408643  0.2128109 -0.8378791  1.5983054  0.3366216

f2$par
#[1] -0.6408643  0.2128109 -0.8378791  1.5983054  0.3366216

f1$hessian
#  [,1] [,2] [,3] [,4] [,5]
#[1,] 2 4000 4000 4000 4000
#[2,]  4000 4000000
#[3,]  40000 400000
#[4,]  400000 40000
#[5,]  4000000 4000

f2$hessian
#  [,1] [,2] [,3] [,4] [,5]
#[1,] 2 4.00e+03 4000 4.00e+03 4000
#[2,]  4000 4.00e+030 2.273737e-070
#[3,]  4000 0.00e+00 4000 0.00e+000
#[4,]  4000 2.273737e-070 4.00e+030
#[5,]  4000 0.00e+000 0.00e+00 4000
#

Does this answer your question? Furthermore, have you read the chapter 
in MASS that discusses optim?

HTH,

--sundar

__
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


[R] additional graphical parameters in contour function

2005-08-04 Thread Abdou ALI
Hello,
Do you know why additional graphical parameters (like "type","pch", ...) do not 
work in the R contour fonction. For example the command 'contour(..., 
type="o",pch=16)' gives nothing, just simple contour lines.
Thank you for your response.

Abdou. 
[[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


Re: [R] optim

2005-08-04 Thread Prof Brian Ripley
On Thu, 4 Aug 2005, nwew wrote:

> Dear R-helpers,
>
> The function optim implements algorithms that I would like to use.

They are available to you as part of the R API at C level.

> I have function implemented in R, which given the parameters of which
> minimization is to take place returns a scalar as well as the gradient.
>
> Unfortunately optim requires two function _fn_ and _gr_ where fn returns the
> function value and gr the gradient. Splitting my function in two functions
> would be easy, however I am wondering if evaluating both is not doubling the
> the very high computational costs. Most of the computational intensive
> operations are identical if computing the function value and gradient.

That is an unusual situation.

> Question: is there a way to tweek optim that only one function evaluation is
> necessary? Are ther other implementations of the algorithm, which do assume
> that the function to be minimized returns the function value and the gradient
> as well?

You can of course write your function to cache the work and check if the
parameter value is unchanged from the last call.  Then if the optimizer 
calls for the gradient after the function value in the same place (and 
most methods will) you can just do the additional work for the gradient.

That is what nnet does, at C level.

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


Re: [R] optim

2005-08-04 Thread Duncan Murdoch
nwew wrote:
> Dear R-helpers,
> 
> The function optim implements algorithms that I would like to use.
> 
> 
> I have function implemented in R, which given the parameters of which 
> minimization is to take place returns a scalar as well as the gradient.
> 
> Unfortunately optim requires two function _fn_ and _gr_ where fn returns the 
> function value and gr the gradient. Splitting my function in two functions 
> would be easy, however I am wondering if evaluating both is not doubling the 
> the very high computational costs. Most of the computational intensive 
> operations are identical if computing the function value and gradient.
> 
> Question: is there a way to tweek optim that only one function evaluation is 
> necessary? Are ther other implementations of the algorithm, which do assume 
> that the function to be minimized returns the function value and the gradient 
> as well?

I don't know the answer to your question, but here's a different 
approach.  Write a function that effectively splits your single function 
into two:

splitfn <- function(f) {
   lastx <- NA
   lastfn <- NA
   lastgr <- NA

   doeval <- function(x) {
 if (identical(all.equal(x, lastx), TRUE)) return(lastfn)
 lastx <<- x
 both <- f(x)
 lastfn <<- both$fnval
 lastgr <<- both$grval
 return(lastfn)
   }

   fn <- function(x) doeval(x)

   gr <- function(x) {
 doeval()
 lastgr
   }

   list(fn=fn, gr=gr)
}

I haven't tested this, but the idea is that it sets up a local 
environment where the last x value and last function and gradient values 
are stored.  If the next call asks for the same x, then the cached 
values are returned.  I don't know if it will actually improve 
efficiency:  that depends on whether optim evaluates the gradient and 
function values at the same points or at different points.

You would use this as follows, assuming your function is called f:

  f2 <- splitfn(f)

  optim(par, f2$fn, f2$gr, ...)

Duncan Murdoch

__
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


Re: [R] help for cell2nb and queencell in spdep package

2005-08-04 Thread Roger Bivand
On Wed, 3 Aug 2005, ecoinfo wrote:

> Dear Dr. Bivand and R-users,
>  I have a 5 by 5 grid, say, location[1:5,1:5], and I want to know the 
> indices of 8 neighbours of each cell. For example, for location[2,2], its 
> neighbour coordinates are [1,1:3], [2,1], [2,3] and [3,1:3]. Sometimes I 
> also need to remove edge effects (torus = TRUE).
>  I have tried "cell2nb" function in your spdep package. Here's my example:
>  > neigh <- cell2nb(5,5,type="queen",torus=T)
> > neigh
> Neighbour list object:
> Number of regions: 25 
> Number of nonzero links: 200 
> Percentage nonzero weights: 32 
> Average number of links: 8 
> > neigh[1]
> [[1]]
> [1] 2 5 6 7 10 21 22 25
>  Is there way to index each element of neigh[1], i.e., the first is 2, the 
> second is 5, ... ? 

neigh is a list of integer vectors, so you can use standard indexing:

> neigh[[1]][1]
[1] 2

using double square brackets for accessing the list components, and single 
for the vector elements. I think this is what you are asking for, if not, 
please clarify. To find out which (row, column) address this corresponds 
to, look it up in the "region.id" attribute:

> attr(neigh, "region.id")[neigh[[1]][1]]
[1] "2:1"

>  Could you also give me an example of the function "queencell(rowcol, nrow, 
> ncol, torus=FALSE, rmin=1, cmin=1)"? What's a rowcol? 

>From the help page: 

"rowcol: matrix with two columns of row, column indices"

The queencell function is used internally, but takes a single row matrix 
of (row, column) indices, and returns a matrix of (row, column) indices 
for the contiguous neighbours of that cell:

> queencell(matrix(c(1,1),1,2), 8, 8, TRUE)
 row col
[1,]   2   8
[2,]   1   8
[3,]   8   8
[4,]   2   1
[5,]   8   1
[6,]   2   2
[7,]   1   2
[8,]   8   2
attr(,"coords")
[1] 1 1

for your case on a torus.

Hope this helps,

Roger

>  Thanks,
> Xiaohua
> 
> 

-- 
Roger Bivand
Economic Geography Section, Department of Economics, Norwegian School of
Economics and Business Administration, Helleveien 30, N-5045 Bergen,
Norway. voice: +47 55 95 93 55; fax +47 55 95 95 43
e-mail: [EMAIL PROTECTED]

__
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


[R] optim

2005-08-04 Thread nwew
Dear R-helpers,

The function optim implements algorithms that I would like to use.


I have function implemented in R, which given the parameters of which 
minimization is to take place returns a scalar as well as the gradient.

Unfortunately optim requires two function _fn_ and _gr_ where fn returns the 
function value and gr the gradient. Splitting my function in two functions 
would be easy, however I am wondering if evaluating both is not doubling the 
the very high computational costs. Most of the computational intensive 
operations are identical if computing the function value and gradient.

Question: is there a way to tweek optim that only one function evaluation is 
necessary? Are ther other implementations of the algorithm, which do assume 
that the function to be minimized returns the function value and the gradient 
as well?

Thanks
Eryk.

__
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


[R] fit non linear model using weighted least squares

2005-08-04 Thread Di Tanna Gian Luca
Dear all, 

I am new in using R.

 

I'd like to fit a non linear model using weighted least squares.

I am using the gnls function but I don't know how to perform a weighted
least squares (my weights are a "simple" colum of data).

 

Thank you in advance, 

Gian Luca

 


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


Re: [R] [EMAIL PROTECTED]

2005-08-04 Thread Nensi Brailo
I will be on vacation until August 11, 2005.  
I will respond to your message when I return.  Thank you.  

If you need immediate assistance please call or e-mail the following:

for circulation related questions please call Meyer Library Circulation 
at 510-594-3658
for reference assistance please call Simpson Library at 415-703-9574
for reference and ARTstore related questions please call Jon Worona at 
415-551-9252 or e-mail [EMAIL PROTECTED] 

--Nensi Brailo, Librarian
Meyer Library, California College of the Arts 

P.S. For more information please visit the CCA Libraries website at 
http://library.cca.edu

__
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


Re: [R] multivariate F distribution

2005-08-04 Thread Dimitris Rizopoulos
Well, there is a way for constructing a "multivariate F" (i.e., a 
multivariate distribution with F marginals), using copulas, thanks to 
Jun Yan's copula package. For instance, in for the bivariate case

library(copula)
x <- mvdc(claytonCopula(2), c("f", "f"),
  list(list(df1 = 8, df2 = 9), list(df1 = 8, df2 = 9)))
x
contour(x, dmvdc, xis = seq(1e-04, 2, len = 51), yis = seq(1e-04, 2, 
len = 51))

x.samp <- rmvdc(x, 1000)
hist(x.samp[, 1])
hist(x.samp[, 2])


Regarding the "correlation", the Clayton copula for theta = 2 gives 
Kendall's tau = 0.5, e.g.,

cor(x.samp, method = "kendall")


Best,
Dimitris


Dimitris Rizopoulos
Ph.D. Student
Biostatistical Centre
School of Public Health
Catholic University of Leuven

Address: Kapucijnenvoer 35, Leuven, Belgium
Tel: +32/16/336899
Fax: +32/16/337015
Web: http://www.med.kuleuven.be/biostat/
 http://www.student.kuleuven.be/~m0390867/dimitris.htm


- Original Message - 
From: "Peter Dalgaard" <[EMAIL PROTECTED]>
To: "Anna Oganyan" <[EMAIL PROTECTED]>
Cc: 
Sent: Thursday, August 04, 2005 10:05 AM
Subject: Re: [R] multivariate F distribution


Anna Oganyan <[EMAIL PROTECTED]> writes:

> Dear List,
>
> Is there any function in R to generate multivariate F distribution 
> with
> given correlation/covariance matrix?
>
> Actually, I just want to generate some 2-dimentional non-normal data
> sets (skewed) for low (may be around 0.3 cor coeff.) negatively and 
> also
> positively correlated variables .
>
> Thanks in advance.
>
> Anna

Er, what is "multivariate F"? I have a guess (solve(A,B) where A and B
have independent Wishart distributions with the same covariance matrix
-- the matrix that gets summarized into Wilk's Lambda, Pillai's trace,
etc.) but Googling also pops up something about "inverted Dirichlet"
which may or may not be equivalent.

Wishart variates can be generate from (multivariate) normals in a
brute-force way using crossprod(). Some may have thought up a more
efficient way.

-- 
   O__   Peter Dalgaard Øster Farimagsgade 5, Entr.B
  c/ /'_ --- Dept. of Biostatistics PO Box 2099, 1014 Cph. K
 (*) \(*) -- University of Copenhagen   Denmark  Ph:  (+45) 
35327918
~~ - ([EMAIL PROTECTED])  FAX: (+45) 
35327907

__
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

__
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


Re: [R] using weighted.mean with tapply()

2005-08-04 Thread Martyn Plummer
On Wed, 2005-08-03 at 17:00 -0400, roger bos wrote:
> I am trying to calculate the weighted mean for a of 10 deciles and I
> get an error:
> > decile <- tapply(X=mat$trt1m, INDEX=mat$Rank, FUN=weighted.mean, w=mat$mcap)
> Error in FUN(X[[1]], ...) : 'x' and 'w' must have the same length
> 
> All three of my inputs have the same length, as shown below, and the
> weighted.mean calculation works by itself, just not in tapply()
> 
> > length(mat$Rank)
> [1] 1853
> > length(mat$mcap)
> [1] 1853
> > length(mat$trt1m)
> [1] 1853
> > mean(mat$trt1m)
> [1] -0.04475397
> weighted.mean(mat$trt1m, w=mat$mcap)
> [1] -0.04819243
> > mat$mcap[is.na(mat$mcap)] <- min(mat$mcap, na.rm=TRUE)
> 
> I am probably making a simple error in how I pass the optional
> parameter w.  Any help would be greatly appreciated.

When you use tapply, only the first argument of the function you supply
is split by the index variable.  There is no way for tapply to know if
further arguments should be split or not, so it doesn't split them.  
People are regularly caught out by this.  If you look carefully at the
documentation for split, there is a warning about it.

Here is a very dense solution (due to Peter Dalgaard):

by(mat, mat$Rank, with, weighted.mean(trt1m,  mcap))

Alternatively you can split up the data frame using split, write your
own custom wrapper function for doing the weighted mean, and use lapply
or sapply:

sapply(split(mat,mat$Rank), function(x) {weighted.mean(x$trt1m,x$mcap)})

Martyn



---
This message and its attachments are strictly confidential. ...{{dropped}}

__
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


Re: [R] Eclipse, R, plug-in?

2005-08-04 Thread Peter Dalgaard
Uwe Ligges <[EMAIL PROTECTED]> writes:

> Robert Citek wrote:
> 
> > Has any developed or is anyone developing a plug-in[1] for using R  
> > with Eclipse[2]?
> 
> Stephan Wahlbrink made a Plug-In available at
> http://www.walware.de/goto/statet
> 
> Uwe Ligges

Cool. Especially now that Eclipse exists in an entirely Free Software
variant (GNU classpath) that ships with FC4. Judging from Stephan's
comments there is still work to be done, though.

I seem to recall that there is an S-PLUS plugin in the latest version,
but we haven't received it yet.

-p

-- 
   O__   Peter Dalgaard Øster Farimagsgade 5, Entr.B
  c/ /'_ --- Dept. of Biostatistics PO Box 2099, 1014 Cph. K
 (*) \(*) -- University of Copenhagen   Denmark  Ph:  (+45) 35327918
~~ - ([EMAIL PROTECTED])  FAX: (+45) 35327907

__
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


Re: [R] problem with for()

2005-08-04 Thread Simone Gabbriellini
Marc,
I did it with the simple trick of keepin separate vector values and  
index values, as you suggested in your mail

it was simple, but you know, it's always simple when you've done it :)

thank you very much,
simone

Il giorno 04/ago/05, alle ore 00:39, Marc Schwartz ha scritto:

> It would help to have an example of what it is you are trying to do.
>
> Importantly, keep separate the need to have zero be a value in a  
> vector
> as opposed to using zero to index a vector.
>
> As I note below in my reply, you can have:
>
>
>> x <- 0:5
>>
>
>
>> x
>>
> [1] 0 1 2 3 4 5
>
>
>> x ^ 2
>>
> [1]  0  1  4  9 16 25
>
> Marc
>
> On Thu, 2005-08-04 at 00:25 +0200, Simone Gabbriellini wrote:
>
>> how can I have a 0 evaluated in my loop then?
>> it is important for my algorithm
>>
>> do you have any hints?
>>
>> simone
>>
>> Il giorno 03/ago/05, alle ore 23:37, Marc Schwartz ha scritto:
>>
>>
>>> On Wed, 2005-08-03 at 23:24 +0200, Simone Gabbriellini wrote:
>>>
>>>
 Dear list,
 can someone tell me why this two pieces of code give me the same
 results?



> for(i in 0:5){ sum[i] = i }
> sum
>
>
 [1] 1 2 3 4 5



> for(i in 1:5){ sum[i] = i }
> sum
>
>
 [1] 1 2 3 4 5

 shouldn't the first one be

 0 1 2 3 4 5

 thank you,
 simone


>>>
>>> Nothe indexing of R objects is 1 based. Thus your first loop  
>>> tried
>>> to set i[0], which is a non-existent entry.
>>>
>>>
>>>
 i <- 0:5


>>>
>>>
>>>
 i


>>> [1] 0 1 2 3 4 5
>>>
>>>
>>>
 i[0]


>>> numeric(0)
>>>
>>>
>>>
 i[1]


>>> [1] 0
>>>
>>> HTH,
>>>
>>> Marc Schwartz
>>>
>>>
>>>
>>>
>>>
>
>

__
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


Re: [R] multivariate F distribution

2005-08-04 Thread Peter Dalgaard
Anna Oganyan <[EMAIL PROTECTED]> writes:

> Dear List,
> 
> Is there any function in R to generate multivariate F distribution with 
> given correlation/covariance matrix?
> 
> Actually, I just want to generate some 2-dimentional non-normal data 
> sets (skewed) for low (may be around 0.3 cor coeff.) negatively and also 
> positively correlated variables …
> 
> Thanks in advance.
> 
> Anna

Er, what is "multivariate F"? I have a guess (solve(A,B) where A and B
have independent Wishart distributions with the same covariance matrix
-- the matrix that gets summarized into Wilk's Lambda, Pillai's trace,
etc.) but Googling also pops up something about "inverted Dirichlet"
which may or may not be equivalent.

Wishart variates can be generate from (multivariate) normals in a
brute-force way using crossprod(). Some may have thought up a more
efficient way.

-- 
   O__   Peter Dalgaard Øster Farimagsgade 5, Entr.B
  c/ /'_ --- Dept. of Biostatistics PO Box 2099, 1014 Cph. K
 (*) \(*) -- University of Copenhagen   Denmark  Ph:  (+45) 35327918
~~ - ([EMAIL PROTECTED])  FAX: (+45) 35327907

__
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


[R] how to read individual values from a pixmap object

2005-08-04 Thread Tony Gill
Hi All,
 
I have a greyscale image that I am reading in through RGDAL and placing in a
pixmap object.
 
As an example use the logo.jpg file that comes with the RGDAL package:
 
#Read the file
logo <- system.file("pictures/logo.jpg", package="rgdal")[1]
x <- new("GDALReadOnlyDataset", logo)
 
#Create the pixmap object
xGrey <- getPixmapGDAL(x)
 
Now I would like to read individual pixel values and store them in a
separate vector. However I have not found a straight-forward way to do this.
 
I thought that something like:
 
x <- xGrey[1,1]
 
would return the pixel value, but it seems to return a pixmap object with
dimension 1x1 (i.e. only one pixel in size)
 
xGrey[1,1]
Pixmap image
  Type  : pixmapGrey 
  Size  : 1x1 
  Resolution: 1x1 
  Bounding box  : 1 0 2 1
 
Any ideas on how to get the actual pixel value from a pixmap? (Note I could
output to an ascii file and then read the file back in as text - but not
nice!)
 
Thanks in advance
 
Tony
 
**
Tony Gill - PhD Candidate
Centre for Remote Sensing & Spatial Information Science
School of Geography, Planning & Architecture
University of Queensland
Brisbane, Queensland, AUSTRALIA, 4072
Ph: 61-7-3365-7027
email: [EMAIL PROTECTED]

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


Re: [R] Puzzled at rpart prediction

2005-08-04 Thread Uwe Ligges
Ajay Narottam Shah wrote:

> I'm in a situation where I say:
> 
> 
>>predict(m.rpart, newdata=D[N1+t,])
> 
>   0   1
> 173 0.8 0.2
> 
> which I interpret as meaning: an 80% chance of "0" and a 20% chance of
> "1". Okay. This is consistent with:
> 
> 
>>predict(m.rpart, newdata=D[N1+t,], type="class")
> 
> [1] 0
> Levels: 0 1
> 
> But I'm puzzled at the following. If I say:
> 
> 
>>predict(m.rpart, newdata=D[N1+t,], type="vector")
> 
> 173 
>   1 
> 
> What gives?

This means that the class of the first level is chosen, and the first 
level is "0".

Uwe Ligges


> I will be happy to packup a runnable demonstration for any of you, but
> I wondered if it was just my lack of knowledge about "type" in
> predict.rpart; wondered if there was a simple and logical explanation.
>

__
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


Re: [R] Eclipse, R, plug-in?

2005-08-04 Thread Uwe Ligges
Robert Citek wrote:

> Has any developed or is anyone developing a plug-in[1] for using R  
> with Eclipse[2]?

Stephan Wahlbrink made a Plug-In available at
http://www.walware.de/goto/statet

Uwe Ligges


> Eclipse is an Integrated Development Environment (IDE) written in  
> Java.  While originally used as an IDE for Java, it has become an  
> nice environment for developing and testing in other languages, too,  
> including perl, C#, PHP, python, PL/SQL, among many others.
> 
> [1] http://www.eclipse.org/community/osplugins.html
> [2] http://www.eclipse.org/
> 
> Regards,
> - Robert
> http://www.cwelug.org/downloads
> Help others get OpenSource software.  Distribute FLOSS
> for Windows, Linux, *BSD, and MacOS X with BitTorrent
> 
> __
> 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

__
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