Re: [R] Rscript -e, Sweave and tempdir()

2008-10-16 Thread Prof Brian Ripley

My first thought was that this is R  2.7.2 and you have encountered
(from the CHANGES file)

   o   Rscript -e (and Rterm -e) failed on Vista because the MSVCRT
   function 'tmpfile' is broken on that platform.

But that couldn't possibly be the case, as the posting guide required you 
to update your R before posting (and tell us lots of information I don't 
see, including your OS).


On Thu, 16 Oct 2008, [EMAIL PROTECTED] wrote:



Hello R-Help

I have a question about the behind the scenes behaviour of the Rscript 
-e command and particularly its interaction with Sweave and tempdir().


We are trying to deploy R as a web service to do water quality analyses 
and have been writing software to call Sweave via Rscript eg:


cmd Rscript -e Sweave('sweavefile.Rnw')

One problem we have been having is that Sweave tries to write temporary 
files in a temporary directory given by the tempdir() command (as per an 
email from F. Leitsch appended below).  This is where our problem seems 
to lie.


As a simplified example, if we call

cmd Rscript -e tempdir()

from our web service we get a win32(Cannot read memory:0x0037) error 
message unless we grant Read+Write permissions to the root directory, 
which we are trying to avoid doing for security reasons.  This suggests 
Sweave(?) is trying to write to somewhere else OTHER than tempdir() 
perhaps.


However if we run:

Rscirpt testdir.r  (ie. sourcing a file without the -e option)

where testdir.r contains:

outpath - tempdir()
write.table(outpath,D:\\Internet\\RWebService\\Data\\dir.txt)

there appears to be no problem with the call to the tempdir() command. 
Also if we put the call to Sweave within a call2sweave.r file and do


cmdRscript call2sweave.r (ie. run sweave via a file that is sourced, 
rather than using the -e option)


then things go OK.

In short, something seems to be happening with the -e version of 
Rscript, the tempdir() command and its invocation by Sweave.


Any ideas?

Thanks
Paul.


EARLIER EMAIL FROM F. LEISCH (AUTHOR OF SWEAVE)
___
It's not figures but text output which is collected via temporary files. The 
corresponding code in Sweave is:

tmpcon - file()
sink(file=tmpcon)
err - NULL
if(options$eval) err - evalFunc(ce, options)
cat(\n) # make sure final line is complete
sink()
output - readLines(tmpcon)
close(tmpcon)


So you need to figure out where file() opens the anoymous temporary file on 
your operating system. His is the same place as a call to
tempdir() shows, e.g. on my Linux box:

R tempdir()
[1] /tmp/RtmpIzi6Yv

so it tries to write under /tmp.
_
Paul Rustomji
Rivers and Estuaries
CSIRO Land and Water
GPO Box 1666
Canberra ACT 2601

ph +61 2 6246 5810
mobile 0406 375 739

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



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

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


Re: [R] how to count unique observations by variables

2008-10-16 Thread David Winsemius


On Oct 16, 2008, at 1:27 AM, Lijiang Guo wrote:


Dear R-helpers,

I have a data frame with 3 variables, each record is a unique  
combination of
the three variables. I would like to count the number of unique  
values of v3

in each v1, and save it as a new variable v4 in the same data frame.
e.g.
df1
[v1] [v2] [v3]
[1,] a  C  1
[2,] b  C  2
[3,] c  B  3
[4,] a  B  3
[5,] b  A  2
[6,] c  A  1

In this case, the 4th column would become (2, 1, 2, 2, 1, 2).

 txt - '   v1 v2 v3
+  a  C  1
+  b  C  2
+  c  B  3
+  a  B  3
+  b  A  2
+  c  A  1'

df1 - read.table(textConnection(txt), header=TRUE)

grps - tapply(df1$v3, df1$v1,FUN=table)

#  sapply(grps,length)
# a b c
# 2 1 2

df1$v4 - sapply(grps,length)[df1$v1]

df1


  v1 v2 v3 v4
1  a  C  1  2
2  b  C  2  1
3  c  B  3  2
4  a  B  3  2
5  b  A  2  1
6  c  A  1  2


--
David Winsemius, MD
Heritage Labs



Could someone tell me how to do this?

regards,
Lijiang


--

[[alternative HTML version deleted]]

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


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


[R] Using source()

2008-10-16 Thread Michael Just
Hello,
I have never used source and I am a R beginner. If I have text file that
contains 1,000's of lines of code. Can I use source to bring this code into
R and execute the code? Does it run the code one line at a time? Is there a
best way to setup source() for maximum effieciency? After reading ?source()
would I just do:

source(my_Rcode.txt)

Thanks,
Michael

[[alternative HTML version deleted]]

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


Re: [R] how to count unique observations by variables

2008-10-16 Thread ronggui
How about this:

 df1=data.frame(v1=c(1,1,2,3,2,4,1))
 df1$v2 - ave(df1$v1,df1$v1,FUN=length)
 df1
  v1 v2
1  1  3
2  1  3
3  2  2
4  3  1
5  2  2
6  4  1
7  1  3


On Thu, Oct 16, 2008 at 1:27 PM, Lijiang Guo [EMAIL PROTECTED] wrote:
 Dear R-helpers,

 I have a data frame with 3 variables, each record is a unique combination of
 the three variables. I would like to count the number of unique values of v3
 in each v1, and save it as a new variable v4 in the same data frame.
 e.g.
 df1
 [v1] [v2] [v3]
 [1,] a  C  1
 [2,] b  C  2
 [3,] c  B  3
 [4,] a  B  3
 [5,] b  A  2
 [6,] c  A  1

 In this case, the 4th column would become (2, 1, 2, 2, 1, 2).

 Could someone tell me how to do this?

 regards,
 Lijiang


 --

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




-- 
HUANG Ronggui, Wincent
Tel: (00852) 3442 3832
Ph.D. Candidate, CityU of HK
Master of sociology, Fudan University, China
Bachelor of Social Work, Fudan University, China
Personal homepage: http://ronggui.huang.googlepages.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] qt with df1 (repost)

2008-10-16 Thread Prof Brian Ripley

On Sun, 12 Oct 2008, Peter Dalgaard wrote:


Prof Brian Ripley wrote:

Please do RTFM, for the help says

  df: degrees of freedom ( 0, maybe non-integer).  'df = Inf' is
  allowed.  For 'qt' only values of at least one are currently
  supported.

On Sun, 12 Oct 2008, Enrico Rossi wrote:


Sorry about the html-formatted message. Here it is again in plain text.

Hello,

The function qt returns NaN for degrees of freedom 1. For example:


qt(0.5,0.5)

[1] NaN
Warning message:
In qt(p, df, lower.tail, log.p) : NaNs produced

But qt(0.5,0.5) should be 0, since the distribution is symmetric.


pt(0,0.5)

[1] 0.5

It actually fails with any value, as long as df1.
Is this a bug, or is there some fundamental reason why this cannot be
computed?


Neither 
Well, presumably, it is using an algorithm that only works for df =1. 
However, qf() works fine with df1  1, so there's a fairly easy workaround.


Are you referring to

If X ~ t(df) then X^2 ~ F(1, df)

? That needs df2  1.  So the workaround is

fake_qt - function(p, df)
sign(p-0.5) * sqrt(qf(2*min(p, 1-p), 1, df, lower=FALSE))

Another workaround is qt(x, df, ncp=1e-10)

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

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


Re: [R] Using source()

2008-10-16 Thread Prof Brian Ripley

On Thu, 16 Oct 2008, Michael Just wrote:


Hello,



I have never used source and I am a R beginner.


Not a 'beginner' R-help poster, though.  (32 posts this month so far under 
this name.)


If I have text file that contains 1,000's of lines of code. Can I use 
source to bring this code into R and execute the code?


Yes.  But surely after you have written (or even understood) a file with 
1,000's of lines of code you are no longer a 'beginner'.



Does it run the code one line at a time?


No.  It parses the file and runs the parsed code one expression at a time.


Is there a best way to setup source() for maximum effieciency?


Worry about efficiency when you have to (when you are no longer a 
'beginner'). Remember Jackson's Rules of Optimization (in the context of 
programming):


1) Don't do it.
2) (For experts only) Don't do it yet.

But you can use other means to run large collections of code, 
e.g. make a package or use Rscript.



After reading ?source() would I just do:

source(my_Rcode.txt)


Yes (most people use extension 'R' for R source, though).  Note that you 
have to explicitly print() in code run this way: auto-printing is not 
done.




Thanks,
Michael

[[alternative HTML version deleted]]


After so many postings, please do follow the posting guide.  (No HTML.)


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


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

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


[R] Statistical courses

2008-10-16 Thread timpanister
Hi,

Can anyone suggest some short term statistical courses using R that one
could take? Name or Links will be much appreciated.

many thanks,

j

[[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] Using source()

2008-10-16 Thread Michael Just
On Thu, Oct 16, 2008 at 1:42 AM, Prof Brian Ripley
[EMAIL PROTECTED] wrote:

 On Thu, 16 Oct 2008, Michael Just wrote:

 Hello,

 I have never used source and I am a R beginner.

 Not a 'beginner' R-help poster, though.  (32 posts this month so far under 
 this name.)
I hope this isn't bad form on my part. My thought was beginners may
need the most help and therefore post the most. I hope my name or
posts won't cause fatigue.

 If I have text file that contains 1,000's of lines of code. Can I use source 
 to bring this code into R and execute the code?

 Yes.  But surely after you have written (or even understood) a file with 
 1,000's of lines of code you are no longer a 'beginner'.

I think I am still a beginner, hence all the questions. I am pretty
sure my code has redundancies and I use excel as an text editor, its
the fastest way I know how (lots of dragging formulas). I have
1,000's because I have 1000's of locations in my dataset and I am
running a few regressions on each. I think that this 1,000's of lines
R code should not discredit my 'beginner' status. I am still just
using univariate statistics and learning how to do EDA in R.

 Does it run the code one line at a time?

 No.  It parses the file and runs the parsed code one expression at a time.

Thank you.

 Is there a best way to setup source() for maximum effieciency?

 Worry about efficiency when you have to (when you are no longer a 
 'beginner'). Remember Jackson's Rules of Optimization (in the context of 
 programming):

 1) Don't do it.
 2) (For experts only) Don't do it yet.

Thanks, I had to look up Jackson's Rules of Optimization. I asked
about efficiency to make sure that I wasn't suggesting to do something
totally ridiculous. The only 'programming' I do is for R and this is
partly why I have so many questions and furthermore posts.  I came to
R after using Excel or Systat for statistical analysis.

 But you can use other means to run large collections of code, e.g. make a 
 package or use Rscript.

 After reading ?source() would I just do:

 source(my_Rcode.txt)

 Yes (most people use extension 'R' for R source, though).  Note that you have 
 to explicitly print() in code run this way: auto-printing is not done.

Thanks for .R and print() tips. I would not have done those.



 Thanks,
 Michael

[[alternative HTML version deleted]]

 After so many postings, please do follow the posting guide.  (No HTML.)

Thanks for bringing this to my attention.

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


Re: [R] Using source()

2008-10-16 Thread Barry Rowlingson
2008/10/16 Michael Just [EMAIL PROTECTED]:

 On Thu, 16 Oct 2008, Michael Just wrote:

 I think I am still a beginner, hence all the questions. I am pretty
 sure my code has redundancies and I use excel as an text editor, its
 the fastest way I know how (lots of dragging formulas). I have
 1,000's because I have 1000's of locations in my dataset and I am
 running a few regressions on each. I think that this 1,000's of lines
 R code should not discredit my 'beginner' status. I am still just
 using univariate statistics and learning how to do EDA in R.

 Having 1,000s of lines of R code that do almost the same thing 1000
times is not beginner R status, it's beginner programmer status. You
should never have:

 doThing(1)
 doThing(2)
 doThing(3)
 ...
 for 1000 lines. Can you see what would be better?

 for(i in 1:1000){doThing(i)}

 Why is it better? Because I can make it go to 10,000 by adding one
character. Because I can see the whole thing on one line. Because it
just IS.

 In the most beautiful programs, everything unique only happens
exactly once[1]. For example if your dataset is of size 143, you don't
have all your loops going for(i in 1:143) - you do size=143 and then
use for(i in 1:size). It makes things much more easy to maintain,
modify, and reuse.

 Maybe you could post an extract from this big file so we can get the
gist of what you are doing.

Barry

[1] This may be a bit too zen for a Thursday

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

2008-10-16 Thread Muhammad Azam
Dear friends
As a result I get an array containing certain no of rows and columns. In the 
resultant array first row represents first node of a tree starting from left 
side, second row represents second node of that tree and so on. In the example 
below, the resultant tree contains 6 nodes.  We get the first node on L.H.S by 
splitting top node using variable 10, node 2 by taking start from the R.H.S 
node then splitting it using variables 7 and 11 respectively [ Note: 0's are 
not the variables ]. All the nodes are connected on this way to get the whole 
tree.  We can easily draw it manually. Now the question is, is it possible to 
draw it using R. Any help in this regard is needed. Thanks
 [,1] [,2] [,3] [,4]
[1,]   10000
[2,]   107   110
[3,]   107   110
[4,]   107   13   11
[5,]   107   13   11
[6,]   107   130

regards
M. Azam



  
[[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] qt with df1 (repost)

2008-10-16 Thread Peter Dalgaard

Prof Brian Ripley wrote:

On Sun, 12 Oct 2008, Peter Dalgaard wrote:


Prof Brian Ripley wrote:

Please do RTFM, for the help says

  df: degrees of freedom ( 0, maybe non-integer).  'df = Inf' is
  allowed.  For 'qt' only values of at least one are currently
  supported.

On Sun, 12 Oct 2008, Enrico Rossi wrote:


Sorry about the html-formatted message. Here it is again in plain text.

Hello,

The function qt returns NaN for degrees of freedom 1. For example:


qt(0.5,0.5)

[1] NaN
Warning message:
In qt(p, df, lower.tail, log.p) : NaNs produced

But qt(0.5,0.5) should be 0, since the distribution is symmetric.


pt(0,0.5)

[1] 0.5

It actually fails with any value, as long as df1.
Is this a bug, or is there some fundamental reason why this cannot be
computed?


Neither 
Well, presumably, it is using an algorithm that only works for df =1. 
However, qf() works fine with df1  1, so there's a fairly easy 
workaround.


Are you referring to

If X ~ t(df) then X^2 ~ F(1, df)

? That needs df2  1.  So the workaround is

fake_qt - function(p, df)
sign(p-0.5) * sqrt(qf(2*min(p, 1-p), 1, df, lower=FALSE))


Yes, that's what I meant. For some reason I couldn't come up with the 
compact expression at the time.


(df1 was a typo, but not actually wrong since 1/F(1,df) ~ F(df,1)...)



Another workaround is qt(x, df, ncp=1e-10)



Somewhat easier, yes!


--
   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@r-project.org mailing list
https://stat.ethz.ch/mailman/listinfo/r-help
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 count unique observations by variables

2008-10-16 Thread Chuck Cleland
On 10/16/2008 1:27 AM, Lijiang Guo wrote:
 Dear R-helpers,
 
 I have a data frame with 3 variables, each record is a unique combination of
 the three variables. I would like to count the number of unique values of v3
 in each v1, and save it as a new variable v4 in the same data frame.
 e.g.
 df1
  [v1] [v2] [v3]
 [1,] a  C  1
 [2,] b  C  2
 [3,] c  B  3
 [4,] a  B  3
 [5,] b  A  2
 [6,] c  A  1
 
 In this case, the 4th column would become (2, 1, 2, 2, 1, 2).
 
 Could someone tell me how to do this?

df1 - data.frame(V1=rep(c('a','b','c'),2),
  V2=rep(c('C','B','A'),each=2),
  V3=c(1,2,3,3,2,1))

df1$V4 - with(df1, ave(V3, V1, FUN = function(x){length(unique(x))}))

df1
  V1 V2 V3 V4
1  a  C  1  2
2  b  C  2  1
3  c  B  3  2
4  a  B  3  2
5  b  A  2  1
6  c  A  1  2

?ave
?unique
?length

 regards,
 Lijiang
 
 --
 
   [[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. 

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

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


Re: [R] dynlm and lm: should they give same estimates?

2008-10-16 Thread Pfaff, Bernhard Dr.
Hello Werner,

this is easily clarified. The code in my book contains an error: please
replace the line:

error.lagged - error[-c(99, 100)]
with
error.lagged - error[-c(1, 100)]


I will file this in the errata section on my web-site and will correct
the relevant example in the urca and vars packages for their next
releases.


Best,
Bernhard


Hi,

I was wondering why the results from lm and dynlm are not the 
same for what I think is the same model. 
I have just modified example 4.2 from the Pfaff book, please 
see below for the code and results.

Can anyone tell my what I am doing wrongly?

Many thanks,
  Werner

set.seed(123456)
e1 - rnorm(100)
e2 - rnorm(100)
y1 - ts(cumsum(e1))
y2 - ts(0.6*y1 + e2)
lr.reg - lm(y2 ~ y1)
error - ts(residuals(lr.reg))
error.lagged - error[-c(99, 100)]

dy1 - diff(y1)
dy2 - diff(y2)
diff.dat - data.frame(embed(cbind(dy1, dy2), 2))
colnames(diff.dat) - c('dy1', 'dy2', 'dy1.1', 'dy2.1')
ecm.reg - lm(dy2 ~ error.lagged + dy1.1 + dy2.1,
  data=diff.dat)
ecm.dynreg - dynlm(d(y2) ~ L(error) + L(d(y1),1) + L(d(y2),1))
summary(ecm.reg)
summary(ecm.dynreg)

 summary(ecm.reg)

Call:
lm(formula = dy2 ~ error.lagged + dy1.1 + dy2.1, data = diff.dat)

Residuals:
Min  1Q  Median  3Q Max 
-2.9588 -0.5439  0.1370  0.7114  2.3065 

Coefficients:
  Estimate Std. Error t value Pr(|t|)
(Intercept)   0.003398   0.103611   0.0330.974
error.lagged -0.968796   0.158554  -6.110 2.24e-08 ***
dy1.1 0.808633   0.112042   7.217 1.35e-10 ***
dy2.1-1.058913   0.108375  -9.771 5.64e-16 ***
---
Signif. codes:  0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1 

Residual standard error: 1.026 on 94 degrees of freedom
Multiple R-Squared: 0.5464, Adjusted R-squared: 0.5319 
F-statistic: 37.74 on 3 and 94 DF,  p-value: 4.243e-16 

 summary(ecm.dynreg)

Time series regression with ts data:
Start = 3, End = 100

Call:
dynlm(formula = d(y2) ~ L(error) + L(d(y1), 1) + L(d(y2), 1))

Residuals:
Min  1Q  Median  3Q Max 
-2.9588 -0.5439  0.1370  0.7114  2.3065 

Coefficients:
 Estimate Std. Error t value Pr(|t|)
(Intercept)  0.003398   0.103611   0.033   0.9739
L(error)-0.968796   0.158554  -6.110 2.24e-08 ***
L(d(y1), 1)  0.245649   0.126996   1.934   0.0561 .  
L(d(y2), 1) -0.090117   0.105938  -0.851   0.3971
---
Signif. codes:  0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1 

Residual standard error: 1.026 on 94 degrees of freedom
Multiple R-Squared: 0.5464, Adjusted R-squared: 0.5319 
F-statistic: 37.74 on 3 and 94 DF,  p-value: 4.243e-16 

 




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

*
Confidentiality Note: The information contained in this ...{{dropped:10}}

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

2008-10-16 Thread Fernando Marmolejo Ramos
Dear all

Recently the granova package was launched. I installed but after when I
invoked it in R it requested for other libraries. They were downloaded and
install automatically.

I tried to run the example syntax of “granova.1w” and “granova.2w” but two
things happened: i) either a file called “granova.rdb” wasn’t existent or ii)
the GUI clashed and R shut down.

Has anyone else experience this? Do the developers have an answer for this
troubleshot?

I’m using a Windows Vista system and I have the R version 2.7.2.

Cheers,

Fer

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


[R] One-sample test for p

2008-10-16 Thread rr400

Hi, i am doing a statistics course and am having trouble with an exercise
where i need to determine whether my success rate at something is higher
than 80%. 
I was successful in 29 out of 60 trials, so these were the commands i
entered into R:
n=60
p.hat=29/n
p.0=0.8
se.0=sqrt(p.0*(1-p.0)/n)
z=(p.hat-p.0)/se.0
print(z)
Which returned:
[1] -6.132224
1-pnorm(z)
Which returned
[1] 1

My problem is that i am meant to state a null and alternative hypothesis
which at the moment i have stated as  p0.8 (null) and p≤0.8 (alternative).
As things stand, though, a p-value of 1 suggests i should reject the null
hypothesis which can't be right since i am obviously successful less than
80% of the time. 
I am not sure where i am getting muddled. Any advice would be greatly
appreciated. Thanks!
-- 
View this message in context: 
http://www.nabble.com/One-sample-test-for-p-tp20010677p20010677.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] One-sample test for p

2008-10-16 Thread Peter Dalgaard

rr400 wrote:

Hi, i am doing a statistics course and am having trouble with an exercise
where i need to determine whether my success rate at something is higher
than 80%. 
I was successful in 29 out of 60 trials, so these were the commands i

entered into R:

n=60
p.hat=29/n
p.0=0.8
se.0=sqrt(p.0*(1-p.0)/n)
z=(p.hat-p.0)/se.0
print(z)

Which returned:
[1] -6.132224

1-pnorm(z)

Which returned
[1] 1

My problem is that i am meant to state a null and alternative hypothesis
which at the moment i have stated as  p0.8 (null) and p≤0.8 (alternative).
As things stand, though, a p-value of 1 suggests i should reject the null
hypothesis which can't be right since i am obviously successful less than
80% of the time. 
I am not sure where i am getting muddled. Any advice would be greatly

appreciated. Thanks!


This isn't really about R, and maybe it is homework, but now that we got 
you in the appropriate frame of mind:


(a) p values should look at this or more unfavourable events. You have 
arranged things so that that translates to -6.13 or _lower_. I.e. you're 
looking at the wrong tail.


(b) Make sure you get your accept/reject logic right. You _reject_ the 
null when data would be _un_likely if the null hypothesis were true.


(c) You might also want to play with binom.test and prop.test

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


Re: [R] merge/combine data

2008-10-16 Thread jim holtman
try this:

 x - read.table(textConnection(  user_id site_id   name
+ 11  11  februari
+ 21  11   redbook
+ 31  11  tips
+ 73   6 sleep
+ 83   6monitoring
+ 93   6 alarm), header=TRUE)
 closeAllConnections()
 y - lapply(split(x, list(x$user_id, x$site_id), drop=TRUE), function(.data){
+ data.frame(user_id=.data$user_id[1], site_id=.data$site_id[1],
+ name=paste(as.character(.data$name), collapse=','))
+ })
 do.call(rbind, y)
 user_id site_id   name
3.63   6 sleep,monitoring,alarm
1.11   1  11  februari,redbook,tips


On Thu, Oct 16, 2008 at 4:43 AM, Dirkheld [EMAIL PROTECTED] wrote:

 Hi,

 I have the following data imported from a csv file
   user_id site_id   name
 11  11  februari
 21  11   redbook
 31  11  tips
 73   6 sleep
 83   6monitoring
 93   6 alarm

 Which I would like to merge/combine into
   user_id site_id   name
 11  11  februari, redbook, tips
 23   6 sleep, monitoring, alarm
 3 .

 So I would like to combine data from similar user_id and site_id in one line
 with a merge of the 'name'.



 --
 View this message in context: 
 http://www.nabble.com/merge-combine-data-tp20009538p20009538.html
 Sent from the R help mailing list archive at Nabble.com.

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




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

What is the problem that you are trying to solve?

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


Re: [R] Fw: Logistic regresion - Interpreting (SENS) and (SPEC)

2008-10-16 Thread Frank E Harrell Jr

Gad Abraham wrote:

Frank E Harrell Jr wrote:

Gad Abraham wrote:
This approach leaves much to be desired.  I hope that its 
practitioners start gauging it by the mean squared error of 
predicted probabilities.


Is the logic here is that low MSE of predicted probabilities equals a 
better calibrated model? What about discrimination? Perfect calibration 


Almost.  I was addressed more the wish for the use of strategies that 
maximize precision while keeping bias to a minimim.


implies perfect discrimination, but I often find that you can have two 


That doesn't follow.  You can have perfect calibration in the large 
with no discrimination.


I'm not sure I understand: if you have perfect calibration, so that you 
correctly assign the probability Pr(y=1|x) to each x, doesn't it follow 
that the x will also be ranked in correct order of probability, which is 
what the AUC is measuring?


You can have a prediction model that assigns Pr(y=1|x) to a range of 
0.45 to 0.55 such that the probabilities are perfectly accurate, but the 
ROC area is 0.6.




competing models, the first with higher discrimination (AUC) and 
worse calibration, and the the second the other way round. Which one 
is the better model?


I judge models on the basis of both discrimination (best measured with 
log likelihood measures, 2nd best AUC) and calibration.  It's a 
two-dimensional issue and we don't always know how to weigh the two. 
For many purposes calibration is a must.  In those we don't look at 
discrimination until calibration-in-the-small is verified at high 
resolution.


By log likelihood measures do you mean likelihood-ratio tests?


I mean generalized R^2, log-likelihood, or the adequacy index in my book.

Frank






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

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

2008-10-16 Thread John Sorkin
R 2.7.2
Windows XP

I am using apply to compute a series of Student's t-test from two matrices, 
sample1 and sample2.
boo-apply(sample1,1,t.test,sample2)

 I want to pick of the p-values from the tests, but can't seem to get it to 
work. I have tried several methods to get the values including:
boo-apply(sample1,1,t.test$t.test,sample2)
boo-apply(sample1,1,t.test,sample2)$t.test

any suggestions?

Thanks
John

John Sorkin M.D., Ph.D.
Chief, Biostatistics and Informatics
Baltimore VA Medical Center GRECC,
University of Maryland School of Medicine Claude D. Pepper OAIC,
University of Maryland Clinical Nutrition Research Unit, and
Baltimore VA Center Stroke of Excellence

University of Maryland School of Medicine
Division of Gerontology
Baltimore VA Medical Center
10 North Greene Street
GRECC (BT/18/GR)
Baltimore, MD 21201-1524

(Phone) 410-605-7119
(Fax) 410-605-7913 (Please call phone number above prior to faxing)
[EMAIL PROTECTED]
Confidentiality Statement:
This email message, including any attachments, is for th...{{dropped:6}}

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


Re: [R] apply, t-test and p-values

2008-10-16 Thread Jorge Ivan Velez
Dear John,
Yes. Assuming that 'sample2' is fixed, something like this should do what
you want:

# Data sets
set.seed(123)
sample1=matrix(rnorm(100),ncol=10)
sample2=rnorm(10,5,4)

# t-test p-values
apply(X,1,function(x) t.test(x,sample2)$p.value)
[1] 0.002348970 0.004733230 0.004810952 0.004907549 0.002342979 0.018748229
0.003546655 0.006084410
 [9] 0.003100983 0.007007980


HTH,

Jorge


On Thu, Oct 16, 2008 at 8:01 AM, John Sorkin [EMAIL PROTECTED]wrote:

 R 2.7.2
 Windows XP

 I am using apply to compute a series of Student's t-test from two matrices,
 sample1 and sample2.
 boo-apply(sample1,1,t.test,sample2)

  I want to pick of the p-values from the tests, but can't seem to get it to
 work. I have tried several methods to get the values including:
 boo-apply(sample1,1,t.test$t.test,sample2)
 boo-apply(sample1,1,t.test,sample2)$t.test

 any suggestions?

 Thanks
 John

 John Sorkin M.D., Ph.D.
 Chief, Biostatistics and Informatics
 Baltimore VA Medical Center GRECC,
 University of Maryland School of Medicine Claude D. Pepper OAIC,
 University of Maryland Clinical Nutrition Research Unit, and
 Baltimore VA Center Stroke of Excellence

 University of Maryland School of Medicine
 Division of Gerontology
 Baltimore VA Medical Center
 10 North Greene Street
 GRECC (BT/18/GR)
 Baltimore, MD 21201-1524

 (Phone) 410-605-7119
 (Fax) 410-605-7913 (Please call phone number above prior to faxing)
 [EMAIL PROTECTED]
 Confidentiality Statement:
 This email message, including any attachments, is for ...{{dropped:13}}

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


Re: [R] One-sample test for p

2008-10-16 Thread Duncan Murdoch

On 10/16/2008 7:35 AM, Peter Dalgaard wrote:

rr400 wrote:

Hi, i am doing a statistics course and am having trouble with an exercise
where i need to determine whether my success rate at something is higher
than 80%. 
I was successful in 29 out of 60 trials, so these were the commands i

entered into R:

n=60
p.hat=29/n
p.0=0.8
se.0=sqrt(p.0*(1-p.0)/n)
z=(p.hat-p.0)/se.0
print(z)

Which returned:
[1] -6.132224

1-pnorm(z)

Which returned
[1] 1

My problem is that i am meant to state a null and alternative hypothesis
which at the moment i have stated as  p0.8 (null) and p≤0.8 (alternative).
As things stand, though, a p-value of 1 suggests i should reject the null
hypothesis which can't be right since i am obviously successful less than
80% of the time. 
I am not sure where i am getting muddled. Any advice would be greatly

appreciated. Thanks!


This isn't really about R, and maybe it is homework, but now that we got 
you in the appropriate frame of mind:


(a) p values should look at this or more unfavourable events. You have 
arranged things so that that translates to -6.13 or _lower_. I.e. you're 
looking at the wrong tail.


I think he was looking at the right tail, since his p value was 1.  Your 
comment (b) is the important one; comment (c) might not be allowed by 
his instructor, which is one reason I'm always reluctant to give advice 
on other people's homework problems.


Duncan Murdoch



(b) Make sure you get your accept/reject logic right. You _reject_ the 
null when data would be _un_likely if the null hypothesis were true.


(c) You might also want to play with binom.test and prop.test



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

2008-10-16 Thread Guillermo Aravena Cuevas

Dear users
I am fitting a Generalized Additive Mixed Models (gamm) model to  
establish possible relationship between explanatory variables (water  
temperature, dissolved oxygen and chlorophyll) and zooplankton data  
collected in the inner and outer estuarine waters. I am using monthly  
time-series which are auto-correlated.


In the case of the inner waters, I have applied satisfactoryly (by ACF  
and PACF) an corAR1() as follows:
gamm.zoo - gamm(zoo~s(water.temperature) + s(dissolved.oxygen) +  
s(chlorophyll), data=datos,family=gaussian,corr=corAR1() )


But in the case of the outer estuarine waters, our data has a seasonal  
auto-correlation. I have tried to applied corARMA(p,q), but it is not  
completely satisfactory because I have an autocorrelation of order 1  
and 12 as an seasonal ARIMA=(1,0,0)(1,0,0)


I have tried to model it with

corr=corARMA(p=12, fixed=c(NA,0,0,0,0,0,0,0,0,0,0,NA,NA)))

However, I am not completely sure I am modelling what I should.

I suspect the autocorrelation structure in the error term has been  
taken into account with corAR1/corARMA, but I cannot work it out how  
it is the random structure. I do not need to incorporate a random  
structure in my model, only need to take into account the  
autocorrelation term structure in the error term, but I am not sure  
that the model aforementioned is doing what I am trying to do.

Any help would be appreciated.

Thanks in advance
Guille

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


Re: [R] One-sample test for p

2008-10-16 Thread Peter Dalgaard

Duncan Murdoch wrote:

This isn't really about R, and maybe it is homework, but now that we 
got you in the appropriate frame of mind:


(a) p values should look at this or more unfavourable events. You 
have arranged things so that that translates to -6.13 or _lower_. I.e. 
you're looking at the wrong tail.


I think he was looking at the right tail, since his p value was 1.  


Yes, clearly, but then he needs to rearrange his definitions so that 
deviations go that way when data move away from the null (i.e., to look 
at p.0 - p.hat).


Your 
comment (b) is the important one; comment (c) might not be allowed by 
his instructor, which is one reason I'm always reluctant to give advice 
on other people's homework problems.




Not allowed to _play_? Surely not, I hope. Not allowed as the _solution_ 
is of course quite possible.


-p




Duncan Murdoch



(b) Make sure you get your accept/reject logic right. You _reject_ the 
null when data would be _un_likely if the null hypothesis were true.


(c) You might also want to play with binom.test and prop.test






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

2008-10-16 Thread kdebusk
What test do I use to determine if there is a correlation between a
discrete variable and a continuous variable?

For example - I have water quality ratings for streams (excellent,
good, fair, poor) and a corresponding nitrogen concentration for each
rating. I want to know if the the ratings correlate with the
concentration of nitrogen in the stream.

Help?

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


Re: [R] Network meta-analysis, varConstPower in nlme - Thank you!

2008-10-16 Thread Christian Gold

Excellent - now it works. Thank you, Christian!

(I still seem to be unable to replicate the results as reported in the
paper, but that is unrelated to R-help. Thomas, do you have any idea
what I may have entered wrongly?)

Best,
Christian


Christian Ritz wrote:

Hi Christian,

I believe that the argument var has changed name to weights.

The following lines work for me:

...
sigma - rep(sqrt(.5), nrow(lumley1))  # not nrow=

lme1 - lme(Y1 ~ trt.B + trt.C + trt.D + trt.E, random = ~ 1 | trtpair,
data=lumley1, weights = varConstPower(form=~sigma, fixed=list(power=1)))

lme2 - lme(Y2 ~ trt.B + trt.C + trt.D + trt.E, random = ~ 1 | trtpair,
data=lumley1), weights = varConstPower(form=~sigma, fixed=list(power=1)))


I hope you can now make it work!?

Christian



__
R-help@r-project.org mailing list
https://stat.ethz.ch/mailman/listinfo/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] correlation between a discrete variable and a continuous variable

2008-10-16 Thread kdebusk
What test would you use to determine if a correlation exists between a
discrete variable and a continuous variable?

For example, I have a rating for stream water quality (excellent,
good, fair, poor) and a corresponding nitrogen concentration. I want
to see if there is a correlation between the water quality rating and
the concentration of nitrogen in the stream.

Help?

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


[R] saving result of a for loop

2008-10-16 Thread Alex99


Hi everyone,
I have dataset which I take random samples of it 5 times. each time I get
the mean for rows for each sample.
at the end I need to calculate the Average of all means for  each sample and
each row. to clear it up I give an example:
say this is my dataset.
X8 X9X10X12 X13 X14 X15 X16X17X18X19 X20 X21 X22
s1  0  1   000100000000
s2  0  0   001000000010
s3  0  1   000000000010
s4  1  0   001000010000

I get a random sample and mean of row for that sample(5 times , but I just
put 2 of them here to give you   an idea)

X12 X9 X10
s10  1   0
s20  0   0
s30  1   0
s40  0   0
   s1s2s3s4 
0.333 0.000 0.333 0.000 

X10 X18 X8
s100  0
s200  0
s300  0
s401  1
 s1s2s3s4 
0.000 0.000 0.000 0.667 

This is the code I used:
 for(i in 1:5) 
 {
   temp-sample(A3,3, replace=F)
   Avg=rowMeans(temp)
   show(temp)
   show(Avg)
 }

Now, the problem is how can I save the result for each row(s1,s2,s3,s4) so
that I can get the grand average from 5 runs?I thought about using a vector
in the for loop but it's no good, it over right so basically I only get
the means for last sample. any idea how to do it?
Thanks a lot

-- 
View this message in context: 
http://www.nabble.com/saving-result-of-a-%22for%22-loop-tp20013519p20013519.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] correlation

2008-10-16 Thread stephen sefick
This may be incorrect, but couldn't you just assign a number to the
ratings 1:4 and then scatterplot them agianst N (x-axis).  Or you may
want to plot boxplots of N by water quality ratings.  If these are
water quality ratings derived from aquatic macroinvertebrates and you
have access to the actual count information (reguardless of taxanomic
level) you may want to consider some ordination techniques to see if
there is an ecological gradient underlying your taxa information.
hope this helps and good luck

Stephen

On Thu, Oct 16, 2008 at 9:05 AM, kdebusk [EMAIL PROTECTED] wrote:
 What test do I use to determine if there is a correlation between a
 discrete variable and a continuous variable?

 For example - I have water quality ratings for streams (excellent,
 good, fair, poor) and a corresponding nitrogen concentration for each
 rating. I want to know if the the ratings correlate with the
 concentration of nitrogen in the stream.

 Help?

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




-- 
Stephen Sefick
Research Scientist
Southeastern Natural Sciences Academy

Let's not spend our time and resources thinking about things that are
so little or so large that all they really do for us is puff us up and
make us feel like gods.  We are mammals, and have not exhausted the
annoying little problems of being mammals.

-K. Mullis

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


Re: [R] saving result of a for loop

2008-10-16 Thread stephen sefick
a - c(1:10)
b - c(.5, .6, .9, 10, .4, 3, 4, 9, 0, 11)
d - c(21:30)

z - data.frame(a,b,d)
library(fields)
results - c()
for(i in 1:(length(rownames(z))-1)){
 results[i] - rdist(z[i,], z[(i+1),])
 }

results.1 - data.frame(results)
 f - rownames(z)
 r - f[-1]
 rownames(results.1) - r
 colnames(results.1) - f[1]

This is a for loop that I used not too long ago defining the results
outside of the loop worked for me.
hope this helps

stephen

On Thu, Oct 16, 2008 at 9:10 AM, Alex99 [EMAIL PROTECTED] wrote:


 Hi everyone,
 I have dataset which I take random samples of it 5 times. each time I get
 the mean for rows for each sample.
 at the end I need to calculate the Average of all means for  each sample and
 each row. to clear it up I give an example:
 say this is my dataset.
X8 X9X10X12 X13 X14 X15 X16X17X18X19 X20 X21 X22
 s1  0  1   000100000000
 s2  0  0   001000000010
 s3  0  1   000000000010
 s4  1  0   001000010000

 I get a random sample and mean of row for that sample(5 times , but I just
 put 2 of them here to give you   an idea)

X12 X9 X10
 s10  1   0
 s20  0   0
 s30  1   0
 s40  0   0
   s1s2s3s4
 0.333 0.000 0.333 0.000

X10 X18 X8
 s100  0
 s200  0
 s300  0
 s401  1
  s1s2s3s4
 0.000 0.000 0.000 0.667

 This is the code I used:
  for(i in 1:5)
  {
   temp-sample(A3,3, replace=F)
   Avg=rowMeans(temp)
   show(temp)
   show(Avg)
  }

 Now, the problem is how can I save the result for each row(s1,s2,s3,s4) so
 that I can get the grand average from 5 runs?I thought about using a vector
 in the for loop but it's no good, it over right so basically I only get
 the means for last sample. any idea how to do it?
 Thanks a lot

 --
 View this message in context: 
 http://www.nabble.com/saving-result-of-a-%22for%22-loop-tp20013519p20013519.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.




-- 
Stephen Sefick
Research Scientist
Southeastern Natural Sciences Academy

Let's not spend our time and resources thinking about things that are
so little or so large that all they really do for us is puff us up and
make us feel like gods.  We are mammals, and have not exhausted the
annoying little problems of being mammals.

-K. Mullis

__
R-help@r-project.org mailing list
https://stat.ethz.ch/mailman/listinfo/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] tune function using sigmoid and polynomial kernels

2008-10-16 Thread alexandre lejeune
Hello,
When i use tune svm with sigmoid oy polynomial kernels to optimize
Cost/gamma/coef0 (sigmoid) or cost/gamma/coef0/degree (polynomial)
parameters, i can't get a summary of the best parameters. instead I got this
result:
  dummyparameter
1  0

I use the following command line (7 fold cross validation):
tunesv - tune(svm, x, y, kernel=sigmoid, coef0= -1:1, gamma=10^(-6:-2),
cost=10^(0:3), tunecontrol=tune.control(sampling=cross, cross=7))

When i use a similar function for radial kernels, I get the best gamma and
cost parameters.

Thanks for  your help.

[[alternative HTML version deleted]]

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


Re: [R] saving result of a for loop

2008-10-16 Thread Jorge Ivan Velez
Dear Alex,
Is this what you want?

my=read.table(textConnection(
X8 X9 X10 X102 X110 X177 X283 X284 X286 X292 X297 X306 X308 X314
0  1   000100000000
0  0   001000000010
0  1   000000000010
1  0   00100001000
 0),header=TRUE)
closeAllConnections()
rownames(my)=paste('s',1:4,sep=)

# Five samples
res=replicate(5,my[,sample(colnames(my),5)],simplify=FALSE)

# mean for each sample
Means=do.call(rbind,lapply(res,function(x) rowMeans(x)))
rownames(Means)=paste('sample',1:5,sep=)
Means

# Global mean for sample
colMeans(Means)


HTH,

Jorge


On Thu, Oct 16, 2008 at 9:10 AM, Alex99 [EMAIL PROTECTED] wrote:



 Hi everyone,
 I have dataset which I take random samples of it 5 times. each time I get
 the mean for rows for each sample.
 at the end I need to calculate the Average of all means for  each sample
 and
 each row. to clear it up I give an example:
 say this is my dataset.
X8 X9X10X12 X13 X14 X15 X16X17X18X19 X20 X21 X22
 s1  0  1   000100000000
 s2  0  0   001000000010
 s3  0  1   000000000010
 s4  1  0   001000010000

 I get a random sample and mean of row for that sample(5 times , but I just
 put 2 of them here to give you   an idea)

X12 X9 X10
 s10  1   0
 s20  0   0
 s30  1   0
 s40  0   0
   s1s2s3s4
 0.333 0.000 0.333 0.000

X10 X18 X8
 s100  0
 s200  0
 s300  0
 s401  1
  s1s2s3s4
 0.000 0.000 0.000 0.667

 This is the code I used:
  for(i in 1:5)
  {
   temp-sample(A3,3, replace=F)
   Avg=rowMeans(temp)
   show(temp)
   show(Avg)
  }

 Now, the problem is how can I save the result for each row(s1,s2,s3,s4) so
 that I can get the grand average from 5 runs?I thought about using a vector
 in the for loop but it's no good, it over right so basically I only get
 the means for last sample. any idea how to do it?
 Thanks a lot

 --
 View this message in context:
 http://www.nabble.com/saving-result-of-a-%22for%22-loop-tp20013519p20013519.html
 Sent from the R help mailing list archive at Nabble.com.

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


[[alternative HTML version deleted]]

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


Re: [R] apply, t-test and p-values

2008-10-16 Thread David Winsemius


On Oct 16, 2008, at 8:11 AM, Jorge Ivan Velez wrote:


Dear John,
Yes. Assuming that 'sample2' is fixed, something like this should do  
what

you want:

# Data sets
set.seed(123)
sample1=matrix(rnorm(100),ncol=10)
sample2=rnorm(10,5,4)

# t-test p-values
apply(X,1,function(x) t.test(x,sample2)$p.value)


It seems clear that you meant to type:
apply(sample1,1,function(x) t.test(x,sample2)$p.value)




[1] 0.002348970 0.004733230 0.004810952 0.004907549 0.002342979  
0.018748229

0.003546655 0.006084410
[9] 0.003100983 0.007007980


HTH,

Jorge


On Thu, Oct 16, 2008 at 8:01 AM, John Sorkin [EMAIL PROTECTED] 
wrote:



R 2.7.2
Windows XP

I am using apply to compute a series of Student's t-test from two  
matrices,

sample1 and sample2.
boo-apply(sample1,1,t.test,sample2)

I want to pick of the p-values from the tests, but can't seem to  
get it to

work. I have tried several methods to get the values including:
boo-apply(sample1,1,t.test$t.test,sample2)
boo-apply(sample1,1,t.test,sample2)$t.test

any suggestions?

Thanks
John

John Sorkin M.D., Ph.D.
Chief, Biostatistics and Informatics
Baltimore VA Medical Center GRECC,
University of Maryland School of Medicine Claude D. Pepper OAIC,
University of Maryland Clinical Nutrition Research Unit, and
Baltimore VA Center Stroke of Excellence

University of Maryland School of Medicine
Division of Gerontology
Baltimore VA Medical Center
10 North Greene Street
GRECC (BT/18/GR)
Baltimore, MD 21201-1524

(Phone) 410-605-7119
(Fax) 410-605-7913 (Please call phone number above prior to faxing)
[EMAIL PROTECTED]
Confidentiality Statement:
This email message, including any attachments, is for ...{{dropped: 
13}}


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

2008-10-16 Thread rr400

Thanks for your responses. I know it is bad form asking about these things
but i was really having trouble getting my head around it, and i wanted to
make sure that the cause wasn't due to the commands i was entering into R.
At least now i know it's a conceptual error i am making rather than a
technical one. 

Thanks again for your help. R.

Duncan Murdoch-2 wrote:
 
 On 10/16/2008 7:35 AM, Peter Dalgaard wrote:
 rr400 wrote:
 Hi, i am doing a statistics course and am having trouble with an
 exercise
 where i need to determine whether my success rate at something is higher
 than 80%. 
 I was successful in 29 out of 60 trials, so these were the commands i
 entered into R:
 n=60
 p.hat=29/n
 p.0=0.8
 se.0=sqrt(p.0*(1-p.0)/n)
 z=(p.hat-p.0)/se.0
 print(z)
 Which returned:
 [1] -6.132224
 1-pnorm(z)
 Which returned
 [1] 1
 
 My problem is that i am meant to state a null and alternative hypothesis
 which at the moment i have stated as  p0.8 (null) and p≤0.8
 (alternative).
 As things stand, though, a p-value of 1 suggests i should reject the
 null
 hypothesis which can't be right since i am obviously successful less
 than
 80% of the time. 
 I am not sure where i am getting muddled. Any advice would be greatly
 appreciated. Thanks!
 
 This isn't really about R, and maybe it is homework, but now that we got 
 you in the appropriate frame of mind:
 
 (a) p values should look at this or more unfavourable events. You have 
 arranged things so that that translates to -6.13 or _lower_. I.e. you're 
 looking at the wrong tail.
 
 I think he was looking at the right tail, since his p value was 1.  Your 
 comment (b) is the important one; comment (c) might not be allowed by 
 his instructor, which is one reason I'm always reluctant to give advice 
 on other people's homework problems.
 
 Duncan Murdoch
 
 
 (b) Make sure you get your accept/reject logic right. You _reject_ the 
 null when data would be _un_likely if the null hypothesis were true.
 
 (c) You might also want to play with binom.test and prop.test

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

-- 
View this message in context: 
http://www.nabble.com/One-sample-test-for-p-tp20010677p20012878.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] apply, t-test and p-values

2008-10-16 Thread Jorge Ivan Velez
Thanks for the correction David!  You're absolutely right!  A typo  :- )
 ...
Cheers,

Jorge


On Thu, Oct 16, 2008 at 10:00 AM, David Winsemius [EMAIL PROTECTED]wrote:


 On Oct 16, 2008, at 8:11 AM, Jorge Ivan Velez wrote:

  Dear John,
 Yes. Assuming that 'sample2' is fixed, something like this should do what
 you want:

 # Data sets
 set.seed(123)
 sample1=matrix(rnorm(100),ncol=10)
 sample2=rnorm(10,5,4)

 # t-test p-values
 apply(X,1,function(x) t.test(x,sample2)$p.value)


 It seems clear that you meant to type:
 apply(sample1,1,function(x) t.test(x,sample2)$p.value)



 [1] 0.002348970 0.004733230 0.004810952 0.004907549 0.002342979
 0.018748229
 0.003546655 0.006084410
 [9] 0.003100983 0.007007980


 HTH,

 Jorge


 On Thu, Oct 16, 2008 at 8:01 AM, John Sorkin [EMAIL PROTECTED]
 wrote:

  R 2.7.2
 Windows XP

 I am using apply to compute a series of Student's t-test from two
 matrices,
 sample1 and sample2.
 boo-apply(sample1,1,t.test,sample2)

 I want to pick of the p-values from the tests, but can't seem to get it
 to
 work. I have tried several methods to get the values including:
 boo-apply(sample1,1,t.test$t.test,sample2)
 boo-apply(sample1,1,t.test,sample2)$t.test

 any suggestions?

 Thanks
 John

 John Sorkin M.D., Ph.D.
 Chief, Biostatistics and Informatics
 Baltimore VA Medical Center GRECC,
 University of Maryland School of Medicine Claude D. Pepper OAIC,
 University of Maryland Clinical Nutrition Research Unit, and
 Baltimore VA Center Stroke of Excellence

 University of Maryland School of Medicine
 Division of Gerontology
 Baltimore VA Medical Center
 10 North Greene Street
 GRECC (BT/18/GR)
 Baltimore, MD 21201-1524

 (Phone) 410-605-7119
 (Fax) 410-605-7913 (Please call phone number above prior to faxing)
 [EMAIL PROTECTED]
 Confidentiality Statement:
 This email message, including any attachments, is for ...{{dropped:13}}


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




[[alternative HTML version deleted]]

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


Re: [R] NAs in color2D.matplot

2008-10-16 Thread Jim Lemon

bg708 wrote:

Hi,

I am trying to plot a large matrix by using color2D.matplot. A substantial
part of the matrix has no data (NAs). However, when trying to plot it, I get
an error. It is only when I change all NAs to zeros that it works, but that
in some way introduces 'wrong' data. Is there any workaround this? Thank you
in advance!!!
  

Hi Bernardo,
The problem is really in color.scale, and I can't really fix it properly 
this evening. I will try to rewrite both functions to handle this 
problem. With any luck, I may have it done this weekend, and it will 
appear sometime next week in version 2.4-8. The intended solution is to 
have NAs preserved in the output of color.scale.


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] Two last questions: about output

2008-10-16 Thread Gabor Grothendieck
Please read the last line of every message to r-help and provide
reproducible code.

On Thu, Oct 16, 2008 at 12:44 AM, Ted Byers [EMAIL PROTECTED] wrote:
 Thanks Gabor,

 To be clear, would something like testframe$est[[i]] - fp$estimate be
 valid within my loop, as in (assuming I created testframe before the
 loop):

 for (i in 1:length(V4) ) {
   x = read.csv(as.character(V4[[i]]), header = FALSE, na.strings=);
   y = x[,1];
   fp = fitdistr(y,exponential);
   print(c(V1[[i]],V2[[i]],V3[[i]],fp$estimate,fp$sd))
   testframe$est[[i]] - fp$estimate
   testframe$sd[[i]] - fp$sd
 }

 Thanks

 Ted

 On Thu, Oct 16, 2008 at 12:08 AM, Gabor Grothendieck
 [EMAIL PROTECTED] wrote:
 testframe$newvar - ...whatever...
 (or see ?transform for another way)
 adds a new column to the data frame.   The table does not
 have to pre-exist in your MySQL database and you don't need
 a create statement; however, if the table does pre-exist the columns
 of your data frame and those of the database table should have the
 same names in the same order and use dbWriteTable(..., append = TRUE)


 On Wed, Oct 15, 2008 at 11:54 PM, Ted Byers [EMAIL PROTECTED] wrote:
 Thanks Gabor,

 I get how to make a frame using existing vectors.  In my example, the
 following puts my first three columns into a frame (and displays it:

 testframe - data.frame(mid=V1,year=V2,week=V3)
 testframe
   mid year week
 1  251 2008   18
 2  251 2008   19
 3  251 2008   20
 4  251 2008   22
 5  251 2008   23
 6  251 2008   24
 7  251 2008   25

 I show the first of about 60 rows, and I am pleased that these values
 appear as integers.

 But what I don't see is how to add the fp$estimate,fp$sd values
 obtained from my analyses to vectors to form the last two columns in
 the data frame.  Is there something like a vector type, analogous to
 the vector class std::vector from C++, that has a push_back function
 allowing a vector to grow as new values are generated?

 And suppose I have the following table in MySQL (ignoring for the
 moment keys and indeces):

 CREATE TABLE (
  id INTEGER  UNSIGNED NOT NULL auto_increment,
  mid INTEGER NOT NULL,
  y  INTEGER NOT NULL,
  w INTEGER NOT NULL,
  rate DOUBLE NOT NULL,
  sd DOUBLE NOT NULL
  process_date DATETIME NOT NULL DEFAULT CURRENT_TIMESTAMP
 ) ENGINE=InnoDB;

 How would I tell dbWriteTable() that my frame's five columns
 correspond to mid,y,w,rate and sd in that order, and that the fields
 id and process_date will take the appropriate default values?  Or do I
 need a temporary table, in memory, that has only the five columns, and
 use a stored procedure to move the data to its final home?

 Thanks again,

 Ted


 On Wed, Oct 15, 2008 at 9:57 PM, Gabor Grothendieck
 [EMAIL PROTECTED] wrote:
 Put the data in an R data frame and use dbWriteTable() to
 write it to your MySQL database directly.

 On Wed, Oct 15, 2008 at 9:34 PM, Ted Byers [EMAIL PROTECTED] wrote:

 Here is my little scriptlet:

 optdata =
 read.csv(K:\\MerchantData\\RiskModel\\AutomatedRiskModel\\soptions.dat,
 header = FALSE, na.strings=)
 attach(optdata)
 library(MASS)
 setwd(K:\\MerchantData\\RiskModel\\AutomatedRiskModel)
 for (i in 1:length(V4) ) {
   x = read.csv(as.character(V4[[i]]), header = FALSE, na.strings=);
   y = x[,1];
   fp = fitdistr(y,exponential);
   print(c(V1[[i]],V2[[i]],V3[[i]],fp$estimate,fp$sd))
 }


 And here are the first few lines of output:

   rate rate
 2.51e+02 2.008000e+03 1.80e+01 6.869301e-02 6.462095e-03
   rate rate
 2.51e+02 2.008000e+03 1.90e+01 5.958023e-02 4.491029e-03
   rate rate
 2.51e+02 2.008000e+03 2.00e+01 8.631714e-02 7.428996e-03
   rate rate
 2.51e+02 2.008000e+03 2.20e+01 1.261538e-01 1.137491e-02
   rate rate
 2.51e+02 2.008000e+03 2.30e+01 1.339523e-01 1.332875e-02
   rate rate
 2.51e+02 2.008000e+03 2.40e+01 8.916084e-02 1.248501e-02

 There are only two things wrong, here.

 1) the first three columns are integers, and are output variously as
 integers, floating point numbers and, as shown here, in scientific 
 notation.
 2) this output isn't going to a file or to my DB.  This second issue isn't
 much of a problem, as I think I know now how to deal with it.

 This output data is, in one sense, perfectly organized, and there is a 
 table
 with a nearly identical structure (these five columns, plus one to hold 
 the
 date on which the analysis is performed (and of course, therefore, it has 
 a
 default value of the current timestamp  - handled in MySQL).  If I can get
 the data written to a CSV file, with the first three columns provided as
 integers, I can use the DB's bulk load utility to get the data into the 
 DB,
 and this may be faster 

[R] package Utils Sweave Example Error

2008-10-16 Thread Felipe Carrillo
 Hi:
I'm still trying to figure out how use Sweave. Trying the example below I get 
the error message when texi2dvi is executed. Any ideas about how to make 
texi2dvi work?

library(tools)
   testfile - system.file(Sweave, Sweave-test-1.Rnw, package = utils)
 options(device.ask.default=FALSE)
 Sweave(testfile)
Writing to file Sweave-test-1.tex
Processing code chunks ...
 1 : print term verbatim
 2 : term hide
 3 : echo print term verbatim
 4 : term verbatim
 5 : echo term verbatim
 6 : echo term verbatim eps pdf
 7 : echo term verbatim eps pdf

You can now run LaTeX on 'Sweave-test-1.tex'
 texi2dvi(Sweave-test-1.tex, pdf=TRUE) # Error here

C:/Documents and Settings/fcarrillo/Desktop/Sweave-test-1.tex:11: Missing 
C:/Documents and Settings/fcarrillo/Desktop/Sweave-test-1.tex:11: 
C:/Documents and Settings/fcarrillo/Desktop/Sweave-test-1.tex:11: Extra 
C:/Documents and Settings/fcarrillo/Desktop/Sweave-test-1.tex:11: Missing 
C:/Documents and Settings/fcarrillo/Desktop/Sweave-test-1.tex:11: Extra 
C:/Documents and Settings/fcarrillo/Desktop/Sweave-test-1.tex:11: Missing 
C:/Documents and Settings/fcarrillo/Desktop/Sweave-test-1.tex:11: Extra 
C:/Documents and Settings/fcarrillo/Desktop/Sweave-test-1.tex:11: Missing 
C:/Documents and Settings/fcarrillo/Desktop/Sweave-test-1.tex:11: Missing 
C:/Documents and Settings/fcarrillo/Desktop/Sweave-test-1.tex:11: Extra 
C:/Documents and Settings/fcarrillo/Desktop/Sweave-test-1.tex:11: Missing 
C:/Documents and Settings/fcarrillo/Desktop/Sweave-test-1.tex:11: Extra 
Error in texi2dvi(Sweave-test-1.tex, pdf = TRUE) : 
  running 'texi2dvi' on 'Sweave-test-1.tex' failed


Felipe D. Carrillo  
Supervisory Fishery Biologist  
Department of the Interior  
US Fish  Wildlife Service  
California, USA

__
R-help@r-project.org mailing list
https://stat.ethz.ch/mailman/listinfo/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] lmer for two models followed by anova to compare the two models

2008-10-16 Thread Lawrence Hanser
Dear Colleagues,

I run this model:

mod1 - lmer(x~category+subcomp+category*subcomp+(1|id),data=impchiefsrm)

obtain this summary result:

Linear mixed-effects model fit by REML
Formula: x ~ category + subcomp + category * subcomp + (1 | id)
  Data: impchiefsrm
 AIC  BIC logLik MLdeviance REMLdeviance
4102 4670  -1954   3665 3908
Random effects:
Groups   NameVariance Std.Dev.
id   (Intercept) 0.11562  0.34003
Residual 0.22765  0.47713
number of obs: 2568, groups: id, 107


run this model (only difference is I've removed the interaction term):

mod2 - lmer(x~category+subcomp+(1|id),data=impchiefsrm)

obtain this summary result:

Linear mixed-effects model fit by REML
Formula: x ~ category + subcomp + (1 | id)
   Data: impchiefsrm
  AIC  BIC logLik MLdeviance REMLdeviance
 3987 4151  -1966   3823 3931
Random effects:
 Groups   NameVariance Std.Dev.
 id   (Intercept) 0.11528  0.33953
 Residual 0.23584  0.48564
number of obs: 2568, groups: id, 107

Note that the loglik from the first model is -1954 and from the second
model loglik is -1966.

Next, to test the difference between the two models I run:

anova(mod1, mod2) and obtain this result:

Data: impchiefsrm
Models:
mod2: x ~ category + subcomp + (1 | id)
mod1: x ~ category + subcomp + category * subcomp + (1 | id)
 Df AIC BIC  logLik  Chisq Chi Df Pr(Chisq)
mod2 28  3879.1  4042.9 -1911.5
mod1 97  3859.3  4426.9 -1832.7 157.72 69   6.71e-09 ***
---
Signif. codes:  0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1

Note that in this result the logLiks are reported as -1832.7 and
-1911.5 respectively for models 1 and 2.

Now my question:

Why are the logLiks from the anova command that compares the two
models different from what was reported in the separate model results?

Thanks,

Larry

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

2008-10-16 Thread Dirkheld

Hi,

I have the following data imported from a csv file
   user_id site_id   name
11  11  februari
21  11   redbook
31  11  tips
73   6 sleep
83   6monitoring
93   6 alarm

Which I would like to merge/combine into
   user_id site_id   name
11  11  februari, redbook, tips
23   6 sleep, monitoring, alarm
3 .

So I would like to combine data from similar user_id and site_id in one line
with a merge of the 'name'.



-- 
View this message in context: 
http://www.nabble.com/merge-combine-data-tp20009538p20009538.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] R: in-place appending to a matrix.

2008-10-16 Thread culpritNr1

Hello Gabor,

First of all, thanks for your reply.

Indeed, your strategy solves the problem of speed=). My question was,
however, more of an R design question.

Your suggestion of pre-allocating a big and continuous portion of memory is
probably the first manual work around to try. And it will work.

Now, modern high level languages like the continually improving R, Python
and also Matlab and Perl come with built-in goodies that run at C/C++ speed.
Those built-in functions are high level versions of functionalities that we
would code manually in low level languages.

Being relatively new to R, my expectations are that in a high level language
like this, I do not need to manually program a simple operation such as
in-place appending. Manipulation of rectangular data should be extremely
efficient. (I use it to make computation of DNA properties in organisms with
huge genomes like human and mouse.)

So, do you know whether or not such functions exists or is planned to be
incorporated in the near future? An optional module perhaps?

Again, thank you,

culpritNr1





Gabor Grothendieck wrote:
 
 Create an empty matrix first and then fill it in.   That
 will avoid the overhead in repeatedly expanding it.  If
 you don't know how many rows then make it 1000 rows
 and remove the unused ones once finished.
 
 On Wed, Oct 15, 2008 at 4:05 PM, culpritNr1 [EMAIL PROTECTED]
 wrote:

 Hello fellow R sufferers,

 Is there a way to perform an appending operation in place?

 Currently, the way my pseudo-code goes is like this

 for (i in 1:1000) {
if (some condition) {
newRow - myFunction(myArguments)
X - rbind(X, newRow) #  - this is the bottleneck!!
}
 }

 As you can see, it works but as the matrix X gets the size of a few
 million
 rows, the code runs very slow.

 I am looking for something like the natively in place appending python
 function called append() or the perl function push. In-place
 operations would allow me to do (in pseudocode)

 for (i in 1:1000) {
if (some condition) {
newRow - myFunction(myArguments)
append(X, newRow)
}
 }

 You see? I do not have to call and re-assign the giant X matrix every
 loop
 cycle.

 Any help?

 Thank you,

 Your culpritNr1



 --
 View this message in context:
 http://www.nabble.com/R%3A-%22in-place%22-appending-to-a-matrix.-tp20001258p20001258.html
 Sent from the R help mailing list archive at Nabble.com.

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

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

-- 
View this message in context: 
http://www.nabble.com/R%3A-%22in-place%22-appending-to-a-matrix.-tp20001258p20014954.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] R: in-place appending to a matrix.

2008-10-16 Thread Gabor Grothendieck
The real problem is that running a loop to build up an object bit by bit
is not the preferred way to write an R program.  The preferred way
is to use lapply or other apply command in which case the object
gets built for you.

On Thu, Oct 16, 2008 at 10:50 AM, culpritNr1 [EMAIL PROTECTED] wrote:

 Hello Gabor,

 First of all, thanks for your reply.

 Indeed, your strategy solves the problem of speed=). My question was,
 however, more of an R design question.

 Your suggestion of pre-allocating a big and continuous portion of memory is
 probably the first manual work around to try. And it will work.

 Now, modern high level languages like the continually improving R, Python
 and also Matlab and Perl come with built-in goodies that run at C/C++ speed.
 Those built-in functions are high level versions of functionalities that we
 would code manually in low level languages.

 Being relatively new to R, my expectations are that in a high level language
 like this, I do not need to manually program a simple operation such as
 in-place appending. Manipulation of rectangular data should be extremely
 efficient. (I use it to make computation of DNA properties in organisms with
 huge genomes like human and mouse.)

 So, do you know whether or not such functions exists or is planned to be
 incorporated in the near future? An optional module perhaps?

 Again, thank you,

 culpritNr1





 Gabor Grothendieck wrote:

 Create an empty matrix first and then fill it in.   That
 will avoid the overhead in repeatedly expanding it.  If
 you don't know how many rows then make it 1000 rows
 and remove the unused ones once finished.

 On Wed, Oct 15, 2008 at 4:05 PM, culpritNr1 [EMAIL PROTECTED]
 wrote:

 Hello fellow R sufferers,

 Is there a way to perform an appending operation in place?

 Currently, the way my pseudo-code goes is like this

 for (i in 1:1000) {
if (some condition) {
newRow - myFunction(myArguments)
X - rbind(X, newRow) #  - this is the bottleneck!!
}
 }

 As you can see, it works but as the matrix X gets the size of a few
 million
 rows, the code runs very slow.

 I am looking for something like the natively in place appending python
 function called append() or the perl function push. In-place
 operations would allow me to do (in pseudocode)

 for (i in 1:1000) {
if (some condition) {
newRow - myFunction(myArguments)
append(X, newRow)
}
 }

 You see? I do not have to call and re-assign the giant X matrix every
 loop
 cycle.

 Any help?

 Thank you,

 Your culpritNr1



 --
 View this message in context:
 http://www.nabble.com/R%3A-%22in-place%22-appending-to-a-matrix.-tp20001258p20001258.html
 Sent from the R help mailing list archive at Nabble.com.

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


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



 --
 View this message in context: 
 http://www.nabble.com/R%3A-%22in-place%22-appending-to-a-matrix.-tp20001258p20014954.html
 Sent from the R help mailing list archive at Nabble.com.

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


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


[R] NAs in color2D.matplot

2008-10-16 Thread bg708

Hi,

I am trying to plot a large matrix by using color2D.matplot. A substantial
part of the matrix has no data (NAs). However, when trying to plot it, I get
an error. It is only when I change all NAs to zeros that it works, but that
in some way introduces 'wrong' data. Is there any workaround this? Thank you
in advance!!!

Bernardo
-- 
View this message in context: 
http://www.nabble.com/NAs-in-color2D.matplot-tp20009959p20009959.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] lmer for two models followed by anova to compare the two models

2008-10-16 Thread Peter Dalgaard

Lawrence Hanser wrote:

Dear Colleagues,

I run this model:

mod1 - lmer(x~category+subcomp+category*subcomp+(1|id),data=impchiefsrm)

obtain this summary result:

Linear mixed-effects model fit by REML
Formula: x ~ category + subcomp + category * subcomp + (1 | id)
  Data: impchiefsrm
 AIC  BIC logLik MLdeviance REMLdeviance
4102 4670  -1954   3665 3908
Random effects:
Groups   NameVariance Std.Dev.
id   (Intercept) 0.11562  0.34003
Residual 0.22765  0.47713
number of obs: 2568, groups: id, 107


run this model (only difference is I've removed the interaction term):

mod2 - lmer(x~category+subcomp+(1|id),data=impchiefsrm)

obtain this summary result:

Linear mixed-effects model fit by REML
Formula: x ~ category + subcomp + (1 | id)
   Data: impchiefsrm
  AIC  BIC logLik MLdeviance REMLdeviance
 3987 4151  -1966   3823 3931
Random effects:
 Groups   NameVariance Std.Dev.
 id   (Intercept) 0.11528  0.33953
 Residual 0.23584  0.48564
number of obs: 2568, groups: id, 107

Note that the loglik from the first model is -1954 and from the second
model loglik is -1966.

Next, to test the difference between the two models I run:

anova(mod1, mod2) and obtain this result:

Data: impchiefsrm
Models:
mod2: x ~ category + subcomp + (1 | id)
mod1: x ~ category + subcomp + category * subcomp + (1 | id)
 Df AIC BIC  logLik  Chisq Chi Df Pr(Chisq)
mod2 28  3879.1  4042.9 -1911.5
mod1 97  3859.3  4426.9 -1832.7 157.72 69   6.71e-09 ***
---
Signif. codes:  0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1

Note that in this result the logLiks are reported as -1832.7 and
-1911.5 respectively for models 1 and 2.

Now my question:

Why are the logLiks from the anova command that compares the two
models different from what was reported in the separate model results?



REML likelihoods cannot be compared between models with different mean 
value structure, so it is switching to ordinary likelihood. This is 
arguably not all that smart, but at least it makes some sense. Compare 
the anova table with half the MLdeviances and you'll see the light.


--
   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@r-project.org mailing list
https://stat.ethz.ch/mailman/listinfo/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] histogram without bars but with density line

2008-10-16 Thread Jörg Groß

Hi,

I know how to plot an histogram and how to add a density line.
But how can I plot only the density line without the bars?

Is there a way to say the hist() function not to plot bars, but a  
density line instead?


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


Re: [R] saving result of a for loop

2008-10-16 Thread Alex99

Jorge you are awesome,

This code is very efficient.  it's exactly what I wanted to do and it's very
short and not complicated. 

Thanks a lot

Jorge Ivan Velez wrote:
 
 Dear Alex,
 Is this what you want?
 
 my=read.table(textConnection(
 X8 X9 X10 X102 X110 X177 X283 X284 X286 X292 X297 X306 X308 X314
 0  1   000100000000
 0  0   001000000010
 0  1   000000000010
 1  0   00100001000
  0),header=TRUE)
 closeAllConnections()
 rownames(my)=paste('s',1:4,sep=)
 
 # Five samples
 res=replicate(5,my[,sample(colnames(my),5)],simplify=FALSE)
 
 # mean for each sample
 Means=do.call(rbind,lapply(res,function(x) rowMeans(x)))
 rownames(Means)=paste('sample',1:5,sep=)
 Means
 
 # Global mean for sample
 colMeans(Means)
 
 
 HTH,
 
 Jorge
 
 
 On Thu, Oct 16, 2008 at 9:10 AM, Alex99 [EMAIL PROTECTED] wrote:
 


 Hi everyone,
 I have dataset which I take random samples of it 5 times. each time I get
 the mean for rows for each sample.
 at the end I need to calculate the Average of all means for  each sample
 and
 each row. to clear it up I give an example:
 say this is my dataset.
X8 X9X10X12 X13 X14 X15 X16X17X18X19 X20 X21 X22
 s1  0  1   000100000000
 s2  0  0   001000000010
 s3  0  1   000000000010
 s4  1  0   001000010000

 I get a random sample and mean of row for that sample(5 times , but I
 just
 put 2 of them here to give you   an idea)

X12 X9 X10
 s10  1   0
 s20  0   0
 s30  1   0
 s40  0   0
   s1s2s3s4
 0.333 0.000 0.333 0.000

X10 X18 X8
 s100  0
 s200  0
 s300  0
 s401  1
  s1s2s3s4
 0.000 0.000 0.000 0.667

 This is the code I used:
  for(i in 1:5)
  {
   temp-sample(A3,3, replace=F)
   Avg=rowMeans(temp)
   show(temp)
   show(Avg)
  }

 Now, the problem is how can I save the result for each row(s1,s2,s3,s4)
 so
 that I can get the grand average from 5 runs?I thought about using a
 vector
 in the for loop but it's no good, it over right so basically I only get
 the means for last sample. any idea how to do it?
 Thanks a lot

 --
 View this message in context:
 http://www.nabble.com/saving-result-of-a-%22for%22-loop-tp20013519p20013519.html
 Sent from the R help mailing list archive at Nabble.com.

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

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

-- 
View this message in context: 
http://www.nabble.com/saving-result-of-a-%22for%22-loop-tp20013519p20015092.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] histogram without bars but with density line

2008-10-16 Thread Yihui Xie
plot(density(x))

Regards,
Yihui
--
Yihui Xie [EMAIL PROTECTED]
Phone: +86-(0)10-82509086 Fax: +86-(0)10-82509086
Mobile: +86-15810805877
Homepage: http://www.yihui.name
School of Statistics, Room 1037, Mingde Main Building,
Renmin University of China, Beijing, 100872, China



On Thu, Oct 16, 2008 at 10:54 PM, Jörg Groß [EMAIL PROTECTED] wrote:
 Hi,

 I know how to plot an histogram and how to add a density line.
 But how can I plot only the density line without the bars?

 Is there a way to say the hist() function not to plot bars, but a density
 line instead?

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


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


Re: [R] saving result of a for loop

2008-10-16 Thread Alex99

Thanks a lot Stephen. It worked for me. also Jorge had a solution, it's a
short and easy code. U could have a look in case U want to use it in future.
Thanks again for all your help


stephen sefick wrote:
 
 a - c(1:10)
 b - c(.5, .6, .9, 10, .4, 3, 4, 9, 0, 11)
 d - c(21:30)
 
 z - data.frame(a,b,d)
 library(fields)
 results - c()
 for(i in 1:(length(rownames(z))-1)){
  results[i] - rdist(z[i,], z[(i+1),])
  }
 
 results.1 - data.frame(results)
  f - rownames(z)
  r - f[-1]
  rownames(results.1) - r
  colnames(results.1) - f[1]
 
 This is a for loop that I used not too long ago defining the results
 outside of the loop worked for me.
 hope this helps
 
 stephen
 
 On Thu, Oct 16, 2008 at 9:10 AM, Alex99 [EMAIL PROTECTED] wrote:


 Hi everyone,
 I have dataset which I take random samples of it 5 times. each time I get
 the mean for rows for each sample.
 at the end I need to calculate the Average of all means for  each sample
 and
 each row. to clear it up I give an example:
 say this is my dataset.
X8 X9X10X12 X13 X14 X15 X16X17X18X19 X20 X21 X22
 s1  0  1   000100000000
 s2  0  0   001000000010
 s3  0  1   000000000010
 s4  1  0   001000010000

 I get a random sample and mean of row for that sample(5 times , but I
 just
 put 2 of them here to give you   an idea)

X12 X9 X10
 s10  1   0
 s20  0   0
 s30  1   0
 s40  0   0
   s1s2s3s4
 0.333 0.000 0.333 0.000

X10 X18 X8
 s100  0
 s200  0
 s300  0
 s401  1
  s1s2s3s4
 0.000 0.000 0.000 0.667

 This is the code I used:
  for(i in 1:5)
  {
   temp-sample(A3,3, replace=F)
   Avg=rowMeans(temp)
   show(temp)
   show(Avg)
  }

 Now, the problem is how can I save the result for each row(s1,s2,s3,s4)
 so
 that I can get the grand average from 5 runs?I thought about using a
 vector
 in the for loop but it's no good, it over right so basically I only get
 the means for last sample. any idea how to do it?
 Thanks a lot

 --
 View this message in context:
 http://www.nabble.com/saving-result-of-a-%22for%22-loop-tp20013519p20013519.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.

 
 
 
 -- 
 Stephen Sefick
 Research Scientist
 Southeastern Natural Sciences Academy
 
 Let's not spend our time and resources thinking about things that are
 so little or so large that all they really do for us is puff us up and
 make us feel like gods.  We are mammals, and have not exhausted the
 annoying little problems of being mammals.
 
   -K. Mullis
 
 __
 R-help@r-project.org mailing list
 https://stat.ethz.ch/mailman/listinfo/r-help
 PLEASE do read the posting guide
 http://www.R-project.org/posting-guide.html
 and provide commented, minimal, self-contained, reproducible code.
 
 

-- 
View this message in context: 
http://www.nabble.com/saving-result-of-a-%22for%22-loop-tp20013519p20015119.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] draw a 5cm x 3cm rectangle

2008-10-16 Thread Thomas Steiner
Hi I want to draw sth in a pdf file with a predefined defined size.
Say a 5cm x 3cm rectangle (a ruler):

pdf(rect.pdf, paper=a4)
plot(c(1,5,5,1,1),c(1,1,3,3,1),asp=1,axes=n)
dev.off()

but how do I fix that one unit is 1cm?
Thanks
thomas

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


Re: [R] correlation

2008-10-16 Thread hadley wickham
On Thu, Oct 16, 2008 at 8:05 AM, kdebusk [EMAIL PROTECTED] wrote:
 What test do I use to determine if there is a correlation between a
 discrete variable and a continuous variable?

 For example - I have water quality ratings for streams (excellent,
 good, fair, poor) and a corresponding nitrogen concentration for each
 rating. I want to know if the the ratings correlate with the
 concentration of nitrogen in the stream.

What does correlation mean in this example?  How can you interpret a
linear correlation when one of your variables is discrete?

Why not start with some exploratory graphics?  For your case, I would
suggest drawing a histogram of nitrogen concentration for each water
quality.  Then look at the histograms - do they look the same? Do they
look different?  If they are different, what features are different?

Hadley

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

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


Re: [R] R: in-place appending to a matrix.

2008-10-16 Thread Duncan Murdoch

On 10/16/2008 10:50 AM, culpritNr1 wrote:

Hello Gabor,

First of all, thanks for your reply.

Indeed, your strategy solves the problem of speed=). My question was,
however, more of an R design question.

Your suggestion of pre-allocating a big and continuous portion of memory is
probably the first manual work around to try. And it will work.

Now, modern high level languages like the continually improving R, Python
and also Matlab and Perl come with built-in goodies that run at C/C++ speed.
Those built-in functions are high level versions of functionalities that we
would code manually in low level languages.

Being relatively new to R, my expectations are that in a high level language
like this, I do not need to manually program a simple operation such as
in-place appending. Manipulation of rectangular data should be extremely
efficient. (I use it to make computation of DNA properties in organisms with
huge genomes like human and mouse.)


I think it's unlikely that this will soon be very efficient in R, 
because the only way to make it so is to pre-allocate a lot of extra 
space (so the appends don't grow the memory footprint).  Generally 
people run into space limitations that are harder to deal with than the 
speed limitations, so inefficient allocations for the sake of speed 
aren't going to happen unless the user asks for them (and Gabor told you 
how to do that).


Duncan Murdoch



So, do you know whether or not such functions exists or is planned to be
incorporated in the near future? An optional module perhaps?

Again, thank you,

culpritNr1





Gabor Grothendieck wrote:


Create an empty matrix first and then fill it in.   That
will avoid the overhead in repeatedly expanding it.  If
you don't know how many rows then make it 1000 rows
and remove the unused ones once finished.

On Wed, Oct 15, 2008 at 4:05 PM, culpritNr1 [EMAIL PROTECTED]
wrote:


Hello fellow R sufferers,

Is there a way to perform an appending operation in place?

Currently, the way my pseudo-code goes is like this

for (i in 1:1000) {
   if (some condition) {
   newRow - myFunction(myArguments)
   X - rbind(X, newRow) #  - this is the bottleneck!!
   }
}

As you can see, it works but as the matrix X gets the size of a few
million
rows, the code runs very slow.

I am looking for something like the natively in place appending python
function called append() or the perl function push. In-place
operations would allow me to do (in pseudocode)

for (i in 1:1000) {
   if (some condition) {
   newRow - myFunction(myArguments)
   append(X, newRow)
   }
}

You see? I do not have to call and re-assign the giant X matrix every
loop
cycle.

Any help?

Thank you,

Your culpritNr1



--
View this message in context:
http://www.nabble.com/R%3A-%22in-place%22-appending-to-a-matrix.-tp20001258p20001258.html
Sent from the R help mailing list archive at Nabble.com.

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



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






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


Re: [R] package Utils Sweave Example Error

2008-10-16 Thread Duncan Murdoch

On 10/16/2008 10:18 AM, Felipe Carrillo wrote:

 Hi:
I'm still trying to figure out how use Sweave. Trying the example below I get 
the error message when texi2dvi is executed. Any ideas about how to make 
texi2dvi work?


Try running it as texi2dvi(Sweave-test-1.tex, pdf=TRUE, quiet=FALSE), 
and post the list of error messages.


You should also show us the results of sessionInfo() and 
Sys.getenv(PATH), and tell us which version of LaTeX you have installed.


Duncan Murdoch



library(tools)

  testfile - system.file(Sweave, Sweave-test-1.Rnw, package = utils)
options(device.ask.default=FALSE)
Sweave(testfile)

Writing to file Sweave-test-1.tex
Processing code chunks ...
 1 : print term verbatim
 2 : term hide
 3 : echo print term verbatim
 4 : term verbatim
 5 : echo term verbatim
 6 : echo term verbatim eps pdf
 7 : echo term verbatim eps pdf

You can now run LaTeX on 'Sweave-test-1.tex'

texi2dvi(Sweave-test-1.tex, pdf=TRUE) # Error here


C:/Documents and Settings/fcarrillo/Desktop/Sweave-test-1.tex:11: Missing 
C:/Documents and Settings/fcarrillo/Desktop/Sweave-test-1.tex:11: 
C:/Documents and Settings/fcarrillo/Desktop/Sweave-test-1.tex:11: Extra 
C:/Documents and Settings/fcarrillo/Desktop/Sweave-test-1.tex:11: Missing 
C:/Documents and Settings/fcarrillo/Desktop/Sweave-test-1.tex:11: Extra 
C:/Documents and Settings/fcarrillo/Desktop/Sweave-test-1.tex:11: Missing 
C:/Documents and Settings/fcarrillo/Desktop/Sweave-test-1.tex:11: Extra 
C:/Documents and Settings/fcarrillo/Desktop/Sweave-test-1.tex:11: Missing 
C:/Documents and Settings/fcarrillo/Desktop/Sweave-test-1.tex:11: Missing 
C:/Documents and Settings/fcarrillo/Desktop/Sweave-test-1.tex:11: Extra 
C:/Documents and Settings/fcarrillo/Desktop/Sweave-test-1.tex:11: Missing 
C:/Documents and Settings/fcarrillo/Desktop/Sweave-test-1.tex:11: Extra 
Error in texi2dvi(Sweave-test-1.tex, pdf = TRUE) : 
  running 'texi2dvi' on 'Sweave-test-1.tex' failed



Felipe D. Carrillo  
Supervisory Fishery Biologist  
Department of the Interior  
US Fish  Wildlife Service  
California, USA


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

2008-10-16 Thread John Sorkin
Jorge, David,
Thank you for a brilliant solution to my problem!
Thanks
John

John David Sorkin M.D., Ph.D.
Chief, Biostatistics and Informatics
University of Maryland School of Medicine Division of Gerontology
Baltimore VA Medical Center
10 North Greene Street
GRECC (BT/18/GR)
Baltimore, MD 21201-1524
(Phone) 410-605-7119
(Fax) 410-605-7913 (Please call phone number above prior to faxing)

 Jorge Ivan Velez [EMAIL PROTECTED] 10/16/2008 10:04 AM 
Thanks for the correction David!  You're absolutely right!  A typo  :- )
 ...
Cheers,

Jorge


On Thu, Oct 16, 2008 at 10:00 AM, David Winsemius [EMAIL PROTECTED]wrote:


 On Oct 16, 2008, at 8:11 AM, Jorge Ivan Velez wrote:

  Dear John,
 Yes. Assuming that 'sample2' is fixed, something like this should do what
 you want:

 # Data sets
 set.seed(123)
 sample1=matrix(rnorm(100),ncol=10)
 sample2=rnorm(10,5,4)

 # t-test p-values
 apply(X,1,function(x) t.test(x,sample2)$p.value)


 It seems clear that you meant to type:
 apply(sample1,1,function(x) t.test(x,sample2)$p.value)



 [1] 0.002348970 0.004733230 0.004810952 0.004907549 0.002342979
 0.018748229
 0.003546655 0.006084410
 [9] 0.003100983 0.007007980


 HTH,

 Jorge


 On Thu, Oct 16, 2008 at 8:01 AM, John Sorkin [EMAIL PROTECTED] 
 wrote:

  R 2.7.2
 Windows XP

 I am using apply to compute a series of Student's t-test from two
 matrices,
 sample1 and sample2.
 boo-apply(sample1,1,t.test,sample2)

 I want to pick of the p-values from the tests, but can't seem to get it
 to
 work. I have tried several methods to get the values including:
 boo-apply(sample1,1,t.test$t.test,sample2)
 boo-apply(sample1,1,t.test,sample2)$t.test

 any suggestions?

 Thanks
 John

 John Sorkin M.D., Ph.D.
 Chief, Biostatistics and Informatics
 Baltimore VA Medical Center GRECC,
 University of Maryland School of Medicine Claude D. Pepper OAIC,
 University of Maryland Clinical Nutrition Research Unit, and
 Baltimore VA Center Stroke of Excellence

 University of Maryland School of Medicine
 Division of Gerontology
 Baltimore VA Medical Center
 10 North Greene Street
 GRECC (BT/18/GR)
 Baltimore, MD 21201-1524

 (Phone) 410-605-7119
 (Fax) 410-605-7913 (Please call phone number above prior to faxing)
 [EMAIL PROTECTED] 
 Confidentiality Statement:
 This email message, including any attachments, is for ...{{dropped:13}}


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




Confidentiality Statement:
This email message, including any attachments, is for th...{{dropped:6}}

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


Re: [R] plot - central limit theorem

2008-10-16 Thread Greg Snow
I wonder if including the p-values for the normality test is the best approach 
in you animation?  The clt does not say that the distribution of the means will 
be normal, just that it approaches normality (and therefore may be a decent 
approximation).  The normality test can just reject the null that the data 
(simulated means) comes from a normal distribution.  Since the true 
distribution of the means is not normal (unless you use a sample size of Inf, 
and I for one have better things to than wait for a computer to simulate 
several samples of size Inf) the null for the normality test is always false 
and therefore the test will always result in either saying it is not normal or 
a type II error.  The real goal is not to show normality, but to show that 
using the normal gives a good enough approximation.  I would prefer the 
bottom plot to show either the proportion of p-values from a normal based test 
on the simulated data that is less than alpha, or the proportion of confidence 
intervals based on the normal based test that include the true parameter.  Then 
the user can see when those values become close enough an approximation.

What is your target audience for this demo?  In my opinion, anyone who could 
understand the bottom plot should already understand the clt enough not to need 
the demo, those that I would aim the demo at would just be confused by the 
current bottom plot.

--
Gregory (Greg) L. Snow Ph.D.
Statistical Data Center
Intermountain Healthcare
[EMAIL PROTECTED]
801.408.8111


 -Original Message-
 From: [EMAIL PROTECTED] [mailto:[EMAIL PROTECTED]
 project.org] On Behalf Of Yihui Xie
 Sent: Wednesday, October 15, 2008 10:51 PM
 To: roger koenker
 Cc: r-help
 Subject: Re: [R] plot - central limit theorem

 Thanks, Roger, your demo is interesting. I'm thinking about improving
 it later.

 I've also made a demo for the CLT in my package 'animation', in which
 there's also normality testing for the sample means, because I don't
 think bell-shaped alone means normality - so I performed the
 Shapiro-Wilk test and plotted the P-values under the demo. See the
 function clt.ani() in the package 'animation', or
 http://animation.yihui.name/prob:central_limit_theorem

 You can use any function to denote the population (specify the
 argument 'FUN') in clt.ani().

 Regards,
 Yihui
 --
 Yihui Xie [EMAIL PROTECTED]
 Phone: +86-(0)10-82509086 Fax: +86-(0)10-82509086
 Mobile: +86-15810805877
 Homepage: http://www.yihui.name
 School of Statistics, Room 1037, Mingde Main Building,
 Renmin University of China, Beijing, 100872, China



 On Thu, Oct 16, 2008 at 4:22 AM, roger koenker [EMAIL PROTECTED]
 wrote:
  Galton's 19th century mechanical version of this is the quincunx.  I
 have a
  (very primitive) version of this for R at:
 
 
 http://www.econ.uiuc.edu/~roger/courses/476/routines/quincunx.R
 
 
  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
 
 
 
  Jörg Groß wrote:
 
  Hi,
 
 
  Is there a way to simulate a population with R and pull out m
 samples,
  each with n values
  for calculating m means?
 
  I need that kind of data to plot a graphic, demonstrating the
 central
  limit theorem
  and I don't know how to begin.
 
  So, perhaps someone can give me some tips and hints how to start
 and
  which functions to use.
 
 
 
  thanks for any help,
  joerg
 
 

 __
 R-help@r-project.org mailing list
 https://stat.ethz.ch/mailman/listinfo/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] histogram without bars but with density line - frequency-lines?

2008-10-16 Thread Jörg Groß


Am 16.10.2008 um 17:12 schrieb Yihui Xie:


plot(density(x))

Regards,
Yihui
--


Thanks!

Is there also a way to plot the frequency-bars (not the density) as  
lines instead of bars?


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


Re: [R] apply, t-test and p-values PREVIOUS SUGGESTION DID NOT WORK

2008-10-16 Thread John Sorkin
Although I am grateful to Jorge and David for their suggestions, their solution 
will not solve my problem as sample2 is not fixed. Let me demonstrate what I 
want to do:


# Define two matricies
sample1-matrix(data=c(1:20),byrow=TRUE,ncol=5,nrow=4)
sample2-sample1+rnorm(20)

These are the computations that I would like to perform using apply (or some 
similar method):


# Compute t-test comparing first row of sample 1 to first row of sample 2
t.test(sample1[1,],sample2[1,])

# Compute t-test comparing second row of sample 1 to second row of sample 2
t.test(sample1[2,],sample2[2,])

# Compute t-test comparing third row of sample 1 to third row of sample 2
t.test(sample1[3,],sample2[3,])

# Compute t-test comparing fourth row of sample 1 to fourth row of sample 2
t.test(sample1[4,],sample2[4,])



As you can see, the code below does not return the same values! It does not 
work.
apply(sample1,1,function(x) t.test(x,sample1)$p.value)

Sugestions would be appreciated!
John








John David Sorkin M.D., Ph.D.
Chief, Biostatistics and Informatics
University of Maryland School of Medicine Division of Gerontology
Baltimore VA Medical Center
10 North Greene Street
GRECC (BT/18/GR)
Baltimore, MD 21201-1524
(Phone) 410-605-7119
(Fax) 410-605-7913 (Please call phone number above prior to faxing)

 Jorge Ivan Velez [EMAIL PROTECTED] 10/16/2008 10:04 AM 
Thanks for the correction David!  You're absolutely right!  A typo  :- )
 ...
Cheers,

Jorge


On Thu, Oct 16, 2008 at 10:00 AM, David Winsemius [EMAIL PROTECTED]wrote:


 On Oct 16, 2008, at 8:11 AM, Jorge Ivan Velez wrote:

  Dear John,
 Yes. Assuming that 'sample2' is fixed, something like this should do what
 you want:

 # Data sets
 set.seed(123)
 sample1=matrix(rnorm(100),ncol=10)
 sample2=rnorm(10,5,4)

 # t-test p-values
 apply(X,1,function(x) t.test(x,sample2)$p.value)


 It seems clear that you meant to type:
 apply(sample1,1,function(x) t.test(x,sample2)$p.value)



 [1] 0.002348970 0.004733230 0.004810952 0.004907549 0.002342979
 0.018748229
 0.003546655 0.006084410
 [9] 0.003100983 0.007007980


 HTH,

 Jorge


 On Thu, Oct 16, 2008 at 8:01 AM, John Sorkin [EMAIL PROTECTED] 
 wrote:

  R 2.7.2
 Windows XP

 I am using apply to compute a series of Student's t-test from two
 matrices,
 sample1 and sample2.
 boo-apply(sample1,1,t.test,sample2)

 I want to pick of the p-values from the tests, but can't seem to get it
 to
 work. I have tried several methods to get the values including:
 boo-apply(sample1,1,t.test$t.test,sample2)
 boo-apply(sample1,1,t.test,sample2)$t.test

 any suggestions?

 Thanks
 John

 John Sorkin M.D., Ph.D.
 Chief, Biostatistics and Informatics
 Baltimore VA Medical Center GRECC,
 University of Maryland School of Medicine Claude D. Pepper OAIC,
 University of Maryland Clinical Nutrition Research Unit, and
 Baltimore VA Center Stroke of Excellence

 University of Maryland School of Medicine
 Division of Gerontology
 Baltimore VA Medical Center
 10 North Greene Street
 GRECC (BT/18/GR)
 Baltimore, MD 21201-1524

 (Phone) 410-605-7119
 (Fax) 410-605-7913 (Please call phone number above prior to faxing)
 [EMAIL PROTECTED] 
 Confidentiality Statement:
 This email message, including any attachments, is for ...{{dropped:13}}


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




[[alternative HTML version deleted]]

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

Confidentiality Statement:
This email message, including any attachments, is for th...{{dropped:6}}

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


Re: [R] One-sample test for p

2008-10-16 Thread Greg Snow
I don't think that your question was bad form, there are some things you can do 
in the future to make it better form.  Your questions was certainly better form 
than others who just ask for an answer to their homework without even admitting 
that it is homework.  You were confused about some very fundamental concepts, 
but that in not necessarily a bad thing.

Confusion correctly applied is the first step on the road to greater 
understanding.

I would suggest that you go back to your text book and reread the information 
on testing and work through some more of the examples from the start (you have 
your hypotheses switched and the understanding of p-values backwards).

For future posting on this list, those of us who are current/former teachers 
are hesitant to give answers to what looks like homework when we don't know 
what the teachers intent in giving the homework was (do they want you to work 
something out for yourself, and just being given the answer will not help you 
understand where it came from; or have you already done that and learning 
different ways to do the same thing will expand your knowledge).  When others 
have posted that they have a hw problem that they have already answered by hand 
or using the official software of the class, they just now want to learn how to 
do the same thing in R, we have been happy to help.

For your future posts I would suggest (beyond reading the posting guide) that 
you give detail on what you have already done, what the teacher has said about 
using software, and what your focus is in asking the question (clarifying if an 
unexpected result is due to misunderstanding or wrong syntax, vs. finding if 
there is a better way to do something, etc.)

I have had many students who just get an answer, write it down, and go on 
without ever stopping to ask if the answer makes sense.  You are ahead of them 
already in the quest for understanding.

We don't want students to take shortcuts that bypass their understanding of 
something, but I for one would think it was a good thing if any students, after 
doing the homework the long way, found another way to do it to check their 
answers and expand their options.

Good luck in learning statistics and R,

--
Gregory (Greg) L. Snow Ph.D.
Statistical Data Center
Intermountain Healthcare
[EMAIL PROTECTED]
801.408.8111


 -Original Message-
 From: [EMAIL PROTECTED] [mailto:[EMAIL PROTECTED]
 project.org] On Behalf Of rr400
 Sent: Thursday, October 16, 2008 6:38 AM
 To: r-help@r-project.org
 Subject: Re: [R] One-sample test for p


 Thanks for your responses. I know it is bad form asking about these
 things
 but i was really having trouble getting my head around it, and i wanted
 to
 make sure that the cause wasn't due to the commands i was entering into
 R.
 At least now i know it's a conceptual error i am making rather than a
 technical one.

 Thanks again for your help. R.

 Duncan Murdoch-2 wrote:
 
  On 10/16/2008 7:35 AM, Peter Dalgaard wrote:
  rr400 wrote:
  Hi, i am doing a statistics course and am having trouble with an
  exercise
  where i need to determine whether my success rate at something is
 higher
  than 80%.
  I was successful in 29 out of 60 trials, so these were the commands
 i
  entered into R:
  n=60
  p.hat=29/n
  p.0=0.8
  se.0=sqrt(p.0*(1-p.0)/n)
  z=(p.hat-p.0)/se.0
  print(z)
  Which returned:
  [1] -6.132224
  1-pnorm(z)
  Which returned
  [1] 1
 
  My problem is that i am meant to state a null and alternative
 hypothesis
  which at the moment i have stated as  p0.8 (null) and p≤0.8
  (alternative).
  As things stand, though, a p-value of 1 suggests i should reject
 the
  null
  hypothesis which can't be right since i am obviously successful
 less
  than
  80% of the time.
  I am not sure where i am getting muddled. Any advice would be
 greatly
  appreciated. Thanks!
 
  This isn't really about R, and maybe it is homework, but now that we
 got
  you in the appropriate frame of mind:
 
  (a) p values should look at this or more unfavourable events. You
 have
  arranged things so that that translates to -6.13 or _lower_. I.e.
 you're
  looking at the wrong tail.
 
  I think he was looking at the right tail, since his p value was 1.
 Your
  comment (b) is the important one; comment (c) might not be allowed by
  his instructor, which is one reason I'm always reluctant to give
 advice
  on other people's homework problems.
 
  Duncan Murdoch
 
 
  (b) Make sure you get your accept/reject logic right. You _reject_
 the
  null when data would be _un_likely if the null hypothesis were true.
 
  (c) You might also want to play with binom.test and prop.test
 
 
  __
  R-help@r-project.org mailing list
  https://stat.ethz.ch/mailman/listinfo/r-help
  PLEASE do read the posting guide
  http://www.R-project.org/posting-guide.html
  and provide commented, minimal, self-contained, reproducible code.
 
 

 --
 View this message in context: 

Re: [R] package Utils Sweave Example Error

2008-10-16 Thread Felipe Carrillo
This is my sessionInfo() and Sys.getenv(PATH) 

  library(tools)
testfile - system.file(Sweave, Sweave-test-1.Rnw, package = utils)
## enforce par(ask=FALSE)
options(device.ask.default=FALSE)
## create a LaTeX file
Sweave(testfile)
Writing to file Sweave-test-1.tex
Processing code chunks ...
 1 : print term verbatim
 2 : term hide
 3 : echo print term verbatim
 4 : term verbatim
 5 : echo term verbatim
 6 : echo term verbatim eps pdf
 7 : echo term verbatim eps pdf

You can now run LaTeX on 'Sweave-test-1.tex'
## This can be compiled to PDF by
texi2dvi(Sweave-test-1.tex, pdf=TRUE,quiet=FALSE)

This is pdfTeX, Version 3.1415926-1.40.9 (MiKTeX 2.7)
entering extended mode
(C:/Program Files/R/R-2.7.2/bin/Sweave-test-1.tex
LaTeX2e 2005/12/01
Babel v3.8l and hyphenation patterns for english, dumylang, nohyphenation, ge
rman, ngerman, german-x-2008-06-18, ngerman-x-2008-06-18, french, loaded.
(C:\Program Files\MiKTeX 2.7\tex\latex\base\article.cls
Document Class: article 2005/09/16 v1.4f Standard LaTeX document class
(C:\Program Files\MiKTeX 2.7\tex\latex\base\size10.clo))
(C:\Program Files\MiKTeX 2.7\tex\latex\ltxmisc\a4wide.sty
(C:\Program Files\MiKTeX 2.7\tex\latex\ntgclass\a4.sty))
! Missing \endcsname inserted.
to be read again 
   \protect 
l.11 \begin
   {document}
? pdflatex.EXE: Bad file descriptor
texify: pdflatex failed for some reason (see log file).
Error in texi2dvi(Sweave-test-1.tex, pdf = TRUE, quiet = FALSE) : 
  running 'texi2dvi' on 'Sweave-test-1.tex' failed

sessionInfo()
R version 2.7.2 (2008-08-25) 
i386-pc-mingw32 

locale:
LC_COLLATE=English_United States.1252;LC_CTYPE=English_United 
States.1252;LC_MONETARY=English_United 
States.1252;LC_NUMERIC=C;LC_TIME=English_United States.1252

attached base packages:
[1] tools stats graphics  grDevices utils datasets  methods   base  
   
 Sys.getenv(PATH) 
PATH
C:\\Program Files\\MiKTeX 
2.7\\miktex\\bin;C:\\GTK\\bin;C:\\WINDOWS\\system32;C:\\WINDOWS;C:\\WINDOWS\\System32\\Wbem;C:\\Program
 Files\\SYSTAT 10\\;C:\\Program Files\\SYSTAT 10\\XGRAPH\\;C:\\Program 
Files\\Wave Systems Corp\\Dell Preboot Manager\\Access Client\\v5\\;C:\\Program 
Files\\ATI Technologies\\ATI.ACE\\Core-Static;c:\\Program Files\\Microsoft SQL 
Server\\90\\Tools\\binn\\

Thank you

Felipe D. Carrillo  
Supervisory Fishery Biologist  
Department of the Interior  
US Fish  Wildlife Service  
California, USA


--- On Thu, 10/16/08, Duncan Murdoch [EMAIL PROTECTED] wrote:

 Try running it as texi2dvi(Sweave-test-1.tex,
 pdf=TRUE, quiet=FALSE), 
 and post the list of error messages.
 
 You should also show us the results of sessionInfo() and 
 Sys.getenv(PATH), and tell us which version of
 LaTeX you have installed.
 
 Duncan Murdoch
  
  __
  R-help@r-project.org mailing list
  https://stat.ethz.ch/mailman/listinfo/r-help
  PLEASE do read the posting guide
 http://www.R-project.org/posting-guide.html
  and provide commented, minimal, self-contained,
 reproducible code.

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


Re: [R] apply, t-test and p-values PREVIOUS SUGGESTION DID NOT WORK

2008-10-16 Thread Gábor Csárdi
How about the following?

sapply(1:nrow(sample1), function(x) t.test(sample1[x,], sample2[x,])$p.value)

Gabor

On Thu, Oct 16, 2008 at 6:07 PM, John Sorkin
[EMAIL PROTECTED] wrote:
 Although I am grateful to Jorge and David for their suggestions, their 
 solution will not solve my problem as sample2 is not fixed. Let me 
 demonstrate what I want to do:


 # Define two matricies
 sample1-matrix(data=c(1:20),byrow=TRUE,ncol=5,nrow=4)
 sample2-sample1+rnorm(20)

 These are the computations that I would like to perform using apply (or some 
 similar method):


 # Compute t-test comparing first row of sample 1 to first row of sample 2
 t.test(sample1[1,],sample2[1,])

 # Compute t-test comparing second row of sample 1 to second row of sample 2
 t.test(sample1[2,],sample2[2,])

 # Compute t-test comparing third row of sample 1 to third row of sample 2
 t.test(sample1[3,],sample2[3,])

 # Compute t-test comparing fourth row of sample 1 to fourth row of sample 2
 t.test(sample1[4,],sample2[4,])



 As you can see, the code below does not return the same values! It does not 
 work.
 apply(sample1,1,function(x) t.test(x,sample1)$p.value)

 Sugestions would be appreciated!
 John

[...]
-- 
Gabor Csardi [EMAIL PROTECTED] UNIL DGM

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


Re: [R] apply, t-test and p-values PREVIOUS SUGGESTION DID NOT WORK

2008-10-16 Thread Jorge Ivan Velez
Dear John,
Perhaps is possible to do the job using apply or any of its friends. For
now, here is a solution using for() :

# Data sets
set.seed(123)
sample1-matrix(data=c(1:20),byrow=TRUE,ncol=5,nrow=4)
sample2-sample1+rnorm(20)

# t-test p-values
k=nrow(sample1)
res=NULL
for(i in 1:k) res[i]=t.test(sample1[i,],sample2[i,])$p.value
res

Another approach could be pag 5 in [1].

HTH,

Jorge

[1]
http://www.amstat-online.org/sections/graphics/newsletter/Volumes/v181.pdf


On Thu, Oct 16, 2008 at 12:07 PM, John Sorkin
[EMAIL PROTECTED]wrote:

 Although I am grateful to Jorge and David for their suggestions, their
 solution will not solve my problem as sample2 is not fixed. Let me
 demonstrate what I want to do:


 # Define two matricies
 sample1-matrix(data=c(1:20),byrow=TRUE,ncol=5,nrow=4)
 sample2-sample1+rnorm(20)

 These are the computations that I would like to perform using apply (or
 some similar method):


 # Compute t-test comparing first row of sample 1 to first row of sample 2
 t.test(sample1[1,],sample2[1,])

 # Compute t-test comparing second row of sample 1 to second row of sample 2
 t.test(sample1[2,],sample2[2,])

 # Compute t-test comparing third row of sample 1 to third row of sample 2
 t.test(sample1[3,],sample2[3,])

 # Compute t-test comparing fourth row of sample 1 to fourth row of sample 2
 t.test(sample1[4,],sample2[4,])



 As you can see, the code below does not return the same values! It does not
 work.
 apply(sample1,1,function(x) t.test(x,sample1)$p.value)

 Sugestions would be appreciated!
 John








 John David Sorkin M.D., Ph.D.
 Chief, Biostatistics and Informatics
 University of Maryland School of Medicine Division of Gerontology
 Baltimore VA Medical Center
 10 North Greene Street
 GRECC (BT/18/GR)
 Baltimore, MD 21201-1524
 (Phone) 410-605-7119
 (Fax) 410-605-7913 (Please call phone number above prior to faxing)

  Jorge Ivan Velez [EMAIL PROTECTED] 10/16/2008 10:04 AM 
 Thanks for the correction David!  You're absolutely right!  A typo  :- )
  ...
 Cheers,

 Jorge


 On Thu, Oct 16, 2008 at 10:00 AM, David Winsemius [EMAIL PROTECTED]
 wrote:

 
  On Oct 16, 2008, at 8:11 AM, Jorge Ivan Velez wrote:
 
   Dear John,
  Yes. Assuming that 'sample2' is fixed, something like this should do
 what
  you want:
 
  # Data sets
  set.seed(123)
  sample1=matrix(rnorm(100),ncol=10)
  sample2=rnorm(10,5,4)
 
  # t-test p-values
  apply(X,1,function(x) t.test(x,sample2)$p.value)
 
 
  It seems clear that you meant to type:
  apply(sample1,1,function(x) t.test(x,sample2)$p.value)
 
 
 
  [1] 0.002348970 0.004733230 0.004810952 0.004907549 0.002342979
  0.018748229
  0.003546655 0.006084410
  [9] 0.003100983 0.007007980
 
 
  HTH,
 
  Jorge
 
 
  On Thu, Oct 16, 2008 at 8:01 AM, John Sorkin 
 [EMAIL PROTECTED]
  wrote:
 
   R 2.7.2
  Windows XP
 
  I am using apply to compute a series of Student's t-test from two
  matrices,
  sample1 and sample2.
  boo-apply(sample1,1,t.test,sample2)
 
  I want to pick of the p-values from the tests, but can't seem to get it
  to
  work. I have tried several methods to get the values including:
  boo-apply(sample1,1,t.test$t.test,sample2)
  boo-apply(sample1,1,t.test,sample2)$t.test
 
  any suggestions?
 
  Thanks
  John
 
  John Sorkin M.D., Ph.D.
  Chief, Biostatistics and Informatics
  Baltimore VA Medical Center GRECC,
  University of Maryland School of Medicine Claude D. Pepper OAIC,
  University of Maryland Clinical Nutrition Research Unit, and
  Baltimore VA Center Stroke of Excellence
 
  University of Maryland School of Medicine
  Division of Gerontology
  Baltimore VA Medical Center
  10 North Greene Street
  GRECC (BT/18/GR)
  Baltimore, MD 21201-1524
 
  (Phone) 410-605-7119
  (Fax) 410-605-7913 (Please call phone number above prior to faxing)
  [EMAIL PROTECTED]
  Confidentiality Statement:
  This email message, including any attachments, is for ...{{dropped:13}}
 
 
  __
  R-help@r-project.org mailing list
  https://stat.ethz.ch/mailman/listinfo/r-help
  PLEASE do read the posting guide
  http://www.R-project.org/posting-guide.html
  and provide commented, minimal, self-contained, reproducible code.
 
 
 

[[alternative HTML version deleted]]

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

 Confidentiality Statement:
 This email message, including any attachments, is for ...{{dropped:10}}

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


Re: [R] draw a 5cm x 3cm rectangle

2008-10-16 Thread Barry Rowlingson
2008/10/16 Thomas Steiner [EMAIL PROTECTED]:
 Hi I want to draw sth in a pdf file with a predefined defined size.
 Say a 5cm x 3cm rectangle (a ruler):

 pdf(rect.pdf, paper=a4)
 plot(c(1,5,5,1,1),c(1,1,3,3,1),asp=1,axes=n)
 dev.off()

 but how do I fix that one unit is 1cm?

 I just did help.search(inch) and found xinch:

 'xinch' and 'yinch' convert the specified number of inches given
 as their arguments into the correct units for plotting with
 graphics functions.  Usually, this only makes sense when normal
 coordinates are used, i.e., _no_ 'log' scale (see the 'log'
 argument to 'par').

 Then help.search(cm) gave me cm:

Description:

 Translates from inches to cm (centimeters).

 You just need the inverse of this. Not too hard.

 Also, the symbol() function takes an inches=TRUE parameter that lets
you specify inches as the object size.

 The grid graphics package has a units system as well, but I've not
played with that. See help(unit) for info.

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] correlation between a discrete variable and a continuous variable

2008-10-16 Thread Greg Snow
Since water quality is ordered, you could use cor.test with method of kendall 
or spearman.  This will basically give a test of whether the rank based 
correlation is significantly different from 0.  Often more interesting 
information can come from the data if you do some more work.  Start by graphing 
your data to see what is there and if anything stands out.  Then decide what 
you really want to learn from the data to decide what other tests to do.  If 
you want to predict nitrogen given water quality, then you can use lm or aov 
(or other related methods), if you want to predict quality given nitrogen, then 
possibilities include proportional odds logistic regression (polr in MASS, lrm 
in Design) or recursive partitioning (rpart and other packages).

Hope this helps,

--
Gregory (Greg) L. Snow Ph.D.
Statistical Data Center
Intermountain Healthcare
[EMAIL PROTECTED]
801.408.8111


 -Original Message-
 From: [EMAIL PROTECTED] [mailto:[EMAIL PROTECTED]
 project.org] On Behalf Of kdebusk
 Sent: Thursday, October 16, 2008 6:54 AM
 To: r-help@r-project.org
 Subject: [R] correlation between a discrete variable and a continuous
 variable

 What test would you use to determine if a correlation exists between a
 discrete variable and a continuous variable?

 For example, I have a rating for stream water quality (excellent,
 good, fair, poor) and a corresponding nitrogen concentration. I want
 to see if there is a correlation between the water quality rating and
 the concentration of nitrogen in the stream.

 Help?

 __
 R-help@r-project.org mailing list
 https://stat.ethz.ch/mailman/listinfo/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] counting the frequencies of a vector

2008-10-16 Thread Jörg Groß

Hi,


Is there a function which counts the frequencies of the occurence of a  
number within an interval?


for example I have this vector:

x - c(1, 3, 1.2, 5, 5.9)

and I want a vector that gives me the frequencies within an interval  
of 2, beginning at 0

(so the intervals are 0-2, 2-4, 4-6 and so on)

so I get these frequencies:

2, 1, 2


Which functions do I have to use for this purpose?

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


Re: [R] draw a 5cm x 3cm rectangle

2008-10-16 Thread Greg Snow
Add to that list the functions grconvertX and grconvertY which can take 
coordinates in many different units and convert them to others (including 
inches, then just multiply/divide by 2.54 for the conversion from/to cm).

--
Gregory (Greg) L. Snow Ph.D.
Statistical Data Center
Intermountain Healthcare
[EMAIL PROTECTED]
801.408.8111


 -Original Message-
 From: [EMAIL PROTECTED] [mailto:[EMAIL PROTECTED]
 project.org] On Behalf Of Barry Rowlingson
 Sent: Thursday, October 16, 2008 10:34 AM
 To: Thomas Steiner
 Cc: [EMAIL PROTECTED]
 Subject: Re: [R] draw a 5cm x 3cm rectangle

 2008/10/16 Thomas Steiner [EMAIL PROTECTED]:
  Hi I want to draw sth in a pdf file with a predefined defined size.
  Say a 5cm x 3cm rectangle (a ruler):
 
  pdf(rect.pdf, paper=a4)
  plot(c(1,5,5,1,1),c(1,1,3,3,1),asp=1,axes=n)
  dev.off()
 
  but how do I fix that one unit is 1cm?

  I just did help.search(inch) and found xinch:

  'xinch' and 'yinch' convert the specified number of inches given
  as their arguments into the correct units for plotting with
  graphics functions.  Usually, this only makes sense when normal
  coordinates are used, i.e., _no_ 'log' scale (see the 'log'
  argument to 'par').

  Then help.search(cm) gave me cm:

 Description:

  Translates from inches to cm (centimeters).

  You just need the inverse of this. Not too hard.

  Also, the symbol() function takes an inches=TRUE parameter that lets
 you specify inches as the object size.

  The grid graphics package has a units system as well, but I've not
 played with that. See help(unit) for info.

 Barry

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

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


Re: [R] counting the frequencies of a vector

2008-10-16 Thread Barry Rowlingson
2008/10/16 Jörg Groß [EMAIL PROTECTED]:
 Hi,


 Is there a function which counts the frequencies of the occurence of a
 number within an interval?

 for example I have this vector:

 x - c(1, 3, 1.2, 5, 5.9)

 and I want a vector that gives me the frequencies within an interval of 2,
 beginning at 0
 (so the intervals are 0-2, 2-4, 4-6 and so on)

 so I get these frequencies:

 2, 1, 2


 Which functions do I have to use for this purpose?


 'cut' cuts your vector into chunks, and 'table' counts the number in
each chunk:

  x
 [1] 1.0 3.0 1.2 5.0 5.9
  table(cut(x,c(0,2,4,6)))

 (0,2] (2,4] (4,6]
 2 1 2

Barry

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


[R] Grouped Histogram (colored)

2008-10-16 Thread x0rr0x

Hi all,

I'm trying to create a histogram which shows the frequency of variables
within a certain timeframe.

I've been using SPSS before, but I didn't quite like it...

To describe my problem further here are some example variables:

the event is actually a string which I recoded using:
[code]
data$event_class = as.numeric(as.factor(data$event))
[/code]
I've recoded them into numerics


csv:
[code]
time,event,event_class
01,cookies,1
05,cookies,1
06,pie,2
07,coffee,3
08,cookies,1
30,pie,2
31,coffee,3
[/code]
and so on...

Now I'd like to create a histogram where X is the time, the color of the
area is the event_class
and Y is defined by the frequency of event_class around some accumulated
time



In SPSS I used this:
Graphs - Chart Builder
Gallery-Histogram
use some horizontal histogram
put time on the x-axis
select grouping/stacking variables in the groups/point id tab
and then set Stack: set-color to event_class
the y-axis will be automatically set to histogram

thanks a lot in advance!

Regards,
- x0rr0x
-- 
View this message in context: 
http://www.nabble.com/Grouped-Histogram-%28colored%29-tp20015941p20015941.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] draw a 5cm x 3cm rectangle

2008-10-16 Thread Erik Iverson

I would personally use grid for this.

library(grid)
grid.rect(width = 5, height = 3, default.units = cm)


Barry Rowlingson wrote:

2008/10/16 Thomas Steiner [EMAIL PROTECTED]:

Hi I want to draw sth in a pdf file with a predefined defined size.
Say a 5cm x 3cm rectangle (a ruler):

pdf(rect.pdf, paper=a4)
plot(c(1,5,5,1,1),c(1,1,3,3,1),asp=1,axes=n)
dev.off()

but how do I fix that one unit is 1cm?


 I just did help.search(inch) and found xinch:

 'xinch' and 'yinch' convert the specified number of inches given
 as their arguments into the correct units for plotting with
 graphics functions.  Usually, this only makes sense when normal
 coordinates are used, i.e., _no_ 'log' scale (see the 'log'
 argument to 'par').

 Then help.search(cm) gave me cm:

Description:

 Translates from inches to cm (centimeters).

 You just need the inverse of this. Not too hard.

 Also, the symbol() function takes an inches=TRUE parameter that lets
you specify inches as the object size.

 The grid graphics package has a units system as well, but I've not
played with that. See help(unit) for info.

Barry

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


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


Re: [R] Grouped Histogram (colored)

2008-10-16 Thread hadley wickham
On Thu, Oct 16, 2008 at 11:42 AM, x0rr0x [EMAIL PROTECTED] wrote:

 Hi all,

 I'm trying to create a histogram which shows the frequency of variables
 within a certain timeframe.

 I've been using SPSS before, but I didn't quite like it...

 To describe my problem further here are some example variables:

 the event is actually a string which I recoded using:
 [code]
 data$event_class = as.numeric(as.factor(data$event))
 [/code]
 I've recoded them into numerics


 csv:
 [code]
 time,event,event_class
 01,cookies,1
 05,cookies,1
 06,pie,2
 07,coffee,3
 08,cookies,1
 30,pie,2
 31,coffee,3
 [/code]
 and so on...

 Now I'd like to create a histogram where X is the time, the color of the
 area is the event_class
 and Y is defined by the frequency of event_class around some accumulated
 time

install.packages(ggplot2)
library(ggplot2)

qplot(time, fill = event, data = mydata, geom = histogram)

You can find out more about ggplot2 at http://had.co.nz/ggplot2 - it's
inspired by the Grammar of Graphics, which is also the theory that
underlies SPSS's plotting systems.

Hadley

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

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


Re: [R] Grouped Histogram (colored)

2008-10-16 Thread Greg Snow
Does this do what you want?

colhist - function(x,col){
 tmp - hist(x,plot=F)
 br - tmp$breaks
 w - as.numeric(cut(x,br,include.lowest=TRUE))
 sy - unlist(lapply(tmp$counts,function(x)seq(length=x)))
 sy - sy[order(order(x))]
plot( range(br), range( 0, sy ), xlab=deparse(substitute(x)),
ylab='Frequency', type='n')
 rect(br[w], sy-1, br[w+1], sy,
col=col,
border=NA)
 rect(br[-length(br)], 0, br[-1], tmp$counts)
 }

x - rnorm(75, rep( c(90,100,110), each=25), 5 )
g - rep( c('red','green','blue'), each=25 )

colhist(x,g)

note: this colhist function is a modified version of the one from the help file 
for the tkBrush function in the TeachingDemos package.

--
Gregory (Greg) L. Snow Ph.D.
Statistical Data Center
Intermountain Healthcare
[EMAIL PROTECTED]
801.408.8111


 -Original Message-
 From: [EMAIL PROTECTED] [mailto:[EMAIL PROTECTED]
 project.org] On Behalf Of x0rr0x
 Sent: Thursday, October 16, 2008 10:42 AM
 To: r-help@r-project.org
 Subject: [R] Grouped Histogram (colored)


 Hi all,

 I'm trying to create a histogram which shows the frequency of variables
 within a certain timeframe.

 I've been using SPSS before, but I didn't quite like it...

 To describe my problem further here are some example variables:

 the event is actually a string which I recoded using:
 [code]
 data$event_class = as.numeric(as.factor(data$event))
 [/code]
 I've recoded them into numerics


 csv:
 [code]
 time,event,event_class
 01,cookies,1
 05,cookies,1
 06,pie,2
 07,coffee,3
 08,cookies,1
 30,pie,2
 31,coffee,3
 [/code]
 and so on...

 Now I'd like to create a histogram where X is the time, the color of
 the
 area is the event_class
 and Y is defined by the frequency of event_class around some
 accumulated
 time



 In SPSS I used this:
 Graphs - Chart Builder
 Gallery-Histogram
 use some horizontal histogram
 put time on the x-axis
 select grouping/stacking variables in the groups/point id tab
 and then set Stack: set-color to event_class
 the y-axis will be automatically set to histogram

 thanks a lot in advance!

 Regards,
 - x0rr0x
 --
 View this message in context: http://www.nabble.com/Grouped-Histogram-
 %28colored%29-tp20015941p20015941.html
 Sent from the R help mailing list archive at Nabble.com.

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

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


Re: [R] increase memory limit in R

2008-10-16 Thread Prof Brian Ripley
AFAICS, you have a 2GB address space: please do read the rw-FAQ and fix 
that, in which case R will automatically make use of the increased space.


Hint: what is /3GB for?

On Thu, 16 Oct 2008, liujb wrote:



Dear R users,

I am running lmer() and having memory problem: reached total allocation of
1535Mb.

The lmer() function was successful (no errors or warnings). However when I
do summary(fit.lmer), I got this Error: cannot allocate vector of size
19.5 Mb). I used memory.size() and got 1880. I used memory.limit(2500) to
increase the memory size to 2500Mb, however I still get the warning messages
as above. I entered memory.limit() to check whether the size has been
increased or not, and R returns 2500.

I am running the program on Windows XP Professional, CPU 2.00GHz and 3.3 GB
of RAM.

I appreciate your advices. Thank you.
Julia
--
View this message in context: 
http://www.nabble.com/increase-memory-limit-in-R-tp20015931p20015931.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.



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

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


[R] rpart display

2008-10-16 Thread Sharma, Dhruv
Hi,
is there a way to replace long splits with some short naming
conventions?
 
For example if my resulting tree from rpart has 50-100 values can I
display some summary text like group1 instead of group num = 1 or 2 or
3100?
 
is there a way to specify different display text for nodes instead
of the actual split conditions?
 
thanks
Dhruv
 
 

[[alternative HTML version deleted]]

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


[R] How to save/load RWeka models into/from a file?

2008-10-16 Thread Paulo Cortez

Hi,

I want to save a RWeka model into a file, in order to retrive it latter 
with a load function.


See this example:

library(RWeka)

NB - make_Weka_classifier(weka/classifiers/bayes/NaiveBayes)
model-NB(formula,data=data,...) # does not run but you get the idea

save(model,file=model.dat) # simple save R command
# ...
load(model.dat) # load the model from the previously saved file...
model # should work but I get instead this error:
Error in .jcall(x$classifier, S, toString) :
  RcallMethod: attempt to call a method of a NULL object.

What is wrong and how can I solve this problem?

Regards,
--
Paulo Alexandre Ribeiro Cortez  (PhD, MSc)
Lecturer (Prof. Auxiliar) at the Department of Information Systems (DSI)
University of Minho, Campus de AzurÈm, 4800-058 Guimaraes, Portugal
http://www.dsi.uminho.pt/~pcortez +351253510313 Fax:+351253510300

__
R-help@r-project.org mailing list
https://stat.ethz.ch/mailman/listinfo/r-help
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 save/load RWeka models into/from a file?

2008-10-16 Thread Achim Zeileis

On Thu, 16 Oct 2008, Paulo Cortez wrote:


Hi,

I want to save a RWeka model into a file, in order to retrive it latter with 
a load function.


See this example:

library(RWeka)

NB - make_Weka_classifier(weka/classifiers/bayes/NaiveBayes)
model-NB(formula,data=data,...) # does not run but you get the idea

save(model,file=model.dat) # simple save R command
# ...
load(model.dat) # load the model from the previously saved file...
model # should work but I get instead this error:
Error in .jcall(x$classifier, S, toString) :
 RcallMethod: attempt to call a method of a NULL object.

What is wrong and how can I solve this problem?


The R object is just a reference to the corresponding object on the Java 
side (in Weka). When you close R, the Java/Weka session is also closed and 
the model is gone. Thus, when you load the object again in a new session, 
you only have a reference to a Java object that does not live anymore.

Z


Regards,
--
Paulo Alexandre Ribeiro Cortez  (PhD, MSc)
Lecturer (Prof. Auxiliar) at the Department of Information Systems (DSI)
University of Minho, Campus de AzurÈm, 4800-058 Guimaraes, Portugal
http://www.dsi.uminho.pt/~pcortez +351253510313 Fax:+351253510300

__
R-help@r-project.org mailing list
https://stat.ethz.ch/mailman/listinfo/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] plot - central limit theorem *solved*

2008-10-16 Thread Jörg Groß

Thanks for your great help!

I have now what I wanted.
For sure it's not well written and you can realize it with much less  
lines.

But it works and it's like how I wanted it to look like;


z1 - rnorm(4500, mean=20, sd=5)
z2 - rnorm(3600,  mean=28, sd=5)
z3 - rnorm(1300,  mean=40, sd=7)
z4 - rnorm(1200,  mean=10, sd=7)
z5 - rnorm(1500,  mean=50, sd=5)
z6 - rnorm(1500,  mean=10, sd=5)
z7 - rnorm(1400,  mean=37, sd=3)
pop - c(z1, z2, z3, z4, z5, z6, z7)

 meansN2 - numeric()
 meansN10 - numeric()
 meansN40 - numeric()

for (i in 1:1000) {
x - runif(2, min=1, max=15000)
x - round(x)
sample - c(pop[x])
meansN2 - append(meansN2, mean(sample))
 }
for (i in 1:1000) {
x - runif(10, min=1, max=15000)
x - round(x)

sample - c(pop[x])
meansN10 - append(meansN10, mean(sample))
 }
for (i in 1:1000) {
x - runif(40, min=1, max=15000)
x - round(x)
sample - c(pop[x])
meansN40 - append(meansN40, mean(sample))
}

pop - table(cut(pop,breaks=seq(from=-10, to=70, length.out=80)))

meansN2 - table(cut(meansN2,breaks=seq(from=-10, to=70,  
length.out=80)))
meansN10 - table(cut(meansN10,breaks=seq(from=-10, to=70,  
length.out=80)))
meansN40 - table(cut(meansN40,breaks=seq(from=-10, to=70,  
length.out=80)))


pop - smooth(pop)
meansN2 - smooth(meansN2)
meansN10 - smooth(meansN10)
meansN40 - smooth(meansN40)

plot(pop, type=l, lwd=1.5)
lines(meansN2, lty=dotted, lwd=1.5)
lines(meansN10, lty=dashed, lwd=1.5)
lines(meansN40, lty=twodash, lwd=1.5)

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


Re: [R] package Utils Sweave Example Error

2008-10-16 Thread Duncan Murdoch

On 10/16/2008 12:19 PM, Felipe Carrillo wrote:
This is my sessionInfo() and Sys.getenv(PATH) 


  library(tools)
testfile - system.file(Sweave, Sweave-test-1.Rnw, package = utils)
## enforce par(ask=FALSE)
options(device.ask.default=FALSE)
## create a LaTeX file
Sweave(testfile)
Writing to file Sweave-test-1.tex
Processing code chunks ...
 1 : print term verbatim
 2 : term hide
 3 : echo print term verbatim
 4 : term verbatim
 5 : echo term verbatim
 6 : echo term verbatim eps pdf
 7 : echo term verbatim eps pdf

You can now run LaTeX on 'Sweave-test-1.tex'
## This can be compiled to PDF by
texi2dvi(Sweave-test-1.tex, pdf=TRUE,quiet=FALSE)

This is pdfTeX, Version 3.1415926-1.40.9 (MiKTeX 2.7)
entering extended mode
(C:/Program Files/R/R-2.7.2/bin/Sweave-test-1.tex
LaTeX2e 2005/12/01
Babel v3.8l and hyphenation patterns for english, dumylang, nohyphenation, ge
rman, ngerman, german-x-2008-06-18, ngerman-x-2008-06-18, french, loaded.
(C:\Program Files\MiKTeX 2.7\tex\latex\base\article.cls
Document Class: article 2005/09/16 v1.4f Standard LaTeX document class
(C:\Program Files\MiKTeX 2.7\tex\latex\base\size10.clo))
(C:\Program Files\MiKTeX 2.7\tex\latex\ltxmisc\a4wide.sty
(C:\Program Files\MiKTeX 2.7\tex\latex\ntgclass\a4.sty))
! Missing \endcsname inserted.
to be read again 
   \protect 
l.11 \begin

   {document}
? pdflatex.EXE: Bad file descriptor



This appears to be the problem.  I'm not certain, but I would guess if 
you look in the C:/Program Files/R/R-2.7.2/bin/Sweave-test-1.tex file 
you'll see a line something like this:


\usepackage{C:/Program Files/R/R-2.7.2/share/texmf/Sweave}

That line (which was added by Sweave) will not work, because LaTeX does 
not understand blanks in file paths.  There are a couple of workarounds:


1.  Install R in a directory that doesn't contain blanks.

2.  Include \usepackage{Sweave} in the Rnw file you're processing; this 
will stop Sweave from adding anything.  I believe we set things up so 
that MikTeX will find it in the right place (though I don't normally use 
texi2dvi, so I'm not sure).


To test this, you can just go and edit the Sweave-test-1.tex file now, 
replacing the long line with the short version.


Duncan Murdoch


texify: pdflatex failed for some reason (see log file).
Error in texi2dvi(Sweave-test-1.tex, pdf = TRUE, quiet = FALSE) : 
  running 'texi2dvi' on 'Sweave-test-1.tex' failed


sessionInfo()
R version 2.7.2 (2008-08-25) 
i386-pc-mingw32 


locale:
LC_COLLATE=English_United States.1252;LC_CTYPE=English_United 
States.1252;LC_MONETARY=English_United 
States.1252;LC_NUMERIC=C;LC_TIME=English_United States.1252

attached base packages:
[1] tools stats graphics  grDevices utils datasets  methods   base 
Sys.getenv(PATH) 

PATH
C:\\Program Files\\MiKTeX 
2.7\\miktex\\bin;C:\\GTK\\bin;C:\\WINDOWS\\system32;C:\\WINDOWS;C:\\WINDOWS\\System32\\Wbem;C:\\Program
 Files\\SYSTAT 10\\;C:\\Program Files\\SYSTAT 10\\XGRAPH\\;C:\\Program Files\\Wave 
Systems Corp\\Dell Preboot Manager\\Access Client\\v5\\;C:\\Program Files\\ATI 
Technologies\\ATI.ACE\\Core-Static;c:\\Program Files\\Microsoft SQL 
Server\\90\\Tools\\binn\\

Thank you

Felipe D. Carrillo  
Supervisory Fishery Biologist  
Department of the Interior  
US Fish  Wildlife Service  
California, USA



--- On Thu, 10/16/08, Duncan Murdoch [EMAIL PROTECTED] wrote:


Try running it as texi2dvi(Sweave-test-1.tex,
pdf=TRUE, quiet=FALSE), 
and post the list of error messages.


You should also show us the results of sessionInfo() and 
Sys.getenv(PATH), and tell us which version of

LaTeX you have installed.

Duncan Murdoch
 
 __

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






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

2008-10-16 Thread David Winsemius


On Oct 16, 2008, at 12:55 PM, Jorge Ivan Velez wrote:


Dear Jörg,
See ?cut and ?table. Is this what you want?

x - c(1, 3, 1.2, 5, 5.9)
table(cut(x,breaks=c(0,2,4,6)))
(0,2] (2,4] (4,6]
   2 1 2


Perhaps even greater future efficiency could be had by also adding

?seq

table(cut(x, breaks=seq(0, 6, by=2)))

A couple more keysrokes in this toy example but scales up much better  
to the requested purpose of evenly divided interval.


The OP should also note carefully the open aspect on the left of these  
intervals. That can be controlled with option in cut:


 x - c(1, 3, 1.2, 5, 5.9, 6)
 table(cut(x, breaks=seq(0,6,by=2)))

(0,2] (2,4] (4,6]
2 1 3
 x - c(1, 3, 1.2, 4, 5, 5.9, 6)
 table(cut(x, breaks=seq(0,6,by=2)))

(0,2] (2,4] (4,6]
2 2 3

 table(cut(x, breaks=seq(0,6,by=2), right=FALSE))

[0,2) [2,4) [4,6)
2 1 3

--
David Winsemius
Heritage Labs




HTH,

Jorge


On Thu, Oct 16, 2008 at 12:46 PM, Jörg Groß [EMAIL PROTECTED]  
wrote:



Hi,


Is there a function which counts the frequencies of the occurence  
of a

number within an interval?

for example I have this vector:

x - c(1, 3, 1.2, 5, 5.9)

and I want a vector that gives me the frequencies within an  
interval of 2,

beginning at 0
(so the intervals are 0-2, 2-4, 4-6 and so on)

so I get these frequencies:

2, 1, 2


Which functions do I have to use for this purpose?

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



[[alternative HTML version deleted]]

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


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


[R] Sweave working now!!!

2008-10-16 Thread Felipe Carrillo
Duncan:
I installed R in C:\R\R-2.7.2 and worked beautifully. I hope this will help 
others with the same problem. Thanks a lot for your help.



--- On Thu, 10/16/08, Duncan Murdoch [EMAIL PROTECTED] wrote:

 On 10/16/2008 12:19 PM, Felipe Carrillo wrote:
  This is my sessionInfo() and
 Sys.getenv(PATH) 
  
library(tools)
  testfile - system.file(Sweave,
 Sweave-test-1.Rnw, package = utils)
  ## enforce par(ask=FALSE)
  options(device.ask.default=FALSE)
  ## create a LaTeX file
  Sweave(testfile)
  Writing to file Sweave-test-1.tex
  Processing code chunks ...
   1 : print term verbatim
   2 : term hide
   3 : echo print term verbatim
   4 : term verbatim
   5 : echo term verbatim
   6 : echo term verbatim eps pdf
   7 : echo term verbatim eps pdf
  
  You can now run LaTeX on 'Sweave-test-1.tex'
  ## This can be compiled to PDF by
  texi2dvi(Sweave-test-1.tex,
 pdf=TRUE,quiet=FALSE)
  
  This is pdfTeX, Version 3.1415926-1.40.9 (MiKTeX 2.7)
  entering extended mode
  (C:/Program
 Files/R/R-2.7.2/bin/Sweave-test-1.tex
  LaTeX2e 2005/12/01
  Babel v3.8l and hyphenation patterns for
 english, dumylang, nohyphenation, ge
  rman, ngerman, german-x-2008-06-18,
 ngerman-x-2008-06-18, french, loaded.
  (C:\Program Files\MiKTeX
 2.7\tex\latex\base\article.cls
  Document Class: article 2005/09/16 v1.4f Standard
 LaTeX document class
  (C:\Program Files\MiKTeX
 2.7\tex\latex\base\size10.clo))
  (C:\Program Files\MiKTeX
 2.7\tex\latex\ltxmisc\a4wide.sty
  (C:\Program Files\MiKTeX
 2.7\tex\latex\ntgclass\a4.sty))
  ! Missing \endcsname inserted.
  to be read again 
 \protect 
  l.11 \begin
 {document}
  ? pdflatex.EXE: Bad file descriptor
 
 
 This appears to be the problem.  I'm not certain, but I
 would guess if 
 you look in the C:/Program
 Files/R/R-2.7.2/bin/Sweave-test-1.tex file 
 you'll see a line something like this:
 
 \usepackage{C:/Program
 Files/R/R-2.7.2/share/texmf/Sweave}
 
 That line (which was added by Sweave) will not work,
 because LaTeX does 
 not understand blanks in file paths.  There are a couple of
 workarounds:
 
 1.  Install R in a directory that doesn't contain
 blanks.
 
 2.  Include \usepackage{Sweave} in the Rnw file
 you're processing; this 
 will stop Sweave from adding anything.  I believe we set
 things up so 
 that MikTeX will find it in the right place (though I
 don't normally use 
 texi2dvi, so I'm not sure).
 
 To test this, you can just go and edit the
 Sweave-test-1.tex file now, 
 replacing the long line with the short version.
 
 Duncan Murdoch
 
  texify: pdflatex failed for some reason (see log
 file).
  Error in texi2dvi(Sweave-test-1.tex, pdf =
 TRUE, quiet = FALSE) : 
running 'texi2dvi' on
 'Sweave-test-1.tex' failed
  
  sessionInfo()
  R version 2.7.2 (2008-08-25) 
  i386-pc-mingw32 
  
  locale:
  LC_COLLATE=English_United
 States.1252;LC_CTYPE=English_United
 States.1252;LC_MONETARY=English_United
 States.1252;LC_NUMERIC=C;LC_TIME=English_United States.1252
  
  attached base packages:
  [1] tools stats graphics  grDevices utils
 datasets  methods   base 
  Sys.getenv(PATH) 
  PATH
  C:\\Program Files\\MiKTeX
 2.7\\miktex\\bin;C:\\GTK\\bin;C:\\WINDOWS\\system32;C:\\WINDOWS;C:\\WINDOWS\\System32\\Wbem;C:\\Program
 Files\\SYSTAT 10\\;C:\\Program
 Files\\SYSTAT
 10\\XGRAPH\\;C:\\Program
 Files\\Wave Systems Corp\\Dell Preboot
 Manager\\Access
 Client\\v5\\;C:\\Program
 Files\\ATI
 Technologies\\ATI.ACE\\Core-Static;c:\\Program
 Files\\Microsoft SQL
 Server\\90\\Tools\\binn\\
  
  Thank you
  
  Felipe D. Carrillo  
  Supervisory Fishery Biologist  
  Department of the Interior  
  US Fish  Wildlife Service  
  California, USA
  
  
  --- On Thu, 10/16/08, Duncan Murdoch
 [EMAIL PROTECTED] wrote:
  
  Try running it as
 texi2dvi(Sweave-test-1.tex,
  pdf=TRUE, quiet=FALSE), 
  and post the list of error messages.
  
  You should also show us the results of
 sessionInfo() and 
  Sys.getenv(PATH), and tell us which
 version of
  LaTeX you have installed.
  
  Duncan Murdoch
   
  
 __
   R-help@r-project.org mailing list
   https://stat.ethz.ch/mailman/listinfo/r-help
   PLEASE do read the posting guide
  http://www.R-project.org/posting-guide.html
   and provide commented, minimal,
 self-contained,
  reproducible code.
  
  
 

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


Re: [R] Programing and writing function help

2008-10-16 Thread Stephen Cole
Thank- you all for you suggestions and help.  I have now resolved my
issue.   This help forum is one of the things that makes R a great platform
for statistics.

Stephen Cole
Marine Ecology Lab
Saint Francis Xavier University

On Wed, Oct 8, 2008 at 8:07 AM, Erin Hodgess [EMAIL PROTECTED]wrote:

 Actually, you will have duplicates with 400 pairs.

 Here you will have 13^2 pairs with replacement and 13*12 pairs without
 replacement and with regard to order.
 How about this:
  z - unique(x)
  y - expand.grid(z[1:13],z[1:13])
  xx - y[,1] != y[,2]
  y[xx,]

 Just another thought.

 Erin


 On Wed, Oct 8, 2008 at 5:55 AM, Erin Hodgess [EMAIL PROTECTED]
 wrote:
  For all possible pairs, you'll have 20^2 pairs.
  This is a way to do it:
 
  expand.grid(x[1:20],x[1:20])
 
  HTH,
  Erin
 
 
  On Wed, Oct 8, 2008 at 4:43 AM, Jim Lemon [EMAIL PROTECTED] wrote:
  Stephen Cole wrote:
 
  ...
  I have a vector of 20 values
 
  x - c(20,18, 45, 16, 47, 47, 15, 26,
 14,14,12,16,35,27,18,94,16,26,26,30)
 
  1.
  I  want to select random pairs from this data set but do it without
  replacement exhaustively
 
 
  matrix(x[sample(1:20,20)],nrow=2)
 
  then step through the columns of the resulting matrix
 
  I know i can select random pairs without replacement using
 
  sample(N,n,replace=F)
  However i am wondering if there is any way to get 10 random pairs from
  this
  data set without repeating any of the data points
  that is to say if i got a (20, 94) for one pair, i would like to get 9
  other
  pairs from the data without again getting 20 or 94?
 
  2.
  The second thing i would like to do is be able to select all possible
  pairs
  of numbers and calculate each pairs variance.
 
  I think you want to use the combn function, but you are going to get a
 lot
  of pairs...
 
  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.
 
 
 
 
  --
  Erin Hodgess
  Associate Professor
  Department of Computer and Mathematical Sciences
  University of Houston - Downtown
  mailto: [EMAIL PROTECTED]
 



 --
 Erin Hodgess
 Associate Professor
 Department of Computer and Mathematical Sciences
 University of Houston - Downtown
 mailto: [EMAIL PROTECTED]


[[alternative HTML version deleted]]

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


Re: [R] package Utils Sweave Example Error

2008-10-16 Thread Prof Brian Ripley

On Thu, 16 Oct 2008, Duncan Murdoch wrote:


On 10/16/2008 12:19 PM, Felipe Carrillo wrote:

This is my sessionInfo() and Sys.getenv(PATH)
  library(tools)
testfile - system.file(Sweave, Sweave-test-1.Rnw, package = utils)
## enforce par(ask=FALSE)
options(device.ask.default=FALSE)
## create a LaTeX file
Sweave(testfile)
Writing to file Sweave-test-1.tex
Processing code chunks ...
 1 : print term verbatim
 2 : term hide
 3 : echo print term verbatim
 4 : term verbatim
 5 : echo term verbatim
 6 : echo term verbatim eps pdf
 7 : echo term verbatim eps pdf

You can now run LaTeX on 'Sweave-test-1.tex'
## This can be compiled to PDF by
texi2dvi(Sweave-test-1.tex, pdf=TRUE,quiet=FALSE)

This is pdfTeX, Version 3.1415926-1.40.9 (MiKTeX 2.7)
entering extended mode
(C:/Program Files/R/R-2.7.2/bin/Sweave-test-1.tex
LaTeX2e 2005/12/01
Babel v3.8l and hyphenation patterns for english, dumylang, 
nohyphenation, ge

rman, ngerman, german-x-2008-06-18, ngerman-x-2008-06-18, french, loaded.
(C:\Program Files\MiKTeX 2.7\tex\latex\base\article.cls
Document Class: article 2005/09/16 v1.4f Standard LaTeX document class
(C:\Program Files\MiKTeX 2.7\tex\latex\base\size10.clo))
(C:\Program Files\MiKTeX 2.7\tex\latex\ltxmisc\a4wide.sty
(C:\Program Files\MiKTeX 2.7\tex\latex\ntgclass\a4.sty))
! Missing \endcsname inserted.
to be read again\protect l.11 \begin
   {document}
? pdflatex.EXE: Bad file descriptor



This appears to be the problem.  I'm not certain, but I would guess if you 
look in the C:/Program Files/R/R-2.7.2/bin/Sweave-test-1.tex file you'll 
see a line something like this:


\usepackage{C:/Program Files/R/R-2.7.2/share/texmf/Sweave}

That line (which was added by Sweave) will not work, because LaTeX does not 
understand blanks in file paths.  There are a couple of workarounds:


1.  Install R in a directory that doesn't contain blanks.

2.  Include \usepackage{Sweave} in the Rnw file you're processing; this will 
stop Sweave from adding anything.  I believe we set things up so that MikTeX 
will find it in the right place (though I don't normally use texi2dvi, so I'm 
not sure).


Yes, and 2.8.0 RC does this even better.

To test this, you can just go and edit the Sweave-test-1.tex file now, 
replacing the long line with the short version.


Duncan Murdoch


texify: pdflatex failed for some reason (see log file).
Error in texi2dvi(Sweave-test-1.tex, pdf = TRUE, quiet = FALSE) : 
running 'texi2dvi' on 'Sweave-test-1.tex' failed


sessionInfo()
R version 2.7.2 (2008-08-25) i386-pc-mingw32 
locale:
LC_COLLATE=English_United States.1252;LC_CTYPE=English_United 
States.1252;LC_MONETARY=English_United 
States.1252;LC_NUMERIC=C;LC_TIME=English_United States.1252


attached base packages:
[1] tools stats graphics  grDevices utils datasets  methods 
base 
Sys.getenv(PATH) 

PATH
C:\\Program Files\\MiKTeX 
2.7\\miktex\\bin;C:\\GTK\\bin;C:\\WINDOWS\\system32;C:\\WINDOWS;C:\\WINDOWS\\System32\\Wbem;C:\\Program 
Files\\SYSTAT 10\\;C:\\Program Files\\SYSTAT 10\\XGRAPH\\;C:\\Program 
Files\\Wave Systems Corp\\Dell Preboot Manager\\Access 
Client\\v5\\;C:\\Program Files\\ATI 
Technologies\\ATI.ACE\\Core-Static;c:\\Program Files\\Microsoft SQL 
Server\\90\\Tools\\binn\\


Thank you

Felipe D. Carrillo  Supervisory Fishery Biologist  Department of the 
Interior  US Fish  Wildlife Service  California, USA



--- On Thu, 10/16/08, Duncan Murdoch [EMAIL PROTECTED] wrote:


Try running it as texi2dvi(Sweave-test-1.tex,
pdf=TRUE, quiet=FALSE), and post the list of error messages.

You should also show us the results of sessionInfo() and 
Sys.getenv(PATH), and tell us which version of

LaTeX you have installed.

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






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



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

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


Re: [R] Variable shortlisting for the logistic regression

2008-10-16 Thread useR
Let's try to bring this discussion back again after Frank made
very funny remark!

What I'm doing at the moment is:

1. I split dataset in two (development and holdout)
2. I fit single predictor logistic model for every variable and
collect following stats:

DMaxDeriv=modelD$stats[2]
DModelLR=modelD$stats[3]
DP=modelD$stats[5]
DC=modelD$stats[6]
DDxy=modelD$stats[7]
DGamma=modelD$stats[8]
DTau=modelD$stats[9]
DR2=modelD$stats[10]
DBier=modelD$stats[11]

HMaxDeriv=modelH$stats[2]
HModelLR=modelH$stats[3]
HP=modelH$stats[5]
HC=modelH$stats[6]
HDxy=modelH$stats[7]
HGamma=modelH$stats[8]
HTau=modelH$stats[9]
HR2=modelH$stats[10]
HBier=modelH$stats[11]

where D is prefix for stats on development sample and H is prefix for
stats derived from hold out sample



3. Now I screen factor with sommers d grather than 0.3 and relative
change on hold out sample is smaller than 5%


Any comments are very welcomed















On Oct 14, 2:48 pm, John Kane [EMAIL PROTECTED] wrote:
 --- On Mon, 10/13/08, David Scott [EMAIL PROTECTED] wrote:



  From: David Scott [EMAIL PROTECTED]
  Subject: Re: [R] Variable shortlisting for the logistic regression
  To: Frank E Harrell Jr [EMAIL PROTECTED]
  Cc: [EMAIL PROTECTED]
  Received: Monday, October 13, 2008, 6:32 PM
  On Mon, 13 Oct 2008, Frank E Harrell Jr wrote:

   useR wrote:
   Hi R helpers,

   One rather statistical question?

   What would be the best startegy to shortlist
  thousands of continous
   variables automaticaly using R
   as the preparation for logistic regression
  modleing!

   Thanks

   The easiest approach is to use a random number
  generator.
   Frank

  Got a laugh from me Frank!

  Can I nominate it for a fortune?

  David

 Seconded.

       __
 [[elided Yahoo spam]]

 __
 [EMAIL PROTECTED] mailing listhttps://stat.ethz.ch/mailman/listinfo/r-help
 PLEASE do read the posting guidehttp://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] defining a function using strings

2008-10-16 Thread Rolf Turner


On 17/10/2008, at 7:40 AM, Chernomoretz Ariel wrote:


Hi All,
I need to evaluate a series expansion using Legendre polynomials.
Using the 'orthopolinom' package I can get a list of the first n
Legendre polynomials as character strings.


library(orthopolynom)
l-legendre.polynomials(4)
l

[[1]]
1

[[2]]
x

[[3]]
-0.5 + 1.5*x^2

[[4]]
-1.5*x + 2.5*x^3

[[5]]
0.375 - 3.75*x^2 + 4.375*x^4

But I can't figure out how to implement functions that could be
evaluated for arbitrary 'x', from this list,
Thanks for your help.


?as.function
methods(as.function)
?as.function.polynomial
foo - as.function(l[[4]])
foo(3)

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] Variable shortlisting for the logistic regression

2008-10-16 Thread Rolf Turner


On 17/10/2008, at 8:22 AM, useR wrote:


Let's try to bring this discussion back again after Frank made
very funny remark!


Frank's remark was *serious*.  Take it seriously.

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] defining a function using strings

2008-10-16 Thread Dimitris Rizopoulos

try this:

library(orthopolynom)
l - legendre.polynomials(4)
fun.l - lapply(l, as.function)

fun.l[[3]](1:3)


I hope it helps.

Best,
Dimitris


Chernomoretz Ariel wrote:

Hi All,
I need to evaluate a series expansion using Legendre polynomials.
Using the 'orthopolinom' package I can get a list of the first n
Legendre polynomials as character strings.


library(orthopolynom)
l-legendre.polynomials(4)
l

[[1]]
1

[[2]]
x

[[3]]
-0.5 + 1.5*x^2

[[4]]
-1.5*x + 2.5*x^3

[[5]]
0.375 - 3.75*x^2 + 4.375*x^4

But I can't figure out how to implement functions that could be
evaluated for arbitrary 'x', from this list,
Thanks for your help.

Ariel./




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

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

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


Re: [R] defining a function using strings

2008-10-16 Thread Gabor Grothendieck
Try this (to evaluate them at 10):

polynomial.values(l, 10)


On Thu, Oct 16, 2008 at 2:40 PM, Chernomoretz Ariel [EMAIL PROTECTED] wrote:
 Hi All,
 I need to evaluate a series expansion using Legendre polynomials.
 Using the 'orthopolinom' package I can get a list of the first n
 Legendre polynomials as character strings.

 library(orthopolynom)
 l-legendre.polynomials(4)
 l
 [[1]]
 1

 [[2]]
 x

 [[3]]
 -0.5 + 1.5*x^2

 [[4]]
 -1.5*x + 2.5*x^3

 [[5]]
 0.375 - 3.75*x^2 + 4.375*x^4

 But I can't figure out how to implement functions that could be
 evaluated for arbitrary 'x', from this list,
 Thanks for your help.

 Ariel./


 --
  Dr. Ariel Chernomoretz
   Departamento de Fisica, FCEyN,Universidad de Buenos Aires,
   (1428) Ciudad Universitaria,Ciudad de Buenos Aires, Argentina.
   TE +54 11 4576 3390 ext 817
   Fax +54 11 4576 3357
   email: [EMAIL PROTECTED]Webpage: 
 http://www.df.uba.ar/users/ariel

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

2008-10-16 Thread David Afshartous


All, 

I'd like to simulate a vector that is formed from many distinct
distributions and avoid a loop if possible.  E.g, consider:

mu = c(1, 2, 3)
sigma = c(1, 2, 3)
n = c(10, 10, 10)

And we simulate a vector of length 30 that consists of N(mu[i], sigma[i])
distributed data, each of length n[i].   Of course for just three groups we
can simply write it out as:

DV = c(rnorm(n[1], mu[1], sigma[1]), rnorm(n[2], mu[2], sigma[2]),
rnorm(n[3], mu[3], sigma[3]) )

For many groups we can use a loop (assuming equal numbers per group):

n = n[1]
DV = numeric(N*n)
for (i in 1:N) {
DV[(n*i - (n-1)): (n*i)] = rnorm(n, mu[i], sigma[i])
}

Is there any way to do the general cas without using a loop?

Cheers,
David

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


Re: [R] Loop avoidance in simulating a vector

2008-10-16 Thread Christos Hatzis
Have a look at mapply.

-Christos 

 -Original Message-
 From: [EMAIL PROTECTED] 
 [mailto:[EMAIL PROTECTED] On Behalf Of David Afshartous
 Sent: Thursday, October 16, 2008 3:47 PM
 To: r-help@r-project.org
 Subject: [R] Loop avoidance in simulating a vector
 
 
 
 All, 
 
 I'd like to simulate a vector that is formed from many 
 distinct distributions and avoid a loop if possible.  E.g, consider:
 
 mu = c(1, 2, 3)
 sigma = c(1, 2, 3)
 n = c(10, 10, 10)
 
 And we simulate a vector of length 30 that consists of 
 N(mu[i], sigma[i])
 distributed data, each of length n[i].   Of course for just 
 three groups we
 can simply write it out as:
 
 DV = c(rnorm(n[1], mu[1], sigma[1]), rnorm(n[2], mu[2], 
 sigma[2]), rnorm(n[3], mu[3], sigma[3]) )
 
 For many groups we can use a loop (assuming equal numbers per group):
 
 n = n[1]
 DV = numeric(N*n)
 for (i in 1:N) {
 DV[(n*i - (n-1)): (n*i)] = rnorm(n, mu[i], sigma[i])
 }
 
 Is there any way to do the general cas without using a loop?
 
 Cheers,
 David
 
 __
 R-help@r-project.org mailing list
 https://stat.ethz.ch/mailman/listinfo/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] Loop avoidance in simulating a vector

2008-10-16 Thread Bert Gunter
mapply is still a (disguised) loop (at the interpreted level). So other than
improving code readability (always a good thing!), it shouldn't make much of
an efficiency difference.

A longer answer is: if all you're doing is a location-scale family of
distributions, then creating a matrix of standard normal (or whatever)
distributed data for all 1:N at once and then using matrix operations to
multiply and add, say, so each column becomes your different distribution
might be faster. This gets the loops down to C code.

A shorter answer is: it's unlikely that any of this makes enough of a
difference to be worth the effort. Random number generation is so efficient
in R that avoiding loops rarely matters.

Also see ?replicate for a way to perhaps write cleaner code (but still using
hidden interpreted loops).

-- Bert Gunter

-Original Message-
From: [EMAIL PROTECTED] [mailto:[EMAIL PROTECTED] On
Behalf Of Christos Hatzis
Sent: Thursday, October 16, 2008 1:06 PM
To: 'David Afshartous'; r-help@r-project.org
Subject: Re: [R] Loop avoidance in simulating a vector

Have a look at mapply.

-Christos 

 -Original Message-
 From: [EMAIL PROTECTED] 
 [mailto:[EMAIL PROTECTED] On Behalf Of David Afshartous
 Sent: Thursday, October 16, 2008 3:47 PM
 To: r-help@r-project.org
 Subject: [R] Loop avoidance in simulating a vector
 
 
 
 All, 
 
 I'd like to simulate a vector that is formed from many 
 distinct distributions and avoid a loop if possible.  E.g, consider:
 
 mu = c(1, 2, 3)
 sigma = c(1, 2, 3)
 n = c(10, 10, 10)
 
 And we simulate a vector of length 30 that consists of 
 N(mu[i], sigma[i])
 distributed data, each of length n[i].   Of course for just 
 three groups we
 can simply write it out as:
 
 DV = c(rnorm(n[1], mu[1], sigma[1]), rnorm(n[2], mu[2], 
 sigma[2]), rnorm(n[3], mu[3], sigma[3]) )
 
 For many groups we can use a loop (assuming equal numbers per group):
 
 n = n[1]
 DV = numeric(N*n)
 for (i in 1:N) {
 DV[(n*i - (n-1)): (n*i)] = rnorm(n, mu[i], sigma[i])
 }
 
 Is there any way to do the general cas without using a loop?
 
 Cheers,
 David
 
 __
 R-help@r-project.org mailing list
 https://stat.ethz.ch/mailman/listinfo/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] Loop avoidance in simulating a vector

2008-10-16 Thread Christos Hatzis
Yes, but the difference is that the looping in mapply is done in C.
There are no interpreted loops in mapply,as far as I can see.

-Christos 

 -Original Message-
 From: Bert Gunter [mailto:[EMAIL PROTECTED] 
 Sent: Thursday, October 16, 2008 4:13 PM
 To: [EMAIL PROTECTED]; 'David Afshartous'; 
 r-help@r-project.org
 Subject: RE: [R] Loop avoidance in simulating a vector
 
 mapply is still a (disguised) loop (at the interpreted 
 level). So other than improving code readability (always a 
 good thing!), it shouldn't make much of an efficiency difference.
 
 A longer answer is: if all you're doing is a location-scale 
 family of distributions, then creating a matrix of standard 
 normal (or whatever) distributed data for all 1:N at once and 
 then using matrix operations to multiply and add, say, so 
 each column becomes your different distribution might be 
 faster. This gets the loops down to C code.
 
 A shorter answer is: it's unlikely that any of this makes 
 enough of a difference to be worth the effort. Random number 
 generation is so efficient in R that avoiding loops rarely matters.
 
 Also see ?replicate for a way to perhaps write cleaner code 
 (but still using hidden interpreted loops).
 
 -- Bert Gunter
 
 -Original Message-
 From: [EMAIL PROTECTED] 
 [mailto:[EMAIL PROTECTED] On Behalf Of Christos Hatzis
 Sent: Thursday, October 16, 2008 1:06 PM
 To: 'David Afshartous'; r-help@r-project.org
 Subject: Re: [R] Loop avoidance in simulating a vector
 
 Have a look at mapply.
 
 -Christos 
 
  -Original Message-
  From: [EMAIL PROTECTED]
  [mailto:[EMAIL PROTECTED] On Behalf Of David Afshartous
  Sent: Thursday, October 16, 2008 3:47 PM
  To: r-help@r-project.org
  Subject: [R] Loop avoidance in simulating a vector
  
  
  
  All,
  
  I'd like to simulate a vector that is formed from many distinct 
  distributions and avoid a loop if possible.  E.g, consider:
  
  mu = c(1, 2, 3)
  sigma = c(1, 2, 3)
  n = c(10, 10, 10)
  
  And we simulate a vector of length 30 that consists of N(mu[i], 
  sigma[i])
  distributed data, each of length n[i].   Of course for just 
  three groups we
  can simply write it out as:
  
  DV = c(rnorm(n[1], mu[1], sigma[1]), rnorm(n[2], mu[2], sigma[2]), 
  rnorm(n[3], mu[3], sigma[3]) )
  
  For many groups we can use a loop (assuming equal numbers 
 per group):
  
  n = n[1]
  DV = numeric(N*n)
  for (i in 1:N) {
  DV[(n*i - (n-1)): (n*i)] = rnorm(n, mu[i], sigma[i])
  }
  
  Is there any way to do the general cas without using a loop?
  
  Cheers,
  David
  
  __
  R-help@r-project.org mailing list
  https://stat.ethz.ch/mailman/listinfo/r-help
  PLEASE do read the posting guide
  http://www.R-project.org/posting-guide.html
  and provide commented, minimal, self-contained, reproducible code.
  
 
 
 __
 R-help@r-project.org mailing list
 https://stat.ethz.ch/mailman/listinfo/r-help
 PLEASE do read the posting guide 
 http://www.R-project.org/posting-guide.html
 and provide commented, minimal, self-contained, reproducible code.
 
 


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


[R] Saving results of Kruskal Walis test

2008-10-16 Thread Himanshu Ardawatia
Hello,

I am running Kruskal-Walis test in R. When I try to save results using
write.table it gives me the following error :

Error in as.data.frame.default(x[[i]], optional = TRUE, stringsAsFactors =
stringsAsFactors) :
  cannot coerce class htest into a data.frame

The overall code is as follows :

data_file = read.table(~/DATA.dir/data_file.txt, header=T)

attach(data_file)

data_file.out - krukal.test(data_file)

write.table(data_file.out, ~/DATA/results/data_file_out.txt)

Error in as.data.frame.default(x[[i]], optional = TRUE, stringsAsFactors =
stringsAsFactors) :
  cannot coerce class htest into a data.frame
Results do come in data_file.out after analysis as seen below:

data_file.out


Kruskal-Wallis rank sum test

data:  value by pathway
Kruskal-Wallis chi-squared = 5.6031, df = 3, p-value = 0.1326


I am wondering if I am making a mistake with using write.table (It works
very well saving results from anova analysis) or is there any other way to
save results in a file for future use..

Thanks
Himanshu
\\

[[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] Loop avoidance in simulating a vector

2008-10-16 Thread Ray Brownrigg
If you want to avoid using a loop, rather than coding a loop, then someting 
like:

DV - rnorm(sum(n))
DV - DV * rep(sigma, times=n) + rep(mu, times=n)

will achieve the same as the loop you specified, but generalised to 
non-constant n.

HTH
Ray Brownrigg

On Fri, 17 Oct 2008, Bert Gunter wrote:
 mapply is still a (disguised) loop (at the interpreted level). So other
 than improving code readability (always a good thing!), it shouldn't make
 much of an efficiency difference.

 A longer answer is: if all you're doing is a location-scale family of
 distributions, then creating a matrix of standard normal (or whatever)
 distributed data for all 1:N at once and then using matrix operations to
 multiply and add, say, so each column becomes your different distribution
 might be faster. This gets the loops down to C code.

 A shorter answer is: it's unlikely that any of this makes enough of a
 difference to be worth the effort. Random number generation is so efficient
 in R that avoiding loops rarely matters.

 Also see ?replicate for a way to perhaps write cleaner code (but still
 using hidden interpreted loops).

 -- Bert Gunter

 -Original Message-
 From: [EMAIL PROTECTED] [mailto:[EMAIL PROTECTED] On
 Behalf Of Christos Hatzis
 Sent: Thursday, October 16, 2008 1:06 PM
 To: 'David Afshartous'; r-help@r-project.org
 Subject: Re: [R] Loop avoidance in simulating a vector

 Have a look at mapply.

 -Christos

  -Original Message-
  From: [EMAIL PROTECTED]
  [mailto:[EMAIL PROTECTED] On Behalf Of David Afshartous
  Sent: Thursday, October 16, 2008 3:47 PM
  To: r-help@r-project.org
  Subject: [R] Loop avoidance in simulating a vector
 
 
 
  All,
 
  I'd like to simulate a vector that is formed from many
  distinct distributions and avoid a loop if possible.  E.g, consider:
 
  mu = c(1, 2, 3)
  sigma = c(1, 2, 3)
  n = c(10, 10, 10)
 
  And we simulate a vector of length 30 that consists of
  N(mu[i], sigma[i])
  distributed data, each of length n[i].   Of course for just
  three groups we
  can simply write it out as:
 
  DV = c(rnorm(n[1], mu[1], sigma[1]), rnorm(n[2], mu[2],
  sigma[2]), rnorm(n[3], mu[3], sigma[3]) )
 
  For many groups we can use a loop (assuming equal numbers per group):
 
  n = n[1]
  DV = numeric(N*n)
  for (i in 1:N) {
  DV[(n*i - (n-1)): (n*i)] = rnorm(n, mu[i], sigma[i])
  }
 
  Is there any way to do the general cas without using a loop?
 
  Cheers,
  David
 
  __
  R-help@r-project.org mailing list
  https://stat.ethz.ch/mailman/listinfo/r-help
  PLEASE do read the posting guide
  http://www.R-project.org/posting-guide.html
  and provide commented, minimal, self-contained, reproducible code.

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

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

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

2008-10-16 Thread Lavan


Dear R users,

I have two uniform random variables and I need to estimate the joint
density. I like to know whether 
there is any package which estimates bivariate uniform densities.

Thanks,

Lavan 
-- 
View this message in context: 
http://www.nabble.com/bivariate-uniform-density-estimation-tp20016805p20016805.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] Statistical courses

2008-10-16 Thread Erin Hodgess
XLSolutions-corp has 2 day training courses; one for beginners and one
for advanced.

Here is the website:

www.xlsolutions-corp.com

Hope this helps!
Sincerely,
Erin


On Thu, Oct 16, 2008 at 1:50 AM, timpanister [EMAIL PROTECTED] wrote:
 Hi,

 Can anyone suggest some short term statistical courses using R that one
 could take? Name or Links will be much appreciated.

 many thanks,

 j

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




-- 
Erin Hodgess
Associate Professor
Department of Computer and Mathematical Sciences
University of Houston - Downtown
mailto: [EMAIL PROTECTED]

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


Re: [R] gWidgets install

2008-10-16 Thread Michael Lawrence
On Tue, Oct 14, 2008 at 7:15 PM, john verzani [EMAIL PROTECTED] wrote:

 Tim Smith tim_smith_666 at yahoo.com writes:

 
  Thanks Charlie - I just tried it, but still get the same error:
 
  ---
   install.packages(gWidgets,dependencies=TRUE)

 ...

   library(gWidgets)
  Error in fun(...) :
 
  *** gWidgets requires a toolkit implementation to be
   installed, for instance gWidgetsRGtk2, gWidgetstcltk, or
 gWidgetsrJava***
 



 Try installing gWidgetstcltk. That will allow you to use gWidgets with the
 tcltk
 package. Although the RGtk2 package works better with gWidgets, the tcltk
 one
 will require no extra software to install under windows.


Perhaps the gWidgets package should prompt the user to install one of these?




 --John

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


[[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] stablefit can fit the parameters of a truncated normal distribution?

2008-10-16 Thread John C Frain
This idea is very wrong,  Have a look at the function cnormal1 in the
VGAM package

John frain

2008/10/15 drbn [EMAIL PROTECTED]:

 I'm using stableFit from the package fBasics to estimate the parameters of a
 truncated normal distribution (I'm interested in the parameters of the
 underlying normal distribution). It is correct to generalize this truncated
 normal distribution as a stable distribution ?

 Thanks

 David
 --
 View this message in context: 
 http://www.nabble.com/stablefit-can-fit-the-parameters-of-a-truncated-normal-distribution--tp20002335p20002335.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.




-- 
John C Frain
Trinity College Dublin
Dublin 2
Ireland
www.tcd.ie/Economics/staff/frainj/home.html
mailto:[EMAIL PROTECTED]
mailto:[EMAIL PROTECTED]

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


[R] Roman numeral question

2008-10-16 Thread Erin Hodgess
Hi R People!

Is there a setup for Roman numerals similar to that of LETTERS and
letters, please?

I was putting together a randomized block design and thought that it
might be nice for factors.

Thanks,
Erin


-- 
Erin Hodgess
Associate Professor
Department of Computer and Mathematical Sciences
University of Houston - Downtown
mailto: [EMAIL PROTECTED]

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


Re: [R] R: in-place appending to a matrix.

2008-10-16 Thread repkakala Gazeta.pl
On 10/16/2008 10:50 AM, culpritNr1 wrote:


 Now, modern high level languages like the continually improving R,



References:

 Becker, R. A., Chambers, J. M. and Wilks, A. R. (1988) _The New S
 Language_. Wadsworth  Brooks/Cole.


This is most important reference in many help pages in R.
Modern Language, haha.  Old crap, not a modern language.

\misiek

[[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: in-place appending to a matrix.

2008-10-16 Thread markleeds
 that's extremely rude , especially to all the people who made and make 
R what it is. If you don't like R, noone is forcing you to use it.




On Thu, Oct 16, 2008 at  5:50 PM, repkakala Gazeta.pl wrote:


On 10/16/2008 10:50 AM, culpritNr1 wrote:




Now, modern high level languages like the continually improving R,





References:

 Becker, R. A., Chambers, J. M. and Wilks, A. R. (1988) _The New S
 Language_. Wadsworth  Brooks/Cole.


This is most important reference in many help pages in R.
Modern Language, haha.  Old crap, not a modern language.

\misiek

[[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] MLE Constraints

2008-10-16 Thread LFRC

Dears,

Any help?

Thanks,
LFRC



LFRC wrote:
 
 Dears,
 
 I'm trying to find the parameters (a,b, ... l) that optimize the function
 (Model) 
 described below.
 
 1) How can I set some constraints with MLE2 function? I want to set p10,
 p20, 
 p30, p1p3. 
 
 2) The code is giving the following warning. 
 Warning: optimization did not converge (code 1)
 How can I solve this problem?
 
 Can someone help me?
 
 M - 14
 Y = c(0, 1, 0, 0, 0, 0, 1, 0, 0, 0, 0, 0, 0, 1)
 x1 = c(0.50, 0.50, 0.50, 0.50, 0.50, 0.50, 0.50, 0.50, 0.50, 0.50, 0.25, 
 0.25, 0.25, 0.25)
 x2 = c(-1, -1, -1, -1, -1,  1,  1,  1,  1,  1,  1,  1,  1,  1)
 x3 = c(0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0)
 states = c(1, 1, 2, 3, 1, 2, 3, 1, 1, 2, 2, 3, 1, 1)
 prob_fn = rep(0,M)
 
 Model=function(a, b, c, d, e, f, g, h, i, j, k, l)
 {
 p1 = exp(-(a   g*x1   d*x2   j*x3))
 p2 = exp(-(b   h*x1   e*x2   k*x3))
 p3 = exp(-(c   i*x1   f*x2   l*x3))
 
 ### Set P
 t5 = 0
 while(t5M)
 {
 t5 = t5 1
 
 if(states[t5]==1)  {prob_ok = p1[1]}
 if(states[t5]==2)  {prob_ok = p2[1]}
 if(states[t5]==3)  {prob_ok = p3[1]}
 prob_fn[t5] = c(prob_ok)
 }
 
 prob_fn[prob_fn==0] = 0.1
 
 ### LL
 ll_calc = -(sum(Y*log(prob_fn)))
 return(ll_calc)
 }
 
 res = mle2(Model, start=list(a=1, b=1, c=1, d=0.15, e=0.15,
 f=0.15, g=0.9, h=0.9, i=0.9, j=0.1, k=0.1, l=0.1), method = Nelder-
 Mead)
 res
 
 Best regards,
 LFRC
 
 

-- 
View this message in context: 
http://www.nabble.com/MLE-Constraints-tp19994553p20016631.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] Roman numeral question

2008-10-16 Thread Barry Rowlingson
2008/10/16 Erin Hodgess [EMAIL PROTECTED]:
 Hi R People!

 Is there a setup for Roman numerals similar to that of LETTERS and
 letters, please?

 I was putting together a randomized block design and thought that it
 might be nice for factors.

 Thanks,
 Erin


 as.roman() in utils:

  library(utils)
  as.roman(1:10)
 [1] III   III  IV   VVI   VII  VIII IX   X

Barry

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


[R] How to constrain the residual variance to be 0 in linear mixed-effects models?

2008-10-16 Thread Wen Luo
Hi everyone,
How to constrain the residual variance to be 0 when using the lmer
function?  

Wen Luo

Wen Luo, Ph.D.
Assistant Professor
Department of Educational Psychology
University of Wisconsin -- Milwaukee
Enderis Hall 759
P.O. Box 413
Milwaukee, WI 53201-0413
Office: 414 229 4998
Fax: 414 229 4939
[EMAIL PROTECTED]

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


Re: [R] R: in-place appending to a matrix.

2008-10-16 Thread repkakala Gazeta.pl
Rigth, sorry.  R is great for many usages even when it did not got
modernised as many realy modern languages did.
Appologies for developers, I were too rude.

\misiek


2008/10/16 [EMAIL PROTECTED]

  that's extremely rude , especially to all the people who made and make R 
 what it is. If you don't like R, noone is forcing you to use it.



 On Thu, Oct 16, 2008 at  5:50 PM, repkakala Gazeta.pl wrote:

 On 10/16/2008 10:50 AM, culpritNr1 wrote:


 Now, modern high level languages like the continually improving R,


 
 References:

 Becker, R. A., Chambers, J. M. and Wilks, A. R. (1988) _The New S
 Language_. Wadsworth  Brooks/Cole.
 

 This is most important reference in many help pages in R.
 Modern Language, haha.  Old crap, not a modern language.

 \misiek

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


  1   2   >