Re: [R] Uncompressing data from read.socket

2010-09-08 Thread Dieter Menne


raje...@cse.iitm.ac.in wrote:
 
 Is it possible to uncompress gzipped data coming over a socket? 
 

As far I remember a message by Brian Ripley (I could not find it, though),
it's not possible directly. You have to save as a file and read from disk;
see docs on connection.

Dieter


-- 
View this message in context: 
http://r.789695.n4.nabble.com/Uncompressing-data-from-read-socket-tp2530790p2530829.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] choose.dir() gone?

2010-09-08 Thread Johannes Graumann
Hi,

I fail to find choose.dir() in my current R install (see below)? Didn't 
that exist at some point? How to achieve file.choose() equivalent 
functionality for directories?

Thanks for any hints, Joh

 sessionInfo()
R version 2.11.1 (2010-05-31) 
x86_64-pc-linux-gnu 

locale:
 [1] LC_CTYPE=en_US.UTF-8  LC_NUMERIC=C 
 [3] LC_TIME=en_US.UTF-8   LC_COLLATE=en_US.UTF-8   
 [5] LC_MONETARY=en_US.UTF-8   LC_MESSAGES=en_US.UTF-8  
 [7] LC_PAPER=en_US.UTF-8  LC_NAME=en_US.UTF-8  
 [9] LC_ADDRESS=en_US.UTF-8LC_TELEPHONE=en_US.UTF-8 
[11] LC_MEASUREMENT=en_US.UTF-8LC_IDENTIFICATION=en_US.UTF-8

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

other attached packages:
[1] rkward_0.5.3

loaded via a namespace (and not attached):
[1] tools_2.11.1

__
R-help@r-project.org mailing list
https://stat.ethz.ch/mailman/listinfo/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] choose.dir() gone?

2010-09-08 Thread Johannes Graumann
OK. Just checked and choose.file/choose.dir exists in the windows 
version - apparently not in the linux one ... does anybody have a nice 
platform-agnostic solution for this?

Thanks, Joh

Johannes Graumann wrote:

 Hi,
 
 I fail to find choose.dir() in my current R install (see below)? Didn't
 that exist at some point? How to achieve file.choose() equivalent
 functionality for directories?
 
 Thanks for any hints, Joh
 
 sessionInfo()
 R version 2.11.1 (2010-05-31)
 x86_64-pc-linux-gnu
 
 locale:
  [1] LC_CTYPE=en_US.UTF-8  LC_NUMERIC=C
  [3] LC_TIME=en_US.UTF-8   LC_COLLATE=en_US.UTF-8
  [5] LC_MONETARY=en_US.UTF-8   LC_MESSAGES=en_US.UTF-8
  [7] LC_PAPER=en_US.UTF-8  LC_NAME=en_US.UTF-8
  [9] LC_ADDRESS=en_US.UTF-8LC_TELEPHONE=en_US.UTF-8
 [11] LC_MEASUREMENT=en_US.UTF-8LC_IDENTIFICATION=en_US.UTF-8
 
 attached base packages:
 [1] stats graphics  grDevices utils datasets  methods   base
 
 other attached packages:
 [1] rkward_0.5.3
 
 loaded via a namespace (and not attached):
 [1] tools_2.11.1

__
R-help@r-project.org mailing list
https://stat.ethz.ch/mailman/listinfo/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] Interactions in GAM

2010-09-08 Thread Lucia Cañas
Thank you so much for your answer, it has been really useful. I have already 
included the interactions in the models and I have obtained better results. 

Best regards,

Lucía Cañás



Lucía Cañás Ferreiro
Instituto Español de Oceanografía
Centro Oceanográfico de A Coruña
Paseo Marítimo Alcalde Francisco Vázquez, nº 10
15001 - A Coruña, SPAIN
e-mail: lucia.ca...@co.ieo.es
Tel: +34981205362; Fax: +34981229077
http://www.ieo.es



[[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] Passing aruments with source

2010-09-08 Thread Joel

Hi.

Im writing a small test program just to see how passing arguments work with
R.
From the command line everything works as expected but from inside R using
source(test.R) i dont know where and how to send in the arguments did try
source(test.R --test) but it just says that it cant find or open the file.
(without the argument part it can).

Anyone know how to make it work?

//Joel Damberg
-- 
View this message in context: 
http://r.789695.n4.nabble.com/Passing-aruments-with-source-tp2531012p2531012.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] Passing aruments with source

2010-09-08 Thread Barry Rowlingson
On Wed, Sep 8, 2010 at 10:11 AM, Joel joda2...@student.uu.se wrote:

 Hi.

 Im writing a small test program just to see how passing arguments work with
 R.
 From the command line everything works as expected but from inside R using
 source(test.R) i dont know where and how to send in the arguments did try
 source(test.R --test) but it just says that it cant find or open the file.
 (without the argument part it can).

 Anyone know how to make it work?

 source() runs the file in the context of the caller, so if you have
an 'x' in the caller then the file sourced will see it. So here, where
s.R is just:

print(x)

 you can do:

 x=12
 source(s.R)
[1] 12
 x=99
 source(s.R)
[1] 99

Barry

__
R-help@r-project.org mailing list
https://stat.ethz.ch/mailman/listinfo/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] choose.dir() gone?

2010-09-08 Thread G. Jay Kerns
Dear Joh,

On Wed, Sep 8, 2010 at 3:18 AM, Johannes Graumann
johannes_graum...@web.de wrote:
 OK. Just checked and choose.file/choose.dir exists in the windows
 version - apparently not in the linux one ... does anybody have a nice
 platform-agnostic solution for this?

 Thanks, Joh


[snip]

Have a look at tk_choose.files in the tcltk package.

library(tcltk)
?tk_choose.files

Good luck,
Jay


***
G. Jay Kerns, Ph.D.
Associate Professor
Department of Mathematics  Statistics
Youngstown State University
Youngstown, OH 44555-0002 USA
Office: 1035 Cushwa Hall
Phone: (330) 941-3310 Office (voice mail)
-3302 Department
-3170 FAX
VoIP: gjke...@ekiga.net
E-mail: gke...@ysu.edu
http://people.ysu.edu/~gkerns/

__
R-help@r-project.org mailing list
https://stat.ethz.ch/mailman/listinfo/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] Passing aruments with source

2010-09-08 Thread Joel

That is true but then I (or anyone else using the script) most know exactly
what the name in the script is to be able to set it correctly and so on.
Therefor it would be much better to be able to just send in the value and
let the script handle the variable setting.

But thx for the answer

//Joel Damberg
-- 
View this message in context: 
http://r.789695.n4.nabble.com/Passing-aruments-with-source-tp2531012p2531087.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] Uncompressing data from read.socket

2010-09-08 Thread Matt Shotwell
Have a look at gzcon, for decompressing data as they arrive. From the
help file:

 ‘gzcon’ provides a modified connection that wraps an existing
 connection, and decompresses reads or compresses writes through
 that connection.  Standard ‘gzip’ headers are assumed.

There is no indication in the gzcon help file that explicitly prohibits
socketConnections. Also, see memDecompress for in-memory decompression
of the entire object. 

-Matt

On Wed, 2010-09-08 at 00:50 -0400, raje...@cse.iitm.ac.in wrote:
 Hi,
 
 Is it possible to uncompress gzipped data coming over a socket? 
   [[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.

-- 
Matthew S. Shotwell
Graduate Student 
Division of Biostatistics and Epidemiology
Medical University of South Carolina

__
R-help@r-project.org mailing list
https://stat.ethz.ch/mailman/listinfo/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] Passing aruments with source

2010-09-08 Thread Barry Rowlingson
On Wed, Sep 8, 2010 at 11:29 AM, Joel joda2...@student.uu.se wrote:

 That is true but then I (or anyone else using the script) most know exactly
 what the name in the script is to be able to set it correctly and so on.
 Therefor it would be much better to be able to just send in the value and
 let the script handle the variable setting.

 But thx for the answer

 Then what you really want to do is write a _function_ that takes
arguments, and not a script. Tell your users something like:

 Do 'source(foo.R)' and then call the fnord function with your data
set: fnord(x).

Your foo.R file looks like this:

 fnord =function(x){
   print(x) # etc
 }

It's even possible to save functions to .RData files and then tell
your users to attach() them, thus not putting objects in their working
spaces.

And the next step is to write a package for your function...

Barry

__
R-help@r-project.org mailing list
https://stat.ethz.ch/mailman/listinfo/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] likelyhood maximization problem with polr

2010-09-08 Thread blackscorpio

Ok, thanks a lot ! I tried to compute the inverse of the variance covariance
matrix of the estimators with vcov, which gave me this error :

require(MASS) 
data(iris) 
model=polr(Species~Sepal.Length+Sepal.Width+Petal.Length+Petal.Width,iris,start
= rep(1, 6),method= logistic) 
require(stats)
vcov(model)

Re-fitting to get Hessian

Erreur dans optim(s0, fmin, gmin, method = BFGS, hessian = Hess, ...) : 
  la valeur initiale dans 'vmin' n'est pas finie
  
which means  Error in optim(...) : the initial value in 'vmin' is not
finite ...
-- 
View this message in context: 
http://r.789695.n4.nabble.com/likelyhood-maximization-problem-with-polr-tp2528818p2531045.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] Saving/loading custom R scripts

2010-09-08 Thread DrCJones

Hi,
How does R automatically load functions so that they are available from the
workspace? Is it anything like Matlab - you just specify a directory path
and it finds it? 

The reason I ask is because  I found a really nice script that I would like
to use on a regular basis, and it would be nice not to have to 'copy and
paste' it into R on every startup: 

http://www.r-statistics.com/wp-content/uploads/2010/02/Friedman-Test-with-Post-Hoc.r.txt
 

This would be for Ubuntu, if that makes any difference. 

Cheers
-- 
View this message in context: 
http://r.789695.n4.nabble.com/Saving-loading-custom-R-scripts-tp2530924p2530924.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] Interpolation missing data

2010-09-08 Thread abotaha

Hi R experts, 

I have set of data consists of 50 data. some of them are missing. I would
need a function in R that can estimate missing data using interpolation
methods. 
If you know this kind of function, write me the name of the function and its
library. 

Thanks very much in advance!

abotaha
-- 
View this message in context: 
http://r.789695.n4.nabble.com/Interpolation-missing-data-tp2530871p2530871.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] adding list to data.frame iteratively

2010-09-08 Thread raje...@cse.iitm.ac.in

Hi,

I have a preallocated dataframe to which I have to add a list whose vectors 
will become rows in the dataframe. This is done iteratively. How can I do this?
I'm dealing with very large numbers...list of 1000 vectors to a dataframe of 
20 iteratively

for e.g.
my list is as follows

ll-list(c(1,2,3),c(2,3,4))

I have to add this to a dataframe
dd-data.frame(matrix(nrow=10,ncol=3))

so that I get
1 2 3
2 3 4
etc.
[[alternative HTML version deleted]]

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


[R] How to project a vector on a subspace?

2010-09-08 Thread James

Hi experts,

I have a subspace represented as matrix of basic vectors and I want to
project a vector on that subspace. Does R have any function that help me to
do so?

Thanks,

James.
-- 
View this message in context: 
http://r.789695.n4.nabble.com/How-to-project-a-vector-on-a-subspace-tp2530886p2530886.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] forecasting with non-linear models

2010-09-08 Thread Елена Белых


Dear colleagues!
Is it possible to make predictions in R?
there is an exponential relationship detween y and x
x-c(0.001,0.003,0.01,0.16,0.3,0.7,0.9)
y-c(38.8,41.5,44.2,27,26.9,6.9,3)
f-function(x,a,b){a*exp(b*x)}
fm-nls(y~f(x,a,b), start=c(a=1,b=1))

How one can predict x when y=10 and is it possible to calculate standard 
error of x?
The task is equal to function ED in drc package, but it use logistic 
regression only.


Best regards,
Elena.

--
da...@rambler.ru.

__
R-help@r-project.org mailing list
https://stat.ethz.ch/mailman/listinfo/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] forecasting with non-linear models

2010-09-08 Thread Елена Белых


Dear colleagues!
Is it possible to make predictions in R?
there is an exponential relationship detween y and x
x-c(0.001,0.003,0.01,0.16,0.3,0.7,0.9)
y-c(38.8,41.5,44.2,27,26.9,6.9,3)
f-function(x,a,b){a*exp(b*x)}
fm-nls(y~f(x,a,b), start=c(a=1,b=1))

How one can predict x when y=10 and is it possible to calculate standard 
error of x?
The task is equal to function ED in drc package, but it use logistic 
regression only.


Best regards,
Elena.


--
da...@rambler.ru.

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


[R] How to change font size in plot() function

2010-09-08 Thread FMH
Dear All,

Could someone please advice me the way to change the size of the title and x 
and 
y-label in plot() function. I've tried to use 'font' and 'font.main' call in 
plot() function, but it didn't make any changes in terms of the size.

Thanks
Fir

__
R-help@r-project.org mailing list
https://stat.ethz.ch/mailman/listinfo/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] Failure to aggregate

2010-09-08 Thread Dimitri Shvorob

Mnay thanks fr suggestions. I am afraid this is one tough daatframe...

 t = sqldf(select h, count(*) from x group by h)
Error in sqliteExecStatement(con, statement, bind.data) : 
  RS-DBI driver: (error in statement: no such table: x)
In addition: Warning message:
In value[[3L]](cond) : RAW() can only be applied to a 'raw', not a 'double'

 t = aggregate(x[price], by = x[h], FUN = NROW) 
Error in sort.list(y) : 'x' must be atomic for 'sort.list'
Have you called 'sort' on a list?

 t = aggregate(x[price], by = x[h], FUN = length) 
Error in sort.list(y) : 'x' must be atomic for 'sort.list'
Have you called 'sort' on a list?

 t = tapply(x$price, by = x$h, FUN = length) 
Error in is.list(INDEX) : 'INDEX' is missing

 class(x)
[1] data.frame
 class(x$h)
[1] POSIXt  POSIXlt
 class(x$price)
[1] integer

-- 
View this message in context: 
http://r.789695.n4.nabble.com/Failure-to-aggregate-tp2528613p2530963.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] choose.dir() gone?

2010-09-08 Thread Michael Grant
Maybe 'tk_choose.dir' in the tcltk package will do what you want.

--- On Wed, 9/8/10, Johannes Graumann johannes_graum...@web.de wrote:

 From: Johannes Graumann johannes_graum...@web.de
 Subject: Re: [R] choose.dir() gone?
 To: r-h...@stat.math.ethz.ch
 Date: Wednesday, September 8, 2010, 3:18 AM
 OK. Just checked and
 choose.file/choose.dir exists in the windows 
 version - apparently not in the linux one ... does anybody
 have a nice 
 platform-agnostic solution for this?
 
 Thanks, Joh
 
 Johannes Graumann wrote:
 
  Hi,
  
  I fail to find choose.dir() in my current R install
 (see below)? Didn't
  that exist at some point? How to achieve
 file.choose() equivalent
  functionality for directories?
  
  Thanks for any hints, Joh
  
  sessionInfo()
  R version 2.11.1 (2010-05-31)
  x86_64-pc-linux-gnu
  
  locale:
   [1] LC_CTYPE=en_US.UTF-8     
     LC_NUMERIC=C
   [3] LC_TIME=en_US.UTF-8     
      LC_COLLATE=en_US.UTF-8
   [5] LC_MONETARY=en_US.UTF-8   
    LC_MESSAGES=en_US.UTF-8
   [7] LC_PAPER=en_US.UTF-8     
     LC_NAME=en_US.UTF-8
   [9] LC_ADDRESS=en_US.UTF-8     
   LC_TELEPHONE=en_US.UTF-8
  [11] LC_MEASUREMENT=en_US.UTF-8   
 LC_IDENTIFICATION=en_US.UTF-8
  
  attached base packages:
  [1] stats     graphics 
 grDevices utils     datasets 
 methods   base
  
  other attached packages:
  [1] rkward_0.5.3
  
  loaded via a namespace (and not attached):
  [1] tools_2.11.1
 
 __
 R-help@r-project.org
 mailing list
 https://stat.ethz.ch/mailman/listinfo/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] (no subject)

2010-09-08 Thread Isaac SAGAON TEYSSIER

Dear all, 
 
I need to estimate intensity and probability matrices by the continuous-time 
markov model... in a first time I used msm and it works perfectly. 
Nevertheless, I have to do other estimations that need programming the 
likelihood. Is it possible to see somewhere the likelihood used in the msm 
package? I have readen the papers about likelihood estimation of 
continuous-time markov models but and I tried to write the program but it does 
not work.
 
Thank you very much
 
Luis SAGAON TEYSSIER  
[[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] Failure to aggregate

2010-09-08 Thread Dimitri Shvorob

I was able to aggregate (with sqldf, at least), after saving and re-loading
the dataframe. My first guess was that h (and/or price?) now being a factor
- stringsAsFactors = T by default - made the difference, and I tried to
convert x$h to factor, but received an error. 
-- 
View this message in context: 
http://r.789695.n4.nabble.com/Failure-to-aggregate-tp2528613p2530989.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] big data

2010-09-08 Thread André de Boer
Hello,

I searched the internet but i didn't find the answer for the next problem:
I want to do a glm on a csv file consisting of 25 columns and 4 mln rows.
Not all the columns are relevant. My problem is to read the data into R.
Manipulate the data and then do a glm.

I've tried with:

dd-scan(myfile.csv,colClasses=classes)
dat-as.data.frame(dd)

My question is: what is the right way to do is?
Can someone give me a hint?

Thanks,
Arend

[[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] Saving/loading custom R scripts

2010-09-08 Thread Abhijit Dasgupta, PhD
 You can create a .First function in your .Rprofile file (which  will 
be in ~/.Rprofile). For example


.First - function(){
source(Friedman-Test-with-Post-Hoc.r.txt)
}

You can also create your own package (mylibrary) down the line (see 
the R manual for creating extensions at 
http://cran.fhcrc.org/doc/manuals/R-exts.pdf) which will be a collection 
of your custom scripts that you have written, and then you can 
automatically load them using


.First - function(){
library(mylibrary)
}

Hope this helps.

Abhijit

On 9/8/10 3:25 AM, DrCJones wrote:

Hi,
How does R automatically load functions so that they are available from the
workspace? Is it anything like Matlab - you just specify a directory path
and it finds it?

The reason I ask is because  I found a really nice script that I would like
to use on a regular basis, and it would be nice not to have to 'copy and
paste' it into R on every startup:

http://www.r-statistics.com/wp-content/uploads/2010/02/Friedman-Test-with-Post-Hoc.r.txt

This would be for Ubuntu, if that makes any difference.

Cheers



--

Abhijit Dasgupta, PhD
Director and Principal Statistician
ARAASTAT
Ph: 301.385.3067
E: adasgu...@araastat.com
W: http://www.araastat.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] programming continuous-time markov model likelihood

2010-09-08 Thread Isaac SAGAON TEYSSIER

Dear all, 
 
I need to estimate intensity and probability matrices by the continuous-time 
markov model... in a first time I used msm and it works perfectly. 
Nevertheless, I have to do other estimations that need programming the 
likelihood. Is it possible to see somewhere the likelihood used in the msm 
package? I have readen the papers about likelihood estimation of 
continuous-time markov models but and I tried to write the program but it does 
not work.
 
Thank you very much
 
Luis SAGAON TEYSSIER 
  
[[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] Passing aruments with source

2010-09-08 Thread Joel

Thats an idea will try it out and see how it works

Thanks a lot for your help.

Joel
-- 
View this message in context: 
http://r.789695.n4.nabble.com/Passing-aruments-with-source-tp2531012p2531138.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] Regression using mapply?

2010-09-08 Thread Philipp Kunze
Hi,
I have huge matrices in which the response variable is in the first
column and the regressors are in the other columns. What I wanted to do
now is something like this:

#this is just to get an example-matrix
DataMatrix - rep(1,1000);
Disturbance - rnorm(900);
DataMatrix[101:1000] - DataMatrix[101:1000]+Disturbance;
DataMatrix - matrix(DataMatrix,ncol=10,nrow=100);

#estimate univariate linear model with each regressor-column, response
in the first column

for(i in 2:10){
result - lm(DataMatrix[,1]~DataMatrix[,i])
}


Is there any way to get rid of the for-loop using mapply (or some other
function)? 

Thanks!
Philipp

__
R-help@r-project.org mailing list
https://stat.ethz.ch/mailman/listinfo/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 change font size in plot() function

2010-09-08 Thread Peng, C

try:

?title
-- 
View this message in context: 
http://r.789695.n4.nabble.com/How-to-change-font-size-in-plot-function-tp2531127p2531161.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] bigmemory doubt

2010-09-08 Thread Jay Emerson
By far the easiest way to achieve this would be to use the bigmemory
C++ structures in your program itself.  However, if you do something
on your own (but fundamentally have a column-major matrix in shared
memory), it should be possible to play around with the pointer with
R/bigmemory to accomplish this, yes.  Feel free to email us directly
for advice.

Jay


 Message: 153
 Date: Wed, 8 Sep 2010 10:52:19 +0530 (IST)
 From: raje...@cse.iitm.ac.in raje...@cse.iitm.ac.in
 To: r-help  r-help@r-project.org
 Subject: [R] bigmemory doubt
 Message-ID:
   1204692515.13855.1283923339865.javamail.r...@mail.cse.iitm.ac.in
 Content-Type: text/plain

 Hi,

 Is it possible for me to read data from shared memory created by a vc++ 
 program into R using bigmemory?

-- 
John W. Emerson (Jay)
Associate Professor of Statistics
Department of Statistics
Yale University
http://www.stat.yale.edu/~jay

__
R-help@r-project.org mailing list
https://stat.ethz.ch/mailman/listinfo/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] forecasting with non-linear models

2010-09-08 Thread Peng, C

predict x for a given y(response)?  If this is the case, you will have
multiple x for a single y for this exponential model. In terms of logistic
regression, If y =1, logit([P(Y=1)] = a + b*bx has infinite many x. The
question seems not quite clear to me.
-- 
View this message in context: 
http://r.789695.n4.nabble.com/forecasting-with-non-linear-models-tp2531125p2531186.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] Aggregating data from two data frames

2010-09-08 Thread Michael Haenlein
Dear all,

I'm working with two data frames.

The first frame (agg_data) consists of two columns. agg_data[,1] is a unique
ID for each row and agg_data[,2] contains a continuous variable.

The second data frame (geo_data) consists of several columns. One of these
columns (geo_data$ZCTA) corresponds to the unique ID in the first data
frame. The problem is that only a subset of the unique ID present in the
first data frame also appears in the second data fame.

What I would like to do is to add another column to the second data frame
(geo_data) that includes the value of the continuous variable from the first
frame that corresponds to the unique ID. To put it differently, I want R to
look at each row in the second data frame, look for the unique ID
(geo_data$ZCTA), look for the same unique ID in the first data frame and
then paste the value from the continous variable as a new column into the
second data frame. I hope I'm somewhat clear here ...

Is there a convenient way of doing this?

Thanks very much in advance,

Michael

[[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] Aggregating data from two data frames

2010-09-08 Thread Hadley Wickham
Have a look at match and merge.
Hadley

On Wednesday, September 8, 2010, Michael Haenlein
haenl...@escpeurope.eu wrote:
 Dear all,

 I'm working with two data frames.

 The first frame (agg_data) consists of two columns. agg_data[,1] is a unique
 ID for each row and agg_data[,2] contains a continuous variable.

 The second data frame (geo_data) consists of several columns. One of these
 columns (geo_data$ZCTA) corresponds to the unique ID in the first data
 frame. The problem is that only a subset of the unique ID present in the
 first data frame also appears in the second data fame.

 What I would like to do is to add another column to the second data frame
 (geo_data) that includes the value of the continuous variable from the first
 frame that corresponds to the unique ID. To put it differently, I want R to
 look at each row in the second data frame, look for the unique ID
 (geo_data$ZCTA), look for the same unique ID in the first data frame and
 then paste the value from the continous variable as a new column into the
 second data frame. I hope I'm somewhat clear here ...

 Is there a convenient way of doing this?

 Thanks very much in advance,

 Michael

         [[alternative HTML version deleted]]

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


-- 
Assistant Professor / Dobelman Family Junior Chair
Department of Statistics / Rice University
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] big data

2010-09-08 Thread Dirk Eddelbuettel

On 8 September 2010 at 13:26, André de Boer wrote:
| I searched the internet but i didn't find the answer for the next problem:
| I want to do a glm on a csv file consisting of 25 columns and 4 mln rows.
| Not all the columns are relevant. My problem is to read the data into R.
| Manipulate the data and then do a glm.
| 
| I've tried with:
| 
| dd-scan(myfile.csv,colClasses=classes)
| dat-as.data.frame(dd)
| 
| My question is: what is the right way to do is?
| Can someone give me a hint?

Look at the biglm package by Thomas Lumley which will allow you to fit glm
models in chunks.  

Dirk

-- 
Dirk Eddelbuettel | e...@debian.org | http://dirk.eddelbuettel.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] Extracting elements from list: Is [[ always faster than $ ??

2010-09-08 Thread Søren Højsgaard
Dear list

It seems to me that extracting elements from a list using '[[' is somewhat 
faster than using '$'. For example:

 x- as.list(1:25)
 names(x) - letters[1:length(x)]
 dput(x)
structure(list(a = 1L, b = 2L, c = 3L, d = 4L, e = 5L, f = 6L,
g = 7L, h = 8L, i = 9L, j = 10L, k = 11L, l = 12L, m = 13L,
n = 14L, o = 15L, p = 16L, q = 17L, r = 18L, s = 19L, t = 20L,
u = 21L, v = 22L, w = 23L, x = 24L, y = 25L), .Names = c(a,
b, c, d, e, f, g, h, i, j, k, l, m, n,
o, p, q, r, s, t, u, v, w, x, y))

 system.time({ for (ii in 1:100)  x[[21]] })
   user  system elapsed
   0.550.000.54
 system.time({ for (ii in 1:100)  x[[u]]})
   user  system elapsed
   0.840.000.84
 system.time({ for (ii in 1:100)  x$u})
   user  system elapsed
   1.120.001.13
Does anyone know if this is always the case? (I have not found anything about 
speed in this connection on the help pages, apologies if I have overlooked 
something).

I use R.2.11.1 on Windows 7.

Regards

__
R-help@r-project.org mailing list
https://stat.ethz.ch/mailman/listinfo/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] Decision Tree in Python or C++?

2010-09-08 Thread Liaw, Andy
For Python, check out the project orange:
http://www.ailab.si/orange/doc/catalog/Classify/ClassificationTree.htm

Not sure about C++, but OpenDT is in C:
http://opendt.sourceforge.net/

Looks like OpenCV has both Python and C++ interface (didn't see Python interace 
to decision tree, though):
http://opencv.willowgarage.com/documentation/cpp/decision_trees.html

Andy

 -Original Message-
 From: r-help-boun...@r-project.org 
 [mailto:r-help-boun...@r-project.org] On Behalf Of Wensui Liu
 Sent: Saturday, September 04, 2010 5:14 PM
 To: noclue_
 Cc: r-help@r-project.org
 Subject: Re: [R] Decision Tree in Python or C++?
 
 for python, please check
 http://onlamp.com/pub/a/python/2006/02/09/ai_decision_trees.html
 
 On Sat, Sep 4, 2010 at 11:21 AM, noclue_ tim@netzero.net wrote:
 
 
  Have anybody used Decision Tree in Python or C++?  (or 
 written their own
  decision tree implementation in Python or C++)?  My goal is 
 to run decision
  tree on 8 million obs as training set and score 7 million 
 in test set.
 
  I am testing 'rpart' package on a 64-bit-Linux + 64-bit-R 
 environment. But
  it seems that rpart is either not stable or running out of 
 memory very
  quickly. (Is it because R is passing everything as copy 
 instead of as object
  reference?)
 
  Any idea would be greatly appreciated!
 
  Have a nice weekend!
  --
  View this message in context: 
 http://r.789695.n4.nabble.com/Decision-Tree-in-Python-or-C-tp2
 526810p2526810.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.
 
 
 
 
 -- 
 ==
 WenSui Liu
 wens...@paypal.com
 statcompute.spaces.live.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.
 
Notice:  This e-mail message, together with any attachme...{{dropped:11}}

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


[R] lattice: layout and number of pages

2010-09-08 Thread Philipp Pagel

Dear expeRts,

?xyplot says: In general, giving a high value of ‘layout[3]’ is not
wasteful because blank pages are never created.

But the following example does generate blank pages - well except for
the ylab:

data(barley)
require(lattice)
stripplot(yield~year|site, barley, layout=c(2,1,5))

Did I misinterpret the sentence from the help page or is this a bug?
Yes - I know that his works fine:

stripplot(yield~year|site, barley, layout=c(2,1))

Just curious...

cu
Philipp

-- 
Dr. Philipp Pagel
Lehrstuhl für Genomorientierte Bioinformatik
Technische Universität München
Wissenschaftszentrum Weihenstephan
Maximus-von-Imhof-Forum 3
85354 Freising, Germany
http://webclu.bio.wzw.tum.de/~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.


Re: [R] How to project a vector on a subspace?

2010-09-08 Thread Peng, C

Can you be a little bit more specific? For example, the base vectors of the
subspace and the vector you want to project. Specific artificial
vectors/matrices are helpful.
-- 
View this message in context: 
http://r.789695.n4.nabble.com/How-to-project-a-vector-on-a-subspace-tp2530886p2531245.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] How to project a vector on a subspace?

2010-09-08 Thread Gabor Grothendieck
On Wed, Sep 8, 2010 at 2:52 AM, James vuda...@gmail.com wrote:

 Hi experts,

 I have a subspace represented as matrix of basic vectors and I want to
 project a vector on that subspace. Does R have any function that help me to
 do so?


The projection of vector y onto the space spanned by the columns of X
is fitted(lm.fit(X, y)) .
Although not numerically optimal it can also be written:
X %*% solve(crossprod(X, X), crossprod(X, y))

-- 
Statistics  Software Consulting
GKX Group, GKX Associates Inc.
tel: 1-877-GKX-GROUP
email: ggrothendieck at gmail.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] Over lay 2 scale in same plot

2010-09-08 Thread mamunbabu2001

Hi Peng,
Thanks for your reply. I have tried it and it does work fine
apart from one problem. Even though the second data set 
has same length as the first one, the point function seems
to shit all the points towards left side. So the points are not
in concordat  co-ordinates as the bars. Any idea how this can 
be fixed ???

thanks in advace.

regards,
Mamun 
-- 
View this message in context: 
http://r.789695.n4.nabble.com/Over-lay-2-scale-in-same-plot-tp2528661p2531255.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] shared memory system for R windows

2010-09-08 Thread raje...@cse.iitm.ac.in

Hi,

is there a shared memory implementation for R windows, preferably something 
that resembles the boost c++ libraries
[[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] optimized value worse than starting Value

2010-09-08 Thread Michael Bernsteiner

Dear all,

I'm optimizing a relatively simple function. Using optimize the optimized 
parameter value is worse than the starting.
why?

f-function(delta,P,U){
minimiz-P+delta*U
x-minimiz[1]
y-minimiz[2]
z-100*(y-x^2)^2+(1-x)^2
return(z)
}
  
result-optimize(f, interval=c(-10, 10), P=c(0.99,1.01), U=c(1,0))
result

Output:

 result-optimize(f, interval=c(-10, 10), P=c(0.99,1.01), U=c(1,0))
 result
$minimum
[1] -1.990015

$objective
[1] 4.01

Function Value at Starting Point with free parameter=0:

 f(0,c(0.99,1.01),c(1,0))
[1] 0.089501


It seems as if optimize doesn't check the whole interval.

 result-optimize(f, interval=c(-1, 10), P=c(0.99,1.01), U=c(1,0))
 result
$minimum
[1] 0.01497394

$objective
[1] 2.481504e-05


Changing the lower interval value leads to the result I am looking for. How do 
I find this result when I have no idea where the optimal values lies and want 
to look in an interval that is as wide as possible?
any ideas?

Michael


  
[[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] Uniform Distribution

2010-09-08 Thread Alaios
Hello,
I would like to uniformly distribute values from 0 to 200. Can someone help me 
find the appropriate uniform distribution generator?

I would like to thank you in advance for your help.


Best Regards
Alex



  
[[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] Uniform Distribution

2010-09-08 Thread Stephan Kolassa

Hi Alex,

help.search(uniform)

HTH,
Stephan


Am 08.09.2010 15:36, schrieb Alaios:

Hello,
I would like to uniformly distribute values from 0 to 200. Can someone help me
find the appropriate uniform distribution generator?

I would like to thank you in advance for your help.


Best Regards
Alex




[[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] Interpolation missing data

2010-09-08 Thread Peng, C

try packages:

{yaImpute}, {impute}, etc.
-- 
View this message in context: 
http://r.789695.n4.nabble.com/Interpolation-missing-data-tp2530871p2531288.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] Uniform Distribution

2010-09-08 Thread Peng, C

?runif
-- 
View this message in context: 
http://r.789695.n4.nabble.com/Uniform-Distribution-tp2531282p2531292.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] Uniform Distribution

2010-09-08 Thread Gavin Simpson
On Wed, 2010-09-08 at 06:36 -0700, Alaios wrote:
 Hello,
 I would like to uniformly distribute values from 0 to 200. Can someone help 
 me 
 find the appropriate uniform distribution generator?
 
 I would like to thank you in advance for your help.
 
 
 Best Regards
 Alex

?runif

runif(10, min = 0, max = 200)

will give you 10 numbers uniformally distributed on the interval 0, 200.

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] Uniform Distribution

2010-09-08 Thread Alaios
Thanks a lot. Tired the help.search(uniform) one other member of the list 
told 
me but the computer 10 minutes now it is scanning to infinity :)






From: Gavin Simpson gavin.simp...@ucl.ac.uk

Cc: r-help@r-project.org
Sent: Wed, September 8, 2010 3:45:12 PM
Subject: Re: [R] Uniform Distribution

On Wed, 2010-09-08 at 06:36 -0700, Alaios wrote:
 Hello,
 I would like to uniformly distribute values from 0 to 200. Can someone help 
 me 

 find the appropriate uniform distribution generator?
 
 I would like to thank you in advance for your help.
 
 
 Best Regards
 Alex

?runif

runif(10, min = 0, max = 200)

will give you 10 numbers uniformally distributed on the interval 0, 200.

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


  
[[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] circular data

2010-09-08 Thread Karen Sargsyan

 Is there any package for clustering of circular data?

karsar

__
R-help@r-project.org mailing list
https://stat.ethz.ch/mailman/listinfo/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] question on optim

2010-09-08 Thread Ravi Varadhan
Hi Nan,

You can take a look at the optimx package on CRAN.  John Nash and I wrote
this package to help lay and sophisticated users alike.  This package
unifies various optimization algorithms in R for smooth, box-constrained
optimization. It has features for checking objective function, gradient (and
hessian) specifications.  It checks for potential problems due to poor
scaling; checks feasibility of starting values.  It provides diagnostics
(KKT conditions) on whether or not a local optimum has been located.  It
also allows the user to run various optimization algorithms in one simple
call, which is essentially identical to optim call. This feature can be
especially useful for developers to benchmark different algorithms and
choose the best one for their class of problems.

http://cran.r-project.org/web/packages/optimx/index.html

Ravi.

-Original Message-
From: r-help-boun...@r-project.org [mailto:r-help-boun...@r-project.org] On
Behalf Of Hey Sky
Sent: Tuesday, September 07, 2010 2:48 PM
To: Ben Bolker; r-h...@stat.math.ethz.ch
Subject: Re: [R] question on optim

thanks. Ben

after read your email, I realized the initial value of w[5]=0 is a stupid 
mistake. and I have changed it. but I am sorry I cannot reproduce the
result, 
convergence, as you get. the error message is non-finite finite difference 
value [12]. any suggestion about it?

and could you plz recommend some R books on optimization, such as tips for
setup 
gradient and others, or common mistakes?  thanks

Nan







- Original Message 
From: Ben Bolker bbol...@gmail.com
To: r-h...@stat.math.ethz.ch
Sent: Tue, September 7, 2010 11:15:43 AM
Subject: Re: [R] question on quot;optimquot;

Hey Sky heyskywalker at yahoo.com writes:

 I do not know how to describe my question. I am a new user for R and
 write the 
 following code for a dynamic labor economics model and use OPTIM to get 
 optimizations and parameter values. the following code does not work due
to 
 the equation:
 
wden[,i]-dnorm((1-regw[,i])/w[5])/w[5]
 
 where w[5] is one of the parameters (together with vector a, b and other 
 elements in vector w) need to be estimated. if I
  delete the w[5] from the upper 
 equation. that is:
 
  wden[,i]-dnorm(1-regw[,i])
 
 optim will give me the estimated parameters.

  Thank you for the reproducible example!

  The problem is that you are setting the initial value of w[5]
to zero, and then trying to divide by it ...

  I find that


guess-rep(0,times=npar)
guess[16] - 1

system.time(r1-optim(guess,myfunc1,data=mydata, method=BFGS,hessian=TRUE,
  control=list(trace=TRUE)))

seems to work OK (I have no idea if the answers are sensible are not ...)

If you're going to be doing a lot of this it might be wise to see
if you can specify the gradient of your objective function for R --
it will speed up and stabilize the fitting considerably.

  By the way, you should be careful with this function: if we try
this with Nelder-Mead instead, it appears to head to a set of
parameters that lead to some sort of singularity in the objective
function:

system.time(r2-optim(guess,myfunc1,data=mydata, 
   method=Nelder-Mead,hessian=FALSE,
  control=list(trace=TRUE,maxit=5000)))

## still thinks it hasn't converged, but objective function is
##   much smaller

## plot 'slice' through objective space where 0 corresponds to
##  fit-1 parameters and 1 corresponds to fit-2 parameters;
## adapted from emdbook::calcslice
range - seq(-0.1,1.1,length=400)
slicep - seq(range[1], range[2], length = 400)
slicepars - t(sapply(slicep, function(x) (1 - x) * r1$par +  x * r2$par))
v - apply(slicepars, 1, myfunc1)
plot(range,v,type=l)


  Ideally, you should be able to look at the parameters of fit #2
and figure out (a) what the result means in terms of labor economics
and (b) how to keep the objective function from going there, or at
least identifying when it does.

  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.

__
R-help@r-project.org mailing list
https://stat.ethz.ch/mailman/listinfo/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] optimized value worse than starting Value

2010-09-08 Thread Ravi Varadhan
Dieter Menne had already told you what the problem is.  You have 2 local
minima.  One is a global minimum.  Depending on your starting interval, the
optimizer can converge to one of the two local minima. If you want to be
reasonably sure that you always find the global minimum, you either have to
use problem-specific knowledge or try a sufficiently large number of
starting values and pick the best solution.  Here is one approach:

require(BB)
p0 - matrix(rnorm(20), 20, 1)  # 20 random starting values
ans - multiStart(par=p0, fn=f, action=optimize, P=c(0.99,1.01), U=c(1,0))
ans

Hope this helps,
Ravi.

-Original Message-
From: r-help-boun...@r-project.org [mailto:r-help-boun...@r-project.org] On
Behalf Of Michael Bernsteiner
Sent: Wednesday, September 08, 2010 8:36 AM
To: r-help@r-project.org
Subject: [R] optimized value worse than starting Value


Dear all,

I'm optimizing a relatively simple function. Using optimize the optimized
parameter value is worse than the starting.
why?

f-function(delta,P,U){
minimiz-P+delta*U
x-minimiz[1]
y-minimiz[2]
z-100*(y-x^2)^2+(1-x)^2
return(z)
}
  
result-optimize(f, interval=c(-10, 10), P=c(0.99,1.01), U=c(1,0))
result

Output:

 result-optimize(f, interval=c(-10, 10), P=c(0.99,1.01), U=c(1,0))
 result
$minimum
[1] -1.990015

$objective
[1] 4.01

Function Value at Starting Point with free parameter=0:

 f(0,c(0.99,1.01),c(1,0))
[1] 0.089501


It seems as if optimize doesn't check the whole interval.

 result-optimize(f, interval=c(-1, 10), P=c(0.99,1.01), U=c(1,0))
 result
$minimum
[1] 0.01497394

$objective
[1] 2.481504e-05


Changing the lower interval value leads to the result I am looking for. How
do I find this result when I have no idea where the optimal values lies and
want to look in an interval that is as wide as possible?
any ideas?

Michael


  
[[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] How to project a vector on a subspace?

2010-09-08 Thread peter dalgaard

On Sep 8, 2010, at 15:22 , Gabor Grothendieck wrote:

 On Wed, Sep 8, 2010 at 2:52 AM, James vuda...@gmail.com wrote:
 
 Hi experts,
 
 I have a subspace represented as matrix of basic vectors and I want to
 project a vector on that subspace. Does R have any function that help me to
 do so?
 
 
 The projection of vector y onto the space spanned by the columns of X
 is fitted(lm.fit(X, y)) .
 Although not numerically optimal it can also be written:
 X %*% solve(crossprod(X, X), crossprod(X, y))

Perhaps qr.fitted(qr(X),y) is slightly faster than fitted(lm.fit(X,y)). Looks 
like it might be bypassing some red tape, and otherwise do the same. 

-- 
Peter Dalgaard
Center for Statistics, Copenhagen Business School
Solbjerg Plads 3, 2000 Frederiksberg, Denmark
Phone: (+45)38153501
Email: pd@cbs.dk  Priv: pda...@gmail.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 using mapply?

2010-09-08 Thread David Winsemius


On Sep 8, 2010, at 7:34 AM, Philipp Kunze wrote:


Hi,
I have huge matrices in which the response variable is in the first
column and the regressors are in the other columns. What I wanted to  
do

now is something like this:

#this is just to get an example-matrix
DataMatrix - rep(1,1000);
Disturbance - rnorm(900);
DataMatrix[101:1000] - DataMatrix[101:1000]+Disturbance;
DataMatrix - matrix(DataMatrix,ncol=10,nrow=100);

#estimate univariate linear model with each regressor-column, response
in the first column

for(i in 2:10){
result - lm(DataMatrix[,1]~DataMatrix[,i])
}


result - apply(DataMatrix[,2:10], 2, function (x) lm(DataMatrix[, 
1]~x) )


Which would have the added advantage that result would not be  
overwritten for iterations 3:10, which is what your code would have  
done. result will be a list of 9 models which might be a bit  
unweildy, so you might consider something like


result - apply(DataMatrix[,2:10], 2, function (x)  
coef( lm(DataMatrix[,1]~x) ) )

result

When you do so,  you uncover a fatal flaw in your strategy, which  
suggests you have not even done this once on your data or simulations.


--
David.



Is there any way to get rid of the for-loop using mapply (or some  
other

function)?

--
David Winsemius, MD
West Hartford, CT

__
R-help@r-project.org mailing list
https://stat.ethz.ch/mailman/listinfo/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 change font size in plot() function

2010-09-08 Thread David Winsemius

That is one method, but he should also review:

?par

where he will discover that cex.main is a parameter that could be used  
from within the plot function.



FMH had written, by Peng, C had failed to include context:


Could someone please advice me the way to change the size of the  
title and x and
y-label in plot() function. I've tried to use 'font' and  
'font.main' call in

plot() function, but it didn't make any changes in terms of the size.


On Sep 8, 2010, at 7:46 AM, Peng, C wrote:



try:

?title
--
View this message in context: 
http://r.789695.n4.nabble.com/How-to-change-font-size-in-plot-function-tp2531127p2531161.html
Sent from the R help mailing list archive at Nabble.com.


David Winsemius, MD
West Hartford, CT

__
R-help@r-project.org mailing list
https://stat.ethz.ch/mailman/listinfo/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] optimized value worse than starting Value

2010-09-08 Thread Barry Rowlingson
On Wed, Sep 8, 2010 at 1:35 PM, Michael Bernsteiner
dethl...@hotmail.com wrote:

 Dear all,

 I'm optimizing a relatively simple function. Using optimize the optimized 
 parameter value is worse than the starting.
 why?

 f-function(delta,P,U){
    minimiz-P+delta*U
    x-minimiz[1]
    y-minimiz[2]
    z-100*(y-x^2)^2+(1-x)^2
    return(z)
 }

 This looks familiar. Is this some 1-d version of the Rosenbrock
Banana Function?

 http://en.wikipedia.org/wiki/Rosenbrock_function

 It's designed to be hard to find the minimum. In the real world one
would hope that things would not have such a pathological behaviour.

 Numerical optimisations are best done using as many methods as
possible - see optimise, nlm, optim, nlminb and the whole shelf of
library books devoted to it.

Barry

__
R-help@r-project.org mailing list
https://stat.ethz.ch/mailman/listinfo/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] pairs and panel.smooth for two groups

2010-09-08 Thread Marie-Pierre Sylvestre
Hi,
I have modified the USJudgeRatings data (available in R)  to
illustrate my question.

# Use the first 4 variables of USJudgeRatings and add a group variable
with two levels
USJudgeRatings - USJudgeRatings[,1:4]
USJudgeRatings$group - factor(c(rep(1, 22), rep(0, 21)))

# I can draw a pairs graph where members of each group are drawn in
different colors:

pairs(USJudgeRatings[,1:4], col = c(2,3)[USJudgeRatings$group], pch =
c(21,3)[USJudgeRatings$group])

# I would also like to add a smooth line to each subplot like
pairs(USJudgeRatings[,1:4], panel=panel.smooth)

# but I want the smooth to be done for each of the group, i.e. I want
two smooths per subplot.

# this creates only one smooth
pairs(USJudgeRatings[,1:4], col = c(2,3)[USJudgeRatings$group], pch =
c(21,3)[USJudgeRatings$group], panel = panel.smooth)

# I understand that panel.smooth is a function that is called for each
subplot. I don't know how to tell it to do a smooth for each of my
group in each of the subplot.

Any help would be appreciated!

Best,

Marie-Pierre

__
R-help@r-project.org mailing list
https://stat.ethz.ch/mailman/listinfo/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] Over lay 2 scale in same plot

2010-09-08 Thread Joshua Wiley
Hi Mamum,

The co-ordinates appear shifted because the bars are not centered at
1, 2, 3, etc.  To give an example:

# Create a barplot
# of the numbers 1 through 10
barplot(1:10)

# Now look at the x axis coordinates of these actual bars
barplot(1:10, plot = FALSE)

# One way to get these coordinates for yourself would be
x - barplot(1:10) # this will plot AND save the object
x # see the coordinates

# This should have the points properly centered with the bars
points(x = x, y = 10:1)

HTH,

Josh

On Wed, Sep 8, 2010 at 6:14 AM, mamunbabu2001 mrashi...@hotmail.com wrote:

 Hi Peng,
 Thanks for your reply. I have tried it and it does work fine
 apart from one problem. Even though the second data set
 has same length as the first one, the point function seems
 to shit all the points towards left side. So the points are not
 in concordat  co-ordinates as the bars. Any idea how this can
 be fixed ???

 thanks in advace.

 regards,
 Mamun
 --
 View this message in context: 
 http://r.789695.n4.nabble.com/Over-lay-2-scale-in-same-plot-tp2528661p2531255.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.




-- 
Joshua Wiley
Ph.D. Student, Health Psychology
University of California, Los Angeles
http://www.joshuawiley.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] Checking if the distribution follow a power law

2010-09-08 Thread NatsumiYotsumoto
Dear all.


I'm using igraph package, and do a research about network analysis.

With power.law.fit from igraph package, it seems that we can fit a power law
distribution to some data.


But, I want to know how to judge whether the network distribution follows a
power law or not.


Does anyone know the way to do this?


Thanks for any help.


Daigo





p.s.

Also,  I tried several ways such as

http://www.mail-archive.com/r-h...@stat.math.ethz.ch/msg62520.html


and I got results like this:


Profiling...

   2.5 %   97.5 %

2.393297 2.412650


What do these suggest?

please tell me about this if someone knows.

[[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] Matrixes inside matrixes

2010-09-08 Thread Alaios
Hello everyone,

Could you please help me find out if R supports matrixes inside matrixes?
This is what I would like to do

I have an area map of humidity per km. I would like at every cell to keep also 
information about the height of this area, the current temperature etc.

Is something like that supported?

I would like to thank you in advance for your help

Best Regards
Alex



  
[[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] Matrixes inside matrixes

2010-09-08 Thread Erik Iverson

Hello,

from ?array

 An array in R can have one, two or more dimensions.  It is simply
 a vector which is stored with additional attributes giving the
 dimensions (attribute ‘dim’) and optionally names for those
 dimensions (attribute ‘dimnames’).

 A two-dimensional array is the same thing as a ‘matrix’.


So, to answer your question, yes.

Alaios wrote:

Hello everyone,

Could you please help me find out if R supports matrixes inside matrixes?
This is what I would like to do

I have an area map of humidity per km. I would like at every cell to keep also 
information about the height of this area, the current temperature etc.


Is something like that supported?

I would like to thank you in advance for your help

Best Regards
Alex



  
	[[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] Saving/loading custom R scripts

2010-09-08 Thread Joshua Wiley
Hi,

Just create a file called .Rprofile that is located in your working
directory (this means you could actually have different ones in each
working directory).  In that file, you can put in code just like any
other code that would be source()d in.  For instance, all my .Rprofile
files start with:

r - getOption(repos)
r[CRAN] - http://cran.stat.ucla.edu;
options(repos = r)
rm(r)

So that I do not have to pick my CRAN mirror.  Similarly you could
merely add this line to the file:

source(file = 
http://www.r-statistics.com/wp-content/uploads/2010/02/Friedman-Test-with-Post-Hoc.r.txt;)

and R would go online, download that file and source it in (not that I
am recommending re-downloading every time you start R).  Then whatever
names they used to define the functions, would be in your workspace.

Note that in general, you will not get any output alerting you that it
has worked; however, if you type ls() you should see those functions'
names.

Cheers,

Josh

On Wed, Sep 8, 2010 at 12:25 AM, DrCJones matthias.godd...@gmail.com wrote:

 Hi,
 How does R automatically load functions so that they are available from the
 workspace? Is it anything like Matlab - you just specify a directory path
 and it finds it?

 The reason I ask is because  I found a really nice script that I would like
 to use on a regular basis, and it would be nice not to have to 'copy and
 paste' it into R on every startup:

 http://www.r-statistics.com/wp-content/uploads/2010/02/Friedman-Test-with-Post-Hoc.r.txt

 This would be for Ubuntu, if that makes any difference.

 Cheers
 --
 View this message in context: 
 http://r.789695.n4.nabble.com/Saving-loading-custom-R-scripts-tp2530924p2530924.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.




-- 
Joshua Wiley
Ph.D. Student, Health Psychology
University of California, Los Angeles
http://www.joshuawiley.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] saving heatmaps in graphical format that can be edited in graphic editor tools

2010-09-08 Thread Bhakti Dwivedi
I generated a heatmap in R using the following commands:

 mydata - read.csv(file=Data.csv, header=TRUE, sep=,)
 mydata - mydata[rowSums(mydata[,-1]^2) 0, ]
 rownames(mydata)=mydata$Name
 mydata - mydata[,2:253]
 mydatamatrix - data.matrix(mydata)
 mydatascale - t(scale(t(mydatamatrix)))
 hr - hclust(as.dist(1-cor(t(mydatascale), method=pearson)),
method=complete)
 hc - hclust(as.dist(1-cor(mydatascale, method=spearman)),
method=complete)
 myclhr - cutree(hr, h=max(hr$height)/2); mycolhr - sample(rainbow(256));

 myclhc - cutree(hc, h=max(hc$height)/2); mycolhc - sample(rainbow(256));

 mycolhr - mycolhr[as.vector(myclhr)];
 mycolhc - mycolhc[as.vector(myclhc)];
 library(gplots)
 library(RSvgDevice)
 jpeg(Heatmap.jpg, height=6+2/3, width=6+2/3, units=in, res=1200)
 heatmap.2(mydatamatrix, Rowv=as.dendrogram(hr), Colv=as.dendrogram(hc),
dendrogram=both, scale=row, col=brewer.pal(3, YlOrRd), cexRow=0.01,
cexCol=0.01,
trace=none, density.info=none, key=TRUE, keysize=1.5,
margin=c(5,8),RowSideColor=mycolhr, ColSideColor=mycolhc)
 dev.off()


I would like to save the file in a graphical format that can be edited later
in any image editing program (like corel).  is there a way to do this in R?
Its a lot of data I plotted on heatmap (~ 300*600). The x and y labels are
difficult to read.  I used cexRow = 0.01 and cexCol =0.01 with 1200
resolution to save as jpeg file.  That helped but I can still hardly figure
out the row labels.  I want to be able to read them to interpret the results
and also to edit them with different font/color in corel and may be add
other things that could be relevant to my work.  So, I guess my question
here- is there a way I can make the labels readable in R itself or can I
generate a list of the row and col labels (in the exact order as in figure)
in a text file separately so I know the order and can try attaching it to
heatmap in corel draw?

any help will be appreciated!  Thanks

BD

[[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] saving heatmaps in graphical format that can be edited in graphic editor tool

2010-09-08 Thread BD

I generated a heatmap in R using the following commands:

 mydata - read.csv(file=Data.csv, header=TRUE, sep=,)
 mydata - mydata[rowSums(mydata[,-1]^2) 0, ]
 rownames(mydata)=mydata$Name
 mydata - mydata[,2:253]
 mydatamatrix - data.matrix(mydata)
 mydatascale - t(scale(t(mydatamatrix)))
 hr - hclust(as.dist(1-cor(t(mydatascale), method=pearson)),
 method=complete)
 hc - hclust(as.dist(1-cor(mydatascale, method=spearman)),
 method=complete)
 myclhr - cutree(hr, h=max(hr$height)/2); mycolhr - sample(rainbow(256));
 myclhc - cutree(hc, h=max(hc$height)/2); mycolhc - sample(rainbow(256));
 mycolhr - mycolhr[as.vector(myclhr)];
 mycolhc - mycolhc[as.vector(myclhc)];
 library(gplots)
 library(RSvgDevice)
 jpeg(Heatmap.jpg, height=6+2/3, width=6+2/3, units=in, res=1200)
 heatmap.2(mydatamatrix, Rowv=as.dendrogram(hr), Colv=as.dendrogram(hc),
 dendrogram=both, 
   scale=row, col=brewer.pal(3, YlOrRd), cexRow=0.01, cexCol=0.01,
trace=none, density.info=none, 
   key=TRUE, keysize=1.5, margin=c(5,8),RowSideColor=mycolhr,
ColSideColor=mycolhc)
 dev.off()


I would like to save the file in a graphical format that can be edited later
in any image editing program (like corel).  is there a way to do this in R? 
Its a lot of data I plotted on heatmap (~ 300*600). The x and y labels are
difficult to read.  I used cexRow = 0.01 and cexCol =0.01 with 1200
resolution to save as jpeg file.  That helped but I can still hardly figure
out the row labels.  I want to be able to read them to interpret the results
and also to edit them with different font/color in corel and may be add
other things that could be relevant to my work.  So, I guess my question
here- is there a way I can make the labels readable in R itself or can I
generate a list of the row and col labels (in the exact order as in figure) 
in a text file separately so I know the order and can try attaching it to
heatmap in corel draw?

any help will be appreciated!  Thanks!

BD
-- 
View this message in context: 
http://r.789695.n4.nabble.com/saving-heatmaps-in-graphical-format-that-can-be-edited-in-graphic-editor-tool-tp2531512p2531512.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] saving heatmaps in graphical format that can be edited in graphic editor tools

2010-09-08 Thread Joshua Wiley
Hi,

Without your data, we cannot actually reproduce your plot; however, if
you cannot read labels, there are generally three options.

1) Make the labels smaller (I have not used the function you used, so
I'm not sure exactly how one would)
2) Use fewer labels (if you need them all, this is a particularly
unattractive choice)
3) Make your graph bigger (this is the easiest though not always the best).

Sometimes, simply rotating the labels can help them not overlap too.

You can try changing the jpeg() line to:

jpeg(Heatmap.jpg, height=10+2/3, width=10+2/3, units=in, res=1200)

and keeping adding inches until things seem to work.  The downside, of
course, is that if it is every being printed, it may have to be
shrunk, but as long as it is an image, that will just make everything
smaller, not re-overlap the labels.

HTH,

Josh

On Wed, Sep 8, 2010 at 8:29 AM, Bhakti Dwivedi bhakti.dwiv...@gmail.com wrote:
 I generated a heatmap in R using the following commands:

 mydata - read.csv(file=Data.csv, header=TRUE, sep=,)
 mydata - mydata[rowSums(mydata[,-1]^2) 0, ]
 rownames(mydata)=mydata$Name
 mydata - mydata[,2:253]
 mydatamatrix - data.matrix(mydata)
 mydatascale - t(scale(t(mydatamatrix)))
 hr - hclust(as.dist(1-cor(t(mydatascale), method=pearson)),
 method=complete)
 hc - hclust(as.dist(1-cor(mydatascale, method=spearman)),
 method=complete)
 myclhr - cutree(hr, h=max(hr$height)/2); mycolhr - sample(rainbow(256));

 myclhc - cutree(hc, h=max(hc$height)/2); mycolhc - sample(rainbow(256));

 mycolhr - mycolhr[as.vector(myclhr)];
 mycolhc - mycolhc[as.vector(myclhc)];
 library(gplots)
 library(RSvgDevice)
 jpeg(Heatmap.jpg, height=6+2/3, width=6+2/3, units=in, res=1200)
 heatmap.2(mydatamatrix, Rowv=as.dendrogram(hr), Colv=as.dendrogram(hc),
 dendrogram=both, scale=row, col=brewer.pal(3, YlOrRd), cexRow=0.01,
 cexCol=0.01,
    trace=none, density.info=none, key=TRUE, keysize=1.5,
 margin=c(5,8),RowSideColor=mycolhr, ColSideColor=mycolhc)
 dev.off()


 I would like to save the file in a graphical format that can be edited later
 in any image editing program (like corel).  is there a way to do this in R?
 Its a lot of data I plotted on heatmap (~ 300*600). The x and y labels are
 difficult to read.  I used cexRow = 0.01 and cexCol =0.01 with 1200
 resolution to save as jpeg file.  That helped but I can still hardly figure
 out the row labels.  I want to be able to read them to interpret the results
 and also to edit them with different font/color in corel and may be add
 other things that could be relevant to my work.  So, I guess my question
 here- is there a way I can make the labels readable in R itself or can I
 generate a list of the row and col labels (in the exact order as in figure)
 in a text file separately so I know the order and can try attaching it to
 heatmap in corel draw?

 any help will be appreciated!  Thanks

 BD

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




-- 
Joshua Wiley
Ph.D. Student, Health Psychology
University of California, Los Angeles
http://www.joshuawiley.com/

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


[R] How to get OR and CI from GEE R package

2010-09-08 Thread PZ HU









Hi,

I am fitting a GEE model using gee R package, but I am not sure how to get 

OR and its CI?


Could anyone give me some hints?

Here are some output:
 gee.obj - gee(Affection~Sibsex+Probandsex,id = FAMID,family = 
 binomial,corstr = independence,data =seldata)
Beginning Cgee S-function, @(#) geeformula.q 4.13 98/01/27
running glm to get initial regression estimate
(Intercept) Sibsex2 Probandsex2 
 -1.6067213   0.3495830   0.5645009 
 summary(gee.obj)

 GEE:  GENERALIZED LINEAR MODELS FOR DEPENDENT DATA
 gee S-function, version 4.13 modified 98/01/27 (1998) 

Model:
 Link:  Logit 
 Variance to Mean Relation: Binomial 
 Correlation Structure: Independent 

Call:
gee(formula = Affection ~ Sibsex + Probandsex, id = FAMID, data = seldata, 
family = binomial, corstr = independence)

Summary of Residuals:
   Min 1Q Median 3QMax 
-0.3334466 -0.3334466 -0.2607218  0.6665534  0.8329557 


Coefficients:
  Estimate Naive S.E.Naive z Robust S.E.   Robust z
(Intercept) -1.6067213  0.5265207 -3.0515824   0.5475068 -2.9346145
Sibsex2  0.3495830  0.4043623  0.8645293   0.4045141  0.8642049
Probandsex2  0.5645009  0.5543902  1.0182374   0.5580999  1.0114691

Estimated Scale Parameter:  1.027439
Number of Iterations:  1

Working Correlation
 [,1] [,2] [,3] [,4]
[1,]1000
[2,]0100
[3,]0010
[4,]0001
 exp(cbind(coef(gee.obj),confint(gee.obj,level = 0.9))) 
Waiting for profiling to be done...
Error in profile.glm(object, which = parm, alpha = (1 - level)/4, trace = 
trace) : 
  subscript out of bounds
Error in exp(cbind(coef(gee.obj), confint(gee.obj, level = 0.9))) : 
  Non-numeric argument to mathematical function
 exp(coef(gee.obj) 
+ )
(Intercept) Sibsex2 Probandsex2 
  0.2005441   1.4184760   1.7585698 



Thank you for your help,

pingzhao
  
[[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] Matrixes inside matrixes

2010-09-08 Thread baptiste auguie
Hi,

You can have each cell of a matrix contain a matrix, but for a reason
that is just not clear to me the matrices are wrapped in a list,

m = matrix(replicate(4,matrix(1:9,3,3),simplify=FALSE), 2,2)

m[1,2][[1]]

str(m)

and even more surprising to me, m itself has become a list for some reason.

baptiste



On 8 September 2010 17:22, Alaios ala...@yahoo.com wrote:
 Hello everyone,

 Could you please help me find out if R supports matrixes inside matrixes?
 This is what I would like to do

 I have an area map of humidity per km. I would like at every cell to keep also
 information about the height of this area, the current temperature etc.

 Is something like that supported?

 I would like to thank you in advance for your help

 Best Regards
 Alex




        [[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] saving heatmaps in graphical format that can be edited in graphic editor tools

2010-09-08 Thread Joshua Wiley
Side note, since Nabble posts to R-help also, you only need to use
Nabble or email, not both.

__
R-help@r-project.org mailing list
https://stat.ethz.ch/mailman/listinfo/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] Change plot order in lattice xyplot

2010-09-08 Thread Paul Simonin
Greetings,

I am writing with a question regarding plotting using the xyplot command in 
lattice. I currently have the commands shown below, but I need to produce a 
plot that orders the Month variable differently. I was told to use the 
lattice.options command (shown below) to change the plot order, and this helped 
by starting the plot at a point other than the bottom-left origin, but this did 
not transpose the plot in the way I need. I need the plot to begin with June, 
then July, August, September, October, beginning at the top left side of the 
plot area. Does anyone now how to make this happen?

A section of my data and the commands I am currently using are shown below. 
Thank you for any assistance!
Data:


Month
Log10_echo_integration_dens
Log10_trawl_dens
June
-2.55876
-2.74726
June
-2.24346
-3.7015
July
-3.14616
-2.83227
July
-2.69961
-3.7015
August
-2.96135
-3.7015
August
-2.29246
-2.29232
September
-2.2096
-2.20181
September
-1.80488
-1.81614
October
-2.28896
-1.84266
October
-2.4
-2.35319


#Commands
lattice.options(default.args = list(as.table = TRUE))
xyplot(Log10_trawl_dens~Log10_echo_integration_dens | Month, data = 
(subset(T.A., Net_Type==T)),ylim=c(-4,0),xlim=c(-4,0),xlab=Log density from 
hydroacoustics (integration),ylab=Log density from Tucker 
trawl,main=Density estimates, Tucker Trawl, cex=1.5)

Best,
Paul S.


[[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] Saving/loading custom R scripts

2010-09-08 Thread Bert Gunter
.. Not quite.

?Startup

provides details, but note the comment about only the base package
being loaded and the need to use somepackage::somefunction() or to
explicitly first load a package whose functions are used in .Profile.

Note also that .First could also be used instead of putting the code
in a profile file.

Cheers,

Bert Gunter
Genentech Nonclinical Statistics

On Wed, Sep 8, 2010 at 8:20 AM, Joshua Wiley jwiley.ps...@gmail.com wrote:
 Hi,

 Just create a file called .Rprofile that is located in your working
 directory (this means you could actually have different ones in each
 working directory).  In that file, you can put in code just like any
 other code that would be source()d in.  For instance, all my .Rprofile
 files start with:

 r - getOption(repos)
 r[CRAN] - http://cran.stat.ucla.edu;
 options(repos = r)
 rm(r)

 So that I do not have to pick my CRAN mirror.  Similarly you could
 merely add this line to the file:

 source(file = 
 http://www.r-statistics.com/wp-content/uploads/2010/02/Friedman-Test-with-Post-Hoc.r.txt;)

 and R would go online, download that file and source it in (not that I
 am recommending re-downloading every time you start R).  Then whatever
 names they used to define the functions, would be in your workspace.

 Note that in general, you will not get any output alerting you that it
 has worked; however, if you type ls() you should see those functions'
 names.

 Cheers,

 Josh

 On Wed, Sep 8, 2010 at 12:25 AM, DrCJones matthias.godd...@gmail.com wrote:

 Hi,
 How does R automatically load functions so that they are available from the
 workspace? Is it anything like Matlab - you just specify a directory path
 and it finds it?

 The reason I ask is because  I found a really nice script that I would like
 to use on a regular basis, and it would be nice not to have to 'copy and
 paste' it into R on every startup:

 http://www.r-statistics.com/wp-content/uploads/2010/02/Friedman-Test-with-Post-Hoc.r.txt

 This would be for Ubuntu, if that makes any difference.

 Cheers
 --
 View this message in context: 
 http://r.789695.n4.nabble.com/Saving-loading-custom-R-scripts-tp2530924p2530924.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.




 --
 Joshua Wiley
 Ph.D. Student, Health Psychology
 University of California, Los Angeles
 http://www.joshuawiley.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.




-- 
Bert Gunter
Genentech Nonclinical Biostatistics
467-7374
http://devo.gene.com/groups/devo/depts/ncb/home.shtml

__
R-help@r-project.org mailing list
https://stat.ethz.ch/mailman/listinfo/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] saving heatmaps in graphical format that can be edited in graphic editor tool

2010-09-08 Thread Barry Rowlingson
On Wed, Sep 8, 2010 at 4:32 PM, BD bhakti.dwiv...@gmail.com wrote:

 I generated a heatmap in R using the following commands:

 mydata - read.csv(file=Data.csv, header=TRUE, sep=,)
 mydata - mydata[rowSums(mydata[,-1]^2) 0, ]
 rownames(mydata)=mydata$Name
 mydata - mydata[,2:253]
 mydatamatrix - data.matrix(mydata)
 mydatascale - t(scale(t(mydatamatrix)))
 hr - hclust(as.dist(1-cor(t(mydatascale), method=pearson)),
 method=complete)
 hc - hclust(as.dist(1-cor(mydatascale, method=spearman)),
 method=complete)
 myclhr - cutree(hr, h=max(hr$height)/2); mycolhr - sample(rainbow(256));
 myclhc - cutree(hc, h=max(hc$height)/2); mycolhc - sample(rainbow(256));
 mycolhr - mycolhr[as.vector(myclhr)];
 mycolhc - mycolhc[as.vector(myclhc)];
 library(gplots)
 library(RSvgDevice)
 jpeg(Heatmap.jpg, height=6+2/3, width=6+2/3, units=in, res=1200)
 heatmap.2(mydatamatrix, Rowv=as.dendrogram(hr), Colv=as.dendrogram(hc),
 dendrogram=both,
   scale=row, col=brewer.pal(3, YlOrRd), cexRow=0.01, cexCol=0.01,
 trace=none, density.info=none,
   key=TRUE, keysize=1.5, margin=c(5,8),RowSideColor=mycolhr,
 ColSideColor=mycolhc)
 dev.off()


 I would like to save the file in a graphical format that can be edited later
 in any image editing program (like corel).  is there a way to do this in R?
 Its a lot of data I plotted on heatmap (~ 300*600). The x and y labels are
 difficult to read.  I used cexRow = 0.01 and cexCol =0.01 with 1200
 resolution to save as jpeg file.  That helped but I can still hardly figure
 out the row labels.  I want to be able to read them to interpret the results
 and also to edit them with different font/color in corel and may be add
 other things that could be relevant to my work.  So, I guess my question
 here- is there a way I can make the labels readable in R itself or can I
 generate a list of the row and col labels (in the exact order as in figure)
 in a text file separately so I know the order and can try attaching it to
 heatmap in corel draw?

 any help will be appreciated!  Thanks!

 I've been doing exactly this today.

 Use the svg() device driver to create an svg file. Then edit it with
Inkscape, and open-source graphics layout and design program. For a
demo, try:

svg(foo.svg)
plot(1:10)
dev.off()

Then open Inkscape and load foo.svg. You should be able to move all
the bits of the plot around.

 It has saved me a ton of time today, since I wanted to move a legend
on a ggplot graph to make room for another graphic. In Inkscape I can
just select the elements of the legend and drag them around.

 Inkscape is cross-platform, so works on Windows/Mac/Linux I think (am
using the Linux version).

Barry

__
R-help@r-project.org mailing list
https://stat.ethz.ch/mailman/listinfo/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] saving heatmaps in graphical format that can be edited in graphic editor tool

2010-09-08 Thread BD

Thanks!  I will try it now.  I am using linux too!

Bhakti

On Wed, Sep 8, 2010 at 11:54 AM, Barry Rowlingson [via R] 
ml-node+2531559-939380251-160...@n4.nabble.comml-node%2b2531559-939380251-160...@n4.nabble.com
 wrote:

 On Wed, Sep 8, 2010 at 4:32 PM, BD [hidden 
 email]http://user/SendEmail.jtp?type=nodenode=2531559i=0
 wrote:

 
  I generated a heatmap in R using the following commands:
 
  mydata - read.csv(file=Data.csv, header=TRUE, sep=,)
  mydata - mydata[rowSums(mydata[,-1]^2) 0, ]
  rownames(mydata)=mydata$Name
  mydata - mydata[,2:253]
  mydatamatrix - data.matrix(mydata)
  mydatascale - t(scale(t(mydatamatrix)))
  hr - hclust(as.dist(1-cor(t(mydatascale), method=pearson)),
  method=complete)
  hc - hclust(as.dist(1-cor(mydatascale, method=spearman)),
  method=complete)
  myclhr - cutree(hr, h=max(hr$height)/2); mycolhr -
 sample(rainbow(256));
  myclhc - cutree(hc, h=max(hc$height)/2); mycolhc -
 sample(rainbow(256));
  mycolhr - mycolhr[as.vector(myclhr)];
  mycolhc - mycolhc[as.vector(myclhc)];
  library(gplots)
  library(RSvgDevice)
  jpeg(Heatmap.jpg, height=6+2/3, width=6+2/3, units=in, res=1200)
  heatmap.2(mydatamatrix, Rowv=as.dendrogram(hr), Colv=as.dendrogram(hc),
  dendrogram=both,
scale=row, col=brewer.pal(3, YlOrRd), cexRow=0.01, cexCol=0.01,
  trace=none, density.info=none,
key=TRUE, keysize=1.5, margin=c(5,8),RowSideColor=mycolhr,
  ColSideColor=mycolhc)
  dev.off()
 
 
  I would like to save the file in a graphical format that can be edited
 later
  in any image editing program (like corel).  is there a way to do this in
 R?
  Its a lot of data I plotted on heatmap (~ 300*600). The x and y labels
 are
  difficult to read.  I used cexRow = 0.01 and cexCol =0.01 with 1200
  resolution to save as jpeg file.  That helped but I can still hardly
 figure
  out the row labels.  I want to be able to read them to interpret the
 results
  and also to edit them with different font/color in corel and may be add
  other things that could be relevant to my work.  So, I guess my question
  here- is there a way I can make the labels readable in R itself or can I
  generate a list of the row and col labels (in the exact order as in
 figure)
  in a text file separately so I know the order and can try attaching it to

  heatmap in corel draw?
 
  any help will be appreciated!  Thanks!

  I've been doing exactly this today.

  Use the svg() device driver to create an svg file. Then edit it with
 Inkscape, and open-source graphics layout and design program. For a
 demo, try:

 svg(foo.svg)
 plot(1:10)
 dev.off()

 Then open Inkscape and load foo.svg. You should be able to move all
 the bits of the plot around.

  It has saved me a ton of time today, since I wanted to move a legend
 on a ggplot graph to make room for another graphic. In Inkscape I can
 just select the elements of the legend and drag them around.

  Inkscape is cross-platform, so works on Windows/Mac/Linux I think (am
 using the Linux version).

 Barry

 __
 [hidden email] http://user/SendEmail.jtp?type=nodenode=2531559i=1mailing 
 list
 https://stat.ethz.ch/mailman/listinfo/r-help
 PLEASE do read the posting guide
 http://www.R-project.org/posting-guide.html
 and provide commented, minimal, self-contained, reproducible code.


 --
  View message @
 http://r.789695.n4.nabble.com/saving-heatmaps-in-graphical-format-that-can-be-edited-in-graphic-editor-tool-tp2531512p2531559.html
 To unsubscribe from saving heatmaps in graphical format that can be edited
 in graphic editor tool, click 
 herehttp://r.789695.n4.nabble.com/template/TplServlet.jtp?tpl=unsubscribe_by_codenode=2531512code=Ymhha3RpLmR3aXZlZGlAZ21haWwuY29tfDI1MzE1MTJ8LTE3NjEyNTUyNg==.




-- 
View this message in context: 
http://r.789695.n4.nabble.com/saving-heatmaps-in-graphical-format-that-can-be-edited-in-graphic-editor-tool-tp2531512p2531575.html
Sent from the R help mailing list archive at Nabble.com.

[[alternative HTML version deleted]]

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


Re: [R] optimized value worse than starting Value

2010-09-08 Thread Ravi Varadhan
Numerical optimisations are best done using as many methods as possible

See the optimx package:

http://cran.r-project.org/web/packages/optimx/index.html

Ravi.

-Original Message-
From: r-help-boun...@r-project.org [mailto:r-help-boun...@r-project.org] On
Behalf Of Barry Rowlingson
Sent: Wednesday, September 08, 2010 10:27 AM
To: Michael Bernsteiner
Cc: r-help@r-project.org
Subject: Re: [R] optimized value worse than starting Value

On Wed, Sep 8, 2010 at 1:35 PM, Michael Bernsteiner
dethl...@hotmail.com wrote:

 Dear all,

 I'm optimizing a relatively simple function. Using optimize the optimized
parameter value is worse than the starting.
 why?

 f-function(delta,P,U){
    minimiz-P+delta*U
    x-minimiz[1]
    y-minimiz[2]
    z-100*(y-x^2)^2+(1-x)^2
    return(z)
 }

 This looks familiar. Is this some 1-d version of the Rosenbrock
Banana Function?

 http://en.wikipedia.org/wiki/Rosenbrock_function

 It's designed to be hard to find the minimum. In the real world one
would hope that things would not have such a pathological behaviour.

 Numerical optimisations are best done using as many methods as
possible - see optimise, nlm, optim, nlminb and the whole shelf of
library books devoted to it.

Barry

__
R-help@r-project.org mailing list
https://stat.ethz.ch/mailman/listinfo/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] XML getNodeSet syntax for PUBMED XML export

2010-09-08 Thread Rob James
 I am looking for the syntax to capture XML tags marked with 
/DescriptorName MajorTopicYN=Y/ , but the combination of the internal 
space (between Name and Major and the embedded quote marks are 
defeating me. I can get all the DescriptorName tags, but these include 
both MajroTopicYN = Y and N variants. Any suggestions?

Thanks in advance.

Prototype text from PUBMED

MeshHeadingList
MeshHeading
DescriptorName MajorTopicYN=YAntibodies, Monoclonal/DescriptorName
/MeshHeading
MeshHeading
DescriptorName MajorTopicYN=NBlood Platelets/DescriptorName
QualifierName MajorTopicYN=Nimmunology/QualifierName
QualifierName MajorTopicYN=Yphysiology/QualifierName
QualifierName MajorTopicYN=Nultrastructure/QualifierName
/MeshHeading
/MeshHeadingList



[[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] Checking if the distribution follow a power law

2010-09-08 Thread David Winsemius


On Sep 8, 2010, at 10:34 AM, NatsumiYotsumoto wrote:


Dear all.


I'm using igraph package, and do a research about network analysis.

With power.law.fit from igraph package, it seems that we can fit a  
power law

distribution to some data.


But, I want to know how to judge whether the network distribution  
follows a

power law or not.


In order to determine whether something is from distribution A or not- 
A, one needs to have a sensible way of characterizing or considering  
what would be in the range of distributions in the not-A.  
Unfortunately for your question, the range of possible distributions  
is infinite. That means it would always be possible to have a better  
fitting distribution than what ever is distribution A.  If you have  
alternatives to the power-law that you want to put to the test, then  
now is the time to offer them.


My guess is that you do not, so I will offer alternatives:

Alt A:
a) read the citations in the email you cited, especially Newman then ...
b) set up a histogram of your data using hist with logarithmic or  
geometric progression of the breaks argument.
c) as a check on you exponent estimate, calculate alpha and se(alpha)  
as on pg 4-5 of that citation.


Alt B:
require(sos)
???fitting pareto
???fitting power network   # and proceed from there

--
David.


Does anyone know the way to do this?

Thanks for any help.

Daigo

p.s.

Also,  I tried several ways such as

http://www.mail-archive.com/r-h...@stat.math.ethz.ch/msg62520.html

and I got results like this:

Profiling...

  2.5 %   97.5 %

2.393297 2.412650

What do these suggest?

please tell me about this if someone knows.


--

David Winsemius, MD
West Hartford, CT

__
R-help@r-project.org mailing list
https://stat.ethz.ch/mailman/listinfo/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] 3d plot layout?

2010-09-08 Thread Martin Ivanov
 Hello!

I would like to ask if R can solve the following problem. 
I need to produce two 3d plots on a single page, that is
to arrange them one above the other. Also, I need to
 visualize points by means of spheres, pyramids and cubes
in the 3d space. Also, I would like to fill these symbols
with colours. Is this possible to be done with R?

In the two dimensional case the R plots are of excellent quality,
I use the layout function to arrange the plots and the symbols
from 20 to 25 that can be filled. So my question is can I produce
an analogous 3d plot with R?

Thank you in advance.

Regards, Martin

__
R-help@r-project.org mailing list
https://stat.ethz.ch/mailman/listinfo/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] two questions

2010-09-08 Thread Greg Snow
Have you considered doing a permutation test on the interaction?

Here is an article that gives the general procedure for a couple of algorithms 
and a comparison of how well they do:

Anderson, Marti J and Legendre, Pierre; An Empirical Comparison of Permutation 
Methods for Tests of Partial Regression Coefficients in a Linear Model.  J. 
Statist. Comput. Simul., 1999, vol 62, pp. 271-303.

-- 
Gregory (Greg) L. Snow Ph.D.
Statistical Data Center
Intermountain Healthcare
greg.s...@imail.org
801.408.8111


 -Original Message-
 From: r-help-boun...@r-project.org [mailto:r-help-boun...@r-
 project.org] On Behalf Of Iasonas Lamprianou
 Sent: Tuesday, September 07, 2010 12:25 AM
 To: juan xiong; Dennis Murphy
 Cc: r-help@r-project.org
 Subject: Re: [R] two questions
 
 By the way, ordinal regression would require huge datasets because my
 dependent variable has around 20 different responses... but again, one
 might say that with so many  ordinal responses, it is as if we have a
 linear/interval variable, right? I just hoped that there would be a
 two-way kruskal-wallis or something like that. On the other hand, what
 is going to happen if I (1) bootstrap data from all cells of my design
 and average the rank ordering of the data of every cell? And then (2)
 do the same but using data from a uniform/normal distribution so that I
 assume that there is no difference between the cells? From point (1) I
 will find the statistical value and from point (2) the expectation and
 then with a third step (3) I can run a chi-square on the
 observed/expected values. Would this be reasonable? But again, how can
 I distinguish between main and interaction effects?
 
 Dr. Iasonas Lamprianou
 
 
 
 
 
 Assistant Professor (Educational Research and Evaluation)
 
 Department of Education Sciences
 
 European University-Cyprus
 
 P.O. Box 22006
 
 1516 Nicosia
 
 Cyprus
 
 Tel.: +357-22-713178
 
 Fax: +357-22-590539
 
 
 
 
 
 Honorary Research Fellow
 
 Department of Education
 
 The University of Manchester
 
 Oxford Road, Manchester M13 9PL, UK
 
 Tel. 0044  161 275 3485
 
 iasonas.lampria...@manchester.ac.uk
 
 --- On Tue, 7/9/10, Dennis Murphy djmu...@gmail.com wrote:
 
 From: Dennis Murphy djmu...@gmail.com
 Subject: Re: [R] two questions
 To: juan xiong xiongjuan2...@gmail.com
 Cc: David Winsemius dwinsem...@comcast.net, r-help@r-project.org,
 Iasonas Lamprianou lampria...@yahoo.com
 Date: Tuesday, 7 September, 2010, 4:47
 
 Hi:
 
 On Mon, Sep 6, 2010 at 5:26 PM, juan xiong xiongjuan2...@gmail.com
 wrote:
 
 Maybe Friedman test
 
 The Friedman test corresponds to randomized complete block designs, not
 general two-way classifications. David's advice is sound, but also
 investigate proportional odds models (e.g., lrm in Prof. Harrell's rms
 package) in case the 'usual' approach comes up short. It would be
 helpful to know the number of response categories and some idea of the
 number of cities-of-birth under study, though...
 
 
 HTH,
 Dennis
 
 
 
 
 On Mon, Sep 6, 2010 at 4:47 PM, David Winsemius
 dwinsem...@comcast.netwrote:
 
 
 
  The usual least-squares methods are fairly robust to departures from
 
  normality. Furthermore, it is the residuals that are assumed to be
 normally
 
  distributed (not the marginal distributions that you are probably
 looking
 
  at) , so it does not sound as though you have yet examined the data
 
  properly. Tell us what the descriptive stats (say the means,
 variance, 10th
 
  and 90th percentiles) are on the residuals within cells cross-
 classified by
 
  the gender and city-of-birth variables (say the means, variance, 10th
 and
 
  90th percentiles).
 
 
 
 
 
  On Sep 6, 2010, at 4:34 PM, Iasonas Lamprianou wrote:
 
 
 
 
 
  Dear friends, two questions
 
 
 
  (1) does anyone know if there are any non-parametric equivalents of
 the
 
  two-way ANOVA in R? I have an ordinal non-normally distributed
 dependent
 
  variable and two factors (gender and city of birth). Normally, one
 would try
 
  a two-way anova, but if R has any non-parametric equivalents, that
 might be
 
  great.
 
 
 
 
 
  There is an entire task view page on robust methods if you decide to
 press
 
  on with this quest.
 
 
 
 
 
   (2) Also, if the interaction of gender and city of birth is
 statistically
 
  significant, which post-hoc tests should I run?
 
 
 
 
 
  How many cities are we talking about?
 
 
 
 
 
   Thanks
 
 
 
  Jason
 
 
 
 
 
  Dr. Iasonas Lamprianou
 
 
 
 
 
  --
 
 
 
  David Winsemius, MD
 
  West Hartford, CT
 
 
 
 
 
  __
 
  R-help@r-project.org mailing list
 
  https://stat.ethz.ch/mailman/listinfo/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
 
 

Re: [R] Change plot order in lattice xyplot

2010-09-08 Thread Sam Albers

Prior to creating a plot I usually just order the factor levels to the order
I want them in. So for your example I would do:

#Create some data
library(lattice)
x - runif(100, 0, 20) 
df - data.frame(x) 
df$y - (1:10) 
df$Month - c(October, September, August, July,June) 

#Plot the figure
plt -xyplot(x~y | Month, data =df,
 layout=c(5,1),
 xlab=Log density from hydroacoustics (integration),
 ylab=Log density from Tucker trawl,
 main=Density estimates, Tucker Trawl, 
 cex=1.5) 

#Factor levels aren't in the order you want them in. Reorder them how you
want.
df$Month - factor(df$Month, levels=c(June,July,August, September,
October), order=TRUE)

#Plot again.
plt

HTH,

Sam

-- 
View this message in context: 
http://r.789695.n4.nabble.com/Change-plot-order-in-lattice-xyplot-tp2531542p2531619.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] forecasting with non-linear models

2010-09-08 Thread Dennis Murphy
Hi:

You're fitting y as a function of x; as in any regression model, the x's are
assumed to be conditionally fixed. If you want to model x as a function of
y, that's a calibration problem.

There are several issues at play:

1. In the model, you have assumed x is fixed, but afterward, you want to
treat it as random.
2. You're implicitly assuming that the relationship between Y and X is
invertible. If this were a math problem, you would be right:   y = a exp(b *
x)   =  x = (1/b) log(y/a). Unfortunately, this is a statistical problem,
and several problems arise, among them:
   - the X and Y scales are very different, which suggests
 rather strongly that the distribution associated with
 random variation in Y is not the same as the distribution
 associated with random variation in X.
  -  the distribution of random errors in Y is quite likely not
 going to have the same relationship to the distribution
 of random errors in X as the functional relationship
 between x and y above. More succinctly, the problem is a
 lack of invariance, so you can't simply invert the problem
 at the end.
3. Predictions are only as valid/reliable as the underlying model and its
attendant assumptions. Your request to predict x as a function of y is
essentially acknowledging that the prediction is useless before it is ever
made, by point (1).

Chemometrics deals with calibration problems regularly - I presume that many
calibration functions are nonlinear, so you may find something useful by
hunting in that area. In econometrics, a related (but not equivalent)
problem is the so-called 'errors in variables', in which both y and x are
assumed to be random. Of course, you could model the problem from a Bayesian
perspective and hope that MCMC comes to the rescue :)

The bottom line is that a statistical relationship between y and x does not
translate to a corresponding relationship between x and y (through
mathematical inversion). Basically, they are treated as separate problems,
which makes sense because the conditional distribution of Y|X = x is not the
same as that of X|Y = y.

HTH,
Dennis

2010/9/8 åÌÅÎÁ âÅÌÙÈ da...@rambler.ru


 Dear colleagues!
 Is it possible to make predictions in R?
 there is an exponential relationship detween y and x
 x-c(0.001,0.003,0.01,0.16,0.3,0.7,0.9)
 y-c(38.8,41.5,44.2,27,26.9,6.9,3)
 f-function(x,a,b){a*exp(b*x)}
 fm-nls(y~f(x,a,b), start=c(a=1,b=1))

 How one can predict x when y=10 and is it possible to calculate standard
 error of x?
 The task is equal to function ED in drc package, but it use logistic
 regression only.

 Best regards,
 Elena.

 --
 da...@rambler.ru.

 __
 R-help@r-project.org mailing list
 https://stat.ethz.ch/mailman/listinfo/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] question on optim

2010-09-08 Thread nashjc
Ben and Ravi have already pointed out that you have a problem with a
non-computable (e.g., divide by zero or similar) objective function. This
is common.

optim() has mostly unconstrained optimizers. L-BFGS-B does handle box or
bounds constraints. There is also Rvmmin, which is supposedly the same
algorithm as optim's BFGS (I'm the author, but not the implementor of
optim). However, Rvmmin has bounds constraints, so you could constrain the
parameter going to zero to be  .1 or something like that. You don't want
to use a bound that would cause the computational failure, because the
numerical gradient routine takes a step, essentially walking off the
cliff.

If you have analytic gradients, you can do much better usually.

Note that bounds in Nelder-Mead are fairly awkward to use, and our codes
are not very good for that.

You might also try bobyqa from the minqa package, but be warned that it is
an F1 race car relative to the Chevy of Rvmmin. Very good when set up
right, but sometimes tricky to set up.

John Nash


 Message: 33
 Date: Tue, 7 Sep 2010 07:38:55 -0700 (PDT)
 From: Hey Sky heyskywal...@yahoo.com
 To: R r-help@r-project.org
 Subject: [R] question on optim
 Message-ID: 741050.53212...@web113920.mail.gq1.yahoo.com
 Content-Type: text/plain; charset=iso-8859-1

 Hey, R users

 I do not know how to describe my question. I am a new user for R and write
 the
 following?code for a dynamic labor economics?model and use OPTIM to get
 optimizations and parameter values. the following code does not work due
 to
 the?equation:

 ?? wden[,i]-dnorm((1-regw[,i])/w[5])/w[5]

 where w[5]?is one of the parameters (together with vector a, b and other
 elements in vector w)?need to be estimated. if I delete the w[5] from the
 upper
 equation. that is:

 ?wden[,i]-dnorm(1-regw[,i])

 optim will give me the estimated parameters. but the paramter w[5] is a
 key one
 for me.


 now my questions is: what reason lead to the first?equation does not work
 and
 the way to correct it to make it work?

 ?I wish I made the queston clear and thanks for any suggestion.

 Nan
 from Montreal


__
R-help@r-project.org mailing list
https://stat.ethz.ch/mailman/listinfo/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 you output a vector to a column in excel?

2010-09-08 Thread Greg Snow
If you have Excel running with the sheet that you want to use open, then in R 
you can just do:

  write.table( 1:10, 'clipboard', sep='\t', row.names=FALSE, col.names=FALSE )


(replace 1:10 with your vector)

Then go to excel, right click on the cell where you want the first number to 
be, and select paste.

-- 
Gregory (Greg) L. Snow Ph.D.
Statistical Data Center
Intermountain Healthcare
greg.s...@imail.org
801.408.8111


 -Original Message-
 From: r-help-boun...@r-project.org [mailto:r-help-boun...@r-
 project.org] On Behalf Of lord12
 Sent: Tuesday, September 07, 2010 3:33 PM
 To: r-help@r-project.org
 Subject: [R] how to you output a vector to a column in excel?
 
 
 What is the syntax for this?
 
 If you have: vector = c(1,2,3,4), how would you output this to column A
 of
 an excel spreadsheet?
 --
 View this message in context: http://r.789695.n4.nabble.com/how-to-you-
 output-a-vector-to-a-column-in-excel-tp2530470p2530470.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@r-project.org mailing list
https://stat.ethz.ch/mailman/listinfo/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] Change plot order in lattice xyplot

2010-09-08 Thread William Dunlap
 -Original Message-
 From: r-help-boun...@r-project.org 
 [mailto:r-help-boun...@r-project.org] On Behalf Of Sam Albers
 Sent: Wednesday, September 08, 2010 9:42 AM
 To: r-help@r-project.org
 Subject: Re: [R] Change plot order in lattice xyplot
 
 
 Prior to creating a plot I usually just order the factor 
 levels to the order
 I want them in. So for your example I would do:
 
 #Create some data
 library(lattice)
 x - runif(100, 0, 20) 
 df - data.frame(x) 
 df$y - (1:10) 
 df$Month - c(October, September, August, July,June) 
 
 #Plot the figure
 plt -xyplot(x~y | Month, data =df,
layout=c(5,1),
xlab=Log density from hydroacoustics 
 (integration),
  ylab=Log density from Tucker trawl,
  main=Density estimates, Tucker Trawl, 
  cex=1.5) 
 
 #Factor levels aren't in the order you want them in. Reorder 
 them how you
 want.
 df$Month - factor(df$Month, levels=c(June,July,August, 
 September,
 October), order=TRUE)

You don't need to use the ordered=TRUE argument there
and it may be mildly inappropriate.  The command
   factor(theData, levels=theLevels)
does not reorder theLevels.  Using ordered=TRUE means
to make an object of class ordered (a subclass
of factor).  Modelling functions like lm() deal with
ordered factors a bit differently than unordered factors,
but the ordered/factor distinction has no effect on how
most graphics and data manipulation functions deal with them.

Bill Dunlap
Spotfire, TIBCO Software
wdunlap tibco.com 

 
 #Plot again.
 plt
 
 HTH,
 
 Sam
 
 -- 
 View this message in context: 
 http://r.789695.n4.nabble.com/Change-plot-order-in-lattice-xyp
lot-tp2531542p2531619.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@r-project.org mailing list
https://stat.ethz.ch/mailman/listinfo/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] Matrixes inside matrixes

2010-09-08 Thread Patrick Burns

To add to Erik's answer:

You can use a three dimensional array
if all of your data for one cell is the
same type -- numeric presumably.

If the data were different types (numeric
and character, say), you could have a
matrix of mode list to do that.  However,
that's unlikely to be worth the hassle.

'S Poetry' (found on www.burns-stat.com)
has a chapter on arrays that might be of
interest if you are using 3D arrays.  I
think all of that chapter should apply to
R as well.

On 08/09/2010 16:27, Erik Iverson wrote:

Hello,

from ?array

An array in R can have one, two or more dimensions. It is simply
a vector which is stored with additional attributes giving the
dimensions (attribute ‘dim’) and optionally names for those
dimensions (attribute ‘dimnames’).

A two-dimensional array is the same thing as a ‘matrix’.


So, to answer your question, yes.

Alaios wrote:

Hello everyone,

Could you please help me find out if R supports matrixes inside matrixes?
This is what I would like to do

I have an area map of humidity per km. I would like at every cell to
keep also information about the height of this area, the current
temperature etc.

Is something like that supported?

I would like to thank you in advance for your help

Best Regards
Alex



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



--
Patrick Burns
pbu...@pburns.seanet.com
http://www.burns-stat.com
(home of 'Some hints for the R beginner'
and 'The R Inferno')

__
R-help@r-project.org mailing list
https://stat.ethz.ch/mailman/listinfo/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] big data

2010-09-08 Thread Greg Snow
In addition to Dirks advice about the biglm package, you may also want to look 
at the RSQLite and SQLiteDF packages which may make dealing with the large 
dataset faster and easier, especially for passing the chunks to bigglm.

-- 
Gregory (Greg) L. Snow Ph.D.
Statistical Data Center
Intermountain Healthcare
greg.s...@imail.org
801.408.8111


 -Original Message-
 From: r-help-boun...@r-project.org [mailto:r-help-boun...@r-
 project.org] On Behalf Of André de Boer
 Sent: Wednesday, September 08, 2010 5:27 AM
 To: r-help@r-project.org
 Subject: [R] big data
 
 Hello,
 
 I searched the internet but i didn't find the answer for the next
 problem:
 I want to do a glm on a csv file consisting of 25 columns and 4 mln
 rows.
 Not all the columns are relevant. My problem is to read the data into
 R.
 Manipulate the data and then do a glm.
 
 I've tried with:
 
 dd-scan(myfile.csv,colClasses=classes)
 dat-as.data.frame(dd)
 
 My question is: what is the right way to do is?
 Can someone give me a hint?
 
 Thanks,
 Arend
 
   [[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] XML getNodeSet syntax for PUBMED XML export

2010-09-08 Thread Duncan Temple Lang

Hi Rob

  doc = xmlParse(url for document)

  dn = getNodeSet(doc, //descriptorna...@majortopic = 'Y'])

will do what you want, I believe.

XPath - a language for expressing such queries - is quite
simple and based on a few simple primitive concepts from which
one can create complex compound queries. The //DescriptorName
is a node test. The [] is a predicate that includes/discards
some of the resulting nodes.

   D.

On 9/8/10 9:09 AM, Rob James wrote:
  I am looking for the syntax to capture XML tags marked with 
 /DescriptorName MajorTopicYN=Y/ , but the combination of the internal 
 space (between Name and Major and the embedded quote marks are 
 defeating me. I can get all the DescriptorName tags, but these include 
 both MajroTopicYN = Y and N variants. Any suggestions?
 
 Thanks in advance.
 
 Prototype text from PUBMED
 
 MeshHeadingList
 MeshHeading
 DescriptorName MajorTopicYN=YAntibodies, Monoclonal/DescriptorName
 /MeshHeading
 MeshHeading
 DescriptorName MajorTopicYN=NBlood Platelets/DescriptorName
 QualifierName MajorTopicYN=Nimmunology/QualifierName
 QualifierName MajorTopicYN=Yphysiology/QualifierName
 QualifierName MajorTopicYN=Nultrastructure/QualifierName
 /MeshHeading
 /MeshHeadingList
 
 
 
   [[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] try-error can not be test. Why?

2010-09-08 Thread telm8

Hi,

I am having some strange problem with detecting try-error. From what I
have read so far the following statement:


try( log(a) ) == try-error


should yield TRUE, however, it yields FALSE. I can not figure out why. Can
someone help?

Many thanks
-- 
View this message in context: 
http://r.789695.n4.nabble.com/try-error-can-not-be-test-Why-tp2531675p2531675.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] try-error can not be test. Why?

2010-09-08 Thread David Winsemius


On Sep 8, 2010, at 1:18 PM, telm8 wrote:



Hi,

I am having some strange problem with detecting try-error. From  
what I

have read so far the following statement:


try( log(a) ) == try-error


should yield TRUE, however, it yields FALSE. I can not figure out  
why. Can

someone help?



 class(try( log(a), silent=TRUE )) == try-error
[1] TRUE





Many thanks
--
View this message in context: 
http://r.789695.n4.nabble.com/try-error-can-not-be-test-Why-tp2531675p2531675.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.


David Winsemius, MD
West Hartford, CT

__
R-help@r-project.org mailing list
https://stat.ethz.ch/mailman/listinfo/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] pairs and panel.smooth for two groups

2010-09-08 Thread Greg Snow
This is fairly simple using lattice graphics:

USJudgeRatings - USJudgeRatings[,1:4]
USJudgeRatings$group - factor(c(rep(1, 22), rep(0, 21)))

library(lattice)
splom( ~USJudgeRatings[,1:4], groups=group, data=USJudgeRatings,
type=c('p','smooth'))


The ggplot2 package probably makes this easy as well (but I am still learning 
that).

If you really need to use the pairs function then you will need to create your 
own panel function (which could call panel.smooth).

-- 
Gregory (Greg) L. Snow Ph.D.
Statistical Data Center
Intermountain Healthcare
greg.s...@imail.org
801.408.8111


 -Original Message-
 From: r-help-boun...@r-project.org [mailto:r-help-boun...@r-
 project.org] On Behalf Of Marie-Pierre Sylvestre
 Sent: Wednesday, September 08, 2010 8:03 AM
 To: r-help@r-project.org
 Subject: [R] pairs and panel.smooth for two groups
 
 Hi,
 I have modified the USJudgeRatings data (available in R)  to
 illustrate my question.
 
 # Use the first 4 variables of USJudgeRatings and add a group variable
 with two levels
 USJudgeRatings - USJudgeRatings[,1:4]
 USJudgeRatings$group - factor(c(rep(1, 22), rep(0, 21)))
 
 # I can draw a pairs graph where members of each group are drawn in
 different colors:
 
 pairs(USJudgeRatings[,1:4], col = c(2,3)[USJudgeRatings$group], pch =
 c(21,3)[USJudgeRatings$group])
 
 # I would also like to add a smooth line to each subplot like
 pairs(USJudgeRatings[,1:4], panel=panel.smooth)
 
 # but I want the smooth to be done for each of the group, i.e. I want
 two smooths per subplot.
 
 # this creates only one smooth
 pairs(USJudgeRatings[,1:4], col = c(2,3)[USJudgeRatings$group], pch =
 c(21,3)[USJudgeRatings$group], panel = panel.smooth)
 
 # I understand that panel.smooth is a function that is called for each
 subplot. I don't know how to tell it to do a smooth for each of my
 group in each of the subplot.
 
 Any help would be appreciated!
 
 Best,
 
 Marie-Pierre
 
 __
 R-help@r-project.org mailing list
 https://stat.ethz.ch/mailman/listinfo/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] large files produced from image plots?

2010-09-08 Thread Stephen T.

Hi list,
I wonder if anyone has thoughts on making image plots in R [using image() or 
image.plot(), or filled.contour()]- I've made quite a bit now, but they seem 
quite large in size when exported to pdf file format (even after compressing 
with pdftk or ghostscript, which I regularly do). I know that for images, 
raster graphics output (png, tiff) may be the way to go, but often the ones I 
make are multi-panel plots with other graphics on them, and are usually 
included in a LaTeX document (PDFLaTeX does accept png) and require 
stretching/shrinking (and/or possibly editing with Adobe Illustrator). I have 
had some luck exporting image plots from Matlab (to postscript or pdf) before 
in the sense that the files seem smaller and less pixelated. Is this a 
difference in the way image() plots are produced, or with the way the image is 
written to the pdf() device (if anyone is familiar with other image-exporting 
programs...)? The other day I had a 13MB dataset, and probably plotted 3/4 of 
it!
  using image() and the compressed pdf output was about 8 MB (it contained 
other stuff but was an addition of a few KB). I tried filled.contour(), as I 
understand that it colors polygons to fill contours instead of coloring 
rectangles at each pixel - and it has saved me before - but this time the 
contours may have been too sharp as as its compressed pdf came out to be 62 
MB... (ouch!). I have not tested this data set with other software programs so 
it may just have been a difficult data set. 
Is there a good solution to this (or is it simply not to use a vector-graphics 
format in these instances), and just for my curiosity, are you aware of any 
things that other software (data analysis) programs do uder the hood to make 
their exported images smaller/smoother? 
Thanks much!
Stephen   
[[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] large files produced from image plots?

2010-09-08 Thread baptiste Auguié
Hi,

Have you tried the recent rasterImage() function?

HTH,

baptiste

On Sep 8, 2010, at 7:30 PM, Stephen T. wrote:

 
 Hi list,
 I wonder if anyone has thoughts on making image plots in R [using image() or 
 image.plot(), or filled.contour()]- I've made quite a bit now, but they seem 
 quite large in size when exported to pdf file format (even after compressing 
 with pdftk or ghostscript, which I regularly do). I know that for images, 
 raster graphics output (png, tiff) may be the way to go, but often the ones I 
 make are multi-panel plots with other graphics on them, and are usually 
 included in a LaTeX document (PDFLaTeX does accept png) and require 
 stretching/shrinking (and/or possibly editing with Adobe Illustrator). I have 
 had some luck exporting image plots from Matlab (to postscript or pdf) before 
 in the sense that the files seem smaller and less pixelated. Is this a 
 difference in the way image() plots are produced, or with the way the image 
 is written to the pdf() device (if anyone is familiar with other 
 image-exporting programs...)? The other day I had a 13MB dataset, and 
 probably plotted 3/4 of !
 it!
  using image() and the compressed pdf output was about 8 MB (it contained 
 other stuff but was an addition of a few KB). I tried filled.contour(), as I 
 understand that it colors polygons to fill contours instead of coloring 
 rectangles at each pixel - and it has saved me before - but this time the 
 contours may have been too sharp as as its compressed pdf came out to be 62 
 MB... (ouch!). I have not tested this data set with other software programs 
 so it may just have been a difficult data set. 
 Is there a good solution to this (or is it simply not to use a 
 vector-graphics format in these instances), and just for my curiosity, are 
 you aware of any things that other software (data analysis) programs do uder 
 the hood to make their exported images smaller/smoother? 
 Thanks much!
 Stephen 
   [[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] try-error can not be test. Why?

2010-09-08 Thread telm8

Thank worked! Thank you so much!!!
-- 
View this message in context: 
http://r.789695.n4.nabble.com/try-error-can-not-be-test-Why-tp2531675p2531726.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] optimized value worse than starting Value

2010-09-08 Thread Michael Bernsteiner

@Barry: Yes it is the Rosenbrock Function. I'm trying out some thing I found 
here: http://math.fullerton.edu/mathews/n2003/PowellMethodMod.html

@Ravi: Thanks for your help. I will have a closer look at the BB package. Am I 
right, that the optimx package is ofline atm? (Windows)


Michael


 From: rvarad...@jhmi.edu
 To: b.rowling...@lancaster.ac.uk; dethl...@hotmail.com
 CC: r-help@r-project.org
 Subject: RE: [R] optimized value worse than starting Value
 Date: Wed, 8 Sep 2010 12:09:31 -0400
 
 Numerical optimisations are best done using as many methods as possible
 
 See the optimx package:
 
 http://cran.r-project.org/web/packages/optimx/index.html
 
 Ravi.
 
 -Original Message-
 From: r-help-boun...@r-project.org [mailto:r-help-boun...@r-project.org] On
 Behalf Of Barry Rowlingson
 Sent: Wednesday, September 08, 2010 10:27 AM
 To: Michael Bernsteiner
 Cc: r-help@r-project.org
 Subject: Re: [R] optimized value worse than starting Value
 
 On Wed, Sep 8, 2010 at 1:35 PM, Michael Bernsteiner
 dethl...@hotmail.com wrote:
 
  Dear all,
 
  I'm optimizing a relatively simple function. Using optimize the optimized
 parameter value is worse than the starting.
  why?
 
  f-function(delta,P,U){
 minimiz-P+delta*U
 x-minimiz[1]
 y-minimiz[2]
 z-100*(y-x^2)^2+(1-x)^2
 return(z)
  }
 
  This looks familiar. Is this some 1-d version of the Rosenbrock
 Banana Function?
 
  http://en.wikipedia.org/wiki/Rosenbrock_function
 
  It's designed to be hard to find the minimum. In the real world one
 would hope that things would not have such a pathological behaviour.
 
  Numerical optimisations are best done using as many methods as
 possible - see optimise, nlm, optim, nlminb and the whole shelf of
 library books devoted to it.
 
 Barry
 
 __
 R-help@r-project.org mailing list
 https://stat.ethz.ch/mailman/listinfo/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] multiple graphs

2010-09-08 Thread moleps
Problem solved..

My bad. No prb with cdplot or graphics-part. The problem was the a-list.. 
command which resulted in all three levels of bar$h.r in a[[1]]. Skipping the 
list function sorted it out.


par(mfrow=c(2,2))
a-levels(bar$h.r)[c(1,3,6)]
print(a)
lapply(a,function(x){
a-subset(bar,h.r==x)
with(a, cdplot(wh~Age,ylab=x))
#plot.new()
})

Regards,

//M



On 8. sep. 2010, at 03.37, David Winsemius wrote:

 
 On Sep 7, 2010, at 8:02 PM, moleps wrote:
 
 Dear all,
 
 I´m trying to create multiple graphs on the same page, but they are all 
 stacked on top of each other.
 
 My code:
 
 
 par(mfrow=c(2,2))
 a-list(levels(bar$h.r)[c(1,3,6)])
 print(a)
 
 lapply(a,function(x){
  a-subset(bar,h.r==x)
  with(a, cdplot(wh~Age,ylab=x))
  #plot.new()
  })
 
 The plot.new command doesnt help...
 
 Any ideas??
 
 ?layout  # assuming that the undescribed plotting function is base graphics. 
 Some plotting functions are hard coded and are able to defeat the usual 
 formatting options.
 
 -- 
 David Winsemius, MD
 West Hartford, CT
 

__
R-help@r-project.org mailing list
https://stat.ethz.ch/mailman/listinfo/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] quot;try-errorquot; can not be test. Why?

2010-09-08 Thread Ben Bolker
telm8 chienlinterry.huang at postgrad.manchester.ac.uk writes:

 
 
 Thank worked! Thank you so much!!!


  in general it is safer (I think) to test

inherits(try(log(a)),try-error)

  which takes care of the case when class(try(log(a))) has
length  1

__
R-help@r-project.org mailing list
https://stat.ethz.ch/mailman/listinfo/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] Replace NAs in one column with data from another column

2010-09-08 Thread Jakob Hedegaard
Hi list,

I have a data frame (m) with 169221 rows and 10 columns and would like to make 
a new column containing the content of column 3 but replace the NAs in column 3 
with the data in column 1 (from the same row as the NA in column 3). Column 1 
has data in all rows.

My first attempt was:

for (i in 1:169221){
if (is.na(m[i,3])==TRUE){
m[i,11] - as.character(m[i,1])}
else{
m[i,11] - as.character(m[i,3])}
}

Works - but takes too long time.
I would appreciate alternative solutions.

Best regards, Jakob

__
R-help@r-project.org mailing list
https://stat.ethz.ch/mailman/listinfo/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] Replace NAs in one column with data from another column

2010-09-08 Thread Dimitris Rizopoulos

one way is the following:

m - data.frame(x = rnorm(100), y = rnorm(100), z = rnorm(100))
m$z[sample(100, 20)] - NA

m$z.new - ifelse(is.na(m$z), m$x, m$z)


I hope it helps.

Best,
Dimitris


On 9/8/2010 8:17 PM, Jakob Hedegaard wrote:

Hi list,

I have a data frame (m) with 169221 rows and 10 columns and would like to make 
a new column containing the content of column 3 but replace the NAs in column 3 
with the data in column 1 (from the same row as the NA in column 3). Column 1 
has data in all rows.

My first attempt was:

for (i in 1:169221){
if (is.na(m[i,3])==TRUE){
m[i,11]- as.character(m[i,1])}
else{
m[i,11]- as.character(m[i,3])}
}

Works - but takes too long time.
I would appreciate alternative solutions.

Best regards, Jakob

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



--
Dimitris Rizopoulos
Assistant Professor
Department of Biostatistics
Erasmus University Medical Center

Address: PO Box 2040, 3000 CA Rotterdam, the Netherlands
Tel: +31/(0)10/7043478
Fax: +31/(0)10/7043014

__
R-help@r-project.org mailing list
https://stat.ethz.ch/mailman/listinfo/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] Replace NAs in one column with data from another column

2010-09-08 Thread jim holtman
?ifelse

df$newCol - ifelse(is.na(df$col3), df$col1, df$col3)

On Wed, Sep 8, 2010 at 2:17 PM, Jakob Hedegaard
jakob.hedega...@agrsci.dk wrote:
 Hi list,

 I have a data frame (m) with 169221 rows and 10 columns and would like to 
 make a new column containing the content of column 3 but replace the NAs in 
 column 3 with the data in column 1 (from the same row as the NA in column 3). 
 Column 1 has data in all rows.

 My first attempt was:

 for (i in 1:169221){
 if (is.na(m[i,3])==TRUE){
 m[i,11] - as.character(m[i,1])}
 else{
 m[i,11] - as.character(m[i,3])}
 }

 Works - but takes too long time.
 I would appreciate alternative solutions.

 Best regards, Jakob

 __
 R-help@r-project.org mailing list
 https://stat.ethz.ch/mailman/listinfo/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 that 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] Replace NAs in one column with data from another column

2010-09-08 Thread Joshua Wiley
Hi Jakob,

You can use is.na() to create an index of which rows in column 3 are
missing data, and then select these from column 1.  Here is a simple
example:

dat - data.frame(V1 = 1:5, V3 = c(1, NA, 3, 4,  NA))
dat$new - dat$V3
my.na - is.na(dat$V3)
dat$new[my.na] - dat$V1[my.na]

dat

This should be quite fast.  I broke the steps up to be explicit, but
you can readily simplify them.

HTH,

Josh

On Wed, Sep 8, 2010 at 11:17 AM, Jakob Hedegaard
jakob.hedega...@agrsci.dk wrote:
 Hi list,

 I have a data frame (m) with 169221 rows and 10 columns and would like to 
 make a new column containing the content of column 3 but replace the NAs in 
 column 3 with the data in column 1 (from the same row as the NA in column 3). 
 Column 1 has data in all rows.

 My first attempt was:

 for (i in 1:169221){
 if (is.na(m[i,3])==TRUE){
 m[i,11] - as.character(m[i,1])}
 else{
 m[i,11] - as.character(m[i,3])}
 }

 Works - but takes too long time.
 I would appreciate alternative solutions.

 Best regards, Jakob

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




-- 
Joshua Wiley
Ph.D. Student, Health Psychology
University of California, Los Angeles
http://www.joshuawiley.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] circular data

2010-09-08 Thread Ben Bolker
Karen Sargsyan karsar at ibms.sinica.edu.tw writes:

 
   Is there any package for clustering of circular data?
 

install.packages(sos)
library(sos)
findFn(circular clustering)

See first row ...

  cheers
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] Saving/loading custom R scripts

2010-09-08 Thread Peter Ehlers

One comment on the function: I see that it uses T/F instead of
TRUE/FALSE in a number of places. You'll save yourself some
headaches if you replace those 'T/F's.

  -Peter Ehlers

On 2010-09-08 1:25, DrCJones wrote:


Hi,
How does R automatically load functions so that they are available from the
workspace? Is it anything like Matlab - you just specify a directory path
and it finds it?

The reason I ask is because  I found a really nice script that I would like
to use on a regular basis, and it would be nice not to have to 'copy and
paste' it into R on every startup:

http://www.r-statistics.com/wp-content/uploads/2010/02/Friedman-Test-with-Post-Hoc.r.txt

This would be for Ubuntu, if that makes any difference.

Cheers


__
R-help@r-project.org mailing list
https://stat.ethz.ch/mailman/listinfo/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] 'par mfrow' and not filling horizontally

2010-09-08 Thread Ted Harding
Greetings, Folks.
I'd appreciate being shown the way out of this one!
I've been round the documentation in ever-drecreasing
circles, and along other paths, without stumbling on
the answer.

The background to the question can be exemplified by
the example (no graphics window open to start with):

  set.seed(54321)
  X0 - rnorm(50) ; Y0 - rnorm(50)

  par(mfrow=c(2,1),mfg=c(1,1),cex=0.5)
  plot(X0,Y0,pch=+,col=blue,xlim=c(-3,3),ylim=c(-3,3),
  xlab=X,ylab=Y,main=My Plot,asp=1)

  par(mfg=c(2,1))
  plot(X0,Y0,pch=+,col=blue,xlim=c(-3,3),ylim=c(-3,3),
  xlab=X,ylab=Y,main=My Plot,asp=1)

As you will see, both plots have been extended laterally
to fill the plotting area horizontally, hence extend from
approx X = -8 to approx X = +8 (on my X11 display), despite
the xlim=c(-3,3); however, the ylim=c(-3,3) has been
respected, as has asp=1.

What I would like to see, independently of the shape of
the graphics window, is a pair of square plots, each with
X and Y ranging from -3 to 3, even if this leaves empty
space in the graphics window on either side.

Hints?

With thanks,
Ted.


E-Mail: (Ted Harding) ted.hard...@manchester.ac.uk
Fax-to-email: +44 (0)870 094 0861
Date: 08-Sep-10   Time: 20:01:19
-- XFMail --

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


Re: [R] Replace NAs in one column with data from another column

2010-09-08 Thread David Winsemius


On Sep 8, 2010, at 2:24 PM, Joshua Wiley wrote:


Hi Jakob,

You can use is.na() to create an index of which rows in column 3 are
missing data, and then select these from column 1.  Here is a simple
example:

dat - data.frame(V1 = 1:5, V3 = c(1, NA, 3, 4,  NA))
dat$new - dat$V3
my.na - is.na(dat$V3)
dat$new[my.na] - dat$V1[my.na]

dat

This should be quite fast.  I broke the steps up to be explicit, but
you can readily simplify them.


I was about to post something similar except I was going to avoid the  
$ operator thinking, incorrectly as it turned out, that it would be  
faster. I also include the Holtman/Rizopoulos suggestion of ifelse().  
I was also surprised that ifelse is the winning strategy:


dat[4] - dat[3]; idx -is.na(dat[, 3])
dat[is.na(dat[, 3]), 4] - dat[is.na(dat[, 3]), 1]

 benchmark(meth.ifelse = {dat$z.new - ifelse(is.na(dat$V3), dat$V1,  
dat$V3)},

+  meth.dlr.sign={dat$new - dat$V3
+  my.na - is.na(dat$V3)
+  dat$new[my.na] - dat$V1[my.na]},
+  meth.index ={dat[4] - dat[3]; idx -is.na(dat[, 3])
+  dat[idx, 4] - dat[idx, 1]},
+ meth.forloop ={for (i in 1:nrow(dat)){
+ if (is.na(dat[i,3])==TRUE){
+ dat[i,4]- dat[i,1]}
+ else{
+ dat[i,4]- dat[i,3]} }
+ },
+ replications=5000, columns = c(test, replications, elapsed,
+  relative, user.self) )
   test replications elapsed  relative user.self
2 meth.dlr.sign 5000   0.502  1.081897 0.501
4  meth.forloop 5000   6.419 13.834052 6.409
1   meth.ifelse 5000   0.464  1.00 0.463
3meth.index 5000   2.908  6.267241 2.904

--
David.


HTH,

Josh

On Wed, Sep 8, 2010 at 11:17 AM, Jakob Hedegaard
jakob.hedega...@agrsci.dk wrote:

Hi list,

I have a data frame (m) with 169221 rows and 10 columns and would  
like to make a new column containing the content of column 3 but  
replace the NAs in column 3 with the data in column 1 (from the  
same row as the NA in column 3). Column 1 has data in all rows.


My first attempt was:

for (i in 1:169221){
if (is.na(m[i,3])==TRUE){
m[i,11] - as.character(m[i,1])}
else{
m[i,11] - as.character(m[i,3])}
}

Works - but takes too long time.
I would appreciate alternative solutions.

Best regards, Jakob



--

David Winsemius, MD
West Hartford, CT

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


  1   2   >