[R] Replacing characters

2010-08-10 Thread Orvalho Augusto
Hello guys! May be I am lazy but

I need to replace a character like \ or ' or to escape them in a character
vector to write a SQL statement.

How can I do that?

Caveman

[[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] Using R in combination with GRASS for image classification

2010-08-10 Thread Chethan S
Hello everybody!

For my academic project work I intend to use only open-source software. My
objective is to carry out classification of satellite digital images using
Geostatistics. I found out GRASS is a good software for image processing.
Also a good geostatistics software is R. It is also known that R can be used
in combination with GRASS. But I am not able to confirm that satellite
digital image classification can be carried out using geostatistical
analysis with GRASS in combination with R.

Can anybody confirm the capability of the software in question or give any
alternative suggestions?

Regards,

Chethan S.

-- 
Chethan S.
PG Student | Remote Sensing and Geographic Information Systems
Dept. of Applied Mechanics  Hydraulics
National Institute of Technology Karnataka | Surathkal
Karnataka | India - 575 025

***e-mail:* chethanuniver...@gmail.com
*Blog:* http://gischethans.blogspot.com
 http://gischethans.wordpress.com
*Twitter:* http://twitter.com/gischethans

[[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] Why use numFold in evaluate_Weka_classifier of RWeka

2010-08-10 Thread Hans W Borchers
s0300851 s0300851 at tp.edu.tw writes:

 
 Hi everyone,
 
 I have a question about using RWeka package,
 we know that instruction make_Weka_classifier that can help 
 us to build a model,and evaluate_Weka_classifier instruction
 can help us to evaluate the performance of  the model using on new data.
 But I have a question about how to using the parameter numFold in
 evaluate_Weka_classifier.Cross-validation means that using some parts 
 to train our data,and some parts to do test,but it should be using in 
 the step of building our model not evaluation.
 I try to think about the numFold=n in the evaluate_Weka_classifier may be 
 this:
 randomly(but in proportion) to select data in the dataset then redo n times,
 then to evaluate the performance.Is this correct?

No. It's preferable to learn about Weka right from the Weka manual.
About the number of folds ('numFold') it says:

A more elaborate method is cross-validation. Here, a number of
folds n is specified. The dataset is randomly reordered and then
split into n folds of equal size. In each iteration, one fold is
used for testing and the other n-1 folds are used for training the
classifier. The test results are collected and averaged over all
folds. This gives the cross-validation estimate of the accuracy.

 Thanks.
 Best regards ,
 
 Hsiao

__
R-help@r-project.org mailing list
https://stat.ethz.ch/mailman/listinfo/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 draw a spherical quadrant

2010-08-10 Thread [Ricardo Rodriguez] Your XEN ICT Team

Hi,

Please, could you tell me if is there a R package that allow to draw 
spherical quadrants?


The value of each point of the quadrant has to represent the power 
generated by a kite on that point tied to a line located in the center 
of the quadrant.


Please, could you give me any clue? Thanks!

Greetings,

Ricardo


--
Ricardo Rodríguez
Your XEN ICT Team

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


[R] R support for 64 bit integers

2010-08-10 Thread Theo Tannen
 Are integers strictly a signed 32 bit number on R even if I am running a 64
bit version of R on a x86_64 bit machine?

I ask because I have integers stored in a hdf5 file where some of the data
is 64 bit integers. When I read that into R using the hdf5 library it seems
any integer greater than 2**31 returns NA.

Any solutions?

Thanks,
Theo

[[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] PCA analysis, presence-absence of mammals in parks

2010-08-10 Thread zloutor

Hi everyone,

So I am trying to see which ecological parameter of different parks in nyc
influence the most the diversity of the medium-sized mammals in those parks.
I have a bunch of different parameters for each park I'm done studying and
the presence (1) and absence (0) of each mammal. I wanted to do a principal
component analysis of those data to know which ones of those parameters are
the most important.

Here is what I have:


Parc PBP VCPPP  CP
surfacekm²  0.917  4.64 0.0213  3.4
woodenarea  0.514   0.6355  0.320.4952
scrubland   0.0905  0.0412  0.060.0498
lawn0.3654  0.2837  0.500.296
lake0.0028  0.0166  0.120.1488
wetareas0.0273  0.0230  0   0.0102
intertidalearea 0.0283  0   0   0
sportsfields0.0887  0.2579  0.120.1323
humanactivity   0.4196  0.7271  0.230.7912
#ofhighways 2   3   0   0
#ofroads4   22  7   11
distanceA   5.314.021.614.02
distanceB   6.124.513.7 4.02
distanceC   7.565.477.726.44
distanceD   9.669.6619.31   9.01
AvgPopN 11330   53806835
AvgPopS 0   702253804711
AvgPopE 0   359285364307
AvgPopW 3940322048409360
raccoon 1   1   1   1
skunk   1   1   1   1
opossum 1   1   1   0
rabbit  1   1   1   0
groundhog   0   0   0   0
muskrat 0   0   0   0


I get to open the .txt with R but then it gives me something pretty weird
when I try to use the function dudi.pca(parcs)... 

Can anyone suggest me how I should to my analysis? I would really really be
thankful for that!

Geo.
-- 
View this message in context: 
http://r.789695.n4.nabble.com/PCA-analysis-presence-absence-of-mammals-in-parks-tp2319051p2319051.html
Sent from the R help mailing list archive at Nabble.com.

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


[R] How to extract the conf.level out of t.test() data

2010-08-10 Thread Etienne Stockhausen

Good afternoon everybody,

I'm writing a little function to visualise hypothesis testing. Therefore 
I need to extract the confidence level of a t-test. Here a little example:


   x - str(t.test(1:10)

gives

   List of 9
$ statistic  : Named num 5.74
 ..- attr(*, names)= chr t
$ parameter  : Named num 9
 ..- attr(*, names)= chr df
$ p.value: num 0.000278
$ conf.int   : atomic [1:2] 3.33 7.67
 ..- attr(*, conf.level)= num 0.95
$ estimate   : Named num 5.5
 ..- attr(*, names)= chr mean of x
$ null.value : Named num 0
 ..- attr(*, names)= chr mean
$ alternative: chr two.sided
$ method : chr One Sample t-test
$ data.name  : chr 1:10
- attr(*, class)= chr htest

Now I can use

   x$conf.int

what gives

   [1] 496.9141 499.6276
   attr(,conf.level)
   [1] 0.95

In the example I try to extract the value 0.95 but I have no Idea how. I 
hope somebody can help me.

Thanks in advance an greetings from Berlin

Etienne

__
R-help@r-project.org mailing list
https://stat.ethz.ch/mailman/listinfo/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] coef(summary) and plyr

2010-08-10 Thread moleps
Upon reading the plyr documentation that was the distinct impression I got and 
I´m glad that whatever expectations  I had developed regarding plyr were 
fulfilled. Thx for the input Hadley. 

 Maybe this is a cumbersome solution, but it works.. 

And Matthew, I will most definitively look into the datatable library. 

mydf - data.frame(x1=rnorm(100), x2=rnorm(100), x3=rnorm(100))
mydf$fac-factor(sample((0:2),replace=T,100))
 mydf$y- mydf$x1+0.01+mydf$x2*3-mydf$x3*19+rnorm(100)
dlply(mydf,.(fac),function(df) lm(y~x1+x2+x3,data=df))-dl


test-function(a){
coef(summary(a))-lo
a-colnames(lo)
b-rownames(lo)
c-length(a)
e-character(0)
r-NULL
for (x in (1:c)){
d-rep(paste(a[1:c],b[x],sep= ))
e-paste(c(e,d))
t-lo[x,]
r-c(r,t)
names(r)-e
}
return(r)
}


ldply(dl,function(x) test(x))-g
g


Regards,

Moleps


On 9. aug. 2010, at 19.55, Hadley Wickham wrote:

 That's exactly what dlply does - so you should never have to do that
 yourself.
 
 I'm unclear what you are saying. Are you saying that the plyr function
 _should_ have examined the objects in that list and determined that there
 were 4 rows and properly labeled the rows to indicate which list they came
 from?
 
 Yes, exactly.  It's the output from coef(summary(x)) that makes it
 look like this isn't happening.
 
 Hadley
 
 -- 
 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.


[R] how to interpolate multidimensional (3D) spatial data

2010-08-10 Thread Georg Roth


 Hello,

I am an archaeologist who wonders wether a
multidimensional (3D) spatial interpolation
is possible in R.
The data consists of measurements in 3D space
with coordinates X-Y-Z and a measured variable
U, that is, U is measured at points located
at X-Y-Z.
e.g. a data structure like the following:

X   Y   Z   U
5.105.0216.03   6.674
5.414.3214.03   6.668
1.723.5912.28   7.521
.   .   .   .
.   .   .   .

I am used to interpolation in GIS with 2D-data
(x-y, u). The interpolation method should possible
be any I am familiar with like kriging, minimum
curvature (splines), inverse distance or something
like this.

Having done 3D kernel density estimation I think
of a visualization of the interpolated 3D field
of U like the density in 3D rgl-plots {function
'plot(kde(xyz,hpi(xyz)))', package=ks}, that is,
having the interpolated values shown as a kind of
semitransparent cloud in 3D with the colour and/or
the transparency representing the values of U.

Is there any function or package that does this
kind of computation and visualization?

Please excuse my bumpy English.

Thank You for any help.

And, thanks to the volunteer moderators allowing
mails for non-subscribers

Georg


   *
Any technology sufficiently advanced  *
 is indistinguishable from magic. *
 (Arthur C. Clarke)*
   *


Georg Roth M.A. (prom.)
Historisches Seminar
Professur für Ur- und Frühgeschichte
Universität Leipzig
Ritterstraße 14
04109 Leipzig
Tel: 0049 - (0)341 - 97 37069
Fax: 0049 - (0)341 - 97 37046

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

2010-08-10 Thread Farrel Buchinsky
Do you use RGoogleDocs? If so can you please try run a script now and tell
me if you get what I am getting?

Error in curlPerform(curl = curl, .opts = opts, .encoding = .encoding) : SSL
certificate problem, verify that the CA cert is OK. Details:
error:14090086:SSL routines:SSL3_GET_SERVER_CERTIFICATE:certificate verify
failed

It came after I ran this:
library(RGoogleDocs)
ps -readline(prompt=get the password in )
sheets.con = getGoogleDocsConnection(getGoogleAuth(fx...@gmail.com, ps,
service =wise))
ts2=getWorksheets(OnCall,sheets.con)

I posted the question on StackOverflow at
http://stackoverflow.com/questions/3442781/rgoogledocs-or-rcurl-giving-ssl-certificate-problem
Is it a breach of etiquette to cross post?


Farrel Buchinsky

[[alternative HTML version deleted]]

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


Re: [R] How to extract the conf.level out of t.test() data

2010-08-10 Thread Romain Francois


Le 09/08/10 20:39, Etienne Stockhausen a écrit :


Good afternoon everybody,

I'm writing a little function to visualise hypothesis testing. Therefore
I need to extract the confidence level of a t-test. Here a little example:

x - str(t.test(1:10)

gives

List of 9
$ statistic : Named num 5.74
..- attr(*, names)= chr t
$ parameter : Named num 9
..- attr(*, names)= chr df
$ p.value : num 0.000278
$ conf.int : atomic [1:2] 3.33 7.67
..- attr(*, conf.level)= num 0.95
$ estimate : Named num 5.5
..- attr(*, names)= chr mean of x
$ null.value : Named num 0
..- attr(*, names)= chr mean
$ alternative: chr two.sided
$ method : chr One Sample t-test
$ data.name : chr 1:10
- attr(*, class)= chr htest

Now I can use

x$conf.int

what gives

[1] 496.9141 499.6276
attr(,conf.level)
[1] 0.95

In the example I try to extract the value 0.95 but I have no Idea how. I
hope somebody can help me.
Thanks in advance an greetings from Berlin

Etienne


You need the conf.level attribute, as in :

x - t.test(1:10)
attr( x$conf.int, conf.level )

Romain

--
Romain Francois
Professional R Enthusiast
+33(0) 6 28 91 30 30
http://romainfrancois.blog.free.fr
|- http://bit.ly/aAyra4 : highlight 0.2-2
|- http://bit.ly/94EBKx : inline 0.3.6
`- http://bit.ly/aryfrk : useR! 2010

__
R-help@r-project.org mailing list
https://stat.ethz.ch/mailman/listinfo/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] coef(summary) and plyr

2010-08-10 Thread moleps
correction...

Col and rows were mixed up and loop only worked when rows were less than or 
equal to number of columns

//M


test-function(a){
coef(summary(a))-lo
a-colnames(lo)
b-rownames(lo)
c-length(a)
e-character(0)
r-NULL
for (x in (1:length(b))){
d-rep(paste(a[1:c],b[x],sep= ))
e-paste(c(e,d))
t-lo[x,]
r-c(r,t)
names(r)-e
}
return(r)
}

On 9. aug. 2010, at 19.55, Hadley Wickham wrote:

 That's exactly what dlply does - so you should never have to do that
 yourself.
 
 I'm unclear what you are saying. Are you saying that the plyr function
 _should_ have examined the objects in that list and determined that there
 were 4 rows and properly labeled the rows to indicate which list they came
 from?
 
 Yes, exactly.  It's the output from coef(summary(x)) that makes it
 look like this isn't happening.
 
 Hadley
 
 -- 
 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] How to extract the conf.level out of t.test() data

2010-08-10 Thread Dimitris Rizopoulos

try this:

x - t.test(1:10)

x$conf.int
attr(x$conf.int, conf.level)


I hope it helps.

Best,
Dimitris


On 8/9/2010 8:39 PM, Etienne Stockhausen wrote:

Good afternoon everybody,

I'm writing a little function to visualise hypothesis testing. Therefore
I need to extract the confidence level of a t-test. Here a little example:

x - str(t.test(1:10)

gives

List of 9
$ statistic : Named num 5.74
..- attr(*, names)= chr t
$ parameter : Named num 9
..- attr(*, names)= chr df
$ p.value : num 0.000278
$ conf.int : atomic [1:2] 3.33 7.67
..- attr(*, conf.level)= num 0.95
$ estimate : Named num 5.5
..- attr(*, names)= chr mean of x
$ null.value : Named num 0
..- attr(*, names)= chr mean
$ alternative: chr two.sided
$ method : chr One Sample t-test
$ data.name : chr 1:10
- attr(*, class)= chr htest

Now I can use

x$conf.int

what gives

[1] 496.9141 499.6276
attr(,conf.level)
[1] 0.95

In the example I try to extract the value 0.95 but I have no Idea how. I
hope somebody can help me.
Thanks in advance an greetings from Berlin

Etienne

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


[R] Identifying integers (as opposed to real #s) in matrix

2010-08-10 Thread David Katz
Is there a way to identify (for subsequent replacement) which rows in a
matrix are comprised entirely of *integers*?  I have a large set of
*nx3 *matrices
where each row either consists of a set of 3 integers or a set of 3 real
numbers.  A given matrix might looks something like this:

   [ ,1]   [ ,2]   [ ,3]

[1, ] 121.-98.   276.

[2, ]  10.1234 25.4573 -188.9204

[3, ]  121.-98.   276.

[4, ]  -214.4982   -99.1043-312.0495

.

[n, ]  99.  1.   -222.

Ultimately, I'm going to replace the values in the integer-only rows with
NAs.  But first I need r to recognize the integer-only rows.  I assume
whatever function I write will be keyed off of the .s, but have no
clue how to write that function.  Any ideas?

David Katz

[[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] Identifying integers (as opposed to real #s) in matrix

2010-08-10 Thread Romain Francois


Le 10/08/10 10:05, David Katz a écrit :


Is there a way to identify (for subsequent replacement) which rows in a
matrix are comprised entirely of *integers*?  I have a large set of
*nx3 *matrices
where each row either consists of a set of 3 integers or a set of 3 real
numbers.  A given matrix might looks something like this:

[ ,1]   [ ,2]   [ ,3]

[1, ] 121.-98.   276.

[2, ]  10.1234 25.4573 -188.9204

[3, ]  121.-98.   276.

[4, ]  -214.4982   -99.1043-312.0495

.

[n, ]  99.  1.   -222.

Ultimately, I'm going to replace the values in the integer-only rows with
NAs.  But first I need r to recognize the integer-only rows.  I assume
whatever function I write will be keyed off of the .s, but have no
clue how to write that function.  Any ideas?

David Katz


Something like this perhaps:

 x - rbind( c(1, 2, 3), c(1.2,2.2, 3.2), c(1,2,3), c(1.2, 1.2, 1.3 ) )
 x
 [,1] [,2] [,3]
[1,]  1.0  2.0  3.0
[2,]  1.2  2.2  3.2
[3,]  1.0  2.0  3.0
[4,]  1.2  1.2  1.3

 rowSums( x == round(x) ) == ncol(x)
[1]  TRUE FALSE  TRUE FALSE

 x[ rowSums( x == round(x) ) == ncol(x) , ] - NA
 x
 [,1] [,2] [,3]
[1,]   NA   NA   NA
[2,]  1.2  2.2  3.2
[3,]   NA   NA   NA
[4,]  1.2  1.2  1.3


Romain

--
Romain Francois
Professional R Enthusiast
+33(0) 6 28 91 30 30
http://romainfrancois.blog.free.fr
|- http://bit.ly/aAyra4 : highlight 0.2-2
|- http://bit.ly/94EBKx : inline 0.3.6
`- http://bit.ly/aryfrk : useR! 2010

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

2010-08-10 Thread Evgenia

Yes, this is exactly want I want.

Thanks Michael 

-- 
View this message in context: 
http://r.789695.n4.nabble.com/Results-with-name-of-dataset-tp2318328p2319484.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] Sweave with dev.new()

2010-08-10 Thread Gro Nilsen
Dear list.
I am preparing a R package, and the last step is to write a package
vignette using Sweave. However, I am experiencing some trouble when trying
to include plots in my Sweave document. That is, in my package I have made
some plotting functions in which I start by calling 'new.dev()' to start a
graphics device of a certain width and height, and then proceed with
plot(). These functions work perfectly fine in R, and when I check and
build my package with R CMD build/check.

The problems start when I try to include the command and the output of my
plotting functions in the Sweave document, and I suspect it must have
something to do with the command 'dev.new()' in my code. Here is a basic
example of a Sweave file which can hopefully illustrate the problem:

\documentclass[a4paper]{article}

\usepackage{Sweave}
\RequirePackage{graphicx,fancyvrb}


\title{Sweavetest}

\begin{document}

\section{Plotting}

label=testfig,include=FALSE,echo=TRUE=
dev.new(width=7,height=6,record=TRUE)
plot(1:10,col=red)
@
\begin{figure}[ht]
\begin{center}
label=fig,fig=TRUE,echo=FALSE=
testfig
@
\end{center}
\caption{Testplot}
\label{fig:test}
\end{figure}

\end{document}


When I run Sweave on this file I get empty pdf and eps files named
Sweavetest-fig.pdf and Sweavetest-fig.eps, and the corresponding latex
file is unable to create a PDF-file.

Does anyone know what the problem is, and how I might solve it? This is
the first time that I have worked with Sweave, so I might be missing
something basic...

Best regards,
Gro Nilsen
PhD-student, University of Oslo

__
R-help@r-project.org mailing list
https://stat.ethz.ch/mailman/listinfo/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] Identifying integers (as opposed to real #s) in matrix

2010-08-10 Thread peter dalgaard

On Aug 10, 2010, at 10:13 AM, Romain Francois wrote:

  rowSums( x == round(x) ) == ncol(x)
 [1]  TRUE FALSE  TRUE FALSE

For later readability, I think I'd prefer

apply(x==round(x), 1, all)

-- 
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] package for measurement error models

2010-08-10 Thread peter dalgaard

On Aug 10, 2010, at 3:52 AM, Carrie Li wrote:

 Thanks. I found the code in the link you gave me very helpful.
 But, I just have few questions regarding the code.
 It seems to me that in (from wikipdeia)Deming regression, it assumes that
 the ratios of the variances of two measurement errors are constant for all
 pairs of (x_i, y_i). However, if the ratios are not constant, (i.e. the
 variances of measurement are heterogeneous) , is it still appropriate to use
 Deming regression ?

In a word, no.

One way of looking at it is that as the ratio of variances varies from 0 to 
infinity, the analysis goes from regression of y on x to (inverse) regression 
of x on y, and those give different results, not just numerically but also 
asymptotically. I.e., getting the ratio wrong gives an inconsistent estimate; 
getting it wrong for some of the data, as is bound to happen if you assume it 
constant and it isn't, will also give a inconsistent estimate. Unless, that is, 
you can find a definition of average ratio that eliminates the bias, but I 
don't think it is worth the paperwork. 

Rather, I'd suggest direct minimization of the SSR (from the Wikipedia page), 
noting that you can plug in x_i^* as a function of beta also if the 
_individual_ ratios are known. (I get the feeling that someone must have been 
here before, so possibly others can fill in the gaps?) For modest sample sizes, 
it might also be possible to formulate the problem as a nonlinear model and use 
nls(). 

-- 
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] Turning a source into a Package

2010-08-10 Thread Jim Lemon

On 08/10/2010 02:51 AM, JH wrote:


I want to edit a function in the nlme package. I download the package source
nlme_3.1-96.tar.gz from the link below then edit it one of the scripts
inside of it. From this stage how can I turn it into a package that I can
use in R?

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


Hi JH,
The problem I have encountered with this is that installed packages 
often do not have all the required directories and the source code for 
checking and building. With a small package, you can get the source code 
for all the functions by sinking the output produced by invoking each 
function name without arguments to a file in the R subdirectory (copy 
the whole installed package directory to another location first):


sink(anova.lme.R)
cat(anova.lme-)
anova.lme
sink()

but this is only practical for small packages. You would also have to 
back translate the HTML help files to Rd format and place these in the 
man directory, again a considerable task for a package like nlme. Your 
best bet for something like this is to load the library:


library(nlme)

and then source the modified code:

source(anova.lme.R)

or whatever function you have modified. You can even write a function to 
do this:


my.library(x,newfile) {
 library(x)
 source(newfile)
}

my.library(nlme,anova.lme.R)

Jim

__
R-help@r-project.org mailing list
https://stat.ethz.ch/mailman/listinfo/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] one (small) sample wilcox.test confidence intervals

2010-08-10 Thread Panos Hadjinicolaou
Dear R people,

I notice that the confidence intervals of a very  small sample (e.g. n=6) 
derived from the one-sample wilcox.test are  just the maximum and minimum 
values of the sample. This only occurs  when the required confidence level is 
higher than 0.93. Example:


 sample - c(1.22, 0.89, 1.14, 0.98, 1.37, 1.06)

 summary(sample)
   Min. 1st Qu.  MedianMean 3rd Qu.Max.
   0.891.001.101.111.201.37

  wilcox.test(sample,conf.int=TRUE,conf.lev=0.95)

Wilcoxon signed rank test

data:  sample
V = 21, p-value = 0.03125
alternative hypothesis: true location is not equal to 0
95 percent confidence interval:
 0.89 1.37
sample estimates:
(pseudo)median
   1.1

According  to help, since my sample contains less than 50 values, an exact  
p-value is calculated that should enable the confidence interval to be  
obtained from Bauer (1972) (I have not read it):

 By default (if ‘exact’ is not specified), an exact p-value is
 computed if the samples contain less than 50 finite values and
 there are no ties.  Otherwise, a normal approximation is used.
 ...
 If exact p-values are available, an exact
 confidence interval is obtained by the algorithm described in
 Bauer (1972), and the Hodges-Lehmann estimator is employed.
 Otherwise, the returned confidence interval and point estimate are
 based on normal approximations.  These are continuity-corrected
 for the interval but _not_ the estimate (as the correction depends
 on the ‘alternative’). With small samples it may not be possible to 
achieve very high
 confidence interval coverages. If this happens a warning will be
 given and an interval with lower coverage will be substituted. 

The latter indeed happens if I ask for confidence level of 0.99:

 wilcox.test(sample,mu=0,conf.int=TRUE,conf.lev=0.99)

Wilcoxon signed rank test

data:  sample
V = 21, p-value = 0.03125
alternative hypothesis: true location is not equal to 0
96.9 percent confidence interval:
 0.89 1.37
sample estimates:
(pseudo)median
   1.1

Warning message:
In wilcox.test.default(sample, mu = 0, conf.int = TRUE, conf.lev = 0.99) :
  Requested conf.level not achievable

My questions (finally!) are:

1.  Why the above warning for conf.lev = 0.99 does not appear for 0.93   
conf.lev  0.98 although it produces the same summary?

2. For  conf.lev = 0.95, is there anything else I can do in order to obtain  
confidence intervals other than the max. and min. values of my sample  or I am 
limited from my sample's size ?

Thanks for your patience in reading this,

Panos

 ---
  Dr Panos Hadjinicolaou
  
  Energy Environment  Water Research Center (EEWRC)
  The Cyprus Institute
---
[[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] Pie Chart in map

2010-08-10 Thread Jim Lemon

On 08/10/2010 03:04 AM, LCOG1 wrote:


Hey R'rs,
 So im sick of dealing with ESRI products and am looking to stream line a
process i now use GIS to do using R.  I have made a lot of maps using R but
have not yet seen a map that puts pie charts within the map to help
represent data like the attachment.
http://r.789695.n4.nabble.com/file/n2318816/template1.bmp

I found Tanimura et al. work Proportional Symbol Mapping in R, but after a
discussion with one of the authors i have learned that the function is out
of date and would require a great deal of reworking.  I also found hexbinpie
on the R graphics gallery that i could incorporate.

Before i go through the process of rewriting or out right creation of a
process to replicate my GIS results i was hoping to make sure there wasnt
something out there i could use to start or use altogether.  Or perhaps a
set of functions that already exists that i havent thought to use.


Hi JR,
You can also check out the floating.pie function in the plotrix package.

Jim

__
R-help@r-project.org mailing list
https://stat.ethz.ch/mailman/listinfo/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] package for measurement error models

2010-08-10 Thread Prof Brian Ripley

On Tue, 10 Aug 2010, peter dalgaard wrote:



On Aug 10, 2010, at 3:52 AM, Carrie Li wrote:


Thanks. I found the code in the link you gave me very helpful.
But, I just have few questions regarding the code.
It seems to me that in (from wikipdeia)Deming regression, it assumes that
the ratios of the variances of two measurement errors are constant for all
pairs of (x_i, y_i). However, if the ratios are not constant, (i.e. the
variances of measurement are heterogeneous) , is it still appropriate to use
Deming regression ?


In a word, no.

One way of looking at it is that as the ratio of variances varies 
from 0 to infinity, the analysis goes from regression of y on x to 
(inverse) regression of x on y, and those give different results, 
not just numerically but also asymptotically. I.e., getting the 
ratio wrong gives an inconsistent estimate; getting it wrong for 
some of the data, as is bound to happen if you assume it constant 
and it isn't, will also give a inconsistent estimate. Unless, that 
is, you can find a definition of average ratio that eliminates the 
bias, but I don't think it is worth the paperwork.


Rather, I'd suggest direct minimization of the SSR (from the 
Wikipedia page), noting that you can plug in x_i^* as a function of 
beta also if the _individual_ ratios are known. (I get the feeling 
that someone must have been here before, so possibly others can fill 
in the gaps?) For modest sample sizes, it might also be possible to


Yes, people have been there before. Mike Thompson and I published a 
now-much-cited-in-analytical-chemistry paper in The Analyst in 1987. 
A companion paper was rejected by a mainstream statistics journal as 
'already known', but the journal editor was unable to get any prior 
publication out of the referee.



formulate the problem as a nonlinear model and use nls().


Direct minimization is simple enough.


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


--
Brian D. Ripley,  rip...@stats.ox.ac.uk
Professor of Applied Statistics,  http://www.stats.ox.ac.uk/~ripley/
University of Oxford, Tel:  +44 1865 272861 (self)
1 South Parks Road, +44 1865 272866 (PA)
Oxford OX1 3TG, UKFax:  +44 1865 272595

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


Re: [R] Concatenate a mix of numbers and letters to create a vector name

2010-08-10 Thread Panos Hadjinicolaou
I was not aware of the R-FAQ, it seems to have some very useful tips, thanks 
for pointing there. 

Regarding the 7.21 in the FAQ, I read it a few times but it did not lead me 
anywhere. For the moment I am blaming my inexperience with some R basics, I 
will come back after I do some more serious studying.

Thanks again,

Panos


Dr Panos Hadjinicolaou

Energy Environment  Water Research Center (EEWRC)
The Cyprus Institute

-


  _  
From: Greg Snow [mailto:greg.s...@imail.org]
To: Panos Hadjinicolaou [mailto:p.hadjinicol...@cyi.ac.cy], 
r-help@r-project.org [mailto:r-h...@r-project.org]
Sent: Wed, 28 Jul 2010 00:39:41 +0300
Subject: RE: [R] Concatenate a mix of numbers and letters to create a vector 
name

This is a frequently asked/answered question (7.21 in the FAQ).  What searching 
did you do and why did it not find this FAQ or previous discussion of it?  How 
could the documentation/search/etc. be improved so that you (and the next n 
people with this question) will find the answer easier?

The most important of part of the FAQ answer is the last section where it 
points out that using a list will be much simpler.  You mentioned in the first 
post that you were doing this in a loop, just start with an empty list, use 
paste (or sprintf) to create the name, and then assign it as a new element of 
the list with that name (e.g. mylist[[ sprintf('tmax.%d%d', var1, var2) ]] - 
outputfromcomputations ).

-- 
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 Panos Hadjinicolaou
 Sent: Monday, July 26, 2010 8:24 AM
 To: r-help@r-project.org
 Subject: Re: [R] Concatenate a mix of numbers and letters to create a
 vector name
 
 Thanks for the reply. Indeed the paste function results in
 concatenation:
   paste(c(tmax., 1950, 12), collapse=)
 [1] tmax.195012
 
 but  I am looking for a way to subsequently get rid of the -  - in
 order to  use tmax.195012 as an object (e.g. to define a vector with
 that name).  Any ideas?
 
 Thanks,
 
 Panos
 
   _
 
 From: Dimitris Rizopoulos [mailto:d.rizopou...@erasmusmc.nl]
 To: Panos Hadjinicolaou [mailto:p.hadjinicol...@cyi.ac.cy]
 Cc: r-help@r-project.org
 Sent: Mon, 26 Jul 2010 16:48:31 +0300
 Subject: Re: [R] Concatenate a mix of numbers and letters to create a
 vector name
 
 have a look at function paste(), i.e., ?paste
 
 
   I hope it helps.
 
   Best,
   Dimitris
 
 
   On 7/26/2010 3:44 PM, Panos Hadjinicolaou wrote:
Dear all,
   
I am trying to create a vector name, for example tmax.195012 from
 tmax., 1950 and 12. Obviously I don't wish to simply type it because
 the 3 name components are changing in each iteration within a loop. Is
 there any way of concatenating those 3 components (which are a mixture
 of numbers and letters)?
   
Thanks for reading,
   
Panos
   
-
Dr Panos Hadjinicolaou
   
Energy Environment  Water Research Center (EEWRC)
The Cyprus Institute
--
 [[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.
   
 
   --
   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
   [[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 draw a spherical quadrant

2010-08-10 Thread Jim Lemon

On 08/10/2010 05:32 PM, [Ricardo Rodriguez] Your XEN ICT Team wrote:

Hi,

Please, could you tell me if is there a R package that allow to draw
spherical quadrants?

The value of each point of the quadrant has to represent the power
generated by a kite on that point tied to a line located in the center
of the quadrant.


Hi Ricardo,
You may find that the radial.plot function in the plotrix package will 
do what you want. I think you are looking at the polygon type of plot.


Jim

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

2010-08-10 Thread elaine kuo
Dear list,

I am learning moran.test in package spdep.
There is a setting of alternative, defined as a character string specifying
the alternative hypothesis,
must be one of greater (default), less or two.sided.

I would like to learn what a alternative hypothesis is in moran.test but
found little in R-help.
Please kindly share the references and thank you.

Elaine

[[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] Replacing characters

2010-08-10 Thread David Winsemius


On Aug 10, 2010, at 2:02 AM, Orvalho Augusto wrote:


Hello guys! May be I am lazy but

I need to replace a character like \ or ' or to escape them in a  
character

vector to write a SQL statement.



?sub
?regex



How can I do that?

Caveman


--

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] Sweave with dev.new()

2010-08-10 Thread Marc Schwartz
On Aug 10, 2010, at 3:51 AM, Gro Nilsen wrote:

 Dear list.
 I am preparing a R package, and the last step is to write a package
 vignette using Sweave. However, I am experiencing some trouble when trying
 to include plots in my Sweave document. That is, in my package I have made
 some plotting functions in which I start by calling 'new.dev()' to start a
 graphics device of a certain width and height, and then proceed with
 plot(). These functions work perfectly fine in R, and when I check and
 build my package with R CMD build/check.
 
 The problems start when I try to include the command and the output of my
 plotting functions in the Sweave document, and I suspect it must have
 something to do with the command 'dev.new()' in my code. Here is a basic
 example of a Sweave file which can hopefully illustrate the problem:
 
 \documentclass[a4paper]{article}
 
 \usepackage{Sweave}
 \RequirePackage{graphicx,fancyvrb}
 
 
 \title{Sweavetest}
 
 \begin{document}
 
 \section{Plotting}
 
 label=testfig,include=FALSE,echo=TRUE=
 dev.new(width=7,height=6,record=TRUE)
 plot(1:10,col=red)
 @
 \begin{figure}[ht]
 \begin{center}
 label=fig,fig=TRUE,echo=FALSE=
 testfig
 @
 \end{center}
 \caption{Testplot}
 \label{fig:test}
 \end{figure}
 
 \end{document}
 
 
 When I run Sweave on this file I get empty pdf and eps files named
 Sweavetest-fig.pdf and Sweavetest-fig.eps, and the corresponding latex
 file is unable to create a PDF-file.
 
 Does anyone know what the problem is, and how I might solve it? This is
 the first time that I have worked with Sweave, so I might be missing
 something basic...
 
 Best regards,
 Gro Nilsen
 PhD-student, University of Oslo


It is not clear to me why you need the dev.new() call.  By default using 
Sweave, both PDF and EPS plot files will be created, for subsequent inclusion 
in the document as appropriate. Just define the plot dimensions in the figure 
chunk header:

  label=fig,fig=TRUE,echo=FALSE,height=6,width=7=

Be aware however, that by default, the image size in the final document will be 
set to \textwidth * 0.8, irrespective of the dimensions that you have 
specified. You can alter that default behavior by using:

  \usepackage[nogin]{Sweave}

in your document preamble. The figures will then be set to the sizes that you 
define in the figure chunk header.

See ?RweaveLatex for more information.

HTH,

Marc Schwartz

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


[R] FAQ package, anyone?

2010-08-10 Thread baptiste Auguié
Dear list,

Here's a reproducible example that fails,

library(faq)
Error in library(faq) : there is no package called 'faq'

faq(lattice sweave)
Error: could not find function faq

As a fun challenge, I propose to remedy this by creating a fortune-like package 
dedicated to Frequently Asked Questions (FAQ) entries. The aim is multifold,

1- Provide a generic template for use in a variety of situations. I imagine 
that any package could then define its own FAQ entries and use the faq package 
to display them, search, etc.

2- Improve the visibility of the current FAQ: currently directing someone to a 
FAQ entry involves some web-browsing, which is not as convenient as it could be 
(compare with  fortune()).

3- Once stored in a R-like data format, the FAQ could be straight-forwardly 
converted into a wide variety of output formats, including the original html 
page (thus made easier to maintain, perhaps).

4- Extend and generalise the fortune package to similar kinds of problems. 

In practical terms, I can imagine the following distinct steps,

- check the FAQ license, and whether we can borrow its content

- use some kind of html parsing package (XML?, i forget)

- clean up the data and store it as a data.frame or higher class

- modify / generalise the fortune functions to deal with the different fields 
and categories

- write output formatting functions

et voilà!

Comments, contributions, etc. welcome

Regards,

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

2010-08-10 Thread Henrique Dallazuanna
Try this:

library(RMySQL)
#conn - dbConnect(...)
mysqlEscapeStrings(conn, tes't)

On Tue, Aug 10, 2010 at 3:02 AM, Orvalho Augusto orvaq...@gmail.com wrote:

 Hello guys! May be I am lazy but

 I need to replace a character like \ or ' or to escape them in a character
 vector to write a SQL statement.

 How can I do that?

 Caveman

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




-- 
Henrique Dallazuanna
Curitiba-Paraná-Brasil
25° 25' 40 S 49° 16' 22 O

[[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] one (small) sample wilcox.test confidence intervals

2010-08-10 Thread peter dalgaard

On Aug 10, 2010, at 1:30 PM, Panos Hadjinicolaou wrote:

 My questions (finally!) are:
 
 1.  Why the above warning for conf.lev = 0.99 does not appear for 0.93   
 conf.lev  0.98 although it produces the same summary?
 
 2. For  conf.lev = 0.95, is there anything else I can do in order to obtain  
 confidence intervals other than the max. and min. values of my sample  or I 
 am limited from my sample's size ?
 
 Thanks for your patience in reading this,
 
 Panos


It is as it should be. 

I think it is instructive to look at explicitly shifted samples, e.g.

 wilcox.test(sample-1.369)

Wilcoxon signed rank test

data:  sample - 1.369 
V = 1, p-value = 0.0625
alternative hypothesis: true location is not equal to 0 

 wilcox.test(sample-1.371)

Wilcoxon signed rank test

data:  sample - 1.371 
V = 0, p-value = 0.03125
alternative hypothesis: true location is not equal to 0 

Notice how the p-value jumps as the shift crosses 1.37. You can shift the 
distribution by 1.36 to the left and have nonsignificant test that the 
center is at zero. However if you shift by more than 1.37, then you do get 
significance. This is true for all significance levels between 0.03125 and 
0.0625 (and 0.03125 == 1/32, the probability that all ranks have the same 
sign). 

The above explains almost everything if you think a little about the 
definitions. The only slightly puzzling thing is why confidence levels larger 
than 1-0.03125 are considered achievable. The actual code has

if (achieved.alpha - alpha  alpha/2) {
  warning(Requested conf.level not achievable)
  conf.level - 1 - signif(achieved.alpha, 2)
}

so I have to assume that the author has considered this with some care.


-- 
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] R support for 64 bit integers

2010-08-10 Thread David Winsemius


On Aug 9, 2010, at 2:45 PM, Theo Tannen wrote:

Are integers strictly a signed 32 bit number on R even if I am  
running a 64

bit version of R on a x86_64 bit machine?

I ask because I have integers stored in a hdf5 file where some of  
the data
is 64 bit integers. When I read that into R using the hdf5 library  
it seems

any integer greater than 2**31 returns NA.


That's the limit. It's hard coded and not affected by the memory  
pointer size.




Any solutions?


I have heard of packages that handle big numbers. A bit of searching  
produces suggestions to look at gmp on CRAN and Rmpfr on R-Forge.


--
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] p-values with pvclust

2010-08-10 Thread syrvn

Hi,


if you look at the first image (Image1)  you see that there are 2 main
clusters 7 and 8
I wanted to use pvclust to calculate a p-value whether these clusters are
due to chance
or statistically significant. Unfortunately pvclust does not provide a
p-value for the first
brunch (7 and 8).

So I added a row to my matrix which is very different to the rest of the
data to create an additional
brunch. See image here 
http://r.789695.n4.nabble.com/file/n2319732/Image2.png . I finally got my
p-value for the brunch (7 and 8) which is 98 (9).

I was happy to see that the p-value was significant until I realised that if
I add an additional brunch which
is not that different from the rest but still cluster in a sperate cluster
(see image here  http://r.789695.n4.nabble.com/file/n2319732/Image3.png )
the p-value is changing and not significant any longer (84).



I was wondering why this happens because I thought that for each brunch the
p-value is calculated independently?

Does anybody know how to get a correct p-value for the first brunch (7 and
8) maybe without adding an additional brunch?

Best regards
syrvn
-- 
View this message in context: 
http://r.789695.n4.nabble.com/p-values-with-pvclust-tp2319732p2319732.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] p-values with pvclust

2010-08-10 Thread syrvn

Hi,


if you look at the first image (Image1)  you see that there are 2 main
clusters 7 and 8
I wanted to use pvclust to calculate a p-value whether these clusters are
due to chance
or statistically significant. Unfortunately pvclust does not provide a
p-value for the first
brunch (7 and 8).

So I added a row to my matrix which is very different to the rest of the
data to create an additional
brunch. See image 2. I finally got my p-value for the brunch (7 and 8) which
is 98 (9).

I was happy to see that the p-value was significant until I realised that if
I add an additional brunch which
is not that different from the rest but still cluster in a sperate cluster
(see image 3) the p-value is changing and not significant any longer (84).

http://r.789695.n4.nabble.com/file/n2319739/ImageNew2.png 

I was wondering why this happens because I thought that for each brunch the
p-value is calculated independently?

Does anybody know how to get a correct p-value for the first brunch (7 and
8) maybe without adding an additional brunch?

Best regards
syrvn
-- 
View this message in context: 
http://r.789695.n4.nabble.com/p-values-with-pvclust-tp2319739p2319739.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] Function to Define a Function

2010-08-10 Thread Derek Ogle
Gabor ... that worked perfectly.  Thank you.

 -Original Message-
 From: Gabor Grothendieck [mailto:ggrothendi...@gmail.com]
 Sent: Monday, August 09, 2010 10:20 PM
 To: Derek Ogle
 Cc: R (r-help@R-project.org)
 Subject: Re: [R] Function to Define a Function
 
 On Mon, Aug 9, 2010 at 9:31 PM, Derek Ogle do...@northland.edu wrote:
  I am trying to define a general R function that has a function as the
 output that depends on the user's input arguments (this may make more
 sense by looking at the toy example below).  My real use for this type
 of code is to allow a user to choose from many parameterizations of the
 same general model.
 
  My issue is that when I compile a package with this type of code in
 it I get a __warning__ that multiple local function definitions for
 'm' with different formal arguments.  While this is not a deadly
 error I would like to avoid the warning if possible.  Can someone
 provide some guidance?  Thank you in advance for any help you can
 offer.
 
  For what it is worth ... I am working on a Windows XP machine with R
 2.11.1.
 
 
 
 
  ## A function that allows the user to create a new function that
 depends on their
  ##   choice in the type argument.  As a simple example, if the user
 chooses one
  ##   then the output function is exponential growth, if the user
 choses two then
  ##   thhe output function is logistic growth.
 
  mdlChooser - function(type=c(one,two)) {
   type - match.arg(type)
   switch(type,
     one={ m - function(x,N0,r) N0*exp(x*r) },
     two={ m - function(x,N0,r,K) (N0*K)/(N0+(K-N0)*exp(-x*r)) },
   )
   m
  }
 
  ## define time steps
  t - 0:10
 
  ## create a function -- junk1 -- that produces exponential growth
  junk1 - mdlChooser(one)
  junk1
  res1 - junk1(t,500,0.2)
  res1
 
  ## create a function -- junk2 -- that produces logistic growth
  junk2 - mdlChooser(two)
  junk2
  res2 - junk2(t,500,0.2,1000)
  res2
 
 
 
 Try this:
 
 mdlChooser - function(type = c(one, two)) {
one - function(x,N0,r) N0*exp(x*r)
two - function(x,N0,r,K) (N0*K)/(N0+(K-N0)*exp(-x*r))
type - match.arg(type)
get(type)
 }

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


Re: [R] optimization subject to constraints

2010-08-10 Thread Gildas Mazo
Thanks, but I still cannot get to solve my problem: consider this simple
example:



f - function(x){
  return(x[1]+x[2])
} # objective function

g - function(x){
  return(x[1]^2+x[2]^2)
} # constraint

#

I wanna Maximize f(x) subject to g(x) = 1. By hand the solution is
(1/sqrt(2), 1/sqrt(2), sqrt(2)). This is to maximizing a linear function
subject to a nonlinear equality constraint.  I didn't find any suitable
function in the packages I went through.

Thanks in advance,

Gildas





Spencer Graves a écrit :
To find every help page containing the term constrained
 optimization, you can try the following:


 library(sos)
 co - findFn('constrained optimization')


   Printing this co object opens a table in a web browser with
 all matches sorted first by the package with the most matches and with
 hot links to the documentation page.


 writeFindFn2xls(co)


   This writes an excel file, with the browser table as the second
 tab and the first being a summary of the packages.  This summary table
 can be made more complete and useful using the installPackages
 function, as noted in the sos vignette.


   A shameless plug from the lead author of the  sos package.
   Spencer Graves


 On 8/9/2010 10:01 AM, Ravi Varadhan wrote:
 constrOptim can only handle linear inequality constraints.  It cannot
 handle
 equality (linear or nonlinear) as well as nonlinear inequality
 constraints.

 Ravi.

 -Original Message-
 From: r-help-boun...@r-project.org
 [mailto:r-help-boun...@r-project.org] On
 Behalf Of Dwayne Blind
 Sent: Monday, August 09, 2010 12:56 PM
 To: Gildas Mazo
 Cc: r-help@r-project.org
 Subject: Re: [R] optimization subject to constraints

 Hi !

 Why not constrOptim ?

 Dwayne

 2010/8/9 Gildas Mazogildas.m...@curie.fr

 Dear R users,

 I'm looking for tools to perform optimization subject to constraints,
 both linear and non-linear. I don't mind which algorithm may be
 used, my
 primary aim is to get something general and easy-to-use to study
 simples
 examples.

 Thanks for helping,

 Gildas

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

 http://www.R-project.org/posting-guide.htmlhttp://www.r-project.org/posting

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

 [[alternative HTML version deleted]]

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

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


__
R-help@r-project.org mailing list
https://stat.ethz.ch/mailman/listinfo/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] Fwd: List of lists ?

2010-08-10 Thread Carlos Petti
-- Forwarded message --
From: Carlos Petti carlos.pe...@gmail.com
Date: 2010/8/10
Subject: Re: [R] List of lists ?
To: David Winsemius dwinsem...@comcast.net


Thanks for answer.

I read the error messages but I did not find the solution :-(

Your solution works.
But, a new problem remains because I want
to use the list of lists as follows :

x - list(list())

x[[2]][[1]] - c(1, 2, 3)
x[[2]][[2]] - c(3, 2, 1)

Thanks in advance,
Carlos

2010/8/9 David Winsemius dwinsem...@comcast.net:

 On Aug 9, 2010, at 12:57 PM, Carlos Petti wrote:

 Dear list,

 I have to use a list of lists containing vectors.

 For instance :

 [[1]]
 [[1]][[1]]
 [1] 1 2 3

 [[1]][[2]]
 [1] 3 2 1

 I want to attribute vectors to the main list

 without use of an intermediate list,

 but it does not work :

 More specifically it produces an error that has information in it.
 x[[1]][[1]] - c(1, 2, 3)
 Error in `*tmp*`[[1]] : subscript out of bounds


 x - list()
 x[[1]][[1]] - c(1, 2, 3)
 x[[1]][[2]] - c(3, 2, 1)

 So thinking perhaps we just needed another level of subscripting available
 I tried:

 x - list(list())
 x[[1]][[1]] - c(1, 2, 3)
 x[[1]][[2]] - c(3, 2, 1)
 x
 [[1]]
 [[1]][[1]]
 [1] 1 2 3

 [[1]][[2]]
 [1] 3 2 1

 Success. Moral: Read the error messages for meaning or at least clues.
 (Further testing showed that almost anything inside the original list()
 call, even NULL,  would have created enough structure for the interpreter to
 work with.



 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] Fwd: List of lists ?

2010-08-10 Thread Carlos Petti
-- Forwarded message --
From: Carlos Petti carlos.pe...@gmail.com
Date: 2010/8/10
Subject: Re: [R] List of lists ?
To: David Winsemius dwinsem...@comcast.net


Perhaps a solution :

x - list()
x[[2]] - list()

x[[2]][[1]] - c(1, 2, 3)
x[[2]][[2]] - c(3, 2, 1)

2010/8/10 Carlos Petti carlos.pe...@gmail.com:
 Thanks for answer.

 I read the error messages but I did not find the solution :-(

 Your solution works.
 But, a new problem remains because I want
 to use the list of lists as follows :

 x - list(list())

 x[[2]][[1]] - c(1, 2, 3)
 x[[2]][[2]] - c(3, 2, 1)

 Thanks in advance,
 Carlos

 2010/8/9 David Winsemius dwinsem...@comcast.net:

 On Aug 9, 2010, at 12:57 PM, Carlos Petti wrote:

 Dear list,

 I have to use a list of lists containing vectors.

 For instance :

 [[1]]
 [[1]][[1]]
 [1] 1 2 3

 [[1]][[2]]
 [1] 3 2 1

 I want to attribute vectors to the main list

 without use of an intermediate list,

 but it does not work :

 More specifically it produces an error that has information in it.
 x[[1]][[1]] - c(1, 2, 3)
 Error in `*tmp*`[[1]] : subscript out of bounds


 x - list()
 x[[1]][[1]] - c(1, 2, 3)
 x[[1]][[2]] - c(3, 2, 1)

 So thinking perhaps we just needed another level of subscripting available
 I tried:

 x - list(list())
 x[[1]][[1]] - c(1, 2, 3)
 x[[1]][[2]] - c(3, 2, 1)
 x
 [[1]]
 [[1]][[1]]
 [1] 1 2 3

 [[1]][[2]]
 [1] 3 2 1

 Success. Moral: Read the error messages for meaning or at least clues.
 (Further testing showed that almost anything inside the original list()
 call, even NULL,  would have created enough structure for the interpreter to
 work with.



 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] optimization subject to constraints

2010-08-10 Thread Matthias Gondan

 try this (package Rsolnp)

library(Rsolnp)

g- function(x)
{
  return(x[1]^2+x[2]^2)
} # constraint

f- function(x)
{
  return(x[1]+x[2])
} # objective function

x0 = c(1, 1)

solnp(x0, fun=f, eqfun=g, eqB=c(1))



Am 10.08.2010 14:59, schrieb Gildas Mazo:

Thanks, but I still cannot get to solve my problem: consider this simple
example:



f- function(x){
   return(x[1]+x[2])
} # objective function

g- function(x){
   return(x[1]^2+x[2]^2)
} # constraint

#

I wanna Maximize f(x) subject to g(x) = 1. By hand the solution is
(1/sqrt(2), 1/sqrt(2), sqrt(2)). This is to maximizing a linear function
subject to a nonlinear equality constraint.  I didn't find any suitable
function in the packages I went through.

Thanks in advance,

Gildas





Spencer Graves a écrit :

To find every help page containing the term constrained
optimization, you can try the following:


library(sos)
co- findFn('constrained optimization')


   Printing this co object opens a table in a web browser with
all matches sorted first by the package with the most matches and with
hot links to the documentation page.


writeFindFn2xls(co)


   This writes an excel file, with the browser table as the second
tab and the first being a summary of the packages.  This summary table
can be made more complete and useful using the installPackages
function, as noted in the sos vignette.


   A shameless plug from the lead author of the  sos package.
   Spencer Graves


On 8/9/2010 10:01 AM, Ravi Varadhan wrote:

constrOptim can only handle linear inequality constraints.  It cannot
handle
equality (linear or nonlinear) as well as nonlinear inequality
constraints.

Ravi.

-Original Message-
From: r-help-boun...@r-project.org
[mailto:r-help-boun...@r-project.org] On
Behalf Of Dwayne Blind
Sent: Monday, August 09, 2010 12:56 PM
To: Gildas Mazo
Cc: r-help@r-project.org
Subject: Re: [R] optimization subject to constraints

Hi !

Why not constrOptim ?

Dwayne

2010/8/9 Gildas Mazogildas.m...@curie.fr


Dear R users,

I'm looking for tools to perform optimization subject to constraints,
both linear and non-linear. I don't mind which algorithm may be
used, my
primary aim is to get something general and easy-to-use to study
simples
examples.

Thanks for helping,

Gildas

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


http://www.R-project.org/posting-guide.htmlhttp://www.r-project.org/posting

-guide.html

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


 [[alternative HTML version deleted]]

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

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




__
R-help@r-project.org mailing list
https://stat.ethz.ch/mailman/listinfo/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] grep problem decimal points looping

2010-08-10 Thread RCulloch

Hi R Users, 

I have been trying to work out how to rename column names using grep,
basically I have generated these column names using tapply:

  [1] NAME  X1.1  X2.1  X3.1  X4.1  X5.1  X6.1  X7.1  X8.1 
 [10] X1.2  X2.2  X3.2  X4.2  X5.2  X6.2  X7.2  X8.2  X1.3 
 [19] X2.3  X3.3  X4.3  X5.3  X6.3  X7.3  X8.3  X1.5  X2.5 
 [28] X3.5  X4.5  X5.5  X6.5  X7.5  X8.5  X1.6  X2.6  X3.6 
 [37] X4.6  X5.6  X6.6  X7.6  X8.6  X1.8  X2.8  X3.8  X4.8 
 [46] X5.8  X6.8  X7.8  X8.8  X1.9  X2.9  X3.9  X4.9  X5.9 
 [55] X6.9  X7.9  X8.9  X1.10 X2.10 X3.10 X4.10 X5.10
X6.10
 [64] X7.10 X8.10 X1.12 X2.12 X3.12 X4.12 X5.12 X6.12
X7.12
 [73] X8.12 X1.13 X2.13 X3.13 X4.13 X5.13 X6.13 X7.13
X8.13
 [82] X1.14 X2.14 X3.14 X4.14 X5.14 X6.14 X7.14 X8.14
X1.15
 [91] X2.15 X3.15 X4.15 X5.15 X6.15 X7.15 X8.15 X1.16
X2.16
[100] X3.16 X4.16 X5.16 X6.16 X7.16 X8.16 X1.17 X2.17
X3.17
[109] X4.17 X5.17 X6.17 X7.17 X8.17 X1.18 X2.18 X3.18
X4.18
[118] X5.18 X6.18 X7.18 X8.18 X1.19 X2.19 X3.19 X4.19
X5.19
[127] X6.19 X7.19 X8.19 X1.20 X2.20 X3.20 X4.20 X5.20
X6.20
[136] X7.20 X8.20 X1.21 X2.21 X3.21 X4.21 X5.21 X6.21
X7.21
[145] X8.21 X1.22 X2.22 X3.22 X4.22 X5.22 X6.22 X7.22
X8.22
[154] X1.23 X2.23 X3.23 X4.23 X5.23 X6.23 X7.23 X8.23
X1.24
[163] X2.24 X3.24 X4.24 X5.24 X6.24 X7.24 X8.24 X1.25
X2.25
[172] X3.25 X4.25 X5.25 X6.25 X7.25 X8.25 X1.26 X2.26
X3.26
[181] X4.26 X5.26 X6.26 X7.26 X8.26 X1.27 X2.27 X3.27
X4.27
[190] X5.27 X6.27 X7.27 X8.27 X1.28 X2.28 X3.28 X4.28
X5.28
[199] X6.28 X7.28 X8.28 X1.29 X2.29 X3.29 X4.29 X5.29
X6.29
[208] X7.29 X8.29 X1.30 X2.30 X3.30 X4.30 X5.30 X6.30
X7.30
[217] X8.30 X1.31 X2.31 X3.31 X4.31 X5.31 X6.31 X7.31
X8.31
[226] X1.32 X2.32 X3.32 X4.32 X5.32 X6.32 X7.32 X8.32
X1.33
[235] X2.33 X3.33 X4.33 X5.33 X6.33 X7.33 X8.33

What the names mean are behaviour.day the X is not important to the data, it
is the numbers I am trying to select on. 

So I want to split the data by day i.e. selecting for the number after the
decimal. 

I am using this code (where scananal is the data) with out looping so the
number following the decimal I change manually (NB the data have been
changed to character):

DAY - grep((X[[:digit:]]+).3,colnames(scananal))

However, this will select for day 3, 30, 31, 32, etc I have tried to use
fixed = TRUE, but that just returns integer(0). But if I use 30, it will
select only 30. Not sure what I'm doing wrong here, and I assumed that fixed
= T would fix this, but doesn't. 

I have tried to loop this too, but with no luck, so if anyone can point me
in the right direction about how to loop using grep I would be most
grateful!

The main problem I have is where to put the loop, for example:

for(i in 1:33){
print(i)
DAY[[i]] - grep((X[[:digit:]]+).[[i]],colnames(scananal))
}


which doesn't work, and no doubt there are obvious reasons for this! Any
help would be much appreciated,

All the best,

Ross






-- 
View this message in context: 
http://r.789695.n4.nabble.com/grep-problem-decimal-points-looping-tp2319773p2319773.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] [Fwd: Re: optimization subject to constraints]

2010-08-10 Thread Gildas Mazo

---BeginMessage---
Danke schön Matthias.

 I had naively started with x0 = c(0,0) and I got a Redundant
constraints were found error. What's the problem with (0,0) ?







Matthias Gondan a écrit :
  try this (package Rsolnp)

 library(Rsolnp)

 g- function(x)
 {
   return(x[1]^2+x[2]^2)
 } # constraint

 f- function(x)
 {
   return(x[1]+x[2])
 } # objective function

 x0 = c(1, 1)

 solnp(x0, fun=f, eqfun=g, eqB=c(1))



 Am 10.08.2010 14:59, schrieb Gildas Mazo:
 Thanks, but I still cannot get to solve my problem: consider this simple
 example:

 

 f- function(x){
return(x[1]+x[2])
 } # objective function

 g- function(x){
return(x[1]^2+x[2]^2)
 } # constraint

 #

 I wanna Maximize f(x) subject to g(x) = 1. By hand the solution is
 (1/sqrt(2), 1/sqrt(2), sqrt(2)). This is to maximizing a linear function
 subject to a nonlinear equality constraint.  I didn't find any suitable
 function in the packages I went through.

 Thanks in advance,

 Gildas





 Spencer Graves a écrit :
 To find every help page containing the term constrained
 optimization, you can try the following:


 library(sos)
 co- findFn('constrained optimization')


Printing this co object opens a table in a web browser with
 all matches sorted first by the package with the most matches and with
 hot links to the documentation page.


 writeFindFn2xls(co)


This writes an excel file, with the browser table as the second
 tab and the first being a summary of the packages.  This summary table
 can be made more complete and useful using the installPackages
 function, as noted in the sos vignette.


A shameless plug from the lead author of the  sos package.
Spencer Graves


 On 8/9/2010 10:01 AM, Ravi Varadhan wrote:
 constrOptim can only handle linear inequality constraints.  It cannot
 handle
 equality (linear or nonlinear) as well as nonlinear inequality
 constraints.

 Ravi.

 -Original Message-
 From: r-help-boun...@r-project.org
 [mailto:r-help-boun...@r-project.org] On
 Behalf Of Dwayne Blind
 Sent: Monday, August 09, 2010 12:56 PM
 To: Gildas Mazo
 Cc: r-help@r-project.org
 Subject: Re: [R] optimization subject to constraints

 Hi !

 Why not constrOptim ?

 Dwayne

 2010/8/9 Gildas Mazogildas.m...@curie.fr

 Dear R users,

 I'm looking for tools to perform optimization subject to constraints,
 both linear and non-linear. I don't mind which algorithm may be
 used, my
 primary aim is to get something general and easy-to-use to study
 simples
 examples.

 Thanks for helping,

 Gildas

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

 http://www.R-project.org/posting-guide.htmlhttp://www.r-project.org/posting


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

  [[alternative HTML version deleted]]

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

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


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




---End Message---
__
R-help@r-project.org mailing list
https://stat.ethz.ch/mailman/listinfo/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] grep problem decimal points looping

2010-08-10 Thread David Winsemius


On Aug 10, 2010, at 9:51 AM, David Winsemius wrote:



On Aug 10, 2010, at 9:17 AM, RCulloch wrote:



Hi R Users,

I have been trying to work out how to rename column names using grep,
basically I have generated these column names using tapply:

[1] NAME  X1.1  X2.1  X3.1  X4.1  X5.1  X6.1  X7.1   
X8.1
[10] X1.2  X2.2  X3.2  X4.2  X5.2  X6.2  X7.2   
X8.2  X1.3
[19] X2.3  X3.3  X4.3  X5.3  X6.3  X7.3  X8.3   
X1.5  X2.5
[28] X3.5  X4.5  X5.5  X6.5  X7.5  X8.5  X1.6   
X2.6  X3.6
[37] X4.6  X5.6  X6.6  X7.6  X8.6  X1.8  X2.8   
X3.8  X4.8
[46] X5.8  X6.8  X7.8  X8.8  X1.9  X2.9  X3.9   
X4.9  X5.9

[55] X6.9  X7.9  X8.9  X1.10 X2.10 X3.10 X4.10 X5.10
X6.10
[64] X7.10 X8.10 X1.12 X2.12 X3.12 X4.12 X5.12 X6.12
X7.12
[73] X8.12 X1.13 X2.13 X3.13 X4.13 X5.13 X6.13 X7.13
X8.13
[82] X1.14 X2.14 X3.14 X4.14 X5.14 X6.14 X7.14 X8.14
X1.15
[91] X2.15 X3.15 X4.15 X5.15 X6.15 X7.15 X8.15 X1.16
X2.16
[100] X3.16 X4.16 X5.16 X6.16 X7.16 X8.16 X1.17 X2.17
X3.17
[109] X4.17 X5.17 X6.17 X7.17 X8.17 X1.18 X2.18 X3.18
X4.18
[118] X5.18 X6.18 X7.18 X8.18 X1.19 X2.19 X3.19 X4.19
X5.19
[127] X6.19 X7.19 X8.19 X1.20 X2.20 X3.20 X4.20 X5.20
X6.20
[136] X7.20 X8.20 X1.21 X2.21 X3.21 X4.21 X5.21 X6.21
X7.21
[145] X8.21 X1.22 X2.22 X3.22 X4.22 X5.22 X6.22 X7.22
X8.22
[154] X1.23 X2.23 X3.23 X4.23 X5.23 X6.23 X7.23 X8.23
X1.24
[163] X2.24 X3.24 X4.24 X5.24 X6.24 X7.24 X8.24 X1.25
X2.25
[172] X3.25 X4.25 X5.25 X6.25 X7.25 X8.25 X1.26 X2.26
X3.26
[181] X4.26 X5.26 X6.26 X7.26 X8.26 X1.27 X2.27 X3.27
X4.27
[190] X5.27 X6.27 X7.27 X8.27 X1.28 X2.28 X3.28 X4.28
X5.28
[199] X6.28 X7.28 X8.28 X1.29 X2.29 X3.29 X4.29 X5.29
X6.29
[208] X7.29 X8.29 X1.30 X2.30 X3.30 X4.30 X5.30 X6.30
X7.30
[217] X8.30 X1.31 X2.31 X3.31 X4.31 X5.31 X6.31 X7.31
X8.31
[226] X1.32 X2.32 X3.32 X4.32 X5.32 X6.32 X7.32 X8.32
X1.33
[235] X2.33 X3.33 X4.33 X5.33 X6.33 X7.33 X8.33

What the names mean are behaviour.day the X is not important to the  
data, it

is the numbers I am trying to select on.

So I want to split the data by day i.e. selecting for the number  
after the

decimal.

I am using this code (where scananal is the data) with out looping  
so the

number following the decimal I change manually (NB the data have been
changed to character):



You need to learn the special character$ which marks the no- 
character end of string. After creating a replica of your column- 
names with scan and grep:

inp - scan(what=character)
inX - inp[grep(X, inp)]

 DAY - grep((X[[:digit:]]+).3$,inX)
 inX[DAY]
[1] X1.3 X2.3 X3.3 X4.3 X5.3 X6.3 X7.3 X8.3


DAY - grep((X[[:digit:]]+).3,colnames(scananal))

However, this will select for day 3, 30, 31, 32, etc I have tried  
to use
fixed = TRUE, but that just returns integer(0). But if I use 30, it  
will
select only 30. Not sure what I'm doing wrong here, and I assumed  
that fixed

= T would fix this, but doesn't.

I have tried to loop this too, but with no luck, so if anyone can  
point me

in the right direction about how to loop using grep I would be most
grateful!

The main problem I have is where to put the loop, for example:

for(i in 1:33){
print(i)
DAY[[i]] - grep((X[[:digit:]]+).[[i]],colnames(scananal))
}


Hit the send button a bit prematurely. I have not figured out what  
sort of process or result you hope to achieve but perhaps showing how  
to improve the use of grep inside a loop will help:


for(i in 1:33){
patt - paste((X[[:digit:]]+)., i, $, sep=);
if (length(inX[grep(patt,inX)]) 0 ) { DAY[i] -  
list( grep(patt,inX) ) }

}

 DAY[1:5]
[[1]]
[1] 1 2 3 4 5 6 7 8

[[2]]
[1]  9 10 11 12 13 14 15 16

[[3]]
[1] 17 18 19 20 21 22 23 24

[[4]]
NULL

[[5]]
[1] 25 26 27 28 29 30 31 32


This first constructs a pattern. It also needs to test if there are  
any results at each iteration because there are no days==4. Unless  
you supply the result of grep() as a list it only records the first  
day in a series, so  it only gives you the starting locations. Maybe  
if you clarified what you will be doing with this DAY construct, there  
might be more of a target to shoot for. You could use lapply on those  
column numbers at the moment.



--


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] memory use without running gc()

2010-08-10 Thread Johann Hibschman
Allan Engelhardt all...@cybaea.com writes:

 ### Method 2
 ## Setup
 file - paste(/proc, Sys.getpid(), stat, sep = /)
 what - vector(list, 44); what[[23]] - integer(0)
 ## In your logging routine
 vsz - scan(file, what = what, quiet = TRUE)[[23]]/1024
 cat(Virtual size: , vsz, \n, sep = )

[...]

 The scan method should be plenty fast.  Change as appropriate if your
 definition of memory is different from virtual size.

Thanks, that works well.  I'm on an older kernel (2.6.18), so I only
have 42 entries in /proc/pid/stat, but VSZ is still in position 23.

Looking at the proc man page also shows /proc/[pid]/statm, which
collects some of the memory information, but requires me to know what
the page size is to make sense of it.

Gegards,
Johann

__
R-help@r-project.org mailing list
https://stat.ethz.ch/mailman/listinfo/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] grep problem decimal points looping

2010-08-10 Thread Henrique Dallazuanna
Try this also:
nm - scan('clipboard', what = '')
transform(structure(do.call(rbind, strsplit(nm[-1], \\.)), .Dimnames =
list(NULL, c('V1', 'V2'))), V1 = gsub(X, , V1))

On Tue, Aug 10, 2010 at 10:17 AM, RCulloch ross.cull...@dur.ac.uk wrote:


 Hi R Users,

 I have been trying to work out how to rename column names using grep,
 basically I have generated these column names using tapply:

  [1] NAME  X1.1  X2.1  X3.1  X4.1  X5.1  X6.1  X7.1  X8.1
  [10] X1.2  X2.2  X3.2  X4.2  X5.2  X6.2  X7.2  X8.2
  X1.3
  [19] X2.3  X3.3  X4.3  X5.3  X6.3  X7.3  X8.3  X1.5
  X2.5
  [28] X3.5  X4.5  X5.5  X6.5  X7.5  X8.5  X1.6  X2.6
  X3.6
  [37] X4.6  X5.6  X6.6  X7.6  X8.6  X1.8  X2.8  X3.8
  X4.8
  [46] X5.8  X6.8  X7.8  X8.8  X1.9  X2.9  X3.9  X4.9
  X5.9
  [55] X6.9  X7.9  X8.9  X1.10 X2.10 X3.10 X4.10 X5.10
 X6.10
  [64] X7.10 X8.10 X1.12 X2.12 X3.12 X4.12 X5.12 X6.12
 X7.12
  [73] X8.12 X1.13 X2.13 X3.13 X4.13 X5.13 X6.13 X7.13
 X8.13
  [82] X1.14 X2.14 X3.14 X4.14 X5.14 X6.14 X7.14 X8.14
 X1.15
  [91] X2.15 X3.15 X4.15 X5.15 X6.15 X7.15 X8.15 X1.16
 X2.16
 [100] X3.16 X4.16 X5.16 X6.16 X7.16 X8.16 X1.17 X2.17
 X3.17
 [109] X4.17 X5.17 X6.17 X7.17 X8.17 X1.18 X2.18 X3.18
 X4.18
 [118] X5.18 X6.18 X7.18 X8.18 X1.19 X2.19 X3.19 X4.19
 X5.19
 [127] X6.19 X7.19 X8.19 X1.20 X2.20 X3.20 X4.20 X5.20
 X6.20
 [136] X7.20 X8.20 X1.21 X2.21 X3.21 X4.21 X5.21 X6.21
 X7.21
 [145] X8.21 X1.22 X2.22 X3.22 X4.22 X5.22 X6.22 X7.22
 X8.22
 [154] X1.23 X2.23 X3.23 X4.23 X5.23 X6.23 X7.23 X8.23
 X1.24
 [163] X2.24 X3.24 X4.24 X5.24 X6.24 X7.24 X8.24 X1.25
 X2.25
 [172] X3.25 X4.25 X5.25 X6.25 X7.25 X8.25 X1.26 X2.26
 X3.26
 [181] X4.26 X5.26 X6.26 X7.26 X8.26 X1.27 X2.27 X3.27
 X4.27
 [190] X5.27 X6.27 X7.27 X8.27 X1.28 X2.28 X3.28 X4.28
 X5.28
 [199] X6.28 X7.28 X8.28 X1.29 X2.29 X3.29 X4.29 X5.29
 X6.29
 [208] X7.29 X8.29 X1.30 X2.30 X3.30 X4.30 X5.30 X6.30
 X7.30
 [217] X8.30 X1.31 X2.31 X3.31 X4.31 X5.31 X6.31 X7.31
 X8.31
 [226] X1.32 X2.32 X3.32 X4.32 X5.32 X6.32 X7.32 X8.32
 X1.33
 [235] X2.33 X3.33 X4.33 X5.33 X6.33 X7.33 X8.33

 What the names mean are behaviour.day the X is not important to the data,
 it
 is the numbers I am trying to select on.

 So I want to split the data by day i.e. selecting for the number after the
 decimal.

 I am using this code (where scananal is the data) with out looping so the
 number following the decimal I change manually (NB the data have been
 changed to character):

 DAY - grep((X[[:digit:]]+).3,colnames(scananal))

 However, this will select for day 3, 30, 31, 32, etc I have tried to use
 fixed = TRUE, but that just returns integer(0). But if I use 30, it will
 select only 30. Not sure what I'm doing wrong here, and I assumed that
 fixed
 = T would fix this, but doesn't.

 I have tried to loop this too, but with no luck, so if anyone can point me
 in the right direction about how to loop using grep I would be most
 grateful!

 The main problem I have is where to put the loop, for example:

 for(i in 1:33){
 print(i)
 DAY[[i]] - grep((X[[:digit:]]+).[[i]],colnames(scananal))
 }


 which doesn't work, and no doubt there are obvious reasons for this! Any
 help would be much appreciated,

 All the best,

 Ross






 --
 View this message in context:
 http://r.789695.n4.nabble.com/grep-problem-decimal-points-looping-tp2319773p2319773.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.




-- 
Henrique Dallazuanna
Curitiba-Paraná-Brasil
25° 25' 40 S 49° 16' 22 O

[[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 build R on Mac to keep packages running?

2010-08-10 Thread Karsten Wolf
Hi there,
I am trying to install RApache on my Mac
(see 
http://worldofrcraft.blogspot.com/2010/08/installing-rapache-on-mac-os-x-snow.html).

I needed to build R with --enable-R-shlib option, so very naively did the 
following

./configure --enable-R-shlib
make
sudo make install

RApache runs like a charm now, but when I want to start my R.app, it does not 
start. Only my R64.app is starting, but not all packages are running with 
R64.app.

Where can I find the magic configure-charms used to configure and build R for 
the Mac platform?

Yours,
Karsten

===
Karsten D. Wolf
http://www.ifeb.uni-bremen.de/wolf

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

2010-08-10 Thread TGS
I want to take this numerical methods course where the text is 
http://www.amazon.com/Numerical-Methods-J-Douglas-Faires/dp/0534407617 . The 
instructor recommends MATLAB, but states Fortran, C, Mathematica, or Maple will 
also do the job.

Will R do the job as well?

If not, where do you think it will be lacking in the context of this 
book/course.
__
R-help@r-project.org mailing list
https://stat.ethz.ch/mailman/listinfo/r-help
PLEASE do read the posting guide http://www.R-project.org/posting-guide.html
and provide commented, minimal, self-contained, reproducible code.


[R] Plotting confidence bands around regression line

2010-08-10 Thread Michal Figurski

Dear R-helpers and graphics gurus,

I have two problems with plotting confidence bands:

1. First is relatively simple. I am using the Passing-Bablok procedure 
to obtain unbiased regression coefficients. This procedure yields the 
a  b coefficient values along with their confidence intervals. I 
then plot the raw data with the regression line, but I would like to add 
the confidence band for the line... and I can't figure out how to do it.


In other words, given:

   Estimate  5%CI 95%CI
Intercept -4.305562 -9.931152 -1.381792
Slope  1.257318  1.053025  1.678516

How to plot the regression line with confidence band?

2. Second problem is plotting confidence bands along fitted nls 
regression line. I tried predict(nls.object, int='c') - but doesn't 
work. Later I figured in the documentation that the 'int' parameter is 
currently ignored. I guess this means it's not a trivial thing to do. 
Does anyone have a suggestion on how to obtain confidence predictions 
for such a model?


Please cc my email address when you reply. Thanks and best regards,

--
Michal J. Figurski, PhD
HUP, Pathology  Laboratory Medicine
Biomarker Research Laboratory
3400 Spruce St. 7 Maloney
Philadelphia, PA 19104
tel. (215) 662-3413

__
R-help@r-project.org mailing list
https://stat.ethz.ch/mailman/listinfo/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] [Fwd: Re: optimization subject to constraints]

2010-08-10 Thread Ravi Varadhan
I think the problem is because the the Hessian of the augmented Lagrangian iis 
singular at c(0,0). 

Try this:

require(alabama)

heq - function(x) {
x[1]^2+x[2]^2 - 1
}

  constrOptim.nl(par=c(0,0), fn=f, heq=heq, control.outer=list(trace=FALSE))
$par
[1] -0.7071067 -0.7071067

$value
[1] -1.414213

$iterations
[1] 10

$lambda
[1] -0.7068717

$penalty
[1] -6.496021e-08

$counts
function gradient 
 100   30 


Ravi.



Ravi Varadhan, Ph.D.
Assistant Professor,
Division of Geriatric Medicine and Gerontology
School of Medicine
Johns Hopkins University

Ph. (410) 502-2619
email: rvarad...@jhmi.edu


- Original Message -
From: Gildas Mazo gildas.m...@curie.fr
Date: Tuesday, August 10, 2010 10:11 am
Subject: [R] [Fwd: Re:  optimization subject to constraints]
To: r-help@r-project.org


 
 - Original Message -

  From Gildas Mazo gildas.m...@curie.fr

  Date Tue, 10 Aug 2010 15:49:19 +0200

  To Matthias Gondan matthias-gon...@gmx.de
 Subject Re: [R] optimization subject to constraints
 Danke schön Matthias.
  
   I had naively started with x0 = c(0,0) and I got a Redundant
  constraints were found error. What's the problem with (0,0) ?
  
  
  
  
  
  
  
  Matthias Gondan a écrit :
try this (package Rsolnp)
  
   library(Rsolnp)
  
   g- function(x)
   {
 return(x[1]^2+x[2]^2)
   } # constraint
  
   f- function(x)
   {
 return(x[1]+x[2])
   } # objective function
  
   x0 = c(1, 1)
  
   solnp(x0, fun=f, eqfun=g, eqB=c(1))
  
  
  
   Am 10.08.2010 14:59, schrieb Gildas Mazo:
   Thanks, but I still cannot get to solve my problem: consider this 
 simple
   example:
  
   
  
   f- function(x){
  return(x[1]+x[2])
   } # objective function
  
   g- function(x){
  return(x[1]^2+x[2]^2)
   } # constraint
  
   #
  
   I wanna Maximize f(x) subject to g(x) = 1. By hand the solution is
   (1/sqrt(2), 1/sqrt(2), sqrt(2)). This is to maximizing a linear function
   subject to a nonlinear equality constraint.  I didn't find any suitable
   function in the packages I went through.
  
   Thanks in advance,
  
   Gildas
  
  
  
  
  
   Spencer Graves a écrit :
   To find every help page containing the term constrained
   optimization, you can try the following:
  
  
   library(sos)
   co- findFn('constrained optimization')
  
  
  Printing this co object opens a table in a web browser 
 with
   all matches sorted first by the package with the most matches and 
 with
   hot links to the documentation page.
  
  
   writeFindFn2xls(co)
  
  
  This writes an excel file, with the browser table as the second
   tab and the first being a summary of the packages.  This summary 
 table
   can be made more complete and useful using the installPackages
   function, as noted in the sos vignette.
  
  
  A shameless plug from the lead author of the  sos package.
  Spencer Graves
  
  
   On 8/9/2010 10:01 AM, Ravi Varadhan wrote:
   constrOptim can only handle linear inequality constraints.  It cannot
   handle
   equality (linear or nonlinear) as well as nonlinear inequality
   constraints.
  
   Ravi.
  
   -Original Message-
   From: r-help-boun...@r-project.org
   [ On
   Behalf Of Dwayne Blind
   Sent: Monday, August 09, 2010 12:56 PM
   To: Gildas Mazo
   Cc: r-help@r-project.org
   Subject: Re: [R] optimization subject to constraints
  
   Hi !
  
   Why not constrOptim ?
  
   Dwayne
  
   2010/8/9 Gildas Mazogildas.m...@curie.fr
  
   Dear R users,
  
   I'm looking for tools to perform optimization subject to constraints,
   both linear and non-linear. I don't mind which algorithm may be
   used, my
   primary aim is to get something general and easy-to-use to study
   simples
   examples.
  
   Thanks for helping,
  
   Gildas
  
   __
   R-help@r-project.org mailing list
   
   PLEASE do read the posting guide
  
   
  
  
   -guide.html
   and provide commented, minimal, self-contained, reproducible code.
  
[[alternative HTML version deleted]]
  
   __
   R-help@r-project.org mailing list
   
   PLEASE do read the posting guide
   
   and provide commented, minimal, self-contained, reproducible code.
  
   __
   R-help@r-project.org mailing list
   
   PLEASE do read the posting guide
   
   and provide commented, minimal, self-contained, reproducible code.
  
  
   __
   R-help@r-project.org mailing list
   
   PLEASE do read the posting guide
   
   and provide commented, minimal, self-contained, reproducible code.
  
  
  
   
 __
  R-help@r-project.org mailing list
  
  PLEASE do read the posting guide 
  and provide commented, minimal, self-contained, reproducible code.


[R] influence measures for multivariate linear models

2010-08-10 Thread Michael Friendly
Barrett  Ling, JASA, 1992, v.87(417), pp184-191 define general classes 
of influence measures for multivariate
regression models, including analogs of Cook's D, Andrews  Pregibon 
COVRATIO, etc.  As in univariate
response models, these are based on leverage and residuals based on 
omitting one (or more) observations at
a time and refitting, although, in the univariate case, the computations 
can be optimized, as they are in

stats::influence() and related methods.

I'm interested in exploring the multivariate extension in R.  I tried 
the following, and was surprised to find that
R returned a result rather than an error -- presumably because mlm 
objects are not trapped before they

get to lm.influence()

 # multivariate model
 data(Rohwer, package=heplots)
 rohwer.mod - lm(cbind(SAT, PPVT, Raven) ~ n + s + ns + na + ss, 
data=Rohwer)


 names(influence(rohwer.mod))
[1] hat  coefficients sigmawt.res 
 head(influence(rohwer.mod)$coefficients, 2)

   [,1]   [,2]  [,3] [,4]  [,5]  [,6]
[1,] 2.25039  0.0254739 -0.025252 -0.06297 -0.121507  0.094355
[2,] 0.84649 -0.0062656 -0.077430  0.08345 -0.022579 -0.059480


Of course, the correct calculations would result from refitting, 
omitting each observation in turn, though doing this

directly would be horribly inefficient.
e.g, calculating B(i), deleting case i:

 coef(update(rohwer.mod, subset=1:69 !=1, data=Rohwer))
 SAT PPVT Raven
(Intercept) -2.466079 35.68664 11.510068
n1.888286  0.60949  0.075931
s   -0.034524 -0.53040  0.160328
ns  -2.739834 -0.67355  0.066392
na   2.219340  1.20481 -0.037272
ss   1.072300  0.99033  0.058509
 coef(update(rohwer.mod, subset=1:69 !=2, data=Rohwer))
 SAT PPVT  Raven
(Intercept) -1.062178 33.88199 10.8988006
n1.920026  0.59735  0.0713976
s0.017654 -0.47464  0.1774135
ns  -2.886254 -0.67905  0.0673686
na   2.120411  1.29016 -0.0077484
ss   1.226135  0.96430  0.0471764

Is there anything existing for this case that I've missed, or does 
anyone have an interest in pursuing this topic?


-Michael

--
Michael Friendly Email: friendly AT yorku DOT ca 
Professor, Psychology Dept.

York University  Voice: 416 736-5115 x66249 Fax: 416 736-5814
4700 Keele StreetWeb:   http://www.datavis.ca
Toronto, ONT  M3J 1P3 CANADA

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


Re: [R] Plotting confidence bands around regression line

2010-08-10 Thread David Winsemius


On Aug 10, 2010, at 10:56 AM, Michal Figurski wrote:


Dear R-helpers and graphics gurus,

I have two problems with plotting confidence bands:

1. First is relatively simple. I am using the Passing-Bablok  
procedure to obtain unbiased regression coefficients. This  
procedure yields the a  b coefficient values along with their  
confidence intervals. I then plot the raw data with the regression  
line, but I would like to add the confidence band for the line...  
and I can't figure out how to do it.


In other words, given:

  Estimate  5%CI 95%CI
Intercept -4.305562 -9.931152 -1.381792
Slope  1.257318  1.053025  1.678516

How to plot the regression line with confidence band?


Take a look at plotCI in either gplots or plotrix packages.

Harrell's rms/Hmisc packages are nicely integrated with lattice and  
encourage you to create effective displays of models that remove  
simplistic linearity assumptions.


--
David.



2. Second problem is plotting confidence bands along fitted nls  
regression line. I tried predict(nls.object, int='c') - but  
doesn't work. Later I figured in the documentation that the 'int'  
parameter is currently ignored. I guess this means it's not a  
trivial thing to do. Does anyone have a suggestion on how to obtain  
confidence predictions for such a model?


Please cc my email address when you reply. Thanks and best regards,

--
Michal J. Figurski, PhD
HUP, Pathology  Laboratory Medicine
Biomarker Research Laboratory
3400 Spruce St. 7 Maloney
Philadelphia, PA 19104
tel. (215) 662-3413

__
R-help@r-project.org mailing list
https://stat.ethz.ch/mailman/listinfo/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] grep problem decimal points looping

2010-08-10 Thread RCulloch

Hi David, 

Thanks very much for that reply! I might be a touch out of my comfort zone,
but I can see how the loop script works and where I went wrong, but I'm not
sure if I am asking the correct questions here, or perhaps more accurately
I'm using the wrong command for the task in question - and as you say more
info would be better! So.

I want to split the data by day to look at the proportion of time an
individual spent in each of the eight behaviours - there are 30 rows (i.e.
individuals).

So I'm going over old code trying to make it better (not that it could be
worse!), especially trying to make it more efficient!

So my old code did this (manually for each day):

##DAY1##
DAY1 -cbind(scananal$X1.1, scananal$X2.1, scananal$X3.1, scananal$X4.1,
scananal$X5.1, scananal$X6.1, scananal$X7.1, scananal$X8.1)
head(DAY1)

which would give, for example,

head(DAY1)
 [,1] [,2] [,3] [,4] [,5] [,6] [,7] [,8]
[1,]   140212203
[2,]   230010000
[3,]00000000
[4,]00000000
[5,]00000000
[6,]00000000



I'd run the following script to get the proportions then bind that together
with other data



###DAY1~~~###

## CALC NSCANS PER ID ##
n - rowSums(DAY1)

## GIVE THE DAY NUMBER TO THE DATAFILE
DAY - rep(1,30)

## CALC PROPORTION OF TIME IN EACH ACTIVITY ##
scansprop - as.data.frame(prop.table(DAY1,1))
head(scansprop)

##CALC AS ARC_SINE_TRANSFORMED###
transscan-asin(scansprop)
head (transscan)
##gives column headings##
names(transscan)

##CHECK IT ALL ADDS TO ONE!! ##
rowSums(scansprop)

##MERGES ALL THE DATA FOR THE DAY
DAY1_SUM - cbind(n,DAY,DAY1,scansprop,transscan)



Then I would merge each of the days, so this script works, but I know it is
rather a poor effort in R script to say the least!

I'm trying to work through this myself, but hit a hurdle in the first
instance!

Not sure if this is any clearer?

Cheers,

Ross

-- 
View this message in context: 
http://r.789695.n4.nabble.com/grep-problem-decimal-points-looping-tp2319773p2319941.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] Numerical Methods Course

2010-08-10 Thread Matt Shotwell
TGS,

Given that you have to pay an outrageous $155.86 for that book, it seems
reasonable to look for a free environment for numerical computing (like
R!). If your instructor says that such a variety of programming
languages would work, you could probably make a good argument to use R.
But why not just ask your instructor?

If your instructor insists on MATLAB, you could also consider using GNU
Octave, a free MATLAB clone.

-Matt

On Tue, 2010-08-10 at 10:55 -0400, TGS wrote:
 I want to take this numerical methods course where the text is 
 http://www.amazon.com/Numerical-Methods-J-Douglas-Faires/dp/0534407617 . The 
 instructor recommends MATLAB, but states Fortran, C, Mathematica, or Maple 
 will also do the job.
 
 Will R do the job as well?
 
 If not, where do you think it will be lacking in the context of this 
 book/course.
 __
 R-help@r-project.org mailing list
 https://stat.ethz.ch/mailman/listinfo/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] grep problem decimal points looping

2010-08-10 Thread David Winsemius


On Aug 10, 2010, at 9:17 AM, RCulloch wrote:



Hi R Users,

I have been trying to work out how to rename column names using grep,
basically I have generated these column names using tapply:

 [1] NAME  X1.1  X2.1  X3.1  X4.1  X5.1  X6.1  X7.1   
X8.1
[10] X1.2  X2.2  X3.2  X4.2  X5.2  X6.2  X7.2  X8.2   
X1.3
[19] X2.3  X3.3  X4.3  X5.3  X6.3  X7.3  X8.3  X1.5   
X2.5
[28] X3.5  X4.5  X5.5  X6.5  X7.5  X8.5  X1.6  X2.6   
X3.6
[37] X4.6  X5.6  X6.6  X7.6  X8.6  X1.8  X2.8  X3.8   
X4.8
[46] X5.8  X6.8  X7.8  X8.8  X1.9  X2.9  X3.9  X4.9   
X5.9

[55] X6.9  X7.9  X8.9  X1.10 X2.10 X3.10 X4.10 X5.10
X6.10
[64] X7.10 X8.10 X1.12 X2.12 X3.12 X4.12 X5.12 X6.12
X7.12
[73] X8.12 X1.13 X2.13 X3.13 X4.13 X5.13 X6.13 X7.13
X8.13
[82] X1.14 X2.14 X3.14 X4.14 X5.14 X6.14 X7.14 X8.14
X1.15
[91] X2.15 X3.15 X4.15 X5.15 X6.15 X7.15 X8.15 X1.16
X2.16
[100] X3.16 X4.16 X5.16 X6.16 X7.16 X8.16 X1.17 X2.17
X3.17
[109] X4.17 X5.17 X6.17 X7.17 X8.17 X1.18 X2.18 X3.18
X4.18
[118] X5.18 X6.18 X7.18 X8.18 X1.19 X2.19 X3.19 X4.19
X5.19
[127] X6.19 X7.19 X8.19 X1.20 X2.20 X3.20 X4.20 X5.20
X6.20
[136] X7.20 X8.20 X1.21 X2.21 X3.21 X4.21 X5.21 X6.21
X7.21
[145] X8.21 X1.22 X2.22 X3.22 X4.22 X5.22 X6.22 X7.22
X8.22
[154] X1.23 X2.23 X3.23 X4.23 X5.23 X6.23 X7.23 X8.23
X1.24
[163] X2.24 X3.24 X4.24 X5.24 X6.24 X7.24 X8.24 X1.25
X2.25
[172] X3.25 X4.25 X5.25 X6.25 X7.25 X8.25 X1.26 X2.26
X3.26
[181] X4.26 X5.26 X6.26 X7.26 X8.26 X1.27 X2.27 X3.27
X4.27
[190] X5.27 X6.27 X7.27 X8.27 X1.28 X2.28 X3.28 X4.28
X5.28
[199] X6.28 X7.28 X8.28 X1.29 X2.29 X3.29 X4.29 X5.29
X6.29
[208] X7.29 X8.29 X1.30 X2.30 X3.30 X4.30 X5.30 X6.30
X7.30
[217] X8.30 X1.31 X2.31 X3.31 X4.31 X5.31 X6.31 X7.31
X8.31
[226] X1.32 X2.32 X3.32 X4.32 X5.32 X6.32 X7.32 X8.32
X1.33
[235] X2.33 X3.33 X4.33 X5.33 X6.33 X7.33 X8.33

What the names mean are behaviour.day the X is not important to the  
data, it

is the numbers I am trying to select on.

So I want to split the data by day i.e. selecting for the number  
after the

decimal.

I am using this code (where scananal is the data) with out looping  
so the

number following the decimal I change manually (NB the data have been
changed to character):



You need to learn the special character$ which marks the no- 
character end of string. After creating a replica of your column-names  
with scan and grep:

inp - scan(what=character)
inX - inp[grep(X, inp)]

 DAY - grep((X[[:digit:]]+).3$,inX)
 inX[DAY]
[1] X1.3 X2.3 X3.3 X4.3 X5.3 X6.3 X7.3 X8.3


DAY - grep((X[[:digit:]]+).3,colnames(scananal))

However, this will select for day 3, 30, 31, 32, etc I have tried to  
use
fixed = TRUE, but that just returns integer(0). But if I use 30, it  
will
select only 30. Not sure what I'm doing wrong here, and I assumed  
that fixed

= T would fix this, but doesn't.

I have tried to loop this too, but with no luck, so if anyone can  
point me

in the right direction about how to loop using grep I would be most
grateful!

The main problem I have is where to put the loop, for example:

for(i in 1:33){
print(i)
DAY[[i]] - grep((X[[:digit:]]+).[[i]],colnames(scananal))
}


which doesn't work, and no doubt there are obvious reasons for this!  
Any

help would be much appreciated,

All the best,

Ross






--
View this message in context: 
http://r.789695.n4.nabble.com/grep-problem-decimal-points-looping-tp2319773p2319773.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] grep problem decimal points looping

2010-08-10 Thread David Winsemius


On Aug 10, 2010, at 11:14 AM, RCulloch wrote:



Hi David,

Thanks very much for that reply! I might be a touch out of my  
comfort zone,
but I can see how the loop script works and where I went wrong, but  
I'm not
sure if I am asking the correct questions here, or perhaps more  
accurately
I'm using the wrong command for the task in question - and as you  
say more

info would be better! So.

I want to split the data by day to look at the proportion of time an
individual spent in each of the eight behaviours - there are 30 rows  
(i.e.

individuals).

So I'm going over old code trying to make it better (not that it  
could be

worse!), especially trying to make it more efficient!

So my old code did this (manually for each day):

##DAY1##
DAY1 -cbind($X1.1, scananal$X2.1, scananal$X3.1, scananal$X4.1,
scananal$X5.1, scananal$X6.1, scananal$X7.1, scananal$X8.1)
head(DAY1)


From our earlier efforts:
 DAY[[1]]
[1] 1 2 3 4 5 6 7 8

If you were using the earlier results, then this could be made easier  
and more generalizable to an iterative process by:


DAY1cols - scananal[ , DAY[[1]] ]   or just ...

DAY1cols - scananal[  DAY[[1]] ]

You could replace the 1 by an i in a for loop, or create a list of  
subsets with lapply.





which would give, for example,

head(DAY1)
[,1] [,2] [,3] [,4] [,5] [,6] [,7] [,8]
[1,]   140212203
[2,]   230010000
[3,]00000000
[4,]00000000
[5,]00000000
[6,]00000000



I'd run the following script to get the proportions then bind that  
together

with other data



###DAY1~~~###

## CALC NSCANS PER ID ##
n - rowSums(DAY1)

## GIVE THE DAY NUMBER TO THE DATAFILE
DAY - rep(1,30)

## CALC PROPORTION OF TIME IN EACH ACTIVITY ##
scansprop - as.data.frame(prop.table(DAY1,1))
head(scansprop)

##CALC AS ARC_SINE_TRANSFORMED###
transscan-asin(scansprop)
head (transscan)
##gives column headings##
names(transscan)

##CHECK IT ALL ADDS TO ONE!! ##
rowSums(scansprop)

##MERGES ALL THE DATA FOR THE DAY
DAY1_SUM - cbind(n,DAY,DAY1,scansprop,transscan)



Then I would merge each of the days, so this script works, but I  
know it is

rather a poor effort in R script to say the least!


That may work perfectly well. I don't know. I didn't follow the logic  
because your reference to proportions was not made with an  
unambiguous definition of a denominator in several locations.





I'm trying to work through this myself, but hit a hurdle in the first
instance!

Not sure if this is any clearer?


Perhaps. Two options: Try to put that sequence into a function that  
will return a structure. Then test it. Then lapply it.


Or put it into sequence that makes DAY1_SUM inside a for-loop, take  
the results of for() {} on DAY[[i]]  and have it assign values to a  
structure like a list or a matrix.


--

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] Fwd: List of lists ?

2010-08-10 Thread William Dunlap
 -Original Message-
 From: r-help-boun...@r-project.org 
 [mailto:r-help-boun...@r-project.org] On Behalf Of Carlos Petti
 Sent: Tuesday, August 10, 2010 6:12 AM
 To: r-help@r-project.org
 Subject: [R] Fwd: List of lists ?
 
 -- Forwarded message --
 From: Carlos Petti carlos.pe...@gmail.com
 Date: 2010/8/10
 Subject: Re: [R] List of lists ?
 To: David Winsemius dwinsem...@comcast.net
 
 
 Thanks for answer.
 
 I read the error messages but I did not find the solution :-(
 
 Your solution works.
 But, a new problem remains because I want
 to use the list of lists as follows :
 
 x - list(list())
 
 x[[2]][[1]] - c(1, 2, 3)
 x[[2]][[2]] - c(3, 2, 1)

You need to tell it that x[[i]] will be a list
for each i.  You can do that with
   x - list()
   for(i in 1:3) {
   x[[i]] - list()
   for(j in seq_len(i)) {
   x[[i]][[j]] - i*100 + seq_len(j)
   }
   }
It might be easier to read and perhaps faster to do
   x - list()
   for(i in 1:3) {
   xi - list() # will become x[[i]]
   for(j in seq_len(i)) {
   xi[[j]] - i*100 + seq_len(j)
   }
   x[[i]] - xi
   }
If you know the ultimate length of a list, and it will
be long, it may save time to allocate the whole thing
up front with
   xlength - 3
   x - vector(list, xlength)

Bill Dunlap
Spotfire, TIBCO Software
wdunlap tibco.com  

 Thanks in advance,
 Carlos
 
 2010/8/9 David Winsemius dwinsem...@comcast.net:
 
  On Aug 9, 2010, at 12:57 PM, Carlos Petti wrote:
 
  Dear list,
 
  I have to use a list of lists containing vectors.
 
  For instance :
 
  [[1]]
  [[1]][[1]]
  [1] 1 2 3
 
  [[1]][[2]]
  [1] 3 2 1
 
  I want to attribute vectors to the main list
 
  without use of an intermediate list,
 
  but it does not work :
 
  More specifically it produces an error that has information in it.
  x[[1]][[1]] - c(1, 2, 3)
  Error in `*tmp*`[[1]] : subscript out of bounds
 
 
  x - list()
  x[[1]][[1]] - c(1, 2, 3)
  x[[1]][[2]] - c(3, 2, 1)
 
  So thinking perhaps we just needed another level of 
 subscripting available
  I tried:
 
  x - list(list())
  x[[1]][[1]] - c(1, 2, 3)
  x[[1]][[2]] - c(3, 2, 1)
  x
  [[1]]
  [[1]][[1]]
  [1] 1 2 3
 
  [[1]][[2]]
  [1] 3 2 1
 
  Success. Moral: Read the error messages for meaning or at 
 least clues.
  (Further testing showed that almost anything inside the 
 original list()
  call, even NULL,  would have created enough structure for 
 the interpreter to
  work with.
 
 
 
  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-help@r-project.org mailing list
https://stat.ethz.ch/mailman/listinfo/r-help
PLEASE do read the posting guide http://www.R-project.org/posting-guide.html
and provide commented, minimal, self-contained, reproducible code.


Re: [R] Plotting confidence bands around regression line

2010-08-10 Thread Michal Figurski

David,

I may have stated my problem incorrectly - my problem is to *obtain the 
coordinates* for confidence boundary lines. As input data I have only 
CIs for slope and intercept.


rms/Hmisc packages are very nice, but unfortunately they do not work 
with Passing-Bablok nor 'nls' models.


--
Michal J. Figurski, PhD
HUP, Pathology  Laboratory Medicine
Biomarker Research Laboratory
3400 Spruce St. 7 Maloney
Philadelphia, PA 19104
tel. (215) 662-3413

W dniu 2010-08-10 11:09, David Winsemius pisze:


On Aug 10, 2010, at 10:56 AM, Michal Figurski wrote:


Dear R-helpers and graphics gurus,

I have two problems with plotting confidence bands:

1. First is relatively simple. I am using the Passing-Bablok procedure
to obtain unbiased regression coefficients. This procedure yields
the a  b coefficient values along with their confidence
intervals. I then plot the raw data with the regression line, but I
would like to add the confidence band for the line... and I can't
figure out how to do it.

In other words, given:

Estimate 5%CI 95%CI
Intercept -4.305562 -9.931152 -1.381792
Slope 1.257318 1.053025 1.678516

How to plot the regression line with confidence band?


Take a look at plotCI in either gplots or plotrix packages.

Harrell's rms/Hmisc packages are nicely integrated with lattice and
encourage you to create effective displays of models that remove
simplistic linearity assumptions.



__
R-help@r-project.org mailing list
https://stat.ethz.ch/mailman/listinfo/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] useR! 2011: announcement and call for tutorials

2010-08-10 Thread Heather Turner
We are pleased to announce that the R user conference

   useR! 2011

is scheduled for August 16-18, 2011, and will take place at the
University of Warwick, Coventry, UK.

As for the predecessor conferences, the program will consist of two
parts: invited lectures and user-contributed sessions (abstract
submission will be available online later this year). Prior to the
conference, there will be tutorials on R (proposals for tutorials should
be sent before October 29, 2010, see below).

INVITED SPEAKERS

Adrian Bowman, Lee Edlefsen, Ulrike Grömping, Wolfgang Huber, Brian
Ripley, Jonathan Rougier, Simon Urbanek, and Brandon Whitcher.

USER-CONTRIBUTED SESSIONS

The conference will feature both talks and posters illustrating the use
of R in practice. Contributions are welcome that introduce recent
developments in the R Project (including CRAN packages), demonstrate
applications of R in areas of current interest, or otherwise engage and
inspire participants in their use of R.

PRE-CONFERENCE TUTORIALS

Before the official program, half-day tutorials will be offered on
Monday, August 15.

We invite R users to submit proposals for three hour tutorials on
special topics regarding R. The proposals should give a brief
description of the tutorial, including goals, detailed outline,
justification of why the tutorial is important, background knowledge
required and potential attendees. The proposals should be sent before
October 29, 2010 to useR-2011_at_R-project.org.

A web page offering more information on the `useR!' conference is
available at

   http://www.R-project.org/useR-2011

We hope to see you in Coventry!

The organizing committee:

John Aston, Julia Brettschneider, David Firth, Ashley Ford, Ioannis
Kosmidis, Tom Nichols, Elke Thönnes and Heather Turner

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


Re: [R] Plotting confidence bands around regression line

2010-08-10 Thread David Winsemius


On Aug 10, 2010, at 11:23 AM, Michal Figurski wrote:


David,

I may have stated my problem incorrectly - my problem is to *obtain  
the coordinates* for confidence boundary lines. As input data I have  
only CIs for slope and intercept.


Wouldn't you also need to specify the range over which these estimates  
might be valid and to offer the means for the X values? What level of  
R knowledge are you at? You have provided no data or code. Many R  
methods offer predict methods that return CI's.


--
david


rms/Hmisc packages are very nice, but unfortunately they do not work  
with Passing-Bablok nor 'nls' models.


--
Michal J. Figurski, PhD
HUP, Pathology  Laboratory Medicine
Biomarker Research Laboratory
3400 Spruce St. 7 Maloney
Philadelphia, PA 19104
tel. (215) 662-3413

W dniu 2010-08-10 11:09, David Winsemius pisze:


On Aug 10, 2010, at 10:56 AM, Michal Figurski wrote:


Dear R-helpers and graphics gurus,

I have two problems with plotting confidence bands:

1. First is relatively simple. I am using the Passing-Bablok  
procedure

to obtain unbiased regression coefficients. This procedure yields
the a  b coefficient values along with their confidence
intervals. I then plot the raw data with the regression line, but I
would like to add the confidence band for the line... and I can't
figure out how to do it.

In other words, given:

Estimate 5%CI 95%CI
Intercept -4.305562 -9.931152 -1.381792
Slope 1.257318 1.053025 1.678516

How to plot the regression line with confidence band?


Take a look at plotCI in either gplots or plotrix packages.

Harrell's rms/Hmisc packages are nicely integrated with lattice and
encourage you to create effective displays of models that remove
simplistic linearity assumptions.



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] Function to Define a Function

2010-08-10 Thread Greg Snow
What if you change your function to:

mdlChooser - function(type=c(one,two)) {
  type - match.arg(type)
  switch(type,
one={ function(x,N0,r) N0*exp(x*r) },
two={ function(x,N0,r,K) (N0*K)/(N0+(K-N0)*exp(-x*r)) },
  )
}

Does that work for you?

-- 
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 Derek Ogle
 Sent: Monday, August 09, 2010 7:31 PM
 To: R (r-help@R-project.org)
 Subject: [R] Function to Define a Function
 
 I am trying to define a general R function that has a function as the
 output that depends on the user's input arguments (this may make more
 sense by looking at the toy example below).  My real use for this type
 of code is to allow a user to choose from many parameterizations of the
 same general model.
 
 My issue is that when I compile a package with this type of code in
 it I get a __warning__ that multiple local function definitions for
 'm' with different formal arguments.  While this is not a deadly
 error I would like to avoid the warning if possible.  Can someone
 provide some guidance?  Thank you in advance for any help you can
 offer.
 
 For what it is worth ... I am working on a Windows XP machine with R
 2.11.1.
 
 
 
 
 ## A function that allows the user to create a new function that
 depends on their
 ##   choice in the type argument.  As a simple example, if the user
 chooses one
 ##   then the output function is exponential growth, if the user choses
 two then
 ##   thhe output function is logistic growth.
 
 mdlChooser - function(type=c(one,two)) {
   type - match.arg(type)
   switch(type,
 one={ m - function(x,N0,r) N0*exp(x*r) },
 two={ m - function(x,N0,r,K) (N0*K)/(N0+(K-N0)*exp(-x*r)) },
   )
   m
 }
 
 ## define time steps
 t - 0:10
 
 ## create a function -- junk1 -- that produces exponential growth
 junk1 - mdlChooser(one)
 junk1
 res1 - junk1(t,500,0.2)
 res1
 
 ## create a function -- junk2 -- that produces logistic growth
 junk2 - mdlChooser(two)
 junk2
 res2 - junk2(t,500,0.2,1000)
 res2
 
 
 
   [[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] Concatenate a mix of numbers and letters to create a vector name

2010-08-10 Thread Greg Snow
Others gave you some examples using assign, which is the same information as in 
the FAQ.  But I expect that you will be better served by using a list (you can 
use the paste function to create the names for the list elements) rather than 
assign and global variables.

Something like:

mylist - list()

for (i in c(1950, 1960, 1970) ) {
  for (j in 1:12) {
mylist[[ paste( 'tmax.', i, j, sep='' ) ]] - somefunction(i, j)
  }
}

Then you can access a single result like:

mylist[['tmax.15012']]

or you can do something with all the output using something like:

sapply( mylist, summary )

hope this helps,

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


 -Original Message-
 From: Panos Hadjinicolaou [mailto:p.hadjinicol...@cyi.ac.cy]
 Sent: Tuesday, August 10, 2010 6:07 AM
 To: Greg Snow; r-help@r-project.org
 Subject: RE: [R] Concatenate a mix of numbers and letters to create a
 vector name
 
 I was not aware of the R-FAQ, it seems to have some very useful tips,
 thanks for pointing there.
 
 Regarding the 7.21 in the FAQ, I read it a few times but it did not
 lead me anywhere. For the moment I am blaming my inexperience with some
 R basics, I will come back after I do some more serious studying.
 
 Thanks again,
 
 Panos
 
 
 Dr Panos Hadjinicolaou
 
 Energy Environment  Water Research Center (EEWRC)
 The Cyprus Institute
 
 -
 
 
   _
 From: Greg Snow [mailto:greg.s...@imail.org]
 To: Panos Hadjinicolaou [mailto:p.hadjinicol...@cyi.ac.cy], r-h...@r-
 project.org [mailto:r-h...@r-project.org]
 Sent: Wed, 28 Jul 2010 00:39:41 +0300
 Subject: RE: [R] Concatenate a mix of numbers and letters to create a
 vector name
 
 This is a frequently asked/answered question (7.21 in the FAQ).  What
 searching did you do and why did it not find this FAQ or previous
 discussion of it?  How could the documentation/search/etc. be improved
 so that you (and the next n people with this question) will find the
 answer easier?
 
 The most important of part of the FAQ answer is the last section where
 it points out that using a list will be much simpler.  You mentioned in
 the first post that you were doing this in a loop, just start with an
 empty list, use paste (or sprintf) to create the name, and then assign
 it as a new element of the list with that name (e.g. mylist[[
 sprintf('tmax.%d%d', var1, var2) ]] - outputfromcomputations ).
 
 --
 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 Panos Hadjinicolaou
  Sent: Monday, July 26, 2010 8:24 AM
  To: r-help@r-project.org
  Subject: Re: [R] Concatenate a mix of numbers and letters to create a
  vector name
 
  Thanks for the reply. Indeed the paste function results in
  concatenation:
paste(c(tmax., 1950, 12), collapse=)
  [1] tmax.195012
 
  but  I am looking for a way to subsequently get rid of the -  - in
  order to  use tmax.195012 as an object (e.g. to define a vector with
  that name).  Any ideas?
 
  Thanks,
 
  Panos
 
_
 
  From: Dimitris Rizopoulos [mailto:d.rizopou...@erasmusmc.nl]
  To: Panos Hadjinicolaou [mailto:p.hadjinicol...@cyi.ac.cy]
  Cc: r-help@r-project.org
  Sent: Mon, 26 Jul 2010 16:48:31 +0300
  Subject: Re: [R] Concatenate a mix of numbers and letters to create a
  vector name
 
  have a look at function paste(), i.e., ?paste
 
 
I hope it helps.
 
Best,
Dimitris
 
 
On 7/26/2010 3:44 PM, Panos Hadjinicolaou wrote:
 Dear all,

 I am trying to create a vector name, for example tmax.195012 from
  tmax., 1950 and 12. Obviously I don't wish to simply type it because
  the 3 name components are changing in each iteration within a loop.
 Is
  there any way of concatenating those 3 components (which are a
 mixture
  of numbers and letters)?

 Thanks for reading,

 Panos

 -
 Dr Panos Hadjinicolaou

 Energy Environment  Water Research Center (EEWRC)
 The Cyprus Institute
 -
 -
  [[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.

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

Re: [R] Plotting confidence bands around regression line

2010-08-10 Thread Michal Figurski

David,

I would consider myself intermediate in R, but a beginner in statistics. 
I need a formula that would allow me to calculate confidence boundaries 
of the regression line given the slope, intercept and their CIs (and 
*any* range).


Passing-Bablok regression doesn't yet exist in R - I am developing it. 
Therefore I am sure there is no predict method for it ;)


I believe I have provided sufficient data to address this problem, but 
if that would help anyone, here is more:


# data frame
 a - structure(list(x = c(0.1, 1.43, 4.21, 3.67, 3.23, 7.72, 5.99, 
9.16, 10.6, 9.84, 11.94, 12.03, 12.89, 11.26, 15.54, 15.58, 17.32, 
17.65, 19.52, 20.48, 20.44, 20.51, 22.27, 23.58, 25.83, 26.04, 26.92, 
28.44, 30.73, 28.78), y = c(1.08, 1.39, 1.84, 0.56, 7.23, 4.91, 3.35, 
7.09, 3.16, 8.98, 16.37, 7.46, 15.46, 23.2, 4.63, 11.13, 15.68, 13.92, 
26.44, 21.65, 21.01, 20.22, 22.69, 22.21, 23.6, 17.24, 45.24, 30.09, 40, 
49.6)), .Names = c(x, y), row.names = c(NA, -30L), class = data.frame)


Then I run the regression procedure (in development - now part of the 
'MethComp' package):

 print(PBreg(a))

# And the result of the Passing-Bablok regression on this data frame:
   Estimate  5%CI 95%CI
Intercept -4.306197 -9.948438 -1.374663
Slope  1.257584  1.052696  1.679290

The original Passing  Bablok article on this method has an easy 
prescription for CIs on coefficients, so I implemented that. Now I need 
a way to calculate CI boundaries for individual points - this may be a 
basic handbook stuff - I just don't know it (I'm not a statistician). I 
would appreciate if anyone could point me to a handbook or website where 
it is described.


Regarding 2 - the predict method for 'nls' class currently *ignores* the 
interval parameter - as it is stated in documentation.


Regards

--
Michal J. Figurski, PhD
HUP, Pathology  Laboratory Medicine
Biomarker Research Laboratory
3400 Spruce St. 7 Maloney
Philadelphia, PA 19104
tel. (215) 662-3413

On 2010-08-10 11:38, David Winsemius wrote:


On Aug 10, 2010, at 11:23 AM, Michal Figurski wrote:


David,

I may have stated my problem incorrectly - my problem is to *obtain
the coordinates* for confidence boundary lines. As input data I have
only CIs for slope and intercept.


Wouldn't you also need to specify the range over which these estimates
might be valid and to offer the means for the X values? What level of R
knowledge are you at? You have provided no data or code. Many R methods
offer predict methods that return CI's.



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

2010-08-10 Thread Peter Dalgaard
Michael Friendly wrote:
 Barrett  Ling, JASA, 1992, v.87(417), pp184-191 define general classes 
 of influence measures for multivariate
 regression models, including analogs of Cook's D, Andrews  Pregibon 
 COVRATIO, etc.  As in univariate
 response models, these are based on leverage and residuals based on 
 omitting one (or more) observations at
 a time and refitting, although, in the univariate case, the computations 
 can be optimized, as they are in
 stats::influence() and related methods.
 
 I'm interested in exploring the multivariate extension in R.  I tried 
 the following, and was surprised to find that
 R returned a result rather than an error -- presumably because mlm 
 objects are not trapped before they
 get to lm.influence()
 
   # multivariate model
   data(Rohwer, package=heplots)
   rohwer.mod - lm(cbind(SAT, PPVT, Raven) ~ n + s + ns + na + ss, 
 data=Rohwer)
 
   names(influence(rohwer.mod))
 [1] hat  coefficients sigmawt.res 
   head(influence(rohwer.mod)$coefficients, 2)
 [,1]   [,2]  [,3] [,4]  [,5]  [,6]
 [1,] 2.25039  0.0254739 -0.025252 -0.06297 -0.121507  0.094355
 [2,] 0.84649 -0.0062656 -0.077430  0.08345 -0.022579 -0.059480
  
 
 Of course, the correct calculations would result from refitting, 
 omitting each observation in turn, though doing this
 directly would be horribly inefficient.
 e.g, calculating B(i), deleting case i:
 
   coef(update(rohwer.mod, subset=1:69 !=1, data=Rohwer))
   SAT PPVT Raven
 (Intercept) -2.466079 35.68664 11.510068
 n1.888286  0.60949  0.075931
 s   -0.034524 -0.53040  0.160328
 ns  -2.739834 -0.67355  0.066392
 na   2.219340  1.20481 -0.037272
 ss   1.072300  0.99033  0.058509
   coef(update(rohwer.mod, subset=1:69 !=2, data=Rohwer))
   SAT PPVT  Raven
 (Intercept) -1.062178 33.88199 10.8988006
 n1.920026  0.59735  0.0713976
 s0.017654 -0.47464  0.1774135
 ns  -2.886254 -0.67905  0.0673686
 na   2.120411  1.29016 -0.0077484
 ss   1.226135  0.96430  0.0471764
 
 Is there anything existing for this case that I've missed, or does 
 anyone have an interest in pursuing this topic?

Hmm, fitted coefficients in this sort multivariate models are the same
as those in the univariate ones, so as long as you do whole-case
deletions, I would think that you should be able to reuse the 1D code. I
would conjecture that the main problem with what you currently get is
that it only pertains to the 1st column -- looks like the differences
between the two rows from lm.influence matches the differences between
the first two colums from coef(update(...)).

Since lm() only handles complete cases, casewise deletion diagnostics is
probably the best you can get, otherwise it would be interesting to see
the effect of deleting each coordinate separately.

(As you know, these matters are within my general sphere of interest,
but I'm afraid my time is too constrained at them moment for more than a
sideline view.)

 
 -Michael
 


-- 
Peter Dalgaard
Center for Statistics, Copenhagen Business School
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] Function to Define a Function

2010-08-10 Thread Thomas Lumley

On Mon, 9 Aug 2010, Derek Ogle wrote:


I am trying to define a general R function that has a function as the output 
that depends on the user's input arguments (this may make more sense by looking 
at the toy example below).  My real use for this type of code is to allow a 
user to choose from many parameterizations of the same general model.

My issue is that when I compile a package with this type of code in it I get a __warning__ that 
multiple local function definitions for 'm' with different formal arguments.  While this is not a 
deadly error I would like to avoid the warning if possible.  Can someone provide some guidance?  
Thank you in advance for any help you can offer.


snip


mdlChooser - function(type=c(one,two)) {
 type - match.arg(type)
 switch(type,
   one={ m - function(x,N0,r) N0*exp(x*r) },
   two={ m - function(x,N0,r,K) (N0*K)/(N0+(K-N0)*exp(-x*r)) },
 )
 m
}



One approach is to put the assignment outside the switch

mdlChooser - function(type=c(one,two)) {
  type - match.arg(type)
  m- switch(type,
one={  function(x,N0,r) N0*exp(x*r) },
two={ function(x,N0,r,K) (N0*K)/(N0+(K-N0)*exp(-x*r)) },
  )
  m
 }

or not even assign the result

mdlChooser - function(type=c(one,two)) {
  type - match.arg(type)
  switch(type,
one= function(x,N0,r) N0*exp(x*r) ,
two=function(x,N0,r,K) (N0*K)/(N0+(K-N0)*exp(-x*r)) ,
  )
}

   -thomas

Thomas Lumley
Professor of Biostatistics
University of Washington, Seattle

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

2010-08-10 Thread Greg Snow
I don't know much about pvclust itself, but you might consider the technique in 
this paper:

 Buja, A., Cook, D. Hofmann, H., Lawrence, M. Lee, E.-K., Swayne,
 D.F and Wickham, H. (2009) Statistical Inference for exploratory
 data analysis and model diagnostics Phil. Trans. R. Soc. A 2009
 367, 4361-4383 doi: 10.1098/rsta.2009.0120

You just need to understand your null hypothesis enough to be able to simulate 
data from the null (possibly permuting original data, or generating data from a 
distribution similar to your data but without clusters).

The vis.test function in the TeachingDemos package helps with an implementation 
of the test (you will still need to write some of your own code though).

Hope this helps,

-- 
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 syrvn
 Sent: Tuesday, August 10, 2010 6:45 AM
 To: r-help@r-project.org
 Subject: [R] p-values with pvclust
 
 
 Hi,
 
 
 if you look at the first image (Image1)  you see that there are 2 main
 clusters 7 and 8
 I wanted to use pvclust to calculate a p-value whether these clusters
 are
 due to chance
 or statistically significant. Unfortunately pvclust does not provide a
 p-value for the first
 brunch (7 and 8).
 
 So I added a row to my matrix which is very different to the rest of
 the
 data to create an additional
 brunch. See image here
 http://r.789695.n4.nabble.com/file/n2319732/Image2.png . I finally got
 my
 p-value for the brunch (7 and 8) which is 98 (9).
 
 I was happy to see that the p-value was significant until I realised
 that if
 I add an additional brunch which
 is not that different from the rest but still cluster in a sperate
 cluster
 (see image here  http://r.789695.n4.nabble.com/file/n2319732/Image3.png
 )
 the p-value is changing and not significant any longer (84).
 
 
 
 I was wondering why this happens because I thought that for each brunch
 the
 p-value is calculated independently?
 
 Does anybody know how to get a correct p-value for the first brunch (7
 and
 8) maybe without adding an additional brunch?
 
 Best regards
 syrvn
 --
 View this message in context: http://r.789695.n4.nabble.com/p-values-
 with-pvclust-tp2319732p2319732.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] Function to Define a Function

2010-08-10 Thread Martin Maechler
 Gabor Grothendieck ggrothendi...@gmail.com
 on Mon, 9 Aug 2010 23:20:18 -0400 writes:

 On Mon, Aug 9, 2010 at 9:31 PM, Derek Ogle do...@northland.edu wrote:

 I am trying to define a general R function that has a
 function as the output that depends on the user's input
 arguments (this may make more sense by looking at the toy
 example below).  My real use for this type of code is to
 allow a user to choose from many parameterizations of the
 same general model.

 
 My issue is that when I compile a package with this
 type of code in it I get a __warning__ that multiple local
 function definitions for 'm' with different formal
 arguments.  While this is not a deadly error I would like
 to avoid the warning if possible.  Can someone provide some
 guidance? 
 Thank you in advance for any help you can offer.
 
 For what it is worth ... I am working on a Windows XP machine with R 
2.11.1.
 
 

 ## A function that allows the user to create a new function that depends 
on their
 ##   choice in the type argument.  As a simple example, if the user 
chooses one
 ##   then the output function is exponential growth, if the user choses 
two then
 ##   thhe output function is logistic growth.
 
 mdlChooser - function(type=c(one,two)) {
  type - match.arg(type)
  switch(type,
one={ m - function(x,N0,r) N0*exp(x*r) },
two={ m - function(x,N0,r,K) (N0*K)/(N0+(K-N0)*exp(-x*r)) },
  )
  m
 }
 
 ## define time steps
 t - 0:10
 
 ## create a function -- junk1 -- that produces exponential growth
 junk1 - mdlChooser(one)
 junk1
 res1 - junk1(t,500,0.2)
 res1
 
 ## create a function -- junk2 -- that produces logistic growth
 junk2 - mdlChooser(two)
 junk2
 res2 - junk2(t,500,0.2,1000)
 res2
 


 Try this:

 mdlChooser - function(type = c(one, two)) {
 one - function(x,N0,r) N0*exp(x*r)
 two - function(x,N0,r,K) (N0*K)/(N0+(K-N0)*exp(-x*r))
 type - match.arg(type)
 get(type)
 }

or a bit more elegantly, I think,

mdlChooser - function(type=c(one,two)) {
  switch(match.arg(type),
one= function(x,N0,r) N0*exp(x*r),
two= function(x,N0,r,K) (N0*K)/(N0+(K-N0)*exp(-x*r))
  )
}

which just leaves away some unnecessary code from Derek's
original code (and here you could even drop the last { .. }
pair).

Martin Maechler, ETH Zurich

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


Re: [R] Plotting confidence bands around regression line

2010-08-10 Thread Frank Harrell


Please give the prescription.  The article is not available on our 
extensive online library.  I wonder if the method can compete with the 
bootstrap.


Frank

Frank E Harrell Jr   Professor and ChairmanSchool of Medicine
 Department of Biostatistics   Vanderbilt University

On Tue, 10 Aug 2010, Michal Figurski wrote:


David,

I would consider myself intermediate in R, but a beginner in statistics.
I need a formula that would allow me to calculate confidence boundaries
of the regression line given the slope, intercept and their CIs (and
*any* range).

Passing-Bablok regression doesn't yet exist in R - I am developing it.
Therefore I am sure there is no predict method for it ;)

I believe I have provided sufficient data to address this problem, but
if that would help anyone, here is more:

# data frame
 a - structure(list(x = c(0.1, 1.43, 4.21, 3.67, 3.23, 7.72, 5.99,
9.16, 10.6, 9.84, 11.94, 12.03, 12.89, 11.26, 15.54, 15.58, 17.32,
17.65, 19.52, 20.48, 20.44, 20.51, 22.27, 23.58, 25.83, 26.04, 26.92,
28.44, 30.73, 28.78), y = c(1.08, 1.39, 1.84, 0.56, 7.23, 4.91, 3.35,
7.09, 3.16, 8.98, 16.37, 7.46, 15.46, 23.2, 4.63, 11.13, 15.68, 13.92,
26.44, 21.65, 21.01, 20.22, 22.69, 22.21, 23.6, 17.24, 45.24, 30.09, 40,
49.6)), .Names = c(x, y), row.names = c(NA, -30L), class = data.frame)

Then I run the regression procedure (in development - now part of the
'MethComp' package):
 print(PBreg(a))

# And the result of the Passing-Bablok regression on this data frame:
   Estimate  5%CI 95%CI
Intercept -4.306197 -9.948438 -1.374663
Slope  1.257584  1.052696  1.679290

The original Passing  Bablok article on this method has an easy
prescription for CIs on coefficients, so I implemented that. Now I need
a way to calculate CI boundaries for individual points - this may be a
basic handbook stuff - I just don't know it (I'm not a statistician). I
would appreciate if anyone could point me to a handbook or website where
it is described.

Regarding 2 - the predict method for 'nls' class currently *ignores* the
interval parameter - as it is stated in documentation.

Regards

--
Michal J. Figurski, PhD
HUP, Pathology  Laboratory Medicine
Biomarker Research Laboratory
3400 Spruce St. 7 Maloney
Philadelphia, PA 19104
tel. (215) 662-3413

On 2010-08-10 11:38, David Winsemius wrote:


On Aug 10, 2010, at 11:23 AM, Michal Figurski wrote:


David,

I may have stated my problem incorrectly - my problem is to *obtain
the coordinates* for confidence boundary lines. As input data I have
only CIs for slope and intercept.


Wouldn't you also need to specify the range over which these estimates
might be valid and to offer the means for the X values? What level of R
knowledge are you at? You have provided no data or code. Many R methods
offer predict methods that return CI's.



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



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


Re: [R] Plotting confidence bands around regression line

2010-08-10 Thread David Winsemius


On Aug 10, 2010, at 12:12 PM, Michal Figurski wrote:


David,

I would consider myself intermediate in R, but a beginner in  
statistics. I need a formula that would allow me to calculate  
confidence boundaries of the regression line given the slope,  
intercept and their CIs (and *any* range).


For ordinary regression the CI's for prediction intervals are going  
to be much wider than the CI's for parameter estimates. In both cases  
they are quadratic functions that depend on the mean_x_hat and on  
s_hat^2 (used as an estimate of sigma^2). These formulae should be  
available in any basic regression text. I am sufficiently aware of my  
non-statistician status to know that I could not comment on whether  
naively applying those functions to estimates from another method  
would have validity.


--
David.


Passing-Bablok regression doesn't yet exist in R - I am developing  
it. Therefore I am sure there is no predict method for it ;)


I believe I have provided sufficient data to address this problem,  
but if that would help anyone, here is more:


# data frame
 a - structure(list(x = c(0.1, 1.43, 4.21, 3.67, 3.23, 7.72, 5.99,  
9.16, 10.6, 9.84, 11.94, 12.03, 12.89, 11.26, 15.54, 15.58, 17.32,  
17.65, 19.52, 20.48, 20.44, 20.51, 22.27, 23.58, 25.83, 26.04,  
26.92, 28.44, 30.73, 28.78), y = c(1.08, 1.39, 1.84, 0.56, 7.23,  
4.91, 3.35, 7.09, 3.16, 8.98, 16.37, 7.46, 15.46, 23.2, 4.63, 11.13,  
15.68, 13.92, 26.44, 21.65, 21.01, 20.22, 22.69, 22.21, 23.6, 17.24,  
45.24, 30.09, 40, 49.6)), .Names = c(x, y), row.names = c(NA,  
-30L), class = data.frame)


Then I run the regression procedure (in development - now part of  
the 'MethComp' package):

 print(PBreg(a))

# And the result of the Passing-Bablok regression on this data frame:
  Estimate  5%CI 95%CI
Intercept -4.306197 -9.948438 -1.374663
Slope  1.257584  1.052696  1.679290

The original Passing  Bablok article on this method has an easy  
prescription for CIs on coefficients, so I implemented that. Now I  
need a way to calculate CI boundaries for individual points - this  
may be a basic handbook stuff - I just don't know it (I'm not a  
statistician). I would appreciate if anyone could point me to a  
handbook or website where it is described.


Regarding 2 - the predict method for 'nls' class currently *ignores*  
the interval parameter - as it is stated in documentation.


Regards

--
Michal J. Figurski, PhD
HUP, Pathology  Laboratory Medicine
Biomarker Research Laboratory
3400 Spruce St. 7 Maloney
Philadelphia, PA 19104
tel. (215) 662-3413

On 2010-08-10 11:38, David Winsemius wrote:


On Aug 10, 2010, at 11:23 AM, Michal Figurski wrote:


David,

I may have stated my problem incorrectly - my problem is to *obtain
the coordinates* for confidence boundary lines. As input data I have
only CIs for slope and intercept.


Wouldn't you also need to specify the range over which these  
estimates
might be valid and to offer the means for the X values? What level  
of R
knowledge are you at? You have provided no data or code. Many R  
methods

offer predict methods that return CI's.



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] How to invert a list ?

2010-08-10 Thread Carlos Petti
Dear list,

I have a list, as follows :

a - 5
names(a) - a
b - 9
names(b) - b
c - 15
names(c) - c
x - list(i = a, j = b, j = c)

I want to invert the list, like this :

$a
i
5

$b
j  k
9 15

I do not find a clean solution.

Could anyone give me elegant ideas ?

Thanks in advance,
Carlos

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

2010-08-10 Thread S Ellison
Neat. But why assign the functions to separate variables at all?

mdlChooser - function(type=c(one,two)) {
  type - match.arg(type)
  m - switch(type,
one=function(x,N0,r) N0*exp(x*r) ,
two=function(x,N0,r,K) (N0*K)/(N0+(K-N0)*exp(-x*r)) 
  )
  m
 }


also works without appearing to assign different functions to the same
variable. 
(In this simple example, you wouldn't need the m- assignment either;
you could simply let the switch return its result. But I assume the real
intended use is more complicated than just returning the function)



 Derek Ogle do...@northland.edu 10/08/2010 13:48:13 
Gabor ... that worked perfectly.  Thank you.

 -Original Message-
 Try this:
 
 mdlChooser - function(type = c(one, two)) {
one - function(x,N0,r) N0*exp(x*r)
two - function(x,N0,r,K) (N0*K)/(N0+(K-N0)*exp(-x*r))
type - match.arg(type)
get(type)
 }

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

***
This email and any attachments are confidential. Any use...{{dropped:8}}

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


Re: [R] Plotting confidence bands around regression line

2010-08-10 Thread Peter Dalgaard
Michal Figurski wrote:

 # And the result of the Passing-Bablok regression on this data frame:
 Estimate  5%CI 95%CI
 Intercept -4.306197 -9.948438 -1.374663
 Slope  1.257584  1.052696  1.679290
 
 The original Passing  Bablok article on this method has an easy 
 prescription for CIs on coefficients, so I implemented that. Now I need 
 a way to calculate CI boundaries for individual points - this may be a 
 basic handbook stuff - I just don't know it (I'm not a statistician).

The answer is that you can't. You can't even do it with ordinary linear
regression without knowing the correlation between slope and intercept.
However, if you can get a CI for the intercept then you could subtract
x0 from all the x and get a CI for the value at x0.

(This brings echos from a distant past. My master's thesis was about
some similar median-type estimators. I can't remember whether I looked
at the Passing-Bablok paper at the time (1985!!) but my general
recollection is that this group of methods is littered with unstated
assumptions.)

-- 
Peter Dalgaard
Center for Statistics, Copenhagen Business School
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] How to invert a list ?

2010-08-10 Thread Henrique Dallazuanna
Here is one way:

xst - stack(x)
let - letters[cumsum(duplicated(match(xst$ind, letters))) + match(xst$ind,
letters)]
with(xst,
 structure(split(structure(values, names = let), ind), .Names =
row.names(xst)[1:length(unique(ind))]))



On Tue, Aug 10, 2010 at 1:58 PM, Carlos Petti carlos.pe...@gmail.comwrote:

 Dear list,

 I have a list, as follows :

 a - 5
 names(a) - a
 b - 9
 names(b) - b
 c - 15
 names(c) - c
 x - list(i = a, j = b, j = c)

 I want to invert the list, like this :

 $a
 i
 5

 $b
 j  k
 9 15

 I do not find a clean solution.

 Could anyone give me elegant ideas ?

 Thanks in advance,
 Carlos

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




-- 
Henrique Dallazuanna
Curitiba-Paraná-Brasil
25° 25' 40 S 49° 16' 22 O

[[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] Error in R2Bugs

2010-08-10 Thread John Poulsen
Hello,

I am running a GLMM using R2Bugs, but am getting the below error message.  I am 
including the entire output, although the 2nd and 3rd lines seem to indicate 
the problem.  Note that I do define N (it is an integer) and send it to a 
datalist (see the R commands and model below).  Interestingly, when I put all 
of this into OpenBugs directly, the model runs.  I do have reasons, however, 
that I would like to do this through R.

model is syntactically correct
expected variable name error pos 341553 (error on line 1)
variable N is not defined
Initializing chain 1: model must be compiled before initial values loaded
Initializing chain 2: model must be compiled before initial values loaded
Initializing chain 3: model must be compiled before initial values loaded
model must be compiled before generating initial values
Sampling has been started...
model must be initialized before updating
model must be initialized before DIC an be monitored
Error in BRugs::samplesSet(parametersToSave) :
  model must be initialized before monitors used

Thanks for your help!
John

R commands

 datalist-list(r, N,n,Lev, Light, Soil1, Soil2, Soil3, 
Consp, Plot, DConsp, 
Spp, n.plot, n.sp)

 bugs.data(datalist)

 parmlist-c(b.lev, b.light, b.con, b.dcon, b.s1, b.s2, b.s3, 
sigma.ind, sigma.plt, sigma.sp, sigma.sppl)
 
 initlist-list(list(b.lev=0.01, b.light=0.01, b.con=0.01, b.s1=0.01, 
b.s2=0.01, b.s3=0.01, b.dcon=0.01, tau.ind=rep(0,N), 
tau.plt=rep(0,n.plot), tau.sp=rep(0,n.sp), tau=array(0, c(n.sp, 
n.plot))),
list(b.lev=0.01, b.light=0.01, b.con=0.01, b.s1=0.01, 
b.s2=0.01, b.s3=0.01, b.dcon=0.01, tau.ind=rep(0,N), 
tau.plt=rep(0,n.plot), tau.sp=rep(0,n.sp), tau=array(0, c(n.sp, 
n.plot))),
list(b.lev=0.01, b.light=0.01, b.con=0.01, b.s1=0.01, 
b.s2=0.01, b.s3=0.01, b.dcon=0.01, tau.ind=rep(0,N), 
tau.plt=rep(0,n.plot), tau.sp=rep(0,n.sp), tau=array(0, c(n.sp, 
n.plot
 
 modfile-(GLMM Model.txt)
 GLMMcom1-bugs(data=datalist, inits=initlist, parameters=parmlist, 
model.file=modfile,
n.chains=3, n.iter=2000, DIC=TRUE, n.burnin=500,
bugs.directory=/Program Files/OpenBUGS, program=openbugs, 
debug=TRUE)
 


model {  

 for (i in 1:N){  # No. of sect x dist plots
  
 r[i]~dbin(p[i], n[i])
  eps.ind[i]~dnorm(0, tau.ind)
  logit(p[i]) - b.lev*Lev[i] + b.light*Light[i] + b.con*Consp[i] + 
b.dcon*DConsp[i] + 
 b.s1*Soil1[i]  + b.s2*Soil2[i]  + b.s3*Soil3[i]  + 
 eps.sp[Sp[i]] + eps.plt[Plot[i]] + eps[Sp[i], Plot[i]]  + 
eps.ind[i]
  }

 for(k in 1:n.sp){for(s in 1:n.plot){eps[k, s] ~ dnorm(0.0,tau)}}
 for(s in 1:n.plot){eps.plt[s] ~ dnorm(0.0, tau.plt)}
 for(k in 1:n.sp){eps.sp[k] ~ dnorm(0.0, tau.sp)}
  

 b.lev~dnorm(0, 0.01) 
 b.light~dnorm(0, 0.01)
 b.con~dnorm(0,0.01)
 b.s1~dnorm(0, 0.01)
 b.s2~dnorm(0, 0.01)
 b.s3~dnorm(0, 0.01)
 b.dcon~dnorm(0, 0.01)
 
  tau.ind~dunif(0,100)
  sigma.ind-1/sqrt(tau.ind)
  tau.plt ~ dunif(0,100)
  sigma.plt-1/sqrt(tau.plt)
  tau.sp ~ dunif(0,100)
  sigma.sp-1/sqrt(tau.sp)
  tau ~ dunif(0,100)
  sigma.sppl-1/sqrt(tau) #sd of species x plot random effect
   }






-
John Poulsen, PhD
Assistant Scientist
Woods Hole Research Center
149 Woods Hole Road
Falmouth, MA 02540-1644 USA

Tel: 508.540.9900 x168
www.whrc.org






[[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] matrix problem

2010-08-10 Thread zhenjiang xu
Hi,

I have a file like this:
1 2 0.1
2 3 0.2
3 1 0.3

And I want to read it to create a matrix like this:
 [,1] [,2][,3]
[1,]0   0.1 0
[2,]0   00.2
[3,]0.300

How can I do it efficiently? Thanks.
-- 
Best,
Zhenjiang

[[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] matrix problem

2010-08-10 Thread Henrique Dallazuanna
Try this:

Lines - '1 2 0.1
2 3 0.2
3 1 0.3'

DF - read.table(textConnection(Lines))
m - matrix(0, ncol = nrow(DF), nrow = nrow(DF))
m[as.matrix(DF[1:2])] - DF[[3]]

On Tue, Aug 10, 2010 at 3:03 PM, zhenjiang xu zhenjiang...@gmail.comwrote:

 Hi,

 I have a file like this:
 1 2 0.1
 2 3 0.2
 3 1 0.3

 And I want to read it to create a matrix like this:
 [,1] [,2][,3]
 [1,]0   0.1 0
 [2,]0   00.2
 [3,]0.300

 How can I do it efficiently? Thanks.
 --
 Best,
 Zhenjiang

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




-- 
Henrique Dallazuanna
Curitiba-Paraná-Brasil
25° 25' 40 S 49° 16' 22 O

[[alternative HTML version deleted]]

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


Re: [R] Plotting confidence bands around regression line

2010-08-10 Thread Michal Figurski

Frank,

I had to order this article through Inter-Library Loan and wait for it 
for a week!


I'll try to make it short. In Passing-Bablok the principle is to 
calculate slopes between all possible pairs of points in the dataset, 
and then to take a shifted median of those slopes, where the offset is 
the number of slopes of value (-1). Because of this, bootstrap is out 
of question - it would take too much time.


Let n be the number of data points, N - the number of slopes and K - 
the offset. The locations of CI boundaries in the set of N slopes are 
then calculated with formulas:

M1 - N - qnorm(1 - conf.level/2) * sqrt((n*(n-1)*(2*n+5))/18))/2
M2 - N - M1 + 1

CIs for intercept are calculated as medians of y(i) - slopes[M1,M2]*x(i)

I hope I don't confuse anyone.

The article has a mathematical derivations section and justification 
for these formulas. It looks solid to me, although after 25 years the 
flaws may be apparent to some of you.


--
Michal J. Figurski, PhD
HUP, Pathology  Laboratory Medicine
Biomarker Research Laboratory
3400 Spruce St. 7 Maloney
Philadelphia, PA 19104
tel. (215) 662-3413

On 2010-08-10 12:29, Frank Harrell wrote:


Please give the prescription. The article is not available on our
extensive online library. I wonder if the method can compete with the
bootstrap.

Frank

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

On Tue, 10 Aug 2010, Michal Figurski wrote:


David,

I would consider myself intermediate in R, but a beginner in statistics.
I need a formula that would allow me to calculate confidence boundaries
of the regression line given the slope, intercept and their CIs (and
*any* range).

Passing-Bablok regression doesn't yet exist in R - I am developing it.
Therefore I am sure there is no predict method for it ;)

I believe I have provided sufficient data to address this problem, but
if that would help anyone, here is more:

# data frame
 a - structure(list(x = c(0.1, 1.43, 4.21, 3.67, 3.23, 7.72, 5.99,
9.16, 10.6, 9.84, 11.94, 12.03, 12.89, 11.26, 15.54, 15.58, 17.32,
17.65, 19.52, 20.48, 20.44, 20.51, 22.27, 23.58, 25.83, 26.04, 26.92,
28.44, 30.73, 28.78), y = c(1.08, 1.39, 1.84, 0.56, 7.23, 4.91, 3.35,
7.09, 3.16, 8.98, 16.37, 7.46, 15.46, 23.2, 4.63, 11.13, 15.68, 13.92,
26.44, 21.65, 21.01, 20.22, 22.69, 22.21, 23.6, 17.24, 45.24, 30.09, 40,
49.6)), .Names = c(x, y), row.names = c(NA, -30L), class =
data.frame)

Then I run the regression procedure (in development - now part of the
'MethComp' package):
 print(PBreg(a))

# And the result of the Passing-Bablok regression on this data frame:
Estimate 5%CI 95%CI
Intercept -4.306197 -9.948438 -1.374663
Slope 1.257584 1.052696 1.679290

The original Passing  Bablok article on this method has an easy
prescription for CIs on coefficients, so I implemented that. Now I need
a way to calculate CI boundaries for individual points - this may be a
basic handbook stuff - I just don't know it (I'm not a statistician). I
would appreciate if anyone could point me to a handbook or website where
it is described.

Regarding 2 - the predict method for 'nls' class currently *ignores* the
interval parameter - as it is stated in documentation.

Regards

--
Michal J. Figurski, PhD
HUP, Pathology  Laboratory Medicine
Biomarker Research Laboratory
3400 Spruce St. 7 Maloney
Philadelphia, PA 19104
tel. (215) 662-3413

On 2010-08-10 11:38, David Winsemius wrote:


On Aug 10, 2010, at 11:23 AM, Michal Figurski wrote:


David,

I may have stated my problem incorrectly - my problem is to *obtain
the coordinates* for confidence boundary lines. As input data I have
only CIs for slope and intercept.


Wouldn't you also need to specify the range over which these estimates
might be valid and to offer the means for the X values? What level of R
knowledge are you at? You have provided no data or code. Many R methods
offer predict methods that return CI's.



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



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


Re: [R] Plotting confidence bands around regression line

2010-08-10 Thread Michal Figurski

Peter,

Since in PB the procedure is to calculate a whole list of slopes and 
intercepts, wouldn't it be a solution to determine the correlation and 
go from there? How do I do it?


--
Michal J. Figurski, PhD
HUP, Pathology  Laboratory Medicine
Biomarker Research Laboratory
3400 Spruce St. 7 Maloney
Philadelphia, PA 19104
tel. (215) 662-3413

On 2010-08-10 13:12, Peter Dalgaard wrote:

Michal Figurski wrote:


# And the result of the Passing-Bablok regression on this data frame:
 Estimate  5%CI 95%CI
Intercept -4.306197 -9.948438 -1.374663
Slope  1.257584  1.052696  1.679290

The original Passing  Bablok article on this method has an easy
prescription for CIs on coefficients, so I implemented that. Now I need
a way to calculate CI boundaries for individual points - this may be a
basic handbook stuff - I just don't know it (I'm not a statistician).


The answer is that you can't. You can't even do it with ordinary linear
regression without knowing the correlation between slope and intercept.
However, if you can get a CI for the intercept then you could subtract
x0 from all the x and get a CI for the value at x0.

(This brings echos from a distant past. My master's thesis was about
some similar median-type estimators. I can't remember whether I looked
at the Passing-Bablok paper at the time (1985!!) but my general
recollection is that this group of methods is littered with unstated
assumptions.)



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

2010-08-10 Thread Xia.Li

Let me give you a not that efficient one...

assume you have read the matrix (named as x) into R:

n=dim(x)[1]
y=matrix(0,n,n)
for (i in 1:n) y[x[i,1],x[i,2]]=x[i,3]


-- 
View this message in context: 
http://r.789695.n4.nabble.com/matrix-problem-tp2320193p2320219.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] matrix problem

2010-08-10 Thread William Dunlap

 -Original Message-
 From: r-help-boun...@r-project.org 
 [mailto:r-help-boun...@r-project.org] On Behalf Of zhenjiang xu
 Sent: Tuesday, August 10, 2010 11:03 AM
 To: R-help@r-project.org
 Subject: [R] matrix problem
 
 Hi,
 
 I have a file like this:
 1 2 0.1
 2 3 0.2
 3 1 0.3
 
 And I want to read it to create a matrix like this:
  [,1] [,2][,3]
 [1,]0   0.1 0
 [2,]0   00.2
 [3,]0.300
 
 How can I do it efficiently? Thanks.

Use a k-column matrix as a subscript into your
k-dimensional output array.  (k is 2 in your case.)

E.g., 'input' is your matrix in a form that one
can paste into an R session:
   input - cbind(c(1,2,3), c(2,3,1), c(.1,.2,.3))
   size - max(input[,1:2]) # you may want something else here
   output - matrix(0.0, size, size)
   output[input[,1:2]] - input[,3]
   output
   [,1] [,2] [,3]
  [1,]  0.0  0.1  0.0
  [2,]  0.0  0.0  0.2
  [3,]  0.3  0.0  0.0

Bill Dunlap
Spotfire, TIBCO Software
wdunlap tibco.com  

 -- 
 Best,
 Zhenjiang
 
   [[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] extracting information from an object

2010-08-10 Thread David Howell
I was working on a project involving a linear model, and wanted to 
extract the standard error of a predictor. I am able to do so, but not 
in the way I would expect.


I would have expected that if a created a model such as Model1 - 
lm(y~x,z,d), the object Model1 would contain that information even 
though it does not print it out when I simply type Model1. I would also 
have (wrongly) suspected that if I type summary(Model1) R would simply 
look at the object Model1 and find whatever it needs. But it doesn't 
work that way. If I want that standard error I have to first create a 
summary of Model1 and then extract the standard error from the summary 
with something like summary(Model1)$coefficients or, more specifically, 
summary(Model)$coefficients[2,2]. [I know that I can cram all of that 
into one line if I want to.] But doesn't that mean that when I ask for a 
summary R has to recreate the linear model all over again before pulling 
out the standard error. (Venables and Ripley, p. 77) suggest that this 
could happen if the method is not written correctly, but how is it not 
happening anyway?) And if so, if Model1 doesn't contain the raw data, 
how does summary produce an answer even if I delete one of the variables 
before calling it?


As you can see, I have figured out how to get what I want, but I don't 
understand the process of building objects, which is the important thing 
to understand. Perhaps I don't understand methods well enough.


Below is sample code:

#Sample for linear model

x - c(3,7,9,15,18)
y - c(5,4,8,6,9)
reg - lm(y~x)
reg
#Produces only the regression coefficients and using str(reg) indicates 
that

# that is all that it has.
regsummary - summary(reg)
#Produces what I need and str(regsummary) shows that st. errors are part 
of the object.

regsummary$coefficients[1:2, 1:4]

rm(y)
out - summary(reg)
# works just fine although y is no longer available and reg doesn't look 
like it

# could supply it.

Thanks,
Dave Howell

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


Re: [R] Plotting confidence bands around regression line

2010-08-10 Thread Frank Harrell



Thanks Michael,

That's the method that Dana Quade taught me in his intro 
nonparametrics course at UNC in the mid 1970s, at least for a single 
predictor.  His method did not incorporate the shift you mentioned 
though.  The method looks robust.  Not sure about efficiency.


Frank

Frank E Harrell Jr   Professor and ChairmanSchool of Medicine
 Department of Biostatistics   Vanderbilt University

On Tue, 10 Aug 2010, Michal Figurski wrote:


Frank,

I had to order this article through Inter-Library Loan and wait for it
for a week!

I'll try to make it short. In Passing-Bablok the principle is to
calculate slopes between all possible pairs of points in the dataset,
and then to take a shifted median of those slopes, where the offset is
the number of slopes of value (-1). Because of this, bootstrap is out
of question - it would take too much time.

Let n be the number of data points, N - the number of slopes and K -
the offset. The locations of CI boundaries in the set of N slopes are
then calculated with formulas:
M1 - N - qnorm(1 - conf.level/2) * sqrt((n*(n-1)*(2*n+5))/18))/2
M2 - N - M1 + 1

CIs for intercept are calculated as medians of y(i) - slopes[M1,M2]*x(i)

I hope I don't confuse anyone.

The article has a mathematical derivations section and justification
for these formulas. It looks solid to me, although after 25 years the
flaws may be apparent to some of you.

--
Michal J. Figurski, PhD
HUP, Pathology  Laboratory Medicine
Biomarker Research Laboratory
3400 Spruce St. 7 Maloney
Philadelphia, PA 19104
tel. (215) 662-3413

On 2010-08-10 12:29, Frank Harrell wrote:


Please give the prescription. The article is not available on our
extensive online library. I wonder if the method can compete with the
bootstrap.

Frank

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

On Tue, 10 Aug 2010, Michal Figurski wrote:


David,

I would consider myself intermediate in R, but a beginner in statistics.
I need a formula that would allow me to calculate confidence boundaries
of the regression line given the slope, intercept and their CIs (and
*any* range).

Passing-Bablok regression doesn't yet exist in R - I am developing it.
Therefore I am sure there is no predict method for it ;)

I believe I have provided sufficient data to address this problem, but
if that would help anyone, here is more:

# data frame

a - structure(list(x = c(0.1, 1.43, 4.21, 3.67, 3.23, 7.72, 5.99,

9.16, 10.6, 9.84, 11.94, 12.03, 12.89, 11.26, 15.54, 15.58, 17.32,
17.65, 19.52, 20.48, 20.44, 20.51, 22.27, 23.58, 25.83, 26.04, 26.92,
28.44, 30.73, 28.78), y = c(1.08, 1.39, 1.84, 0.56, 7.23, 4.91, 3.35,
7.09, 3.16, 8.98, 16.37, 7.46, 15.46, 23.2, 4.63, 11.13, 15.68, 13.92,
26.44, 21.65, 21.01, 20.22, 22.69, 22.21, 23.6, 17.24, 45.24, 30.09, 40,
49.6)), .Names = c(x, y), row.names = c(NA, -30L), class =
data.frame)

Then I run the regression procedure (in development - now part of the
'MethComp' package):

print(PBreg(a))


# And the result of the Passing-Bablok regression on this data frame:
Estimate 5%CI 95%CI
Intercept -4.306197 -9.948438 -1.374663
Slope 1.257584 1.052696 1.679290

The original Passing  Bablok article on this method has an easy
prescription for CIs on coefficients, so I implemented that. Now I need
a way to calculate CI boundaries for individual points - this may be a
basic handbook stuff - I just don't know it (I'm not a statistician). I
would appreciate if anyone could point me to a handbook or website where
it is described.

Regarding 2 - the predict method for 'nls' class currently *ignores* the
interval parameter - as it is stated in documentation.

Regards

--
Michal J. Figurski, PhD
HUP, Pathology  Laboratory Medicine
Biomarker Research Laboratory
3400 Spruce St. 7 Maloney
Philadelphia, PA 19104
tel. (215) 662-3413

On 2010-08-10 11:38, David Winsemius wrote:


On Aug 10, 2010, at 11:23 AM, Michal Figurski wrote:


David,

I may have stated my problem incorrectly - my problem is to *obtain
the coordinates* for confidence boundary lines. As input data I have
only CIs for slope and intercept.


Wouldn't you also need to specify the range over which these estimates
might be valid and to offer the means for the X values? What level of R
knowledge are you at? You have provided no data or code. Many R methods
offer predict methods that return CI's.



__
R-help@r-project.org mailing list
https://stat.ethz.ch/mailman/listinfo/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] partial match of one column in data frame to another character vector

2010-08-10 Thread Juliet Hannah
Here is some data (dput output below)

 myData
  id  group
1   D599  A
2   002-0004  B
3 F01932  A
18  F16   B
19  F28   A
20   A94  B


and a vector of IDs (the full label).

 fullID
[1] F16-284  ACC-A94-AB   ADAD599  002-0004BCC
CDCF01932.AB F28DDB   NOMATCH-EX

For each id in myData, there could be a partial match in fullID. For
example D599 in myData matches  ADAD599. I would like to add a column
to myData that contains the corresponding fullID or NA if a match was
not found.

Thanks for your help.

Juliet

#
#Data
#

myData - structure(list(id = structure(c(6L, 5L, 1L, 2L, 3L, 4L),
.Label = c( F01932,
   F16 ,F28 ,   A94,
   002-0004,  D599), class = factor), group = structure(c(5L,
4L, 1L, 3L, 2L, 3L), .Label = c( A,
   A,B,
  B,  A), class = factor)), .Names = c(id, group
), class = data.frame, row.names = c(1, 2, 3, 18, 19 ,
20  ))

fullID - c(F16-284, ACC-A94-AB, ADAD599, 002-0004BCC, CDCF01932.AB,
F28DDB, NOMATCH-EX)

__
R-help@r-project.org mailing list
https://stat.ethz.ch/mailman/listinfo/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] partial match of one column in data frame to another character vector

2010-08-10 Thread Henrique Dallazuanna
Try this:

myData$fullID - sapply(gsub(^ +| +$, ,  myData$id), grep, x = fullID,
value = TRUE)

On Tue, Aug 10, 2010 at 3:39 PM, Juliet Hannah juliet.han...@gmail.comwrote:

 Here is some data (dput output below)

  myData
  id  group
 1   D599  A
 2   002-0004  B
 3 F01932  A
 18  F16   B
 19  F28   A
 20   A94  B


 and a vector of IDs (the full label).

  fullID
 [1] F16-284  ACC-A94-AB   ADAD599  002-0004BCC
 CDCF01932.AB F28DDB   NOMATCH-EX

 For each id in myData, there could be a partial match in fullID. For
 example D599 in myData matches  ADAD599. I would like to add a column
 to myData that contains the corresponding fullID or NA if a match was
 not found.

 Thanks for your help.

 Juliet

 #
 #Data
 #

 myData - structure(list(id = structure(c(6L, 5L, 1L, 2L, 3L, 4L),
 .Label = c( F01932,
F16 ,F28 , 
  A94,
002-0004,  D599), class = factor), group = structure(c(5L,
 4L, 1L, 3L, 2L, 3L), .Label = c( A,
A,B,
   B,  A), class = factor)), .Names = c(id, group
 ), class = data.frame, row.names = c(1, 2, 3, 18, 19 ,
 20  ))

 fullID - c(F16-284, ACC-A94-AB, ADAD599, 002-0004BCC,
 CDCF01932.AB,
 F28DDB, NOMATCH-EX)

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




-- 
Henrique Dallazuanna
Curitiba-Paraná-Brasil
25° 25' 40 S 49° 16' 22 O

[[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] extracting information from an object

2010-08-10 Thread Erik Iverson

David,

I was working on a project involving a linear model, and wanted to 
extract the standard error of a predictor. I am able to do so, but not 
in the way I would expect.


I would have expected that if a created a model such as Model1 - 
lm(y~x,z,d), the object Model1 would contain that information even 
though it does not print it out when I simply type Model1. 


You can always see what information objects contain by using the ?str
function on them.

In this instance, str(Model1) will show the components of the Model1
object.


I would also 
have (wrongly) suspected that if I type summary(Model1) R would simply 
look at the object Model1 and find whatever it needs. But it doesn't 
work that way. 


Correct.  You can always see what a function does by printing its
definition at the R prompt.  In this case, typing summary.lm will
show you what the summary function does when passed an 'lm' object.


If I want that standard error I have to first create a 
summary of Model1 and then extract the standard error from the summary 
with something like summary(Model1)$coefficients or, more specifically, 
summary(Model)$coefficients[2,2]. 


Use the ?coef function for this purpose, which works with most modelling
functions, including 'lm'.

[I know that I can cram all of that 
into one line if I want to.] But doesn't that mean that when I ask for a 
summary R has to recreate the linear model all over again before pulling 
out the standard error. (Venables and Ripley, p. 77) 


Which book? I don't think MASS 4th edition.


suggest that this
could happen if the method is not written correctly, but how is it not 
happening anyway?) 


The Model1 object contains the necessary components to calculate the
quantity.  Look at how it's done in summary.lm.

And if so, if Model1 doesn't contain the raw data, 
how does summary produce an answer even if I delete one of the variables 
before calling it?




By default, an 'lm' object will contain the model.matrix.  See the ?lm 
value section for other components.


In general, it would be bad practice to have a function like summary.lm
depend not only on a supplied argument, but on some other object that it
is not a function of being present in the workspace.

As you can see, I have figured out how to get what I want, but I don't 
understand the process of building objects, which is the important thing 
to understand. Perhaps I don't understand methods well enough.


I think a combination of the ?str function, looking at the actual lm and 
summary.lm functions, and a careful reading of the help pages will help.




Below is sample code:

#Sample for linear model

x - c(3,7,9,15,18)
y - c(5,4,8,6,9)
reg - lm(y~x)
reg
#Produces only the regression coefficients and using str(reg) indicates 
that

# that is all that it has.
regsummary - summary(reg)
#Produces what I need and str(regsummary) shows that st. errors are part 
of the object.

regsummary$coefficients[1:2, 1:4]

rm(y)
out - summary(reg)
# works just fine although y is no longer available and reg doesn't look 
like it

# could supply it.


reg$model
reg$qr

__
R-help@r-project.org mailing list
https://stat.ethz.ch/mailman/listinfo/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] sapply/lapply instead of loop

2010-08-10 Thread GL

Using the input below, can I do something more elegant (and more efficient)
than the loop also listed below to pad strings to a width of 5? The true
matrix is about 300K rows and 31 columns. 

###
#INPUT
###
 temp
DX1   DX2   DX3
1 13761  8125 49178
2 63371   v75 22237
3 51745 77703 93500
4 64081 32826   v72
5 78477 43828 87645
 

###
#CODE
###

ssize - c(nrow(temp), ncol(temp))
aa - c(1:ssize[2])
aa - paste(DX, aa, sep = )
record - matrix(?, nrow = ssize, ncol = ssize[2])
colnames(record) - aa

mm - 0
#for (j in 1:1) {
for (j in 1:ssize[1]) {
mm - j
a - as.character(as.matrix(as.data.frame(temp[j,])))
len2 - sum(a != ?)
mi - 0
for (k in 1:len2) {
aa - a[k]
a0 - 5 - nchar(aa)
if (a0  0) {
for (st in 1:a0) {
  aa - paste(aa,  , sep = )
}
}
record[j, k] - aa
}
}

###
#OUTPUT
###

DX1   DX2   DX3
1 13761  8125 49178
2 63371   v75 22237
3 51745 77703 93500
4 64081 32826   v72
5 78477 43828 87645
-- 
View this message in context: 
http://r.789695.n4.nabble.com/sapply-lapply-instead-of-loop-tp2320265p2320265.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] problem installing boot package on Mac

2010-08-10 Thread Malcolm Fairbrother
Dear all,

I cannot seem to get boot running. Can anybody help? I've tried downloading 
and compiling the binary from 
http://cran.r-project.org/web/packages/boot/index.html, as well as the below. 
(Please see the scary-sounding error message, and the sessionInfo.) Neither 
works.

Any help would be much appreciated.

- Malcolm



 install.packages(boot, dependencies=T)
trying URL 
'http://cran.uk.r-project.org/bin/macosx/leopard/contrib/2.11/boot_1.2-42.tgz'
Content type 'application/x-gzip' length 448826 bytes (438 Kb)
opened URL
==
downloaded 438 Kb


The downloaded packages are in

/var/folders/8O/8OQqiVUgEBSa2PwHYc1b1E+++TI/-Tmp-//RtmpXuArKA/downloaded_packages
 library(boot)
Error in FUN(melanoma[[1L]], ...) : internal error -3 in R_decompress1
 boot
Error: object 'boot' not found


 sessionInfo()
R version 2.11.1 (2010-05-31) 
x86_64-apple-darwin9.8.0 

locale:
[1] en_GB.UTF-8/en_GB.UTF-8/C/C/en_GB.UTF-8/en_GB.UTF-8

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

other attached packages:
[1] coda_0.13-5deldir_0.0-12  maptools_0.7-34nlme_3.1-96   
[5] MASS_7.3-7 Matrix_0.999375-42 lattice_0.18-8 sp_0.9-66 
[9] foreign_0.8-40

loaded via a namespace (and not attached):
[1] boot_1.2-42  grid_2.11.1  spdep_0.5-17 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] sapply/lapply instead of loop

2010-08-10 Thread jim holtman
will this do what you want:

 newTemp[] - lapply(newTemp, function(.col){
+ # convert to character and pad to 5 space
+ sprintf(%5s, as.character(.col))
+ })

 str(newTemp)
'data.frame':   5 obs. of  3 variables:
 $ DX1: chr  13761 63371 51745 64081 ...
 $ DX2: chr   8125   v75 77703 32826 ...
 $ DX3: chr  49178 22237 93500   v72 ...



On Tue, Aug 10, 2010 at 2:55 PM, GL pfl...@shands.ufl.edu wrote:

 Using the input below, can I do something more elegant (and more efficient)
 than the loop also listed below to pad strings to a width of 5? The true
 matrix is about 300K rows and 31 columns.

 ###
 #INPUT
 ###
 temp
    DX1   DX2   DX3
 1 13761  8125 49178
 2 63371   v75 22237
 3 51745 77703 93500
 4 64081 32826   v72
 5 78477 43828 87645


 ###
 #CODE
 ###

 ssize - c(nrow(temp), ncol(temp))
 aa - c(1:ssize[2])
 aa - paste(DX, aa, sep = )
 record - matrix(?, nrow = ssize, ncol = ssize[2])
 colnames(record) - aa

 mm - 0
    #for (j in 1:1) {
    for (j in 1:ssize[1]) {
        mm - j
        a - as.character(as.matrix(as.data.frame(temp[j,])))
        len2 - sum(a != ?)
        mi - 0
        for (k in 1:len2) {
            aa - a[k]
            a0 - 5 - nchar(aa)
            if (a0  0) {
                for (st in 1:a0) {
                  aa - paste(aa,  , sep = )
                }
            }
            record[j, k] - aa
        }
    }

 ###
 #OUTPUT
 ###

    DX1   DX2   DX3
 1 13761  8125 49178
 2 63371   v75 22237
 3 51745 77703 93500
 4 64081 32826   v72
 5 78477 43828 87645
 --
 View this message in context: 
 http://r.789695.n4.nabble.com/sapply-lapply-instead-of-loop-tp2320265p2320265.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.




-- 
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] matrix problem

2010-08-10 Thread Wu Gong

Hi,

I guess you just want to reshape your data to wide format.

strs - Index Time Value
1 2 0.1
2 3 0.2
3 1 0.3
DF - read.table(textConnection(strs),header=T)
rDF - reshape(DF, idvar=Index, timevar=Time, direction=wide) 
rDF[is.na(rDF)] - 0

-
A R learner.
-- 
View this message in context: 
http://r.789695.n4.nabble.com/matrix-problem-tp2320193p2320287.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] sapply/lapply instead of loop

2010-08-10 Thread Henrique Dallazuanna
Try this:

formatC(as.matrix(temp))


On Tue, Aug 10, 2010 at 3:55 PM, GL pfl...@shands.ufl.edu wrote:


 Using the input below, can I do something more elegant (and more efficient)
 than the loop also listed below to pad strings to a width of 5? The true
 matrix is about 300K rows and 31 columns.

 ###
 #INPUT
 ###
  temp
DX1   DX2   DX3
 1 13761  8125 49178
 2 63371   v75 22237
 3 51745 77703 93500
 4 64081 32826   v72
 5 78477 43828 87645
 

 ###
 #CODE
 ###

 ssize - c(nrow(temp), ncol(temp))
 aa - c(1:ssize[2])
 aa - paste(DX, aa, sep = )
 record - matrix(?, nrow = ssize, ncol = ssize[2])
 colnames(record) - aa

 mm - 0
#for (j in 1:1) {
for (j in 1:ssize[1]) {
mm - j
a - as.character(as.matrix(as.data.frame(temp[j,])))
len2 - sum(a != ?)
mi - 0
for (k in 1:len2) {
aa - a[k]
a0 - 5 - nchar(aa)
if (a0  0) {
for (st in 1:a0) {
  aa - paste(aa,  , sep = )
}
}
record[j, k] - aa
}
}

 ###
 #OUTPUT
 ###

DX1   DX2   DX3
 1 13761  8125 49178
 2 63371   v75 22237
 3 51745 77703 93500
 4 64081 32826   v72
 5 78477 43828 87645
 --
 View this message in context:
 http://r.789695.n4.nabble.com/sapply-lapply-instead-of-loop-tp2320265p2320265.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.




-- 
Henrique Dallazuanna
Curitiba-Paraná-Brasil
25° 25' 40 S 49° 16' 22 O

[[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] sapply/lapply instead of loop

2010-08-10 Thread GL

Both of those approaches seem to return (  v75) instead of (v75  ). 
-- 
View this message in context: 
http://r.789695.n4.nabble.com/sapply-lapply-instead-of-loop-tp2320265p2320305.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] sapply/lapply instead of loop

2010-08-10 Thread Henrique Dallazuanna
So try:

format(as.matrix(temp))

On Tue, Aug 10, 2010 at 4:13 PM, GL pfl...@shands.ufl.edu wrote:


 Both of those approaches seem to return (  v75) instead of (v75  ).
 --
 View this message in context:
 http://r.789695.n4.nabble.com/sapply-lapply-instead-of-loop-tp2320265p2320305.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.




-- 
Henrique Dallazuanna
Curitiba-Paraná-Brasil
25° 25' 40 S 49° 16' 22 O

[[alternative HTML version deleted]]

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


[R] [R-pkgs] tikzDevice 0.5.0 released to CRAN

2010-08-10 Thread Charlie Sharpsteen
# tikzDevice

---

## Description

The tikzDevice package new graphics device for R which enables direct
output of graphics in a LaTeX-friendly way.  Plotting commands issued
by R functions are transformed into LaTeX code blocks.  These blocks
are interpreted with the help of TikZ-- a graphics library for TeX and
friends written by Till Tantau.

The tikzDevice supports three main modes of output:

  - Figure chunks: placed in .tex files and suitable for inclusion in
LaTeX documents via the \input{} command.

  - Stand alone figures: Complete LaTeX documents containing figure
code that can be compiled into stand-alone images.  Pages are
cropped to the size of the figure using the preview package.

  - Console output: TikZ code is returned directly to the R console
as a character vector for further manipulation.

## Beta Notice

The tikzDevice is currently flagged as a beta work.  The package is
reasonably stable and has been used by the authors to produce graphics
for academic publications for over a year.  The reason for beta status
is that there are several open design issues- two of which are:

  - Providing support for UTF8 text.

  - Supporting TeX variants other than LaTeX.

Resolving these issues may require changes to the tikzDevice that
break backwards compatibility with previous versions.  The beta flag
is a reminder that such changes may occur- although we will strive to
avoid them if possible.

The beta flag will be removed upon release of version 1.0. At this
time maintaining backwards compatibility will become a primary concern.

## Obtaining the Package

Stable versions of the tikzDevice may be downloaded from CRAN:

install.packages( 'tikzDevice' )

Development versions may be obtained from R-Forge:

install.packages( 'tikzDevice',
  repos='http://r-forge.r-project.net' )


## Reporting Bugs and Getting Help

The tikzDevice has a dedicated mailing list courtesy of R-Forge.  The
mailing list is the easiest way to get answers for questions related
to usage:

  tikzdevice-bugs @at@ lists.r-forge.r-project.org

Primary development takes place on GitHub.  Bugs and feature requests
may be made by opening issues at the primary repository:

  http://github.com/Sharpie/RTikZDevice/issues

Adventurous users are encouraged to fork the repository and contribute
to the development of the device!

## Latest Changes
*See the CHANGELOG for changes that occurred in previous releases*

---

### Version 0.5.0 Beta

---

 Contributors
The following people contributed to this release of the tikzDevice:

- Lorenzo Isella contributed bug reports and examples that led to the
  discovery of a bug in fontsize calculations that appeared when
  certain LaTeX commands were used to change the active font.

- Vivianne Vilar for spotting spelling and grammar errors in the
  vignette.

- Gabor Grothendieck for the idea for sending output to the screen
  for use with sink() (i.e. the console option)

 New Features

- console option for directing tikz() output back into the R console
  instead of to a file.

- Preliminary support for a sanitize option which allows automatic
  escaping of characters that have special meaning to TeX like $ and
  %.

- tikzAnnotate() and tikzCoord() functions.  tikzAnnotate() allows
  arbitrary LaTeX code to be injected into the output stream of an
  active tikz() graphics device.  tikzCoord() is a wrapper for
  tikzAnnotate() that inserts named locations into the graphics code.
  These locations may be referenced by other TikZ drawing commands.


 Bug Fixes

- Removed bad colon in the DESCRIPTION file.

- Proper fontsize calculations now include ps from par() and fontsize
  from gpar().  This fixes issues with lattice-based graphics such as
  ggplot2.

- Metrics are now calculated properly when commands like
  \renewcommand\rmdefault are used to adjust the active font.

- Sanitization of % signs in labels.

- The package no longer overwrites user customizations set in places like
  .Rprofile with default values when loaded.

- Attempting to use new graphics functions such as rasterImage() now
  produces error messages instead of fatal crashes in R 2.11.0 and
  above.

[[alternative HTML version deleted]]

___
R-packages mailing list
r-packa...@r-project.org
https://stat.ethz.ch/mailman/listinfo/r-packages

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


Re: [R] sapply/lapply instead of loop

2010-08-10 Thread GL

That works great, and is ever so much simpler. Thanks much!
-- 
View this message in context: 
http://r.789695.n4.nabble.com/sapply-lapply-instead-of-loop-tp2320265p2320317.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 draw a spherical quadrant

2010-08-10 Thread [Ricardo Rodriguez] Your XEN ICT Team

Thanks, Jim!

Jim Lemon wrote:

You may find that the radial.plot function in the plotrix package will 
do what you want. I think you are looking at the polygon type of plot.


It seems to me that I've a lot of things to learn only from plotrix 
package! With the functions included in this package seems relatively 
easy to get a planar projection of the spherical quarter holding all 
power values. But, please, do you know if is there any package that 
could be able to add some 3D effect to the representation?


For instance, look at this MATLAB example:

http://www.matrixlab-examples.com/3D-plot-part3.html

Thanks!

Greetings,

Ricardo

--
Ricardo Rodríguez
Your XEN ICT Team

__
R-help@r-project.org mailing list
https://stat.ethz.ch/mailman/listinfo/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 draw a spherical quadrant

2010-08-10 Thread Duncan Murdoch

On 10/08/2010 3:34 PM, [Ricardo Rodriguez] Your XEN ICT Team wrote:

Thanks, Jim!

Jim Lemon wrote:

 You may find that the radial.plot function in the plotrix package will 
 do what you want. I think you are looking at the polygon type of plot.


It seems to me that I've a lot of things to learn only from plotrix 
package! With the functions included in this package seems relatively 
easy to get a planar projection of the spherical quarter holding all 
power values. But, please, do you know if is there any package that 
could be able to add some 3D effect to the representation?


For instance, look at this MATLAB example:

http://www.matrixlab-examples.com/3D-plot-part3.html
  



The rgl package can do general 3D plotting, but I don't know of anyone 
who has put together what you're looking for, so you'll need to compute 
the individual line segments or polygons yourself.


Duncan Murdoch

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


Re: [R] Importing arguments for use by functions in a script

2010-08-10 Thread EvansA

Thank you for your response.

Re: I guess my point with all that is that you might reconsider problem and
what your goal is

You are quite right, I just got caught up with the not being able to do
something - and now see the error of my ways. 

But I am glad to see your solution.
-- 
View this message in context: 
http://r.789695.n4.nabble.com/Importing-arguments-for-use-by-functions-in-a-script-tp2317758p2320383.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] Intersecting list vs rows in matrix

2010-08-10 Thread GL

Know that if I have List_1 and List_2 that I can check to see if the
intersect via the code below:

List _1: 
a, b, c, d, e, f, g 
List_2: 
z, y, x, w, v, u, b 
length(intersect(List_1, List_2))  0
return = true

If instead I wanted to check a dataframe that is a list of lists, how
would I do that by record without looping?

List _1: 
a, b, c, d, e, f, g 

List_2: 
z, y, x, w, v, u, b 
y, z, w, v, v, u, m
z, y, x, a, b, c
.
.
.

return
true
false
true
,
,
,

-- 
View this message in context: 
http://r.789695.n4.nabble.com/Intersecting-list-vs-rows-in-matrix-tp2320427p2320427.html
Sent from the R help mailing list archive at Nabble.com.

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


Re: [R] regression line of 2 independent variables

2010-08-10 Thread David Reiner
If appropriate for your data, you could try errors-in-variables (package leiv)
or use the first component from principal components.
HTH,
-- David


-Original Message-
From: r-help-boun...@r-project.org [mailto:r-help-boun...@r-project.org] On 
Behalf Of array chip
Sent: Monday, August 09, 2010 11:34 AM
To: r-help@r-project.org
Subject: [R] regression line of 2 independent variables

Hi, I would like to a draw a scatterplot of x1 and x2 (plot (x1, x2)), and also
want to draw a sort of regression line across the data points. But x1 and x2
are just 2 independent variables, so in this case a regression of x1 over x2, or
vice versa, is not appropriate per se. What would be an appropriate way to do
this? Thanks for any suggestions.

John

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


This e-mail and any materials attached hereto, including, without limitation, 
all content hereof and thereof (collectively, XR Content) are confidential 
and proprietary to XR Trading, LLC (XR) and/or its affiliates, and are 
protected by intellectual property laws.  Without the prior written consent of 
XR, the XR Content may not (i) be disclosed to any third party or (ii) be 
reproduced or otherwise used by anyone other than current employees of XR or 
its affiliates, on behalf of XR or its affiliates.

THE XR CONTENT IS PROVIDED AS IS, WITHOUT REPRESENTATIONS OR WARRANTIES OF ANY 
KIND.  TO THE MAXIMUM EXTENT PERMISSIBLE UNDER APPLICABLE LAW, XR HEREBY 
DISCLAIMS ANY AND ALL WARRANTIES, EXPRESS AND IMPLIED, RELATING TO THE XR 
CONTENT, AND NEITHER XR NOR ANY OF ITS AFFILIATES SHALL IN ANY EVENT BE LIABLE 
FOR ANY DAMAGES OF ANY NATURE WHATSOEVER, INCLUDING, BUT NOT LIMITED TO, 
DIRECT, INDIRECT, CONSEQUENTIAL, SPECIAL AND PUNITIVE DAMAGES, LOSS OF PROFITS 
AND TRADING LOSSES, RESULTING FROM ANY PERSON'S USE OR RELIANCE UPON, OR 
INABILITY TO USE, ANY XR CONTENT, EVEN IF XR IS ADVISED OF THE POSSIBILITY OF 
SUCH DAMAGES OR IF SUCH DAMAGES WERE FORESEEABLE.

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

2010-08-10 Thread Wu Gong

Hi Carlos,

I give a handmade code, hope it helps.

y - list()
y$a - a
y$b - c(b,c)
names(y$a) - i
names(y$b) - c(j,k)


Carlos Petti wrote:
 
 a - 5
 names(a) - a
 b - 9
 names(b) - b
 c - 15
 names(c) - c
 x - list(i = a, j = b, j = c)
 


-
A R learner.
-- 
View this message in context: 
http://r.789695.n4.nabble.com/How-to-invert-a-list-tp2320108p2320433.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] Importing arguments for use by functions in a script

2010-08-10 Thread Joshua Wiley
I just got caught up with the not being able to do something

I have done that so frequently I think I should include at the
beginning of each of my R sessions:
When you find the path hard and steep, it's probably because you
missed the trail.

It always seems the more frustrating the problem, the simpler the solution.

Cheers,

Josh

On Tue, Aug 10, 2010 at 1:11 PM, EvansA annaevan...@hotmail.com wrote:

 Thank you for your response.

 Re: I guess my point with all that is that you might reconsider problem and
 what your goal is

 You are quite right, I just got caught up with the not being able to do
 something - and now see the error of my ways.

 But I am glad to see your solution.
 --
 View this message in context: 
 http://r.789695.n4.nabble.com/Importing-arguments-for-use-by-functions-in-a-script-tp2317758p2320383.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.


Re: [R] Intersecting list vs rows in matrix

2010-08-10 Thread Erik Iverson



GL wrote:

Know that if I have List_1 and List_2 that I can check to see if the
intersect via the code below:

List _1: 
a, b, c, d, e, f, g 
List_2: 
z, y, x, w, v, u, b 
length(intersect(List_1, List_2))  0

return = true

If instead I wanted to check a dataframe that is a list of lists, how
would I do that by record without looping?

List _1: 
a, b, c, d, e, f, g 

List_2: 
z, y, x, w, v, u, b 
y, z, w, v, v, u, m

z, y, x, a, b, c
.
.
.

return
true
false
true


*Please* use actual R code and objects to represent your examples, not
pseudo-code!  I believe you may have some confusion about the difference
between lists and vectors in R.  A data.frame is a list, but not a list
of lists.

Since you haven't given a reproducible example, it's hard for me to know
exactly what you want.

Assume a data.frame df1 composed of all character data, and a character
vector cv to match against.

apply(df1, 1, function(x) length(intersect(x, cv))  0)

may do what you want.

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