Re: [R] Is this my mistake or a bug?(K-S test and EVT)

2006-05-31 Thread Peter Ehlers

Mu Tian wrote:

 Hi,
 
 I was doing a Kolmogrov test on x, y shown below. They are both 151 long.
 According to the help file, exact p-value is not available so I set exact =
 FALSE, but still got the warning. There are no duplicated values in either
 X or Y.
 
But I'll wager that there are some Xs equal to Ys.

 Thank you for your tips.
 
 BTW, is there functions in R about Extreme value theory?
 
Packages evd and evir and perhaps others.

Peter Ehlers

 
 
 
ks.test(x, y, exact=FALSE)
 
 
 Two-sample Kolmogorov-Smirnov test
 
 data:  x and y
 D = 0.0199, p-value = 1
 alternative hypothesis: two.sided
 
 Warning message:
 cannot compute correct p-values with ties in: ks.test(x, y, exact = FALSE)
 
[snip]

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


Re: [R] a problem 'cor' function

2006-05-31 Thread Peter Ehlers
Looks like another case of the most F of all FAQs: FAQ 7.31.

See if the following makes sense to you:

  pl - iris[101:150, 3]
  all.equal(cor(pl,pl), 1)
  [1] TRUE
  cor(pl,pl) == 1
  [1] FALSE
  sprintf(%1.22g, cor(pl, pl))
  [1] 0.99989
  sprintf(%1.22g, pl)
  [1] 6  5.0996 5.9004
etc

Peter Ehlers

Tao Shi wrote:

 Hi list,
 
 One of my co-workers found this problem with 'cor' in his code and I confirm 
 it too (see below).  He's using R 2.2.1 under Win 2K and I'm using R 2.3.0 
 under Win XP.
 
 ===
 
R.Version()
 
 $platform
 [1] i386-pc-mingw32
 
 $arch
 [1] i386
 
 $os
 [1] mingw32
 
 $system
 [1] i386, mingw32
 
 $status
 [1] 
 
 $major
 [1] 2
 
 $minor
 [1] 3.0
 
 $year
 [1] 2006
 
 $month
 [1] 04
 
 $day
 [1] 24
 
 $`svn rev`
 [1] 37909
 
 $language
 [1] R
 
 $version.string
 [1] Version 2.3.0 (2006-04-24)
 
data(iris)
cor(iris[1:4])
 
  Sepal.Length Sepal.Width Petal.Length Petal.Width
 Sepal.Length   1. -0.1176   0.8718  0.8179
 Sepal.Width   -0.1176  1.  -0.4284 -0.3661
 Petal.Length   0.8718 -0.4284   1.  0.9629
 Petal.Width0.8179 -0.3661   0.9629  1.
 
cor(iris[1:4])==1
 
  Sepal.Length Sepal.Width Petal.Length Petal.Width
 Sepal.Length TRUE   FALSEFALSE   FALSE
 Sepal.Width FALSETRUEFALSE   FALSE
 Petal.LengthFALSE   FALSE TRUE   FALSE
 Petal.Width FALSE   FALSEFALSETRUE
 
cor(iris[1:4], iris[1:4])
 
  Sepal.Length Sepal.Width Petal.Length Petal.Width
 Sepal.Length   1. -0.1176   0.8718  0.8179
 Sepal.Width   -0.1176  1.  -0.4284 -0.3661
 Petal.Length   0.8718 -0.4284   1.  0.9629
 Petal.Width0.8179 -0.3661   0.9629  1.
 
cor(iris[1:4], iris[1:4])==1
 
  Sepal.Length Sepal.Width Petal.Length Petal.Width
 Sepal.Length TRUE   FALSEFALSE   FALSE
 Sepal.Width FALSETRUEFALSE   FALSE
 Petal.LengthFALSE   FALSEFALSE   FALSE
 Petal.Width FALSE   FALSEFALSETRUE
 ===
 
 The two ways of calculating correlation seem to generate the 'same' results, 
 but the second one doesn't appear to be numerically stable (see the 3rd 
 diagonal element of the last matrix).
 
 thanks,
 
 ...Tao 
 
 _
 Join the next generation of Hotmail and you could win the adventure of a 
 lifetime
 
 __
 R-help@stat.math.ethz.ch mailing list
 https://stat.ethz.ch/mailman/listinfo/r-help
 PLEASE do read the posting guide! http://www.R-project.org/posting-guide.html

-- 
Peter Ehlers
Chair, Division of Statistics and Actuarial Science
Department of Mathematics and Statistics
University of Calgary, 2500 University Dr. NW   ph: 403-220-3936
Calgary, Alberta  T2N 1N4, CANADA  fax: 403-282-5150
email: [EMAIL PROTECTED]

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


Re: [R] Vertical Line on Plot

2006-05-25 Thread Peter Ehlers

Barry Rowlingson wrote:
 Peter Lauren wrote:
 
I was wondering what would be the best way to put a
vertical line on a graph made with plot().  I can get
an horizontal line by plotting a vector where every
element has the same value but it is not as clear how
a vertical line should be done.

 
 
   abline(v=42)
 
 you can use it for horizontal lines too: abline(h=42) and several other 
 things. See help(abline) for details.
 
 Barry
 

I don't wish to discourage new R users from asking questions in
this forum, but this seems like a good time to remind new R users
of the existence of some _very_ useful documentation:

1. As has just recently been mentioned again by Berton Gunter
in his periodic reminder, there exists a nice, concise ref-card at
  http://www.rpad.org/Rpad/Rpad-refcard.pdf

This would have led to abline() almost immediately (page 3).

2. 'An Introduction to R' is installed with R. Again, it would
have quickly led to abline() (section 12.2).

The help pages are great when you know what function you need.
The above two documents (and others on CRAN) help one to discover
what function might be needed.

Peter Ehlers

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


Re: [R] missed ylim from plot.default

2006-05-25 Thread Peter Ehlers

Antonio, Fabio Di Narzo wrote:

 Hi all.
 On my R-2.3.0,  calling:
 
 
plot(1:5, rep(1,5), xlim=c(-0.5,7), ylim=c(-0.5,2.8), asp=1)
 
 
 gives to me a plot (tried pdf and X11) whose y axis goes from about -2 to
 about 4.5. What I've missed? How can I show some pre-specified x and y
 ranges from a plot (keeping fixed the aspect ratio)?
 
 Tnx all,
 Antonio, Fabio Di Narzo.
 
   [[alternative HTML version deleted]]

Do you want a wide, but not very tall plot? If so, you
could specify the width/height in your X11() call.

Peter Ehlers

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


Re: [R] How to use lm.predict to obtain fitted values?

2006-05-19 Thread Peter Ehlers


Larry Howe wrote:
 I have had a similar issue recently, and looking at the archives of this 
 list, 
 I see other cases of it as well. It took me a while to figure out that the 
 variable name in the data frame must be identical to the variable name in the 
 model. I don't see this mentioned in the documentation of predict.lm, and R 
 issues no warning in this case.
 
 How would I go about officially requesting that this is mentioned, either in 
 the documentation, or as a warning?
 
 Sincerely,
 Larry Howe
 
Here's what I would do before officially requesting anything: read
'An Introduction to R', especially section 11.3:

  predict(object, newdata=data.frame)
  The data frame supplied must have variables specified with the same
  labels as the original.

Seems pretty explicit.

As well, the predict.lm help page has, under Arguments:

  newdata   An optional data frame in which to look for variables with
which to predict.

That, too, seems unambiguous; i.e. you can't predict with values of z
when z is not in your formula.

Peter Ehlers


 On Friday May 19 2006 13:26, Prof Brian Ripley wrote:
 
data.frame(x=newData)  will not have any entries called x:  You supplied
newdata, so assuming you means newdata,


data.frame(x=newdata)

   x.1 x.2 x.3 x.4 x.5 x.6
1   1   1   1   1   1   1

has 6 columns none of which is labelled x.

If you read the help for lm, it does not mention having a matrix on the
rhs of a formula, and the help for data.frame does explain how it works.

predict(model, data.frame(x=I(newData)))

might work.

On Fri, 19 May 2006, Richard Lawn wrote:

I am writing a function to assess the out of sample predictive
capabilities of a time series regression model.  However lm.predict isn't
behaving as I expect it to.  What I am trying to do is give it a set of
explanatory variables and have it give me a single predicted value using
the lm fitted model.


model = lm(y~x)
newdata=matrix(1,1,6)
pred = predict.lm(model,data.frame(x=newData));

Warning message:
'newdata' had 6 rows but variable(s) found have 51 rows.


pred = predict.lm(model,data.frame(newData));

Warning message:
'newdata' had 6 rows but variable(s) found have 51 rows.

y is a vector of length 51.
x is a 6x51 matrix
newdata is a matrix of the explanatory variables I'd like a prediction
for.

The predict.lm function is giving me 51 (=number of observations I had)
numbers, rather than the one number I do want - the predicted value of y,
given the values of x I have supplied it.

Many thanks,
R


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


Re: [R] Can't there be a cd command?

2006-05-16 Thread Peter Ehlers
Rolf Turner wrote:

 Duncan Murdoch wrote (amongst other things):
 
 
Statistical computing is not easy, so how could R be?  Who has ever 
claimed it is?  Any package that makes statistical computing appear to 
be easy is probably giving you wrong answers half the time, or is 
extremely limited in scope.
 
 
   Well expressed, Duncan!  (A slam Dunc, one might say. :-) )
 
   cheers,
 
   Rolf
 

I agree - well said! The only thing Duncan missed is that the volume
is high partly because there are quite a few people who want to use R
without reading any documentation. But is it just my imagination or
is that type of post on the decrease?

Peter Ehlers

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


Re: [R] 3D pie

2006-04-19 Thread Peter Ehlers
This discussion of 3-d pie charts comes at an opportune time. I have
just formulated a new theory of graphical information transfer which
is particularly simple in the case of 3-d pie charts.

Let theta denote the angle between the normal to the pie cylinder and
the pie-eyed line (connecting eye and centre of pie). Then the
information transmitted from pie to viewer is

   K * (pi/2 - theta)^3

for theta in [0, pi/2]. The normalizing constant may be written in
the obvious manner as

   K = 8 * I_0 / pi^3.

I conjecture that I_0 is not large, but I'm still waiting to hear
from Microsoft regarding my application for funding to allow me to
conduct extensive testing.

I'm also working on higher-dimensional generalizations, but even
the 4-d case does not seem to be simple.

Peter Ehlers


Frank E Harrell Jr wrote:

 Rolf Turner wrote:
 
Gabor Grothendieck wrote:



Since everyone else wimped out with a tedious you-do-not-want-to-do-that,
here is a solution that uses R to control Excel and create a 3d chart.

.
.
.

People really ***should not*** be encouraged or abetted in
wrong-headedness.  Excel is terrible.  Pie charts are terrible.
Don't mess with them.  Period.


  cheers,

  Rolf Turner
  [EMAIL PROTECTED]
 
 
 I second that.  Helping people do things known to have major problems 
 with the approaches can actually hurt others in the long run.  2-D pie 
 charts are terrible.  That makes 3-D pie charts terrible to the 3/2 
 power.  Excel has serious errors and is not a good model for 
 reproducible research.

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


Re: [R] About poisson distribution fitting and testing

2006-04-19 Thread Peter Ehlers
Does fitdistr() in package MASS help?

  Peter Ehlers

Linda Lei wrote:

 Hi All,
 
  
 
 I have a sequence of positive integers, which is right skewed. The mean
 value is 6 and variance is 11. 
 
 I suspect it can be fitted by poisson distribution. But I'm not familiar
 with the function to fit distribution. 
 
 Could you please help me with it? Also, once I fit the poisson 
 
 distribution, how can I check the good-ness of this fitting?
 
  
 
 Thank you!
 
 
   [[alternative HTML version deleted]]
 
 __
 R-help@stat.math.ethz.ch mailing list
 https://stat.ethz.ch/mailman/listinfo/r-help
 PLEASE do read the posting guide! http://www.R-project.org/posting-guide.html

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


Re: [R] Unfound objects in function

2006-04-18 Thread Peter Ehlers
Colin,

Did you use correction = trans in Kinhom in the past? I think
Ki$trans will contain a number of NAs. Try

diff- sum (Ki$theo - Ki$trans, na.rm = TRUE)

Peter Ehlers

Colin Beale wrote:
 A couple of my functions that were working last week seem to have been
 changed over the weekend and no longer work, but I can't understand why
 not: it seems that objects defined at the start of the function are not
 located further on in the function, when this worked fine before. An
 example follows at the end, using the package spatstat, though the
 problem seems more general. My only guess is that I've accidentally
 changed something to do with the environment that functions are
 searching in to exclude themselves, but if so I've no idea how I did or
 how I can cancel it!
 
 Thanks in advance,
 
 Colin
 
 
 library (spatstat)
 
 kernelEst - function (data, max.r = 10, edge = TRUE) {
 
   if (!is.ppp (data)) stop (data must be a point process object)
 
   i - 0.1
   diff- 1
   smo - 1
 
   while (diff  0) {
 olddiff - diff
 oldsmo  - smo
 smo - density.ppp (data, sigma = 2 * i, edge = edge)
 lambda  - smo[data]
 Ki  - Kinhom (data[,data$window], lambda = lambda, r = seq (0,
 max.r, length = 100), correction = trans)
 diff- sum (Ki$theo - Ki$trans)
 i   - i + 0.1
 if (i  max.r) stop (no suitable kernel found within 0.2 to
 max.r)
   }
 
   if (abs (olddiff)  abs (diff)) return (smo) else return (oldsmo)
 }
 
 data (simdat)
 test - kernelEst (simdat)
 Error in while (diff  0) { : missing value where TRUE/FALSE needed
 
  
 
 
version
 
  _  
 platform i386-pc-mingw32
 arch i386   
 os   mingw32
 system   i386, mingw32  
 status  
 major2  
 minor2.1
 year 2005   
 month12 
 day  20 
 svn rev  36812  
 language R
 
 __
 R-help@stat.math.ethz.ch mailing list
 https://stat.ethz.ch/mailman/listinfo/r-help
 PLEASE do read the posting guide! http://www.R-project.org/posting-guide.html

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


Re: [R] installation of package randomForest failed

2006-04-18 Thread Peter Ehlers
Ruth,

Does your R know about the library
  C://Programme//R//rw2011//library//randomForest
?

I suspect that you want
  lib = C://Programme//R//rw2011//library
in your install.packages() call. Or you could just leave the 'lib='
argument at its default.

Peter Ehlers


Ruth Meili wrote:
 Hello
 
 I'd like to try out some functions in the package randomForest. Therefore, 
 I did install this package. However, it is not possible to load the 
 library, although I have R-Version 2.1.1 (i.e. later than 2.0.0). The 
 commands I used and the Answers/Error from R is as follows:
 
   
 install.packages(C://Programme//R//rw2011//library//randomForest_4.5-16.zip,
  
 lib=C://Programme//R//rw2011//library//randomForest,repos = NULL)
 package 'randomForest' successfully unpacked and MD5 sums checked
 updating HTML package descriptions
   library(randomForest)
 Fehler in library(randomForest) : 'randomForest' ist kein gültiges Paket -- 
 vor 2.0.0 installiert?
 
 I run in this problem for the first time. Until now, I used to install new 
 packages by copying the*.zip-file to the library-directory in the 
 rw2011-directory. This seam not to work anymore. So I tried using the 
 function install.package(), but I did not success.
 
 Does anybody know the Problem? I did not find any hints in the NEWS.
 Thanks anyway.
 Ruth
 
 
 
 
 
 
 **
 This footnote confirms that this email message has been swept by
 MIMEsweeper for the presence of computer viruses.
 
 www.clearswift.com
 
 __
 R-help@stat.math.ethz.ch mailing list
 https://stat.ethz.ch/mailman/listinfo/r-help
 PLEASE do read the posting guide! http://www.R-project.org/posting-guide.html

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


Re: [R] interaction terms in formula of lm or glm

2006-04-17 Thread Peter Ehlers
Luke,

A really useful thing to do would be to read section 11.1 of
An Introduction to R, which comes with your R installation.

Peter Ehlers

Luke wrote:
 Thanks, Christos. Another relevant question:
 
 If  I want to include the interaction term consisting of V2 and V3 (they are
 numeric vectors), should I use:
 
 y ~ 1 + V2:V3 or y ~ 1 + I(V2*V3)
 
 or both are good?
 
 -Luke
 
 On 4/17/06, Christos Hatzis [EMAIL PROTECTED] wrote:
 
If you want the quadratic term, you need to pass it as an argument in
function I():

y ~ 1 + V1 + V3 + I(V3^2)

This is documented in ?formula

-Christos

-Original Message-
From: [EMAIL PROTECTED]
[mailto:[EMAIL PROTECTED] On Behalf Of Luke
Sent: Monday, April 17, 2006 12:08 AM
To: R-help@stat.math.ethz.ch
Subject: [R] interaction terms in formula of lm or glm

I would like to include pairwise interaction terms for lm(). For example,
I
want to include the quadratic term of variable V3.


my.formula

y ~ 1 + V1 + V3 + V3:V3


my.data

   y V1 V2  V3
1 31  1 42 140
2 32  0 43 120
3 33  0 57 150
4 34  0 55 132


foo - lm(my.formula, data = my.data)

foo$coefficients

(Intercept)  V1  V3
29.47368421 -2.15789474  0.02631579

Why do the foo coefficients not include V3:V3 ?

I thought that the variable V3:V3 has the values of squares of V3
elements, that is,
V3:V3
140*140
120*120

Am I wrong?

If I specify a fouth varaible V4 with square values of V3, and the
formula
is y ~ 1 + V1 + V3 + V4, it seems that the foo will give me different in
and
out-sample predictions.

-Luke

[[alternative HTML version deleted]]

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



 
 
   [[alternative HTML version deleted]]
 
 __
 R-help@stat.math.ethz.ch mailing list
 https://stat.ethz.ch/mailman/listinfo/r-help
 PLEASE do read the posting guide! http://www.R-project.org/posting-guide.html

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


Re: [R] subset a matrix

2006-04-12 Thread Peter Ehlers
Assuming that you want odd-numbered rows/cols, the
seq() function is handy, as in:

mat - matrix(1:(20*30), nr = 20)
mat1 - mat[seq(1, 19, by = 2), seq(1, 29, by = 2)]

Peter Ehlers

zhijie zhang wrote:

 Dear friends,
  I have a (20*30) matrix,and want to get a subset of it like the following:
 The original matrix: rows:1,2,3,20; columns:1,2,3,30
 I want to get my subset of The original matrix and delete others:
rows:1,3,5,7,...19;   columns:1,3,5.29
 
 
 --
 Kind Regards,Zhi Jie,Zhang ,PHDDepartment of EpidemiologySchool of Public
 HealthFudan UniversityTel:86-21-54237149
 
   [[alternative HTML version deleted]]
 
 __
 R-help@stat.math.ethz.ch mailing list
 https://stat.ethz.ch/mailman/listinfo/r-help
 PLEASE do read the posting guide! http://www.R-project.org/posting-guide.html

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


Re: [R] TukeyHSDs function (pgirmess package)

2006-04-10 Thread Peter Ehlers
Rune Vejen Petersen wrote:

 Dear R-help,
  
 I have been trying to use the TukeyHSDs function in the pgirmess
 package to quickly extract all
 significant pairwise comparisons in an aov object. However, it seems
 that this function isn't working
 as intended when only the two last populations means being tested are
 significant.
  
 An example of this can be seen below:
  
 
numbers-c(464,482,453,434,495,487) 
group-gl(3,2,label=c(A,B,C))
testobject-aov(numbers~group)
result-TukeyHSD(testobject,conf.level=0.95)
error-TukeyHSDs(result)
error$group[,1]
 
 Error in error$group[, 1] : incorrect number of dimensions
  
 To illustrate the normal function, the data set below can be used.
  
 
numbers-c(845,829,682, 689,581,495)
 
  
 Is there something wrong with this function? Or is there a better way
 to extract significant comparisons
 from a tukey test?

It looks like the line

   res[[1]] - x[y, ]

in TukeyHSDs() should be replaced with

   res[[1]] - x[y, , drop = FALSE]


Peter Ehlers

  
 Cheers,
 Rune
 ---
 Rune Vejen Petersen, M.Sc.Eng.
 Statens Serum Institute
 Dept. of Infectious Disease Immunology
 Artillerivej 5, 81/344
 DK-2300 Copenhagen
 
   [[alternative HTML version deleted]]
 
 __
 R-help@stat.math.ethz.ch mailing list
 https://stat.ethz.ch/mailman/listinfo/r-help
 PLEASE do read the posting guide! http://www.R-project.org/posting-guide.html

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


Re: [R] a statistics question

2006-04-07 Thread Peter Ehlers
It sounds as though 'logic regression' might help. See

Ruczinski I, Kooperberg C, LeBlanc ML (2003). Logic Regression,
Journal of Computational and Graphical Statistics, 12, 475-511.

and the LogicReg package.

Peter Ehlers

Weiwei Shi wrote:

 Hi there,
 I have a statistics question on a classification problem:
 
 Suppose I have 1000 binary variables and one binary dependent variable. I
 want to find a way similar to PCA, in which I can find a couple of
 combinations of those variables to discriminate best according to the
 dependent variable. It is not only for dimension reduction, but more
 important, for finding best way to construct features. This is NOT CDA since
 the explanatory variables are NOT continuous. I knew the existence of that
 method since I consulted before with a professor but I forgot the name of
 the method.. sigh...
 
 I am also wondering if R has already some function or package addressing
 this kind of problem.
 
 Thanks
 
 --
 Weiwei Shi, Ph.D
 
 Did you always know?
 No, I did not. But I believed...
 ---Matrix III
 
   [[alternative HTML version deleted]]
 
 __
 R-help@stat.math.ethz.ch mailing list
 https://stat.ethz.ch/mailman/listinfo/r-help
 PLEASE do read the posting guide! http://www.R-project.org/posting-guide.html

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


Re: [R] how to run stepAIC starting with NULL model?

2006-04-07 Thread Peter Ehlers

Joshua B Robins wrote:

 Hello,
 
 I'm trying to figure out how to run the stepAIC function starting with the
 NULL model.  I can call the null model (e.g., lm(y ~ NULL)), but using
 this object in stepAIC doesn't seem to work.
 
I don't know what doesn't seem to work means here, but your null
model is equivalent to lm(y ~ 1) and stepAIC handles both just fine
for me. Did you specify 'scope' with an 'upper' component?

Peter Ehlers


 The objective is to calculate AICc.  This can be done if stepAIC can be
 run starting with the NULL model; the (2p(p-1)/(n-p-1))to get AICc would
 be added to the final step AIC value. Can anyone suggest how to run
 stepAIC beginning with the NULL model, and sequentially adding and
 removing variables (essentially a bottom-up approach)?
 
 Thanks,
 
 Josh Robins
 School of Fisheries and Ocean Sciences
 University of Alaska Fairbanks
 Juneau Center
 (206) 331-8633
 [EMAIL PROTECTED]
 http://students.washington.edu/jbrobins
 
 __
 R-help@stat.math.ethz.ch mailing list
 https://stat.ethz.ch/mailman/listinfo/r-help
 PLEASE do read the posting guide! http://www.R-project.org/posting-guide.html

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


Re: [R] Correlation of coefficients?

2006-04-05 Thread Peter Ehlers
If you're talking about regression models, then I'm puzzled that
this occurs frequently in R, since the summary.lm() function
defaults to 'correlation = FALSE'. S-PLUS defaults to TRUE.
Can you give an example where R gives you the correlations of
coefficients?

Anyway, parameter estimators are correlated random variables and,
in the case of regression, summary(model, correlation = TRUE) gives
the estimated correlation matrix. This must be somewhere in MASS,
the book; any decent linear models text should will have a
discussion, e.g. Draper and Smith, Applied Regression Analysis.

Peter Ehlers

asako Ishii wrote:

 Hi R users!
 
 One thing I cannot understand with R is the frequently appearing 
 Correlation of coefficients. I do not find a through going explanation
 of this concept either on the help pages of R or on the internet. A
 Google search has shown many examples of R/S-Plus outputs but no
 explanations of meaning.
 
 I am afraid this turns out to be a silly and unworthy question. Would
 anyone be kind enough to show relevant literature or a text book to a
 layperson studying on his/her own? 
 
 Thanks in advance.


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


Re: [R] S-PLUS 8 beta program [repost]

2006-03-31 Thread Peter Ehlers
I have to come to the defence of Insightful here. In my
experience, they have been one of the better software companies
I've dealt with. (Try getting Microsoft to fix something.)
I think that their new packages initiative is an excellent idea.

Peter Ehlers

eugene dalt wrote:

 In addition, I think people should always explore ways
 to repackage exclusive S-Plus facilities and libraries
 into R. By rewritting them or using GPL loopholes. 
 
 It seems to me that Insightful is very good at
 protecting whatever they create and the same time
 feels very comfortable taking R stuff to keep they
 clients happy. In essence they are selling free stuff.
 
 
 --- Spencer Graves [EMAIL PROTECTED] wrote:
 
 
Correct:  I'm not an attorney, but I've read the
GPL.  It clearly 
says that if you have software that has
functionality independent of GPL 
code, the GPL applies to the code you use to connect
to GPL code not to 
your original code.  Thus, Insightful would have to
make publicly 
available anything special they do to link to GPL
code that they can't 
reasonably claim works for other purposes.  However,
they are not 
required to reveal other parts of their source code.

hope this helps,
spencer graves

Philippe Grosjean wrote:


David Smith wrote:


The GPL code is available as separately-downloaded

packages for S-PLUS, as

has been done for many years. My own Oswald

library for S-PLUS was published

under the GPL in 1997, for example, and many other

authors produce

open-source libraries for S-PLUS under a variety

of licenses.  The only

difference is that they will be packaged as, well,

packages rather than

libraries.

# David Smith


Thank you for the explanation. The fact that GPL

code is distributed 

*separately* from S-PLUS is the key point here.

PhG

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

http://www.R-project.org/posting-guide.html

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

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

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


Re: [R] calcualtign a trailing 12 column mean in a dataframe?

2006-03-29 Thread Peter Ehlers
While we wait for others to provide the best way, here's
one way (if I understand your question correctly):

numrows - 10
x - rnorm(25 * numrows)
dat - as.data.frame(matrix(x, nc = 25))
newdat - as.data.frame(matrix(0, nr = numrows, nc = 14))
for(j in 1:14) newdat[, j] - rowMeans(dat[, j:(j + 11)], na.rm = TRUE)

Peter Ehlers

r user wrote:

 I have a dataframe of 25 columns and 100,000 rows
 called “testdf”.
 
 I wish to build a new dataframe, with 14 columns and
 100,000 rows.
 
 I wish the new dataframe to have the “trailing 12
 column” mean.  That is, I want column 1 of the new
 dataframe to have soemthing like:
 
 “( mean(testdf[,1:12],na.rm=T)”
 
 What is the best way to accomplish this?
 
 __
 R-help@stat.math.ethz.ch mailing list
 https://stat.ethz.ch/mailman/listinfo/r-help
 PLEASE do read the posting guide! http://www.R-project.org/posting-guide.html

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


Re: [R] Welch test for equality of variance

2006-03-28 Thread Peter Ehlers
Peter,

I don't know the Welch test for variances, but you might consider
using the Fligner-Killeen test (fligner.test) or one of the
Levene test variations (package:car). A useful reference is

WJ Conover, ME Johnson, MM Johnson. 1981. Technometrics 23:351

with a minor correction in Technometrics 26:302.

Peter Ehlers


Peter Flom wrote:

 Hello
 
 Using R 2.2.1 on a Windows machine.
 
 Has anyone programmed the Welch test for equality of variances?
 
 I tried RSiteSearch, but this gave references to t test and
 oneway.test, which are not quite what I need.I need the Welch test
 itself, for use in a meta-analysis (to determine if variances are
 equal).
 
 
 TIA
 
 Peter
 
 
 
 Peter L. Flom, PhD
 Assistant Director, Statistics and Data Analysis Core
 Center for Drug Use and HIV Research
 National Development and Research Institutes
 71 W. 23rd St
 http://cduhr.ndri.org
 www.peterflom.com
 New York, NY 10010
 (212) 845-4485 (voice)
 (917) 438-0894 (fax)
 
 __
 R-help@stat.math.ethz.ch mailing list
 https://stat.ethz.ch/mailman/listinfo/r-help
 PLEASE do read the posting guide! http://www.R-project.org/posting-guide.html

-- 
Department of Mathematics and Statistics
University of Calgary, 2500 University Dr. NW   ph: 403-220-3936
Calgary, Alberta  T2N 1N4, CANADA  fax: 403-282-5150

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


Re: [R] install local packages

2006-03-23 Thread Peter Ehlers
Where did you get mclust.zip? CRAN shows mclust_2.1-11.zip.
Why not just let R install mclust directly from the CRAN mirror
at SFU? Use the menu: Packages  Install package(s).

As to your install.packages(), you need forward slashes,
contriburl=, and you probably want a different destdir (or
just leave the default NULL).

Peter Ehlers

[EMAIL PROTECTED] wrote:
 Hello all,
 
 I'm trying to install the local package under window system. Two ways I've
 tried:
 
 1. using the menupackages install package(s) from local zip files 
 
My .zip file is mclust.zip. But it shows Errors which are:
   
Error in gzfile(file,r): unable to open connection 
 In addition: Warning messages:
 1.error -1 in extracting from zip file
 2.cannot open compressed file 'mclust/DESCRIPTION'
 
 2. using function install.packages.
 
the command I use is 
 
install.packages(mclust.zip,D:\sfu\BC project\clustering project\stuff
from Jeffrey\flowCytometryClustering,repos=NULL,destdir=C:\Program 
Files\R\rw2011\library)
   
But error is object mclust.zip not found.
 
 Could you please help me how I can install the local packages?
 
 Thanks a lot!
 
 __
 R-help@stat.math.ethz.ch mailing list
 https://stat.ethz.ch/mailman/listinfo/r-help
 PLEASE do read the posting guide! http://www.R-project.org/posting-guide.html

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


Re: [R] RGui: windows-record and command history

2006-03-23 Thread Peter Ehlers

Duncan Murdoch wrote:
 On 3/23/2006 7:35 AM, Thomas Steiner wrote:
 
a) How can I set the recording of all windows()-history forever to
true? I want something like windows(record = TRUE) but not just for
the window that opens then, but for all windows I will open ever.
 
 
 options(graphics.record=TRUE)
 
 will make that happen for the rest of the session.  To really make it 
 happen forever, you need to put this line in your Rprofile (see 
 ?Rprofile for where that comes from).
 
 Watch out though:  the graphics history is stored in your current 
 workspace in memory, and it can get big.  You might find you're running 
 out of memory if you store everything, and you'll find your .RData files 
 quite large if you save your workspace.
 
 On my todo list (but not for 2.3.0) is the possibility of setting a 
 default history length, perhaps defaulting to saving the last 2 or 3 
 pages.
[snip]

Duncan,

This may be asking too much, but would it be possible to consider
implementing selective graph removal from the graph history?
I use graph.record=TRUE frequently for comparing graphs, but often
find that I'd like to kill one of the graphs while keeping others
in memory.

Peter Ehlers

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


Re: [R] RGui: windows-record and command history

2006-03-23 Thread Peter Ehlers


Paul Murrell wrote:

 Hi
 
 
 Duncan Murdoch wrote:
 
On 3/23/2006 10:46 AM, Gabor Grothendieck wrote:


On 3/23/06, Duncan Murdoch [EMAIL PROTECTED] wrote:


On 3/23/2006 10:29 AM, Gabor Grothendieck wrote:


On 3/23/06, Duncan Murdoch [EMAIL PROTECTED] wrote:


On 3/23/2006 7:35 AM, Thomas Steiner wrote:


a) How can I set the recording of all windows()-history forever to
true? I want something like windows(record = TRUE) but not just for
the window that opens then, but for all windows I will open ever.

options(graphics.record=TRUE)

will make that happen for the rest of the session.  To really make it
happen forever, you need to put this line in your Rprofile (see
?Rprofile for where that comes from).

Watch out though:  the graphics history is stored in your current
workspace in memory, and it can get big.  You might find you're running
out of memory if you store everything, and you'll find your .RData files
quite large if you save your workspace.

On my todo list (but not for 2.3.0) is the possibility of setting a
default history length, perhaps defaulting to saving the last 2 or 3
pages.

Would it be feasible to have history on disk or perhaps the last
m in memory and the last n (possibly Inf) on disk?

The history is just another R object.  Saving big R objects on disk
might be desirable, but it would be a big change, so I'd call it
infeasible.  I wouldn't want to get into special-casing this particular
R object:  that way lies madness.

However, since it is just an R object, it's available for R code to work
with, so someone who was interested in doing this could write a
contributed package that did it.

Are there R-level facilities to manipulate the history, not
just the top?


Sure, it's a regular R object. You will need to read the source to know 
how to interpret it, and since it's undocumented there's a risk of 
changes in future R versions, but it's not very complicated.  See my 
message to Peter.
 
 
 
 Be careful with this.  The objects that are recorded on the display list 
 are calls to graphics functions PLUS state information in a raw binary 
 format.  The display list was originally intended for reuse within the 
 same R session (for redrawing the screen).  If you try to save it and 
 use it between sessions or (worse) between versions of R you could run 
 into some nasty problems.  For example, what if the graphics function 
 interface has changed?  what if the raw binary state information format 
 has changed?  what if the required packages are not installed?   At 
 best, your saved object produces errors;  at worst it becomes completely 
 useless and is unrecoverable.
 
 Paul

Paul,
If I read your comments correctly, the problem with manipulating the
graph history is with saved histories across sessions/versions. Is
there any reason not to manipulate it *within* a session? I never
save plots for re-use in R. Re-running code is usually best for me.
But I would find it handy to fiddle with the display list in a
session.

Peter Ehlers

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


Re: [R] RGui: windows-record and command history

2006-03-23 Thread Peter Ehlers
Thanks, Paul, that's useful information.

Peter

Paul Murrell wrote:
 Hi
 
 
 Peter Ehlers wrote:
 

Paul Murrell wrote:


Hi


Duncan Murdoch wrote:


On 3/23/2006 10:46 AM, Gabor Grothendieck wrote:



On 3/23/06, Duncan Murdoch [EMAIL PROTECTED] wrote:



On 3/23/2006 10:29 AM, Gabor Grothendieck wrote:



On 3/23/06, Duncan Murdoch [EMAIL PROTECTED] wrote:



On 3/23/2006 7:35 AM, Thomas Steiner wrote:



a) How can I set the recording of all windows()-history forever to
true? I want something like windows(record = TRUE) but not 
just for
the window that opens then, but for all windows I will open ever.


options(graphics.record=TRUE)

will make that happen for the rest of the session.  To really 
make it
happen forever, you need to put this line in your Rprofile (see
?Rprofile for where that comes from).

Watch out though:  the graphics history is stored in your current
workspace in memory, and it can get big.  You might find you're 
running
out of memory if you store everything, and you'll find your 
.RData files
quite large if you save your workspace.

On my todo list (but not for 2.3.0) is the possibility of setting a
default history length, perhaps defaulting to saving the last 2 or 3
pages.


Would it be feasible to have history on disk or perhaps the last
m in memory and the last n (possibly Inf) on disk?


The history is just another R object.  Saving big R objects on disk
might be desirable, but it would be a big change, so I'd call it
infeasible.  I wouldn't want to get into special-casing this 
particular
R object:  that way lies madness.

However, since it is just an R object, it's available for R code to 
work
with, so someone who was interested in doing this could write a
contributed package that did it.


Are there R-level facilities to manipulate the history, not
just the top?



Sure, it's a regular R object. You will need to read the source to 
know how to interpret it, and since it's undocumented there's a risk 
of changes in future R versions, but it's not very complicated.  See 
my message to Peter.




Be careful with this.  The objects that are recorded on the display 
list are calls to graphics functions PLUS state information in a raw 
binary format.  The display list was originally intended for reuse 
within the same R session (for redrawing the screen).  If you try to 
save it and use it between sessions or (worse) between versions of R 
you could run into some nasty problems.  For example, what if the 
graphics function interface has changed?  what if the raw binary state 
information format has changed?  what if the required packages are not 
installed?   At best, your saved object produces errors;  at worst it 
becomes completely useless and is unrecoverable.

Paul


Paul,
If I read your comments correctly, the problem with manipulating the
graph history is with saved histories across sessions/versions. Is
there any reason not to manipulate it *within* a session? I never
save plots for re-use in R. Re-running code is usually best for me.
But I would find it handy to fiddle with the display list in a
session.
 
 
 
 That is *one* problem with the display list.  Messing directly with the 
 display list *within a session* is *less* dangerous, but R's behaviour 
 if you do that is undefined.
 
 The display list is technically an internal structure for R's internal 
 use.  We can't stop you playing with it, but I do not encourage it and 
 it is not officially supported.
 
 There are a number of simple things that you could do to the display 
 list that should work, but providing proper support for general 
 manipulations of the display list would require a significant amount of 
 (re)design of the R graphics code.
 
 Paul
 
 p.s.  These comments apply to the display list in R's graphics engine. 
   The 'grid' package also maintains a display list, and that has been 
 designed to support more general manipulations.

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