Re: [R] .Rprofile error: ps.options

2004-04-25 Thread Prof Brian Ripley
Do look at the NEWS file.  This is covered in the top 40 lines, and points
you to an example (?setHook) of how to do almost exactly this.

BTW, please use FALSE not F for FALSE in programming (as in .Rprofile).

On Sun, 25 Apr 2004, Akop Pogosian wrote:

> After upgrading to R 1.9.0, I started getting the following error on
> startup:
> 
> Error: couldn't find function "ps.options"
> 
> My .Rprofile file contains this line:
> 
> ps.options(paper="letter",horizontal=F)
> 
> If I type "source ~/.Rprofile" after R starts, it works just fine. Did
> something related to startup change in R 1.9.0?

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

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


Re: [R] .Rprofile error: ps.options

2004-04-25 Thread Roger D. Peng
Yes, the startup is different in 1.9.0.  See the NEWS file in the 
installation directory.

-roger

Akop Pogosian wrote:

After upgrading to R 1.9.0, I started getting the following error on
startup:
Error: couldn't find function "ps.options"

My .Rprofile file contains this line:

ps.options(paper="letter",horizontal=F)

If I type "source ~/.Rprofile" after R starts, it works just fine. Did
something related to startup change in R 1.9.0?
-akop

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


Re: [R] expression with running index

2004-04-25 Thread Prof Brian Ripley
lapply(-1:2, function(i) substitute(expression(b[i]), list(i=i)))

would be a good start. (Note that what it gives is

[[1]]
expression(b[as.integer(-1)])

which is not what you asked for but is what I think you intended.

Then we can elaborate this to 

f <- function(ind, vec)
lapply(ind, 
   function(i, vec) substitute(expression(vec[i]), 
   list(i=i, vec=vec)), 
   vec=as.name(vec))

f(-1:2, "b") and f(c("f", "g", "h"), "b") both work

Also, I am not sure you need the expression() in there, as without it you 
have a language call which will almost certainly do.


On Sun, 25 Apr 2004, Tamas Papp wrote:

> Hi,
> 
> I need a list of expression of the form expression(b[i]), where i is a
> running index.  So for example, if i <- -1:2, I would like to have a
> list equivalent to
> 
> list(expression(b[-1]), expression(b[0]), expression(b[1]), expression(b[2]))
> 
> "i" might be a character vector (like c("f", "g", "h"))
> 
> Could somebody help me out by writing a function that produces the
> list above for a given string in place of "b" and a vector of subscripts?
> 
> Sorry if this has been discussed before, I tried searching the
> archives but "expression" as a keyword gives too many results on
> different subjects.

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

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


Re: [R] expression with running index

2004-04-25 Thread Uwe Ligges
Tamas Papp wrote:

Hi,

I need a list of expression of the form expression(b[i]), where i is a
running index.  So for example, if i <- -1:2, I would like to have a
list equivalent to
list(expression(b[-1]), expression(b[0]), expression(b[1]), expression(b[2]))

"i" might be a character vector (like c("f", "g", "h"))

Could somebody help me out by writing a function that produces the
list above for a given string in place of "b" and a vector of subscripts?
Sorry if this has been discussed before, I tried searching the
archives but "expression" as a keyword gives too many results on
different subjects.
Thanks,

Tamas

For example:

 lapply(as.double(-1:2), function(x) substitute(b[i], i = list(i=x)))

Uwe Ligges

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


[R] .Rprofile error: ps.options

2004-04-25 Thread Akop Pogosian
After upgrading to R 1.9.0, I started getting the following error on
startup:

Error: couldn't find function "ps.options"

My .Rprofile file contains this line:

ps.options(paper="letter",horizontal=F)

If I type "source ~/.Rprofile" after R starts, it works just fine. Did
something related to startup change in R 1.9.0?


-akop

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


[R] expression with running index

2004-04-25 Thread Tamas Papp
Hi,

I need a list of expression of the form expression(b[i]), where i is a
running index.  So for example, if i <- -1:2, I would like to have a
list equivalent to

list(expression(b[-1]), expression(b[0]), expression(b[1]), expression(b[2]))

"i" might be a character vector (like c("f", "g", "h"))

Could somebody help me out by writing a function that produces the
list above for a given string in place of "b" and a vector of subscripts?

Sorry if this has been discussed before, I tried searching the
archives but "expression" as a keyword gives too many results on
different subjects.

Thanks,

Tamas

-- 
Tamás K. Papp
E-mail: [EMAIL PROTECTED]
Please try to send only (latin-2) plain text, not HTML or other garbage.

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


Re: [R] nonparametric multiple sample comparison

2004-04-25 Thread Gabor Grothendieck

I have not attempted to follow this in detail but a few comments 
are interspersed within your discussion and the code:

  bignet.com.br> writes:

: 
: Hello all,
: 
: Here goes one of my first functions.
: 
: I want to make a nonparametric multiple sample comparison with unequal 
sample 
: sizes (see ZarÂs Biostatistical Analysis, 3rd. Ed., pg. 201 Example 10.11, 
pg. 
: 288 Example 11.10). In the real world, I want to compare samples of fish 
: length captured with different fishing gears.
: 
: After using the Kruskal-Wallis test I want to check the differences between 
: each two samples. 
: 
: I wrote the function multcomp (see below) and itÂs working OK but I still 
have 
: some doubts. To use it one must have a two-column dataframe with groups and 
: measurements.
: 
: 1) In line 20 (Results <- data.frameÂ) I create a dataframe to store the 
final 
: results. It has a fixed row number but it would be better to have a variable 
: number, i.e., the number of combination of the groups taken 2 by 2 (4 groups 
= 
: 5 combinations, 6 groups = 15 combinations). Which function in R returns the 
: number of combinations? I couldnÂt find it!


?choose


: 
: 2) In lines 35 to 39 I print the result tables. How can I make a "clean" 
: print, without row numbers and quotation marks?


?cat

: 
: 3) Also IÂd like to calculate the critical values "q" and p-values but I 
: couldnÂt find the distribution indicated in ZarÂs Table B.15 
: (App107) "Critical Values of Q for Nonparametric Multiple Comparison 
Testing". 
: Is it possible to calculate these numbers in R?
: 
: Thanks in advance for any help or comments to improve this function.
: 
: Best regards,
: 
: Antonio Olinto
: Sao Paulo Fisheries Institute
: Brazil
: 
: multcomp <- function(DataSet) {
: dat.multcomp <- DataSet

You don't need to copy the DataSet.  If you try to modify any object
within a function then R makes a copy of it automatically anyways.

: names(dat.multcomp) <- c("VarCat","VarNum")
: attach(dat.multcomp)

attach is generally frowned upon.  Just call it a short name such as d so that
its easy to refer to.  (Alternately wrap references to data frame in a with.)
I have assumed the data frame is called d in what follows.

: dat.multcomp$Rank <- rank(VarNum)
: attach(dat.multcomp)
: RankList <- aggregate(Rank,list(Rank=Rank),FUN=length)
: t <- length(RankList$Rank)
: st <- 0
: for (i in 1:t) if (RankList[i,2]>1) st<-st+(RankList[i,2]^3-RankList[i,2])

The last two statements could be reduced to:

st <- sum(ifelse( RankList[,2]>1, RankList[,2]^3-RankList[,2], 0 )

: LevCat <- levels(dat.multcomp$VarCat)
: NLevCat <- aggregate(VarCat,list(LevCat=VarCat),FUN=length)
: RLevCat <- aggregate(Rank,list(LevCat=VarCat),FUN=sum)
: MLevCat <- aggregate(Rank,list(LevCat=VarCat),FUN=mean)
: SampleSummary <- data.frame(LevCat,RLevCat[,2],NLevCat[,2],MLevCat[,2])
: names(SampleSummary)<-c("Samples","RSum","N","RMean")

If I have followed this correctly then the above 6 lines can be reduced to:

SampleSummary <- do.call( "rbind", by(d$Rank, d$VarCat, 
function(x) c(Rsum=sum(x),N=length(x),RMean=mean(x

although that produces a matrix rather than a data frame and puts the 
levels as the row rather than a column so you will have to adjust 
what follows.

: SampleSummary <- SampleSummary[order(SampleSummary$RMean,decreasing=T),]
: NCat <- length(LevCat)
: N <- length(dat.multcomp$VarCat)
: Results <- data.frame(rep(NA,6),rep(NA,6),rep(NA,6),rep(NA,6))
: names(Results) <- c("Comparison","Difference","SE","Q")
: l <- 1
: for (i in 1:(NCat-1)) {
:for (j in NCat:(i+1)) {
:SE <- sqrt(((N*(N+1)/12)-(st/(12*(N-1*((1/SampleSummary[i,3])+
: (1/SampleSummary[j,3])))
:Dif <- SampleSummary[i,4]-SampleSummary[j,4]
:Q=Dif/SE
: Results[l,1] <- paste(SampleSummary[i,1],"vs",SampleSummary[j,1])
: Results[l,2] <- round(Dif,4)
: Results[l,3] <- round(SE,4)
: Results[l,4] <- round(Q,4)
: l <-l+1
:}
: }
: print("Sample summary ranked by mean ranks")
: print(SampleSummary)
: print("")
: print("Table of multiple comparisons")
: print(Results)
: }
: 
: ===
: 
: Data example taken from Zar (Biostatiscical Analysis):
: 
: dat.limno <- data.frame(scan(what = list (Pound=" ", pH=0), sep=" "))
: 1 7.68
: 1 7.69
: 1 7.7
: 1 7.7
: 1 7.72
: 1 7.73
: 1 7.73
: 1 7.76
: 2 7.71
: 2 7.73
: 2 7.74
: 2 7.74
: 2 7.78
: 2 7.78
: 2 7.8
: 2 7.81
: 3 7.74
: 3 7.75
: 3 7.77
: 3 7.78
: 3 7.8
: 3 7.81
: 3 7.84
: 4 7.71
: 4 7.71
: 4 7.74
: 4 7.79
: 4 7.81
: 4 7.85
: 4 7.87
: 4 7.91
: 
: kruskal.test(pH~Pound)
: 
: Kruskal-Wallis rank sum test
: 
: data
: Kruskal-Wallis chi-squared = 11.9435, df = 3, p-value = 0.007579
: 
: multcomp(dat.limno)
: 
: [1] "Sample summary ranked by mean ranks"
:   Samples  RSum NRMean
: 3   3 145.0 7 20.71429
: 4   4 163.5 8 20.43750
: 2   2 132.5 8 16.56250
: 1   1  55.0 8  6.87500
: [1] ""
: [1] "Table of multiple comparisons"
:   Comparison Difference SE  Q
: 1 3 vs 113.8393 4.6923 2.9493
: 2

Re: [R] Bug?

2004-04-25 Thread Duncan Murdoch
On Sun, 25 Apr 2004 17:23:03 +0100 (BST), Prof Brian Ripley
<[EMAIL PROTECTED]> wrote:

>There is a workaround in R-patched, usually available from
>
>http://cran.r-project.org/bin/windows/base/rpatched.html
>
>but I think that has the wrong version at present since it is labelled
>R-2.0.0 patch build for Windows and contains rw2000dev.exe, not 
>rw1090pat.exe.

The right file is there, but I uploaded the wrong link to it.  You can
download http://cran.r-project.org/bin/windows/base/rw1090pat.exe.
I've replaced the rpatched.html web page (but it won't be visible
until tomorrow).

Duncan Murdoch

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


Re: [R] Bug?

2004-04-25 Thread Prof Brian Ripley
Yes, it is a bug, but not in R.  It is a bug in a Windows XP critical 
update: are you *sure* no new software has been installed behind your 
back?

The fix (which you can find several times in the list archives) is to add

R_USER=c:/

(or better, the correct path to your home aka personal directory) to the
shortcut you use to start R.

There is a workaround in R-patched, usually available from

http://cran.r-project.org/bin/windows/base/rpatched.html

but I think that has the wrong version at present since it is labelled
R-2.0.0 patch build for Windows and contains rw2000dev.exe, not 
rw1090pat.exe.

On Sun, 25 Apr 2004, Alain Yamakana wrote:

> Either something is wrong with my machine or there may be a bugg. I had run
> R-1.8.1 two weeks ago. Since yesterday, I am getting this message:< Windows GUI front-end has encountered a problem and needs to close. We are
> sorry for the inconvenience.>> No new software has been installed since I
> installed R-1.8.1. Tired to fail getting R-1.8.1 work, I decided to install
> R-1.9.0 and got the following message <>. How to
> solve either one of these two problems?

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

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


Re: [R] ts's in lm()

2004-04-25 Thread Prof Brian Ripley
On Sun, 25 Apr 2004 [EMAIL PROTECTED] wrote:

> Is this a bug?

Without even a traceback() nor reproducible code it is hard to say.
But for lm, you don't want time series and it would be better to drop the 
ts class and tsp attributes.

> seasonal.dummies <-
> function(x, contr=NULL) {
> # takes a time series and returns a matrix of seasonal dummies for 
> # x. This is almost cycle(x), we only have to make it into a factor
> # and add suitable level names.
> # return a matrix which includes a constant!
> # level names here assumes frequency is 12!
> cyc <- factor( cycle(x), labels=c("ene","feb", "mar", "abr", "may",
>"jun","jul", "ago", "sep",  "oct","nov", "dic") )
> if(!is.null(contr)) cyc <- C(cyc, contr)
> model.matrix( ~  cyc )
> }
> 
> 
> > modelo1 <- function(xx, yy) {
>  # xx es serie explicativa (economia)
>  # yy es serie para predecir --- gasolina.eq
>  name.x <- deparse(substitute(xx))
>  name.y <- deparse(substitute(yy))
>  xx <- ts(rep(xx,rep(3, length(xx))), frequency=12, start=
> c(start(xx)[1], (start(xx)[2]-1)*3+1) )
>  common <- ts.intersect(xx, yy)
>  colnames(common) <- c(name.x, name.y)
>  xx <- common[,1]
>  yy <- common[,2]
>  sea <- seasonal.dummies(xx)
>  return(lm(yy  ~ 0+sea+xx))
>  }
> > mod1 <- modelo1(PIBtrimestral, gasolina.eq)
> Error in "storage.mode<-"(`*tmp*`, value = "double") : 
> invalid time series parameters specified
> 
> lm() works with time series objects made directly with ts(), and the 
> arguments to modelo1() is of this type.
> 
> Kjetil Halvorsen
> 
> __
> [EMAIL PROTECTED] mailing list
> https://www.stat.math.ethz.ch/mailman/listinfo/r-help
> PLEASE do read the posting guide! http://www.R-project.org/posting-guide.html
> 
> 

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

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


[R] nonparametric multiple sample comparison

2004-04-25 Thread aolinto_r
Hello all,

Here goes one of my first functions.

I want to make a nonparametric multiple sample comparison with unequal sample 
sizes (see Zar’s Biostatistical Analysis, 3rd. Ed., pg. 201 Example 10.11, pg. 
288 Example 11.10). In the real world, I want to compare samples of fish 
length captured with different fishing gears.

After using the Kruskal-Wallis test I want to check the differences between 
each two samples. 

I wrote the function multcomp (see below) and it’s working OK but I still have 
some doubts. To use it one must have a two-column dataframe with groups and 
measurements.

1) In line 20 (Results <- data.frame…) I create a dataframe to store the final 
results. It has a fixed row number but it would be better to have a variable 
number, i.e., the number of combination of the groups taken 2 by 2 (4 groups = 
5 combinations, 6 groups = 15 combinations). Which function in R returns the 
number of combinations? I couldn’t find it!

2) In lines 35 to 39 I print the result tables. How can I make a "clean" 
print, without row numbers and quotation marks?

3) Also I’d like to calculate the critical values "q" and p-values but I 
couldn’t find the distribution indicated in Zar’s Table B.15 
(App107) "Critical Values of Q for Nonparametric Multiple Comparison Testing". 
Is it possible to calculate these numbers in R?

Thanks in advance for any help or comments to improve this function.

Best regards,

Antonio Olinto
Sao Paulo Fisheries Institute
Brazil

multcomp <- function(DataSet) {
dat.multcomp <- DataSet
names(dat.multcomp) <- c("VarCat","VarNum")
attach(dat.multcomp)
dat.multcomp$Rank <- rank(VarNum)
attach(dat.multcomp)
RankList <- aggregate(Rank,list(Rank=Rank),FUN=length)
t <- length(RankList$Rank)
st <- 0
for (i in 1:t) if (RankList[i,2]>1) st<-st+(RankList[i,2]^3-RankList[i,2])
LevCat <- levels(dat.multcomp$VarCat)
NLevCat <- aggregate(VarCat,list(LevCat=VarCat),FUN=length)
RLevCat <- aggregate(Rank,list(LevCat=VarCat),FUN=sum)
MLevCat <- aggregate(Rank,list(LevCat=VarCat),FUN=mean)
SampleSummary <- data.frame(LevCat,RLevCat[,2],NLevCat[,2],MLevCat[,2])
names(SampleSummary)<-c("Samples","RSum","N","RMean")
SampleSummary <- SampleSummary[order(SampleSummary$RMean,decreasing=T),]
NCat <- length(LevCat)
N <- length(dat.multcomp$VarCat)
Results <- data.frame(rep(NA,6),rep(NA,6),rep(NA,6),rep(NA,6))
names(Results) <- c("Comparison","Difference","SE","Q")
l <- 1
for (i in 1:(NCat-1)) {
   for (j in NCat:(i+1)) {
   SE <- sqrt(((N*(N+1)/12)-(st/(12*(N-1*((1/SampleSummary[i,3])+
(1/SampleSummary[j,3])))
   Dif <- SampleSummary[i,4]-SampleSummary[j,4]
   Q=Dif/SE
Results[l,1] <- paste(SampleSummary[i,1],"vs",SampleSummary[j,1])
Results[l,2] <- round(Dif,4)
Results[l,3] <- round(SE,4)
Results[l,4] <- round(Q,4)
l <-l+1
   }
}
print("Sample summary ranked by mean ranks")
print(SampleSummary)
print("")
print("Table of multiple comparisons")
print(Results)
}

===

Data example taken from Zar (Biostatiscical Analysis):

dat.limno <- data.frame(scan(what = list (Pound=" ", pH=0), sep=" "))
1 7.68
1 7.69
1 7.7
1 7.7
1 7.72
1 7.73
1 7.73
1 7.76
2 7.71
2 7.73
2 7.74
2 7.74
2 7.78
2 7.78
2 7.8
2 7.81
3 7.74
3 7.75
3 7.77
3 7.78
3 7.8
3 7.81
3 7.84
4 7.71
4 7.71
4 7.74
4 7.79
4 7.81
4 7.85
4 7.87
4 7.91

kruskal.test(pH~Pound)

Kruskal-Wallis rank sum test

data
Kruskal-Wallis chi-squared = 11.9435, df = 3, p-value = 0.007579

multcomp(dat.limno)

[1] "Sample summary ranked by mean ranks"
  Samples  RSum NRMean
3   3 145.0 7 20.71429
4   4 163.5 8 20.43750
2   2 132.5 8 16.56250
1   1  55.0 8  6.87500
[1] ""
[1] "Table of multiple comparisons"
  Comparison Difference SE  Q
1 3 vs 113.8393 4.6923 2.9493
2 3 vs 2 4.1518 4.6923 0.8848
3 3 vs 4 0.2768 4.6923 0.0590
4 4 vs 113.5625 4.5332 2.9918
5 4 vs 2 3.8750 4.5332 0.8548
6 2 vs 1 9.6875 4.5332 2.1370


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

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


RE: [R] R vs Matlab: which is more "programmer friendly"?

2004-04-25 Thread Bill Vinyard

I was exposed to and have used Matlab and R both in and out of the
classroom, both as a student and as an instructor.

1.  Both Matlab and R are "smart."  In terms of flexibility, I think they
are both about the same.  This includes their FSF or commercial counterparts
Octave and SPlus respectively.  With appropriate guidance, all of these
applications can be used to develop better programming habits.  As a general
rule the commercial versions have a smoother appearance and better
documentation...but this is not true of R.  R has some of the best
documentation around as well as superb on-line support via the R mailing
lists.  From a student's perspective access to well written documentation
and on-line support are essential.

2.  Both require the user to have some programming experience; otherwise the
learning curve is steep in the beginning.  Both can be used to introduce
programming provided you make room in your syllabus for the basics in the
beginning.

3.  In my opinion, the main difference -- besides the obvious one...cost --
is that R is easily accessible anywhere in the world, costs nothing (which
makes it affordable for students), has excellent documentation, a robust,
friendly and helpful user base, superior on-line support ...

4.  The power of R and Matlab is that they are both easily extensible.  If
you can't find a ready-made function to do what you want, you can easily, on
the fly, write your own and then make it a permanent function for your use
at any time.

Bill
-Original Message-
From: [EMAIL PROTECTED]
[mailto:[EMAIL PROTECTED] Behalf Of Tamas Papp
Sent: Sunday, April 25, 2004 05:08
To: R-help mailing list
Subject: [R] R vs Matlab: which is more "programmer friendly"?


Hi,

The department of economics at our university (Budapest) is planning a
course on numerical methods in economics.  They are trying to decide
which software to use for that, and I would like to advocate R.  The
other alternative is Matlab.

I have found comparisons in terms of computational time for matrix
algebra, but I don't think that is relevant: the bottleneck for
economists is usually the programmer's time: if it takes a couple of
hours to write something that is run only a few times, one should not
care whether it runs in 2 or 2.1 minutes...

I am an economist, and I have used Octave, but only until I found R.
So I am not in a position to evaluate Matlab vs R.  I would be
grateful if somebody could compare R to Matlab, especially regarding
the following:

1. How "smart" the language is.  R appears to be a nice functional
programming language, is Matlab comparable?  Last time I used Octave,
it seemed to be little more than syntactic sugar on some C/Fortran
libraries.  It appears to me that using R gradually pushes people
towards better programming habits, but I may be biased (I am a Scheme
lover).

2. Learning curve.  If somebody could share his/her experience on
using R or Matlab or both in the classrom, how students take to it.

3. Which language do you think is better for students' further
development?  We would like to equip them with something they can use
later on in their career even if they don't become theoretical
economists (very few undergraduate students do that).

4. How flexible are these languages when developing new
applications/functions?  Very few of the problems I encounter have a
ready-made solution in a toolbox/library.

Thanks,

Tamas

--
Tamás K. Papp
E-mail: [EMAIL PROTECTED]
Please try to send only (latin-2) plain text, not HTML or other garbage.

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

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


[R] Bug?

2004-04-25 Thread Alain Yamakana
Either something is wrong with my machine or there may be a bugg. I had run
R-1.8.1 two weeks ago. Since yesterday, I am getting this message:<> No new software has been installed since I
installed R-1.8.1. Tired to fail getting R-1.8.1 work, I decided to install
R-1.9.0 and got the following message <>. How to
solve either one of these two problems?

Best regards,
Alain

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


RE: [R] R vs Matlab: which is more "programmer friendly"?

2004-04-25 Thread Daniel Bebber
I have been using R for about 2 years and recently took a 6 week
introductory course to Matlab.
I can give entirely personal answers to your questions.

1. 'How smart?'. Don't know exactly what you mean, but both languages are
extremely functional. Both emphasize writing of functions to call rather
than repeatedly typing in the same code, so they encourage good programming
practice. I started with R, so prefer its syntax.

2. 'Learning curve'. Similar. R has a simpler interface. Matlab has various
enhancements that may help in the learning process, for example the path
browser and workspace browser in which you can interactively keep track of
all the objects in the workspace. Both have comprehensive help packages.

3. 'Further development'. Has to be R- its FREE! I don't know many students
who would fork out the money for a Matlab license.

4. 'Flexibility'. Both are perhaps infinitely flexible. You can write any
code you like, to do any statistical or mathematical processing. I would say
R is better for statistical analysis (though Matlab has a stats package you
can purchase), while Matlab is designed for mathematics. With Matlab you can
compile GUIs to run analyses, which are probably useful for sharing with
people who can't program.

Some other points.
1. I have heard that Matlab is faster than S-PLUS (and hence R?) at
performing calculations.
2. I found Matlab to be quite frustrating in its handling of data- for
example it is extremely difficult to save a data frame in which variables
are labelled with there names.

Hope this helps.

Dan Bebber

Department of Plant Sciences
University of Oxford
South Parks Road
Oxford OX1 3RB
UK

--

Message: 24
Date: Sun, 25 Apr 2004 11:08:09 +0200
From: Tamas Papp <[EMAIL PROTECTED]>
Subject: [R] R vs Matlab: which is more "programmer friendly"?
To: R-help mailing list <[EMAIL PROTECTED]>
Message-ID: <[EMAIL PROTECTED]>
Content-Type: text/plain; charset=iso-8859-1

Hi,

The department of economics at our university (Budapest) is planning a
course on numerical methods in economics.  They are trying to decide
which software to use for that, and I would like to advocate R.  The
other alternative is Matlab.

I have found comparisons in terms of computational time for matrix
algebra, but I don't think that is relevant: the bottleneck for
economists is usually the programmer's time: if it takes a couple of
hours to write something that is run only a few times, one should not
care whether it runs in 2 or 2.1 minutes...

I am an economist, and I have used Octave, but only until I found R.
So I am not in a position to evaluate Matlab vs R.  I would be
grateful if somebody could compare R to Matlab, especially regarding
the following:

1. How "smart" the language is.  R appears to be a nice functional
programming language, is Matlab comparable?  Last time I used Octave,
it seemed to be little more than syntactic sugar on some C/Fortran
libraries.  It appears to me that using R gradually pushes people
towards better programming habits, but I may be biased (I am a Scheme
lover).

2. Learning curve.  If somebody could share his/her experience on
using R or Matlab or both in the classrom, how students take to it.

3. Which language do you think is better for students' further
development?  We would like to equip them with something they can use
later on in their career even if they don't become theoretical
economists (very few undergraduate students do that).

4. How flexible are these languages when developing new
applications/functions?  Very few of the problems I encounter have a
ready-made solution in a toolbox/library.

Thanks,

Tamas

--
Tamás K. Papp
E-mail: [EMAIL PROTECTED]
Please try to send only (latin-2) plain text, not HTML or other garbage.



--

___
[EMAIL PROTECTED] mailing list
https://www.stat.math.ethz.ch/mailman/listinfo/r-help
PLEASE read the posting guide! http://www.R-project.org/posting-guide.html


End of R-help Digest, Vol 14, Issue 25

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


[R] ts's in lm()

2004-04-25 Thread kjetil
Is this a bug?

seasonal.dummies <-
function(x, contr=NULL) {
# takes a time series and returns a matrix of seasonal dummies for 
# x. This is almost cycle(x), we only have to make it into a factor
# and add suitable level names.
# return a matrix which includes a constant!
# level names here assumes frequency is 12!
cyc <- factor( cycle(x), labels=c("ene","feb", "mar", "abr", "may",
   "jun","jul", "ago", "sep",  "oct","nov", "dic") )
if(!is.null(contr)) cyc <- C(cyc, contr)
model.matrix( ~  cyc )
}


> modelo1 <- function(xx, yy) {
 # xx es serie explicativa (economia)
 # yy es serie para predecir --- gasolina.eq
 name.x <- deparse(substitute(xx))
 name.y <- deparse(substitute(yy))
 xx <- ts(rep(xx,rep(3, length(xx))), frequency=12, start=
c(start(xx)[1], (start(xx)[2]-1)*3+1) )
 common <- ts.intersect(xx, yy)
 colnames(common) <- c(name.x, name.y)
 xx <- common[,1]
 yy <- common[,2]
 sea <- seasonal.dummies(xx)
 return(lm(yy  ~ 0+sea+xx))
 }
> mod1 <- modelo1(PIBtrimestral, gasolina.eq)
Error in "storage.mode<-"(`*tmp*`, value = "double") : 
invalid time series parameters specified

lm() works with time series objects made directly with ts(), and the 
arguments to modelo1() is of this type.

Kjetil Halvorsen

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


Re: [R] Moving window regressions - how can I improve this code?

2004-04-25 Thread Gabor Grothendieck
Gabor Grothendieck  myway.com> writes:
 
> movingWindow <- function(formula, data, width, ...) {
> nr <- nrow(data)
> width <- as.integer(width)[1]
> stopifnot( width > 0, width <= nr )
> indices <- as.data.frame( t( embed( 1:nr, width ) ) )
> lapply(indices, function(st) summary(lm(formula, data[st,])) )
> }
> 

Just one further simplification using apply instead of lapply to
eliminate having to transform embed:

movingWindow <- function(formula, data, width, ...) {
nr <- nrow(data)
width <- as.integer(width)[1]
stopifnot( width > 0, width <= nr )
apply( embed(1:nr, width), 1, # rows are indices of successive windows
function(st) summary(lm(formula, data[st,])) )
}

This could also be used in movingWindow2, as well.

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


Re: [R] R vs Matlab: which is more "programmer friendly"?

2004-04-25 Thread Gabor Grothendieck
Tamas Papp  axelero.hu> writes:
> 4. How flexible are these languages when developing new
> applications/functions?  Very few of the problems I encounter have a
> ready-made solution in a toolbox/library.

You might want to check your assumption that what you need is not available.
I believe that there is more not in CRAN than in CRAN.  Henrik Bengtsson's
site lists 370 packages:
http://www.maths.lth.se/help/R/.R/doc/html/packages.html
You could try posting if googling and looking at the usual places, 
cran.r-project.org, www.bioconductor.org and www.omegahat.org, does 
not turn up what you are looking for.

Also, there is a document on the R site that
provides a translation between Octave and R that might give you some
insight into your questions:
http://cran.r-project.org/doc/contrib/R-and-octave-2.txt

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


Re: [R] Stichprobe bilden

2004-04-25 Thread Jonathan Baron
On 04/25/04 12:27, [EMAIL PROTECTED] wrote:
>Liebe Alle,
>
>ich habe ien Problemm. ich habe einen Panel-Datensatz ueber die 185
>Staaten (nach Code von IMF) und von 1948-1999. Ich habe auch 12 Variablen
>in diesem Datensatz, die ich fuer die Regression benoetige. ich muss ein
>sub-sample bilden fuer die 65 Staaten und fuer den 1970-1999 Jahren. Wie
>kann ich aus dieser Stichprobe eine kleienere Stichprobe mit R bilden,
>damit auch meine 12 Variablen in Bezug auf die Jahren und Laendern richtig
>selektiert wurden.

My German is good enough to understand what you wrote, but not
good enough to write back.

You do not say enough.  The simple answer is to use the subset
operator [], or subset(), and something else like %in% to match
the countries.

For example, if your data are in a data frame called Gross, which
has a variable for Staat and another for Jahr,

Klein <- Gross[(Gross$Jahr > 1969) & (Gross$Staat %in% Staat65),]

where Staat65 is a vector with the list of countries you want,
like

Staat65 <- c("Germany","China", .)

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

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


[R] Stichprobe bilden

2004-04-25 Thread sebastian . goeres
Liebe Alle,

ich habe ien Problemm. ich habe einen Panel-Datensatz ueber die 185 
Staaten (nach Code von IMF) und von 1948-1999. Ich habe auch 12 Variablen 
in diesem Datensatz, die ich fuer die Regression benoetige. ich muss ein 
sub-sample bilden fuer die 65 Staaten und fuer den 1970-1999 Jahren. Wie 
kann ich aus dieser Stichprobe eine kleienere Stichprobe mit R bilden, 
damit auch meine 12 Variablen in Bezug auf die Jahren und Laendern richtig 
selektiert wurden. 

Vielen Dank fuer Ihre Hilfe im voraus,

Sebastjan
[[alternative HTML version deleted]]

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


[R] R vs Matlab: which is more "programmer friendly"?

2004-04-25 Thread Tamas Papp
Hi,

The department of economics at our university (Budapest) is planning a
course on numerical methods in economics.  They are trying to decide
which software to use for that, and I would like to advocate R.  The
other alternative is Matlab.

I have found comparisons in terms of computational time for matrix
algebra, but I don't think that is relevant: the bottleneck for
economists is usually the programmer's time: if it takes a couple of
hours to write something that is run only a few times, one should not
care whether it runs in 2 or 2.1 minutes...

I am an economist, and I have used Octave, but only until I found R.
So I am not in a position to evaluate Matlab vs R.  I would be
grateful if somebody could compare R to Matlab, especially regarding
the following:

1. How "smart" the language is.  R appears to be a nice functional
programming language, is Matlab comparable?  Last time I used Octave,
it seemed to be little more than syntactic sugar on some C/Fortran
libraries.  It appears to me that using R gradually pushes people
towards better programming habits, but I may be biased (I am a Scheme
lover).

2. Learning curve.  If somebody could share his/her experience on
using R or Matlab or both in the classrom, how students take to it.

3. Which language do you think is better for students' further
development?  We would like to equip them with something they can use
later on in their career even if they don't become theoretical
economists (very few undergraduate students do that).

4. How flexible are these languages when developing new
applications/functions?  Very few of the problems I encounter have a
ready-made solution in a toolbox/library.

Thanks,

Tamas

-- 
Tamás K. Papp
E-mail: [EMAIL PROTECTED]
Please try to send only (latin-2) plain text, not HTML or other garbage.

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


Re: [R] Colour coding and point types in a plot

2004-04-25 Thread Tamas Papp
On Sat, Apr 24, 2004 at 02:33:10PM -0500, Mihai Nica wrote:

> R 1.8.1, Windows 2000.

You might want to upgrade to 1.9.0.

> I am trying to find the "legend" for color coding and point types in
> a plot, which probably are standard for everybody but myself. Thanks
> for the tip!

> help.search("legend")

Help files with alias or concept or title matching 'legend' using
fuzzy matching:



gauss.quad(gss) Generating Gauss-Legendre Quadrature
legend(graphics)Add Legends to Plots
grid.legend(grid)   Internal Grid Functions
grid.plot.and.legend(grid)
A Simple Plot and Legend Demo
draw.key(lattice-0.9.9)
Produce a Legend or Key



Type 'help(FOO, package = PKG)' to inspect entry 'FOO(PKG) TITLE'.

> ?legend

is what you need, if I understand your question correctly.

Please read the posting guide.

Best,

Tamas

-- 
Tamás K. Papp
E-mail: [EMAIL PROTECTED]
Please try to send only (latin-2) plain text, not HTML or other garbage.

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


[R] multipanel display of levelplots?

2004-04-25 Thread Yan Wang
I cannot achieve a multipanel display of several levelplots. Here is 
part of my code.

At first, create the layout:
push.viewport(viewport(layout=grid.layout(1, 2)))
Then for the left panel:
push.viewport(viewport(layout.pos.col=1,layout.pos.row=1))
push.viewport(viewport(width=0.6, height=0.6))
levelplot(z~x*y, grid)
pop.viewport()
Similar code for the right panel.

However, there is always error message for "pop.viewport()" as "Error in 
pop.vp(i == n, recording) : Illegal to pop top-level viewport". If I 
omit "pop.viewport()", the two levelplots were printed on seperate pages 
without a layout of (1,2).

Any suggestion is greatly appreciated.

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