Re: [R] Inconsistent linear model calculations

2008-05-16 Thread e-letter
For the record, v6 represented the averages for columns v3-v5 because
I could not quickly find the r instruction to calculate the average.
Similiarly v7 represents  square power of v2. At the time it was
quicker than trawling through five or so user manuals for the formula
syntax.

__
R-help@r-project.org mailing list
https://stat.ethz.ch/mailman/listinfo/r-help
PLEASE do read the posting guide http://www.R-project.org/posting-guide.html
and provide commented, minimal, self-contained, reproducible code.


[R] gamma parameters fitted

2008-05-16 Thread KOITA Lassana - STAC/ACE
Hi R-users,
I'm fitting gamma parameters (shape and rate ) by two methods (by direct 
and and fitdistr of MASS library). I have realized the following code 
which gives me two results. However, I find that those two outcomes are 
significantly different. Is there any explanation to this case? Many 
thanks in advance for your help

> param <- function(y)
+ 
+ {
+ library(MASS)
+ 
+ b <- subset(tab[!is.na(tab$DVTDR) & (tab$DVTDR > 0),], IDAV<= y )
+ 
+ z <- b$DVTDR
+ 
+ m <- mean(z)
+ 
+ v <- var(z)
+ 
+ para1 <- list(shape = m^2/v, rate = m/v)
+ 
+ para2 <- fitdistr(z, "gamma")
+ 
+ return(list(para1,para2)) 
+ 
+ }
> 
> param("321")
[[1]]
[[1]]$shape
[1] 1.603642

[[1]]$rate
[1] 1.286430


[[2]]
 shape rate 
  1.81991260   1.45992004 
 (0.02503046) (0.02309113)

##

Lassana KOITA 

E-mail: [EMAIL PROTECTED]
http://www.stac.aviation-civile.gouv.fr/
[[alternative HTML version deleted]]

__
R-help@r-project.org mailing list
https://stat.ethz.ch/mailman/listinfo/r-help
PLEASE do read the posting guide http://www.R-project.org/posting-guide.html
and provide commented, minimal, self-contained, reproducible code.


[R] How to swap and rearrange rows?

2008-05-16 Thread Roslina Zakaria
Dear R-expert,
How to swap and rearrange the row so that I will have
Jan-Dec in order?
> est31
    p0 est.alpha est.beta  est.rate
Jan  0.8802867 0.7321440 7.241757 0.1380880
Mar  0.8598566 0.7096567 7.376367 0.1355681
May  0.6204301 0.8657272 6.036106 0.1656697
July 0.5032258 0.9928488 4.027408 0.2482986
Aug  0.5322581 0.9625738 4.103121 0.2437169
Oct  0.6792115 0.8526226 5.105218 0.1958780
Dec  0.8397849 0.7490287 7.070349 0.1414357
> est30
    p0 est.alpha est.beta  est.rate
Apr  0.7296296 0.7929348 6.303877 0.1586325
Jun  0.5574074 0.8588608 5.695905 0.1755647
Sept 0.607 0.9031150 4.594891 0.2176330
Nov  0.7725926 0.7600906 5.636366 0.1774193
> est28
  p0 est.alpha est.beta  est.rate
Feb 0.877262 0.6567584 8.708051 0.1148363
Thank you so much.




__
R-help@r-project.org mailing list
https://stat.ethz.ch/mailman/listinfo/r-help
PLEASE do read the posting guide http://www.R-project.org/posting-guide.html
and provide commented, minimal, self-contained, reproducible code.


Re: [R] How to swap and rearrange rows?

2008-05-16 Thread Richard . Cotton
> How to swap and rearrange the row so that I will have
> Jan-Dec in order?
> > est31
> p0 est.alpha est.beta  est.rate
> Jan  0.8802867 0.7321440 7.241757 0.1380880
> Mar  0.8598566 0.7096567 7.376367 0.1355681
> May  0.6204301 0.8657272 6.036106 0.1656697
> July 0.5032258 0.9928488 4.027408 0.2482986
> Aug  0.5322581 0.9625738 4.103121 0.2437169
> Oct  0.6792115 0.8526226 5.105218 0.1958780
> Dec  0.8397849 0.7490287 7.070349 0.1414357
> > est30
> p0 est.alpha est.beta  est.rate
> Apr  0.7296296 0.7929348 6.303877 0.1586325
> Jun  0.5574074 0.8588608 5.695905 0.1755647
> Sept 0.607 0.9031150 4.594891 0.2176330
> Nov  0.7725926 0.7600906 5.636366 0.1774193
> > est28
>   p0 est.alpha est.beta  est.rate
> Feb 0.877262 0.6567584 8.708051 0.1148363
> Thank you so much.

First, concatenate the data frames:
est <- cbind(est31, est30, est28)

Now you can sort the resulting data frame using order, as described in FAQ 
on R 7.23.
months <- factor(rownames(est), levels=c("Jan", "Feb", "Mar", "Apr", 
"May", "Jun", "July", "Aug", "Sept", "Oct", "Nov", "Dec"))
sortedest <- est[order(months),]

(You might also want to recode 'July' to 'Jul' and 'Sept' to 'Sep' to be 
consistent with the other months.)

Regards,
Richie.

Mathematical Sciences Unit
HSL



ATTENTION:

This message contains privileged and confidential inform...{{dropped:20}}

__
R-help@r-project.org mailing list
https://stat.ethz.ch/mailman/listinfo/r-help
PLEASE do read the posting guide http://www.R-project.org/posting-guide.html
and provide commented, minimal, self-contained, reproducible code.


[R] Getting JRI/rJava to work

2008-05-16 Thread john seers (IFR)

Hello All

I am trying to get the JRI examples from rJava to work on Windows XP and
failing. (And as a more general and connected question is there any
review/summary of front-end software for R?)

I have installed rJava from the Windows binary supplied. I compile and
run the example supplied (rtest.java) and get the results below. I do
not think the notes about a deprecated API are a problem. But I do not
know what causes the unsupported conversion messages.

Versions used etc below.

Any ideas please? Thanks for any help.

Regards


John Seers




C:\temp\JRI\examples>javac -cp "C:/Program
Files/R/mylibrary/rJava/jri/JRI.jar" rtest.java
Note: rtest.java uses or overrides a deprecated API.
Note: Recompile with -Xlint:deprecation for details.

C:\temp\JRI\examples>java -Djava.library.path="C:/Program
Files/R/mylibrary/rJava/jri" -cp .;"C:/Program
Files/R/mylibrary/rJava/jri/JRI.jar" rtest
Creating Rengine (with arguments)
Error in structure(.Internal(Sys.getenv(as.character(x),
as.character(unset))),  :
  unsupported conversion

R version 2.7.0 (2008-04-22)
Copyright (C) 2008 The R Foundation for Statistical Computing
ISBN 3-900051-07-0

R is free software and comes with ABSOLUTELY NO WARRANTY.
You are welcome to redistribute it under certain conditions.
Type 'license()' or 'licence()' for distribution details.

  Natural language support but running in an English locale

R is a collaborative project with many contributors.
Type 'contributors()' for more information and
'citation()' on how to cite R or R packages in publications.

Type 'demo()' for some demos, 'help()' for on-line help, or
'help.start()' for an HTML browser interface to help.
Type 'q()' to quit R.

Error in file.info(lib.loc) : unsupported conversion in
'filenameToWchar'
Error in file.exists(name) : unsupported conversion in 'filenameToWchar'
rShowMessage "Fatal error: unable to restore saved data in .RData

"

C:\temp\JRI\examples>


##


C:\temp\JRI\examples>which java
/cygdrive/c/Program Files/Java/jdk1.6.0_06/bin/java

C:\temp\JRI\examples>which javac
/cygdrive/c/Program Files/Java/jdk1.6.0_06/bin/javac

C:\temp\JRI\examples>

> sessionInfo()
R version 2.7.0 (2008-04-22) 
i386-pc-mingw32 

locale:
LC_COLLATE=English_United Kingdom.1252;LC_CTYPE=English_United
Kingdom.1252;LC_MONETARY=English_United
Kingdom.1252;LC_NUMERIC=C;LC_TIME=English_United Kingdom.1252

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


other attached packages:
[1] rJava_0.5-1   RWinEdt_1.8-0
> 



---

__
R-help@r-project.org mailing list
https://stat.ethz.ch/mailman/listinfo/r-help
PLEASE do read the posting guide http://www.R-project.org/posting-guide.html
and provide commented, minimal, self-contained, reproducible code.


Re: [R] How to swap and rearrange rows?

2008-05-16 Thread Abhijit Dasgupta
Another possibility:
# Generate the months in sequential order:
m <- months(seq(as.Date('2000/1/1'), by='month',length=12),abbreviate=T)
# Concatenate the data
est=rbind(est31,est30,est28)
# generate the right order
ind <- match(substr(rownames(est),1,3),m)
# reorder the rows
est <- est[ind,]

BTW, Richard meant "rbind" instead of "cbind" in his code, which I'm sure you 
knew.

Abhijit

On Fri, 16 May 2008 10:09:22 +0100
[EMAIL PROTECTED] wrote:

> > How to swap and rearrange the row so that I will have
> > Jan-Dec in order?
> > > est31
> > p0 est.alpha est.beta  est.rate
> > Jan  0.8802867 0.7321440 7.241757 0.1380880
> > Mar  0.8598566 0.7096567 7.376367 0.1355681
> > May  0.6204301 0.8657272 6.036106 0.1656697
> > July 0.5032258 0.9928488 4.027408 0.2482986
> > Aug  0.5322581 0.9625738 4.103121 0.2437169
> > Oct  0.6792115 0.8526226 5.105218 0.1958780
> > Dec  0.8397849 0.7490287 7.070349 0.1414357
> > > est30
> > p0 est.alpha est.beta  est.rate
> > Apr  0.7296296 0.7929348 6.303877 0.1586325
> > Jun  0.5574074 0.8588608 5.695905 0.1755647
> > Sept 0.607 0.9031150 4.594891 0.2176330
> > Nov  0.7725926 0.7600906 5.636366 0.1774193
> > > est28
> >   p0 est.alpha est.beta  est.rate
> > Feb 0.877262 0.6567584 8.708051 0.1148363
> > Thank you so much.
> 
> First, concatenate the data frames:
> est <- cbind(est31, est30, est28)
> 
> Now you can sort the resulting data frame using order, as described in FAQ 
> on R 7.23.
> months <- factor(rownames(est), levels=c("Jan", "Feb", "Mar", "Apr", 
> "May", "Jun", "July", "Aug", "Sept", "Oct", "Nov", "Dec"))
> sortedest <- est[order(months),]
> 
> (You might also want to recode 'July' to 'Jul' and 'Sept' to 'Sep' to be 
> consistent with the other months.)
> 
> Regards,
> Richie.
> 
> Mathematical Sciences Unit
> HSL
> 
> 
> 
> ATTENTION:
> 
> This message contains privileged and confidential info...{{dropped:12}}

__
R-help@r-project.org mailing list
https://stat.ethz.ch/mailman/listinfo/r-help
PLEASE do read the posting guide http://www.R-project.org/posting-guide.html
and provide commented, minimal, self-contained, reproducible code.


Re: [R] Getting JRI/rJava to work

2008-05-16 Thread Prof Brian Ripley

On Fri, 16 May 2008, john seers (IFR) wrote:



Hello All

I am trying to get the JRI examples from rJava to work on Windows XP and
failing. (And as a more general and connected question is there any
review/summary of front-end software for R?)

I have installed rJava from the Windows binary supplied. I compile and
run the example supplied (rtest.java) and get the results below. I do
not think the notes about a deprecated API are a problem. But I do not
know what causes the unsupported conversion messages.


Trying to run R in a non-existent locale (or at least in a charset iconv() 
does not understand).  However, your example (with suitably modified 
paths) does work for me in apparently the same locale, so I cannot debug 
it for you.


I do think the R posting guide clearly indicates this as off-topic for 
R-help -- it is a non-R programming issue involving a contributed package.




Versions used etc below.

Any ideas please? Thanks for any help.

Regards


John Seers




C:\temp\JRI\examples>javac -cp "C:/Program
Files/R/mylibrary/rJava/jri/JRI.jar" rtest.java
Note: rtest.java uses or overrides a deprecated API.
Note: Recompile with -Xlint:deprecation for details.

C:\temp\JRI\examples>java -Djava.library.path="C:/Program
Files/R/mylibrary/rJava/jri" -cp .;"C:/Program
Files/R/mylibrary/rJava/jri/JRI.jar" rtest
Creating Rengine (with arguments)
Error in structure(.Internal(Sys.getenv(as.character(x),
as.character(unset))),  :
 unsupported conversion

R version 2.7.0 (2008-04-22)
Copyright (C) 2008 The R Foundation for Statistical Computing
ISBN 3-900051-07-0

R is free software and comes with ABSOLUTELY NO WARRANTY.
You are welcome to redistribute it under certain conditions.
Type 'license()' or 'licence()' for distribution details.

 Natural language support but running in an English locale

R is a collaborative project with many contributors.
Type 'contributors()' for more information and
'citation()' on how to cite R or R packages in publications.

Type 'demo()' for some demos, 'help()' for on-line help, or
'help.start()' for an HTML browser interface to help.
Type 'q()' to quit R.

Error in file.info(lib.loc) : unsupported conversion in
'filenameToWchar'
Error in file.exists(name) : unsupported conversion in 'filenameToWchar'
rShowMessage "Fatal error: unable to restore saved data in .RData

"

C:\temp\JRI\examples>


##


C:\temp\JRI\examples>which java
/cygdrive/c/Program Files/Java/jdk1.6.0_06/bin/java

C:\temp\JRI\examples>which javac
/cygdrive/c/Program Files/Java/jdk1.6.0_06/bin/javac

C:\temp\JRI\examples>


sessionInfo()

R version 2.7.0 (2008-04-22)
i386-pc-mingw32

locale:
LC_COLLATE=English_United Kingdom.1252;LC_CTYPE=English_United
Kingdom.1252;LC_MONETARY=English_United
Kingdom.1252;LC_NUMERIC=C;LC_TIME=English_United Kingdom.1252

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


other attached packages:
[1] rJava_0.5-1   RWinEdt_1.8-0






---

__
R-help@r-project.org mailing list
https://stat.ethz.ch/mailman/listinfo/r-help
PLEASE do read the posting guide http://www.R-project.org/posting-guide.html
and provide commented, minimal, self-contained, reproducible code.



--
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@r-project.org mailing list
https://stat.ethz.ch/mailman/listinfo/r-help
PLEASE do read the posting guide http://www.R-project.org/posting-guide.html
and provide commented, minimal, self-contained, reproducible code.


Re: [R] Inconsistent linear model calculations

2008-05-16 Thread Petr PIKAL
Hi

Maybe you shall reconsider your decision to avoid manuals especially 
R-intro.pdf, where you can learn basic operations and data structures. 

[EMAIL PROTECTED] napsal dne 16.05.2008 09:52:22:

> For the record, v6 represented the averages for columns v3-v5 because
> I could not quickly find the r instruction to calculate the average.

Did you try ?mean. You could get to it in seconds if you used

help.search("average")
and then from ave page there is direct link to mean.

> Similiarly v7 represents  square power of v2. At the time it was

In many programs n^m means to m'th power of n.

Least but not last the problem **was not** in R but in your data, as was 
suggested originally by D.Bates.

Regards
Petr

> quicker than trawling through five or so user manuals for the formula
> syntax.
> 
> __
> R-help@r-project.org mailing list
> https://stat.ethz.ch/mailman/listinfo/r-help
> PLEASE do read the posting guide 
http://www.R-project.org/posting-guide.html
> and provide commented, minimal, self-contained, reproducible code.

__
R-help@r-project.org mailing list
https://stat.ethz.ch/mailman/listinfo/r-help
PLEASE do read the posting guide http://www.R-project.org/posting-guide.html
and provide commented, minimal, self-contained, reproducible code.


[R] Fedora 9?

2008-05-16 Thread Jonathan Baron
Not to be impatient, but something seems odd.

The CRAN repository has nothing for Fedora 9.

The RPM of R that comes with Fedora 9 is version 2.6.2.  Someone
connected with the Fedora project must have built that.

R 2.7 is not in the "updates" for Fedora 9, so nobody connected with
Fedora has done that.

However - and this is the odd thing - the "development" repository of
Fedora has R 2.7 for Fedora 10.  So whoever did that skipped Fedora 9.

Advice?  

I will happily accept the answers "wait" or "install from source" or
"submit a bug report to Fedora."  I just want to know, in part so I
know what to do with the computer that serves RSiteSearch (which is
still running Fedora 8 and R 2.6.2).

Jon
-- 
Jonathan Baron, Professor of Psychology, University of Pennsylvania
Home page: http://www.sas.upenn.edu/~baron

__
R-help@r-project.org mailing list
https://stat.ethz.ch/mailman/listinfo/r-help
PLEASE do read the posting guide http://www.R-project.org/posting-guide.html
and provide commented, minimal, self-contained, reproducible code.


[R] parameters for a function in list format

2008-05-16 Thread Prof. Dr. Joachim Werner

Hi,
can anybody help me concerning ther following problem:
We do simulations with fARMA and use the function armaSim, which 
requires the input parameters in list format; this works perfect, 
however we would like to  write the input for several different  
parameter  lists (models)  in a loop. I tried several versions and got 
no error indication, but judging from the results  only the first 
specified group of list parameters is used and the further ones are 
ignored.

Since the code has more than 3 lines, I will send it only on request.
Thanks for help
Joachim Werner

__
R-help@r-project.org mailing list
https://stat.ethz.ch/mailman/listinfo/r-help
PLEASE do read the posting guide http://www.R-project.org/posting-guide.html
and provide commented, minimal, self-contained, reproducible code.


Re: [R] Font settings in xfig

2008-05-16 Thread Kevin E. Thorpe
Is there a reason you are going through this route to get figures
into LaTeX instead of using postscript (or PDF for pdflatex)?

Robert wrote:
> If I edit the fig file with Xfig, I have to change the value of
> "special flag" to "special" and the font to a LaTeX font instead of a
> postscript font.
> If these changes are not made, the pstex_t file produced from fig2dev
> doesn't contain the text as it should. So if I input the pstex_t in a
> tex file, the text in the figure is not in the same font as the rest
> of the document.
> 
> I'm exporting figures like this:
> 
> xfig(file="test.fig", width=5, height=4, onefile=TRUE)
> plot(data,xlab="Something", ylab="Some other thing")
> dev.off()
> 
> The xfig command does have an argument called encoding, but I can't
> figure out if this can be used to make the changes I want. In the par
> command there's an argument called family, which is used to specify
> the font family in figures, but I don't know how changes this font to
> a LaTeX font.
> 
> Thanks for your help!
> 
> Robert
> 
> On 15 Maj, 17:50, Prof Brian Ripley <[EMAIL PROTECTED]> wrote:
>> On Thu, 15 May 2008, Robert wrote:
>>> Hello
>>> I'm using the xfig-function in R to export figures in fig-format. To
>>> use these exported figures in LaTeX, I first run a fig2dev to get a
>>> pstex and pstex_t file. However, in order to get the right pstex_t
>>> file (that is, with the text of the original figure) I have to change
>>> the font and special text variables in the fig files.
>>> I would like R to do this font changing job, but I can't figure out
>>> how by reading the help files.
>>> Does anybody know how to do accomplish this?
>> Unlikely without knowing what changes you want made and why 
>>
>>
>>
>>> Best regards
>>> Robert


-- 
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.864.5776  Fax: 416.864.6057

__
R-help@r-project.org mailing list
https://stat.ethz.ch/mailman/listinfo/r-help
PLEASE do read the posting guide http://www.R-project.org/posting-guide.html
and provide commented, minimal, self-contained, reproducible code.


Re: [R] Fedora 9?

2008-05-16 Thread Peter Dalgaard
Jonathan Baron wrote:
> Not to be impatient, but something seems odd.
>
> The CRAN repository has nothing for Fedora 9.
>
> The RPM of R that comes with Fedora 9 is version 2.6.2.  Someone
> connected with the Fedora project must have built that.
>
> R 2.7 is not in the "updates" for Fedora 9, so nobody connected with
> Fedora has done that.
>
> However - and this is the odd thing - the "development" repository of
> Fedora has R 2.7 for Fedora 10.  So whoever did that skipped Fedora 9.
>
> Advice?  
>
> I will happily accept the answers "wait" or "install from source" or
> "submit a bug report to Fedora."  I just want to know, in part so I
> know what to do with the computer that serves RSiteSearch (which is
> still running Fedora 8 and R 2.6.2).
>
> Jon
>   
There's already a bugzilla report, see

https://www.redhat.com/archives/fedora-list/2008-May/msg01341.html

The upshot seems to be that

(a) 2.7.0 came out while F9 was frozen

(b) while F9 was frozen there were also no F8/F7 version upgrades (so
that you don't need to downgrade R to upgrade Fedora)

(c) the process for getting new releases out is intrinsically slow.
There's a "karma system" where potential new RPM's are kept in
quarantine and can be thumbed up or down by testers, and this apparently
invariably times out at a score of 0 after two weeks (a +3 would cause
immediate release).

-- 
   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@r-project.org mailing list
https://stat.ethz.ch/mailman/listinfo/r-help
PLEASE do read the posting guide http://www.R-project.org/posting-guide.html
and provide commented, minimal, self-contained, reproducible code.


[R] Dimensions of svd V matrix

2008-05-16 Thread Gad Abraham

Hi,

I'm trying to do PCA on a n by p wide matrix (n < p), and I'd like to 
get more principal components than there are rows. However, svd() only 
returns a V matrix of with n columns (instead of p) unless the argument 
nv=p is set (prcomp calls svd without setting it). Moreover, the 
eigenvalues returned are always min(n, p) instead of p, even if nv is set:


> x <- matrix(rnorm(15), 3, 5)
> dim(svd(x)$v)
[1] 5 3
> length(svd(x)$d)
[1] 3
> dim(svd(x, nv=5)$v)
[1] 5 5
> length(svd(x, nv=5)$d)
[1] 3
>

Is there a way of getting more PCs and eigenvalues than rows? Is the 
eigen-decomposition of the covariance matrix really that numerically 
bad? (i.e., eigen(cov(x)) )


Thanks,
Gad

--
Gad Abraham
Dept. CSSE and NICTA
The University of Melbourne
Parkville 3010, Victoria, Australia
email: [EMAIL PROTECTED]
web: http://www.csse.unimelb.edu.au/~gabraham

__
R-help@r-project.org mailing list
https://stat.ethz.ch/mailman/listinfo/r-help
PLEASE do read the posting guide http://www.R-project.org/posting-guide.html
and provide commented, minimal, self-contained, reproducible code.


[R] creating a 2d plan graphic and projecting points in it

2008-05-16 Thread Khaled OUANES
Hello;
I want to create a 2 D plan with (123 values) for axis1 and 7 values for
axis 2.
I then want to make  a projection of points with their coordonates in that
plan!
is that possible and how to proceed?
Thanks

[[alternative HTML version deleted]]

__
R-help@r-project.org mailing list
https://stat.ethz.ch/mailman/listinfo/r-help
PLEASE do read the posting guide http://www.R-project.org/posting-guide.html
and provide commented, minimal, self-contained, reproducible code.


Re: [R] How to swap and rearrange rows?

2008-05-16 Thread Gabor Grothendieck
This can be shortened slightly using the builtin month.abb in place of m:

ind <- match(substr(rownames(est), 1, 3), month.abb)


On Fri, May 16, 2008 at 5:38 AM, Abhijit Dasgupta
<[EMAIL PROTECTED]> wrote:
> Another possibility:
> # Generate the months in sequential order:
> m <- months(seq(as.Date('2000/1/1'), by='month',length=12),abbreviate=T)
> # Concatenate the data
> est=rbind(est31,est30,est28)
> # generate the right order
> ind <- match(substr(rownames(est),1,3),m)
> # reorder the rows
> est <- est[ind,]
>
> BTW, Richard meant "rbind" instead of "cbind" in his code, which I'm sure you 
> knew.
>
> Abhijit
>
> On Fri, 16 May 2008 10:09:22 +0100
> [EMAIL PROTECTED] wrote:
>
>> > How to swap and rearrange the row so that I will have
>> > Jan-Dec in order?
>> > > est31
>> > p0 est.alpha est.beta  est.rate
>> > Jan  0.8802867 0.7321440 7.241757 0.1380880
>> > Mar  0.8598566 0.7096567 7.376367 0.1355681
>> > May  0.6204301 0.8657272 6.036106 0.1656697
>> > July 0.5032258 0.9928488 4.027408 0.2482986
>> > Aug  0.5322581 0.9625738 4.103121 0.2437169
>> > Oct  0.6792115 0.8526226 5.105218 0.1958780
>> > Dec  0.8397849 0.7490287 7.070349 0.1414357
>> > > est30
>> > p0 est.alpha est.beta  est.rate
>> > Apr  0.7296296 0.7929348 6.303877 0.1586325
>> > Jun  0.5574074 0.8588608 5.695905 0.1755647
>> > Sept 0.607 0.9031150 4.594891 0.2176330
>> > Nov  0.7725926 0.7600906 5.636366 0.1774193
>> > > est28
>> >   p0 est.alpha est.beta  est.rate
>> > Feb 0.877262 0.6567584 8.708051 0.1148363
>> > Thank you so much.
>>
>> First, concatenate the data frames:
>> est <- cbind(est31, est30, est28)
>>
>> Now you can sort the resulting data frame using order, as described in FAQ
>> on R 7.23.
>> months <- factor(rownames(est), levels=c("Jan", "Feb", "Mar", "Apr",
>> "May", "Jun", "July", "Aug", "Sept", "Oct", "Nov", "Dec"))
>> sortedest <- est[order(months),]
>>
>> (You might also want to recode 'July' to 'Jul' and 'Sept' to 'Sep' to be
>> consistent with the other months.)
>>
>> Regards,
>> Richie.
>>
>> Mathematical Sciences Unit
>> HSL
>>
>>
>> 
>> ATTENTION:
>>
>> This message contains privileged and confidential info...{{dropped:12}}
>
> __
> R-help@r-project.org mailing list
> https://stat.ethz.ch/mailman/listinfo/r-help
> PLEASE do read the posting guide http://www.R-project.org/posting-guide.html
> and provide commented, minimal, self-contained, reproducible code.
>

__
R-help@r-project.org mailing list
https://stat.ethz.ch/mailman/listinfo/r-help
PLEASE do read the posting guide http://www.R-project.org/posting-guide.html
and provide commented, minimal, self-contained, reproducible code.


Re: [R] parameters for a function in list format

2008-05-16 Thread Yohan Chalabi
 "PDJW" == "Prof. Dr. Joachim Werner" <[EMAIL PROTECTED]>
 on Fri, 16 May 2008 12:55:32 +0200


   PDJW> Hi,
   PDJW> can anybody help me concerning ther following problem:
   PDJW> We do simulations with fARMA and use the function armaSim,
   PDJW> which
   PDJW> requires the input parameters in list format; this works
   PDJW> perfect,
   PDJW> however we would like to  write the input for several
   PDJW> different
   PDJW> parameter  lists (models)  in a loop. I tried several versions
   PDJW> and got
   PDJW> no error indication, but judging from the results  only
   PDJW> the first
   PDJW> specified group of list parameters is used and the further
   PDJW> ones are
   PDJW> ignored.
   PDJW> Since the code has more than 3 lines, I will send it only
   PDJW> on request.
   PDJW> Thanks for help
   PDJW> Joachim Werner

Dear Joachim,

You can send your question with your code directly to the Rmetrics
core team developer mailing-list ([EMAIL PROTECTED]). 

regards,
Yohan


-- 
PhD student
Swiss Federal Institute of Technology
Zurich

www.ethz.ch
www.rmetrics.org

NOTE:
Rmetrics Workshop: http://www.rmetrics.org/meielisalp.htm
June 29th - July 3rd Meielisalp, Lake Thune, Switzerland

__
R-help@r-project.org mailing list
https://stat.ethz.ch/mailman/listinfo/r-help
PLEASE do read the posting guide http://www.R-project.org/posting-guide.html
and provide commented, minimal, self-contained, reproducible code.


[R] Problem in Removing Correlated Columns

2008-05-16 Thread Nataraj
Dear all,
For removing correlated columns in a data frame,df.
I found a code written in R in the page
http://cheminfo.informatics.indiana.edu/~rguha/code/R/ of
Mr.Rajarshi Guha. 
The code is 
#
r2test <- function(df, cutoff=0.8) {
  if (cutoff > 1 || cutoff <= 0) {
stop(" 0 <= cutoff < 1")
  }
  if (!is.matrix(d) && !is.data.frame(d)) {
stop("Must supply a data.frame or matrix")
  }
  r2cut = sqrt(cutoff);
  cormat <- cor(d);
  bad.idx <- which(abs(cormat)>r2cut,arr.ind=T);
  bad.idx <- matrix( bad.idx[bad.idx[,1] > bad.idx[,2]],
ncol=2);
  drop.idx <- ifelse(runif(nrow(bad.idx)) > .5,
bad.idx[,1], bad.idx [,2]);
  if (length(drop.idx) == 0) {
  1:ncol(d)
  } else {
  (1:ncol(d))[-unique(drop.idx)]
  }
}

Now the problem is the code return different output (i.e.
different column number) for a different call. I could not
understood why it happens from that code, but I can
understand the logic in code except the line

drop.idx <- ifelse(runif(nrow(bad.idx)) > .5, bad.idx[,1],
bad.idx [,2]);

what it means by comparing > 0.5 of nrow(bad.idx).
So I am looking for anyone to help me for different output
generation between the different function call as well as
 meaning of the line which I mentioned above.

Thanks!
B.Nataraj

__
R-help@r-project.org mailing list
https://stat.ethz.ch/mailman/listinfo/r-help
PLEASE do read the posting guide http://www.R-project.org/posting-guide.html
and provide commented, minimal, self-contained, reproducible code.


Re: [R] Getting JRI/rJava to work

2008-05-16 Thread john seers (IFR)
 


Hello 

>Trying to run R in a non-existent locale (or at least in a charset
iconv() does not understand).  
>However, your example (with suitably modified paths) does work for me
in apparently the same locale, so > I cannot debug it for you.

Thank you for trying. I do not understand the non-existent locale and
iconv() you mention. JRI calls R and I do not know how it does it.
Perhaps that is the problem and a clue for where I should look.


>I do think the R posting guide clearly indicates this as off-topic for
R-help -- it is a non-R 
>programming issue involving a contributed package.

Sorry if it is off topic. I was not sure, so I took the middle road of
posting to R-help and the package owner.


Regards


John Seers

__
R-help@r-project.org mailing list
https://stat.ethz.ch/mailman/listinfo/r-help
PLEASE do read the posting guide http://www.R-project.org/posting-guide.html
and provide commented, minimal, self-contained, reproducible code.


Re: [R] Fedora 9?

2008-05-16 Thread Peter Dalgaard
Peter Dalgaard wrote:
> Jonathan Baron wrote:
>   
>> Not to be impatient, but something seems odd.
>>
>> The CRAN repository has nothing for Fedora 9.
>>
>> The RPM of R that comes with Fedora 9 is version 2.6.2.  Someone
>> connected with the Fedora project must have built that.
>>
>> R 2.7 is not in the "updates" for Fedora 9, so nobody connected with
>> Fedora has done that.
>>
>> However - and this is the odd thing - the "development" repository of
>> Fedora has R 2.7 for Fedora 10.  So whoever did that skipped Fedora 9.
>>
>> Advice?  
>>
>> I will happily accept the answers "wait" or "install from source" or
>> "submit a bug report to Fedora."  I just want to know, in part so I
>> know what to do with the computer that serves RSiteSearch (which is
>> still running Fedora 8 and R 2.6.2).
>>
>> Jon
>>   
>> 
> There's already a bugzilla report, see
>
> https://www.redhat.com/archives/fedora-list/2008-May/msg01341.html
>
> The upshot seems to be that
>
> (a) 2.7.0 came out while F9 was frozen
>
> (b) while F9 was frozen there were also no F8/F7 version upgrades (so
> that you don't need to downgrade R to upgrade Fedora)
>
> (c) the process for getting new releases out is intrinsically slow.
> There's a "karma system" where potential new RPM's are kept in
> quarantine and can be thumbed up or down by testers, and this apparently
> invariably times out at a score of 0 after two weeks (a +3 would cause
> immediate release).
>
>   
Credit where due: I forgot to say that Marc Schwartz dug out most of
this information.

-- 
   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@r-project.org mailing list
https://stat.ethz.ch/mailman/listinfo/r-help
PLEASE do read the posting guide http://www.R-project.org/posting-guide.html
and provide commented, minimal, self-contained, reproducible code.


Re: [R] creating a 2d plan graphic and projecting points in it

2008-05-16 Thread Khaled OUANES
Hey Jim,
In fact the 123 values range from:  (minus) -1,50156 to 0,61068 and I need
to enter them as graduation for the X axis (axis 1) and the other 7 values
(0,45833  0,609  0,6123   0,63  0,72  1  1) I need them to form a
graduation for axis 2.
then I have points with coordinates (x,y) that I want to project on this 2D
plan.
Thanks again.

On Fri, May 16, 2008 at 1:59 PM, Jim Lemon <[EMAIL PROTECTED]> wrote:

> Khaled OUANES wrote:
>
>> Hello;
>> I want to create a 2 D plan with (123 values) for axis1 and 7 values for
>> axis 2.
>> I then want to make  a projection of points with their coordonates in that
>> plan!
>> is that possible and how to proceed?
>>
>
> Hi Khaled,
> If you want an empty plot with dimensions 123 x 7:
>
> plot(0,xlim=c(1,123),ylim=c(1.7),type="n",axes=FALSE)
>
> If your points are specified as something like:
>
> x<-sample(1:123,20)
> y<-round(rnorm(20,4,2),2)
>
> you can place the coordinates of those points like this
>
> text(x,y,paste(x,y,sep=","))
>
> Jim
>

[[alternative HTML version deleted]]

__
R-help@r-project.org mailing list
https://stat.ethz.ch/mailman/listinfo/r-help
PLEASE do read the posting guide http://www.R-project.org/posting-guide.html
and provide commented, minimal, self-contained, reproducible code.


Re: [R] Fedora 9?

2008-05-16 Thread Marc Schwartz

on 05/16/2008 07:22 AM Peter Dalgaard wrote:

Peter Dalgaard wrote:

Jonathan Baron wrote:
  

Not to be impatient, but something seems odd.

The CRAN repository has nothing for Fedora 9.

The RPM of R that comes with Fedora 9 is version 2.6.2.  Someone
connected with the Fedora project must have built that.

R 2.7 is not in the "updates" for Fedora 9, so nobody connected with
Fedora has done that.

However - and this is the odd thing - the "development" repository of
Fedora has R 2.7 for Fedora 10.  So whoever did that skipped Fedora 9.

Advice?  


I will happily accept the answers "wait" or "install from source" or
"submit a bug report to Fedora."  I just want to know, in part so I
know what to do with the computer that serves RSiteSearch (which is
still running Fedora 8 and R 2.6.2).

Jon
  


There's already a bugzilla report, see

https://www.redhat.com/archives/fedora-list/2008-May/msg01341.html

The upshot seems to be that

(a) 2.7.0 came out while F9 was frozen

(b) while F9 was frozen there were also no F8/F7 version upgrades (so
that you don't need to downgrade R to upgrade Fedora)

(c) the process for getting new releases out is intrinsically slow.
There's a "karma system" where potential new RPM's are kept in
quarantine and can be thumbed up or down by testers, and this apparently
invariably times out at a score of 0 after two weeks (a +3 would cause
immediate release).

  

Credit where due: I forgot to say that Marc Schwartz dug out most of
this information.


Thanks Peter   :-)

Jon, before you jump on the F9 bandwagon, you might want to note my post 
on r-devel from this past Wednesday:


  https://stat.ethz.ch/pipermail/r-devel/2008-May/049569.html

Best regards,

Marc

__
R-help@r-project.org mailing list
https://stat.ethz.ch/mailman/listinfo/r-help
PLEASE do read the posting guide http://www.R-project.org/posting-guide.html
and provide commented, minimal, self-contained, reproducible code.


Re: [R] Font settings in xfig

2008-05-16 Thread Scionforbai
> Is there a reason you are going through this route to get figures
> into LaTeX instead of using postscript (or PDF for pdflatex)?

To have LaTeX-formatted text printed onto your pdf figures, to include
in LaTeX documents.

R cannot output 'special' text in xfig. You need to post-process the
.fig file, according to the fig format
(http://www.xfig.org/userman/fig-format.html), replacing, on lines
starting with '4', the correct values for font and font_flags. Using
awk (assuming you work on Linux) this is straightforward :

awk '$1==4{$6=0;$9=2}{print}' R_FILE.fig > OUT.fig

Then, in order to obtain a pdf figure with LaTeX-formatted text, you
need a simple driver.tex:

driver.tex :

\documentclass{article}
\usepackage{epsfig}
\usepackage{color} %(note: you might not might not need to do this)
\begin{document}
\pagestyle{empty}
\input{FILE.pstex_t}
\end{document}

Now you can go through the compilation:

fig2dev -L pstex OUT.fig > OUT.pstex
fig2dev -L pstex_t -p OUT.pstex OUT.fig > OUT.pstex_t
sed s/FILE/"OUT"/ driver.tex > ./OUT.tex
latex OUT.tex
dvips -E OUT.dvi -o OUT.eps
epstopdf OUT.eps

Of course you need R to write the correct Latex math strings (like $\sigma^2$).
Hope this helps,

scionforbai

__
R-help@r-project.org mailing list
https://stat.ethz.ch/mailman/listinfo/r-help
PLEASE do read the posting guide http://www.R-project.org/posting-guide.html
and provide commented, minimal, self-contained, reproducible code.


Re: [R] Inconsistent linear model calculations

2008-05-16 Thread Gavin Simpson
On Thu, 2008-05-15 at 14:50 +0100, e-letter wrote:
> 2008/5/15 Douglas Bates <[EMAIL PROTECTED]>:
> > Did you happen to notice the part at the bottom of every message about
> > "provide commented, minimal, self-contained, reproducible code"?
> >
> Sorry, don't understand what that statement means in my context.
> 
> > Considering that the result you quote from "251" has 2 coefficients
> > and the result from "171" has 3 coefficients one might contemplate the
> > possibility that you are fitting different models or perhaps using
> > different data.  However we can't verify anything about the causes
> > because we have no data regarding the problem.
> 
> data below:
> 
>   yabcd   e f
> 1  300 39.87 39.85 39.90 39.87333  9
> 2  400 45.16 45.23 45.17 45.18667 16
> 3  500 50.72 51.03 50.90 50.88333 25
> 4  600 56.85 56.80 57.02 56.89000 36
> 5  700 63.01 63.09 63.14 63.08000 49
> 6  800 69.52 59.68 69.63 66.27667 64
> 
> so substitute a in my generic equation below for data column e (e.g.
> 39.87...) and b for f (e.g. 9e4).
> 
> >
> > Perhaps you are Brian Ripley's evil twin trying to provoke him.  I
> > would say that references to a nonexistent version "171" are
> > deliberately provocative.
> 
> No idea and couldn't care less who br is:
> 
> R : Copyright 2003, The R Development Core Team
> Version 1.7.1  (2003-06-16)
> 
> Get your facts correct before spouting further rubbish.

I'm sorry "e-letter", but that is just not an acceptable attitude for
this list.

I could explain Doug's BR comment (it was just a little bit of fun), but
I guess from your answer you haven't been on the list for very long -
and you might come to regret caring less who BR is - the assistance he
has given me and countless other UseR's other the years has been
invaluable.

I'm amazed people still bothered to help you after this response - just
goes to show that most people on this list are incredibly helpful and
are doing their bit to help people use a wonderful piece of software;
furthering the cause.

There really isn't an R version 171 or even 251; the printed output from
the R session *you* quote shows that.

Glad you got your problem sorted in the end.

G

-- 
%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%
 Dr. Gavin Simpson [t] +44 (0)20 7679 0522
 ECRC, UCL Geography,  [f] +44 (0)20 7679 0565
 Pearson Building, [e] gavin.simpsonATNOSPAMucl.ac.uk
 Gower Street, London  [w] http://www.ucl.ac.uk/~ucfagls/
 UK. WC1E 6BT. [w] http://www.freshwaters.org.uk
%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%

__
R-help@r-project.org mailing list
https://stat.ethz.ch/mailman/listinfo/r-help
PLEASE do read the posting guide http://www.R-project.org/posting-guide.html
and provide commented, minimal, self-contained, reproducible code.


[R] (1-alpha)th percentile

2008-05-16 Thread hanen

hello;
firstly, my gratitude to all who help me to find a function that allows me
to add confidence interval to my graph.  
in order to calculate the (1-alpha)th percentile of for exemple an
F(df1,df2) distribution i do like this:
v<-df(alpha,df1,df2)
percentile<-qf(v,df1,df2,alpha)

if it is true please alert me , and if it is not what should do then?

:handshake:
-- 
View this message in context: 
http://www.nabble.com/%281-alpha%29th-percentile-tp17273198p17273198.html
Sent from the R help mailing list archive at Nabble.com.

__
R-help@r-project.org mailing list
https://stat.ethz.ch/mailman/listinfo/r-help
PLEASE do read the posting guide http://www.R-project.org/posting-guide.html
and provide commented, minimal, self-contained, reproducible code.


[R] How to determine sensible values for 'fnscale' and 'parscale' in optim

2008-05-16 Thread Karl Ove Hufthammer
Dear R-help,

I'm using the 'optim' functions to minimise functions, and have read the
documentation, but I'm still not sure how to determine sensible values to
use for the 'fnscale' and 'parscale' options.

If I have understood everything correctly, 'fnscale' should be used to scale
the objective function, so that for example if the default is 'sensible'
(or even 'optimal') for minimising 'f', one should use 'fnscale=1e-6' for
minimizing the function 'function(...) 1e-6 f(...)'.

But in which range of numbers should 'f' lie for the default 'fnscale' to
be reasonable (with other options, such as 'reltol', at their defaults)?
I understand that if 'f takes values around, e.g., 1e-10 (at least for
parameter values close the optimal ones), I need to use 'fnscale'. But how
much should I scale?

The same applies to 'parscale'. How do I termine reasonable values?
To make the question a bit less theoretical, how would one go about
choosing good values of 'fnscale' and 'parscale' to use when finding,
for example, the MLEs of a bivariate normal distribution using optim.

Here's code for this example:

---
library(MASS) # needed mvrnorm
library(mvtnorm) # needed for dmvnorm

set.sed(20080516)
n=1000
mu1=3
mu2=5
sig1=7
sig2=20
rho=.5
sigmat=matrix(c(sig1^2,sig1*sig2*rho,sig1*sig2*rho,sig2^2),2)
xy=mvrnorm(n,c(mu1,mu2),sigmat) # n = 1000 observations from this
# distribution.

obj=function(par,xy) # The function to maximize.
{
mu=par[1:2]
sigmat=matrix(c(par[3]^2,par[3]*par[4]*par[5],par[3]*par[4]*par[5],par[4]^2),2)
mean(dmvnorm(xy, mu, sigmat, log=TRUE))
}

# Using optim to find the MLEs.
optim( c(5,5,10,10,.5), obj, control=list(fnscale=-1), xy=xy)

# We could of course also calculated MLEs directly.
colMeans(xy)
sd(xy)*sqrt(1-1/n)
cor(xy)
---

Here optim converges to (approximately) the correct values, even with 
not very good initial values (though with method="CG" we do not get 
convergence without increasing maxit). But how should one choose 'fnscale'
and 'parscale' for faster or better convergence?

-- 
Karl Ove Hufthammer

__
R-help@r-project.org mailing list
https://stat.ethz.ch/mailman/listinfo/r-help
PLEASE do read the posting guide http://www.R-project.org/posting-guide.html
and provide commented, minimal, self-contained, reproducible code.


Re: [R] Font settings in xfig

2008-05-16 Thread Kevin E. Thorpe
Scionforbai wrote:
>> Is there a reason you are going through this route to get figures
>> into LaTeX instead of using postscript (or PDF for pdflatex)?
> 
> To have LaTeX-formatted text printed onto your pdf figures, to include
> in LaTeX documents.
> 
> R cannot output 'special' text in xfig. You need to post-process the
> .fig file, according to the fig format
> (http://www.xfig.org/userman/fig-format.html), replacing, on lines
> starting with '4', the correct values for font and font_flags. Using
> awk (assuming you work on Linux) this is straightforward :
> 
> awk '$1==4{$6=0;$9=2}{print}' R_FILE.fig > OUT.fig
> 
> Then, in order to obtain a pdf figure with LaTeX-formatted text, you
> need a simple driver.tex:
> 
> driver.tex :
> 
> \documentclass{article}
> \usepackage{epsfig}
> \usepackage{color} %(note: you might not might not need to do this)
> \begin{document}
> \pagestyle{empty}
> \input{FILE.pstex_t}
> \end{document}
> 
> Now you can go through the compilation:
> 
> fig2dev -L pstex OUT.fig > OUT.pstex
> fig2dev -L pstex_t -p OUT.pstex OUT.fig > OUT.pstex_t
> sed s/FILE/"OUT"/ driver.tex > ./OUT.tex
> latex OUT.tex
> dvips -E OUT.dvi -o OUT.eps
> epstopdf OUT.eps
> 
> Of course you need R to write the correct Latex math strings (like 
> $\sigma^2$).
> Hope this helps,
> 
> scionforbai
> 

I asked because I have found the plotmath capabilities in R to be
sufficient for LaTeXish text on plots.  Then there are no
intermediate steps.  It didn't seem that from the OP that
anything incredibly complex was being attempted.


-- 
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.864.5776  Fax: 416.864.6057

__
R-help@r-project.org mailing list
https://stat.ethz.ch/mailman/listinfo/r-help
PLEASE do read the posting guide http://www.R-project.org/posting-guide.html
and provide commented, minimal, self-contained, reproducible code.


[R] problem with X11 when talking via PHP web interface

2008-05-16 Thread Paul Hammer
hi members,

At the moment i try to create a web-based GUI for R. I am at the 
beginning of this project but i have already now a strange problem.

I would like to create an image which should also be saved. i realize 
this with following code line in my PHP file:

$output= intval(shell_exec("R --no-save --slave < test.R 
1>../tmp/R.output 2>../tmp/R.log"));

The code in the R script (test.R) is:

jpeg(filename = "plot.jpeg", width = 1024, height = 768, units = "px", 
pointsize = 12, quality = 75, bg = "white")
split.screen(c(2,1));
screen(1,new=TRUE)
plot(s);
screen(2,new=TRUE)
plot(y);
dev.off()

The error message which I get is this one:

Error in jpeg(filename = "plot.jpeg", width = 1024, height = 768, units 
= "px",  :X11 module cannot be loaded In addition: Warning message: 
In jpeg(filename = "plot.jpeg", width = 1024, height = 768, units = 
"px",  :   unable to load shared library 
'/home/combiuser/emeyer/R/R-2.7.0/modules//R_X11.so':   
/usr/lib/libcairo.so.2: undefined symbol: FT_GlyphSlot_Embolden 
Execution halted

And the strange thing is when i type in the shell just "R --no-save 
--slave < test.R 1>../tmp/R.output 2>../tmp/R.log" the image is created 
and all works fine It has to be a problem for the X11 module when i 
start R via Apache/PHP. But why and what could I do to solve this problem???

Any suggestions would be really helpful.

Best regards from Germany
Paul


sessionInfo()
R version 2.7.0 (2008-04-22)
i686-pc-linux-gnu

locale:
LC_CTYPE=en_US.UTF-8;LC_NUMERIC=C;LC_TIME=en_US.UTF-8;LC_COLLATE=en_US.UTF-8;LC_MONETARY=C;LC_MESSAGES=en_US.UTF-8;LC_PAPER=en_US.UTF-8;LC_NAME=C;LC_ADDRESS=C;LC_TELEPHONE=C;LC_MEASUREMENT=en_US.UTF-8;LC_IDENTIFICATION=C

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

[[alternative HTML version deleted]]

__
R-help@r-project.org mailing list
https://stat.ethz.ch/mailman/listinfo/r-help
PLEASE do read the posting guide http://www.R-project.org/posting-guide.html
and provide commented, minimal, self-contained, reproducible code.


[R] How to extract estimates, Std. Error, t Value and Pr(>|t|) from summary

2008-05-16 Thread Daphne Renault

__
R-help@r-project.org mailing list
https://stat.ethz.ch/mailman/listinfo/r-help
PLEASE do read the posting guide http://www.R-project.org/posting-guide.html
and provide commented, minimal, self-contained, reproducible code.


Re: [R] Getting JRI/rJava to work

2008-05-16 Thread Prof Brian Ripley
Some off-line discussion showed that the problem was a different iconv.dll 
ahead of R's in the path.  This is a risk for embedded applications of R, 
and worth checking for if this error comes up for you.  (We have also seen 
it reported just once when the issue was Windows' locale settings.)


On Fri, 16 May 2008, Prof Brian Ripley wrote:


On Fri, 16 May 2008, john seers (IFR) wrote:



Hello All

I am trying to get the JRI examples from rJava to work on Windows XP and
failing. (And as a more general and connected question is there any
review/summary of front-end software for R?)

I have installed rJava from the Windows binary supplied. I compile and
run the example supplied (rtest.java) and get the results below. I do
not think the notes about a deprecated API are a problem. But I do not
know what causes the unsupported conversion messages.


Trying to run R in a non-existent locale (or at least in a charset iconv() 
does not understand).  However, your example (with suitably modified paths) 
does work for me in apparently the same locale, so I cannot debug it for you.


I do think the R posting guide clearly indicates this as off-topic for R-help 
-- it is a non-R programming issue involving a contributed package.




Versions used etc below.

Any ideas please? Thanks for any help.

Regards


John Seers




C:\temp\JRI\examples>javac -cp "C:/Program
Files/R/mylibrary/rJava/jri/JRI.jar" rtest.java
Note: rtest.java uses or overrides a deprecated API.
Note: Recompile with -Xlint:deprecation for details.

C:\temp\JRI\examples>java -Djava.library.path="C:/Program
Files/R/mylibrary/rJava/jri" -cp .;"C:/Program
Files/R/mylibrary/rJava/jri/JRI.jar" rtest
Creating Rengine (with arguments)
Error in structure(.Internal(Sys.getenv(as.character(x),
as.character(unset))),  :
 unsupported conversion

R version 2.7.0 (2008-04-22)
Copyright (C) 2008 The R Foundation for Statistical Computing
ISBN 3-900051-07-0

R is free software and comes with ABSOLUTELY NO WARRANTY.
You are welcome to redistribute it under certain conditions.
Type 'license()' or 'licence()' for distribution details.

 Natural language support but running in an English locale

R is a collaborative project with many contributors.
Type 'contributors()' for more information and
'citation()' on how to cite R or R packages in publications.

Type 'demo()' for some demos, 'help()' for on-line help, or
'help.start()' for an HTML browser interface to help.
Type 'q()' to quit R.

Error in file.info(lib.loc) : unsupported conversion in
'filenameToWchar'
Error in file.exists(name) : unsupported conversion in 'filenameToWchar'
rShowMessage "Fatal error: unable to restore saved data in .RData

"

C:\temp\JRI\examples>


##


C:\temp\JRI\examples>which java
/cygdrive/c/Program Files/Java/jdk1.6.0_06/bin/java

C:\temp\JRI\examples>which javac
/cygdrive/c/Program Files/Java/jdk1.6.0_06/bin/javac

C:\temp\JRI\examples>


sessionInfo()

R version 2.7.0 (2008-04-22)
i386-pc-mingw32

locale:
LC_COLLATE=English_United Kingdom.1252;LC_CTYPE=English_United
Kingdom.1252;LC_MONETARY=English_United
Kingdom.1252;LC_NUMERIC=C;LC_TIME=English_United Kingdom.1252

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


other attached packages:
[1] rJava_0.5-1   RWinEdt_1.8-0






---

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

and provide commented, minimal, self-contained, reproducible code.



--
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@r-project.org mailing list
https://stat.ethz.ch/mailman/listinfo/r-help
PLEASE do read the posting guide http://www.R-project.org/posting-guide.html
and provide commented, minimal, self-contained, reproducible code.



--
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@r-project.org mailing list
https://stat.ethz.ch/mailman/listinfo/r-help
PLEASE do read the posting guide http://www.R-project.org/posting-guide.html
and provide commented, minimal, self-contained, reproducible code.


[R] Lattice box percentile plot

2008-05-16 Thread Mr Derik

Dear Nabble.

I am trying to draw a box percentile plot with trellis using the panel in
Hmisc. I really want to colour the plots in. I can alter several of features
of the plot by changing the trellis par settings but I just can’t fill the
shape in.

Here is some example code which alters line colour and dot symbol:

require(lattice)
require(Hmisc)
A<-c(rnorm(100,50,2),rnorm(100,60,5),rnorm(100,55,7))
B<-rep(c(1,2,3),each=100)

trellis.par.set(list(box.rectangle=list(col="black")))
trellis.par.set(list(box.umbrella=list(col="black")))
trellis.par.set(list(box.dot=list(pch=3,col="red")))

bwplot(B~A,panel=panel.bpplot, probs=seq(.01,.49,by=.01))

I’d really appreciate it if someone could tell me how to change the fill
colour as well as it is driving me mad.

Chears.

-- 
View this message in context: 
http://www.nabble.com/Lattice-box-percentile-plot-tp17274559p17274559.html
Sent from the R help mailing list archive at Nabble.com.

[[alternative HTML version deleted]]

__
R-help@r-project.org mailing list
https://stat.ethz.ch/mailman/listinfo/r-help
PLEASE do read the posting guide http://www.R-project.org/posting-guide.html
and provide commented, minimal, self-contained, reproducible code.


Re: [R] How to extract estimates, Std. Error, t Value and Pr(>|t|) from summary

2008-05-16 Thread John Kane
Here is a response some time ago from John Fox which
should help.


#  Extracting values from various objects.
#  From "John Fox" <[EMAIL PROTECTED]>

# Using an anova
 mod <- lm(mpg ~ ., data=mtcars)
 av <- anova(mod)

 names(av)
#[1] "Df"  "Sum Sq"  "Mean Sq" "F value" "Pr(>F)"

 str(av)
#Classes 'anova' and 'data.frame':   11 obs. of  5
variables:
# $ Df : int  1 1 1 1 1 1 1 1 1 1 ...
# $ Sum Sq : num  817.71  37.59   9.37  16.47  77.48
...
# $ Mean Sq: num  817.71  37.59   9.37  16.47  77.48
...
# $ F value: num  116.42   5.35   1.33   2.34  11.03
...
# $ Pr(>F) : num  5.03e-10 3.09e-02 2.61e-01 1.41e-01
3.24e-03 ...
# - attr(*, "heading")= chr  "Analysis of Variance
Table\n" "Response: mpg"
#
#Thus, e.g., av$"Sum Sq" returns the sums of squares:

 av$"Sum Sq"
# [1] 817.7129524  37.5939529   9.3709293  16.4674349 
77.4757948  3.9493082
# [7]   0.1297687  14.4742372   0.9717105   0.4066688
147.4944300

#You could do the same thing with the object returned
by summary().

==
--- Daphne Renault <[EMAIL PROTECTED]> wrote:



  __
[[elided Yahoo spam]]

__
R-help@r-project.org mailing list
https://stat.ethz.ch/mailman/listinfo/r-help
PLEASE do read the posting guide http://www.R-project.org/posting-guide.html
and provide commented, minimal, self-contained, reproducible code.


Re: [R] (1-alpha)th percentile

2008-05-16 Thread Ben Bolker
hanen  yahoo.fr> writes:

> 
> 
> hello;
> firstly, my gratitude to all who help me to find a function that allows me
> to add confidence interval to my graph.  
> in order to calculate the (1-alpha)th percentile of for exemple an
> F(df1,df2) distribution i do like this:
> v<-df(alpha,df1,df2)
> percentile<-qf(v,df1,df2,alpha)
> 
> if it is true please alert me , and if it is not what should do then?
> 
> :handshake:


   I think it's just qf(1-alpha,df1,df2)

   To use a well-known example:
qnorm(0.975) = 1.959964
(in this case, for a two-tailed test, you need 1-alpha/2 , but
F is one-tailed so that's no problem.

  Ben Bolker

__
R-help@r-project.org mailing list
https://stat.ethz.ch/mailman/listinfo/r-help
PLEASE do read the posting guide http://www.R-project.org/posting-guide.html
and provide commented, minimal, self-contained, reproducible code.


Re: [R] How to extract estimates, Std. Error, t Value and Pr(>|t|) from summary

2008-05-16 Thread Yasir Kaheil

> dat<-array(runif(30),c(15,2));
> dat<-data.frame(x=dat[,1],y=dat[,2]);
> linm<-lm(y~x,data=dat);
> linm.s<-summary(linm);
> attributes(linm.s) #to see all attributes of the summary
$names
 [1] "call"  "terms" "residuals" "coefficients" 
 [5] "aliased"   "sigma" "df""r.squared"
 [9] "adj.r.squared" "fstatistic""cov.unscaled" 

$class
[1] "summary.lm"

> linm.s$coefficients # that's the variable you're looking for, right?
  Estimate Std. Error   t valuePr(>|t|)
(Intercept)  0.6132455  0.1907463  3.214980 0.006769529
x   -0.3648345  0.3134967 -1.163759 0.265436835


thanks
y




Daphne Renault wrote:
> 
> 
> __
> R-help@r-project.org mailing list
> https://stat.ethz.ch/mailman/listinfo/r-help
> PLEASE do read the posting guide
> http://www.R-project.org/posting-guide.html
> and provide commented, minimal, self-contained, reproducible code.
> 
> 


-
Yasir H. Kaheil
Catchment Research Facility
The University of Western Ontario 

-- 
View this message in context: 
http://www.nabble.com/How-to-extract-estimates%2C-Std.-Error%2C-t-Value-and-Pr%28%3E%7Ct%7C%29-from-summary-tp17274673p17274850.html
Sent from the R help mailing list archive at Nabble.com.

__
R-help@r-project.org mailing list
https://stat.ethz.ch/mailman/listinfo/r-help
PLEASE do read the posting guide http://www.R-project.org/posting-guide.html
and provide commented, minimal, self-contained, reproducible code.


Re: [R] ANOVA between linear models.

2008-05-16 Thread Rune Haubo
Hi Richard

You are trying to compare two models, that are not nested. This means
that all usual asymptotics of the test statistics break down, hence
the (second) test you are attempting is not meaningful. Usually one
decides on the form of the response on other grounds such as residual
analysis or based on a box-cox analysis. You could take a look at
boxcox() in MASS (book as well as package).

That said it *is* possible to compare completely different models
using the likelihood or AIC in case of difference in number of
parameters although tests are seldom (if ever) available. In this case
you need to be sure to include the additive constants of the log
likelihood - see ?extractAIC.

In case the log-transform makes sense for your problem, you might want
to contemplate a gamma-GLM with a log link.

Hope this helps

/Rune

2008/5/15 Richard Martin <[EMAIL PROTECTED]>:
> Hi All,
>
> I'm accustomed to performing an ANOVA to aid in choosing between
> linear models (for example y~x or y~x+x^2), however with different
> models I can't seem to do it. I'm trying to fit an exponential model
> of the form ye^(bt).
>
> Below is a code snippet that highlights what I'm trying to do
>
> s = rnorm(100, sd = 1, mean=10)
> s = s + seq(0.1,10,0.1)
> x = 1:length(s)
> model.lin = lm(s ~ x)
> model.poly = lm(s ~x  + I(x^2))
> model.exp = lm(log(s) ~ x)
>
> anova(model.lin, model.poly)
> #gives the correct outcome
>
> anova(model.lin, model.exp)
> #doesn't.
>
> This fails because of the transformation of the response variable. Can
> anyone give any advice as to how I should proceed - is there a
> different test to use in this instance, or some way of reversing the
> transform after the model has been fitted?
>
> Any help greatly appreciated!!
>
> Richard
>
> --
> Contendere, Explorare, Invenire, et non Cedere
>
> __
> R-help@r-project.org mailing list
> https://stat.ethz.ch/mailman/listinfo/r-help
> PLEASE do read the posting guide http://www.R-project.org/posting-guide.html
> and provide commented, minimal, self-contained, reproducible code.
>

__
R-help@r-project.org mailing list
https://stat.ethz.ch/mailman/listinfo/r-help
PLEASE do read the posting guide http://www.R-project.org/posting-guide.html
and provide commented, minimal, self-contained, reproducible code.


[R] aggregate(), with multiple functions in FUN?

2008-05-16 Thread Mike !


I've got a data frame having numerical data by zip code:

ZIP DATA
94111 12135.545
93105 321354.65654
94111 545.555
94706 558858.66
...   ...

I'm using this function to group records by ZIP and calculate the median of 
DATA:

aggregate(d$DATA, list(Zip = d$ZIP), FUN=median, na.rm=T)

but what I really want to do is to calculate several statistics (median, mean, 
etc.) for each group of records, so that I'll get a result organized like:

Zip   median(DATA)mean(DATA)
94706   565555
94111   59585 6
93105   595685   666
...

I tried using FUN=funstofun(median,mean), but found that doesn't work in 
aggregate.  Is there a straightforward way to do what I'm after (I'm pretty new 
to R)?  thanks
_
Change the world with e-mail. Join the i’m Initiative from Microsoft.

ld
__
R-help@r-project.org mailing list
https://stat.ethz.ch/mailman/listinfo/r-help
PLEASE do read the posting guide http://www.R-project.org/posting-guide.html
and provide commented, minimal, self-contained, reproducible code.


[R] reading and analyzing a text file

2008-05-16 Thread DAVID ARTETA GARCIA

Dear list,

I have a text file from a scanner that includes 20 lines of text  
(scanner settings) before it actually starts showing the readings in a  
tabular format (headings are ID, intensity, background and few others).


I am a biologist with some experience using R and my question is if it  
is possible to read this file into an R workspace and store the actual  
readings in a dataframe, avoiding the text at the begining. It seems  
to me that this is not the actual purpose of R, but maybe someone can  
point me to a method for doing this. Do I need to parse the file with  
some other programming language? is it possible to link, say, Perl or  
C++ with R to automate the reading and the analysis of such files? The  
aim is to be able to automate this analysis since these files are our  
routine experimental output.


Thanks for your help,

D.

__
R-help@r-project.org mailing list
https://stat.ethz.ch/mailman/listinfo/r-help
PLEASE do read the posting guide http://www.R-project.org/posting-guide.html
and provide commented, minimal, self-contained, reproducible code.


Re: [R] re ading and analyzing a text file

2008-05-16 Thread Yasir Kaheil

use the parameter 'skip' in read.table

dat<-read.table("filename",skip=number of rows you want to skip)

thanks

y


DAVID ARTETA GARCIA wrote:
> 
> Dear list,
> 
> I have a text file from a scanner that includes 20 lines of text  
> (scanner settings) before it actually starts showing the readings in a  
> tabular format (headings are ID, intensity, background and few others).
> 
> I am a biologist with some experience using R and my question is if it  
> is possible to read this file into an R workspace and store the actual  
> readings in a dataframe, avoiding the text at the begining. It seems  
> to me that this is not the actual purpose of R, but maybe someone can  
> point me to a method for doing this. Do I need to parse the file with  
> some other programming language? is it possible to link, say, Perl or  
> C++ with R to automate the reading and the analysis of such files? The  
> aim is to be able to automate this analysis since these files are our  
> routine experimental output.
> 
> Thanks for your help,
> 
> D.
> 
> __
> R-help@r-project.org mailing list
> https://stat.ethz.ch/mailman/listinfo/r-help
> PLEASE do read the posting guide
> http://www.R-project.org/posting-guide.html
> and provide commented, minimal, self-contained, reproducible code.
> 
> 


-
Yasir H. Kaheil
Catchment Research Facility
The University of Western Ontario 

-- 
View this message in context: 
http://www.nabble.com/reading-and-analyzing-a-text-file-tp17276177p17276263.html
Sent from the R help mailing list archive at Nabble.com.

__
R-help@r-project.org mailing list
https://stat.ethz.ch/mailman/listinfo/r-help
PLEASE do read the posting guide http://www.R-project.org/posting-guide.html
and provide commented, minimal, self-contained, reproducible code.


Re: [R] Lattice box percentile plot

2008-05-16 Thread Yasir Kaheil

it's a good question.. my guess is using "panel.bpplot" prevents filling in
the shape "the coffins"- since the box is now two mirrored graphs. i hope
i'm wrong.

trellis.par.get() 
br = trellis.par.get("box.rectangle") 
br$col = "black" 
br$fill = "lightblue"  #this is the parameter that fills in the box, but it
doesn't work with panel.bpplot
trellis.par.set("box.rectangle", br) 
bwplot(B~A,probs=seq(.01,.49,by=.01)) 

thanks
y


Mr Derik wrote:
> 
> Dear Nabble.
> 
> I am trying to draw a box percentile plot with trellis using the panel in
> Hmisc. I really want to colour the plots in. I can alter several of
> features of the plot by changing the trellis par settings but I just can’t
> fill the shape in.
> 
> Here is some example code which alters line colour and dot symbol:
> 
> require(lattice)
> require(Hmisc)
> A<-c(rnorm(100,50,2),rnorm(100,60,5),rnorm(100,55,7))
> B<-rep(c(1,2,3),each=100)
> 
> trellis.par.set(list(box.rectangle=list(col="black")))
> trellis.par.set(list(box.umbrella=list(col="black")))
> trellis.par.set(list(box.dot=list(pch=3,col="red")))
> 
> bwplot(B~A,panel=panel.bpplot, probs=seq(.01,.49,by=.01))
> 
> I’d really appreciate it if someone could tell me how to change the fill
> colour as well as it is driving me mad.
> 
> Chears.
> 
> 


-
Yasir H. Kaheil
Catchment Research Facility
The University of Western Ontario 

-- 
View this message in context: 
http://www.nabble.com/Lattice-box-percentile-plot-tp17274559p17276179.html
Sent from the R help mailing list archive at Nabble.com.

__
R-help@r-project.org mailing list
https://stat.ethz.ch/mailman/listinfo/r-help
PLEASE do read the posting guide http://www.R-project.org/posting-guide.html
and provide commented, minimal, self-contained, reproducible code.


Re: [R] reading and analyzing a text file

2008-05-16 Thread Erin Hodgess
Hi David!

if you use read.table, there is an argument called skip.

You can set that to skip=20, say.

HTH,
Erin


On Fri, May 16, 2008 at 9:30 AM, DAVID ARTETA GARCIA
<[EMAIL PROTECTED]> wrote:
> Dear list,
>
> I have a text file from a scanner that includes 20 lines of text (scanner
> settings) before it actually starts showing the readings in a tabular format
> (headings are ID, intensity, background and few others).
>
> I am a biologist with some experience using R and my question is if it is
> possible to read this file into an R workspace and store the actual readings
> in a dataframe, avoiding the text at the begining. It seems to me that this
> is not the actual purpose of R, but maybe someone can point me to a method
> for doing this. Do I need to parse the file with some other programming
> language? is it possible to link, say, Perl or C++ with R to automate the
> reading and the analysis of such files? The aim is to be able to automate
> this analysis since these files are our routine experimental output.
>
> Thanks for your help,
>
> D.
>
> __
> R-help@r-project.org mailing list
> https://stat.ethz.ch/mailman/listinfo/r-help
> PLEASE do read the posting guide http://www.R-project.org/posting-guide.html
> and provide commented, minimal, self-contained, reproducible code.
>



-- 
Erin Hodgess
Associate Professor
Department of Computer and Mathematical Sciences
University of Houston - Downtown
mailto: [EMAIL PROTECTED]

__
R-help@r-project.org mailing list
https://stat.ethz.ch/mailman/listinfo/r-help
PLEASE do read the posting guide http://www.R-project.org/posting-guide.html
and provide commented, minimal, self-contained, reproducible code.


Re: [R] reading and analyzing a text file

2008-05-16 Thread Doran, Harold
This may be possible using the skip argument in read.table. It's hard to
know w/o a bit more info on the structure of the text file.  

> -Original Message-
> From: [EMAIL PROTECTED] 
> [mailto:[EMAIL PROTECTED] On Behalf Of DAVID ARTETA GARCIA
> Sent: Friday, May 16, 2008 10:31 AM
> To: r-help@r-project.org
> Subject: [R] reading and analyzing a text file
> 
> Dear list,
> 
> I have a text file from a scanner that includes 20 lines of 
> text (scanner settings) before it actually starts showing the 
> readings in a tabular format (headings are ID, intensity, 
> background and few others).
> 
> I am a biologist with some experience using R and my question 
> is if it is possible to read this file into an R workspace 
> and store the actual readings in a dataframe, avoiding the 
> text at the begining. It seems to me that this is not the 
> actual purpose of R, but maybe someone can point me to a 
> method for doing this. Do I need to parse the file with some 
> other programming language? is it possible to link, say, Perl or  
> C++ with R to automate the reading and the analysis of such files? The
> aim is to be able to automate this analysis since these files 
> are our routine experimental output.
> 
> Thanks for your help,
> 
> D.
> 
> __
> R-help@r-project.org mailing list
> https://stat.ethz.ch/mailman/listinfo/r-help
> PLEASE do read the posting guide 
> http://www.R-project.org/posting-guide.html
> and provide commented, minimal, self-contained, reproducible code.
> 

__
R-help@r-project.org mailing list
https://stat.ethz.ch/mailman/listinfo/r-help
PLEASE do read the posting guide http://www.R-project.org/posting-guide.html
and provide commented, minimal, self-contained, reproducible code.


Re: [R] re ading and analyzing a text file

2008-05-16 Thread Ted Harding
On 16-May-08 14:35:18, Yasir Kaheil wrote:
> 
> use the parameter 'skip' in read.table
> 
> dat<-read.table("filename",skip=number of rows you want to skip)
> 
> thanks
> y

Or, ironically, you can use scan(...,skip=number of rows to skip)!
See ?scan.

Best wishes,
Ted.

> DAVID ARTETA GARCIA wrote:
>> 
>> Dear list,
>> 
>> I have a text file from a scanner that includes 20 lines of text  
>> (scanner settings) before it actually starts showing the readings in a
>> tabular format (headings are ID, intensity, background and few
>> others).
>> 
>> I am a biologist with some experience using R and my question is if it
>> is possible to read this file into an R workspace and store the actual
>> readings in a dataframe, avoiding the text at the begining. It seems  
>> to me that this is not the actual purpose of R, but maybe someone can 
>> point me to a method for doing this. Do I need to parse the file with 
>> some other programming language? is it possible to link, say, Perl or 
>> C++ with R to automate the reading and the analysis of such files? The
>> aim is to be able to automate this analysis since these files are our 
>> routine experimental output.
>> 
>> Thanks for your help,
>> 
>> D.
>> 
>> __
>> R-help@r-project.org mailing list
>> https://stat.ethz.ch/mailman/listinfo/r-help
>> PLEASE do read the posting guide
>> http://www.R-project.org/posting-guide.html
>> and provide commented, minimal, self-contained, reproducible code.
>> 
>> 
> 
> 
> -
> Yasir H. Kaheil
> Catchment Research Facility
> The University of Western Ontario 
> 
> -- 
> View this message in context:
> http://www.nabble.com/reading-and-analyzing-a-text-file-tp17276177p17276
> 263.html
> Sent from the R help mailing list archive at Nabble.com.
> 
> __
> R-help@r-project.org mailing list
> https://stat.ethz.ch/mailman/listinfo/r-help
> PLEASE do read the posting guide
> http://www.R-project.org/posting-guide.html
> and provide commented, minimal, self-contained, reproducible code.


E-Mail: (Ted Harding) <[EMAIL PROTECTED]>
Fax-to-email: +44 (0)870 094 0861
Date: 16-May-08   Time: 15:45:05
-- XFMail --

__
R-help@r-project.org mailing list
https://stat.ethz.ch/mailman/listinfo/r-help
PLEASE do read the posting guide http://www.R-project.org/posting-guide.html
and provide commented, minimal, self-contained, reproducible code.


[R] Integer / floating point question

2008-05-16 Thread Erik Iverson

Dear R-help -

I have thought about this question for a bit, and come up with no 
satisfactory answer.


Say I have the numeric vector t1, given as

t1 <- c(1.0, 1.5, 2.0, 2.5, 3.0)

I simply want to reliably extract the unique integers from t1, i.e., the 
vector c(1, 2, 3).  This is of course superficially simple to carry out.


However, my question is related to R FAQ 7.31, "Why doesn't R think 
these numbers are equal?" The first sentence of that FAQ reads, "The 
only numbers that can be represented exactly in R's numeric type are 
integers and fractions whose denominator is a power of 2."


All the methods I've devised to do the above task seem to ultimately 
rely on the fact that identical(x.0, x) == TRUE, for integer x.


My assumption, which I'm hoping can be verified, is that, for example, 
2.0 (when, say, entered at the prompt and not computed from an 
algorithm) is an integer in the sense of FAQ 7.31.


This seems to be the case on my machine.

> identical(2.0, 2)
[1] TRUE

Apologies that this is such a trivial question, it seems so obvious on 
the surface, I just want to be sure I am understanding it correctly.


Erik Iverson
[EMAIL PROTECTED]

sessionInfo()
R version 2.7.0 (2008-04-22)
i686-pc-linux-gnu

locale:
LC_CTYPE=en_US.UTF-8;LC_NUMERIC=C;LC_TIME=en_US.UTF-8;LC_COLLATE=en_US.UTF-8;LC_MONETARY=C;LC_MESSAGES=en_US.UTF-8;LC_PAPER=en_US.UTF-8;LC_NAME=C;LC_ADDRESS=C;LC_TELEPHONE=C;LC_MEASUREMENT=en_US.UTF-8;LC_IDENTIFICATION=C

attached base packages:
[1] grDevices datasets  tcltk splines   graphics  utils stats
[8] methods   base

other attached packages:
[1] fortunes_1.3-4  debug_1.1.0 mvbutils_1.1.1  SPLOTS_1.3-47
[5] Hmisc_3.4-3 chron_2.3-21survival_2.34-1 erik_0.0-1

loaded via a namespace (and not attached):
[1] cluster_1.11.10 grid_2.7.0  lattice_0.17-6

__
R-help@r-project.org mailing list
https://stat.ethz.ch/mailman/listinfo/r-help
PLEASE do read the posting guide http://www.R-project.org/posting-guide.html
and provide commented, minimal, self-contained, reproducible code.


Re: [R] reading and analyzing a text file

2008-05-16 Thread Prof Brian Ripley

1) read.table has a 'skip' argument which may suffice.

2) R has the concept of 'connections' to read sequentially through a file. 
See the 'R Data Import/Export' manual.


If that is not enough hints, showing us an example usually intrigues 
people enough to offer working code.


On Fri, 16 May 2008, DAVID ARTETA GARCIA wrote:


Dear list,

I have a text file from a scanner that includes 20 lines of text (scanner 
settings) before it actually starts showing the readings in a tabular format 
(headings are ID, intensity, background and few others).


I am a biologist with some experience using R and my question is if it is 
possible to read this file into an R workspace and store the actual readings 
in a dataframe, avoiding the text at the begining. It seems to me that this 
is not the actual purpose of R, but maybe someone can point me to a method 
for doing this. Do I need to parse the file with some other programming 
language? is it possible to link, say, Perl or C++ with R to automate the 
reading and the analysis of such files? The aim is to be able to automate 
this analysis since these files are our routine experimental output.


Thanks for your help,

D.

__
R-help@r-project.org mailing list
https://stat.ethz.ch/mailman/listinfo/r-help
PLEASE do read the posting guide http://www.R-project.org/posting-guide.html
and provide commented, minimal, self-contained, reproducible code.


--
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@r-project.org mailing list
https://stat.ethz.ch/mailman/listinfo/r-help
PLEASE do read the posting guide http://www.R-project.org/posting-guide.html
and provide commented, minimal, self-contained, reproducible code.


Re: [R] Integer / floating point question

2008-05-16 Thread Marc Schwartz

on 05/16/2008 09:56 AM Erik Iverson wrote:

Dear R-help -

I have thought about this question for a bit, and come up with no 
satisfactory answer.


Say I have the numeric vector t1, given as

t1 <- c(1.0, 1.5, 2.0, 2.5, 3.0)

I simply want to reliably extract the unique integers from t1, i.e., the 
vector c(1, 2, 3).  This is of course superficially simple to carry out.


Use modulo division:

> t1[t1 %% 1 == 0]
[1] 1 2 3

or

> unique(t1[t1 %% 1 == 0])
[1] 1 2 3

However, my question is related to R FAQ 7.31, "Why doesn't R think 
these numbers are equal?" The first sentence of that FAQ reads, "The 
only numbers that can be represented exactly in R's numeric type are 
integers and fractions whose denominator is a power of 2."


All the methods I've devised to do the above task seem to ultimately 
rely on the fact that identical(x.0, x) == TRUE, for integer x.


My assumption, which I'm hoping can be verified, is that, for example, 
2.0 (when, say, entered at the prompt and not computed from an 
algorithm) is an integer in the sense of FAQ 7.31.


This seems to be the case on my machine.

 > identical(2.0, 2)
[1] TRUE

Apologies that this is such a trivial question, it seems so obvious on 
the surface, I just want to be sure I am understanding it correctly.


Keep in mind that by default and unless specifically coerced to integer, 
numbers in R are double precision floats:


> is.integer(2)
[1] FALSE

> is.numeric(2)
[1] TRUE

> is.integer(2.0)
[1] FALSE

> is.numeric(2.0)
[1] TRUE


So:

> identical(2.0, as.integer(2))
[1] FALSE


Does that help?

Marc Schwartz

__
R-help@r-project.org mailing list
https://stat.ethz.ch/mailman/listinfo/r-help
PLEASE do read the posting guide http://www.R-project.org/posting-guide.html
and provide commented, minimal, self-contained, reproducible code.


[R] glm model syntax

2008-05-16 Thread Birgit Lemcke


Hello R users!

What is the difference between

glm(A~N+M)
glm(A~N:M)
glm(A~N*M)

Thanks in advance.

Birgit

Birgit Lemcke
Institut für Systematische Botanik
Zollikerstrasse 107
CH-8008 Zürich
Switzerland
Ph: +41 (0)44 634 8351
[EMAIL PROTECTED]

175 Jahre UZH
«staunen.erleben.begreifen. Naturwissenschaft zum Anfassen.»
MNF-Jubiläumsevent für gross und klein.
19. April 2008, 10.00 Uhr bis 02.00 Uhr
Campus Irchel, Winterthurerstrasse 190, 8057 Zürich
Weitere Informationen http://www.175jahre.uzh.ch/naturwissenschaft

__
R-help@r-project.org mailing list
https://stat.ethz.ch/mailman/listinfo/r-help
PLEASE do read the posting guide http://www.R-project.org/posting-guide.html
and provide commented, minimal, self-contained, reproducible code.


Re: [R] reading and analyzing a text file

2008-05-16 Thread DAVID ARTETA GARCIA
here I show the first text lines and some of the data. There are  
actually 6272 rows in the dataframe. Actually the skip parameter works  
fine as some people already suggested.


ATF 1.0
20  5
"Type=Mapix Results 2"
"DateTime=2008/05/15 11:05:38"
"ConfigFile="
"GalFile=Y:\experimental\090508\_v1.0.gal"
"PixelSize=20"
"Wavelengths=635   532"
"ImageFiles=Y:\May_2008\B_1.0_090508\Images\B_1.0_090508_50.tif"
"RatioFormulations=W1/W2 (635/532)"
"FeatureType=Circular"
"Barcode=0581"
"BackgroundSubtraction=LocalFeature"
"ImageOrigin=2110, 5479"
"Creator=Mapix 3.0.0 (driver 1.0.25)"
"Scanner=is700 7A02C1 706008"
"Temperature=26.3"
"Comment="
"LaserPower=5.05.0"
"SoftwareVersion=3.5.0.1"
"Name""F532 Median" "B532 Median" "F635 Median" "B635 Median"
"V001O01" 4964.0  125.0   220.0   112.0
"V001O01" 5340.5  122.0   240.5   95.0
"V001O02" 5536.0  117.0   273.0   122.0
"V001O02" 5800.5  115.0   285.5   108.0
"V001O03" 3201.0  131.0   226.0   122.0
.
.
.
...



Prof Brian Ripley <[EMAIL PROTECTED]> ha escrito:


1) read.table has a 'skip' argument which may suffice.

2) R has the concept of 'connections' to read sequentially through a
file. See the 'R Data Import/Export' manual.

If that is not enough hints, showing us an example usually intrigues
people enough to offer working code.

On Fri, 16 May 2008, DAVID ARTETA GARCIA wrote:


Dear list,

I have a text file from a scanner that includes 20 lines of text   
(scanner settings) before it actually starts showing the readings   
in a tabular format (headings are ID, intensity, background and few  
 others).


I am a biologist with some experience using R and my question is if  
 it is possible to read this file into an R workspace and store the  
 actual readings in a dataframe, avoiding the text at the begining.  
 It seems to me that this is not the actual purpose of R, but maybe  
 someone can point me to a method for doing this. Do I need to  
parse  the file with some other programming language? is it  
possible to  link, say, Perl or C++ with R to automate the reading  
and the  analysis of such files? The aim is to be able to automate  
this  analysis since these files are our routine experimental output.


Thanks for your help,

D.

__
R-help@r-project.org mailing list
https://stat.ethz.ch/mailman/listinfo/r-help
PLEASE do read the posting guide http://www.R-project.org/posting-guide.html
and provide commented, minimal, self-contained, reproducible code.


--
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@r-project.org mailing list
https://stat.ethz.ch/mailman/listinfo/r-help
PLEASE do read the posting guide http://www.R-project.org/posting-guide.html
and provide commented, minimal, self-contained, reproducible code.


Re: [R] Font settings in xfig

2008-05-16 Thread Greg Snow
If the main goal is to include graphs created by R in LaTeX documents and have 
them look nice, and using xfig was just one way of attempting this, then here 
are a couple other options that may or may not work better.

Use the postscript graphics device and use psfrag in LaTeX to replace text in 
plot with LaTeX commands.  This is fine if you are using postscript and only 
have a couple of things that need to be replaced.  This can be a pain if you 
want to replace every tick mark label with the current font in the document, or 
if you want to go directly to pdf without going through postscript.

Generate pdf/eps files of the graphs using the same font as your LaTeX document 
(see R-news article (6)2 41-47, on ways to specify the font).  This changes the 
font to match, but does not do arbitrary LaTeX commands.

Create an eps file, then use eps2pgf (http://sourceforge.net/projects/eps2pgf/) 
to convert to a pgf file to be included in your LaTeX file (via \input{}).  You 
need to use the pgf package in your LaTeX file, but then all the graphics are 
done internally using by default the same fonts as the rest of the document.  
You can also do psfrag like replacements when converting the file to include 
LaTeX commands.


Hope this helps,

--
Gregory (Greg) L. Snow Ph.D.
Statistical Data Center
Intermountain Healthcare
[EMAIL PROTECTED]
(801) 408-8111



> -Original Message-
> From: [EMAIL PROTECTED]
> [mailto:[EMAIL PROTECTED] On Behalf Of Scionforbai
> Sent: Friday, May 16, 2008 6:57 AM
> To: Kevin E. Thorpe
> Cc: r-help@r-project.org; Robert
> Subject: Re: [R] Font settings in xfig
>
> > Is there a reason you are going through this route to get
> figures into
> > LaTeX instead of using postscript (or PDF for pdflatex)?
>
> To have LaTeX-formatted text printed onto your pdf figures,
> to include in LaTeX documents.
>
> R cannot output 'special' text in xfig. You need to
> post-process the .fig file, according to the fig format
> (http://www.xfig.org/userman/fig-format.html), replacing, on
> lines starting with '4', the correct values for font and
> font_flags. Using awk (assuming you work on Linux) this is
> straightforward :
>
> awk '$1==4{$6=0;$9=2}{print}' R_FILE.fig > OUT.fig
>
> Then, in order to obtain a pdf figure with LaTeX-formatted
> text, you need a simple driver.tex:
>
> driver.tex :
>
> \documentclass{article}
> \usepackage{epsfig}
> \usepackage{color} %(note: you might not might not need to do
> this) \begin{document} \pagestyle{empty} \input{FILE.pstex_t}
> \end{document}
>
> Now you can go through the compilation:
>
> fig2dev -L pstex OUT.fig > OUT.pstex
> fig2dev -L pstex_t -p OUT.pstex OUT.fig > OUT.pstex_t sed
> s/FILE/"OUT"/ driver.tex > ./OUT.tex latex OUT.tex dvips -E
> OUT.dvi -o OUT.eps epstopdf OUT.eps
>
> Of course you need R to write the correct Latex math strings
> (like $\sigma^2$).
> Hope this helps,
>
> scionforbai
>
> __
> R-help@r-project.org mailing list
> https://stat.ethz.ch/mailman/listinfo/r-help
> PLEASE do read the posting guide
> http://www.R-project.org/posting-guide.html
> and provide commented, minimal, self-contained, reproducible code.
>

__
R-help@r-project.org mailing list
https://stat.ethz.ch/mailman/listinfo/r-help
PLEASE do read the posting guide http://www.R-project.org/posting-guide.html
and provide commented, minimal, self-contained, reproducible code.


Re: [R] glm model syntax

2008-05-16 Thread Doran, Harold
N+M gives only the main effects, N:M gives only the interaction, and G*M gives 
the main effects and the interaction. 

> -Original Message-
> From: [EMAIL PROTECTED] 
> [mailto:[EMAIL PROTECTED] On Behalf Of Birgit Lemcke
> Sent: Friday, May 16, 2008 11:27 AM
> To: R Hilfe
> Subject: [R] glm model syntax
> 
> 
> Hello R users!
> 
> What is the difference between
> 
> glm(A~N+M)
> glm(A~N:M)
> glm(A~N*M)
> 
> Thanks in advance.
> 
> Birgit
> 
> Birgit Lemcke
> Institut für Systematische Botanik
> Zollikerstrasse 107
> CH-8008 Zürich
> Switzerland
> Ph: +41 (0)44 634 8351
> [EMAIL PROTECTED]
> 
> 175 Jahre UZH
> «staunen.erleben.begreifen. Naturwissenschaft zum Anfassen.» 
> MNF-Jubiläumsevent für gross und klein.
> 19. April 2008, 10.00 Uhr bis 02.00 Uhr
> Campus Irchel, Winterthurerstrasse 190, 8057 Zürich Weitere 
> Informationen http://www.175jahre.uzh.ch/naturwissenschaft
> 
> __
> R-help@r-project.org mailing list
> https://stat.ethz.ch/mailman/listinfo/r-help
> PLEASE do read the posting guide 
> http://www.R-project.org/posting-guide.html
> and provide commented, minimal, self-contained, reproducible code.
> 

__
R-help@r-project.org mailing list
https://stat.ethz.ch/mailman/listinfo/r-help
PLEASE do read the posting guide http://www.R-project.org/posting-guide.html
and provide commented, minimal, self-contained, reproducible code.


[R] Box.test degrees of freedom

2008-05-16 Thread Nuno Prista
Dear colleagues,

 

I am new to R and statistics so please keep that in mind. 

 

I have doubts on the df calculation of Ljung-Box test (Box.test). The
function seems to use always the df=lag=m and not df=m-p-q like suggested in
Ljung and Box (1978) paper (that is referenced).

 

Do you agree with this? If so, is there an R package function that computes
Ljung-Box test with the degrees of freedom as described in Ljung and Box
(1978) paper?

 

Note: this issue was discussed in
http://tolstoy.newcastle.edu.au/R/help/06/03/22768.html (and thread) but it
seems with little consensus.

 

 

Thanks in advance,

 

Nuno 

__ 

Centro de Oceanografia - IO-FCUL, Portugal

Center for Quantitative Fisheries Ecology - ODU, USA

 

 


[[alternative HTML version deleted]]

__
R-help@r-project.org mailing list
https://stat.ethz.ch/mailman/listinfo/r-help
PLEASE do read the posting guide http://www.R-project.org/posting-guide.html
and provide commented, minimal, self-contained, reproducible code.


Re: [R] Making slope coefficients ``relative to 0''.

2008-05-16 Thread Bert Gunter
 Either lm(y~ a-1 + a:x) or lm (y~ a + (a-1):x) or lm(y~ a+ a:(x-1))

-- Bert Gunter
Genentech

-Original Message-
From: bgunter 
Sent: Friday, May 16, 2008 8:39 AM
To: Rolf Turner
Subject: RE: [R] Making slope coefficients ``relative to 0''.

lm(y ~ a + a:(x-1)) 

-Original Message-
From: [EMAIL PROTECTED] [mailto:[EMAIL PROTECTED] On
Behalf Of Rolf Turner
Sent: Thursday, May 15, 2008 8:55 PM
To: R-help forum
Subject: [R] Making slope coefficients ``relative to 0''.


I am interested in whether the slopes in a linear model are different  
from 0.

I.e. I would like to obtain the slope estimates, and their standard  
errors,
``relative to 0'' for each group, rather than relative to some baseline.

Explicitly I would like to write/represent the model as

y = a_i + b_i*x + E

i = 1, ..., K, where x is a continuous variate and i indexes groups
(levels of a factor with K levels).

The ``usual'' structure (using ``treatment contrasts'') gives

y = a + a_i + b*x + b_i*x + E

i = 2, ..., K.  (So that b is the slope for the baseline group, and  
b_i measures
how much the slope for group i differs from that for the baseline group.

I can force the *intercepts* to be ``relative to 0'' by putting a  
``-1'' into the formula:

lm(y ~ g*x-1)

But I don't really care about the intercepts; it's the slopes I'm  
interested in.

And there doesn't seem to a way to do the thing equivalent to the  
``-1'' trick
for slopes.  Or is there?

There are of course several work-arounds.  (E.g. calculate my b_i- 
hats and their
standard errors from the information obtained from the usual model  
structure.
Or set up my own dummy variable to regress upon.  Easy enough, and I  
could do that.)

I just wanted to know for sure that there wasn't a sexier way, using  
some aspect
of the formula machinery with which I am not yet familiar.

Thanks for any insights.

cheers,

Rolf Turner

##
Attention:\ This e-mail message is privileged and confid...{{dropped:9}}

__
R-help@r-project.org mailing list
https://stat.ethz.ch/mailman/listinfo/r-help
PLEASE do read the posting guide http://www.R-project.org/posting-guide.html
and provide commented, minimal, self-contained, reproducible code.

__
R-help@r-project.org mailing list
https://stat.ethz.ch/mailman/listinfo/r-help
PLEASE do read the posting guide http://www.R-project.org/posting-guide.html
and provide commented, minimal, self-contained, reproducible code.


Re: [R] Integer / floating point question

2008-05-16 Thread Erik Iverson

Marc -

Marc Schwartz wrote:

on 05/16/2008 09:56 AM Erik Iverson wrote:

Dear R-help -

I have thought about this question for a bit, and come up with no 
satisfactory answer.


Say I have the numeric vector t1, given as

t1 <- c(1.0, 1.5, 2.0, 2.5, 3.0)

I simply want to reliably extract the unique integers from t1, i.e., 
the vector c(1, 2, 3).  This is of course superficially simple to 
carry out.


Use modulo division:

 > t1[t1 %% 1 == 0]
[1] 1 2 3

or

 > unique(t1[t1 %% 1 == 0])
[1] 1 2 3


Yes, that is one of the solutions.  However, can I be sure that, say,

2.0 %% 1 == 0

The help page for '%%' addresses this a bit, but then caveats it with 
'up to rounding error', which is really my question.  Is there ever 
'rounding error' with 2.0 %% 1 as opposed to 2 %% 1?




However, my question is related to R FAQ 7.31, "Why doesn't R think 
these numbers are equal?" The first sentence of that FAQ reads, "The 
only numbers that can be represented exactly in R's numeric type are 
integers and fractions whose denominator is a power of 2."


All the methods I've devised to do the above task seem to ultimately 
rely on the fact that identical(x.0, x) == TRUE, for integer x.


My assumption, which I'm hoping can be verified, is that, for example, 
2.0 (when, say, entered at the prompt and not computed from an 
algorithm) is an integer in the sense of FAQ 7.31.


This seems to be the case on my machine.

 > identical(2.0, 2)
[1] TRUE

Apologies that this is such a trivial question, it seems so obvious on 
the surface, I just want to be sure I am understanding it correctly.


Keep in mind that by default and unless specifically coerced to integer, 
numbers in R are double precision floats:


 > is.integer(2)
[1] FALSE

 > is.numeric(2)
[1] TRUE

 > is.integer(2.0)
[1] FALSE

 > is.numeric(2.0)
[1] TRUE


So:

 > identical(2.0, as.integer(2))
[1] FALSE


Does that help?


A bit, and this is the source of my confusion.  Can I always assume that 
2.0 == 2 when the class of each is 'numeric'?




Marc Schwartz


__
R-help@r-project.org mailing list
https://stat.ethz.ch/mailman/listinfo/r-help
PLEASE do read the posting guide http://www.R-project.org/posting-guide.html
and provide commented, minimal, self-contained, reproducible code.


[R] logistic transformation using nlminb

2008-05-16 Thread John Pitchard
Dear all,

I want to find the optimal values of a vector, x (with 6 elements)
say, satisfying the following conditions:

1. for all x>=0
2. sum(x)=1
3. x[5]<=0.5 and x[6]<=0.5

For the minimisation I'm using nlminb and to satisfy the first 2
conditions the logistic transformation is used with box constraints
for condition 3. However, I don't seem to be able to get the values x
that i'm expecting from fitting a simpler model. For example,


set.seed(0)
# creating a correlation matrix
corr <- diag(5)
corr[lower.tri(corr)] <- 0.5
corr[upper.tri(corr)] <- 0.5

# Data for the minimisation
mat <- rmvnorm(1, mean=c(3, 2.75, 2.8, 3, 2.9), sd=c(0.1,
0.1,0.12, 0.15, 0.10), cov=corr)


# here is the simple optimisation function that allows the 5th
element to be potentially negative

obj.funA <- function(opt, mat) {
  opt <- c(opt, 1-sum(opt))
  LinearComb <- mat%*%opt
 obj <- -min(LinearComb)
 obj
}

# I want to put an upper boundary constraint on the first variable -
not being greater than 0.35 and the rest being between 0 and 1

opt <- nlminb(rep(0,4), lower=rep(0,4), upper=c(0.35, 1, 1, 1) ,
obj.funA, mat=mat)
opt.x <- opt$parameters
opt.x <- c(opt.x, 1-sum(opt.x))
opt.x

# Result
[1] 0.3402 0.06475651 0. 0.16561760 0.41962686

However, I don't get the same result from the logistic transformation

obj.funB <- function(opt, mat) {
 opt <- c(opt, 0)
 opt <- exp(opt)/sum(exp(opt))
  LinearComb <- mat%*%opt
 obj <- -min(LinearComb)
 obj
}

opt <- nlminb(rep(0,4), upper=c(log(0.35), NA, NA, NA), obj.funB, mat=mat)
opt.x <- opt$parameters
opt.x <- c(opt.x, 0)
opt.x <- exp(opt.x)/sum(exp(opt.x))
opt.x

# Result
[1] 2.355325e-001 6.339398e-009 1.202751e-004 9.139718e-002 6.729500e-001

I don't know how to obtain the same answer for both optimisations. In
reality, my own optimisation typically gives negative values for the standard
minimisation- so I have no choice but to use a more advanced method.
Also, there appears to be a dependency between the first and the last,
i.e. 2.355325e-001/6.729500e-001 =0.35

Does anyone know why the logistic doesn't give the same answer as the
simpler method?

Any help is much appreciated.

Regards,
John

__
R-help@r-project.org mailing list
https://stat.ethz.ch/mailman/listinfo/r-help
PLEASE do read the posting guide http://www.R-project.org/posting-guide.html
and provide commented, minimal, self-contained, reproducible code.


[R] heatmap on pre-established hclust output?

2008-05-16 Thread Johannes Graumann
Hi,

Can someone please guide me towards how to produce "heatmap" output from the
output of "hclust" run prior to the actual "heatmap" call? I have some
rather lengthy clustering going on and tweeking the visual output
with "heatmap" recalculating the clustering every time is not feasible.

Thanks, Joh

__
R-help@r-project.org mailing list
https://stat.ethz.ch/mailman/listinfo/r-help
PLEASE do read the posting guide http://www.R-project.org/posting-guide.html
and provide commented, minimal, self-contained, reproducible code.


Re: [R] How to swap and rearrange rows?

2008-05-16 Thread Dieter Menne
Roslina Zakaria  yahoo.com> writes:
> How to swap and rearrange the row so that I will have
> Jan-Dec in order?
> > est31
> p0 est.alpha est.beta  est.rate
> Jan  0.8802867 0.7321440 7.241757 0.1380880
> Mar  0.8598566 0.7096567 7.376367 0.1355681
> May  0.6204301 0.8657272 6.036106 0.1656697
> July 0.5032258 0.9928488 4.027408 0.2482986
> Aug  0.5322581 0.9625738 4.103121 0.2437169
> Oct  0.6792115 0.8526226 5.105218 0.1958780
> Dec  0.8397849 0.7490287 7.070349 0.1414357
> > est30
> p0 est.alpha est.beta  est.rate
> Apr  0.7296296 0.7929348 6.303877 0.1586325
> Jun  0.5574074 0.8588608 5.695905 0.1755647
> Sept 0.607 0.9031150 4.594891 0.2176330
> Nov  0.7725926 0.7600906 5.636366 0.1774193


# Generate sample data
est31 = data.frame(p0=1:3,x=2:4)
rownames(est31) = c("Jan","Mar","Apr")

est30 = data.frame(p0=5:7,x=3:5)
rownames(est30) = c("Feb","Jun","May")

# -
est = rbind(est31,est30)
est
goodsort = c("Jan","Feb","Apr","May","Jun")
est.sorted = est[goodsort,]
est.sorted

__
R-help@r-project.org mailing list
https://stat.ethz.ch/mailman/listinfo/r-help
PLEASE do read the posting guide http://www.R-project.org/posting-guide.html
and provide commented, minimal, self-contained, reproducible code.


Re: [R] Dimensions of svd V matrix

2008-05-16 Thread Kenn Konstabel
I'm not an expert at all, but isn't it that you really want svd(x)$u to be
different (instead of V)?

that would be easy to do:

x <- matrix(rnorm(15), 3, 5)

s1 <- svd(x)
s2 <- svd(x, nv=ncol(x))

x1 <- s1$u %*% diag(s1$d) %*% t(s1$v)
x2 <- cbind(s2$u,1,1) %*% diag(c(s1$d,0,0)) %*% t(s2$v)

all.equal(x,x1,x2)

In other words, I would (perhaps naively) think that in your case the
"missing"  elements of d would be 0 anyway, and so the "missing" columns in
u are of no importance. (No idea, though, if this is of any help).

Kenn


On Fri, May 16, 2008 at 2:34 PM, Gad Abraham <[EMAIL PROTECTED]>
wrote:

> Hi,
>
> I'm trying to do PCA on a n by p wide matrix (n < p), and I'd like to get
> more principal components than there are rows. However, svd() only returns a
> V matrix of with n columns (instead of p) unless the argument nv=p is set
> (prcomp calls svd without setting it). Moreover, the eigenvalues returned
> are always min(n, p) instead of p, even if nv is set:
>
> > x <- matrix(rnorm(15), 3, 5)
> > dim(svd(x)$v)
> [1] 5 3
> > length(svd(x)$d)
> [1] 3
> > dim(svd(x, nv=5)$v)
> [1] 5 5
> > length(svd(x, nv=5)$d)
> [1] 3
> >
>
> Is there a way of getting more PCs and eigenvalues than rows? Is the
> eigen-decomposition of the covariance matrix really that numerically bad?
> (i.e., eigen(cov(x)) )
>
> Thanks,
> Gad
>
> --
> Gad Abraham
> Dept. CSSE and NICTA
> The University of Melbourne
> Parkville 3010, Victoria, Australia
> email: [EMAIL PROTECTED]
> web: 
> http://www.csse.unimelb.edu.au/~gabraham
>
> __
> R-help@r-project.org mailing list
> https://stat.ethz.ch/mailman/listinfo/r-help
> PLEASE do read the posting guide
> http://www.R-project.org/posting-guide.html
> and provide commented, minimal, self-contained, reproducible code.
>

[[alternative HTML version deleted]]

__
R-help@r-project.org mailing list
https://stat.ethz.ch/mailman/listinfo/r-help
PLEASE do read the posting guide http://www.R-project.org/posting-guide.html
and provide commented, minimal, self-contained, reproducible code.


[R] How to get subset of rows and columns that are most strongly correlated ?

2008-05-16 Thread Ng Stanley
Hi,

I have a relatively large matrix 20k rows and 1000 columns. Instead of
trying all possible combinations, is there a way to identify subset of rows
and columns that are most strongly correlated ?

Thanks
Stanley

[[alternative HTML version deleted]]

__
R-help@r-project.org mailing list
https://stat.ethz.ch/mailman/listinfo/r-help
PLEASE do read the posting guide http://www.R-project.org/posting-guide.html
and provide commented, minimal, self-contained, reproducible code.


Re: [R] heatmap on pre-established hclust output?

2008-05-16 Thread Jeremiah Rounds

> To: [EMAIL PROTECTED]> From: [EMAIL PROTECTED]> Date: Fri, 16 May 2008 
> 17:55:26 +0200> Subject: [R] heatmap on pre-established hclust output?> > 
> Hi,> > Can someone please guide me towards how to produce "heatmap" output 
> from the> output of "hclust" run prior to the actual "heatmap" call? I have 
> some> rather lengthy clustering going on and tweeking the visual output> with 
> "heatmap" recalculating the clustering every time is not feasible.> > Thanks, 
> Joh
 
I can't say that i have actually tackled this, but I have some experience with 
the functions you mentioned.  Heatmap takes an hclustfun function parameter.  
You can create a custom clustering function.  I don't believe there is a rule 
that says you have to do actual work in that function call.  Look at just 
returning the results of your more complicated clustering in that call without 
actually doing the calculations.
 
Jeremiah Rounds
Graduate Student
Utah State University
 
> > __> R-help@r-project.org 
> > mailing list> https://stat.ethz.ch/mailman/listinfo/r-help> PLEASE do read 
> > the posting guide http://www.R-project.org/posting-guide.html> and provide 
> > commented, minimal, self-contained, reproducible code.
_
E-mail for the greater good. Join the i’m Initiative from Microsoft.

ood
[[alternative HTML version deleted]]

__
R-help@r-project.org mailing list
https://stat.ethz.ch/mailman/listinfo/r-help
PLEASE do read the posting guide http://www.R-project.org/posting-guide.html
and provide commented, minimal, self-contained, reproducible code.


Re: [R] heatmap on pre-established hclust output?

2008-05-16 Thread James W. MacDonald

You just have to pass in the *dendrogram* to heatmap() or heatmap.2().

So if you have an hclust object for the rows and columns (called, say 
rhclust and chclust):


heatmap(datamatrix, Rowv = as.dendrogram(rhclust), Colv = 
as.dendrogram(chclust), otherargs)


Best,

Jim



Johannes Graumann wrote:

Hi,

Can someone please guide me towards how to produce "heatmap" output from the
output of "hclust" run prior to the actual "heatmap" call? I have some
rather lengthy clustering going on and tweeking the visual output
with "heatmap" recalculating the clustering every time is not feasible.

Thanks, Joh

__
R-help@r-project.org mailing list
https://stat.ethz.ch/mailman/listinfo/r-help
PLEASE do read the posting guide http://www.R-project.org/posting-guide.html
and provide commented, minimal, self-contained, reproducible code.


--
James W. MacDonald, M.S.
Biostatistician
Affymetrix and cDNA Microarray Core
University of Michigan Cancer Center
1500 E. Medical Center Drive
7410 CCGC
Ann Arbor MI 48109
734-647-5623

__
R-help@r-project.org mailing list
https://stat.ethz.ch/mailman/listinfo/r-help
PLEASE do read the posting guide http://www.R-project.org/posting-guide.html
and provide commented, minimal, self-contained, reproducible code.


Re: [R] glm model syntax

2008-05-16 Thread Berwin A Turlach
G'day Harold,

On Fri, 16 May 2008 11:43:32 -0400
"Doran, Harold" <[EMAIL PROTECTED]> wrote:

> N+M gives only the main effects, N:M gives only the interaction, and
> G*M gives the main effects and the interaction. 

I guess this begs the question what you mean with "N:M gives only the
interaction" ;-)

Consider:

R> (M <- gl(2, 1, length=12))
 [1] 1 2 1 2 1 2 1 2 1 2 1 2
Levels: 1 2
R> (N <- gl(2, 6))
 [1] 1 1 1 1 1 1 2 2 2 2 2 2
Levels: 1 2
R> dat <- data.frame(y= rnorm(12), N=N, M=M)
R> dim(model.matrix(y~N+M, dat))
[1] 12  3
R> dim(model.matrix(y~N:M, dat))
[1] 12  5
R> dim(model.matrix(y~N*M, dat))
[1] 12  4

Why has the model matrix of y~N:M more columns than the model matrix of
y~N*M if the former contains the interactions only and the latter
contains main terms and interactions?  Of course, if we leave the dim()
command away, we will see why.  Moreover, it seems that the model
matrix constructed from y~N:M has a redundant column.

Furthermore:

R> D1 <- model.matrix(y~N*M, dat)
R> D2 <- model.matrix(y~N:M, dat)
R> resid(lm(D1~D2-1))

Shows that the column space created by the model matrix of y~N*M is
completely contained within the column space created by the model
matrix of y~N:M, and it is easy to check that the reverse is also
true.  So it seems to me that y~N:M and y~N*M actually fit the same
models.  To see how to construct one design matrix from the other, try:

R> lm(D1~D2-1)

Thus, I guess the answer is that y~N+M fits a model with main terms
only while y~N:M and y~N*M fit the same model, namely a model with main
and interaction terms, these two formulations just create different
design matrices which has to be taken into account if one tries to
interpret the estimates.

Of course, all the above assumes that N and M are actually factors,
something that Birgit did not specify.  If N and M (or only one of
them) is a numeric vector, then the constructed matrices might be
different, but this is left as an exercise. ;-)  (Apparently, if N and
M are both numeric, then your summary is pretty much correct.)

Cheers,

Berwin

=== Full address =
Berwin A TurlachTel.: +65 6515 4416 (secr)
Dept of Statistics and Applied Probability+65 6515 6650 (self)
Faculty of Science  FAX : +65 6872 3919   
National University of Singapore
6 Science Drive 2, Blk S16, Level 7  e-mail: [EMAIL PROTECTED]
Singapore 117546http://www.stat.nus.edu.sg/~statba

__
R-help@r-project.org mailing list
https://stat.ethz.ch/mailman/listinfo/r-help
PLEASE do read the posting guide http://www.R-project.org/posting-guide.html
and provide commented, minimal, self-contained, reproducible code.


Re: [R] aggregate(), with multiple functions in FUN?

2008-05-16 Thread jim holtman
Will something like this work for you:

> d <- read.table(textConnection("ZIP DATA
+ 94111 12135.545
+ 93105 321354.65654
+ 94111 545.555
+ 94706 558858.66"), header=TRUE)
> closeAllConnections()
> aggregate(d$DATA, list(Zip = d$ZIP), FUN=median, na.rm=T)
Zip x
1 93105 321354.66
2 94111   6340.55
3 94706 558858.66
> do.call(rbind, by(d$DATA, list(Zip=d$ZIP), function(x){
+ c(Mean=mean(x), Median=median(x))
+ }))
   MeanMedian
93105 321354.66 321354.66
94111   6340.55   6340.55
94706 558858.66 558858.66
>
> t(sapply(split(d$DATA, d$ZIP), function(x) c(Mean=mean(x),
Median=median(x
   MeanMedian
93105 321354.66 321354.66
94111   6340.55   6340.55
94706 558858.66 558858.66


On Fri, May 16, 2008 at 10:18 AM, Mike ! <[EMAIL PROTECTED]> wrote:

>
>
> I've got a data frame having numerical data by zip code:
>
> ZIP DATA
> 94111 12135.545
> 93105 321354.65654
> 94111 545.555
> 94706 558858.66
> ...   ...
>
> I'm using this function to group records by ZIP and calculate the median of
> DATA:
>
> aggregate(d$DATA, list(Zip = d$ZIP), FUN=median, na.rm=T)
>
> but what I really want to do is to calculate several statistics (median,
> mean, etc.) for each group of records, so that I'll get a result organized
> like:
>
> Zip   median(DATA)mean(DATA)
> 94706   565555
> 94111   59585 6
> 93105   595685   666
> ...
>
> I tried using FUN=funstofun(median,mean), but found that doesn't work in
> aggregate.  Is there a straightforward way to do what I'm after (I'm pretty
> new to R)?  thanks
> _
> Change the world with e-mail. Join the i'm Initiative from Microsoft.
>
> ld
> __
> R-help@r-project.org mailing list
> https://stat.ethz.ch/mailman/listinfo/r-help
> PLEASE do read the posting guide
> http://www.R-project.org/posting-guide.html
> and provide commented, minimal, self-contained, reproducible code.
>



-- 
Jim Holtman
Cincinnati, OH
+1 513 646 9390

What is the problem you are trying to solve?

[[alternative HTML version deleted]]

__
R-help@r-project.org mailing list
https://stat.ethz.ch/mailman/listinfo/r-help
PLEASE do read the posting guide http://www.R-project.org/posting-guide.html
and provide commented, minimal, self-contained, reproducible code.


Re: [R] Box.test degrees of freedom

2008-05-16 Thread markleeds
 Spencer Graves has discussed this recently ( in the last couple of 
months ) in a thread and I think his FinTS package has a variant of the 
Box.test

 function that does what you need.



On Fri, May 16, 2008 at 11:45 AM, Nuno Prista wrote:


Dear colleagues,


I am new to R and statistics so please keep that in mind.

I have doubts on the df calculation of Ljung-Box test (Box.test). The
function seems to use always the df=lag=m and not df=m-p-q like 
suggested in

Ljung and Box (1978) paper (that is referenced).


Do you agree with this? If so, is there an R package function that 
computes
Ljung-Box test with the degrees of freedom as described in Ljung and 
Box

(1978) paper?


Note: this issue was discussed in
http://tolstoy.newcastle.edu.au/R/help/06/03/22768.html (and thread) 
but it

seems with little consensus.



Thanks in advance,


Nuno
__
Centro de Oceanografia - IO-FCUL, Portugal

Center for Quantitative Fisheries Ecology - ODU, USA




[[alternative HTML version deleted]]

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

and provide commented, minimal, self-contained, reproducible code.


__
R-help@r-project.org mailing list
https://stat.ethz.ch/mailman/listinfo/r-help
PLEASE do read the posting guide http://www.R-project.org/posting-guide.html
and provide commented, minimal, self-contained, reproducible code.


Re: [R] Integer / floating point question

2008-05-16 Thread Berwin A Turlach
G'day Erik,

On Fri, 16 May 2008 10:45:43 -0500
Erik Iverson <[EMAIL PROTECTED]> wrote:

[...]
> The help page for '%%' addresses this a bit, but then caveats it with 
> 'up to rounding error', which is really my question.  Is there ever 
> 'rounding error' with 2.0 %% 1 as opposed to 2 %% 1?

I am not in the position to give an authoritative answer, but I think
there should be no problem with rounding error in the situation that
you describe.  At least I hope there is no problem, otherwise I would
consider this a serious issue. :)

> >> However, my question is related to R FAQ 7.31, "Why doesn't R
> >> think these numbers are equal?" The first sentence of that FAQ
> >> reads, "The only numbers that can be represented exactly in R's
> >> numeric type are integers and fractions whose denominator is a
> >> power of 2."

Again, I did not write this FAQ answer and cannot give an authoritative
answer, but the word "integer" in that answer does not IMHO refer to
variables in R that are of integer type; in particular since the answer
discusses what kind of numbers "can be represented exactly in R's
numeric type". (Perhaps this should actually be plural since there are
several numeric types?)

My interpretation is that 2.0 and 2 are both *text constants* that
represent the integer 2, and that number is representable in a floating
point (and in an integer).

The paper by Goldberg, referenced in FAQ 7.31, contains a discussion on
whether it is possible (it is) to convert a floating point number
from binary representation to decimal representation and then back;
ending up with the same binary representation.  This kind of questions
are important if you use commands like write.table() or write.csv()
which write out floating points in decimal representation, readable to
normal humans.  When you read the data back in, you want to end up with
the exact same binary representation of the numbers.  Goldberg is
indeed an interesting paper to read.

And the comments I made above are based on my understanding of
Goldberg, 2 and 2.0 are both decimal representation of the integer 2,
and this number has an exact representation (in integer type variables
and in floating point type variables).  Hence, both these decimal
representation should lead to a binary representation that correspond
to that number exactly.

Thus, I would expect 
R> x <- 2.0
R> x %% 1 == 0
always to work and to return TRUE.  It is things like:
R> x <- sqrt(2.0)^2
R> x %% 1 == 0
that FAQ 7.31 is about and what, IMHO, the comment in the help page
of %% warns about; if the variable x contains a value that was created
by some finite precision floating point calculations.  But the
conversion from a textual representation of an integer to a binary
representation should not create problems.

Cheers,

Berwin

=== Full address =
Berwin A TurlachTel.: +65 6515 4416 (secr)
Dept of Statistics and Applied Probability+65 6515 6650 (self)
Faculty of Science  FAX : +65 6872 3919   
National University of Singapore
6 Science Drive 2, Blk S16, Level 7  e-mail: [EMAIL PROTECTED]
Singapore 117546http://www.stat.nus.edu.sg/~statba

__
R-help@r-project.org mailing list
https://stat.ethz.ch/mailman/listinfo/r-help
PLEASE do read the posting guide http://www.R-project.org/posting-guide.html
and provide commented, minimal, self-contained, reproducible code.


Re: [R] Integer / floating point question

2008-05-16 Thread Gabor Grothendieck
2, 2.0, 2e0 are all double while 2L is an integer.

On Fri, May 16, 2008 at 10:56 AM, Erik Iverson <[EMAIL PROTECTED]> wrote:
> Dear R-help -
>
> I have thought about this question for a bit, and come up with no
> satisfactory answer.
>
> Say I have the numeric vector t1, given as
>
> t1 <- c(1.0, 1.5, 2.0, 2.5, 3.0)
>
> I simply want to reliably extract the unique integers from t1, i.e., the
> vector c(1, 2, 3).  This is of course superficially simple to carry out.
>
> However, my question is related to R FAQ 7.31, "Why doesn't R think these
> numbers are equal?" The first sentence of that FAQ reads, "The only numbers
> that can be represented exactly in R's numeric type are integers and
> fractions whose denominator is a power of 2."
>
> All the methods I've devised to do the above task seem to ultimately rely on
> the fact that identical(x.0, x) == TRUE, for integer x.
>
> My assumption, which I'm hoping can be verified, is that, for example, 2.0
> (when, say, entered at the prompt and not computed from an algorithm) is an
> integer in the sense of FAQ 7.31.
>
> This seems to be the case on my machine.
>
>> identical(2.0, 2)
> [1] TRUE
>
> Apologies that this is such a trivial question, it seems so obvious on the
> surface, I just want to be sure I am understanding it correctly.
>
> Erik Iverson
> [EMAIL PROTECTED]
>
> sessionInfo()
> R version 2.7.0 (2008-04-22)
> i686-pc-linux-gnu
>
> locale:
> LC_CTYPE=en_US.UTF-8;LC_NUMERIC=C;LC_TIME=en_US.UTF-8;LC_COLLATE=en_US.UTF-8;LC_MONETARY=C;LC_MESSAGES=en_US.UTF-8;LC_PAPER=en_US.UTF-8;LC_NAME=C;LC_ADDRESS=C;LC_TELEPHONE=C;LC_MEASUREMENT=en_US.UTF-8;LC_IDENTIFICATION=C
>
> attached base packages:
> [1] grDevices datasets  tcltk splines   graphics  utils stats
> [8] methods   base
>
> other attached packages:
> [1] fortunes_1.3-4  debug_1.1.0 mvbutils_1.1.1  SPLOTS_1.3-47
> [5] Hmisc_3.4-3 chron_2.3-21survival_2.34-1 erik_0.0-1
>
> loaded via a namespace (and not attached):
> [1] cluster_1.11.10 grid_2.7.0  lattice_0.17-6
>
> __
> R-help@r-project.org mailing list
> https://stat.ethz.ch/mailman/listinfo/r-help
> PLEASE do read the posting guide http://www.R-project.org/posting-guide.html
> and provide commented, minimal, self-contained, reproducible code.
>

__
R-help@r-project.org mailing list
https://stat.ethz.ch/mailman/listinfo/r-help
PLEASE do read the posting guide http://www.R-project.org/posting-guide.html
and provide commented, minimal, self-contained, reproducible code.


Re: [R] glm model syntax

2008-05-16 Thread Doran, Harold
Dear Berwin:

Indeed, it seems I was incorrect. Using your data, it seems that only in
the case that the variables are numeric would my earlier statements be
true, as you note. For example, if we did

lm(y ~ as.numeric(N)+as.numeric(M), dat)
lm(y ~ as.numeric(N)*as.numeric(M), dat)
lm(y ~ as.numeric(N):as.numeric(M), dat) 

Then the latter two are different, but only under the coercion to
numeric.

> -Original Message-
> From: Berwin A Turlach [mailto:[EMAIL PROTECTED] 
> Sent: Friday, May 16, 2008 12:27 PM
> To: Doran, Harold
> Cc: Birgit Lemcke; R Hilfe
> Subject: Re: [R] glm model syntax
> 
> G'day Harold,
> 
> On Fri, 16 May 2008 11:43:32 -0400
> "Doran, Harold" <[EMAIL PROTECTED]> wrote:
> 
> > N+M gives only the main effects, N:M gives only the interaction, and
> > G*M gives the main effects and the interaction. 
> 
> I guess this begs the question what you mean with "N:M gives 
> only the interaction" ;-)
> 
> Consider:
> 
> R> (M <- gl(2, 1, length=12))
>  [1] 1 2 1 2 1 2 1 2 1 2 1 2
> Levels: 1 2
> R> (N <- gl(2, 6))
>  [1] 1 1 1 1 1 1 2 2 2 2 2 2
> Levels: 1 2
> R> dat <- data.frame(y= rnorm(12), N=N, M=M) dim(model.matrix(y~N+M, 
> R> dat))
> [1] 12  3
> R> dim(model.matrix(y~N:M, dat))
> [1] 12  5
> R> dim(model.matrix(y~N*M, dat))
> [1] 12  4
> 
> Why has the model matrix of y~N:M more columns than the model 
> matrix of y~N*M if the former contains the interactions only 
> and the latter contains main terms and interactions?  Of 
> course, if we leave the dim() command away, we will see why.  
> Moreover, it seems that the model matrix constructed from 
> y~N:M has a redundant column.
> 
> Furthermore:
> 
> R> D1 <- model.matrix(y~N*M, dat)
> R> D2 <- model.matrix(y~N:M, dat)
> R> resid(lm(D1~D2-1))
> 
> Shows that the column space created by the model matrix of 
> y~N*M is completely contained within the column space created 
> by the model matrix of y~N:M, and it is easy to check that 
> the reverse is also true.  So it seems to me that y~N:M and 
> y~N*M actually fit the same models.  To see how to construct 
> one design matrix from the other, try:
> 
> R> lm(D1~D2-1)
> 
> Thus, I guess the answer is that y~N+M fits a model with main 
> terms only while y~N:M and y~N*M fit the same model, namely a 
> model with main and interaction terms, these two formulations 
> just create different design matrices which has to be taken 
> into account if one tries to interpret the estimates.
> 
> Of course, all the above assumes that N and M are actually 
> factors, something that Birgit did not specify.  If N and M 
> (or only one of
> them) is a numeric vector, then the constructed matrices 
> might be different, but this is left as an exercise. ;-)  
> (Apparently, if N and M are both numeric, then your summary 
> is pretty much correct.)
> 
> Cheers,
> 
>   Berwin
> 
> === Full address =
> Berwin A TurlachTel.: +65 6515 4416 (secr)
> Dept of Statistics and Applied Probability+65 6515 6650 (self)
> Faculty of Science  FAX : +65 6872 3919   
> National University of Singapore
> 6 Science Drive 2, Blk S16, Level 7  e-mail: [EMAIL PROTECTED]
> Singapore 117546http://www.stat.nus.edu.sg/~statba
> 

__
R-help@r-project.org mailing list
https://stat.ethz.ch/mailman/listinfo/r-help
PLEASE do read the posting guide http://www.R-project.org/posting-guide.html
and provide commented, minimal, self-contained, reproducible code.


Re: [R] Integer / floating point question

2008-05-16 Thread Duncan Murdoch

On 5/16/2008 11:45 AM, Erik Iverson wrote:

Marc -

Marc Schwartz wrote:

on 05/16/2008 09:56 AM Erik Iverson wrote:

Dear R-help -

I have thought about this question for a bit, and come up with no 
satisfactory answer.


Say I have the numeric vector t1, given as

t1 <- c(1.0, 1.5, 2.0, 2.5, 3.0)

I simply want to reliably extract the unique integers from t1, i.e., 
the vector c(1, 2, 3).  This is of course superficially simple to 
carry out.


Use modulo division:

 > t1[t1 %% 1 == 0]
[1] 1 2 3

or

 > unique(t1[t1 %% 1 == 0])
[1] 1 2 3


Yes, that is one of the solutions.  However, can I be sure that, say,

2.0 %% 1 == 0

The help page for '%%' addresses this a bit, but then caveats it with 
'up to rounding error', which is really my question.  Is there ever 
'rounding error' with 2.0 %% 1 as opposed to 2 %% 1?


If you enter them as part of your source, then 2.0 and 2 are guaranteed 
to be the same number, because both are exactly representable as the 
ratio of an integer and a power of 2:  2/2^0, or 1/2^(-1).  (There are 
limits on the range of both the numerator and denominator for this to 
work, but they are quite wide.)


If you calculate them, e.g. as 0.2*10, then there is no guarantee, and 
the results may vary from machine to machine.  This is because 0.2 is 
*not* representable as an integer over a power of two.  It will likely 
be represented to 52 or 53 bit precision, but with some 
compiler/hardware combinations, you might get 64 bit (or other) 
precision in intermediate results.  I don't think R currently does this, 
but I wouldn't be very surprised if there were situations where it did.


There might be cases where R doesn't correctly convert literal numeric 
constants into the closest floating point value, but I think it would be 
considered a serious bug if it messed up small integers.


Duncan Murdoch








However, my question is related to R FAQ 7.31, "Why doesn't R think 
these numbers are equal?" The first sentence of that FAQ reads, "The 
only numbers that can be represented exactly in R's numeric type are 
integers and fractions whose denominator is a power of 2."


All the methods I've devised to do the above task seem to ultimately 
rely on the fact that identical(x.0, x) == TRUE, for integer x.


My assumption, which I'm hoping can be verified, is that, for example, 
2.0 (when, say, entered at the prompt and not computed from an 
algorithm) is an integer in the sense of FAQ 7.31.


This seems to be the case on my machine.

 > identical(2.0, 2)
[1] TRUE

Apologies that this is such a trivial question, it seems so obvious on 
the surface, I just want to be sure I am understanding it correctly.


Keep in mind that by default and unless specifically coerced to integer, 
numbers in R are double precision floats:


 > is.integer(2)
[1] FALSE

 > is.numeric(2)
[1] TRUE

 > is.integer(2.0)
[1] FALSE

 > is.numeric(2.0)
[1] TRUE


So:

 > identical(2.0, as.integer(2))
[1] FALSE


Does that help?


A bit, and this is the source of my confusion.  Can I always assume that 
2.0 == 2 when the class of each is 'numeric'?




Marc Schwartz


__
R-help@r-project.org mailing list
https://stat.ethz.ch/mailman/listinfo/r-help
PLEASE do read the posting guide http://www.R-project.org/posting-guide.html
and provide commented, minimal, self-contained, reproducible code.


__
R-help@r-project.org mailing list
https://stat.ethz.ch/mailman/listinfo/r-help
PLEASE do read the posting guide http://www.R-project.org/posting-guide.html
and provide commented, minimal, self-contained, reproducible code.


[R] autocorrelation error: cannot allocate vector of size 220979 Kb

2008-05-16 Thread J S
Dear R community,



I used a linear mixed model (named lm11) to model daily soil temperature
depending upon vegetation cover and air temperature. I have almost 17,000
observations for six years.



I can not account for autocorrelation in my model, since I receive the error
message after applying the function:



update(lm11, corr=corAR1())



Error: cannot allocate vector of size 220979 Kb



Do you have any suggestions?



Thanks, Julia

[[alternative HTML version deleted]]

__
R-help@r-project.org mailing list
https://stat.ethz.ch/mailman/listinfo/r-help
PLEASE do read the posting guide http://www.R-project.org/posting-guide.html
and provide commented, minimal, self-contained, reproducible code.


[R] R package building

2008-05-16 Thread Angelos Markos
In a few days I'll give a talk on R package development and my
personal experience, at the 3rd Free / Libre / Open Source Software
(FLOSS) Conference which will take place on May 27th & 28th 2008, in
the National Technical University of Athens, in Greece.

I would appreciate if you could share
your thoughts with me; What are today's obstacles on R package
building, according to your
opinion and personal experience.

Thanks,
--
Angelos I. Markos
Scientific Associate, Dpt of Exact Sciences, TEI of Thessaloniki, GR
"I'm not an outlier; I just haven't found my distribution yet"

__
R-help@r-project.org mailing list
https://stat.ethz.ch/mailman/listinfo/r-help
PLEASE do read the posting guide http://www.R-project.org/posting-guide.html
and provide commented, minimal, self-contained, reproducible code.


[R] 64-bit R and cache memory

2008-05-16 Thread Joram Posma

Dear all,

I have a few questions regarding the 64 bit version of R and the cache 
memory R uses.


---
Computer & software info:

OS: kUbuntu Feasty Fawn 7.04 (64-bit)
Processor: AMD Opteron 64-bit
R: version 2.7.0 (64-bit)
Cache memory: currently 16 GB (was 2 GB)
Outcome of 'limit' command in shell: cputime unlimited, filesize 
unlimited, datasize unlimited, stacksize 8192 kbytes, coredumpsize 0 
kbytes, memoryuse unlimited, vmemoryuse unlimited, descriptors 1024, 
memorylocked unlimited, maxproc unlimited

---

a. We have recently upgraded the cache memory from 2 to 16 GB. However, 
we have noticed that somehow R still swaps memory when datasets 
exceeding 2 GB in size are used. An indication that R uses approx. 2 GB 
of cache memory is that sometimes R also kills the session when datasets 
> 2 GB are loaded. How/where can we see how much cache memory R uses 
(since memory.size and memory.limit are only for windows, and to us 
those might be what we need)? Could this be caused by the limit of the 
stack size (we are not exactly sure what the stack size is either) ?
b. And how can we increase the cache memory used by R to 14 or even 16 
GB (which might be tricky when running other programs, but still)?


So in general: how can we get R to use the full memory capacity of the 
computer?


--
Joram Posma

Department of Analytical Chemistry – Chemometics Radboud University 
Nijmegen (Netherlands) http://www.science.ru.nl/cac


__
R-help@r-project.org mailing list
https://stat.ethz.ch/mailman/listinfo/r-help
PLEASE do read the posting guide http://www.R-project.org/posting-guide.html
and provide commented, minimal, self-contained, reproducible code.


Re: [R] R package building

2008-05-16 Thread Duncan Murdoch

On 5/16/2008 2:08 PM, Angelos Markos wrote:

In a few days I'll give a talk on R package development and my
personal experience, at the 3rd Free / Libre / Open Source Software
(FLOSS) Conference which will take place on May 27th & 28th 2008, in
the National Technical University of Athens, in Greece.

I would appreciate if you could share
your thoughts with me; What are today's obstacles on R package
building, according to your
opinion and personal experience.


If you get useful private replies to this, could you please summarize 
them on the R-devel list?


Duncan Murdoch

__
R-help@r-project.org mailing list
https://stat.ethz.ch/mailman/listinfo/r-help
PLEASE do read the posting guide http://www.R-project.org/posting-guide.html
and provide commented, minimal, self-contained, reproducible code.


Re: [R] R package building

2008-05-16 Thread Doran, Harold
Wow, this is going open a can :) OK, my comments below in no way
discount the enormous efforts of R core, but it is my experience.

Using Windows, the biggest obstacles are collecting all programs needed
to build the package and then structuring your OS path exactly (exactly)
as D. Murdoch says it needs to be.

As it turns out, once you collect these programs and fix your path, the
package build is actually quite simple. 

Second, I found building a vignette impossible, so I just drop in the
pdf file for distribution. I followed exact directions from the R News
article teaching how to do this and made sure everything was set up
correctly. After no success, I posted to R-Help where many told me
everything seemed to be set up properly, but still no success.


> -Original Message-
> From: [EMAIL PROTECTED] 
> [mailto:[EMAIL PROTECTED] On Behalf Of Angelos Markos
> Sent: Friday, May 16, 2008 2:08 PM
> To: r-help@r-project.org
> Subject: [R] R package building
> 
> In a few days I'll give a talk on R package development and 
> my personal experience, at the 3rd Free / Libre / Open Source Software
> (FLOSS) Conference which will take place on May 27th & 28th 
> 2008, in the National Technical University of Athens, in Greece.
> 
> I would appreciate if you could share
> your thoughts with me; What are today's obstacles on R 
> package building, according to your opinion and personal experience.
> 
> Thanks,
> --
> Angelos I. Markos
> Scientific Associate, Dpt of Exact Sciences, TEI of 
> Thessaloniki, GR "I'm not an outlier; I just haven't found my 
> distribution yet"
> 
> __
> R-help@r-project.org mailing list
> https://stat.ethz.ch/mailman/listinfo/r-help
> PLEASE do read the posting guide 
> http://www.R-project.org/posting-guide.html
> and provide commented, minimal, self-contained, reproducible code.
> 

__
R-help@r-project.org mailing list
https://stat.ethz.ch/mailman/listinfo/r-help
PLEASE do read the posting guide http://www.R-project.org/posting-guide.html
and provide commented, minimal, self-contained, reproducible code.


Re: [R] Integer / floating point question

2008-05-16 Thread Prof Brian Ripley
'numeric' is a class but not a type -- so I think the FAQ is wrongly 
worded but the concept is well defined (despite the presence of 
is.numeric!) But it does not say that all such numbers can be represented 
exactly, and only some can.


On Sat, 17 May 2008, Berwin A Turlach wrote:


G'day Erik,

On Fri, 16 May 2008 10:45:43 -0500
Erik Iverson <[EMAIL PROTECTED]> wrote:

[...]

The help page for '%%' addresses this a bit, but then caveats it with
'up to rounding error', which is really my question.  Is there ever
'rounding error' with 2.0 %% 1 as opposed to 2 %% 1?


I am not in the position to give an authoritative answer, but I think
there should be no problem with rounding error in the situation that
you describe.  At least I hope there is no problem, otherwise I would
consider this a serious issue. :)


However, my question is related to R FAQ 7.31, "Why doesn't R
think these numbers are equal?" The first sentence of that FAQ
reads, "The only numbers that can be represented exactly in R's
numeric type are integers and fractions whose denominator is a
power of 2."


Again, I did not write this FAQ answer and cannot give an authoritative
answer, but the word "integer" in that answer does not IMHO refer to
variables in R that are of integer type; in particular since the answer
discusses what kind of numbers "can be represented exactly in R's
numeric type". (Perhaps this should actually be plural since there are
several numeric types?)

My interpretation is that 2.0 and 2 are both *text constants* that
represent the integer 2, and that number is representable in a floating
point (and in an integer).

The paper by Goldberg, referenced in FAQ 7.31, contains a discussion on
whether it is possible (it is) to convert a floating point number
from binary representation to decimal representation and then back;
ending up with the same binary representation.  This kind of questions
are important if you use commands like write.table() or write.csv()
which write out floating points in decimal representation, readable to
normal humans.  When you read the data back in, you want to end up with
the exact same binary representation of the numbers.  Goldberg is
indeed an interesting paper to read.


Possible to write out and read in *on the same computer*. R doesn't aspire 
to that, as it assumes text files are for humans or transfer to unknown 
other programs, and does provides binary save formats.  (Human-friendly 
numbers will be written out faithfully, but if there is a choice between a 
short representation and a one with sequence of 9s, the short one will be 
chosen.)



And the comments I made above are based on my understanding of
Goldberg, 2 and 2.0 are both decimal representation of the integer 2,
and this number has an exact representation (in integer type variables
and in floating point type variables).  Hence, both these decimal
representation should lead to a binary representation that correspond
to that number exactly.


They should, at least for small integer values.  In R this relies on 
strtod for which C99 and POSIX say


  If the subject sequence has the decimal form and at most DECIMAL_DIG
  (defined in ) significant digits, the result should be
  correctly rounded [...].

So this means that x.0 for x up to 10^15 or so should be represented 
exactly and be different from x.y for y =1...9.


Note too that non-integer values > 10^16 or so will be represented as 
integers.


Lots of 'should' here -- compiler and runtime writers do make mistakes and 
may not have been working to the C99 standard (e.g. the Windows runtime 
predates it).




Thus, I would expect
R> x <- 2.0
R> x %% 1 == 0
always to work and to return TRUE.  It is things like:
R> x <- sqrt(2.0)^2
R> x %% 1 == 0
that FAQ 7.31 is about and what, IMHO, the comment in the help page
of %% warns about; if the variable x contains a value that was created
by some finite precision floating point calculations.  But the
conversion from a textual representation of an integer to a binary
representation should not create problems.

Cheers,

Berwin

=== Full address =
Berwin A TurlachTel.: +65 6515 4416 (secr)
Dept of Statistics and Applied Probability+65 6515 6650 (self)
Faculty of Science  FAX : +65 6872 3919
National University of Singapore
6 Science Drive 2, Blk S16, Level 7  e-mail: [EMAIL PROTECTED]
Singapore 117546http://www.stat.nus.edu.sg/~statba

__
R-help@r-project.org mailing list
https://stat.ethz.ch/mailman/listinfo/r-help
PLEASE do read the posting guide http://www.R-project.org/posting-guide.html
and provide commented, minimal, self-contained, reproducible code.



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

Re: [R] Box.test degrees of freedom

2008-05-16 Thread Prof Brian Ripley

Bear in mind that Box.test knows nothing about p or q: it says

 Compute the Box-Pierce or Ljung-Box test statistic for examining
 the null hypothesis of independence in a given time series.

I think you are referring to its application to the residuals of an 
ARMA(p, q) fit, and that is not what Box.test says it does.


It is very easy to edit the code if you want to use a different degrees of
freedom.


On Fri, 16 May 2008, Nuno Prista wrote:


Dear colleagues,

I am new to R and statistics so please keep that in mind.

I have doubts on the df calculation of Ljung-Box test (Box.test). The
function seems to use always the df=lag=m and not df=m-p-q like suggested in
Ljung and Box (1978) paper (that is referenced).

Do you agree with this? If so, is there an R package function that computes
Ljung-Box test with the degrees of freedom as described in Ljung and Box
(1978) paper?

Note: this issue was discussed in
http://tolstoy.newcastle.edu.au/R/help/06/03/22768.html (and thread) but it
seems with little consensus.

Thanks in advance,

Nuno
__

Centro de Oceanografia - IO-FCUL, Portugal
Center for Quantitative Fisheries Ecology - ODU, USA

[[alternative HTML version deleted]]

__
R-help@r-project.org mailing list
https://stat.ethz.ch/mailman/listinfo/r-help
PLEASE do read the posting guide http://www.R-project.org/posting-guide.html
and provide commented, minimal, self-contained, reproducible code.



--
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@r-project.org mailing list
https://stat.ethz.ch/mailman/listinfo/r-help
PLEASE do read the posting guide http://www.R-project.org/posting-guide.html
and provide commented, minimal, self-contained, reproducible code.


Re: [R] R package building

2008-05-16 Thread Gabor Grothendieck
On Fri, May 16, 2008 at 2:20 PM, Doran, Harold <[EMAIL PROTECTED]> wrote:
> Wow, this is going open a can :) OK, my comments below in no way
> discount the enormous efforts of R core, but it is my experience.
>
> Using Windows, the biggest obstacles are collecting all programs needed
> to build the package and then structuring your OS path exactly (exactly)
> as D. Murdoch says it needs to be.

If you use the latest Rcmd.bat from batchfiles (and also the latest rtools
which it requires) then you don't have to change your path at all.  With
just a vanilla PATH place Rcmd.bat from the batchfiles distribution
anywhere in your PATH and build the package as usual.
There is more info on the home page:

http://batchfiles.googlecode.com

>
> As it turns out, once you collect these programs and fix your path, the
> package build is actually quite simple.
>
> Second, I found building a vignette impossible, so I just drop in the
> pdf file for distribution. I followed exact directions from the R News
> article teaching how to do this and made sure everything was set up
> correctly. After no success, I posted to R-Help where many told me
> everything seemed to be set up properly, but still no success.
>
>
>> -Original Message-
>> From: [EMAIL PROTECTED]
>> [mailto:[EMAIL PROTECTED] On Behalf Of Angelos Markos
>> Sent: Friday, May 16, 2008 2:08 PM
>> To: r-help@r-project.org
>> Subject: [R] R package building
>>
>> In a few days I'll give a talk on R package development and
>> my personal experience, at the 3rd Free / Libre / Open Source Software
>> (FLOSS) Conference which will take place on May 27th & 28th
>> 2008, in the National Technical University of Athens, in Greece.
>>
>> I would appreciate if you could share
>> your thoughts with me; What are today's obstacles on R
>> package building, according to your opinion and personal experience.
>>
>> Thanks,
>> --
>> Angelos I. Markos
>> Scientific Associate, Dpt of Exact Sciences, TEI of
>> Thessaloniki, GR "I'm not an outlier; I just haven't found my
>> distribution yet"
>>
>> __
>> R-help@r-project.org mailing list
>> https://stat.ethz.ch/mailman/listinfo/r-help
>> PLEASE do read the posting guide
>> http://www.R-project.org/posting-guide.html
>> and provide commented, minimal, self-contained, reproducible code.
>>
>
> __
> R-help@r-project.org mailing list
> https://stat.ethz.ch/mailman/listinfo/r-help
> PLEASE do read the posting guide http://www.R-project.org/posting-guide.html
> and provide commented, minimal, self-contained, reproducible code.
>

__
R-help@r-project.org mailing list
https://stat.ethz.ch/mailman/listinfo/r-help
PLEASE do read the posting guide http://www.R-project.org/posting-guide.html
and provide commented, minimal, self-contained, reproducible code.


[R] wmtsa (wavCWT)

2008-05-16 Thread stephen sefick
I can send data along, but it is too large for the list:
I am using wmtsa and the function wavCWT

I would like to use the range.scale to only evaluate a subset of
frequencies.

deltat of the time series that I am trying to analyze is 1
d = wavCWT(RM202.ts, range.scale = c(96, 2688))
and I get the error message

Error in wavCWT(RM202.ts, scale.range = c(96, 2688) :
  Minimum scale must be greater than or equal to sampling interval of the
time series

I have tried many other integers in this argument and I can't get anything
to work except deltat(RM202.ts) and 1 which are the same thing.  Is there a
way to specify a different frequency range- it seems to me that 96 is larger
than one.  I must be confusing something.

Stephen



-- 
Let's not spend our time and resources thinking about things that are so
little or so large that all they really do for us is puff us up and make us
feel like gods. We are mammals, and have not exhausted the annoying little
problems of being mammals.

-K. Mullis

[[alternative HTML version deleted]]

__
R-help@r-project.org mailing list
https://stat.ethz.ch/mailman/listinfo/r-help
PLEASE do read the posting guide http://www.R-project.org/posting-guide.html
and provide commented, minimal, self-contained, reproducible code.


Re: [R] Integer / floating point question

2008-05-16 Thread Berwin A Turlach
G'day Brian,

On Fri, 16 May 2008 19:28:59 +0100 (BST)
Prof Brian Ripley <[EMAIL PROTECTED]> wrote:

> 'numeric' is a class but not a type -- so I think the FAQ is wrongly 
> worded but the concept is well defined 

Though there may be multiple definitions. :-)

Reading a bit in "R Language Definition" (yes, I am aware that it is a
draft), 'numeric' seems to be also used as a mode.  I guess this comes
from S3, the mode (no pun intended) that I am still using and thinking
in mostly, and that 'numeric' being a class came in with S4.  And I
notice that mode(1L) and class(1L) gives different results, the former
returns "numeric" while the latter returns "integer".
 
Hence, when I read "R's numeric type" in the FAQ, I take this as
referring to those basic types that are of mode numeric, i.e. integer
and real.  I am not sure whether changing this to "R's object of
mode 'numeric'" or "R's object class 'numeric'" will make the answer
more readable/understandable. 

> But it does not say that all such numbers can be represented
> exactly, and only some can.

I am well aware that integers and reals can only hold "integers and
fractions whose denominator is a power of 2" from a limited range; in
particular, the former will not hold any fractions.  However, given the
discussion in Goldberg (which FAQ 7.31 points to) on changing from
binary to decimal representation and back, I would expect that given
any such number (within the appropriate range) in decimal
representation, it would be transformed into the correct, exact binary
representation. However, I also know that if I stumble across an
example where this is not the case, I shall only complain after
ensuring that documented behaviour is violated and that the FAQ not
necessarily documents expected behaviour.

I guess Duncan's answer said it all, at the extreme ends of the
appropriate ranges surprises might lurk, but it would be considered a
serious bug if R did not transform small integers into their exact
binary representation.

Cheers,

Berwin

__
R-help@r-project.org mailing list
https://stat.ethz.ch/mailman/listinfo/r-help
PLEASE do read the posting guide http://www.R-project.org/posting-guide.html
and provide commented, minimal, self-contained, reproducible code.


[R] xyplot: subscripts, groups and subset

2008-05-16 Thread Jim Price

I have stumbled across something in the Lattice package that is vexing me.
Consider the code below:
__

library(lattice)


myData <- expand.grid(sub = factor(1:16), time = 1:10)

myData$observed <- rnorm(nrow(myData))
myData$fitted <- with(myData, ave(observed, sub, FUN = mean))
myData$event.time <- with(myData, ave(observed, sub, FUN = function(.x) 10 *
runif(1)))

myData <- myData[order(myData$sub, myData$time),]



# This version works...
xyplot(
fitted + observed ~ time | sub,
data = myData,
subscripts = TRUE,
panel = function(..., groups = groups, subscripts = subscripts)
{
panel.xyplot(..., groups = groups, subscripts = subscripts)

event.time <- unique(myData$event.time[subscripts])
panel.abline(v = event.time, lty = 2, col = 'green')
},
type = c('l','p'),
distribute.type = TRUE,
as.table = TRUE
)



# ...but when you add the subset parameter it produces multiple index lines
per subject
xyplot(
fitted + observed ~ time | sub,
data = myData,
subset = sub %in% sample(unique(sub), 9),
subscripts = TRUE,
panel = function(..., groups = groups, subscripts = subscripts)
{
panel.xyplot(..., groups = groups, subscripts = subscripts)

event.time <- unique(myData$event.time[subscripts])
#   print(event.time)
panel.abline(v = event.time, lty = 2, col = 'green')
},
type = c('l','p'),
distribute.type = TRUE,
as.table = TRUE
)

___


The (commented out) print statement I think indicates that there is a data
reordering going on for the second example, that is causing the multiple
index lines issue. Is there a neat solution to get the correct index lines
per subject, or do I need a workaround? Or am I missing something
fundamental in the code above that is causing issues?


> sessionInfo()
R version 2.7.0 (2008-04-22) 
i386-pc-mingw32 

locale:
LC_COLLATE=English_United States.1252;LC_CTYPE=English_United
States.1252;LC_MONETARY=English_United
States.1252;LC_NUMERIC=C;LC_TIME=English_United States.1252

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

other attached packages:
[1] lattice_0.17-6

loaded via a namespace (and not attached):
[1] grid_2.7.0



Thanks,
Jim Price
Cardiome Pharmaceutical Corporation.
-- 
View this message in context: 
http://www.nabble.com/xyplot%3A-subscripts%2C-groups-and-subset-tp17282996p17282996.html
Sent from the R help mailing list archive at Nabble.com.

__
R-help@r-project.org mailing list
https://stat.ethz.ch/mailman/listinfo/r-help
PLEASE do read the posting guide http://www.R-project.org/posting-guide.html
and provide commented, minimal, self-contained, reproducible code.


[R] gam negative.binomial

2008-05-16 Thread Markus Loecher
Dear list members,
while I appreciate the possibility to deal with overdispersion for count
data either by specifying the family argument to be quasipoisson() or
negative.binomial(), it estimates just one overdispersion parameter for the
entire data set.
In my applications I often would like the estimate for overdispersion  to
depend on the covariates in the same manner as the mean.

For example,
#either library(mgcv) or library(gam):

 x <- seq(0,1,length = 100)*2*pi
 mu <- 4+ 2*sin(x)
 size <- 4 + 2*cos(x)
data <- cbind.data.frame(x<- rep(x,10), y =
rnbinom(10*100,mu=rep(mu,10),size=rep(size,10)))

x.gam <- gam(y~s(x), data=data,family=quasipoisson())
plot(x.gam)
summary(x.gam)

How would I get a smooth estimate of the overdispersion ?

Thanks,

Markus

[[alternative HTML version deleted]]

__
R-help@r-project.org mailing list
https://stat.ethz.ch/mailman/listinfo/r-help
PLEASE do read the posting guide http://www.R-project.org/posting-guide.html
and provide commented, minimal, self-contained, reproducible code.


[R] Identify groups

2008-05-16 Thread mike Ad.


Dear group,

I have hundreds
of independent data sets, each data sets contains >100 values. In some data
sets, all the values can be classified into several groups with clear
difference between groups; while in some other data sets, all the values are
randomly distributed. I would like to find a statistics method to automatically
pick out the data sets which have group pattern, or specifically found data
sets have certain number of groups, e.g.  2, 3, 4. 

Are there
any functions or packages that could solve this issue, or any other suggestions?
 Many Thanks!

/Mike

 


_
Make every e-mail and IM count. Join the i’m Initiative from Microsoft.

[[alternative HTML version deleted]]

__
R-help@r-project.org mailing list
https://stat.ethz.ch/mailman/listinfo/r-help
PLEASE do read the posting guide http://www.R-project.org/posting-guide.html
and provide commented, minimal, self-contained, reproducible code.


[R] wavCWT plot

2008-05-16 Thread stephen sefick
is there a way to plot the modulus graph with a different color scheme.  The
contrast is very bad (for my eyes).

-- 
Let's not spend our time and resources thinking about things that are so
little or so large that all they really do for us is puff us up and make us
feel like gods. We are mammals, and have not exhausted the annoying little
problems of being mammals.

-K. Mullis

[[alternative HTML version deleted]]

__
R-help@r-project.org mailing list
https://stat.ethz.ch/mailman/listinfo/r-help
PLEASE do read the posting guide http://www.R-project.org/posting-guide.html
and provide commented, minimal, self-contained, reproducible code.


[R] autocorrelation in nlme; Error: cannot allocate vector of size

2008-05-16 Thread J S
Dear R community,



I used a linear mixed model (named lm11) to model daily soil temperature
depending upon vegetation cover and air temperature. I have almost 17,000
observations for six years.



I can not account for autocorrelation in my model, since I receive the error
message after applying the function:



update(lm11, corr=corAR1())



Error: cannot allocate vector of size 220979 Kb



Do you have any suggestions?



Thanks, Julia

[[alternative HTML version deleted]]

__
R-help@r-project.org mailing list
https://stat.ethz.ch/mailman/listinfo/r-help
PLEASE do read the posting guide http://www.R-project.org/posting-guide.html
and provide commented, minimal, self-contained, reproducible code.


Re: [R] autocorrelation in nlme; Error: cannot allocate vector of size

2008-05-16 Thread ONKELINX, Thierry
Dear Julia,

You'll need to give more details on your model and the structure of your
dataset. The problem will probably be in the specification of the random
effects. But without the detail we can't check that.

Thierry




ir. Thierry Onkelinx
Instituut voor natuur- en bosonderzoek / Research Institute for Nature
and Forest
Cel biometrie, methodologie en kwaliteitszorg / Section biometrics,
methodology and quality assurance
Gaverstraat 4
9500 Geraardsbergen
Belgium 
tel. + 32 54/436 185
[EMAIL PROTECTED] 
www.inbo.be 

To call in the statistician after the experiment is done may be no more
than asking him to perform a post-mortem examination: he may be able to
say what the experiment died of.
~ Sir Ronald Aylmer Fisher

The plural of anecdote is not data.
~ Roger Brinner

The combination of some data and an aching desire for an answer does not
ensure that a reasonable answer can be extracted from a given body of
data.
~ John Tukey

-Oorspronkelijk bericht-
Van: [EMAIL PROTECTED] [mailto:[EMAIL PROTECTED]
Namens J S
Verzonden: vrijdag 16 mei 2008 23:06
Aan: r-help@r-project.org
Onderwerp: [R] autocorrelation in nlme; Error: cannot allocate vector of
size

Dear R community,



I used a linear mixed model (named lm11) to model daily soil temperature
depending upon vegetation cover and air temperature. I have almost
17,000
observations for six years.



I can not account for autocorrelation in my model, since I receive the
error
message after applying the function:



update(lm11, corr=corAR1())



Error: cannot allocate vector of size 220979 Kb



Do you have any suggestions?



Thanks, Julia

[[alternative HTML version deleted]]

__
R-help@r-project.org mailing list
https://stat.ethz.ch/mailman/listinfo/r-help
PLEASE do read the posting guide
http://www.R-project.org/posting-guide.html
and provide commented, minimal, self-contained, reproducible code.

__
R-help@r-project.org mailing list
https://stat.ethz.ch/mailman/listinfo/r-help
PLEASE do read the posting guide http://www.R-project.org/posting-guide.html
and provide commented, minimal, self-contained, reproducible code.


[R] sample function

2008-05-16 Thread carol white
Hi,
I use sample function in a for loop to get a new random indexing but I don't 
know why, I get the same indexes in different iterations of for.

I have a script that uses for loop calling crossval function (the same 
definition as crossval in bootstrap package) defined in another script. Both 
scripts are loaded into R by source function. When I reach
o <- sample (1:n) where n is the length of a vector, for ex 10
print(o)
I always get the same indexes at the same position
  3  7  5  6 10  9  2  1  8  4

note that i don't change the value of o anywhere in the program. only, at a new 
iteration, o gets initialized.

but when I use sample(1:n) in R environement, random sampling works perfectly.

Best

carol
---
for (i in 1:5)
new.lst = crossval(data, y, s, 3)
 
crossval <- function (x, y, s, ngroup)
{
 
   call <- match.call()
x <- as.matrix(x)
n <- length(y)
  
if (ngroup < 2) {
stop("ngroup should be greater than or equal to 2")
}
if (ngroup > n) {
stop("ngroup should be less than or equal to the number of 
observations")
}
if (ngroup == n) {
groups <- 1:n
leave.out <- 1
}

if (ngroup < n) {
leave.out <- trunc(n/ngroup)
o <- sample(1:n)
print(o)
groups <- vector("list", ngroup)
for (j in 1:(ngroup - 1)) {
jj <- (1 + (j - 1) * leave.out)
groups[[j]] <- (o[jj:(jj + leave.out - 1)])
}
groups[[ngroup]] <- o[(1 + (ngroup - 1) * leave.out):n]
}
.


   
[[alternative HTML version deleted]]

__
R-help@r-project.org mailing list
https://stat.ethz.ch/mailman/listinfo/r-help
PLEASE do read the posting guide http://www.R-project.org/posting-guide.html
and provide commented, minimal, self-contained, reproducible code.


Re: [R] autocorrelation in nlme; Error: cannot allocate vector of size

2008-05-16 Thread J S
Dear R community,



Here are details of my model, which gives me trouble modeling
autocorrelation.



lm11<-lme(Soil.temp ~ Veg*M+Veg*year,

   data=a,

   random = list(Site=pdDiag(~Veg),

   Plot=pdDiag(~Veg))



dataset:



a-data frame of daily measurements of soil temperature (Soil.temp) over six
years

Site (6 sites),

Plot(2 plots per site),

Veg(2 vegetation types: 2 sites as grassland, 4 sites as forest)

M-month (categorical predictor)

year (continues)



Thanks,

Julia


> Van: [EMAIL PROTECTED] [mailto:[EMAIL PROTECTED]
> Namens J S
> Verzonden: vrijdag 16 mei 2008 23:06
> Aan: r-help@r-project.org
> Onderwerp: [R] autocorrelation in nlme; Error: cannot allocate vector of
> size
>
> Dear R community,
>
>
>
> I used a linear mixed model (named lm11) to model daily soil temperature
> depending upon vegetation cover and air temperature. I have almost
> 17,000
> observations for six years.
>
>
>
> I can not account for autocorrelation in my model, since I receive the
> error
> message after applying the function:
>
>
>
> update(lm11, corr=corAR1())
>
>
>
> Error: cannot allocate vector of size 220979 Kb
>
>
>
> Do you have any suggestions?
>
>
>
> Thanks, Julia
>
>[[alternative HTML version deleted]]
>
> __
> R-help@r-project.org mailing list
> https://stat.ethz.ch/mailman/listinfo/r-help
> PLEASE do read the posting guide
> http://www.R-project.org/posting-guide.html
> and provide commented, minimal, self-contained, reproducible code.
>

[[alternative HTML version deleted]]

__
R-help@r-project.org mailing list
https://stat.ethz.ch/mailman/listinfo/r-help
PLEASE do read the posting guide http://www.R-project.org/posting-guide.html
and provide commented, minimal, self-contained, reproducible code.


[R] interactive rotatable 3d scatterplot

2008-05-16 Thread francois Guilhaumon
I am facing the same problem than Mark Kimpel with the rgl package :

Running various 3D rendering I'm always faced with a static 3d plot,
which does not
rotate when I click and mouse over it.

I'm running Ubuntu linux 7.10 with a 32bit processor, thus the problem
is not arising from 64bit issues.

François.

> sessionInfo()
R version 2.7.0 (2008-04-22)
i486-pc-linux-gnu

locale:
LC_CTYPE=fr_FR.UTF-8;LC_NUMERIC=C;LC_TIME=fr_FR.UTF-8;LC_COLLATE=fr_FR.UTF-8;LC_MONETARY=C;LC_MESSAGES=fr_FR.UTF-8;LC_PAPER=fr_FR.UTF-8;LC_NAME=C;LC_ADDRESS=C;LC_TELEPHONE=C;LC_MEASUREMENT=fr_FR.UTF-8;LC_IDENTIFICATION=C

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

other attached packages:
[1] sp_0.9-17 rgl_0.73

loaded via a namespace (and not attached):
[1] grid_2.7.0 lattice_0.17-2


-- 
Guilhaumon François
Laboratoire "Ecosystèmes Lagunaires"
UMR 5119 cc 93 Bat 24
Université Montpellier II
34 095 Montpellier
France

http://www.ecolag.univ-montp2.fr
Tel : +33 4 67 14 45 71
Fax : +33 4 67 14 37 19

__
R-help@r-project.org mailing list
https://stat.ethz.ch/mailman/listinfo/r-help
PLEASE do read the posting guide http://www.R-project.org/posting-guide.html
and provide commented, minimal, self-contained, reproducible code.


Re: [R] interactive rotatable 3d scatterplot

2008-05-16 Thread Ben Bolker

francois Guilhaumon  gmail.com> writes:

> 
> I am facing the same problem than Mark Kimpel with the rgl package :
> 
> Running various 3D rendering I'm always faced with a static 3d plot,
> which does not
> rotate when I click and mouse over it.
> 
> I'm running Ubuntu linux 7.10 with a 32bit processor, thus the problem
> is not arising from 64bit issues.
> 
> François.

  Are you running Compiz (fancy desktop effects)?  You have
to go to Appearance/Visual Effects in the Preferences menu
and set "None", because Compiz conflicts with rgl in its use
of OpenGL.

   Ben Bolker

__
R-help@r-project.org mailing list
https://stat.ethz.ch/mailman/listinfo/r-help
PLEASE do read the posting guide http://www.R-project.org/posting-guide.html
and provide commented, minimal, self-contained, reproducible code.


Re: [R] interactive rotatable 3d scatterplot

2008-05-16 Thread francois Guilhaumon
The problem is arising because graphical effects are certainly turn-on
on the computer.

I deactivated the graphical effects and was able to rotate the 3D surface plot.
Turning effects on bring me back in the original state of a non rotating scene.

It seems that it is more an openGL issue.
Perhaps is there a kind of priority to give to the rgl device in the
global openGL flow ?


françois.


2008/5/17 francois Guilhaumon <[EMAIL PROTECTED]>:
> I am facing the same problem than Mark Kimpel with the rgl package :
>
> Running various 3D rendering I'm always faced with a static 3d plot,
> which does not
> rotate when I click and mouse over it.
>
> I'm running Ubuntu linux 7.10 with a 32bit processor, thus the problem
> is not arising from 64bit issues.
>
> François.
>
>> sessionInfo()
> R version 2.7.0 (2008-04-22)
> i486-pc-linux-gnu
>
> locale:
> LC_CTYPE=fr_FR.UTF-8;LC_NUMERIC=C;LC_TIME=fr_FR.UTF-8;LC_COLLATE=fr_FR.UTF-8;LC_MONETARY=C;LC_MESSAGES=fr_FR.UTF-8;LC_PAPER=fr_FR.UTF-8;LC_NAME=C;LC_ADDRESS=C;LC_TELEPHONE=C;LC_MEASUREMENT=fr_FR.UTF-8;LC_IDENTIFICATION=C
>
> attached base packages:
> [1] stats graphics  grDevices utils datasets  methods   base
>
> other attached packages:
> [1] sp_0.9-17 rgl_0.73
>
> loaded via a namespace (and not attached):
> [1] grid_2.7.0 lattice_0.17-2
>
>
> --
> Guilhaumon François
> Laboratoire "Ecosystèmes Lagunaires"
> UMR 5119 cc 93 Bat 24
> Université Montpellier II
> 34 095 Montpellier
> France
>
> http://www.ecolag.univ-montp2.fr
> Tel : +33 4 67 14 45 71
> Fax : +33 4 67 14 37 19
>



-- 
Guilhaumon François
Laboratoire "Ecosystèmes Lagunaires"
UMR 5119 cc 93 Bat 24
Université Montpellier II
34 095 Montpellier
France

http://www.ecolag.univ-montp2.fr
Tel : +33 4 67 14 45 71
Fax : +33 4 67 14 37 19

__
R-help@r-project.org mailing list
https://stat.ethz.ch/mailman/listinfo/r-help
PLEASE do read the posting guide http://www.R-project.org/posting-guide.html
and provide commented, minimal, self-contained, reproducible code.


Re: [R] xyplot: subscripts, groups and subset

2008-05-16 Thread Deepayan Sarkar
On 5/16/08, Jim Price <[EMAIL PROTECTED]> wrote:
>
>  I have stumbled across something in the Lattice package that is vexing me.
>  Consider the code below:
>  __
>
>  library(lattice)
>
>
>  myData <- expand.grid(sub = factor(1:16), time = 1:10)
>
>  myData$observed <- rnorm(nrow(myData))
>  myData$fitted <- with(myData, ave(observed, sub, FUN = mean))
>  myData$event.time <- with(myData, ave(observed, sub, FUN = function(.x) 10 *
>  runif(1)))
>
>  myData <- myData[order(myData$sub, myData$time),]
>
>
>
>  # This version works...
>  xyplot(
> fitted + observed ~ time | sub,
> data = myData,
> subscripts = TRUE,
> panel = function(..., groups = groups, subscripts = subscripts)
> {
> panel.xyplot(..., groups = groups, subscripts = subscripts)
>
> event.time <- unique(myData$event.time[subscripts])
> panel.abline(v = event.time, lty = 2, col = 'green')
> },
> type = c('l','p'),
> distribute.type = TRUE,
> as.table = TRUE
>  )
>
>
>
>  # ...but when you add the subset parameter it produces multiple index lines
>  per subject
>  xyplot(
> fitted + observed ~ time | sub,
> data = myData,
> subset = sub %in% sample(unique(sub), 9),
> subscripts = TRUE,
> panel = function(..., groups = groups, subscripts = subscripts)
> {
> panel.xyplot(..., groups = groups, subscripts = subscripts)
>
> event.time <- unique(myData$event.time[subscripts])
>  #   print(event.time)
> panel.abline(v = event.time, lty = 2, col = 'green')
> },
> type = c('l','p'),
> distribute.type = TRUE,
> as.table = TRUE
>  )
>
>  ___
>
>
>  The (commented out) print statement I think indicates that there is a data
>  reordering going on for the second example, that is causing the multiple
>  index lines issue. Is there a neat solution to get the correct index lines
>  per subject, or do I need a workaround? Or am I missing something
>  fundamental in the code above that is causing issues?

The short answer is that the value of 'subscripts' in the panel
function has an unusual interpretation when you use the extended
formula notation (as in 'fitted + observed ~ time')

You would get better insight if you also printed out the 'subscripts'
variable in each panel function. Basically, when you use the extended
notation, lattice creates an artificial 'groups' variable that is
longer than the original data frame, and consequently, the
'subscripts' variable must also have indices that exceed the number of
rows of the original data frame. This is not a problem in your first
call, because event.time[subscripts] returns NA for out-of-bound
indices.

When using 'subset', things get complicated further because this
artificial 'groups' variable is computed after the subsetting, and
'subscripts' no longer even partially refer to the original data
frame. There is no good solution to this; it is the price you pay for
the usefulness of the extended formula notation.

Your reasonable options are

(1) to subset your data beforehand; e.g.,

myDataSub <- subset(myData, sub %in% sample(unique(sub), 9))

and then use myDataSub in the call.

(2) not use the extended formula (this is conceptually cleaner, I think); e.g.,


xyplot(observed ~ time | sub, data = myData,
   subset = sub %in% sample(unique(sub), 9),
   fitted = myData$fitted,
   event.time = myData$event.time,
   panel = function(x, y, fitted, event.time, subscripts, ...)
   {
   panel.lines(x, fitted[subscripts], col = "black")
   panel.xyplot(x, y, ...)
   event.time <- unique(event.time[subscripts])
   panel.abline(v = event.time, lty = 2, col = 'green')
   },
   as.table = TRUE)

-Deepayan

__
R-help@r-project.org mailing list
https://stat.ethz.ch/mailman/listinfo/r-help
PLEASE do read the posting guide http://www.R-project.org/posting-guide.html
and provide commented, minimal, self-contained, reproducible code.


[R] merging data frames

2008-05-16 Thread Srinivas Iyyer
Dear group, 
I have 3 different data frames. I want to merge all 3
data frames for which there is intersection.

Say DF 1 and DF2 has 100 common elements in Column 1. 

DF3 does not have many intersection either with DF1 or
with DF2. 

For names in column 1 not present in DF3 I want to
introduce NA. 
DF1:
Name   Age
A   21
B   45
C   30

DF2:
Name   Age
A   50
B   20
X   10

DF3:
Name   Age
B   40
Y   21
K   30

I want to merge all 3 into one:


Df4:

Name.1Age.1  Age.2  Age.3
A 21   50 NA  
B 45   20 40
C 30   NA NA
K NA   NA 30
X NA   10 NA
Y NA   NA 21


Could any one help me how can I merge 3 dataframes. 

appreciate your help. Thank you. 

srini

__
R-help@r-project.org mailing list
https://stat.ethz.ch/mailman/listinfo/r-help
PLEASE do read the posting guide http://www.R-project.org/posting-guide.html
and provide commented, minimal, self-contained, reproducible code.


Re: [R] Dimensions of svd V matrix

2008-05-16 Thread Gad Abraham

Kenn Konstabel wrote:
I'm not an expert at all, but isn't it that you really want svd(x)$u to 
be different (instead of V)?


that would be easy to do:

x <- matrix(rnorm(15), 3, 5)

s1 <- svd(x)
s2 <- svd(x, nv=ncol(x))

x1 <- s1$u %*% diag(s1$d) %*% t(s1$v)
x2 <- cbind(s2$u,1,1) %*% diag(c(s1$d,0,0)) %*% t(s2$v)

all.equal(x,x1,x2)


Yep, you're absolutely correct. As someone's explained to me, the number 
of PCs cannot be larger than the rank of the matrix, therefore like you 
say the rest of the eigenvalues are practically zero anyway.


Thanks,
Gad

--
Gad Abraham
Dept. CSSE and NICTA
The University of Melbourne
Parkville 3010, Victoria, Australia
email: [EMAIL PROTECTED]
web: http://www.csse.unimelb.edu.au/~gabraham

__
R-help@r-project.org mailing list
https://stat.ethz.ch/mailman/listinfo/r-help
PLEASE do read the posting guide http://www.R-project.org/posting-guide.html
and provide commented, minimal, self-contained, reproducible code.


[R] How to paste graph from R in Latex?

2008-05-16 Thread Roslina Zakaria
Dear R-expert,
Is it possible to save graph from R into Latex document? I can see save as 
metafile , PNG, pdf etc, but I'm not sure which one to use.
Thank  you so much for your help.




__
R-help@r-project.org mailing list
https://stat.ethz.ch/mailman/listinfo/r-help
PLEASE do read the posting guide http://www.R-project.org/posting-guide.html
and provide commented, minimal, self-contained, reproducible code.


Re: [R] How to paste graph from R in Latex?

2008-05-16 Thread Vincent Goulet

Le ven. 16 mai à 21:24, Roslina Zakaria a écrit :


Dear R-expert,
Is it possible to save graph from R into Latex document? I can see  
save as metafile , PNG, pdf etc, but I'm not sure which one to use.

Thank  you so much for your help.


If you use latex, you should go for Encapsulated PostScript (EPS)  
using the postscript() device. With pdflatex, you may opt for PDF.


Want a good hint? Have a look at Sweave[1] and let it take care of the  
graph for you. That way, the code to create the graph will be saved  
with your LaTeX document.


HTHVincent

[1] See http://www.statistik.lmu.de/~leisch/Sweave/

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

__
R-help@r-project.org mailing list
https://stat.ethz.ch/mailman/listinfo/r-help
PLEASE do read the posting guide http://www.R-project.org/posting-guide.html
and provide commented, minimal, self-contained, reproducible code.


Re: [R] merging data frames

2008-05-16 Thread Yasir Kaheil

> DF1<- data.frame(Name=as.factor(c("A","B","C")), Age= c(21,45,30))
> DF2<- data.frame(Name=as.factor(c("A","B","X")), Age= c(50,20,10))
> DF3<- data.frame(Name=as.factor(c("B","Y","K")), Age= c(40,21,30))
> 
> merge(merge(DF1,DF2, by.x= "Name", by.y="Name",
> all=TRUE),DF3,by.x="Name",by.y="Name", all=TRUE);
  Name Age.x Age.y Age
1A2150  NA
2B4520  40
3C30NA  NA
4XNA10  NA
5KNANA  30
6YNANA  21

thanks
y

Srinivas Iyyer wrote:
> 
> Dear group, 
> I have 3 different data frames. I want to merge all 3
> data frames for which there is intersection.
> 
> Say DF 1 and DF2 has 100 common elements in Column 1. 
> 
> DF3 does not have many intersection either with DF1 or
> with DF2. 
> 
> For names in column 1 not present in DF3 I want to
> introduce NA. 
> DF1:
> Name   Age
> A   21
> B   45
> C   30
> 
> DF2:
> Name   Age
> A   50
> B   20
> X   10
> 
> DF3:
> Name   Age
> B   40
> Y   21
> K   30
> 
> I want to merge all 3 into one:
> 
> 
> Df4:
> 
> Name.1Age.1  Age.2  Age.3
> A 21   50 NA  
> B 45   20 40
> C 30   NA NA
> K NA   NA 30
> X NA   10 NA
> Y NA   NA 21
> 
> 
> Could any one help me how can I merge 3 dataframes. 
> 
> appreciate your help. Thank you. 
> 
> srini
> 
> __
> R-help@r-project.org mailing list
> https://stat.ethz.ch/mailman/listinfo/r-help
> PLEASE do read the posting guide
> http://www.R-project.org/posting-guide.html
> and provide commented, minimal, self-contained, reproducible code.
> 
> 


-
Yasir H. Kaheil
Catchment Research Facility
The University of Western Ontario 

-- 
View this message in context: 
http://www.nabble.com/merging-data-frames-tp17286503p17287302.html
Sent from the R help mailing list archive at Nabble.com.

__
R-help@r-project.org mailing list
https://stat.ethz.ch/mailman/listinfo/r-help
PLEASE do read the posting guide http://www.R-project.org/posting-guide.html
and provide commented, minimal, self-contained, reproducible code.


[R] fast multipole methods(FMM)/fast Gauss transfrorm(FGT)/improved fast gauss transform (IGFT)

2008-05-16 Thread Mark.Palmer
I'm just curious, but wondering if there has been any work in making
these algorithms available in R. They are aimed at accelerating
matrix-vector products using approximation ideas, and might be useful in
applications such as kernel machines, Gaussian processes/kriging.

 

Thanks

 

Mark Palmer 

Landscape Monitoring and Modelling

CSIRO Mathematical and Information Sciences 
Private bag 5, Wembley, Western Australia, 6913 
Phone   61-8-9333-6293 
Mobile  0427-50-2353 
Fax:61-8-9333-6121 
Email:  [EMAIL PROTECTED] mailto:[EMAIL PROTECTED]> 
URL:www.csiro.au

 


[[alternative HTML version deleted]]

__
R-help@r-project.org mailing list
https://stat.ethz.ch/mailman/listinfo/r-help
PLEASE do read the posting guide http://www.R-project.org/posting-guide.html
and provide commented, minimal, self-contained, reproducible code.


[R] Correlated Columns in data frame

2008-05-16 Thread Nataraj
Dear all,
Sorry to post my query once again in the list, since I did
not get attention from anyone in my previous mail to this
list. 
Now I make it simple here that please give me a code for
find out the columns of a dataframe whose correlation
coefficient is below a pre-determined threshold. (For
detailed query please see my previous message to this list,
pasted hereunder)

Thanks and regards,
B.Nataraj

Following is my previous message to this list to which I do
not get any reply.

Dear all,
For removing correlated columns in a data frame,df.
I found a code written in R in the page
http://cheminfo.informatics.indiana.edu/~rguha/code/R/ of
Mr.Rajarshi Guha. 
The code is 
#
r2test <- function(df, cutoff=0.8) {
  if (cutoff > 1 || cutoff <= 0) {
stop(" 0 <= cutoff < 1")
  }
  if (!is.matrix(d) && !is.data.frame(d)) {
stop("Must supply a data.frame or matrix")
  }
  r2cut = sqrt(cutoff);
  cormat <- cor(d);
  bad.idx <- which(abs(cormat)>r2cut,arr.ind=T);
  bad.idx <- matrix( bad.idx[bad.idx[,1] > bad.idx[,2]],
ncol=2);
  drop.idx <- ifelse(runif(nrow(bad.idx)) > .5,
bad.idx[,1], bad.idx [,2]);
  if (length(drop.idx) == 0) {
  1:ncol(d)
  } else {
  (1:ncol(d))[-unique(drop.idx)]
  }
}

Now the problem is the code return different output (i.e.
different column number) for a different call. I could not
understood why it happens from that code, but I can
understand the logic in code except the line

drop.idx <- ifelse(runif(nrow(bad.idx)) > .5, bad.idx[,1],
bad.idx [,2]);

what it means by comparing > 0.5 of nrow(bad.idx).
So I am looking for anyone to help me for different output
generation between the different function call as well as
 meaning of the line which I mentioned above.

Thanks!
B.Nataraj

__
R-help@r-project.org mailing list
https://stat.ethz.ch/mailman/listinfo/r-help
PLEASE do read the posting guide http://www.R-project.org/posting-guide.html
and provide commented, minimal, self-contained, reproducible code.