[R] Writing list object to a file

2008-04-23 Thread Arun Kumar Saha
Hi all,

I am wondering how to write a 'list' object to a file. I already gone
through some threads like
http://mail.python.org/pipermail/python-list/2001-April/080639.html, however
could not trace out any reliable solution. I tried following :

 write.table(calc, file=c:/data.csv)
Error in data.frame(200501 = c(-0.000387071806652095,
-0.000387221689252648,  :
  arguments imply differing number of rows: 25, 24, 16, 17, 18, 26, 27, 19,
23, 20, 11
Anybody can help?

Regards,

[[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] find directories

2008-04-23 Thread mel
Hello,
Function dir() is very useful for finding files.
However, is there a analog function for finding directories
based eg on a pattern ?
Apologies if I've missed something obvious.
Thanks
Vincent

__
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] problem with data for metaMDS analysis please help

2008-04-23 Thread Gavin Simpson
On Tue, 2008-04-22 at 20:19 -0400, stephen sefick wrote:
 am at my wit's end.  I am not sure what is wrong with this data matrix.  It
 is sparse because it is a matrix of species, but I have looked at the row
 totals and column totals and they are positive.
 rmetaMDS(x.d)
 Error in if (autotransform  xam  50) { :
 missing value where TRUE/FALSE needed
 What is wrong?  And in the future how in God's name do I easily diagnose
 whatever problem there is with this data.  I am in debt to anyone who
 figures this one out.

[All this presumes that x.d is your data as in the file you attached.
You could have helped by including the few lines to read in the data and
do the metaMDS so I didn't have to work this out and guess what x.d
was.]

The problem is very simple; you don't have *all* positive marginal
totals with the dataset you attached. Two variables have missing values
in the R sense, and unless you ask for R to remove missing values (which
in this case would defeat the object of checking the marginal totals),
you can't have found all positive values using the common R tools for
marginal totals.

Take a closer look at your data (that you attached). There are two
columns with NA in them.

This is how I diagnosed the problem:

 # read in the data
 dat - read.delim(trans.txt)
 # generate species sums these will be NA is any are missing
 csum - colSums(dat)
 # check if any are missing
 any(is.na(csum))
[1] TRUE
 # yes, some missing, so which ones?
 which(is.na(csum))
X49 X68 
 49  67 
 # Check how many are missing
 summary(dat[, c(X49,X68)])
  X49  X68 
 Min.   :  0.00   Min.   :0.0  
 1st Qu.:  0.00   1st Qu.:0.0  
 Median :  1.00   Median :0.0  
 Mean   :  9.13   Mean   :0.02094  
 3rd Qu.:  6.00   3rd Qu.:0.0  
 Max.   :257.00   Max.   :2.0  
 NA's   :  1.00   NA's   :1.0

These are rudimentary data management and checking steps in R. It would
be worth brushing up on these sorts of things in one of the online
documents. Alternatively, you could have included what you did that lead
you to believe that you had all positive marginal totals so we could see
where you went wrong.

HTH

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.


Re: [R] Writing list object to a file

2008-04-23 Thread Arun Kumar Saha
Previous question that I asked was originated from this problem :

suppose I have following time series :

library(zoo)
date1 = seq(as.Date(01/01/01, format = %m/%d/%y), as.Date(12/31/08,
format = %m/%d/%y), by = 1)
len1 = length(date1); data1 = zoo(matrix(rnorm(len1, mean=0, sd=0.5), nrow =
len1),  date1)
Now I group those time series observation month wise :
data2 = split(as.data.frame(data1), format(index(data1), %Y%m)

Now I want to perform  Levene test (
http://en.wikipedia.org/wiki/Levene's_test) to test whether the variance for
each group (here month) is significantly different or not.

Can anyone suggest me any easiest way how to construct the test statistic,
described above?

Thanks




On Wed, Apr 23, 2008 at 12:21 PM, Arun Kumar Saha [EMAIL PROTECTED]
wrote:

 Hi all,

 I am wondering how to write a 'list' object to a file. I already gone
 through some threads like
 http://mail.python.org/pipermail/python-list/2001-April/080639.html,
 however could not trace out any reliable solution. I tried following :

  write.table(calc, file=c:/data.csv)
 Error in data.frame(200501 = c(-0.000387071806652095,
 -0.000387221689252648,  :
   arguments imply differing number of rows: 25, 24, 16, 17, 18, 26, 27,
 19, 23, 20, 11
 Anybody can help?

 Regards,




--

[[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] select rows from data based on a vector of char strings

2008-04-23 Thread Dirkheld

Hi,

I have loaded a dataset in R :
data = 

label   freq1   freq2
news   54  35
fun  37  21
milk19  7
food 3   3
 etc

And I have a vector
flist-c(fun,food)

Now I want to use the vector 'flist' for selecting these values from 'data'
so that I get the following dataset :
label   freq1   freq2
fun  37  21
food 3   3

When I do 'data$label==flist[1]' I get 'F T F F', so it works for one item
in the char vector flist.
But, when I do 'data$label==flist' I get 'F F F F' while I expected 'F T F
T'. It seems that I can't perform this action with a vector of charstrings? 

Is there an other way to do so?

-- 
View this message in context: 
http://www.nabble.com/select-rows-from-data-based-on-a-vector-of-char-strings-tp16832735p16832735.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] select rows from data based on a vector of char strings

2008-04-23 Thread Chuck Cleland
On 4/23/2008 3:13 AM, Dirkheld wrote:
 Hi,
 
 I have loaded a dataset in R :
 data = 
 
 label   freq1   freq2
 news   54  35
 fun  37  21
 milk19  7
 food 3   3
  etc
 
 And I have a vector
 flist-c(fun,food)
 
 Now I want to use the vector 'flist' for selecting these values from 'data'
 so that I get the following dataset :
 label   freq1   freq2
 fun  37  21
 food 3   3
 
 When I do 'data$label==flist[1]' I get 'F T F F', so it works for one item
 in the char vector flist.
 But, when I do 'data$label==flist' I get 'F F F F' while I expected 'F T F
 T'. It seems that I can't perform this action with a vector of charstrings? 
 
 Is there an other way to do so?

newdata - subset(data, label %in% flist)

?subset
?is.element

-- 
Chuck Cleland, Ph.D.
NDRI, Inc. (www.ndri.org)
71 West 23rd Street, 8th floor
New York, NY 10010
tel: (212) 845-4495 (Tu, Th)
tel: (732) 512-0171 (M, W, F)
fax: (917) 438-0894

__
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] Documentation General Comments

2008-04-23 Thread seanpor

Good morning,

Firstly I'd like to say that I'm a huge fan of R and I think it's great
system.

Part of the problem in searching for information is knowing what buzzwords /
keywords to use.  I was recently caught out like this as I didn't see my
problem as a cumulative sum (keyword=cumsum) only as referencing one line of
a dataframe from another.  Academic papers and certain webpages add special
classification keywords to the text of a page to help.  Searching is a
general problem - not just within R - ask any archivist or librarian!

A partial solution is to have disambiguation pages,
e.g. http://en.wikipedia.org/wiki/Comma
Is it reasonable to have help pages with no specific R / package item behind
it only a See Also section?  Does somebody have access to the most
frequent RSiteSearch() terms?

It would probably help to increase the number of See Also details - for
example when I run into a problem the first thing I do is try to recreate it
as a reproduceable toy problem which I could send to this list (which
incidentally is actually a great way of figuring out solution to the problem
without having to bother the list!!!).  To do this I invariably want to
generate some random numbers, and I can never remember the names runif() or
rnorm() so I say help.search(random) which doesn't actually reference
either runif() or rnorm() directly so I look at ?RNG which leads me to
rnorm() - and already knowing that this is what I'm looking for I'm ok - but
if somebody didn't already know this it is not obvious.

I appreciate that there is always a difficult balance when writing
documentation between having enough and too much.  Just looking at the core
documentation for R-2.6.2 (and ignoring the many many additional packages)
The introduction to R is 100 pages of PDF and the reference manual runs to
1,576 pages of PDF.  Adding more information as many of us want would make
the reference manual even more unwieldy and far too big to print out to
peruse, which gives rise to a market for books which take over where the
introduction manual leaves off...

Part of the difficulty that we encounter is that sometimes our difficulties
are pure R, and other times the difficulty is statistical or mathematical -
more often than not the problem is between the two... and frequently those
of us asking the question don't actually know where on the spectrum it is...

Q: Could there be ways other than submitting a bug / patch to help improve
R?

Q: Should this discussion be on r-devel or r-help?


Best Regards,
Sean




The root of the problem is that R is a voluntary/cooperative project  
and those who develop and maintain R are (generously) contributing their
time and
probably have little-to-no time left over to devote to the  
improvement of the documentation.
snip...

This is why the documentation tends to be opaque in the first place.   
The people who build R are so clever and understand so much that
they cannot put themselves in the shoes of those of us who are
not so blessed with intelligence and erudition.  So they (often)
write terse cryptic instructions which (often) depend on background
knowledge that many of us lack.  That background knowledge can
of course be found ***if you know where to look***
--- or even if you don't, given that you are prepared to put in  
sufficient time and effort searching ***and*** are clever at
searching.  It's that last requirement that leaves *me* out in the cold.

snip...

-- 
View this message in context: 
http://www.nabble.com/Documentation-General-Comments-tp16821085p16833353.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] Regression inclusion of variable, effect on coefficients

2008-04-23 Thread Michael Dewey
At 20:06 21/04/2008, Thiemo Fetzer wrote:
Hello :)

I am happy to hear that I am not necessarily asking stupid questions.

The thing is, that I have data on x1 and x4 for the whole sample. However,
theoretically, it is clear that the informational content of x1 is not as
high as of x4. x4 provides more accurate information to the subjects
participating in the game, as it has been experimentally and theoretically
shown that the x1 is biased.

It sounds as though you are thinking of some sort of path analysis or 
structural equation model. If you look at the sem package you should 
find some links to helpful material by John Fox and located on his 
web site (I think). Of course I could be quite wrong here and you may 
want something completely different. I am not advocating SEMs if they 
are not needed as they provide many temptations to dredge into your 
data but you do seem to have a theory to test.


So the experimentators introduced x4 in response to the biased x1. Both
prevail however together, so that the subjects have available information on
x1 and x4.

Theoretically, I argued that the relative importance of x1 on y will
decrease in light that information x4 is available, as x4 is more accurate.

With a simple regression, however, I do not find significant relationships.
For x1 it has been empirically and theoretically shown that it has a
positive effect on y. The same should hold for x4.

There is no necessary theoretical argument as how x1 and x4 interact
mathematically, as they both are a measure of the same thing. Yet, x4 is
more accurate and contains even more information.  It could be any kind of
interaction. They are positively correlated, which is also reasonable.

Could you suggest me a simple interaction model, with which I could try my
luck?

Thanks a lot

Thiemo

-Original Message-
From: Uwe Ligges [mailto:[EMAIL PROTECTED]
Sent: Montag, 21. April 2008 18:54
To: Thiemo Fetzer
Cc: r-help@r-project.org
Subject: Re: [R] Regression inclusion of variable, effect on coefficients

This is not a dump question. This is a serious problem and it depends on
what you know or assume about the relastionship between x1 and x4. If
you assume linear interaction, you might want to introduce some
interaction term to the model for example.

Uwe Ligges


Thiemo Fetzer wrote:
  Hello dear R users!
 
  I know this question is not strictly R-help, yet, maybe some of the guru's
  in statistics can help me out.
 
 
 
  I have a sample of data all from the same population. Say my regression
  equation is now this:
 
 
 
  m1 - lm(y ~ x1 + x2 + x3)
 
 
 
  I also regress on
 
 
 
  m2 - lm(y ~ x1 + x2 + x3 + x4)
 
 
 
  The thing is, that I want to study the effect of information x4.
 
 
 
  I would hypothesize, that the coefficient estimate for x1 goes down as I
  introduce x4, as x4 conveys some of the information conveyed by x1 (but
not
  only). Of course x1 and x4 are correlated, however multicollinearity does
  not appear to be a problem, the variance inflation factors are rather low
  (around 1.5 or so).
 
 
 
  I want to basically study, how the interplay between x1 and x4 is, when
  introducing x4 into the regression equation and whether my hypothesis is
  correct; i.e. that given I consider the information x4, not so much of the
  variation is explained via x1 anymore.
 
 
 
  I observe that introducing x4 into the regression, the coefficient
estimate
  for x1 goes down; also the associated p-value becomes bigger; i.e. x1
  becomes comparatively less significant. However, x4 is not significant.
Yet,
  the observation is in line with my theoretical argument.
 
 
 
  The question is now simple: how can I work this out?
 
 
 
  I know this is likely a dumb question, but I would really appreciate some
  links or help.
 
 
  Regards
 
  Thiemo
 
 
[[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.

Michael Dewey
http://www.aghmed.fsnet.co.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.


Re: [R] find directories

2008-04-23 Thread Prof Brian Ripley
On Wed, 23 Apr 2008, mel wrote:

 Hello,
 Function dir() is very useful for finding files.
 However, is there a analog function for finding directories
 based eg on a pattern ?

No.

 Apologies if I've missed something obvious.

list.dirs - function(...)
{
 x - dir(...)
 x[file_test(-d, x)]
}

 Thanks
 Vincent

-- 
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] find directories

2008-04-23 Thread mel
Prof Brian Ripley a écrit :
 On Wed, 23 Apr 2008, mel wrote:
 
 Hello,
 Function dir() is very useful for finding files.
 However, is there a analog function for finding directories
 based eg on a pattern ?
 
 No.
 
 Apologies if I've missed something obvious.
 
 list.dirs - function(...)
 {
 x - dir(...)
 x[file_test(-d, x)]
 }

Thanks for the fast answer Prof Ripley.

In fact, I was using (on a tree of directories of depth 4)
x - dir(..., recursive=TRUE)
and didn't notice that the results from
dir(...) is not included in dir(..., recursive=TRUE)

If I'm not wrong, x - dir(..., recursive=TRUE)
seems to return the findable *files only* in the tree.
While x - dir(...)
returns the *files and the directories* present at the top level
of the tree.

The directories I'm searching are unfortunately not at the top level,
But, in my special case, I'm lucky enough that a simple trick allows
to identify the directories.

Thanks
Vincent

__
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 read in multiple files with unequal number of columns

2008-04-23 Thread Tania Oh
Thank you John.
It was useful to know about this package.

I tried merge_all and I got this error:

Error in .subset2(x, i, exact = exact) : subscript out of bounds

It could be due to the way my data is and I will try the other  
solutions suggested by the other kind souls on this list.

Best wishes,
tania

On 22 Apr 2008, at 19:29, John Kane wrote:

 You might want to have a look at the merge_all
 function in the reshape package.
 --- Tania Oh [EMAIL PROTECTED] wrote:

 Dear all,

 I want to read in 1000 files which contain varying
 number of columns.
 For example:

 file[1] contains 8 columns (mixture of characters
 and numbers)
 file[2] contains 16 columns etc

 I'm reading everything into one big data frame and
 when I try rbind, R
 returns an error of
 Error in rbind(deparse.level, ...) :
   numbers of columns of arguments do not match


 Below is my code:

 all - NULL
 all - as.data.frame(all)

 ##read in the contents of the files
 for (f in 1:length(fnames)){

   tmp - try(read.table(fnames[f], header=F,
 fill=T, sep=\t),
 TRUE)

   if (class(tmp) == try-error) {
   next ## skip this file if it's
 empty/non-existent
}else{
 ## combine all the file contents into one
 big data frame
all - rbind(all, tmp)
   }
 }


 Here is some example of what the data in the files:

 L3 - LETTERS[1:3]
 (d - data.frame(cbind(x=1, y=1:10), fac=sample(L3,
 10, replace=TRUE)))

 str(d)
 'data.frame':10 obs. of  3 variables:
  $ x  : num  1 1 1 1 1 1 1 1 1 1
  $ y  : num  1 2 3 4 5 6 7 8 9 10
  $ fac: Factor w/ 3 levels A,B,C: 1 3 1 2 2 2
 2 1 1 2

 my.fake.data - data.frame(cbind(x=1, y=2))
 str(my.fake.data)
 'data.frame':1 obs. of  2 variables:
  $ x: num 1
  $ y: num 2


 all - rbind(d, my.fake.data)

 Error in rbind(deparse.level, ...) :
   numbers of columns of arguments do not match


 I've searched the R-site but couldn't find any
 relevant solution.I
 might have used the wrong keywords to search, so if
 this question has
 been answered already, I'd be very grateful if
 someone could point me
 to the post. Else any help/suggestions would be
 greatly appreciated.

 Many thanks in advance,
 tania

 D.Phil student
 Department of Physiology, Anatomy and Genetics
 University of Oxford

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




   
 __
 Be smarter than spam. See how smart SpamGuard is at giving junk  
 email the boot with the All-new Yahoo! Mail.  Click on Options in  
 Mail and switch to New Mail today or register for free at http://mail.yahoo.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] optimization setup

2008-04-23 Thread bartjoosen

The error comes from the way you specify the parameters:
At least not as elegant, but it works:

function4 - function(x){
theta1 - x[1]
theta2 - x[2]
theta3 - x[3]
function3(theta1,theta2,theta3)
}

fit-optim(par=c(1, 1.2, .2), fn=function4) 


Bart



threshold wrote:
 
 Hi, here comes my problem, say I have the following functions (example
 case)
 #
 function1 - function (x, theta) 
 {a - theta[1] ( 1 - exp(-theta[2]) ) * theta[3] )
  b - x * theta[1] / theta[3]^2
  return( list( a = a, b = b )) }
 #---
 function2-function (x, theta) 
 {P - function1(x, theta)
   c - P$a * x * exp(-theta[2])
   d - P$b * exp(x)
   q - theta[1] / theta[3]
   res - c + d + q; res}
 
 # Function to be optimized
 function3 - function(theta1,theta2,theta3) {
 n - length(data)
 -sum( function2(x = data[2:n], theta = c(theta1, theta2, theta3) ))}
 # 'data' is my input ts class object
 #--
 
 Then I want to maximize function3 with respect to theta(s) (given some
 starting values) 
 
 fit-optim(par=c(theta1=1, theta2=1.2, theta3=.2), fn=function3)
 
 I get the following:
 Error in function1(x, theta) : 
   argument theta2 is missing, with no default
 
 Where I made a mistake? I will appreciate any help ...
 
 r
 

-- 
View this message in context: 
http://www.nabble.com/optimization-setup-tp16825410p16833769.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] Problems with Windows RGUI R-2.7.0 when PA TH includes 'æ'

2008-04-23 Thread Erik Jørgensen
I have a subdirectory named 'Fælles Filer' in my PATH.  When I start the
RGUI, I receive the following error/warning messages:

Error in Sys.setenv(PATH = PATH) : invalid input in wtransChar

and

Warning message:
package methods in options(defaultPackages) was not found

The problems disappear, when I change the the subdirectory name to its short
version, 'FLLES~1' in the PATH specification in the Windows setup.

regards

Erik Jørgensen
Faculty of Agricultural Sciences
University of Aarhus, Denmark






platform   i386-pc-mingw32
arch   i386
os mingw32
system i386, mingw32
status
major  2
minor  7.0
year   2008
month  04
day22
svn rev45424
language   R
version.string R version 2.7.0 (2008-04-22)

[[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] Time arithmetic

2008-04-23 Thread Worik R
I am a bit worried I am reinventing the wheel.  Isn't there a calendar
system in R?

I have written a function to add months to a date and return the number of
days resulting.   I am newish to R so I am hoping there is a package that
can do this sort of date arithmetic for me...

Worik

DaysInMonths - function(s,d){
  ## Days in d months from s
  sdate - MSTD(s)

  ## Get day, month and the year
  sd - as.double(days(sdate))
  sm - as.double(months(sdate))
  sy - as.double.difftime(years(sdate))

  sm - sm+d
  while(sm  12){
sm - sm-12
sy - sy+1
  }
  sdate2 - MSTD(paste(sd,sm,sy,sep=/))
  return(as.double(difftime(sdate2, sdate, units=days)))
}

MSTD - function(a){
  if(class(a)[1]  == dates) return (a)
  return(dates(a, format=d/m/y))
}

[[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 appears not to reallocate memory on linux

2008-04-23 Thread Lars
Hi,

I have a question concerning the memory management of R
2.6.1 on a 32-bit linux with 3.2 GB RAM.

Especially, I found the current memory size reported from gc() to be 
different from the amount reported by e.g. top.
The 'max used' number of gc() seems more to match the actually used memory.

so is it the case that R keeps the allocated memory for its own memory 
manager and does not return it to the OS?
this is what the situation looks like, although what i read in the 
newsgroups sounded like the opposite (e.g. R gives all unneeded memory back)

this is especially important for me since i am processing huge data and 
evaulate different learning methods, and i frequently ran into
'cannot allocate vector of (say) 70M'

any hint would be appreciated
thanks a lot

lars

__
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-pkgs] new package multipol

2008-04-23 Thread Robin Hankin
Hello List

please find a new package, multipol, recently uploaded to CRAN.

This package generalizes the polynom package (which handles univariate
polynomials) to the multivariate case.   A  short article discussing the
package will appear in the next issue of Rnews,  Insha'Allah


enjoy



--
Robin Hankin
Uncertainty Analyst and Neutral Theorist,
National Oceanography Centre, Southampton
European Way, Southampton SO14 3ZH, UK
  tel  023-8059-7743

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

__
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] g(x,y) = f(x,y) - e(x)- e(y)?

2008-04-23 Thread William Simpson
Thanks Phipp very much for your help. I had meant, given that I'd
computed the matrix f[x,y] and the vector e[x], how to take the
difference. What is confusing is how to subtract a vector from a
matrix. I don't want the recycling rule.

Cheers
Bill

On Tue, Apr 22, 2008 at 9:53 AM, Philipp Pagel [EMAIL PROTECTED] wrote:

   g(x,y) = f(x,y) - e(x)- e(y)
   These are continuous functions. I am not sure how to do this with the
   discrete equivalents in R.

  Is this what you are looking for?

  g - function(x, y) {

 f(x,y) - e(x) - e(y)
  }

  cu
 Philipp

  --
  Dr. Philipp Pagel
  Lehrstuhl für Genomorientierte Bioinformatik
  Technische Universität München
  Wissenschaftszentrum Weihenstephan
  85350 Freising, Germany
  http://mips.gsf.de/staff/pagel

  __
  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] Density estimation

2008-04-23 Thread Gunther Jansen
Hi,

I am analysing a dataset containing genetic distances within and between 
species. I want to show a overlap of the distributions of the intra- and 
interspecific values; on a second graph I use a cut-off value to determine 
these boundaries. As the dataset contains 30 000 values, I would like to do 
this with a simple line rather than superimposed histograms. Hence, density 
plots. With the standard settings of plot(density(x)), I receive the 
desirable result, except that the function extends slightly in negative x 
values (which is impossible, distance values are always positive). 
Furthermore, in the second figure I supplied the cut-off value a priori, so 
overlap between the two classes is zero by definition. Is there a way to 
visualise this information in another way, or to readjust the density 
parameters so intraspecific values below zero have zero probability in the 
first case, and there is no overlap in the second case?


Thanks,

gunther

__
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] Problems with Windows RGUI R-2.7.0 when P ATH includes 'æ'

2008-04-23 Thread Prof Brian Ripley
Your email was not properly encoded by the time it reached me (see the ? 
in crucial places), so I may be missing something.


I am guessing you are in a Danish locale with codepage CP1252, and 
fortunately the subject line appears to have worked.  I think I have a 
reproduction test, in which case this will be fixed in R-patched shortly 
(but please test that for us).


No one reported this in the alpha/beta/RC test period, and we do know that 
the Japanese did some testing of the new features.  I guess that real 
testing started yesterday 


Thanks for the report -- if you find further misfeatures it would be 
helpful to have the locale and an email in a marked encoding.


On Wed, 23 Apr 2008, Erik Jørgensen wrote:


I have a subdirectory named 'F?lles Filer' in my PATH.  When I start the
RGUI, I receive the following error/warning messages:

Error in Sys.setenv(PATH = PATH) : invalid input in wtransChar

and

Warning message:
package methods in options(defaultPackages) was not found

The problems disappear, when I change the the subdirectory name to its short
version, 'FLLES~1' in the PATH specification in the Windows setup.

regards

Erik J?rgensen
Faculty of Agricultural Sciences
University of Aarhus, Denmark






platform   i386-pc-mingw32
arch   i386
os mingw32
system i386, mingw32
status
major  2
minor  7.0
year   2008
month  04
day22
svn rev45424
language   R
version.string R version 2.7.0 (2008-04-22)

[[alternative HTML version deleted]]




--
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] Time arithmetic

2008-04-23 Thread Gabor Grothendieck
library(zoo)
?yearmon

library(chron)
?month.day.year

?strptime

See R News 4/1.

On Wed, Apr 23, 2008 at 6:13 AM, Worik R [EMAIL PROTECTED] wrote:
 I am a bit worried I am reinventing the wheel.  Isn't there a calendar
 system in R?

 I have written a function to add months to a date and return the number of
 days resulting.   I am newish to R so I am hoping there is a package that
 can do this sort of date arithmetic for me...

 Worik

 DaysInMonths - function(s,d){
  ## Days in d months from s
  sdate - MSTD(s)

  ## Get day, month and the year
  sd - as.double(days(sdate))
  sm - as.double(months(sdate))
  sy - as.double.difftime(years(sdate))

  sm - sm+d
  while(sm  12){
sm - sm-12
sy - sy+1
  }
  sdate2 - MSTD(paste(sd,sm,sy,sep=/))
  return(as.double(difftime(sdate2, sdate, units=days)))
 }

 MSTD - function(a){
  if(class(a)[1]  == dates) return (a)
  return(dates(a, format=d/m/y))
 }

[[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] Ubuntu vs. Windows

2008-04-23 Thread Douglas Bates
On 4/22/08, Prof Brian Ripley [EMAIL PROTECTED] wrote:
 On Tue, 22 Apr 2008, Peter Dalgaard wrote:

   Doran, Harold wrote:
   Dear List:
  
   I am very much a unix neophyte, but recently had a Ubuntu box installed
   in my office. I commonly use Windows XP with 3 GB RAM on my machine and
   the Ubuntu machine is exactly the same as my windows box (e.g.,
   processor and RAM) as far as I can tell.
  
   Now, I recently had to run a very large lmer analysis using my windows
   machine, but was unable to due to memory limitations, even after
   increasing all the memory limits in R (which I think is a 2gig max
   according to the FAQ for windows). So, to make this computationally
   feasible, I had to sample from my very big data set and then run the
   analysis. Even still, it would take something on the order of 45 mins to
   1 hr to get parameter estimates. (BTW, SAS Proc nlmixed was even worse
   and kept giving execution errors until the data set was very small and
   then it ran for a long time)
  
   However, I just ran the same analysis on the Ubuntu machine with the
   full, complete data set, which is very big and lmer gave me back
   parameter estimates in less than 5 minutes.
  
   Because I have so little experience with Ubuntu, I am quite pleased and
   would like to understand this a bit better. Does this occur because R is
   a bit friendlier with unix somehow? Or, is this occuring because unix
   somehow has more efficient methods for memory allocation?
  
   Probably partly the latter and not the former (we try to make the most
   of what the OS offers in either case), but a more important difference
   is that we can run in 64 bit address space on non-Windows platforms
   (assuming that you run a 64 bit Ubuntu).
  
   Even with 64 bit Windows we do not have the 64 bit toolchain in place to
   build R except as a 32 bit program. Creating such a toolchain is beyond
   our reach, and although progress is being made, it is painfully slow
   (http://sourceforge.net/projects/mingw-w64/). Every now and then, the
   prospect of using commercial tools comes up, but they are not
   plug-compatible and using them would leave end users without the
   possibility of building packages with C code, unless they go out and buy
   the same toolchain.

 There is another possibility.  lmer is heavy on matrix algebra, and so
  usually benefits considerably from an optimized BLAS.  Under Windows you
  need to download one of those on CRAN (or build your own).  I believe that
  under Ubuntu R will make use of one if it is already installed.

Optimized BLAS is a possible explanation but it would depend on the
Ubuntu package for the correct version of Atlas having been installed.
 I don't think those packages are installed by default.  Even if they
were installed, optimized BLAS are not always beneficial for lmer.
Depending on the structure of the model, optimized BLAS, especially
multithreaded BLAS, can actually slow lmer down.

I think the difference is more likely due to swapping.  A typical lmer
call does considerable memory allocation at the beginning of the
computation then keeps a stable memory footprint during the
optimization of the deviance with respect to the model parameters.  It
does access essentially all the big chunks of memory in that footprint
during the optimization.  If the required memory is a bit larger than
the available memory you get a lot of swapping, as I found out
yesterday.  I started an lmer run on a 64-bit Ubuntu machine
forgetting that I had recently removed a defective memory module from
that machine.  It had only 2 GB of memory and about 8 GB of swap
space.  It spent a lot of time swapping.  I definitely should have
done that run on one of our servers that has much more real memory.

Harold: Typing either

cat /proc/meminfo

or

free

in a shell window on your Ubuntu machine will tell you the amount of
memory and swap space on the machine.  If you start the lmer fit and
switch to a terminal window where you run the program top you can
watch the evolution of the memory usage by the R program.  It will
probably increase  at the beginning of the run then stabilize.



Harold

__
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] ROracle error at step 1

2008-04-23 Thread Creighton, Sean
Hi

I Can't connect to the Oracle database, any tips? Has anybody actually
got ROracle up and running on windows?

  unable to find an inherited method for function dbConnect,
for signature OraDriver

I can happily connect to the same database through RODBC. Oracle client,
version 9.2 installed, amongst others.

Sean





 library(DBI)
 library(ROracle)
 
 packageDescription(ROracle)
Package: ROracle
Version: 0.5-7
Date: 2006-02-13
Title: Oracle database interface for R
Author: David A. James [EMAIL PROTECTED] Jake Luciani
[EMAIL PROTECTED]
Maintainer: David A. James [EMAIL PROTECTED]
Description: Oracle database interface (DBI) driver for R. This is a
DBI-compliant Oracle driver based on the ProC/C++ embedded SQL. It
implements the DBI version 0.1-8 plus one extension.
SaveImage: yes
Depends: R (= 2.0.0), methods, DBI (= 0.1-8)
License: LGPL version 2 or newer
URL: http://stat.bell-labs.com/RS-DBI http://www.omegahat.org
Packaged: Mon Feb 13 18:05:55 2006; dj
Built: R 2.2.1; i386-pc-mingw32; 2006-02-13 18:05:59; windows

-- File: C:/PROGRA~1/R/R-26~1.0/library/ROracle/DESCRIPTION 
 packageDescription(DBI)
Package: DBI
Version: 0.2-4
Title: R Database Interface
Author: R Special Interest Group on Databases (R-SIG-DB)
Maintainer: David A. James [EMAIL PROTECTED]
Depends: R (= 2.3.0), methods
Imports: methods
Description: A database interface (DBI) definition for communication
between R and relational database management systems.  All classes in
this package are virtual and need to be extended by the various
   R/DBMS implementations.
LazyLoad: yes
License: LGPL (version 2 or later)
Collate: DBI.R Util.R zzz.R
Packaged: Tue Oct 16 21:43:31 2007; dj
Built: R 2.6.0; ; 2007-10-17 12:21:14; windows

-- File: C:/PROGRA~1/R/R-26~1.0/library/DBI/DESCRIPTION 
 
 R.Version()
$platform
[1] i386-pc-mingw32

$arch
[1] i386

$os
[1] mingw32

$system
[1] i386, mingw32

$status
[1] 

$major
[1] 2

$minor
[1] 6.0

$year
[1] 2007

$month
[1] 10

$day
[1] 03

$`svn rev`
[1] 43063

$language
[1] R

$version.string
[1] R version 2.6.0 (2007-10-03)

 
 
 sDB_un- scott
 sDB_pwd- tiger
 
 
 Oracle()
An object of class OraDriver
Slot Id:
[1] 1952

 dbDriver(Oracle)
An object of class OraDriver
Slot Id:
[1] 1952

 
   Ora- dbDriver(Oracle)
 Con - dbConnect(Ora, user = sDB_un, passwd = sDB_pwd)
Error in function (classes, fdef, mtable)  : 
  unable to find an inherited method for function dbConnect, for
signature OraDriver


__
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 read in multiple files with unequal number of columns

2008-04-23 Thread jim holtman
Is this what you want?  I am assuming that you will read the
dataframes into a list and then process them like below:

 # put dataframe in a list -- would have read them in via a list
 x - list(d, my.fake.data)
 # determine maximum number of columns and then pad out the short one
 # also use the column names of the largest one

 col.max - max(sapply(x, ncol))
 colNames - lapply(x, function(.data){
+ if (ncol(.data) == col.max) colnames(.data)
+ })[[1]]
 new.data - lapply(x, function(.data){
+ if (ncol(.data)  col.max){
+ .data[(ncol(.data) + 1):col.max] - NA
+ colnames(.data) - colNames
+ }
+ .data
+ })
 all - do.call(rbind, new.data)
 all
   x  y  fac
1  1  1B
2  1  2B
3  1  3B
4  1  4B
5  1  5A
6  1  6A
7  1  7C
8  1  8C
9  1  9A
10 1 10C
11 1  2 NA



On Tue, Apr 22, 2008 at 9:05 AM, Tania Oh [EMAIL PROTECTED] wrote:
 Dear all,

 I want to read in 1000 files which contain varying number of columns.
 For example:

 file[1] contains 8 columns (mixture of characters and numbers)
 file[2] contains 16 columns etc

 I'm reading everything into one big data frame and when I try rbind, R
 returns an error of
 Error in rbind(deparse.level, ...) :
   numbers of columns of arguments do not match


 Below is my code:

 all - NULL
 all - as.data.frame(all)

 ##read in the contents of the files
 for (f in 1:length(fnames)){

   tmp - try(read.table(fnames[f], header=F, fill=T, sep=\t),
 TRUE)

   if (class(tmp) == try-error) {
   next ## skip this file if it's empty/non-existent
}else{
   ## combine all the file contents into one big data frame
all - rbind(all, tmp)
   }
 }


 Here is some example of what the data in the files:

 L3 - LETTERS[1:3]
 (d - data.frame(cbind(x=1, y=1:10), fac=sample(L3, 10, replace=TRUE)))

   str(d)
 'data.frame':   10 obs. of  3 variables:
  $ x  : num  1 1 1 1 1 1 1 1 1 1
  $ y  : num  1 2 3 4 5 6 7 8 9 10
  $ fac: Factor w/ 3 levels A,B,C: 1 3 1 2 2 2 2 1 1 2

 my.fake.data - data.frame(cbind(x=1, y=2))
   str(my.fake.data)
 'data.frame':   1 obs. of  2 variables:
  $ x: num 1
  $ y: num 2


 all - rbind(d, my.fake.data)

 Error in rbind(deparse.level, ...) :
   numbers of columns of arguments do not match


 I've searched the R-site but couldn't find any relevant solution.I
 might have used the wrong keywords to search, so if this question has
 been answered already, I'd be very grateful if someone could point me
 to the post. Else any help/suggestions would be greatly appreciated.

 Many thanks in advance,
 tania

 D.Phil student
 Department of Physiology, Anatomy and Genetics
 University of Oxford

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

__
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] Writing list object to a file

2008-04-23 Thread jim holtman
?save

On Wed, Apr 23, 2008 at 2:51 AM, Arun Kumar Saha
[EMAIL PROTECTED] wrote:
 Hi all,

 I am wondering how to write a 'list' object to a file. I already gone
 through some threads like
 http://mail.python.org/pipermail/python-list/2001-April/080639.html, however
 could not trace out any reliable solution. I tried following :

  write.table(calc, file=c:/data.csv)
 Error in data.frame(200501 = c(-0.000387071806652095,
 -0.000387221689252648,  :
  arguments imply differing number of rows: 25, 24, 16, 17, 18, 26, 27, 19,
 23, 20, 11
 Anybody can help?

 Regards,

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




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

What is the problem you are trying to solve?

__
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] lmer model building--include random effects?

2008-04-23 Thread Douglas Bates
On 4/22/08, Ista Zahn [EMAIL PROTECTED] wrote:
 Hello,
  This is a follow up question to my previous one 
 http://tolstoy.newcastle.edu.au/R/e4/help/08/02/3600.html

  I am attempting to model relationship satisfaction (MAT) scores
  (measurements at 5 time points), using participant (spouseID) and
  couple id (ID) as grouping variables, and time (years) and conflict
  (MCI.c) as predictors. I have been instructed to include random
  effects for the slopes of both predictors as well as the intercepts,
  and then to drop non-significant random effects from the model. The
  instructor and the rest of the class is using HLM 6.0, which gives p-
  values for random effects, and the procedure is simply to run a model,
  note which random effects are not significant, and drop them from the
  model. I was hoping I could to something analogous by using the anova
  function to compare models with and without a particular random
  effect, but I get dramatically different results than those obtained
  with HLM 6.0.

  For example, I wanted to determine if I should include a random effect
  for the variable MCI.c (at the couple level), so I created two
  models, one with and one without, and compared them:

m.3 - lmer(MAT ~ 1 + years + MCI.c + (1 + years | spouseID) + (1 +
  years + MCI.c | ID), data=Data, method = ML)
m.1 - lmer(MAT ~ 1 + years + MCI.c  + (1 + years + MCI.c |
  spouseID) + (1 + years + MCI.c | ID), data=Data, method = ML)
anova(m.1, m.3)
  Data: Data
  Models:
  m.3: MAT ~ 1 + years + MCI.c + (1 + years | spouseID) + (1 + years +
  m.1: MCI.c | ID)
  m.3: MAT ~ 1 + years + MCI.c + (1 + years + MCI.c | spouseID) + (1 +
  m.1: years + MCI.c | ID)
  Df AIC BIC  logLik  Chisq Chi Df Pr(Chisq)
  m.3 12  5777.8  5832.7 -2876.9
  m.1 15  5780.9  5849.5 -2875.4 2.9428  3 0.4005

  The corresponding output from HLM 6.0 reads

   Random Effect   Standard  Variance dfChi- square   
 P-value
   Deviation Component

  
 --
   INTRCPT1,   R0  6.80961  46.37075  60  112.809140.000
  YEARS slope, R1  1.49329   2.22991  60  59.38729.500
MCI slope, R2  5.45608  29.76881  60   90.576150.007
  
 --

  To me, this seems to indicate that HLM 6.0 is suggesting that the
  random effect should be included in the model, while R is suggesting
  that it need not be. This is not (quite) a why do I get different
  results with X post, but rather an I'm worried that I might be doing
  something wrong post. Does what I've done look reasonable? Is there a
  better way to go about it

The first thing I would try to determine is whether the model fit by
HLM is equivalent to the model you have fit with lmer.  The part of
the HLM model output you have shown lists only variance components.
It does not provide covariances or correlations.  The lmer model is
fitting a 3 by 3 symmetric positive definite variance-covariance
matrix with a total of 6 parameters - 3 variances and 3 covariances.
It may be that HLM is fitting a simpler model in which the covariances
are all zero.

The next question would be exactly how HLM is calculating that
p-value.  I wonder where the 60 degrees of freedom comes from.  Do you
happen to have 60 couples in the study?

__
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] ROracle error at step 1

2008-04-23 Thread Prof Brian Ripley
Where did you get your ROracle package from?

 Built: R 2.2.1; i386-pc-mingw32; 2006-02-13 18:05:59; windows

indicates it was too old.  All methods-using packages need to have been 
installed recently, and definitely since 2.4.0.  (It is unsafe to use one 
that has not been installed for the same 'y' in 2.y.z because of its 
propensity for extracting bits of the R under which the package was 
installed.)

So 'step 1' is to install ROracle from the sources.


On Wed, 23 Apr 2008, Creighton, Sean  wrote:

 Hi

 I Can't connect to the Oracle database, any tips? Has anybody actually
 got ROracle up and running on windows?

 unable to find an inherited method for function dbConnect,
 for signature OraDriver

 I can happily connect to the same database through RODBC. Oracle client,
 version 9.2 installed, amongst others.

 Sean





 library(DBI)
 library(ROracle)

 packageDescription(ROracle)
 Package: ROracle
 Version: 0.5-7
 Date: 2006-02-13
 Title: Oracle database interface for R
 Author: David A. James [EMAIL PROTECTED] Jake Luciani
 [EMAIL PROTECTED]
 Maintainer: David A. James [EMAIL PROTECTED]
 Description: Oracle database interface (DBI) driver for R. This is a
 DBI-compliant Oracle driver based on the ProC/C++ embedded SQL. It
 implements the DBI version 0.1-8 plus one extension.
 SaveImage: yes
 Depends: R (= 2.0.0), methods, DBI (= 0.1-8)
 License: LGPL version 2 or newer
 URL: http://stat.bell-labs.com/RS-DBI http://www.omegahat.org
 Packaged: Mon Feb 13 18:05:55 2006; dj
 Built: R 2.2.1; i386-pc-mingw32; 2006-02-13 18:05:59; windows

 -- File: C:/PROGRA~1/R/R-26~1.0/library/ROracle/DESCRIPTION
 packageDescription(DBI)
 Package: DBI
 Version: 0.2-4
 Title: R Database Interface
 Author: R Special Interest Group on Databases (R-SIG-DB)
 Maintainer: David A. James [EMAIL PROTECTED]
 Depends: R (= 2.3.0), methods
 Imports: methods
 Description: A database interface (DBI) definition for communication
 between R and relational database management systems.  All classes in
 this package are virtual and need to be extended by the various
   R/DBMS implementations.
 LazyLoad: yes
 License: LGPL (version 2 or later)
 Collate: DBI.R Util.R zzz.R
 Packaged: Tue Oct 16 21:43:31 2007; dj
 Built: R 2.6.0; ; 2007-10-17 12:21:14; windows

 -- File: C:/PROGRA~1/R/R-26~1.0/library/DBI/DESCRIPTION

 R.Version()
 $platform
 [1] i386-pc-mingw32

 $arch
 [1] i386

 $os
 [1] mingw32

 $system
 [1] i386, mingw32

 $status
 [1] 

 $major
 [1] 2

 $minor
 [1] 6.0

 $year
 [1] 2007

 $month
 [1] 10

 $day
 [1] 03

 $`svn rev`
 [1] 43063

 $language
 [1] R

 $version.string
 [1] R version 2.6.0 (2007-10-03)



 sDB_un- scott
 sDB_pwd- tiger


 Oracle()
 An object of class OraDriver
 Slot Id:
 [1] 1952

 dbDriver(Oracle)
 An object of class OraDriver
 Slot Id:
 [1] 1952


   Ora- dbDriver(Oracle)
 Con - dbConnect(Ora, user = sDB_un, passwd = sDB_pwd)
 Error in function (classes, fdef, mtable)  :
  unable to find an inherited method for function dbConnect, for
 signature OraDriver


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

2008-04-23 Thread Ole Roessler

   Hello,
   I want to do some analyses with data originating from a hydrological model
   that are saved in multiple output files.
   I  want  to  import  the  output-files  in  R without a treatment like
   preproceesing every output file.
   The output file is more or less a matrix, but with additional rows in the
   header, describing the type of data.
   My question is:
   1. Is there a possibility to skip the rows or start with a certain row?
   I want to exclude row 2 and 3, so the first line become the header of the
   list below.
   This is the beginning of the output file to be imported.
   YYMMDDHH12345tot_average
   total runoff [mm per zone] (sum of QB, QI und QD)_submodel:unsatzon_model
   --------0.14666240.29580420.22250480.2279085
   0.10712021.
   2001 1 1 10.0552420.0373910.0515500.057681
   0.0210700.046036
   2001 1 1 20.0512880.0324040.0470270.056636
   0.0210700.042736
   2001 1 1 30.0524910.0329370.0480420.058415
   0.0210700.043701
   2001 1 1 40.0513890.0325080.0471360.056663
   0.0210700.042812
   2001 1 1 50.0507300.0322630.0465990.055585
   0.0210700.042278
   Would be a great help if there is a possibility.
   Thank you very much !
   best regards
   Ole

   --


   
   ---


   Ole Rößler 

   PhD - student 

   Climatology and Landscape-Ecology Research Group 

   Department of Geography 

   University of Bonn 


   Postal Address: 

   Meckenheimer Allee 166 

   53115 Bonn 

   Germany 



   Tel.:  +49-(0)228-737895 

   Fax.: +49-(0)228-737506 



   Email: [EMAIL PROTECTED]

   Homepage:
   [2]http://www.giub.uni-bonn.de/loeffler/people/people_sites/roessler.htm


   
   -

References

   1. mailto:[EMAIL PROTECTED]
   2. http://www.giub.uni-bonn.de/loeffler/people/people_sites/roessler.htm
__
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] lmer model building--include random effects?

2008-04-23 Thread Ista Zahn

On Apr 23, 2008, at 8:56 AM, Douglas Bates wrote:

 On 4/22/08, Ista Zahn [EMAIL PROTECTED] wrote:
 Hello,
 This is a follow up question to my previous one 
 http://tolstoy.newcastle.edu.au/R/e4/help/08/02/3600.html

 I am attempting to model relationship satisfaction (MAT) scores
 (measurements at 5 time points), using participant (spouseID) and
 couple id (ID) as grouping variables, and time (years) and conflict
 (MCI.c) as predictors. I have been instructed to include random
 effects for the slopes of both predictors as well as the intercepts,
 and then to drop non-significant random effects from the model. The
 instructor and the rest of the class is using HLM 6.0, which gives p-
 values for random effects, and the procedure is simply to run a  
 model,
 note which random effects are not significant, and drop them from the
 model. I was hoping I could to something analogous by using the anova
 function to compare models with and without a particular random
 effect, but I get dramatically different results than those obtained
 with HLM 6.0.

 For example, I wanted to determine if I should include a random  
 effect
 for the variable MCI.c (at the couple level), so I created two
 models, one with and one without, and compared them:

 m.3 - lmer(MAT ~ 1 + years + MCI.c + (1 + years | spouseID) + (1 +
 years + MCI.c | ID), data=Data, method = ML)
 m.1 - lmer(MAT ~ 1 + years + MCI.c  + (1 + years + MCI.c |
 spouseID) + (1 + years + MCI.c | ID), data=Data, method = ML)
 anova(m.1, m.3)
 Data: Data
 Models:
 m.3: MAT ~ 1 + years + MCI.c + (1 + years | spouseID) + (1 + years +
 m.1: MCI.c | ID)
 m.3: MAT ~ 1 + years + MCI.c + (1 + years + MCI.c | spouseID) + (1 +
 m.1: years + MCI.c | ID)
 Df AIC BIC  logLik  Chisq Chi Df Pr(Chisq)
 m.3 12  5777.8  5832.7 -2876.9
 m.1 15  5780.9  5849.5 -2875.4 2.9428  3 0.4005

 The corresponding output from HLM 6.0 reads

  Random Effect   Standard  Variance dfChi-  
 square   P-value
  Deviation Component

 --
  INTRCPT1,   R0  6.80961  46.37075  60   
 112.809140.000
 YEARS slope, R1  1.49329   2.22991  60  59.38729 
 .500
   MCI slope, R2  5.45608  29.76881  60
 90.576150.007
 --

 To me, this seems to indicate that HLM 6.0 is suggesting that the
 random effect should be included in the model, while R is suggesting
 that it need not be. This is not (quite) a why do I get different
 results with X post, but rather an I'm worried that I might be  
 doing
 something wrong post. Does what I've done look reasonable? Is  
 there a
 better way to go about it

 The first thing I would try to determine is whether the model fit by
 HLM is equivalent to the model you have fit with lmer.  The part of
 the HLM model output you have shown lists only variance components.
 It does not provide covariances or correlations.  The lmer model is
 fitting a 3 by 3 symmetric positive definite variance-covariance
 matrix with a total of 6 parameters - 3 variances and 3 covariances.
 It may be that HLM is fitting a simpler model in which the covariances
 are all zero.

Yes, I was also concerned that the model I fit in R may not be exactly  
the model fit by HLM. The estimates are similar but not exact. The  
model summaries from HLM and R are as follows:

HLM OUTPUT:


   The outcome variable is  MAT

   The model specified for the fixed effects was:
  

Level-1Level-2   Level-3
Coefficients   PredictorsPredictors
  -  ---   
 INTRCPT1, P0  INTRCPT2, B00INTRCPT3, G000
  YEARS slope, P1  INTRCPT2, B10INTRCPT3, G100
  * MCI slope, P2  INTRCPT2, B20INTRCPT3, G200

  '*' - This variable has been centered around its group mean


  Summary of the model specified (in equation format)
  ---

Level-1 Model

Y = P0 + P1*(YEARS) + P2*(MCI) + E

Level-2 Model

P0 = B00 + R0
P1 = B10 + R1
P2 = B20 + R2


Level-3 Model

B00 = G000 + U00
B10 = G100 + U10
B20 = G200 + U20

Run-time deletion has reduced the number of level-1 records to 716

 For starting values, data from 716 level-1 and 120 level-2 records  
were used

Iterations stopped due to small change in likelihood function
*** ITERATION 1008 ***

  Sigma_squared =110.43050

  Standard Error of Sigma_squared =  7.77797

Tau(pi)
  INTRCPT1,P0 46.37075  5.48151 -5.91342
 YEARS,P1  5.48151  2.22991  5.80536
   MCI,P2 -5.91342  5.80536 29.76881


Tau(pi) (as correlations)
  INTRCPT1,P0  1.000  0.539 -0.159
 YEARS,P1  

Re: [R] g(x,y) = f(x,y) - e(x)- e(y)?

2008-04-23 Thread Vincent Goulet
Le mer. 23 avr. à 06:59, William Simpson a écrit :

 Thanks Phipp very much for your help. I had meant, given that I'd
 computed the matrix f[x,y] and the vector e[x], how to take the
 difference. What is confusing is how to subtract a vector from a
 matrix. I don't want the recycling rule.

Well, then, how do you define the difference between a matrix and a  
vector if the vector is not recycled into a matrix?

Thanks to the column major order S uses and recycling, the difference  
between an m x n matrix 'M' and a vector of length n 'v',

M - v,

yields the right thing, namely the difference between each column of  
M and v.

HTH   Vincent




 Cheers
 Bill

 On Tue, Apr 22, 2008 at 9:53 AM, Philipp Pagel [EMAIL PROTECTED]  
 wrote:

 g(x,y) = f(x,y) - e(x)- e(y)
 These are continuous functions. I am not sure how to do this with  
 the
 discrete equivalents in R.

 Is this what you are looking for?

 g - function(x, y) {

f(x,y) - e(x) - e(y)
 }

 cu
Philipp

 --
 Dr. Philipp Pagel
 Lehrstuhl für Genomorientierte Bioinformatik
 Technische Universität München
 Wissenschaftszentrum Weihenstephan
 85350 Freising, Germany
 http://mips.gsf.de/staff/pagel

 __
 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] Luis Miguel Delgado Gomez/BBK está ausente d e la oficina.

2008-04-23 Thread ldelgado


Estaré ausente de la oficina desde el  22/04/2008 y no volveré hasta el
11/05/2008.

Responderé a su mensaje cuando regrese.
[[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] Writing list object to a file

2008-04-23 Thread Mike Prager
Arun Kumar Saha [EMAIL PROTECTED] wrote:

 Hi all,
 
 I am wondering how to write a 'list' object to a file. I already gone
 through some threads like
 http://mail.python.org/pipermail/python-list/2001-April/080639.html, however
 could not trace out any reliable solution. I tried following :
 
  write.table(calc, file=c:/data.csv)
 Error in data.frame(200501 = c(-0.000387071806652095,
 -0.000387221689252648,  :
   arguments imply differing number of rows: 25, 24, 16, 17, 18, 26, 27, 19,
 23, 20, 11
 Anybody can help?

Remember that a list is not a rectangular table. It may have
components of various types and shapes. Therefore, it's unlikely
you'll be able to write a file that can be read easily by
another program.

That said, we do this occasionally for users who want to use
spreadsheets (yuck!) to analyze part of a list.  We use the
following function, which simply prints the list to an ASCII
file with a long line length:

##
#  File:  Robj2txt.r
#  Language:  R
#  Programmer:Michael H. Prager
#  Date:  July 7, 2004
#  Synopsis:
#  Function to write a complex R object to an ASCII file.
#  Main use is to write objects created from .rdat files;
#  however, could be used to save other objects as well.
#  This can be used to create files for those who want to use
#  a spreadsheet or other program on the data.
###
Robj2txt - function(x, file = paste(deparse(substitute(x)),
.txt, sep = )) {
   #
   # ARGUMENTS:
   #  x:  R data object to save as ascii
   #  filename:   Name of file to save. Default is name of x
with .txt extension
   #
   tmp.wid = getOption(width)  # save current width
   options(width = 1)# increase output width
   sink(file)# redirect output to file
   print(x)  # print the object
   sink()# cancel redirection
   options(width = tmp.wid)  # restore linewidth
   return(invisible(NULL))   # return (nothing) from
function
   }
##

-- 
Mike Prager, NOAA, Beaufort, NC
* Opinions expressed are personal and not represented otherwise.
* Any use of tradenames does not constitute a NOAA endorsement.

__
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] Modeling presence only data in R

2008-04-23 Thread Alejandro González
Dear Milton, you have 2 packages for modelling species distribution in 
R: grasper and Biomod (by Wilfried Thuiller), but they are all 
presence-absence models, so you must generate pseudoabsences for each 
species, following recommendations in papers (see Lobo 2007). On the 
other side, there are free gis tools to perform presence-only models 
(Biomapper, GARP, Openmodeller). Write me if you need if you want some 
advice.


-- 
Alejandro González Fernández de Castro

Departamento de Biodiversidad y Conservación
Real Jardín Botánico (Consejo Superior de Investigaciones Científicas)

Plaza de Murillo, 2
28014 Madrid - Spain
00 34 91 4203017

__
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] Feed list of vectors to vioplot()?

2008-04-23 Thread Johannes Graumann
Johannes Graumann wrote:

 Hi,
 
 I have a list of vectors and am trying to coerce them into something that
 vioplot will take as groups of data to be plotted independently. Can
 someone nudge me into the right direction?
 
 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.

I'll try less impolite and with more info ...

I'm writing a function that contains this:

# function(x, ... , morestuff){}

which is gathered into a list like so:

# mylist - list(x, ...)

down the line I'd like to output all elements from mylist in seperate
vioplots in a single coordiante system. Now I have a hell of a time with
that because vioplot does not accept a list as input but only a succession
of vectors ... how can I now force my list into that form so a can say

# vioplot(magicfunction(mylist))

and get a violin plot for each list-member?

Thanks for any hint,

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] Modeling presence only data in R

2008-04-23 Thread Stéphane Dray
Ecological Niche Factor Analysis (ENFA) is implemented in the adehabitat 
package available on CRAN.

Cheers,



Alejandro González wrote:
 Dear Milton, you have 2 packages for modelling species distribution in 
 R: grasper and Biomod (by Wilfried Thuiller), but they are all 
 presence-absence models, so you must generate pseudoabsences for each 
 species, following recommendations in papers (see Lobo 2007). On the 
 other side, there are free gis tools to perform presence-only models 
 (Biomapper, GARP, Openmodeller). Write me if you need if you want some 
 advice.


   

-- 
Stéphane DRAY ([EMAIL PROTECTED] )
Laboratoire BBE-CNRS-UMR-5558, Univ. C. Bernard - Lyon I
43, Bd du 11 Novembre 1918, 69622 Villeurbanne Cedex, France
Tel: 33 4 72 43 27 57   Fax: 33 4 72 43 13 88
http://biomserv.univ-lyon1.fr/~dray/

__
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] g(x,y) = f(x,y) - e(x)- e(y)?

2008-04-23 Thread hadley wickham
 Thanks Phipp very much for your help. I had meant, given that I'd
  computed the matrix f[x,y] and the vector e[x], how to take the
  difference. What is confusing is how to subtract a vector from a
  matrix. I don't want the recycling rule.

That function sounds like its describing how to subtract the vector
from the matrix:

g[1, 1] = f[1, 1] - e[1] - e[1]
g[2, 3] = f[2, 3] - e[2] - e[3]

(which implies that f is square)

So maybe something like:

g - f - outer(e, e, -)

But a link to the paper and an example would be very helpful!

Hadley


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

__
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] Modeling presence only data in R

2008-04-23 Thread milton ruser
Dear Alejandro,

Thank you very much for your advice.
In fact I use GARP and Openmodeller, and they - up to I know - also generate
pseudo-absence when modelling. I am searching some R solution to compare the
results with OpenModeller outputs. Could you send-me a PDF (or the complete
reference) of Lobo 2007?

I never heared about grasper and Biomod. I will give a look on it.

Kind regards,
miltinho
Brazil


On 4/23/08, Alejandro González [EMAIL PROTECTED] wrote:

 Dear Milton, you have 2 packages for modelling species distribution in
 R: grasper and Biomod (by Wilfried Thuiller), but they are all
 presence-absence models, so you must generate pseudoabsences for each
 species, following recommendations in papers (see Lobo 2007). On the
 other side, there are free gis tools to perform presence-only models
 (Biomapper, GARP, Openmodeller). Write me if you need if you want some
 advice.


 --
 Alejandro González Fernández de Castro

 Departamento de Biodiversidad y Conservación
 Real Jardín Botánico (Consejo Superior de Investigaciones Científicas)

 Plaza de Murillo, 2
 28014 Madrid - Spain
 00 34 91 4203017

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


Re: [R] Modeling presence only data in R

2008-04-23 Thread Clément Calenge
Actually, the ENFA (function enfa, in the package adehabitat) is not 
really suitable for modelling environment suitability maps (though it is 
still useful to discover the patterns of the ecological niche with 
presence-only data). However, the package adehabitat also contains other 
functions allowing this kind of modelling: the Mahalanobis distances 
(function mahasuhab) and their factorial decomposition (function madifa) 
could be a useful approach. See:

Calenge C, Darmon G, Basille M, Loison A, Jullien JM. (2008) The 
factorial decomposition of the Mahalanobis distances in habitat 
selection studies. Ecology, 89, 555-566.

and references therein. You may also consider the GNESFA, a 
generalization of the MADIFA/ENFA approach (see the function gnesfa and 
references therein). Other commonly used approaches are also available 
in adehabitat.
Best wishes,


Clément Calenge.

Stéphane Dray wrote:
 Ecological Niche Factor Analysis (ENFA) is implemented in the adehabitat 
 package available on CRAN.

 Cheers,



 Alejandro González wrote:
   
 Dear Milton, you have 2 packages for modelling species distribution in 
 R: grasper and Biomod (by Wilfried Thuiller), but they are all 
 presence-absence models, so you must generate pseudoabsences for each 
 species, following recommendations in papers (see Lobo 2007). On the 
 other side, there are free gis tools to perform presence-only models 
 (Biomapper, GARP, Openmodeller). Write me if you need if you want some 
 advice.


   
 

   

-- 
Clément CALENGE
Observatoire des galliformes de montagne
Office national de la chasse et de la faune sauvage
Saint Benoist - 78610 Auffargis
tel. (33) 01.30.46.54.14

__
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 needed: Plotting step by step.

2008-04-23 Thread Atul Kulkarni
Hello,

I have generated 2 Poisson processes and want to plot them on a single graph
in a step by step manner in order to be able to compare them. I tried plot
and biplot but it does not help, I could connect two points by hand for
point graph if they were 5 or 10 I have more than 200 such point to be
connected and Poisson cluster makes it difficult for me to even read them
properly.

Can anyone tell me which is the function that can plot a stepwise graph for
me? I did google over the plot for step fun but did not understand much of
it. A simpler help would be more useful to me, as I am not a expert either
in Statistics or R.

Regards,
Atul.

-- 
Atul S. Kulkarni
Graduate Student,
Department of Computer Science,
University Of Minnesota,
Duluth, MN 55812.
www.d.umn.edu/~kulka053
-
Before you start some work, always ask yourself three questions - Why am I
doing it, What the results might be and Will I be successful. Only when you
think deeply and find satisfactory answers to these questions, go ahead.
Chanakya quotes (Indian politician, strategist and writer, 350 BC-275 BC)

[[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] Comparing kendall's tau values?

2008-04-23 Thread Ben Bolker
Ashton, Gail ashtong at si.edu writes:

 
 I have 3 variables relating to the successful introductions of species
 to 95 different areas: introduction frequency; number of successes pre
 1906; number of successes post 1906
 
 The data are not normal, nor homo-skedatic, so I am using non-parametric
 statistics.
 
 I have calculated Kendall's tau between both introduction  successes
 pre 1906 (tau=0.3903) and introduction  successes post 1906
 (tau=0.3317)- pre + post values are independent.
 
 Is it possible to test whether there is a significant difference between
 the tau values, ie one correlation is 'significantly' 'better'? Is there
 a way to calculate confidence intervals for tau?
 
 Thanks,
 
 Gail

  I think I would try bootstrapping/permutation tests in this case.
  Just a warning: nonparametric tests do _not_ necessarily do what
you think in the case of heteroscedasticity -- they are often
constructed to test for a difference in location parameter, assuming
the same distribution around the location parameter (mean, median etc.) --
i.e. assuming homoscedasticity.

   Any chance of using GLMs (i.e., treating success as a binary
variable)?

  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] Equivalent of intervals() in lmer

2008-04-23 Thread Michael Kubovy
Dear Friends,

(1) There may be a solution for those (e.g., experimental  
psychologists) who are *not at all* interested in generalizing the  
absolute level of the response variable (say, reaction time, rt) to  
other subjects, but *only* to generalize the effect of the manipulated  
variables within subjects (because that's what the theory speaks to)  
to other subjects. First, center the predictor(s) so as to remove any  
spurious correlation between mean and intercept, and then write the  
random effect w/o an intercept. Now the model will not address whether  
rt is different from 0, it will only estimate the slope and whether  
it's different from 0:

require(lme4)
require(gmodels)
data(sleepstudy)
ss - sleepstudy
ss$days - with(ss, Days - mean(Days))
(fm1 - lmer(Reaction ~ days + (days|Subject), ss))
(fm3 - lmer(Reaction ~ days + (-1 + days|Subject), ss))
ci(fm1)
ci(fm3) # CIs for days are about 14% smaller

(2) When the predictor is not continuous, this approach doesn't work.  
A solution for a designed experiment is to plot CIs for differences,  
i.e., 5%LSDs (rather than plot the CIs on cell means). Those CIs are  
smaller and address the question of interest. Here is a one-way ANOVA:

recall - c(10, 13, 13, 6, 8, 8, 11, 14, 14, 22, 23, 25, 16, 18, 20,
15, 17, 17, 1, 1, 4, 12, 15, 17, 9, 12, 12, 8, 9, 12)
fr - data.frame(rcl = recall, time = factor(rep(c(1, 2, 5), 10)),
subj = factor(rep(1:10, each = 3)))
(fr.lmer - lmer(rcl ~ time -1 +(1 | subj), fr))
mm - unique(model.matrix(~ time -1, fr))
cm - mm[1, ] - mm[3, ]
cm1 - mm[1, ] - mm[2, ]
estimable(fr.lmer, cm = cm, conf.into = 0.95)
estimable(fr.lmer, cm = cm1, conf.into = 0.95)

plot mean \pm 2* 0.366 and call it a 5%LSD (uncorrected for multiple  
comparisons)

In the case of a more-than-one-way ANOVA with interaction (say 2x2),  
choose which simple effects are of interest, get SEs for those; and  
then plot the four points with the CIs. These are not quite right for  
the difference between simple effects, but I don't know what to do  
about that.
_
Professor Michael Kubovy
University of Virginia
Department of Psychology
USPS: P.O.Box 400400Charlottesville, VA 22904-4400
Parcels:Room 102Gilmer Hall
 McCormick RoadCharlottesville, VA 22903
Office:B011+1-434-982-4729
Lab:B019+1-434-982-4751
Fax:+1-434-982-4766
WWW:http://www.people.virginia.edu/~mk9y/

On Apr 21, 2008, at 9:05 AM, Dieter Menne wrote:

 Douglas Bates bates at stat.wisc.edu writes:

 If you want to examine the three means then you should fit the  
 model as
 lmer(rcl ~ time - 1 + (1 | subj), fr)

 True, but for the notorious error bars in plots that reviewers  
 always request
 the 0.35 is probable more relevant than the 1.87. Which I think is  
 justified in
 this case, but in most non-orthogonal designs with three or more  
 factors, where
 we have a mixture of between/withing subject, there is no clear  
 solution. What
 to do when required to produce error-bars that reasonably mirror p- 
 values?

 It's easier with British Journals  in the medical field that often  
 have
 statistical professionals as reviewers, but many American Journals  
 with their
 amateur physician/statisticians (why no t-test on raw data?) drive  
 me nuts.

 Dieter

 #-
 library(lme4)
 recall - c(10, 13, 13, 6, 8, 8, 11, 14, 14, 22, 23, 25, 16, 18, 20,
 15, 17, 17, 1, 1, 4, 12, 15, 17, 9, 12, 12, 8, 9, 12)
 fr - data.frame(rcl = recall, time = factor(rep(c(1, 2, 5), 10)),
 subj = factor(rep(1:10, each = 3)))
 fr.lmer - lmer(rcl ~ time -1 +(1 | subj), fr)
 summary(fr.lmer)
 fr.lmer - lmer(rcl ~ time +(1 | subj), fr)
 summary(fr.lmer)
 --
 Fixed effects:
  Estimate Std. Error t value
 time1   11.000  1.879   5.853
 time2   13.000  1.879   6.918
 time5   14.200  1.879   7.556

 Fixed effects:
Estimate Std. Error t value
 (Intercept)  11. 1.8793   5.853
 time2 2. 0.3507   5.703
 time5 3.2000 0.3507   9.125


[[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] Overall p-value from a factor in a coxph fit

2008-04-23 Thread David Winsemius
Kåre Edvardsen [EMAIL PROTECTED] wrote in
news:[EMAIL PROTECTED]: 

 Prof. Paul,  Prof. Frank.
 
 Thank you very much for helping me out. The Design package did the
 trick.
 
 Here is how the anova table looks like without using the Design
 package: 
 
 anova(Fit1)
 Analysis of Deviance Table
 Cox model: response is Surv(Time, cancer)
 Terms added sequentially (first to last)
 
 Df Deviance Resid. Df Resid. Dev
 NULL   16783 5341.8
 relativ  1  0.01678214995.0
 hormone  3939.41677914055.6

 
 As you see, no p-values reported
 
 Here is how it looks with after implementing Design:
 
 anova(Fit1)
  Wald Statistics   Response: Surv(Time, cancer) 
  Factor Chi-Square d.f.P
  relativ 6.08   1   0.0137
  hormone 8.68   3   0.0339

(spacing added to hopefully look correct in monospaced font)

I was a puzzled looking at those two outputs. In the first the change 
in deviance with addition of hormone was 939.4 with 3 df. In the 
second the Wald chi-square, which I presume should be similar to the 
difference in deviance, is only 8.68. Were these outputs from 
completely different models or data? Or are there pitfalls in applying 
Design functions to Surv objects created with other packages?

-- 
David Winsemius



 Regards,
 Kare
 
 
 On Fri, 2008-04-18 at 11:03 -0500, Frank E Harrell Jr wrote:
 
 Paul Johnson wrote:
  On Fri, Apr 18, 2008 at 3:06 AM, Kåre Edvardsen [EMAIL PROTECTED]
  wrote 
:
  Hi all.
 
   If I run the simple regression when x is a categorical variable
   ( x 
  -
   factor(x) ):
 
MyFit -coxph( Surv(start, stop, event) ~ x )
 
   How can I get the overall p-value on x other than for each
   dummy variable?
 
anova(MyFit)
 
   does NOT provide that information as previously suggested on
   the li 
 st.
 
  
  It should work...  Here's a self contained example showing that
  anova does give the desired significance test for an lm model.
  
  y - rnorm(100)
  x - gl(5,20)
  mod - lm(y~x)
  anova(mod)
  Analysis of Variance Table
  
  Response: y
Df  Sum Sq Mean Sq F value Pr(F)
  x  4   6.575   1.644  1.5125 0.2047
  Residuals 95 103.237   1.087
  
  If you provide a similar self contained example leading up to a
  coxph 
 ,
  I would be glad to investigate your question.  You don't give
  enough information for me to tell which version of coxph you are
  running, an 
 d
  from what  package.
  
  Suppose I guess that you are using the coxph from the package
  survival. If so, it appears to me there is a bug in that
  package at the moment.  The methods anova.coxph and drop1.coxph
  did exist at one time, until very recently.  There is a thread in
  r-help (which I foun 
 d
  by typing RSiteSearch(anova.coxph) ) discussing recent
  troubles with anova.coxph.
  
  http://finzi.psych.upenn.edu/R/Rhelp02a/archive/118481.html
  
  As you see from the discussion in that thread, there used to be
  an anova method for coxph, and in the version of survival I have
  now, there is no such method.  The version I have is  2.34-1,
  Date: 
   2008-03-31.
  
  Here's what I see after I run example(coxph) in order to create
  som 
 e
  coxph objects, on which I can test the diagnostics:
  
  drop1(test2)
  Error in terms.default(terms1) : no terms component
  anova(test2)
  Error in UseMethod(anova) : no applicable method for anova
  
  In that survival package, I do find anova.survreg, but not
  anova.coxph. If you are using the survival package, I'd suggest
  you contact Thomas Lumley directly, since he maintains it.
  
  I think if you had reported the exact error you saw, it would
  have been easier for me to diagnose the trouble.
  
  HTH
  pj
  
 
 In the meantime you can do
 
 library(Design)
 f - cph( . . . )
 anova(f)  # multiple d.f. Wald statistics including tests of 
 nonlinearity
 
 cph uses coxph but anova.Design is separate from the survival
 package. 
 
 Frank
 
 
  [[alternative HTML version deleted]]
 
 
 --===0807199787==
 __
 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. 
 
 Attachment decoded: untitled-3.txt
 --===0807199787==--

__
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] Density estimation

2008-04-23 Thread Greg Snow
Look at the logspline package.  It has a different way of estimating
densities that allows for limits to be specified (i.e. probability is 0
beyond the point(s) you specify).

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 Gunther Jansen
 Sent: Wednesday, April 23, 2008 4:59 AM
 To: r-help@r-project.org
 Subject: [R] Density estimation
 
 Hi,
 
 I am analysing a dataset containing genetic distances within 
 and between species. I want to show a overlap of the 
 distributions of the intra- and interspecific values; on a 
 second graph I use a cut-off value to determine these 
 boundaries. As the dataset contains 30 000 values, I would 
 like to do this with a simple line rather than superimposed 
 histograms. Hence, density plots. With the standard settings 
 of plot(density(x)), I receive the desirable result, except 
 that the function extends slightly in negative x values 
 (which is impossible, distance values are always positive). 
 Furthermore, in the second figure I supplied the cut-off 
 value a priori, so overlap between the two classes is zero by 
 definition. Is there a way to visualise this information in 
 another way, or to readjust the density parameters so 
 intraspecific values below zero have zero probability in the 
 first case, and there is no overlap in the second case?
 
 
 Thanks,
 
 gunther
 
 __
 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] nested time series data with measurement error

2008-04-23 Thread Toby Gass
Dear R helpers,

I am trying to fit a model with the main objective of
assessing differences, rather than predicting.
The treatment was applied to half of the subjects after 9
months of measurement.
Then 9 more months of data were collected. The variable
month has measurement error
due to the complexities of data collection.
The dependent variable is numeric and continuous.
This would be a simple difference between means were it not
for the repeated
measurements and measurement error.

I am wondering what the R gurus suggest as to which R
function might best model
these data.  I have been looking at tsls (two-stage least
squares) in the sem package
and pls (partial least squares).  I am not sure about their
compatibility with repeated
measurements and time series.  The response curve is also
likely to be non-linear.

The following script approximates the data, including sample
size.  In the real data, there are 18 months spread out over 
a
36 month period.

#generate data

tree- gl(6,18,label = paste(tree,1:6))
month - gl(18,1,length = 108,label = paste(month,1:18),
ordered = TRUE)
trtmt - gl(2, 54, length = 108, label = paste(trt,1:2))
pre.post - gl(2,9,length = 108,  label = c(pre,post))
response - runif(108, min = -28, max = -25)
help - data.frame(tree,month,trtmt,pre.post, response)


Thank you in advance for your assistance.

Toby Gass

Graduate Degree Program in Ecology
Department of Forest, Rangeland, and Watershed Stewardship
Warner College of Natural Resources
Colorado State University
Fort Collins, CO  80523
email: [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.


[R] pdf() and histogram() in function call

2008-04-23 Thread qian z

   Here is a function I wrote. It runs no problem, but generate empty pdf
   files.

   I can't find what is the problem.


   create.pdf- function(x, dir)
{
 dir.create(dir, showWarnings = FALSE)
 plist- c(a, b , c, d)

 for(j in plist)
 {

  filedir- paste(dir, /, j, .pdf, sep=)

  form1- as.formula(paste(~ , j,  | var1, sep= ))
  form2- as.formula(paste(~ , j,  | var2, sep= ))
  form3- as.formula(paste(~ , j,  | var3, sep= ))
  pdf(filedir)

  histogram(form1,data=x,type=count, xlab=j,main=Histogram conditioned
   on the levels of var1)
  histogram(form2,data=x, type=count,xlab=j,main=Histogram conditioned
   on the levels of var2)
  histogram(form3, data=x, type=count, xlab=j, main=Histogram
   conditioned on the levels of var3 )

  dev.off()
 }


}


   I have tried to find the problem, but no luck!  Seriously need HELP! Thanks.

 _

   Be a better friend, newshound, and know-it-all with Yahoo! Mobile. [1]Try it
   now.

References

   1. 
http://us.rd.yahoo.com/evt=51733/*http://mobile.yahoo.com/;_ylt=Ahu06i62sR8HDtDypao8Wcj9tAcJ
__
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] g(x,y) = f(x,y) - e(x)- e(y)?

2008-04-23 Thread Greg Snow
It is not clear exactly what you want to do by subtracting a vector from a 
matrix, but look at the sweep function, it may do what you want.

-- 
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 William Simpson
 Sent: Wednesday, April 23, 2008 4:59 AM
 To: Philipp Pagel
 Cc: r-help@r-project.org
 Subject: Re: [R] g(x,y) = f(x,y) - e(x)- e(y)?
 
 Thanks Phipp very much for your help. I had meant, given that 
 I'd computed the matrix f[x,y] and the vector e[x], how to 
 take the difference. What is confusing is how to subtract a 
 vector from a matrix. I don't want the recycling rule.
 
 Cheers
 Bill
 
 On Tue, Apr 22, 2008 at 9:53 AM, Philipp Pagel 
 [EMAIL PROTECTED] wrote:
 
g(x,y) = f(x,y) - e(x)- e(y)
These are continuous functions. I am not sure how to do 
 this with 
  the   discrete equivalents in R.
 
   Is this what you are looking for?
 
   g - function(x, y) {
 
  f(x,y) - e(x) - e(y)
   }
 
   cu
  Philipp
 
   --
   Dr. Philipp Pagel
   Lehrstuhl für Genomorientierte Bioinformatik  Technische 
 Universität 
  München  Wissenschaftszentrum Weihenstephan  85350 
 Freising, Germany  
  http://mips.gsf.de/staff/pagel
 
   __
   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.


Re: [R] help needed: Plotting step by step.

2008-04-23 Thread Greg Snow
Can you show us the code you used for the 5 to 10 points? (either
generate some random data, or use a sample dataset).

-- 
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 Atul Kulkarni
 Sent: Wednesday, April 23, 2008 9:07 AM
 To: r-help@r-project.org
 Subject: [R] help needed: Plotting step by step.
 
 Hello,
 
 I have generated 2 Poisson processes and want to plot them on 
 a single graph in a step by step manner in order to be able 
 to compare them. I tried plot and biplot but it does not 
 help, I could connect two points by hand for point graph if 
 they were 5 or 10 I have more than 200 such point to be 
 connected and Poisson cluster makes it difficult for me to 
 even read them properly.
 
 Can anyone tell me which is the function that can plot a 
 stepwise graph for me? I did google over the plot for step 
 fun but did not understand much of it. A simpler help would 
 be more useful to me, as I am not a expert either in Statistics or R.
 
 Regards,
 Atul.
 
 --
 Atul S. Kulkarni
 Graduate Student,
 Department of Computer Science,
 University Of Minnesota,
 Duluth, MN 55812.
 www.d.umn.edu/~kulka053
 -
 Before you start some work, always ask yourself three 
 questions - Why am I doing it, What the results might be and 
 Will I be successful. Only when you think deeply and find 
 satisfactory answers to these questions, go ahead.
 Chanakya quotes (Indian politician, strategist and writer, 
 350 BC-275 BC)
 
   [[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] Course*** R/S-Plus Advanced Programming ****by XLSolutions Corp / May 2008 in San Francisco

2008-04-23 Thread [EMAIL PROTECTED]
Announcing R/Splus Advanced Programming course: May 29-30, 2008
in  San Francisco.

***  half of the seats are already taken  ***

Please email for earlybird rates: Payments due after the class.


R/Splus Advanced Programming Course Outline:

Day 1 

- Overview of R/S fundamentals: Syntax and Semantics 
- Class and Inheritance 
- Concepts, Construction and good use of Language Objects 
- Coercion and Efficiency 
- Object-oriented Programming in R and S-Plus 
- Taking advantage of fast objects and fast functions 
- Advanced Manipulation tools: Parse, Deparse, Substitute, etc. 
- How to fully take advantage of Vectorization 
- Generic and Method Functions 
- Search path, Databases and Frames Visibility (S-plus) 

Day 2 

- Working with Large Objects 
- Handling Properly Recursion and Iterative Calculations 
- Managing loops; For (S-Plus) and for() loops 
- Consequences of Lazy Evaluation 
- Efficient Code Practices for Large Computations 
- Memory Management and Resource Monitoring 
- Writing R and S-plus Functions to call Compiled Code 
- Writing and Debugging Compiled Code for S-plus and R system 
- Connecting R to External Data Sources 
- Macros in R 
- Understanding the Structure of Model fitting Functions in R and
S-plus 
- Designing and Packaging Efficiently a new model Function 

Payment due AFTER the class
Email us for group discounts.
Email Sue Turner: [EMAIL PROTECTED]
Phone: 206-686-1578
Visit us: www.xlsolutions-corp.com/courselist.htm
Please let us know if you and your colleagues are interested in this
class to take advantage of group discount. 

Register now to secure your seat!

Cheers,
Elvis Miller, PhD
Manager Training.
XLSolutions Corporation
206 686 1578
www.xlsolutions-corp.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] pdf() and histogram() in function call

2008-04-23 Thread Greg Snow
Read FAQ 7.22

-- 
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 qian z
 Sent: Wednesday, April 23, 2008 10:49 AM
 To: r-help@r-project.org
 Subject: [R] pdf() and histogram() in function call
 
 
Here is a function I wrote. It runs no problem, but 
 generate empty pdf
files.
 
I can't find what is the problem.
 
 
create.pdf- function(x, dir)
 {
  dir.create(dir, showWarnings = FALSE)
  plist- c(a, b , c, d)
 
  for(j in plist)
  {
 
   filedir- paste(dir, /, j, .pdf, sep=)
 
   form1- as.formula(paste(~ , j,  | var1, sep= ))
   form2- as.formula(paste(~ , j,  | var2, sep= ))
   form3- as.formula(paste(~ , j,  | var3, sep= ))
   pdf(filedir)
 
   histogram(form1,data=x,type=count, 
 xlab=j,main=Histogram conditioned
on the levels of var1)
   histogram(form2,data=x, 
 type=count,xlab=j,main=Histogram conditioned
on the levels of var2)
   histogram(form3, data=x, type=count, xlab=j, main=Histogram
conditioned on the levels of var3 )
 
   dev.off()
  }
 
 
 }
 
 
I have tried to find the problem, but no luck!  Seriously 
 need HELP! Thanks.
 
  _
 
Be a better friend, newshound, and know-it-all with Yahoo! 
 Mobile. [1]Try it
now.
 
 References
 
1. 
 http://us.rd.yahoo.com/evt=51733/*http://mobile.yahoo.com/;_yl
t=Ahu06i62sR8HDtDypao8Wcj9tAcJ
 __
 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] Feed list of vectors to vioplot()?

2008-04-23 Thread jim holtman
PLEASE do read the posting guide
http://www.R-project.org/posting-guide.html and provide commented,
minimal, self-contained, reproducible code.

It is hard to provide a solution if we do not understand the problem
to be solved.  Sample data would be helpful along with an
understanding of what you would expect for output.

On Wed, Apr 23, 2008 at 10:11 AM, Johannes Graumann
[EMAIL PROTECTED] wrote:

 Johannes Graumann wrote:

  Hi,
 
  I have a list of vectors and am trying to coerce them into something that
  vioplot will take as groups of data to be plotted independently. Can
  someone nudge me into the right direction?
 
  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.

 I'll try less impolite and with more info ...

 I'm writing a function that contains this:

 # function(x, ... , morestuff){}

 which is gathered into a list like so:

 # mylist - list(x, ...)

 down the line I'd like to output all elements from mylist in seperate
 vioplots in a single coordiante system. Now I have a hell of a time with
 that because vioplot does not accept a list as input but only a succession
 of vectors ... how can I now force my list into that form so a can say

 # vioplot(magicfunction(mylist))

 and get a violin plot for each list-member?

 Thanks for any hint,


 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.




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

What is the problem you are trying to solve?

__
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] help needed: Plotting step by step.

2008-04-23 Thread Charles C. Berry

Maybe like this?

 proc.1 - rexp(200,1)
 proc.2 - rexp(200,2)
 plot( ecdf( proc.1 ), xlim=range( proc.1, proc.2 ) )
 plot( ecdf( proc.2 ), add=T, col.points='red' )


See

?ecdf
?plot.stepfun


HTH,

Chuck

On Wed, 23 Apr 2008, Greg Snow wrote:

 Can you show us the code you used for the 5 to 10 points? (either
 generate some random data, or use a sample dataset).

 -- 
 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 Atul Kulkarni
 Sent: Wednesday, April 23, 2008 9:07 AM
 To: r-help@r-project.org
 Subject: [R] help needed: Plotting step by step.

 Hello,

 I have generated 2 Poisson processes and want to plot them on
 a single graph in a step by step manner in order to be able
 to compare them. I tried plot and biplot but it does not
 help, I could connect two points by hand for point graph if
 they were 5 or 10 I have more than 200 such point to be
 connected and Poisson cluster makes it difficult for me to
 even read them properly.

 Can anyone tell me which is the function that can plot a
 stepwise graph for me? I did google over the plot for step
 fun but did not understand much of it. A simpler help would
 be more useful to me, as I am not a expert either in Statistics or R.

 Regards,
 Atul.

 --
 Atul S. Kulkarni
 Graduate Student,
 Department of Computer Science,
 University Of Minnesota,
 Duluth, MN 55812.
 www.d.umn.edu/~kulka053
 -
 Before you start some work, always ask yourself three
 questions - Why am I doing it, What the results might be and
 Will I be successful. Only when you think deeply and find
 satisfactory answers to these questions, go ahead.
 Chanakya quotes (Indian politician, strategist and writer,
 350 BC-275 BC)

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


Charles C. Berry(858) 534-2098
 Dept of Family/Preventive Medicine
E mailto:[EMAIL PROTECTED]  UC San Diego
http://famprevmed.ucsd.edu/faculty/cberry/  La Jolla, San Diego 92093-0901

__
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] ccf and covariance

2008-04-23 Thread Bob Farmer
Hi.
It's my understanding that a cross-correlation function of vectors x
and y at lag zero is equivalent to their correlation (or covariance,
depending on how the ccf is defined).
If this is true, could somebody please explain why I get an
inconsistent result between cov() and ccf(type = covariance), but a
consistent result between cor() and ccf(type = correlation)?
Or have I misunderstood what is a cross-correlation?
(unfortunately, I can't seem to get a look at the ccf code, since I
think it's buried in some C function outside of the main environment)

Thanks very much.
--Bob Farmer
PhD candidate, Dalhousie University
Halifax, NS, Canada

Example:
d1-data.frame(matrix(ldeaths, nrow = 6, byrow = T))
seventy_4-as.numeric(d1[1,])
seventy_5-as.numeric(d1[2,])

ccf(x=seventy_4, y=seventy_5,
  plot = F, lag.max = 0, type = covariance
)
cov(seventy_4, seventy_5)  #inconsistent

ccf(x=seventy_4, y=seventy_5,
  plot = F, lag.max = 0, type = correlation
)
cor(seventy_4, seventy_5)  #consistent

__
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] significant variables in GPLS ?

2008-04-23 Thread Lena Lieckfeld
Hello,
I am using the gpls package for modelling vegetation classes.

My problem is that I now want to know which input variables are significant for 
the modelling of the classes to recalculate the equation again with just the 
selected variables.
I think I can analyse the significance of the variables via their weights.

I used the gpls1a term for two group classification. Here my code:

--
library(gpls)   #

 spex_Y-read.csv(F:/GPLS/spex_Y.csv, header=TRUE, sep=;)#, 
 row.names=ID)  #

 spex_X-read.csv(F:/GPLS/spex_X.csv, header=TRUE, sep=;)#, 
 row.names=ID)  #



 test - glpls1a(spex_X, spex_Y$A_mell,K.prov=7, br=FALSE)

 names(test)

[1] coefficients   convergenceniter  family   

[5] link   levs   bias.reduction


coefficients = regression coefficients

convergence = whether convergence is achieved

niter total = number of iterations

bias.reduction =  whether Firth's procedure is used

link = link function, logit is the only one practically implemented now


-

But the values (coefficients, convergence, niter, family, link, levs,
bias.reduction) I have got from the gpls1a do not contain any information about 
the significance of my input variables.

Does anybody have an idea how I can get information about the significance of 
my input values?

This would really help me a lot.


-- 

Jetzt dabei sein: http://www.shortview.de/[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] ccf and covariance

2008-04-23 Thread Prof Brian Ripley
On Wed, 23 Apr 2008, Bob Farmer wrote:

 Hi.
 It's my understanding that a cross-correlation function of vectors x
 and y at lag zero is equivalent to their correlation (or covariance,
 depending on how the ccf is defined).

The ratio of your values is

 MASS::fractions(282568.5/259021)
[1] 12/11

?  Do you recognize it?

There is an explanation in MASS4, p. 390, for example.

 If this is true, could somebody please explain why I get an
 inconsistent result between cov() and ccf(type = covariance), but a
 consistent result between cor() and ccf(type = correlation)?
 Or have I misunderstood what is a cross-correlation?
 (unfortunately, I can't seem to get a look at the ccf code, since I
 think it's buried in some C function outside of the main environment)

It is in the R sources, not 'buried' at all - that is what 'Open Source' 
means. You can browse them at https://svn.r-project.org/R/trunk, or 
download them for study.


 Thanks very much.
 --Bob Farmer
 PhD candidate, Dalhousie University
 Halifax, NS, Canada

 Example:
 d1-data.frame(matrix(ldeaths, nrow = 6, byrow = T))
 seventy_4-as.numeric(d1[1,])
 seventy_5-as.numeric(d1[2,])

 ccf(x=seventy_4, y=seventy_5,
  plot = F, lag.max = 0, type = covariance
 )
 cov(seventy_4, seventy_5)  #inconsistent

 ccf(x=seventy_4, y=seventy_5,
  plot = F, lag.max = 0, type = correlation
 )
 cor(seventy_4, seventy_5)  #consistent

 __
 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] Feed list of vectors to vioplot()?

2008-04-23 Thread Johannes Graumann
posted  mailed

Thanks for the very appropriate scolding.

Here's my example (based on ?vioplot):
mu-2
si-0.6
bimodal-c(rnorm(1000,-mu,si),rnorm(1000,mu,si))
uniform-runif(2000,-4,4)
normal-rnorm(2000,0,3)
# Working just fine
myfunction1 - function(x, ...){vioplot(x,...)}
myfunction1(bimodal,uniform,normal)
# What I (believe to) need
myfunction2 - function(x, ...){
  mylist - list(x, ...)
  # plenty of lapply stuff
  vioplot(mylist)
}
myfunction2(bimodal,uniform,normal)
-- Error in min(data) : invalid 'type' (list) of argument

I'm at a loss on how to disentangle mylist - unlist just gives me one big
vector back rather than the 3 I want to have back ...

Thanks for your patience, Joh

jim holtman wrote:

 PLEASE do read the posting guide
 http://www.R-project.org/posting-guide.html and provide commented,
 minimal, self-contained, reproducible code.
 
 It is hard to provide a solution if we do not understand the problem
 to be solved.  Sample data would be helpful along with an
 understanding of what you would expect for output.
 
 On Wed, Apr 23, 2008 at 10:11 AM, Johannes Graumann
 [EMAIL PROTECTED] wrote:

 Johannes Graumann wrote:

  Hi,
 
  I have a list of vectors and am trying to coerce them into something
  that vioplot will take as groups of data to be plotted independently.
  Can someone nudge me into the right direction?
 
  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.

 I'll try less impolite and with more info ...

 I'm writing a function that contains this:

 # function(x, ... , morestuff){}

 which is gathered into a list like so:

 # mylist - list(x, ...)

 down the line I'd like to output all elements from mylist in seperate
 vioplots in a single coordiante system. Now I have a hell of a time with
 that because vioplot does not accept a list as input but only a
 succession of vectors ... how can I now force my list into that form so a
 can say

 # vioplot(magicfunction(mylist))

 and get a violin plot for each list-member?

 Thanks for any hint,


 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.

 
 


__
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] Can I get rid of this for loop using apply?

2008-04-23 Thread Mike Dugas
Hey all,

The code below creates a partial dependence plot for the variable x1 in the
linear model y ~ x1 + x1^2 + x2.

I have noticed that the for loop in the code takes a long time to run if the
size of the data is increased.  Is there a way to change the for loop into
an apply statement?  The tricky part is that I need to change the values of
x1 in each step of the loop to give me the appropriate dataset to make
predictions on  cbind(m[,-match(x1,names(m))],x1=a[1,i+1]) .   If I try
and add the 1112 columns to the dataset a priori and use apply, the code
won't work because the predict function needs the column labeled x1.  I
realize I could just grab the form of the linear function and use that
instead of predict(), but I don't want to do that because I want to make
this code applicable to generic model fits.

#create fake data and fit a simple linear regression model
x1 - rep(c(1,3,4),100)
x2 - rep(c(1:6),50)
y - 40+2*x1^.5 - 6*x2 + rnorm(100,0,2)
m - as.data.frame(cbind(y,x1,x2))
lm1 - lm(y~x1+I(x1^2)+x2,data=m)

#super small version of R code for partial dependence plot
a - rbind(c(0:)*(max(m$x1)-min(m$x1))/ +
min(m$x1),c(0:)*0-9)
for(i in c(0:))
{
  a[2,i+1] -
mean(predict(lm1,cbind(m[,-match(x1,names(m))],x1=a[1,i+1])))
}
plot(a[1,],a[2,],xlab=x1,ylab=Response,type=l,main=Partial Dependence
Plot)

Many thanks,

Mike

[[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] Minimise a parameter of a given function f, with f 0

2008-04-23 Thread Kevin Lu
Hi,

I need to find the minimum value of the parameter, s, such that the function
f(s,t)  0 (where -Inf  t  Inf)

I've looked into optim, constrOptim and others but they don't seem to do
this. Des anyone have some suggestions?

Thanks in advance.

[[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] ccf and covariance

2008-04-23 Thread Bob Farmer
Thanks to Prof. Ripley and Phil Spector for pointing out that the
autocorrelation functions must use a nontraditional definition of
the covariance, involving a denominator of n (instead of n-1) in order
to satisfy an assumption of second-order stationarity in the
(unbiased) covariance estimators of a time series.

In terms of getting at the source code for the (apparently compiled)
R_acf, however, I've had no luck.  While
https://svn.r-project.org/R/trunk
seems to be able to show me the source code for otherwise obscured (in
the R console) functions like print()
(e.g. https://svn.r-project.org/R/trunk/src/library/base/R/print.R ),
I can't seem to find the C code (R_acf?) called in this section:

array(.C(R_acf, as.double(x), as.integer(sampleT),
as.integer(nser), as.integer(lag.max), as.integer(type ==
correlation), acf = double((lag.max + 1) * nser *
nser), NAOK = TRUE)


of acf().
For instance, in https://svn.r-project.org/R/trunk/src/library/stats/src/
there is (seemingly) no R_acf.C or stats.C file that I would expect to see.
I apologize in advance if this question is elementary or naive -- this
is my first time dealing with the source code.

Thanks again.
--Bob Farmer

On Wed, Apr 23, 2008 at 3:31 PM, Prof Brian Ripley
[EMAIL PROTECTED] wrote:
 On Wed, 23 Apr 2008, Bob Farmer wrote:


  Hi.
  It's my understanding that a cross-correlation function of vectors x
  and y at lag zero is equivalent to their correlation (or covariance,
  depending on how the ccf is defined).
 

  The ratio of your values is


  MASS::fractions(282568.5/259021)
 
  [1] 12/11

  ?  Do you recognize it?

  There is an explanation in MASS4, p. 390, for example.



  If this is true, could somebody please explain why I get an
  inconsistent result between cov() and ccf(type = covariance), but a
  consistent result between cor() and ccf(type = correlation)?
  Or have I misunderstood what is a cross-correlation?
  (unfortunately, I can't seem to get a look at the ccf code, since I
  think it's buried in some C function outside of the main environment)
 

  It is in the R sources, not 'buried' at all - that is what 'Open Source'
 means. You can browse them at https://svn.r-project.org/R/trunk, or download
 them for study.



 
  Thanks very much.
  --Bob Farmer
  PhD candidate, Dalhousie University
  Halifax, NS, Canada
 
  Example:
  d1-data.frame(matrix(ldeaths, nrow = 6, byrow = T))
  seventy_4-as.numeric(d1[1,])
  seventy_5-as.numeric(d1[2,])
 
  ccf(x=seventy_4, y=seventy_5,
   plot = F, lag.max = 0, type = covariance
  )
  cov(seventy_4, seventy_5)  #inconsistent
 
  ccf(x=seventy_4, y=seventy_5,
   plot = F, lag.max = 0, type = correlation
  )
  cor(seventy_4, seventy_5)  #consistent
 
 
  __
  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] Feed list of vectors to vioplot()?

2008-04-23 Thread Johannes Graumann
Off-list it was pointed out to me that the trivial solution to this would
look like this:
myfunction2 - function(x, ...){
  mylist - list(x, ...)
  # plenty of lapply stuff
  do.call(vioplot,mylist)
}

Thanks for everybodies patience,

Joh

Johannes Graumann wrote:

 posted  mailed
 
 Thanks for the very appropriate scolding.
 
 Here's my example (based on ?vioplot):
 mu-2
 si-0.6
 bimodal-c(rnorm(1000,-mu,si),rnorm(1000,mu,si))
 uniform-runif(2000,-4,4)
 normal-rnorm(2000,0,3)
 # Working just fine
 myfunction1 - function(x, ...){vioplot(x,...)}
 myfunction1(bimodal,uniform,normal)
 # What I (believe to) need
 myfunction2 - function(x, ...){
   mylist - list(x, ...)
   # plenty of lapply stuff
   vioplot(mylist)
 }
 myfunction2(bimodal,uniform,normal)
 -- Error in min(data) : invalid 'type' (list) of argument
 
 I'm at a loss on how to disentangle mylist - unlist just gives me one
 big vector back rather than the 3 I want to have back ...
 
 Thanks for your patience, Joh
 
 jim holtman wrote:
 
 PLEASE do read the posting guide
 http://www.R-project.org/posting-guide.html and provide commented,
 minimal, self-contained, reproducible code.
 
 It is hard to provide a solution if we do not understand the problem
 to be solved.  Sample data would be helpful along with an
 understanding of what you would expect for output.
 
 On Wed, Apr 23, 2008 at 10:11 AM, Johannes Graumann
 [EMAIL PROTECTED] wrote:

 Johannes Graumann wrote:

  Hi,
 
  I have a list of vectors and am trying to coerce them into something
  that vioplot will take as groups of data to be plotted independently.
  Can someone nudge me into the right direction?
 
  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.

 I'll try less impolite and with more info ...

 I'm writing a function that contains this:

 # function(x, ... , morestuff){}

 which is gathered into a list like so:

 # mylist - list(x, ...)

 down the line I'd like to output all elements from mylist in seperate
 vioplots in a single coordiante system. Now I have a hell of a time with
 that because vioplot does not accept a list as input but only a
 succession of vectors ... how can I now force my list into that form so
 a can say

 # vioplot(magicfunction(mylist))

 and get a violin plot for each list-member?

 Thanks for any hint,


 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.

 
 

 
 __
 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] combining two (or more) tables by creating another dimension

2008-04-23 Thread Georg Ehret
Dear R community, I wish to combine two tables in one by adding an
additional dimension:

e.g.:

t1-as.table(matrix(rnorm(40),nrow=4,ncol=10));rownames(t1)-c(rowone,rowtwo,rowthree,rowfour)
 t1
   A   B   C   D   E
  F   G   H   I   J
rowone   -1.04203810 -0.05148987 -1.74162922  0.02683198 -0.28622512
-0.87690444 -0.12335543 -0.60394319 -0.15923255  0.53235864
rowtwo   -1.01168507  1.07785313 -0.17483300 -0.60747916  1.12944895
 0.89512881  0.13972544  0.05006999  1.08190614  1.65985042
rowthree -1.52667891 -0.50032166  2.04588634 -1.55943514  1.58400939
-0.03039314 -0.21145199  0.11526848  2.24376313 -0.74787863
rowfour   0.39287271 -0.55125576 -0.74755340 -1.73366333  0.18886435
 0.60942387  1.03573198 -1.93694305  0.32919872 -0.09073655

t2-as.table(matrix(rnorm(40),nrow=4,ncol=10));rownames(t1)-c(rowone,rowtwo,rowthree,rowfour)
 t2
A   B   C   D   E   F
G   H   I   J
A -0.23533769 -1.13888448  0.33531402  0.53159432  0.37499285  0.14237453
 0.38195561 -1.06769856 -0.43285636  0.50321651
B -1.96015770 -0.70381431  0.24031069 -0.65790501 -0.87634039  0.26629589
 0.66948553 -0.78660318  0.86132576 -1.03440605
C  1.48375673 -0.07710868 -0.18416378 -2.39868210 -0.09285612  0.88384443
 1.34379990  1.15250558 -1.26557860 -0.63810608
D -1.45636216  0.03015655  1.68455454  1.19187925  0.10197788  0.54773000
-0.19173498  0.74170610  1.10240139  1.32562483

How can t1 and t2 be combined in an object with dim(object)=c(2,4,10)?
Thank you and wishing you a great day!
Georg.
*
Georg B. Ehret
Johns Hopkins
Baltimore, 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 on coxph.wtest

2008-04-23 Thread Weilian Sang
Hi,
i need to use pspline. In this pspline function coxph.wtest was used. When I
try to make some change to this function by pulling out the pspline
function, it turns out R gave me an error msg, saying coxph.wtest cannot be
found. Even if i dont change anything in pspline and just rename it and run
the function, it did not work out. Can any one help me with this? is there
anyway to get the coxph.wtest function? thank you

[[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] Multidimensional contingency tables

2008-04-23 Thread Giovanni Petris

It seems to me that a combination of ftable and xtabs works fine:

 prob1- data.frame(victim=c(rep('white',4),rep('black',4)),
+ perp=c(rep('white',2),rep('black',2),rep('white',2),rep('black',2)),
+ death=rep(c('yes','no'),4), count=c(19,132,11,52,0,9,6,97))
 prob1
  victim  perp death count
1  white white   yes19
2  white whiteno   132
3  white black   yes11
4  white blackno52
5  black white   yes 0
6  black whiteno 9
7  black black   yes 6
8  black blackno97
 ftable(xtabs(count ~ victim + perp + death, data = prob1))
 death  no yes
victim perp   
black  black97   6
   white 9   0
white  black52  11
   white   132  19
 
Best,
Giovanni

 Date: Tue, 22 Apr 2008 08:24:36 -0500
 From: hadley wickham [EMAIL PROTECTED]
 Sender: [EMAIL PROTECTED]
 Cc: [EMAIL PROTECTED]
 Precedence: list
 
 On Mon, Apr 21, 2008 at 9:46 PM, Robert A. LaBudde [EMAIL PROTECTED] wrote:
  How does one ideally handle and display multidimenstional contingency
   tables in R v. 2.6.2?
 
   E.g.:
 
 prob1- data.frame(victim=c(rep('white',4),rep('black',4)),
   +   perp=c(rep('white',2),rep('black',2),rep('white',2),rep('black',2)),
   +   death=rep(c('yes','no'),4), count=c(19,132,11,52,0,9,6,97))
 prob1
 victim  perp death count
   1  white white   yes19
   2  white whiteno   132
   3  white black   yes11
   4  white blackno52
   5  black white   yes 0
   6  black whiteno 9
   7  black black   yes 6
   8  black blackno97
 
   The xtabs() function doesn't seem appropriate, as it has no means of
   using 'count'.
 
   This must be a common problem.
 
 You can also use the reshape package (http://had.co.nz/reshape)
 
 cast(prob1, victim ~ perp, sum, value=count)
 cast(prob1, victim ~ perp ~ death, sum, value=count)
 cast(prob1, death + victim ~ perp, sum, value=count)
 
 etc.
 
 Hadley
 -- 
 http://had.co.nz/
 
 __
 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.
 
 

-- 

Giovanni Petris  [EMAIL PROTECTED]
Associate Professor
Department of Mathematical Sciences
University of Arkansas - Fayetteville, AR 72701
Ph: (479) 575-6324, 575-8630 (fax)
http://definetti.uark.edu/~gpetris/

__
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] BB - a new package for solving nonlinear system of equations and for optimization with simple constraints

2008-04-23 Thread Ravi Varadhan
Hi,

 

We (Paul Gilbert and I) have just released a new R package on CRAN called
BB (stands for Barzilai-Borwein) that provides functionality for solving
large-scale (and small-scale) nonlinear system of equations.  Until now, R
didn't have any functionality for solving nonlinear systems.  We hope that
this package fills that need.  

 

We also have an implementation of the spectral projected gradient method for
the optimization of (smooth) nonlinear objective functions, subject to
simple constraints that can be defined as a projection mapping.  This
function, spg(), is suited for large-scale optimization.  It generally
performs better than the conjugate-gradient methods in optim, and
complements the low-memory BFGS method for constraints that can be defined
by the user as projection mapping.  

 

Best regards,

Ravi.


---

Ravi Varadhan, Ph.D.

Assistant Professor, The Center on Aging and Health

Division of Geriatric Medicine and Gerontology 

Johns Hopkins University

Ph: (410) 502-2619

Fax: (410) 614-9625

Email: [EMAIL PROTECTED]

Webpage:  http://www.jhsph.edu/agingandhealth/People/Faculty/Varadhan.html

 




 


[[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] filled contour plots

2008-04-23 Thread Fernando De Sales
   hello everyone,
   I was wondering if anybody can help me solve 2
problems related to the function filled.contour.
   I am entering the following R command:

filled.contour(xx,yy,P1, nlevels=20,color=cm.colors,
 plot.axes={
 contour(xx,yy,P1,add=T,col=grey,
nlevels=20, drawlabels=F)
axis(1,1:length(xx),labels=xlabels)
axis(2,1:length(yy),labels=ylabels)
   })

which results in the figure attached. Overall the
figure looks great. However, my 2 question are:

1) how can I make sure that the contour lines match
the shading?  you can see from the figure (center
left) there's a contour missing.

2) how can I get smoother contours/shading, without so
many sharp angles?

   I appreciate any help from you.
   thank you so very much for the attention.

   F. DeSales
   


  

Be a better friend, newshound, and 
__
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] filled contour plots

2008-04-23 Thread Fernando De Sales
  sorry. the figure did not go through.
  sending again as PDF. hope it will work this time.
  Thanks
  


  

Be a better friend, newshound, and 
__
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] Compiling msm on Fedora Core Linux

2008-04-23 Thread Adam Wilson
Greetings all,

I'm trying to install the msm package and it is failing on compilation.  The
problem seems to be the analyticp component?  Any advice on how to get it to
work?

error message is below.  I'm running R version 2.6.2 (2008-02-08)
x86_64-redhat-linux-gnu  on a dell precision 690 with Fedora Core 8.

Thanks,
Adam


 install.packages(msm,lib=/usr/lib64/R/library)
trying URL 'http://cran.mirrors.hoobly.com/src/contrib/msm_0.8.tar.gz'
Content type 'application/x-tar' length 577213 bytes (563 Kb)
opened URL
==
downloaded 563 Kb

* Installing *source* package 'msm' ...
** libs
gcc -m64 -std=gnu99 -I/usr/include/R -I/usr/include/R
-I/usr/local/include-fpic  -O2 -g -pipe -Wall -Wp,-D_FORTIFY_SOURCE=2
-fexceptions -fstack-protector --param=ssp-buffer-size=4 -m64 -mtune=generic
-c analyticp.c -o analyticp.o
In file included from analyticp.c:9:
msm.h:3:15: error: R.h: No such file or directory
msm.h:4:26: error: R_ext/Applic.h: No such file or directory
analyticp.c: In function 'AnalyticP':
analyticp.c:51: warning: implicit declaration of function 'Calloc'
analyticp.c:51: error: expected expression before 'double'
analyticp.c:51: warning: cast to pointer from integer of different size
analyticp.c:52: error: expected expression before 'double'
analyticp.c:52: warning: cast to pointer from integer of different size
analyticp.c:63: warning: implicit declaration of function 'error'
analyticp.c:91: warning: implicit declaration of function 'Free'
make: *** [analyticp.o] Error 1
ERROR: compilation failed for package 'msm'
** Removing '/usr/lib64/R/library/msm'

The downloaded packages are in
/tmp/RtmpaoUZiC/downloaded_packages
Updating HTML index of packages in '.Library'
Warning messages:
1: In install.packages(msm, lib = /usr/lib64/R/library) :
  installation of package 'msm' had non-zero exit status
2: In tools:::unix.packages.html(.Library) :
  cannot create HTML package index







-- 
Adam Wilson
http://hydrodictyon.eeb.uconn.edu/people/wilson/
Department of Ecology and Evolutionary Biology
BioPharm 223
University of Connecticut
Tel: 860.486.4157
[EMAIL PROTECTED]

[[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] 64 bit Linux/Ubuntu memory limit problem?

2008-04-23 Thread zack holden

Dear list,
 
I've recently installed R on a 64 bit machine with 8 GB of RAM. I set this 
computer up as a dual-boot system, with windows XP 64 and Ubuntu 7.10. I 
downloaded the Linux 64 bit version of R and installed it. 
 
I'm trying to run rather large Random forest models and was running into severe 
memory limitations with my old windows 32 bit machines.
 
When I run Random Forest models on my new machine, I get the error message: 
Error: cannot allocate vector of size 2.1 GB. 
 
I'm a new Linux user, but I thought that R under Linux would by default take 
advantage of all available memory. I've searched previous posts and found only 
1 thread (posted by David Katz) that didn't really help.
 
Do I need to specify that the Ubuntu/Linux OS use all 8 Gigs of RAM? Could I 
have done something wrong when I downloaded and installed R? 
 
I'd appreciate any advice. 
 
Thanks in advance,
 
Zack
[[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] Can I get rid of this for loop using apply?

2008-04-23 Thread Mike Dugas
The answer to my post is yes (which I just figured out).

Solution:



#super small version of R code for pd plot using apply

a - rbind(c(0:)*(max(m$x1)-min(m$x1))/ +
min(m$x1),c(0:)*0-9)

b - matrix(rep(c(0:)*(max(m$x1)-min(m$x1))/ + min(m$x1), nrow(m)),
nrow(m), 1112, byrow=T)

a[2,] - apply(b,2,FUN=function(x)
{mean(predict(lm1,cbind(m[,-match(x1,names(m))],x1=x)))  })

plot(a[1,],a[2,],xlab=x1,ylab=Response,type=l,main=Partial Dependence
Plot)


Mike Dugas

[[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] filled contour plots

2008-04-23 Thread Fernando De Sales
   The see the figure I refer to on my email, please
use this link:

http://us.f13.yahoofs.com/bc/480fa972_411e/bc/My+Documents/filled_contour_plot.pdf?bfy26DIBonZ1vybc

   thanks

hello everyone,
I was wondering if anybody can help me solve 2
 problems related to the function filled.contour.
I am entering the following R command:
 
 filled.contour(xx,yy,P1, nlevels=20,color=cm.colors,
  plot.axes={
  contour(xx,yy,P1,add=T,col=grey,
 nlevels=20, drawlabels=F)
 axis(1,1:length(xx),labels=xlabels)
 axis(2,1:length(yy),labels=ylabels)
})
 
 which results in the figure attached. Overall the
 figure looks great. However, my 2 question are:
 
 1) how can I make sure that the contour lines match
 the shading?  you can see from the figure (center
 left) there's a contour missing.
 
 2) how can I get smoother contours/shading, without
 so
 many sharp angles?
 
I appreciate any help from you.
thank you so very much for the attention.
 
F. DeSales

 
 
  


 Be a better friend, newshound, and 
  __
 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.
 



  

Be a better friend, newshound, and

__
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] help on coxph.wtest

2008-04-23 Thread Weilian Sang
 Hi
 i need to use pspline. In this pspline function coxph.wtest was used. When
 I try to make some change to this function by pulling out the pspline
 function, it turns out R gave me an error msg, saying coxph.wtest cannot be
 found. Even if i dont change anything in pspline and just rename it and run
 the function, it did not work out. Can any one help me with this? is there
 anyway to get the coxph.wtest function? thank you


[[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] Can I get rid of this for loop using apply?

2008-04-23 Thread hadley wickham
On Wed, Apr 23, 2008 at 4:23 PM, Mike Dugas [EMAIL PROTECTED] wrote:
 The answer to my post is yes (which I just figured out).


Switching from for to apply isn't going to speed up your code.  If you
carefully read the source code of apply, you'll see the guts of the
work is done by:

 for (i in 1:d2) {
tmp - FUN(array(newX[, i], d.call, dn.call), ...)
if (!is.null(tmp))
ans[[i]] - tmp
}

i.e apply uses for internally.  The reason to use apply instead of a
for loop is so that you can better express the intent of your
algorithm.

Hadley


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

__
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] printing to the console in color

2008-04-23 Thread Applejus

Hi,

Is there a function that would allow me to print things in different colors
to the CONSOLE, say one line in blue and another line in green? 
Right now, the print() function only prints in navy blue...

Thanks!
-- 
View this message in context: 
http://www.nabble.com/printing-to-the-console-in-color-tp16834851p16834851.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] help on coxph.wtest

2008-04-23 Thread Lisa Sang
Hi,
i need to use pspline. In this pspline function coxph.wtest was used. When I
try to make some change to this function by pulling out the pspline
function, it turns out R gave me an error msg, saying coxph.wtest cannot be
found. Even if i dont change anything in pspline and just rename it and run
the function, it did not work out. Can any one help me with this? is there
anyway to get the coxph.wtest function? thank you

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

2008-04-23 Thread Judith Flores
Hello,

   I have been trying to apply some of the different
ways suggested in the past to replace empty values in
a vector for a letter, without success.

   Actually, I have a data frame that might contain
empty values, I need to replace all those empty values
for the letter 'N'.

  This was my latest try:

   dat-read.csv('myfile.csv', na.strings=)

   

   


  

Be a better friend, newshound, and

__
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] filled contour plots (link)

2008-04-23 Thread Fernando De Sales
   I have moved the figure to the link below. thank
you
  




  

Be a better friend, newshound, and

__
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] select rows from data based on a vector of char strings

2008-04-23 Thread Jorge Ivan Velez
Try this,

x=label   freq1   freq2
news   54  35
fun  37  21
milk19  7
food 3   3

yourdata=read.table(textConnection(x),header=TRUE)
attached(yourdata)
flist-c(fun,food)

yourdata[label %in% flist,]


I hope this helps,


Jorge



On Wed, Apr 23, 2008 at 3:13 AM, Dirkheld [EMAIL PROTECTED]
wrote:


 Hi,

 I have loaded a dataset in R :
 data =

 label   freq1   freq2
 news   54  35
 fun  37  21
 milk19  7
 food 3   3
  etc

 And I have a vector
 flist-c(fun,food)

 Now I want to use the vector 'flist' for selecting these values from
 'data'
 so that I get the following dataset :
 label   freq1   freq2
 fun  37  21
 food 3   3

 When I do 'data$label==flist[1]' I get 'F T F F', so it works for one item
 in the char vector flist.
 But, when I do 'data$label==flist' I get 'F F F F' while I expected 'F T F
 T'. It seems that I can't perform this action with a vector of
 charstrings?

 Is there an other way to do so?

 --
 View this message in context:
 http://www.nabble.com/select-rows-from-data-based-on-a-vector-of-char-strings-tp16832735p16832735.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.


[[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] mysterious (to me) automatic loading of packages when R starts up

2008-04-23 Thread Duncan Mackay
Hello,
I have recently noticed that in one of my work areas, a number of packages
are automatically loaded without my explicitly requesting them to be loaded
(see below). This only happens in one particular workspace (located in a
folder). I suspect (without any real evidence) that this may be related to
my creating plots using the ggplot2 package earlier in this workspace.

I am running R 2.7.0 under Vista but I noticed the same behavior under R
2.6.2 last week.

Can someone please tell me why this is happening and how I can prevent this
automatic package loading in this workspace?

Thanks,
Duncan


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.

Loading required package: proto
Loading required package: grid
Loading required package: reshape
[Previously saved workspace restored]



__
Dr. Duncan Mackay
School of Biological Sciences
Flinders University
GPO Box 2100
Adelaide
S.A.  5001
AUSTRALIA

Phone61-8-82012627
FAX  61-8-82013015

http://www.scieng.flinders.edu.au/biology/people/academic/mackay_d/index.htm
l

__
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] select rows from data based on a vector of char strings

2008-04-23 Thread Bert Gunter
u...

One of the S language's great strengths is the variety and flexibility of
it's data structures. It pays to familiarize yourself with them. So if x is
already a dataframe (dataset is a rather unhelpful description), then
row.names(x) - x$label 
x[c(fun,food),] 

will extract the rows you want (to be suitably assigned by you, of course).
Incidentally, the row names typically could have been set when you first
read the data in (e.g. via ?read.table() and friends).

If x is not a dataframe, then your should make it one, and ?data.frame will
tell you how, depending on what it actually is.

I repeat: learn about R's data structures and how to use them if you wish to
take full advantage of the language and its power (and avoid the
unnecessary, though correct (mod the typo), manipulations described in the
reply below).

-- Bert Gunter



-Original Message-
From: [EMAIL PROTECTED] [mailto:[EMAIL PROTECTED] On
Behalf Of Jorge Ivan Velez
Sent: Wednesday, April 23, 2008 4:48 PM
To: Dirkheld
Cc: r-help@r-project.org
Subject: Re: [R] select rows from data based on a vector of char strings

Try this,

x=label   freq1   freq2
news   54  35
fun  37  21
milk19  7
food 3   3

yourdata=read.table(textConnection(x),header=TRUE)
attached(yourdata)
flist-c(fun,food)

yourdata[label %in% flist,]


I hope this helps,


Jorge



On Wed, Apr 23, 2008 at 3:13 AM, Dirkheld [EMAIL PROTECTED]
wrote:


 Hi,

 I have loaded a dataset in R :
 data =

 label   freq1   freq2
 news   54  35
 fun  37  21
 milk19  7
 food 3   3
  etc

 And I have a vector
 flist-c(fun,food)

 Now I want to use the vector 'flist' for selecting these values from
 'data'
 so that I get the following dataset :
 label   freq1   freq2
 fun  37  21
 food 3   3

 When I do 'data$label==flist[1]' I get 'F T F F', so it works for one item
 in the char vector flist.
 But, when I do 'data$label==flist' I get 'F F F F' while I expected 'F T F
 T'. It seems that I can't perform this action with a vector of
 charstrings?

 Is there an other way to do so?

 --
 View this message in context:

http://www.nabble.com/select-rows-from-data-based-on-a-vector-of-char-string
s-tp16832735p16832735.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.


[[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] select rows from data based on a vector of char strings

2008-04-23 Thread Jorge Ivan Velez
I'm sorry about that. Second line should be

attach(yourdata)


Cheers,

Jorge



On Wed, Apr 23, 2008 at 7:48 PM, Jorge Ivan Velez [EMAIL PROTECTED]
wrote:


 Try this,

 x=label   freq1   freq2
 news   54  35
 fun  37  21
 milk19  7
 food 3   3

 yourdata=read.table(textConnection(x),header=TRUE)
 attached(yourdata)
 flist-c(fun,food)

 yourdata[label %in% flist,]


 I hope this helps,


 Jorge




 On Wed, Apr 23, 2008 at 3:13 AM, Dirkheld [EMAIL PROTECTED]
 wrote:

 
  Hi,
 
  I have loaded a dataset in R :
  data =
 
  label   freq1   freq2
  news   54  35
  fun  37  21
  milk19  7
  food 3   3
   etc
 
  And I have a vector
  flist-c(fun,food)
 
  Now I want to use the vector 'flist' for selecting these values from
  'data'
  so that I get the following dataset :
  label   freq1   freq2
  fun  37  21
  food 3   3
 
  When I do 'data$label==flist[1]' I get 'F T F F', so it works for one
  item
  in the char vector flist.
  But, when I do 'data$label==flist' I get 'F F F F' while I expected 'F T
  F
  T'. It seems that I can't perform this action with a vector of
  charstrings?
 
  Is there an other way to do so?
 
  --
  View this message in context:
  http://www.nabble.com/select-rows-from-data-based-on-a-vector-of-char-strings-tp16832735p16832735.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.
 




[[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] Can I get rid of this for loop using apply?

2008-04-23 Thread hadley wickham
On Wed, Apr 23, 2008 at 7:31 PM, Mike Dugas [EMAIL PROTECTED] wrote:
 Thanks for the help.  That explains why my time testing showed no
 difference.  Is there any way to speed up the program?  It is unbearably
 slow if I increase the number of loops.

Could you explain exactly what you're trying to do with your code?
It's a little hard to understand.

Hadley


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

__
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] Can I get rid of this for loop using apply?

2008-04-23 Thread Mike Dugas
Thanks for the help.  That explains why my time testing showed no
difference.  Is there any way to speed up the program?  It is unbearably
slow if I increase the number of loops.

Mike


On Wed, Apr 23, 2008 at 6:23 PM, hadley wickham [EMAIL PROTECTED] wrote:

 On Wed, Apr 23, 2008 at 4:23 PM, Mike Dugas [EMAIL PROTECTED] wrote:
  The answer to my post is yes (which I just figured out).
 

 Switching from for to apply isn't going to speed up your code.  If you
 carefully read the source code of apply, you'll see the guts of the
 work is done by:

  for (i in 1:d2) {
tmp - FUN(array(newX[, i], d.call, dn.call), ...)
if (!is.null(tmp))
ans[[i]] - tmp
}

 i.e apply uses for internally.  The reason to use apply instead of a
 for loop is so that you can better express the intent of your
 algorithm.

 Hadley


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


[[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] Can I get rid of this for loop using apply?

2008-04-23 Thread Mike Dugas
Sure, I am creating a partial dependence plot (reference Friedman's
stochastic gradient paper from, I want to say, 2001).  The idea is to find
the relationship between one of the predictors, say x1, and y by creating
the following plot: take a random sample of actual data points, hold other
predictors fixed (x2-xp), vary x1 across its range, create a string of
predictions for each value of x1, repeat for all observations in sample, and
finally average all the predictions for each value of x1.  If you think
about it, this plot solves Simpson's paradox under fairly mild conditions.

The code I wrote does this using predict() which is useful for modeling
approaches like GAMs.

Mike


On Wed, Apr 23, 2008 at 8:47 PM, hadley wickham [EMAIL PROTECTED] wrote:

 On Wed, Apr 23, 2008 at 7:31 PM, Mike Dugas [EMAIL PROTECTED] wrote:
  Thanks for the help.  That explains why my time testing showed no
  difference.  Is there any way to speed up the program?  It is unbearably
  slow if I increase the number of loops.

 Could you explain exactly what you're trying to do with your code?
 It's a little hard to understand.

 Hadley


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


[[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] Replecing empty values with a letter (continuation)

2008-04-23 Thread David Winsemius
Judith Flores [EMAIL PROTECTED] wrote in
news:[EMAIL PROTECTED]: 

 Sorry, I hit the send botton by accident. Here is my
 code so far:
 
 dat-read.csv('myfile.csv', na.strings=)
 dat[is.na(dat]-'N'
 
But it doesn't replace the NA for the letter 'N'.
 
 
What happens when you just type:

dat[is.na(dat)]   #?

My guess is that you don't have any, since na.strings= told 
read.table that there were no values that should be assigned NA. It 
is possible to have a value of NA that is not NA.

 x - c(NA, 1 , 2)
#NA is not NA
 is.na(x)
[1] FALSE FALSE FALSE
 txt - nnn 1 2 3 4 5
 xt- read.table(textConnection(txt), header=FALSE)
 xt
   V1 V2 V3 V4 V5 V6
1 nnn  1  2  3  4  5
 xt- read.table(textConnection(txt), header=FALSE,na.strings=nnn)
 xt
  V1 V2 V3 V4 V5 V6
1 NA  1  2  3  4  5

#That is a TRUE NA
 is.na(xt)
   V1V2V3V4V5V6
[1,] TRUE FALSE FALSE FALSE FALSE FALSE

 xt[is.na(xt)] - N
 xt
  V1 V2 V3 V4 V5 V6
1  N  1  2  3  4  5


-- 
David Winsemius

__
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] Replecing empty values with a letter (continuation)

2008-04-23 Thread Peter Alspach
Judith

I think you'll find the issue is that read.csv creates a data.frame and
your subsetting syntax
dat[is.na(dat)] is assuming it to be a matrix.  If this is the case, you
have two options:

Coerce dat into a matrix with as.matrix(dat);
Use apply() to replace the missing data for each column in turn ...
apply(dat, 2, function(x) x[is.na(x)] - 'N')

HTH ...

Peter Alspach


 -Original Message-
 From: [EMAIL PROTECTED] 
 [mailto:[EMAIL PROTECTED] On Behalf Of Judith Flores
 Sent: Thursday, 24 April 2008 11:20 a.m.
 To: RHelp
 Subject: [R] Replecing empty values with a letter (continuation)
 
 Sorry, I hit the send botton by accident. Here is my code so far:
 
 dat-read.csv('myfile.csv', na.strings=) dat[is.na(dat]-'N'
 
But it doesn't replace the NA for the letter 'N'.
 
 
  I am using R v 2/7/0, running it under Windows XP.
 
 Thank you,
 
 Judith
 
 
   
 __
 __
 Be a better friend, newshound, and
 
 __
 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.
 

The contents of this e-mail are privileged and/or confidential to the named
 recipient and are not to be used by any other person and/or organisation.
 If you have received this e-mail in error, please notify the sender and delete
 all material pertaining to this e-mail.

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

2008-04-23 Thread jim holtman
One way is to first read in the data with readLines.  This will create
a character vector of the input lines.  You can then remove the lines
you want and then use textConnect to read in the modified data:

x - readLines(file)
x - x[-c(2,3)]  # delete lines two and three
input - read.table(textConnection(x), header=TRUE)

On Wed, Apr 23, 2008 at 9:29 AM, Ole Roessler
[EMAIL PROTECTED] wrote:

   Hello,
   I want to do some analyses with data originating from a hydrological model
   that are saved in multiple output files.
   I  want  to  import  the  output-files  in  R without a treatment like
   preproceesing every output file.
   The output file is more or less a matrix, but with additional rows in the
   header, describing the type of data.
   My question is:
   1. Is there a possibility to skip the rows or start with a certain row?
   I want to exclude row 2 and 3, so the first line become the header of the
   list below.
   This is the beginning of the output file to be imported.
   YYMMDDHH12345tot_average
   total runoff [mm per zone] (sum of QB, QI und QD)_submodel:unsatzon_model
   --------0.14666240.29580420.22250480.2279085
   0.10712021.
   2001 1 1 10.0552420.0373910.0515500.057681
   0.0210700.046036
   2001 1 1 20.0512880.0324040.0470270.056636
   0.0210700.042736
   2001 1 1 30.0524910.0329370.0480420.058415
   0.0210700.043701
   2001 1 1 40.0513890.0325080.0471360.056663
   0.0210700.042812
   2001 1 1 50.0507300.0322630.0465990.055585
   0.0210700.042278
   Would be a great help if there is a possibility.
   Thank you very much !
   best regards
   Ole

   --


   
   ---


   Ole Röà ler

   PhD - student

   Climatology and Landscape-Ecology Research Group

   Department of Geography

   University of Bonn


   Postal Address:

   Meckenheimer Allee 166

   53115 Bonn

   Germany



   Tel.:  +49-(0)228-737895

   Fax.: +49-(0)228-737506



   Email: [EMAIL PROTECTED]

   Homepage:
   [2]http://www.giub.uni-bonn.de/loeffler/people/people_sites/roessler.htm


   
   -

 References

   1. mailto:[EMAIL PROTECTED]
   2. http://www.giub.uni-bonn.de/loeffler/people/people_sites/roessler.htm
 __
 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?

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

2008-04-23 Thread Gabor Grothendieck
You can issue a read for just the headers and then skip first 3 lines so
as to issue a read for just the body.

fn - myfile.dat
DF - read.table(fn, skip = 3, na.strings = --,
col.names = read.table(fn, nrows = 1, as.is = TRUE))


On Wed, Apr 23, 2008 at 9:29 AM, Ole Roessler
[EMAIL PROTECTED] wrote:

   Hello,
   I want to do some analyses with data originating from a hydrological model
   that are saved in multiple output files.
   I  want  to  import  the  output-files  in  R without a treatment like
   preproceesing every output file.
   The output file is more or less a matrix, but with additional rows in the
   header, describing the type of data.
   My question is:
   1. Is there a possibility to skip the rows or start with a certain row?
   I want to exclude row 2 and 3, so the first line become the header of the
   list below.
   This is the beginning of the output file to be imported.
   YYMMDDHH12345tot_average
   total runoff [mm per zone] (sum of QB, QI und QD)_submodel:unsatzon_model
   --------0.14666240.29580420.22250480.2279085
   0.10712021.
   2001 1 1 10.0552420.0373910.0515500.057681
   0.0210700.046036
   2001 1 1 20.0512880.0324040.0470270.056636
   0.0210700.042736
   2001 1 1 30.0524910.0329370.0480420.058415
   0.0210700.043701
   2001 1 1 40.0513890.0325080.0471360.056663
   0.0210700.042812
   2001 1 1 50.0507300.0322630.0465990.055585
   0.0210700.042278
   Would be a great help if there is a possibility.
   Thank you very much !
   best regards
   Ole

   --


   
   ---


   Ole Röà ler

   PhD - student

   Climatology and Landscape-Ecology Research Group

   Department of Geography

   University of Bonn


   Postal Address:

   Meckenheimer Allee 166

   53115 Bonn

   Germany



   Tel.:  +49-(0)228-737895

   Fax.: +49-(0)228-737506



   Email: [EMAIL PROTECTED]

   Homepage:
   [2]http://www.giub.uni-bonn.de/loeffler/people/people_sites/roessler.htm


   
   -

 References

   1. mailto:[EMAIL PROTECTED]
   2. http://www.giub.uni-bonn.de/loeffler/people/people_sites/roessler.htm
 __
 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] plotting two functions

2008-04-23 Thread Manoel Santos
by the way, i want both in the same figure, not side by side or others..
tks

[[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] plotting two functions

2008-04-23 Thread Jorge Ivan Velez
Hi Manoel,

Try this:

x-seq(-10, 10, l=100)
plot(x^2,type=l,col=2,ylim=range(x^2,x^5),ylab='f(x)')
points(x^5,type=l,col=4)
legend('topleft',c(expression(x^2),expression(x^5)),col=c(2,4),lty=1)

See ?plot

HTH,

Jorge



On Wed, Apr 23, 2008 at 11:23 PM, Manoel Santos [EMAIL PROTECTED]
wrote:

 i wanna compare functions
 to be simple , let's say i want x^2  and x^5 in same plot ( it's not the
 case but if i get it i'll understand for others  )
 how i do it?

 x-seq(-10, 10, l=100)
  plot(x^2)
 and?
 tks

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


Re: [R] plotting two functions

2008-04-23 Thread Charles C. Berry
On Thu, 24 Apr 2008, Manoel Santos wrote:

 i wanna compare functions
 to be simple , let's say i want x^2  and x^5 in same plot ( it's not the
 case but if i get it i'll understand for others  )
 how i do it?


See

?curve
example( curve )

HTH,

Chuck



 x-seq(-10, 10, l=100)
 plot(x^2)
 and?
 tks

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


Charles C. Berry(858) 534-2098
 Dept of Family/Preventive Medicine
E mailto:[EMAIL PROTECTED]  UC San Diego
http://famprevmed.ucsd.edu/faculty/cberry/  La Jolla, San Diego 92093-0901

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

2008-04-23 Thread Melanie Abecassis
Hi,
I'm having trouble with the which or the seq function, I'm not sure.
Here's an example :


  lat=seq(1,2,by=0.1)
  lat
 [1] 1.0 1.1 1.2 1.3 1.4 1.5 1.6 1.7 1.8 1.9 2.0

  which(lat==1)
[1] 1
  which(lat==1.1)
[1] 2
  which(lat==1.2)
[1] 3
  which(lat==1.3)
[1] 4
  which(lat==1.4)
[1] 5
  which(lat==1.5)
[1] 6
  which(lat==1.6)
[1] 7
  which(lat==1.7)
*integer(0)*
  which(lat==1.8)
[1] 9
  which(lat==1.9)
[1] 10
  which(lat==2)
[1] 11

This doesn't seem to happen with integers.
Am I missing something ?? Is there a better function for non-integers ?

Thanks a lot,
Melanie

__
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] problem with which

2008-04-23 Thread David Winsemius
Melanie Abecassis [EMAIL PROTECTED] wrote in
news:[EMAIL PROTECTED]: 

 Hi,
 I'm having trouble with the which or the seq function, I'm not
 sure. Here's an example :
 
 
  lat=seq(1,2,by=0.1)
  lat
  [1] 1.0 1.1 1.2 1.3 1.4 1.5 1.6 1.7 1.8 1.9 2.0
 
  which(lat==1)
 [1] 1
  which(lat==1.1)
snip
 [1] 7
  which(lat==1.7)
 *integer(0)*
 This doesn't seem to happen with integers.
 Am I missing something ?? Is there a better function for
 non-integers ? 

Read the FAQ 
(Section 7.31 Why doesn't R think these numbers are equal?
http://cran.r-project.org/doc/FAQ/R-FAQ.html#Why-doesn_0027t-R-think-these-numbers-are-equal_003f

and look at this:
 lat - 1.7
 [1] -7.00e-01 -6.00e-01 -5.00e-01 -4.00e-01
 [5] -3.00e-01 -2.00e-01 -1.00e-01  2.220446e-16
 [9]  1.00e-01  2.00e-01  3.00e-01

-- 
David Winsemius

__
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] problem with which

2008-04-23 Thread Berwin A Turlach
G'day Melanie,

On Wed, 23 Apr 2008 17:46:56 -1000
Melanie Abecassis [EMAIL PROTECTED] wrote:

 This doesn't seem to happen with integers.
 Am I missing something ?? 

Yes, FAQ 7.31:

http://cran.r-project.org/doc/FAQ/R-FAQ.html#Why-doesn_0027t-R-think-these-numbers-are-equal_003f

 Is there a better function for non-integers ?

 which(sapply(tt, function(x) isTRUE(all.equal(x,1.7
[1] 8

seems to work.

HTH.

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.


[R] plotting two functions

2008-04-23 Thread Manoel Santos
i wanna compare functions
to be simple , let's say i want x^2  and x^5 in same plot ( it's not the
case but if i get it i'll understand for others  )
how i do it?

x-seq(-10, 10, l=100)
 plot(x^2)
and?
tks

[[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] Compiling msm on Fedora Core Linux

2008-04-23 Thread Prof Brian Ripley
The problem seems to be in the header paths:

 gcc -m64 -std=gnu99 -I/usr/include/R -I/usr/include/R
 -I/usr/local/include

Is R.h not in /usr/include/R?

My guess is that you installed an R rpm and not the R-devel rpm.  But if 
you installed from rpms, this is a Fedora support issue -- this community 
is not responsible for Fedora's re-packaging of R.

On Wed, 23 Apr 2008, Adam Wilson wrote:

 Greetings all,

 I'm trying to install the msm package and it is failing on compilation.  The
 problem seems to be the analyticp component?  Any advice on how to get it to
 work?

 error message is below.  I'm running R version 2.6.2 (2008-02-08)
 x86_64-redhat-linux-gnu  on a dell precision 690 with Fedora Core 8.

 Thanks,
 Adam


 install.packages(msm,lib=/usr/lib64/R/library)
 trying URL 'http://cran.mirrors.hoobly.com/src/contrib/msm_0.8.tar.gz'
 Content type 'application/x-tar' length 577213 bytes (563 Kb)
 opened URL
 ==
 downloaded 563 Kb

 * Installing *source* package 'msm' ...
 ** libs
 gcc -m64 -std=gnu99 -I/usr/include/R -I/usr/include/R
 -I/usr/local/include-fpic  -O2 -g -pipe -Wall -Wp,-D_FORTIFY_SOURCE=2
 -fexceptions -fstack-protector --param=ssp-buffer-size=4 -m64 -mtune=generic
 -c analyticp.c -o analyticp.o
 In file included from analyticp.c:9:
 msm.h:3:15: error: R.h: No such file or directory
 msm.h:4:26: error: R_ext/Applic.h: No such file or directory
 analyticp.c: In function 'AnalyticP':
 analyticp.c:51: warning: implicit declaration of function 'Calloc'
 analyticp.c:51: error: expected expression before 'double'
 analyticp.c:51: warning: cast to pointer from integer of different size
 analyticp.c:52: error: expected expression before 'double'
 analyticp.c:52: warning: cast to pointer from integer of different size
 analyticp.c:63: warning: implicit declaration of function 'error'
 analyticp.c:91: warning: implicit declaration of function 'Free'
 make: *** [analyticp.o] Error 1
 ERROR: compilation failed for package 'msm'
 ** Removing '/usr/lib64/R/library/msm'

 The downloaded packages are in
/tmp/RtmpaoUZiC/downloaded_packages
 Updating HTML index of packages in '.Library'
 Warning messages:
 1: In install.packages(msm, lib = /usr/lib64/R/library) :
  installation of package 'msm' had non-zero exit status
 2: In tools:::unix.packages.html(.Library) :
  cannot create HTML package index







 -- 
 Adam Wilson
 http://hydrodictyon.eeb.uconn.edu/people/wilson/
 Department of Ecology and Evolutionary Biology
 BioPharm 223
 University of Connecticut
 Tel: 860.486.4157
 [EMAIL PROTECTED]

   [[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] printing to the console in color

2008-04-23 Thread Prof Brian Ripley
If this is RGui on Windows, no.  It supports only two colours of text 
(which you can set in the preferences dialiog box).

More generally, you send the appopriate escapes to your console to change 
colour, and the console/terminal documentation will tell you what those 
are.

On Wed, 23 Apr 2008, Applejus wrote:


 Hi,

 Is there a function that would allow me to print things in different colors
 to the CONSOLE, say one line in blue and another line in green?
 Right now, the print() function only prints in navy blue...

 Thanks!
 -- 
 View this message in context: 
 http://www.nabble.com/printing-to-the-console-in-color-tp16834851p16834851.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.

PLEASE do.  We ask for minimal information that you have not supplied.


-- 
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] Coefficient of determination in a regression model with AR(1) residuals

2008-04-23 Thread Hofert Marius
Dear R-users,

I used lm() to fit a standard linear regression model to a given data  
set, which  led to a coefficient of determination (R^2) of about  
0.96. After checking the residuals I realized that they follow an  
autoregressive process (AR) of order 1 (and therefore contradicting  
the i.i.d. assumption of the regression model). I then used gls()  
[library nlme] to fit a linear regression model with AR(1)-residuals.  
The residuals look perfect (residual plot, ACF, PACF, QQPlot, Ljung- 
Box test).
As mentioned on http://en.wikipedia.org/wiki/ 
Coefficient_of_determination (citation [2008-04-24]: For cases other  
than fitting by ordinary least squares, the R^2 statistic can be  
calculated as above and later: Values for R^2 can be calculated for  
any type of predictive model), I tried to calculate the standard R^2  
for the model with AR(1) residuals. However, I ended up with R^2  
larger than 1!
As mentioned on the German wikipedia page (http://de.wikipedia.org/ 
wiki/Bestimmtheitsmaß), in models fitted using Maximum Likelihood  
Estimation (MLE), the coefficient of determination does _not_ exist  
(citation [2008-04-24]: Bei bestimmten statistischen Modellen, z.B.  
bei Maximum-Likelihood-Schätzungen, existiert das Bestimmtheitsmaß  
R^2 nicht). Any comments on that?

The German Wikipedia page mentions McFadden's pseudo-coefficient of  
determination, the English Wikipedia page the one of Nagelkerke. I  
know there are others, too. Is there a general agreement on which  
coefficient of determination (or goodness-of-fit measure in  
general) to use for a regression model with autocorrelated errors? Is  
there a possibility to compare (non-graphically) the standard  
regression model with the model with AR(1) residuals to justify the  
better fit of the latter?

Any comments are appreciated.

Best regards.

Marius

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