[R] Problems with dmvnorm and outer

2010-03-28 Thread Severin Kacianka

Hello,

I try to create a persp-plot for the bivariate normal distribution. 
There are a few solutions online ([1],[2]), but I did not want to 
hard-code the formula like [2] did or use a kernel density estimate like 
[1].


My plan was to use dmvnorm, and use outer to calculate the z-dimension 
for each point. Here is what I tried:

library(mvtnorm)
x-seq(0,1,len=40)
y-x
g-function(a,b) {
dmvnorm(x=c(a,b))
}
z-outer(x,y,g)

Which results in the following error:
Error in dim(robj) - c(dX, dY) :
  dims [product 1600] do not match the length of object [1]

What causes this error? If I set g to be a simple function like:
g-function(a,b){
a*b
}
Everything works fine. Why does it fail when I pass the parameters to 
dmvnorm?


Thank you for your time,
Severin

[1]https://stat.ethz.ch/pipermail/r-help/2003-September/038314.html
[2]http://www.stat.ucl.ac.be/ISpersonnel/lecoutre/stats/fichiers/_gallery.pdf

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

2010-03-28 Thread Robert Ruser
Chuck thank you very much for help. I will follow your advice and see
what happen.

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

2010-03-28 Thread ManInMoon

Is there a 64 bit R - and where can I get hold of it for Windows please?

Your sizes function is useful thanks - but is there some R parameter to
allow maximum usage of memory?
-- 
View this message in context: 
http://n4.nabble.com/R-Cmdr-memory-tp1693483p1693978.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] any quick way to write this label

2010-03-28 Thread Roslina Zakaria
Hi r-users,
 
Is there any quick way to write this label?
 
c(0,50,100,150,200,250,300,350,400,450,
500,550,600,650,700,750,800,850,900)
 
Thank you.




  
[[alternative HTML version deleted]]

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


Re: [R] any quick way to write this label

2010-03-28 Thread Barry Rowlingson
On Sun, Mar 28, 2010 at 8:56 AM, Roslina Zakaria zrosl...@yahoo.com wrote:
 Hi r-users,

 Is there any quick way to write this label?

 c(0,50,100,150,200,250,300,350,400,450,
 500,550,600,650,700,750,800,850,900)

Not sure what you mean by 'write this label'. But to generate that
vector, yes there is a quick way...

Hint:
 Use 'seq' to generate the numeric sequence and then use as.character
to make it into character values.

Barry

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


Re: [R] any quick way to write this label

2010-03-28 Thread Jim Lemon

On 03/28/2010 07:56 PM, Roslina Zakaria wrote:

Hi r-users,

Is there any quick way to write this label?

c(0,50,100,150,200,250,300,350,400,450,
500,550,600,650,700,750,800,850,900)


Hi Rosalina,
I'm going to take a leap in the dark and guess that you want to use 
these as axis labels and want them all to appear. Have a look at the 
staxlab 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.


[R] Design of a survey using the survey package

2010-03-28 Thread Tom La Bone

I have looked through the new Complex Surveys book and the documentation
for the survey package and it appears to me that there are no functions in
survey that help one to design a sampling scheme. For example, in the book
section 2.8 discusses the design of stratified samples, but there is no
mention of any functions in the survey package that implement the
discussed strategies. So, am I missing something obvious here or is the
survey package meant only for analyzing survey data once you have it in
hand?

Tom 
-- 
View this message in context: 
http://n4.nabble.com/Design-of-a-survey-using-the-survey-package-tp1694075p1694075.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] Design of a survey using the survey package

2010-03-28 Thread Tobias Verbeke

Tom La Bone wrote:


I have looked through the new Complex Surveys book and the documentation
for the survey package and it appears to me that there are no functions in
survey that help one to design a sampling scheme. For example, in the book
section 2.8 discusses the design of stratified samples, but there is no
mention of any functions in the survey package that implement the
discussed strategies. So, am I missing something obvious here or is the
survey package meant only for analyzing survey data once you have it in
hand?


Yes.

 packageDescription(survey)
Package: survey
Title: analysis of complex survey samples
[...]

For drawing samples, see e.g. the sampling package:

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

HTH,
Tobias

__
R-help@r-project.org mailing list
https://stat.ethz.ch/mailman/listinfo/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] Assigning factors probabilistically based on the value of another variable.

2010-03-28 Thread Economics Guy
 It is really the same thing. One of many possibilities:

 theFrame - data.frame(theValues=runif(150,-10,10))
 exact - diag(15)[1+ (rank(theFrame$theValues)-1)%/%10,]
 not.so.exact - diag(15)[1+
 (rank(theFrame$theValues+runif(150,0,3))-1)%/%10,]

 If what you actually wanted was one factor with fifteen levels, just wrap
 the subscript in the last assignment in factor() instead.

 HTH,

 Chuck

Thanks Chuck, this does what I asked for:

theValues - runif(150,-10,10)
exact - factor(1+(rank(theValues)-1)%/%100)

Unfortunately, it looks like my example may have been too contrived
for my actual program.

In the solution that Chuck proposed he antisipated that I may not want
the assignment of factor levels to be exact:

notSoExact - factor(1+(rank(theValues+runif(150,0,3)-1)%/%100)

This is close to what I need. However, in the real program what I need
to be able to do is precisely vary the degree of exactness in the
assignment. So I need to be able to have the assignment range from
completely random assignment to the exact assignment that exact
above provides.

Anyone think of a simple way to do this?

Thanks Agan,

That Economics Guy

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


Re: [R] Problems with dmvnorm and outer

2010-03-28 Thread David Winsemius


On Mar 28, 2010, at 3:19 AM, Severin Kacianka wrote:


Hello,

I try to create a persp-plot for the bivariate normal distribution.  
There are a few solutions online ([1],[2]), but I did not want to  
hard-code the formula like [2] did or use a kernel density estimate  
like [1].


My plan was to use dmvnorm, and use outer to calculate the z- 
dimension for each point. Here is what I tried:

library(mvtnorm)
x-seq(0,1,len=40)
y-x
g-function(a,b) {
dmvnorm(x=c(a,b))


The construction c(a,b) would in the later function call turn those  
two 40 element vectors into an 80 element vector. See if you get  
better success with cbind.



}
z-outer(x,y,g)

Which results in the following error:
Error in dim(robj) - c(dX, dY) :
 dims [product 1600] do not match the length of object [1]

What causes this error? If I set g to be a simple function like:
g-function(a,b){
a*b
}
Everything works fine. Why does it fail when I pass the parameters  
to dmvnorm?


Thank you for your time,
Severin

[1]https://stat.ethz.ch/pipermail/r-help/2003-September/038314.html
[2]http://www.stat.ucl.ac.be/ISpersonnel/lecoutre/stats/fichiers/_gallery.pdf




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] R Cmdr memory

2010-03-28 Thread David Winsemius


On Mar 28, 2010, at 4:35 AM, ManInMoon wrote:



Is there a 64 bit R - and where can I get hold of it for Windows  
please?


For Windows XP?, Not that I know of. There are proprietary versions  
for Vista and I believe Professor Ripley is working on an experimental  
version for the 64 bit versions of Windows.




Your sizes function is useful thanks - but is there some R parameter  
to

allow maximum usage of memory?


Read the Windows FAQ and seearch on memory.

--

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 make stacked plot?

2010-03-28 Thread sdzhangping
Dear friends:
 I'm interested to make a stacked plot of cumulative incidence. that's, 
the cuminc model is fitted [fit=cuminc(time, relapse)] and cumulative incidence 
is in place. I'd like to stack the cuminc plots(line 1: relapse of luekemia and 
line 2: treatment related mortality, for example) , then  the constituent ratio 
of leukemia relapse and treatment related mortality is very clear. Can you give 
me some directions?
 Yours Ping Zhang
   
   



[[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] survival data with competing risks and time-dependent covariates!

2010-03-28 Thread sdzhangping
Dear friends:

  I’m very interested in the analysis of survival data of leukemic patients, 
which involves competing risks and time-dependent covariates (infections or 
relapse of leukemia after BMT). In my present work, I’d like to estimate the 
risk of chemotherapy, BMT or gvhd on the onset and prognosis of invasive fungal 
infections (IFI). In detail, the leukemic patients will receive several cycles 
of chemotherapy and some of them will receive BMT. The patients have three 
outcomes, that’s acquisition of IFI, death free from IFI or IFI free survival. 
My puzzle is: 

(1)Dose multi-state model fit this situation? 

(2)I tried to fit coxphf model:  fit = coxphf(Surv(start,stop,ifi==1)~bmt, 
data=ifi). The system always goes wrong when variable “gvhd” was fitted. 
[coxphf(Surv(start,stop,ifi==1)~bmt+gvhd, data=ifi)]. Is there something wrong 
with my data format?

Thank you!

Ping Zhang

Mar 26 2010

 

simulation dataset of six patients: (with ifi.csv in the attachment)  

  id  start stop ifi chemo  bmt  gvhd  death   

   1 0 7   01  0  0   0 #chemo at d7 and 
died at d30

   1 0 7   01  0  0   0   

   2 0 8   01  0  00#chemo1 at d7, ifi 
at d100, chemo2 at d120 ,bmt at d200 and death at d450

   28 100  1  0   0 00

   2100  120  0  1   0 0   0

   2120  200  0 0   1  00

   2200   450  00   0  01

   30 6   0 1  0  00   #chemo1 at d6, ifi 
at d44, chemo2 at d60, censor at d300

   3644  1 0  0   0   0

   344   60  0 1  0  0   0

   360 300  0  0  0  0   0

   4  0   10  0  1  0  0   0   #chemo1 at d10, 
chemo2 at d60,

   4 10  60   0 1  0  0   0   #bmt at d120, 
censor at d300

   4 60  120  0 0 1  0   0

   4 120 300  00 0  00

   50   91 00   0   0   #ifi at d9, die 
at d30

   59   30  0 0 0   0   0

   6  300 301  0 0 1   0  0  #(left censored) 
bmt at d301, gvhd at d330, ifi at 340, death at 350

   6  301 330  0 0 0   1  0  

   6  330 340  1 0  0  0  0

   6  340 350  0 0 0   0  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] R Cmdr memory

2010-03-28 Thread Duncan Murdoch

On 28/03/2010 9:03 AM, David Winsemius wrote:

On Mar 28, 2010, at 4:35 AM, ManInMoon wrote:

Is there a 64 bit R - and where can I get hold of it for Windows  
please?


For Windows XP?, Not that I know of. There are proprietary versions  
for Vista and I believe Professor Ripley is working on an experimental  
version for the 64 bit versions of Windows.


We're planning to release 64 bit builds with R 2.11.0.  They are 
currently being built as part of the test process, though the builds are 
still a little irregular.  You can download from CRAN 
mirror/bin/windows64/contrib for now, and soon from CRAN 
mirror/bin/windows64/base.


The 64 bit versions of R will require a 64 bit version of Windows to run 
on.  I think there may be 64 bit versions of XP, but they are uncommon 
and I don't know if they support our builds; we're testing in 64 bit 
Vista and Windows 7.


Revolution Computing also sells a build produced with a different 
compiler.  It has the advantage that the compiler is probably in better 
shape than the one we are using and they'll provide support with it; the 
disadvantage is that they'll charge for it, and they are probably not as 
up to date as us with respect to released version number.


Duncan Murdoch



Your sizes function is useful thanks - but is there some R parameter  
to

allow maximum usage of memory?


Read the Windows FAQ and seearch on memory.



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

2010-03-28 Thread Stefan Grosse
Am 28.03.2010 15:06, schrieb sdzhangping:
 Dear friends:
  I'm interested to make a stacked plot of cumulative incidence. 
 that's, the cuminc model is fitted [fit=cuminc(time, relapse)] and cumulative 
 incidence is in place. I'd like to stack the cuminc plots(line 1: relapse of 
 luekemia and line 2: treatment related mortality, for example) , then  the 
 constituent ratio of leukemia relapse and treatment related mortality is very 
 clear. Can you give me some directions?
  Yours Ping Zhang
   

Dear friend what makes you think that if you repost your question
again and again with the same text you will somehow receive an answer? I
believe the lack of an answer might be due to the lack of you showing
some effort on explaining what you did, what you want and what went
wrong. You already got an answer suggesting a package but you did not
respond.

There is a reason why every mail gets attached this text:

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

If you want help, make it people easy.

Stefan.

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


Re: [R] Problems with dmvnorm and outer

2010-03-28 Thread Severin Kacianka

Hello David and Dennis,

thank you two for your replies. You not only helped me solve my problem, 
but also helper me to understand my problem better.

Here is my -now working- code:

x-y-seq(-4,4,len=40)

g-function(a,b) {
dmvnorm(x=cbind(a,b),sigma=matrix(c(4,2,2,3), ncol = 2))
}
z-outer(x,y,g)
persp(x,y,z)

Thank you a lot!

Severin

__
R-help@r-project.org mailing list
https://stat.ethz.ch/mailman/listinfo/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] survival data with competing risks and time-dependent covariates!

2010-03-28 Thread Stefan Grosse
Am 28.03.2010 15:08, schrieb sdzhangping:
   I??m very interested in the analysis of survival data of leukemic patients, 
 which involves competing risks and time-dependent covariates (infections or 
 relapse of leukemia after BMT). In my present work, I??d like to estimate the 
 risk of chemotherapy, BMT or gvhd on the onset and prognosis of invasive 
 fungal infections (IFI). In detail, the leukemic patients will receive 
 several cycles of chemotherapy and some of them will receive BMT. The 
 patients have three outcomes, that??s acquisition of IFI, death free from IFI 
 or IFI free survival. My puzzle is: 

 (1)Dose multi-state model fit this situation? 

 (2)I tried to fit coxphf model:  fit = coxphf(Surv(start,stop,ifi==1)~bmt, 
 data=ifi). The system always goes wrong when variable ??gvhd?? was fitted. 
 [coxphf(Surv(start,stop,ifi==1)~bmt+gvhd, data=ifi)]. Is there something 
 wrong with my data format?
 ted, minimal, self-contained, reproducible code.
   

You were posting exactly this question already on Friday twice and then
today twice. You have been pointed out that you might be using the wrong
function. So why should anyone answer you question when you do not show
any effort? You did not even ask back.

Stefan

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

2010-03-28 Thread Uwe Ligges



On 28.03.2010 15:20, Duncan Murdoch wrote:

On 28/03/2010 9:03 AM, David Winsemius wrote:

On Mar 28, 2010, at 4:35 AM, ManInMoon wrote:


Is there a 64 bit R - and where can I get hold of it for Windows please?


For Windows XP?, Not that I know of. There are proprietary versions
for Vista and I believe Professor Ripley is working on an experimental
version for the 64 bit versions of Windows.


We're planning to release 64 bit builds with R 2.11.0. They are
currently being built as part of the test process, though the builds are
still a little irregular.


 You can download from CRAN

mirror/bin/windows64/contrib for now, and soon from CRAN
mirror/bin/windows64/base.





The 64 bit versions of R will require a 64 bit version of Windows to run
on. I think there may be 64 bit versions of XP, but they are uncommon
and I don't know if they support our builds; we're testing in 64 bit
Vista and Windows 7.



Actually, the 64-bit version that you can currently download is a daily 
build on Windows Server 2008 (where all the package checks happen as well).


Uwe



Revolution Computing also sells a build produced with a different
compiler. It has the advantage that the compiler is probably in better
shape than the one we are using and they'll provide support with it; the
disadvantage is that they'll charge for it, and they are probably not as
up to date as us with respect to released version number.

Duncan Murdoch




Your sizes function is useful thanks - but is there some R parameter to
allow maximum usage of memory?


Read the Windows FAQ and seearch on memory.



__
R-help@r-project.org mailing list
https://stat.ethz.ch/mailman/listinfo/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] any quick way to write this label

2010-03-28 Thread Rainer Hurling

On 28.03.2010 13:33 (UTC+1), Jim Lemon wrote:

On 03/28/2010 07:56 PM, Roslina Zakaria wrote:

Hi r-users,

Is there any quick way to write this label?

c(0,50,100,150,200,250,300,350,400,450,
500,550,600,650,700,750,800,850,900)


If it is not for graphics, perhaps this helps?

as.character(seq(0,900,50))

Rainer


Hi Rosalina,
I'm going to take a leap in the dark and guess that you want to use
these as axis labels and want them all to appear. Have a look at the
staxlab 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] Matching pairs of values

2010-03-28 Thread Bert Gunter
Sorting is unnecesssary. If column order is unimportant, identical() is
unnecessary.

foo - function(x,lookfor)apply(x,1,function(x)all(lookfor %in% x
 
will do. If column order is important, 

apply(x,1,identical,lookfor)

will do.

Bert Gunter
Genentech Nonclinical Statistics

-Original Message-
From: r-help-boun...@r-project.org [mailto:r-help-boun...@r-project.org] On
Behalf Of David Scott
Sent: Saturday, March 27, 2010 8:36 PM
To: Peter Ehlers
Cc: r-help@r-project.org; Berend Hasselman
Subject: Re: [R] Matching pairs of values

Many thanks Peter and Berend.

I think I can make this work for my problem. Apologies for not giving an 
example: I was a bit tired and frustrated when I posted to R-help and 
only on later reflection realised that I didn't really follow the 
posting guidelines.

David

Peter Ehlers wrote:
 (Sorry, I think that I just hit a wrong button and managed
 to send a non-reply.)
 
 I think that David might have meant that the column order of the
 numbers in lookfor is unimportant. In that case, a simple fix would
 be either to check both lookfor and rev(lookfor) (since the
 matrix is nX2) or to sort before testing:
 
   vtest - function(x, lookfor){
   any(apply(x, 1, function(v)
   {identical(sort(v), sort(lookfor))}))}
 
   -Peter Ehlers
 
 
 On 2010-03-27 2:46, Berend Hasselman wrote:

 David Scott-6 wrote:
 I am sure someone can come up with a clever way of doing what I want---I
 don't seem to be able to.

 I want to check if a pair of numbers occurs as one of the rows of an n
 by 2 matrix. If I was only checking whether a single number was in a
 vector of numbers I would use %in% but I can't see how to generalize to
 this case.

 Would this help?

 vtest- function(x, lookfor) any(apply(x,1, function(v)
 identical(v,lookfor)))

 ma- matrix(c(2,3,1,5,7,3),ncol=2)
 ma
   [,1] [,2]
 [1,]25
 [2,]37
 [3,]13
 vtest(ma,c(3,7))
 [1] TRUE
 vtest(ma,c(1,7))
 [1] FALSE

 Berend
 


-- 
_
David Scott Department of Statistics
The University of Auckland, PB 92019
Auckland 1142,NEW ZEALAND
Phone: +64 9 923 5055, or +64 9 373 7599 ext 85055
Email:  d.sc...@auckland.ac.nz,  Fax: +64 9 373 7018

Director of Consulting, Department of Statistics

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

2010-03-28 Thread David Winsemius


On Mar 28, 2010, at 9:36 AM, Severin Kacianka wrote:


Hello David and Dennis,

thank you two for your replies. You not only helped me solve my  
problem, but also helper me to understand my problem better.

Here is my -now working- code:

x-y-seq(-4,4,len=40)

g-function(a,b) {
dmvnorm(x=cbind(a,b),sigma=matrix(c(4,2,2,3), ncol = 2))
}
z-outer(x,y,g)
persp(x,y,z)



From that point, you will get a better idea of what you are looking  
at with some additional views:

 persp(x,y,z)
 persp(x,y,z, theta=-45)
 persp(x,y,z, theta=-60)
 persp(x,y,z, theta=-90)
 persp(x,y,z, theta=-135)



--

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] insert/copy skipped lines to output

2010-03-28 Thread Jannis

Hallo,

have a look at the documentation of the different output functions
(write(),cat(),write.table()). Most of them have an argument like
append. If you set this to TRUE, your command adds the lines you are
writing into the file to the lines already existent in that file. So if
you run this write() command first with your additional data (header
data) and then with the real data and append=TRUE, your information
ends up in the same file.


HTH
Jannis


Muhammad Rahiz schrieb:

Hello all,

I'd like some advise on this. When I read my files, I pass the 
argument, skip=6, to skip 6 lines of header information. After 
performing the desired calculations, I have the output. Now I want to 
copy the 6 lines of skipped information to the output.


What I've been doing so far is to use a shell script (i.e. the cat 
function)  to copy the header information to the output file. This 
means I need 2 additional files, namely a file containing the header 
information only, and the shell script to run the the function.


Is there a direct way to perform this in R?

The following forms the main component of my R script;

x - as.matrix(read.table(file.txt,skip=6))
y - x*2
write.table(y,output.txt,row.names=FALSE,col.names=FALSE)


Thanks

Muhammad

__
R-help@r-project.org mailing list
https://stat.ethz.ch/mailman/listinfo/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] Calculate variance/covariance with complex numbers

2010-03-28 Thread Ben Bolker
Gang Chen gangchen6 at gmail.com writes:

 
 Thanks a lot for the help, Ben Bolker and Chuck!
 
 Chuck, it seems your version needs a little modification. Instead of this:
 
  xri - matrix(rnorm(1)+1i*rnorm(1),nc=2)
  crossprod(xri-colMeans(xri))/(nrow(xri)-1)
 
 it seems to me it should be this (maybe there is a more elegant
 modification than mine?):
  crossprod(t(apply(xri, 1, '-', colMeans(xri/(nrow(xri)-1)
 

   Not sure, but you could take a look at sweep() and scale( ,scale=FALSE)
for slightly more specialized/efficient ways of doing the column centering,
i.e.

  crossprod(scale(xri,scale=FALSE))/(nrow(xri)-1)

 (warning, almost completely untested)

  Ben

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

2010-03-28 Thread Muhammad Rahiz

Dear Jannis,

Thanks for the tip. It works but I'd like to improve on the way I did it.

x - array(1:50,dim=c(10,10)) # data

h1 - c(ncols180) # header, line 1
h2 - c(nrows   290) # header, line 2
h3 - c(xllcorner   -20) # header, line 3
h4 - c(yllcorner   -20) # header, line 4
h5 - c(cellsize 5000) # header, line 5
h6 - c(NODATA_value  NA) # header, line 6

h0 - rbind(h1,h2,h3,h4,h5,h6)

write(ho,file.txt)
write.table(x,file.txt,row.names=FALSE,col.names=FALSE,append=TRUE)

The header should display as;

ncols   180
nrows  290
xllcorner  -20
yllcorner  -20
cellsize 5000
NODATA_value NA





Jannis wrote:

Hallo,

have a look at the documentation of the different output functions
(write(),cat(),write.table()). Most of them have an argument like
append. If you set this to TRUE, your command adds the lines you are
writing into the file to the lines already existent in that file. So if
you run this write() command first with your additional data (header
data) and then with the real data and append=TRUE, your information
ends up in the same file.


HTH
Jannis


Muhammad Rahiz schrieb:
  

Hello all,

I'd like some advise on this. When I read my files, I pass the 
argument, skip=6, to skip 6 lines of header information. After 
performing the desired calculations, I have the output. Now I want to 
copy the 6 lines of skipped information to the output.


What I've been doing so far is to use a shell script (i.e. the cat 
function)  to copy the header information to the output file. This 
means I need 2 additional files, namely a file containing the header 
information only, and the shell script to run the the function.


Is there a direct way to perform this in R?

The following forms the main component of my R script;

x - as.matrix(read.table(file.txt,skip=6))
y - x*2
write.table(y,output.txt,row.names=FALSE,col.names=FALSE)


Thanks

Muhammad

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

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




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



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


Re: [R] insert/copy skipped lines to output

2010-03-28 Thread David Winsemius


On Mar 28, 2010, at 12:51 PM, Muhammad Rahiz wrote:


Dear Jannis,

Thanks for the tip. It works but I'd like to improve on the way I  
did it.


x - array(1:50,dim=c(10,10)) # data

h1 - c(ncols180) # header, line 1
h2 - c(nrows   290) # header, line 2
h3 - c(xllcorner   -20) # header, line 3
h4 - c(yllcorner   -20) # header, line 4
h5 - c(cellsize 5000) # header, line 5
h6 - c(NODATA_value  NA) # header, line 6

h0 - rbind(h1,h2,h3,h4,h5,h6)

write(ho,file.txt)
write.table(x,file.txt,row.names=FALSE,col.names=FALSE,append=TRUE)

The header should display as;

ncols   180
nrows  290
xllcorner  -20
yllcorner  -20
cellsize 5000
NODATA_value NA


Executing that code appears to deliver what you requested. So rather  
than asking us to read you mind, can you explain what is missing?


ncols180
nrows   290
xllcorner   -20
yllcorner   -20
cellsize 5000
NODATA_value  NA
1 11 21 31 41 1 11 21 31 41
2 12 22 32 42 2 12 22 32 42
3 13 23 33 43 3 13 23 33 43
4 14 24 34 44 4 14 24 34 44
5 15 25 35 45 5 15 25 35 45
6 16 26 36 46 6 16 26 36 46
7 17 27 37 47 7 17 27 37 47
8 18 28 38 48 8 18 28 38 48
9 19 29 39 49 9 19 29 39 49
10 20 30 40 50 10 20 30 40 50

--
David.







Jannis wrote:

Hallo,

have a look at the documentation of the different output functions
(write(),cat(),write.table()). Most of them have an argument like
append. If you set this to TRUE, your command adds the lines you  
are
writing into the file to the lines already existent in that file.  
So if

you run this write() command first with your additional data (header
data) and then with the real data and append=TRUE, your information
ends up in the same file.


HTH
Jannis


Muhammad Rahiz schrieb:


Hello all,

I'd like some advise on this. When I read my files, I pass the  
argument, skip=6, to skip 6 lines of header information. After  
performing the desired calculations, I have the output. Now I want  
to copy the 6 lines of skipped information to the output.


What I've been doing so far is to use a shell script (i.e. the cat  
function)  to copy the header information to the output file. This  
means I need 2 additional files, namely a file containing the  
header information only, and the shell script to run the the  
function.


Is there a direct way to perform this in R?

The following forms the main component of my R script;

x - as.matrix(read.table(file.txt,skip=6))
y - x*2
write.table(y,output.txt,row.names=FALSE,col.names=FALSE)


Thanks

Muhammad

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


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] insert/copy skipped lines to output

2010-03-28 Thread Muhammad Rahiz

Yes, it works. Just wondering if the technique can be optimized...

David Winsemius wrote:

On Mar 28, 2010, at 12:51 PM, Muhammad Rahiz wrote:

  

Dear Jannis,

Thanks for the tip. It works but I'd like to improve on the way I  
did it.


x - array(1:50,dim=c(10,10)) # data

h1 - c(ncols180) # header, line 1
h2 - c(nrows   290) # header, line 2
h3 - c(xllcorner   -20) # header, line 3
h4 - c(yllcorner   -20) # header, line 4
h5 - c(cellsize 5000) # header, line 5
h6 - c(NODATA_value  NA) # header, line 6

h0 - rbind(h1,h2,h3,h4,h5,h6)

write(ho,file.txt)
write.table(x,file.txt,row.names=FALSE,col.names=FALSE,append=TRUE)

The header should display as;

ncols   180
nrows  290
xllcorner  -20
yllcorner  -20
cellsize 5000
NODATA_value NA



Executing that code appears to deliver what you requested. So rather  
than asking us to read you mind, can you explain what is missing?


ncols180
nrows   290
xllcorner   -20
yllcorner   -20
cellsize 5000
NODATA_value  NA
1 11 21 31 41 1 11 21 31 41
2 12 22 32 42 2 12 22 32 42
3 13 23 33 43 3 13 23 33 43
4 14 24 34 44 4 14 24 34 44
5 15 25 35 45 5 15 25 35 45
6 16 26 36 46 6 16 26 36 46
7 17 27 37 47 7 17 27 37 47
8 18 28 38 48 8 18 28 38 48
9 19 29 39 49 9 19 29 39 49
10 20 30 40 50 10 20 30 40 50




__
R-help@r-project.org mailing list
https://stat.ethz.ch/mailman/listinfo/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] Coding of categorical variables for logistic regression?

2010-03-28 Thread Ravi Kulkarni

Hello,
  I am trying to do a logistic regression and have one predictor variable
(x) that is ratio and two predictor variables (y and z) that are
categorical. These have three levels each which I have called High,
Medium and Low.
  My question: do I need to use a numerical coding scheme for the
categorical variables as required by some statistical software packages,
with some sort of numeric dummy-variable coding? 

  I am using:
 glm(binvar~x+y+z, family=binomial(link=logit))

  Thanks,

Ravi Kulkarni
-- 
View this message in context: 
http://n4.nabble.com/Coding-of-categorical-variables-for-logistic-regression-tp1694250p1694250.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] Calculate variance/covariance with complex numbers

2010-03-28 Thread Charles C. Berry

On Sun, 28 Mar 2010, Gang Chen wrote:


Thanks a lot for the help, Ben Bolker and Chuck!

Chuck, it seems your version needs a little modification. Instead of this:


xri - matrix(rnorm(1)+1i*rnorm(1),nc=2)
crossprod(xri-colMeans(xri))/(nrow(xri)-1)


it seems to me it should be this (maybe there is a more elegant
modification than mine?):

crossprod(t(apply(xri, 1, '-', colMeans(xri/(nrow(xri)-1)


Do you agree?



Argh! Sorry for the 'thinko' (like a 'typo', but a misapplication of the 
brain rather than the fingers)!



I'd use this:

crossprod( sweep( xri, 2, colMeans(xri), - ))/(nrow(xri)-1)

or

crossprod(xri - rep(colMeans(xri),each=nrow(xri)))/(nrow(xri)-1)

Chuck



Gang



On Sat, Mar 27, 2010 at 7:07 PM, Charles C. Berry cbe...@tajo.ucsd.edu wrote:

On Sat, 27 Mar 2010, Gang Chen wrote:


Anybody knows what functions can be used to calculate
variance/covariance with complex numbers? var and cov don't seem to
work:


How about?


xri - matrix(rnorm(1)+1i*rnorm(1),nc=2)
crossprod(xri-colMeans(xri))/(nrow(xri)-1)


HTH,

Chuck




a


                      1
V1 0.00810014+0.00169366i
V2 0.00813054+0.00158251i
V3 0.00805489+0.00163295i
V4 0.00809141+0.00159533i
V5 0.00813976+0.00161850i


var(a)


           1
1 1.141556e-09
Warning message:
In var(a) : imaginary parts discarded in coercion


cov(a)


           1
1 1.141556e-09
Warning message:
In cov(a) : imaginary parts discarded in coercion

Thanks in advance,
Gang

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



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





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



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

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


Re: [R] Assigning factors probabilistically based on the value of another variable.

2010-03-28 Thread Charles C. Berry

On Sun, 28 Mar 2010, Economics Guy wrote:


It is really the same thing. One of many possibilities:


theFrame - data.frame(theValues=runif(150,-10,10))
exact - diag(15)[1+ (rank(theFrame$theValues)-1)%/%10,]
not.so.exact - diag(15)[1+
(rank(theFrame$theValues+runif(150,0,3))-1)%/%10,]


If what you actually wanted was one factor with fifteen levels, just wrap
the subscript in the last assignment in factor() instead.

HTH,

Chuck


Thanks Chuck, this does what I asked for:

theValues - runif(150,-10,10)
exact - factor(1+(rank(theValues)-1)%/%100)

Unfortunately, it looks like my example may have been too contrived
for my actual program.

In the solution that Chuck proposed he antisipated that I may not want
the assignment of factor levels to be exact:

notSoExact - factor(1+(rank(theValues+runif(150,0,3)-1)%/%100)

This is close to what I need. However, in the real program what I need
to be able to do is precisely vary the degree of exactness in the
assignment. So I need to be able to have the assignment range from
completely random assignment to the exact assignment that exact
above provides.

Anyone think of a simple way to do this?


That's div 10, not div 100 (check your typing).

The range of the runif() call determines the 'exactness'.

Alternatively, apply weights of a and  1-a, for 0=a=1, to the components 
in rank().


Chuck



Thanks Agan,

That Economics Guy

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



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

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


Re: [R] insert/copy skipped lines to output

2010-03-28 Thread David Winsemius


On Mar 28, 2010, at 1:11 PM, Muhammad Rahiz wrote:


Yes, it works. Just wondering if the technique can be optimized...


IN WHAT WAY
--  
David.


David Winsemius wrote:

On Mar 28, 2010, at 12:51 PM, Muhammad Rahiz wrote:



Dear Jannis,

Thanks for the tip. It works but I'd like to improve on the way I   
did it.


x - array(1:50,dim=c(10,10)) # data

h1 - c(ncols180) # header, line 1
h2 - c(nrows   290) # header, line 2
h3 - c(xllcorner   -20) # header, line 3
h4 - c(yllcorner   -20) # header, line 4
h5 - c(cellsize 5000) # header, line 5
h6 - c(NODATA_value  NA) # header, line 6

h0 - rbind(h1,h2,h3,h4,h5,h6)

write(ho,file.txt)
write 
.table(x,file.txt,row.names=FALSE,col.names=FALSE,append=TRUE)


The header should display as;

ncols   180
nrows  290
xllcorner  -20
yllcorner  -20
cellsize 5000
NODATA_value NA



Executing that code appears to deliver what you requested. So  
rather  than asking us to read you mind, can you explain what is  
missing?


ncols180
nrows   290
xllcorner   -20
yllcorner   -20
cellsize 5000
NODATA_value  NA
1 11 21 31 41 1 11 21 31 41
2 12 22 32 42 2 12 22 32 42
3 13 23 33 43 3 13 23 33 43
4 14 24 34 44 4 14 24 34 44
5 15 25 35 45 5 15 25 35 45
6 16 26 36 46 6 16 26 36 46
7 17 27 37 47 7 17 27 37 47
8 18 28 38 48 8 18 28 38 48
9 19 29 39 49 9 19 29 39 49
10 20 30 40 50 10 20 30 40 50




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] Coding of categorical variables for logistic regression?

2010-03-28 Thread David Winsemius


On Mar 28, 2010, at 1:15 PM, Ravi Kulkarni wrote:



Hello,
 I am trying to do a logistic regression and have one predictor  
variable

(x) that is ratio and two predictor variables (y and z) that are
categorical. These have three levels each which I have called High,
Medium and Low.
 My question: do I need to use a numerical coding scheme for the
categorical variables as required by some statistical software  
packages,

with some sort of numeric dummy-variable coding?


No. If you have constructed those variables as factors, the regression  
functions in R will interpret them correctly, i.e. as though the  
dummies were in there. If you have not constructed them as factors,  
you should do so now.


?factor
?levels




 I am using:
glm(binvar~x+y+z, family=binomial(link=logit))

 Thanks,

   Ravi Kulkarni
--



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] Preserving both yearmon and numeric data in an xls object

2010-03-28 Thread Marshall Feldman
Hi R gourmets,

I am trying to convert an HTML table into an xts object. The table has 
six columns, with the data of interest in a single row with each cell 
containing a long, \n-delimited character string. Initially, I work with 
these strings as elements in a list. This is necessary because the 
strings in each cell do not translate into a regular matrix with 
equal-length columns. Once I fix the entries, I'm ready to convert them 
into an xts object. The first two columns of the original table contain 
dates, and I want them to be of type yearmon in the xts object. The 
other four columns have numeric data.

Here's my problem. If I convert the list into a data frame on the way to 
making it an xlt, the first two columns correctly keep the data as the 
yearmon class, but the remaining columns are converted to character 
class. Alternatively, if I convert the list into a matrix on the way to 
making the xlt, all six columns become numeric; the first two columns 
lose their yearmon class.

How can I make an xlt from a list, such that the first two columns are 
yearmon and the last four are numeric?

Thanks.

 Marsh Feldman

P.S. Here is some sample code:

  #... input has been converted to a list of length 6; each element
is a vector, but they themselves are of different length
  #... fix the 6 vectors to have equal length
  mylist[1:2] - lapply(mylist[1:2], as.yearmon)# Convert
the first two elements into yearmon class
  #... Now try one of the following; tindex is the time index in
yearmon format
  myxts - as.xts(as.data.frame(mylist), order.by=tindex)# this
makes columns 3-6 of myxts all have class = character
  myxts - as.xts(matrix(unlist(mylist), ncol=6), order.by=tindex)
# this makes myxts entirely numeric
 I even tried using the following statement afterwards but
had no luck
  myxts[,1] - as.yearmon(myxts[,1])



[[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] R Cmdr memory

2010-03-28 Thread Prof Brian Ripley

On Sun, 28 Mar 2010, Duncan Murdoch wrote:


On 28/03/2010 9:03 AM, David Winsemius wrote:

On Mar 28, 2010, at 4:35 AM, ManInMoon wrote:


Is there a 64 bit R - and where can I get hold of it for Windows  please?


For Windows XP?, Not that I know of. There are proprietary versions  for 
Vista and I believe Professor Ripley is working on an experimental  version 
for the 64 bit versions of Windows.


We're planning to release 64 bit builds with R 2.11.0.  They are currently 
being built as part of the test process, though the builds are still a little 
irregular.  You can download from CRAN mirror/bin/windows64/contrib for 
now, and soon from CRAN mirror/bin/windows64/base.


The 64 bit versions of R will require a 64 bit version of Windows to run on. 
I think there may be 64 bit versions of XP, but they are uncommon and I don't


Rare indeed: they are really personal versions of Server 2003 (using 
that codebase, not XP's).


But as it happens one of my IT staff uses x64 XP on his personal 
machine (he prefers XP to later versions of Windows) and has tested 
the R pre-2.11.0 installer there.



know if they support our builds; we're testing in 64 bit Vista and Windows 7.


And Server 2008 (win-builder).

Revolution Computing also sells a build produced with a different compiler. 
It has the advantage that the compiler is probably in better shape than the 
one we are using


Pros and cons.  Yes, their compiler is more mature and better tested, 
but ours is a variant of gcc and a great deal of code (especially C++ 
in packages) is written for and tested on g++ and is more likely to 
give the intended answers on the R-core build.


and they'll provide support with it; the disadvantage is that 
they'll charge for it, and they are probably not as up to date as us 
with respect to released version number.


--
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] Coding of categorical variables for logistic regression?

2010-03-28 Thread Johannes Huesing
Ravi Kulkarni ravi.k...@gmail.com [Sun, Mar 28, 2010 at 07:15:52PM CEST]:
[...]
   I am trying to do a logistic regression and have one predictor variable
 (x) that is ratio and two predictor variables (y and z) that are
 categorical. These have three levels each which I have called High,
 Medium and Low.

You don't plan to use the information that y and z are apparently ordinal?
-- 
Johannes Hüsing   There is something fascinating about science. 
  One gets such wholesale returns of conjecture 
mailto:johan...@huesing.name  from such a trifling investment of fact.  
  
http://derwisch.wikidot.com (Mark Twain, Life on the Mississippi)

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

2010-03-28 Thread Muhammad Rahiz

something like this...

x1 - as.matrix(read.table(input.txt))[1:6,] # reads only header
x2  -array(1:6,dim=c(2,3))

write(x,output.txt)
write.table(x3,output.txt,row.names=FALSE,col.names=FALSE,append=TRUE)

But the results print;

ncols
nrows
xllcorner
yllcorner
cellsize
NODATA_value
   180.00
   290.00
-20.00
-20.00
  5000.00
 -.00
1 3 5
2 4 6




Muhammad Rahiz  |  Doctoral Student in Regional Climate Modeling
Climate Research Laboratory, School of Geography  the Environment  
Oxford University Centre for the Environment, University of Oxford
South Parks Road, Oxford, OX1 3QY, United Kingdom
Tel: +44 (0)1865-285194  Mobile: +44 (0)7854-625974
Email: muhammad.ra...@ouce.ox.ac.uk



David Winsemius wrote:

On Mar 28, 2010, at 1:11 PM, Muhammad Rahiz wrote:

  

Yes, it works. Just wondering if the technique can be optimized...



IN WHAT WAY
--  
David.
  

David Winsemius wrote:


On Mar 28, 2010, at 12:51 PM, Muhammad Rahiz wrote:


  

Dear Jannis,

Thanks for the tip. It works but I'd like to improve on the way I   
did it.


x - array(1:50,dim=c(10,10)) # data

h1 - c(ncols180) # header, line 1
h2 - c(nrows   290) # header, line 2
h3 - c(xllcorner   -20) # header, line 3
h4 - c(yllcorner   -20) # header, line 4
h5 - c(cellsize 5000) # header, line 5
h6 - c(NODATA_value  NA) # header, line 6

h0 - rbind(h1,h2,h3,h4,h5,h6)

write(ho,file.txt)
write 
.table(x,file.txt,row.names=FALSE,col.names=FALSE,append=TRUE)


The header should display as;

ncols   180
nrows  290
xllcorner  -20
yllcorner  -20
cellsize 5000
NODATA_value NA


Executing that code appears to deliver what you requested. So  
rather  than asking us to read you mind, can you explain what is  
missing?


ncols180
nrows   290
xllcorner   -20
yllcorner   -20
cellsize 5000
NODATA_value  NA
1 11 21 31 41 1 11 21 31 41
2 12 22 32 42 2 12 22 32 42
3 13 23 33 43 3 13 23 33 43
4 14 24 34 44 4 14 24 34 44
5 15 25 35 45 5 15 25 35 45
6 16 26 36 46 6 16 26 36 46
7 17 27 37 47 7 17 27 37 47
8 18 28 38 48 8 18 28 38 48
9 19 29 39 49 9 19 29 39 49
10 20 30 40 50 10 20 30 40 50


  


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] insert/copy skipped lines to output

2010-03-28 Thread David Winsemius


On Mar 28, 2010, at 2:41 PM, Muhammad Rahiz wrote:


something like this...

x1 - as.matrix(read.table(input.txt))[1:6,] # reads only header
x2  -array(1:6,dim=c(2,3))

write(x,output.txt)


write() will process the matrix elements in their natural vector  
order.


write 
.table(x3,output.txt,row.names=FALSE,col.names=FALSE,append=TRUE)


But the results print;

ncols
nrows
xllcorner
yllcorner
cellsize
NODATA_value
  180.00
  290.00
-20.00
-20.00
 5000.00
-.00
1 3 5
2 4 6



?write.table

Add an appropriate , file= , to this and it should do what you expect

 write.table(x1, row.names=FALSE, col.names=FALSE, quote=FALSE)

ncols 180
nrows 290
xllcorner -20
yllcorner -20
cellsize5000
NODATA_value NA






Muhammad Rahiz  |  Doctoral Student in Regional Climate Modeling
Climate Research Laboratory, School of Geography  the Environment  
Oxford University Centre for the Environment, University of Oxford
South Parks Road, Oxford, OX1 3QY, United Kingdom
Tel: +44 (0)1865-285194  Mobile: +44 (0)7854-625974
Email: muhammad.ra...@ouce.ox.ac.uk



David Winsemius wrote:

On Mar 28, 2010, at 1:11 PM, Muhammad Rahiz wrote:



Yes, it works. Just wondering if the technique can be optimized...



IN WHAT WAY
--  David.


David Winsemius wrote:


On Mar 28, 2010, at 12:51 PM, Muhammad Rahiz wrote:




Dear Jannis,

Thanks for the tip. It works but I'd like to improve on the way  
I   did it.


x - array(1:50,dim=c(10,10)) # data

h1 - c(ncols180) # header, line 1
h2 - c(nrows   290) # header, line 2
h3 - c(xllcorner   -20) # header, line 3
h4 - c(yllcorner   -20) # header, line 4
h5 - c(cellsize 5000) # header, line 5
h6 - c(NODATA_value  NA) # header, line 6

h0 - rbind(h1,h2,h3,h4,h5,h6)

write(ho,file.txt)
write 
 .table(x,file.txt,row.names=FALSE,col.names=FALSE,append=TRUE)


The header should display as;

ncols   180
nrows  290
xllcorner  -20
yllcorner  -20
cellsize 5000
NODATA_value NA


Executing that code appears to deliver what you requested. So   
rather  than asking us to read you mind, can you explain what is   
missing?


ncols180
nrows   290
xllcorner   -20
yllcorner   -20
cellsize 5000
NODATA_value  NA
1 11 21 31 41 1 11 21 31 41
2 12 22 32 42 2 12 22 32 42
3 13 23 33 43 3 13 23 33 43
4 14 24 34 44 4 14 24 34 44
5 15 25 35 45 5 15 25 35 45
6 16 26 36 46 6 16 26 36 46
7 17 27 37 47 7 17 27 37 47
8 18 28 38 48 8 18 28 38 48
9 19 29 39 49 9 19 29 39 49
10 20 30 40 50 10 20 30 40 50





David Winsemius, MD
West Hartford, CT




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] Trouble loading package

2010-03-28 Thread Peter Ehlers

I haven't seen an answer to this yet.

Your problem may stem from having defined a variable T.
I can replicate your error messages with:

 T - hello
 library(RMark)

So methinks that this probably indicates that there may be
a problem with using T for TRUE (when will Rusers finally
stop doing that???).

And sure enough, after loading RMark (with no T in my
workspace), I find that the authors of RMark have replaced
base R's .First.lib with their own version which contains
the line:

info - strsplit(library(help = pkgname, character.only = T)$info[[1]],
\\:[ ]+)

Note to RMark authors (and others): get used to using
TRUE and FALSE. The few characters saved by using T/F
are not worth it!

 -Peter Ehlers

On 2010-03-26 15:40, Glenn E Stauffer wrote:

I am trying to load a package called Rmark, but when I run

library(Rmark)

I get the following:


library(RMark)

Error in !character.only : invalid argument type
Error in library(RMark) : .First.lib failed for 'RMark'

When I try to load Rmark from the packages menu, I get:


local({pkg- select.list(sort(.packages(all.available = TRUE)))

+ if(nchar(pkg)) library(pkg, character.only=TRUE)})
Error in !character.only : invalid argument type
Error in library(pkg, character.only = TRUE) :
   .First.lib failed for 'RMark'

Any ideas what is causing this error?

My OS is Windows XP, and my R version is R.2.10.1

Thanks,
Glenn

*
Glenn E. Stauffer
Graduate Research Assistant
Department of Ecology
Montana State University
Bozeman, MT 59717
406-994-5677
gestauf...@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.




--
Peter Ehlers
University of Calgary

__
R-help@r-project.org mailing list
https://stat.ethz.ch/mailman/listinfo/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] Calculate variance/covariance with complex numbers

2010-03-28 Thread Ben Bolker


Rolf Turner wrote:
 On 28/03/2010, at 11:50 AM, Ben Bolker wrote:
 
 Gang Chen gangchen6 at gmail.com writes:

 Anybody knows what functions can be used to calculate
 variance/covariance with complex numbers? var and cov don't seem to
 work:
 How about:

 y - complex(real=5:1,imag=2:6)
 z - complex(real=1:5,imag=6:10)

 complex.var - function(x) {
  mx - mean(x)
  n - length(x)
  mean((x-mx)^2)*n/(n-1)
 }
 
   SNIP
 
 Don't you want variances to be positive (non-negative) reals?
 
 IIRC the population variance of a complex random variable is
 
   E(|X - mu|^2) not E((X - mu)^2)
 
 So shouldn't your complex.var function have Mod(x-mx)^2 where
 you currently have (x-mx)^2 ???
 
   cheers,
 
   Rolf

  Probably.  To be honest, I wasn't thinking about it that carefully.
It crossed my mind to wonder what the appropriate definition was of the
variance for complex numbers, but I didn't bother to go find out.
   I guess it goes to show (yet again) that advice may be worth what you
pay for it ...


  cheers
Ben



signature.asc
Description: OpenPGP digital signature
__
R-help@r-project.org mailing list
https://stat.ethz.ch/mailman/listinfo/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: col.axis

2010-03-28 Thread Enio Jelihovschi
I need a help in the following code. I could not find any hint at the help
files

m - c( 58, 47, 51, 57, 48)
 plot(1:5, m, pch=19, col=1:5, axes=FALSE)
  axis(1, at=1:length(m), labels=LETTERS[1:5], col.axis=2)

The labels A B C D E appear in this case with the red color.
What I really want is that thay get the same color as the circles, but if I
try the line

axis(1, at=1:length(m), labels=LETTERS[1:5], col.axis=1:5)

I get the message  the graphic parameter col.axis has the wrong length.

Is there any way to circumvent it?
Thank you very much
Enio Jelihovschi
UESC, Brasil

[[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] Renumbering

2010-03-28 Thread Val
HI all,
Is there a renumbering function in R?

I would like to renumber the following id numbers

*Input file
*
  Id Father Mother  123 0 0  124 0 0  125 123 124  126 123 0  127 125 126
128 0 127  130 123 125
*Output*

 Id Father Mother  1 0 0  2 0 0  3 1 2  4 1 0  5 3 4  6 0 7  7 1 2
Any help is highly appreciated in Advance

Val K

[[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] Fwd: col.axis

2010-03-28 Thread Lukas Schefczyk

Hi

you can use mtext()


m - c( 58, 47, 51, 57, 48)
plot(1:5, m, pch=19, col=1:5, axes=FALSE)
axis(1, at=1:length(m), labels=LETTERS[1:5], col.axis=FALSE) # color =FALSE 
to make them disappear


at - axTicks(1) # get Ticks from Axis 1
mtext(side = 1, text = at, at = at, col = (1:5), line = 1)




Lukas Schefczyk

(btw my first message here)

--
From: Enio Jelihovschi eniojelih...@gmail.com
Sent: Sunday, March 28, 2010 10:07 PM
To: r-help@r-project.org
Subject: [R] Fwd: col.axis


I need a help in the following code. I could not find any hint at the help
files

m - c( 58, 47, 51, 57, 48)
plot(1:5, m, pch=19, col=1:5, axes=FALSE)
 axis(1, at=1:length(m), labels=LETTERS[1:5], col.axis=2)

The labels A B C D E appear in this case with the red color.
What I really want is that thay get the same color as the circles, but if 
I

try the line

axis(1, at=1:length(m), labels=LETTERS[1:5], col.axis=1:5)

I get the message  the graphic parameter col.axis has the wrong 
length.


Is there any way to circumvent it?
Thank you very much
Enio Jelihovschi
UESC, Brasil

[[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] Renumbering

2010-03-28 Thread jim holtman
This is not really a renumbering and there is no builtin function.  This
is a case where you want to do some special remapping of numbers and you
have to decide what it is in your case.  Also use 'dput' to put data in
email since what you sent was not parseable.  Also I think the last two
lines of your desired output is incorrect.

Try this:

 x - read.table(textConnection( Id Father Mother
+ 123 0 0
+ 124 0 0
+ 125 123 124
+ 126 123 0
+ 127 125 126
+ 128 0 127
+ 130 123 125), header=TRUE)
 # convert to matrix
 x - as.matrix(x)
 closeAllConnections()
 # map numbers to a new sequence
 allNums - sort(unique(as.vector(x)))
 # new numbers
 newNums - seq(0, by=1, length=length(allNums))
 # now remap the numbers
 x[] - newNums[match(x, allNums)]

 x
 Id Father Mother
[1,]  1  0  0
[2,]  2  0  0
[3,]  3  1  2
[4,]  4  1  0
[5,]  5  3  4
[6,]  6  0  5
[7,]  7  1  3



On Sun, Mar 28, 2010 at 4:50 PM, Val valkr...@gmail.com wrote:

 HI all,
 Is there a renumbering function in R?

 I would like to renumber the following id numbers

 *Input file
 *
  Id Father Mother  123 0 0  124 0 0  125 123 124  126 123 0  127 125 126
 128 0 127  130 123 125
 *Output*

  Id Father Mother  1 0 0  2 0 0  3 1 2  4 1 0  5 3 4  6 0 7  7 1 2
 Any help is highly appreciated in Advance

 Val K

[[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.htmlhttp://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?

[[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] grid graphics - concatenating gLists - is there a function?

2010-03-28 Thread Paul Murrell

Hi

Mark Heckmann wrote:

I have to gList objects containing several grobs.
Now, I want to combine them into a single gList object as e.g. gTree()  
does not take a nested gList as children argument.


gl1 - gList(rectGrob(), rectGrob())
gl2 - gList(textGrob(Text 1))

Now I want to combine gl1 and gl2 into a single gList object, that is  
not nested.


I think this should work ...

gList(gl1, gl2)

Paul



Thanks,
Mark
–––
Mark Heckmann
Blog: www.markheckmann.de
R-Blog: http://ryouready.wordpress.com





[[alternative HTML version deleted]]



--
Dr Paul Murrell
Department of Statistics
The University of Auckland
Private Bag 92019
Auckland
New Zealand
64 9 3737599 x85392
p...@stat.auckland.ac.nz
http://www.stat.auckland.ac.nz/~paul/

__
R-help@r-project.org mailing list
https://stat.ethz.ch/mailman/listinfo/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] grid graphics - concatenating gLists - is there a function?

2010-03-28 Thread Mark Heckmann
Hi Paul,

unfortunately this did not work out.
I use the following now:

childgrobs - c(gl1, gl2)
class(childgrobs) - gList

This seems to work for me.
Bests, Mark


Am 28.03.2010 um 23:44 schrieb Paul Murrell:

 Hi

 Mark Heckmann wrote:
 I have to gList objects containing several grobs.
 Now, I want to combine them into a single gList object as e.g. gTree 
 ()  does not take a nested gList as children argument.
 gl1 - gList(rectGrob(), rectGrob())
 gl2 - gList(textGrob(Text 1))
 Now I want to combine gl1 and gl2 into a single gList object, that  
 is  not nested.

 I think this should work ...

 gList(gl1, gl2)

 Paul


 Thanks,
 Mark
 –––
 Mark Heckmann
 Blog: www.markheckmann.de
 R-Blog: http://ryouready.wordpress.com
  [[alternative HTML version deleted]]

 -- 
 Dr Paul Murrell
 Department of Statistics
 The University of Auckland
 Private Bag 92019
 Auckland
 New Zealand
 64 9 3737599 x85392
 p...@stat.auckland.ac.nz
 http://www.stat.auckland.ac.nz/~paul/

–––
Mark Heckmann
Dipl. Wirt.-Ing. cand. Psych.
Vorstraße 93 B01
28359 Bremen
Blog: www.markheckmann.de
R-Blog: http://ryouready.wordpress.com





[[alternative HTML version deleted]]

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


Re: [R] Renumbering

2010-03-28 Thread Val
Thank you for your quick response. You are right the ls two rows were not
correct.  Typ error.

 Is it possible to add the original ID number as  a cross reference as well
Like,
 Id Father Mother Original ID
[1,]  1  0  0   123
[2,]  2  0  0   124
[3,]  3  1  2   125
[4,]  4  1  0   126
[5,]  5  3  4   127
[6,]  6  0  5   128
[7,]  7  1  3   130

Thanks again
Val




On Sun, Mar 28, 2010 at 5:09 PM, jim holtman jholt...@gmail.com wrote:

 This is not really a renumbering and there is no builtin function.  This
 is a case where you want to do some special remapping of numbers and you
 have to decide what it is in your case.  Also use 'dput' to put data in
 email since what you sent was not parseable.  Also I think the last two
 lines of your desired output is incorrect.

 Try this:

  x - read.table(textConnection( Id Father Mother

 + 123 0 0
 + 124 0 0
 + 125 123 124
 + 126 123 0
 + 127 125 126
 + 128 0 127
 + 130 123 125), header=TRUE)
  # convert to matrix
  x - as.matrix(x)
  closeAllConnections()
  # map numbers to a new sequence
  allNums - sort(unique(as.vector(x)))
  # new numbers
  newNums - seq(0, by=1, length=length(allNums))
  # now remap the numbers
  x[] - newNums[match(x, allNums)]
 
  x
  Id Father Mother
 [1,]  1  0  0
 [2,]  2  0  0
 [3,]  3  1  2
 [4,]  4  1  0
 [5,]  5  3  4
 [6,]  6  0  5
 [7,]  7  1  3
 


 On Sun, Mar 28, 2010 at 4:50 PM, Val valkr...@gmail.com wrote:

 HI all,
 Is there a renumbering function in R?

 I would like to renumber the following id numbers

 *Input file
 *
  Id Father Mother  123 0 0  124 0 0  125 123 124  126 123 0  127 125 126
 128 0 127  130 123 125
 *Output*

  Id Father Mother  1 0 0  2 0 0  3 1 2  4 1 0  5 3 4  6 0 7  7 1 2
 Any help is highly appreciated in Advance

 Val K

[[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.htmlhttp://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?


[[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] grid graphics - concatenating gLists - is there a function?

2010-03-28 Thread David Winsemius


On Mar 28, 2010, at 5:59 PM, Mark Heckmann wrote:


Hi Paul,

unfortunately this did not work out.
I use the following now:

childgrobs - c(gl1, gl2)
class(childgrobs) - gList

This seems to work for me.


What about?:

gl3 - gl1
gl3[length(g1)+1] - gl2

--
David

Bests, Mark


Am 28.03.2010 um 23:44 schrieb Paul Murrell:


Hi

Mark Heckmann wrote:

I have to gList objects containing several grobs.
Now, I want to combine them into a single gList object as e.g. gTree
()  does not take a nested gList as children argument.
gl1 - gList(rectGrob(), rectGrob())
gl2 - gList(textGrob(Text 1))
Now I want to combine gl1 and gl2 into a single gList object, that
is  not nested.


I think this should work ...

gList(gl1, gl2)

Paul



Thanks,
Mark
–––
Mark Heckmann
Blog: www.markheckmann.de
R-Blog: http://ryouready.wordpress.com
[[alternative HTML version deleted]]


--
Dr Paul Murrell
Department of Statistics
The University of Auckland
Private Bag 92019
Auckland
New Zealand
64 9 3737599 x85392
p...@stat.auckland.ac.nz
http://www.stat.auckland.ac.nz/~paul/


–––
Mark Heckmann
Dipl. Wirt.-Ing. cand. Psych.
Vorstraße 93 B01
28359 Bremen
Blog: www.markheckmann.de
R-Blog: http://ryouready.wordpress.com





[[alternative HTML version deleted]]

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


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] Ellipse that Contains 95% of the Observed Data

2010-03-28 Thread Tom La Bone

I can take the results of a simulation with one random variable and generate
an empirical interval that contains 95% of the observations, e.g.,

x - rnorm(1)
quantile(x,probs=c(0.025,0.975))

Is there an R function that can take the results from two random variables
and generate an empirical ellipse that contains 95% of the observations,
e.g.,  

x - rnorm(1)
y - rnorm(1)
?

I am specifically looking for an ellipse that does not assume normality.

Tom


-- 
View this message in context: 
http://n4.nabble.com/Ellipse-that-Contains-95-of-the-Observed-Data-tp1694538p1694538.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] CRAN (and crantastic) updates this week

2010-03-28 Thread Crantastic
CRAN (and crantastic) updates this week

New packages



Updated packages


Amelia (1.2-16), AMORE (0.2-12), Bolstad (0.2-17), CADStat (2.2-4)



This email provided as a service for the R community by
http://crantastic.org.

Like it?  Hate it?  Please let us know: crana...@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] Renumbering

2010-03-28 Thread jim holtman
This should do it:

 x - read.table(textConnection( Id Father Mother
+ 123 0 0
+ 124 0 0
+ 125 123 124
+ 126 123 0
+ 127 125 126
+ 128 0 127
+ 130 123 125), header=TRUE)
 # convert to matrix
 x - as.matrix(x)
 closeAllConnections()
 # map numbers to a new sequence
 allNums - sort(unique(as.vector(x)))
 # new numbers
 newNums - seq(0, by=1, length=length(allNums))
 # now remap the numbers
 x[] - newNums[match(x, allNums)]
 x - cbind(x, orig=allNums[x[, Id] + 1])

 x
 Id Father Mother orig
[1,]  1  0  0  123
[2,]  2  0  0  124
[3,]  3  1  2  125
[4,]  4  1  0  126
[5,]  5  3  4  127
[6,]  6  0  5  128
[7,]  7  1  3  130



On Sun, Mar 28, 2010 at 6:33 PM, Val valkr...@gmail.com wrote:

 Thank you for your quick response. You are right the ls two rows were not
 correct.  Typ error.

  Is it possible to add the original ID number as  a cross reference as well
 Like,
  Id Father Mother Original ID
 [1,]  1  0  0   123
 [2,]  2  0  0   124
 [3,]  3  1  2   125
 [4,]  4  1  0   126
 [5,]  5  3  4   127
 [6,]  6  0  5   128
 [7,]  7  1  3   130

 Thanks again
 Val





 On Sun, Mar 28, 2010 at 5:09 PM, jim holtman jholt...@gmail.com wrote:

 This is not really a renumbering and there is no builtin function.  This
 is a case where you want to do some special remapping of numbers and you
 have to decide what it is in your case.  Also use 'dput' to put data in
 email since what you sent was not parseable.  Also I think the last two
 lines of your desired output is incorrect.

 Try this:

  x - read.table(textConnection( Id Father Mother

 + 123 0 0
 + 124 0 0
 + 125 123 124
 + 126 123 0
 + 127 125 126
 + 128 0 127
 + 130 123 125), header=TRUE)
  # convert to matrix
  x - as.matrix(x)
  closeAllConnections()
  # map numbers to a new sequence
  allNums - sort(unique(as.vector(x)))
  # new numbers
  newNums - seq(0, by=1, length=length(allNums))
  # now remap the numbers
  x[] - newNums[match(x, allNums)]
 
  x
  Id Father Mother
 [1,]  1  0  0
 [2,]  2  0  0
 [3,]  3  1  2
 [4,]  4  1  0
 [5,]  5  3  4
 [6,]  6  0  5
 [7,]  7  1  3
 


   On Sun, Mar 28, 2010 at 4:50 PM, Val valkr...@gmail.com wrote:

  HI all,
 Is there a renumbering function in R?

 I would like to renumber the following id numbers

 *Input file
 *
  Id Father Mother  123 0 0  124 0 0  125 123 124  126 123 0  127 125 126
 128 0 127  130 123 125
 *Output*

  Id Father Mother  1 0 0  2 0 0  3 1 2  4 1 0  5 3 4  6 0 7  7 1 2
 Any help is highly appreciated in Advance

 Val K

[[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.htmlhttp://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?





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

What is the problem that you are trying to solve?

[[alternative HTML version deleted]]

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


Re: [R] Calculate variance/covariance with complex numbers

2010-03-28 Thread Jim Lemon

On 03/29/2010 04:17 AM, Charles C. Berry wrote:

...
Argh! Sorry for the 'thinko' (like a 'typo', but a misapplication of the
brain rather than the fingers)!

Well, a typo is the _result_ of a misapplication of the fingers to a 
keyboard, so I would expect that if the result of thinking can be called 
a meme, then the appropriate term for the mistake would be a memo. I 
have seen plenty of examples.


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] tapply syntax

2010-03-28 Thread Jeff Brown

What is the function set()?  Is that a typo?  When I type ?set I get
nothing, and when I try to evaluate that code R tells me it can't find the
function.
-- 
View this message in context: 
http://n4.nabble.com/tapply-syntax-tp1692503p1694586.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] tapply syntax

2010-03-28 Thread Rolf Turner

On 29/03/2010, at 1:27 PM, Jeff Brown wrote:

 
 What is the function set()?  Is that a typo?  When I type ?set I get
 nothing, and when I try to evaluate that code R tells me it can't find the
 function.


Yeah, it's a typo.  (S)he meant ``subset''.

cheers,

Rolf Turner

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

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


Re: [R] tapply syntax

2010-03-28 Thread jim holtman
The message tells you everything - there is no function 'set' in the
workspace you are using.  Did you forget to load a library?  What is the
context in which you are trying to use it?

On Sun, Mar 28, 2010 at 8:27 PM, Jeff Brown dopethatwantsc...@yahoo.comwrote:


 What is the function set()?  Is that a typo?  When I type ?set I get
 nothing, and when I try to evaluate that code R tells me it can't find the
 function.
 --
 View this message in context:
 http://n4.nabble.com/tapply-syntax-tp1692503p1694586.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.htmlhttp://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?

[[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] Heirarchical tree data structure

2010-03-28 Thread Jeff Brown

When I tried ??tree, I found something called dendrogram that looks like it
might be what you want.
-- 
View this message in context: 
http://n4.nabble.com/Heirarchical-tree-data-structure-tp1692838p1694575.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] Page width figures in Latex

2010-03-28 Thread Jim Lemon

bRotheRs  sisteRs,
I am once again attempting to learn enough Latex voodoo to get something 
done, and failing comically. The document RJAuthorguide.pdf
mentions that one can get page width figures through the use of the 
figure* or table* environments, but despite considerable searching 
through the mail archives and reading Frank Harrell's discussion of 
Using Latex Figure Environments for Plots until my eyes went on 
strike, I am nowhere near a solution. Would anyone be kind enough to 
point me to the Idiot's Guide to Latex Figure Environments?


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] tapply syntax

2010-03-28 Thread David Freedman

sorry - I use many abbreviations and I try to remove them before I post 
questions/answers - 'set' is my abb. for subset

david

On 3/28/2010 8:27 PM, Jeff Brown [via R] wrote:
 What is the function set()?  Is that a typo?  When I type ?set I get 
 nothing, and when I try to evaluate that code R tells me it can't find 
 the function.

 View message @ http://n4.nabble.com/tapply-syntax-tp1692503p1694586.html
 To unsubscribe from Re: tapply syntax, click here 
  (link removed) =. 



-- 
View this message in context: 
http://n4.nabble.com/tapply-syntax-tp1692503p1694626.html
Sent from the R help mailing list archive at Nabble.com.

[[alternative HTML version deleted]]

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


[R] Question on entry exit tabulating in any R finance package

2010-03-28 Thread rtist

I asked the question in Rmetrics subforum, but for some reason, almost two
weeks later, it keeps saying I haven't been approved to post yet there.

I'll try again here on the open forum.

I wanted to have a script that tabulates results by trade. I.e. instead of
tabulating each day as a trade event, you enter on one date, exit another,
and simply tabulate metrics based on one trade period.  For example, you
could have a moving average crossover system and the results would be
tabulated based on each trade (including entry/exit date attributes).

The package, Tradesys, is very close, but I can't seem to find any
documentation beyond:
http://r-forge.r-project.org/plugins/scmsvn/viewcvs.php/*checkout*/pkg/inst/doc/tradesys.pdf?rev=19root=tradesys
And unfortunately, the definitions are a bit sparse and I had trouble
reverse engineering them.
For instance, in the table on page 3:
Phase ETime XTime Time Numb EPrice XPrice PnL RoR
107 EL 2006-09-21 2007-09-12 356 244 1324.89 1471.10 146.21 0.264117052

Pnl Makes sense (1471.10-1324.89 )= 146.21, but, I would expect ROR to be
~1471.1/1324.89-1 ~ 11.03%, yet RoR col shows 26.411% 

I also looked at blotter, which shows an example that is long only and seems
a bit cumbersome to run the simple metrics for trade entry/exit.  Any ideas
on packages that will do this, or why I'm misunderstanding the Tradesys
results?

thanks,
rtist
Pat W.
-- 
View this message in context: 
http://n4.nabble.com/Question-on-entry-exit-tabulating-in-any-R-finance-package-tp1694607p1694607.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] Coding of categorical variables for logistic regression?

2010-03-28 Thread Ravi Kulkarni

How do I use the extra information that two of my predictors are ordinal? 
(I did not know I could do that.)

Thanks,
  Ravi
-- 
View this message in context: 
http://n4.nabble.com/Coding-of-categorical-variables-for-logistic-regression-tp1694250p1694644.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] Ellipse that Contains 95% of the Observed Data

2010-03-28 Thread Ben Bolker
Tom La Bone booboo at gforcecable.com writes:

 
 
 I can take the results of a simulation with one random variable and generate
 an empirical interval that contains 95% of the observations, e.g.,
 
 x - rnorm(1)
 quantile(x,probs=c(0.025,0.975))
 
 Is there an R function that can take the results from two random variables
 and generate an empirical ellipse that contains 95% of the observations,
 e.g.,  
 
 x - rnorm(1)
 y - rnorm(1)
 ?
 
 I am specifically looking for an ellipse that does not assume normality.

  I'll be interested to hear what others come up with.
  I'm not sure the problem as you have stated it is well-posed, or 
necessarily possible. Suppose there is a true unknown
bivariate probability distribution with a non-elliptical 95%
quantile region. Will you be able to draw an ellipse that
has the properties you want?

  Here's one possible alternative:

  library(coda)
  library(emdbook)
  plot(x,y)
  z = HPDregionplot(as.mcmc(cbind(x,y)),add=TRUE,col=2,lwd=2)

  is not an ellipse, but does contain (approximately) 95% of
the points.

  Convex hulls are another plausible approach.

__
R-help@r-project.org mailing list
https://stat.ethz.ch/mailman/listinfo/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] Coding of categorical variables for logistic regression?

2010-03-28 Thread C.H.
?polr of the MASS package.


On Mon, Mar 29, 2010 at 10:39 AM, Ravi Kulkarni ravi.k...@gmail.com wrote:

 How do I use the extra information that two of my predictors are ordinal?
 (I did not know I could do that.)

 Thanks,
  Ravi
 --
 View this message in context: 
 http://n4.nabble.com/Coding-of-categorical-variables-for-logistic-regression-tp1694250p1694644.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.




-- 
CH Chan
Research Assistant - KWH
http://www.macgrass.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] Page width figures in Latex

2010-03-28 Thread Sharpie


Jim Lemon wrote:
 
 bRotheRs  sisteRs,
 I am once again attempting to learn enough Latex voodoo to get something 
 done, and failing comically. The document RJAuthorguide.pdf
 mentions that one can get page width figures through the use of the 
 figure* or table* environments, but despite considerable searching 
 through the mail archives and reading Frank Harrell's discussion of 
 Using Latex Figure Environments for Plots until my eyes went on 
 strike, I am nowhere near a solution. Would anyone be kind enough to 
 point me to the Idiot's Guide to Latex Figure Environments?
 
 Jim
 

As far as I can recall, figure* and table* are used to create figures/tables
that span the entire page when the rest of the document is in twocolumn or
multicol mode.  I.e. these environments allow you to break out of a
multi-column layout to place a figure that acts like it was in a normal
single-column layout.

There are a bunch of caveats such as the figure/table will only appear at
the top or bottom of a page and will not appear on the same page as the
point at which it was declared in the source.  That is to say, when you
declare a figure* in a LaTeX document, one page break must pass before the
environment actually gets set in your document- no matter what !h or H vodoo
you pull.


If your document is not using multiple columns, then you may want to specify
the width of your figure when you place it using \includegraphics.  In order
to scale the figure so that it spans the entire page, set the width argument
equal to \textwidth:

\begin{figure}

  \centering
  \caption{A graph of x verses y along with a linear regression fit.}
  \label{fig:xVsY}

  \includegraphics[width=\textwidth]{/path/to/your/figure}

\end{figure}

Some good resources are:

The LaTeX Wikibook:

  http://en.wikibooks.org/wiki/LaTeX

Getting to Grips with LaTeX:

  http://www.andy-roberts.net/misc/latex/


Hope this helps!

-Charlie

-
Charlie Sharpsteen
Undergraduate-- Environmental Resources Engineering
Humboldt State University
-- 
View this message in context: 
http://n4.nabble.com/Page-width-figures-in-Latex-tp1694612p1694673.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] Page width figures in Latex

2010-03-28 Thread Rolf Turner

On 29/03/2010, at 4:21 PM, Sharpie wrote:

SNIP

 There are a bunch of caveats such as the figure/table will only appear at
 the top or bottom of a page and will not appear on the same page as the
 point at which it was declared in the source.  That is to say, when you
 declare a figure* in a LaTeX document, one page break must pass before the
 environment actually gets set in your document- no matter what !h or H vodoo
 you pull.

SNIP

I'm not convinced that this is correct; I'm sure I have had floats
(including figures) placed where I asked them to be placed. :-)

Be that as is it were; if you put:

\usepackage{float}

in your preamble and then do

\begin{figure}[H]

whatever

\end{figure}

the figure will appear ***exactly*** where you put it --- provided
of course that there is room for it there.  Elsewise you'll get a
page break just before the figure.

cheers,

Rolf Turner
##
Attention: 
This e-mail message is privileged and confidential. If you are not the 
intended recipient please delete the message and notify the sender. 
Any views or opinions presented are solely those of the author.

This e-mail has been scanned and cleared by MailMarshal 
www.marshalsoftware.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] Page width figures in Latex

2010-03-28 Thread Mike Prager
On Mon, 29 Mar 2010 12:21:40 +1100, Jim Lemon j...@bitwrit.com.au
wrote:

bRotheRs  sisteRs,
I am once again attempting to learn enough Latex voodoo to get something 
done, and failing comically. The document RJAuthorguide.pdf
mentions that one can get page width figures through the use of the 
figure* or table* environments, but despite considerable searching 
through the mail archives and reading Frank Harrell's discussion of 
Using Latex Figure Environments for Plots until my eyes went on 
strike, I am nowhere near a solution. Would anyone be kind enough to 
point me to the Idiot's Guide to Latex Figure Environments?

Jim

Jim,

You need a good book on Latex.  I like this one:

http://www.amazon.com/Guide-LaTeX-4th-Helmut-Kopka/dp/0321173856/ref=sr_1_4?ie=UTF8s=booksqid=1269833347sr=8-4

The width of the figure is controlled by the \includegraphics
statement, not any particular part of the environment specification.
That assumes you have loaded the graphicx package.  For example,

\begin{figure}[!th]
\begin{center}
\includegraphics[width=\textwidth]{myfig.eps}\\
\end{center}
\end{figure}%

HTH,
Mike

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

2010-03-28 Thread Sharpie


Rolf Turner wrote:
 
 
 On 29/03/2010, at 4:21 PM, Sharpie wrote:
 
   SNIP
 
 There are a bunch of caveats such as the figure/table will only appear at
 the top or bottom of a page and will not appear on the same page as the
 point at which it was declared in the source.  That is to say, when you
 declare a figure* in a LaTeX document, one page break must pass before
 the
 environment actually gets set in your document- no matter what !h or H
 vodoo
 you pull.
 
   SNIP
 
 I'm not convinced that this is correct; I'm sure I have had floats
 (including figures) placed where I asked them to be placed. :-)
 
 Be that as is it were; if you put:
 
 \usepackage{float}
 
 in your preamble and then do
 
 \begin{figure}[H]
 
 whatever
 
 \end{figure}
 
 the figure will appear ***exactly*** where you put it --- provided
 of course that there is room for it there.  Elsewise you'll get a
 page break just before the figure.
 
   cheers,
 
   Rolf Turner
 

Aye, that is exactly true for the figure environment.

However, I was referring to the figure* environment (note the asterisk)
which is used when setting a figure that spans a full page in a document
with multiple columns.  Under these conditions, I recall there being some
gotchas such as the figure having to appear at the top or bottom of the page
and one pagebreak having to pass before it appears.

-Charlie

-
Charlie Sharpsteen
Undergraduate-- Environmental Resources Engineering
Humboldt State University
-- 
View this message in context: 
http://n4.nabble.com/Page-width-figures-in-Latex-tp1694612p1694686.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] large dataset

2010-03-28 Thread kMan
This was *very* useful for me when I dealt with a 1.5Gb text file
http://www.csc.fi/sivut/atcsc/arkisto/atcsc3_2007/ohjelmistot_html/R_and_la
rge_data/

Two hours is a *very* long time to transfer a csv file to a db. The author
of the linked article has not documented how to use scan() arguments
appropriately for the task. I take particular issue with the authors
statement that R is said to be slow, memory hungry and only capable of
handling small datasets, indicating he/she has crummy informants and not
challenged the notion him/herself. 

n.vialma, 100,000 records is likely not a lot of data. If it is taking more
than two or three minutes, something is wrong. Knowing the record limits in
R is a good starting point, but will only get you part of the way. How many
records does your file contain? Do you know how to find out? What are the
data types of the records? What is the call you are using to import the
records into R? What OS are you using? How much RAM does your system have?
What is the size of the R-environment on your system? Do you have resource
intensive applications running (such as MS-Office)?

A lot of folks on this list have been through what you are now dealing with,
so there is plenty of help. I find myself smiling inside  wanting to say
welcome!

Sincerely,
KeithC.

-Original Message-
From: Khanh Nguyen [mailto:nguyen.h.kh...@gmail.com] 
Sent: Saturday, March 27, 2010 8:59 AM
To: n.via...@libero.it
Cc: r-help
Subject: Re: [R] large dataset

This was *very* useful for me when I dealt with a 1.5Gb text file

http://www.csc.fi/sivut/atcsc/arkisto/atcsc3_2007/ohjelmistot_html/R_and_lar
ge_data/


On Sat, Mar 27, 2010 at 5:19 AM, n.via...@libero.it n.via...@libero.it
wrote:
 Hi I have a question,
 as im not able to import a csv file which contains a big dataset(100.000
records) someone knows how many records R can handle without giving
problems?
 What im facing when i try to import the file is that R generates more than
100.000 records and is very slow...
 thanks a lot!!!

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

2010-03-28 Thread Duncan Mackay

Hi
All you need to know to get started with figures (and even up to 
intermediate level)-


Keith Reckdahl's Using Imported Graphics in LATEX and pdfLATEX

Regards

Duncan

Duncan Mackay
Department of Agronomy and Soil Science
University of New England
ARMIDALE NSW 2351
Email home: mac...@northnet.com.au


At 13:37 29/03/2010, you wrote:


On 29/03/2010, at 4:21 PM, Sharpie wrote:

SNIP

 There are a bunch of caveats such as the figure/table will only appear at
 the top or bottom of a page and will not appear on the same page as the
 point at which it was declared in the source.  That is to say, when you
 declare a figure* in a LaTeX document, one page break must pass before the
 environment actually gets set in your document- no matter what !h or H 
vodoo

 you pull.

SNIP

I'm not convinced that this is correct; I'm sure I have had floats
(including figures) placed where I asked them to be placed. :-)

Be that as is it were; if you put:

\usepackage{float}

in your preamble and then do

\begin{figure}[H]

whatever

\end{figure}

the figure will appear ***exactly*** where you put it --- provided
of course that there is room for it there.  Elsewise you'll get a
page break just before the figure.

cheers,

Rolf Turner
##
Attention:
This e-mail message is privileged and confidential. If you are not the
intended recipient please delete the message and notify the sender.
Any views or opinions presented are solely those of the author.

This e-mail has been scanned and cleared by MailMarshal
www.marshalsoftware.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] Page width figures in Latex

2010-03-28 Thread Jim Lemon

On 03/29/2010 02:34 PM, Mike Prager wrote:

...
\begin{figure}[!th]
\begin{center}
\includegraphics[width=\textwidth]{myfig.eps}\\
\end{center}
\end{figure}%


Hi Mike,
I wrote too soon, for there was one combination that I had not tried:

\begin{figure*}[!th]
\includegraphics[width=\textwidth]{hypertens.pdf}
\caption{\label{figure:hypertens}
 Reported hypertension by age, sex and alcohol consumption}
\end{figure*}

did exactly what I wanted. Thanks.

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] Coding of categorical variables for logistic regression?

2010-03-28 Thread David Winsemius
Just because a covariate is ordered does not ensure that the  
relationship will be monotonic.


--
David.

On Mar 28, 2010, at 11:09 PM, C.H. wrote:


?polr of the MASS package.


On Mon, Mar 29, 2010 at 10:39 AM, Ravi Kulkarni  
ravi.k...@gmail.com wrote:


How do I use the extra information that two of my predictors are  
ordinal?

(I did not know I could do that.)

Thanks,
 Ravi
--
View this message in context: 
http://n4.nabble.com/Coding-of-categorical-variables-for-logistic-regression-tp1694250p1694644.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.





--
CH Chan
Research Assistant - KWH
http://www.macgrass.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] Help with assigning a value based on existing numbers

2010-03-28 Thread Petr PIKAL
Hi


Jessica Cathro jcat...@london.edu napsal dne 26.03.2010 15:33:19:

 Hi
 Can you explain what the purpose of the cut function is, and how I would
 use it?

?cut

x-runif(100)*300
cut(x, breaks=seq(0,300,50), labels=letters[1:6])

Regards
Petr


 Thanks
 Jessica
 
 _
 
 Jessica Cathro | Business Analyst | Executive Education 
 London Business School | Regent's Park | London NW1 4SA | United Kingdom
 Switchboard +44 (0)20 7000 7000| Direct line +44 (0)20 7000 7383 |
 Email jcat...@london.edu
 
 www.london.edu | London experience. World impact.
 -Original Message-
 From: Petr PIKAL [mailto:petr.pi...@precheza.cz] 
 Sent: 26 March 2010 14:00
 To: Jessica Cathro
 Cc: r-help@r-project.org
 Subject: Odp: [R] Help with assigning a value based on existing numbers
 
 Hi
 
 again a work for cut.
 
 See ?cut and notice a labels option.
 
 Regards
 Petr
 
 r-help-boun...@r-project.org napsal dne 26.03.2010 11:37:20:
 
  Hi All
  
  I have a column/variable called time difference.  It has a whole list
 of
  numbers from 0 through to the hundreds eg 236.  I want to assign a
  corresponding name to each variable from a predefined list: Month or
  less, 1 -2 months, 2-3 months etc
  
  So the result would look something like:
  
  Time Difference   Month
  
  1  Month or less
  
  365 1-2 years
  
  52   2-3 months
  
  Etc
  
  
  
  I have tried using if elseif (as shown below), but it kept coming up
  with the error:
  
  Error:
  
  In if (curvedata$Date.difference == NULL) { :
  
the condition has length  1 and only the first element will be used
  
  2: In if (curvedata$Date.difference = 29) { :
  
the condition has length  1 and only the first element will be used
  
  3: In if (curvedata$Date.difference = 59) { :
  
the condition has length  1 and only the first element will be used
  
  
  
  If Else Statement:
  
  month -if (curvedata$Date.difference ==NULL) {Month -0}  ifelse
  
  (curvedata$Date.difference =29) {Month -month or less} else if
  
  (curvedata$Date.difference =59) {Month -1-2 months} else if
  
  (curvedata$Date.difference =89) {Month -2-3 months} else if
  
  (curvedata$Date.difference =119) {Month -3-4 months} else if
  
  (curvedata$Date.difference =149) {Month -4-5 months} else if
  
  (curvedata$Date.difference =179) {Month -5-6 months} else if
  
  (curvedata$Date.difference =209) {Month -6-7 months} else if
  
  (curvedata$Date.difference =239) {Month -7-8 months} else if
  
  (curvedata$Date.difference =269) {Month -8-9 months} else if
  
  (curvedata$Date.difference =299) {Month -9-10 months} else if
  
  (curvedata$Date.difference =329) {Month -10-11 months} else if
  
  (curvedata$Date.difference =359) {Month -11-12 months} else if
  
  (curvedata$Date.difference =719) {Month -1-2 years} else 
  
  {Month -More than 2 years}
  
  
  
  I'm pretty new to R, so any help would be appreciated.
  
  Thanks
  
  Jessica
  
  _
  
  Jessica Cathro | Business Analyst | Executive Education 
  London Business School | Regent's Park | London NW1 4SA | United
 Kingdom
  Switchboard +44 (0)20 7000 7000| Direct line +44 (0)20 7000 7383 |
  Email jcat...@london.edu mailto:jcat...@london.edu 
  
  www.london.edu http://www.london.edu/  | London experience. World
  impact.
  
  
  __
  
  This email has been scanned by the MessageLabs Email Security System
  on behalf of the London Business School community.
  For more information please visit http://www.messagelabs.com/email
  __
 [[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.
 
 
 __
 
 This email has been scanned by the MessageLabs Email Security System
 on behalf of the London Business School community.
 For more information please visit http://www.messagelabs.com/email
 __
 
 __
 
 This email has been scanned by the MessageLabs Email Security System
 on behalf of the London Business School community.
 For more information please visit http://www.messagelabs.com/email
 __

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