[R] How to repeat vectors ?

2006-09-30 Thread Tong Wang
Hi,
If I have a matrix  , say   a11   a12
   a21  a22
Is there a routine to get:  a11  a12
 a11  a12
 a21   a22
 a21   a22

 Thanks a lot for any help.

best

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

2006-09-30 Thread Tong Wang
I just figured out a way to do this: 
  rep.vec - function(X,n)return(t(array(rep(X,n),c(length(X),n

   Then,apply(MyMatrix, 2, rep.vec,2)

Is there a better way ?  Is there an internal function to repeat a vector or 
matrix ?

Thanks a lot.


- Original Message -
From: Tong Wang [EMAIL PROTECTED]
Date: Friday, September 29, 2006 11:23 pm
Subject: How to repeat vectors ?
To: r-help@stat.math.ethz.ch

 Hi,
If I have a matrix  , say   a11   a12
   a21  a22
Is there a routine to get:  a11  a12
 a11  a12
 a21   a22
 a21   a22
 
 Thanks a lot for any help.
 
 best


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


Re: [R] strange warning message

2006-09-30 Thread Duncan Murdoch
On 9/30/2006 1:00 AM, Tong Wang wrote:
 Hi Duncan:
  Thank you for your help last time,  since I do not use NULL to indicate 
 empty enviroment, I think I'm fine. 
 And yes, I did upgrade my R version recently,  but how comes I still get this 
 warning for new files created
 and saved after that update ? Is there anyway to get rid of this message ?

Please show some code that leads to the message.  You shouldn't get it 
in new objects, but there could be a bug in R or in a package you're using.

Duncan Murdoch

  Thanks a lot . 
 
 best  
 
 - Original Message -
 From: Duncan Murdoch [EMAIL PROTECTED]
 Date: Saturday, September 23, 2006 5:59 pm
 Subject: Re: [R] strange  warning message
 To: Tong Wang [EMAIL PROTECTED]
 Cc: r-help@stat.math.ethz.ch
 
 On 9/23/2006 7:15 PM, Tong Wang wrote:
 Hi Everyone,
 I recently start to get this warning message,  while loading 
 files in to R.   Could someone tell me what does it mean ?
 I am using R 2.3.0 with Emacs on WinXP.

 use of NULL environment is deprecated 
 The files were saved in an earlier version of R, which used NULL to 
 indicate the base environment.  R is telling you that NULL is not a 
 legal environment.  It should be automatically converted to baseenv().

 In a number of cases, people used NULL to indicate an empty 
 environment 
 (even though there was no such thing when NULL was used); if that's 
 true 
 for your code, then you'll need to fix it.  emptyenv() now gives 
 you an 
 empty environment if that's what you really want.

 Duncan Murdoch


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


Re: [R] if then else

2006-09-30 Thread Uwe Ligges


[EMAIL PROTECTED] wrote:
 What is the correct form to write statement meaning:
 
 if (a==1) {b=2; c=3}; else {b=0; c=0};


if (a==1) {b=2; c=3} else {b=0; c=0};

;-)

Uwe Ligges


 Thank you
 
 
 Jue Wang, Biostatistician
 Contracted Position for Preclinical  Research Biostatistics
 PrO Unlimited
 (908) 231-3022
 
 __
 R-help@stat.math.ethz.ch mailing list
 https://stat.ethz.ch/mailman/listinfo/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@stat.math.ethz.ch mailing list
https://stat.ethz.ch/mailman/listinfo/r-help
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 repeat vectors ?

2006-09-30 Thread Alex Brown
Solution:

m[rep(1:nrow(m),each=2),]

Explanation:

There is a simple and effective way to do this, using array slices.

for your input matrix, m:

  m=matrix(paste(a,c(11,12,21,22),sep=),2)
  m
  [,1]  [,2]
[1,] a11 a21
[2,] a12 a22

you want to create

  [,1]  [,2]
[1,] a11 a21
[2,] a11 a21
[3,] a12 a22
[3,] a12 a22

First, let's just consider the simpler problem of vectors - taking  
the first column as an example:

  v=m[,1]
  v
[1] a11 a12

and you want:

[1] a11 a11 a12 a12

which is the first element, followed by another copy of the first,  
and then the second, followed by another copy of the second, ie:

  v[c(1,1,2,2)]
[1] a11 a11 a12 a12

can we generate the sequence c(1,1,2,2) automatically?  yes:

  rep(c(1,2),each=2)
[1] 1 1 2 2

or:

  rep(1:length(v),each=2)
[1] 1 1 2 2

So let's apply that to the vector:

  v[rep(1:length(v),each=2)]
[1] a11 a11 a12 a12

Going back to the matrix, we can see that we want to do the same  
thing, but to the rows of the matrix, instead of the elements of the  
vector:

Instead of length, we use nrow, and we use the row specifier [r,]

  m[rep(1:nrow(m),each=2),]
  [,1]  [,2]
[1,] a11 a21
[2,] a11 a21
[3,] a12 a22
[4,] a12 a22


-Alex

On 30 Sep 2006, at 07:33, Tong Wang wrote:

 I just figured out a way to do this:
   rep.vec - function(X,n)return(t(array(rep(X,n),c 
 (length(X),n

Then,apply(MyMatrix, 2, rep.vec,2)

 Is there a better way ?  Is there an internal function to repeat a  
 vector or matrix ?

 Thanks a lot.


 - Original Message -
 From: Tong Wang [EMAIL PROTECTED]
 Date: Friday, September 29, 2006 11:23 pm
 Subject: How to repeat vectors ?
 To: r-help@stat.math.ethz.ch

 Hi,
If I have a matrix  , say   a11   a12
   a21  a22
Is there a routine to get:  a11  a12
 a11  a12
 a21   a22
 a21   a22

 Thanks a lot for any help.

 best


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


Re: [R] if then else

2006-09-30 Thread Jim Lemon
[EMAIL PROTECTED] wrote:
 What is the correct form to write statement meaning:
 
 if (a==1) {b=2; c=3}; else {b=0; c=0};
 
if (a==1) {b=2; c=3} else {b=0; c=0};

Jim

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

2006-09-30 Thread Adrian DUSA
Maybe this one?

 MyMatrix - matrix(1:4, nrow=2)

 MyMatrix
 [,1] [,2]
[1,]13
[2,]24

 MyMatrix[rep(seq(nrow(MyMatrix)), each=2), ]
 [,1] [,2]
[1,]13
[2,]13
[3,]24
[4,]24


HTH,
Adrian

On Saturday 30 September 2006 09:33, Tong Wang wrote:
 I just figured out a way to do this:
   rep.vec - function(X,n)   
 return(t(array(rep(X,n),c(length(X),n

Then,apply(MyMatrix, 2, rep.vec,2)

 Is there a better way ?  Is there an internal function to repeat a vector
 or matrix ?

 Thanks a lot.


 - Original Message -
 From: Tong Wang [EMAIL PROTECTED]
 Date: Friday, September 29, 2006 11:23 pm
 Subject: How to repeat vectors ?
 To: r-help@stat.math.ethz.ch

  Hi,
 If I have a matrix  , say   a11   a12
a21  a22
 Is there a routine to get:  a11  a12
  a11  a12
  a21   a22
  a21   a22
 
  Thanks a lot for any help.
 
  best

-- 
Adrian DUSA
Arhiva Romana de Date Sociale
Bd. Schitu Magureanu nr.1
050025 Bucuresti sectorul 5
Romania
Tel./Fax: +40 21 3126618 \
  +40 21 3120210 / int.101

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

2006-09-30 Thread Gabor Grothendieck
Here are 4 approaches in order from most compact
to least.  #1 only works for numeric matrices, # 2 is
a shorter versio of your solution using rep.vec and # 3
is from Alex's post and is likely what I would
use in practice.

m - matrix(1:4, 2) # test matrix

# 1 - m must be numeric for this one to work
kronecker(m, rep(1,2))

# 2
apply(m, 2, rep, each = 2) # 2

# 3 - from Alex's post
m[rep(1:nrow(m), each = 2),]

# 4
matrix(rbind(c(m), c(m)), nc = ncol(m))

On 9/30/06, Tong Wang [EMAIL PROTECTED] wrote:
 I just figured out a way to do this:
  rep.vec - function(X,n)return(t(array(rep(X,n),c(length(X),n

   Then,apply(MyMatrix, 2, rep.vec,2)

 Is there a better way ?  Is there an internal function to repeat a vector or 
 matrix ?

 Thanks a lot.


 - Original Message -
 From: Tong Wang [EMAIL PROTECTED]
 Date: Friday, September 29, 2006 11:23 pm
 Subject: How to repeat vectors ?
 To: r-help@stat.math.ethz.ch

  Hi,
 If I have a matrix  , say   a11   a12
a21  a22
 Is there a routine to get:  a11  a12
  a11  a12
  a21   a22
  a21   a22
 
  Thanks a lot for any help.
 
  best
 

 __
 R-help@stat.math.ethz.ch mailing list
 https://stat.ethz.ch/mailman/listinfo/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@stat.math.ethz.ch mailing list
https://stat.ethz.ch/mailman/listinfo/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] autologistic model? - what package?

2006-09-30 Thread Sara Mouro
Dear all,

 

Could you pleas advise me on the following?

 

I need to use general(ized) linear models (binomial distribution + logit
link function) , to describe the preferred environment of each species (each
sample is an individual in which I have measured several variables and also
recorded the species it belongs to) 

 

However,  must account for the spatial autrefoocorrelation between
individuals.

 

- So I think I need something like the so called autologistic models.
isn't it?

- What package would you advise me to use for that?

 

Thank you in advance.

 

Best regards,

Sara Mouro


[[alternative HTML version deleted]]

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


Re: [R] Heteroskedasticity test

2006-09-30 Thread Achim Zeileis
On Fri, 29 Sep 2006, Alberto Monteiro wrote:

 Is there any heteroskedasticity test in the package? Something
 that would flag a sample like

  x - c(rnorm(1000), rnorm(1000, 0, 1.2))

The package lmtest contains several tests for heteroskedasticity, in 
particular the Breusch-Pagan test (and also the Goldfeld-Quandt test for 
known change point). Furthermore, some of the structural change tests in 
strucchange can be used to test for non-constant variances, e.g, the 
Nyblom-Hansen test.
Z

 Alberto Monteiro

 __
 R-help@stat.math.ethz.ch mailing list
 https://stat.ethz.ch/mailman/listinfo/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@stat.math.ethz.ch mailing list
https://stat.ethz.ch/mailman/listinfo/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] Textmate project drawer: is there a Windows alternative?

2006-09-30 Thread Graham Smith
I was reading about the project drawer feature in Textmate, which is Mac
only.

Is there a similar feature in a Windows based text editor that works with R.
This feature sounds really useful.

Thanks,

Graham

[[alternative HTML version deleted]]

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


Re: [R] autologistic model? - what package?

2006-09-30 Thread Roger Bivand
On Sat, 30 Sep 2006, Sara Mouro wrote:

 Dear all,
 
 Could you pleas advise me on the following?
 
 I need to use general(ized) linear models (binomial distribution + logit
 link function) , to describe the preferred environment of each species (each
 sample is an individual in which I have measured several variables and also
 recorded the species it belongs to) 
 
  
 
 However,  must account for the spatial autrefoocorrelation between
 individuals.
 
  
 
 - So I think I need something like the so called autologistic models.
 isn't it?
 
 - What package would you advise me to use for that?
 

RSiteSearch(autologistic)

tells you what is known about this, which I'm afraid seems to be that no 
such function is available. Your question is very similar to the first hit 
in the site search, and that received no answer. 

If you are willing to try a different framework, the ME() Moran
eigenvector function in the spdep package is a possibility, albeit not yet
well-proven. It adds selected eigenvectors from a centred spatial weights
matrix to the RHS of the glm to whiten out spatial dependence, but it
will also whiten out or paint over other spatially patterned
mis-specification problems.

  
 
 Thank you in advance.
 
  
 
 Best regards,
 
 Sara Mouro
 
 
   [[alternative HTML version deleted]]
 
 __
 R-help@stat.math.ethz.ch mailing list
 https://stat.ethz.ch/mailman/listinfo/r-help
 PLEASE do read the posting guide http://www.R-project.org/posting-guide.html
 and provide commented, minimal, self-contained, reproducible code.
 

-- 
Roger Bivand
Economic Geography Section, Department of Economics, Norwegian School of
Economics and Business Administration, Helleveien 30, N-5045 Bergen,
Norway. voice: +47 55 95 93 55; fax +47 55 95 95 43
e-mail: [EMAIL PROTECTED]

__
R-help@stat.math.ethz.ch mailing list
https://stat.ethz.ch/mailman/listinfo/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] only need the p-value

2006-09-30 Thread Boks, M.P.M.
 

Dear R users,

 

I am calculating several cox proportional hazard models after each other (I 
know this is unusual, but I am just exploring the data). For the purpose of 
multiple testing correction I need to construct an array of these p-values. 
However since the output is not an array in itself, I cannot find a way to 
obtain the p-value only.

 

 attach(tms)  

 

 goal-rep(0.7*FREQUENC[1:13],6)

 event- Surv(TIJD,FREQUENCgoal)

 results-coxph(event~ TYPETREA)

 summary(results)

 

Call:

coxph(formula = event ~ TYPETREA)

 

  n=76 (2 observations deleted due to missing)

 coef exp(coef) se(coef) z p

TYPETREAnon-guided -0.826 0.4380.484 -1.71 0.088

 

   exp(coef) exp(-coef) lower .95 upper .95

TYPETREAnon-guided 0.438   2.28 0.169  1.13

 

Rsquare= 0.041   (max possible= 0.829 )

Likelihood ratio test= 3.2  on 1 df,   p=0.0737

Wald test= 2.91  on 1 df,   p=0.088

Score (logrank) test = 3.08  on 1 df,   p=0.0794

 

Does anyone now how to extract the p-value?

Many thanks!,

Marco

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


Re: [R] Build error on Windows

2006-09-30 Thread Duncan Murdoch
On 9/29/2006 5:41 PM, Pankaj Savdekar wrote:
 Thanks for the quick reply.
 
 On 9/29/2006 8:53 AM, Pankaj Savdekar wrote:
 Hi,

 I'm trying to build R-2.3.1 on windows, but make gives me following error 
 while building pkg-base:
 -- Making package base 
   adding build stamp to DESCRIPTION
 make[4]: *** [frontmatter] Error 1
 make[3]: *** [all] Error 2
 make[2]: *** [pkg-base] Error 2
 make[1]: *** [rpackage] Error 2
 make: *** [all] Error 2

 Please note that R.exe, Rterm.exe, Rgui.exe, RCmd.exe are build without 
 any errors.

 I have three questions, can anyone please help me to resolve it?
 1. How to solve (or get more details) of the above mentioned error?
 You need to look through the make files, to see what was happening. Reading 
 the messages in reverse order:  make all called make rpackage and so on 
 to make frontmatter.  The errors don't tell you which makefiles these are 
 in, but the frontmatter target only occurs in src/gnuwin32/MakePkg.  You 
 could try deleting the @ signs from the lines for that target to see 
 exactly what was happening when the error was generated.
 
 Yes I could figure out the source of 'frontmatter', but my problem is, there 
 is no error message. I tried 'make -d' too. I tried removing '@', but no 
 change.
 
 I'd guess that this is happening because your build is messed up:  the base 
 package is used in later build steps.  If you start from a clean checkout 
 and just call make, you probably won't see this.
 
 Is there any way to check what could have been wrong in building base 
 package?

You could look at whatever command in the makefile failed, and try it 
outside of the makefile, try variations on it, etc.  I can't give more 
specific advice without more specific information on where the error 
happened.

If you're not used to working in Windows, remember that it is not like 
Unix in several ways.  In particular, you can't delete an open file, 
because it's considered an error for a file to exist unless it has a 
valid directory entry.  If you try to replace a file that is open, the 
replacement will fail, and that may lead to other errors later.

Duncan Murdoch

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


Re: [R] if then else

2006-09-30 Thread Duncan Murdoch
On 9/30/2006 6:29 AM, Uwe Ligges wrote:
 
 [EMAIL PROTECTED] wrote:
 What is the correct form to write statement meaning:

 if (a==1) {b=2; c=3}; else {b=0; c=0};
 
 
 if (a==1) {b=2; c=3} else {b=0; c=0};

That's valid, but is it correct form?  The semicolon at the end is not 
needed.  I'd say it's a bad idea to use one, because it might give a 
mistaken impression about the meaning of something like

  a = 1
  + 2;

It's better to avoid semi-colons whenever possible, to make sure the C 
parser in your brain throws an exception and lets the R parser take over.

Duncan Murdoch

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


Re: [R] Textmate project drawer: is there a Windows alternative?

2006-09-30 Thread Duncan Murdoch
On 9/30/2006 8:38 AM, Graham Smith wrote:
 I was reading about the project drawer feature in Textmate, which is Mac
 only.
 
 Is there a similar feature in a Windows based text editor that works with R.
 This feature sounds really useful.

If you don't get an answer, it would probably be a good idea to describe 
what a project drawer is.  The population of people who know Textmate 
and Windows text editors is probably pretty small.

Duncan Murdoch

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


Re: [R] Textmate project drawer: is there a Windows alternative?

2006-09-30 Thread Graham Smith
Duncan,

That seems a good idea :-)

Project drawer appears to be a side panel in TextMate with folders where you
can drop and drag R output and code into, not sure about graphic output, but
that would also be useful.

Each folder representing a particular project - hence the name.

Graham


On 30/09/06, Duncan Murdoch [EMAIL PROTECTED] wrote:

 On 9/30/2006 8:38 AM, Graham Smith wrote:
  I was reading about the project drawer feature in Textmate, which is Mac
  only.
 
  Is there a similar feature in a Windows based text editor that works
 with R.
  This feature sounds really useful.

 If you don't get an answer, it would probably be a good idea to describe
 what a project drawer is.  The population of people who know Textmate
 and Windows text editors is probably pretty small.

 Duncan Murdoch

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



[[alternative HTML version deleted]]

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


Re: [R] if then else

2006-09-30 Thread Uwe Ligges


Duncan Murdoch wrote:
 On 9/30/2006 6:29 AM, Uwe Ligges wrote:

 [EMAIL PROTECTED] wrote:
 What is the correct form to write statement meaning:

 if (a==1) {b=2; c=3}; else {b=0; c=0};


 if (a==1) {b=2; c=3} else {b=0; c=0};
 
 That's valid, but is it correct form?  The semicolon at the end is not 
 needed.  I'd say it's a bad idea to use one, because it might give a 
 mistaken impression about the meaning of something like
 
  a = 1
  + 2;
 
 It's better to avoid semi-colons whenever possible, to make sure the C 
 parser in your brain throws an exception and lets the R parser take over.
 
 Duncan Murdoch


Of course, Duncan is right, and shame on me for posting it in such a 
pedagogically bad way on R-help, but I could not resist to simply remove 
a single semicolon from the original question.

Thank you, Duncan, for pointing it out.

Uwe

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


Re: [R] only need the p-value

2006-09-30 Thread Ritwik Sinha
This is how you go about doing this.

summary(results)$coefficients[1,5]

You will have to check this for you code. But the idea is that
summary(results) is a list (?) and one of its components is called
coefficients, which is a matrix. So the problem is just to extract
one element of this matrix.

I am not well versed with coxph so there may be some minor details I
am missing, but that is the general idea (same as with lm, glm etc.).

Ritwik.

On 9/30/06, Boks, M.P.M. [EMAIL PROTECTED] wrote:


 Dear R users,



 I am calculating several cox proportional hazard models after each other (I 
 know this is unusual, but I am just exploring the data). For the purpose of 
 multiple testing correction I need to construct an array of these p-values. 
 However since the output is not an array in itself, I cannot find a way to 
 obtain the p-value only.



  attach(tms)

 

  goal-rep(0.7*FREQUENC[1:13],6)

  event- Surv(TIJD,FREQUENCgoal)

  results-coxph(event~ TYPETREA)

  summary(results)



 Call:

 coxph(formula = event ~ TYPETREA)



   n=76 (2 observations deleted due to missing)

  coef exp(coef) se(coef) z p

 TYPETREAnon-guided -0.826 0.4380.484 -1.71 0.088



exp(coef) exp(-coef) lower .95 upper .95

 TYPETREAnon-guided 0.438   2.28 0.169  1.13



 Rsquare= 0.041   (max possible= 0.829 )

 Likelihood ratio test= 3.2  on 1 df,   p=0.0737

 Wald test= 2.91  on 1 df,   p=0.088

 Score (logrank) test = 3.08  on 1 df,   p=0.0794



 Does anyone now how to extract the p-value?

 Many thanks!,

 Marco

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



-- 
Ritwik Sinha
Graduate Student
Epidemiology and Biostatistics
Case Western Reserve University
[EMAIL PROTECTED] | +12163682366 | http://darwin.cwru.edu/~rsinha

__
R-help@stat.math.ethz.ch mailing list
https://stat.ethz.ch/mailman/listinfo/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] Print/Save/Cat/Write list

2006-09-30 Thread Ritwik Sinha
Hi,

I would like to write a list to an ascii file.
I tried the following

y - list(a = 1, b = c(TRUE,FALSE), c = oops)
save(y, file=y.data, ascii=TRUE)
# Not satisfactory

print does not have a file= option
cat cannot handle lists.
write does not handle lists
write.table converts it to a d.f

Perhaps I could loop through the elements of a list and keep appending
its elements to a file, but that will have a problem if any of the
elements of the list is a list. I suppose there must be a simple
function that does what I need. Sorry if I have missed anything
obvious, my searches did not return anything useful.

Thanks and regards,
Ritwik.

Here is my version

platform i686-redhat-linux-gnu
arch i686
os   linux-gnu
system   i686, linux-gnu
status
major2
minor2.1
year 2005
month12
day  20
svn rev  36812
language R

-- 
Ritwik Sinha
Graduate Student
Epidemiology and Biostatistics
Case Western Reserve University
[EMAIL PROTECTED] | +12163682366 | http://darwin.cwru.edu/~rsinha

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


Re: [R] Print/Save/Cat/Write list

2006-09-30 Thread jim holtman
try:

sink(y.data)
y
sink()

On 9/30/06, Ritwik Sinha [EMAIL PROTECTED] wrote:
 Hi,

 I would like to write a list to an ascii file.
 I tried the following

 y - list(a = 1, b = c(TRUE,FALSE), c = oops)
 save(y, file=y.data, ascii=TRUE)
 # Not satisfactory

 print does not have a file= option
 cat cannot handle lists.
 write does not handle lists
 write.table converts it to a d.f

 Perhaps I could loop through the elements of a list and keep appending
 its elements to a file, but that will have a problem if any of the
 elements of the list is a list. I suppose there must be a simple
 function that does what I need. Sorry if I have missed anything
 obvious, my searches did not return anything useful.

 Thanks and regards,
 Ritwik.

 Here is my version

 platform i686-redhat-linux-gnu
 arch i686
 os   linux-gnu
 system   i686, linux-gnu
 status
 major2
 minor2.1
 year 2005
 month12
 day  20
 svn rev  36812
 language R

 --
 Ritwik Sinha
 Graduate Student
 Epidemiology and Biostatistics
 Case Western Reserve University
 [EMAIL PROTECTED] | +12163682366 | http://darwin.cwru.edu/~rsinha

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



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

What is the problem you are trying to solve?

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


Re: [R] Print/Save/Cat/Write list

2006-09-30 Thread Rolf Turner

?sink

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


Re: [R] Print/Save/Cat/Write list

2006-09-30 Thread Ritwik Sinha
thanks.

Ritwik.

On 9/30/06, jim holtman [EMAIL PROTECTED] wrote:
 try:

 sink(y.data)
 y
 sink()

 On 9/30/06, Ritwik Sinha [EMAIL PROTECTED] wrote:
  Hi,
 
  I would like to write a list to an ascii file.
  I tried the following
 
  y - list(a = 1, b = c(TRUE,FALSE), c = oops)
  save(y, file=y.data, ascii=TRUE)
  # Not satisfactory
 
  print does not have a file= option
  cat cannot handle lists.
  write does not handle lists
  write.table converts it to a d.f
 
  Perhaps I could loop through the elements of a list and keep appending
  its elements to a file, but that will have a problem if any of the
  elements of the list is a list. I suppose there must be a simple
  function that does what I need. Sorry if I have missed anything
  obvious, my searches did not return anything useful.
 
  Thanks and regards,
  Ritwik.
 
  Here is my version
 
  platform i686-redhat-linux-gnu
  arch i686
  os   linux-gnu
  system   i686, linux-gnu
  status
  major2
  minor2.1
  year 2005
  month12
  day  20
  svn rev  36812
  language R
 
  --
  Ritwik Sinha
  Graduate Student
  Epidemiology and Biostatistics
  Case Western Reserve University
  [EMAIL PROTECTED] | +12163682366 | http://darwin.cwru.edu/~rsinha
 
  __
  R-help@stat.math.ethz.ch mailing list
  https://stat.ethz.ch/mailman/listinfo/r-help
  PLEASE do read the posting guide http://www.R-project.org/posting-guide.html
  and provide commented, minimal, self-contained, reproducible code.
 


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

 What is the problem you are trying to solve?



-- 
Ritwik Sinha
Graduate Student
Epidemiology and Biostatistics
Case Western Reserve University
[EMAIL PROTECTED] | +12163682366 | http://darwin.cwru.edu/~rsinha

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


Re: [R] Heteroskedasticity test

2006-09-30 Thread Ritwik Sinha
you may also try to levene test. Once again i think it is for a known
change point.

http://finzi.psych.upenn.edu/R/library/car/html/levene.test.html

On 9/30/06, Achim Zeileis [EMAIL PROTECTED] wrote:
 On Fri, 29 Sep 2006, Alberto Monteiro wrote:

  Is there any heteroskedasticity test in the package? Something
  that would flag a sample like
 
   x - c(rnorm(1000), rnorm(1000, 0, 1.2))

 The package lmtest contains several tests for heteroskedasticity, in
 particular the Breusch-Pagan test (and also the Goldfeld-Quandt test for
 known change point). Furthermore, some of the structural change tests in
 strucchange can be used to test for non-constant variances, e.g, the
 Nyblom-Hansen test.
 Z

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



-- 
Ritwik Sinha
Graduate Student
Epidemiology and Biostatistics
Case Western Reserve University
[EMAIL PROTECTED] | +12163682366 | http://darwin.cwru.edu/~rsinha

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


Re: [R] Print/Save/Cat/Write list

2006-09-30 Thread Gabor Grothendieck
Check out ?dput

On 9/30/06, Ritwik Sinha [EMAIL PROTECTED] wrote:
 Hi,

 I would like to write a list to an ascii file.
 I tried the following

 y - list(a = 1, b = c(TRUE,FALSE), c = oops)
 save(y, file=y.data, ascii=TRUE)
 # Not satisfactory

 print does not have a file= option
 cat cannot handle lists.
 write does not handle lists
 write.table converts it to a d.f

 Perhaps I could loop through the elements of a list and keep appending
 its elements to a file, but that will have a problem if any of the
 elements of the list is a list. I suppose there must be a simple
 function that does what I need. Sorry if I have missed anything
 obvious, my searches did not return anything useful.

 Thanks and regards,
 Ritwik.

 Here is my version

 platform i686-redhat-linux-gnu
 arch i686
 os   linux-gnu
 system   i686, linux-gnu
 status
 major2
 minor2.1
 year 2005
 month12
 day  20
 svn rev  36812
 language R

 --
 Ritwik Sinha
 Graduate Student
 Epidemiology and Biostatistics
 Case Western Reserve University
 [EMAIL PROTECTED] | +12163682366 | http://darwin.cwru.edu/~rsinha

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


[R] plotting

2006-09-30 Thread Anupam Tyagi
Is there something in R that will display both observed values and their
influence on calculated statistics?
Anupam.

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


Re: [R] a decimal aligned column

2006-09-30 Thread BBands
As requested:

The alignment problem came from calling format many times. Marc
Schwartz suggested a solution of putting my results in a vector and
then formatting. As I understand it the problem is that fixed-width
fields are only available from sprintf, while comma delineation is
only available from format, formatC and prettyNum. The
interrelationships are complicated (format calls prettyNum) and
require _very_ careful study. Here is Marc's solution with a few
changes. It left aligns the symbols and truncates, right aligns and
comma delineates the numbers. In short you get a nice table that is
easy to scan.

If I had one wish for format, it would be that it could set fixed
field width as well as minimum.

library(tseries)
# the symbols
symbols - c('spy', 'ise', 'oih', 'mot', 'pbj', '')
# set the start date to a year ago
Start - Sys.Date() - 366
# Pre-allocate dolVol as a vector
dolVol - numeric(length(symbols))
# Now get the values, assign to dolVol by indexing
for(line in seq(along = symbols))
{
 a - get.hist.quote(instrument=symbols[line], start=Start,
 compression=w, quote=c(Close, Volume),
 quiet=TRUE)

 dolVol[line] - mean(a[,1]) * mean(a[,2])
}
# Now for the initial common formatting,
# truncating the dolVol values to whole numbers
dolVol.pretty - format(trunc(dolVol), big.mark=,, scientific=FALSE,
   justify=right, width=15)
# Now output
cat(paste(sprintf('%-4s',symbols), dolVol.pretty,
collapse = \n, sep = ), \n)

spy  8,770,399,023
ise 21,296,087
oih  1,415,206,983
mot416,923,148
pbj246,700
 4,077,543,493

jab
-- 
John Bollinger, CFA, CMT
www.BollingerBands.com

If you advance far enough, you arrive at the beginning.

__
R-help@stat.math.ethz.ch mailing list
https://stat.ethz.ch/mailman/listinfo/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] Gradient problem in nlm

2006-09-30 Thread singyee ling
Hello everyone!


I am having some trouble supplying the gradient function to nlm in R for
windows version 2.2.1.

What follows are the R-code I use:

fredcs39-function(a1,b1,b2,x){return(a1+exp(b1+b2*x))}
loglikcs39-function(theta,len){
value-sum(mcs39[1:len]*fredcs39(theta[1],theta[2],theta[3],c(8:(7+len))) -
pcs39[1:len] * log(fredcs39(theta[1],theta[2],theta[3],c(8:(7+len)
a1-theta[1]; b1-theta[2]; b2-theta[3]
df.a1-sum(-mcs39[1:len] + pcs39[1:len]/(a1+exp(b1+b2*c(8:(7+len)
df.b1-sum( -mcs39[1:len] * exp(b1+b2*c(8:(7+len))) + (pcs39[1:len] *
exp(b1+b2*c(8:(7+len))) ) /(a1+exp(b1+b2*c(8:(7+len)
df.b2- sum(-mcs39[1:len] * exp(b1+b2*c(8:(7+len))) * c(8:(7+len))  +
(pcs39[1:len] * exp(b1+b2*c(8:(7+len)))  * c(8:(7+len))  )
/(a1+exp(b1+b2*c(8:(7+len )


attr(value,gradient)-c(df.a1,df.b1,df.b2)
return(value)
}

theta.start-c(0.01 ,-1.20, -0.0005)
outcs39-nlm(loglikcs39,theta.start,len=50)


Error in nlm(loglikcs39, theta.start, len = 50) :
probable coding error in analytic gradient


Any light that can be shed on this would be highly appreciated.
Many thanks

Singyee Ling

[[alternative HTML version deleted]]

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


Re: [R] a decimal aligned column

2006-09-30 Thread Gabor Grothendieck
For the last line you could also consider the print.data.frame method:

   data.frame(Symbol = symbols, dolVol = dolVol.pretty)

or

   data.frame(row.names = symbols, dolVol = dolVol.pretty)

capture.output or sink could be used if you want to direct it to a file.

On 9/30/06, BBands [EMAIL PROTECTED] wrote:
 As requested:

 The alignment problem came from calling format many times. Marc
 Schwartz suggested a solution of putting my results in a vector and
 then formatting. As I understand it the problem is that fixed-width
 fields are only available from sprintf, while comma delineation is
 only available from format, formatC and prettyNum. The
 interrelationships are complicated (format calls prettyNum) and
 require _very_ careful study. Here is Marc's solution with a few
 changes. It left aligns the symbols and truncates, right aligns and
 comma delineates the numbers. In short you get a nice table that is
 easy to scan.

 If I had one wish for format, it would be that it could set fixed
 field width as well as minimum.

 library(tseries)
 # the symbols
 symbols - c('spy', 'ise', 'oih', 'mot', 'pbj', '')
 # set the start date to a year ago
 Start - Sys.Date() - 366
 # Pre-allocate dolVol as a vector
 dolVol - numeric(length(symbols))
 # Now get the values, assign to dolVol by indexing
 for(line in seq(along = symbols))
 {
  a - get.hist.quote(instrument=symbols[line], start=Start,
 compression=w, quote=c(Close, Volume),
 quiet=TRUE)

  dolVol[line] - mean(a[,1]) * mean(a[,2])
 }
 # Now for the initial common formatting,
 # truncating the dolVol values to whole numbers
 dolVol.pretty - format(trunc(dolVol), big.mark=,, scientific=FALSE,
   justify=right, width=15)
 # Now output
 cat(paste(sprintf('%-4s',symbols), dolVol.pretty,
collapse = \n, sep = ), \n)

 spy  8,770,399,023
 ise 21,296,087
 oih  1,415,206,983
 mot416,923,148
 pbj246,700
  4,077,543,493

jab
 --
 John Bollinger, CFA, CMT
 www.BollingerBands.com

 If you advance far enough, you arrive at the beginning.

 __
 R-help@stat.math.ethz.ch mailing list
 https://stat.ethz.ch/mailman/listinfo/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@stat.math.ethz.ch mailing list
https://stat.ethz.ch/mailman/listinfo/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] Setting NA

2006-09-30 Thread Anupam Tyagi
Is there a way to set NA values in R, without changing the dataframe? I would
like to use different combinations of non-response values, as if they were NA
for some of the computations. I don't want to change the dataframe each time I
have to do this?
Anupam.

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


Re: [R] Need help to estimate the Coef matrices in mAr

2006-09-30 Thread Spencer Graves
  I'm sorry, but I can't follow what you are asking.  If you'd like 
more help, please provide commented, minimal, self-contained, 
reproducible code, as suggested in the posting guide 
www.R-project.org/posting-guide.html. 
http://www.R-project.org/posting-guide.html  Please include a minimal 
data set, e.g., 10 simulated observations on 2 variables, with comments 
describing what you tried and what you don't understand about it. 

  Hope this helps. 
  Spencer Graves

Arun Kumar Saha wrote:

 Dear Spencer,

  

 Thank you very much for your attention on my problem. According to 
 your advice I did some home work on this problem, but unfortunately I 
 could not solve my problem.

  

  

 Suppose I have a dataset of length 300 with 2 variables. And I want to 
 fit a VAR model on this of order 2.

  

 I went through the function mAr.est and got understand that, here 'K' 
 is a matrix with (300-2) rows and 7 columns. the first col. consists 
 only 1, next two columns consist of lagged values of two variables 
 with lag-length 2, next two col. consist of lagged value with lag 
 length-1, and next two cols are for lag-length-0.

  

 Next, they add additional a 7-7 matrix to K. For this matrix diagonal 
 elements are the square root of sum of square of elements of K (col. 
 wise) and rest of the elements are 0.

  

 I feel that this matrix, that is added to K, is the key matrix for any 
 type of modification that you prescribed. Therefore for experimental 
 purpose I put NA against one of its off-diagonal elements. But I got 
 error.

  

 However I cannot understand why they put such figures for diagonal and 
 off-diagonal elements of that matrix.

  

 Can you suggest me any solution more specifically?

  

  

 Thanks and regards,

 Arun



 On 9/4/06, *Spencer Graves* [EMAIL PROTECTED] 
 mailto:[EMAIL PROTECTED] wrote:

   Have you tried 'RSiteSearch(multivariate autoregression,
 functions)'?  This produced 14 hits for me just now, the first of
 which mentions a package 'MSBVAR'.  Have you looked at that?

   If that failed, I don't think it would be too hard to modify
 'mAr.est' to do what you want.  If it were my problem, I might a local
 copy of the function, then add an argument accepting a 2 or
 3-dimensional array with numbers for AR coefficients to be fixed
 and NAs
 for the coefficients.  Then I'd use 'debug' to walk through the
 function
 line by line until I figured out how to modify the function to do
 what I
 wanted.  I haven't checked all the details, so I don't know for
 sure if
 this would work, but the function contains a line 'R =
 qr.R(qr((rbind(K,
 diag(scale, complete = TRUE)' which I would start by decomposing,
 possibly starting as follows:

   Z - rbind(K, diag(scale)

 I'd figure out how the different columns of Z relate to my
 problem, then
 modify it appropriately to get what I wanted.

   Another alternative would be to program it from scratch using
 something like 'optim' to minimize the sum of squares of residuals
 over
 the free parameters in my AR matrices.   I'm confident I could
 make this
 work, even if the I somehow could not get it with either of the
 other two.

   There may be something else  better, e.g., a Kalman filter
 representation, but I can't think how to do that off the top if my
 head.

   Hope this helps.
   Spencer Graves

 Arun Kumar Saha wrote:
  Dear R users,
 
  I am using mAr package to fit a Vector autoregressive model to
 my data. But
  here I want to put some predetermined values for some elements in
  coefficient matrix that mAr.est going to estimate. For example
 if p=3 then I
  want to put A3[1,3] = 0 and keep rest of the elements of
 coefficient
  matrices to be determined by mAr.est.
 
  Can anyone please tell me how can I do that?
 
  Sincerely yours,
  Arun
 
[[alternative HTML version deleted]]
 
  __
  R-help@stat.math.ethz.ch mailto:R-help@stat.math.ethz.ch
 mailing list
  https://stat.ethz.ch/mailman/listinfo/r-help
 https://stat.ethz.ch/mailman/listinfo/r-help
  PLEASE do read the posting guide
 http://www.R-project.org/posting-guide.html
  and provide commented, minimal, self-contained, reproducible code.
 




 -- 
 Arun Kumar Saha, M.Sc.[C.U.]
 S T A T I S T I C I A N[Analyst]
 RISK  MANAGEMENT  DIVISION
 Transgraph Consulting [ www.transgraph.com http://www.transgraph.com]
 Hyderabad, INDIA
 Contact #  Home: (91-033) 25558038
 Office: (91-040) 30685012 Ext. 17
   FAX: (91-040) 55755003
Mobile: 919989122010
 E-Mail: [EMAIL PROTECTED] 
 mailto:[EMAIL PROTECTED]
 [EMAIL PROTECTED] mailto:[EMAIL PROTECTED]


Re: [R] Setting NA

2006-09-30 Thread David Barron
Would using the subset argument that is available in many functions
(eg lm) achieve what you want?

On 30/09/06, Anupam Tyagi [EMAIL PROTECTED] wrote:
 Is there a way to set NA values in R, without changing the dataframe? I would
 like to use different combinations of non-response values, as if they were NA
 for some of the computations. I don't want to change the dataframe each time I
 have to do this?
 Anupam.

 __
 R-help@stat.math.ethz.ch mailing list
 https://stat.ethz.ch/mailman/listinfo/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 Barron
Said Business School
University of Oxford
Park End Street
Oxford OX1 1HP

__
R-help@stat.math.ethz.ch mailing list
https://stat.ethz.ch/mailman/listinfo/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] package e1071 - class probabilities

2006-09-30 Thread David Meyer
Vince:

the implementations for both are different, so this might happen
(although undesirably).

Can you provide me an example with data (off-list)?

David

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


Re: [R] fitting a gaussian to some x,y data

2006-09-30 Thread H. Paul Benton
Michael,



I'm also playing with the nls function trying to get it to work
with a Gaussian. My lines that I have at the moment and I hope will help you
are 

 

class(fo - (x ~ (A/(sig*sqrt(2*pi)))* exp(-1*((bin-mu)^2/(2* sig^2)

nls.AB - nls(fo,data=freq.tab, start= list(A=0.1*len, mu=0.01, sig=0.5),
trace=TRUE)

 

So first I create the eq to put into the nls function, my var
are the freq.tab which is a list of some binned frequency into 0.1 units and
the len is amount of features in the data. I'll say quickly that at the
moment I am getting a 'singular gradient error'. I hope that this helps.

 

Cheers.

 

Paul Benton



Research Technician

Mass Spectrometry

   o The

  /

o Scripps

  \

   o Research

  /

o Institute

 


[[alternative HTML version deleted]]

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


Re: [R] strange warning message

2006-09-30 Thread Duncan Murdoch
On 9/30/2006 3:31 PM, John C Frain wrote:
 I get a similar message when i start Sciviews R console.  I do not get the
 message when I start R directly or through Tinn-r .  If I load the libraries
 one by one the message is returned after svViews is loaded.  I presume there
 is some problem with svViews.  However it does not appear to have any
 consequences for my work.  I use R 2.3.1 with Windows XP and I should have
 the latest versions of packages installed

This does look like an svViews problem, possibly because it's loading an 
  old binary copy of some object, or because it hasn't been recompiled 
for the release you're using.

It may become a more serious problem when the use becomes defunct 
instead of deprecated:  then the usage will generate an error. 
However, I believe we intend to maintain the ability to read old data 
files as long as possible, so you might not see any consequences.

Duncan Murdoch

 
 John C Frain
 
 output of R session started with Sciviews
 R is a collaborative project with many contributors.
 Type 'contributors()' for more information and
 'citation()' on how to cite R or R packages in publications.
 
 Type 'demo()' for some demos, 'help()' for on-line help, or
 'help.start()' for an HTML browser interface to help.
 Type 'q()' to quit R.
 
 [Previously saved workspace restored]
 
 Loading required package: datasets
 Loading required package: utils
 Loading required package: grDevices
 Loading required package: graphics
 Loading required package: stats
 Loading required package: methods
 Loading required package: tcltk
 Loading Tcl/Tk interface ... done
 Loading required package: R2HTML
 Loading required package: svMisc
 Loading required package: svIO
 Loading required package: svViews
 During startup - Warning message:
 use of NULL environment is deprecated
 
 
 On 30/09/06, Duncan Murdoch [EMAIL PROTECTED] wrote:
 On 9/30/2006 1:00 AM, Tong Wang wrote:
 Hi Duncan:
  Thank you for your help last time,  since I do not use NULL to
 indicate empty enviroment, I think I'm fine.
 And yes, I did upgrade my R version recently,  but how comes I still get
 this warning for new files created
 and saved after that update ? Is there anyway to get rid of this message
 ?

 Please show some code that leads to the message.  You shouldn't get it
 in new objects, but there could be a bug in R or in a package you're
 using.

 Duncan Murdoch

  Thanks a lot .

 best

 - Original Message -
 From: Duncan Murdoch [EMAIL PROTECTED]
 Date: Saturday, September 23, 2006 5:59 pm
 Subject: Re: [R] strange  warning message
 To: Tong Wang [EMAIL PROTECTED]
 Cc: r-help@stat.math.ethz.ch

 On 9/23/2006 7:15 PM, Tong Wang wrote:
 Hi Everyone,
 I recently start to get this warning message,  while loading
 files in to R.   Could someone tell me what does it mean ?
 I am using R 2.3.0 with Emacs on WinXP.

 use of NULL environment is deprecated
 The files were saved in an earlier version of R, which used NULL to
 indicate the base environment.  R is telling you that NULL is not a
 legal environment.  It should be automatically converted to baseenv().

 In a number of cases, people used NULL to indicate an empty
 environment
 (even though there was no such thing when NULL was used); if that's
 true
 for your code, then you'll need to fix it.  emptyenv() now gives
 you an
 empty environment if that's what you really want.

 Duncan Murdoch

 __
 R-help@stat.math.ethz.ch mailing list
 https://stat.ethz.ch/mailman/listinfo/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@stat.math.ethz.ch mailing list
https://stat.ethz.ch/mailman/listinfo/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] Inner product

2006-09-30 Thread Sonal Darbari
Hi,

How do we find out the inner product  norm of eigen vectors in R?

Lets say we have eigen vectors :
x1 = 1,2,3 and x2 = 2,-3,4

are there any functions buit in R which directly calculate the inner product
 norm of vectors?

Thanks,
Sonal.

[[alternative HTML version deleted]]

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


[R] error from pmvnorm

2006-09-30 Thread yonghai
Hi all,

Can anyone tell me what the following error message means?
 Error in mvt(lower = lower, upper = upper, df = 0, corr = corr, delta = mean, 
:  NA/NaN/Inf in foreign function call (arg 6)

It was generated when I used the 'pmvnorm' function in the 'mvtnorm' package.

Thanks a lot.

Yonghai Li

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


Re: [R] Inner product

2006-09-30 Thread David Barron
For inner product see ?%*%.  There is a norm function in the Matrix package.

On 30/09/06, Sonal Darbari [EMAIL PROTECTED] wrote:
 Hi,

 How do we find out the inner product  norm of eigen vectors in R?

 Lets say we have eigen vectors :
 x1 = 1,2,3 and x2 = 2,-3,4

 are there any functions buit in R which directly calculate the inner product
  norm of vectors?

 Thanks,
 Sonal.

 [[alternative HTML version deleted]]

 __
 R-help@stat.math.ethz.ch mailing list
 https://stat.ethz.ch/mailman/listinfo/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 Barron
Said Business School
University of Oxford
Park End Street
Oxford OX1 1HP

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


[R] [R-pkgs] Reshape version 0.7.1

2006-09-30 Thread hadley wickham
Reshape version 0.7.1
=

Reshape is an R package for flexibly restructuring and aggregating
data.  It's inspired by Excel's pivot tables, and it (hopefully) makes
it very easy to get your data into the shape that you want.  You can find out
more at http://had.co.nz/reshape

What's new in this version?

 * A 25 page introductory vignette, also available at
http://had.co.nz/reshape/introduction.pdf, which shows some of the
many ways that you can use reshape.

 * The biggest change is that reshape now outputs regular data.frames,
which should make it easier to use them for further analysis and
transformation.

 * Added a fill argument to cast which specifies what value should be
used for structural missings

Various bug fixes and completion missing features:

 * fun.aggregate will always be applied if specified, even if no
aggregation occurs

 * margins now work for non-aggregated data

 * cast now accepts a list of functions for fun.aggregate

 * very long formulas will now work in cast

 * fixed bug in rbind.fill

 * should be able to melt any cast form

Please let me know if you have any comments, questions, or something
isn't working right.

Regards,

Hadley

___
R-packages mailing list
R-packages@stat.math.ethz.ch
https://stat.ethz.ch/mailman/listinfo/r-packages

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


Re: [R] Inner product

2006-09-30 Thread Peter Dalgaard
David Barron [EMAIL PROTECTED] writes:

 For inner product see ?%*%.  There is a norm function in the Matrix package.

Or crossprod(). Notice that this gives _squared_ norms when applied to
a single vector.

 
 On 30/09/06, Sonal Darbari [EMAIL PROTECTED] wrote:
  Hi,
 
  How do we find out the inner product  norm of eigen vectors in R?
 
  Lets say we have eigen vectors :
  x1 = 1,2,3 and x2 = 2,-3,4
 
  are there any functions buit in R which directly calculate the inner product
   norm of vectors?
 
  Thanks,
  Sonal.
 
  [[alternative HTML version deleted]]
 
  __
  R-help@stat.math.ethz.ch mailing list
  https://stat.ethz.ch/mailman/listinfo/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 Barron
 Said Business School
 University of Oxford
 Park End Street
 Oxford OX1 1HP
 
 __
 R-help@stat.math.ethz.ch mailing list
 https://stat.ethz.ch/mailman/listinfo/r-help
 PLEASE do read the posting guide http://www.R-project.org/posting-guide.html
 and provide commented, minimal, self-contained, reproducible code.
 

-- 
   O__   Peter Dalgaard Ă˜ster Farimagsgade 5, Entr.B
  c/ /'_ --- Dept. of Biostatistics PO Box 2099, 1014 Cph. K
 (*) \(*) -- University of Copenhagen   Denmark  Ph:  (+45) 35327918
~~ - ([EMAIL PROTECTED])  FAX: (+45) 35327907

__
R-help@stat.math.ethz.ch mailing list
https://stat.ethz.ch/mailman/listinfo/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] counting a sequence of charactors or numbers

2006-09-30 Thread Joe Byers
I have the following sequence of characters.  These could be integers as 
well.  For this problem, only two values are valid.

S S S S S S W W W W W W W W S S S S S S S S W W W W W W W W S S S S S S 
S S S S S S S W W W W W W W W W

I need to determine the count of the classes/groups in sequence. as
6,8,8,8,13,9 where the sum of these equal my total observations.

Any help is greatly appreciated.

Thank you
Joe

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


Re: [R] counting a sequence of charactors or numbers

2006-09-30 Thread roger koenker
?rle

url:www.econ.uiuc.edu/~rogerRoger Koenker
email   [EMAIL PROTECTED]   Department of Economics
vox:217-333-4558University of Illinois
fax:217-244-6678Champaign, IL 61820


On Sep 30, 2006, at 5:13 PM, Joe Byers wrote:

 I have the following sequence of characters.  These could be  
 integers as
 well.  For this problem, only two values are valid.

 S S S S S S W W W W W W W W S S S S S S S S W W W W W W W W S S S S  
 S S
 S S S S S S S W W W W W W W W W

 I need to determine the count of the classes/groups in sequence. as
 6,8,8,8,13,9 where the sum of these equal my total observations.

 Any help is greatly appreciated.

 Thank you
 Joe

 __
 R-help@stat.math.ethz.ch mailing list
 https://stat.ethz.ch/mailman/listinfo/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@stat.math.ethz.ch mailing list
https://stat.ethz.ch/mailman/listinfo/r-help
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 R and tckl/tk on Mac OS X

2006-09-30 Thread Bill Northcott
On 30/09/2006, at 8:00 PM, Rob J Goedman wrote:
 Thanks for catching this question. I'd missed Ingo's original email.

 Rcmdr does need X.11 and Tcl/Tk, although it uses the versions that
 come with Mac OS 10.4. Hence, as Alex indicates, there is no need to
 separately install these.

 Ingo, if you can't get it to work using John's link, let me know
 where you get stuck.  R-Sig-Mac is an alias dedicated to Mac OS
 specific questions.

1.  R-sig-mac is the place to go for these sorts of questions.  This  
issue is being discussed there right now.

2.  The instructions at http://socserv.socsci.mcmaster.ca/jfox/Misc/ 
Rcmdr/installation-notes.html are not correct and will mislead you.

3.  The problems with Tcl/Tk are caused by the nice Aqua GUI.  The  
tcl/tk package or any of its dependencies such as Rcmdr can be built  
on MacOS in one of two ways:
   a.  use the Apple included (in 10.4.x) AquaTk.
   b.  use an X11 version of Tk

Packages built as a. cannot be run from within the R GUI but will  
launch happily from a command line.  The problem is that AquaTk  
thinks it is the only GUI for the app and fights with the R GUI for  
possession of the menu bar and system events.  They will work if you  
run R from a shell instead of the GUI.

Packages built as b. can be run from inside the R GUI.  So this is  
the standard for the CRAN binary distributions.

The current R binary (2.3.1) includes an X11 Tcl/Tk.  Make sure that  
it is installed.

Bill Northcott

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

2006-09-30 Thread Gabor Grothendieck
Here are some timings.  From fastest to slowest
we have: #3, #4, #1, #2 so, yes, the apply
approach, even with the improvement (#2), is the
slowest and, in fact, on this test is an order
of magnitude slower than #3 which is the fastest one.

 m - matrix(1:4, 200) # test matrix

 # 1 - m must be numeric for this one to work
 system.time(for(i in 1:100)kronecker(m, rep(1,2)))
[1] 2.93 0.29 3.34   NA   NA

 # 2
 system.time(for(i in 1:100)apply(m, 2, rep, each = 2))
[1] 5.22 0.09 5.73   NA   NA

 # 3 - from Alex's post
 system.time(for(i in 1:100)m[rep(1:nrow(m), each = 2),])
[1] 0.50 0.07 0.60   NA   NA

 # 4
 system.time(for(i in 1:100)matrix(rbind(c(m), c(m)), nc = ncol(m)))
[1] 1.54 0.20 1.77   NA   NA

On 10/1/06, Tong Wang [EMAIL PROTECTED] wrote:
 Hi,
Thanks you guys for all the help. I learned a lot from it.
It looks using apply() is not an efficient way, since all it does is 
 looping through
 each row(or col) , which would be slow for large matrix, right ?

 cheers

 - Original Message -
 From: Gabor Grothendieck [EMAIL PROTECTED]
 Date: Saturday, September 30, 2006 4:54 am
 Subject: Re: [R] How to repeat vectors ?
 To: Tong Wang [EMAIL PROTECTED]
 Cc: r-help@stat.math.ethz.ch

  Here are 4 approaches in order from most compact
  to least.  #1 only works for numeric matrices, # 2 is
  a shorter versio of your solution using rep.vec and # 3
  is from Alex's post and is likely what I would
  use in practice.
 
  m - matrix(1:4, 2) # test matrix
 
  # 1 - m must be numeric for this one to work
  kronecker(m, rep(1,2))
 
  # 2
  apply(m, 2, rep, each = 2) # 2
 
  # 3 - from Alex's post
  m[rep(1:nrow(m), each = 2),]
 
  # 4
  matrix(rbind(c(m), c(m)), nc = ncol(m))
 
  On 9/30/06, Tong Wang [EMAIL PROTECTED] wrote:
   I just figured out a way to do this:
rep.vec - function(X,n)
  return(t(array(rep(X,n),c(length(X),n
 Then,apply(MyMatrix, 2, rep.vec,2)
  
   Is there a better way ?  Is there an internal function to repeat
  a vector or matrix ?
  
   Thanks a lot.
  
  
   - Original Message -
   From: Tong Wang [EMAIL PROTECTED]
   Date: Friday, September 29, 2006 11:23 pm
   Subject: How to repeat vectors ?
   To: r-help@stat.math.ethz.ch
  
Hi,
   If I have a matrix  , say   a11   a12
  a21  a22
   Is there a routine to get:  a11  a12
a11  a12
a21   a22
a21   a22
   
Thanks a lot for any help.
   
best
   
  
   __
   R-help@stat.math.ethz.ch mailing list
   https://stat.ethz.ch/mailman/listinfo/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@stat.math.ethz.ch mailing list
https://stat.ethz.ch/mailman/listinfo/r-help
PLEASE do read the posting guide http://www.R-project.org/posting-guide.html
and provide commented, minimal, self-contained, reproducible code.


[R] Can I avoid loops here ?

2006-09-30 Thread Tong Wang
Hi,
  I have two lists of matrices, and I  would like to get  a list of term by 
term product, say,
 mylist1- list( X1,X2);  mylist2-list(Y1,Y2)

Need: mylist3-list(X1%*%Y1,X2%*%Y2)

Is there a way that allows me to do this without loops ?

Thanks a lot. 

best

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


Re: [R] Can I avoid loops here ?

2006-09-30 Thread Gabor Grothendieck
Try:

mapply(%*%, mylist1, mylist2, SIMPLIFY = FALSE)

Please provide self-contained examples as requested on
the last line of every message to r-help.  That means the
data for X1, X2, Y1, Y2 should be included so one can
run the code you post.

On 10/1/06, Tong Wang [EMAIL PROTECTED] wrote:
 Hi,
  I have two lists of matrices, and I  would like to get  a list of term 
 by term product, say,
  mylist1- list( X1,X2);  mylist2-list(Y1,Y2)

 Need: mylist3-list(X1%*%Y1,X2%*%Y2)

 Is there a way that allows me to do this without loops ?

 Thanks a lot.

 best

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