Re: [R] question about coxph (was covariance matrix under null)

2005-08-25 Thread Prof Brian Ripley
You will need to tell us of _what_ you want the covariance matrix and what 
you mean by the `null hypothesis':  coxph does estimation, not testing.

If you want the covariance matrix of the parameter estimates, see vcov(), 
which has a coxph method.

On Thu, 25 Aug 2005, Devarajan, Karthik wrote:

>
> Hello
>
> I am fitting a Cox PH model using the function coxph(). Does anyone know how
> to obtain the estimate of the covariance matrix under the null hypothesis.
> The function coxph.detail() does not seem to be useful for this purpose.
>
> Thanks,
> KD.
>
>   [[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

PLEASE do (no HTML mail, useful subject, please)

-- 
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 data to gaussian distributions

2005-08-25 Thread Prof Brian Ripley
See also the book MASS, the one fitdistr supports.

On Thu, 25 Aug 2005, Luis Gracia wrote:

> Hi again,
>
> self-answered. I took a breath and started another google search, this
> time more successful. I found the following packages in case somebody
> has the same question:
> nor1mix
> wle
> mixdist(I found this one to be the most useful in my case)
>
> Best,
>
> Luis
>
> Luis Gracia said the following on 08/25/05 20:31:
>> Hi!
>>
>> I need to fit a data that shows up as two gaussians partially
>> superimposed to the corresponding gaussian distributions, i.e.
>>
>> data=c(rnorm(100,5,2),rnorm(100,-6,1))
>>
>> I figured it out how to do it with mle or fitdistr when only one
>> gaussian is necessary, but not with two or more. Is there a function in
>> R to do this?
>>
>> Thank you very much in advance,
>>
>> Luis
>>
>> __
>> 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
>

-- 
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] Quick partitioning

2005-08-25 Thread Prof Brian Ripley
On Thu, 25 Aug 2005, Anna Oganyan wrote:

> Hello,
> I am quite new in R, and  I have one problem:
> I have large d-dimensional data sets (d=2, 3, 6, 10). I would like to
> divide the d-dim space into n (n may be 10, but better some larger
> number, for example 20) equally sized d-dim hypercubes  and count  how
> many data points are in each cube. Is there any way to do  it quickly, I
> mean - in a reasonable time? Actually, I  want  to get some rough idea
> of underlying densities of these data and compare them.
> Thanks a lot!
> Anna

How do you divide a 10D space into 10 hypercubes?  You need at least 
some of dimensions to be undivided.

The general idea is easy: apply cut() to each dimension, so your 
dimensions become factors, then table() will produce the counts.  That 
will be quick enough for millions of points.

-- 
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] update.packages() is NOT broken?

2005-08-25 Thread Prof Brian Ripley
Please use a less contentious subject.  This is discourteous to the people 
who gave you update.packages().

If you had bothered to look, you would have seen that

http://cran.r-project.org/bin/macosx/2.1

was last updated on 14 July.  Thus the issue is that the binary builds for 
MacOS X have not been updated recently. You can of course change your 
defaults so R uses source packages and you will get all the updates (if 
you have the tools to install such packages). Alternatively, you could 
report the problem to the proper place.

On Fri, 26 Aug 2005, Ajay Narottam Shah wrote:

> Folks,
>
> I am using R 2.1.1 on Apple OS X 10.3.
>
> Earlier, I used to say
>
> $ sudo R
>> update.packages()
>
> and all the packages used to get installed.
>
> For several weeks, I noticed that nothing has been coming through. I
> used the R-for-Mac graphics console and I find that there are many
> packages where new versions have come out which I don't have. Is
> something wrong with update.packages()?
>
> I also noticed that the CRAN Task Views function update.ctv()
>
>> update.ctv <- function(view, force.bundles = FALSE) {
>f <- function(x) if (x[1] == view) x$packagelist$name
>ctv.pkgs <- unlist( sapply( CRAN.views(), f) )
>idx <- if (force.bundles) 1 else c(1,5)
>installed.pkgs <- c(installed.packages()[,idx])
>dnld.packages <- setdiff(ctv.pkgs, installed.pkgs)
>install.packages(dnld.packages, dependencies = TRUE)
>update.packages()
>  }
>
> misbehaves, perhaps because it's internally using update.packages()?

Please do read the posting guide and learn from its advice.  What does 
`misbehaves' mean?

-- 
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] update.packages() is broken?

2005-08-25 Thread Ajay Narottam Shah
Folks,

I am using R 2.1.1 on Apple OS X 10.3.

Earlier, I used to say

$ sudo R
> update.packages() 

and all the packages used to get installed. 

For several weeks, I noticed that nothing has been coming through. I
used the R-for-Mac graphics console and I find that there are many
packages where new versions have come out which I don't have. Is
something wrong with update.packages()?

I also noticed that the CRAN Task Views function update.ctv() 

> update.ctv <- function(view, force.bundles = FALSE) {
f <- function(x) if (x[1] == view) x$packagelist$name
ctv.pkgs <- unlist( sapply( CRAN.views(), f) )
idx <- if (force.bundles) 1 else c(1,5)
installed.pkgs <- c(installed.packages()[,idx])
dnld.packages <- setdiff(ctv.pkgs, installed.pkgs)
install.packages(dnld.packages, dependencies = TRUE)
update.packages()
  }

misbehaves, perhaps because it's internally using update.packages()?

-- 
Ajay Shah   Consultant
[EMAIL PROTECTED]  Department of Economic Affairs
http://www.mayin.org/ajayshah   Ministry of Finance, New Delhi

__
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 create design matrix for LLMNL?

2005-08-25 Thread Spencer Graves
  I haven't seen a reply to this, so I will attempt a few comments.  If 
you've already received an adequate reply, please excuse my tardy 
comments.

  1.  It is generally not wise to use the name of a standard S / R 
function for a data.frame.  Please type "df" at a command prompt to see 
what you get.  In this case, this is probably not creating problems for 
you, but it might in other contexts.

  2.  Did you try the examples in the help file for "createX" in 
library(bayesm)?  If no, I suggest you do so.  If yes, I suggest you 
examine carefully your call to "createX" in comparison with the examples 
and the rest of the documentation.

  3.  If you still have a question, please submit another post after 
(re)reading posting guide! 
"http://www.R-project.org/posting-guide.html";.  You may think you 
already did this.  However, 289 observations in an attached file is not, 
for me at least, a toy example within the spirit of the posting guide. 
That posting guide is not intended to be a burocratic obstacle.  It was 
written to help people get quicker answers to their questions.  When 
followed, I believe it succeeds fairly well.  To me it is roughly like 
the famous book by George Pólya on "How to Solve It", which I also 
highly recommend.

  Viel Glueck!
  spencer graves

Tetyana Stepanchuk wrote:

> Hello, 
> 
>  
> 
> I have a small problem with developing design matrix X, which I use in
> estimation the log-likelihood of a multinomial logit model.
> 
>  
> 
> I have the data: 
> 
>  number of observation - 289
> 
> number of choice alternative- 3
> 
> number of choice specific variables in matrix X -4
> 
> matrix X =289x4
> 
> I tried to use the function createX, I know that I have to get design matrix
> 289x12 (am I right?) but it always says "bad dim" (my code and data in
> attachment)
> 
>  
> 
> Where is my fault? Can I use another method in order to create design
> matrix? 
> 
> Or need it at all here in logmnl (see code in attachment)?
> 
>  
> 
> Can anyone help me with this issue?
> 
>  
> 
> Thanks in advance,
> 
> Tatyana
> 
>  
> 
>  
> 
> 
> 
> 
> 
>>df=read.table("data.dat",header=TRUE)
>>inp=as.matrix(df)
> 
> Y X1 X2   X3   X4
> 1   1  1  1   65 20999.89
> 2   1  1  2   67  2719.60
> 3   1  1  3  110  3581.09
> 4   1  1  4   64  1731.63
> 5   1  1  5   84  4434.97
> 6   1  6  1   90   691.32
> 7   1  6  2   31   228.50
> 8   1  6  3   33   615.12
> 9   1  6  4   39   910.62
> 10  1  7  1  169  1246.75
> 11  1  7  2  183  1183.03
> 12  1  7  3  203  1345.32
> 13  1  7  4  177  1088.98
> 14  1  7  5  169   896.42
> 15  1  8  1   71  1264.57
> 16  1  8  2   80  1094.40
> 17  1  8  3   75  1715.99
> 18  1  8  4   55   905.37
> 19  1  8  5   67  1448.17
> 20  1 10  1  349  1396.77
> 21  1 10  2  666  2026.89
> 22  1 10  3  480   774.37
> 23  1 10  4  456  1972.15
> 24  1 11  1  500   245.88
> 25  1 11  2  288  2927.77
> 26  1 11  3  211  9221.67
> 27  1 11  4  206  5632.91
> 28  1 11  5  175  1636.62
> 29  1 12  1  107   857.06
> 30  1 12  2   87   789.25
> 31  1 12  3  103   856.27
> 32  1 12  4  377   933.74
> 33  1 12  5  229  1316.31
> 34  1 13  1   32   149.13
> 35  1 13  2   19   153.74
> 36  1 13  3   25   179.60
> 37  1 13  4   28   252.70
> 38  1 13  5   22   294.80
> 39  1 14  1   47  1261.82
> 40  1 14  2   19  2332.21
> 41  1 15  1  348   558.91
> 42  1 15  2  399   550.91
> 43  1 15  3  388   797.68
> 44  1 15  4  208   804.76
> 45  1 15  5  241   673.12
> 46  1 17  1   70   151.06
> 47  1 17  2   96   255.22
> 48  1 17  3  102  1220.30
> 49  1 17  4  128   793.54
> 50  1 18  3   10   134.95
> 51  1 18  4   28   992.30
> 52  1 21  1   85  1170.71
> 53  1 21  2  257   464.95
> 54  1 21  3  353   404.21
> 55  1 21  4  293   517.64
> 56  1 21  5  515  1202.68
> 57  1 22  1   66   372.89
> 58  1 22  2   79   498.70
> 59  1 22  3   47   304.83
> 60  1 22  4   48   430.03
> 61  1 22  5   52   319.86
> 62  1 23  1   14   165.28
> 63  1 23  2   35  2044.52
> 64  1 23  3   20   499.59
> 65  1 24  1   94   107.76
> 66  1 24  2   5961.64
> 67  1 24  3   47   111.15
> 68  1 24  4   32   100.75
> 69  1 25  1   17   142.34
> 70  1 26  1  144  1105.71
> 71  1 26  2  196  1445.43
> 72  1 26  3  328  2297.11
> 73  1 26  4  517  2143.55
> 74  1 27  1   85  2457.58
> 75  1 27  2   99  1921.27
> 76  1 27  3   65  3380.86
> 77  1 27  4   88  2218.37
> 78  1 27  5  100  1881.00
> 79  1 29  1  107   561.27
> 80  1 29  2   67   557.43
> 81  1 29  3   49   387.71
> 82  1 30  1   77   106.50
> 83  1 30  2  225   267.87
> 84  1 30  3  520   502.18
> 85  1 30  4  552   443.07
> 86  1 30  5  319   255.50
> 87  1 31  1   38  6522.32
> 88  1 31  2   38   632.35
> 89  1 31  3   50  1615.18
> 90  1 31  4   53  1657.59
> 91  1 31  5   25   425.01
> 92  1 32  1   82   681.77
> 93  1 32  2   82   605.14
> 94  1 32  3  117  1068.86
> 95  1 32  4   90   638.95
> 96  1 33  1   5

Re: [R] Fitting data to gaussian distributions

2005-08-25 Thread Luis Gracia
Hi again,

self-answered. I took a breath and started another google search, this
time more successful. I found the following packages in case somebody
has the same question:
nor1mix
wle
mixdist(I found this one to be the most useful in my case)

Best,

Luis

Luis Gracia said the following on 08/25/05 20:31:
> Hi!
> 
> I need to fit a data that shows up as two gaussians partially
> superimposed to the corresponding gaussian distributions, i.e.
> 
> data=c(rnorm(100,5,2),rnorm(100,-6,1))
> 
> I figured it out how to do it with mle or fitdistr when only one
> gaussian is necessary, but not with two or more. Is there a function in
> R to do this?
> 
> Thank you very much in advance,
> 
> Luis
> 
> __
> 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] Plotting nls

2005-08-25 Thread Francisco J. Zagmutt

Review the code in example(predict.nls)

For the R squared question check on this thread 
http://finzi.psych.upenn.edu/R/Rhelp02a/archive/51678.html

Cheers

Francisco

>From: Lanre Okusanya <[EMAIL PROTECTED]>
>Reply-To: [EMAIL PROTECTED]
>To: "'r-help@stat.math.ethz.ch'" 
>Subject: [R] Plotting nls
>Date: Thu, 25 Aug 2005 19:50:34 -0400
>
>Kindly excuse a non-statistician newbie attempting to wrestle with R.
>
>This might be a relatively easy question, but I am trying to perform nls
>regression and plot the fitted function through the data superimposed on
>the raw data. from reading the R-help, Rtips et al, I am only able to do
>that by extracting the parameter values manually and using it to create
>the plot.
>
>Is there an easier way to do this,  (I have ~60 Plots), obtain an r^2,
>and also plot the x axis in the log domain (any attempts I have tried
>have screwed up).
>
>NLS script
>
>fit<- nls(y~-emax*x^h/(ec50^h+x^h),
>data= sample, start=list(emax=4,h=2,ec50=1))
>
>summary(fit)
>
>Thank you all for your help
>
>Lanre Okusanya, Pharm.D.,BCPS
>UB/Pfizer Pharmacometrics Fellow
>University at Buffalo School of Pharmacy and Pharmaceutical Sciences
>237 Cooke Hall
>Buffalo, NY 14260
>Email: [EMAIL PROTECTED]
>Tel: (716)645-2828 x 275
>Fax: (716)645-2886
>
>__
>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] Fitting data to gaussian distributions

2005-08-25 Thread Luis Gracia
Hi!

I need to fit a data that shows up as two gaussians partially
superimposed to the corresponding gaussian distributions, i.e.

data=c(rnorm(100,5,2),rnorm(100,-6,1))

I figured it out how to do it with mle or fitdistr when only one
gaussian is necessary, but not with two or more. Is there a function in
R to do this?

Thank you very much in advance,

Luis

__
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] Plotting nls

2005-08-25 Thread Lanre Okusanya
Kindly excuse a non-statistician newbie attempting to wrestle with R.

This might be a relatively easy question, but I am trying to perform nls 
regression and plot the fitted function through the data superimposed on 
the raw data. from reading the R-help, Rtips et al, I am only able to do 
that by extracting the parameter values manually and using it to create 
the plot.

Is there an easier way to do this,  (I have ~60 Plots), obtain an r^2,  
and also plot the x axis in the log domain (any attempts I have tried 
have screwed up).

NLS script

fit<- nls(y~-emax*x^h/(ec50^h+x^h),
   data= sample, start=list(emax=4,h=2,ec50=1))

summary(fit)

Thank you all for your help

Lanre Okusanya, Pharm.D.,BCPS
UB/Pfizer Pharmacometrics Fellow
University at Buffalo School of Pharmacy and Pharmaceutical Sciences
237 Cooke Hall
Buffalo, NY 14260
Email: [EMAIL PROTECTED]
Tel: (716)645-2828 x 275
Fax: (716)645-2886

__
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] problem building dendrograms to use with heatmap()

2005-08-25 Thread Paul Murrell
Hi


Wittner, Ben wrote:
> Hi,
> 
> I'm trying to build dendrograms to pass to heatmap().
> The dendrograms I build plot properly, but when I pass them to heatmap() I get
> the error message "row dendrogram ordering gave index of wrong length" (see
> output log below).


Looks like you're not building the dendrograms "properly".  Compare 
unclass(nr2) with unclass() of a dendrogram from 
as.dendrogram(hclust()).  You might need to look closely at 
stats:::as.dendrogram.hclust to get it right.

Paul


> I looked in the code of heatmap() and saw that the error was due to a NULL
> return value from order.dendrogram(), which in turn got a NULL return value 
> from
> unlist(). But I have no idea why unlist() is returning NULL.
> 
> I've included code below which reproduces the problem and below that the 
> output
> from a run of that code on my computer.
> 
> Any help would be greatly appreciated. Thanks in advance.
> 
> -Ben
> 
> ###  begin code  ###
> 
> version
> 
> dendro.leaf <- function(label) {
>   ans <- list()
>   attr(ans, 'members') <- 1
>   attr(ans, 'height') <- 0
>   attr(ans, 'leaf') <- T
>   attr(ans, 'midpoint') <- 0
>   attr(ans, 'label') <- label
>   attr(ans, 'class') <- 'dendrogram'
>   ans
> }
> 
> dendro.merge <- function(d1, d2, height) {
>   ans <- list(d1, d2)
>   members <- attr(d1, 'members') + attr(d2, 'members')
>   attr(ans, 'members') <- members
>   attr(ans, 'height') <- height
>   attr(ans, 'leaf') <- F
>   attr(ans, 'midpoint') <- (members - 1)/2
>   attr(ans, 'class') <- 'dendrogram'
>   ans
> }
> 
> lc1 <- dendro.leaf('c1')
> lc2 <- dendro.leaf('c2')
> lc3 <- dendro.leaf('c3')
> nc1 <- dendro.merge(lc1, lc2, 0.1)
> nc2 <- dendro.merge(nc1, lc3, 0.2)
> plot(nc2)
> 
> lr1 <- dendro.leaf('r1')
> lr2 <- dendro.leaf('r2')
> lr3 <- dendro.leaf('r3')
> nr1 <- dendro.merge(lr2, lr3, 0.1)
> nr2 <- dendro.merge(lr1, nr1, 0.3)
> plot(nr2)
> 
> x <- matrix(seq(-1, 1, length.out=9), nrow=3)
> rownames(x) <- paste('r', 1:3, sep='')
> colnames(x) <- paste('c', 1:3, sep='')
> 
> heatmap(x, Rowv=nr2, Colv=nc2, scale='none')
> 
> order.dendrogram(nr2)
> 
> unlist(nr2)
> 
> ###  begin output from run of code above  ##
> 
> 
>>version
> 
>  _
> platform i686-pc-linux-gnu
> arch i686 
> os   linux-gnu
> system   i686, linux-gnu  
> status
> major2
> minor1.1  
> year 2005 
> month06   
> day  20   
> language R
> 
>>dendro.leaf <- function(label) {
> 
> +   ans <- list()
> +   attr(ans, 'members') <- 1
> +   attr(ans, 'height') <- 0
> +   attr(ans, 'leaf') <- T
> +   attr(ans, 'midpoint') <- 0
> +   attr(ans, 'label') <- label
> +   attr(ans, 'class') <- 'dendrogram'
> +   ans
> + }
> 
>>dendro.merge <- function(d1, d2, height) {
> 
> +   ans <- list(d1, d2)
> +   members <- attr(d1, 'members') + attr(d2, 'members')
> +   attr(ans, 'members') <- members
> +   attr(ans, 'height') <- height
> +   attr(ans, 'leaf') <- F
> +   attr(ans, 'midpoint') <- (members - 1)/2
> +   attr(ans, 'class') <- 'dendrogram'
> +   ans
> + }
> 
>>lc1 <- dendro.leaf('c1')
>>lc2 <- dendro.leaf('c2')
>>lc3 <- dendro.leaf('c3')
>>nc1 <- dendro.merge(lc1, lc2, 0.1)
>>nc2 <- dendro.merge(nc1, lc3, 0.2)
>>plot(nc2)
>>
>>lr1 <- dendro.leaf('r1')
>>lr2 <- dendro.leaf('r2')
>>lr3 <- dendro.leaf('r3')
>>nr1 <- dendro.merge(lr2, lr3, 0.1)
>>nr2 <- dendro.merge(lr1, nr1, 0.3)
>>plot(nr2)
>>
>>x <- matrix(seq(-1, 1, length.out=9), nrow=3)
>>rownames(x) <- paste('r', 1:3, sep='')
>>colnames(x) <- paste('c', 1:3, sep='')
>>
>>heatmap(x, Rowv=nr2, Colv=nc2, scale='none')
> 
> Error in heatmap(x, Rowv = nr2, Colv = nc2, scale = "none") : 
> row dendrogram ordering gave index of wrong length
> 
>>order.dendrogram(nr2)
> 
> NULL
> 
>>unlist(nr2)
> 
> NULL
> 
> 
> __
> 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


-- 
Dr Paul Murrell
Department of Statistics
The University of Auckland
Private Bag 92019
Auckland
New Zealand
64 9 3737599 x85392
[EMAIL PROTECTED]
http://www.stat.auckland.ac.nz/~paul/

__
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] S3 class question

2005-08-25 Thread Berton Gunter
Have you defined matSummary() as a generic with UseMethod:

matSummary<-function(...)UseMethod('matSummary')


-- 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 Joel Bremson
> Sent: Thursday, August 25, 2005 4:03 PM
> To: r-help@stat.math.ethz.ch
> Subject: [R] S3 class question
> 
> Hi,
> 
> I have a class called "spss" containing prepared info from an 
> SPSS file.
> >...
> >class(ret) = "spss"
> >return(ret)
> The function that returns this defined in a file that I source into R.
> 
> Also in that file is a function matSummary.spss.
> 
> I think I ought to be able to call 
> >matSummary(ret)
> 
> to run the function, but only 
> >matSummary.spss(ret)
> 
> will work.
> 
> What am I doing wrong here? This seems like a simple problem
> yet I've been able to find nothing in the archives about this.
> 
> 
> Joel
> 
> -- 
> Joel Bremson
> Graduate Student
> Institute for Transportation Studies - UC Davis
> http://etrans.blogspot.com
> 
>   [[alternative HTML version deleted]]
> 
> __
> R-help@stat.math.ethz.ch mailing list
> https://stat.ethz.ch/mailman/listinfo/r-help
> PLEASE do read the posting guide! 
> http://www.R-project.org/posting-guide.html
>

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


Re: [R] S3 class question

2005-08-25 Thread Gabor Grothendieck
On 8/25/05, Joel Bremson <[EMAIL PROTECTED]> wrote:
> Hi,
> 
> I have a class called "spss" containing prepared info from an SPSS file.
> >...
> >class(ret) = "spss"
> >return(ret)
> The function that returns this defined in a file that I source into R.
> 
> Also in that file is a function matSummary.spss.
> 
> I think I ought to be able to call
> >matSummary(ret)
> 
> to run the function, but only
> >matSummary.spss(ret)
> 
> will work.
> 
> What am I doing wrong here? This seems like a simple problem
> yet I've been able to find nothing in the archives about this.

Methods have to have a corresponding generic to be called like that.
Assuming your method has a single argument called ret define this:

matSummary <- function(ret) UseMethod("matSummary")

When you call matSummary the UseMethod call will forward
it to the appropriate method depending on the class of the
first argument, ret.

__
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] S3 class question

2005-08-25 Thread Joel Bremson
Hi,

I have a class called "spss" containing prepared info from an SPSS file.
>...
>class(ret) = "spss"
>return(ret)
The function that returns this defined in a file that I source into R.

Also in that file is a function matSummary.spss.

I think I ought to be able to call 
>matSummary(ret)

to run the function, but only 
>matSummary.spss(ret)

will work.

What am I doing wrong here? This seems like a simple problem
yet I've been able to find nothing in the archives about this.


Joel

-- 
Joel Bremson
Graduate Student
Institute for Transportation Studies - UC Davis
http://etrans.blogspot.com

[[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] Irregular Time Series: zoo & its: Pros & Cons

2005-08-25 Thread Gabor Grothendieck
On 8/25/05, David James <[EMAIL PROTECTED]> wrote:
> Hello,
> 
> I'm working with irregular time series data.  What do you all think
> about the strengths and weaknesses of the "zoo" and "its" packages?


I have worked on the development of zoo with Achim Zeileis so
I will just speak to that one.

The key to notice about zoo is its independence of index class
(i.e.  date, time or date/time class) making it general in
nature so that you can use any one you like.  It supports
all the standard date and time classes in R and you can add
your own too. In your case you probably want to use chron
(or POSIXct if you need time zones) or you could create your 
own special hourly class.  See the Help Desk article in 
R News 4/1 for a discussion of the main classes and
see the table at the end of that article for various idioms which 
you may need.

zoo supports not only irregular but also weakly regular
series (zooreg class) which are ones that have an underlying 
regularity, e.g. hourly, monthly even though they may not
have every hour, month, etc. filled in.

zoo has a PDF manual available via (in R):

   library(zoo)
   vignette("zoo")

zoo can work together with the 'its' class and 'ts' class via as.zoo, 
as.its and as.ts.

> 
> I've installed and skimmed the documentation on both packages.  I was
> hoping to get a little guidance from the user community before
> proceeding further.
> 
> In case anyone is interested in my particular problem:  I'm looking
> at some (surface) temperature data from NOAA:  http://
> cdo.ncdc.noaa.gov/ulcd/ULCD
> It is (irregular) time series format.  The NOAA data reports year,
> month, date, hour, and minute.  I want to group the data into hourly
> chunks.  However, sometimes there are multiple observation per hour
> -- i.e an observation at 3:45 and 3:56.  Also, sometimes a particular
> hour may be missing altogether.  I need to clean up the data so that
> each hour has one and only one data point.



Using the chron date/time class here is an example:

library(chron)
library(zoo)

set.seed(1)

# create zoo series with random dates/times between tt0 and tt1 
# also random values
set.seed(1)
n <- 25
tt0 <- chron("01/01/90")
tt1 <- chron("01/01/00")
tt <- sort(as.numeric(tt1-tt0)*runif(n)+tt0)
z <- zoo(rnorm(n), tt)  # create zoo series from values and date/times

# aggregate by hour choosing first data point if there are mulitples.
# The arguments are (1) the zoo series (2) time rounded to the hour
# (3) aggregate function to use -- indexing in this case, (4) an
# argument to the indexing function -- in this case its 1 since
# we want the first element.  See ?aggregate.zoo
z.hr <- aggregate(z, chron(floor(24*as.numeric(tt))/24), "[", 1)

# plot hourly series, see ?plot.zoo
plot(z.hr) 

Packages with explicit support for zoo are strucchange, dynlm
and dyn.  (dyn also supports ts and its.)

> 
> I'm relatively new to R, but I think I'm getting a hold on it pretty
> well so far.  I used to do a lot with MATLAB, and there seem to be

Check out 
   http://cran.r-project.org/doc/contrib/R-and-octave-2.txt

> many parallels between it and R.  I have background in public policy
> and econometrics.

Check out
   http://cran.r-project.org/src/contrib/Views/

__
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] covariance matrix under null

2005-08-25 Thread Devarajan, Karthik

Hello

I am fitting a Cox PH model using the function coxph(). Does anyone know how
to obtain the estimate of the covariance matrix under the null hypothesis.
The function coxph.detail() does not seem to be useful for this purpose.

Thanks,
KD.  

 



[[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] Quick partitioning

2005-08-25 Thread Anna Oganyan
Hello,
I am quite new in R, and  I have one problem:
I have large d-dimensional data sets (d=2, 3, 6, 10). I would like to 
divide the d-dim space into n (n may be 10, but better some larger 
number, for example 20) equally sized d-dim hypercubes  and count  how 
many data points are in each cube. Is there any way to do  it quickly, I 
mean - in a reasonable time? Actually, I  want  to get some rough idea 
of underlying densities of these data and compare them.
Thanks a lot!
Anna

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


Re: [R] rgui on windows quiting automatically Resolved

2005-08-25 Thread Duncan Murdoch
On 8/25/2005 3:39 PM, Greg Snow wrote:
> I have resolved the problem I had with rgui quiting automatically.
> I am posting this mainly so that if anyone else in the future has
> the same problem there will be a solution in the archives.
> 
> The problem was apparently with the file Rconsole that was 
> in the directory "My Documents", when I deleted that file
> then everything started working fine again.  

Could you take a look at that file, if it's still in your recycle bin? 
It's supposed to be a text file.  I'm curious what was wrong with it 
that caused this behaviour.

Duncan Murdoch

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


[R] rgui on windows quiting automatically Resolved

2005-08-25 Thread Greg Snow
I have resolved the problem I had with rgui quiting automatically.
I am posting this mainly so that if anyone else in the future has
the same problem there will be a solution in the archives.

The problem was apparently with the file Rconsole that was 
in the directory "My Documents", when I deleted that file
then everything started working fine again.  

Greg Snow, Ph.D.
Statistical Data Center, LDS Hospital
Intermountain Health Care
[EMAIL PROTECTED]
(801) 408-8111

__
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] box m-test

2005-08-25 Thread Liaw, Andy
I posted a translation from a Matlab version a while ago.  Search in the
list archive.

Andy

> From: Petra Wallem
> 
> Hello everybody, 
>  Is there in R a so called box m-test for testing the equality of the 
>  variance/cov. matrix for checking on homoscedasticity? I 
> could not find
> it among the traditional packages for multivariate statistics...
> Petra
> -- 
> Petra Wallem
> Centro de Estudios Avanzados en Ecología & Biodiversidad (CASEB)
> Departamento de Ecología
> Facultad de Ciencias Biológicas
> Pontificia Universidad Católica de Chile
> Av. Libertador Bernardo O'Higgins # 340
> Casilla 114-D
> 
> __
> 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] Irregular Time Series: zoo & its: Pros & Cons

2005-08-25 Thread Philippe Grosjean
Hello David,

You may be interested also by the regul() function and similar fro the 
pastecs package: it is designed to solve the kind of problems you talk 
about. You should read the manual, which is included. However, this 
manual is in French.
Best,

Philippe

..<°}))><
  ) ) ) ) )
( ( ( ( (Prof. Philippe Grosjean
  ) ) ) ) )
( ( ( ( (Numerical Ecology of Aquatic Systems
  ) ) ) ) )   Mons-Hainaut University, Pentagone (3D08)
( ( ( ( (Academie Universitaire Wallonie-Bruxelles
  ) ) ) ) )   8, av du Champ de Mars, 7000 Mons, Belgium
( ( ( ( (
  ) ) ) ) )   phone: + 32.65.37.34.97, fax: + 32.65.37.30.54
( ( ( ( (email: [EMAIL PROTECTED]
  ) ) ) ) )
( ( ( ( (web:   http://www.umh.ac.be/~econum
  ) ) ) ) )  http://www.sciviews.org
( ( ( ( (
..

David James wrote:
> Hello,
> 
> I'm working with irregular time series data.  What do you all think  
> about the strengths and weaknesses of the "zoo" and "its" packages?
> 
> I've installed and skimmed the documentation on both packages.  I was  
> hoping to get a little guidance from the user community before  
> proceeding further.
> 
> In case anyone is interested in my particular problem:  I'm looking  
> at some (surface) temperature data from NOAA:  http:// 
> cdo.ncdc.noaa.gov/ulcd/ULCD
> It is (irregular) time series format.  The NOAA data reports year,  
> month, date, hour, and minute.  I want to group the data into hourly  
> chunks.  However, sometimes there are multiple observation per hour  
> -- i.e an observation at 3:45 and 3:56.  Also, sometimes a particular  
> hour may be missing altogether.  I need to clean up the data so that  
> each hour has one and only one data point.
> 
> I'm relatively new to R, but I think I'm getting a hold on it pretty  
> well so far.  I used to do a lot with MATLAB, and there seem to be  
> many parallels between it and R.  I have background in public policy  
> and econometrics.
> 
> Thanks,
> David
> 
> On Aug 25, 2005, at 12:29 PM, Mathieu Drapeau wrote:
> 
> 
>>Hi,
>>I just installed ROracle and RDBI. The connection to the database  
>>seems
>>to work also. My problem is when I am selection rows that really exist
>>in the database, it is returning nothing. Where should I look to see
>>what could be my problem?
>>
>>Thank you very much,
>>Mathieu
>>
>>
>>
>>>drv <- dbDriver("Oracle")
>>>summary(drv, verbose=TRUE)
>>>
>>
>>
>>  Driver name:  Oracle (ProC/C++)
>>  Max  connections: 10
>>  Conn. processed: 8
>>  Default records per fetch: 500
>>  Oracle R/S client version: 0.5-4
>>  RS-DBI version:  0.1-9
>>  Open connections: 2
>>1  
>>2  
>>
>>>conn <- dbConnect(drv, "mathieu/[EMAIL PROTECTED]")
>>>summary(conn, verbose=TRUE) 
>>>
>>  User: mathieu
>>  Dbname: MYDB
>>  Oracle Server version:
>>
>>
>>>rs <- dbSendQuery(conn, statement = paste("select * from cat"))
>>>summary(rs, verbose=TRUE)
>>>
>>
>>
>>  Statement: select * from cat
>>  Has completed? no
>>  Affected rows: 0
>>  Rows fetched: -1
>>  Fields:
>>nameSclass type len precision scale isVarLength nullOK
>>1 TABLE_NAME character VARCHAR2  30 0 0TRUE  FALSE
>>2 TABLE_TYPE character VARCHAR2  11 0 0TRUE   TRUE
>>
>>
>>>myContent <- fetch(rs, n = -1)
>>>myContent
>>>
>>
>>[1] TABLE_NAME TABLE_TYPE
>><0 rows> (or 0-length row.names)
>>
>>
>>>summary(myContent, verbose=TRUE)
>>>
>>
>>  TABLE_NAME TABLE_TYPE
>> Length:0   Length:0
>> Class :character   Class :character
>> Mode  :character   Mode  :character
>>
>>
>>>summary(rs, verbose=TRUE)
>>>
>>
>>
>>  Statement: select * from cat
>>  Has completed? yes
>>  Affected rows: 0
>>  Rows fetched: -1
>>  Fields:
>>nameSclass type len precision scale isVarLength nullOK
>>1 TABLE_NAME character VARCHAR2  30 0 0TRUE  FALSE
>>2 TABLE_TYPE character VARCHAR2  11 0 0TRUE   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
>>
> 
> 
> __
> 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] Irregular Time Series: zoo & its: Pros & Cons

2005-08-25 Thread Whit Armstrong
I am the maintainer of its, but not it's original author.

One of the main strengths of its is that it uses POSIXct dates.

Zoo has the flexibility of using almost any date format, but I don't
know if the other date formats can store hour, min, sec data.

You might want to do a little exploring with each before you commit.

I'll be happy to give you a hand if you decide to work with its.

Cheers,
Whit


> -Original Message-
> From: [EMAIL PROTECTED] 
> [mailto:[EMAIL PROTECTED] On Behalf Of David James
> Sent: Thursday, August 25, 2005 1:51 PM
> To: r-help@stat.math.ethz.ch
> Subject: [R] Irregular Time Series: zoo & its: Pros & Cons
> 
> Hello,
> 
> I'm working with irregular time series data.  What do you all 
> think about the strengths and weaknesses of the "zoo" and 
> "its" packages?
> 
> I've installed and skimmed the documentation on both 
> packages.  I was hoping to get a little guidance from the 
> user community before proceeding further.
> 
> In case anyone is interested in my particular problem:  I'm 
> looking at some (surface) temperature data from NOAA:  
> http:// cdo.ncdc.noaa.gov/ulcd/ULCD It is (irregular) time 
> series format.  The NOAA data reports year, month, date, 
> hour, and minute.  I want to group the data into hourly 
> chunks.  However, sometimes there are multiple observation per hour
> -- i.e an observation at 3:45 and 3:56.  Also, sometimes a 
> particular hour may be missing altogether.  I need to clean 
> up the data so that each hour has one and only one data point.
> 
> I'm relatively new to R, but I think I'm getting a hold on it 
> pretty well so far.  I used to do a lot with MATLAB, and 
> there seem to be many parallels between it and R.  I have 
> background in public policy and econometrics.
> 
> Thanks,
> David
> 
> On Aug 25, 2005, at 12:29 PM, Mathieu Drapeau wrote:
> 
> > Hi,
> > I just installed ROracle and RDBI. The connection to the database 
> > seems to work also. My problem is when I am selection rows 
> that really 
> > exist in the database, it is returning nothing. Where 
> should I look to 
> > see what could be my problem?
> >
> > Thank you very much,
> > Mathieu
> >
> >
> >> drv <- dbDriver("Oracle")
> >> summary(drv, verbose=TRUE)
> >>
> > 
> >   Driver name:  Oracle (ProC/C++)
> >   Max  connections: 10
> >   Conn. processed: 8
> >   Default records per fetch: 500
> >   Oracle R/S client version: 0.5-4
> >   RS-DBI version:  0.1-9
> >   Open connections: 2
> > 1  
> > 2  
> >
> >>
> >> conn <- dbConnect(drv, "mathieu/[EMAIL PROTECTED]") summary(conn, 
> >> verbose=TRUE) 
> >>
> >   User: mathieu
> >   Dbname: MYDB
> >   Oracle Server version:
> >
> >>
> >> rs <- dbSendQuery(conn, statement = paste("select * from cat")) 
> >> summary(rs, verbose=TRUE)
> >>
> > 
> >   Statement: select * from cat
> >   Has completed? no
> >   Affected rows: 0
> >   Rows fetched: -1
> >   Fields:
> > nameSclass type len precision scale 
> isVarLength nullOK
> > 1 TABLE_NAME character VARCHAR2  30 0 0
> TRUE  FALSE
> > 2 TABLE_TYPE character VARCHAR2  11 0 0
> TRUE   TRUE
> >
> >>
> >> myContent <- fetch(rs, n = -1)
> >> myContent
> >>
> > [1] TABLE_NAME TABLE_TYPE
> > <0 rows> (or 0-length row.names)
> >
> >> summary(myContent, verbose=TRUE)
> >>
> >   TABLE_NAME TABLE_TYPE
> >  Length:0   Length:0
> >  Class :character   Class :character
> >  Mode  :character   Mode  :character
> >
> >> summary(rs, verbose=TRUE)
> >>
> > 
> >   Statement: select * from cat
> >   Has completed? yes
> >   Affected rows: 0
> >   Rows fetched: -1
> >   Fields:
> > nameSclass type len precision scale 
> isVarLength nullOK
> > 1 TABLE_NAME character VARCHAR2  30 0 0
> TRUE  FALSE
> > 2 TABLE_TYPE character VARCHAR2  11 0 0
> TRUE   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
> >
> 
> __
> 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] Irregular Time Series: zoo & its: Pros & Cons

2005-08-25 Thread David James
Hello,

I'm working with irregular time series data.  What do you all think  
about the strengths and weaknesses of the "zoo" and "its" packages?

I've installed and skimmed the documentation on both packages.  I was  
hoping to get a little guidance from the user community before  
proceeding further.

In case anyone is interested in my particular problem:  I'm looking  
at some (surface) temperature data from NOAA:  http:// 
cdo.ncdc.noaa.gov/ulcd/ULCD
It is (irregular) time series format.  The NOAA data reports year,  
month, date, hour, and minute.  I want to group the data into hourly  
chunks.  However, sometimes there are multiple observation per hour  
-- i.e an observation at 3:45 and 3:56.  Also, sometimes a particular  
hour may be missing altogether.  I need to clean up the data so that  
each hour has one and only one data point.

I'm relatively new to R, but I think I'm getting a hold on it pretty  
well so far.  I used to do a lot with MATLAB, and there seem to be  
many parallels between it and R.  I have background in public policy  
and econometrics.

Thanks,
David

On Aug 25, 2005, at 12:29 PM, Mathieu Drapeau wrote:

> Hi,
> I just installed ROracle and RDBI. The connection to the database  
> seems
> to work also. My problem is when I am selection rows that really exist
> in the database, it is returning nothing. Where should I look to see
> what could be my problem?
>
> Thank you very much,
> Mathieu
>
>
>> drv <- dbDriver("Oracle")
>> summary(drv, verbose=TRUE)
>>
> 
>   Driver name:  Oracle (ProC/C++)
>   Max  connections: 10
>   Conn. processed: 8
>   Default records per fetch: 500
>   Oracle R/S client version: 0.5-4
>   RS-DBI version:  0.1-9
>   Open connections: 2
> 1  
> 2  
>
>>
>> conn <- dbConnect(drv, "mathieu/[EMAIL PROTECTED]")
>> summary(conn, verbose=TRUE) 
>>
>   User: mathieu
>   Dbname: MYDB
>   Oracle Server version:
>
>>
>> rs <- dbSendQuery(conn, statement = paste("select * from cat"))
>> summary(rs, verbose=TRUE)
>>
> 
>   Statement: select * from cat
>   Has completed? no
>   Affected rows: 0
>   Rows fetched: -1
>   Fields:
> nameSclass type len precision scale isVarLength nullOK
> 1 TABLE_NAME character VARCHAR2  30 0 0TRUE  FALSE
> 2 TABLE_TYPE character VARCHAR2  11 0 0TRUE   TRUE
>
>>
>> myContent <- fetch(rs, n = -1)
>> myContent
>>
> [1] TABLE_NAME TABLE_TYPE
> <0 rows> (or 0-length row.names)
>
>> summary(myContent, verbose=TRUE)
>>
>   TABLE_NAME TABLE_TYPE
>  Length:0   Length:0
>  Class :character   Class :character
>  Mode  :character   Mode  :character
>
>> summary(rs, verbose=TRUE)
>>
> 
>   Statement: select * from cat
>   Has completed? yes
>   Affected rows: 0
>   Rows fetched: -1
>   Fields:
> nameSclass type len precision scale isVarLength nullOK
> 1 TABLE_NAME character VARCHAR2  30 0 0TRUE  FALSE
> 2 TABLE_TYPE character VARCHAR2  11 0 0TRUE   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
>

__
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] ROracle and select query empty

2005-08-25 Thread Mathieu Drapeau
Hi,
I just installed ROracle and RDBI. The connection to the database seems 
to work also. My problem is when I am selection rows that really exist 
in the database, it is returning nothing. Where should I look to see 
what could be my problem?

Thank you very much,
Mathieu

 > drv <- dbDriver("Oracle")
 > summary(drv, verbose=TRUE)

  Driver name:  Oracle (ProC/C++)
  Max  connections: 10
  Conn. processed: 8
  Default records per fetch: 500
  Oracle R/S client version: 0.5-4
  RS-DBI version:  0.1-9
  Open connections: 2
1  
2  
 >
 > conn <- dbConnect(drv, "mathieu/[EMAIL PROTECTED]")
 > summary(conn, verbose=TRUE) 
  User: mathieu
  Dbname: MYDB
  Oracle Server version:
 >
 > rs <- dbSendQuery(conn, statement = paste("select * from cat"))
 > summary(rs, verbose=TRUE)

  Statement: select * from cat
  Has completed? no
  Affected rows: 0
  Rows fetched: -1
  Fields:
nameSclass type len precision scale isVarLength nullOK
1 TABLE_NAME character VARCHAR2  30 0 0TRUE  FALSE
2 TABLE_TYPE character VARCHAR2  11 0 0TRUE   TRUE
 >
 > myContent <- fetch(rs, n = -1)
 > myContent
[1] TABLE_NAME TABLE_TYPE
<0 rows> (or 0-length row.names)
 > summary(myContent, verbose=TRUE)
  TABLE_NAME TABLE_TYPE
 Length:0   Length:0
 Class :character   Class :character
 Mode  :character   Mode  :character
 > summary(rs, verbose=TRUE)

  Statement: select * from cat
  Has completed? yes
  Affected rows: 0
  Rows fetched: -1
  Fields:
nameSclass type len precision scale isVarLength nullOK
1 TABLE_NAME character VARCHAR2  30 0 0TRUE  FALSE
2 TABLE_TYPE character VARCHAR2  11 0 0TRUE   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] help on retrieving output from by( ) for regression

2005-08-25 Thread Marc Schwartz (via MN)
Sorry to reply to my own post, but in reviewing the NAMESPACE file for
lme4, it looks like Doug is perhaps planning to add additional model
object accessor methods for the lmList class, including resid() and
summary(), which are commented out now. coef() is available presently. 

So when in place, it would appear that the use of lmList would be
advantageous over the use of by().

Marc

On Thu, 2005-08-25 at 11:52 -0500, Marc Schwartz (via MN) wrote:
> That works also (using the example in ?lmList)
> 
> library(lme4)
> 
> ?lmList
> 
> fm1 <- lmList(breaks ~ wool | tension, warpbreaks)
> 
> 
> However, one still would need to use either sapply() or lapply() as
> below to get the details that Krishna is looking for. 
> 
> 'fm1' above is a list of models (S4 class 'lmList') not overly different
> from 'tmp' below, which is a list of models (S3 class 'by').
> 
> If you review str(fm1) and str(tmp), you would note that they are
> virtually identical, save the use of slots, etc.
> 
> HTH,
> 
> Marc Schwartz
> 
> On Thu, 2005-08-25 at 12:17 -0400, Randy Johnson wrote:
> > What about using lmList from the lme4 package?
> > 
> > Randy
> > 
> > 
> > On 8/25/05 9:44 AM, "Marc Schwartz" <[EMAIL PROTECTED]> wrote:
> > 
> > > Also, looking at the last example in ?by would be helpful:
> > > 
> > > attach(warpbreaks)
> > > tmp <- by(warpbreaks, tension, function(x) lm(breaks ~ wool, data = x))
> > > 
> > > # To get coefficients:
> > > sapply(tmp, coef)
> > > 
> > > # To get residuals:
> > > sapply(tmp, resid)
> > > 
> > > # To get the model matrix:
> > > sapply(tmp, model.matrix)
> > > 
> > > 
> > > 
> > > To get the summary() output, I suspect that using:
> > > 
> > >   lapply(tmp, summary)
> > > 
> > > would yield more familiar output as compared to using:
> > > 
> > >   sapply(tmp, summary)
> > > 
> > > The output from the latter might require a bit more "navigation" through
> > > the resultant matrix, depending upon how the output is to be ultimately
> > > used.
> > > 
> > > HTH,
> > > 
> > > Marc Schwartz
> > > 
> > > 
> > > 
> > > On Thu, 2005-08-25 at 14:57 +0200, TEMPL Matthias wrote:
> > >> Look more carefully at
> > >> ?lm 
> > >> at the See Also section ...
> > >> 
> > >> X <- rnorm(30)
> > >> Y <- rnorm(30)
> > >> lm(Y~X)
> > >> summary(lm(Y~X))
> > >> 
> > >> Best,
> > >> Matthias
> > >> 
> > >> 
> > >>> Hi all 
> > >>> 
> > >>> I used a function
> >  qtrregr <- by(AB, AB$qtr, function(AB) lm(AB$X~AB$Y))
> > >>> 
> > >>> objective is to run a regression on quartery subsets in the
> > >>> data set AB, having variables X and Y, grouped by variable qtr.
> > >>> 
> > >>> Now i retrieved the output using qtrregr, however it only
> > >>> showed the coefficients (intercept and B) with out
> > >>> significant levels and residuals for each qtr. Can some on
> > >>> help me on how can retrieve the detailed regression output.
> > >>> 
> > >>> rgds
> > >>> 
> > >>> snvk
> > >>> 
> > > 
> > > __
> > > 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
> > > 
> > 
> > ~~
> > Randy Johnson
> > Laboratory of Genomic Diversity
> > NCI-Frederick
> > Bldg 560, Rm 11-85
> > Frederick, MD 21702
> > (301)846-1304
> > ~~
> > 
> > __
> > 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] PDL model

2005-08-25 Thread Carsten . Colombier
Dear r-help team:

Is a package implemented in R which includes a function that calculates
polynomial distributed lag models (also: Almon models, pdl-model)? Provided
a pdl function is available, can it be applied to robust statistics like
MM-estimators?

Thanks in advance!

Best regards,
Carsten Colombier

Dr. Carsten Colombier
Economist
Group of Economic Advisers
Swiss Federal Finance Administration
Bundesgasse 3
CH-3003 Bern

phone +41 31 322 63 32
fax +41 31 323 08 33
email: [EMAIL PROTECTED]
www.efv.admin.ch

__
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] Code in lattice::dotplot function.

2005-08-25 Thread Deepayan Sarkar
On 8/25/05, ernesto <[EMAIL PROTECTED]> wrote:
> Hi,
> 
> I'm trying to understand the code of lattice functions so that I can
> write some S4 methods using lattice. The following code is a snipet of
> dotplot that is reused in several other functions. I don't understand
> why this is needed can someone help ?

It was a hack to enable usage of the form dotplot(x). The latest
version of lattice does not use this sort of construct any more
(replacing it by generics and methods).

Deepayan

__
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] histogram method for S4 class.

2005-08-25 Thread Deepayan Sarkar
On 8/24/05, ernesto <[EMAIL PROTECTED]> wrote:
> Hi,
> 
> I'm trying to develop an histogram method for a class called "FLQuant"
> which is used by the package FLCore (http://flr-project.org). FLQuant is
> an extension to "array". There is an as.data.frame method that coerces
> flquant into a data.frame suitable for lattice plotting. The problem is
> that when I coerce the object and plot it after it works but if the
> method is applied within the histogram method it does not work. See the
> code below (the FLCore package is here
> http://prdownloads.sourceforge.net/flr/FLCore_1.0-1.tar.gz?download)
> 
> > library(FLCore)
> Loading required package: lattice
> > data(ple4)
> > histogram(~data|year, [EMAIL PROTECTED])
> Error in inherits(x, "factor") : Object "x" not found
> > histogram(~data|year, data=as.data.frame([EMAIL PROTECTED]))
> 
> The catch.n slot is a FLQuant object and the code for histogram is the
> following
> 
> setMethod("histogram", signature(formula="formula", data="FLQuant"),
> function (formula, data = parent.frame(), allow.multiple =
> is.null(groups) || outer,
> outer = FALSE, auto.key = FALSE, aspect = "fill", panel =
> "panel.histogram", prepanel = NULL,
> scales = list(), strip = TRUE, groups = NULL, xlab, xlim, ylab,
> ylim,
> type = c("percent", "count", "density"),
> nint = if (is.factor(x)) length(levels(x)) else
> round(log2(length(x)) + 1),
> endpoints = extend.limits(range(x[!is.na(x)]), prop = 0.04),
> breaks = if (is.factor(x)) seq(0.5, length = length(levels(x)) +
> 1) else do.breaks(endpoints, nint),
> equal.widths = TRUE, drop.unused.levels =
> lattice.getOption("drop.unused.levels"), ...,
> default.scales = list(), subscripts = !is.null(groups), subset =
> TRUE) {
> 
> qdf <- as.data.frame(data)
> 
> histogram(formula, data = qdf, allow.multiple = allow.multiple,
> outer = outer,
> auto.key = auto.key, aspect = aspect, panel = panel,
> prepanel = prepanel, scales = scales,
> strip = strip, groups = groups, xlab=xlab, xlim=xlim,
> ylab=ylab, ylim=ylim, type = type,
> nint = nint, endpoints = endpoints, breaks = breaks,
> equal.widths = equal.widths,
> drop.unused.levels = drop.unused.levels, ..., default.scales
> = default.scales,
> subscripts = subscripts, subset = subset)
> }
> )
> 
> 
> Any ideas ?

[I'm CC-ing to r-devel, please post follow-ups there]

What version of lattice are you using? Please use the latest one, in
which histogram is an S3 generic, with only one argument, formula. The
eventual solution to your problem may involve changing that, but the
first question to ask is whether any other formula makes sense in your
context (if not, I would rather keep one argument and dispatch on
signature(formula = "FLQuant").

Disclaimer: I haven't actually had time to check out FLCore yet, I
will as soon as I can.

Deepayan

__
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] help on retrieving output from by( ) for regression

2005-08-25 Thread Marc Schwartz (via MN)
That works also (using the example in ?lmList)

library(lme4)

?lmList

fm1 <- lmList(breaks ~ wool | tension, warpbreaks)


However, one still would need to use either sapply() or lapply() as
below to get the details that Krishna is looking for. 

'fm1' above is a list of models (S4 class 'lmList') not overly different
from 'tmp' below, which is a list of models (S3 class 'by').

If you review str(fm1) and str(tmp), you would note that they are
virtually identical, save the use of slots, etc.

HTH,

Marc Schwartz

On Thu, 2005-08-25 at 12:17 -0400, Randy Johnson wrote:
> What about using lmList from the lme4 package?
> 
> Randy
> 
> 
> On 8/25/05 9:44 AM, "Marc Schwartz" <[EMAIL PROTECTED]> wrote:
> 
> > Also, looking at the last example in ?by would be helpful:
> > 
> > attach(warpbreaks)
> > tmp <- by(warpbreaks, tension, function(x) lm(breaks ~ wool, data = x))
> > 
> > # To get coefficients:
> > sapply(tmp, coef)
> > 
> > # To get residuals:
> > sapply(tmp, resid)
> > 
> > # To get the model matrix:
> > sapply(tmp, model.matrix)
> > 
> > 
> > 
> > To get the summary() output, I suspect that using:
> > 
> >   lapply(tmp, summary)
> > 
> > would yield more familiar output as compared to using:
> > 
> >   sapply(tmp, summary)
> > 
> > The output from the latter might require a bit more "navigation" through
> > the resultant matrix, depending upon how the output is to be ultimately
> > used.
> > 
> > HTH,
> > 
> > Marc Schwartz
> > 
> > 
> > 
> > On Thu, 2005-08-25 at 14:57 +0200, TEMPL Matthias wrote:
> >> Look more carefully at
> >> ?lm 
> >> at the See Also section ...
> >> 
> >> X <- rnorm(30)
> >> Y <- rnorm(30)
> >> lm(Y~X)
> >> summary(lm(Y~X))
> >> 
> >> Best,
> >> Matthias
> >> 
> >> 
> >>> Hi all 
> >>> 
> >>> I used a function
>  qtrregr <- by(AB, AB$qtr, function(AB) lm(AB$X~AB$Y))
> >>> 
> >>> objective is to run a regression on quartery subsets in the
> >>> data set AB, having variables X and Y, grouped by variable qtr.
> >>> 
> >>> Now i retrieved the output using qtrregr, however it only
> >>> showed the coefficients (intercept and B) with out
> >>> significant levels and residuals for each qtr. Can some on
> >>> help me on how can retrieve the detailed regression output.
> >>> 
> >>> rgds
> >>> 
> >>> snvk
> >>> 
> > 
> > __
> > 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
> > 
> 
> ~~
> Randy Johnson
> Laboratory of Genomic Diversity
> NCI-Frederick
> Bldg 560, Rm 11-85
> Frederick, MD 21702
> (301)846-1304
> ~~
> 
> __
> 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] Help about R

2005-08-25 Thread Huntsinger, Reid
You might find image() useful, to plot the factory map and overlay the sound
levels as colors. You could also use persp(), or have a look at rgl.surface
in the rgl package on http://cran.r-project.org. 

Reid Huntsinger

-Original Message-
From: [EMAIL PROTECTED]
[mailto:[EMAIL PROTECTED] On Behalf Of Philippe
Sent: Thursday, August 25, 2005 9:55 AM
To: r-help@stat.math.ethz.ch
Subject: [R] Help about R


Hello,
My name is Philippe Favrot, I'm a french occupational doctor (working in 
Luxembourg), and I'm an "R beginner".
I would be happy you could help me about the utilization of "R".
Recently, I measured sound levels in a plant. Before the measuring, I 
divided the plant in 3 virtual rows and 8 virtual columns. I measured 
the sound level at each intersection of rows and columns and obtained a 
set of 24 "sound level" values.
I wrote the results in a excel's spreadsheet.
My question is: I know to do import from excel into "R" (with 
read.table()), but how can I draw a three dimensional graphic of the 
plant's sound level ? Can I overlay a map of this factory (as a 
rectangle with a grid representing each spots where I measured )?
I'd understand if you are too busy to reply to my mail.
Thanks.
Best regards
Philippe Favrot

__
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] question sur R

2005-08-25 Thread Abdelhafid BERRICHI
bonjour

je suis elève à l'ENSAI Rennes et je suis actuellement en stage de fin 
d'études

j'ai une question sur R

en fait lorsque le simule 2 lois normales qui sont mes 2 variables 
explicatives continus 
- une avec que des valeurs > 0 (ou que <0)   X1
- l'autre peut prendre aussi bien des valeurs <0 ou >0  X2


et que je regresse le rating (facteur ordonné) sur X1 ca marche alors que 
sur X2 ca ne marche pas : il m'indique l'erreur suivante 

Re-fitting to get Hessian
Error in svd(X) : infinite or missing 
values in x

 
pourtant svd(X2) fonctionne bien : il fait bien la décomposition en 
valeurs singulière

est-ce du au signe des valeurs ou bien est-ce un autre problème?

merci d'avance!!

cordialement

abdelhafid berrichi
[[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] box m-test

2005-08-25 Thread Petra Wallem
Hello everybody, 
 Is there in R a so called box m-test for testing the equality of the 
 variance/cov. matrix for checking on homoscedasticity? I could not find
it among the traditional packages for multivariate statistics...
Petra
-- 
Petra Wallem
Centro de Estudios Avanzados en Ecología & Biodiversidad (CASEB)
Departamento de Ecología
Facultad de Ciencias Biológicas
Pontificia Universidad Católica de Chile
Av. Libertador Bernardo O'Higgins # 340
Casilla 114-D

__
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] problem with read.table

2005-08-25 Thread Liaw, Andy
Could it be that there are spaces in the names that were read in?

> a <- data.frame(" X"=1:2, " Y"=3:4, " Z"=5:6, check.names=FALSE)
> a
   X  Y  Z
1  1  3  5
2  2  4  6
> names(a)
[1] " X" " Y" " Z"
> a$X
NULL

Andy

> From: Krishna
> 
> Hi  Mr. Pedro
> 
> I tried names(a) and it displayed the names as X, Y and Z.
> 
> rgds
> 
> snvk
> 
> On 8/25/05, Pedro J. Aphalo <[EMAIL PROTECTED]> wrote:
> > Hi,
> > 
> > Did you try names(a) so see what are the names of the columns in the
> > dataframe?
> > 
> > Hope this helps a little.
> > 
> > Pedro.
> > 
> > Krishna wrote:
> > > Hi All
> > >
> > > recently i faced an unknown problem while reading the data. Can
> > > someone help me in understanding why this happened.
> > >
> > > I have .txt file containing X, Y, Z variables. I used the command
> > >
> > >
> > >>a <- read.table("filename", header=TRUE)
> > >
> > > after reading the file i am able to view it by tryping a. but i am
> > > unable to access the variables in a, by giving the command a$X.
> > >
> > >
> > >>a$X
> > >>NULL
> > >
> > >
> > > this is the output it was showing. However the same i am able to
> > > access by giving a[[1]]. i tried changing the mode by 
> issuing command
> > > a <- as.data.frame(a). But situation remains the same.
> > >
> > > look forward for experts suggestion on this.
> > >
> > > rgds
> > >
> > > snvk
> > >
> > > __
> > > 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
> > 
> > 
> > --
> > 
> ==
> > Pedro J. Aphalo
> > Department of Biological and Environmental Science
> > University of Jyväskylä
> > P.O. Box 35, 40351 JYVÄSKYLÄ, Finland
> > Phone  +358 14 260 2339
> > Mobile +358 50 3721504
> > Fax+358 14 260 2321
> > mailto:[EMAIL PROTECTED]
> > http://www.jyu.fi/~aphalo/   ,,,^..^,,,
> > ==
> > 
> >
> 
> __
> 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] Help about R

2005-08-25 Thread Don MacQueen
Also, for the three dimensional graphic,
help.search("3d")
will lead to a reference to the cloud() function in the lattice package.

I don't remember if the lattice package is installed by default. If 
not, you will have to install it.
(If you're using a Mac or Windows computer, there's a menu item for 
installing packages. Otherwise you have to use the install.packages() 
function.)

Then

require(lattice)
   ?cloud

to first load the lattice package, and then view the online 
documentation for the cloud() function.

You can view one of the cloud() examples like this:

require(datasets)
cloud(Sepal.Length ~ Petal.Length * Petal.Width | Species, data = iris,
screen = list(x = -90, y = 70), distance = .4, zoom = .6)

You could consider a bubble plot. There are two packages with 
functions for bubble plots, gstat and sp.
(Neither of them is installed by default.) I suspect the one in gstat 
will be easier to use, at least for someone new to R.

After having installed either of these packages, say gstat, then

   ?bubble

to get its documentation.

Overlaying a grid on the plot created by cloud() might be difficult 
for an R beginner.

Here's a simple example:

bubble(data.frame(x=1:5,y=1:5,z=1:5))

-Don


At 3:54 PM +0200 8/25/05, Philippe wrote:
>Hello,
>My name is Philippe Favrot, I'm a french occupational doctor (working in
>Luxembourg), and I'm an "R beginner".
>I would be happy you could help me about the utilization of "R".
>Recently, I measured sound levels in a plant. Before the measuring, I
>divided the plant in 3 virtual rows and 8 virtual columns. I measured
>the sound level at each intersection of rows and columns and obtained a
>set of 24 "sound level" values.
>I wrote the results in a excel's spreadsheet.
>My question is: I know to do import from excel into "R" (with
>read.table()), but how can I draw a three dimensional graphic of the
>plant's sound level ? Can I overlay a map of this factory (as a
>rectangle with a grid representing each spots where I measured )?
>I'd understand if you are too busy to reply to my mail.
>Thanks.
>Best regards
>Philippe Favrot
>
>__
>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


-- 
--
Don MacQueen
Environmental Protection Department
Lawrence Livermore National Laboratory
Livermore, CA, USA

__
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] A. Mani : Tapply

2005-08-25 Thread A Mani
Hello,
Is it safe to use tapply when the result will be of dim 2
x 1 or more ? In my PC R crashes. The code used was on a 3-col
data frame with two factor cols and a numeric column. The fn was diff
.
data form being 
tapply(data$A, list(data$A, data$B), diff)

-- 
A. Mani
Member, Cal. Math. Soc

__
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] "couldn't find function" error message in R 2.1.1

2005-08-25 Thread Petr Pikal
Hi

Is the package loaded?

What is echoed vhen you do

library(mypackage)

Does search() find your package?

Cheers
Petr




On 25 Aug 2005 at 11:19, qikai xu wrote:

> Dear R-help,
> 
> I have a home-made package works perfectly under R 1.9.1.  Now I'm
> trying to port it to R > 2.0.  So I rebuild the package under R 2.1.1.
> It installs and loads OK. But when I try to call some functions
> "myfoo" in this package, it returns error message: "Couldn't find
> function myfoo".  I checked all available manuals, and didn't find any
> specific requirement that I'm violating.  Have anybody in the list
> ever had similar problem before and how did you solve it?  Thanks a
> lot for your help.
> 
> Qikai Xu
> 
> __
> 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

Petr Pikal
[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] concerning econometrics usage of "R"

2005-08-25 Thread Achim Zeileis
On Thu, 25 Aug 2005 11:20:01 -0500 Jorge de la Vega Gongora wrote:

> There are some reviews. You can read:
>  R: yet another Econometric Programming Environment, Francisco Cibari-
>  Neto 
> and Spyros G. Zarkos.
> Journal of Applied Econometrics, 14: 319-329 (1999)

It's a good article and definitely worth reading (as is Racine &
Hyndman, Using R to Teach Econometrics, JAE, 17, 175-189, 2002) but note
that it reviews version 0.63.1 of R and that many things changed since
then.
Z

> 
>  On 8/25/05, Achim Zeileis <[EMAIL PROTECTED]> wrote: 
> > 
> > On Thu, 25 Aug 2005 11:52:28 +0100 SELIM YILDIRIM wrote:
> > 
> > > Hi,
> > >
> > > I am currently looking for a program or programmng language easy
> > > to learn, easier to operate on.I heva heard about "R", However I
> > > understand that "R" is designed especially for statisticians. As
> > > an economist, working on applied econometrics, I am not sure if it
> > > can meet my needs.
> > >
> > > Will I be able to reach precise time series or panal data
> > > regression results with "R" ?
> > 
> > yes
> > 
> > > Can "R" regress nonlinear models such as TAR, STAR
> > > and Markov Switcing models? Can I use it to do cointegration, unit
> > > root, VAR analysis on both panel and time series data? Can I run
> > > GMM regressions on "R" ?
> > 
> > some things yes, other things not out of the box
> > 
> > > Is it suitable for Monte Carlos?
> > 
> > yes
> > 
> > > In short, is R suitable for applied econometrics?
> > 
> > In principle yes, although not everything you might want to do is
> > already available in CRAN packages. For an overview of what is
> > currently available, look at the task view as Duncan already
> > suggested.
> > 
> > Best,
> > Z
> > 
> > __
> > 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] concerning econometrics usage of "R"

2005-08-25 Thread Jorge de la Vega Gongora
There are some reviews. You can read:
 R: yet another Econometric Programming Environment, Francisco Cibari- Neto 
and Spyros G. Zarkos.
Journal of Applied Econometrics, 14: 319-329 (1999)
 

 On 8/25/05, Achim Zeileis <[EMAIL PROTECTED]> wrote: 
> 
> On Thu, 25 Aug 2005 11:52:28 +0100 SELIM YILDIRIM wrote:
> 
> > Hi,
> >
> > I am currently looking for a program or programmng language easy to
> > learn, easier to operate on.I heva heard about "R", However I
> > understand that "R" is designed especially for statisticians. As an
> > economist, working on applied econometrics, I am not sure if it can
> > meet my needs.
> >
> > Will I be able to reach precise time series or panal data regression
> > results with "R" ?
> 
> yes
> 
> > Can "R" regress nonlinear models such as TAR, STAR
> > and Markov Switcing models? Can I use it to do cointegration, unit
> > root, VAR analysis on both panel and time series data? Can I run GMM
> > regressions on "R" ?
> 
> some things yes, other things not out of the box
> 
> > Is it suitable for Monte Carlos?
> 
> yes
> 
> > In short, is R suitable for applied econometrics?
> 
> In principle yes, although not everything you might want to do is
> already available in CRAN packages. For an overview of what is currently
> available, look at the task view as Duncan already suggested.
> 
> Best,
> Z
> 
> __
> R-help@stat.math.ethz.ch mailing list
> https://stat.ethz.ch/mailman/listinfo/r-help
> PLEASE do read the posting guide! 
> http://www.R-project.org/posting-guide.html
>

[[alternative HTML version deleted]]

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


[R] "couldn't find function" error message in R 2.1.1

2005-08-25 Thread qikai xu
Dear R-help,

I have a home-made package works perfectly under R 1.9.1.  Now I'm trying to
port it to R > 2.0.  So I rebuild the package under R 2.1.1. It installs and
loads OK. But when I try to call some functions "myfoo" in this package, it
returns error message: "Couldn't find function myfoo".  I checked all
available manuals, and didn't find any specific requirement that I'm
violating.  Have anybody in the list ever had similar problem before and how
did you solve it?  Thanks a lot for your help.

Qikai Xu

__
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] help on retrieving output from by( ) for regression

2005-08-25 Thread Randy Johnson
What about using lmList from the lme4 package?

Randy


On 8/25/05 9:44 AM, "Marc Schwartz" <[EMAIL PROTECTED]> wrote:

> Also, looking at the last example in ?by would be helpful:
> 
> attach(warpbreaks)
> tmp <- by(warpbreaks, tension, function(x) lm(breaks ~ wool, data = x))
> 
> # To get coefficients:
> sapply(tmp, coef)
> 
> # To get residuals:
> sapply(tmp, resid)
> 
> # To get the model matrix:
> sapply(tmp, model.matrix)
> 
> 
> 
> To get the summary() output, I suspect that using:
> 
>   lapply(tmp, summary)
> 
> would yield more familiar output as compared to using:
> 
>   sapply(tmp, summary)
> 
> The output from the latter might require a bit more "navigation" through
> the resultant matrix, depending upon how the output is to be ultimately
> used.
> 
> HTH,
> 
> Marc Schwartz
> 
> 
> 
> On Thu, 2005-08-25 at 14:57 +0200, TEMPL Matthias wrote:
>> Look more carefully at
>> ?lm 
>> at the See Also section ...
>> 
>> X <- rnorm(30)
>> Y <- rnorm(30)
>> lm(Y~X)
>> summary(lm(Y~X))
>> 
>> Best,
>> Matthias
>> 
>> 
>>> Hi all 
>>> 
>>> I used a function
 qtrregr <- by(AB, AB$qtr, function(AB) lm(AB$X~AB$Y))
>>> 
>>> objective is to run a regression on quartery subsets in the
>>> data set AB, having variables X and Y, grouped by variable qtr.
>>> 
>>> Now i retrieved the output using qtrregr, however it only
>>> showed the coefficients (intercept and B) with out
>>> significant levels and residuals for each qtr. Can some on
>>> help me on how can retrieve the detailed regression output.
>>> 
>>> rgds
>>> 
>>> snvk
>>> 
> 
> __
> 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
> 

~~
Randy Johnson
Laboratory of Genomic Diversity
NCI-Frederick
Bldg 560, Rm 11-85
Frederick, MD 21702
(301)846-1304
~~

__
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] problem with read.table

2005-08-25 Thread Don MacQueen
  Potential helpers need more information.

Type:

head(a)

and

str(a)

and post the results.

Compare with the output of the same commands on a 
dataframe that does have this problem.

-Don

At 5:01 PM +0530 8/25/05, Krishna wrote:
>Hi  Mr. Pedro
>
>I tried names(a) and it displayed the names as X, Y and Z.
>
>rgds
>
>snvk
>
>On 8/25/05, Pedro J. Aphalo <[EMAIL PROTECTED]> wrote:
>>  Hi,
>>
>>  Did you try names(a) so see what are the names of the columns in the
>>  dataframe?
>>
>>  Hope this helps a little.
>>
>>  Pedro.
>>
>>  Krishna wrote:
>>  > Hi All
>>  >
>>  > recently i faced an unknown problem while reading the data. Can
>>  > someone help me in understanding why this happened.
>>  >
>>  > I have .txt file containing X, Y, Z variables. I used the command
>>  >
>>  >
>>  >>a <- read.table("filename", header=TRUE)
>>  >
>>  > after reading the file i am able to view it by tryping a. but i am
>>  > unable to access the variables in a, by giving the command a$X.
>>  >
>>  >
>>  >>a$X
>>  >>NULL
>>  >
>>  >
>>  > this is the output it was showing. However the same i am able to
>>  > access by giving a[[1]]. i tried changing the mode by issuing command
>>  > a <- as.data.frame(a). But situation remains the same.
>>  >
>>  > look forward for experts suggestion on this.
>>  >
>>  > rgds
>>  >
>>  > snvk
>>  >
>>  > __
>>  > 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
>>
>>
>>  --
>>  ==
>>  Pedro J. Aphalo
>>  Department of Biological and Environmental Science
>>  University of Jyväskylä
>>  P.O. Box 35, 40351 JYVÄSKYLÄ, Finland
>>  Phone  +358 14 260 2339
>>  Mobile +358 50 3721504
>>  Fax+358 14 260 2321
>>  mailto:[EMAIL PROTECTED]
>>  http://www.jyu.fi/~aphalo/   ,,,^..^,,,
>>  ==
>>
>>
>
>__
>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


-- 
--
Don MacQueen
Environmental Protection Department
Lawrence Livermore National Laboratory
Livermore, CA, USA

__
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] Help about R

2005-08-25 Thread Romain Francois
Le 25.08.2005 15:54, Philippe a écrit :

>Hello,
>My name is Philippe Favrot, I'm a french occupational doctor (working in 
>Luxembourg), and I'm an "R beginner".
>I would be happy you could help me about the utilization of "R".
>Recently, I measured sound levels in a plant. Before the measuring, I 
>divided the plant in 3 virtual rows and 8 virtual columns. I measured 
>the sound level at each intersection of rows and columns and obtained a 
>set of 24 "sound level" values.
>I wrote the results in a excel's spreadsheet.
>My question is: I know to do import from excel into "R" (with 
>read.table()), but how can I draw a three dimensional graphic of the 
>plant's sound level ? Can I overlay a map of this factory (as a 
>rectangle with a grid representing each spots where I measured )?
>I'd understand if you are too busy to reply to my mail.
>Thanks.
>Best regards
>Philippe Favrot
>  
>
Bonjour Philippe,

Have you tried :
** RSiteSearch('3D')
** RSiteSearch('map')
** http://addictedtor.free.fr/graphiques/search.php?q=3D
** http://addictedtor.free.fr/graphiques/search.php?q=map
** http://www.stat.auckland.ac.nz/~paul/RGraphics/rgraphics.html about a 
great book on R graphics (I can't wait to have my copy, just ordered one 
by amazon)

Also, have a look at the package rgl on cran, that's terrific !!

Cheers,

Romain

-- 
visit the R Graph Gallery : http://addictedtor.free.fr/graphiques
 ~ 
~~  Romain FRANCOIS - http://addictedtor.free.fr ~~
Etudiant  ISUP - CS3 - Industrie et Services   
~~http://www.isup.cicrp.jussieu.fr/  ~~
   Stagiaire INRIA Futurs - Equipe SELECT  
~~   http://www.inria.fr/recherche/equipes/select.fr.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] Help about R

2005-08-25 Thread vincent
Philippe a écrit :

> ... how can I draw a three dimensional graphic of the 
> plant's sound level ?

Not an answer, but I find image() very useful
to visualize 3D data simply on a 2D colored image.
hih

__
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 about R

2005-08-25 Thread Philippe
Hello,
My name is Philippe Favrot, I'm a french occupational doctor (working in 
Luxembourg), and I'm an "R beginner".
I would be happy you could help me about the utilization of "R".
Recently, I measured sound levels in a plant. Before the measuring, I 
divided the plant in 3 virtual rows and 8 virtual columns. I measured 
the sound level at each intersection of rows and columns and obtained a 
set of 24 "sound level" values.
I wrote the results in a excel's spreadsheet.
My question is: I know to do import from excel into "R" (with 
read.table()), but how can I draw a three dimensional graphic of the 
plant's sound level ? Can I overlay a map of this factory (as a 
rectangle with a grid representing each spots where I measured )?
I'd understand if you are too busy to reply to my mail.
Thanks.
Best regards
Philippe Favrot

__
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] help on retrieving output from by( ) for regression

2005-08-25 Thread Marc Schwartz
Also, looking at the last example in ?by would be helpful:

attach(warpbreaks)
tmp <- by(warpbreaks, tension, function(x) lm(breaks ~ wool, data = x))

# To get coefficients:
sapply(tmp, coef)

# To get residuals:
sapply(tmp, resid)

# To get the model matrix:
sapply(tmp, model.matrix)



To get the summary() output, I suspect that using:

  lapply(tmp, summary)

would yield more familiar output as compared to using:

  sapply(tmp, summary)

The output from the latter might require a bit more "navigation" through
the resultant matrix, depending upon how the output is to be ultimately
used.

HTH,

Marc Schwartz



On Thu, 2005-08-25 at 14:57 +0200, TEMPL Matthias wrote:
> Look more carefully at 
> ?lm 
> at the See Also section ...
> 
> X <- rnorm(30)
> Y <- rnorm(30)
> lm(Y~X)
> summary(lm(Y~X))
> 
> Best,
> Matthias
> 
> 
> > Hi all 
> > 
> > I used a function 
> > > qtrregr <- by(AB, AB$qtr, function(AB) lm(AB$X~AB$Y))
> > 
> > objective is to run a regression on quartery subsets in the 
> > data set AB, having variables X and Y, grouped by variable qtr.
> > 
> > Now i retrieved the output using qtrregr, however it only 
> > showed the coefficients (intercept and B) with out 
> > significant levels and residuals for each qtr. Can some on 
> > help me on how can retrieve the detailed regression output.
> > 
> > rgds
> > 
> > snvk
> >

__
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] concerning econometrics usage of "R"

2005-08-25 Thread Achim Zeileis
On Thu, 25 Aug 2005 11:52:28 +0100 SELIM YILDIRIM wrote:

> Hi, 
> 
> I am currently looking for a program or programmng language easy to
> learn, easier to operate on.I heva heard about "R", However I
> understand that "R" is designed especially for statisticians. As an
> economist, working on applied econometrics, I am not sure if it can
> meet my needs.
> 
> Will I be able to reach precise time series or panal data regression
> results with "R" ?

yes

> Can "R" regress nonlinear models such as TAR, STAR
> and Markov Switcing models? Can I use it to do cointegration, unit
> root, VAR analysis on both panel and time series data? Can I run GMM
> regressions on "R" ?

some things yes, other things not out of the box

> Is it suitable for Monte Carlos? 

yes

> In short, is R suitable for applied econometrics?

In principle yes, although not everything you might want to do is
already available in CRAN packages. For an overview of what is currently
available, look at the task view as Duncan already suggested.

Best,
Z

__
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] concerning econometrics usage of "R"

2005-08-25 Thread Duncan Murdoch
On 8/25/2005 6:52 AM, SELIM YILDIRIM wrote:
> Hi, 
> 
> I am currently looking for a program or programmng language easy to
> learn, easier to operate on.I heva heard about "R", However I
> understand that "R" is designed especially for statisticians. As an
> economist, working on applied econometrics, I am not sure if it can
> meet my needs.
> 
> Will I be able to reach precise time series or panal data regression
> results with "R" ? Can "R" regress nonlinear models such as TAR, STAR
> and Markov Switcing models? Can I use it to do cointegration, unit
> root, VAR analysis on both panel and time series data? Can I run GMM
> regressions on "R" ? Is it suitable for Monte Carlos? 
> 
> In short, is R suitable for applied econometrics?

I'm not an econometrician, so I don't know the answer to that question, 
but you can read about econometrics uses of R in the task view for 
Econometrics, here:

http://cran.r-project.org/src/contrib/Views

Duncan Murdoch

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


Re: [R] help on retrieving output from by( ) for regression

2005-08-25 Thread TEMPL Matthias
Look more carefully at 
?lm 
at the See Also section ...

X <- rnorm(30)
Y <- rnorm(30)
lm(Y~X)
summary(lm(Y~X))

Best,
Matthias


> Hi all 
> 
> I used a function 
> > qtrregr <- by(AB, AB$qtr, function(AB) lm(AB$X~AB$Y))
> 
> objective is to run a regression on quartery subsets in the 
> data set AB, having variables X and Y, grouped by variable qtr.
> 
> Now i retrieved the output using qtrregr, however it only 
> showed the coefficients (intercept and B) with out 
> significant levels and residuals for each qtr. Can some on 
> help me on how can retrieve the detailed regression output.
> 
> rgds
> 
> snvk
> 
> __
> 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] Re : Packages

2005-08-25 Thread Uwe Ligges
justin bem wrote:

> Hi !
>  
> I got the same problem. I use R itself to install those package I got them.
> Try this It may work !


If you reply to a question posted on R-help, please
a) include the original question in your reply, others probably forgot 
the original question;
b) reply to the poster who might not be subscribed on the list.

Thanks,
Uwe Ligges



> Sincerly !
> 
>   
> -
> 
> 
>   [[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 on retrieving output from by( ) for regression

2005-08-25 Thread Krishna
Hi all 

I used a function 
> qtrregr <- by(AB, AB$qtr, function(AB) lm(AB$X~AB$Y))

objective is to run a regression on quartery subsets in the data set
AB, having variables X and Y, grouped by variable qtr.

Now i retrieved the output using qtrregr, however it only showed the
coefficients (intercept and B) with out significant levels and
residuals for each qtr. Can some on help me on how can retrieve the
detailed regression output.

rgds

snvk

__
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] Call SAS from R

2005-08-25 Thread justin bem
hi ,
 
Ihave you try to use the package foreign ? try it may be you will see how to 
read foreign data file.
 
Sincerly !


-


[[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] Re : Packages

2005-08-25 Thread justin bem
Hi !
 
I got the same problem. I use R itself to install those package I got them.
Try this It may work !
 
Sincerly !


-


[[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] Converting characters to numbers in data frames

2005-08-25 Thread Gabor Grothendieck
On 8/25/05, Anon. <[EMAIL PROTECTED]> wrote:
> I'm sure I'm missing something obvious here, but I can't find the
> solution (including in the FAQ etc.).
> 
> I have a vector of names of variables like this: NRes.x.y. where x and y
> are numbers.  I want to extract these numbers as numbers to use
> elsewhere.  I can extract the numbers as a list of characters using
> strsplit(), and convert that to a data frame, e.g.:
> 
> NAMES=c("NRes.1.2.", "NRes.1.3.", "NRes.1.4.", "NRes.1.5.", "NRes.1.6.")
> NUMBERS=strsplit(gsub("NRes.","", NAMES, perl =T), '.', fixed = TRUE)
> NUMBERS.df=t(data.frame(NUMBERS))
> 
> But I now want to convert the characters to be numeric.  Using
> as.numeric(NUMBERS.df) converts them, but to a vector.  How can I
> convert and keep as a data frame?  I could use this:
> 
> matrix(as.numeric(NUMBERS.df), ncol=dim(NUMBERS.df)[2])
> 
> but I seem to be jumping through far too many hoops: there must be an
> easier way.  An suggestions?


Try this:

   read.table(textConnection(NAMES), sep = ".")[,2:3]

You may also want to add the col.names= argument to the read.table call
if you want prettier column names.  Also I think Names and Numbers would
be sufficient to distinguish them from potential lower case counterparts.

__
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] problem with read.table

2005-08-25 Thread vincent
Krishna a écrit :

> unable to access the variables in a, by giving the command a$X.

try a$V1 or a[1] or a[,1] or a$V2 etc
hih

__
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] Converting characters to numbers in data frames

2005-08-25 Thread Peter Wolf
Try:

NAMES=c("NRes.1.2.", "NRes.1.3.", "NRes.1.4.", "NRes.1.5.", "NRes.1.6.")
pattern<-"NRes\.([0-9]*)\.([0-9]*)\."
data.frame(x=sub(pattern,"\\1",NAMES),y=sub(pattern,"\\2",NAMES))

@
output-start
Thu Aug 25 14:08:50 2005
  x y
1 1 2
2 1 3
3 1 4
4 1 5
5 1 6
output-end

Peter Wolf

Anon. wrote:
>I'm sure I'm missing something obvious here, but I can't find the 
>solution (including in the FAQ etc.).
>
>I have a vector of names of variables like this: NRes.x.y. where x and y 
>are numbers.  I want to extract these numbers as numbers to use 
>elsewhere.  I can extract the numbers as a list of characters using 
>strsplit(), and convert that to a data frame, e.g.:
>
>NAMES=c("NRes.1.2.", "NRes.1.3.", "NRes.1.4.", "NRes.1.5.", "NRes.1.6.")
>NUMBERS=strsplit(gsub("NRes.","", NAMES, perl =T), '.', fixed = TRUE)
>NUMBERS.df=t(data.frame(NUMBERS))
>
>But I now want to convert the characters to be numeric.  Using 
>as.numeric(NUMBERS.df) converts them, but to a vector.  How can I 
>convert and keep as a data frame?  I could use this:
>
>matrix(as.numeric(NUMBERS.df), ncol=dim(NUMBERS.df)[2])
>
>but I seem to be jumping through far too many hoops: there must be an 
>easier way.  An suggestions?
>
>Bob
>
>

__
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] Converting characters to numbers in data frames

2005-08-25 Thread Sundar Dorai-Raj


Anon. wrote:
> I'm sure I'm missing something obvious here, but I can't find the 
> solution (including in the FAQ etc.).
> 
> I have a vector of names of variables like this: NRes.x.y. where x and y 
> are numbers.  I want to extract these numbers as numbers to use 
> elsewhere.  I can extract the numbers as a list of characters using 
> strsplit(), and convert that to a data frame, e.g.:
> 
> NAMES=c("NRes.1.2.", "NRes.1.3.", "NRes.1.4.", "NRes.1.5.", "NRes.1.6.")
> NUMBERS=strsplit(gsub("NRes.","", NAMES, perl =T), '.', fixed = TRUE)
> NUMBERS.df=t(data.frame(NUMBERS))
> 
> But I now want to convert the characters to be numeric.  Using 
> as.numeric(NUMBERS.df) converts them, but to a vector.  How can I 
> convert and keep as a data frame?  I could use this:
> 
> matrix(as.numeric(NUMBERS.df), ncol=dim(NUMBERS.df)[2])
> 
> but I seem to be jumping through far too many hoops: there must be an 
> easier way.  An suggestions?
> 
> Bob
> 


How about this?

NUMBERS <- lapply(strsplit(NAMES, "\\."), "[", -1)
as.data.frame(do.call("rbind", lapply(NUMBERS, as.numeric)))

--sundar

__
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] concerning econometrics usage of "R"

2005-08-25 Thread SELIM YILDIRIM
Hi, 

I am currently looking for a program or programmng language easy to
learn, easier to operate on.I heva heard about "R", However I
understand that "R" is designed especially for statisticians. As an
economist, working on applied econometrics, I am not sure if it can
meet my needs.

Will I be able to reach precise time series or panal data regression
results with "R" ? Can "R" regress nonlinear models such as TAR, STAR
and Markov Switcing models? Can I use it to do cointegration, unit
root, VAR analysis on both panel and time series data? Can I run GMM
regressions on "R" ? Is it suitable for Monte Carlos? 

In short, is R suitable for applied econometrics?

__
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] Code in lattice::dotplot function.

2005-08-25 Thread ernesto
Hi,

I'm trying to understand the code of lattice functions so that I can
write some S4 methods using lattice. The following code is a snipet of
dotplot that is reused in several other functions. I don't understand
why this is needed can someone help ?

Thanks

EJ

[...]

right.name <- deparse(substitute(formula))
try(formula <- eval(formula), silent = TRUE)
foo <- substitute(formula)

if (!(is.call(foo) && foo[[1]] == "~")) {
formula <- as.formula(paste("~", right.name)) #   deparse(foo)))
environment(formula) <- parent.frame()
}

[...]

__
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] Converting characters to numbers in data frames

2005-08-25 Thread Anon.
I'm sure I'm missing something obvious here, but I can't find the 
solution (including in the FAQ etc.).

I have a vector of names of variables like this: NRes.x.y. where x and y 
are numbers.  I want to extract these numbers as numbers to use 
elsewhere.  I can extract the numbers as a list of characters using 
strsplit(), and convert that to a data frame, e.g.:

NAMES=c("NRes.1.2.", "NRes.1.3.", "NRes.1.4.", "NRes.1.5.", "NRes.1.6.")
NUMBERS=strsplit(gsub("NRes.","", NAMES, perl =T), '.', fixed = TRUE)
NUMBERS.df=t(data.frame(NUMBERS))

But I now want to convert the characters to be numeric.  Using 
as.numeric(NUMBERS.df) converts them, but to a vector.  How can I 
convert and keep as a data frame?  I could use this:

matrix(as.numeric(NUMBERS.df), ncol=dim(NUMBERS.df)[2])

but I seem to be jumping through far too many hoops: there must be an 
easier way.  An suggestions?

Bob

-- 
Bob O'Hara
Department of Mathematics and Statistics
P.O. Box 68 (Gustaf Hällströmin katu 2b)
FIN-00014 University of Helsinki
Finland

Telephone: +358-9-191 51479
Mobile: +358 50 599 0540
Fax:  +358-9-191 51400
WWW:  http://www.RNI.Helsinki.FI/~boh/
Journal of Negative Results - EEB: www.jnr-eeb.org

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


Re: [R] correlation by subset

2005-08-25 Thread Chuck Cleland
Krishna wrote:
> Hi Mr. Cleland
> 
> it worked excellently well, and i believe the same logic or function
> by() can be used even for running regressions on subsets of huge
> datasets. correct me if iam wrong

   Yes.  For example, the FUN argument to by() can be a summary of a 
linear model:

by(warpbreaks, warpbreaks$tension, function(x) summary(lm(breaks ~ wool, 
data=x)))

> thank you for the help
> 
> rgds
> 
> snvk
> 
> On 8/24/05, Krishna <[EMAIL PROTECTED]> wrote:
> 
>>Hi Mr. Cleland
>>
>>Could you please detail the function.
>>
>>Thanks and best regards
>>
>>snvk
>>
>>On 8/24/05, Chuck Cleland <[EMAIL PROTECTED]> wrote:
>>
>>>by(mydata, mydata$GROUPING, function(x) cor(x$x, x$y, use="pair"))
>>>
>>>?by
>>>
>>>Krishna wrote:
>>>
Hi all

Having searched the available documentation on R, I request for help
in sorting out the underlying problem.

I have a huge dataset containing 2 variables x and y, which is a daily
price series.

I would like to observe the quarterly correlations among these two
variables. Is there anyway where i can calculate cor.coeff by using a
grouping variable in R.

thanks in advance for the help

rgds

snvk

__
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

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

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

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


Re: [R] correlation by subset

2005-08-25 Thread Krishna
Hi Mr. Cleland

it worked excellently well, and i believe the same logic or function
by() can be used even for running regressions on subsets of huge
datasets. correct me if iam wrong

thank you for the help

rgds

snvk

On 8/24/05, Krishna <[EMAIL PROTECTED]> wrote:
> Hi Mr. Cleland
> 
> Could you please detail the function.
> 
> Thanks and best regards
> 
> snvk
> 
> On 8/24/05, Chuck Cleland <[EMAIL PROTECTED]> wrote:
> > by(mydata, mydata$GROUPING, function(x) cor(x$x, x$y, use="pair"))
> >
> > ?by
> >
> > Krishna wrote:
> > > Hi all
> > >
> > > Having searched the available documentation on R, I request for help
> > > in sorting out the underlying problem.
> > >
> > > I have a huge dataset containing 2 variables x and y, which is a daily
> > > price series.
> > >
> > > I would like to observe the quarterly correlations among these two
> > > variables. Is there anyway where i can calculate cor.coeff by using a
> > > grouping variable in R.
> > >
> > > thanks in advance for the help
> > >
> > > rgds
> > >
> > > snvk
> > >
> > > __
> > > 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
> > >
> >
> > --
> > Chuck Cleland, Ph.D.
> > NDRI, Inc.
> > 71 West 23rd Street, 8th floor
> > New York, NY 10010
> > tel: (212) 845-4495 (Tu, Th)
> > tel: (732) 452-1424 (M, W, F)
> > fax: (917) 438-0894
> >
>

__
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] problem with read.table

2005-08-25 Thread Krishna
Hi  Mr. Pedro

I tried names(a) and it displayed the names as X, Y and Z.

rgds

snvk

On 8/25/05, Pedro J. Aphalo <[EMAIL PROTECTED]> wrote:
> Hi,
> 
> Did you try names(a) so see what are the names of the columns in the
> dataframe?
> 
> Hope this helps a little.
> 
> Pedro.
> 
> Krishna wrote:
> > Hi All
> >
> > recently i faced an unknown problem while reading the data. Can
> > someone help me in understanding why this happened.
> >
> > I have .txt file containing X, Y, Z variables. I used the command
> >
> >
> >>a <- read.table("filename", header=TRUE)
> >
> > after reading the file i am able to view it by tryping a. but i am
> > unable to access the variables in a, by giving the command a$X.
> >
> >
> >>a$X
> >>NULL
> >
> >
> > this is the output it was showing. However the same i am able to
> > access by giving a[[1]]. i tried changing the mode by issuing command
> > a <- as.data.frame(a). But situation remains the same.
> >
> > look forward for experts suggestion on this.
> >
> > rgds
> >
> > snvk
> >
> > __
> > 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
> 
> 
> --
> ==
> Pedro J. Aphalo
> Department of Biological and Environmental Science
> University of Jyväskylä
> P.O. Box 35, 40351 JYVÄSKYLÄ, Finland
> Phone  +358 14 260 2339
> Mobile +358 50 3721504
> Fax+358 14 260 2321
> mailto:[EMAIL PROTECTED]
> http://www.jyu.fi/~aphalo/   ,,,^..^,,,
> ==
> 
>

__
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 do log normal regression?

2005-08-25 Thread Frederico Zanqueta Poleto
A very simple and useful relation between the normal and log-normal 
distributions is that if log(Y) follows the normal distribution, then Y follows 
the log-normal distribution, and vice-versa.

Then, if you want to do a log-normal regression, you can take the natural 
logarithm of your data and do a normal regression.

Take a look on any book about statistical distributions, e.g. the one from 
Evans, Hastings and Peacock or Johnson and Kotz or Patel, Kapadia and Owen,  
because I am not so sure, but I think the exponential of the fitted values will 
be the estimated median of the log-normal distribution.

Regards,
--
Frederico Zanqueta Poleto
[EMAIL PROTECTED]
--
"All knowledge is, in final analysis, History. All sciences are, in the 
abstract, Mathematics. All judgements are, in their rationale, Statistics." 
Radhakrishna Rao


- Segue mensagem original! -

De: Spencer Graves <[EMAIL PROTECTED]>
Data: Wed, 24 Aug 2005 21:18:48 -0700
Para: Haibo Huang <[EMAIL PROTECTED]>
Assunto: Re: [R] How to do log normal regression?

  1.  Have you considered "nls" or "optim"?  The documentation for both 
includes useful examples.

  2.  What do your Y values represent?  The almost universal standard 
today is maximum likelihood estimation.  If you tell us what the Y 
values are, someone might help you write a likelihood function that 
could then be maximized using "optim".

  3.  I notice this is the third post I've answered for you in the past 
month.  I've been so busy recently, I tend to limit myself only to posts 
that are several days old for which I have not seen a reply.  I believe 
you might get quicker and more useful replies to your questions if you 
please read and try to follow the posting guide! 
"http://www.R-project.org/posting-guide.html";.

  Good luck.
  spencer graves

Haibo Huang wrote:

> I want to fit a Log-Normal CDF function between two
> variables, and estimate the parameters. Is there any
> package/functions designed for this purpose? 
> 
> Basically, I have data for Y and X, and I suspect the
> relationship between Y and X is Y = CDF Log-Normal
> (X), and I want to run this regression to verify this
> and estimate the parameters. Anyone has any thoughts?
> 
> Any input is valuable to me, so please do not hesitate
> to share your thoughts. Thank you!
> 
> Ed.
> 
> __
> 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

-- 
Spencer Graves, PhD
Senior Development Engineer
PDF Solutions, Inc.
333 West San Carlos Street Suite 700
San Jose, CA 95110, USA

[EMAIL PROTECTED]
www.pdf.com 
Tel:  408-938-4420
Fax: 408-280-7915

__
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] problem with read.table

2005-08-25 Thread TEMPL Matthias
> Hi All
> 
> recently i faced an unknown problem while reading the data. 
> Can someone help me in understanding why this happened.
> 
> I have .txt file containing X, Y, Z variables. I used the command 

Please show at least 2 lines of your data.

> 
> > a <- read.table("filename", header=TRUE)

Are you sure, that a looks correct? (= have you set the correct
seperator in read.table with option sep= )

Best regards,
Matthias

> after reading the file i am able to view it by tryping a. but 
> i am unable to access the variables in a, by giving the command a$X.
> 
> > a$X
> > NULL
> 
> this is the output it was showing. However the same i am able 
> to access by giving a[[1]]. i tried changing the mode by 
> issuing command a <- as.data.frame(a). But situation remains the same.
> 
> look forward for experts suggestion on this.
> 
> rgds
> 
> snvk
> 
> __
> 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] problem with read.table

2005-08-25 Thread Krishna
Hi All

recently i faced an unknown problem while reading the data. Can
someone help me in understanding why this happened.

I have .txt file containing X, Y, Z variables. I used the command 

> a <- read.table("filename", header=TRUE)
after reading the file i am able to view it by tryping a. but i am
unable to access the variables in a, by giving the command a$X.

> a$X
> NULL

this is the output it was showing. However the same i am able to
access by giving a[[1]]. i tried changing the mode by issuing command
a <- as.data.frame(a). But situation remains the same.

look forward for experts suggestion on this.

rgds

snvk

__
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] lm.ridge

2005-08-25 Thread Berwin A Turlach
G'day Daniel,

> "DR" == daniel  <[EMAIL PROTECTED]> writes:

DR> First: I think coefficients from lm(Employed~.,data=longley)
DR> should be equal coefficients from
DR> lm.ridge(Employed~.,data=longley, lambda=0) why it does not
DR> happen?
Which version of R and which version of MASS are you using?

> lm(Employed~.,data=longley)

Call:
lm(formula = Employed ~ ., data = longley)

Coefficients:
 (Intercept)  GNP.deflator   GNPUnemployed  Armed.Forces  
  -3.482e+03 1.506e-02-3.582e-02-2.020e-02-1.033e-02  
  Population  Year  
  -5.110e-02 1.829e+00  

> lm.ridge(Employed~.,data=longley, lambda=0)
   GNP.deflator   GNPUnemployed  Armed.Forces 
-3.482259e+03  1.506187e-02 -3.581918e-02 -2.020230e-02 -1.033227e-02 
   Population  Year 
-5.110411e-02  1.829151e+00 


These coefficients look pretty identical to me, except that they are
printed to different numbers of significant digits.

In fact, the following shows that they are identical (upto numerical
precision): 

> fm1 <- lm(Employed~.,data=longley)
> fm2 <- lm.ridge(Employed~.,data=longley, lambda=0)
> coef2 <- print(fm2)
   GNP.deflator   GNPUnemployed  Armed.Forces 
-3.482259e+03  1.506187e-02 -3.581918e-02 -2.020230e-02 -1.033227e-02 
   Population  Year 
-5.110411e-02  1.829151e+00 
> max(abs(coef(fm1)-coef2))
[1] 7.275958e-12


DR> Second: if I have for example Ridge<-lm.ridge(Employed~.,
DR> data=longley, lambda = seq(0,0.1,0.001)), I suppose intercept
DR> coefficient is defined implicit,
Yes.

DR> why it does not appear in Ridge$coef?
If you look at the code of lm.ridge, you will see that, if an
intercept is included in the model, all non-constant regressors are
centered (i.e. made orthogonal to the intercept term) and scaled to
have the same variance.  Further more, the intercept term is typically
*not* penalised.  The components in Ridge$coef are the coefficients on
this transformed scale.  No need of including the intercept here,
since it is the same for all values of lambda.  If you print the
model, then the ridge coefficients on the original scale are
calculated, see:

> getAnywhere("print.ridgelm")
A single object matching 'print.ridgelm' was found
It was found in the following places
  registered S3 method for print from namespace MASS
  namespace:MASS
with value

function (x, ...) 
{
scaledcoef <- t(as.matrix(x$coef/x$scales))
if (x$Inter) {
inter <- x$ym - scaledcoef %*% x$xm
scaledcoef <- cbind(Intercept = inter, scaledcoef)
}
print(drop(scaledcoef), ...)
}


DR> Third: I suppose that if I define
DR> 1) y<-longley$Employed
DR> 2) X<-as.matrix(cbind(1,Longley[,1:6])
DR> 3) I = identity matrix the

DR> following should be true: Coef=(X'X+kI)^(-1) X'y
No, as noted above, the intercept term is usually not penalised.

DR> and if a take k=Ridge$kHKV, Coef should be approx equal to
DR> Ridge$Coef[near value of kHKV]
No, as noted above the estimates in the "coef" component of an object
returned by lm.ridge are the coefficients on a different scale.

DR> and it does not seem to happen, why?
Because the intercept is not penalised by lm.ridge and the
non-constant columns of the design matrix are rescaled; hence the
returned coefficients are on another scale.

DR> Any help, suggestion or orientation?
HTH.

Cheers,

Berwin

__
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] Poisson Distribution fitting

2005-08-25 Thread Prof Brian Ripley
On Thu, 25 Aug 2005, Prof Brian Ripley wrote:

> On Thu, 25 Aug 2005, Mark Miller wrote:
>
>> I am trying to fit a number of distributions to a set of data, I have used 
>> the
>> fitdristr() funtion for most of the distributions, but Poisson is not one 
>> of
>> the possible distributions. I found somewhee talking about using the gamlss
>> package, but have been unable to find it again, any help would be greatly
>> appreciated.
>
> If you mean fitdistr in package MASS, it can be used.  But the mle for a 
> Poisson is just the sample mean.
>
>> x <- rpois(250, 2.6)
>> mean(x)
> [1] 2.62
>> fitdistr(x, dpois, list(lambda=2))
>lambda
>  2.6203125
> (0.1023841)
>
> You can even find the s.e. via mu/sqrt(n), here
>> mean(x)/sqrt(250)
> [1] 0.1657033

Sorry, sqrt(mu/n).

-- 
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] how to close connections?

2005-08-25 Thread Prof Brian Ripley
Try this

con <- gzfile("file.gz")
a <- readLines(con, n=1)
showConnections(all=TRUE)
close(con)
showConnections(all=TRUE)

So the connection is opened and closed as it says, but not destroyed.
You do need to call close() explicitly -- from the help file

  'close' closes and destroys a connection.
 

There are  'create - open - close - destroy'  states for a connection.


On Thu, 25 Aug 2005, Ott Toomet wrote:

> Hi everybody,
>
> I am using gzipped files quite extensively and cannot figure out how I
> can close (or reuse) connections.
>
> Example:
>
>> for(i in 1:300) {cat(i, "\n"); a <- readLines(gzfile("file.gz"), n=1) }
> 1
> 2
> ...
> 46
> 47
> Error in gzfile("~/tyyq/andmebaasiq/ETU/ETU1997.tsv.gz") :
>   all connections are in use
>
> To use just gzfile without any open/close should be OK as the help
> states:
>
> ... In general functions using connections will open them if they are not
> open, but then close them again, so to leave a connection open call
> open explicitly.
>
> I have also experimented with explicit open/close but without any more
> success, though, R claims that the connections will be closed.
>
> Any ideas?  Is it my misunderstanding?  What exactly means a
> connection is "in use"?

-- 
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] 'splice' two data frames

2005-08-25 Thread David Whiting
Thank you! I think I can simplify the first line further to:

> z<-data.frame(matrix(rbind(x,y),nrow(x)))

i.e. remove 2 * ncol(x)

Thanks.

Dave

Peter Wolf wrote:
> what about:
> 
> @
> <<*>>=
> z<-data.frame(matrix(rbind(x,y),nrow(x),2*ncol(x)))
> rownames(z)<-rownames(x)
> z
> @
> output-start
> Thu Aug 25 11:24:29 2005
>  X1   X2 X3   X4 X5   X6 X7   X8
> a  2 0.02  1 0.01  2 0.02  2 0.02
> b  3 0.03  0 0.00  4 0.04  3 0.03
> c  3 0.03  2 0.02  1 0.01  6 0.06
> d  3 0.03  4 0.04  2 0.02  3 0.03
> e  4 0.04  1 0.01  4 0.04  2 0.02
> f  2 0.02  5 0.05  2 0.02  2 0.02
> g  4 0.04  5 0.05  3 0.03  3 0.03
> h  3 0.03  3 0.03  5 0.05  4 0.04
> i  1 0.01  0 0.00  3 0.03  3 0.03
> output-end
> 
> Peter Wolf

[...]
-- 
David Whiting
School of Clinical Medical Sciences, The Medical School
University of Newcastle upon Tyne, NE2 4HH, UK.

__
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] 'splice' two data frames

2005-08-25 Thread Peter Wolf
what about:

@
<<*>>=
z<-data.frame(matrix(rbind(x,y),nrow(x),2*ncol(x)))
rownames(z)<-rownames(x)
z
@
output-start
Thu Aug 25 11:24:29 2005
  X1   X2 X3   X4 X5   X6 X7   X8
a  2 0.02  1 0.01  2 0.02  2 0.02
b  3 0.03  0 0.00  4 0.04  3 0.03
c  3 0.03  2 0.02  1 0.01  6 0.06
d  3 0.03  4 0.04  2 0.02  3 0.03
e  4 0.04  1 0.01  4 0.04  2 0.02
f  2 0.02  5 0.05  2 0.02  2 0.02
g  4 0.04  5 0.05  3 0.03  3 0.03
h  3 0.03  3 0.03  5 0.05  4 0.04
i  1 0.01  0 0.00  3 0.03  3 0.03
output-end

Peter Wolf


David Whiting wrote:
>Hi,
>
>I often need to take columns from two data.frames and 'splice' them
>together (alternately taking a column from the first data frame, then
>from the second). For example:
>
>x <- table(sample(letters[1:9], 100, replace=TRUE),
>   sample(letters[1:4], 100, replace=TRUE))
>y <- prop.table(x)
>
>splice <- function (x, y) {
>  z <- matrix(rep(NA, (ncol(x) * 2) * nrow(x)), nrow = nrow(x))
>  j <- 1
>  for (i in seq(1, ncol(z), by = 2)) {
>z[, i] <- x[, j]
>z[, (i + 1)] <- y[, j]
>j <- j + 1
>  }
>  z <- data.frame(z)
>  rownames(z) <- rownames(x)
>  z
>}
>
>splice(x, y)
>
>
>Manually using indexing I can do this:
>
>zz <- data.frame(x[, 1], y[, 1], x[, 2], y[, 2], x[, 3], y[, 3], x[, 4],
>y[, 4])
>
>
>I *feel* that it should be possible in R to generate the sequence of
>column indexes automatically. I can get close with this:
>
>i <- paste("x[,", 1:ncol(x), "], ",
>  "y[,", 1:ncol(y), "]",
>  collapse=", ")
>
>which creates a string version of what I want, but I am not sure how to
>use that with data.frame. FAQ 7.21 ("How can I turn a string into a
>variable?") looked promising but I have not been able to apply any of
>the suggestions to this problem. I also tried using do.call:
>
>i <- paste("x[,", 1:4, "],", "y[,", 1:4, "]", collapse=",")
>i <- gsub("],", "]@", i)  # Create a marker for
>i <- strsplit(i, "@") # strsplit to create a list
>do.call(data.frame, i)
>
>and with lapply:
>
>lappy(i, data.frame)
>
>These "did not work" (i.e. they worked as they were designed to and did
>not give me the results I am after).
>
>I think I need a nudge or two in the right direction.
>
>Thanks.
>
>Dave
>
>

__
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] 'splice' two data frames

2005-08-25 Thread David Whiting
Hi,

I often need to take columns from two data.frames and 'splice' them
together (alternately taking a column from the first data frame, then
from the second). For example:

x <- table(sample(letters[1:9], 100, replace=TRUE),
   sample(letters[1:4], 100, replace=TRUE))
y <- prop.table(x)

splice <- function (x, y) {
  z <- matrix(rep(NA, (ncol(x) * 2) * nrow(x)), nrow = nrow(x))
  j <- 1
  for (i in seq(1, ncol(z), by = 2)) {
z[, i] <- x[, j]
z[, (i + 1)] <- y[, j]
j <- j + 1
  }
  z <- data.frame(z)
  rownames(z) <- rownames(x)
  z
}

splice(x, y)


Manually using indexing I can do this:

zz <- data.frame(x[, 1], y[, 1], x[, 2], y[, 2], x[, 3], y[, 3], x[, 4],
y[, 4])


I *feel* that it should be possible in R to generate the sequence of
column indexes automatically. I can get close with this:

i <- paste("x[,", 1:ncol(x), "], ",
   "y[,", 1:ncol(y), "]",
   collapse=", ")

which creates a string version of what I want, but I am not sure how to
use that with data.frame. FAQ 7.21 ("How can I turn a string into a
variable?") looked promising but I have not been able to apply any of
the suggestions to this problem. I also tried using do.call:

i <- paste("x[,", 1:4, "],", "y[,", 1:4, "]", collapse=",")
i <- gsub("],", "]@", i)  # Create a marker for
i <- strsplit(i, "@") # strsplit to create a list
do.call(data.frame, i)

and with lapply:

lappy(i, data.frame)

These "did not work" (i.e. they worked as they were designed to and did
not give me the results I am after).

I think I need a nudge or two in the right direction.

Thanks.

Dave

-- 
David Whiting
School of Clinical Medical Sciences, The Medical School
University of Newcastle upon Tyne, NE2 4HH, UK.

__
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 close connections?

2005-08-25 Thread Ott Toomet
Hi everybody,

I am using gzipped files quite extensively and cannot figure out how I
can close (or reuse) connections.  

Example:

> for(i in 1:300) {cat(i, "\n"); a <- readLines(gzfile("file.gz"), n=1) }
1 
2 
...
46 
47 
Error in gzfile("~/tyyq/andmebaasiq/ETU/ETU1997.tsv.gz") : 
all connections are in use

To use just gzfile without any open/close should be OK as the help
states:

... In general functions using connections will open them if they are not
open, but then close them again, so to leave a connection open call
open explicitly.

I have also experimented with explicit open/close but without any more
success, though, R claims that the connections will be closed.

Any ideas?  Is it my misunderstanding?  What exactly means a
connection is "in use"?

Thanks in advance,

Ott

> version
 _
platform i686-pc-linux-gnu
arch i686 
os   linux-gnu
system   i686, linux-gnu  
status
major2
minor1.1  
year 2005 
month06   
day  20   
language R




-- 
Ott Toomet, PhD
Research Fellow

Dept. of Economics
Tartu University
Narva 4 - A123
Tartu 51009
Estonia

otoomet (a) ut ee
ph:  (+372) 7 37 6374
fax: (+372) 7 37 6312
---

 (o_ (*_ (O_ (o< -!  
//\ //\ //\ //\  
V_/_V_/_V_/_V_/_ 
 
standarddrunken shocked noisy
penguin penguin penguin penguin

__
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] Poisson Distribution fitting

2005-08-25 Thread Prof Brian Ripley
On Thu, 25 Aug 2005, Mark Miller wrote:

> I am trying to fit a number of distributions to a set of data, I have used the
> fitdristr() funtion for most of the distributions, but Poisson is not one of
> the possible distributions. I found somewhee talking about using the gamlss
> package, but have been unable to find it again, any help would be greatly
> appreciated.

If you mean fitdistr in package MASS, it can be used.  But the mle for a 
Poisson is just the sample mean.

> x <- rpois(250, 2.6)
> mean(x)
[1] 2.62
> fitdistr(x, dpois, list(lambda=2))
 lambda
   2.6203125
  (0.1023841)

You can even find the s.e. via mu/sqrt(n), here
> mean(x)/sqrt(250)
[1] 0.1657033

-- 
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] Poisson Distribution fitting

2005-08-25 Thread Mark Miller
I am trying to fit a number of distributions to a set of data, I have used the 
fitdristr() funtion for most of the distributions, but Poisson is not one of 
the possible distributions. I found somewhee talking about using the gamlss 
package, but have been unable to find it again, any help would be greatly 
appreciated. 

Mark Miller

__
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