Re: [R] Turning off return warning messages.

2005-07-20 Thread Mulholland, Tom
doubleEm <- function(p1,p2,p3,p4){return(p1 *p1,p2 * p2, p3 * p3, p4 * p4)}
suppressWarnings(doubleEm(1,2,3,4)) 
[[1]]
[1] 1

[[2]]
[1] 4

[[3]]
[1] 9

[[4]]
[1] 16

> -Original Message-
> From: [EMAIL PROTECTED]
> [mailto:[EMAIL PROTECTED] Behalf Of Paul Roebuck
> Sent: Wednesday, 20 July 2005 1:50 PM
> To: R Help Mailing List
> Subject: Re: [R] Turning off return warning messages.
> 
> 
> On Wed, 20 Jul 2005, Steve Su wrote:
> 
> > Is there a way I can turn off the following warning message
> > for using multi-argument returns?
> >
> > multi-argument returns are deprecated in: return(p1, p2, p3, p4)
> 
> doubleEm <- function(p1, p2, p3, p4) {
> return(list(p1 = p1*p1,
> p2 = p2*p2,
> p3 = p3*p3,
> p4 = p4*p4))
> }
> 
> res <- doubleEm(1, 2, 3, 4)
> cat("p3 =", res$p3, "\n")
> 
> --
> SIGSIG -- signature too long (core dumped)
> 
> __
> 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] maps and data for german federal states

2005-07-20 Thread Ebersberger, Bernd
dear R-tists,

i want to graph information for the German Federal States (Bundeslaender) using 
the maps package. unfortunately there is no maps for the German Bundeslaender.

does anyone have an idea / a source where to get map data that can be used in 
the maps package that graphs structures below the country level. 

in the long run it would also be interesting to integrate Swiss Cantons and 
Austrian Bundesländer... 

any suggestions are highly appreciated.

thanks

bernd

++
bernd ebersberger
fhg isi
b.ebersberger (AT) isi.fhg.de

__
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] (no subject)

2005-07-20 Thread David Ruau
Hi All,

I want to print a square matrix of 7000 x 7000 into a text file. But I 
got a error after few hours of computation...

 > write.table(MyDistMxDF, file = "temp.csv", sep=",", quote=F)
*** malloc: vm_allocate(size=8421376) failed (error code=3)
*** malloc[2889]: error: Can't allocate region
Error: vector memory exhausted (limit reached?)
*** malloc: vm_allocate(size=8421376) failed (error code=3)
*** malloc[2889]: error: Can't allocate region
 >  q()
*** malloc: vm_allocate(size=8421376) failed (error code=3)
*** malloc[2889]: error: Can't allocate region
*** malloc: vm_allocate(size=8421376) failed (error code=3)
*** malloc[2889]: error: Can't allocate region
Error in lazyLoadDBfetch(key, datafile, compressed, envhook) :
 internal error in decompress1
 >
--
I am running R 2.0.1 on MacOS X 10.3 with 1Gb ram.
How could I write such a matrix to a text file.

David

__
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] package (!) mclust in 64bit compiled R

2005-07-20 Thread Martin Maechler
> "TaeHC" == Tae-Hoon Chung <[EMAIL PROTECTED]>
> on Tue, 19 Jul 2005 10:26:01 -0700 writes:

TaeHC> Hi, All; I tried to use library mclust in 64-bit
TaeHC> compiled R 2.0.1 but failed.  

you mean   "package  mclust"
{a package is installed in a library full of packages}

TaeHC> Installation went smoothly without any warning or
TaeHC> error. However, when I tried to use them with the
TaeHC> following simple code, it crashed.

 >  library(mclust)
 >  Dat <- c(rnorm(20, mean=0, sd=0.2), rnorm(30, mean=1, sd=0.2))
 >  Ind <- Mclust(dat, 1, 5)$classification
 >  cbind(Dat, Ind)

My desktop has been a 64-bit (AMD Athlon 64) for more than a
year now, and I do note small differences to 32-bit some times,
and even have found (and not yet solved) quite severe problem
with the akima package.

Not with 'mclust' though.
I've just run several 1000 of Mclust() fits like the one above
and not seen any problem.

TaeHC> The error message was:

TaeHC> /usr/local/R-2.0.1_64bit/lib/R/bin/BATCH: line 55:
TaeHC> 18097 Done ( echo "invisible(options(echo = TRUE))";
TaeHC> cat ${in}; echo "proc.time()" ) 18099 Segmentation
TaeHC> fault | ${R_HOME}/bin/R ${opts} >${out} 2>&1
  

TaeHC> Can anybody help me with this?  Thanks in advance,

- Does *every* call to Mclust() give a segmentation fault?

- I assume you -- or someone in your group has compiled this R version
from source.  Did you (or he/she) run  "make check" after
building from source?  Could you (or ..) asks to run it?

- What output do you get when you run 
  
  R -d gdb
  r

  then the above R code,
  and then maybe type 'bt' (backtrace) ?


Regards,
Martin Maechler, ETH Zurich

__
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] data mining

2005-07-20 Thread Vito Ricci
Hi Adrian,
give a look to these links concerning R & DM:

http://www.togaware.com/datamining/survivor/R.html
http://sawww.epfl.ch/SIC/SA/publications/FI01/fi-sp-1/sp-1-page45.html
http://www.stats.ox.ac.uk/~vos/DataMining.html

Hoping I helped you.

Regards,

Vito



secretario academico FACEA faceasec at uapar.edu 
wrote:

Dear all,
I'm looking for some material on data mining with R. I
have something 
from Luis Torgo but I'd like to see something else.
If anybody could help me I'll be thankful
Adrián


Diventare costruttori di soluzioni
Became solutions' constructors

"The business of the statistician is to catalyze 
the scientific learning process."  
George E. P. Box

"Statistical thinking will one day be as necessary for efficient citizenship as 
the ability to read and write"
H. G. Wells

Top 10 reasons to become a Statistician

 1. Deviation is considered normal
 2. We feel complete and sufficient
 3. We are 'mean' lovers
 4. Statisticians do it discretely and continuously
 5. We are right 95% of the time
 6. We can legally comment on someone's posterior distribution
 7. We may not be normal, but we are transformable
 8. We never have to say we are certain
 9. We are honestly significantly different
10. No one wants our jobs


Visitate il portale http://www.modugno.it/
e in particolare la sezione su Palese  
http://www.modugno.it/archivio/palesesanto_spirito/

__
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] writing matrices (no subject)

2005-07-20 Thread Prof Brian Ripley
Please use a current version of R: they are much better at this!
write.table was rewritten in R 2.1.0 to use *much* less memory.

There _is_ a `R Data Import/Export Manual' that dicsusses this.
write.table was designed to write `tables' (data frames) not matrices.
write.matrix (package MASS) does a much better job of the latter, 
memory-wise, in particular allowing the use of blocks.

That _is_ on the help page for write.table in your version of R.

Assuming this is a numeric matrix, it is taking up 373MB of storage.
It is not too surprising that you are having problems manipulating it on a 
1GB machine: my 1GB machine ended up swapping just creating such a matrix.


On Wed, 20 Jul 2005, David Ruau wrote:

> Hi All,
>
> I want to print a square matrix of 7000 x 7000 into a text file. But I
> got a error after few hours of computation...
> 
> > write.table(MyDistMxDF, file = "temp.csv", sep=",", quote=F)
> *** malloc: vm_allocate(size=8421376) failed (error code=3)
> *** malloc[2889]: error: Can't allocate region
> Error: vector memory exhausted (limit reached?)
> *** malloc: vm_allocate(size=8421376) failed (error code=3)
> *** malloc[2889]: error: Can't allocate region
> >  q()
> *** malloc: vm_allocate(size=8421376) failed (error code=3)
> *** malloc[2889]: error: Can't allocate region
> *** malloc: vm_allocate(size=8421376) failed (error code=3)
> *** malloc[2889]: error: Can't allocate region
> Error in lazyLoadDBfetch(key, datafile, compressed, envhook) :
> internal error in decompress1
> >
> --
> I am running R 2.0.1 on MacOS X 10.3 with 1Gb ram.
> How could I write such a matrix to a text file.

-- 
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] CPU Usage with R 2.1.0 in Windows

2005-07-20 Thread Prof Brian Ripley
It probably is not a problem to leave hyperthreading on: we found little 
performance difference on a P4 either way.


The Windows task manager is misleading, as `50%' is about as much as a 
P4-class processor with hyperthreading can actually deliver.


On Tue, 19 Jul 2005, Lukasz Komsta wrote:


Dnia 2005-07-19 20:28, Uÿÿytkownik Greene, Michael napisaÿÿ:

Hi,> > I'm using a fairly simple HP Compaq desktop PC running Windows 2K.  When> running a 
large process in R, the process "RGUI.exe" will never exceed 50%> of the CPU usage.

If you have hyperthreading, R catches only one virtual processor (fromtwo 
available), being not able to exceed half of total power (100% ofone only). If 
you want to use full power, you should turn hyperthreadingoff, if your BIOS 
supports such option.
Regards,
-- Lukasz KomstaDepartment of Medicinal ChemistryMedical University of Lublin6 
Chodzki, 20-093 Lublin, PolandFax +48 81 7425165
[EMAIL PROTECTED] mailing 
listhttps://stat.ethz.ch/mailman/listinfo/r-helpPLEASE do read the posting 
guide! http://www.R-project.org/posting-guide.html



--
Brian D. Ripley,  [EMAIL PROTECTED]
Professor of Applied Statistics,  http://www.stats.ox.ac.uk/~ripley/
University of Oxford, Tel:  +44 1865 272861 (self)
1 South Parks Road, +44 1865 272866 (PA)
Oxford OX1 3TG, UKFax:  +44 1865 272595__
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] Problems with date-format (R 2.1.1 + chron)

2005-07-20 Thread Prof Brian Ripley

x <- as.Date("21-07-2005","%d-%m-%y")

is base R, and gives you a object of class "Date".

days() is not part of R, and I guess from your subject is part of chron. 
Its help page does not say what it actually does, but my guess is that it 
finds days of the month, *for a "dates" object not a "Date" object*.  Try


as.POSIXlt(x)$mday

to get that.

On Tue, 19 Jul 2005, Carsten Steinhoff wrote:


today I've updated on the newest R-Version. But sadly a function I needed
didnt want to work:


It should never have worked, as you were using contrary to its 
documentation.



The input is e.g.

days(as.Date("21-07-2005","%d-%m-%y"))

the error is: Fehler in Math.Date(dts): floor nicht definiert für Date
Objekte
(Error in Math.Date(dts): floor not defined for date objects)

Same for year. Only months gives me the correct output.
In Version 2.01 it worked very well, with the same chron library.
Whats wrong ?


There is no version 2.01 of R: do see the posting guide!

--
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] Michaelis-menten equation

2005-07-20 Thread Peter Dalgaard
"Chun-Ying Lee" <[EMAIL PROTECTED]> writes:

> Hi,
> 
>We used known Vm and Km to simulate the data set (time, Cp) without
> adding random error in there.  Yes, the line looks like very close
> to a straight line.  But why can't we obtain the correct values with
> fitting process?  We used optim first and then followed by using nls
> to fit the model.  Thanks.
> 
> regards,


Check your simulation. There is no way that curve is consistent with
Km in the middle of the y range!

> ---Chun-ying Lee
> > 
> > Hmm, sorry, no. I'm talking through a hole in my head there.
> > 
> > Vm*y/(Km+y) makes OK sense. Vm is what you get for large y - passing
> > from 1st order to 0th order kinetics. However, looking at the data
> > 
> >  plot(PKindex)
> >  abline(lm(conc~time,data=PKindex))
> > 
> > shows that they are pretty much on a straight line, i.e. you are 
> > in the domain of 0-order kinetics. So why are you expecting the rate
> > of decrease to have changed by roughly 3/4 (from 2/3*Vm/Vd at y=2*Km
> > to 1/2*Vm/Vd at y=Km when you reach 4.67)??
> >
> 
> __
> 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

-- 
   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] .gct file

2005-07-20 Thread Prof Brian Ripley
On Tue, 19 Jul 2005, Marc Schwartz (via MN) wrote:

> For the TAB delimited columns, adjust the 'sep' argument to:
>
> read.table("data.gct", skip = 2, header = TRUE, sep = "\t")
>
> The 'quote' argument is by default:
>
> quote = "\"'"
>
> which should take care of the quoted strings and bring them in as a
> single value.
>
> The above presumes that the header row is also TAB delimited. If not,
> you may have to set 'skip = 3' to skip over the header row and manually
> set the column names.

Not quite.  You can open a connection, skip 2 rows and read one to get the 
column names, then read the rest of the file using read.table on the open 
connection using the column names you just read.

However, based on what we have been shown

read.table("data.gct", skip = 2, header = TRUE)

ought to work as the file looks as if it is white-space delimited (a tab 
is white space).

>
> HTH,
>
> Marc Schwartz
>
>
> On Tue, 2005-07-19 at 13:52 -0400, mark salsburg wrote:
>> This is all extremely helpful.
>>
>> The data turns out is a little atypical, the columns are tab-delemited
>> except for the description columns
>>
>>
>> DATA1.gct looks like this
>>
>> #1.2
>> 23 3423
>> NAME DESCRIPTION VALUE
>> gene1 "a protein inducer" 1123
>> .  . ..
>>
>> How do I get R to read the data as tab delemited, but read in the 2nd
>> coloumn as one value based on the quotation marks..
>>
>> thanks..
>>
>> On 7/19/05, Marc Schwartz (via MN) <[EMAIL PROTECTED]> wrote:
>>> On Tue, 2005-07-19 at 13:16 -0400, mark salsburg wrote:
 ok so the gct file looks like this:

 #1.2  (version number)
 7283 19   (matrix size)
 Name Description Values
   ...  ..

 How can I tell R to disregard the first two lines and start reading
 the 3rd line in this gct file. I would just delete them, but I do not
 know how to open a gct. file

 thank you

 On 7/19/05, Duncan Murdoch <[EMAIL PROTECTED]> wrote:
> On 7/19/2005 12:10 PM, mark salsburg wrote:
>> I have two files to compare, one is a regular txt file that I can read
>> in no prob.
>>
>> The other is a .gct file (How do I read in this one?)
>>
>> I tried a simple
>>
>> read.table("data.gct", header = T)
>>
>> How do you suggest reading in this file??
>>
>
> .gct is not a standard filename extension.  You need to know what is in
> that file.  Where did you get it?  What program created it?
>
> Chances are the easiest thing to do is to get the program that created
> it to export in a well known format, e.g. .csv.
>
> Duncan Murdoch
>>>
>>>
>>> The above would be consistent with the info in my reply.
>>>
>>> I guess if the format is consistent, as per Mark's example above, you
>>> can use:
>>>
>>> read.table("data.gct", skip = 2, header = TRUE)
>>>
>>> which will start by skipping the first two lines and then reading in the
>>> header row and then the data.
>>>
>>> See ?read.table
>>>
>>> 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
>

-- 
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] problem in Krig function of "Fields" package

2005-07-20 Thread Prof Brian Ripley
My guess is that you have two data points which are very close together.
The normal way out is to included a nugget effect in your model, but it 
can also be appropriate to leave out one of a pair of points.

On Tue, 19 Jul 2005, orkun wrote:

> hello
>
> I try to build DEM  using Krig function of fields package.
> And I get this error message.
> here is the procedure I followed:
>
> > dt<-read.table("/usr/local/bartin/stat/topostat1",header=F,sep="|")
> > names(dt) <-c("x","y","z")
> > coord<-cbind(dt$x,dt$y)
> > elevation<-cbind(dt$z)
> > fit1<-Krig(coord,elevation,cov.function=exp.cov,scale.type="range")
> [1] "condition number is 907405545.878743"
> Error in Krig(kord, el, cov.function = exp.cov, scale.type = "range") :
>Covariance matrix is close
> to
> singular
>
> here is the structure  of my data:
>
> `data.frame':   3911 obs. of  3 variables:
> $ x: num  50139 50169 50214 50223 50227 ...
> $ y: num  4592999 4593322 4593054 4593151 4593246 ...
> $ z: int  320 320 320 320 320 320 320 320 320 320 ...
>
> what do you suggest to solve the problem ?
>
> kind regards
>
>
>
> __
> XamimeLT - installed on mailserver for domain @deprem.gov.tr
> Queries to: [EMAIL PROTECTED]
> __
> The views and opinions expressed in this e-mail message are ...{{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
>

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


[R] normalise a function

2005-07-20 Thread [EMAIL PROTECTED]
hi all,

I need to normalize a function, did something exist in R who can do it for me, 
instead of integrate the function then divide it by the result?

thks, i'm sorry i didn't found any information in the documentations and 
statistic vocabulary in english is a pain for me.


// Webmail Oreka : http://www.oreka.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


[R] Need R Help

2005-07-20 Thread bhumir jhaveri


Hi,

I am newbie in R. I have R installed on Solaris machine and I am connected
to Solaris machine from Windows using telnet. I want to create png image
file using R. But when I issue R command from telnet:-

> png("test.png")

Following error occurs:

Error in X11(paste("png::", filename, sep = ""), width, height, pointsize,
:
unable to start device PNG
In addition: Warning message:
unable to open connection to X11 display ''

  Also, when I checked DISPLAY environment variable, it shows
67.145.62.110:0.0

(67.145.62.110) is windows machine's ip address

Please suggest any solutions for the stated problem.

Thanks,

Bhumir

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

2005-07-20 Thread Adaikalavan Ramasamy
What does class(r1) give you ? If it is "data.frame", then try 
  exp( diff( log( as.matrix( df ) ) ) )

BTW, I made the assumption that both x and y are positive values only.

Regards, Adai



On Tue, 2005-07-19 at 16:30 +0100, Gilbert Wu wrote:
> Hi Adai,
> 
> When I tried the optimized routine, I got the following error message:
> 
> r1
>  899188 902232   901714 28176U 15322M
> 20050713  7.595  10.97 17.96999 5.1925  11.44
> 20050714  7.605  10.94 18.00999 5.2500  11.50
> 20050715  7.480  10.99 17.64999 5.2500  11.33
> 20050718  7.415  11.05 17.64000 5.2250  11.27
> > exp(diff(log(r1))) -1
> Error in r[i1] - r[-length(r):-(length(r) - lag + 1)] : 
> non-numeric argument to binary operator
> >
> 
> Any idea?
> 
> Many Thanks.
> 
> Gilbert
> -Original Message-
> From: Adaikalavan Ramasamy [mailto:[EMAIL PROTECTED]
> Sent: 19 July 2005 12:20
> To: Gilbert Wu
> Cc: r-help@stat.math.ethz.ch
> Subject: RE: [R] colnames
> 
> 
> First, your problem could be boiled down to the following example. See
> how the colnames of the two outputs vary.
> 
> df <- cbind.data.frame( "100"=1:2, "200"=3:4 )
> df/df
>   X100 X200
> 111
> 211
> 
> m  <- as.matrix( df )   # coerce to matrix class
> m/m
>   100 200
> 1   1   1
> 2   1   1
> 
> It appears that whenever R has to create a new dataframe automatically,
> it tries to get nice colnames. See help(data.frame). I am not exactly
> sure why this behaviour is different when creating a matrix. But I do
> not think this is a major problem for most people. If you coerce your
> input to matrix, the problem goes away.
> 
> 
> Next, note the following points :
>  a) "mat[ 1:3, 1:ncol(mat) ]" is equivalent to simply "mat[ 1:3,  ]". 
>  b) "mat[ 2:nrow(mat), ]" is equivalent to simply "mat[ -1,  ]"
> See help(subset) for more information.
> 
> Using the points above, we can simplify your function as 
> 
>  p.RIs2Returns <- function (mat){
> 
>mat <- as.matrix(mat)
>x <- mat[ -nrow(mat), ]
>y <- mat[ -1, ]
>   
>return( y/x -1 )
>  }
> 
> If your data contains only numerical data, it is probably good idea to
> work with matrices as matrix operations are faster.
> 
> 
> Finally, we can shorten your function. You can use the diff (which works
> column-wise if input is a matrix) and apply function if you know that 
> 
>   y/x  =  exp(log(y/x))  =  exp( log(y) - log(x) )
> 
> which could be coded in R as
> 
>   exp( diff( log(r1) ) )
> 
> and then subtract 1 from above to get your returns.
> 
> Regards, Adai
> 
> 
> 
> On Tue, 2005-07-19 at 09:17 +0100, Gilbert Wu wrote:
> > Hi Adai,
> > 
> > Many Thanks for the examples.
> > 
> > I work for a financial institution. We are exploring R as a tool to 
> > implement our portfolio optimization strategies. Hence, R is still a new 
> > language to us.
> > 
> > The script I wrote tried to make a returns matrix from the daily return 
> > indices extracted from a SQL database. Please find below the output that 
> > produces the 'X' prefix in the colnames. The reason to preserve the column 
> > names is that they are stock identifiers which are to be used by other sub 
> > systems rather than R.
> > 
> > I would welcome any suggestion to improve the script.
> > 
> > 
> > Regards,
> > 
> > Gilbert
> > 
> > > "p.RIs2Returns" <-
> > + function (RIm)
> > + {
> > + x<-RIm[1:(nrow(RIm)-1), 1:ncol(RIm)]
> > + y<-RIm[2:nrow(RIm), 1:ncol(RIm)]
> > + RReturns <- (y/x -1)
> > + RReturns
> > + }
> > > 
> > > 
> > > channel<-odbcConnect("ourSQLDB")
> > > result<-sqlQuery(channel,paste("select * from equityRIs;"))
> > > odbcClose(channel)
> > > result
> >stockidsdate  dbPrice
> > 1   899188 20050713  7.59500
> > 2   899188 20050714  7.60500
> > 3   899188 20050715  7.48000
> > 4   899188 20050718  7.41500
> > 5   902232 20050713 10.97000
> > 6   902232 20050714 10.94000
> > 7   902232 20050715 10.99000
> > 8   902232 20050718 11.05000
> > 9   901714 20050713 17.96999
> > 10  901714 20050714 18.00999
> > 11  901714 20050715 17.64999
> > 12  901714 20050718 17.64000
> > 13  28176U 20050713  5.19250
> > 14  28176U 20050714  5.25000
> > 15  28176U 20050715  5.25000
> > 16  28176U 20050718  5.22500
> > 17  15322M 20050713 11.44000
> > 18  15322M 20050714 11.5
> > 19  15322M 20050715 11.33000
> > 20  15322M 20050718 11.27000
> > > r1<-reshape(result, timevar="stockid", idvar="sdate", direction="wide")
> > > r1
> >  sdate dbPrice.899188 dbPrice.902232 dbPrice.901714 dbPrice.28176U 
> > dbPrice.15322M
> > 1 20050713  7.595  10.97   17.96999 5.1925  
> > 11.44
> > 2 20050714  7.605  10.94   18.00999 5.2500  
> > 11.50
> > 3 20050715  7.480  10.99   17.64999 5.2500  
> > 11.33
> > 4 20050718  7.415  11.05   17.64000 5.2250  
> > 11.27
> > > #Set sdate as the rownames
> > > rownames(r1) <-as.character(r1[1:nrow(r1),1:1])
> > > #Get rid of the first colum

Re: [R] Question about creating unique factor labels with the factor function

2005-07-20 Thread Petr Pikal
Hallo

I am not sure what you want to achieve.

your factor has 3 levels but with only 2 different labels

> hb
[1] 1 1 1 1 1 1 2 2 2
Levels: 1 1 2

but

> str(hb)
 Factor w/ 3 levels "1","1","2": 1 1 1 2 2 2 3 3 3

so you gave only one label to level 1 and 2. You can give the same 
label to any level you choose but I can not see a reason in it.

>  hb <- factor(c(1,1,1,2,2,2,3,3,3), 
levels=c(1,2,3),labels=c(1,1,1)) 
> hb
[1] 1 1 1 1 1 1 1 1 1
Levels: 1 1 1

or

>  hb <- factor(c(1,1,1,2,2,2,3,3,3), 
levels=c(1,2,3),labels=c(3,100,100)) 
> hb
[1] 3   3   3   100 100 100 100 100 100
Levels: 3 100 100
> str(hb)
 Factor w/ 3 levels "3","100","100": 1 1 1 2 2 2 3 3 3
-
but surprising for me is an ordered behaviour which I find a bit 
odd.

> hb
[1] 3   3   3   100 100 100 100 100 100
Levels: 3 100 100

> ordered(hb)
[1] 3   3   3   100 100 100 100 100 100
Levels: 3 < 100 < 100

> str(hb)
 Factor w/ 3 levels "3","100","100": 1 1 1 2 2 2 3 3 3

> str(ordered(hb))
 Ord.factor w/ 3 levels "3"<"100"<"100": 1 1 1 2 2 2 2 2 2

> unique((hb))
[1] 3   100 100 #three levels and three values
Levels: 3 100 100

> unique(ordered(hb))
[1] 3   100 # three levels but only 2 values?
Levels: 3 < 100 < 100
*
Can anybody explain why unique(ordered()) results in only 2 
displayed levels although this

> str(unique(ordered(hb)))
 Ord.factor w/ 3 levels "3"<"100"<"100": 1 2

says that the factor still have 3 levels?

Best regards
Petr




On 19 Jul 2005 at 15:11, Gregory Gentlemen wrote:

> Hi guys,
> 
> I ran into a problem of not being able to create unique labels when
> creating a factor. Consider an example below:
> 
>  hb <- factor(c(1,1,1,2,2,2,3,3,3), levels=c(1,2,3),labels=c(1,1,2)) >
> hb [1] 1 1 1 1 1 1 2 2 2 Levels: 1 1 2 
> unique(hb) [1] 1 1 2 Levels:
> 1 1 2
> 
> How come there are three unique levels, I thought this would only
> create one unique level?
> 
> > unique(as.ordered(hb))
> [1] 1 2
> Levels: 1 < 1 < 2
> 
> Is as.ordered the only solution?
> 
> Thanks in advance,
> Greg
> 
> 
> __
> 
> 
> 
>  [[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

Petr Pikal
[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] lapply question

2005-07-20 Thread Dave Evens
Dear members, 

I have numerous arrays that are organised in a list.
For example, suppose I have 2 arrays in a list called
alist 

alist <- list(array(rpois(12,5), 6:8) ,
array(rpois(15,5), 10:12)) 

with array dimnames 

dimnames(alist[[1]]) <- list(LETTERS[1:6],
paste("namesd", 1:7, sep=""), paste("namese", 1:8,
sep="")) 

dimnames(alist[[2]]) <- list(LETTERS[7:16],
paste("namesf", 1:11, sep=""), paste("namesg", 1:12,
sep="")) 

I would like to use the lapply function to produce a
report with:

Array 1 

Dimension name: namese1 

Row Value  Value-Average(excluding Value) 
Aalist[[1]][1,1,1]
alist[[1]][1,1,1]-mean(alist[[1]][1,-1,1]) 
...etc for all elements in the first row on the array 
Balist[[1]][2,1,1]
alist[[1]][2,1,1]-mean(alist[[1]][2,-1,1]) 
...etc 

Dimension name: namese2 
 


Dimension name: namese8 
... 



Array 2 

Dimension name: namesg1 



Dimension name: namesg12 

__ 

Can I use the apply to do this, something like 
lapply(alist, function(k), apply(k, c(1,3), ... 

but how do I layout the report using the array names,
dimension names etc and with each observation on a
separate line? Is it possible to give apply an array
and output a list?

Thanks for any help in advance. 

Dave

__
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] .gct file

2005-07-20 Thread Adaikalavan Ramasamy
Those wondering what gtc file stands for, might be interested in [1].

The original poster can see if the package 'ctc' [2] supports reading in
this format but I think Prof. Ripley's solution works too.

[1]http://www.broad.mit.edu/cancer/software/genepattern/tutorial/gp_tutorial_fileformats.html
[2]http://www.bioconductor.org/packages/bioc/stable/src/contrib/html/ctc.html
 


On Wed, 2005-07-20 at 09:52 +0100, Prof Brian Ripley wrote:
> On Tue, 19 Jul 2005, Marc Schwartz (via MN) wrote:
> 
> > For the TAB delimited columns, adjust the 'sep' argument to:
> >
> > read.table("data.gct", skip = 2, header = TRUE, sep = "\t")
> >
> > The 'quote' argument is by default:
> >
> > quote = "\"'"
> >
> > which should take care of the quoted strings and bring them in as a
> > single value.
> >
> > The above presumes that the header row is also TAB delimited. If not,
> > you may have to set 'skip = 3' to skip over the header row and manually
> > set the column names.
> 
> Not quite.  You can open a connection, skip 2 rows and read one to get the 
> column names, then read the rest of the file using read.table on the open 
> connection using the column names you just read.
> 
> However, based on what we have been shown
> 
> read.table("data.gct", skip = 2, header = TRUE)
> 
> ought to work as the file looks as if it is white-space delimited (a tab 
> is white space).
> 
> >
> > HTH,
> >
> > Marc Schwartz
> >
> >
> > On Tue, 2005-07-19 at 13:52 -0400, mark salsburg wrote:
> >> This is all extremely helpful.
> >>
> >> The data turns out is a little atypical, the columns are tab-delemited
> >> except for the description columns
> >>
> >>
> >> DATA1.gct looks like this
> >>
> >> #1.2
> >> 23 3423
> >> NAME DESCRIPTION VALUE
> >> gene1 "a protein inducer" 1123
> >> .  . ..
> >>
> >> How do I get R to read the data as tab delemited, but read in the 2nd
> >> coloumn as one value based on the quotation marks..
> >>
> >> thanks..
> >>
> >> On 7/19/05, Marc Schwartz (via MN) <[EMAIL PROTECTED]> wrote:
> >>> On Tue, 2005-07-19 at 13:16 -0400, mark salsburg wrote:
>  ok so the gct file looks like this:
> 
>  #1.2  (version number)
>  7283 19   (matrix size)
>  Name Description Values
>    ...  ..
> 
>  How can I tell R to disregard the first two lines and start reading
>  the 3rd line in this gct file. I would just delete them, but I do not
>  know how to open a gct. file
> 
>  thank you
> 
>  On 7/19/05, Duncan Murdoch <[EMAIL PROTECTED]> wrote:
> > On 7/19/2005 12:10 PM, mark salsburg wrote:
> >> I have two files to compare, one is a regular txt file that I can read
> >> in no prob.
> >>
> >> The other is a .gct file (How do I read in this one?)
> >>
> >> I tried a simple
> >>
> >> read.table("data.gct", header = T)
> >>
> >> How do you suggest reading in this file??
> >>
> >
> > .gct is not a standard filename extension.  You need to know what is in
> > that file.  Where did you get it?  What program created it?
> >
> > Chances are the easiest thing to do is to get the program that created
> > it to export in a well known format, e.g. .csv.
> >
> > Duncan Murdoch
> >>>
> >>>
> >>> The above would be consistent with the info in my reply.
> >>>
> >>> I guess if the format is consistent, as per Mark's example above, you
> >>> can use:
> >>>
> >>> read.table("data.gct", skip = 2, header = TRUE)
> >>>
> >>> which will start by skipping the first two lines and then reading in the
> >>> header row and then the data.
> >>>
> >>> See ?read.table
> >>>
> >>> 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
> >
>

__
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] Need R Help

2005-07-20 Thread Prof Brian Ripley
You are probably not running a X server on your Windows machine, or if you 
are, you are not forwarding X connections.  Even then, this is likely to 
be unsatisfactory unless you have a very good X server and a fast 
connection.

Please read the help page for png, and note the See Also section which 
suggests a good solution to your dilemma.

On Wed, 20 Jul 2005, bhumir jhaveri wrote:

> I am newbie in R.

Have you read the posting guide?

> I have R installed on Solaris machine and I am connected
> to Solaris machine from Windows using telnet. I want to create png image
> file using R. But when I issue R command from telnet:-
>
>> png("test.png")
>
> Following error occurs:
>
> Error in X11(paste("png::", filename, sep = ""), width, height, pointsize,
> :
>unable to start device PNG
> In addition: Warning message:
> unable to open connection to X11 display ''
>
>  Also, when I checked DISPLAY environment variable, it shows
> 67.145.62.110:0.0
>
> (67.145.62.110) is windows machine's ip address
>
> Please suggest any solutions for the stated problem.


-- 
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] Question about creating unique factor labels with the factor function

2005-07-20 Thread Peter Dalgaard
"Petr Pikal" <[EMAIL PROTECTED]> writes:

> Hallo
> 
> I am not sure what you want to achieve.
> 
> your factor has 3 levels but with only 2 different labels
> 
> > hb
> [1] 1 1 1 1 1 1 2 2 2
> Levels: 1 1 2
> 
> but
> 
> > str(hb)
>  Factor w/ 3 levels "1","1","2": 1 1 1 2 2 2 3 3 3
> 
> so you gave only one label to level 1 and 2. You can give the same 
> label to any level you choose but I can not see a reason in it.

Well, it does look a bit like a bug compared to the semantics of e.g.
levels<-  In particular:

> hb <- factor(c(1,1,1,2,2,2,3,3,3), levels=c(1,2,3),labels=c(1,1,2))
> hb
[1] 1 1 1 1 1 1 2 2 2
Levels: 1 1 2
> levels(hb) <- levels(hb)
> hb
[1] 1 1 1 1 1 1 2 2 2
Levels: 1 2

Conceptually, one might want to replace 

attr(f, "levels") <-

with 

levels(f) <- 

inside factor(). However, f does not have class "factor" at that point
and if it did, we'd have a recursive call to factor() and the thing
would blow up... 


-- 
   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] sciviews installation

2005-07-20 Thread Philippe Grosjean
Hello,

Several changes in the latest Rcmdr broken the SciViews compatibility. I 
am working on it... but it takes longer than expected. Sorry for the 
inconvenience.
Best,

Philippe

..<°}))><
  ) ) ) ) )
( ( ( ( (Prof. Philippe Grosjean
  ) ) ) ) )
( ( ( ( (Numerical Ecology of Aquatic Systems
  ) ) ) ) )   Mons-Hainaut University, Pentagone (3D08)
( ( ( ( (Academie Universitaire Wallonie-Bruxelles
  ) ) ) ) )   8, av du Champ de Mars, 7000 Mons, Belgium
( ( ( ( (
  ) ) ) ) )   phone: + 32.65.37.34.97, fax: + 32.65.37.30.54
( ( ( ( (email: [EMAIL PROTECTED]
  ) ) ) ) )
( ( ( ( (web:   http://www.umh.ac.be/~econum
  ) ) ) ) )  http://www.sciviews.org
( ( ( ( (
..

ghjmora g mail wrote:
> Hello
> 
> 
> 1. a few months ago, I had sciviews working fine with R (rw2001) under 
> windows XP
> 2. now, upgrading to rw2011, the stuff seems fine (every package 
> installed),but I find a conflict when launching sciviews:
> - it runs, apparently
> - but when I try to work ("import/export In: text" for instance), it 
> asks for Rcmdr ("Would you like to install it now?")
> 
> 3. Rcmdr is already installed (with all dependencies) and works well 
> when called directly in R gui
> 4. and it's impossible to make it reconized or to install it under sciviews
> 
> 
> I have all the latest packages, and I am going to get mad.
> 
> what do you suggest to solve my problem ?
> 
> Thanks
> 
> Georges Moracchini
> 
> __
> 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] Taking the derivative of a quadratic B-spline

2005-07-20 Thread Duncan Murdoch
James McDermott wrote:
> Would the unique quadratic defined by the three points be the same
> curve as the curve predicted by a quadratic B-spline (fit to all of
> the data) through those same three points?

Yes, if you restrict attention to an interval between knots.  You'll 
need to re-evaluate it for each such interval (but since quadratic 
splines are continuous, you can reuse evaluations at the knots, and you 
just need one new point in each interval).

 From a practical point of view, you need to make sure that COBS really 
is giving you a quadratic spline and really is reporting all of the 
knots correctly.  Watch out for coincident knots (zero length 
intervals); you don't care about the derivative on those, but they might 
cause overflows in some calculations.

Duncan Murdoch
> 
> Jim
> 
> On 7/19/05, Duncan Murdoch <[EMAIL PROTECTED]> wrote:
> 
>>On 7/19/2005 3:34 PM, James McDermott wrote:
>>
>>>I wish it were that simple (perhaps it is and I am just not seeing
>>>it).  The output from cobs( ) includes the B-spline coefficients and
>>>the knots.  These coefficients are not the same as the a, b, and c
>>>coefficients in a quadratic polynomial.  Rather, they are the
>>>coefficients of the quadratic B-spline representation of the fitted
>>>curve.  I need to evaluate a linear combination of basis functions and
>>>it is not clear to me how to accomplish this easily.  I was hoping to
>>>find an alternative way of getting the derivatives.
>>
>>I don't know COBS, but doesn't predict just evaluate the B-spline?  The
>>point of what I posted is that the particular basis doesn't matter if
>>you can evaluate the quadratic at 3 points.
>>
>>Duncan Murdoch
>>
>>
>>>Jim McDermott
>>>
>>>On 7/19/05, Duncan Murdoch <[EMAIL PROTECTED]> wrote:
>>>
On 7/19/2005 2:53 PM, James McDermott wrote:

>Hello,
>
>I have been trying to take the derivative of a quadratic B-spline
>obtained by using the COBS library.  What I would like to do is
>similar to what one can do by using
>
>fit<-smooth.spline(cdf)
>xx<-seq(-10,10,.1)
>predict(fit, xx, deriv = 1)
>
>The goal is to fit the spline to data that is approximating a
>cumulative distribution function (e.g. in my example, cdf is a
>2-column matrix with x values in column 1 and the estimate of the cdf
>evaluated at x in column 2) and then take the first derivative over a
>range of values to get density estimates.
>
>The reason I don't want to use smooth.spline is that there is no way
>to impose constraints (e.g. >=0, <=1, and monotonicity) as there is
>with COBS.  However, since COBS doesn't have the 'deriv =' option, the
>only way I can think of doing it with COBS is to evaluate the
>derivatives numerically.

Numerical estimates of the derivatives of a quadratic should be easy to
obtain accurately.  For example, if the quadratic ax^2 + bx + c is
defined on [-1, 1], then the derivative 2ax + b, has 2a = f(1) - f(0) +
f(-1), and b = (f(1) - f(-1))/2.

You should be able to generalize this to the case where the spline is
quadratic between knots k1 and k2 pretty easily.

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] Need R Help

2005-07-20 Thread Adaikalavan Ramasamy
Your alternatives are :
a) Use pdf if you can.
b) See help(bitmap) and especially the details section which tells you
about setting the R_GSCMD path to ghostscript
c) Try Xvfb. I do not know much about this. Try a google search.

Regards, Adai


On Wed, 2005-07-20 at 15:12 +0530, bhumir jhaveri wrote:
> 
> Hi,
> 
> I am newbie in R. I have R installed on Solaris machine and I am connected
> to Solaris machine from Windows using telnet. I want to create png image
> file using R. But when I issue R command from telnet:-
> 
> > png("test.png")
> 
> Following error occurs:
> 
> Error in X11(paste("png::", filename, sep = ""), width, height, pointsize,
> :
> unable to start device PNG
> In addition: Warning message:
> unable to open connection to X11 display ''
> 
>   Also, when I checked DISPLAY environment variable, it shows
> 67.145.62.110:0.0
> 
> (67.145.62.110) is windows machine's ip address
> 
> Please suggest any solutions for the stated problem.
> 
> Thanks,
> 
> Bhumir
> 
> __
> 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] Need R Help

2005-07-20 Thread Andrew Robinson
Hi Bhumir

Do you happen to have an X client installed on your Windows machine?

e.g. cygwin, winaXe, eXceed, ... 

I've used winaXe with some success.

Andrew


On Wed, Jul 20, 2005 at 03:12:24PM +0530, bhumir jhaveri wrote:
> 
> 
> Hi,
> 
> I am newbie in R. I have R installed on Solaris machine and I am connected
> to Solaris machine from Windows using telnet. I want to create png image
> file using R. But when I issue R command from telnet:-
> 
> > png("test.png")
> 
> Following error occurs:
> 
> Error in X11(paste("png::", filename, sep = ""), width, height, pointsize,
> :
> unable to start device PNG
> In addition: Warning message:
> unable to open connection to X11 display ''
> 
>   Also, when I checked DISPLAY environment variable, it shows
> 67.145.62.110:0.0
> 
> (67.145.62.110) is windows machine's ip address
> 
> Please suggest any solutions for the stated problem.
> 
> Thanks,
> 
> Bhumir
> 
> __
> 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

-- 
Andrew Robinson
Senior Lecturer in Statistics   Tel: +61-3-8344-9763
Department of Mathematics and StatisticsFax: +61-3-8344-4599
University of Melbourne, VIC 3010 Australia
Email: [EMAIL PROTECTED]Website: http://www.ms.unimelb.edu.au

__
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] Problems with date-format (R 2.1.1 + chron)

2005-07-20 Thread Gabor Grothendieck
Here are some different approaches to this problem:

#1 just convert it to chron without using Date class.
days(chron("21-07-2005", format = "d-m-y"))

#2 after converting it to Date, convert it to numeric and then
# to chron to avoid the problem
dd <- as.Date("21-07-2005", "%d-%m-%y")
days(chron(unclass(dd)))

#3 do not use chron in the first place, just Date
dd <- as.Date("21-07-2005", "%d-%m-%y")
ordered(format(dd, "%d"), lev = 1:31)

Note that days in the chron package gives the answer as an ordered 
factor, which is what is assumed is desired in these examples as
well as pointers to further information in the references.

R News 4/1 Help Desk has some examples of date manipulations
in Date, chron and POSIXct in the table at the end of the article.

On 7/19/05, Gabor Grothendieck <[EMAIL PROTECTED]> wrote:
> On 7/19/05, Gabor Grothendieck <[EMAIL PROTECTED]> wrote:
> > I think its likely that you are using different versions of chron.
> > I noticed that version "2.2-33" of chron had the statement:
> >
> >   tms <- dts - trunc(dts)
> >
> > but version "2.2-35" seems to have replaced it with:
> >
> >  tms <- dts - floor(dts)
> >
> > and that seems to be causing the problem.
> >
> > As a workaround:
> >
> >floor.Date <- floor.trunc
> 
> That should have been:
> 
>  floor.Date <- trunc.Date
> 
> >days(as.Date("21-07-2005", "%d-%m-%y"))
> >
> >
> > On 7/19/05, Carsten Steinhoff <[EMAIL PROTECTED]> wrote:
> > > Hello,
> > >
> > > today I've updated on the newest R-Version. But sadly a function I needed
> > > didnt want to work:
> > > The input is e.g.
> > >
> > > days(as.Date("21-07-2005","%d-%m-%y"))
> > >
> > > the error is: Fehler in Math.Date(dts): floor nicht definiert für Date
> > > Objekte
> > > (Error in Math.Date(dts): floor not defined for date objects)
> > >
> > > Same for year. Only months gives me the correct output.
> > > In Version 2.01 it worked very well, with the same chron library.
> > > Whats wrong ?
> > >
> > > Carsten
> > >
> > > __
> > > 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] Michaelis-menten equation

2005-07-20 Thread joerg van den hoff
I believe the following is correct:
1.
first of all, as peter daalgaard already pointed out, your data Cp(t)
are following a straight line
very closely, i.e. 0.-order kinetics
2.
for your diff. eq. this means that you are permanently in the range cp
>> Km so that
dCp/dt = - Vm/Vd = const. =: -b and, therefore, Cp = a - b*t
3.
you can't get any reliable information concerning Km from the fit. the
solution of the diff. eq (according to Maxima),
namely t + const. = -(Km*log(Cp) + Cp)/(Vm/Vd) tells you the same:
Km*log(cp) << Cp in your data.
4.
in any case (even in the range Km ~= Cp) you can't determine Vm _and_ Vd
separately according to your diff. eq., you only get the ratio b =
Vm/Vd. this does make sense:
what you are measuring  is the decreasing plasma concentration, you
don't have any information
concerning the "relevant" volume fraction, i.e. the Vd, in you data.
therefore any variation in the effective
max. velocity can either be ascribed to a variation of Vm or to a
modified Vd. in other words:
you should view Vm* = Vm/Vd as your  "effective" Vm.
5.
x<-PKindex[,1]
y<-PKindex[,2]
res <- lm ( y~x ) yields a=8.561, b=Vm*= 0.279
summary(abs(residuals(r)/y)*100)
   Min. 1st Qu.  MedianMean 3rd Qu.Max.
0.00863 0.09340 0.13700 0.26500 0.22900 1.37000

i.e. 0.265 percent deviation on average between data and fit. I believe
that is the max. information you can get from your data
((the result for "b" is  accidently is not so far away
from the ratio of your results Vm = 10.04, Vd = 34.99 which actually
must be completely unstable
(double both parameters and nothing happens to the fit).
6.
you state you simulated the data with km=4.69? using the above Vm and
Vd, the resulting data are (not unexpectedly)
quite different from those you used as input to the fit. maybe you made
an error somewhere "upstream"?
7.
in conclusion: don't try to fit Vm _and_ Vd separately, check whether
your simulated data are correct, keep in mind that if km< Hi,
> 
>We are doing a pharmaockinetic modeling.  This model is
> described as intravenous injection of a certain drug into
> the body.  Then the drug molecule will be eliminated (or decayed)
> from the body.  We here used a MM eq. to describe the elimination
> process and the changes of the drug conc..  So the diff. eq. would
> be: dCp/dt = -Vm/Vd * Cp/(Km+Cp).  Vd is a volume of distribution.
> We used lsoda to solve the diff. eq. first and fit the diff. eq.
> with optim first (Nelder-Mead simplex) and followed by using nls 
> to take over the fitting process of optim.  However, we can not
> obtain the correct value for Km if we used the above model.  The
> correct Km can be obtained only when we modeled the diff eq. with
> dCp/dt= -Vm/Vd * Cp/(Km/vd + Cp).  Now we lost.  The data were
> from simulation with known Vm and Km.  Any idea?  Thanks.
> 
> regards,
> --- Chun-ying Lee
> 
>>it is not clear to me what you are trying to do:
>>you seem to have a time-concentration-curve in PKindex and you seem 
>>to set up a derivative of this time dependency according to some 
>>model in dCpdt. AFAIKS this scenario is  not directly related to the 
>>situation described by the Michaelis-Menten-Equation which relates 
>>some "input" concentration with some "product" concentration. If Vm and
>>Km are meant to be the canonical symbols,
>>what is Vd, a volume of distribution? it is impossible to see (at least
>>for me) what exactly you want to achieve.
>>
>>(and in any case, I would prefer "nls" for a least squares fit 
>>instead of 'optim').
>>
>>joerg
>>
>>>
>>>
>>>__
>>>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] initial points for arms in package HI

2005-07-20 Thread Christoph Buser
Dear Martyn

Thank you for your fast and helpful answer. It showed me to
my wrong thinking.

I confused the previous value of the Markov Chain with the
initial values to construct the envelope.

In the original C code by W. Gilks there are the arguments
"xinit" and "xprev". The first is used to construct the
envelope, the second is the previous value of the Markov chain.
There are comments from the author how to set the initial values
"xinit". It is important to choose these values independent from
the current parameter, being updated (in the case of not
log-concave functions).

In the R code and the C code behind the function arms the
argument "xinit" is missing, since it is set in the function
itself and the user can not change it.

Since I confused the two arguments I didn't realize that
"y.start" is the value "xprev", the state of the Markov chain
and set this value 1 or runif(...). But for an implementation of
a Gibbs Sampler this makes no sense.

My example was a little bit misleading, since I simulated 1000
points from the same distribution. In reality my distribution
is changing at each step and I always need only 1 new value in
my Gibbs Sampler. 
But by implementing it correctly with the previous value of the
chain it should work in my context.

Best regards,

Christoph


[EMAIL PROTECTED] writes:
 > Quoting Christoph Buser <[EMAIL PROTECTED]>:
 > 
 > > Dear R-users
 > >
 > > I have a problem choosing initial points for the function arms()
 > > in the package HI
 > > I intend to implement a Gibbs sampler and one of my conditional
 > > distributions is nonstandard and not logconcave.
 > > Therefore I'd like to use arms.
 > >
 > > But there seem to be a strong influence of the initial point
 > > y.start. To show the effect I constructed a demonstration
 > > example. It is reproducible without further information.
 > >
 > > Please note that my target density is not logconcave.
 > >
 > > Thanks for all comments or ideas.
 > >
 > > Christoph Buser
 > 
 > Dear Christoph,
 > 
 > There is a Metropolis step at each iteration of the ARMS sampler, in
 > which it may choose to reject the proposed move to a new point and stick
 > at the current point (This is what the "M" in "ARMS" stands for)  If you
 > do repeated calls to arms with the same starting point, then the
 > iterations where the Metropolis step rejects a move will create a spike
 > in the sample density at your initial value. If you use a uniform random
 > starting point, then your sample density will be a mixture of the
 > target distribution (Metropolis accepts move) and a uniform distribution
 > (Metropolis rejects move).
 > 
 > You should be doing something like this:
 > 
 > res1 <- arms(runif(1,0,100), logDichteGam, function(x) (x>0)&(x<100), 1)
 > for(i in 2:1000)
 >   res1[i] <- arms(res1[i-1], logDichteGam, function(x) (x>0)&(x<100), 1)
 > 
 > i.e., using each sampled point as the starting value for the next
 > iteration.  The sequence of values in res1 will then be a correlated
 > sample from the given distribution:
 > 
 > acf(res1)
 > 
 > The bottom line is that you can't use ARMS to draw a single sample
 > from a non-log-concave density.
 > 
 > If you are still worried about using ARMS, you can verify your results
 > using the random walk Metropolis sampler (MCMCmetrop1R) in the package
 > MCMCpack.
 > 
 > Martyn
 > 
 > > ## R Code:
 > >
 > > library(HI)
 > > ## parameter for the distribution
 > > para <- 0.1
 > >
 > > ## logdensity
 > > logDichteGam <- function(x, u = para, v = para) {
 > >   -(u*x + v*1/x) - log(x)
 > > }
 > > ## density except for the constant
 > > propDichteGam <- function(x, u = para, v = para) {
 > >   exp(-(u*x + v*1/x) - log(x))
 > > }
 > > ## calculating the constant
 > > (c <- integrate(propDichteGam, 0, 1000, rel.tol = 10^(-12))$value)
 > > ## density
 > > DichteGam <- function(x, u = para, v = para) {
 > >   exp(-(u*x + v*1/x) - log(x))/c
 > > }
 > >
 > > ## calculating 1000 values by repeating a call of arms (this would
 > > ## be the situation in an Gibbs Sample. Of course in a Gibbs sampler
 > > ## the distribution would change. This is only for demonstration
 > > res1 <- NULL
 > > for(i in 1:1000)
 > >   res1[i] <- arms(runif(1,0,100), logDichteGam, function(x) (x>0)&(x<100), 
 > > 1)
 > >
 > > ## Generating a sample of thousand observations with 1 call of arms
 > > res2 <- arms(runif(1,0,100), logDichteGam, function(x) (x>0)&(x<100), 1000)
 > >
 > > ## Plot of the samples
 > > mult.fig(4)
 > > plot(res1, log = "y")
 > > plot(res2, log = "y")
 > > hist(res1, freq = FALSE, xlim = c(0,4), breaks = seq(0,100,by = 0.1),
 > >  ylim = c(0,1))
 > > curve(DichteGam, 0,4, add = TRUE, col = 2)
 > > hist(res2, freq = FALSE, xlim = c(0,4), breaks = seq(0,100,by = 0.1),
 > >  ylim = c(0,1))
 > > curve(DichteGam, 0,4, add = TRUE, col = 2)
 > >
 > >
 > > ## If we repeat the procedure, using the fix intial value 1,
 > > ## the situation is even worse
 > > res3 <- NULL
 > > for(i in 1:1000)
 > >   res3[i] <- arms

[R] R function to kill a process

2005-07-20 Thread Gabor Grothendieck
Is there an R function to kill a process?  I found one in package
fork but it is specific to UNIX and I want something that also
works on Windows.   The XP console command, taskkill,
will do it so I can easily get the effect but it won't work
on other Windows systems, even 2000 and NT.  I found a free utility
pskill.exe by googling around that does work across 2000/NT/XP
but was still wondering about something more general in 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] Chemoinformatic people

2005-07-20 Thread Frédéric Ooms
Dear colleague,
Just an e-mail to know if they are people working in the field of 
chemoinformatic that are using R in their work. If yes I was wondering if we 
couldn't exchange tips and tricks about the use of R in this area ?
Best regards
Fred Ooms

[[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] Code Verification

2005-07-20 Thread Christoph Buser
Hi

"t.test" assumes that your data within each group has a normal
distribution. This is not the case in your example.
I would recommend you a non parametric test like "wilcox.test" if
you want to compare the mean of two samples that are not normal
distributed. 
see ?wilcox.test

Be careful. Your example produces two gamma distributed samples
with rate = 10, not scale = 10. 
rate = 1/scale.
If you want to use scale, you need to specify this argument 
x<-rgamma(40, 2.5, scale = 10)
see ?rgamma

I do not see the interpretation of your result. Since you do
know the distribution and the parameters of your sample, you
know the true means and that they are different. It is only a
question of the sample size and the power of your test, if this
difference is detected.
Is that something you are investigating? Maybe a power
calculation or something similar.

Regards,

Christoph Buser

--
Christoph Buser <[EMAIL PROTECTED]>
Seminar fuer Statistik, LEO C13
ETH (Federal Inst. Technology)  8092 Zurich  SWITZERLAND
phone: x-41-44-632-4673 fax: 632-1228
http://stat.ethz.ch/~buser/
--

[EMAIL PROTECTED] writes:
 > Hi R Users
 > I have a code which I am running for my thesis work. Just want to make sure 
 > that
 > its ok. Its a t test I am conducting between two gamma distributions with
 > different shape parameters.
 > 
 > the code looks like:
 > 
 > sink("a1.txt");
 > 
 > for (i in 1:1000)
 > {
 > x<-rgamma(40, 2.5, 10)  # n = 40, shape = 2.5, Scale = 10
 > y<-rgamma(40, 2.8, 10)  # n = 40, shape = 2.8, Scale = 10
 > z<-t.test(x, y)
 > print(z)
 > }
 > 
 > 
 > I will appreciate it if someone could tell me if its alrite or not.
 > 
 > thanks
 > 
 > -dev
 > 
 > __
 > 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] sciviews installation

2005-07-20 Thread John Fox
Dear Philippe,

The development version 1.1-0 of the Rcmdr package (i.e., the one with
localization facilities) isn't yet on CRAN. Georges doesn't say which
version of the Rcmdr package he's using, but I assume 1.0-2 from CRAN, which
I believe should work with SciViews.

Regards,
 John


John Fox
Department of Sociology
McMaster University
Hamilton, Ontario
Canada L8S 4M4
905-525-9140x23604
http://socserv.mcmaster.ca/jfox 
 

> -Original Message-
> From: [EMAIL PROTECTED] 
> [mailto:[EMAIL PROTECTED] On Behalf Of 
> Philippe Grosjean
> Sent: Wednesday, July 20, 2005 5:24 AM
> To: [EMAIL PROTECTED]
> Cc: r-help@stat.math.ethz.ch
> Subject: Re: [R] sciviews installation
> 
> Hello,
> 
> Several changes in the latest Rcmdr broken the SciViews 
> compatibility. I am working on it... but it takes longer than 
> expected. Sorry for the inconvenience.
> Best,
> 
> Philippe
> 
> ..<°}))><
>   ) ) ) ) )
> ( ( ( ( (Prof. Philippe Grosjean
>   ) ) ) ) )
> ( ( ( ( (Numerical Ecology of Aquatic Systems
>   ) ) ) ) )   Mons-Hainaut University, Pentagone (3D08)
> ( ( ( ( (Academie Universitaire Wallonie-Bruxelles
>   ) ) ) ) )   8, av du Champ de Mars, 7000 Mons, Belgium
> ( ( ( ( (
>   ) ) ) ) )   phone: + 32.65.37.34.97, fax: + 32.65.37.30.54
> ( ( ( ( (email: [EMAIL PROTECTED]
>   ) ) ) ) )
> ( ( ( ( (web:   http://www.umh.ac.be/~econum
>   ) ) ) ) )  http://www.sciviews.org
> ( ( ( ( (
> ..
> 
> ghjmora g mail wrote:
> > Hello
> > 
> > 
> > 1. a few months ago, I had sciviews working fine with R 
> (rw2001) under 
> > windows XP 2. now, upgrading to rw2011, the stuff seems fine (every 
> > package installed),but I find a conflict when launching sciviews:
> > - it runs, apparently
> > - but when I try to work ("import/export In: text" for 
> instance), it 
> > asks for Rcmdr ("Would you like to install it now?")
> > 
> > 3. Rcmdr is already installed (with all dependencies) and 
> works well 
> > when called directly in R gui 4. and it's impossible to make it 
> > reconized or to install it under sciviews
> > 
> > 
> > I have all the latest packages, and I am going to get mad.
> > 
> > what do you suggest to solve my problem ?
> > 
> > Thanks
> > 
> > Georges Moracchini
> > 
> > __
> > 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] Chemoinformatic people

2005-07-20 Thread S.O. Nyangoma
Do you mean people working in areas of mass spectrometry (eg. SELDI, 
LC-MS, MALDI etc) data analysis?

- Original Message -
From: Frédéric Ooms <[EMAIL PROTECTED]>
Date: Wednesday, July 20, 2005 1:44 pm
Subject: [R] Chemoinformatic people

> Dear colleague,
> Just an e-mail to know if they are people working in the field of 
> chemoinformatic that are using R in their work. If yes I was 
> wondering if we couldn't exchange tips and tricks about the use of 
> R in this area ?
> Best regards
> Fred Ooms
> 
>   [[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] Chemoinformatic people

2005-07-20 Thread Frédéric Ooms
I am more lloking at people working in the field of drug discovery performing 
clustering analysis, MDS, LDA in order to classify chemicals based on  computed 
properties.
Fred

-Original Message-
From: S.O. Nyangoma [mailto:[EMAIL PROTECTED] 
Sent: Wednesday, July 20, 2005 1:53 PM
To: Frédéric Ooms
Cc: r-help@stat.math.ethz.ch
Subject: Re: [R] Chemoinformatic people


Do you mean people working in areas of mass spectrometry (eg. SELDI, 
LC-MS, MALDI etc) data analysis?

- Original Message -
From: Frédéric Ooms <[EMAIL PROTECTED]>
Date: Wednesday, July 20, 2005 1:44 pm
Subject: [R] Chemoinformatic people

> Dear colleague,
> Just an e-mail to know if they are people working in the field of
> chemoinformatic that are using R in their work. If yes I was 
> wondering if we couldn't exchange tips and tricks about the use of 
> R in this area ?
> Best regards
> Fred Ooms
> 
>   [[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] R function to kill a process

2005-07-20 Thread Duncan Murdoch
On 7/20/2005 7:25 AM, Gabor Grothendieck wrote:
> Is there an R function to kill a process?  I found one in package
> fork but it is specific to UNIX and I want something that also
> works on Windows.   The XP console command, taskkill,
> will do it so I can easily get the effect but it won't work
> on other Windows systems, even 2000 and NT.  I found a free utility
> pskill.exe by googling around that does work across 2000/NT/XP
> but was still wondering about something more general in R.

There's no such thing in base R, as far as I know.  Killing a process is 
complicated, and I think the procedure is quite different in Unix and 
Windows.  You want to give the process a chance at a clean shutdown if 
possible.

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


[R] Randomization test for interaction effect

2005-07-20 Thread Pedro de Barros
Dear All,

I am trying to build a randomization test for interaction

The problem is as follows: I have a set of stations where the ocurrence and 
biomass of each species being investigated was recorded.

For each group of stations, the relative importance of a set of species was 
calculated, as the Index of Relative Importance (IRI), given as

IRI(i)=(FO(i)*RW(i))/sum(FO(j)*RW(j))

FO(i) is the relative frequency of ocurrence of species i and RW(i) is the 
relative Biomass of species i (Total biomass of this species/Total biomass 
of all species). Stations are grouped according to 3 different criteria, 
say A, B and C, with 3 levels of A, 5 of B, and 3 of C.

The null hypothesis of interest is that the distribution of the IRI among 
the species is independent of these classification levels. I suggest using 
the average difference in IRI(i) of each grouping to the overall IRI(i) as 
the test statistic.

I have no difficulty building the randomization test for the main effects: 
Simply randomize the corresponding group membership factor. However, I am 
having difficulty building the test for the interaction effect: As far as I 
understand, the test should randomize the levels of say B, within the 
levels of A, so that the main effects should not be affected (all 
observations classified as level A1 would still be A1, and all observations 
classified as level B1 should stay as B1). My difficulty is how to 
calculate the "overall" distribution of the IRI in this case. This should 
consider all main effects, but no interaction.

I would really appreciate any pointer to a solution of this problem. I 
believe it is not complicated (and probably quite obvious) but the solution 
keeps out of reach, even though I have been searching for over a week.

Thanks,
Pedro

Pedro de Barros
Faculdade de Ciências do Mar e do Ambiente
Universidade do Algarve ,Campus de Gambelas
8000-117 FARO, Portugal
Tel: + 351 289 800 034
Fax: +351 289 818 353
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] Chemoinformatic people

2005-07-20 Thread Liaw, Andy
You might want to check out Rajarshi Guha's work on connecting CDK to R.  He
has an article in the recent issue of CDK News.

Andy

> From: Frédéric Ooms
> 
> I am more lloking at people working in the field of drug 
> discovery performing clustering analysis, MDS, LDA in order 
> to classify chemicals based on  computed properties.
> Fred
> 
> -Original Message-
> From: S.O. Nyangoma [mailto:[EMAIL PROTECTED] 
> Sent: Wednesday, July 20, 2005 1:53 PM
> To: Frédéric Ooms
> Cc: r-help@stat.math.ethz.ch
> Subject: Re: [R] Chemoinformatic people
> 
> 
> Do you mean people working in areas of mass spectrometry (eg. SELDI, 
> LC-MS, MALDI etc) data analysis?
> 
> - Original Message -
> From: Frédéric Ooms <[EMAIL PROTECTED]>
> Date: Wednesday, July 20, 2005 1:44 pm
> Subject: [R] Chemoinformatic people
> 
> > Dear colleague,
> > Just an e-mail to know if they are people working in the field of
> > chemoinformatic that are using R in their work. If yes I was 
> > wondering if we couldn't exchange tips and tricks about the use of 
> > R in this area ?
> > Best regards
> > Fred Ooms
> > 
> > [[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@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] analysing non-normal spatially autocorrelated data

2005-07-20 Thread Ruben Roa
> -Original Message-
> From: [EMAIL PROTECTED]
> [mailto:[EMAIL PROTECTED] Behalf Of Carsten Dormann
> Sent: 20 July 2005 05:41
> To: r-help@stat.math.ethz.ch
> Subject: [R] analysing non-normal spatially autocorrelated data
> 
> 
> Dear fellow R-users,
> 
> I wish to analyse a lattice of presence-absence data which 
> are spatially autocorrelated.
> 
> For normally distributed errors I used gls {nlme} with the 
> "appropriate" corStruct-method.
> Is there any method for other families (binomial and poisson)?
> 
> A method that look suitable to me as a non-statistician is 
> called gllamm  (generalised linear latent mixed model), by Rabe-Hesketh et 
> al (2001), available apparently only for Stata.
> In R, I found the gamm {Matrix} function doing what I want, but I am 
> interested in the parameter values of the covariates, using the model 
> for prediction, hence gamm is no option.
> Finally, Dan Bebber posted a similar question to the R-help list in 
> September 2004 (about using corStruct in glmmPQL), but there 
> is no reply in the thread 
> (http://tolstoy.newcastle.edu.au/R/help/04/09/3103.html).
> 
> Any suggestions are highly welcome.
> 
> Many thanks,
> 
> Carsten

Check the package geoRglm, which fits by maximum likelihood a generalized 
linear mixed spatial model in the binomial or Poisson families, allowing for
covariates. geoRglm will also need the package geoR which fits the 
spatial model for continuous processes.
The authors of the packages have published several papers on theory
and applications.
Ruben

__
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] writing matrices (no subject)

2005-07-20 Thread David Ruau
Thanks for your answers,
I need to print this data frame into a .csv file to import it in WEKA.
Do you have better solution?
I quite a new user of WEKA I don't know if you can give it a binary 
file. I think you can but it will be complicated...

David

On Jul 20, 2005, at 15:07, jim holtman wrote:

> You might have better luck if you have a loop that is processing one
> row at a time.  That means you will have to determine what the
> formatting should be.  With write.table it is trying to process the
> entire array at once to determine the best formatting and it taking a
> lot of memory (my guess at least 500MB).
>
> What are you going to do with a text file that large?  Can you write
> it out in binary if you are reading it in with another program?  If
> you are going to reread it with R, then 'save' would be a better
> choice.
>
> On 7/20/05, David Ruau <[EMAIL PROTECTED]> wrote:
>> Hi All,
>>
>> I want to print a square matrix of 7000 x 7000 into a text file. But I
>> got a error after few hours of computation...
>> 
>>> write.table(MyDistMxDF, file = "temp.csv", sep=",", quote=F)
>> *** malloc: vm_allocate(size=8421376) failed (error code=3)
>> *** malloc[2889]: error: Can't allocate region
>> Error: vector memory exhausted (limit reached?)
>> *** malloc: vm_allocate(size=8421376) failed (error code=3)
>> *** malloc[2889]: error: Can't allocate region
>>>  q()
>> *** malloc: vm_allocate(size=8421376) failed (error code=3)
>> *** malloc[2889]: error: Can't allocate region
>> *** malloc: vm_allocate(size=8421376) failed (error code=3)
>> *** malloc[2889]: error: Can't allocate region
>> Error in lazyLoadDBfetch(key, datafile, compressed, envhook) :
>> internal error in decompress1
>>>
>> --
>> I am running R 2.0.1 on MacOS X 10.3 with 1Gb ram.
>> How could I write such a matrix to a text file.
>>
>> David
>>
>> __
>> 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
>>
>
>
> -- 
> Jim Holtman
>
> What the problem you are trying to solve?
>
>

__
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] writing matrices (no subject)

2005-07-20 Thread Liaw, Andy
Simply gooling for "writing ARFF file in R" gave the following as first hit,
which is right on the WEKA page:

Miscellaneous code
[...]
Function for reading ARFF files into the R statistical package (kindly
provided by Dr Craig Struble). 
Function for writing ARFF files from the R statistical package (kindly
provided by Nigel Sim). 
http://www.cs.waikato.ac.nz/~ml/weka/example_code/writearff.R

I have not tried it myself.

Andy

PS: AFAIK, ARFF is not a binary format, but simply csv with header
information.

> From: David Ruau
> 
> Thanks for your answers,
> I need to print this data frame into a .csv file to import it in WEKA.
> Do you have better solution?
> I quite a new user of WEKA I don't know if you can give it a binary 
> file. I think you can but it will be complicated...
> 
> David
> 
> On Jul 20, 2005, at 15:07, jim holtman wrote:
> 
> > You might have better luck if you have a loop that is processing one
> > row at a time.  That means you will have to determine what the
> > formatting should be.  With write.table it is trying to process the
> > entire array at once to determine the best formatting and 
> it taking a
> > lot of memory (my guess at least 500MB).
> >
> > What are you going to do with a text file that large?  Can you write
> > it out in binary if you are reading it in with another program?  If
> > you are going to reread it with R, then 'save' would be a better
> > choice.
> >
> > On 7/20/05, David Ruau <[EMAIL PROTECTED]> wrote:
> >> Hi All,
> >>
> >> I want to print a square matrix of 7000 x 7000 into a text 
> file. But I
> >> got a error after few hours of computation...
> >> 
> >>> write.table(MyDistMxDF, file = "temp.csv", sep=",", quote=F)
> >> *** malloc: vm_allocate(size=8421376) failed (error code=3)
> >> *** malloc[2889]: error: Can't allocate region
> >> Error: vector memory exhausted (limit reached?)
> >> *** malloc: vm_allocate(size=8421376) failed (error code=3)
> >> *** malloc[2889]: error: Can't allocate region
> >>>  q()
> >> *** malloc: vm_allocate(size=8421376) failed (error code=3)
> >> *** malloc[2889]: error: Can't allocate region
> >> *** malloc: vm_allocate(size=8421376) failed (error code=3)
> >> *** malloc[2889]: error: Can't allocate region
> >> Error in lazyLoadDBfetch(key, datafile, compressed, envhook) :
> >> internal error in decompress1
> >>>
> >> --
> >> I am running R 2.0.1 on MacOS X 10.3 with 1Gb ram.
> >> How could I write such a matrix to a text file.
> >>
> >> David
> >>
> >> __
> >> 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
> >>
> >
> >
> > -- 
> > Jim Holtman
> >
> > What the problem you are trying to solve?
> >
> >
> 
> __
> 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] Code Verification

2005-07-20 Thread Liaw, Andy
> From: Christoph Buser
> 
> Hi
> 
> "t.test" assumes that your data within each group has a normal
> distribution. This is not the case in your example.

Eh?  What happen to the CLT?

Andy


> I would recommend you a non parametric test like "wilcox.test" if
> you want to compare the mean of two samples that are not normal
> distributed. 
> see ?wilcox.test
> 
> Be careful. Your example produces two gamma distributed samples
> with rate = 10, not scale = 10. 
> rate = 1/scale.
> If you want to use scale, you need to specify this argument 
> x<-rgamma(40, 2.5, scale = 10)
> see ?rgamma
> 
> I do not see the interpretation of your result. Since you do
> know the distribution and the parameters of your sample, you
> know the true means and that they are different. It is only a
> question of the sample size and the power of your test, if this
> difference is detected.
> Is that something you are investigating? Maybe a power
> calculation or something similar.
> 
> Regards,
> 
> Christoph Buser
> 
> --
> Christoph Buser <[EMAIL PROTECTED]>
> Seminar fuer Statistik, LEO C13
> ETH (Federal Inst. Technology)8092 Zurich  SWITZERLAND
> phone: x-41-44-632-4673   fax: 632-1228
> http://stat.ethz.ch/~buser/
> --
> 
> [EMAIL PROTECTED] writes:
>  > Hi R Users
>  > I have a code which I am running for my thesis work. Just 
> want to make sure that
>  > its ok. Its a t test I am conducting between two gamma 
> distributions with
>  > different shape parameters.
>  > 
>  > the code looks like:
>  > 
>  > sink("a1.txt");
>  > 
>  > for (i in 1:1000)
>  > {
>  > x<-rgamma(40, 2.5, 10)  # n = 40, shape = 2.5, Scale = 10
>  > y<-rgamma(40, 2.8, 10)  # n = 40, shape = 2.8, Scale = 10
>  > z<-t.test(x, y)
>  > print(z)
>  > }
>  > 
>  > 
>  > I will appreciate it if someone could tell me if its alrite or not.
>  > 
>  > thanks
>  > 
>  > -dev
>  > 
>  > __
>  > 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


[R] Prefix for colnames

2005-07-20 Thread jhainm

Hi,

I would like to add a prefix to colnames in a matrix but I can't get the prefix
option in colnames to work. What am I doing wrong?

> X<-matrix(NA,3,4)
> colnames(X)<-c("test","test","test","test")
> colnames(X)<-colnames(X,prefix="PREFIX.")
> X
 test test test test
[1,]   NA   NA   NA   NA
[2,]   NA   NA   NA   NA
[3,]   NA   NA   NA   NA

?? I also tried with do.NULL set to FALSE but it still does not work.

Thank you very much for your help!

Best,
Jens

__
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] Cannot update some packages after upgrade to 2.1.1

2005-07-20 Thread Kevin E. Thorpe
Thank you for the information. I have contacted the RPM maintainer and 
am awaiting a response.

It occurs to me that my "problem" could also be fixed by putting ATLAS 
on my system. Are there advantages to doing that or any reasons not to?

Prof Brian Ripley wrote:

> -lf77blas is part of ATLAS, so I do suspect the RPM builder had ATLAS 
> installed.
>
> lme4 needs a compatible Matrix installed.
>
> I do think installing from the sources would solve this, but probably 
> you need to discuss this with the RPM maintainer as a dependency 
> appears to be missing.
>
> On Fri, 15 Jul 2005, Kevin E. Thorpe wrote:
>
>> I just upgraded to version 2.1.1 (from 2.0.1) today.
>>
>> > R.version
>> _
>> platform i686-pc-linux-gnu
>> arch i686
>> os linux-gnu
>> system i686, linux-gnu
>> status
>> major 2
>> minor 1.1
>> year 2005
>> month 06
>> day 20
>> language R
>>
>> I am using SuSE 9.2 and did the upgrade using rpm -U with the RPM
>> available on CRAN. After upgrading r-base, I ran update.packages().
>> Four previously installed packages failed to update:
>>
>> Matrix (0.95-5 to 0.97-4)
>> gam (0.93 to 0.94)
>> lme4 (0.95-3 to 0.96-1)
>> mgcv (1.3-1 to 1.3-4)
>>
>> In the case of Matrix, gam and mgcv I get the message:
>>
>> [long path]/ld: cannot find -lf77blas
>>
>> In the case of lme4 the messages are:
>>
>> ** preparing package for lazy loading
>> Error in setMethod("coef", signature(object = "lmList"), 
>> function(object, :
>> no existing definition for function 'coef'
>> Error: unable to load R code in package 'lme4'
>> Execution halted
>> ERROR: lazy loading failed for package 'lme4'
>>
>> I have searched the SuSE repository for any package that provides
>> f77blas but came up empty.
>>
>> I also could not identify any relevant messages in the mailing list
>> archives.
>>
>> Is R looking for that library because it was present on the machine
>> the RPM was built on? Would building R myself solve the missing library
>> problem or did I do something wrong?
>>


-- 
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] Prefix for colnames

2005-07-20 Thread Duncan Murdoch
On 7/20/2005 9:54 AM, [EMAIL PROTECTED] wrote:
> Hi,
> 
> I would like to add a prefix to colnames in a matrix but I can't get the 
> prefix
> option in colnames to work. What am I doing wrong?

The prefix argument is only used when there are no names and colnames is 
generating some.  You just want to use paste().

> 
>> X<-matrix(NA,3,4)
>> colnames(X)<-c("test","test","test","test")

 > colnames(X) <- paste("PREFIX.", colnames(X), sep="")
 > X
  PREFIX.test PREFIX.test PREFIX.test PREFIX.test
[1,]  NA  NA  NA  NA
[2,]  NA  NA  NA  NA
[3,]  NA  NA  NA  NA

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] Cannot update some packages after upgrade to 2.1.1

2005-07-20 Thread Prof Brian Ripley
On Wed, 20 Jul 2005, Kevin E. Thorpe wrote:

> Thank you for the information. I have contacted the RPM maintainer and am 
> awaiting a response.
>
> It occurs to me that my "problem" could also be fixed by putting ATLAS on my 
> system. Are there advantages to doing that or any reasons not to?

It is a good idea unless you share R systems between different 
architectures (even down to the vintage of P4 or Xeon chips). We do and so 
tend to avoid ATLAS (which gets statically compiled in by default).

>
> Prof Brian Ripley wrote:
>
>> -lf77blas is part of ATLAS, so I do suspect the RPM builder had ATLAS 
>> installed.
>> 
>> lme4 needs a compatible Matrix installed.
>> 
>> I do think installing from the sources would solve this, but probably you 
>> need to discuss this with the RPM maintainer as a dependency appears to be 
>> missing.
>> 
>> On Fri, 15 Jul 2005, Kevin E. Thorpe wrote:
>> 
>>> I just upgraded to version 2.1.1 (from 2.0.1) today.
>>> 
>>> > R.version
>>> _
>>> platform i686-pc-linux-gnu
>>> arch i686
>>> os linux-gnu
>>> system i686, linux-gnu
>>> status
>>> major 2
>>> minor 1.1
>>> year 2005
>>> month 06
>>> day 20
>>> language R
>>> 
>>> I am using SuSE 9.2 and did the upgrade using rpm -U with the RPM
>>> available on CRAN. After upgrading r-base, I ran update.packages().
>>> Four previously installed packages failed to update:
>>> 
>>> Matrix (0.95-5 to 0.97-4)
>>> gam (0.93 to 0.94)
>>> lme4 (0.95-3 to 0.96-1)
>>> mgcv (1.3-1 to 1.3-4)
>>> 
>>> In the case of Matrix, gam and mgcv I get the message:
>>> 
>>> [long path]/ld: cannot find -lf77blas
>>> 
>>> In the case of lme4 the messages are:
>>> 
>>> ** preparing package for lazy loading
>>> Error in setMethod("coef", signature(object = "lmList"), function(object, 
>>> :
>>> no existing definition for function 'coef'
>>> Error: unable to load R code in package 'lme4'
>>> Execution halted
>>> ERROR: lazy loading failed for package 'lme4'
>>> 
>>> I have searched the SuSE repository for any package that provides
>>> f77blas but came up empty.
>>> 
>>> I also could not identify any relevant messages in the mailing list
>>> archives.
>>> 
>>> Is R looking for that library because it was present on the machine
>>> the RPM was built on? Would building R myself solve the missing library
>>> problem or did I do something wrong?
>>> 
>
>
> -- 
> 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
>
>

-- 
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] CPU Usage with R 2.1.0 in Windows

2005-07-20 Thread davidr
If you set the affinity of the R process to processor 0, you can run another (R 
or other) process with affinity set to processor 1 and get 100% usage.
Most applications can't take advantage of hyperthreading (or multiprocessors), 
since they have to be specially written to do so.

It seems that parts of Windows are single threaded, though, so, for example, 
starting up another instance of Excel when one is already using all of a 
'processor' can take a very long time, but if the processes are already 
started, you can take advantage of the gross parallelism.

David L. Reiner
 

> -Original Message-
> From: [EMAIL PROTECTED] [mailto:r-help-
> [EMAIL PROTECTED] On Behalf Of Prof Brian Ripley
> Sent: Wednesday, July 20, 2005 3:12 AM
> To: Lukasz Komsta
> Cc: Greene, Michael; '[EMAIL PROTECTED]'
> Subject: Re: [R] CPU Usage with R 2.1.0 in Windows
> 
> It probably is not a problem to leave hyperthreading on: we found little
> performance difference on a P4 either way.
> 
> The Windows task manager is misleading, as `50%' is about as much as a
> P4-class processor with hyperthreading can actually deliver.
> 
> On Tue, 19 Jul 2005, Lukasz Komsta wrote:
> 
> > Dnia 2005-07-19 20:28, Uÿÿytkownik Greene, Michael napisaÿÿ:
> >> Hi,> > I'm using a fairly simple HP Compaq desktop PC running Windows
> 2K.  When> running a large process in R, the process "RGUI.exe" will never
> exceed 50%> of the CPU usage.
> > If you have hyperthreading, R catches only one virtual processor
> (fromtwo available), being not able to exceed half of total power (100%
> ofone only). If you want to use full power, you should turn
> hyperthreadingoff, if your BIOS supports such option.
> > Regards,
> > -- Lukasz KomstaDepartment of Medicinal ChemistryMedical University of
> Lublin6 Chodzki, 20-093 Lublin, PolandFax +48 81 7425165
> > [EMAIL PROTECTED]
> mailing listhttps://stat.ethz.ch/mailman/listinfo/r-helpPLEASE do read the
> posting guide! http://www.R-project.org/posting-guide.html
> >
> 
> --
> Brian D. Ripley,  [EMAIL PROTECTED]
> Professor of Applied Statistics,  http://www.stats.ox.ac.uk/~ripley/
> University of Oxford, Tel:  +44 1865 272861 (self)
> 1 South Parks Road, +44 1865 272866 (PA)
> Oxford OX1 3TG, UKFax:  +44 1865 272595

__
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] Prefix for colnames

2005-07-20 Thread Peter Dalgaard
[EMAIL PROTECTED] writes:

> Hi,
> 
> I would like to add a prefix to colnames in a matrix but I can't get the 
> prefix
> option in colnames to work. What am I doing wrong?
> 
> > X<-matrix(NA,3,4)
> > colnames(X)<-c("test","test","test","test")
> > colnames(X)<-colnames(X,prefix="PREFIX.")
> > X
>  test test test test
> [1,]   NA   NA   NA   NA
> [2,]   NA   NA   NA   NA
> [3,]   NA   NA   NA   NA
> 
> ?? I also tried with do.NULL set to FALSE but it still does not work.
> 
> Thank you very much for your help!

Well

> colnames
function (x, do.NULL = TRUE, prefix = "col")
{
dn <- dimnames(x)
if (!is.null(dn[[2]]))
dn[[2]]
else {
if (do.NULL)
NULL
else paste(prefix, seq(length = NCOL(x)), sep = "")
}
}

So if x has colnames that's what you get, irrespective of "prefix".

-- 
   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] Prefix for colnames

2005-07-20 Thread Prof Brian Ripley
On Wed, 20 Jul 2005 [EMAIL PROTECTED] wrote:

>
> Hi,
>
> I would like to add a prefix to colnames in a matrix but I can't get the 
> prefix
> option in colnames to work. What am I doing wrong?
>
>> X<-matrix(NA,3,4)
>> colnames(X)<-c("test","test","test","test")
>> colnames(X)<-colnames(X,prefix="PREFIX.")
>> X
> test test test test
> [1,]   NA   NA   NA   NA
> [2,]   NA   NA   NA   NA
> [3,]   NA   NA   NA   NA
>
> ?? I also tried with do.NULL set to FALSE but it still does not work.

The help page is your friend here:

  do.NULL: logical.  Should this create names if they are 'NULL'?

   prefix: for created names.

  If 'do.NULL' is 'FALSE', a character vector (of length 'NROW(x)'
  or 'NCOL(x)') is returned in any case, prepending 'prefix' to
  simple numbers, if there are no dimnames or the corresponding
  
  component of the dimnames is 'NULL'.

so

> X < -matrix(NA,3,4)
> colnames(X,prefix="PREFIX.", do.NULL=FALSE)
[1] "PREFIX.1" "PREFIX.2" "PREFIX.3" "PREFIX.4"

works as documented.


-- 
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] class in apply

2005-07-20 Thread Omar Lakkis
Thank you for teh helpful answer. I do have one aother related
question; If I am not interested in teh result of the lapply, as I am
using it instaid of a for loop, example

lapply(df, function(r) sqlQuery(conn, paste("insert into t
values(",r['a'],',',r['b'],')')))

and I am not interested in teh result of the insert sql statement. Is
it, for memory and other concerns better to do it this way or to
implement a for loop?

for (i in seq(length= nrow(df)) {
   sqlQuery(conn, paste("insert into t values(",df[i,'a'],',',df[i,'b'],')')))
}

On 7/20/05, Stéphane Dray <[EMAIL PROTECTED]> wrote:
> apply transorm your data.frame into a matrix which can contains only one
> type of values (character or numeric or logical).
> data.frame are list, so they can contain various kind of data, and a
> solution to your problem is given by lapply:
> 
>  > b=lapply(df, function(r) print(class(r['a'])))
> [1] "numeric"
> [1] "factor"
> 
> >Numeric data that is part of a mixed type data frame is converted into
> >character. How can I tell apply to maintain the original class of a
> >column and not convert it into character. I would like to do this of
> >the vector and not inside the apply function individually over each
> >element. Consider the following two scenarios, in the second column
> >'a' maintained its class while it lost its numeric type in the first
> >case.
> >
> >
> >
> >>df = data.frame(a=c(1,2), b=c('A','B'))
> >>df
> >>
> >>
> >  a b
> >1 1 A
> >2 2 B
> >
> >
> >>a=apply(df, 1, function(r) print(class(r['a'])))
> >>
> >>
> >[1] "character"
> >[1] "character"
> >
> >
> >>a=apply(df, 1, function(r) print(class(r['b'])))
> >>
> >>
> >[1] "character"
> >[1] "character"
> >
> >
> >
> >
> >>df = data.frame(a=c(1,2))
> >>df
> >>
> >>
> >  a
> >1 1
> >2 2
> >
> >
> >>a=apply(df, 1, function(r) print(class(r['a'])))
> >>
> >>
> >[1] "numeric"
> >[1] "numeric"
> >
> >__
> >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
> >
> >
> >
> >
> 
> 
> --
> Stéphane DRAY ([EMAIL PROTECTED] )
> Laboratoire BBE-CNRS-UMR-5558, Univ. C. Bernard - Lyon I
> 43, Bd du 11 Novembre 1918, 69622 Villeurbanne Cedex, France
> Tel: 33 4 72 43 27 57   Fax: 33 4 72 43 13 88
> http://www.steph280.freesurf.fr/
> 
>

__
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] unable to call R t-test from Java

2005-07-20 Thread O'Brien, Laura
Hello,

My colleague and I would like to write Java code that invokes R to do a simple 
TTest.  I've included my sample java code below.  I tried various alternatives 
and am unable to pass a vector to the TTest method.  In my investigation, I 
tried to call other R methods that take vectors and also ran into various 
degrees of failure.   Any insight you can provide or other Web references you 
can point me to would be appreciated.

Thank you,
Laura O'Brien
Application Architect



---  code   --


package org.omegahat.R.Java.Examples;

import org.omegahat.R.Java.ROmegahatInterpreter;
import org.omegahat.R.Java.REvaluator;


public class JavaRCall2
{

/**
 * want to see if I can eval a t.test command like what I would run in the
 * R command line
 */

static public void runTTestByEval_cores(REvaluator e, ROmegahatInterpreter 
interp)
{
/* produces a core */
System.err.println("eval a t.test");
Object value = e.eval("t.test (c(1,2,3), c(4,5,6))");
if (value != null)
interp.show(value);
}


/**
 * want to see if I can eval anything that takes a vector, e.g. mean, 
 * like what I would run in the R command line
 */

static public void runMeanByEval_works(REvaluator e, ROmegahatInterpreter 
interp)
{
System.err.println("\r\n  evaluation string mean command");
Object value = e.eval("mean(c(1,2,3))");
if(value != null) 
{
interp.show(value ); 
System.err.println("\r\n");
}
}

/**
 *  if I pass mean a org.omegahat.Environment.DataStructures.numeric what do I 
get?  NaN
 */
 
static public void runMeanByNumericList_nan(REvaluator e, 
ROmegahatInterpreter interp)
{
 Object[] funArgs = new Object[1];
 // given argument is not numeric or logical
 
 org.omegahat.Environment.DataStructures.numeric rList1 = new 
org.omegahat.Environment.DataStructures.numeric(3);   

 double[] dList = new double[3];
 dList[0] = (double) 1.1;
 dList[1] = (double) 2.2; 
 dList[2] = (double) 3.3;
 rList1.setData(dList, true);
 System.err.println(rList1.toString());

 funArgs[0] = rList1 ;
 
 System.err.println("\r\n Calling mean and passing an omegahat vector");


 Object value =  e.call("mean", funArgs); 
 if(value != null) 
 {
 interp.show(value ); 
 System.err.println("\r\n");
 }

}

/**
 * let's run some tests on the vector passed in and see what R thinks I'm 
handing it
 * 
 * it returns 
 * isnumeric: false
 * mode:  list
 * length:2
 */

public static void runTestsOnOmegahatNumeric(REvaluator e, 
ROmegahatInterpreter interp)
{
Object[] funArgs = new Object[1];
// given argument is not numeric or logical
 
org.omegahat.Environment.DataStructures.numeric rList1 = new 
org.omegahat.Environment.DataStructures.numeric(3);   

double[] dList = new double[3];
dList[0] = (double) 1.1;
dList[1] = (double) 2.2; 
dList[2] = (double) 3.3;
rList1.setData(dList, true);
System.err.println(rList1.toString());

funArgs[0] = rList1 ;
 
System.err.println("\r\n Calling isnumeric and passing an omegahat 
vector");
   
Object value =  e.call("is.numeric", funArgs); 
if(value != null) 
{
interp.show(value ); 
System.err.println("\r\n");
}

// mode is list

System.err.println("\r\n Calling mode and passing an omegahat vector");
   
value =  e.call("mode", funArgs); 
if(value != null) 
{
interp.show(value ); 
System.err.println("\r\n");
}

System.err.println("\r\n Calling length and passing an omegahat 
vector");
System.err.println("\r\n");
System.err.println("INTERESTING:  thinks the length is 2!");

   
value =  e.call("length", funArgs); 
if(value != null) 
{
interp.show(value ); 
System.err.println("\r\n");
}

}

/**
 * run the mean on a java array.  Does it also return NAN?  
 * It returns a different value than the mean -- 2.1... instead of 2.2
 */

static public void runMeanOnJavaArray(REvaluator e, ROmegahatInterpreter 
interp)
{
Object[] funArgs = new Object[1];
double[] d = { 1.1, 2.2, 3.3};
funArgs[0] = d;
System.err.println("\r\n Calling mean of (1.1, 2.2, 3.3) and passing a 
java array\r\n");
System.err.println("INTERSTING:  thinks the mean is 2.1... it 
should be 2.2 \r\n");
   
Object value =  e.call("mean", funArgs); 
if(value != null) 
{
interp.show(value 

[R] is.Date ?!!!

2005-07-20 Thread Omar Lakkis
Is there a way to test if a variable is a date?

__
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] Is it possible to create highly customized report in *.xls format by using R/S+?

2005-07-20 Thread Greg Snow
See:

http://www.burns-stat.com/pages/Tutor/spreadsheet_addiction.html
and
http://www.stat.uiowa.edu/~jcryer/JSMTalk2001.pdf

Greg Snow, Ph.D.
Statistical Data Center, LDS Hospital
Intermountain Health Care
[EMAIL PROTECTED]
(801) 408-8111

>>> Wensui Liu <[EMAIL PROTECTED]> 07/19/05 03:22PM >>>
I remember in one slide of Prof. Ripley's presentation overhead, he
said the most popular data analysis software is excel.

So is there any resource or tutorial on this topic? 

Thank you so much!

__
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] Cannot update some packages after upgrade to 2.1.1

2005-07-20 Thread Uwe Ligges
Prof Brian Ripley wrote:

> On Wed, 20 Jul 2005, Kevin E. Thorpe wrote:
> 
> 
>>Thank you for the information. I have contacted the RPM maintainer and am 
>>awaiting a response.
>>
>>It occurs to me that my "problem" could also be fixed by putting ATLAS on my 
>>system. Are there advantages to doing that or any reasons not to?
> 
> 
> It is a good idea unless you share R systems between different 
> architectures (even down to the vintage of P4 or Xeon chips). We do and so 
> tend to avoid ATLAS (which gets statically compiled in by default).


We are using you ATLAS-optimized Rblas.dll files for our facutly wide 
Windows installation.

Additional to the regular .../bin directory, we have copies called 
.../bin-At, .../bin-P3, .../bin-P4 but the regular Rblas.dll replaced by 
those optimized Rblas.dll files.
Hence one can simply call .../bin-P4/RGui.exe on any P4/Xeon machine and 
do not need a seperate installation for another Athlon machine using the 
.../bin-At/RGui.exe, for example.


Uwe


> 
>>Prof Brian Ripley wrote:
>>
>>
>>>-lf77blas is part of ATLAS, so I do suspect the RPM builder had ATLAS 
>>>installed.
>>>
>>>lme4 needs a compatible Matrix installed.
>>>
>>>I do think installing from the sources would solve this, but probably you 
>>>need to discuss this with the RPM maintainer as a dependency appears to be 
>>>missing.
>>>
>>>On Fri, 15 Jul 2005, Kevin E. Thorpe wrote:
>>>
>>>
I just upgraded to version 2.1.1 (from 2.0.1) today.


>R.version

_
platform i686-pc-linux-gnu
arch i686
os linux-gnu
system i686, linux-gnu
status
major 2
minor 1.1
year 2005
month 06
day 20
language R

I am using SuSE 9.2 and did the upgrade using rpm -U with the RPM
available on CRAN. After upgrading r-base, I ran update.packages().
Four previously installed packages failed to update:

Matrix (0.95-5 to 0.97-4)
gam (0.93 to 0.94)
lme4 (0.95-3 to 0.96-1)
mgcv (1.3-1 to 1.3-4)

In the case of Matrix, gam and mgcv I get the message:

[long path]/ld: cannot find -lf77blas

In the case of lme4 the messages are:

** preparing package for lazy loading
Error in setMethod("coef", signature(object = "lmList"), function(object, 
:
no existing definition for function 'coef'
Error: unable to load R code in package 'lme4'
Execution halted
ERROR: lazy loading failed for package 'lme4'

I have searched the SuSE repository for any package that provides
f77blas but came up empty.

I also could not identify any relevant messages in the mailing list
archives.

Is R looking for that library because it was present on the machine
the RPM was built on? Would building R myself solve the missing library
problem or did I do something wrong?

>>
>>
>>-- 
>>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] Is it possible to create highly customized report in *.xls format by using R/S+?

2005-07-20 Thread Wensui Liu
I appreciate your reply and understand your point completely. But at
times we can't change the rule, the only choice is to follow the rule.
Most deliverables in my work are in excel format.

On 7/20/05, Greg Snow <[EMAIL PROTECTED]> wrote:
> See:
> 
> http://www.burns-stat.com/pages/Tutor/spreadsheet_addiction.html
> and
> http://www.stat.uiowa.edu/~jcryer/JSMTalk2001.pdf
> 
> Greg Snow, Ph.D.
> Statistical Data Center, LDS Hospital
> Intermountain Health Care
> [EMAIL PROTECTED]
> (801) 408-8111
> 
> >>> Wensui Liu <[EMAIL PROTECTED]> 07/19/05 03:22PM >>>
> I remember in one slide of Prof. Ripley's presentation overhead, he
> said the most popular data analysis software is excel.
> 
> So is there any resource or tutorial on this topic?
> 
> Thank you so much!
> 
> __
> 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
> 
> 


-- 
WenSui Liu, MS MA
Senior Decision Support Analyst
Division of Health Policy and Clinical Effectiveness
Cincinnati Children Hospital Medical Center

__
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] Cannot update some packages after upgrade to 2.1.1

2005-07-20 Thread Prof Brian Ripley
On Wed, 20 Jul 2005, Uwe Ligges wrote:

> Prof Brian Ripley wrote:
>
>> On Wed, 20 Jul 2005, Kevin E. Thorpe wrote:
>> 
>> 
>>> Thank you for the information. I have contacted the RPM maintainer and am 
>>> awaiting a response.
>>> 
>>> It occurs to me that my "problem" could also be fixed by putting ATLAS on 
>>> my system. Are there advantages to doing that or any reasons not to?
>> 
>> 
>> It is a good idea unless you share R systems between different 
>> architectures (even down to the vintage of P4 or Xeon chips). We do and so 
>> tend to avoid ATLAS (which gets statically compiled in by default).
>
>
> We are using you ATLAS-optimized Rblas.dll files for our facutly wide Windows 
> installation.
>
> Additional to the regular .../bin directory, we have copies called 
> .../bin-At, .../bin-P3, .../bin-P4 but the regular Rblas.dll replaced by 
> those optimized Rblas.dll files.
> Hence one can simply call .../bin-P4/RGui.exe on any P4/Xeon machine and do 
> not need a seperate installation for another Athlon machine using the 
> .../bin-At/RGui.exe, for example.

That is fine on Windows, which has a separate Rblas.dll exactly to enable 
this to be done.

You can also do it on Debian Linux, which has a dynamic libatlas (as I 
understand it).

On other systems with a static ATLAS library, the BLAS is compiled into 
the R installation in many (up to hundreds) of places, including each 
package that uses a BLAS.   It's all too easy to build R on, say, an 
Athlon and discover it segfaults on a Xeon because an Athlon-optimized 
ATLAS has been compiled in. (I've done it more than once, and it needs the 
whole setup to be reinstalled, including many of the packages without it 
being obvious which ones).

>
>
> Uwe
>
>
>> 
>>> Prof Brian Ripley wrote:
>>> 
>>> 
 -lf77blas is part of ATLAS, so I do suspect the RPM builder had ATLAS 
 installed.
 
 lme4 needs a compatible Matrix installed.
 
 I do think installing from the sources would solve this, but probably you 
 need to discuss this with the RPM maintainer as a dependency appears to 
 be missing.
 
 On Fri, 15 Jul 2005, Kevin E. Thorpe wrote:
 
 
> I just upgraded to version 2.1.1 (from 2.0.1) today.
> 
> 
>> R.version
> 
> _
> platform i686-pc-linux-gnu
> arch i686
> os linux-gnu
> system i686, linux-gnu
> status
> major 2
> minor 1.1
> year 2005
> month 06
> day 20
> language R
> 
> I am using SuSE 9.2 and did the upgrade using rpm -U with the RPM
> available on CRAN. After upgrading r-base, I ran update.packages().
> Four previously installed packages failed to update:
> 
> Matrix (0.95-5 to 0.97-4)
> gam (0.93 to 0.94)
> lme4 (0.95-3 to 0.96-1)
> mgcv (1.3-1 to 1.3-4)
> 
> In the case of Matrix, gam and mgcv I get the message:
> 
> [long path]/ld: cannot find -lf77blas
> 
> In the case of lme4 the messages are:
> 
> ** preparing package for lazy loading
> Error in setMethod("coef", signature(object = "lmList"), 
> function(object, :
> no existing definition for function 'coef'
> Error: unable to load R code in package 'lme4'
> Execution halted
> ERROR: lazy loading failed for package 'lme4'
> 
> I have searched the SuSE repository for any package that provides
> f77blas but came up empty.
> 
> I also could not identify any relevant messages in the mailing list
> archives.
> 
> Is R looking for that library because it was present on the machine
> the RPM was built on? Would building R myself solve the missing library
> problem or did I do something wrong?
> 
>>> 
>>> 
>>> -- 
>>> 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
>>> 
>>> 
>> 
>> 
>
>

-- 
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] is.Date ?!!!

2005-07-20 Thread Duncan Murdoch
On 7/20/2005 10:41 AM, Omar Lakkis wrote:
> Is there a way to test if a variable is a date?

Yes, but there are several different things people might call dates. 
Which do you mean?

For example,

 > today <- Sys.Date()
 > today
[1] "2005-07-20"
 > inherits(today, "Date")
[1] TRUE

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] is.Date ?!!!

2005-07-20 Thread Prof Brian Ripley
If you mean of class "Date",  use inherits(x, "Date").

On Wed, 20 Jul 2005, Omar Lakkis wrote:

> Is there a way to test if a variable is a date?

-- 
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] Code Verification

2005-07-20 Thread Christoph Buser
Dear Andy

Since the power of the t-test decreases when there are
discrepancies in the data to the normal distribution and there
is only a small loss of power if the data is normal distributed,
the only reason to use the t.test is his simplicity and the
easier interpretation.
Generally I'd prefer the wilcoxon test even if the data is
normal distributed.
But I agree that for a gamma distribution there is no huge loss
of power.

## example simulation:

n <- 1000
z1 <- numeric(n)
z2 <- numeric(n)

## gamma distribution
for (i in 1:n)
{
x<-rgamma(40, 2.5, 0.1)  
y<-rgamma(40, 3.5, 0.1)  
z1[i]<-t.test(x, y)$p.value
z2[i]<-wilcox.test(x, y)$p.value
}
## Power
1 - sum(z1>0.05)/1000  ## 0.71
1 - sum(z2>0.05)/1000  ## 0.76

##

## t distribution
for (i in 1:n)
{
x<-rt(40, df = 3)  
y<-1 + rt(40, df = 3)  
z1[i]<-t.test(x, y)$p.value
z2[i]<-wilcox.test(x, y)$p.value
}
## Power
1 - sum(z1>0.05)/1000  ## 0.76
1 - sum(z2>0.05)/1000  ## 0.91

##

## normal distribution
for (i in 1:n)
{
x<-rnorm(40, 0, 3)  
y<-1 + rnorm(40, 1, 3)  
z1[i]<-t.test(x, y)$p.value
z2[i]<-wilcox.test(x, y)$p.value
}
## Power
1 - sum(z1>0.05)/1000  ## 0.83
1 - sum(z2>0.05)/1000  ## 0.81

Regards,

Christoph Buser

--
Christoph Buser <[EMAIL PROTECTED]>
Seminar fuer Statistik, LEO C13
ETH (Federal Inst. Technology)  8092 Zurich  SWITZERLAND
phone: x-41-44-632-4673 fax: 632-1228
http://stat.ethz.ch/~buser/
--

Liaw, Andy writes:
 > > From: Christoph Buser
 > > 
 > > Hi
 > > 
 > > "t.test" assumes that your data within each group has a normal
 > > distribution. This is not the case in your example.
 > 
 > Eh?  What happen to the CLT?
 > 
 > Andy
 > 
 > 
 > > I would recommend you a non parametric test like "wilcox.test" if
 > > you want to compare the mean of two samples that are not normal
 > > distributed. 
 > > see ?wilcox.test
 > > 
 > > Be careful. Your example produces two gamma distributed samples
 > > with rate = 10, not scale = 10. 
 > > rate = 1/scale.
 > > If you want to use scale, you need to specify this argument 
 > > x<-rgamma(40, 2.5, scale = 10)
 > > see ?rgamma
 > > 
 > > I do not see the interpretation of your result. Since you do
 > > know the distribution and the parameters of your sample, you
 > > know the true means and that they are different. It is only a
 > > question of the sample size and the power of your test, if this
 > > difference is detected.
 > > Is that something you are investigating? Maybe a power
 > > calculation or something similar.
 > > 
 > > Regards,
 > > 
 > > Christoph Buser
 > > 
 > > --
 > > Christoph Buser <[EMAIL PROTECTED]>
 > > Seminar fuer Statistik, LEO C13
 > > ETH (Federal Inst. Technology) 8092 Zurich  SWITZERLAND
 > > phone: x-41-44-632-4673fax: 632-1228
 > > http://stat.ethz.ch/~buser/
 > > --
 > > 
 > > [EMAIL PROTECTED] writes:
 > >  > Hi R Users
 > >  > I have a code which I am running for my thesis work. Just 
 > > want to make sure that
 > >  > its ok. Its a t test I am conducting between two gamma 
 > > distributions with
 > >  > different shape parameters.
 > >  > 
 > >  > the code looks like:
 > >  > 
 > >  > sink("a1.txt");
 > >  > 
 > >  > for (i in 1:1000)
 > >  > {
 > >  > x<-rgamma(40, 2.5, 10)  # n = 40, shape = 2.5, Scale = 10
 > >  > y<-rgamma(40, 2.8, 10)  # n = 40, shape = 2.8, Scale = 10
 > >  > z<-t.test(x, y)
 > >  > print(z)
 > >  > }
 > >  > 
 > >  > 
 > >  > I will appreciate it if someone could tell me if its alrite or not.
 > >  > 
 > >  > thanks
 > >  > 
 > >  > -dev
 > >  > 
 > >  > __
 > >  > 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
 > > 
 > > 
 > > 
 > 
 > 
 > 
 > --
 > Notice:  This e-mail message, together with any attachments, contains 
 > information of Merck & Co., Inc. (One Merck Drive, Whitehouse Station, New 
 > Jersey, USA 08889), and/or its affiliates (which may be known outside the 
 > United States as Merck Frosst, Merck Sharp & Dohme or MSD and in Japan, as 
 > Banyu) that may be confidential, proprietary copyrighted and/or legally 
 > privileged. It is intended solely for the use of the individual or entity 
 > named on this message.  If you are not the intended recipient, and have 
 > received this message in 

Re: [R] is.Date ?!!!

2005-07-20 Thread Uwe Ligges
Omar Lakkis wrote:

> Is there a way to test if a variable is a date?


  is(variable, "Date")

Uwe Ligges


> __
> 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] Is it possible to create highly customized report in *.xlsformat by using R/S+?

2005-07-20 Thread Sung, Iyue
 Your surest bet is to look into S+, not R, since the former does
'integrate' with Microsoft applications. To what extent, I don' know.
This is a desirable feature (IMO) and a reason to use S+ rather then R
(already discussed in different thread).

Try the S+ newsgroup.


> -Original Message-
> From: [EMAIL PROTECTED] 
> [mailto:[EMAIL PROTECTED] On Behalf Of Wensui Liu
> Sent: Wednesday, July 20, 2005 10:56 AM
> To: Greg Snow
> Cc: r-help@stat.math.ethz.ch
> Subject: Re: [R] Is it possible to create highly customized 
> report in *.xlsformat by using R/S+?
> 
> I appreciate your reply and understand your point completely. 
> But at times we can't change the rule, the only choice is to 
> follow the rule.
> Most deliverables in my work are in excel format.
> 
> On 7/20/05, Greg Snow <[EMAIL PROTECTED]> wrote:
> > See:
> > 
> > http://www.burns-stat.com/pages/Tutor/spreadsheet_addiction.html
> > and
> > http://www.stat.uiowa.edu/~jcryer/JSMTalk2001.pdf
> > 
> > Greg Snow, Ph.D.
> > Statistical Data Center, LDS Hospital
> > Intermountain Health Care
> > [EMAIL PROTECTED]
> > (801) 408-8111
> > 
> > >>> Wensui Liu <[EMAIL PROTECTED]> 07/19/05 03:22PM >>>
> > I remember in one slide of Prof. Ripley's presentation overhead, he 
> > said the most popular data analysis software is excel.
> > 
> > So is there any resource or tutorial on this topic?
> > 
> > Thank you so much!
> > 
> > __
> > 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
> > 
> > 
> 
> 
> --
> WenSui Liu, MS MA
> Senior Decision Support Analyst
> Division of Health Policy and Clinical Effectiveness 
> Cincinnati Children Hospital Medical Center
> 
> __
> 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
> --
> --
> This e-mail and any attachments may be confidential or\ > ...{{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] is.Date ?!!!

2005-07-20 Thread Omar Lakkis
The type of date I am asking about is the result of an as.Date(). 
inherits(x, "Date")
and 
is(variable, "Date")
works for me. Thank you all.

On 7/20/05, Uwe Ligges <[EMAIL PROTECTED]> wrote:
> Omar Lakkis wrote:
> 
> > Is there a way to test if a variable is a date?
> 
> 
>   is(variable, "Date")
> 
> Uwe Ligges
> 
> 
> > __
> > 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] maps and data for german federal states

2005-07-20 Thread Greg Snow
There are shapefiles for Europe (and other places) at: 
http://www.vdstech.com/map_data.htm (there are 16 polygons withing the one for 
Germany, is that enough detail).  You can read and plot the shapefiles using 
the maptools package.

hope this helps,

Greg Snow, Ph.D.
Statistical Data Center, LDS Hospital
Intermountain Health Care
[EMAIL PROTECTED]
(801) 408-8111

>>> "Ebersberger, Bernd" <[EMAIL PROTECTED]> 07/20/05 01:07AM >>>
dear R-tists,

i want to graph information for the German Federal States (Bundeslaender) using 
the maps package. unfortunately there is no maps for the German Bundeslaender.

does anyone have an idea / a source where to get map data that can be used in 
the maps package that graphs structures below the country level. 

in the long run it would also be interesting to integrate Swiss Cantons and 
Austrian Bundesländer... 

any suggestions are highly appreciated.

thanks

bernd

++
bernd ebersberger
fhg isi
b.ebersberger (AT) isi.fhg.de

__
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] Is it possible to create highly customized report in *.xlsformat by using R/S+?

2005-07-20 Thread Whit Armstrong
I have a package which I use to create excel files from R.

I have not been able to produce a configure script general enough for me
to post it to cran, but I will send it to you if you like.

I use it for production jobs on our linux servers.  You may have to
tinker a bit to get it to compile on windows.

Have a look at the examples below.  If it suits your needs, I will send
it to you.

Cheers,
Whit


Here are the examples from the help page:

 nc <- 4
 nr <- 20
 x <- matrix(rnorm(nc*nr),ncol=nc,nrow=nr)

 rownames(x) <- rep(letters,length=nr)
 colnames(x) <- rep(letters,length=nc)

 # write a matrix
 write.xls(x,"matrixFromR.xls","matrix")
 write.xls(x,"matrixFromR.no.colnms.xls","matrix",writeColNms=FALSE)
 write.xls(x,"matrix.no.rownms.xls","matrix",writeRowNms=FALSE)
 
write.xls(x,"matrix.no.nms.xls","matrix",writeColNms=FALSE,writeRowNms=F
ALSE)

 # add some formats
 
write.xls(x,"matrixFromR_formatted.xls","matrix",formats=rep("0.0",nc))
 
write.xls(x,"matrixFromR_formatted2.xls","matrix",formats=rep(c("0.0","0
"),nc/2))
 
write.xls(x,"matrixFromR_formatted3.xls","matrix",formats=rep("#,##0.0;[
Red]#-##0.0;\"\"",nc))

 write.xls(x[,1],"vectorFromR.xls","vector")
 
write.xls(x[,1],"vectorFromR.no.colnms.xls","vector",writeColNms=FALSE)
 
write.xls(x[,1],"vectorFromR.no.rownms.xls","vector",writeRowNms=FALSE)
 
write.xls(x[,1],"vectorFromR.no.nms.xls","vector",writeColNms=FALSE,writ
eRowNms=FALSE)

 # char data test
 y <- matrix(rep(letters,each=26),ncol=26)
 rownames(y) <- rep(letters,length=26)
 colnames(y) <- rep(letters,length=26)
 write.xls(y,"char.data.xls","alphabet")

 # logical data test
 z <- matrix(as.logical(round(runif(nc*nr),0)),ncol=nc)
 rownames(z) <- rep(letters,length=nr)
 colnames(z) <- rep(letters,length=nc)

 write.xls(z,"logical.data.xls","myLogic")
 write.xls(z[,1],"logical.data.vector.xls","myLogicVector") 



-Original Message-
From: [EMAIL PROTECTED]
[mailto:[EMAIL PROTECTED] On Behalf Of Wensui Liu
Sent: Wednesday, July 20, 2005 10:56 AM
To: Greg Snow
Cc: r-help@stat.math.ethz.ch
Subject: Re: [R] Is it possible to create highly customized report in
*.xlsformat by using R/S+?

I appreciate your reply and understand your point completely. But at
times we can't change the rule, the only choice is to follow the rule.
Most deliverables in my work are in excel format.

On 7/20/05, Greg Snow <[EMAIL PROTECTED]> wrote:
> See:
> 
> http://www.burns-stat.com/pages/Tutor/spreadsheet_addiction.html
> and
> http://www.stat.uiowa.edu/~jcryer/JSMTalk2001.pdf
> 
> Greg Snow, Ph.D.
> Statistical Data Center, LDS Hospital
> Intermountain Health Care
> [EMAIL PROTECTED]
> (801) 408-8111
> 
> >>> Wensui Liu <[EMAIL PROTECTED]> 07/19/05 03:22PM >>>
> I remember in one slide of Prof. Ripley's presentation overhead, he 
> said the most popular data analysis software is excel.
> 
> So is there any resource or tutorial on this topic?
> 
> Thank you so much!
> 
> __
> 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
> 
> 


--
WenSui Liu, MS MA
Senior Decision Support Analyst
Division of Health Policy and Clinical Effectiveness Cincinnati Children
Hospital Medical Center

__
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] predict.lm - standard error of predicted means?

2005-07-20 Thread kehler
Simple question.

For a simple linear regression, I obtained the "standard error of
predicted means", for both a confidence and prediction interval:

x<-1:15
y<-x + rnorm(n=15)
model<-lm(y~x)
predict.lm(model,newdata=data.frame(x=c(10,20)),se.fit=T,interval="confidence")$se.fit
1 2
0.2708064 0.7254615

predict.lm(model,newdata=data.frame(x=c(10,20)),se.fit=T,interval="prediction")$se.fit
1 2
0.2708064 0.7254615


I was surprised to find that the standard errors returned were in fact the
standard errors of the sampling distribution of Y_hat:

sqrt(MSE(1/n + (x-x_bar)^2/SS_x)),

not the standard errors of Y_new (predicted value):

sqrt(MSE(1 + 1/n + (x-x_bar)^2/SS_x)).

Is there a reason this quantity is called the "standard error of predicted
means" if it doesn't relate to the prediction distribution?

Turning to Neter et al.'s Applied Linear Statistical Models, I note that
if we have multiple observations, then the standard error of the mean of
the predicted value:

sqrt(MSE(1/m + 1/n + (x-x_bar)^2/SS_x)),

reverts to the standard error of the sampling distribution of Y-hat, as m,
the number of samples, gets large. Still, this doesn't explain the result
for small sample sizes.

Using R.2.1 for Windows

__
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] poisson fit for histogram

2005-07-20 Thread Thomas Isenbarger
I haven't been an R lister for a bit, but I hope to enlist someone's  
help here.  I think this is a simple question, so I hope the answer  
is not much trouble.  Can you please respond directly to this email  
address in addition to the list (if responding to the list is  
warranted)?

I have a histogram and I want to see if the data fit a Poisson  
distribution.  How do I do this?  It is preferable if it could be  
done without having to install any or many packages.

I use R Version 1.12 (1622) on OS X

Thank-you very much,
Tom Isenbarger


--
Tom Isenbarger PhD
[EMAIL PROTECTED]
608.265.0850


[[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] unable to call R t-test from Java

2005-07-20 Thread Wiener, Matthew
This does not address the question of how to do this the way you're trying
to do it, using Omegahat.  But I've had good results using Simon Urbanek's
program Rserve:  http://stats.math.uni-augsburg.de/Rserve/

Hope this helps,

Matthew Wiener
Applied Computer Science & Mathematics
Merck Research Laboratories
Rahway, NJ 07065
732-594-5303 


-Original Message-
From: [EMAIL PROTECTED]
[mailto:[EMAIL PROTECTED] On Behalf Of O'Brien, Laura
Sent: Wednesday, July 20, 2005 10:42 AM
To: r-help@stat.math.ethz.ch
Subject: [R] unable to call R t-test from Java


Hello,

My colleague and I would like to write Java code that invokes R to do a
simple TTest.  I've included my sample java code below.  I tried various
alternatives and am unable to pass a vector to the TTest method.  In my
investigation, I tried to call other R methods that take vectors and also
ran into various degrees of failure.   Any insight you can provide or other
Web references you can point me to would be appreciated.

Thank you,
Laura O'Brien
Application Architect



---  code   --


package org.omegahat.R.Java.Examples;

import org.omegahat.R.Java.ROmegahatInterpreter;
import org.omegahat.R.Java.REvaluator;


public class JavaRCall2
{

/**
 * want to see if I can eval a t.test command like what I would run in
the
 * R command line
 */

static public void runTTestByEval_cores(REvaluator e,
ROmegahatInterpreter interp)
{
/* produces a core */
System.err.println("eval a t.test");
Object value = e.eval("t.test (c(1,2,3), c(4,5,6))");
if (value != null)
interp.show(value);
}


/**
 * want to see if I can eval anything that takes a vector, e.g. mean, 
 * like what I would run in the R command line
 */

static public void runMeanByEval_works(REvaluator e,
ROmegahatInterpreter interp)
{
System.err.println("\r\n  evaluation string mean command");
Object value = e.eval("mean(c(1,2,3))");
if(value != null) 
{
interp.show(value ); 
System.err.println("\r\n");
}
}

/**
 *  if I pass mean a org.omegahat.Environment.DataStructures.numeric what do
I get?  NaN
 */
 
static public void runMeanByNumericList_nan(REvaluator e,
ROmegahatInterpreter interp)
{
 Object[] funArgs = new Object[1];
 // given argument is not numeric or logical
 
 org.omegahat.Environment.DataStructures.numeric rList1 = new
org.omegahat.Environment.DataStructures.numeric(3);   

 double[] dList = new double[3];
 dList[0] = (double) 1.1;
 dList[1] = (double) 2.2; 
 dList[2] = (double) 3.3;
 rList1.setData(dList, true);
 System.err.println(rList1.toString());

 funArgs[0] = rList1 ;
 
 System.err.println("\r\n Calling mean and passing an omegahat
vector");


 Object value =  e.call("mean", funArgs); 
 if(value != null) 
 {
 interp.show(value ); 
 System.err.println("\r\n");
 }

}

/**
 * let's run some tests on the vector passed in and see what R thinks
I'm handing it
 * 
 * it returns 
 * isnumeric: false
 * mode:  list
 * length:2
 */

public static void runTestsOnOmegahatNumeric(REvaluator e,
ROmegahatInterpreter interp)
{
Object[] funArgs = new Object[1];
// given argument is not numeric or logical
 
org.omegahat.Environment.DataStructures.numeric rList1 = new
org.omegahat.Environment.DataStructures.numeric(3);   

double[] dList = new double[3];
dList[0] = (double) 1.1;
dList[1] = (double) 2.2; 
dList[2] = (double) 3.3;
rList1.setData(dList, true);
System.err.println(rList1.toString());

funArgs[0] = rList1 ;
 
System.err.println("\r\n Calling isnumeric and passing an omegahat
vector");
   
Object value =  e.call("is.numeric", funArgs); 
if(value != null) 
{
interp.show(value ); 
System.err.println("\r\n");
}

// mode is list

System.err.println("\r\n Calling mode and passing an omegahat
vector");
   
value =  e.call("mode", funArgs); 
if(value != null) 
{
interp.show(value ); 
System.err.println("\r\n");
}

System.err.println("\r\n Calling length and passing an omegahat
vector");
System.err.println("\r\n");
System.err.println("INTERESTING:  thinks the length is 2!");

   
value =  e.call("length", funArgs); 
if(value != null) 
{
interp.show(value ); 
System.err.println("\r\n");
}

}

/**
 * run the mean on a java array.  Does it also return NAN?  
 * It returns a different value than the mean 

Re: [R] sciviews installation

2005-07-20 Thread Philippe Grosjean
John Fox wrote:
> Dear Philippe,
> 
> The development version 1.1-0 of the Rcmdr package (i.e., the one with
> localization facilities) isn't yet on CRAN. Georges doesn't say which
> version of the Rcmdr package he's using, but I assume 1.0-2 from CRAN, which
> I believe should work with SciViews.

That is true, he doesn't say which version. However, SciViews 
compatibility of Rcmdr is broken since version 1.0-0. The last Rcmdr I 
can run properly under SciViews is Rcmdr 0.9-18. So, the current version 
on CRAN is also broken. For those using Rcmdr under SciViews, I would 
suggest to download version 0.9-18 of Rcmdr from the web site 
http://www.sciviews.org/SciViews-R, just for the time I fix the problem.

Sorry for this long delay before I fix this problem. R commander is 
evolving at an incredible speed. This is excellent, of course... but not 
easy to catch up with when you are away from your work for a couple of 
months (indeed, just taking care of my baby and finishing my new house, 
but I am not seeking for excuses) ;-)

Best,

Philippe Grosjean

> 
> Regards,
>  John
> 
> 
> John Fox
> Department of Sociology
> McMaster University
> Hamilton, Ontario
> Canada L8S 4M4
> 905-525-9140x23604
> http://socserv.mcmaster.ca/jfox 
>  
> 
> 
>>-Original Message-
>>From: [EMAIL PROTECTED] 
>>[mailto:[EMAIL PROTECTED] On Behalf Of 
>>Philippe Grosjean
>>Sent: Wednesday, July 20, 2005 5:24 AM
>>To: [EMAIL PROTECTED]
>>Cc: r-help@stat.math.ethz.ch
>>Subject: Re: [R] sciviews installation
>>
>>Hello,
>>
>>Several changes in the latest Rcmdr broken the SciViews 
>>compatibility. I am working on it... but it takes longer than 
>>expected. Sorry for the inconvenience.
>>Best,
>>
>>Philippe
>>
>>..<°}))><
>>  ) ) ) ) )
>>( ( ( ( (Prof. Philippe Grosjean
>>  ) ) ) ) )
>>( ( ( ( (Numerical Ecology of Aquatic Systems
>>  ) ) ) ) )   Mons-Hainaut University, Pentagone (3D08)
>>( ( ( ( (Academie Universitaire Wallonie-Bruxelles
>>  ) ) ) ) )   8, av du Champ de Mars, 7000 Mons, Belgium
>>( ( ( ( (
>>  ) ) ) ) )   phone: + 32.65.37.34.97, fax: + 32.65.37.30.54
>>( ( ( ( (email: [EMAIL PROTECTED]
>>  ) ) ) ) )
>>( ( ( ( (web:   http://www.umh.ac.be/~econum
>>  ) ) ) ) )  http://www.sciviews.org
>>( ( ( ( (
>>..
>>
>>ghjmora g mail wrote:
>>
>>>Hello
>>>
>>>
>>>1. a few months ago, I had sciviews working fine with R 
>>
>>(rw2001) under 
>>
>>>windows XP 2. now, upgrading to rw2011, the stuff seems fine (every 
>>>package installed),but I find a conflict when launching sciviews:
>>>- it runs, apparently
>>>- but when I try to work ("import/export In: text" for 
>>
>>instance), it 
>>
>>>asks for Rcmdr ("Would you like to install it now?")
>>>
>>>3. Rcmdr is already installed (with all dependencies) and 
>>
>>works well 
>>
>>>when called directly in R gui 4. and it's impossible to make it 
>>>reconized or to install it under sciviews
>>>
>>>
>>>I have all the latest packages, and I am going to get mad.
>>>
>>>what do you suggest to solve my problem ?
>>>
>>>Thanks
>>>
>>>Georges Moracchini
>>>
>>>__
>>>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
> 
>

__
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] Is it possible to create highly customized report i n *.xlsformat by using R/S+?

2005-07-20 Thread Dirk Eddelbuettel
Whit Armstrong  twinfieldscapital.com> writes:
> I have a package which I use to create excel files from R.
> 
> I have not been able to produce a configure script general enough for me
> to post it to cran, but I will send it to you if you like.
> 
> I use it for production jobs on our linux servers.  You may have to
> tinker a bit to get it to compile on windows.
> 
> Have a look at the examples below.  If it suits your needs, I will send
> it to you.

Looks straightforward, but does not fancy-pants formatting.  If that is 
sufficient, could one not borrow Greg's approach from read.xls() [ in package 
gdata, part of the unbundled gregmisc bundle ] and create a simpler write.xls()
that uses Perl's SpreadSheet::WriteExcel to write xls files -- just like Greg
uses the related SpreadSheet::ReadExcel to read xls files ?  That way you avoid
the configure hassles of the Java module you use here [ if I recall correctly,
you borrowed this from an Apache sub-project, no ? ]

Cheers, 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] predict.lm - standard error of predicted means?

2005-07-20 Thread Peter Dalgaard
[EMAIL PROTECTED] writes:

> Simple question.
> 
> For a simple linear regression, I obtained the "standard error of
> predicted means", for both a confidence and prediction interval:
> 
> x<-1:15
> y<-x + rnorm(n=15)
> model<-lm(y~x)
> predict.lm(model,newdata=data.frame(x=c(10,20)),se.fit=T,interval="confidence")$se.fit
> 1 2
> 0.2708064 0.7254615
> 
> predict.lm(model,newdata=data.frame(x=c(10,20)),se.fit=T,interval="prediction")$se.fit
> 1 2
> 0.2708064 0.7254615
> 
> 
> I was surprised to find that the standard errors returned were in fact the
> standard errors of the sampling distribution of Y_hat:
> 
> sqrt(MSE(1/n + (x-x_bar)^2/SS_x)),
> 
> not the standard errors of Y_new (predicted value):
> 
> sqrt(MSE(1 + 1/n + (x-x_bar)^2/SS_x)).
> 
> Is there a reason this quantity is called the "standard error of predicted
> means" if it doesn't relate to the prediction distribution?

Yes. Yhat is the predicted mean and se.fit is its standard deviation.
It doesn't change its meaning because you desire another kind of
prediction interval.

 
> Turning to Neter et al.'s Applied Linear Statistical Models, I note that
> if we have multiple observations, then the standard error of the mean of
> the predicted value:
> 
> sqrt(MSE(1/m + 1/n + (x-x_bar)^2/SS_x)),
> 
> reverts to the standard error of the sampling distribution of Y-hat, as m,
> the number of samples, gets large. Still, this doesn't explain the result
> for small sample sizes.

You can make completely similar considerations regarding the standard
errors of and about an estimated mean: sigma*sqrt(1+1/n) vs.
sigma*sqrt(1/m + 1/n) vs. sigma*sqrt(1/n). SEM is still the latter
quantity even if you are interested in another kind of prediction limit. 

-- 
   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] Issues with convolve

2005-07-20 Thread Vincent Goulet
We obtained some disturbing results from convolve() (inaccuracies and negative 
probabilities). We'll try to make the context clear in as few lines as 
possible...

Our function panjer() (code below) basically computes recursively the 
probability mass function of a compound Poisson distribution. When the 
Poisson parameter lambda is very large, the starting value of the recursive 
scheme --- the mass at 0 --- is 0 and the recursion fails. One way to solve 
this problem is to divide lambda by 2^n, apply the panjer() function and then 
convolve the result with itself n times.

We applied the panjer() function with a lambda such that the mass at 0 is just 
larger than .Machine$double.xmin. We thus know that once this pmf is 
convoluted with itself, the first probabilities will be 0 (for the computer).

Here are the two issues we have with convolve():

1. The probabilities we know should be 0 are rather in the vicinity of 1E-19, 
as if convolve() could not "go lower". Using a hand made convolution function 
(not given here), we obtained the correct values. When probabilities get 
around 1E-12, results from convolve() and our home made function are 
essentially identical.

2. We obtained negative probabilities. More accurately, the same example 
returns negative probabilities under Windows, but not under Linux. We also 
obtained negative probabilities for another example under Linux, though.

We understand that convolve() computes the convolutions using fft(), but we 
are not familiar enough with the latter to assess if the above issues are 
some sort of bugs or normal behavior. In the latter case, is there is any 
workaround?

Any help/comments/ideas appreciated.

=== EXAMPLES ===
panjer <- function(fx, lambda)
{
fx0 <- fx[1]
fx <- fx[-1]
r <- length(fx)
cumul <- fs <- exp(-lambda * (1 - fx0))
repeat
{
x <- length(fs)
m <- min(x, r)
fs <- c(fs, sum((lambda * 1:m / x) * head(fx, m) * rev(tail(fs, m
if ((1-1E-8) < (cumul <- cumul + tail(fs, 1)))
break
}
fs
}

### Linux example ###
> R.version
 _
platform i386-pc-linux-gnu
arch i386 
os   linux-gnu
system   i386, linux-gnu  
status
major2
minor1.0  
year 2005 
month04   
day  18   
language R   
> fs <- panjer(rep(0.2, 5), 600)  # compute pmf
> fs[1:10]# small values
 [1] 3.456597e-209 4.147916e-207 2.530229e-205 1.045690e-203
 [5] 3.292657e-202 8.422924e-201 1.822768e-199 3.431181e-198
 [9] 5.733481e-197 8.637025e-196
> fsc <- convolve(fs, rev(fs), type="o")  # convolution
> sum(fsc < 0)# no negatives under Linux
[1] 0
> fsc[1:10]   # these should be 0
 [1] 4.819870e-19 4.135471e-19 4.511455e-19 3.994485e-19 3.820177e-19
 [6] 4.738272e-19 3.885447e-19 3.167399e-19 3.695636e-19 3.701792e-19
> sum(fsc)# no impact on the sum
[1] 1

### Windows example ###
> R.version
 _  
platform i386-pc-mingw32
arch i386   
os   mingw32
system   i386, mingw32  
status  
major2  
minor1.1
year 2005   
month06 
day  20 
language R  
> fs <- panjer(rep(0.2, 5), 600)  # compute pmf
> fs[1:10]# small values
 [1] 3.456597e-209 4.147916e-207 2.530229e-205 1.045690e-203
 [5] 3.292657e-202 8.422924e-201 1.822768e-199 3.431181e-198
 [9] 5.733481e-197 8.637025e-196
> fsc <- convolve(fs, rev(fs), type="o")  # convolution
> sum(fsc < 0)# negatives under Windows
[1] 39
> fsc[1:10]   # these should be 0
 [1] 4.049552e-19 3.345584e-19 4.126913e-19 3.351211e-19 2.758626e-19
 [6] 3.530111e-19 2.735041e-19 2.376711e-19 2.591287e-19 3.196405e-19
> sum(fsc)# no impact on the sum
[1] 1

--
  Vincent Goulet, Associate Professor
  École d'actuariat
  Université Laval, Québec 
  [EMAIL PROTECTED]   http://vgoulet.act.ulaval.ca

__
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] predict.lm - standard error of predicted means?

2005-07-20 Thread mark salsburg
Can someone please refer me to a function or method that resolves this
structuring issue:

I have two matrices with identical colnames (89), but varying number
of observations:

matrix Amatrix B 

217 x 89  16063 x 89

I want to creat one matrix C that has both matrices adjacent to one
another, where matrix A is duplicated many times to create the same
row number for matrix B, i.e. 16063.

matrixA matrix B
matrixA
matrixA

so matrix C will be 16063 x 178

I've tried cbind() and merge() with no success..

__
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] Is it possible to create highly customized report in *.xlsformat by using R/S+?

2005-07-20 Thread Whit Armstrong
It _does_ do formatting:

write.xls(x,"matrixFromR_formatted3.xls","matrix",formats=rep("#,##0.0;[
Red]#-##0.0;\"\"",nc))

And also writes multiple sheets to a workbook (I didn't post all the
examples).

I need those features for the reports I generate, but if the perl module
has the same features, then I'm happy to contribute to a solution for
Greg's package that would use perl instead.  The R -> C++ -> Java ->
file method is a huge pain.

On the other hand, there may be no reason to continue to work on this
project as MS has suggested that it will use xml formats for the next
version of office: http://www.theregister.co.uk/2005/06/03/_office_xml/

btw, here's the list of alternatives suggested by the POI team:
http://jakarta.apache.org/poi/hssf/alternatives.html

fyi, here is the project homepage:
http://jakarta.apache.org/poi/index.html

Thx,
Whit

-Original Message-
From: [EMAIL PROTECTED]
[mailto:[EMAIL PROTECTED] On Behalf Of Dirk Eddelbuettel
Sent: Wednesday, July 20, 2005 11:53 AM
To: r-help@stat.math.ethz.ch
Subject: Re: [R]Is it possible to create highly customized report in
*.xlsformat by using R/S+?

Whit Armstrong  twinfieldscapital.com> writes:
> I have a package which I use to create excel files from R.
> 
> I have not been able to produce a configure script general enough for 
> me to post it to cran, but I will send it to you if you like.
> 
> I use it for production jobs on our linux servers.  You may have to 
> tinker a bit to get it to compile on windows.
> 
> Have a look at the examples below.  If it suits your needs, I will 
> send it to you.

Looks straightforward, but does not fancy-pants formatting.  If that is
sufficient, could one not borrow Greg's approach from read.xls() [ in
package gdata, part of the unbundled gregmisc bundle ] and create a
simpler write.xls() that uses Perl's SpreadSheet::WriteExcel to write
xls files -- just like Greg uses the related SpreadSheet::ReadExcel to
read xls files ?  That way you avoid the configure hassles of the Java
module you use here [ if I recall correctly, you borrowed this from an
Apache sub-project, no ? ]

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

__
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] Combining two matrices

2005-07-20 Thread mark salsburg
Can someone please refer me to a function or method that resolves this
structuring issue:

I have two matrices with identical colnames (89), but varying number
of observations:

matrix Amatrix B

217 x 89  16063 x 89

I want to creat one matrix C that has both matrices adjacent to one
another, where matrix A is duplicated many times to create the same
row number for matrix B, i.e. 16063.

matrixA matrix B
matrixA
matrixA

so matrix C will be 16063 x 178

I've tried cbind() and merge() with no success..

__
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] predict.lm - standard error of predicted means?

2005-07-20 Thread Peter Dalgaard
mark salsburg <[EMAIL PROTECTED]> writes:

> Can someone please refer me to a function or method that resolves this
> structuring issue:
> 
> I have two matrices with identical colnames (89), but varying number
> of observations:
> 
> matrix Amatrix B 
> 
> 217 x 89  16063 x 89
> 
> I want to creat one matrix C that has both matrices adjacent to one
> another, where matrix A is duplicated many times to create the same
> row number for matrix B, i.e. 16063.
> 
> matrixA matrix B
> matrixA
> matrixA
> 
> so matrix C will be 16063 x 178
> 
> I've tried cbind() and merge() with no success..

A: What the !!##"¤ does this have to do with the subject line?

B: This should do it:

cbind(A[rep(1:217,length=16063),], B)

-- 
   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] Issues with convolve

2005-07-20 Thread Duncan Murdoch
On 7/20/2005 12:52 PM, Vincent Goulet wrote:
> We obtained some disturbing results from convolve() (inaccuracies and 
> negative 
> probabilities). We'll try to make the context clear in as few lines as 
> possible...
> 
> Our function panjer() (code below) basically computes recursively the 
> probability mass function of a compound Poisson distribution. When the 
> Poisson parameter lambda is very large, the starting value of the recursive 
> scheme --- the mass at 0 --- is 0 and the recursion fails. One way to solve 
> this problem is to divide lambda by 2^n, apply the panjer() function and then 
> convolve the result with itself n times.
> 
> We applied the panjer() function with a lambda such that the mass at 0 is 
> just 
> larger than .Machine$double.xmin. We thus know that once this pmf is 
> convoluted with itself, the first probabilities will be 0 (for the computer).
> 
> Here are the two issues we have with convolve():
> 
> 1. The probabilities we know should be 0 are rather in the vicinity of 1E-19, 
> as if convolve() could not "go lower". Using a hand made convolution function 
> (not given here), we obtained the correct values. When probabilities get 
> around 1E-12, results from convolve() and our home made function are 
> essentially identical.
> 
> 2. We obtained negative probabilities. More accurately, the same example 
> returns negative probabilities under Windows, but not under Linux. We also 
> obtained negative probabilities for another example under Linux, though.
> 
> We understand that convolve() computes the convolutions using fft(), but we 
> are not familiar enough with the latter to assess if the above issues are 
> some sort of bugs or normal behavior. In the latter case, is there is any 
> workaround?

Rounding will depend on the hardware and the compiler, so this might be 
normal behaviour.  It's a little disturbing, but you shouldn't expect 
calculations to be accurate to more digits than your platform supports.
Convolving using an FFT is essentially rotating the vectors in a high 
dimensional space, multiplying terms, and then rotating back.  Unless 
those rotations are unrealistically accurate very small numbers won't 
necessarily show up as zeros.

I'd suggest re-thinking your panjer function to work in log 
probabilities instead of probabilities, so that you can handle a larger 
dynamic range before you run into underflow problems, and you don't need 
to use convolve at all. Convert them back to probabilities at the very 
end.

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] Combining two matrices

2005-07-20 Thread Pedro de Barros
Please clarify:
Is there a column of common values that you want to use to merge the two 
matrices together? Or do you just want to replicate matrix A enough times 
to have the same number of rows as B? I could think this was the case, but 
16063 is not a multiple of 217.
Anyway, you will have to change the colnames of at least one of them.

Pedro
At 18:03 20/07/2005, you wrote:
>Can someone please refer me to a function or method that resolves this
>structuring issue:
>
>I have two matrices with identical colnames (89), but varying number
>of observations:
>
>matrix Amatrix B
>
>217 x 89  16063 x 89
>
>I want to creat one matrix C that has both matrices adjacent to one
>another, where matrix A is duplicated many times to create the same
>row number for matrix B, i.e. 16063.
>
>matrixA matrix B
>matrixA
>matrixA
>
>so matrix C will be 16063 x 178
>
>I've tried cbind() and merge() with no success..
>
>__
>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] Is it possible to create highly customized report in *.xls format by using R/S+?

2005-07-20 Thread Greg Snow

When you are forced to use excel (but want to really use R and just 
give the result to others in excel), then there are a few options 
depending on what you are trying to do.  We may be able to give
better help if you can give a specific problem you are trying to
solve.

Some Ideas:

To quickly copy data from excel (highlight a region in excel and
choose
copy then:)

mydata <- read.delim(file('clipboard'))

to send a dataframe or matrix to excel:

write.table(mydata, file('clipboard'), sep="\t")
(now switch to excel, select a cell and choose paste).

You can also look at the RODBC package for other ways to transfer
information back and forth between R and excel.

For more complicated output you may want to look at the R2HTML package
or the LaTeX functions in Hmisc and other packages (then use a latex
to
rtf converter so you end users can read the output in word or copy it
over
to latex).

Another place to look
is:http://cran.us.r-project.org/contrib/extra/dcom/RSrv135.html

This has examples of building functions in excel that will take the
data from
excel, analyze it in R, then bring the results back to excel.

More detail on what you are trying to do would help us help you.

Greg Snow, Ph.D.
Statistical Data Center, LDS Hospital
Intermountain Health Care
[EMAIL PROTECTED]
(801) 408-8111

>>> Wensui Liu <[EMAIL PROTECTED]> 07/20/05 08:55AM >>>
I appreciate your reply and understand your point completely. But at
times we can't change the rule, the only choice is to follow the rule.
Most deliverables in my work are in excel format.

On 7/20/05, Greg Snow <[EMAIL PROTECTED]> wrote:
> See:
> 
> http://www.burns-stat.com/pages/Tutor/spreadsheet_addiction.html 
> and
> http://www.stat.uiowa.edu/~jcryer/JSMTalk2001.pdf 
> 
> Greg Snow, Ph.D.
> Statistical Data Center, LDS Hospital
> Intermountain Health Care
> [EMAIL PROTECTED] 
> (801) 408-8111
> 
> >>> Wensui Liu <[EMAIL PROTECTED]> 07/19/05 03:22PM >>>
> I remember in one slide of Prof. Ripley's presentation overhead, he
> said the most popular data analysis software is excel.
> 
> So is there any resource or tutorial on this topic?
> 
> Thank you so much!
> 
> __
> 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 
> 
> 


-- 
WenSui Liu, MS MA
Senior Decision Support Analyst
Division of Health Policy and Clinical Effectiveness
Cincinnati Children Hospital Medical Center

__
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] Combining two matrices

2005-07-20 Thread mark salsburg
The latter, I want to replicate A enough times to have the same rows
as B. I realize that 16063 is not a mutliple 217, that doesn't really
matter for this problem
Assuming I change the colnames of one of them, how can I create a
matrix C that is the composite of the replicated A with B.

thank you again.

On 7/20/05, Pedro de Barros <[EMAIL PROTECTED]> wrote:
> Please clarify:
> Is there a column of common values that you want to use to merge the two
> matrices together? Or do you just want to replicate matrix A enough times
> to have the same number of rows as B? I could think this was the case, but
> 16063 is not a multiple of 217.
> Anyway, you will have to change the colnames of at least one of them.
> 
> Pedro
> At 18:03 20/07/2005, you wrote:
> >Can someone please refer me to a function or method that resolves this
> >structuring issue:
> >
> >I have two matrices with identical colnames (89), but varying number
> >of observations:
> >
> >matrix Amatrix B
> >
> >217 x 89  16063 x 89
> >
> >I want to creat one matrix C that has both matrices adjacent to one
> >another, where matrix A is duplicated many times to create the same
> >row number for matrix B, i.e. 16063.
> >
> >matrixA matrix B
> >matrixA
> >matrixA
> >
> >so matrix C will be 16063 x 178
> >
> >I've tried cbind() and merge() with no success..
> >
> >__
> >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] predict.lm - standard error of predicted means?

2005-07-20 Thread Prof Brian Ripley

On Wed, 20 Jul 2005, Peter Dalgaard wrote:


mark salsburg <[EMAIL PROTECTED]> writes:


Can someone please refer me to a function or method that resolves this
structuring issue:

I have two matrices with identical colnames (89), but varying number
of observations:

matrix Amatrix B

217 x 89  16063 x 89

I want to creat one matrix C that has both matrices adjacent to one
another, where matrix A is duplicated many times to create the same
row number for matrix B, i.e. 16063.

matrixA matrix B
matrixA
matrixA

so matrix C will be 16063 x 178

I've tried cbind() and merge() with no success..


A: What the !!##"¤ does this have to do with the subject line?

B: This should do it:

cbind(A[rep(1:217,length=16063),], B)


But note that makes 74 + 5/217 copies of A, and I did wonder if that was 
the intention (or if not, what was intended).


--
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] Combining two matrices

2005-07-20 Thread Huntsinger, Reid
If 16063 were an integer multiple of 217 you could do this in two steps;
first construct the left half with rep() or

L <- kronecker(rep(1,16063/217),A)

and then use cbind(L,B).

However, 16063 is not a multiple of 217, so I don't know what you want to do
with the leftover 5 rows you need in L. If you want to recycle rows, you
could use ceiling(16063/217) in the call to rep and then use
cbind(L[1:16063,],B).

Reid Huntsinger

-Original Message-
From: [EMAIL PROTECTED]
[mailto:[EMAIL PROTECTED] On Behalf Of mark salsburg
Sent: Wednesday, July 20, 2005 1:03 PM
To: R-help@stat.math.ethz.ch
Subject: [R] Combining two matrices


Can someone please refer me to a function or method that resolves this
structuring issue:

I have two matrices with identical colnames (89), but varying number
of observations:

matrix Amatrix B

217 x 89  16063 x 89

I want to creat one matrix C that has both matrices adjacent to one
another, where matrix A is duplicated many times to create the same
row number for matrix B, i.e. 16063.

matrixA matrix B
matrixA
matrixA

so matrix C will be 16063 x 178

I've tried cbind() and merge() with no success..

__
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] Combining two matrices

2005-07-20 Thread Pedro de Barros
Hi,

Se if this will solve your question (quick and dirty)...
A is the first matrix, B is the second...

"F.CombineMat" <-
function (A, B)
{
ind<-rep(1:nrow(A),ceiling(nrow(B)/nrow(A)))
ind<-ind[1:nrow(B)]
A<-A[ind,]
colnames(A)<-paste('A', colnames(A), sep='')
R<-cbind(A,B)
R
}
Greetings,
Pedro

At 18:24 20/07/2005, you wrote:
>The latter, I want to replicate A enough times to have the same rows
>as B. I realize that 16063 is not a mutliple 217, that doesn't really
>matter for this problem
>Assuming I change the colnames of one of them, how can I create a
>matrix C that is the composite of the replicated A with B.
>
>thank you again.
>
>On 7/20/05, Pedro de Barros <[EMAIL PROTECTED]> wrote:
> > Please clarify:
> > Is there a column of common values that you want to use to merge the two
> > matrices together? Or do you just want to replicate matrix A enough times
> > to have the same number of rows as B? I could think this was the case, but
> > 16063 is not a multiple of 217.
> > Anyway, you will have to change the colnames of at least one of them.
> >
> > Pedro
> > At 18:03 20/07/2005, you wrote:
> > >Can someone please refer me to a function or method that resolves this
> > >structuring issue:
> > >
> > >I have two matrices with identical colnames (89), but varying number
> > >of observations:
> > >
> > >matrix Amatrix B
> > >
> > >217 x 89  16063 x 89
> > >
> > >I want to creat one matrix C that has both matrices adjacent to one
> > >another, where matrix A is duplicated many times to create the same
> > >row number for matrix B, i.e. 16063.
> > >
> > >matrixA matrix B
> > >matrixA
> > >matrixA
> > >
> > >so matrix C will be 16063 x 178
> > >
> > >I've tried cbind() and merge() with no success..
> > >
> > >__
> > >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] Regression lines for differently-sized groups on the same plot

2005-07-20 Thread Laura M Marx
Sundar Dorai-Raj writes: 

> Hi, Laura, 
> 
> Would ?predict.glm be better? 
> 
> plot(logarea, hempresence,
>  xlab = "Surface area of log (m2)",
>  ylab="Probability of hemlock seedling presence",
>  type="n", font.lab=2, cex.lab=1.5, axes=TRUE)
> lines(logarea, predict(hemhem, logreg, "response"), lty=1, lwd=2)
> lines(logarea, predict(hemyb, logreg, "response"), lty="dashed", lwd=2)
> lines(logarea, predict(hemsm, logreg, "response"), lty="dotted", lwd=2) 
> 
> Without seeing more description of your data, this is still a guess. 
> 
> --sundar 
> 

YES!  Thank you.  That solves all of the problems I was having.  Thanks also 
to Tom Mulholland and Bill Venables for their replies.
 Laura
The final code is now: 

logreg <- read.table("C:/Documents and Settings/Laura/Desktop/logreg.txt", 
header=TRUE, sep=",", na.strings="NA", dec=".", strip.white=TRUE)
#This is the full dataset.  A hemlock row followed by a birch row might look 
#like:
#Hemybsm logareahempresence
#1   0.054  0
#2   1.370  1 

hemhem=glm(hempresence~logarea, family=binomial(logit), subset=Hemybsm<2)
#This pulls out only the hemlocks from the full dataset and calculates the 
#regression.
hemyb=glm(hempresence~logarea, family=binomial(logit), subset=Hemybsm==2)
#Same code, with only the birches from the full dataset.
hemsm=glm(hempresence~logarea, family=binomial(logit), subset=Hemybsm>2) 

plot(logarea, hempresence, xlab = "Surface area of log (m2)",
ylab="Probability of hemlock seedling presence",
type="n", font.lab=2, cex.lab=1.5, axes=TRUE)
lines(logarea, predict(hemhem, logreg, "response"), lty=1, lwd=2)
lines(logarea, predict(hemyb, logreg, "response"), lty="dashed", lwd=2)
lines(logarea, predict(hemsm, logreg, "response"), lty="dotted", lwd=2)

__
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] sciviews installation

2005-07-20 Thread ghjmora g mail
Thanks for the replies

1. about Rcmdr versions
Sorry, I did'nt say wich versions because I tried a lot... before asking 
for help
First I tried the version of the site www.sciviews.org  (0.9-14), after 
I tried the Cran version (1.0-2) and at last I got the 1.1-0 version on 
John Fox's web.
After that, I wrote the message for help...
2. my mistake
 Excuse me, I met the first problem a few months ago with sciviews when 
upgrading the packages on line, and I was hoping for a new version of R 
with correct bindings. I never tried to downgrade the package (shame on me).

3.
Now, I run R2.1.1 patched, with Rcmdr 0.9-17 which  was always here in a 
directory on my computer, because I was not able  to find 0.9-18. The 
result is that SciViews runs, with a little disagreement, but I am so 
happy that I take it like a kind of joke (obliged to load ADE4 in 
SciViews with the command line before use it)


Regards

Georges Moracchini
University of Corsica

__
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] Installation error on Sun Solaris

2005-07-20 Thread Richard Valliant
This is from a colleague who is attempting to install R 2.1.1 on a Sun
machine. I hope this is sufficient information for someone to give us
some pointers.
 
thanks,
Richard
 
Our system is a Sunfire 480 running Solaris V2.8
The LD_LIBRARY_PATH is set
to:/usr/local/bin:/usr/lib:/usr/openwin/libL/opt/SUNWspro/libThe
path:/usr/local/lib does not exist on our server.The configure
results in several errors. The final one states:"Error:
--with-readlines=yes (default) and headers/libs are not available"The
install instructions next indicate that the command "make" is to be ran.
This results in the following message:"make: Fatal error: No arguments
to build" 

[[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] Installation error on Sun Solaris

2005-07-20 Thread Peter Dalgaard
"Richard Valliant" <[EMAIL PROTECTED]> writes:

> This is from a colleague who is attempting to install R 2.1.1 on a Sun
> machine. I hope this is sufficient information for someone to give us
> some pointers.
>  
> thanks,
> Richard
>  
> Our system is a Sunfire 480 running Solaris V2.8
> The LD_LIBRARY_PATH is set
> to:/usr/local/bin:/usr/lib:/usr/openwin/libL/opt/SUNWspro/libThe
> path:/usr/local/lib does not exist on our server.The configure
> results in several errors. The final one states:"Error:
> --with-readlines=yes (default) and headers/libs are not available"

Either install the readline library/headerfiles, or use
--with-readline=no (and live without command line editing).

The
> install instructions next indicate that the command "make" is to be ran.
> This results in the following message:"make: Fatal error: No arguments
> to build" 

Yes, this assumes that the configure step succeeded. 

-- 
   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 with a xyplot legend

2005-07-20 Thread Ronaldo Reis-Jr.
Hi,

I try to put a legend in a xyplot graphic.

xyplot(y~x|g,ylim=c(0,80),xlim=c(10,40),as.table=T,layout=c(2,3), ylab="Número 
de machos capturados",xlab=expression(paste("Temperatura (",degree,"C)")), 
key=list(corner=c(0,0),x=0, y=0, text=list(legenda),lines=list(col=cor, lwd = 
espessura, lty=linha),columns=7,between=0.5,betwen.columns=0.5,cex=0.8))

The problem is that legend is very close do xlab. I try change 
corner=c(0,0),x=0, y=0, to corner=c(0,0),x=0, y=1, but in this way the legend 
dont appear.

How to make the vertical bottom area of the plot bigger to put the legend a 
bit separated of the xlabel?

Thanks
Ronaldo
-- 

O preço da sabedoria é detestar tudo

--Millôr Fernandes
--
|>   // | \\   [***]
|   ( õ   õ )  [Ronaldo Reis Júnior]
|>  V  [UFV/DBA-Entomologia]
|/ \   [36570-000 Viçosa - MG  ]
|>  /(.''`.)\  [Fone: 31-3899-4007 ]
|  /(: :'  :)\ [EMAIL PROTECTED]]
|>/ (`. `'` ) \[ICQ#: 5692561 | LinuxUser#: 205366 ]
|( `-  )   [***]
|>>  _/   \_Powered by GNU/Debian Woody/Sarge

__
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] aregImpute in Hmisc

2005-07-20 Thread Young Cho
Hi,

I have a dataframe ds1.2 - 503 categorial variables
and 1 continuous response variables.  I ran aregImpute
to deal with NA's and got the followig error:

> fmla = terms( Response ~ . ,data=ds1.2)
> ds.i = aregImpute(fmla,data=ds1.2)
Error in matrix(as.double(1), nrow = n, ncol = p,
dimnames = list(rnam,  : 
length of dimnames [2] not equal to array
extent

Could you explain what I should do? Thanks a lot.

Young.

__
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] TURF (total unreplicated reach and frequency) Analysis program

2005-07-20 Thread Lorena Adams
Hi! I am trying to program a TURF analysis and have looked everywhere on the 
web to see if I can find any clues on how to do this. I've looked at SAS 
manuals as well.  If anyone has ever heard of this kind of marketing analysis 
and has programmed it I'd be interested in learning how. Any help you could 
give me is greatly appreciated!
Lorena Adams
 
Lorena Adams
The National Food Laboratory
(925) 785-3855
[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] poisson fit for histogram

2005-07-20 Thread Ben Bolker
Thomas Isenbarger  plantpath.wisc.edu> writes:

> 
> I haven't been an R lister for a bit, but I hope to enlist someone's  
> help here.  I think this is a simple question, so I hope the answer  
> is not much trouble.  Can you please respond directly to this email  
> address in addition to the list (if responding to the list is  
> warranted)?
> 
> I have a histogram and I want to see if the data fit a Poisson  
> distribution.  How do I do this?  It is preferable if it could be  
> done without having to install any or many packages.
> 
> I use R Version 1.12 (1622) on OS X
> 
> Thank-you very much,
> Tom Isenbarger
> 
> --
> Tom Isenbarger PhD
> isen  plantpath.wisc.edu
> 608.265.0850
> 
>   [[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
> 
> 

  by "histogram" do you mean that you have counts for each
non-negative integer?  or are the data more binned than that?
(I'll assume the former since it's slightly easier to deal with.)
Say you have vectors "number" and "count".  The mean of
the sample is meanval <- sum(number*count).  The _expected_ number
of counts in each bin if the distribution is
Poisson is expval <- sum(count)*dpois(number,meanval).
The chi-square statistic is csq <- sum((expval-count)^2/expval), with
df <- length(count)-2 degrees of freedom (for the mean and the total
number of observations).  pchisq(csq,df=df,lower.tail=FALSE)
should give you the chi-squared probability.

  A couple of minor issues: (1) beware, this is shooting from
the hip -- haven't tested at all; (2) you may have to deal
with lumping categories (rule of thumb is that expected number
of counts in a bin should not be < 5).

  Other ways to tackle this: use fitdistr() from MASS with
different candidate distributions (Poisson, neg. bin.) and
do a likelihood ratio test or compare AICs; compare variance and
mean of distribution (much cruder).

See
http://www.zoo.ufl.edu/bolker/emd/probs/ED-4.1.html
for a worked example of a similar problem.

__
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] Is it possible to create highly customized report in *.xls format by using R/S+?

2005-07-20 Thread Gabor Grothendieck
Here is an example where R is the client and Excel is the server 
so that R is issuing commands to Excel.  This example uses the 
RDCOMClient package from www.omegahat.org:

library(RDCOMClient)
xl <- COMCreate("Excel.Application")  # starts up Excel
xl[["Visible"]] <- TRUE   # Excel becomes visible
wkbk <- xl$Workbooks()$Add()  # new workbook

# set some cells

sh <- xl$ActiveSheet()

x12 <- sh$Cells(1,2)
x12[["Value"]] <- 123

x22 <- sh$Cells(2,2)
x22[["Value"]] <- 100

x31 <- sh$Cells(3,1)
x31[["Value"]] <- "Total"

B3R <- sh$Range("B3")
B3R[["Formula"]] <- "=Sum(R1C2:R2C2)"
B3R[["NumberFormat"]] <- "_($* #,##0.00_)"
B3RF <- B3R$Font()
B3RF[["Bold"]] <- TRUE


# save and exit
wkbk$SaveAs("\\test.xls")
xl$Quit()

Code using the rcom package at (second link is mailing list):

http://sunsite.univie.ac.at/rcom/download/
http://mailman.csd.univie.ac.at/pipermail/rcom-l/

would be nearly identical once the upcoming version of rcom comes out.  
rcom and omegahat both provide the possibility of having
Excel as the client and R as the server; however, in that setup the
user would have to have R running whereas in the above setup only you do.

On 7/20/05, Wensui Liu <[EMAIL PROTECTED]> wrote:
> I appreciate your reply and understand your point completely. But at
> times we can't change the rule, the only choice is to follow the rule.
> Most deliverables in my work are in excel format.
> 
> On 7/20/05, Greg Snow <[EMAIL PROTECTED]> wrote:
> > See:
> >
> > http://www.burns-stat.com/pages/Tutor/spreadsheet_addiction.html
> > and
> > http://www.stat.uiowa.edu/~jcryer/JSMTalk2001.pdf
> >
> > Greg Snow, Ph.D.
> > Statistical Data Center, LDS Hospital
> > Intermountain Health Care
> > [EMAIL PROTECTED]
> > (801) 408-8111
> >
> > >>> Wensui Liu <[EMAIL PROTECTED]> 07/19/05 03:22PM >>>
> > I remember in one slide of Prof. Ripley's presentation overhead, he
> > said the most popular data analysis software is excel.
> >
> > So is there any resource or tutorial on this topic?
> >
> > Thank you so much!

__
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] poisson fit for histogram

2005-07-20 Thread Gabor Grothendieck
See ?goodfit in package vcd.


On 7/20/05, Thomas Isenbarger <[EMAIL PROTECTED]> wrote:
> I haven't been an R lister for a bit, but I hope to enlist someone's
> help here.  I think this is a simple question, so I hope the answer
> is not much trouble.  Can you please respond directly to this email
> address in addition to the list (if responding to the list is
> warranted)?
> 
> I have a histogram and I want to see if the data fit a Poisson
> distribution.  How do I do this?  It is preferable if it could be
> done without having to install any or many packages.
> 
> I use R Version 1.12 (1622) on OS X
> 
> Thank-you very much,
> Tom Isenbarger
> 
> 
> --
> Tom Isenbarger PhD
> [EMAIL PROTECTED]
> 608.265.0850
> 
> 
>[[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] Issues with convolve

2005-07-20 Thread Gabor Grothendieck
Check out sum.exact in the caTools package.


On 7/20/05, Vincent Goulet <[EMAIL PROTECTED]> wrote:
> We obtained some disturbing results from convolve() (inaccuracies and negative
> probabilities). We'll try to make the context clear in as few lines as
> possible...
> 
> Our function panjer() (code below) basically computes recursively the
> probability mass function of a compound Poisson distribution. When the
> Poisson parameter lambda is very large, the starting value of the recursive
> scheme --- the mass at 0 --- is 0 and the recursion fails. One way to solve
> this problem is to divide lambda by 2^n, apply the panjer() function and then
> convolve the result with itself n times.
> 
> We applied the panjer() function with a lambda such that the mass at 0 is just
> larger than .Machine$double.xmin. We thus know that once this pmf is
> convoluted with itself, the first probabilities will be 0 (for the computer).
> 
> Here are the two issues we have with convolve():
> 
> 1. The probabilities we know should be 0 are rather in the vicinity of 1E-19,
> as if convolve() could not "go lower". Using a hand made convolution function
> (not given here), we obtained the correct values. When probabilities get
> around 1E-12, results from convolve() and our home made function are
> essentially identical.
> 
> 2. We obtained negative probabilities. More accurately, the same example
> returns negative probabilities under Windows, but not under Linux. We also
> obtained negative probabilities for another example under Linux, though.
> 
> We understand that convolve() computes the convolutions using fft(), but we
> are not familiar enough with the latter to assess if the above issues are
> some sort of bugs or normal behavior. In the latter case, is there is any
> workaround?
> 
> Any help/comments/ideas appreciated.
> 
> === EXAMPLES ===
> panjer <- function(fx, lambda)
> {
>fx0 <- fx[1]
>fx <- fx[-1]
>r <- length(fx)
>cumul <- fs <- exp(-lambda * (1 - fx0))
>repeat
>{
>x <- length(fs)
>m <- min(x, r)
>fs <- c(fs, sum((lambda * 1:m / x) * head(fx, m) * rev(tail(fs, m
>if ((1-1E-8) < (cumul <- cumul + tail(fs, 1)))
>break
>}
>fs
> }
> 
> ### Linux example ###
> > R.version
> _
> platform i386-pc-linux-gnu
> arch i386
> os   linux-gnu
> system   i386, linux-gnu
> status
> major2
> minor1.0
> year 2005
> month04
> day  18
> language R
> > fs <- panjer(rep(0.2, 5), 600)  # compute pmf
> > fs[1:10]# small values
>  [1] 3.456597e-209 4.147916e-207 2.530229e-205 1.045690e-203
>  [5] 3.292657e-202 8.422924e-201 1.822768e-199 3.431181e-198
>  [9] 5.733481e-197 8.637025e-196
> > fsc <- convolve(fs, rev(fs), type="o")  # convolution
> > sum(fsc < 0)# no negatives under Linux
> [1] 0
> > fsc[1:10]   # these should be 0
>  [1] 4.819870e-19 4.135471e-19 4.511455e-19 3.994485e-19 3.820177e-19
>  [6] 4.738272e-19 3.885447e-19 3.167399e-19 3.695636e-19 3.701792e-19
> > sum(fsc)# no impact on the sum
> [1] 1
> 
> ### Windows example ###
> > R.version
> _
> platform i386-pc-mingw32
> arch i386
> os   mingw32
> system   i386, mingw32
> status
> major2
> minor1.1
> year 2005
> month06
> day  20
> language R
> > fs <- panjer(rep(0.2, 5), 600)  # compute pmf
> > fs[1:10]# small values
>  [1] 3.456597e-209 4.147916e-207 2.530229e-205 1.045690e-203
>  [5] 3.292657e-202 8.422924e-201 1.822768e-199 3.431181e-198
>  [9] 5.733481e-197 8.637025e-196
> > fsc <- convolve(fs, rev(fs), type="o")  # convolution
> > sum(fsc < 0)# negatives under Windows
> [1] 39
> > fsc[1:10]   # these should be 0
>  [1] 4.049552e-19 3.345584e-19 4.126913e-19 3.351211e-19 2.758626e-19
>  [6] 3.530111e-19 2.735041e-19 2.376711e-19 2.591287e-19 3.196405e-19
> > sum(fsc)# no impact on the sum
> [1] 1
> 
> --
>  Vincent Goulet, Associate Professor
>  École d'actuariat
>  Université Laval, Québec
>  [EMAIL PROTECTED]   http://vgoulet.act.ulaval.ca
> 
> __
> 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] Taking the derivative of a quadratic B-spline

2005-07-20 Thread James McDermott
Thanks a lot for the input on this Professor Murdoch.  I really
appreciate all the help.

Regards,
Jim

On 7/20/05, Duncan Murdoch <[EMAIL PROTECTED]> wrote:
> James McDermott wrote:
> > Would the unique quadratic defined by the three points be the same
> > curve as the curve predicted by a quadratic B-spline (fit to all of
> > the data) through those same three points?
> 
> Yes, if you restrict attention to an interval between knots.  You'll
> need to re-evaluate it for each such interval (but since quadratic
> splines are continuous, you can reuse evaluations at the knots, and you
> just need one new point in each interval).
> 
>  From a practical point of view, you need to make sure that COBS really
> is giving you a quadratic spline and really is reporting all of the
> knots correctly.  Watch out for coincident knots (zero length
> intervals); you don't care about the derivative on those, but they might
> cause overflows in some calculations.
> 
> Duncan Murdoch
> >
> > Jim
> >
> > On 7/19/05, Duncan Murdoch <[EMAIL PROTECTED]> wrote:
> >
> >>On 7/19/2005 3:34 PM, James McDermott wrote:
> >>
> >>>I wish it were that simple (perhaps it is and I am just not seeing
> >>>it).  The output from cobs( ) includes the B-spline coefficients and
> >>>the knots.  These coefficients are not the same as the a, b, and c
> >>>coefficients in a quadratic polynomial.  Rather, they are the
> >>>coefficients of the quadratic B-spline representation of the fitted
> >>>curve.  I need to evaluate a linear combination of basis functions and
> >>>it is not clear to me how to accomplish this easily.  I was hoping to
> >>>find an alternative way of getting the derivatives.
> >>
> >>I don't know COBS, but doesn't predict just evaluate the B-spline?  The
> >>point of what I posted is that the particular basis doesn't matter if
> >>you can evaluate the quadratic at 3 points.
> >>
> >>Duncan Murdoch
> >>
> >>
> >>>Jim McDermott
> >>>
> >>>On 7/19/05, Duncan Murdoch <[EMAIL PROTECTED]> wrote:
> >>>
> On 7/19/2005 2:53 PM, James McDermott wrote:
> 
> >Hello,
> >
> >I have been trying to take the derivative of a quadratic B-spline
> >obtained by using the COBS library.  What I would like to do is
> >similar to what one can do by using
> >
> >fit<-smooth.spline(cdf)
> >xx<-seq(-10,10,.1)
> >predict(fit, xx, deriv = 1)
> >
> >The goal is to fit the spline to data that is approximating a
> >cumulative distribution function (e.g. in my example, cdf is a
> >2-column matrix with x values in column 1 and the estimate of the cdf
> >evaluated at x in column 2) and then take the first derivative over a
> >range of values to get density estimates.
> >
> >The reason I don't want to use smooth.spline is that there is no way
> >to impose constraints (e.g. >=0, <=1, and monotonicity) as there is
> >with COBS.  However, since COBS doesn't have the 'deriv =' option, the
> >only way I can think of doing it with COBS is to evaluate the
> >derivatives numerically.
> 
> Numerical estimates of the derivatives of a quadratic should be easy to
> obtain accurately.  For example, if the quadratic ax^2 + bx + c is
> defined on [-1, 1], then the derivative 2ax + b, has 2a = f(1) - f(0) +
> f(-1), and b = (f(1) - f(-1))/2.
> 
> You should be able to generalize this to the case where the spline is
> quadratic between knots k1 and k2 pretty easily.
> 
> 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


[R] Clustered standard errors in a panel

2005-07-20 Thread Thomas Davidoff
I want to do the following:

glm(y ~ x1 + x2 +...)
within a panel.  Hence y, x1, and x2 all vary at the individual  
level.  However, there is likely correlation of these variables  
within an individual, so standard errors need adjustment.
I do not want to estimate fixed effects, but do want to cluster  
standard errors at the individual level.
Is there an automated way to do this?  Nothing in the cluster  
documentation makes it clear that there is.

(An alternative is to do this by hand.  In that case, I would need to  
be able to calculate weighted sums of x1 and x2... at the individual  
level.  I can do this at the variable level [with lapply,split and  
unsplit], but would love to be able to do so over the matrix of x's.   
Of course, doing by hand is less easy than an automated solution if  
it exists.)


Thomas Davidoff
Assistant Professor
Haas School of Business
UC Berkeley
Berkeley, CA 94720
phone: (510) 643-1425
fax:(510) 643-7357
[EMAIL PROTECTED]
http://faculty.haas.berkeley.edu/davidoff


[[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] aregImpute in Hmisc

2005-07-20 Thread Frank E Harrell Jr
Young Cho wrote:
> Hi,
> 
> I have a dataframe ds1.2 - 503 categorial variables
> and 1 continuous response variables.  I ran aregImpute
> to deal with NA's and got the followig error:
> 
> 
>>fmla = terms( Response ~ . ,data=ds1.2)
>>ds.i = aregImpute(fmla,data=ds1.2)
> 
> Error in matrix(as.double(1), nrow = n, ncol = p,
> dimnames = list(rnam,  : 
> length of dimnames [2] not equal to array
> extent
> 
> Could you explain what I should do? Thanks a lot.
> 
> Young.

Without a small reproducible example (using for example simulated data) 
I can't solve it.  You may have trouble using aregImpute with that many 
variables.  -Frank Harrell

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


-- 
Frank E Harrell Jr   Professor and Chair   School of Medicine
  Department of Biostatistics   Vanderbilt University

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

2005-07-20 Thread Dr L. Y Hin

Dear all,

I am in the process of migrating an S programme library to R, and it 
involves the family entity.


I have checked ?family but it does not give much detail of its components.
I will be very grateful if anyone can point towards sources/ways to look up 
on this areas

with an aim to find the equivalance of the followings in S:
family()$inverse
family()$deriv
family()$variance
family()$deviance t


Thank you
Lin

__
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] The steps of building library in R 2.1.1

2005-07-20 Thread Ivy_Li
Dear All,

With the warm support of every R expert, I have built my R library 
successfully. 
Especially thanks: Duncan Murdoch
Gabor Grothendieck   
Henrik Bengtsson
Uwe Ligges
Without your help, I will lower efficiency.
I noticed that some other friends were puzzled by the method of building 
library. Now, I organize a document about it. Hoping it can help more friends.

1. Read the webpage  
2. Download the "rw2011.exe"; Install the newest version of R
3. Download the "tools.zip"; Unpack it into c:\cygwin
4. Download the "ActivePerl-5.6.1.633-MSWin32-x86.msi"; Install Active Perl in 
c:\Perl
5. Download the "MinGW-3.1.0-1.exe"; Install the mingw32 port of gcc in 
c:\mingwin
6. Then go to "Control Panel -> System -> Advanced -> Environment Variables -> 
Path -> Variable Balue"; add "c:\cygwin;c:\mingwin\bin" 
The PATH variable already contains a couple of paths, add the two given 
above in front of all others, separated by ";". 
Why we add them in the beginning of the path? Because we want the 
folder that contains the tools to be at the beginning so that you eliminate the 
possibility of finding a different program of the same name first in a folder 
that comes prior to the one where the tools are stored.

7. I use the package.skeleton() function to make a draft package. It will 
automate some of the setup for a new source package. It creates directories, 
saves functions anddata to appropriate places, and creates skeleton help 
files and 'README' files describing further steps in packaging.
I type in R:
>f <- function(x,y) x+y
>g <- function(x,y) x-y
>d <- data.frame(a=1, b=2)
>e <- rnorm(1000)
>package.skeleton(list=c("f","g","d","e"), name="example")
Then modify the 'DESCRIPTION':
Package: example
Version: 1.0-1
Date: 2005-07-09
Title: My first function
Author: Ivy <[EMAIL PROTECTED]>
Maintainer: Ivy <[EMAIL PROTECTED]>
Description: simple sum and subtract
License: GPL version 2 or later
Depends: R (>= 1.9), stats, graphics, utils
You can refer to the web page: 
http://cran.r-project.org/src/contrib/Descriptions/  There are larger source of 
examples. And you can read the part of 'Creating R Packages' in 'Writing R 
Extension'. It introduces some useful things for your reference. 

8. Download hhc.exe Microsoft help compiler from somewhere. And save it 
somewhere in your path.
I download a 'htmlhelp.exe' and setup. saved the hhc.exe into the 
'C:\cygwin\bin' because this path has been writen in my PATH Variable Balue.
However if you decided not to use the Help Compiler (hhc), then you need to 
modify the MkRules file in RHOME/src/gnuwin32 to tell it not to try to build 
that kind of help file

9. In the DOS environment. Into the "D:\>"  Type the following code: 
cd \Program Files\R\rw2010 
bin\R CMD INSTALL "/Program Files/R/rw2011/example"
Firstly, because I install the new version R in the D:\Program Files\. So I 
should first into the D drive. Secondly, because I use the package.skeleton() 
function to build 'example' package in the path of D:\Program Files\R\rw2011\  
So I must tell R the path where saved the 'example' package. So I write the 
code is like that. If your path is different from me, you should modify part of 
these code.

10.Finally, this package is successfully built up.

  -- Making package example 
  adding build stamp to DESCRIPTION
  installing R files
  installing data files
  installing man source files
  installing indices
  not zipping data
  installing help
 >>> Building/Updating help pages for package 'example'
 Formats: text html latex example chm
  d texthtmllatex   example
  e texthtmllatex   example
  f texthtmllatex   example
  g texthtmllatex   example
  adding MD5 sums

* DONE (example)

I was very happy to get the great results. I hope the document can help you. 
Thank you again for everyone's support.


Best Regards!
Ivy Li(李琛)
YMS in Production & Testing
Semiconductor Manufactory International(ShangHai) Corporation
#18 ZhangJiang Road, PuDong New Area, Shanghai, China
Tel: 021-5080-2000 *11754
Email: [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] about confounded variances in NESTED and SPLIT PLOT designs

2005-07-20 Thread klebyn
All R users

We observed that for the NESTED DESIGN there is a junction of the 
variable effects randomic that impede the separation of the values of 
these variance components.

Does this also happen in the SPLIT-PLOT method?

Is there junction between main plot error and replicate error?

There is a junction among the main-plot error and the replicatas that 
would impede the determination of these components separately? Is there 
the same effect for SPD?

How to simulate data with values control for each error contribution?

Thanks a lot

Kleber Borges and João Bort

__
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] cut in R

2005-07-20 Thread Steve Su
Dear All, 

I wonder whether it is still valid to use the following R code for cut. All I 
have done is changed:

   if (is.na(breaks) | breaks < 2) 

to:
 
   if (is.na(breaks) | breaks < 1)

so that it covers interval of 1?  

It seems okay for my purposes but I am not sure why R specifically does not 
allow break<2 to happen.

Steve.





cut.default<-
function (x, breaks, labels = NULL, include.lowest = FALSE, right = TRUE, 
dig.lab = 3, ...) 
{
if (!is.numeric(x)) 
stop("'x' must be numeric")
if (length(breaks) == 1) {
if (is.na(breaks) | breaks < 1) 
stop("invalid number of intervals")
nb <- as.integer(breaks + 1)
dx <- diff(rx <- range(x, na.rm = TRUE))
if (dx == 0) 
dx <- rx[1]
breaks <- seq(rx[1] - dx/1000, rx[2] + dx/1000, len = nb)
}
else nb <- length(breaks <- sort(breaks))
if (any(duplicated(breaks))) 
stop("'breaks' are not unique")
codes.only <- FALSE
if (is.null(labels)) {
for (dig in dig.lab:max(12, dig.lab)) {
ch.br <- formatC(breaks, digits = dig, wid = 1)
if (ok <- all(ch.br[-1] != ch.br[-nb])) 
break
}
labels <- if (ok) 
paste(if (right) 
"("
else "[", ch.br[-nb], ",", ch.br[-1], if (right) 
"]"
else ")", sep = "")
else paste("Range", 1:(nb - 1), sep = "_")
if (ok && include.lowest) {
if (right) 
substr(labels[1], 1, 1) <- "["
else substring(labels[nb - 1], nchar(labels[nb - 
1], type = "char")) <- "]"
}
}
else if (is.logical(labels) && !labels) 
codes.only <- TRUE
else if (length(labels) != nb - 1) 
stop("labels/breaks length conflict")
code <- .C("bincode", x = as.double(x), n = as.integer(length(x)), 
breaks = as.double(breaks), as.integer(nb), code = integer(length(x)), 
right = as.logical(right), include = as.logical(include.lowest), 
naok = TRUE, NAOK = TRUE, DUP = FALSE, PACKAGE = "base")$code
if (codes.only) 
code
else factor(code, seq(labels), labels)
}



**

 Steve Su ([EMAIL PROTECTED])
 Postdoctoral fellow

 Faculty of Business 
 Queensland University of Technology  
 
 Postal Address: Steve Su, School of Accountancy, QUT, PO Box 2434, Brisbane, 
 Queensland, Australia, 4001.   

 CRICOS No. 00213J 
 
 Phone:  +61 7 3864 4357
 Fax:+61 7 3864 1812  
 Mobile: 0421  840  586  
 .   
   _--_|\  
  /  QUT   
  \_.--._/  
 
v   
  
**
   
[[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] poisson fit for histogram

2005-07-20 Thread Vito Ricci
Hi,

see: 

http://cran.r-project.org/doc/contrib/Ricci-distributions-en.pdf

Regards,

Vito


Thomas Isenbarger isen at plantpath.wisc.edu 
wrote:
I haven't been an R lister for a bit, but I hope to
enlist someone's  
help here.  I think this is a simple question, so I
hope the answer  
is not much trouble.  Can you please respond directly
to this email  
address in addition to the list (if responding to the
list is  
warranted)?

I have a histogram and I want to see if the data fit a
Poisson  
distribution.  How do I do this?  It is preferable if
it could be  
done without having to install any or many packages.

I use R Version 1.12 (1622) on OS X

Thank-you very much,
Tom Isenbarger


--
Tom Isenbarger PhD
[EMAIL PROTECTED]
608.265.0850


Diventare costruttori di soluzioni
Became solutions' constructors

"The business of the statistician is to catalyze 
the scientific learning process."  
George E. P. Box

"Statistical thinking will one day be as necessary for efficient citizenship as 
the ability to read and write"
H. G. Wells

Top 10 reasons to become a Statistician

 1. Deviation is considered normal
 2. We feel complete and sufficient
 3. We are 'mean' lovers
 4. Statisticians do it discretely and continuously
 5. We are right 95% of the time
 6. We can legally comment on someone's posterior distribution
 7. We may not be normal, but we are transformable
 8. We never have to say we are certain
 9. We are honestly significantly different
10. No one wants our jobs


Visitate il portale http://www.modugno.it/
e in particolare la sezione su Palese  
http://www.modugno.it/archivio/palesesanto_spirito/

__
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] Clustered standard errors in a panel

2005-07-20 Thread Spencer Graves
  Have you considered "lmer" in library(lme4)?  If you are interested 
in this, you may want to check the article by Doug Bates in the latest R 
news, www.r-project.org -> Documentation:  Newsletter.

  spencer graves

Thomas Davidoff wrote:

> I want to do the following:
> 
> glm(y ~ x1 + x2 +...)
> within a panel.  Hence y, x1, and x2 all vary at the individual  
> level.  However, there is likely correlation of these variables  
> within an individual, so standard errors need adjustment.
> I do not want to estimate fixed effects, but do want to cluster  
> standard errors at the individual level.
> Is there an automated way to do this?  Nothing in the cluster  
> documentation makes it clear that there is.
> 
> (An alternative is to do this by hand.  In that case, I would need to  
> be able to calculate weighted sums of x1 and x2... at the individual  
> level.  I can do this at the variable level [with lapply,split and  
> unsplit], but would love to be able to do so over the matrix of x's.   
> Of course, doing by hand is less easy than an automated solution if  
> it exists.)
> 
> 
> Thomas Davidoff
> Assistant Professor
> Haas School of Business
> UC Berkeley
> Berkeley, CA 94720
> phone: (510) 643-1425
> fax:(510) 643-7357
> [EMAIL PROTECTED]
> http://faculty.haas.berkeley.edu/davidoff
> 
> 
>   [[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

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

2005-07-20 Thread Prof Brian Ripley
You want to aim to write a family for R, not find the equivalents of S 
constructs -- they are different and so exact equivalents do not exist. 
In particular, an R family has several components which an S family does 
not.

There are lots of example families for you to follow (e.g. see ?family and 
the negative binomial families in the MASS package).  Others have found 
reading the sources sufficient to write new families.

On Thu, 21 Jul 2005, Dr L. Y Hin wrote:

> I am in the process of migrating an S programme library to R, and it involves 
> the family entity.
>
> I have checked ?family but it does not give much detail of its components.
> I will be very grateful if anyone can point towards sources/ways to look up 
> on this areas
> with an aim to find the equivalance of the followings in S:
> family()$inverse
> family()$deriv
> family()$variance
> family()$deviance t


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


  1   2   >