[R] calling r, from SAS, batch mode

2005-04-13 Thread Y Y
I generally work in SAS but have some graphics features I would like to
run in r.   I would like to do this 'automatically' from SAS.

I'm thinking of  something along the lines of putting the r code in a text
file and calling system of x on it;  r would expect the data in a certain place,
and my SAS would drop the data in the right place/filename before invoking
r.

x 'r.exe myfile.r';

Does anybody have any experience using r from within SAS like this
or in a better way ?

Alas, searching for a one word character r to find an archived answer
is not easy SAS-L.


S.
[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] off-topic question: Latex and R in industries

2005-04-13 Thread Itay Furman
On Fri, 8 Apr 2005, Donald Ingram wrote:
Date: Fri, 8 Apr 2005 00:12:47 +0100
From: Donald Ingram <[EMAIL PROTECTED]>
To: r-help@stat.math.ethz.ch
Subject: Re: [R] off-topic question: Latex and R in industries
Hi Bert and Jonathan,
When I want a quality report - I write it with pdfLaTeX ( TexShop or
TeXnicCenter)  with postscript generated diagrams and R plots as pdf's
- ( so I can use PC / UNIX / OS X inter-changeably with no problems )
The quality and readability of the pdf document is liked but, and it's
a big but is .
When someone else in the team needs to extract quality vector graphics
from the report, I have to give it to them in powerpoint or word
document , which means running R again on a PC  to get WMF's.  Not
impossible just extra work. ( Is there a universal vector format I
could use ? )
I think that SVG is the answer, but it is still a moving target.
http://www.w3.org/Graphics/SVG/
Otherwise, it's PDF.

However, and this is probably off topic-R, when I use drawings /
schematics  in native postscript  from  a Unix box, using them is fine
in LaTeX, but they can't be pasted into MS applications without first
rasterizing.  The other option I tried  - Ghostview  seems to mess up
line angles and fonts in attempting  conversion into WMF.  ( If anyone
knows a way to avoid this, I will be forever grateful )
The TexLive distribution (search www.ctan.org) has dvipdfm, as 
well as epstopdf -- another conversion tool.

Itay

[EMAIL PROTECTED]  /  +1 (206) 543 9040  /  U of Washington
__
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] Wrapping long labels in barplot(2)

2005-04-13 Thread Mulholland, Tom
This may not be the best way but in the past I think I have done something like

levels(x) <- paste(strwrap(levels(x),20,prefix = ""),collapse = "\n")

Tom

> -Original Message-
> From: Jan P. Smit [mailto:[EMAIL PROTECTED]
> Sent: Thursday, 14 April 2005 11:48 AM
> To: r-help@stat.math.ethz.ch
> Subject: [R] Wrapping long labels in barplot(2)
> 
> 
> I am using barplot, and barplot2 in the gregmisc bundle, in the 
> following way:
> 
> barplot2(sort(xtabs(expend / 1000 ~ theme)),
>  col = c(mdg7, mdg8, mdg3, mdg1), horiz = T, las = 1,
>  xlab = "$ '000", plot.grid = T)
> 
> The problem is that the values of 'theme', which is a factor, are in 
> some cases rather long, so that I would like to wrap/split them at a 
> space once they exceed, say, 20 characters. What I'm doing now is 
> specifying names.arg manually with '\n' where I want the 
> breaks, but I 
> would like to automate the process.
> 
> I've looked for a solution using 'strwrap', but am not sure 
> how to apply 
> it in this situation.
> 
> Jan Smit
> 
> Consultant
> Economic and Social Commission for Asia and the Pacific
> 
> __
> 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] how to estimatae in single index models

2005-04-13 Thread r90323036
Hello everyone, Recently, I have encountered a problem about estimation 
of binary response model,as I try to estimate the survival probability 
of firms. I do not want to use the traditional binary respose models, 
such as Probit model or Logit model, since they are too restricted in 
their function form. Therefore, I seek to adopt some semiparametric 
methods, precisely estimation methods of single-index models, such as 
Klein-Spady estimator, Ichimura's SLS estimator, maximum score 
estimator,and smoothed maximum score estimator.

Hence, my question is:
Is there any package in R which can operate above estimation methods? I 
have search them for a long time. If anyone can help me, you really 
give me a huge hand! :)


Best regards
Kuo, Chun-Hung
__
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] Wrapping long labels in barplot(2)

2005-04-13 Thread Jan P. Smit
I am using barplot, and barplot2 in the gregmisc bundle, in the 
following way:

barplot2(sort(xtabs(expend / 1000 ~ theme)),
col = c(mdg7, mdg8, mdg3, mdg1), horiz = T, las = 1,
xlab = "$ '000", plot.grid = T)
The problem is that the values of 'theme', which is a factor, are in 
some cases rather long, so that I would like to wrap/split them at a 
space once they exceed, say, 20 characters. What I'm doing now is 
specifying names.arg manually with '\n' where I want the breaks, but I 
would like to automate the process.

I've looked for a solution using 'strwrap', but am not sure how to apply 
it in this situation.

Jan Smit
Consultant
Economic and Social Commission for Asia and the Pacific
__
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] Getting the row/column of matrix for some values?

2005-04-13 Thread Rajarshi Guha
On Wed, 2005-04-13 at 21:09 -0500, Chris Bergstresser wrote:
> Hi all --
> 
> Quick (I hope) question: I've got a correlation matrix.  Is there a 
> quick way to find all the row/column names for those correlations higher 
> than some value, like 0.4?

> x <- matrix(runif(50), nrow=10)
> which(cor(x) > .4, arr.ind=TRUE)

---
Rajarshi Guha <[EMAIL PROTECTED]> 
GPG Fingerprint: 0CCA 8EE2 2EEB 25E2 AB04 06F7 1BB9 E634 9B87 56EE
---
Q: What do you get when you cross a Post Modernist with a Mafioso?
A: An offer you can't understand.

__
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] Getting the row/column of matrix for some values?

2005-04-13 Thread Marc Schwartz
On Wed, 2005-04-13 at 21:09 -0500, Chris Bergstresser wrote:
> Hi all --
> 
> Quick (I hope) question: I've got a correlation matrix.  Is there a 
> quick way to find all the row/column names for those correlations higher 
> than some value, like 0.4?

> mat <- cor(matrix(rnorm(100), ncol = 5))

> mat
[,1][,2][,3][,4][,5]
[1,]  1.  0.08406738 -0.18412634 -0.15484250  0.18975606
[2,]  0.08406738  1.  0.06242012  0.44583819 -0.03338074
[3,] -0.18412634  0.06242012  1.  0.01045560  0.16876206
[4,] -0.15484250  0.44583819  0.01045560  1.  0.26283234
[5,]  0.18975606 -0.03338074  0.16876206  0.26283234  1.

# Get row/col positions
> which(mat > 0.4, arr.ind = TRUE)
 row col
[1,]   1   1
[2,]   2   2
[3,]   4   2
[4,]   3   3
[5,]   2   4
[6,]   4   4
[7,]   5   5

# Get the actual values
> mat[which(mat > 0.4, arr.ind = TRUE)]
[1] 1.000 1.000 0.4458382 1.000 0.4458382 1.000
[7] 1.000

See ?which for more information.

HTH,

Marc Schwartz

__
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] Getting the row/column of matrix for some values?

2005-04-13 Thread Chris Bergstresser
Hi all --
   Quick (I hope) question: I've got a correlation matrix.  Is there a 
quick way to find all the row/column names for those correlations higher 
than some value, like 0.4?

-- Chris
__
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] Normalization and missing values

2005-04-13 Thread Chris Bergstresser
   I'd just like to thank everyone who wrote in in response to my 
questions -- it's been greatly helpful, and appreciated.

Jonathan Baron wrote:
On 04/13/05 11:36, Chris Bergstresser wrote:
 First, I didn't see a function in R which does normalization -- did
 I miss it?  What's the best way to do it?
Look at scale().  Might be what you mean.
   Yeah; I should have remembered that.  I did search the help files 
for "normalization" and "normalize" but that isn't in the help files. 
Somewhat oddly, I think, since it's exactly what "scale" is doing.

 But, in general, the "right" way
to deal with missing data depends on the assumptions you make.
As a novice, I found the following article to be helpful:
Schafer, J. L., & Graham, J. W. (2002). Missing data: Our view of 
the state of the art. Psychological Methods, 7, 147-177.
   This article is great; thanks for providing it.  The authors 
recommend either using "ML Estimation" or "Multiple Imputation" to fill 
in the missing data.  They don't talk much about which is better for 
certain situations, however.
   I don't think my data are particularly sensitive to the method I use 
-- I've got about 1,100 cases, with 85 variables, and there are only 
about 1,000 missing values overall, spread pretty evenly across the data 
file.
   Are there any recommendations for specific packages?  "transcan()" 
and "aregImpute()" look promising; based on the documentation (and what 
I can understand from it) I'm assuming they both provide Multiple 
Imputation?

-- Chris
__
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] question about "R get vector from C"

2005-04-13 Thread Michael S
Dear ALL-R helpers,
I want to let R get vector from c ,for example :numeric array ,vector .I saw 
some exmple like this :
/* useCall3.c*/
/* Getting an integer vector from C using .Call  */
#include 
#include 

SEXP setInt() {
  SEXP myint;
  int *p_myint;
  int len = 5;
  PROTECT(myint = NEW_INTEGER(len));  // Allocating storage space
  p_myint = INTEGER_POINTER(myint);
  p_myint[0] = 7;
  UNPROTECT(1);
  return myint;
}
then type at the command prompt:
R CMD SHLIB useCall3.c
to get useCall3.so
In windows platform ,how can I create right dll to let dyn.load use
and for .c ,.call ,external ,what are the differece? which one is better for 
 getting vector from C?

thanks in advance
Michael
__
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] terminate R program when trying to access out-of-bounds array element?

2005-04-13 Thread Gabor Grothendieck
On 4/13/05, Vivek Rao <[EMAIL PROTECTED]> wrote:
> I want R to stop running a script (after printing an
> error message) when an array subscript larger than the
> length of the array is used, for example
> 
> x = c(1)
> print(x[2])
> 
> rather than printing NA, since trying to access such
> an element may indicate an error in my program. Is
> there a way to get this behavior in R? Explicit
> testing with the is.na() function everywhere does not
> seem like a good solution. Thanks.

If you can restrict yourself to arrays of dimension > 1 e.g.

> x <- matrix(1)
> print(x[1,2])
Error in print(x[1, 2]) : subscript out of bounds

then R already does that.

__
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] data manipulation

2005-04-13 Thread Marc Schwartz
On Wed, 2005-04-13 at 20:56 -0400, Yoko Nakajima wrote:
> Hello,
> my question is about the data handling.
> 
> I have a data set that is lined as:
> 
> 4 1 17 1 1
>  -5.1536 -0.1668 -2.3412 -0.5062  0.9621  0.3640  0.3678 -0.5081
> -0.2227
>   0.8142 -0.0389 -0.0445 -0.0578 -0.1175 -0.1232  0.8673 -0.1033
> -0.0796
>  -0.0341 -0.1716 -0.1801 -0.7014  0.6578  0.5611
> 4 1 17 2 1
>  -5.1536 -0.1668 -2.3412 -0.5062  0.9621  0.3640  0.3678 -0.5081
> -0.2227
>   0.8142 -0.0389 -0.0445 -0.0578 -0.1175 -0.1232  0.8673 -0.1033
> -0.0796
>  -0.0341 -0.1716 -0.1801 -0.7014  0.6578  0.5611
> 
> This means that 29 variables are together as a set. You saw two sets
> of them in example. I have about 1000 sets (of 29 variables) in my
> data. When I "scan" this data set, the result comes with 7 columns and
> it is not possible, so far, to read the table by column wise, and thus
> it is not possible to analyze the data. I would like to know whether
> there is a way to solve this problem, say, by arranging columns or
> increasing the number of columns of data matrix by R.
> 
> Also, I would like to know how you could name each column of the data
> so that you could use the individual column separately.

You probably change some default setting in scan(). By default it treats
'white space' as field delimiters.

Using your data above, which I save in file called 'test.dat':

> mat <- matrix(scan("test.dat"), ncol = 29)
Read 58 items

> dim(mat)
[1]  2 29

> colnames(mat) <- paste("Col", 1:29, sep = "")

> mat
 Col1 Col2Col3Col4Col5   Col6Col7Col8Col9
[1,]4   17  1. -0.1668 -0.5062 0.3640 -0.5081  0.8142 -0.0445
[2,]11 -5.1536 -2.3412  0.9621 0.3678 -0.2227 -0.0389 -0.0578
   Col10   Col11   Col12   Col13   Col14  Col15 Col16 Col17   Col18
[1,] -0.1175  0.8673 -0.0796 -0.1716 -0.7014 0.5611 1 2 -5.1536
[2,] -0.1232 -0.1033 -0.0341 -0.1801  0.6578 4.17 1 -0.1668
   Col19  Col20   Col21   Col22   Col23   Col24   Col25   Col26
[1,] -2.3412 0.9621  0.3678 -0.2227 -0.0389 -0.0578 -0.1232 -0.1033
[2,] -0.5062 0.3640 -0.5081  0.8142 -0.0445 -0.1175  0.8673 -0.0796
   Col27   Col28  Col29
[1,] -0.0341 -0.1801 0.6578
[2,] -0.1716 -0.7014 0.5611

In this case, 'mat' is a matrix with 2 rows and 29 columns.

You can restructure this differently as per your requirements.

HTH,

Marc Schwartz

__
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] data manipulation

2005-04-13 Thread John Fox
Dear Yoko,

If you're sure that the data are complete, then data <-
matrix(scan("file-name"), ncol=29) should do the trick. Then to name the
columns of the data matrix, colnames(data) <- c("one", "two", etc.). [Of
course, you'd substitute meaningful names.]

I hope this helps,
 John


John Fox
Department of Sociology
McMaster University
Hamilton, Ontario
Canada L8S 4M4
905-525-9140x23604
http://socserv.mcmaster.ca/jfox 
 

> -Original Message-
> From: [EMAIL PROTECTED] 
> [mailto:[EMAIL PROTECTED] On Behalf Of Yoko Nakajima
> Sent: Wednesday, April 13, 2005 7:56 PM
> To: r-help@stat.math.ethz.ch
> Subject: [R] data manipulation
> 
> Hello,
> my question is about the data handling.
> 
> I have a data set that is lined as:
> 
> 4 1 17 1 1
>  -5.1536 -0.1668 -2.3412 -0.5062  0.9621  0.3640  0.3678 
> -0.5081 -0.2227
>   0.8142 -0.0389 -0.0445 -0.0578 -0.1175 -0.1232  0.8673 
> -0.1033 -0.0796
>  -0.0341 -0.1716 -0.1801 -0.7014  0.6578  0.5611
> 4 1 17 2 1
>  -5.1536 -0.1668 -2.3412 -0.5062  0.9621  0.3640  0.3678 
> -0.5081 -0.2227
>   0.8142 -0.0389 -0.0445 -0.0578 -0.1175 -0.1232  0.8673 
> -0.1033 -0.0796
>  -0.0341 -0.1716 -0.1801 -0.7014  0.6578  0.5611
> 
> This means that 29 variables are together as a set. You saw 
> two sets of them in example. I have about 1000 sets (of 29 
> variables) in my data. When I "scan" this data set, the 
> result comes with 7 columns and it is not possible, so far, 
> to read the table by column wise, and thus it is not possible 
> to analyze the data. I would like to know whether there is a 
> way to solve this problem, say, by arranging columns or 
> increasing the number of columns of data matrix by R.
> 
> Also, I would like to know how you could name each column of 
> the data so that you could use the individual column separately.
> 
> Sincerely.
>   [[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


[R] data manipulation

2005-04-13 Thread Yoko Nakajima
Hello,
my question is about the data handling.

I have a data set that is lined as:

4 1 17 1 1
 -5.1536 -0.1668 -2.3412 -0.5062  0.9621  0.3640  0.3678 -0.5081 -0.2227
  0.8142 -0.0389 -0.0445 -0.0578 -0.1175 -0.1232  0.8673 -0.1033 -0.0796
 -0.0341 -0.1716 -0.1801 -0.7014  0.6578  0.5611
4 1 17 2 1
 -5.1536 -0.1668 -2.3412 -0.5062  0.9621  0.3640  0.3678 -0.5081 -0.2227
  0.8142 -0.0389 -0.0445 -0.0578 -0.1175 -0.1232  0.8673 -0.1033 -0.0796
 -0.0341 -0.1716 -0.1801 -0.7014  0.6578  0.5611

This means that 29 variables are together as a set. You saw two sets of them in 
example. I have about 1000 sets (of 29 variables) in my data. When I "scan" 
this data set, the result comes with 7 columns and it is not possible, so far, 
to read the table by column wise, and thus it is not possible to analyze the 
data. I would like to know whether there is a way to solve this problem, say, 
by arranging columns or increasing the number of columns of data matrix by R.

Also, I would like to know how you could name each column of the data so that 
you could use the individual column separately.

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


RE: [R] A suggestion for predict function(s)

2005-04-13 Thread Liaw, Andy
> From: Liaw, Andy
> 
> > From: Ross Darnell 
> > 
> > A good point but what is the value of storing a large set of 
> > predicted 
> > values when the values of the explanatory variables are lost 
> > (predicted 
> > values of what?). I thought the purpose of objects was that 
> they were 
> > self explanatory (pardon the pun).
> > 
> > Maybe we could make it optional.
> 
> If what you are looking for is a way to track the 
> observations, I'd suggest
> simply adding rownames of newdata as names of the predicted 
> values.  Storing
> names is much cheaper than the entire data frame of 
> predictors.  (And in R,
> data frames _must_ have unique row names.)

And as a matter of fact, predict.lm() and predict.glm() 
(and probably most other predict() methods) already do 
that.

Andy

> 
> Cheers,
> Andy
>  
> > Ross Darnell
> > -- 
> > 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
> 
> 
> --
> 
> Notice:  This e-mail message, together with any attachments, 
> contains information of Merck & Co., Inc. (One Merck Drive, 
> Whitehouse Station, New Jersey, USA 08889), and/or its 
> affiliates (which may be known outside the United States as 
> Merck Frosst, Merck Sharp & Dohme or MSD and in Japan, as 
> Banyu) that may be confidential, proprietary copyrighted 
> and/or legally privileged. It is intended solely for the use 
> of the individual or entity named on this message.  If you 
> are not the intended recipient, and have received this 
> message in error, please notify us immediately by reply 
> e-mail and then delete it from your system.
> --
> 
> 
>

__
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 suggestion for predict function(s)

2005-04-13 Thread Liaw, Andy
> From: Ross Darnell 
> 
> Liaw, Andy wrote:
> > I must respectfully disagree.  Why carry extra copies of 
> data arround?  This
> > is probably OK for small to medium sized data, but 
> definitely not for large
> > data.
> > 
> > Besides, in your example, it may do different things 
> depending on whether
> > newdata is supplied:  model.matrix is not necessarily the 
> same as the
> > original data frame.  You need a bit more work to get the 
> right model.matrix
> > that correspond to the newdata.  It's not clear to me 
> whether you want to
> > return model matrix or model frame, but in either case it's 
> not sufficient
> > to just use `newdata'.
> > 
> > Andy
> > 
> > 
> >>From: Ross Darnell
> >>
> >>Maybe a useful addition to the predict functions would be to 
> >>return the 
> >>values of the predictor variables. It just (unless there are 
> >>problems) 
> >>requires an extra line. I have inserted an example below.
> >>
> >>"predict.glm" <-
> >>   function (object, newdata = NULL, type = c("link", "response",
[snip]
> >>
> >>Ross Darnell
> >>-- 
> >>School of Health and Rehabilitation Sciences
> >>University of Queensland, Brisbane QLD 4072 AUSTRALIA
> >>Email: <[EMAIL PROTECTED]>
> >>Phone: +61 7 3365 6087 Fax: +61 7 3365 4754  Room:822, 
> >>Therapies Bldg.
> >>http://www.shrs.uq.edu.au/shrs/school_staff/ross_darnell.html
> 
> A good point but what is the value of storing a large set of 
> predicted 
> values when the values of the explanatory variables are lost 
> (predicted 
> values of what?). I thought the purpose of objects was that they were 
> self explanatory (pardon the pun).
> 
> Maybe we could make it optional.

If what you are looking for is a way to track the observations, I'd suggest
simply adding rownames of newdata as names of the predicted values.  Storing
names is much cheaper than the entire data frame of predictors.  (And in R,
data frames _must_ have unique row names.)

Cheers,
Andy
 
> Ross Darnell
> -- 
> 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] multinom and contrasts

2005-04-13 Thread John Fox
Dear chip,

The difference is small and is due to computational error. 

Your example:

> max(abs(zz[1:10,] - yy[1:10,]))
[1] 2.207080e-05

Tightening the convergence tolerance in multinom() eliminates the
difference:

> options(contrasts=c('contr.treatment','contr.poly'))
> xx<-multinom(Type~Infl+Cont,data=housing[-c(1,10,11,22,25,30),],
reltol=1.0e-12)
# weights:  20 (12 variable)
initial  value 91.495428 
iter  10 value 91.124526
final  value 91.124523 
converged
> yy<-predict(xx,type='probs')
> options(contrasts=c('contr.helmert','contr.poly'))
> xx<-multinom(Type~Infl+Cont,data=housing[-c(1,10,11,22,25,30),],
reltol=1.0e-12)
# weights:  20 (12 variable)
initial  value 91.495428 
iter  10 value 91.125287
iter  20 value 91.124523
iter  20 value 91.124523
iter  20 value 91.124523
final  value 91.124523 
converged
> zz<-predict(xx,type='probs')
> max(abs(zz[1:10,] - yy[1:10,]))
[1] 1.530021e-08

I hope this helps,
 John 


John Fox
Department of Sociology
McMaster University
Hamilton, Ontario
Canada L8S 4M4
905-525-9140x23604
http://socserv.mcmaster.ca/jfox 
 

> -Original Message-
> From: [EMAIL PROTECTED] 
> [mailto:[EMAIL PROTECTED] On Behalf Of array chip
> Sent: Wednesday, April 13, 2005 6:26 PM
> To: R-help@stat.math.ethz.ch
> Subject: [R] multinom and contrasts
> 
> Hi,
> 
> I found that using different contrasts (e.g.
> contr.helmert vs. contr.treatment) will generate different 
> fitted probabilities from multinomial logistic regression 
> using multinom(); while the fitted probabilities from binary 
> logistic regression seem to be the same. Why is that? and for 
> multinomial logisitc regression, what contrast should be 
> used? I guess it's helmert?
> 
> here is an example script:
> 
> library(MASS)
> library(nnet)
> 
>    multinomial logistic
> options(contrasts=c('contr.treatment','contr.poly'))
> xx<-multinom(Type~Infl+Cont,data=housing[-c(1,10,11,22,25,30),])
> yy<-predict(xx,type='probs')
> yy[1:10,]
> 
> options(contrasts=c('contr.helmert','contr.poly'))
> xx<-multinom(Type~Infl+Cont,data=housing[-c(1,10,11,22,25,30),])
> zz<-predict(xx,type='probs')
> zz[1:10,]
> 
> 
>   # binary logistic
> options(contrasts=c('contr.treatment','contr.poly'))
> obj.glm<-glm(Cont~Infl+Type,family='binomial',data=housing[-c(
1,10,11,22,25,30),])
> yy<-predict(xx,type='response')
> 
> options(contrasts=c('contr.helmert','contr.poly'))
> obj.glm<-glm(Cont~Infl+Type,family='binomial',data=housing[-c(
1,10,11,22,25,30),])
> zz<-predict(xx,type='response')
> 
> Thanks
> 
> __
> 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] Map a string to an object

2005-04-13 Thread Seth Falcon
Fernando Saldanha <[EMAIL PROTECTED]> writes:

> Is there a way in R to get an object whose name is given by a string?
>
> That is, like a function getObject(mystring) such that
>
> getObject('astring') 
>
> returns the object astring (assuming it exists)?

?get

__
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] Map a string to an object

2005-04-13 Thread Marc Schwartz
On Wed, 2005-04-13 at 19:46 -0400, Fernando Saldanha wrote:
> Is there a way in R to get an object whose name is given by a string?
> 
> That is, like a function getObject(mystring) such that
> 
> getObject('astring') 
> 
> returns the object astring (assuming it exists)?
> 
> Thanks.

Yep. You are close.

See ?get

> x <- 1:10

> get("x")
 [1]  1  2  3  4  5  6  7  8  9 10


> get("ls")
function (name, pos = -1, envir = as.environment(pos), all.names =
FALSE,
pattern)
{
if (!missing(name)) {
nameValue <- try(name)
...


HTH,

Marc Schwartz

__
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] Map a string to an object

2005-04-13 Thread Fernando Saldanha
Is there a way in R to get an object whose name is given by a string?

That is, like a function getObject(mystring) such that

getObject('astring') 

returns the object astring (assuming it exists)?

Thanks.

FS

__
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] multinom and contrasts

2005-04-13 Thread array chip
Hi,

I found that using different contrasts (e.g.
contr.helmert vs. contr.treatment) will generate
different fitted probabilities from multinomial
logistic regression using multinom(); while the fitted
probabilities from binary logistic regression seem to
be the same. Why is that? and for multinomial logisitc
regression, what contrast should be used? I guess it's
helmert?

here is an example script:

library(MASS)
library(nnet)

   multinomial logistic
options(contrasts=c('contr.treatment','contr.poly'))
xx<-multinom(Type~Infl+Cont,data=housing[-c(1,10,11,22,25,30),])
yy<-predict(xx,type='probs')
yy[1:10,]

options(contrasts=c('contr.helmert','contr.poly'))
xx<-multinom(Type~Infl+Cont,data=housing[-c(1,10,11,22,25,30),])
zz<-predict(xx,type='probs')
zz[1:10,]


  # binary logistic
options(contrasts=c('contr.treatment','contr.poly'))
obj.glm<-glm(Cont~Infl+Type,family='binomial',data=housing[-c(1,10,11,22,25,30),])
yy<-predict(xx,type='response')

options(contrasts=c('contr.helmert','contr.poly'))
obj.glm<-glm(Cont~Infl+Type,family='binomial',data=housing[-c(1,10,11,22,25,30),])
zz<-predict(xx,type='response')

Thanks

__
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] terminate R program when trying to access out-of-bounds array element?

2005-04-13 Thread Tony Plate
Oops.
The message in the 'stop' should be something more like "numeric index 
out of range".

-- Tony Plate
Tony Plate wrote:
One way could be to make a special class with an indexing method that 
checks for out-of-bounds numeric indices.  Here's an example for vectors:

 > setOldClass(c("oobcvec"))
 > x <- 1:3
 > class(x) <- "oobcvec"
 > x
[1] 1 2 3
attr(,"class")
[1] "oobcvec"
 > "[.oobcvec" <- function(x, ..., drop=T) {
+if (!missing(..1) && is.numeric(..1) && any(is.na(..1) | ..1 < 1 | 
..1 > length(x)))
+stop("numeric vector out of range")
+NextMethod("[")
+ }
 > x[2:3]
[1] 2 3
 > x[2:4]
Error in "[.oobcvec"(x, 2:4) : numeric vector out of range
 >

Then, for vectors for which you want out-of-bounds checks done when they 
indexed, set the class to "oobcvec".  This should work for simple 
vectors (I checked, and it works if the vectors have names).

If you want this write a method like this for indexing matrices, you can 
use ..1 and ..2 to refer to the i and j indices.  If you want to also be 
able to check for missing character indices, you'll just need to add 
more code.  Note that the above example disallows 0 and negative 
indices, which may or may not be what you want.

If you're extensively using other classes that you've defined, and you 
want out-of-bounds checking for them, then you need to integrate the 
checks into the subsetting methods for those classes -- you can't just 
use the above approach.

hope this helps,
Tony Plate
Vivek Rao wrote:
I want R to stop running a script (after printing an
error message) when an array subscript larger than the
length of the array is used, for example
x = c(1)
print(x[2])
rather than printing NA, since trying to access such
an element may indicate an error in my program. Is
there a way to get this behavior in R? Explicit
testing with the is.na() function everywhere does not
seem like a good solution. Thanks.
__
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] terminate R program when trying to access out-of-bounds array element?

2005-04-13 Thread Tony Plate
One way could be to make a special class with an indexing method that 
checks for out-of-bounds numeric indices.  Here's an example for vectors:

> setOldClass(c("oobcvec"))
> x <- 1:3
> class(x) <- "oobcvec"
> x
[1] 1 2 3
attr(,"class")
[1] "oobcvec"
> "[.oobcvec" <- function(x, ..., drop=T) {
+if (!missing(..1) && is.numeric(..1) && any(is.na(..1) | ..1 < 1 | 
..1 > length(x)))
+stop("numeric vector out of range")
+NextMethod("[")
+ }
> x[2:3]
[1] 2 3
> x[2:4]
Error in "[.oobcvec"(x, 2:4) : numeric vector out of range
>

Then, for vectors for which you want out-of-bounds checks done when they 
indexed, set the class to "oobcvec".  This should work for simple 
vectors (I checked, and it works if the vectors have names).

If you want this write a method like this for indexing matrices, you can 
use ..1 and ..2 to refer to the i and j indices.  If you want to also be 
able to check for missing character indices, you'll just need to add 
more code.  Note that the above example disallows 0 and negative 
indices, which may or may not be what you want.

If you're extensively using other classes that you've defined, and you 
want out-of-bounds checking for them, then you need to integrate the 
checks into the subsetting methods for those classes -- you can't just 
use the above approach.

hope this helps,
Tony Plate
Vivek Rao wrote:
I want R to stop running a script (after printing an
error message) when an array subscript larger than the
length of the array is used, for example
x = c(1)
print(x[2])
rather than printing NA, since trying to access such
an element may indicate an error in my program. Is
there a way to get this behavior in R? Explicit
testing with the is.na() function everywhere does not
seem like a good solution. Thanks.
__
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 suggestion for predict function(s)

2005-04-13 Thread Ross Darnell
Liaw, Andy wrote:
I must respectfully disagree.  Why carry extra copies of data arround?  This
is probably OK for small to medium sized data, but definitely not for large
data.
Besides, in your example, it may do different things depending on whether
newdata is supplied:  model.matrix is not necessarily the same as the
original data frame.  You need a bit more work to get the right model.matrix
that correspond to the newdata.  It's not clear to me whether you want to
return model matrix or model frame, but in either case it's not sufficient
to just use `newdata'.
Andy

From: Ross Darnell
Maybe a useful addition to the predict functions would be to 
return the 
values of the predictor variables. It just (unless there are 
problems) 
requires an extra line. I have inserted an example below.

"predict.glm" <-
  function (object, newdata = NULL, type = c("link", "response",
  "terms"), se.fit = FALSE, 
dispersion = NULL, terms = NULL,
na.action = na.pass, ...)
{
  type <- match.arg(type)
  na.act <- object$na.action
  object$na.action <- NULL
  if (!se.fit) {
if (missing(newdata)) {
  pred <- switch(type, link = object$linear.predictors,
 response = object$fitted, terms = 
predict.lm(object,
 se.fit = 
se.fit, scale 
= 1, type = "terms",
 terms = terms))
  if (!is.null(na.act))
pred <- napredict(na.act, pred)
}
else {
  pred <- predict.lm(object, newdata, se.fit, scale = 1,
 type = ifelse(type == "link", 
"response", type),
 terms = terms, na.action = na.action)
  switch(type, response = {
pred <- family(object)$linkinv(pred)
  }, link = , terms = )
}
  }
  else {
if (inherits(object, "survreg"))
  dispersion <- 1
if (is.null(dispersion) || dispersion == 0)
  dispersion <- summary(object, dispersion = 
dispersion)$dispersion
residual.scale <- as.vector(sqrt(dispersion))
pred <- predict.lm(object, newdata, se.fit, scale = 
residual.scale,
   type = ifelse(type == "link", 
"response", type),
   terms = terms, na.action = na.action)
fit <- pred$fit
se.fit <- pred$se.fit
switch(type, response = {
  se.fit <- se.fit * abs(family(object)$mu.eta(fit))
  fit <- family(object)$linkinv(fit)
}, link = , terms = )
if (missing(newdata) && !is.null(na.act)) {
  fit <- napredict(na.act, fit)
  se.fit <- napredict(na.act, se.fit)
}
predictors <- if (missing(newdata)) model.matrix(object) 
else newdata
pred <- list(predictors=predictors,
 fit = fit, se.fit = se.fit,
 residual.scale = residual.scale)
  }
  pred

#__ end of R code

Ross Darnell
--
School of Health and Rehabilitation Sciences
University of Queensland, Brisbane QLD 4072 AUSTRALIA
Email: <[EMAIL PROTECTED]>
Phone: +61 7 3365 6087 Fax: +61 7 3365 4754  Room:822, 
Therapies Bldg.
http://www.shrs.uq.edu.au/shrs/school_staff/ross_darnell.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




--
Notice:  This e-mail message, together with any attachment...{{dropped}}
__
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] barplot usage

2005-04-13 Thread Marc Schwartz
On Wed, 2005-04-13 at 19:05 -0300, Antonio Olinto wrote:
> Hi,
> 
> Iâm trying to make a barplot with the following dataframe, with information 
> on
> relative frequency per sediment type (ST) for some species:
> 
> Species  ST1  ST2  ST3
> SP_A 10   6030
> ...
> 
> 
> At x-axis are (should be ...) the species names and at y-axis the frequency 
> per
> sediment, in stacked bars.
> 
> I tried to use barplot command but with no results. Could anyone help me on 
> this?
> 
> Thanks in advance,
> 
> Samantha

You could use something like the following (presuming that your data is
a data frame called 'df'):

  barplot(t(df[2:4]), names.arg = as.character(df$Species))

Note that the row values that you have (excluding the Species name) need
to be rotated 90 degrees as follows:

> t(df[2:4])
 1 ...
ST1 10 ...
ST2 60 ...
ST3 30 ...

In this case, each column represents the segments of each stacked bar
(or if you set 'beside = TRUE', the individual bars in a group of bars)

Then the labels below each bar in the plot come from the df$Species
column. I used as.character(df$Species) presuming that this column might
be a factor. If not, you can eliminate the use of as.character() here.

HTH,

Marc Schwartz

__
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] terminate R program when trying to access out-of-bounds a rray element?

2005-04-13 Thread Liaw, Andy
As Bert said, redefining functions like "[" is surely inadvisable, because
of possibility of breaking codes that depend on the intended behavior.  This
is a language _feature_.

If the problem is indexing beyond array extent, just check for it:  Are any
values that are going to be used for indexing larger than the length of the
object?  E.g.,

if (any(idx > length(x))) stop("index out of bound")
result <- x[i]

If this is still too much work for you, Perhaps R is not for you...

Andy

> From: Rich FitzJohn
> 
> Hi,
> 
> You could try redefining "[", so that if any element subsetted
> returned an NA, it would throw an error, e.g.: 
> (Warning: Largely untested! - this will almost certainly cause
> problems in other classes that use [ to subset.  Possibly defining
> this as "[.default" would be better...)
> 
> "[" <- function(x, ...) {
>   res <- (base::"[")(x, ...)
>   if ( any(is.na(res)) )
> stop("An element was NA in a subset")
>   res
> }
> 
> > x <- 1:5
> > x[4]
> [1] 4
> > x[7]
> Error in x[7] : An element was NA in a subset
> 
> However, you'll probably find this is a little over-zealous, e.g.:
> > y <- c(1:3, NA, 4)
> > y[5]
> [1] 4
> > y[4]
> Error in y[4] : An element was NA in a subset
> 
> If you just want to check for an NA at printing, defining a function
> like this might be more appropriate:
> print.or.stop <- function(x) {
>   if ( any(is.na(x)) )
> stop("An element was NA in a subset")
>   print(x)
> }
> 
> You could write a more complicated "[" function that does a bunch of
> testing, to see if the element extracted is going to be out of the
> extent of the vector (rather than a "genuine" NA), but since there are
> a number of ways elements can be extracted from vectors (numeric,
> logical and character indices can all be used to index vectors, and
> these have recycling rules, etc), this is probably much more work than
> a few checks in your code where an NA would actually indicate an
> error.
> 
> Cheers,
> Rich
> 
> On 4/14/05, Vivek Rao <[EMAIL PROTECTED]> wrote:
> > I want R to stop running a script (after printing an
> > error message) when an array subscript larger than the
> > length of the array is used, for example
> > 
> > x = c(1)
> > print(x[2])
> > 
> > rather than printing NA, since trying to access such
> > an element may indicate an error in my program. Is
> > there a way to get this behavior in R? Explicit
> > testing with the is.na() function everywhere does not
> > seem like a good solution. Thanks.
> > 
> > __
> > 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
> > 
> 
> 
> -- 
> Rich 
> FitzJohn
> rich.fitzjohn  gmail.com   |
> http://homepages.paradise.net.nz/richa183
> 
>   You are in a maze of twisty little functions, all alike
> 
> __
> 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] terminate R program when trying to access out-of-bounds arrayelement?

2005-04-13 Thread Marc Schwartz
On Wed, 2005-04-13 at 15:03 -0700, Berton Gunter wrote:
> WHOA!
> 
> Do not redefine R functions (especially "[" !) in this way! That's what R
> classes and methods (either S3 or S4) are for. Same applies to print
> methods. See the appropriate sections of the R language definition and the
> book S PROGRAMMING by V&R.
> 
> Please do not offer "advice" of this sort if you are not knowledgeable about
> R/S Programming, as it might be taken seriously.

I think that we have another entry for the fortunes package...

:-)

Best regards,

Marc

__
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] barplot usage

2005-04-13 Thread Antonio Olinto
Hi,

I’m trying to make a barplot with the following dataframe, with information on
relative frequency per sediment type (ST) for some species:

Species  ST1  ST2  ST3
SP_A 10   6030
...


At x-axis are (should be ...) the species names and at y-axis the frequency per
sediment, in stacked bars.

I tried to use barplot command but with no results. Could anyone help me on 
this?

Thanks in advance,

Samantha



-
WebMail Bignet - O seu provedor do litoral
www.bignet.com.br

__
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] terminate R program when trying to access out-of-bounds arrayelement?

2005-04-13 Thread Berton Gunter
WHOA!

Do not redefine R functions (especially "[" !) in this way! That's what R
classes and methods (either S3 or S4) are for. Same applies to print
methods. See the appropriate sections of the R language definition and the
book S PROGRAMMING by V&R.

Please do not offer "advice" of this sort if you are not knowledgeable about
R/S Programming, as it might be taken seriously.

-- Bert Gunter
Genentech Non-Clinical Statistics
South San Francisco, CA
 
"The business of the statistician is to catalyze the scientific learning
process."  - George E. P. Box
 
 

> -Original Message-
> From: [EMAIL PROTECTED] 
> [mailto:[EMAIL PROTECTED] On Behalf Of Rich FitzJohn
> Sent: Wednesday, April 13, 2005 2:51 PM
> To: Vivek Rao
> Cc: r-help@stat.math.ethz.ch
> Subject: Re: [R] terminate R program when trying to access 
> out-of-bounds arrayelement?
> 
> Hi,
> 
> You could try redefining "[", so that if any element subsetted
> returned an NA, it would throw an error, e.g.: 
> (Warning: Largely untested! - this will almost certainly cause
> problems in other classes that use [ to subset.  Possibly defining
> this as "[.default" would be better...)
> 
> "[" <- function(x, ...) {
>   res <- (base::"[")(x, ...)
>   if ( any(is.na(res)) )
> stop("An element was NA in a subset")
>   res
> }
> 
> > x <- 1:5
> > x[4]
> [1] 4
> > x[7]
> Error in x[7] : An element was NA in a subset
> 
> However, you'll probably find this is a little over-zealous, e.g.:
> > y <- c(1:3, NA, 4)
> > y[5]
> [1] 4
> > y[4]
> Error in y[4] : An element was NA in a subset
> 
> If you just want to check for an NA at printing, defining a function
> like this might be more appropriate:
> print.or.stop <- function(x) {
>   if ( any(is.na(x)) )
> stop("An element was NA in a subset")
>   print(x)
> }
> 
> You could write a more complicated "[" function that does a bunch of
> testing, to see if the element extracted is going to be out of the
> extent of the vector (rather than a "genuine" NA), but since there are
> a number of ways elements can be extracted from vectors (numeric,
> logical and character indices can all be used to index vectors, and
> these have recycling rules, etc), this is probably much more work than
> a few checks in your code where an NA would actually indicate an
> error.
> 
> Cheers,
> Rich
> 
> On 4/14/05, Vivek Rao <[EMAIL PROTECTED]> wrote:
> > I want R to stop running a script (after printing an
> > error message) when an array subscript larger than the
> > length of the array is used, for example
> > 
> > x = c(1)
> > print(x[2])
> > 
> > rather than printing NA, since trying to access such
> > an element may indicate an error in my program. Is
> > there a way to get this behavior in R? Explicit
> > testing with the is.na() function everywhere does not
> > seem like a good solution. Thanks.
> > 
> > __
> > 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
> > 
> 
> 
> -- 
> Rich FitzJohn
> rich.fitzjohn  gmail.com   |
> http://homepages.paradise.net.nz/richa183
>   You are in a maze of twisty little 
> functions, all alike
> 
> __
> 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] terminate R program when trying to access out-of-bounds array element?

2005-04-13 Thread Rich FitzJohn
Hi,

You could try redefining "[", so that if any element subsetted
returned an NA, it would throw an error, e.g.: 
(Warning: Largely untested! - this will almost certainly cause
problems in other classes that use [ to subset.  Possibly defining
this as "[.default" would be better...)

"[" <- function(x, ...) {
  res <- (base::"[")(x, ...)
  if ( any(is.na(res)) )
stop("An element was NA in a subset")
  res
}

> x <- 1:5
> x[4]
[1] 4
> x[7]
Error in x[7] : An element was NA in a subset

However, you'll probably find this is a little over-zealous, e.g.:
> y <- c(1:3, NA, 4)
> y[5]
[1] 4
> y[4]
Error in y[4] : An element was NA in a subset

If you just want to check for an NA at printing, defining a function
like this might be more appropriate:
print.or.stop <- function(x) {
  if ( any(is.na(x)) )
stop("An element was NA in a subset")
  print(x)
}

You could write a more complicated "[" function that does a bunch of
testing, to see if the element extracted is going to be out of the
extent of the vector (rather than a "genuine" NA), but since there are
a number of ways elements can be extracted from vectors (numeric,
logical and character indices can all be used to index vectors, and
these have recycling rules, etc), this is probably much more work than
a few checks in your code where an NA would actually indicate an
error.

Cheers,
Rich

On 4/14/05, Vivek Rao <[EMAIL PROTECTED]> wrote:
> I want R to stop running a script (after printing an
> error message) when an array subscript larger than the
> length of the array is used, for example
> 
> x = c(1)
> print(x[2])
> 
> rather than printing NA, since trying to access such
> an element may indicate an error in my program. Is
> there a way to get this behavior in R? Explicit
> testing with the is.na() function everywhere does not
> seem like a good solution. Thanks.
> 
> __
> 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
> 


-- 
Rich FitzJohn
rich.fitzjohn  gmail.com   |http://homepages.paradise.net.nz/richa183
  You are in a maze of twisty little functions, all alike

__
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] i param in "for" loop does not takes zeros?

2005-04-13 Thread Francisco J. Zagmutt
Thanks to Rich, Douglas and Erin.  Off course the problem was the index!  I 
was looking at the wrong place!! Thanks for your help!

Francisco
From: Rich FitzJohn <[EMAIL PROTECTED]>
Reply-To: Rich FitzJohn <[EMAIL PROTECTED]>
To: "Francisco J. Zagmutt" <[EMAIL PROTECTED]>
CC: R-help@stat.math.ethz.ch
Subject: Re: [R] i param in "for" loop does not takes zeros?
Date: Thu, 14 Apr 2005 09:36:21 +1200
The for loop is not ignoring the zero at all, but the assignment is,
since R indexes starting at 1, not zero.
> sim <- c()
> sim[0] <- 1
> sim
numeric(0)
To run this loop this way, you need to add one to the index:
for ( i in 0:5 )
  sim[i+1] <- dbinom(i, 5, p)
However, you'd be better off passing your vector of values directly to
dbinom():
> dbinom(0:5, 5, p)
[1] 0.32768 0.40960 0.20480 0.05120 0.00640 0.00032
> all(dbinom(0:5, 5, p) == sim)
[1] TRUE
Cheers,
Rich
On 4/14/05, Francisco J. Zagmutt <[EMAIL PROTECTED]> wrote:
> Hi all
>
> Is there any reason why the parameter i in a "for" loop ignores a value 
of
> zero?  For example
>
> sim=c()
> p=.2
> for(i in 0:5)
>  {sim[i]=dbinom(i,5,p)
>  }
>
> sim
> [1] 0.40960 0.20480 0.05120 0.00640 0.00032
>
> In this example the quantile i= 0 was ignored since
> dbinom(0,5,p)
> [1] 0.32768
>
> The same behaviour occurs if I use a while loop to perform the same
> calculation:
> sim=c()
> p=.2
> i=0
> while(i <6)
>  {sim[i]=dbinom(i,5,p)
>  i=i+1
>  }
> sim
> [1] 0.40960 0.20480 0.05120 0.00640 0.00032
>
> How can I perform a loop passing a zero value parameter?  I know I can 
use
> an if statement for i<=0 but I was wondering why the loop is ignoring 
the
> zero value.
>
> Many thanks!
>
> Francisco
>
> __
> 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
>

--
Rich FitzJohn
rich.fitzjohn  gmail.com   |
http://homepages.paradise.net.nz/richa183
  You are in a maze of twisty little functions, all 
alike
__
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] i param in "for" loop does not takes zeros?

2005-04-13 Thread Rich FitzJohn
The for loop is not ignoring the zero at all, but the assignment is,
since R indexes starting at 1, not zero.

> sim <- c()
> sim[0] <- 1
> sim
numeric(0)

To run this loop this way, you need to add one to the index:
for ( i in 0:5 )
  sim[i+1] <- dbinom(i, 5, p)

However, you'd be better off passing your vector of values directly to
dbinom():

> dbinom(0:5, 5, p)
[1] 0.32768 0.40960 0.20480 0.05120 0.00640 0.00032
> all(dbinom(0:5, 5, p) == sim)
[1] TRUE

Cheers,
Rich

On 4/14/05, Francisco J. Zagmutt <[EMAIL PROTECTED]> wrote:
> Hi all
> 
> Is there any reason why the parameter i in a "for" loop ignores a value of
> zero?  For example
> 
> sim=c()
> p=.2
> for(i in 0:5)
>  {sim[i]=dbinom(i,5,p)
>  }
> 
> sim
> [1] 0.40960 0.20480 0.05120 0.00640 0.00032
> 
> In this example the quantile i= 0 was ignored since
> dbinom(0,5,p)
> [1] 0.32768
> 
> The same behaviour occurs if I use a while loop to perform the same
> calculation:
> sim=c()
> p=.2
> i=0
> while(i <6)
>  {sim[i]=dbinom(i,5,p)
>  i=i+1
>  }
> sim
> [1] 0.40960 0.20480 0.05120 0.00640 0.00032
> 
> How can I perform a loop passing a zero value parameter?  I know I can use
> an if statement for i<=0 but I was wondering why the loop is ignoring the
> zero value.
> 
> Many thanks!
> 
> Francisco
> 
> __
> 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
> 


-- 
Rich FitzJohn
rich.fitzjohn  gmail.com   |http://homepages.paradise.net.nz/richa183
  You are in a maze of twisty little functions, all alike

__
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] terminate R program when trying to access out-of-bounds array element?

2005-04-13 Thread Vivek Rao
I want R to stop running a script (after printing an
error message) when an array subscript larger than the
length of the array is used, for example

x = c(1)
print(x[2])

rather than printing NA, since trying to access such
an element may indicate an error in my program. Is
there a way to get this behavior in R? Explicit
testing with the is.na() function everywhere does not
seem like a good solution. Thanks.

__
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] i param in "for" loop does not takes zeros?

2005-04-13 Thread Francisco J. Zagmutt
Hi all
Is there any reason why the parameter i in a "for" loop ignores a value of 
zero?  For example

sim=c()
p=.2
for(i in 0:5)
 {sim[i]=dbinom(i,5,p)
 }
sim
[1] 0.40960 0.20480 0.05120 0.00640 0.00032
In this example the quantile i= 0 was ignored since
dbinom(0,5,p)
[1] 0.32768
The same behaviour occurs if I use a while loop to perform the same 
calculation:
sim=c()
p=.2
i=0
while(i <6)
 {sim[i]=dbinom(i,5,p)
 i=i+1
 }
sim
[1] 0.40960 0.20480 0.05120 0.00640 0.00032

How can I perform a loop passing a zero value parameter?  I know I can use 
an if statement for i<=0 but I was wondering why the loop is ignoring the 
zero value.

Many thanks!
Francisco
__
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] extracting one element of correlation matrices from a list poroduced by the 'by' statement

2005-04-13 Thread Mohammad A. Chaudhary
Great! Thank you very much. Looks R has unlimited possibilities.
Regards,
Ashraf

-Original Message-
From: [EMAIL PROTECTED] [mailto:[EMAIL PROTECTED] On Behalf Of Peter
Dalgaard
Sent: Wednesday, April 13, 2005 4:11 PM
To: Mohammad A. Chaudhary
Cc: r-help@stat.math.ethz.ch
Subject: Re: [R] extracting one element of correlation matrices from a
list poroduced by the 'by' statement

"Mohammad A. Chaudhary" <[EMAIL PROTECTED]> writes:

> I am producing 2X2 correlation matrices by a class variable. I need to
> extract a vector of correlation coefficients only. I am doing that in
a
> loop (see below) but I am sure there would be a simpler way. Please
> help!
> 
>  
> 
> > by(d1[,c(2,3)],d1[,1],cor)
> 
.
>   c e
> 
> c 1.000 0.3746597
> 
> e 0.3746597 1.000
> 
> ***
> 
> > t<- rep(0,10)
> 
> > ind=0
> 
> > for(r in 1:10) {
> 
> +ind=ind+1 
> 
> +t[ind] <- by(d1[,c(2,3)],d1[,1],cor)[[r]][1,2]
> 
> +} 
> 
> > t   
> 
> [1] 0.1972309 0.2469402 0.3177058 0.3492043 0.3385547 0.2876410
> 0.3374766 0.4380190 0.3452468 0.3746597

One way could be 

 sapply(by(d1[2:3],d1[,1],cor),"[",1,2)

another is 

 by(d1[2:3],d1[,1],function(f)cor(f)[1,2])

or, (this possibility never occurred to me before)

 by(d1[2:3],d1[,1], with, cor(c,e))


You might want to wrap the last two in a c() construct but they
actually are vectors already, they just don't look it when print.by
has done its work.


-- 
   O__   Peter Dalgaard Blegdamsvej 3  
  c/ /'_ --- Dept. of Biostatistics 2200 Cph. N   
 (*) \(*) -- University of Copenhagen   Denmark  Ph: (+45) 35327918
~~ - ([EMAIL PROTECTED]) FAX: (+45) 35327907

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


Re: [R] logistic regression weights problem

2005-04-13 Thread Federico Calboli
On Wed, 2005-04-13 at 17:42 +0100, Prof Brian Ripley wrote:
> Use the cbind(yes, no) form of specification.  Note though that the 
> `weights' in a GLM are case weights and not arbitrary downweighting 
> factors and aspects of the output (e.g. AIC, anova) depend on this.  A 
> different implementation of (differently) weighted GLM is svyglm() in 
> package 'survey'.

I tried to use cbind() on a slightly modified dummy set to get get rid
of all warnings and that's what I got:


status <- c(1,1,1,0,0)
SNPs <- matrix( c(1,0,1,0,0,1,0,1,0,1,0,1,0,1,1), ncol =3)
weight <- c(0.2, 0.1, 1, 0.8, 0.7)

 using cbind()

glm(cbind(status, 1-status) ~ SNPs, weights = weight, family = binomial)

Call:  glm(formula = cbind(status, 1 - status) ~ SNPs, family =
binomial,  weights = weight)

Coefficients:
(Intercept)SNPs1SNPs2SNPs3
 -2.079   43.132  -19.487   NA

Degrees of Freedom: 4 Total (i.e. Null);  2 Residual
Null Deviance:  3.867
Residual Deviance: 0.6279   AIC: 6.236

### NOT using cbind()

glm(status~ SNPs, weights = weight, family = binomial)

Call:  glm(formula = status ~ SNPs, family = binomial, weights = weight)

Coefficients:
(Intercept)SNPs1SNPs2SNPs3
 -2.079   42.944  -19.366   NA

Degrees of Freedom: 4 Total (i.e. Null);  2 Residual
Null Deviance:  3.867
Residual Deviance: 0.6279   AIC: 6.236
Warning message:
non-integer #successes in a binomial glm! in: eval(expr, envir, enclos)
##

The anova() call of the cbind() model seems happy:

###
mod <- glm(cbind(status, 1-status) ~ SNPs, weights = weight, family =
binomial)

anova(mod, test = "Chi")
Analysis of Deviance Table

Model: binomial, link: logit

Response: cbind(status, 1 - status)

Terms added sequentially (first to last)


 Df Deviance Resid. Df Resid. Dev P(>|Chi|)
NULL 4 3.8673
SNPs  2   3.2394 2 0.62790.1980
#

The real data modeldoes not show warnings when I use cbind() but it
still shows warning when I call anova() on the model:

###
anova(glm(cbind(sta, 1-sta) ~ (X1 + X2 + X3 + X4 + X5) * breed, family=
binomial, weights =igf$we, igf),test="Chi")
Analysis of Deviance Table

Model: binomial, link: logit

Response: cbind(sta, 1 - sta)

Terms added sequentially (first to last)


  Df Deviance Resid. Df Resid. Dev P(>|Chi|)
NULL330 372.89
X1 1 0.14   329 372.75  0.71
X2 1 0.26   328 372.49  0.61
X3 1 0.001121   327 372.49  0.97
X4 1 2.63   326 369.86  0.10
X5 1 1.87   325 367.99  0.17
breed  3 5.41   322 362.58  0.14
X1:breed   3 2.98   319 359.60  0.39
X2:breed   3 1.21   316 358.39  0.75
X3:breed   2 1.32   314 357.08  0.52
X4:breed   3 1.75   311 355.33  0.63
X5:breed   2 2.38   309 352.95  0.30
Warning messages:
1: non-integer #successes in a binomial glm! in: eval(expr, envir,
enclos)
2: non-integer #successes in a binomial glm! in: eval(expr, envir,
enclos)
3: non-integer #successes in a binomial glm! in: eval(expr, envir,
enclos)
4: non-integer #successes in a binomial glm! in: eval(expr, envir,
enclos)
5: non-integer #successes in a binomial glm! in: eval(expr, envir,
enclos)
6: non-integer #successes in a binomial glm! in: eval(expr, envir,
enclos)
7: non-integer #successes in a binomial glm! in: eval(expr, envir,
enclos)
8: non-integer #successes in a binomial glm! in: eval(expr, envir,
enclos)
9: non-integer #successes in a binomial glm! in: eval(expr, envir,
enclos)
10: non-integer #successes in a binomial glm! in: eval(expr, envir,
enclos)
##

Why such inconsistency?

Regards,

Federico Calboli

-- 
Federico C. F. Calboli
Department of Epidemiology and Public Health
Imperial College, St Mary's Campus
Norfolk Place, London W2 1PG

Tel  +44 (0)20 7594 1602 Fax (+44) 020 7594 3193

f.calboli [.a.t] imperial.ac.uk
f.calboli [.a.t] gmail.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


Re: [R] extracting one element of correlation matrices from a list poroduced by the 'by' statement

2005-04-13 Thread Peter Dalgaard
"Mohammad A. Chaudhary" <[EMAIL PROTECTED]> writes:

> I am producing 2X2 correlation matrices by a class variable. I need to
> extract a vector of correlation coefficients only. I am doing that in a
> loop (see below) but I am sure there would be a simpler way. Please
> help!
> 
>  
> 
> > by(d1[,c(2,3)],d1[,1],cor)
> 
.
>   c e
> 
> c 1.000 0.3746597
> 
> e 0.3746597 1.000
> 
> ***
> 
> > t<- rep(0,10)
> 
> > ind=0
> 
> > for(r in 1:10) {
> 
> +ind=ind+1 
> 
> +t[ind] <- by(d1[,c(2,3)],d1[,1],cor)[[r]][1,2]
> 
> +} 
> 
> > t   
> 
> [1] 0.1972309 0.2469402 0.3177058 0.3492043 0.3385547 0.2876410
> 0.3374766 0.4380190 0.3452468 0.3746597

One way could be 

 sapply(by(d1[2:3],d1[,1],cor),"[",1,2)

another is 

 by(d1[2:3],d1[,1],function(f)cor(f)[1,2])

or, (this possibility never occurred to me before)

 by(d1[2:3],d1[,1], with, cor(c,e))


You might want to wrap the last two in a c() construct but they
actually are vectors already, they just don't look it when print.by
has done its work.


-- 
   O__   Peter Dalgaard Blegdamsvej 3  
  c/ /'_ --- Dept. of Biostatistics 2200 Cph. N   
 (*) \(*) -- University of Copenhagen   Denmark  Ph: (+45) 35327918
~~ - ([EMAIL PROTECTED]) FAX: (+45) 35327907

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


[R] generalized regression neural nets

2005-04-13 Thread Wensui Liu
Is there a R package that can do GRNN?

Thanks.

__
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] Re: [R-SIG-Mac] BUG in RODBC with OS X?

2005-04-13 Thread Simon Urbanek
Just for the record - this problem concerns Actual drivers for Mac OS  
X 10.3 (later OS X versions are not affected). The current temporary  
work-around is to install "iODBC Runtime" supplied with the Actual  
drivers and compile RODBC as follows (in bash assuming sufficient  
privileges):

LIBS='-framework iODBC' PKG_CFLAGS='-I/Library/Frameworks/ 
iODBC.framework/Headers' R CMD INSTALL RODBC_1.1-3.tar.gz

Simon
__
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] Normalization and missing values

2005-04-13 Thread Ted Harding
On 13-Apr-05 Berton Gunter wrote:
> You can't expect statistical procedures to rescue you from
> poor data.

But they can "kiss it better".


(:-x)

Ted.



E-Mail: (Ted Harding) <[EMAIL PROTECTED]>
Fax-to-email: +44 (0)870 094 0861
Date: 13-Apr-05   Time: 19:13:01
-- XFMail --

__
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] Fitting a mixed negative binomial model

2005-04-13 Thread dave fournier
> I *think* (but am not sure) that these guys were actually (politely)
>advertising a commercial package that they're developing.  But, 
looking >at
>the web page, it seems that this module may be freely available -- >can't
>tell at the moment.

>Ben
The Software for negative binomial mixed models will be
free ie free as in you can use it without paying anything.
It is built using our
proprietary software.  The idea is to show how our software
is good for building nonlinear statstical models including
those with random effects.  Turning our stand alone software
into somethng that can be called easily from r has been a
bit of a steep learning curve for me, but we are making progress.
So far we have looked at 3 models. The model in Booth et al. (easy).
An overdispersed data set that turned out probably be
a zero inflated poisson (faily easy but the negative binomial
is only fit to be rejected for the simpler model) and
what appears to be a true negative binomial (difficult but
doable) and we are discussing the form of the model with the
person who wishes to analyze it.
A few more data sets would be useful if anyone has
an application so that we can ensure the robustness of our
software.
Dave


--
Internal Virus Database is out-of-date.
Checked by AVG Anti-Virus.
__
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] Normalization and missing values

2005-04-13 Thread WeiWei Shi
the way of scaling, IMHO, really depends on the distribution of each
column in your original files. if each column in your data follows a
normal distrbution, then a standard "normalization" will fit your
requirement.

My previous research in microarray data shows me a simple "linear
standardization" might be good enough for some purpose.

If your columns differ in magnitude, then some data transformation
like (log) might be needed first.

Ed


On 4/13/05, Achim Zeileis <[EMAIL PROTECTED]> wrote:
> On Wed, 13 Apr 2005 14:33:25 -0300 (ADT) Rolf Turner wrote:
> 
> >
> > Bert Gunter wrote:
> >
> > > You can't expect statistical procedures to rescue you from poor
> > > data.
> >
> >   That should ***definitely*** go into the fortune package
> >   data base!!!
> 
> :-) added for the next release.
> Z
> 
> >   cheers,
> >
> >   Rolf Turner
> >   [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
> >
> 
> __
> 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] GAMM in mgcv - significance of smooth terms

2005-04-13 Thread SwainD

In the summary of the gam object produced by gamm, the "Approximate
significance of smooth terms" appears to be a test of the improvement in fit
over a linear  model, rather than a test of the significance of the overall
effect of x on y:

test.gamm<-gamm(y~te(x, bs="cr"), random=list(grp=~1))
summary(test.gamm$gam)
.
.
.
Approximate significance of smooth terms:
   edf   chi.sq p-value
te(x)3.691   11.597 0.017802

Is my interpretation of this correct?
If so, is it possible to calculate a test of the overall effect of x 
from the information saved for a gamm object?

Thanks,
Doug Swain

__
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] GAMM in mgcv - degrees of freedom for smooth terms

2005-04-13 Thread SwainD

Is it possible to set the degrees of freedom for the smooth term in a gamm
to a  specfic value?
This can be done using gam in mgcv as follows:
tst.gam<-gam(y~s(x, k=6, fx=T))
However, this doesn't seem to work with gamm:
tst.gamm<-gamm(y~s(x, k=6, fx=TRUE, bs="cr"))
Instead, this results in the following error message:
Error in parse(file, n, text, prompt) : parse error

Similarly,
tst.gamm<-gamm(y~s(x, k=5, fx=T), random=list(grp=~1))
Error in FUN(X[[1]], ...) : Elements in object must be formulas or pdMat
objects

I am using mgcv 1.2-3 with Windows XP.

Thanks,
Doug Swain

__
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] extracting one element of correlation matrices from a list poroduced by the 'by' statement

2005-04-13 Thread Mohammad A. Chaudhary
I am producing 2X2 correlation matrices by a class variable. I need to
extract a vector of correlation coefficients only. I am doing that in a
loop (see below) but I am sure there would be a simpler way. Please
help!

 

> by(d1[,c(2,3)],d1[,1],cor)

d1[, 1]: 1

  c e

c 1.000 0.1972309

e 0.1972309 1.000


- 

d1[, 1]: 2

  c e

c 1.000 0.2469402

e 0.2469402 1.000


- 

d1[, 1]: 3

  c e

c 1.000 0.3177058

e 0.3177058 1.000


- 

d1[, 1]: 4

  c e

c 1.000 0.3492043

e 0.3492043 1.000


- 

d1[, 1]: 5

  c e

c 1.000 0.3385547

e 0.3385547 1.000


- 

d1[, 1]: 6

  c e

c 1.000 0.2876410

e 0.2876410 1.000


- 

d1[, 1]: 7

  c e

c 1.000 0.3374766

e 0.3374766 1.000


- 

d1[, 1]: 8

 ce

c 1.00 0.438019

e 0.438019 1.00


- 

d1[, 1]: 9

  c e

c 1.000 0.3452468

e 0.3452468 1.000


- 

d1[, 1]: 10

  c e

c 1.000 0.3746597

e 0.3746597 1.000

***

> t<- rep(0,10)

> ind=0

> for(r in 1:10) {

+ind=ind+1 

+t[ind] <- by(d1[,c(2,3)],d1[,1],cor)[[r]][1,2]

+} 

> t   

[1] 0.1972309 0.2469402 0.3177058 0.3492043 0.3385547 0.2876410
0.3374766 0.4380190 0.3452468 0.3746597


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


Re: [R] Normalization and missing values

2005-04-13 Thread Achim Zeileis
On Wed, 13 Apr 2005 14:33:25 -0300 (ADT) Rolf Turner wrote:

> 
> Bert Gunter wrote:
> 
> > You can't expect statistical procedures to rescue you from poor
> > data.
> 
>   That should ***definitely*** go into the fortune package
>   data base!!!

:-) added for the next release.
Z

>   cheers,
> 
>   Rolf Turner
>   [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
>

__
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] Normalization and missing values

2005-04-13 Thread Wensui Liu
before I know the scale() function, I just do it by coding it myself.
But probably you could find some cool stuffs in dprep library. I've
never tried it anyway.

for missing values, it is way more complex and also depends on the
methodology you are going to use. some methods are more tolerant to
missing values but others aren't. So the short answer is that there is
no BEST way.

On 4/13/05, Chris Bergstresser <[EMAIL PROTECTED]> wrote:
> Hi all --
> 
> I've got a large dataset which consists of a bunch of different
> scales, and I'm preparing to perform a cluster analysis.  I need to
> normalize the data so I can calculate the difference matrix.
> First, I didn't see a function in R which does normalization -- did
> I miss it?  What's the best way to do it?
> Second, what's the best way to deal with missing values?  Obviously,
> I could just set them to 0 (the mean of the normalized scales), but I'm
> not sure that's the best way.
> 
> -- Chris
> 
> __
> 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
> 


-- 
WenSui Liu, MS MA
Senior Decision Support Analyst
Division of Health Policy and Clinical Effectiveness
Cincinnati Children Hospital Medical Center

__
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] Normalization and missing values

2005-04-13 Thread Jonathan Baron
On 04/13/05 11:36, Chris Bergstresser wrote:
 Hi all --
 
 I've got a large dataset which consists of a bunch of different
 scales, and I'm preparing to perform a cluster analysis.  I need to
 normalize the data so I can calculate the difference matrix.
 First, I didn't see a function in R which does normalization -- did
 I miss it?  What's the best way to do it?

Look at scale().  Might be what you mean.

 Second, what's the best way to deal with missing values?  Obviously,
 I could just set them to 0 (the mean of the normalized scales), but I'm
 not sure that's the best way.

Lots of ways to deal with missing data.  The ones I've found most 
helpful are in the Hmisc library, particularly transcan() and
aregImpute().  See
http://www.psych.upenn.edu/~baron/rpsych/rpsych.html#SECTION000715000
for an example of the latter.  But, in general, the "right" way
to deal with missing data depends on the assumptions you make.
As a novice, I found the following article to be helpful:

Schafer, J. L., & Graham, J. W. (2002). Missing data: Our view of 
the state of the art. Psychological Methods, 7, 147-177.

-- 
Jonathan Baron, Professor of Psychology, University of Pennsylvania
Home page: http://www.sas.upenn.edu/~baron
R search page: http://finzi.psych.upenn.edu/

__
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] Behavior of apply() when used with start()

2005-04-13 Thread Fernando Saldanha
Maybe one person can, but I am not sure who is that person.

When I called 

starts2 <- apply(arr, 2, start)

I was not asking for the attibutes of the whole matrix. 

It rather seems to me that cbind() is the culprit. When it copies the
time series tsa and tsb it seems to reset their start attributes to 1.

In any case, I did what I wanted to do by using list() instead of
cbind() and lapply() instead of apply().

FS


On 4/13/05, Prof Brian Ripley <[EMAIL PROTECTED]> wrote:
> On Wed, 13 Apr 2005, Fernando Saldanha wrote:
> 
> > Can someone explain why starts1 and starts2 are diffferent in the example 
> > below?
> 
> Yes, at least one person can.  Actually, anyone who looked could:
> 
> > arr
> Time Series:
> Start = 1
> End = 3
> Frequency = 1
>tsa tsb
> 1   1  NA
> 2   2   2
> 3   3   3
> 
> Note the times series attributes apply to the whole matrix.
> 
> > After running this program
> >
> > a <- c(1:3)
> > b <- c(2:3)
> > tsa <- ts(a)
> > tsb <- ts(b, start = 2)
> > arr <- cbind(tsa, tsb)
> > starts1 <- cbind(start(tsa), start(tsb))
> > starts2 <- apply(arr, 2, start)
> >
> > I get:
> >
> >> starts1
> > [,1] [,2]
> > [1,]12
> > [2,]11
> >
> >> starts2
> > tsa tsb
> > [1,]   1   1
> > [2,]   1   1
> 
> --
> 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@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] Normalization and missing values

2005-04-13 Thread Rolf Turner

Bert Gunter wrote:

> You can't expect statistical procedures to rescue you from poor
> data.

That should ***definitely*** go into the fortune package
data base!!!

cheers,

Rolf Turner
[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] Fitting a mixed negative binomial model

2005-04-13 Thread Ben Bolker
  I *think* (but am not sure) that these guys were actually (politely) 
advertising a commercial package that they're developing.  But, looking at 
the web page, it seems that this module may be freely available -- can't 
tell at the moment.

   Ben
On Wed, 13 Apr 2005, Henric Nilsson wrote:
Ben Bolker said the following on 2005-04-12 21:40:
  This is a little bit tricky (nonlinear, mixed, count data ...) Off the 
 top of my head, without even looking at the documentation, I think your 
 best bet for this problem would be to use the weights statement to allow 
 the variance to be proportional to the mean (and add a normal error term 
 for individuals) -- this would be close to equivalent to the log-Poisson 
 model used by Elston et al. (Parasitology 2001, 122, 563-569, "Analysis of 
 aggregation, a worked example: numbers of ticks on red grouse chicks"), 
 and might do what you want.
A recent posting
http://finzi.psych.upenn.edu/R/Rhelp02a/archive/48429.html
suggests that an R function for fitting the negative binomial mixed-effects 
model actually exists.

HTH,
Henric
--
620B Bartram Hall[EMAIL PROTECTED]
Zoology Department, University of Floridahttp://www.zoo.ufl.edu/bolker
Box 118525   (ph)  352-392-5697
Gainesville, FL 32611-8525   (fax) 352-392-3704
__
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] Binary Matrices

2005-04-13 Thread Barry Rowlingson
Martin Maechler wrote:
As others have said, you can use either 'SparseM' or 'Matrix'.
The latter has also good code for sparse matrices, and actually
I know that Doug Bates was going to implement sparse logical
matrices in the next few days.
 The old 8-bit assembly language programmer in me baulks at this 
flippant waste of memory. Storing a *single bit* in 4 bytes? That would 
reduce the maximum number of bits you could store on a Z80-based machine 
with a fully maxed-out 64k of RAM to 16384, minus the 8k or whatever 
your system ROM was.

 No, the real solution to this problem lies in the 'rawToChar' 
functions, and its friends. You could pack your entire binary matrix 
into a character string, and store 8 bits per byte. A factor of 32 
improvement in storage (plus a little overhead).

 You could go the whole hog and write a new binary matrix class, but 
that would probably be silly, much easier to just write two functions 
that packed a binary matrix into this form, and unpacked it back into 
full numeric matrix form.

 And of course this method doesn't rely on the matrix being sparse, or 
use run-length encoding or other compression scheme. Its a flat factor 
of 32 compression.

 Okay, I'm being slightly sarcastic here, and if it wasn't time to go 
home now I'd have a quick bash at this, just to see what you can do with 
R's rawToChar function and friends. Never knew they existed until now.

Baz
__
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] Normalization and missing values

2005-04-13 Thread Berton Gunter
Normalization:  ?scale -- or, more usually, an argument in the clustering
function (see package "cluster" where "stand" is the argument in the various
functions. Other packages may have similar capabilties).

Missing Values: A HUGE and COMPLEX issue. One Reference: ANALYSIS OF
INCOMPLETE MULTIVARIATE DATA by J.L. Schafer (Chapman and Hall); Donald
Rubin has published several books and many papers on this, so anything by
him is another good resource.

Setting missings to 0 will clearly produce nonsense, as two cases with lots
of missings in corresponding coordinates will cluster together when there is
no reason for them to do so. Set them to NA, but as some clustering routines
work only with complete cases, this might leave you with a data set of size
0. So you need clustering methods that can work with missing data, e.g. pam,
clara, etc.; but of course one doesn't quite know what to make of two cases
that are deemed to be "close" on the basis of, say, 10% of nonmissing shared
coordinates as compared to cases that are close based on all shared
coordinates. You can't expect statistical procedures to rescue you from poor
data.


-- Bert Gunter
Genentech Non-Clinical Statistics
South San Francisco, CA
 
"The business of the statistician is to catalyze the scientific learning
process."  - George E. P. Box
 
 

> -Original Message-
> From: [EMAIL PROTECTED] 
> [mailto:[EMAIL PROTECTED] On Behalf Of Chris 
> Bergstresser
> Sent: Wednesday, April 13, 2005 9:37 AM
> To: r-help@stat.math.ethz.ch
> Subject: [R] Normalization and missing values
> 
> Hi all --
> 
> I've got a large dataset which consists of a bunch of different 
> scales, and I'm preparing to perform a cluster analysis.  I need to 
> normalize the data so I can calculate the difference matrix.
> First, I didn't see a function in R which does 
> normalization -- did 
> I miss it?  What's the best way to do it?
> Second, what's the best way to deal with missing values?  
> Obviously, 
> I could just set them to 0 (the mean of the normalized 
> scales), but I'm 
> not sure that's the best way.
> 
> -- Chris
> 
> __
> 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] Anova for GLMM (lme4) is a valid method?

2005-04-13 Thread Ronaldo Reis-Jr.
Hi,

I try to make a binomial analysis using GLMM in a longitudinal data file.

Is correct to use anova(model) to access the significance of the fixed terms?

Thanks
Ronaldo
-- 
 Todos somos iguais perante a lei, mas nao perante os 
 encarregados de faze-las cumprir.
  -- S. Jerzy Lec 
--
|>   // | \\   [***]
|   ( õ   õ )  [Ronaldo Reis Júnior]
|>  V  [UFV/DBA-Entomologia]
|/ \   [36571-000 Viçosa - MG  ]
|>  /(.''`.)\  [Fone: 31-3899-4007 ]
|  /(: :'  :)\ [EMAIL PROTECTED]]
|>/ (`. `'` ) \[ICQ#: 5692561 | LinuxUser#: 205366 ]
|( `-  )   [***]
|>>  _/   \_Powered by GNU/Debian Woody/Sarge

__
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] Summary: GLMMs: Negative Binomial family in R

2005-04-13 Thread nflynn
Here is a summary of responses to my original email (see my query at the
bottom).  Thank you to Achim Zeileis , Anders Nielsen, Pierre Kleiber  and Dave
Fournier who all helped out with advice.  I hope that their responses will help
some of you too.

 *
Check out
glm.nb() from package MASS fits negative binomial GLMs.
*

For known theta, you can plug negative.binomial(theta) into glmmPQL()
for example. (Both functions are also available in MASS.)

Look at package zicounts for zero-inflated Poisson and NB models. For
these models, there is also code available at
  http://pscl.stanford.edu/content.html
which also hosts code for hurdle models.
*

Consider using the function supplied in the post:
https://stat.ethz.ch/pipermail/r-help/2005-March/066752.html
for fitting negative binomial mixed effects models.

*

Check out these recent postings to the R list:
http://finzi.psych.upenn.edu/R/Rhelp02a/archive/48429.html
http://finzi.psych.upenn.edu/R/Rhelp02a/archive/48646.html
*this refers to the  random effects module of AD Model Builderthat can be called
from R via the driver functon glmm.admb(). Their example problem fits the model
with a negative binomial. The function can be downloaded from
http://otter-rsch.com/admbre/examples/nbmm/nbmm.html


***
My Original Query

Greetings R Users!

I have a data set of count responses for which I have made repeated observations
on the experimental units (stream reaches) over two air photo dates, hence the
mixed effect.  I have been using Dr. Jim Lindsey's GLMM function found in his
"repeated" measures package with the "poisson" family.

My problem though is that I don't think the poisson distribution is the right
one to discribe my data which is overdispersed; the variance is greater than
the mean.  I have read that the "negative binomial" regression models can
account for some of the differences among observations by adding in a error
term that independent of the the covariates.

I haven't yet come across a mixed effects model that can use the "negative
binomial" distribution.

If any of you know of such a function - I will certainly look forward to hearing
from you!  Additionally, if any of you have insight on zero-inflated data, and
testing for this, I'd be interested in your comments too.  I'll post a summary
of your responses to this list.

Best Regards,
Nadele Flynn, M.Sc. candidate.
University of Alberta

__
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] logistic regression weights problem

2005-04-13 Thread Prof Brian Ripley
On Wed, 13 Apr 2005, Federico Calboli wrote:
I have a problem with weighted logistic regression. I have a number of
SNPs  and a case/control scenario, but not all genotypes are as
"guaranteed" as others, so I am using weights to downsample the
importance of individuals whose genotype has been heavily "inferred".
My data is quite big, but with a dummy example:
status <- c(1,1,1,0,0)
SNPs <- matrix( c(1,0,1,0,0,0,0,1,0,1,0,1,0,1,1), ncol =3)
weight <- c(0.2, 0.1, 1, 0.8, 0.7)
glm(status ~ SNPs, weights = weight, family = binomial)
Call:  glm(formula = status ~ SNPs, family = binomial, weights = weight)
Coefficients:
(Intercept)SNPs1SNPs2SNPs3
-2.079   42.282  -18.964   NA
Degrees of Freedom: 4 Total (i.e. Null);  2 Residual
Null Deviance:  3.867
Residual Deviance: 0.6279   AIC: 6.236
Warning messages:
1: non-integer #successes in a binomial glm! in: eval(expr, envir,
enclos)
2: fitted probabilities numerically 0 or 1 occurred in: glm.fit(x = X, y
= Y, weights = weights, start = start, etastart = etastart,
NB I do not get warning (2) for my data so I'll completely disregard it.
Warning (1) looks suspiciously like a multiplication of my C/C status by
the weights... what exacly is glm doing with the weight vector?
Using it in the GLM definition.  If you specify 0<=y_i<=1 and weights a_i, 
this is how you specify Binomial(a_i, a_iy_i).  Look up any book on GLMs 
and see what it says about the binomial.  E.g. MASS4 pp. 184, 190.

In any case, how would I go about weighting my individuals in a logistic
regression?
Use the cbind(yes, no) form of specification.  Note though that the 
`weights' in a GLM are case weights and not arbitrary downweighting 
factors and aspects of the output (e.g. AIC, anova) depend on this.  A 
different implementation of (differently) weighted GLM is svyglm() in 
package 'survey'.

--
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@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] Normalization and missing values

2005-04-13 Thread Chris Bergstresser
Hi all --
   I've got a large dataset which consists of a bunch of different 
scales, and I'm preparing to perform a cluster analysis.  I need to 
normalize the data so I can calculate the difference matrix.
   First, I didn't see a function in R which does normalization -- did 
I miss it?  What's the best way to do it?
   Second, what's the best way to deal with missing values?  Obviously, 
I could just set them to 0 (the mean of the normalized scales), but I'm 
not sure that's the best way.

-- Chris
__
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] R in Windows

2005-04-13 Thread Prof Brian Ripley
On Wed, 13 Apr 2005, Marc Schwartz wrote:
On Wed, 2005-04-13 at 10:51 -0400, George Kelley wrote:
Has anyone tried to create dialog boxes for Windows in R so that one
doesn't have to type in so much information but rather enter it in a
menu-based format. If not, does anyone plan on doing this in the future
if it's possible?
Thanks.
George (Kelley)

There are a variety of GUI's being actively developed for R.
More information is here:
http://www.sciviews.org/_rgui/
I don't use it actively, but I might specifically suggest that you
review John Fox' R Commander:
http://socserv.mcmaster.ca/jfox/Misc/Rcmdr/
It is written in tcl/tk, which makes it cross-platform compatible if
that is an issue for you.
And R for Windows comes with the sources for a `windlgs' package to 
illustrate how to do guess what?

--
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@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] Behavior of apply() when used with start()

2005-04-13 Thread Prof Brian Ripley
On Wed, 13 Apr 2005, Fernando Saldanha wrote:
Can someone explain why starts1 and starts2 are diffferent in the example below?
Yes, at least one person can.  Actually, anyone who looked could:
arr
Time Series:
Start = 1
End = 3
Frequency = 1
  tsa tsb
1   1  NA
2   2   2
3   3   3
Note the times series attributes apply to the whole matrix.
After running this program
a <- c(1:3)
b <- c(2:3)
tsa <- ts(a)
tsb <- ts(b, start = 2)
arr <- cbind(tsa, tsb)
starts1 <- cbind(start(tsa), start(tsb))
starts2 <- apply(arr, 2, start)
I get:
starts1
[,1] [,2]
[1,]12
[2,]11
starts2
tsa tsb
[1,]   1   1
[2,]   1   1
--
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@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] Fitting a mixed negative binomial model

2005-04-13 Thread Henric Nilsson
Ben Bolker said the following on 2005-04-12 21:40:
  This is a little bit tricky (nonlinear, mixed, count data ...) Off the 
top of my head, without even looking at the documentation, I think your 
best bet for this problem would be to use the weights statement to allow 
the variance to be proportional to the mean (and add a normal error term 
for individuals) -- this would be close to equivalent to the log-Poisson 
model used by Elston et al. (Parasitology 2001, 122, 563-569, "Analysis 
of aggregation, a worked example: numbers of ticks on red grouse 
chicks"), and might do what you want.
A recent posting
http://finzi.psych.upenn.edu/R/Rhelp02a/archive/48429.html
suggests that an R function for fitting the negative binomial 
mixed-effects model actually exists.

HTH,
Henric
__
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] lme problem

2005-04-13 Thread Henric Nilsson
Milos Zarkovic said the following on 2005-04-12 16:40:
I have recently started using R. For the start I have tried to
repeat examples from Milliken &  Johnson "Analysis of
Messy Data - Analysis of Covariance", but I can not replicate
it in R. The example is chocolate chip experiment. Response
variable vas time to dissolve chocolate chip in seconds (time),
covariate was time to dissolve butterscotch chip (bstime), and
type was a type of chocolate chip. Problem is that I obtain
different degrees of freedom compared to one in the book.
Could it be sum of squares problem (type III vs. type I)?
Milliken & Johnson use SAS for calculations and this
is program the used:
proc mixed data=mmacov method=type3; class type;
model time=type bstime*type/solution noint.
The PROC MIXED code above doesn't correspond to the R code below.
My R code is:
LME.1=lme(time~bstime:type+type-1,data=CCE,random=~1|type)
In your `lme' call, a random effect for each of the levels of `type' has 
been added to the model.

Since the analysis performed by PROC MIXED doesn't have any random 
effects it can be reproduced in R using the `lm' function. The results 
below match those of Milliken & Johnson p. 49 (using PROC MIXED) and the 
results on p. 43 (using PROC GLM).

> fit <- lm(time ~ bstime:type + type - 1, data = CCE)
> summary(fit)
Call:
lm(formula = time ~ bstime:type + type - 1, data = CCE)
Residuals:
Min  1Q  Median  3Q Max
-16.982  -3.196  -0.250   1.400  21.694
Coefficients:
 Estimate Std. Error t value Pr(>|t|)
typeBlue M&M  17.974416.1923   1.110  0.27845
typeButton21.571910.7832   2.001  0.05738 .
typeChoc Chip 16.916715.1673   1.115  0.27622
typeRed M&M   26.576013.1722   2.018  0.05545 .
typeSmall M&M 22.197729.0849   0.763  0.45310
typeSnow Cap   8.7000 9.4131   0.924  0.36495
bstime:typeBlue M&M1.0641 0.6187   1.720  0.09887 .
bstime:typeButton  1.3352 0.3743   3.567  0.00164 **
bstime:typeChoc Chip   1.1667 0.7302   1.598  0.12373
bstime:typeRed M&M 0.5300 0.5564   0.953  0.35075
bstime:typeSmall M&M   0.1919 0.9881   0.194  0.84775
bstime:typeSnow Cap0.9000 0.3999   2.250  0.03428 *
---
Signif. codes:  0 `***' 0.001 `**' 0.01 `*' 0.05 `.' 0.1 ` ' 1
Residual standard error: 8.196 on 23 degrees of freedom
Multiple R-Squared: 0.9774, Adjusted R-squared: 0.9656
F-statistic:  82.8 on 12 and 23 DF,  p-value: 5.616e-16
and summary is:
 Value Std.Error DF 
t-valuep-value
 typeBlue M&M18.0 18.5 0 0.97 NaN
 typeButton21.6 14.1 0 
1.53 NaN
 typeChoc Chip 16.9 17.7 0 0.96 NaN
 typeRed M&M26.6 16.0 0 1.66 NaN
 typeSmall M&M  22.2 30.5 0 0.73 NaN
 typeSnow Cap 8.7   13.1 0 0.67 NaN
 bstime:typeBlue M&M 1.1   0.6 24 1.72 0.098
 bstime:typeButton 1.3   0.4 24 3.57 
0.002
 bstime:typeChoc Chip  1.2   0.7 24 1.60 0.123
 bstime:typeRed M&M 0.5   0.6 24 0.95 0.350
 bstime:typeSmall M&M   0.2  1.0  24 0.19 0.848
 bstime:typeSnow Cap  0.9  0.4  24 2.25 0.034

However in Milliken & Johnson all df are 23. Values (estimates) are 
almost identical, but there are some small differences in SE and t.

Using
anova(LME.1)
I obtain
   numDF denDF   F-value p-value
type6  0 18.19 NaN
bstime:type 624   4.04  0.0061
but in the book it is:

   numDF denDF  F-value p-value
type6 23   2.00 0.1075
bstime:type 6 23   4.04  0.0066
The tests reported by Milliken & Johnson are based on so called "Type 
III" sums of squares. If you want to reproduce these, try the `Anova' 
function in John Fox's indispensable `car' package.

> library(car)
> options(contrasts = c("contr.sum", "contr.poly"))
> Anova(fit, type = "III")
Anova Table (Type III tests)
Response: time
 Sum Sq Df F value   Pr(>F)
type 805.13  6  1.9976 0.107510
bstime:type 1628.79  6  4.0412 0.006557 **
Residuals   1545.01 23
---
Signif. codes:  0 `***' 0.001 `**' 0.01 `*' 0.05 `.' 0.1 ` ' 1
HTH,
Henric

Data are at the end of the letter.
I am not sure what I did wrong.
Sincerely,
Milos Zarkovic

**
Milos Zarkovic MD, Ph.D.
Associate Professor of Internal Medicine
Institute of Endocrinology
Dr Subotica 13
11000 Beograd
Serbia
Tel +381-63-202-925
Fax +381-11-685-357
Email

RE: [R] Binary Matrices

2005-04-13 Thread Martin Maechler
> "Mark" == Mark Edmondson-Jones <[EMAIL PROTECTED]>
> on Wed, 13 Apr 2005 15:40:26 +0100 writes:

Mark> 1000x1000 is only indicative.  I need to generate
Mark> larger (adjacency) matrices using a variety of models.

Mark> Most are sparse, with a high proportion of zeros and
Mark> so SparseM sounds very promising.  I will investigate.

As others have said, you can use either 'SparseM' or 'Matrix'.
The latter has also good code for sparse matrices, and actually
I know that Doug Bates was going to implement sparse logical
matrices in the next few days.
Those actually need (quite) a bit less space than sparse double
matrices, since you only need to store the indices of the TRUE
entries.

Martin


 "Liaw, Andy" <[EMAIL PROTECTED]> 13/04/2005 >>>


>> -Original Message-
>> From: Uwe Ligges
>> 
>> Mark Edmondson-Jones wrote:
>> 
>> > I'm wanting to perform analysis (e.g. using eigen()) of 
>> binary matrices - i.e. matrices comprising 0s and 1s.
>> > 
>> > For example:
>> > 
>> > n<-1000
>> > test.mat<-matrix(round(runif(n^2)),n,n)
>> > eigen(test.mat,only.values=T)
>> > 
>> > Is there a more efficient way of setting up test.mat, as 
>> each cell only requires a binary digit?  I imagine R is 
>> setting up a structure which could contain n^2 floats.
>> 
>> No. In principle you could use logicals,

Mark> ... but that doesn't save any memory:

>> object.size(integer(1e6))
Mark> [1] 428
>> object.size(logical(1e6))
Mark> [1] 428

>> but that does not help for further calculations in eigen().

Mark> Besides, if the problem size is really 1000 x 1000, one matrix in 
Mark> double precision is only 8MB.  As Reid said, if the matrix is sparse,
Mark> there's probably a lot more saving in both memory and computation
Mark> by using SparseM and Matrix packages.

Mark> Cheers,
Mark> Andy

 
>> Uwe Ligges
>> 
>> 
>> > Thanks in advance for any help.
>> > 
>> > Regards,
>> > Mark
>> > 
>> > 
>> > This message has been checked for viruses but the contents 
>> of an attachment
>> > may still contain software viruses, which could damage your 
>> computer system:
>> > you are advised to perform your own checks. Email 
>> communications with the
>> > University of Nottingham may be monitored as permitted by 
>> UK legislation.
>> > 
>> > __
>> > 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 
>> 
>> 
>> 



Mark> 
--

Mark> 
--


Mark> This message has been checked for viruses but the contents of an 
attachment
Mark> may still contain software viruses, which could damage your computer 
system:
Mark> you are advised to perform your own checks. Email communications with 
the
Mark> University of Nottingham may be monitored as permitted by UK 
legislation.

Mark> __
Mark> R-help@stat.math.ethz.ch mailing list
Mark> https://stat.ethz.ch/mailman/listinfo/r-help
Mark> 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] logistic regression weights problem

2005-04-13 Thread Federico Calboli
Hi All,

I have a problem with weighted logistic regression. I have a number of
SNPs  and a case/control scenario, but not all genotypes are as
"guaranteed" as others, so I am using weights to downsample the
importance of individuals whose genotype has been heavily "inferred".

My data is quite big, but with a dummy example:

> status <- c(1,1,1,0,0)
> SNPs <- matrix( c(1,0,1,0,0,0,0,1,0,1,0,1,0,1,1), ncol =3)
> weight <- c(0.2, 0.1, 1, 0.8, 0.7)
> glm(status ~ SNPs, weights = weight, family = binomial)

Call:  glm(formula = status ~ SNPs, family = binomial, weights = weight)

Coefficients:
(Intercept)SNPs1SNPs2SNPs3
 -2.079   42.282  -18.964   NA

Degrees of Freedom: 4 Total (i.e. Null);  2 Residual
Null Deviance:  3.867
Residual Deviance: 0.6279   AIC: 6.236
Warning messages:
1: non-integer #successes in a binomial glm! in: eval(expr, envir,
enclos)
2: fitted probabilities numerically 0 or 1 occurred in: glm.fit(x = X, y
= Y, weights = weights, start = start, etastart = etastart,

NB I do not get warning (2) for my data so I'll completely disregard it.

Warning (1) looks suspiciously like a multiplication of my C/C status by
the weights... what exacly is glm doing with the weight vector? 

In any case, how would I go about weighting my individuals in a logistic
regression?

Regards,

Federico Calboli


-- 
Federico C. F. Calboli
Department of Epidemiology and Public Health
Imperial College, St Mary's Campus
Norfolk Place, London W2 1PG

Tel  +44 (0)20 7594 1602 Fax (+44) 020 7594 3193

f.calboli [.a.t] imperial.ac.uk
f.calboli [.a.t] gmail.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


Re: [R] R in Windows

2005-04-13 Thread Marc Schwartz
On Wed, 2005-04-13 at 10:51 -0400, George Kelley wrote:
> Has anyone tried to create dialog boxes for Windows in R so that one
> doesn't have to type in so much information but rather enter it in a
> menu-based format. If not, does anyone plan on doing this in the future
> if it's possible?
> 
> Thanks.
> 
> George (Kelley)


There are a variety of GUI's being actively developed for R.

More information is here:

http://www.sciviews.org/_rgui/

I don't use it actively, but I might specifically suggest that you
review John Fox' R Commander:

http://socserv.mcmaster.ca/jfox/Misc/Rcmdr/

It is written in tcl/tk, which makes it cross-platform compatible if
that is an issue for you.

HTH,

Marc Schwartz

__
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 plot Contour with NA in dataframe

2005-04-13 Thread Earl F. Glynn
"Duncan Murdoch" <[EMAIL PROTECTED]> wrote in message
news:[EMAIL PROTECTED]
> [EMAIL PROTECTED] wrote:

> Your problem isn't the NA values, it's the fact that the contour
> functions want a matrix, and you're passing a data.frame.  If you use
> as.matrix on it, it converts to character mode, presumably because your
> last column is entirely missing (so is read as mode logical, not numeric).
>
> Use this massaging on it and the plot will work:
>
>   myData <- as.matrix(as.data.frame(lapply(myData,as.numeric)))

This looks unnecessarily complicated here, but appears to be necessary.  I
normally would try to use only "as.matrix" here but this can fail as shown
below, but sometimes can work.

R's "rules" about this conversion seem somewhat arbitrary to me.  Example 3,
in particular, doesn't make sense to me.  Can anyone share some insight on
what is going on?

==


Dummy.txt

1,2,3

4,5,6



# 1.  Integers, no missing values; "as.matrix" good enough for conversion

# Results make sense.

> myData <- read.table('Dummy.txt',sep=',')

> typeof(myData)

[1] "list"

> class(myData)

[1] "data.frame"



> myData <- as.matrix(myData)

> myData

  V1 V2 V3

1  1  2  3

2  4  5  6



> typeof(myData)

[1] "integer"

> class(myData)

[1] "matrix"



==



Dummy.txt

1,,3

4,2.5,6



# 2.  Doubles, missing values; "as.matrix" good enough for conversion

# Results make sense.

> myData <- read.table('Dummy.txt',sep=',')

> myData <- as.matrix(myData)

> myData

  V1  V2 V3

1  1  NA  3

2  4 2.5  6



> typeof(myData)

[1] "double"

> class(myData)

[1] "matrix"



==



Dummy.txt

1,,3



# 3.  Drop second row of data from 2 above.  Now instead of integers or
doubles,

# the type is "character" after using as.matrix?

# Results don't make sense.  Why did dropping the second row of data change

# the type to "character" here?

> myData <- read.table('Dummy.txt',sep=',')

> myData <- as.matrix(myData)

> myData

  V1  V2 V3

1 "1" NA "3"



> typeof(myData)

[1] "character"

> class(myData)

[1] "matrix"

==



Dummy.txt

1,,3



# 4.  More complicated solution than 3 above, like what Duncan suggested,

# but this gives expected results

> myData <- read.table('Dummy.txt',sep=',')

> myData <- as.matrix(as.data.frame(lapply(myData,as.numeric)))

> myData

  V1 V2 V3

1  1 NA  3



> typeof(myData)

[1] "double"

> class(myData)

[1] "matrix"



==


Thanks for any help in clarifying this R subtilty.

efg
--
Earl F. Glynn
Scientific Programmer
Stowers Institute for Medical 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] pstoedit

2005-04-13 Thread Mike Prager
Ted,
Have you tried bringing the eps files directly into Word?  The version I am 
using (Word 2002 = Word 10.x) can incorporate eps files and even generates 
its own previews.

Maybe you don't need to make the conversion at all.
Regards,
...Mike

At 4/13/2005 04:36 AM, you wrote:
On 13-Apr-05 Prof Brian Ripley wrote:
> On Wed, 13 Apr 2005, BORGULYA [iso-8859-2] Gábor wrote:
>
>>Has onyone experience with "pstoedit"
>>(http://www.pstoedit.net/pstoedit)
>> to convert eps graphs generated by R on Linux to Windows
>> formats (WMF or EMF)? Does this way work? Is there an other,
>> better way?
>
> You can only do that using pstoedit on Windows.
>  ^^
Well, I have pstoedit on Linux and with
  pstoedit -f emf infile.eps outfile.emf
I get what is claimed to be "Enhanced Windows metafile"
and which can be imported into Word (though then it is
subsequently somewhat resistant to editing operations,
such as rotating if it's the wrong way up).
On the other hand,
  pstoedit -f wmf infile.eps outfile.wmf
which is supposed to produce a Windows metafile, produces
something which Word resists importing.
Best wishes to all,
Ted.

E-Mail: (Ted Harding) <[EMAIL PROTECTED]>
Fax-to-email: +44 (0)870 094 0861
Date: 13-Apr-05   Time: 09:36:21
-- XFMail --
__
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
--
Michael Prager, Ph.D.
Population Dynamics Team, NMFS SE Fisheries Science Center
NOAA Center for Coastal Fisheries and Habitat Research
Beaufort, North Carolina  28516
http://shrimp.ccfhrb.noaa.gov/~mprager/
__
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] Perhaps Off-topic lme question

2005-04-13 Thread Berton Gunter
Many thanks, Doug.

Your explanation was clear and informative. I appreciate your taking the
time.


-- Bert Gunter
Genentech Non-Clinical Statistics
South San Francisco, CA

__
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] R in Windows

2005-04-13 Thread George Kelley
Has anyone tried to create dialog boxes for Windows in R so that one
doesn't have to type in so much information but rather enter it in a
menu-based format. If not, does anyone plan on doing this in the future
if it's possible?

Thanks.

George (Kelley)

George A. Kelley, DA, FACSM 
Professor & Director, Meta-Analytic Research Group 
School of Medicine 
Department of Community Medicine 
PO Box 9190 
Robert C. Byrd Health Sciences Center 
Room 2350-A
West Virginia University 
Morgantown, WV 26506-9190 
Office Phone: 304-293-6279 
Lab Phone: 304-293-6280  
Fax: 304-293-5891 
E-mail: [EMAIL PROTECTED]
Website: http://www.hsc.wvu.edu/som/cmed

__
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.packages and MacOS 10.3.8

2005-04-13 Thread Patrick Giraudoux
Dear Uwe,
That install.binaries() was exactly what I needed...
Thanks a lot.
Uwe Ligges a écrit :
Patrick Giraudoux wrote:
Dear Listers,
I am trying to install packages via install.packages() from MacOS 
10.3.8. Installing work fine when run from the menu, but the 
following command (useful for setting up each computer of the student 
computer room)  leads nowhere for some reasons:

pack<-c("ade4","adehabitat","geoR","gstat","KernSmooth","lattice","leaps") 

install.packages(pack,dependencies=T)

trying URL `http://cran.r-project.org/src/contrib/PACKAGES'
Content type `text/plain; charset=iso-8859-1' length 51500 bytes
opened URL
==
downloaded 50Kb
also installing the dependencies 'SparseM', 'gee', 'waveslim', 
'splancs', 'maptools', 'spdep', 'pixmap', 'ape', 'tripack'

trying URL `http://cran.r-project.org/src/contrib/SparseM_0.60.tar.gz'

[SNIP]

* Installing *source* package 'SparseM' ...
** libs
/Library/Frameworks/R.framework/Resources/bin/SHLIB: line 1: make: 
command not found
ERROR: compilation failed for package 'SparseM'
* Installing *source* package 'gee' ...
** libs
/Library/Frameworks/R.framework/Resources/bin/SHLIB: line 1: make: 
command not found
ERROR: compilation failed for package 'gee'

etc...
Can anybody tell me what goes wrong with this command (which usually 
work without any problem with R 2.0.1 and Windows XP).

So at least "make" and probably much more is missing on your machines 
(or not in your path or whatever). You might want to try 
install.binaries() instead (which is similar to install.packages() on 
Windows, since it installs binary packages rather than trying to 
compile and install source packages) - or set up your machines with 
the required set of tools.

Uwe Ligges


Thanks in advance,
Patrick
__
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] Binary Matrices

2005-04-13 Thread Mark Edmondson-Jones
1000x1000 is only indicative.  I need to generate larger (adjacency) matrices 
using a variety of models.

Most are sparse, with a high proportion of zeros and so SparseM sounds very 
promising.  I will investigate.

Thanks,
Mark

>>> "Liaw, Andy" <[EMAIL PROTECTED]> 13/04/2005 >>>


> -Original Message-
> From: Uwe Ligges
> 
> Mark Edmondson-Jones wrote:
> 
> > I'm wanting to perform analysis (e.g. using eigen()) of 
> binary matrices - i.e. matrices comprising 0s and 1s.
> > 
> > For example:
> > 
> > n<-1000
> > test.mat<-matrix(round(runif(n^2)),n,n)
> > eigen(test.mat,only.values=T)
> > 
> > Is there a more efficient way of setting up test.mat, as 
> each cell only requires a binary digit?  I imagine R is 
> setting up a structure which could contain n^2 floats.
> 
> No. In principle you could use logicals,

... but that doesn't save any memory:

> object.size(integer(1e6))
[1] 428
> object.size(logical(1e6))
[1] 428

> but that does not help for further calculations in eigen().

Besides, if the problem size is really 1000 x 1000, one matrix in 
double precision is only 8MB.  As Reid said, if the matrix is sparse,
there's probably a lot more saving in both memory and computation
by using SparseM and Matrix packages.

Cheers,
Andy

 
> Uwe Ligges
> 
> 
> > Thanks in advance for any help.
> > 
> > Regards,
> > Mark
> > 
> > 
> > This message has been checked for viruses but the contents 
> of an attachment
> > may still contain software viruses, which could damage your 
> computer system:
> > you are advised to perform your own checks. Email 
> communications with the
> > University of Nottingham may be monitored as permitted by 
> UK legislation.
> > 
> > __
> > 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 
> 
> 
> 



--

--


This message has been checked for viruses but the contents of an attachment
may still contain software viruses, which could damage your computer system:
you are advised to perform your own checks. Email communications with the
University of Nottingham may be monitored as permitted by UK legislation.

__
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] Binary Matrices

2005-04-13 Thread Liaw, Andy


> -Original Message-
> From: Uwe Ligges
> 
> Mark Edmondson-Jones wrote:
> 
> > I'm wanting to perform analysis (e.g. using eigen()) of 
> binary matrices - i.e. matrices comprising 0s and 1s.
> > 
> > For example:
> > 
> > n<-1000
> > test.mat<-matrix(round(runif(n^2)),n,n)
> > eigen(test.mat,only.values=T)
> > 
> > Is there a more efficient way of setting up test.mat, as 
> each cell only requires a binary digit?  I imagine R is 
> setting up a structure which could contain n^2 floats.
> 
> No. In principle you could use logicals,

... but that doesn't save any memory:

> object.size(integer(1e6))
[1] 428
> object.size(logical(1e6))
[1] 428

> but that does not help for further calculations in eigen().

Besides, if the problem size is really 1000 x 1000, one matrix in 
double precision is only 8MB.  As Reid said, if the matrix is sparse,
there's probably a lot more saving in both memory and computation
by using SparseM and Matrix packages.

Cheers,
Andy

 
> Uwe Ligges
> 
> 
> > Thanks in advance for any help.
> > 
> > Regards,
> > Mark
> > 
> > 
> > This message has been checked for viruses but the contents 
> of an attachment
> > may still contain software viruses, which could damage your 
> computer system:
> > you are advised to perform your own checks. Email 
> communications with the
> > University of Nottingham may be monitored as permitted by 
> UK legislation.
> > 
> > __
> > 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] Behavior of apply() when used with start()

2005-04-13 Thread Fernando Saldanha
Can someone explain why starts1 and starts2 are diffferent in the example below?

After running this program

a <- c(1:3)
b <- c(2:3)
tsa <- ts(a)
tsb <- ts(b, start = 2)
arr <- cbind(tsa, tsb)
starts1 <- cbind(start(tsa), start(tsb))
starts2 <- apply(arr, 2, start)

I get:

> starts1
 [,1] [,2]
[1,]12
[2,]11

> starts2
 tsa tsb
[1,]   1   1
[2,]   1   1

Thanks for the help.

FS

__
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] Fluctuating asymmetry and measurement error

2005-04-13 Thread Andrew Higginson
Hi all, 

Has anyone tested for FA in R? I need to seperate out the variance due to 
measurement error from variation between individuals (following Palmer & 
Strobeck 1986). 



Andy Higginson

Animal Behaviour and Ecology Research Group
School of Biology
University of Nottingham
NG7 2RD
U.K.


This message has been checked for viruses but the contents of an attachment
may still contain software viruses, which could damage your computer system:
you are advised to perform your own checks. Email communications with the
University of Nottingham may be monitored as permitted by UK legislation.

__
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] Perhaps Off-topic lme question

2005-04-13 Thread Douglas Bates
Berton Gunter wrote:
A question on lme() :
details: nlme() in R 2.1.0 beta or 2.0.1
The data,y, consisted of 82 data value in 5 groups of sizes   3  9  8 28 34
.
I fit a simple one level random effects model by:
myfit <- lme( y~1, rand = ~1|Group)
The REML estimates of between and within Group effects are .0032 and .53,
respectively; the between group component is essentially zero as is clearly
evident from a plot of the data. So, thus far, no problem.
However, the confidence interval for the between Groups sd that I get from
intervals(myfit) goes from essentially 0 to infinity (6 x 10^13, actually).
I assume that this is because the between component estimate is too close to
the boundary of 0 so that the likelihood approximations with default
control values fail, but I would appreciate a more definitive comment from
someone who knows what they're talking about. 

If anyone cares to try this, the data in group order are below (i.e., first
3 from Group 1, next 9 from Group 2, etc.).
The REML and ML estimates for the variance component associated with 
groups in these data are zero but the way they are estimated in the lme 
function will always provide non-zero estimates.   As you have seen the 
intervals constructed in such cases are essentially [0, infinity).

The lmer function in the lme4 package does somewhat better in that it 
shows that the estimates are on the boundary of the parameter space. 
For technical reasons at present that boundary is not at zero but at a 
very small value - a relative variance of 10^{-10}.  (The optimization 
uses an analytic gradient and I haven't worked out what to give the 
optimizer for the gradient when the relative variance is zero so I use a 
small positive value for the boundary instead.)  However, if you use a 
value greater than 2 for the msVerbose control option you will see that 
the optimizer has converged on the boundary.

> bert <- data.frame(grp = factor(rep(1:5, c(3, 9, 8, 28, 34))), resp = 
scan("/tmp/bert.txt"))
Read 82 items
> library(lme4)
> (fm1 <- lmer(resp ~ 1 + (1|grp), bert, control = list(msV=3)))
N = 1, M = 5 machine precision = 2.22045e-16
At X0, 0 variables are exactly at the bounds
At iterate 0  f=   132.39  |proj g|=0.0084942

iterations 1
function evaluations 2
segments explored during Cauchy searches 1
BFGS updates skipped 0
active bounds at final generalized Cauchy point 1
norm of the final projected gradient 0
final function value 132.1
F = 132.1
final  value 132.099870
converged
Linear mixed-effects model fit by REML
Formula: resp ~ 1 + (1 | grp)
   Data: bert
  AIC  BIClogLik MLdeviance REMLdeviance
 138.0999 145.3200 -66.04993   128.2635 132.0999
Random effects:
 Groups   NameVariance   Std.Dev.
 grp  (Intercept) 2.8325e-11 5.3221e-06
 Residual 2.8325e-01 5.3221e-01
# of obs: 82, groups: grp, 5
Fixed effects:
 Estimate Std. Error DF t value  Pr(>|t|)
(Intercept) 15.352683   0.058773 81  261.22 < 2.2e-16
The important information from the optimizer is that there is 1 active 
bound at the final point.  Also the estimate for the variance component 
for grp is exactly 1e-10 times the variance component from the residual.

__
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] R binaries for UMBUTU Linux?

2005-04-13 Thread Dirk Eddelbuettel
Peter Dalgaard  biostat.ku.dk> writes:
> Derek Eder  sdskliniken.se> writes:
> 
> > Has anyone out there compiled R for the Umbutu Linux* (neà Debian) v.
> > 5.04 distribution for Intel-type platforms (32 and 64 bit) ?
[...]
> 
> Er, U*bun*tu, you mean? I believe you just use the standard Debian
> packages and tools like apt-get to install them.
> 
> Have a look at
> 
> http://tolstoy.newcastle.edu.au/R/help/05/02/11878.html
> 
> (which shows that Dirk cannot spell it either...) and related messages
> in that thread.

Yes, I think we can reject the null hypothesis of "Dirk can type" at all
convential significance levels.

Dirk

__
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] Binary Matrices

2005-04-13 Thread Huntsinger, Reid
Actually n^2 doubles. You could insert as.integer() around the call to
round(runif()), to make the matrix have storage mode "integer", but when you
call "eigen" you need a matrix of doubles anyway, so you're not really
saving space. 

If your matrices are large and have mostly zeros, you might benefit from the
SparseM package or the Matrix package.

Reid Huntsinger

-Original Message-
From: [EMAIL PROTECTED]
[mailto:[EMAIL PROTECTED] On Behalf Of Mark Edmondson-Jones
Sent: Wednesday, April 13, 2005 9:51 AM
To: r-help@stat.math.ethz.ch
Subject: [R] Binary Matrices


I'm wanting to perform analysis (e.g. using eigen()) of binary matrices -
i.e. matrices comprising 0s and 1s.

For example:

n<-1000
test.mat<-matrix(round(runif(n^2)),n,n)
eigen(test.mat,only.values=T)

Is there a more efficient way of setting up test.mat, as each cell only
requires a binary digit?  I imagine R is setting up a structure which could
contain n^2 floats.

Thanks in advance for any help.

Regards,
Mark


This message has been checked for viruses but the contents of an attachment
may still contain software viruses, which could damage your computer system:
you are advised to perform your own checks. Email communications with the
University of Nottingham may be monitored as permitted by UK legislation.

__
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] Data Mining in Europe, please advise

2005-04-13 Thread Lisa Solomon
 Our CEO, Dr. Dan Steinberg, is planning to visit Europe in May. He 
would like the opportunity to introduce statisticians (and statistically 
minded people) to data mining, data mining applications and to forefront 
data mining tools. Our algorithms are probably familiar to many 
statisticians (CART, MARS, MART, TreeNet and RandomForests), although it 
isn't necessary to be a statistician to use our tools. We co-develop 
with Jerome Friedman of Stanford University and Leo Breiman of Berkeley.

I am trying to locate people/companies who would benefit from data 
mining. If you know of any, I would appreciate it if you would let me know.
Below is a list of presentations from our recent conferences. This will 
give you a sense of our customers and how they currently use our tools.

Please contact me directly if you would like for me to arrange an onsite 
meeting with Dr. Steinberg. In a meeting, he could demo our tools….even 
on your data. And if any of the presentations (listed below) interest 
you, please let me know.

Sincerely,
Lisa Solomon
[EMAIL PROTECTED] 
 

001-619-543-8880 x109
PRESENTATION TITLES AND SPEAKERS
BUSINESS-ORIENTED (BIOMED-ORIENTED FOLLOWS)
Beng-Hai Chea
Citibank, N. A.
Committee of Decision Trees Solution for Personal Bankruptcy Prediction
David Goldsmith
MDT Advisers,
Combined Time Series and Cross Sectional CART Modeling for Common Stock
Selection
Whitney W. Olsen, MD
Olsen Capital Management
Does Using CART Need to be Complex? Or, Exploiting the Predictive 
Structure of Financial Time Series in the Presence of Intermittent High 
Order Chaos

Arnab Dey and Ritesh Aggarwal
Inductis
Application of CART in Determining Reserve Levels for Customer Loyalty 
Points

Paolo Manasse
International Monetary Fund
Rules of Thumb" for Sovereign Debt Crises
Ali Moazami, MortgageIT Holdings Inc. and Shaolin Li, BlackRock
"Mortgage Business Transformation Program using CART-based Joint Risk 
Modeling with practical discussion of CART/TreeNet"

Glenn Hofmann
HSBC
"Marketing Strategies for Retail Customers Based on Predictive Behavior 
Models"

John Trimble
Wells Fargo Bank
Improving Customer Retention by Identifying Characteristics of Auto Loan 
Prepayers using Mars

David Poole
AT&T Labs - Research
An Out-of-Memory Implementation of the PRIM Procedure for Massive Datasets
Don Cozine
BarnesandNoble.com
CART for Prim-like Analysis to Augment Predefined Market Zones, Boost 
Response Rates for Direct Mail Campaigns and to Identify and Exclude 
Irrelevant Subsections of a Heterogeneous Database from Modeling

Dennis Newhart
International Steel Group
Using CART to Analyze and Improve Operating and Quality Issues in the 
Steel Industry with Perspectives on Six Sigma

Linus Nilsson
Capgemini
Fault Detection in Industrial Process Plants using CART and MARS
Larry Lai, DIRECTV, Inc.
Variable Derivation and Selection For Customer Churn Models
Jon Farrar
Union Bank's Use of CART to Identify Customer Attrition and Screen
Application Fraud
BIOMEDICAL PRESENTATIONS:
Data Mining for Epidemiological Research: Identifying Relationships That 
Cannot Be Identified In Any Other Way
Shenghan Lai, Johns Hopkins Medical School

Drug Discovery Clinical Trials and Random Forests at Novartis
John Warner, Novartis
Model Drift in a Predictive Model of Obstructive Sleep Apnea
Brydon Grant, University of Buffalo Medical School
Using MARS for the Prediction of the Apnea-Hypopnea Index
Brydon Grant, University of Buffalo Medical School
Using CART and TreeNet to Discern Models in Genetics: Alzheimer Disease, 
Alcoholism, Cocaine Addiction and Aging
Marsha Wilcox, Boston University Medical School

Comparison of Several Tree-Based Methods to Detect Complex Gene 
Interactions
Laurent Briollais, Mount Sinai Hospital

Using CART to Develop a Diagnostic Tool for Erectile Dysfunction
Joseph C. Cappelleri, Pfizer
Models for Recurrence of Low Back Disorder in Industry: A Comparison of 
Logistic Regression and CART
Deborah Burr, Ohio State University School of Public Health

A Comparison of Hybrid CART/TreeNET - Generalized Additive Model and 
Support Vector Machine Tools for Drug Discovery and Pre-Clinical Drug 
Development
Wayne Danter, Critical Outcome Technologies, Inc.

Drug Discovery using CART and MARS
Wayne Danter, Critical Outcome Technologies, Inc.
Application of CART for the Control of Bacroftian Filariasis (leading to 
elephantitis and West Nile. Fever) in Andara Pradesh, India
U. Suryanarayana Murty, Indian Institute of Chemical Technology

Generating a Connected Weighted Graph for the Analysis of HIV Data Using 
CART 5
George Towfic, Clarke College

Umbilical Cord Length, Other Placental Growth Measures, Placental Weight 
and Birthweight
Carrie Salafia, Columbia University School of Public Health

Experiences when applying MARS and CART in the Disciplines of 
Biodiversity, Conservation and Wildlife Modeling: The GIS Link
Falk Huettmann, Inst

Re: [R] Binary Matrices

2005-04-13 Thread Dimitris Rizopoulos
you mean something like this:
matrix(sample(0:1, n*n, TRUE), n, n)
I hope it helps.
Best,
Dimitris

Dimitris Rizopoulos
Ph.D. Student
Biostatistical Centre
School of Public Health
Catholic University of Leuven
Address: Kapucijnenvoer 35, Leuven, Belgium
Tel: +32/16/336899
Fax: +32/16/337015
Web: http://www.med.kuleuven.ac.be/biostat/
http://www.student.kuleuven.ac.be/~m0390867/dimitris.htm
- Original Message - 
From: "Mark Edmondson-Jones" <[EMAIL PROTECTED]>
To: 
Sent: Wednesday, April 13, 2005 3:50 PM
Subject: [R] Binary Matrices


I'm wanting to perform analysis (e.g. using eigen()) of binary 
matrices - i.e. matrices comprising 0s and 1s.

For example:
n<-1000
test.mat<-matrix(round(runif(n^2)),n,n)
eigen(test.mat,only.values=T)
Is there a more efficient way of setting up test.mat, as each cell 
only requires a binary digit?  I imagine R is setting up a structure 
which could contain n^2 floats.

Thanks in advance for any help.
Regards,
Mark
This message has been checked for viruses but the contents of an 
attachment
may still contain software viruses, which could damage your computer 
system:
you are advised to perform your own checks. Email communications 
with the
University of Nottingham may be monitored as permitted by UK 
legislation.

__
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] Binary Matrices

2005-04-13 Thread Uwe Ligges
Mark Edmondson-Jones wrote:
I'm wanting to perform analysis (e.g. using eigen()) of binary matrices - i.e. 
matrices comprising 0s and 1s.
For example:
n<-1000
test.mat<-matrix(round(runif(n^2)),n,n)
eigen(test.mat,only.values=T)
Is there a more efficient way of setting up test.mat, as each cell only requires a binary digit?  I imagine R is setting up a structure which could contain n^2 floats.
No. In principle you could use logicals, but that does not help for 
further calculations in eigen().

Uwe Ligges

Thanks in advance for any help.
Regards,
Mark
This message has been checked for viruses but the contents of an attachment
may still contain software viruses, which could damage your computer system:
you are advised to perform your own checks. Email communications with the
University of Nottingham may be monitored as permitted by UK legislation.
__
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] questions about discriminant analysis

2005-04-13 Thread ronggui
i konw the lda and qda in MASS can do discriminant analysis.and lda complete 
the Fisher's method.and qda is the Quadratic discriminant analysis.
1,my first question is if qda do the Mahalanobis's method?
2,as some textbook say,when using fisher's method,"we proceed by assuming that 
the within-group covariance structure for our data is the same across 
groups",so we need test for equailty of covariance matrices. my question is 
:when i using lda,should i test equailty of covariance matrices first? and can 
R do these?

thank you !

__
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] Binary Matrices

2005-04-13 Thread Mark Edmondson-Jones
I'm wanting to perform analysis (e.g. using eigen()) of binary matrices - i.e. 
matrices comprising 0s and 1s.

For example:

n<-1000
test.mat<-matrix(round(runif(n^2)),n,n)
eigen(test.mat,only.values=T)

Is there a more efficient way of setting up test.mat, as each cell only 
requires a binary digit?  I imagine R is setting up a structure which could 
contain n^2 floats.

Thanks in advance for any help.

Regards,
Mark


This message has been checked for viruses but the contents of an attachment
may still contain software viruses, which could damage your computer system:
you are advised to perform your own checks. Email communications with the
University of Nottingham may be monitored as permitted by UK legislation.

__
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] R binaries for UMBUTU Linux?

2005-04-13 Thread Jari Oksanen
On Wed, 2005-04-13 at 15:19 +0200, Derek Eder wrote:
> Has anyone out there compiled R for the Umbutu Linux* (neé Debian) v.
> 5.04 distribution for Intel-type platforms (32 and 64 bit) ?
> 
> Thank you,
> 
> Derek Eder
> 
> * Umbutu, a popular new Linux distribution, not a Nigerian scam, I
> promise!http://www.ubuntulinux.org/
> 
Well, if you mean Ubuntu (and Debian is still there: she's not married
to Ubuntu but kept her name), I have some experience (though not on
Intel -- later about that). First, it seems that R is not in standard
Ubuntu base, but you can find it in the "universe", and install as a
binary. However, the rhythms are a bit off. Previous Ubuntu release was
about simultaneously with the R-2.0.x release, and you got R-1.9.1 in
Ubuntu. The current release of Ubuntu was last week, and R is up to next
week. This means that you're lagging behind by one cycle in R with these
predictable and regular release cycles. However, Ubuntu is a Linux which
means that you can compile R from the sources quite easily. I did this
with Ubuntu 4.04, and compilation went smoothly (like usually). However,
I did this in ppc (32bit, or G4), and some tests failed (at least in
'foreign': I haven't studied this in more detail). The base R seems to
work OK, though. Alternatively, you can use real Debian packages from
its testing repository. Ubuntu does not recommend using native Debian
packages, but I guess with R you can do this fairly safely (the general
problem is a potential conflict in version naming which may lead to
conflicts in upgrades, but I think this is OK with R). So you may get
the latest Debian (testing) packages -- as soon as they get through the
jungle of dependencies and appear in Debian.

cheers, jari oksanen
-- 
Jari Oksanen -- Dept Biology, Univ Oulu, 90014 Oulu, Finland

__
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] R binaries for UMBUTU Linux?

2005-04-13 Thread Peter Dalgaard
Derek Eder <[EMAIL PROTECTED]> writes:

> Has anyone out there compiled R for the Umbutu Linux* (neé Debian) v.
> 5.04 distribution for Intel-type platforms (32 and 64 bit) ?
> 
> Thank you,
> 
> Derek Eder

Er, U*bun*tu, you mean? I believe you just use the standard Debian
packages and tools like apt-get to install them.

Have a look at

http://tolstoy.newcastle.edu.au/R/help/05/02/11878.html

(which shows that Dirk cannot spell it either...) and related messages
in that thread.

-- 
   O__   Peter Dalgaard Blegdamsvej 3  
  c/ /'_ --- Dept. of Biostatistics 2200 Cph. N   
 (*) \(*) -- University of Copenhagen   Denmark  Ph: (+45) 35327918
~~ - ([EMAIL PROTECTED]) FAX: (+45) 35327907

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


Re: [R] R binaries for UMBUTU Linux?

2005-04-13 Thread Barry Rowlingson
Derek Eder wrote:
Has anyone out there compiled R for the Umbutu Linux* (neé Debian) v.
5.04 distribution for Intel-type platforms (32 and 64 bit) ?

* Umbutu, a popular new Linux distribution, not a Nigerian scam, I
promise!http://www.ubuntulinux.org/
 That's 'Ubuntu'.
 If you run the package manager ("synaptic") and set up your repository 
settings to include 'universe' then you should see a bunch of R-related 
stuff in the 'Mathematics (universe)' section, for R 2.0.1. You should 
then be only a few clicks away from an R install.

 If you need any help setting up the Ubuntu package manager in this 
way, best to ask on an Ubuntu discussion list.

Baz
__
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] R binaries for Ubuntu (!) Linux?

2005-04-13 Thread Martin Maechler
When I set up an old weak PC to become a "real workstation" at
home, by installing Ubuntu (spelling!),
I was able to quickly get many debian packages that were not
part of ubuntu proper (including "R-base-dev", "ess") by
outcommenting something like "universe" (forgot the exact name)
in the /etc/apt/sources.list file, and then simply something like

apt-get install r-base-dev
apt-get install r-recommended
apt-get install r-doc-info
apt-get install ess

Martin Maechler, ETH Zurich

> "Derek" == Derek Eder <[EMAIL PROTECTED]>
> on Wed, 13 Apr 2005 15:19:19 +0200 writes:

Derek> Has anyone out there compiled R for the Umbutu Linux* (neé Debian) v.
Derek> 5.04 distribution for Intel-type platforms (32 and 64 bit) ?

Derek> Thank you,

Derek> Derek Eder

Derek> * Umbutu, a popular new Linux distribution, not a Nigerian scam, I
Derek> promise!http://www.ubuntulinux.org/

Please fix the spelling, it's  "ubuntu" -- how do you manage to
achieve two typos in one word ?!

__
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] easy question: obtaining rw1080.exe

2005-04-13 Thread Liaw, Andy
> From: Uwe Ligges
> 
> Wisz, Mary Susanne wrote:
> > Dear All,
> > Can anyone please tell me where I can obtain  uncompiled binary
> 
> You mean "compiled", for sure.
> 
> > instalation  files for R version 1.8. (i.e. rw1080.exe)?
> 
> Why do you want an outdated version of R?
> 
> Binaries are not archived on CRAN. You can either try to compile 
> yourself or send me a private message - I could put that 
> OUTDATED binary 
> up on our web server for you.

Just googling for `rw1080.exe' turns up:
http://mcs.une.edu.au/~nkn/resource/
which has http://mcs.une.edu.au/~nkn/resource/rw1080.exe

Andy
 
> Uwe
> 
> >  
> > I can only find the uncompiled source code on CRAN today.
> >  
> > Thank you,
> > Mary Wisz
> > [EMAIL PROTECTED]
> > 
> > [[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
> 
> 
>

__
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] R binaries for UMBUTU Linux?

2005-04-13 Thread Derek Eder
Has anyone out there compiled R for the Umbutu Linux* (neé Debian) v.
5.04 distribution for Intel-type platforms (32 and 64 bit) ?
Thank you,
Derek Eder
* Umbutu, a popular new Linux distribution, not a Nigerian scam, I
promise!http://www.ubuntulinux.org/
--
Derek Eder
SDS KLINIKEN
Vasaplatsen 8
SE 411 34 Göteborg (Gothenburg) Sweden
phone: +46 (31)* - 10 77 80
  fax: +46 (31)* - 10 77 81
mobile: +46 (31)* 0709 721 283
* note:  (031) within Sweden
webpage:  www.sdskliniken.se
  www.neuro.gu.se/sad
__
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.packages and MacOS 10.3.8

2005-04-13 Thread Uwe Ligges
Patrick Giraudoux wrote:
Dear Listers,
I am trying to install packages via install.packages() from MacOS 
10.3.8. Installing work fine when run from the menu, but the following 
command (useful for setting up each computer of the student computer 
room)  leads nowhere for some reasons:

pack<-c("ade4","adehabitat","geoR","gstat","KernSmooth","lattice","leaps") 

install.packages(pack,dependencies=T)

trying URL `http://cran.r-project.org/src/contrib/PACKAGES'
Content type `text/plain; charset=iso-8859-1' length 51500 bytes
opened URL
==
downloaded 50Kb
also installing the dependencies 'SparseM', 'gee', 'waveslim', 
'splancs', 'maptools', 'spdep', 'pixmap', 'ape', 'tripack'

trying URL `http://cran.r-project.org/src/contrib/SparseM_0.60.tar.gz'

[SNIP]

* Installing *source* package 'SparseM' ...
** libs
/Library/Frameworks/R.framework/Resources/bin/SHLIB: line 1: make: 
command not found
ERROR: compilation failed for package 'SparseM'
* Installing *source* package 'gee' ...
** libs
/Library/Frameworks/R.framework/Resources/bin/SHLIB: line 1: make: 
command not found
ERROR: compilation failed for package 'gee'

etc...
Can anybody tell me what goes wrong with this command (which usually 
work without any problem with R 2.0.1 and Windows XP).

So at least "make" and probably much more is missing on your machines 
(or not in your path or whatever). You might want to try 
install.binaries() instead (which is similar to install.packages() on 
Windows, since it installs binary packages rather than trying to compile 
and install source packages) - or set up your machines with the required 
set of tools.

Uwe Ligges


Thanks in advance,
Patrick
__
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] easy question: obtaining rw1080.exe

2005-04-13 Thread Uwe Ligges
Wisz, Mary Susanne wrote:
Dear All,
Can anyone please tell me where I can obtain  uncompiled binary
You mean "compiled", for sure.
instalation  files for R version 1.8. (i.e. rw1080.exe)?
Why do you want an outdated version of R?
Binaries are not archived on CRAN. You can either try to compile 
yourself or send me a private message - I could put that OUTDATED binary 
up on our web server for you.

Uwe
 
I can only find the uncompiled source code on CRAN today.
 
Thank you,
Mary Wisz
[EMAIL PROTECTED]

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


[R] install.packages and MacOS 10.3.8

2005-04-13 Thread Patrick Giraudoux
Dear Listers,
I am trying to install packages via install.packages() from MacOS 
10.3.8. Installing work fine when run from the menu, but the following 
command (useful for setting up each computer of the student computer 
room)  leads nowhere for some reasons:

pack<-c("ade4","adehabitat","geoR","gstat","KernSmooth","lattice","leaps")
install.packages(pack,dependencies=T)
trying URL `http://cran.r-project.org/src/contrib/PACKAGES'
Content type `text/plain; charset=iso-8859-1' length 51500 bytes
opened URL
==
downloaded 50Kb
also installing the dependencies 'SparseM', 'gee', 'waveslim', 'splancs', 'maptools', 
'spdep', 'pixmap', 'ape', 'tripack'

trying URL `http://cran.r-project.org/src/contrib/SparseM_0.60.tar.gz'
Content type `application/x-tar' length 1064262 bytes
opened URL
==
downloaded 1039Kb
trying URL `http://cran.r-project.org/src/contrib/gee_4.13-10.tar.gz'
Content type `application/x-tar' length 49586 bytes
opened URL
==
downloaded 48Kb
trying URL `http://cran.r-project.org/src/contrib/waveslim_1.4.tar.gz'
Content type `application/x-tar' length 358305 bytes
opened URL
==
(etc)
* Installing *source* package 'SparseM' ...
** libs
/Library/Frameworks/R.framework/Resources/bin/SHLIB: line 1: make: command not 
found
ERROR: compilation failed for package 'SparseM'
* Installing *source* package 'gee' ...
** libs
/Library/Frameworks/R.framework/Resources/bin/SHLIB: line 1: make: command not 
found
ERROR: compilation failed for package 'gee'

etc...
Can anybody tell me what goes wrong with this command (which usually 
work without any problem with R 2.0.1 and Windows XP).

Thanks in advance,
Patrick
__
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] pstoedit

2005-04-13 Thread Ted Harding
On 13-Apr-05 Prof Brian Ripley wrote:
> On Wed, 13 Apr 2005 [EMAIL PROTECTED] wrote:
> 
>> On 13-Apr-05 Prof Brian Ripley wrote:
>>> On Wed, 13 Apr 2005, BORGULYA [iso-8859-2] Gábor wrote:
>>>
Has onyone experience with "pstoedit"
(http://www.pstoedit.net/pstoedit)
 to convert eps graphs generated by R on Linux to Windows
 formats (WMF or EMF)? Does this way work? Is there an other,
 better way?
>>>
>>> You can only do that using pstoedit on Windows.
>>>  ^^
>>
>> Well, I have pstoedit on Linux and with
>>
>>  pstoedit -f emf infile.eps outfile.emf
>>
>> I get what is claimed to be "Enhanced Windows metafile"
>> and which can be imported into Word (though then it is
>> subsequently somewhat resistant to editing operations,
>> such as rotating if it's the wrong way up).
> 
> Maybe, but the URL quoted says
> 
> pstoedit 3.40
> 
># Windows Meta Files (WMF) (Windows 9x/NT only)
># Enhanced Windows Meta Files (EMF) (Windows 9x/NT only)
> 
> so the quoted URL claims otherwise for the current version.

Indeed, on the face of it. My version is 3.33 (the predecessor
of 3.4), and it does produce both WMF and EMF files (even if
Windows does not like the WMF files, though able to accept
the EMF files).

However, if from that site (above) you go to the changelog you
can read, under Version 3.40 (changed from 3.33):

#  disabled the WMF driver when libemf is used
   (all non-Windows systems). Libemf does not really
   handle WMF files. A CreateMetaFile effectively
   creates an EnhMetaFile - but that confuses programs
   which expect an real WMF file in a file with a .wmf suffix.

# added a workaround in the EMF driver for a bug/problem in
  the libemf which is used under *nix for EMF generation.
  The problem in libemf is that if text is rendered using the
  simple TextOut function call the resulting EMF file is no
  longer usable under newer versions of Windows.
  For more details see the description of the -nfw option of
  the wmf format driver.

This suggests that while WMF has been disabled for pstoedit
on non-Windows systems, the EMF driver should still work.

However, having only 3.33 at the moment I can't test the above.

However, for others interested it may be worth a try.

(The first "#" also contains a possible explanation why the
".wmf" file I made with the WMF driver wasn't read by Windows:
if it's really an EMF files carrying a ".wmf" filename extension,
and the ".wmf" leads Windows to expect WMF content rather than
the EMF content it really has, then this could happen; but
it didn't like it either when explicitly asked to import it
as an EMF, nor when the extension was changed to ".emf")

Best wishes,
Ted.



E-Mail: (Ted Harding) <[EMAIL PROTECTED]>
Fax-to-email: +44 (0)870 094 0861
Date: 13-Apr-05   Time: 13:44:13
-- XFMail --

__
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] easy question: obtaining rw1080.exe

2005-04-13 Thread Wisz, Mary Susanne
Dear All,
Can anyone please tell me where I can obtain  uncompiled binary
instalation  files for R version 1.8. (i.e. rw1080.exe)?
 
I can only find the uncompiled source code on CRAN today.
 
Thank you,
Mary Wisz
[EMAIL PROTECTED]

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


Re: [R] functions(t.test) on variables by groups

2005-04-13 Thread Peter Dalgaard
Hai Lin <[EMAIL PROTECTED]> writes:

> Dear R users,
> 
> I have a data frame with categorical Vars. "Groups"
> and a couple  columns of numeric Vars. I am trying to
> make two-sample t.test on each variable(s01-s03) by
> Groups.
> 
> A data generated as following:
> 
> zot <- data.frame(Groups=rep(letters[1:2], each=4),
> s01=rnorm(8), s02=rnorm(8), s03=rnorm(8))
> 
> I have written a piece with a for loop. 
> for (i in 1:(length(zot)-1)) {
>   print(t.test(zot[,i+1]~zot[,1]))
>   }
> 
> I wish something can be easier extracted or can save
> it within for loop, or not even using for loop.  

Something like this?

lapply(zot[-1],function(x)t.test(x~zot$Groups))


-- 
   O__   Peter Dalgaard Blegdamsvej 3  
  c/ /'_ --- Dept. of Biostatistics 2200 Cph. N   
 (*) \(*) -- University of Copenhagen   Denmark  Ph: (+45) 35327918
~~ - ([EMAIL PROTECTED]) FAX: (+45) 35327907

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


Re: [R] pstoedit

2005-04-13 Thread A.J. Rossini
On 4/13/05, Prof Brian Ripley <[EMAIL PROTECTED]> wrote:
> On Wed, 13 Apr 2005 [EMAIL PROTECTED] wrote:
> 
> > On 13-Apr-05 Prof Brian Ripley wrote:
> >> On Wed, 13 Apr 2005, BORGULYA [iso-8859-2] Gábor wrote:
> >>
> >>>Has onyone experience with "pstoedit"
> >>>(http://www.pstoedit.net/pstoedit)
> >>> to convert eps graphs generated by R on Linux to Windows
> >>> formats (WMF or EMF)? Does this way work? Is there an other,
> >>> better way?
> >>
> >> You can only do that using pstoedit on Windows.
> >>  ^^
> >
> > Well, I have pstoedit on Linux and with
> >
> >  pstoedit -f emf infile.eps outfile.emf
> >
> > I get what is claimed to be "Enhanced Windows metafile"
> > and which can be imported into Word (though then it is
> > subsequently somewhat resistant to editing operations,
> > such as rotating if it's the wrong way up).
> 
> Maybe, but the URL quoted says
> 
> pstoedit 3.40
> 
> # Windows Meta Files (WMF) (Windows 9x/NT only)
> # Enhanced Windows Meta Files (EMF) (Windows 9x/NT only)
> 
> so the quoted URL claims otherwise for the current version.

If you follow the link for exact support, you find out that it
supports EMF using a

wemf - Wogls version of EMF 
wemfc - Wogls version of EMF with experimental clip support 
wemfnss - Wogls version of EMF - no subpathes 

which is apparently different than the MS Windows EMF support.  How,
it isn't clear from the documentation.


best,
-tony

"Commit early,commit often, and commit in a repository from which we can easily
roll-back your mistakes" (AJR, 4Jan05).

A.J. Rossini
[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] Combine univariate time series

2005-04-13 Thread Gabor Grothendieck
On 4/13/05, Joerg Klausen <[EMAIL PROTECTED]> wrote:
> Hallo everyone
> 
> I have two univariate time series (class ts) describing the same variable. 
> They have the same resolution, but span different periods in time with a big 
> gap in between. I need to append one to the other such that they are one 
> object, with the gap filled with NAs. The method ts.union produces a 
> multivariate time series where the time axis is correct, but the individual 
> time series are not combined into one.
> 

If ts1 and ts2 are two ts series:

both <- ts.union(ts1, ts2)
pmax(both[,1], both[,2], na.rm = TRUE)

__
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 plot Contour with NA in dataframe

2005-04-13 Thread Duncan Murdoch
[EMAIL PROTECTED] wrote:
Dear friends,
I am trying to produce Contour Plot with R, but there are some NA 
in my data matrix. After I ran the following R script, I got the error 
message:"no proper `z' matrix specified". Does anybody know how to plot 
contour chart with R for the non-strict matrix?

Thank you in advance!!!

myData<-read.table('C:/MyDoc/TestData.txt',sep=',')
x <- 10*1:nrow(myData)
y <- 10*1:ncol(myData)
filled.contour(x, y, myData, color = terrain.colors,
plot.title = title(main = "The Topography of Maunga Whau",
xlab = "Meters North", ylab = "Meters West"),
plot.axes = { axis(1, seq(100, 800, by = 100))
  axis(2, seq(100, 600, by = 100)) },
key.title = title(main="Height\n(meters)"),
key.axes = axis(4, seq(4, 8, by = 1)))

C:/myDoc/TestData.txt  is shown as below:
4.95,,5.6250,5.6667,5.90,5.80,5.50,5.70,5.0250,5.90,5.7250,5.75,5.70,5.30,,6,5.50,5.65,,5.7750,5.70,4.90,6.05,,5.4750,5.85,5.55,,,5.8250,5.65,5.75,,5.5750,5.4750,5.3750,5.8750,5.9250,5.55,6.3750,5.70,5.7833,,5.55,
,5.5250,4.856.15,5.8667,,5.20,5.5750,5.74,5.7667,6.7333,6.05,5.8833,5.80,5.8750,,6.15,,5.6250,5.5375,5.65,6,5.8250,5.55,5.85,5.65,5.89,6.15,5.60,,5.65,5.7250,,5.25,6.25,,5.5667,5.9750,6.0250,,,6.35
5.45,,6.30,5.7167,,5.50,6.05,5.8333,5.5833,5.6250,5.70,5.9250,5.7750,6.20,5.5333,5.6625,5.40,5.75,,6,5.5333,,5.6250,5.55,5.65,5.55,5.70,,6.15,5.90,5.7167,6.1167,5.15,6.10,5.4750,,5.75,5.45,5.95,,5.95,5.36676.15,,,
,5.7250,5.75,6,,,5.65,,6.30,5.65,,5.4750,5.60,5.4167,5.8250,,,6.25,6.30,,5.60,6.15,6.10,5.85,,5.8750,5.65,5.9750,5.80,5.65,5.90,6.15,5.5667,5.75,,,6,5.85,5.75,5.7250,5.75
5.75,,6.1167,,5.3250,,5.9167,5.55,,6.05,5.70,5.7250,5.50,6.15,5.40,5.40,5.40,5.70,5.4250,5.7250,5.45,,,5.85,5.85,5.7750,5.8750,5.25,5.45,5.75,5.70,5.65,5.4750,5.7250,5.70,6.10,6.05,5.6875,5.60,,5.80,,,5.65,
5.6250,6.25,5.60,5.90,6.0750,5.80,5.45,5.60,5.50,5.7375,5.60,6,5.9667,5.6833,5.90,5.8333,5.6750,,5.6750,5.7250,5.6833,5.6333,5.65,6.05,,5.57,5.75,5.2750,5.50,,5.6750,5.85,5.6750,6.35,,5.35,
,5.20,,5.5833,5.8333,5.9250,5.7750,5.6667,5.85,5.95,,6.35,5.55,5.3750,,6.30,5.15,5.40,5.55,,5.75,5.45,6.60,,5.45,5.25,,5.25,5.80,5.45,4.80,,5.4250,5.7750,5.15,5.55,5.35,,5.85,5.7667,,,5.60,,
,,,5.15,,6.05,5.4333,5.70,,5.75,6.05,5.15,5.75,5.60,,6.1750,,6.055.5625,5.4167,,5.6250,5.50,5.90,5.95,5.90,6.0250,5.9667,6,5.70,6,5.90,6,5.55,5.8167,5.7750,5.30,,5.77505.40,,,
,6.0667,5.45,5.60,5.55,5.95,5.8750,5.8750,5.80,5.91675.85,5.75,5.5167,,5.8750,,5.45,6.0250,,5.80,5.9375,5.7750,5.5167,,5.8750,5.60,5.8625,5.6333,,5.50,5.2625,5.65,,5.30,5.35,,5.7250,,5.8333,5.85,5.70,,5.30,,,
5.7750,6,5.55,,5.45,5.4125,5.9917,5.50,5.65,5.9750,,,5.7667,5.8333,5.79,5.85,,5.90,5.9833,6.05,,6.3250,6.0750,,5.25,5.85,6.20,,5.45,,,5.65,5.7250,5.9250,6.50,5.35,5.95,,5.8833,5.80,5.95,5.60,5.75,,5.90,6.45,,,
5.6833,5.60,,5.55,5.1250,,6.05,5.75,5.75,5.6833,6,5.55,6.15,5.45,5.70,6.1250,5.67,5.75,5.55,5.35,5.55,5.9750,5.80,5.60,5.9125,5.9375,5.25,5.85,5.4375,6.10,5.55,,,5.6167,5.6167,5.25,6.25,6.1750,5.85,5.5375,5.8250,6.036.10,,,
5.95,5.4667,6.45,5.7375,,5.55,5.6667,5.70,,5.7750,5.50,5.65,5.90,5.8750,5.9750,6,5.6750,,5.8167,,5.50,5.4250,5.65,6,6.1250,5.25,5.90,5.6875,5.6250,,6.2750,6.15,5.7750,5.9250,5.20,5.57,5.92,,5.35,,5.45,5.40,,,
5.65,4.95,5.70,,5.9167,5.3750,5.3750,5.45,5.6167,6.0250,5.8750,5.55,5.85,6.2833,5.9125,5.55,7.85,5.50,6,,5.53,5.35,5.8250,5.75,5.90,5.7167,5.70,5.90,5.4250,5.4750,5.9333,5.95,5.9750,5.45,5.5333,6.2167,5.20,5.10,,5.37,5.7250,5.5167,,,
5.7667,5.65,5.95,,5.95,5.10,5.60,5.70,5.80,5.5625,6.10,5.45,5.5250,,5.6375,6.20,,5.60,5.3750,,5.95,5.5250,5.35,5.70,5.4250,5.75,5.0750,5.60,5.7833,5.50,5.4250,5.85,6.05,5.05,5.7750,,6.20,6.40,5.35,5.6250,5.65,5.755.50,,4.80,
5.9250,5.15,6.0250,5.15,5.40,,6,,,5.8750,,6.10,,5.6750,5.8750,,6.15,6.30,5.80,5.9667,5.95,5.90,5.50,5.8167,5.60,6.0750,5.10,4.95,5.95,5.35,,5.70,6.05,5.7750,5.7250,5.35,5.8250,5.55,5.7667,7.65,5.75,5.825

Re: [R] pstoedit

2005-04-13 Thread Prof Brian Ripley
On Wed, 13 Apr 2005 [EMAIL PROTECTED] wrote:
On 13-Apr-05 Prof Brian Ripley wrote:
On Wed, 13 Apr 2005, BORGULYA [iso-8859-2] Gábor wrote:
   Has onyone experience with "pstoedit"
   (http://www.pstoedit.net/pstoedit)
to convert eps graphs generated by R on Linux to Windows
formats (WMF or EMF)? Does this way work? Is there an other,
better way?
You can only do that using pstoedit on Windows.
 ^^
Well, I have pstoedit on Linux and with
 pstoedit -f emf infile.eps outfile.emf
I get what is claimed to be "Enhanced Windows metafile"
and which can be imported into Word (though then it is
subsequently somewhat resistant to editing operations,
such as rotating if it's the wrong way up).
Maybe, but the URL quoted says
pstoedit 3.40
# Windows Meta Files (WMF) (Windows 9x/NT only)
# Enhanced Windows Meta Files (EMF) (Windows 9x/NT only)
so the quoted URL claims otherwise for the current version.
--
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@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] How to plot Contour with NA in dataframe

2005-04-13 Thread WeiQiang . Li
Dear friends,

I am trying to produce Contour Plot with R, but there are some NA 
in my data matrix. After I ran the following R script, I got the error 
message:"no proper `z' matrix specified". Does anybody know how to plot 
contour chart with R for the non-strict matrix?

Thank you in advance!!!



myData<-read.table('C:/MyDoc/TestData.txt',sep=',')
x <- 10*1:nrow(myData)
y <- 10*1:ncol(myData)
filled.contour(x, y, myData, color = terrain.colors,
plot.title = title(main = "The Topography of Maunga Whau",
xlab = "Meters North", ylab = "Meters West"),
plot.axes = { axis(1, seq(100, 800, by = 100))
  axis(2, seq(100, 600, by = 100)) },
key.title = title(main="Height\n(meters)"),
key.axes = axis(4, seq(4, 8, by = 1)))



C:/myDoc/TestData.txt  is shown as below:

4.95,,5.6250,5.6667,5.90,5.80,5.50,5.70,5.0250,5.90,5.7250,5.75,5.70,5.30,,6,5.50,5.65,,5.7750,5.70,4.90,6.05,,5.4750,5.85,5.55,,,5.8250,5.65,5.75,,5.5750,5.4750,5.3750,5.8750,5.9250,5.55,6.3750,5.70,5.7833,,5.55,
,5.5250,4.856.15,5.8667,,5.20,5.5750,5.74,5.7667,6.7333,6.05,5.8833,5.80,5.8750,,6.15,,5.6250,5.5375,5.65,6,5.8250,5.55,5.85,5.65,5.89,6.15,5.60,,5.65,5.7250,,5.25,6.25,,5.5667,5.9750,6.0250,,,6.35
5.45,,6.30,5.7167,,5.50,6.05,5.8333,5.5833,5.6250,5.70,5.9250,5.7750,6.20,5.5333,5.6625,5.40,5.75,,6,5.5333,,5.6250,5.55,5.65,5.55,5.70,,6.15,5.90,5.7167,6.1167,5.15,6.10,5.4750,,5.75,5.45,5.95,,5.95,5.36676.15,,,
,5.7250,5.75,6,,,5.65,,6.30,5.65,,5.4750,5.60,5.4167,5.8250,,,6.25,6.30,,5.60,6.15,6.10,5.85,,5.8750,5.65,5.9750,5.80,5.65,5.90,6.15,5.5667,5.75,,,6,5.85,5.75,5.7250,5.75
5.75,,6.1167,,5.3250,,5.9167,5.55,,6.05,5.70,5.7250,5.50,6.15,5.40,5.40,5.40,5.70,5.4250,5.7250,5.45,,,5.85,5.85,5.7750,5.8750,5.25,5.45,5.75,5.70,5.65,5.4750,5.7250,5.70,6.10,6.05,5.6875,5.60,,5.80,,,5.65,
5.6250,6.25,5.60,5.90,6.0750,5.80,5.45,5.60,5.50,5.7375,5.60,6,5.9667,5.6833,5.90,5.8333,5.6750,,5.6750,5.7250,5.6833,5.6333,5.65,6.05,,5.57,5.75,5.2750,5.50,,5.6750,5.85,5.6750,6.35,,5.35,
,5.20,,5.5833,5.8333,5.9250,5.7750,5.6667,5.85,5.95,,6.35,5.55,5.3750,,6.30,5.15,5.40,5.55,,5.75,5.45,6.60,,5.45,5.25,,5.25,5.80,5.45,4.80,,5.4250,5.7750,5.15,5.55,5.35,,5.85,5.7667,,,5.60,,
,,,5.15,,6.05,5.4333,5.70,,5.75,6.05,5.15,5.75,5.60,,6.1750,,6.055.5625,5.4167,,5.6250,5.50,5.90,5.95,5.90,6.0250,5.9667,6,5.70,6,5.90,6,5.55,5.8167,5.7750,5.30,,5.77505.40,,,
,6.0667,5.45,5.60,5.55,5.95,5.8750,5.8750,5.80,5.91675.85,5.75,5.5167,,5.8750,,5.45,6.0250,,5.80,5.9375,5.7750,5.5167,,5.8750,5.60,5.8625,5.6333,,5.50,5.2625,5.65,,5.30,5.35,,5.7250,,5.8333,5.85,5.70,,5.30,,,
5.7750,6,5.55,,5.45,5.4125,5.9917,5.50,5.65,5.9750,,,5.7667,5.8333,5.79,5.85,,5.90,5.9833,6.05,,6.3250,6.0750,,5.25,5.85,6.20,,5.45,,,5.65,5.7250,5.9250,6.50,5.35,5.95,,5.8833,5.80,5.95,5.60,5.75,,5.90,6.45,,,
5.6833,5.60,,5.55,5.1250,,6.05,5.75,5.75,5.6833,6,5.55,6.15,5.45,5.70,6.1250,5.67,5.75,5.55,5.35,5.55,5.9750,5.80,5.60,5.9125,5.9375,5.25,5.85,5.4375,6.10,5.55,,,5.6167,5.6167,5.25,6.25,6.1750,5.85,5.5375,5.8250,6.036.10,,,
5.95,5.4667,6.45,5.7375,,5.55,5.6667,5.70,,5.7750,5.50,5.65,5.90,5.8750,5.9750,6,5.6750,,5.8167,,5.50,5.4250,5.65,6,6.1250,5.25,5.90,5.6875,5.6250,,6.2750,6.15,5.7750,5.9250,5.20,5.57,5.92,,5.35,,5.45,5.40,,,
5.65,4.95,5.70,,5.9167,5.3750,5.3750,5.45,5.6167,6.0250,5.8750,5.55,5.85,6.2833,5.9125,5.55,7.85,5.50,6,,5.53,5.35,5.8250,5.75,5.90,5.7167,5.70,5.90,5.4250,5.4750,5.9333,5.95,5.9750,5.45,5.5333,6.2167,5.20,5.10,,5.37,5.7250,5.5167,,,
5.7667,5.65,5.95,,5.95,5.10,5.60,5.70,5.80,5.5625,6.10,5.45,5.5250,,5.6375,6.20,,5.60,5.3750,,5.95,5.5250,5.35,5.70,5.4250,5.75,5.0750,5.60,5.7833,5.50,5.4250,5.85,6.05,5.05,5.7750,,6.20,6.40,5.35,5.6250,5.65,5.755.50,,4.80,
5.9250,5.15,6.0250,5.15,5.40,,6,,,5.8750,,6.10,,5.6750,5.8750,,6.15,6.30,5.80,5.9667,5.95,5.90,5.50,5.8167,5.60,6.0750,5.10,4.95,5.95,5.35,,5.70,6.05,5.7750,5.7250,5.35,5.8250,5.55,5.7667,7.65,5.75,5.8250,,,5.40
6.25,5

Re: [R] R as programming language: references?

2005-04-13 Thread Peter Dalgaard
"Jan T. Kim" <[EMAIL PROTECTED]> writes:

> I don't know what Federico Calboli has in mind, but as for myself, upon
> starting with R, I've been looking for an R language reference in the
> style of the Python reference (http://docs.python.org/ref/ref.html).
> The specification of the grammar and the associated semantics of a
> language gives me the kind of in-depth conceptual understanding that I
> like to have, and I find this more difficult to accrue for R than for
> other languages. For example, I'm still not certain whether I'm able to
> correctly predict how many copies of an object are created during the
> execution of some code, and consequently, I'm not really confident that
> my code is reasonably optimal.
> 
> I'd appreciate pointers to any (more or less hidden) gems I may have
> overlooked, of course.

The R language definition manual is pretty much of that variety. It
has the parser specification at the end rather than at the beginning,
but otherwise it is quite similar in structure to the Python one.

The document has developed at glacial speed for several years. It
probably could do with some restructuring and rewriting (by whom?),
but you also have to be aware that some aspects of R, notably
computing on the language, creates interdependences in the
specification that are not present in other languages. I.e., the
parsing section needs to talk about parse trees and their
representation as R objects, hence it is useful to have discussed the
structure of an R object first.

-- 
   O__   Peter Dalgaard Blegdamsvej 3  
  c/ /'_ --- Dept. of Biostatistics 2200 Cph. N   
 (*) \(*) -- University of Copenhagen   Denmark  Ph: (+45) 35327918
~~ - ([EMAIL PROTECTED]) FAX: (+45) 35327907

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


RE: [R] A suggestion for predict function(s)

2005-04-13 Thread Liaw, Andy
I must respectfully disagree.  Why carry extra copies of data arround?  This
is probably OK for small to medium sized data, but definitely not for large
data.

Besides, in your example, it may do different things depending on whether
newdata is supplied:  model.matrix is not necessarily the same as the
original data frame.  You need a bit more work to get the right model.matrix
that correspond to the newdata.  It's not clear to me whether you want to
return model matrix or model frame, but in either case it's not sufficient
to just use `newdata'.

Andy

> From: Ross Darnell
> 
> Maybe a useful addition to the predict functions would be to 
> return the 
> values of the predictor variables. It just (unless there are 
> problems) 
> requires an extra line. I have inserted an example below.
> 
> "predict.glm" <-
>function (object, newdata = NULL, type = c("link", "response",
>"terms"), se.fit = FALSE, 
> dispersion = NULL, terms = NULL,
>  na.action = na.pass, ...)
> {
>type <- match.arg(type)
>na.act <- object$na.action
>object$na.action <- NULL
>if (!se.fit) {
>  if (missing(newdata)) {
>pred <- switch(type, link = object$linear.predictors,
>   response = object$fitted, terms = 
> predict.lm(object,
>   se.fit = 
> se.fit, scale 
> = 1, type = "terms",
>   terms = terms))
>if (!is.null(na.act))
>  pred <- napredict(na.act, pred)
>  }
>  else {
>pred <- predict.lm(object, newdata, se.fit, scale = 1,
>   type = ifelse(type == "link", 
> "response", type),
>   terms = terms, na.action = na.action)
>switch(type, response = {
>  pred <- family(object)$linkinv(pred)
>}, link = , terms = )
>  }
>}
>else {
>  if (inherits(object, "survreg"))
>dispersion <- 1
>  if (is.null(dispersion) || dispersion == 0)
>dispersion <- summary(object, dispersion = 
> dispersion)$dispersion
>  residual.scale <- as.vector(sqrt(dispersion))
>  pred <- predict.lm(object, newdata, se.fit, scale = 
> residual.scale,
> type = ifelse(type == "link", 
> "response", type),
> terms = terms, na.action = na.action)
>  fit <- pred$fit
>  se.fit <- pred$se.fit
>  switch(type, response = {
>se.fit <- se.fit * abs(family(object)$mu.eta(fit))
>fit <- family(object)$linkinv(fit)
>  }, link = , terms = )
>  if (missing(newdata) && !is.null(na.act)) {
>fit <- napredict(na.act, fit)
>se.fit <- napredict(na.act, se.fit)
>  }
>  predictors <- if (missing(newdata)) model.matrix(object) 
> else newdata
>  pred <- list(predictors=predictors,
>   fit = fit, se.fit = se.fit,
>   residual.scale = residual.scale)
>}
>pred
> 
> 
> #__ end of R code
> 
> 
> 
> Ross Darnell
> -- 
> School of Health and Rehabilitation Sciences
> University of Queensland, Brisbane QLD 4072 AUSTRALIA
> Email: <[EMAIL PROTECTED]>
> Phone: +61 7 3365 6087 Fax: +61 7 3365 4754  Room:822, 
> Therapies Bldg.
> http://www.shrs.uq.edu.au/shrs/school_staff/ross_darnell.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


  1   2   >