Re: [R] PCA functions

2009-02-16 Thread Bjørn-Helge Mevik
glenn g1enn.robe...@btinternet.com writes:

 Is there a function (before I try and write it !) that allows the input of a
 covariance or correlation matrix to calculate PCA, rather than the actual
 data as in princomp()

Yes, there is: princomp(). :-)


-- 
Bjørn-Helge Mevik

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


Re: [R] I want axes that cross

2009-02-16 Thread Mark Difford

Hi Paul,

 Have you ever seen a drawing of the regions of an R plot with the
 terminology that is used for parts?

From what I can remember, several documents on CRAN cover this. The one that
springs to mind is Alzola  Harrell's An Introduction to S and the Hmisc
and Design Libraries,” which you can download from the Contributed
Documentation link on CRAN.

Chap. 4 of MASS by Venables  Ripley (4th ed.) will also give you what you
want.

Regards, Mark.


Paul Johnson-11 wrote:
 
 On Fri, Feb 13, 2009 at 3:14 PM, Marc Schwartz
 marc_schwa...@comcast.net wrote:
 on 02/13/2009 02:19 PM Paul Johnson wrote:
 On Fri, Feb 13, 2009 at 1:51 PM, Marc Schwartz

 OK, so given all of the above, something like the following should work:

 set.seed(1233240)
 x - rnorm(100)
 z - gl(2,50)
 y - rnorm(100, mean = 1.8 * as.numeric(z))

 # Calculate a new range, subtracting a definable value
 # from the min of each vector for the new minimum
 # Adust the 0.25 as may be needed
 X - c(min(x) - 0.25, max(x))
 Y - c(min(y) - 0.25, max(y))

 # Use 'X' and Y' here, not 'x' and 'y'
 # So that the plot region is extended appropriately
 plot(X, Y, type = n, axes = F, xlab = x, ylab = y)

 points(x, y, pch = $, cex = 0.7, col = z)

 # DO use 'pos'...
 axis(1, pos = Y[1], col = green, col.axis = green)
 axis(2, pos = X[1], col = red, col.axis = red)

 # get the plot region boundaries
 usr - par(usr)

 segments(X[1], usr[3], X[1], usr[4], col = red)
 segments(usr[1], Y[1], usr[2], Y[1], col = green)


 HTH,

 Marc


 
 Thanks, Marc and everybody.
 
 This last suggestion produces the graph I was trying for.
 
 The other approaches that people suggest, using pos or xaxp, produce
 other undesired changes in the tick marks or the position of the axes
 relative to the data. xaxp offers the promise of a more intuitive
 solution, except that, when using it, the tick marks are pushed off in
 a bad way.  Your use of segments to draw the extensions of the axes
 was the first intuition I had, but I did not know about the trick you
 used to retrieve the size of the usr box.
 
 More secrets of par, revealed.
 
 Have you ever seen a drawing of the regions of an R plot with the
 terminology that is used for parts?  Until I saw your example code, I
 had not understood that the plot axes are placed at the absolute edge
 of the user plotting region, for example.
 
 -- 
 Paul E. Johnson
 Professor, Political Science
 1541 Lilac Lane, Room 504
 University of Kansas
 
 __
 R-help@r-project.org mailing list
 https://stat.ethz.ch/mailman/listinfo/r-help
 PLEASE do read the posting guide
 http://www.R-project.org/posting-guide.html
 and provide commented, minimal, self-contained, reproducible code.
 
 

-- 
View this message in context: 
http://www.nabble.com/I-want-axes-that-cross-tp22003252p22033868.html
Sent from the R help mailing list archive at Nabble.com.

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


Re: [R] Unadulterated plot

2009-02-16 Thread Simon Pickett

Hi James,

What you really need to do is to check out the many freely available pdfs 
for R beginners. Here is a good place to start


http://cran.r-project.org/other-docs.html

If I am right interpreting what you want, I think you need to create a blank 
plot with no axes, axis labels etc. Try


plot(x,y,xlab=,ylab=,xaxt=NULL,yaxt=NULL,type=n)
#blank plot
points(x,y)

type ?par into R and see how you can set parameters like this up as the 
default.


Hope this helps?

Simon.


- Original Message - 
From: James Nicolson jlnicol...@gmail.com

To: r-help@r-project.org
Sent: Sunday, February 15, 2009 10:29 PM
Subject: [R] Unadulterated plot



To all,

Apologies if this question has already been asked but I can't find 
anything. I can't seem to think of more specific search terms. I want to 
display/create a file of a pure plot with a specific height and width. I 
want to utilise every single pixel inside the axes. I do not want to 
display any margins, legends, axes, titles or spaces around the edges. Is 
this possible? Additionally, the plot I am working with is a 
filled.contour plot and I can not remove the legend? How can I do this?


Kind Regards,
James

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

and provide commented, minimal, self-contained, reproducible code.



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


Re: [R] PCA functions

2009-02-16 Thread andrew
The PCA is just a singular value decomposition on a sample covariance/
correlation matrix.  Do a search for ?svd and get the eigenvalues and
vectors from that function.

On Feb 14, 10:30 am, glenn g1enn.robe...@btinternet.com wrote:
 Hi All, would appreciate an answer on this if you have a moment;

 Is there a function (before I try and write it !) that allows the input of a
 covariance or correlation matrix to calculate PCA, rather than the actual
 data as in princomp()

 Regards

 Glenn

         [[alternative HTML version deleted]]

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

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


[R] How to create sequence of constant time interval

2009-02-16 Thread Suresh_FSFM

Dear R-Experts, 

seek your help.

There are two parts I want to deal with.
1) 
I want to create a time interval of say, 30 minutes starting from 00:00:00
hrs
Thus at the end, I want to create sequence:
00:00:00
00:30:00
01:00:00 
01:30:00
..
..
How to do so ?
Later, I want to change the time-increment value in a variable and changing
the value of this variable, I would like to create new sequence with that
time increment. How to use seq() correctly?

2)
I have a date stored in one variable. Say 2009-01-01
How can I combine this date with each time interval in the first part? Will
concatenate work?
so at the end, I would like to have:

2009-01-01 00:00:00
2009-01-01 00:30:00
2009-01-01 01:00:00
2009-01-01 01:30:00
...
...

Thank you in advance.






-- 
View this message in context: 
http://www.nabble.com/How-to-create-sequence-of-constant-time-interval-tp22034441p22034441.html
Sent from the R help mailing list archive at Nabble.com.

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


[R] solve.QP with box and equality constraints

2009-02-16 Thread Selwyn McCracken
Dear list,

I am trying to follow an example that estimates a 2x2 markov transition
matrix across several periods from aggregate data using restricted least
squares.

I seem to be making headway using solve.QP(quadprog) as the unrestricted
solution matches the example I am following, and I can specify simple
equality and inequality constraints. However, I cannot correctly specify a
constraint matrix (Amat) with box constraints per cell and equality
constraints that span multiple cells. Namely the solution matrix I am aiming
for needs to respect the following conditions:
  - each row must sum to 1
  - each cell must = 0
  - each cell must = 1

I understand the general principle of creating box constraints by creating
pairs of positive and negative values within the constraint matrix (
http://tolstoy.newcastle.edu.au/R/help/05/10/14251.html), but when I pass
this expanded constraint matrix to solve.QP it complains that Amat and dvec
are incompatible. How should I expand dvec (and consequently Dmat) to
accomodate the larger Amat? Moreover, I am unclear how to apply the meq
equality constraint across more than one cell (i.e. rows summing to one)
although I have attempted a guess below.

Any help warmly received.
Selwyn.


#examples below


library(quadprog)
#pairs of population values over time
mat = cbind(
  cal = c(12988,13408,13834,14267,14707,15155) ,
  rest = c(152082,154201,156352,158536,160754,163006)
  )

(X = kronecker(diag(1, ncol(mat)), mat[-nrow(mat),]))
(y = c(mat[-1,]))

XX = (t(X) %*% X)
Xy = t(X) %*% y

# a working example of simply constrained solution
# i.e. constrain 1st and 4th values to be 1, 2nd and 3rd 0
(a =  diag(c(-1,1,1,-1)))
(b = c(1,0,0,1))

# this is correct according to these constraints, but I need 0 = a = 1 for
all a and each row to sum to 1
solve.QP(Dmat = XX,dvec=Xy,Amat = a,bvec=b)


#my guess at the constraint matrix and b_vec...
(a2 = rbind(
   c(1,0,1,0), #specify the two cells in the 'row' I want to sum to one(???)
   c(0,1,0,1), # likewise
   kronecker(diag(rep(1,4)),c(1,-1)) #create positive and negative
constraint pairs
   )
)

(b2 = c(1,1,rep(0:1,times=4)))

solve.QP(Dmat = XX,dvec=Xy,Amat = a2,bvec=b2,meq=2) #complains that Amat and
dvec are incompatible

[[alternative HTML version deleted]]

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


Re: [R] PCA functions

2009-02-16 Thread Mark Difford

Hi Glen, Andrew,

 The PCA is just a singular value decomposition on a sample covariance/...

I believe that Bjørn-Helge Mevik's point was that __if you read the
documentation__ you will see the argument covmat to princomp(). This,
really, is much more straightforward and practical than Andrew's suggestion.

Regards, Mark.


andrew-246 wrote:
 
 The PCA is just a singular value decomposition on a sample covariance/
 correlation matrix.  Do a search for ?svd and get the eigenvalues and
 vectors from that function.
 
 On Feb 14, 10:30 am, glenn g1enn.robe...@btinternet.com wrote:
 Hi All, would appreciate an answer on this if you have a moment;

 Is there a function (before I try and write it !) that allows the input
 of a
 covariance or correlation matrix to calculate PCA, rather than the actual
 data as in princomp()

 Regards

 Glenn

         [[alternative HTML version deleted]]

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

-- 
View this message in context: 
http://www.nabble.com/PCA-functions-tp22006964p22034611.html
Sent from the R help mailing list archive at Nabble.com.

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


[R] solve.QP with box and equality constraints

2009-02-16 Thread Selwyn McCracken
[reposting as a plain text - apologies for the double posting]

Dear list,

I am trying to follow an example that estimates a 2x2 markov
transition matrix across several periods from aggregate data using
restricted least squares.

I seem to be making headway using solve.QP(quadprog) as the
unrestricted solution matches the example I am following, and I can
specify simple equality and inequality constraints. However, I cannot
correctly specify a constraint matrix (Amat) with box constraints per
cell and equality constraints that span multiple cells. Namely the
solution matrix I am aiming for needs to respect the following
conditions:
  - each row must sum to 1
  - each cell must = 0
  - each cell must = 1

I understand the general principle of creating box constraints by
creating pairs of positive and negative values within the constraint
matrix (http://tolstoy.newcastle.edu.au/R/help/05/10/14251.html), but
when I pass this expanded constraint matrix to solve.QP it complains
that Amat and dvec are incompatible. How should I expand dvec (and
consequently Dmat) to accomodate the larger Amat? Moreover, I am
unclear how to apply the meq equality constraint across more than one
cell (i.e. rows summing to one) although I have attempted a guess
below.

Any help warmly received.
Selwyn.


#examples below


library(quadprog)
#pairs of population values over time
mat = cbind(
  cal = c(12988,13408,13834,14267,
14707,15155) ,
  rest = c(152082,154201,156352,158536,160754,163006)
  )

(X = kronecker(diag(1, ncol(mat)), mat[-nrow(mat),]))
(y = c(mat[-1,]))

XX = (t(X) %*% X)
Xy = t(X) %*% y

# a working example of simply constrained solution
# i.e. constrain 1st and 4th values to be 1, 2nd and 3rd 0
(a =  diag(c(-1,1,1,-1)))
(b = c(1,0,0,1))

# this is correct according to these constraints, but I need 0 = a =
1 for all a and each row to sum to 1
solve.QP(Dmat = XX,dvec=Xy,Amat = a,bvec=b)


#my guess at the constraint matrix and b_vec...
(a2 = rbind(
   c(1,0,1,0), #specify the two cells in the 'row' I want to sum to one(???)
   c(0,1,0,1), # likewise
   kronecker(diag(rep(1,4)),c(1,-1)) #create positive and negative
constraint pairs
   )
)

(b2 = c(1,1,rep(0:1,times=4)))

solve.QP(Dmat = XX,dvec=Xy,Amat = a2,bvec=b2,meq=2) #complains that
Amat and dvec are incompatible

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


[R] Comparison of age categories using contrasts

2009-02-16 Thread Patrick Giraudoux

Dear listers,

I would like to compare the levels of a factor with 8 age categories
(0,10] (10,20] (20,30] (30,40] (40,50] (50,60] (60,70] (70,90] (however,
the factor has not been ordered yet). The default in glm is
cont.treatment (for unordered factors) and that leads to compare each
level to the first one. I would rather prefer to compare the 2nd to the
1st, the 3rd to the 2nd, the 4th to the 3rd, etc... My understanding is
that cont.poly may make the trick, eg specified like this:

mod3-glm(AE~agecat, family=binomial,data=qinghai2,
contrasts=list(agecat=contr.poly))

but I am not sure to be right.

Would be grateful if a true statistician can confirm or fire me... and
before definitive fire tell me how to manage with this...

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


[R] problem with gls finding model terms without specifying data=named.object

2009-02-16 Thread Paul.Rustomji
Hello R-help

I am having trouble getting gls to find the R objects that comprise a linear 
model when the data=named.object option(option!) is not specified.  In the 
gls() help it states data is an optional data frame containing the variables 
named in model, correlation, weights, and subset. By default the variables are 
taken from the environment from which gls is called.


An example:

 temp - data.frame(x=1:10,y=11:20+rnorm(10))
 temp
xy
1   1 11.52458
2   2 10.77643
3   3 12.56845
4   4 14.48822
5   5 13.58116
6   6 16.26223
7   7 17.89619
8   8 19.40359
9   9 18.56699
10 10 21.05374
 gls(temp$y~temp$x)
Error in eval(expr, envir, enclos) : object y not found
 gls(y~x,data=temp)
Generalized least squares fit by REML
  Model: y ~ x 
  Data: temp 
  Log-restricted-likelihood: -14.00387

Coefficients:
(Intercept)   x 
   9.3662561.135619 

Degrees of freedom: 10 total; 8 residual
Residual standard error: 0.9156084 

 I'm trying hard to avoid having to specify the data option if at all possible.

Paul

---

R version 2.8.0 (2008-10-20) (yes I know its not 2.8.1 but nothing in the 2.8.1 
news seemed to be relevant, I also tried on a different PC with R 2.7.0 but 
same problem)

i386-pc-mingw32 

locale:

LC_COLLATE=English_Australia.1252;LC_CTYPE=English_Australia.1252;LC_MONETARY=English_Australia.1252;LC_NUMERIC=C;LC_TIME=English_Australia.1252



attached base packages:

[1] stats graphics  grDevices utils datasets  methods   base 



other attached packages:

[1] nlme_3.1-89



loaded via a namespace (and not attached):

[1] grid_2.8.0  lattice_0.17-17

---



Information on package 'nlme'



Description:



Package:   nlme

Version:   3.1-89

Date:  2008-06-07

Priority:  recommended

Title: Linear and Nonlinear Mixed Effects Models

Author:Jose Pinheiro jose.pinhe...@pharma.novartis.com, Douglas Bates 
ba...@stat.wisc.edu,

   Saikat DebRoy sai...@stat.wisc.edu, Deepayan Sarkar 
deepayan.sar...@r-project.org,

   the R Core team.

Maintainer:R-core r-c...@r-project.org

Description:   Fit and compare Gaussian linear and nonlinear mixed-effects 
models.


Paul Rustomji
Rivers and Estuaries
CSIRO Land and Water
GPO Box 1666
Canberra ACT 2601

ph +61 2 6246 5810
mobile 0406 375 739

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


Re: [R] PCA functions

2009-02-16 Thread S Ellison
princomp uses the raw data and calculates the correlation or covariance matrix 
on the way to the PC's, so that doesn't use a correlation matrix itself. You 
do, however, get the choice.

However, PC's are the eigenvectors of the correlation (or covariance) matrix, 
so in principle calling eigen() on either would be sufficient for the PC's. The 
signs may differ, though, as they are arbitrary; compare 
prcomp(USArrests)$rotation with eigen(cov(USArrests)).

S




 Bjørn-Helge Mevik b.h.me...@usit.uio.no 16/02/2009 09:05 
glenn g1enn.robe...@btinternet.com writes:

 Is there a function (before I try and write it !) that allows the input of a
 covariance or correlation matrix to calculate PCA, rather than the actual
 data as in princomp()

Yes, there is: princomp(). :-)


-- 
Bjørn-Helge Mevik

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

***
This email and any attachments are confidential. Any use...{{dropped:8}}

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


[R] Personal invitation from srinivasa raghavan

2009-02-16 Thread srinivasa raghavan
Hi,

On 2/2/2009 3:10:07 AM, you were invited to join srinivasa 
raghavan's UNYK address book so he/she would always have access to your contact 
info and you to his/hers.

To accept his/her request, Click here.
http://www.unyk.com/ml/65/5/?i=5288fc6dadfb4bfba314862684138e45


UNYK is a smart and simple way to manage your contacts so you never 
lose anyone’s contact information again.

No more worrying about your contacts' info. From now on, let them 
do it for you. By changing their information in UNYK.com, you address book will 
be automatically updated. By changing your information in UNYK.com, their 
address book will be automatically updated.

It’s so simple and it’s free... Already 10 million users.



Click here if you no longer wish to receive invitations 
from srinivasa raghavan to try UNYK!

http://www.unyk.com/ml/245/74/unsubscribe.asp?mid=9E93A2A8817985A2email=r%2Dhelp%40r%2Dproject%2Eorgremove=2s=12048525
Click here if you no longer wish to receive invitations 
to try UNYK!

http://www.unyk.com/ml/65/6/unsubscribe.asp?i=5288fc6dadfb4bfba314862684138e45



UNYK, the first smart address book that updates itself!


[[alternative HTML version deleted]]

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


Re: [R] PCA functions

2009-02-16 Thread andrew
sqrt(svd(x)$d) maybe 2 more operations than princomp(covmat=x), but it
is hardly a chore.

On Feb 16, 9:15 pm, Mark Difford mark_diff...@yahoo.co.uk wrote:
 Hi Glen, Andrew,

  The PCA is just a singular value decomposition on a sample covariance/...

 I believe that Bjørn-Helge Mevik's point was that __if you read the
 documentation__ you will see the argument covmat to princomp(). This,
 really, is much more straightforward and practical than Andrew's suggestion.

 Regards, Mark.



 andrew-246 wrote:

  The PCA is just a singular value decomposition on a sample covariance/
  correlation matrix.  Do a search for ?svd and get the eigenvalues and
  vectors from that function.

  On Feb 14, 10:30 am, glenn g1enn.robe...@btinternet.com wrote:
  Hi All, would appreciate an answer on this if you have a moment;

  Is there a function (before I try and write it !) that allows the input
  of a
  covariance or correlation matrix to calculate PCA, rather than the actual
  data as in princomp()

  Regards

  Glenn

          [[alternative HTML version deleted]]

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

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

 --
 View this message in 
 context:http://www.nabble.com/PCA-functions-tp22006964p22034611.html
 Sent from the R help mailing list archive at Nabble.com.

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

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


Re: [R] PCA functions

2009-02-16 Thread Gavin Simpson
On Mon, 2009-02-16 at 10:45 +, S Ellison wrote:
 princomp uses the raw data and calculates the correlation or
 covariance matrix on the way to the PC's, so that doesn't use a
 correlation matrix itself. You do, however, get the choice.

That *isn't* what princomp() does. If you supply a valid covariance
matrix via argument 'covmat', princomp() uses that instead of
calculating one from the input data.

That is what ?princomp says it does, as does the R source, the true
reference.

G

 
 However, PC's are the eigenvectors of the correlation (or covariance)
 matrix, so in principle calling eigen() on either would be sufficient
 for the PC's. The signs may differ, though, as they are arbitrary;
 compare prcomp(USArrests)$rotation with eigen(cov(USArrests)).
 
 S
 
 
 
 
  Bjørn-Helge Mevik b.h.me...@usit.uio.no 16/02/2009 09:05 
 glenn g1enn.robe...@btinternet.com writes:
 
  Is there a function (before I try and write it !) that allows the input of a
  covariance or correlation matrix to calculate PCA, rather than the actual
  data as in princomp()
 
 Yes, there is: princomp(). :-)
 
 
-- 
%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%
 Dr. Gavin Simpson [t] +44 (0)20 7679 0522
 ECRC, UCL Geography,  [f] +44 (0)20 7679 0565
 Pearson Building, [e] gavin.simpsonATNOSPAMucl.ac.uk
 Gower Street, London  [w] http://www.ucl.ac.uk/~ucfagls/
 UK. WC1E 6BT. [w] http://www.freshwaters.org.uk
%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%



signature.asc
Description: This is a digitally signed message part
__
R-help@r-project.org mailing list
https://stat.ethz.ch/mailman/listinfo/r-help
PLEASE do read the posting guide http://www.R-project.org/posting-guide.html
and provide commented, minimal, self-contained, reproducible code.


Re: [R] How to create sequence of constant time interval

2009-02-16 Thread Gabor Grothendieck
Try this (and see R News 4/1 for more).

 library(chron)
 tt - times(0:47/48)
 tt
 [1] 00:00:00 00:30:00 01:00:00 01:30:00 02:00:00 02:30:00 03:00:00
03:30:00 04:00:00 04:30:00 05:00:00 05:30:00 06:00:00 06:30:00
07:00:00 07:30:00
[17] 08:00:00 08:30:00 09:00:00 09:30:00 10:00:00 10:30:00 11:00:00
11:30:00 12:00:00 12:30:00 13:00:00 13:30:00 14:00:00 14:30:00
15:00:00 15:30:00
[33] 16:00:00 16:30:00 17:00:00 17:30:00 18:00:00 18:30:00 19:00:00
19:30:00 20:00:00 20:30:00 21:00:00 21:30:00 22:00:00 22:30:00
23:00:00 23:30:00

 chron(rep(1/1/09, length = length(tt)), tt)
 [1] (01/01/09 00:00:00) (01/01/09 00:30:00) (01/01/09 01:00:00)
(01/01/09 01:30:00) (01/01/09 02:00:00) (01/01/09 02:30:00) (01/01/09
03:00:00)
 [8] (01/01/09 03:30:00) (01/01/09 04:00:00) (01/01/09 04:30:00)
(01/01/09 05:00:00) (01/01/09 05:30:00) (01/01/09 06:00:00) (01/01/09
06:30:00)
[15] (01/01/09 07:00:00) (01/01/09 07:30:00) (01/01/09 08:00:00)
(01/01/09 08:30:00) (01/01/09 09:00:00) (01/01/09 09:30:00) (01/01/09
10:00:00)
[22] (01/01/09 10:30:00) (01/01/09 11:00:00) (01/01/09 11:30:00)
(01/01/09 12:00:00) (01/01/09 12:30:00) (01/01/09 13:00:00) (01/01/09
13:30:00)
[29] (01/01/09 14:00:00) (01/01/09 14:30:00) (01/01/09 15:00:00)
(01/01/09 15:30:00) (01/01/09 16:00:00) (01/01/09 16:30:00) (01/01/09
17:00:00)
[36] (01/01/09 17:30:00) (01/01/09 18:00:00) (01/01/09 18:30:00)
(01/01/09 19:00:00) (01/01/09 19:30:00) (01/01/09 20:00:00) (01/01/09
20:30:00)
[43] (01/01/09 21:00:00) (01/01/09 21:30:00) (01/01/09 22:00:00)
(01/01/09 22:30:00) (01/01/09 23:00:00) (01/01/09 23:30:00)


On Mon, Feb 16, 2009 at 5:00 AM, Suresh_FSFM suresh.ghals...@gmail.com wrote:

 Dear R-Experts,

 seek your help.

 There are two parts I want to deal with.
 1)
 I want to create a time interval of say, 30 minutes starting from 00:00:00
 hrs
 Thus at the end, I want to create sequence:
 00:00:00
 00:30:00
 01:00:00
 01:30:00
 ..
 ..
 How to do so ?
 Later, I want to change the time-increment value in a variable and changing
 the value of this variable, I would like to create new sequence with that
 time increment. How to use seq() correctly?

 2)
 I have a date stored in one variable. Say 2009-01-01
 How can I combine this date with each time interval in the first part? Will
 concatenate work?
 so at the end, I would like to have:

 2009-01-01 00:00:00
 2009-01-01 00:30:00
 2009-01-01 01:00:00
 2009-01-01 01:30:00
 ...
 ...

 Thank you in advance.






 --
 View this message in context: 
 http://www.nabble.com/How-to-create-sequence-of-constant-time-interval-tp22034441p22034441.html
 Sent from the R help mailing list archive at Nabble.com.

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


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


Re: [R] How to create sequence of constant time interval

2009-02-16 Thread Suresh_FSFM

Thank you very much for the precise response.


Regards,
Suresh


Suresh_FSFM wrote:
 
 Dear R-Experts, 
 
 seek your help.
 
 There are two parts I want to deal with.
 1) 
 I want to create a time interval of say, 30 minutes starting from
 00:00:00 hrs
 Thus at the end, I want to create sequence:
 00:00:00
 00:30:00
 01:00:00 
 01:30:00
 ..
 ..
 How to do so ?
 Later, I want to change the time-increment value in a variable and
 changing the value of this variable, I would like to create new sequence
 with that time increment. How to use seq() correctly?
 
 2)
 I have a date stored in one variable. Say 2009-01-01
 How can I combine this date with each time interval in the first part?
 Will concatenate work?
 so at the end, I would like to have:
 
 2009-01-01 00:00:00
 2009-01-01 00:30:00
 2009-01-01 01:00:00
 2009-01-01 01:30:00
 ...
 ...
 
 Thank you in advance.
 
 
 
 
 
 
 

-- 
View this message in context: 
http://www.nabble.com/How-to-create-sequence-of-constant-time-interval-tp22034441p22035427.html
Sent from the R help mailing list archive at Nabble.com.

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


[R] Don't find a package !

2009-02-16 Thread nabler

Hi,

Please could somebody has any information about the following package:
IlluminaGUI, published here:

http://bioinformatics.oxfordjournals.org/cgi/content/abstract/btm101v1

The link given in the article is dead and authors doesn't reply ! 

Is there someone who uses it ?

Thank you very much for help
-- 
View this message in context: 
http://www.nabble.com/Don%27t-find-a-package-%21-tp22034934p22034934.html
Sent from the R help mailing list archive at Nabble.com.

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


[R] Dynamic Panel Analysis in R

2009-02-16 Thread Millo Giovanni
Dear Tanveer and Johannes,

it *is* indeed possible to estimate dynamic panels by GMM with plm. As
Johannes observes, ?pgmm is a good start. Please see also the package
vignette or its close cousin, this paper on JSS
http://www.jstatsoft.org/v27/i02, section 5.4.

Johannes, if you had problems (assuming it was the software's fault, of
course) it would be nice to get a bug report, possibly with a
reproducible example, so we can try and sort them out.

Best,
Giovanni

### Original message: ###
Message: 1
Date: Sat, 14 Feb 2009 03:41:34 -0800 (PST)
From: Johannes Habel johannes.ha...@gmx.de
Subject: Re: [R] Dynamic Panel Analysis in R
To: r-help@r-project.org
Message-ID: 22011830.p...@talk.nabble.com
Content-Type: text/plain; charset=us-ascii


Hi Tanveer,

the PLM package includes the possibility to estimate instrumental
variable models. It also includes a function PGMM to estimate GMM
models. Try ?pgmm... By the way, if you manage to make this function
work, I'd be glad for a quick note. I've been ecountering massive
problems with this function...

Best,
Johannes


C.T.Shehzad wrote:
 
 Hi!
 
 I am quite a new user of R. I wanted to ask if there was some package
 for dynamic panel analysis (with Arneallo-Bond Method) like stata. PLM

 is for panel analysis but not for dynamic.
 
 Best regards,
 
 Tanveer
 
 __
 R-help@r-project.org mailing list 
 https://stat.ethz.ch/mailman/listinfo/r-help
 PLEASE do read the posting guide 
 http://www.R-project.org/posting-guide.html
 and provide commented, minimal, self-contained, reproducible code.
 
 


Giovanni Millo
Research Dept.,
Assicurazioni Generali SpA
Via Machiavelli 4, 
34132 Trieste (Italy)
tel. +39 040 671184 
fax  +39 040 671160
 
Ai sensi del D.Lgs. 196/2003 si precisa che le informazi...{{dropped:13}}

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


Re: [R] Don't find a package !

2009-02-16 Thread Wolfgang Raffelsberger

You're looking in the wrong repository !
It's on www.bioconductor.org

Wolfgang

nabler a écrit :

Hi,

Please could somebody has any information about the following package:
IlluminaGUI, published here:

http://bioinformatics.oxfordjournals.org/cgi/content/abstract/btm101v1

The link given in the article is dead and authors doesn't reply ! 


Is there someone who uses it ?

Thank you very much for help
  


. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
Wolfgang Raffelsberger, PhD
Laboratoire de BioInformatique et Génomique Intégratives
CNRS UMR7104, IGBMC 
1 rue Laurent Fries,  67404 Illkirch  Strasbourg,  France

Tel (+33) 388 65 3300 Fax (+33) 388 65 3276
wolfgang.raffelsberger (at) igbmc.fr

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


[R] Alternate to for-loop

2009-02-16 Thread megh

Hi, I am trying to create a vector of length 10 (say), wherein each element
will be average of random sample of size 100, from a distribution, say
Normal. Can anyone please tell me without creating a for loop, how I can
do that?

Regards,


-- 
View this message in context: 
http://www.nabble.com/Alternate-to-for-loop-tp22035954p22035954.html
Sent from the R help mailing list archive at Nabble.com.

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


Re: [R] Alternate to for-loop

2009-02-16 Thread Henrique Dallazuanna
Try this:

replicate(10, mean(rnorm(100)))

On Mon, Feb 16, 2009 at 8:59 AM, megh megh700...@yahoo.com wrote:


 Hi, I am trying to create a vector of length 10 (say), wherein each element
 will be average of random sample of size 100, from a distribution, say
 Normal. Can anyone please tell me without creating a for loop, how I can
 do that?

 Regards,


 --
 View this message in context:
 http://www.nabble.com/Alternate-to-for-loop-tp22035954p22035954.html
 Sent from the R help mailing list archive at Nabble.com.

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




-- 
Henrique Dallazuanna
Curitiba-Paraná-Brasil
25° 25' 40 S 49° 16' 22 O

[[alternative HTML version deleted]]

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


Re: [R] (no subject)

2009-02-16 Thread Vincze Orsolya
There are three columns, I was just careless.
I succeed to merge the two tables. But:
1) in the first table there were rows, which were not present in the second
table, these rows were deleted from the merged table too, but I need them.
2) If i want to import from the second table just a certain column, not all
that is missing from the first, how can i do that?
3) How can I save the generated table?

Sorry about the banal questions I'm beginner.
And thanks for the help...
Have a nice day


2009/2/15 Peter Dalgaard p.dalga...@biostat.ku.dk

 Vincze Orsolya wrote:

 Dear all,I had just started to learn R. So my question may sound a bit
 stupid for you.
 Is that possible to match and merge two tables in R? I mean I have two
 tables, in the first I have two columns: RING NUMBER,  WEIGHT and CAPTURE


 Err, ... for large values of two? Or is one of the three a rowname?

  DATE, in the second RING NUMBER, SEX  and CAPTURE DATE.
 1) First I want to see, if to the ring numbers are the same, the capture
 dates are too?
 2) And second if ring numbers are the same, to import the sex from the
 second table in the first.

 Is that possible?


 Yes. It's a job for merge()

 --
   O__   Peter Dalgaard Øster Farimagsgade 5, Entr.B
  c/ /'_ --- Dept. of Biostatistics PO Box 2099, 1014 Cph. K
  (*) \(*) -- University of Copenhagen   Denmark  Ph:  (+45) 35327918
 ~~ - (p.dalga...@biostat.ku.dk)  FAX: (+45) 35327907


[[alternative HTML version deleted]]

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


[R] Ideal (possible) configuration for an exalted R system

2009-02-16 Thread Harsh
Hi All,
I am trying to assemble a system that will allow me to work with large
datasets (45-50 million rows, 300-400 columns) possibly amounting to
10GB + in size.

I am aware that R 64 bit implementations on Linux boxes are suitable
for such an exercise but I am looking for configurations that R users
out there may have used in creating a high-end R system.
Due to a lot of apprehensions that SAS users have about R's data
limitations, I want to demonstrate R's usability even with very large
datasets as mentioned above.
I would be glad to hear from users(share configurations and system
specific information) who have desktops/servers on which they use R to
crunch massive datasets.


Any suggestions in expanding R's functionality in the face of gigabyte
class datasets would be appreciated.

Thanks
Harsh Singhal
Decision Systems,
Mu Sigma Inc.
Chicago, IL

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


Re: [R] Alternate to for-loop

2009-02-16 Thread Uwe Ligges



megh wrote:

Hi, I am trying to create a vector of length 10 (say), wherein each element
will be average of random sample of size 100, from a distribution, say
Normal. Can anyone please tell me without creating a for loop, how I can
do that?



Homework? Then please ask you course material or teacher.

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

Uwe Ligges


Regards,




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


Re: [R] (no subject)

2009-02-16 Thread Uwe Ligges



Vincze Orsolya wrote:

There are three columns, I was just careless.
I succeed to merge the two tables. But:
1) in the first table there were rows, which were not present in the second
table, these rows were deleted from the merged table too, but I need them.
2) If i want to import from the second table just a certain column, not all
that is missing from the first, how can i do that?
3) How can I save the generated table?

Sorry about the banal questions I'm beginner.
And thanks for the help...
Have a nice day



Homework? Then please ask you course material or teacher.

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

Best wishes,
Uwe Ligges



2009/2/15 Peter Dalgaard p.dalga...@biostat.ku.dk


Vincze Orsolya wrote:


Dear all,I had just started to learn R. So my question may sound a bit
stupid for you.
Is that possible to match and merge two tables in R? I mean I have two
tables, in the first I have two columns: RING NUMBER,  WEIGHT and CAPTURE


Err, ... for large values of two? Or is one of the three a rowname?

 DATE, in the second RING NUMBER, SEX  and CAPTURE DATE.

1) First I want to see, if to the ring numbers are the same, the capture
dates are too?
2) And second if ring numbers are the same, to import the sex from the
second table in the first.

Is that possible?


Yes. It's a job for merge()

--
  O__   Peter Dalgaard Øster Farimagsgade 5, Entr.B
 c/ /'_ --- Dept. of Biostatistics PO Box 2099, 1014 Cph. K
 (*) \(*) -- University of Copenhagen   Denmark  Ph:  (+45) 35327918
~~ - (p.dalga...@biostat.ku.dk)  FAX: (+45) 35327907



[[alternative HTML version deleted]]





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


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


Re: [R] PCA functions

2009-02-16 Thread S Ellison
Many apologies for the poor steer; you are quite right. 

'fraid I hit 'send' before double-checking the help page myself. Next time...

S

 Gavin Simpson gavin.simp...@ucl.ac.uk 16/02/2009 10:59 
On Mon, 2009-02-16 at 10:45 +, S Ellison wrote:
 princomp uses the raw data and calculates the correlation or
 covariance matrix on the way to the PC's, so that doesn't use a
 correlation matrix itself. You do, however, get the choice.

That *isn't* what princomp() does. If you supply a valid covariance
matrix via argument 'covmat', princomp() uses that instead of
calculating one from the input data.

That is what ?princomp says it does, as does the R source, the true
reference.

G

 
 However, PC's are the eigenvectors of the correlation (or covariance)
 matrix, so in principle calling eigen() on either would be sufficient
 for the PC's. The signs may differ, though, as they are arbitrary;
 compare prcomp(USArrests)$rotation with eigen(cov(USArrests)).
 
 S
 
 
 
 
  Bjørn-Helge Mevik b.h.me...@usit.uio.no 16/02/2009 09:05 
 glenn g1enn.robe...@btinternet.com writes:
 
  Is there a function (before I try and write it !) that allows the input of a
  covariance or correlation matrix to calculate PCA, rather than the actual
  data as in princomp()
 
 Yes, there is: princomp(). :-)
 
 
-- 
%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%
Dr. Gavin Simpson [t] +44 (0)20 7679 0522
ECRC, UCL Geography,  [f] +44 (0)20 7679 0565
Pearson Building, [e] gavin.simpsonATNOSPAMucl.ac.uk
Gower Street, London  [w] http://www.ucl.ac.uk/~ucfagls/ 
UK. WC1E 6BT. [w] http://www.freshwaters.org.uk 
%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%



***
This email and any attachments are confidential. Any use...{{dropped:8}}

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


Re: [R] Transformation of Variables

2009-02-16 Thread David Winsemius
There are a series of coercion functions, all beginning with as.  
which are designed to return (when possible) objects of specified  
types. Since you offer three examples, only one of which I recognize  
as a valid R type, I am wondering what R text you have been using?


--
David Winsemius


On Feb 16, 2009, at 2:00 AM, Arup wrote:



I have a data frame in R  where all the variables are character in  
nature.

kindly let know how I can transform these character variable into say
numeric,Categorical,continuous etc.Please provide me with the  
proper

syntax. Thank you in advance.
--
View this message in context: 
http://www.nabble.com/Transformation-of-Variables-tp22032424p22032424.html
Sent from the R help mailing list archive at Nabble.com.

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


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


Re: [R] Transformation of Variables

2009-02-16 Thread jim holtman
It would be useful to have some sample input data and then what you
expect as output.  You can always convert the characters to factors
and then use the integer values assigned.

On Mon, Feb 16, 2009 at 2:00 AM, Arup arup.pramani...@gmail.com wrote:

 I have a data frame in R  where all the variables are character in nature.
 kindly let know how I can transform these character variable into say
 numeric,Categorical,continuous etc.Please provide me with the proper
 syntax. Thank you in advance.
 --
 View this message in context: 
 http://www.nabble.com/Transformation-of-Variables-tp22032424p22032424.html
 Sent from the R help mailing list archive at Nabble.com.

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




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

What is the problem that you are trying to solve?

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


Re: [R] Time series

2009-02-16 Thread stephen sefick
?zoo

On Mon, Feb 16, 2009 at 1:16 AM, miya ontiveros_pal...@yahoo.com wrote:

 Hello everyone.
 I am trying to plot data from a time series in R and have run across some
 problems. I was wondering if someone could help.
 I have data taken every 15 minutes of a list of rankings of 25 titles. I
 want to plot one of the article's titles's ranks as a time series.
 I've been trying if statements with no success and am pretty new to R. Can
 anyone help?

 Thank you.
 --
 View this message in context: 
 http://www.nabble.com/Time-series-tp22032122p22032122.html
 Sent from the R help mailing list archive at Nabble.com.

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




-- 
Stephen Sefick

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

-K. Mullis

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


Re: [R] Alternate to for-loop

2009-02-16 Thread megh

No, it is not homework. I obviously could do that using a for-loop, and that
I already did. However I thought whether there could be a better approach as
it was looking very messy and unprofessional.



Uwe Ligges-3 wrote:
 
 
 
 megh wrote:
 Hi, I am trying to create a vector of length 10 (say), wherein each
 element
 will be average of random sample of size 100, from a distribution, say
 Normal. Can anyone please tell me without creating a for loop, how I
 can
 do that?
 
 
 Homework? Then please ask you course material or teacher.
 
 PLEASE do read the posting guide
 http://www.R-project.org/posting-guide.html
 and provide commented, minimal, self-contained, reproducible code.
 
 Uwe Ligges
 
 Regards,
 

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

-- 
View this message in context: 
http://www.nabble.com/Alternate-to-for-loop-tp22035954p22037011.html
Sent from the R help mailing list archive at Nabble.com.

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


Re: [R] I want axes that cross

2009-02-16 Thread Marc Schwartz
I would also add:

1. Chapter 12 in An Introduction to R

2. Chapter 3 in Paul's R Graphics book:

  http://www.stat.auckland.ac.nz/~paul/RGraphics/rgraphics.html

Note that the figures and code used for the graphics in the above
chapter are available here:

http://www.stat.auckland.ac.nz/~paul/RGraphics/chapter3.html

HTH,

Marc


on 02/16/2009 03:14 AM Mark Difford wrote:
 Hi Paul,
 
 Have you ever seen a drawing of the regions of an R plot with the
 terminology that is used for parts?
 
From what I can remember, several documents on CRAN cover this. The one that
 springs to mind is Alzola  Harrell's An Introduction to S and the Hmisc
 and Design Libraries,” which you can download from the Contributed
 Documentation link on CRAN.
 
 Chap. 4 of MASS by Venables  Ripley (4th ed.) will also give you what you
 want.
 
 Regards, Mark.
 
 
 Paul Johnson-11 wrote:
 On Fri, Feb 13, 2009 at 3:14 PM, Marc Schwartz
 marc_schwa...@comcast.net wrote:
 on 02/13/2009 02:19 PM Paul Johnson wrote:
 On Fri, Feb 13, 2009 at 1:51 PM, Marc Schwartz
 OK, so given all of the above, something like the following should work:

 set.seed(1233240)
 x - rnorm(100)
 z - gl(2,50)
 y - rnorm(100, mean = 1.8 * as.numeric(z))

 # Calculate a new range, subtracting a definable value
 # from the min of each vector for the new minimum
 # Adust the 0.25 as may be needed
 X - c(min(x) - 0.25, max(x))
 Y - c(min(y) - 0.25, max(y))

 # Use 'X' and Y' here, not 'x' and 'y'
 # So that the plot region is extended appropriately
 plot(X, Y, type = n, axes = F, xlab = x, ylab = y)

 points(x, y, pch = $, cex = 0.7, col = z)

 # DO use 'pos'...
 axis(1, pos = Y[1], col = green, col.axis = green)
 axis(2, pos = X[1], col = red, col.axis = red)

 # get the plot region boundaries
 usr - par(usr)

 segments(X[1], usr[3], X[1], usr[4], col = red)
 segments(usr[1], Y[1], usr[2], Y[1], col = green)


 HTH,

 Marc


 Thanks, Marc and everybody.

 This last suggestion produces the graph I was trying for.

 The other approaches that people suggest, using pos or xaxp, produce
 other undesired changes in the tick marks or the position of the axes
 relative to the data. xaxp offers the promise of a more intuitive
 solution, except that, when using it, the tick marks are pushed off in
 a bad way.  Your use of segments to draw the extensions of the axes
 was the first intuition I had, but I did not know about the trick you
 used to retrieve the size of the usr box.

 More secrets of par, revealed.

 Have you ever seen a drawing of the regions of an R plot with the
 terminology that is used for parts?  Until I saw your example code, I
 had not understood that the plot axes are placed at the absolute edge
 of the user plotting region, for example.

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


[R] How do i compute predicted failure time from a cox model?

2009-02-16 Thread Eleni Rapsomaniki
 

Given a cox model:

 

library(Hmisc); library(survival); (library(Design); 

cox.model=cph(Surv(futime,  fustat) ~ age, data=ovarian, surv=T)

str(cox.model)

 

What I need is the total estimated time until failure (death), not the
probability of failing at a given time (survival probability), or hazard
etc, which is what I get from survest and predict for example.

 

I suspect the answer is embarrassing simple...

 

Eleni Rapsomaniki

 

Research Associate

Strangeways Research Laboratory

Department of Public Health and Primary Care

 

 

 


[[alternative HTML version deleted]]

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


[R] Odp: several ifelse problems...

2009-02-16 Thread Petr PIKAL
Hi

 x - seq(0,1,.01) 
 y - ifelse(abs(x-.5)=0.3,0,
+ ifelse(abs(w-.5)=0.4,-1, 
+ifelse((0.1w  w0.2),10*x-2,-10*x+8)))
Error in storage.mode(test) - logical : object w not found

what is w?

Why did you use ?

 and  indicate logical AND and | and || indicate logical OR. The 
shorter form performs elementwise comparisons in much the same way as 
arithmetic operators. The longer form evaluates left to right examining 
only the first element of each vector. Evaluation proceeds only until the 
result is determined. The longer form is appropriate for programming 
control-flow and typically preferred in if clauses. 

If I changed w to x and  to  I got

 y - ifelse(abs(x-.5)=0.3,0,
+ ifelse(abs(x-.5)=0.4,-1,
+ifelse((0.1x  x0.2),10*x-2,-10*x+8)))
 
 y
  [1] -1.0 -1.0 -1.0 -1.0 -1.0 -1.0 -1.0 -1.0 -1.0 -1.0 -1.0 -0.9 -0.8 
-0.7 -0.6 -0.5 -0.4 -0.3 -0.2 -0.1  0.0  0.0  0.0  0.0  0.0  0.0  0.0  0.0 
 0.0  0.0
 [31]  0.0  0.0  0.0  0.0  0.0  0.0  0.0  0.0  0.0  0.0  0.0  0.0  0.0 0.0 
 0.0  0.0  0.0  0.0  0.0  0.0  0.0  0.0  0.0  0.0  0.0  0.0  0.0  0.0  0.0 
 0.0
 
Is this what you wanted?

Regards
Petr

r-help-boun...@r-project.org napsal dne 14.02.2009 06:08:25:

 
 Dear R users,
 
 From the code below, I try to compute y value. (In fact, y looks like 
a
 trapezoid)
 
 --
 
 x - seq(0,1,.01) 
 y - ifelse(abs(x-.5)=0.3,0,
 ifelse(abs(w-.5)=0.4,-1, 
ifelse((0.1w  w0.2),10*x-2,-10*x+8)))
 
 --
 
 So, results are...
 
 --
  x
   [1] 0.00 0.01 0.02 0.03 0.04 0.05 0.06 0.07 0.08 0.09 0.10 0.11 0.12 
0.13
 0.14
  [16] 0.15 0.16 0.17 0.18 0.19 0.20 0.21 0.22 0.23 0.24 0.25 0.26 0.27 
0.28
 0.29
  [31] 0.30 0.31 0.32 0.33 0.34 0.35 0.36 0.37 0.38 0.39 0.40 0.41 0.42 
0.43
 0.44
  [46] 0.45 0.46 0.47 0.48 0.49 0.50 0.51 0.52 0.53 0.54 0.55 0.56 0.57 
0.58
 0.59
  [61] 0.60 0.61 0.62 0.63 0.64 0.65 0.66 0.67 0.68 0.69 0.70 0.71 0.72 
0.73
 0.74
  [76] 0.75 0.76 0.77 0.78 0.79 0.80 0.81 0.82 0.83 0.84 0.85 0.86 0.87 
0.88
 0.89
  [91] 0.90 0.91 0.92 0.93 0.94 0.95 0.96 0.97 0.98 0.99 1.00
 
  y
   [1] -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1  8  8  8  8  8  8  8  8  8  0  0 
0 
 0  0
  [26]  0  0  0  0  0  0  0  0  0  0  0  0  0  0  0  0  0  0  0  0  0  0 
0 
 0  0
  [51]  0  0  0  0  0  0  0  0  0  0  0  0  0  0  0  0  0  0  0  0  0  0 
0 
 0  0
  [76]  0  0  0  0  0  8  8  8  8  8  8  8  8  8  8 -1 -1 -1 -1 -1 -1 -1 
-1
 -1 -1
 [101] -1
  
 
 --
 
 However, even though the results show that y=8 for x=0.11, when x=0.11,
 actual y value is -0.9.  And, y=-0.8 for x=0.88.  I cannot understand 
the
 above results.
 
 Any comments will be greatly appreciated.
 
 Kathryn Lord
 -- 
 View this message in context: 
http://www.nabble.com/several-%22ifelse%22-
 problems...-tp22009321p22009321.html
 Sent from the R help mailing list archive at Nabble.com.
 
 __
 R-help@r-project.org mailing list
 https://stat.ethz.ch/mailman/listinfo/r-help
 PLEASE do read the posting guide 
http://www.R-project.org/posting-guide.html
 and provide commented, minimal, self-contained, reproducible code.

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


Re: [R] loading mgcv package

2009-02-16 Thread Simon Wood
What happens if you type

runif(1)

before loading `mgcv'?

best,
Simon

On Sunday 15 February 2009 17:06, Veerappa Chetty wrote:
 Hi ,When I try to load the 'mgcv package, often, but not always, get this
 error message. What am I doing wrong? I even tried reinstalling a few
 times. __
 This is mgcv 1.4-1.1
 Error in runif(1) :
   .Random.seed is not an integer vector but of type 'list'
 Error : .onAttach failed in 'attachNamespace'
 Error: package/namespace load failed for 'mgcv'
 -
 Thanks.
 Chetty

-- 
 Simon Wood, Mathematical Sciences, University of Bath, Bath, BA2 7AY UK
 +44 1225 386603  www.maths.bath.ac.uk/~sw283

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


[R] is there any way to find match with tolerance

2009-02-16 Thread Suresh_FSFM

Hello all,

suppose I have a time-stamp: 16-02-2009 00:20:00
and other array that stores lot of time values.

My tolerance limit = +5 minutes
I would like to find values from this array matching with the value:
16-02-2009 00:20:00 + tolerance
Before I write some function, I would like to know: whether any readymade
function is available?
I checked compare() or which() . but not exactly what I would like to have.

Any suggestion is appreciated.

Thank you.

Best Regards,
Suresh


-- 
View this message in context: 
http://www.nabble.com/is-there-any-way-to-find-match-with-tolerance-tp22037475p22037475.html
Sent from the R help mailing list archive at Nabble.com.

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


[R] How do i compute predicted failure time from a cox model?

2009-02-16 Thread Eleni Rapsomaniki

Given a cox model:
 
library(Hmisc); library(survival); (library(Design); 
cox.model=cph(Surv(futime,  fustat) ~ age, data=ovarian, surv=T)
str(cox.model)
 
What I need is the total estimated time until failure (death), not the 
probability of failing at a given time (survival probability), or hazard etc, 
which is what I get from survest and predict for example.
 
I suspect the answer is embarrassing simple...

(BTW sorry for the duplicate email, the earlier HTML version of my message 
could not be viewed)
Eleni Rapsomaniki
 
Research Associate
Strangeways Research Laboratory
Department of Public Health and Primary Care
 
 
 

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


Re: [R] How do i compute predicted failure time from a cox model?

2009-02-16 Thread Frank E Harrell Jr

Eleni Rapsomaniki wrote:

Given a cox model:
 
library(Hmisc); library(survival); (library(Design); 
cox.model=cph(Surv(futime,  fustat) ~ age, data=ovarian, surv=T)

str(cox.model)
 
What I need is the total estimated time until failure (death), not the probability of failing at a given time (survival probability), or hazard etc, which is what I get from survest and predict for example.
 
I suspect the answer is embarrassing simple...


(BTW sorry for the duplicate email, the earlier HTML version of my message 
could not be viewed)
Eleni Rapsomaniki
 
Research Associate

Strangeways Research Laboratory
Department of Public Health and Primary Care



Eleni,

You can't get the predicted mean from a Cox model unless the longest 
followed subject died.  You can get the mean restricted life:


library(Design)   # implies Hmisc and survival
f - cph(..., surv=TRUE)
M - Mean(f, tmax=3)  # area under S(t) from 0 to 3 time units
M( ) # evaluate the mean at a vector of linear predictor values
M(predict(f, data.frame( ))) # evaluate at user-chosen predictor values

The mean restricted life is the life expectency given failure before 
time tmax.  You have to use a parametric model to get the unrestricted 
mean lifetime estimate.


Also see the Quantile function in Design to derive a function to 
estimate various quantiles of survival time.  In Design, functions 
beginning with an upper case letter (like Mean, Quantile, Function, 
Hazard) are function generators.


Frank

 
 


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

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


Re: [R] Alternate to for-loop

2009-02-16 Thread Uwe Ligges



megh wrote:

No, it is not homework. I obviously



For some value of obvious as you has not given a single line of code 
as the posting guide suggests.


You probably want:

replicate(10, mean(rnorm(100)))

Uwe Ligges



could do that using a for-loop, and that
I already did. However I thought whether there could be a better approach as
it was looking very messy and unprofessional.



Uwe Ligges-3 wrote:



megh wrote:

Hi, I am trying to create a vector of length 10 (say), wherein each
element
will be average of random sample of size 100, from a distribution, say
Normal. Can anyone please tell me without creating a for loop, how I
can
do that?


Homework? Then please ask you course material or teacher.

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

Uwe Ligges


Regards,



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






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


Re: [R] How to create sequence of constant time interval

2009-02-16 Thread Tony Breyal
ahh, didn't see Gabor's solution, that works much better :-)

On 16 Feb, 10:00, Suresh_FSFM suresh.ghals...@gmail.com wrote:
 Dear R-Experts,

 seek your help.

 There are two parts I want to deal with.
 1)
 I want to create a time interval of say, 30 minutes starting from 00:00:00
 hrs
 Thus at the end, I want to create sequence:
 00:00:00
 00:30:00
 01:00:00
 01:30:00
 ..
 ..
 How to do so ?
 Later, I want to change the time-increment value in a variable and changing
 the value of this variable, I would like to create new sequence with that
 time increment. How to use seq() correctly?

 2)
 I have a date stored in one variable. Say 2009-01-01
 How can I combine this date with each time interval in the first part? Will
 concatenate work?
 so at the end, I would like to have:

 2009-01-01 00:00:00
 2009-01-01 00:30:00
 2009-01-01 01:00:00
 2009-01-01 01:30:00
 ...
 ...

 Thank you in advance.

 --
 View this message in 
 context:http://www.nabble.com/How-to-create-sequence-of-constant-time-interva...
 Sent from the R help mailing list archive at Nabble.com.

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

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


Re: [R] solve.QP with box and equality constraints

2009-02-16 Thread Berwin A Turlach
G'day Selwyn,

On Mon, 16 Feb 2009 10:11:20 +
Selwyn McCracken selwyn.mccrac...@gmail.com wrote:

 I am trying to follow an example that estimates a 2x2 markov
 transition matrix across several periods from aggregate data using
 restricted least squares.
 
 I seem to be making headway using solve.QP(quadprog) as the
 unrestricted solution matches the example I am following, and I can
 specify simple equality and inequality constraints. However, I cannot
 correctly specify a constraint matrix (Amat) with box constraints per
 cell and equality constraints that span multiple cells. Namely the
 solution matrix I am aiming for needs to respect the following
 conditions:
   - each row must sum to 1
   - each cell must = 0
   - each cell must = 1

Note that this set of constraints contains some redundancy.  If each
row has to sum to one and the summands are all negative then,
necessarily, each summand is at most one.  So the last set of
constraints is not necessary.

[...]
 (b2 = c(1,1,rep(0:1,times=4)))

This should be 
   (b2 - c(1,1, rep(0:(-1), times=4)))

Since x = 1 iff -x = -1

 solve.QP(Dmat = XX,dvec=Xy,Amat = a2,bvec=b2,meq=2) #complains that
 Amat and dvec are incompatible

The constraints of the QP are A^T b = b0 and b0 is passed to b2 while
A is passed to Amat.  Your matrix a2 contains A^T, so you have to pass
t(a2) to solve.QP:

R solve.QP(Dmat = XX,dvec=Xy,Amat = t(a2),bvec=b2,meq=2)
Error in solve.QP(Dmat = XX, dvec = Xy, Amat = t(a2), bvec = b2, meq = 2) : 
  constraints are inconsistent, no solution!

While this might not be very helpful, the problem now is that the
entries in your matrix XX (and Xy) are quite large and this can lead to
numerical problems in the FORTRAN code that quadprog relies on.  But
this is easily fixed.

R XX - XX*1e-9
R Xy - Xy*1e-9
R solve.QP(Dmat = XX,dvec=Xy,Amat = t(a2),bvec=b2,meq=2)
$solution
[1] 0.9367934 0.000 0.0632066 1.000

$value
[1] -63.38694

$unconstrainted.solution
[1] 1.004181694 0.002401266 0.012673485 1.012848987

$iterations
[1] 4 0

$iact
[1] 10  1  2

But, as pointed out earlier, your constraints contain some 
redundancies, so it would be shorter to code them as:

R a2 = rbind(
   c(1,0,1,0), #specify the two cells in the 'row' I want to sum to one(???)
   c(0,1,0,1), # likewise
   diag(rep(1,4))
   )
R b2 - c(1,1, rep(0, times=4))
R solve.QP(Dmat = XX,dvec=Xy,Amat = t(a2),bvec=b2,meq=2)
$solution
[1] 0.9367934 0.000 0.0632066 1.000

$value
[1] -63.38694

$unconstrainted.solution
[1] 1.004181694 0.002401266 0.012673485 1.012848987

$iterations
[1] 4 0

$iact
[1] 1 2 4


HTH.

Cheers,

Berwin

=== Full address =
Berwin A TurlachTel.: +65 6515 4416 (secr)
Dept of Statistics and Applied Probability+65 6515 6650 (self)
Faculty of Science  FAX : +65 6872 3919   
National University of Singapore
6 Science Drive 2, Blk S16, Level 7  e-mail: sta...@nus.edu.sg
Singapore 117546http://www.stat.nus.edu.sg/~statba

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


[R] How to add direction of time to plot.circular()

2009-02-16 Thread Michael Kubovy
Dear r-helpers,

I want to show that time is flowing CCW in the following:

require(circular)
len - 8
labl - as.character(c(0, 1, 1, 1, 0, 0, 1, 0))
r - circular(2*pi* (rep(c(1, 3, 6), each = 200)/len + rnorm(600, 0,  
0.025)))
r.dens - density(r, bw = 25, adjust = 4, kernel = 'vonmises')
plot(r, shrink = 2.5, axes = FALSE, ticks = FALSE, pch = 1, col =  
'lightblue', stack = TRUE, bins = 12 * len)
axis.circular(at = circular(seq(0, (len - 1) * 2 * pi/len, length.out  
= len)), label = labl)
lines(r.dens, col = 2)

I had imagined a directed arc with a smaller radius than the black  
circle, running from 0 to 315 deg. I also thought that adding a short  
horizontal line at its beginning might be helpful. I would appreciate  
advice on how best to do this or anything else that would provide the  
required information.

_
Professor Michael Kubovy
University of Virginia
Department of Psychology
Postal Address:
P.O.Box 400400, Charlottesville, VA 22904-4400
Express Parcels Address:
Gilmer Hall, Room 102, McCormick Road, Charlottesville, VA 22903
Office:B011;Phone: +1-434-982-4729
Lab:B019;   Phone: +1-434-982-4751
WWW:http://www.people.virginia.edu/~mk9y/
Skype name: polyurinsane





[[alternative HTML version deleted]]

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


Re: [R] is there any way to find match with tolerance

2009-02-16 Thread Gabor Grothendieck
?all.equal has a tolerance argument.

On Mon, Feb 16, 2009 at 8:41 AM, Suresh_FSFM suresh.ghals...@gmail.com wrote:

 Hello all,

 suppose I have a time-stamp: 16-02-2009 00:20:00
 and other array that stores lot of time values.

 My tolerance limit = +5 minutes
 I would like to find values from this array matching with the value:
 16-02-2009 00:20:00 + tolerance
 Before I write some function, I would like to know: whether any readymade
 function is available?
 I checked compare() or which() . but not exactly what I would like to have.

 Any suggestion is appreciated.

 Thank you.

 Best Regards,
 Suresh


 --
 View this message in context: 
 http://www.nabble.com/is-there-any-way-to-find-match-with-tolerance-tp22037475p22037475.html
 Sent from the R help mailing list archive at Nabble.com.

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


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


[R] odd GARCH(1,1) results

2009-02-16 Thread Helena Richter

Hi everybody,

I'm trying to fit a Garch(1,1) process to the DAX returns. My data 
consists of about 2300 10day-logreturns in chronologically descending 
order (see attachment). But if I use the garch function I get a very 
high alpha_1 and a quite low beta, which doesn't make that much sense. I 
think I am missing something, but have no idea what it might be. I'd 
appreciate it a lot if someone could have a look at the output I posted 
at the end of this mail. Maybe there's something an experienced user 
might see at once. I also tried the garchFit function with nearly the 
same results.

I'm very thankful for every answer. Please excuse my bad english.
Helena


 g2005out-garch(g2005,order=c(1,1))

* ESTIMATION WITH ANALYTICAL GRADIENT *


I INITIAL X(I) D(I)

1 2.214508e-03 1.000e+00
2 5.00e-02 1.000e+00
3 5.00e-02 1.000e+00

IT NF F RELDF PRELDF RELDX STPPAR D*STEP NPRELDF
0 1 -5.974e+03
1 6 -5.998e+03 3.91e-03 5.51e-03 3.6e-03 2.5e+08 3.6e-04 6.90e+05
2 7 -6.000e+03 3.19e-04 6.17e-04 3.1e-03 2.0e+00 3.6e-04 5.50e+02
3 8 -6.001e+03 2.76e-04 2.98e-04 3.5e-03 2.0e+00 3.6e-04 5.21e+02
4 13 -6.161e+03 2.59e-02 3.79e-02 4.8e-01 2.0e+00 9.3e-02 5.07e+02
5 21 -6.182e+03 3.39e-03 7.77e-03 1.1e-03 3.6e+00 3.2e-04 4.87e-01
6 22 -6.182e+03 9.68e-05 7.28e-05 1.1e-03 2.0e+00 3.2e-04 2.11e+00
7 23 -6.183e+03 2.15e-05 2.25e-05 1.1e-03 2.0e+00 3.2e-04 2.37e+00
8 29 -6.213e+03 4.86e-03 4.50e-03 5.7e-01 2.0e+00 1.6e-01 2.34e+00
9 31 -6.278e+03 1.03e-02 1.04e-02 4.3e-01 2.0e+00 3.2e-01 1.65e+02
10 33 -6.301e+03 3.67e-03 5.01e-03 2.9e-02 1.9e+00 3.2e-02 7.66e-02
11 36 -6.347e+03 7.26e-03 7.63e-03 1.0e-01 1.3e+00 1.3e-01 1.06e-01
12 37 -6.399e+03 8.17e-03 9.09e-03 2.1e-01 7.0e-01 2.6e-01 1.33e-02
13 39 -6.412e+03 2.04e-03 2.19e-03 2.6e-02 1.8e+00 2.6e-02 2.18e-02
14 41 -6.437e+03 3.80e-03 5.84e-03 9.4e-02 1.1e+00 1.0e-01 1.80e-02
15 43 -6.498e+03 9.44e-03 8.74e-03 2.9e-01 8.5e-02 3.2e-01 8.77e-03
16 44 -6.518e+03 3.07e-03 2.11e-03 9.0e-02 0.0e+00 8.9e-02 2.11e-03
17 45 -6.527e+03 1.38e-03 1.07e-03 7.2e-02 0.0e+00 8.3e-02 1.07e-03
18 46 -6.530e+03 4.03e-04 3.24e-04 4.9e-02 0.0e+00 7.6e-02 3.24e-04
19 47 -6.530e+03 6.83e-05 7.29e-05 1.7e-02 0.0e+00 2.4e-02 7.29e-05
20 48 -6.530e+03 5.26e-06 6.29e-06 6.2e-03 0.0e+00 1.2e-02 6.29e-06
21 49 -6.530e+03 1.53e-07 1.54e-07 9.0e-04 0.0e+00 1.7e-03 1.54e-07
22 50 -6.530e+03 1.33e-10 1.22e-10 2.3e-05 0.0e+00 3.3e-05 1.22e-10
23 51 -6.530e+03 2.08e-12 6.94e-12 3.9e-06 0.0e+00 6.0e-06 6.94e-12

* RELATIVE FUNCTION CONVERGENCE *

FUNCTION -6.530104e+03 RELDX 3.860e-06
FUNC. EVALS 51 GRAD. EVALS 24
PRELDF 6.944e-12 NPRELDF 6.944e-12

I FINAL X(I) D(I) G(I)

1 2.041120e-04 1.000e+00 4.584e-01
2 7.096202e-01 1.000e+00 2.579e-04
3 2.487274e-01 1.000e+00 3.097e-04

 summary(g2005out)

Call:
garch(x = g2005, order = c(1, 1))

Model:
GARCH(1,1)

Residuals:
Min 1Q Median 3Q Max
-4.1857 -0.6978 0.3268 0.9039 4.9820

Coefficient(s):
Estimate Std. Error t value Pr(|t|)
a0 2.041e-04 2.072e-05 9.849 2e-16 ***
a1 7.096e-01 5.780e-02 12.277 2e-16 ***
b1 2.487e-01 2.062e-02 12.060 2e-16 ***
---
Signif. codes: 0 ‘***’ 0.001 ‘**’ 0.01 ‘*’ 0.05 ‘.’ 0.1 ‘ ’ 1

Diagnostic Tests:
Jarque Bera Test

data: Residuals
X-squared = 33.1741, df = 2, p-value = 6.257e-08


Box-Ljung test

data: Squared.Residuals
X-squared = 8.9147, df = 1, p-value = 0.002829

0.0101469753486814
0.0302708525301284
0.0298869542573102
0.0250238066360943
0.0219854269480636
0.0255910978745133
0.0208766939739549
0.024472384972313
0.0104622603956565
0.0156958456499357
0.00856720663997033
0.00554233092097657
0.0178169931968505
0.0210859439733833
0.0237885580502165
0.0167733305146503
0.0188592789433067
0.0135089788757992
0.0240819536500512
0.0184436895969784
0.0353754332617942
0.0321898629583924
0.0217899667893017
0.0172398497190095
0.0163914150178588
0.0201309274983712
0.0338013250091364
0.0361931688792124
0.0325828765178621
0.0287244326640976
0.0253523402633412
0.0175501402847404
0.0252357634588918
0.0374920819481566
0.0326047940338621
0.0534817989667282
0.0426675454652661
0.0223149096583253
0.0274987474190061
0.0246657927597472
0.0319013714312724
0.0297229546082391
0.0222133631437097
-0.00499102835204226
-0.0100445943888354
-0.0305945586081492
-0.0295261769725028
-0.0163888329648776
-0.0322053226938304
-0.0243851116782977
-0.0344066186625488
-0.0309734197068084
-0.0450769173663317
-0.037850073973392
-0.0205237352329365
-0.0136852813721192
-0.0142612563819063
-0.0133534576292516
0.0133184076877491
0.00491571150380778
0.0253169375424642
0.0341114006741854
0.0390611810003106
0.0346856037825977
0.0311649689770797
0.011488947602242
0.0232081050895178
0.0276265045794663
0.0129717174745311
0.00163794296612078
-0.024949441008574
-0.0292122997648142
-0.0228978631488851
-0.00109151628878845
0.00330215163389701
0.0302721218697545
0.0129328948578658
0.0167299192156694
0.0227293766139797
0.0362692295589419
0.045387373127
0.0277697471036363
0.0145780740041389
0.01022462837413
-0.00645583966150953
-0.0188585933198392

[R] I can't apply the summary function when I use de armaFit (fArma)...

2009-02-16 Thread Ana Patricia Silva Cunha Martins (DGR)
Hi,

I can't apply the summary function when I use de armaFit (fArma).

Can you help?

 

fit-armaFit(~arma(1,0),data=age55)

fit

Title:

 ARIMA Modelling 

Call:

 armaFit(formula = ~arma(1, 0), data = age55)

Model:

 ARIMA(1,0,0) with method: CSS-ML

Coefficient(s):

  ar1  intercept  

-0.564184   0.001190  

Description:

 Mon Feb 16 15:00:54 2009 by user: f003553 

 

 summary(fit)

Error in var.default(ans$residuals) : 

  invalid 'use' (computational method)

 

Thanks in advance for your Kind collaboration.

Ana


[[alternative HTML version deleted]]

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


Re: [R] controlling number of decimals printed in anova tables?

2009-02-16 Thread Gabor Grothendieck
Or safer:

df - as.integer(round(...))

On Mon, Feb 16, 2009 at 10:54 AM, Gabor Grothendieck
ggrothendi...@gmail.com wrote:
 Try this:

 On Mon, Feb 16, 2009 at 9:02 AM, Michael Friendly frien...@yorku.ca wrote:
 For glm() models, I often find both the print() and summary() method
 disappointing if my main interest
 is seeing how well a given model fits. A basic display would just compare
 the null model to to my model.

 I wrote the function below based on code in some package.
 How can I make it so that the df in the table are printed with 0 decimals?

 Try this:
 df - as.integer(c(x$df.null, x$df.residual))


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


Re: [R] (no subject)

2009-02-16 Thread Peter Dalgaard
Uwe Ligges wrote:
 
 
 Vincze Orsolya wrote:
 There are three columns, I was just careless.
 I succeed to merge the two tables. But:
 1) in the first table there were rows, which were not present in the
 second
 table, these rows were deleted from the merged table too, but I need
 them.
 2) If i want to import from the second table just a certain column,
 not all
 that is missing from the first, how can i do that?
 3) How can I save the generated table?

 Sorry about the banal questions I'm beginner.
 And thanks for the help...
 Have a nice day
 
 
 Homework? Then please ask you course material or teacher.

What makes you think that, Uwe? I don't see a teacher asking merge()
questions to a rank beginner (I wouldn't).

1) look at the documentation: all.x=TRUE
2) use the usual subsetting mechanisms to work with only the relevant
set of columns, e.g. merge(x, y[,c(1,2,6)], )
3) assign using z - merge(x,y,), then save() (or maybe write.table())

-pd




 2009/2/15 Peter Dalgaard p.dalga...@biostat.ku.dk

 Vincze Orsolya wrote:

 Dear all,I had just started to learn R. So my question may sound a bit
 stupid for you.
 Is that possible to match and merge two tables in R? I mean I have two
 tables, in the first I have two columns: RING NUMBER,  WEIGHT and
 CAPTURE

 Err, ... for large values of two? Or is one of the three a rowname?

  DATE, in the second RING NUMBER, SEX  and CAPTURE DATE.
 1) First I want to see, if to the ring numbers are the same, the
 capture
 dates are too?
 2) And second if ring numbers are the same, to import the sex from the
 second table in the first.

 Is that possible?

 Yes. It's a job for merge()

 -- 
   O__   Peter Dalgaard Øster Farimagsgade 5, Entr.B
  c/ /'_ --- Dept. of Biostatistics PO Box 2099, 1014 Cph. K
  (*) \(*) -- University of Copenhagen   Denmark  Ph:  (+45) 35327918
 ~~ - (p.dalga...@biostat.ku.dk)  FAX: (+45) 35327907


 [[alternative HTML version deleted]]



 

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


-- 
   O__   Peter Dalgaard Øster Farimagsgade 5, Entr.B
  c/ /'_ --- Dept. of Biostatistics PO Box 2099, 1014 Cph. K
 (*) \(*) -- University of Copenhagen   Denmark  Ph:  (+45) 35327918
~~ - (p.dalga...@biostat.ku.dk)  FAX: (+45) 35327907

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


Re: [R] LCA (e1071 package): error

2009-02-16 Thread Evgenia

Before using lca,
try
data-as.matrix(data).

For example when I tried using lca  lca(LSAT,2,niter=100)
for known LSAT data (library ltm), I took error messages.

But, when I use
data-as.matrix(LSAT)
lca(data,2,niter=100)

I took results for lca
King Regards,

Evgenia



Tryntsje Wesselius wrote:
 
 Hello,
 
 I will use the lca method in the e1071 package. But I get the following
 error:
 Error in pas[j, ] - drop(exp(rep(1, nvar) %*% log(mp))) :
   number of items to replace is not a multiple of replacement length
 
 Does anybody know this error and knows what this means?
 
 Kind regards,
 
 Tryntsje
 
 __
 R-help@r-project.org mailing list
 https://stat.ethz.ch/mailman/listinfo/r-help
 PLEASE do read the posting guide
 http://www.R-project.org/posting-guide.html
 and provide commented, minimal, self-contained, reproducible code.
 
 

-- 
View this message in context: 
http://www.nabble.com/LCA-%28e1071-package%29%3A-error-tp21478519p22040077.html
Sent from the R help mailing list archive at Nabble.com.

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


Re: [R] controlling number of decimals printed in anova tables?

2009-02-16 Thread Dieter Menne
Gabor Grothendieck ggrothendieck at gmail.com writes:

 
 Or safer:
 
 df - as.integer(round(...))
 

Did you try? I believe it is a problem of printCoefmat that has quite
a few options for special column, but none for df. Ask Martin Mächler.

Dieter

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


Re: [R] is there any way to find match with tolerance

2009-02-16 Thread Suresh_FSFM

Thank you for the positve response.



Gabor Grothendieck wrote:
 
 ?all.equal has a tolerance argument.
 
 On Mon, Feb 16, 2009 at 8:41 AM, Suresh_FSFM suresh.ghals...@gmail.com
 wrote:

 Hello all,

 suppose I have a time-stamp: 16-02-2009 00:20:00
 and other array that stores lot of time values.

 My tolerance limit = +5 minutes
 I would like to find values from this array matching with the value:
 16-02-2009 00:20:00 + tolerance
 Before I write some function, I would like to know: whether any readymade
 function is available?
 I checked compare() or which() . but not exactly what I would like to
 have.

 Any suggestion is appreciated.

 Thank you.

 Best Regards,
 Suresh


 --
 View this message in context:
 http://www.nabble.com/is-there-any-way-to-find-match-with-tolerance-tp22037475p22037475.html
 Sent from the R help mailing list archive at Nabble.com.

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

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

-- 
View this message in context: 
http://www.nabble.com/is-there-any-way-to-find-match-with-tolerance-tp22037475p22040233.html
Sent from the R help mailing list archive at Nabble.com.

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


Re: [R] controlling number of decimals printed in anova tables?

2009-02-16 Thread Gabor Grothendieck
On Mon, Feb 16, 2009 at 11:08 AM, Dieter Menne
dieter.me...@menne-biomed.de wrote:
 Gabor Grothendieck ggrothendieck at gmail.com writes:


 Or safer:

 df - as.integer(round(...))


 Did you try? I believe it is a problem of printCoefmat that has quite
 a few options for special column, but none for df. Ask Martin Mächler.

Yes, with as.integer(round(...)) It looks like this:

 modelFit.glm(berk.mod2)
Signif. codes:  0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1

 modelFit.glm(berk.mod2)
Analysis of Deviance Table
Formula:  Freq ~ Dept * (Gender + Admit)

   Deviance   df Pr(Chi^2)
Null model 2650   23
Model226 0.0014 **
---
Signif. codes:  0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1

Also note:

 as.integer(1-.1)
[1] 0
 as.integer(round(1-.1))
[1] 1

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


[R] scatterplot and correlation for weird data format

2009-02-16 Thread William Simpson
I have data in a format like this:

namessexsex viewnum rating  rt
ahl4f   m   f   56  -1082246
ahl4f   m   f   74  85  1444
ahl4f   m   f   52  151 1595
ahl4f   m   f   85  1   1447
ahl4f   m   f   53  46  1716
ahl4f   m   f   37  145 1276
ahl4f   m   f   50  98  1465
ahl4f   m   f   51  -26 1322
ahl4f   m   f   38  -97 1790
ahl4f   m   f   14  -158865
...
ahl4f   m   p   43  -1361669
ahl4f   m   p   10  -59 808
ahl4f   m   p   67  -1111279
ahl4f   m   p   85  -86 994
ahl4f   m   p   100 134 1337
ahl4f   m   p   76  56  665
ahl4f   m   p   51  -49 594
ahl4f   m   p   33  -118505
ahl4f   m   p   49  -1561283
...
and so on for many subjects (name)

I would like to do a scatterplot of the rating given by each subject
(with identifier name) for the frontal (view==f) and profile
(view==p) views of each face (each face has an identifier num).
I'd like to find the correlation as well.
For each subject, since there are 100 faces, there will be 100 points
on the scatterplot. I would just lump all the subjects' data together
for the plot and correlation I think (unless somebody tells me I
should do each subject separately).

I'm stumped on how to do this. Thanks very much for any help!

Bill

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


[R] Using eval in multinom argument

2009-02-16 Thread Crouch, Daniel
Hi,

I am having difficulty entering a 'programmable' argument into the multinom 
function from the nnet package. Interactively, I can get the function to work 
fine by calling it this way:

z1=multinom(formula = class.ind(grp[-outgroup])~ (PC1 + PC2 + PC3), 
data=data.frame(scores))

However I need to be able to change the number of variables I am looking for in 
'scores' and so am trying to call it this way...

z1=multinom(formula = class.ind(grp[-outgroup])~ eval(parse(text=PCnames)), 
data=data.frame(scores))

...where, for example, PCnames = c(PC1, +,   PC2, +,   PC3)   

This gives no error messages, but only the last variable (in this case PC3) 
gets considered in the model. z1 looks like this:

  (Intercept) eval(parse(text = PCnames))
23.530352  -116.87140
3   -1.30861313.59134
43.662172   -57.52198
5   -1.216041  -242.38827
6   -9.377894  -367.71614
7   -3.145738  -286.19766

Rather than this:

  (Intercept)   PC1PC2   PC3
2   288.97131   889.281  3776.5837 -2105.751
3  -712.53519  2775.663  8490.5724  8602.834
4   229.17772  4234.950   329.6995 -2182.238
585.54585 -3036.657  3968.2517 -3450.070
6  -676.55377 -9545.785  2422.5340 -7183.686
7  -631.91921 10997.432 -3310.2905 -5348.513

Any help would be much appreciated.

Thanks,
Daniel Crouch


Daniel Crouch
Research Student
Department of Medical  Molecular Genetics
King's College London
8th Floor, Tower Wing
Guy's Hospital
London SE1 9RT
United Kingdom
__
R-help@r-project.org mailing list
https://stat.ethz.ch/mailman/listinfo/r-help
PLEASE do read the posting guide http://www.R-project.org/posting-guide.html
and provide commented, minimal, self-contained, reproducible code.


Re: [R] controlling number of decimals printed in anova tables?

2009-02-16 Thread Dieter Menne
Gabor Grothendieck ggrothendieck at gmail.com writes:

 
 On Mon, Feb 16, 2009 at 11:08 AM, Dieter Menne
 
 Yes, with as.integer(round(...)) It looks like this:
 
  modelFit.glm(berk.mod2)
 Signif. codes:  0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1
 
  modelFit.glm(berk.mod2)
 Analysis of Deviance Table
 Formula:  Freq ~ Dept * (Gender + Admit)
 
Deviance   df Pr(Chi^2)
 Null model 2650   23
 Model226 0.0014 **
 ---

I am 90% I am on the wrong trip, help me out. And what happens to your solutions
if the Null Model has small Deviance?

Dieter


modelFit.glm -
function (x, digits = max(3, getOption(digits) - 3), ...)
{
dev - c(x$null.deviance, x$deviance )
df - as.integer(c(x$df.null, x$df.residual))
#df - as.integer(round(c(x$df.null, x$df.residual)))
table - data.frame(dev, df, c(NA, 1-pchisq(x$deviance, x$df.residual)),
row.names=c(Null model, Model))

dimnames(table) - list(c(Null model, Model), c(Deviance, df, 
Pr(Chi^2)))
title - paste(Analysis of Deviance Table, \n\tFormula: , 
deparse(x$formula), \n)
structure(table, heading = title, class = c(anova, data.frame))

}

berkeley - as.data.frame(UCBAdmissions)
berk.mod2 - glm(Freq ~ Dept * (Gender+Admit), data=berkeley, 
family=poisson)

modelFit.glm(berk.mod2)



Analysis of Deviance Table 
Formula:  Freq ~ Dept * (Gender + Admit) 

   Deviance  df Pr(Chi^2)   
Null model  2650.10   23.00  
Model 21.746.00   0.001352 **
---
Signif. codes:  0 ‘***’ 0.001 ‘**’ 0.01 ‘*’ 0.05 ‘.’ 0.1 ‘ ’ 1 


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


Re: [R] (no subject)

2009-02-16 Thread Uwe Ligges



Peter Dalgaard wrote:

Uwe Ligges wrote:


Vincze Orsolya wrote:

There are three columns, I was just careless.
I succeed to merge the two tables. But:
1) in the first table there were rows, which were not present in the
second
table, these rows were deleted from the merged table too, but I need
them.
2) If i want to import from the second table just a certain column,
not all
that is missing from the first, how can i do that?
3) How can I save the generated table?

Sorry about the banal questions I'm beginner.
And thanks for the help...
Have a nice day


Homework? Then please ask you course material or teacher.


What makes you think that, Uwe? I don't see a teacher asking merge()
questions to a rank beginner (I wouldn't).


Peter,

at least I give them corresponding homeworks so that they learn about 
it: at least merge(), subsetting and assignments are not beyond the 
scope of a beginners course in Dortmund. I feel this is a typical 2nd or 
3rd day R course homework for data manipulation.


Best,
Uwe





1) look at the documentation: all.x=TRUE
2) use the usual subsetting mechanisms to work with only the relevant
set of columns, e.g. merge(x, y[,c(1,2,6)], )
3) assign using z - merge(x,y,), then save() (or maybe write.table())

-pd




2009/2/15 Peter Dalgaard p.dalga...@biostat.ku.dk


Vincze Orsolya wrote:


Dear all,I had just started to learn R. So my question may sound a bit
stupid for you.
Is that possible to match and merge two tables in R? I mean I have two
tables, in the first I have two columns: RING NUMBER,  WEIGHT and
CAPTURE


Err, ... for large values of two? Or is one of the three a rowname?

 DATE, in the second RING NUMBER, SEX  and CAPTURE DATE.

1) First I want to see, if to the ring numbers are the same, the
capture
dates are too?
2) And second if ring numbers are the same, to import the sex from the
second table in the first.

Is that possible?


Yes. It's a job for merge()

--
  O__   Peter Dalgaard Øster Farimagsgade 5, Entr.B
 c/ /'_ --- Dept. of Biostatistics PO Box 2099, 1014 Cph. K
 (*) \(*) -- University of Copenhagen   Denmark  Ph:  (+45) 35327918
~~ - (p.dalga...@biostat.ku.dk)  FAX: (+45) 35327907


[[alternative HTML version deleted]]





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

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





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


Re: [R] Alternate to for-loop

2009-02-16 Thread Patrick Burns

If the goal is to look professional, then
'replicate' probably suits.  If the goal is to
compute as fast as possible, then that isn't
the case because 'replicate' is really a 'for'
loop in disguise and there are other ways.

Here's one other way:

function (size, replicates, distfun, ...)
{

   colMeans(array(distfun(size * replicates, ...), c(size, 
replicates)))

}



Patrick Burns
patr...@burns-stat.com
+44 (0)20 8525 0696
http://www.burns-stat.com
(home of The R Inferno and A Guide for the Unwilling S User)

Uwe Ligges wrote:



megh wrote:

No, it is not homework. I obviously



For some value of obvious as you has not given a single line of code 
as the posting guide suggests.


You probably want:

replicate(10, mean(rnorm(100)))

Uwe Ligges



could do that using a for-loop, and that
I already did. However I thought whether there could be a better 
approach as

it was looking very messy and unprofessional.



Uwe Ligges-3 wrote:



megh wrote:

Hi, I am trying to create a vector of length 10 (say), wherein each
element
will be average of random sample of size 100, from a distribution, say
Normal. Can anyone please tell me without creating a for loop, how I
can
do that?


Homework? Then please ask you course material or teacher.

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

Uwe Ligges


Regards,



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






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

and provide commented, minimal, self-contained, reproducible code.




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


Re: [R] Alternate to for-loop

2009-02-16 Thread Gustaf Rydevik
On Mon, Feb 16, 2009 at 12:59 PM, megh megh700...@yahoo.com wrote:

 Hi, I am trying to create a vector of length 10 (say), wherein each element
 will be average of random sample of size 100, from a distribution, say
 Normal. Can anyone please tell me without creating a for loop, how I can
 do that?

 Regards,


 --
 View this message in context: 
 http://www.nabble.com/Alternate-to-for-loop-tp22035954p22035954.html
 Sent from the R help mailing list archive at Nabble.com.


as a variant of Patrick Burns code, you can write:

rowMeans(matrix(rnorm(1000),ncol=100))

,and substitute another distribution for rnorm if you want.

/Gustaf

-- 
Gustaf Rydevik, M.Sci.
tel: +46(0)703 051 451
address:Essingetorget 40,112 66 Stockholm, SE
skype:gustaf_rydevik

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


Re: [R] scatterplot and correlation for weird data format

2009-02-16 Thread hadley wickham
On Mon, Feb 16, 2009 at 10:21 AM, William Simpson
william.a.simp...@gmail.com wrote:
 I have data in a format like this:

 namessexsex viewnum rating  rt
 ahl4f   m   f   56  -1082246
 ahl4f   m   f   74  85  1444
 ahl4f   m   f   52  151 1595
 ahl4f   m   f   85  1   1447
 ahl4f   m   f   53  46  1716
 ahl4f   m   f   37  145 1276
 ahl4f   m   f   50  98  1465
 ahl4f   m   f   51  -26 1322
 ahl4f   m   f   38  -97 1790
 ahl4f   m   f   14  -158865
 ...
 ahl4f   m   p   43  -1361669
 ahl4f   m   p   10  -59 808
 ahl4f   m   p   67  -1111279
 ahl4f   m   p   85  -86 994
 ahl4f   m   p   100 134 1337
 ahl4f   m   p   76  56  665
 ahl4f   m   p   51  -49 594
 ahl4f   m   p   33  -118505
 ahl4f   m   p   49  -1561283
 ...
 and so on for many subjects (name)

 I would like to do a scatterplot of the rating given by each subject
 (with identifier name) for the frontal (view==f) and profile
 (view==p) views of each face (each face has an identifier num).
 I'd like to find the correlation as well.
 For each subject, since there are 100 faces, there will be 100 points
 on the scatterplot. I would just lump all the subjects' data together
 for the plot and correlation I think (unless somebody tells me I
 should do each subject separately).

You might find the reshape package, http://had.co.nz/reshape, helpful.
You could do something like:

dfm - melt(mydataframe, m = c(num, rating, rt))
cast(dfm, ... ~ view, subset = variable == rating)

Then do a scatterplot of the variables f and p.

Hadley

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

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


[R] Printing out a graph using different graphics devices

2009-02-16 Thread Dimitri Liakhovitski
Hello, everyone!
The code below allows me to produce the graph I want (I know - the
colors are strange, but it's just for the sake of an example).
After you run the plot- part and then do print(plot) - that's what I want.
However, when I run the bits of code below (with graphics devices) -
what they print is different from the original plot. In .png, .emf,
and .tiff - my dots change their shape and my lines (I think) become
thinner. And in .ps format - the dots stay what they are supposed to
be but they change their color.
Could you please explain to me what the reasons are for those changes?
Also - should I specify my chart characteristics differently depending
on the device I'll be using?
Thank you very much!
Dimitri

library(lattice)
d=data.frame(xx=c(2.2,2.1,3.3),yy=c(0.1,0.2,0.3),zz=c(2.5,2.0,1.8))
d[[2]]-as.factor(as.numeric((d[[2]])))

trellis.par.set(superpose.line = list(col=c(green,red), lwd = 2),
   superpose.symbol = list(col=c(yellow,blue),cex =
1.3, pch = 20),
   reference.line = list(col = gray, lty =dotted))

plot-dotplot(c(d[[1]],d[[3]])~rep(d[[2]],2),
   groups=rep(c(Group 1,Group 2), each=nrow(d)),
   main=list(Chart Title,cex=1),

   type=b,
   auto.key = list(space = top, points = TRUE, lines = TRUE),

   xlab=list(Title for X,cex=.9,font=2),
   ylab=list(Title for Y,cex=.9,font=2),

   panel = function(y,x,...) {
   panel.grid(h = -1, v = -1)
   panel.xyplot(x, y, ...)

   ltext(x, y, labels=round(y,3),
 cex=.8,col=black,font=2,
 adj=c(-0.2,1))

   })
print(plot)

win.metafile(file=test.emf)
print(plot)
dev.off()

postscript(file=test.ps)
print(plot)
dev.off()

png(file=test.png)
print(plot)
dev.off()

tiff(file=test.tiff)
print(plot)
dev.off()

-- 
Dimitri Liakhovitski
MarketTools, Inc.
dimitri.liakhovit...@markettools.com

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


[R] Whitening Time Series

2009-02-16 Thread Pele

Hi R users,

I am doing cross correlation analysis on  2 time series (call them y-series
and x-series) where I need the use the model developed on the x-series to
prewhiten the yseries..  Can someone point me to a function/filter in R that
would allow me to do that? 

Thanks in advance for any help!
-- 
View this message in context: 
http://www.nabble.com/Whitening-Time-Series-tp22041765p22041765.html
Sent from the R help mailing list archive at Nabble.com.

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


[R] assuming AR(1) residuals in OLS

2009-02-16 Thread constantine
Hi to all,


In other statistical software, such as Eviews, it is possible to
regress a model with the Least Squares method, assuming that the
residuals follow an AR(q) process.
For example the resulting regression is something like

y = 1.2154  + 0.2215 x + 0.251 AR(1)

How is it possible to do the same in R?

Thank you very much in advance,


Constantine Tsardounis
http://www.costis.name

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


[R] sandwich matrix multiplication and efficient determinant

2009-02-16 Thread Shimrit Abraham
Hi,

I am looking for two ways to speed up my computations:

1. Is there a function that efficiently computes the 'sandwich product' of
three matrices, say, ZPZ'
2. Is there a function that efficiently computes the determinant of a
positive definite symmetric matrix?

Thanks,

S.A.

[[alternative HTML version deleted]]

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


Re: [R] Outlier Detection for timeseries

2009-02-16 Thread Bert Gunter
Danger: More careful thought required.

Outliers (Title of a TECHNOMETRICS paper of a couple of decades ago)
are an artificial construct: there is NO SUCH THING in the abstract. They
exist only wrt to a model. So there is no such thing as software that tells
whether the changes are considered  Rather, you must consider
alternative suitable models, examine their fits, scientific implications,
interpretation, etc. Frequently, several models will fit essentially equally
well, but different subsets of the data will appear unusual (I no longer
use the word outlier because of the intimation that there is an objective
statistical meaning to this term, which there is not) for each.

Statistical algorithms cannot replace careful thinking. Sorry about that.

-- Bert Gunter
Genentech


-Original Message-
From: r-help-boun...@r-project.org [mailto:r-help-boun...@r-project.org] On
Behalf Of Pele
Sent: Saturday, February 14, 2009 5:16 AM
To: r-help@r-project.org
Subject: Re: [R] Outlier Detection for timeseries


Hi Stephen,

I am doing cross correlation analysis and I am trying to find a outlier
detection function in R that can detect changes in the level of the response
series that are not accounted for by the estimated model. Something that
tells whether the changes are considered Additive Outliers, Level Shifts, or
Temporary Changes... The output in the original not is what SAS produces and
I was looking for something similar..  R is very new to me (4 weeks) hence
still feeling my way around...

Many thanks!



Pele wrote:
 
 Hello R users,
 
 Can someone tell if there is a package in R that can do outlier detection
 that give outputs simiilar to what I got from SAS  below.
 
 Many thanks in advance for any help!
 
   Outlier Details


 Approx

 Chi- Prob
ObsTime ID Type  Estimate 
 Square ChiSq
 
 12   12.00Additive 2792544.6 
 186.13.0001
 13   13.00Additive  954302.1  
 21.23.0001
 15   15.00Shift63539.3   
 9.060.0026
 
 

-- 
View this message in context:
http://www.nabble.com/Outlier-Detection-for-timeseries-tp22008448p22012539.h
tml
Sent from the R help mailing list archive at Nabble.com.

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

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


[R] Applying functions to partitions

2009-02-16 Thread Titus von der Malsburg

Hi list!  I have a large matrix which I'd like to partition into blocks
and for each block I'd like to compute the mean.  Following a example
where each letter marks a block of the partition:

 a a a d g g 
 a a a d g g
 a a a d g g
 b b b e h h
 b b b e h h
 c c c f i i

I'm only interested in the resulting matrix of means.  How can this be
done efficiently?

Thanks!  Titus

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


Re: [R] (no subject)

2009-02-16 Thread Vincze Orsolya
Dear Peter,Thanks for the answer, it's working very well. And again sorry,
about asking as a banal question, but I really didn't have who to ask to
help me.
Uwe: I don't have a teacher, I never learned R before. I'm just trying to
learn self-educating, because it's very helpful in data manipulation
Answering my question would not take more time, than this sour answer...

All the best!
Orsolya

2009/2/16 Peter Dalgaard p.dalga...@biostat.ku.dk

 Uwe Ligges wrote:
 
 
  Vincze Orsolya wrote:
  There are three columns, I was just careless.
  I succeed to merge the two tables. But:
  1) in the first table there were rows, which were not present in the
  second
  table, these rows were deleted from the merged table too, but I need
  them.
  2) If i want to import from the second table just a certain column,
  not all
  that is missing from the first, how can i do that?
  3) How can I save the generated table?
 
  Sorry about the banal questions I'm beginner.
  And thanks for the help...
  Have a nice day
 
 
  Homework? Then please ask you course material or teacher.

 What makes you think that, Uwe? I don't see a teacher asking merge()
 questions to a rank beginner (I wouldn't).

 1) look at the documentation: all.x=TRUE
 2) use the usual subsetting mechanisms to work with only the relevant
 set of columns, e.g. merge(x, y[,c(1,2,6)], )
 3) assign using z - merge(x,y,), then save() (or maybe write.table())

 -pd



 
  2009/2/15 Peter Dalgaard p.dalga...@biostat.ku.dk
 
  Vincze Orsolya wrote:
 
  Dear all,I had just started to learn R. So my question may sound a bit
  stupid for you.
  Is that possible to match and merge two tables in R? I mean I have two
  tables, in the first I have two columns: RING NUMBER,  WEIGHT and
  CAPTURE
 
  Err, ... for large values of two? Or is one of the three a rowname?
 
   DATE, in the second RING NUMBER, SEX  and CAPTURE DATE.
  1) First I want to see, if to the ring numbers are the same, the
  capture
  dates are too?
  2) And second if ring numbers are the same, to import the sex from the
  second table in the first.
 
  Is that possible?
 
  Yes. It's a job for merge()
 
  --
O__   Peter Dalgaard Øster Farimagsgade 5, Entr.B
   c/ /'_ --- Dept. of Biostatistics PO Box 2099, 1014 Cph. K
   (*) \(*) -- University of Copenhagen   Denmark  Ph:  (+45)
 35327918
  ~~ - (p.dalga...@biostat.ku.dk)  FAX: (+45)
 35327907
 
 
  [[alternative HTML version deleted]]
 
 
 
  
 
  __
  R-help@r-project.org mailing list
  https://stat.ethz.ch/mailman/listinfo/r-help
  PLEASE do read the posting guide
  http://www.R-project.org/posting-guide.html
  and provide commented, minimal, self-contained, reproducible code.
 
  __
  R-help@r-project.org mailing list
  https://stat.ethz.ch/mailman/listinfo/r-help
  PLEASE do read the posting guide
  http://www.R-project.org/posting-guide.html
  and provide commented, minimal, self-contained, reproducible code.


 --
O__   Peter Dalgaard Øster Farimagsgade 5, Entr.B
  c/ /'_ --- Dept. of Biostatistics PO Box 2099, 1014 Cph. K
  (*) \(*) -- University of Copenhagen   Denmark  Ph:  (+45) 35327918
 ~~ - (p.dalga...@biostat.ku.dk)  FAX: (+45) 35327907



[[alternative HTML version deleted]]

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


Re: [R] Using eval in multinom argument

2009-02-16 Thread Charles C. Berry



Forget eval(parse(text = ))

See

?as.formula
?update.formula

and try out the example() s there.

HTH,

Chuck




On Mon, 16 Feb 2009, Crouch, Daniel wrote:


Hi,

I am having difficulty entering a 'programmable' argument into the multinom 
function from the nnet package. Interactively, I can get the function to work 
fine by calling it this way:

z1=multinom(formula = class.ind(grp[-outgroup])~ (PC1 + PC2 + PC3), 
data=data.frame(scores))

However I need to be able to change the number of variables I am looking for in 
'scores' and so am trying to call it this way...

z1=multinom(formula = class.ind(grp[-outgroup])~ eval(parse(text=PCnames)), 
data=data.frame(scores))

...where, for example, PCnames = c(PC1, +,   PC2, +,   PC3)

This gives no error messages, but only the last variable (in this case PC3) 
gets considered in the model. z1 looks like this:

 (Intercept) eval(parse(text = PCnames))
23.530352  -116.87140
3   -1.30861313.59134
43.662172   -57.52198
5   -1.216041  -242.38827
6   -9.377894  -367.71614
7   -3.145738  -286.19766

Rather than this:

 (Intercept)   PC1PC2   PC3
2   288.97131   889.281  3776.5837 -2105.751
3  -712.53519  2775.663  8490.5724  8602.834
4   229.17772  4234.950   329.6995 -2182.238
585.54585 -3036.657  3968.2517 -3450.070
6  -676.55377 -9545.785  2422.5340 -7183.686
7  -631.91921 10997.432 -3310.2905 -5348.513

Any help would be much appreciated.

Thanks,
Daniel Crouch


Daniel Crouch
Research Student
Department of Medical  Molecular Genetics
King's College London
8th Floor, Tower Wing
Guy's Hospital
London SE1 9RT
United Kingdom
__
R-help@r-project.org mailing list
https://stat.ethz.ch/mailman/listinfo/r-help
PLEASE do read the posting guide http://www.R-project.org/posting-guide.html
and provide commented, minimal, self-contained, reproducible code.



Charles C. Berry(858) 534-2098
Dept of Family/Preventive Medicine
E mailto:cbe...@tajo.ucsd.edu   UC San Diego
http://famprevmed.ucsd.edu/faculty/cberry/  La Jolla, San Diego 92093-0901

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


Re: [R] Whitening Time Series

2009-02-16 Thread stephen sefick
if you want to whiten the series why not just
new series - rnorm(num.obs)+series

On Mon, Feb 16, 2009 at 12:25 PM, Pele drdi...@yahoo.com wrote:

 Hi R users,

 I am doing cross correlation analysis on  2 time series (call them y-series
 and x-series) where I need the use the model developed on the x-series to
 prewhiten the yseries..  Can someone point me to a function/filter in R that
 would allow me to do that?

 Thanks in advance for any help!
 --
 View this message in context: 
 http://www.nabble.com/Whitening-Time-Series-tp22041765p22041765.html
 Sent from the R help mailing list archive at Nabble.com.

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




-- 
Stephen Sefick

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

-K. Mullis

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


Re: [R] assuming AR(1) residuals in OLS

2009-02-16 Thread Michael Kubovy

?gls

On Feb 16, 2009, at 12:28 PM, constantine wrote:


In other statistical software, such as Eviews, it is possible to
regress a model with the Least Squares method, assuming that the
residuals follow an AR(q) process.
For example the resulting regression is something like

y = 1.2154  + 0.2215 x + 0.251 AR(1)

How is it possible to do the same in R?


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


[R] Help with rgl

2009-02-16 Thread Iuri Gavronski
Hi,

I don't know much about the RGL package, and I have read the
documentation and tried some parameters, with no luck... I would like
to generate a movie from a 3D object (code below), where the vortex A
is closer to the observer, and then the object rotates and the B
vortex gets closer. I would like to capture this movie to a file.

By the way, I am not being able to insert unicode text with text3d.

rgl 0.82, R 2.8.1, Windows Vista.

Any help would be appreciated.

Code follows:

library(rgl)
open3d()

coord.1=c(0,100,0)
coord.2=c(100,100,0)
coord.3=c(100,0,0)
coord.4=c(0,0,0)
coord.5=c(50,50,70)

pyrcolor=red
triangles3d(rbind(coord.1,coord.4,coord.5),color=pyrcolor)
triangles3d(rbind(coord.1,coord.2,coord.5),color=pyrcolor)
triangles3d(rbind(coord.2,coord.3,coord.5),color=pyrcolor)
triangles3d(rbind(coord.3,coord.4,coord.5),color=pyrcolor)
quads3d(rbind(coord.1,coord.2,coord.3,coord.4),color=pyrcolor)

vertices = LETTERS[1:5]
text3d(coord.1,text=vertices[1],adj=1,color=blue)
text3d(coord.2,text=vertices[2],adj=0,color=blue)
text3d(coord.3,text=vertices[3],adj=0,color=blue)
text3d(coord.4,text=vertices[4],adj=1,color=blue)
text3d(coord.5,text=vertices[5],adj=0,color=blue)

# couldn't make this work...
#open3d(viewport=c(0,0,686,489))
#par3d(zoom = 1.157625)

filename = piramide.png
rgl.snapshot(filename)

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


Re: [R] Website, book, paper, etc. that shows example plots of distributions?

2009-02-16 Thread Greg Snow
I had a Murphy's law calendar a while back with many different laws in it.  One 
of those laws was along the lines of:

An easily understood, simple falsehood is often more useful than a complicated, 
often misunderstood truth

(though the original was probably much better phrased than my memory).

Many rules in textbooks and classes follow this principle, especially when 
outside pressures force teachers to cover 4-6 hours of material in a 3 hour 
course.  The set of assumptions you list below are of this type.  They are a 
good simple place to start, and good enough for an introductory class, but a 
full discussion of the truth would take more time than is reasonable for an 
intro class.

Yes, the theory on which linear models is based was originally derived using 
the assumptions of normality, but linear models are amazingly robust, meaning 
that if the normality assumptions don't hold, the results (p-values, confidence 
intervals) will still usually be close enough.  How close and if it is 
enough depends on sample size, how nonnormal the residuals are, and the 
specific question(s).

For regression, start by doing the regression, but then look at the 
diagnostic plots of the residuals (see ?plot.lm).  If you sample size is large 
and the residuals do not show strong skewness/outliers, then you are probably 
safe using the output of lm as is (Central Limit Thoerem, but still check other 
assumptions and make sure that what you are seeing/saying makes sense).  If 
there is more skewness/outliers than you are comfortable with, then there are 
robust methods that will be more helpful here.


Also note that if you know enough to find and use the lm function in R, then 
you know enough statistics to be dangerous (unless you are not allowed to make 
any decisions or communicate with anyone else (comma patients maybe)).  The 
goal now is to learn to use that power to do good, posting/reading here and 
Frank's book are a good start in that direction.

Hope this helps,
  

-- 
Gregory (Greg) L. Snow Ph.D.
Statistical Data Center
Intermountain Healthcare
greg.s...@imail.org
801.408.8111


 -Original Message-
 From: r-help-boun...@r-project.org [mailto:r-help-boun...@r-
 project.org] On Behalf Of Jason Rupert
 Sent: Saturday, February 14, 2009 4:48 PM
 To: David Winsemius
 Cc: R-help@r-project.org
 Subject: Re: [R] Website, book, paper, etc. that shows example plots of
 distributions?
 
 Many thanks to Greg L. Snow and David Winsemius for their responses.
 
 First off I can safely say I don't know enough statistics to be
 dangerous, but hopefully I will get to that point:)
 
 Regarding the goal - ultimately I would like to use linear regression
 (constrained for using linear regression at this point) for my data.  I
 thought the requirements for using linear regression was the following
 (I pulled this list from
 www.utexas.edu/courses/schwab/sw318_spring_2004/SolvingProblems/Class27
 _RegressionNCorrHypoTest.ppt):
 
 The assumptions required for utilizing a regression equation are the
 same as the assumptions for the test of significance of a correlation
 coefficient.
 Both variables are interval level.
 Both variables are normally distributed.
 The relationship between the two variables is linear.
 The variance of the values of the dependent variable is uniform for all
 values of the independent variable (equality of variance).
 
 Thus, I was going to attempt to (1) identify which distribution my data
 most closely represents, (2) translate my data so that it is normal,
 and (3) then use linear regression on the data.
 
 However, if
 The assumptions of most regression methods is that the *errors* need
 to have the desired relationship between means and variance, and not
 that the dependent variable be normal. Many times the apparent non-
 normality will be explained or captured by the regression model.
 
 Does this mean I can just do linear regression without translating my
 data and it will be okay?
 
 Note that I was using lm from R to access the errors, however, I had
 not an opportunity to do much analysis of those results to determine if
 they are Gaussian or not.
 
 I guess I am going to try to track down the following documents:
 (1) Statistical Distributions (Paperback)
 by Merran Evans (Author), Nicholas Hastings (Author), Brian Peacock
 (Author)
 # ISBN-10: 0471371246
 # ISBN-13: 978-0471371243
 
 (2) Regression Modeling Strategies (Hardcover)
 by Frank E. Jr. Harrell (Author)
 # ISBN-10: 0387952322
 # ISBN-13: 978-0387952321
 
 Maybe electronic versions of those documents are available.  My wife is
 already giving me a hard time the volume of books around.
 
 Thank you again for all your feedback and insights.
 
 
 --- On Fri, 2/13/09, David Winsemius dwinsem...@comcast.net wrote:
 From: David Winsemius dwinsem...@comcast.net
 Subject: Re: [R] Website, book, paper, etc. that shows example plots of
 distributions?
 To: jasonkrup...@yahoo.com
 Cc: Gabor Grothendieck ggrothendi...@gmail.com, 

Re: [R] several ifelse problems...

2009-02-16 Thread Patrizio Frederic
do you mean:

 f=function(x) 
0*(abs(x-.5)=.3)-1*(abs(x-.5)=.4)+(10*x-2)*(x.1x.2)+(-10*x+8)*(x=.2x=.5)
 f(x)
 curve(f,0,1)

hope it helps.

Patrizio

2009/2/14 kathie kathryn.lord2...@gmail.com:

 Dear R users,

 From the code below, I try to compute y value. (In fact, y looks like a
 trapezoid)

 --

 x - seq(0,1,.01)
 y - ifelse(abs(x-.5)=0.3,0,
ifelse(abs(w-.5)=0.4,-1,
   ifelse((0.1w  w0.2),10*x-2,-10*x+8)))

 --

 So, results are...

 --
 x
  [1] 0.00 0.01 0.02 0.03 0.04 0.05 0.06 0.07 0.08 0.09 0.10 0.11 0.12 0.13
 0.14
  [16] 0.15 0.16 0.17 0.18 0.19 0.20 0.21 0.22 0.23 0.24 0.25 0.26 0.27 0.28
 0.29
  [31] 0.30 0.31 0.32 0.33 0.34 0.35 0.36 0.37 0.38 0.39 0.40 0.41 0.42 0.43
 0.44
  [46] 0.45 0.46 0.47 0.48 0.49 0.50 0.51 0.52 0.53 0.54 0.55 0.56 0.57 0.58
 0.59
  [61] 0.60 0.61 0.62 0.63 0.64 0.65 0.66 0.67 0.68 0.69 0.70 0.71 0.72 0.73
 0.74
  [76] 0.75 0.76 0.77 0.78 0.79 0.80 0.81 0.82 0.83 0.84 0.85 0.86 0.87 0.88
 0.89
  [91] 0.90 0.91 0.92 0.93 0.94 0.95 0.96 0.97 0.98 0.99 1.00

 y
  [1] -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1  8  8  8  8  8  8  8  8  8  0  0  0
 0  0
  [26]  0  0  0  0  0  0  0  0  0  0  0  0  0  0  0  0  0  0  0  0  0  0  0
 0  0
  [51]  0  0  0  0  0  0  0  0  0  0  0  0  0  0  0  0  0  0  0  0  0  0  0
 0  0
  [76]  0  0  0  0  0  8  8  8  8  8  8  8  8  8  8 -1 -1 -1 -1 -1 -1 -1 -1
 -1 -1
 [101] -1


 --

 However, even though the results show that y=8 for x=0.11, when x=0.11,
 actual y value is -0.9.  And, y=-0.8 for x=0.88.  I cannot understand the
 above results.

 Any comments will be greatly appreciated.

 Kathryn Lord
 --
 View this message in context: 
 http://www.nabble.com/several-%22ifelse%22-problems...-tp22009321p22009321.html
 Sent from the R help mailing list archive at Nabble.com.

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


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


[R] Adjusting the Axis in a histogram to the prespecified breaks

2009-02-16 Thread Christian Langkamp

Hello
I tried a few searches on hist, histogram, equidist and space (space=0 was
mentioned in one contribution), but none of that so far worked. It also says
in the help ##-- For non-equidistant breaks, counts should NOT be graphed
unscaled: - which is precisely what I am looking for, but I cannot find it.

I want to make a histogram using breaks which are spaced exponentially and
in reference to the largest item in the dataset
(e.g. 0,1,2,4,8,16 if the largest one is 14).
I want to make a histogram where the units on the axes have the same spacing
as the breaks used for the histogram. I could of course log the whole data
set, but then explaining that transformation within a presentation is
generally not a pleasant exercise. On the other hand I would like to keep
the code short and thus would like to avoid issues like factorisation.
Something like
x- breaks 
hist(data, breaks= x, xaxisbreaks=x)
At the moment the axis is equalspaced by units (2,4,6,8) with 0-2 having 2
areas and the blocks 4-6 and 6-8 only having one block. 

I tried also the xlog entry (i.e. log=x) which returned log is not valid
(ist kein Grafikparameter).
I tried also fixing things with the par utility (par(log=TRUE)) which again
did not work.

Hence if somebody has a recommendation (possibly a link to an older
contribution which I did not find using the above searches), that would be
great.
-- 
View this message in context: 
http://www.nabble.com/Adjusting-the-Axis-in-a-histogram-to-the-prespecified-breaks-tp22043635p22043635.html
Sent from the R help mailing list archive at Nabble.com.

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


Re: [R] Applying functions to partitions

2009-02-16 Thread Titus von der Malsburg
On Mon, Feb 16, 2009 at 01:45:52PM -0500, Stavros Macrakis wrote:
 How are the blocks defined? As a priori index ranges? By factors? By
 some property of i,j? Or...?

Ok, I should have been more specific.

The blocks are defined by factors.  There's a factor for the columns and
a factor for the rows.  In the example below the column factor would be
c(1,1,1,2,3,3) and the row factor c(1,1,1,2,2,3).  In the particular
case I'm working on the matrix is square and symmetric and there's only
one factor for both.

I can figure out ways to subset the matrix, similar to what Jorge
proposed, but I'm looking for a way to get the means more or less at
once because the matrix is pretty large and doing it block-wise is too
slow.

Thanks again!

 Titus


 On 2/16/09, Titus von der Malsburg malsb...@gmail.com wrote:
 
  Hi list!  I have a large matrix which I'd like to partition into blocks
  and for each block I'd like to compute the mean.  Following a example
  where each letter marks a block of the partition:
 
   a a a d g g
   a a a d g g
   a a a d g g
   b b b e h h
   b b b e h h
   c c c f i i
 
  I'm only interested in the resulting matrix of means.  How can this be
  done efficiently?
 
  Thanks!  Titus
 
  __
  R-help@r-project.org mailing list
  https://stat.ethz.ch/mailman/listinfo/r-help
  PLEASE do read the posting guide http://www.R-project.org/posting-guide.html
  and provide commented, minimal, self-contained, reproducible code.
 


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


Re: [R] Adjusting the Axis in a histogram to the prespecified breaks

2009-02-16 Thread Titus von der Malsburg
On Mon, Feb 16, 2009 at 11:08:24AM -0800, Christian Langkamp wrote:
 I could of course log the whole data
 set, but then explaining that transformation within a presentation is
 generally not a pleasant exercise.

You don't have to explain it.  Just calculate the hist of the log and
label the axis with 0, 1, 2, 4, 8, 16

See ?axis

  Titus

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


Re: [R] assuming AR(1) residuals in OLS

2009-02-16 Thread Prof Brian Ripley

You will need

library(nlme)

first.

But not for ?arima, which seems the more obvious way to do this simple 
example.


On Mon, 16 Feb 2009, Michael Kubovy wrote:


?gls

On Feb 16, 2009, at 12:28 PM, constantine wrote:


In other statistical software, such as Eviews, it is possible to
regress a model with the Least Squares method, assuming that the
residuals follow an AR(q) process.
For example the resulting regression is something like

y = 1.2154  + 0.2215 x + 0.251 AR(1)

How is it possible to do the same in R?


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



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

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


Re: [R] Alternate to for-loop

2009-02-16 Thread Wacek Kusnierczyk
Patrick Burns wrote:
 If the goal is to look professional, then
 'replicate' probably suits.  If the goal is to
 compute as fast as possible, then that isn't
 the case because 'replicate' is really a 'for'
 loop in disguise and there are other ways.

 Here's one other way:

 function (size, replicates, distfun, ...)
 {

colMeans(array(distfun(size * replicates, ...), c(size,
 replicates)))
 }

a naive benchmark:

f.rep = function(n, m) replicate(n, rnorm(m))
f.pat = function(n, m) colMeans(array(rnorm(n*m), c(n, m)))

system.time(f.pat(1000, 1000))
system.time(f.rep(1000, 1000))

makes me believe that there is no significant difference in efficiency
between the 'professionally-looking' replicate-based solution and the
'as fast as possible' pat's solution.

vQ

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


Re: [R] Applying functions to partitions

2009-02-16 Thread Charles C. Berry

On Mon, 16 Feb 2009, Titus von der Malsburg wrote:


On Mon, Feb 16, 2009 at 01:45:52PM -0500, Stavros Macrakis wrote:

How are the blocks defined? As a priori index ranges? By factors? By
some property of i,j? Or...?


Ok, I should have been more specific.

The blocks are defined by factors.  There's a factor for the columns and
a factor for the rows.  In the example below the column factor would be
c(1,1,1,2,3,3) and the row factor c(1,1,1,2,2,3).  In the particular
case I'm working on the matrix is square and symmetric and there's only
one factor for both.


If the number of factor levels is manageable and if as.numeric( 
your.factor ) orders the blocks properly something like this


mat - model.matrix( ~ 0 + your.factor )

tab - table( your.factor )

means - (t(mat) %*% your.block.matrix %*% mat) / outer( tab, tab )

Alternatively, use

means -
   sapply(split.data.frame(your.block.matrix,your.factor),function(x)
sapply(split(colMeans(x),your.factor),mean))


HTH,

Chuck



I can figure out ways to subset the matrix, similar to what Jorge
proposed, but I'm looking for a way to get the means more or less at
once because the matrix is pretty large and doing it block-wise is too
slow.

Thanks again!

Titus



On 2/16/09, Titus von der Malsburg malsb...@gmail.com wrote:


Hi list!  I have a large matrix which I'd like to partition into blocks
and for each block I'd like to compute the mean.  Following a example
where each letter marks a block of the partition:

 a a a d g g
 a a a d g g
 a a a d g g
 b b b e h h
 b b b e h h
 c c c f i i

I'm only interested in the resulting matrix of means.  How can this be
done efficiently?

Thanks!  Titus

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





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



Charles C. Berry(858) 534-2098
Dept of Family/Preventive Medicine
E mailto:cbe...@tajo.ucsd.edu   UC San Diego
http://famprevmed.ucsd.edu/faculty/cberry/  La Jolla, San Diego 92093-0901

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


Re: [R] superscript

2009-02-16 Thread David Douterlungne

David and Danel,
 
Indeed, the missing symbol is *. Now it works, although, with a change of 
font in the brackets of the axis=label. 
 
Thanks,
david
 
 

 To: daviddou...@hotmail.com
 Subject: Re: [R] superscript
 From: davidcr...@charter.net
 Date: Sat, 14 Feb 2009 17:49:11 -0600
 
 
 Could it be that the key expression should be something like:
 
 (gr/(0.25*m)^2)
 
 Cheers,
 David Cross
 
 
 David Douterlungne  writes:
 
 Dear R-users. 
 
 I'm struggeling to fix the superscript of a label of a figure axis. For some 
 reason R doesn't recognize the hat symbol. 
 
 
 plot(1,1,xlab=ligth intensity (PAR),ylab=expression(mass Pteridium 
 rhizomes (gr/0.25m^2)))
 
 
 A very similiar scriptline does not give any problem at all: 
 
 plot(1,1,xlab=expression(balsa plot basal area (m^2/ha)),ylab=light 
 intensity (PAR))
 
 
 Someone?
 _

 s. It's easy!

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

s. It's easy!

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


[R] rimage

2009-02-16 Thread Koen Hufkens
Hi list,

I'm trying to install/compile rimage on ubuntu linux (i386) interpid.
However, the compilation hangs on:

gcc -std=gnu99 -I/usr/share/R/include -g -O2   -fpic  -g -O2 -c
laplacian.c -o laplacian.o
laplacian.c: In function ‘laplacian’:
laplacian.c:14: warning: implicit declaration of function ‘clearFrame’
g++ -I/usr/share/R/include -g -O2   -fpic  -g -O2 -c matrix.cpp -o
matrix.o
/usr/include/c++/4.3/bits/stl_vector.h: In member function ‘void
std::vector_Tp, _Alloc::_M_initialize_dispatch(_Integer, _Integer,
std::__true_type) [with _Integer = int, _Tp = std::vectordouble,
std::allocatordouble , _Alloc = std::allocatorstd::vectordouble,
std::allocatordouble  ]’:
/usr/include/c++/4.3/bits/stl_vector.h:290:   instantiated from
‘std::vector_Tp, _Alloc::vector(_InputIterator, _InputIterator, const
_Alloc) [with _InputIterator = int, _Tp = std::vectordouble,
std::allocatordouble , _Alloc = std::allocatorstd::vectordouble,
std::allocatordouble  ]’

has anyone encountered problems to compile the module and found a
solution. I can't found a solution online, only some reference to gcc
4.3 not being compatible.

Any pointers would be appreciated.

Kind regards,
Koen

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


Re: [R] Applying functions to partitions

2009-02-16 Thread Stavros Macrakis
Assuming your matrix is:

mm - matrix(runif(6*6),6,6)

And your blocks are defined by integers or factors:

   cfact - c(1,1,1,2,3,3)
   rfact - c(1,1,1,2,2,3)

Then the following should do the trick:

   matrix(tapply(mm, outer(rfact,cfact,paste), mean),
  length(unique(rfact)))

The 'outer' calculates a joint factor for each element of the matrix; the
'tapply' treats the matrix as a vector, grouping by factor and calculating
means; the 'matrix' rearranges them as a matrix corresponding to the
original block structure.

Is that what you had in mind?

  -s


On Mon, Feb 16, 2009 at 12:43 PM, Titus von der Malsburg malsb...@gmail.com
 wrote:


 Hi list!  I have a large matrix which I'd like to partition into blocks
 and for each block I'd like to compute the mean.  Following a example
 where each letter marks a block of the partition:

 a a a d g g
 a a a d g g
 a a a d g g
 b b b e h h
 b b b e h h
 c c c f i i

 I'm only interested in the resulting matrix of means.  How can this be
 done efficiently?

 Thanks!  Titus

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


[[alternative HTML version deleted]]

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


Re: [R] Applying functions to partitions

2009-02-16 Thread David Winsemius
Its not clear that the object returned from such an operation would be  
a matrix, but if things remain very regular then perhapos you will  
succeed with this:


 markmtx - matrix(scan(textConnection(a a a d g g
+ a a a d g g
+ a a a d g g
+ b b b e h h
+ b b b e h h
+ c c c f i i), what=character), nrow=6)
Read 36 items
 nummtx -matrix(rnorm(36),nrow=6)
 nummtx
[,1]   [,2][,3] [,4]   [,5]
[,6]
[1,] -1.49492952 -0.1000962 -0.54546587 -0.536216056  0.1065169  
-1.3368842
[2,] -0.64393278  0.3343573  0.76247880  0.282666215  0.2236401   
0.8210809
[3,]  1.42879752 -1.3246770  0.06403316 -0.002843621 -0.2990221  
-0.4885461
[4,] -0.38740975  0.7800235  0.12819144  0.206188106  0.8481351   
0.2572268
[5,] -0.07082702 -0.7870970  0.60560030 -1.381615740  1.4935228   
0.1165892
[6,] -0.06916424 -0.5869168  0.39492984  0.016430970 -0.6531722  
-0.1194990


 tapply(nummtx, markmtx, FUN=mean)
   abcd 
efg
-0.168826070 -0.037543099 -0.334783145  0.173601720  0.527161589   
0.257226798 -0.085579151

   hi
-0.131208561 -0.001454904

 matrix(tapply(nummtx, markmtx, FUN=mean), nrow=3)
   [,1]  [,2] [,3]
[1,] -0.1688261 0.1736017 -0.085579151
[2,] -0.0375431 0.5271616 -0.131208561
[3,] -0.3347831 0.2572268 -0.001454904

--
David Winsemius

On Feb 16, 2009, at 12:43 PM, Titus von der Malsburg wrote:



Hi list!  I have a large matrix which I'd like to partition into  
blocks

and for each block I'd like to compute the mean.  Following a example
where each letter marks a block of the partition:

a a a d g g
a a a d g g
a a a d g g
b b b e h h
b b b e h h
c c c f i i

I'm only interested in the resulting matrix of means.  How can this be
done efficiently?

Thanks!  Titus

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


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


Re: [R] Ideal (possible) configuration for an exalted R system

2009-02-16 Thread Kingsford Jones
Hi Harsh,

The useR! 2008 site has useful information.  E.g. talks by

Graham Williams:

http://www.statistik.uni-dortmund.de/useR-2008/slides/Williams.pdf

Dirk Eddelbuettel

http://www.statistik.uni-dortmund.de/useR-2008/tutorials/useR2008introhighperfR.pdf

and others

http://www.statistik.uni-dortmund.de/useR-2008/abstracts/AbstractsByTopic.html#High%20Performance%20Computing



A few days ago I was googling to see what types of workstations are
available these days.  Here's some with up to 64gb ram:

http://www.colfax-intl.com/jlrid/SpotLight.asp?IT=0RID=80

Perhaps it won't be long before we see such memory in laptops:

http://www.ubergizmo.com/15/archives/2009/01/samsung_opens_door_to_32gb_ram_stick.html

Like you, I'd also be interested in hearing about configurations folks
have used to work w/ large datasets.


hth,

Kingsford Jones







On Mon, Feb 16, 2009 at 5:10 AM, Harsh singhal...@gmail.com wrote:
 Hi All,
 I am trying to assemble a system that will allow me to work with large
 datasets (45-50 million rows, 300-400 columns) possibly amounting to
 10GB + in size.

 I am aware that R 64 bit implementations on Linux boxes are suitable
 for such an exercise but I am looking for configurations that R users
 out there may have used in creating a high-end R system.
 Due to a lot of apprehensions that SAS users have about R's data
 limitations, I want to demonstrate R's usability even with very large
 datasets as mentioned above.
 I would be glad to hear from users(share configurations and system
 specific information) who have desktops/servers on which they use R to
 crunch massive datasets.


 Any suggestions in expanding R's functionality in the face of gigabyte
 class datasets would be appreciated.

 Thanks
 Harsh Singhal
 Decision Systems,
 Mu Sigma Inc.
 Chicago, IL

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


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


Re: [R] Alternate to for-loop

2009-02-16 Thread Patrick Burns

Wacek Kusnierczyk wrote:

Patrick Burns wrote:
  

If the goal is to look professional, then
'replicate' probably suits.  If the goal is to
compute as fast as possible, then that isn't
the case because 'replicate' is really a 'for'
loop in disguise and there are other ways.

Here's one other way:

function (size, replicates, distfun, ...)
{

   colMeans(array(distfun(size * replicates, ...), c(size,
replicates)))
}



a naive benchmark:

f.rep = function(n, m) replicate(n, rnorm(m))
f.pat = function(n, m) colMeans(array(rnorm(n*m), c(n, m)))

system.time(f.pat(1000, 1000))
system.time(f.rep(1000, 1000))

makes me believe that there is no significant difference in efficiency
between the 'professionally-looking' replicate-based solution and the
'as fast as possible' pat's solution.
  


I think Wacek is largely correct.  First off, a correction:
the dimensions on the array if 'f.pat' should be c(m, n)
rather than c(n, m).

What I'm seeing on my machine is that the array trick seems
always to be a bit faster, but only substantially faster if 'm'
(that is, the number being summed) is smallish.

That makes sense: loops are slow because of the overhead
of doing the calling.  When each call takes a lot of time,
the overhead becomes insignificant.


Patrick Burns
patr...@burns-stat.com
+44 (0)20 8525 0696
http://www.burns-stat.com
(home of The R Inferno and A Guide for the Unwilling S User)

vQ






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


Re: [R] rimage

2009-02-16 Thread Dirk Eddelbuettel

On 16 February 2009 at 21:09, Koen Hufkens wrote:
| Hi list,
| 
| I'm trying to install/compile rimage on ubuntu linux (i386) interpid.
| However, the compilation hangs on:
| 
| gcc -std=gnu99 -I/usr/share/R/include -g -O2   -fpic  -g -O2 -c
| laplacian.c -o laplacian.o
| laplacian.c: In function  laplacian :
| laplacian.c:14: warning: implicit declaration of function  clearFrame 
| g++ -I/usr/share/R/include -g -O2   -fpic  -g -O2 -c matrix.cpp -o
| matrix.o
| /usr/include/c++/4.3/bits/stl_vector.h: In member function  void
| std::vector_Tp, _Alloc::_M_initialize_dispatch(_Integer, _Integer,
| std::__true_type) [with _Integer = int, _Tp = std::vectordouble,
| std::allocatordouble , _Alloc = std::allocatorstd::vectordouble,
| std::allocatordouble  ] :
| /usr/include/c++/4.3/bits/stl_vector.h:290:   instantiated from
|  std::vector_Tp, _Alloc::vector(_InputIterator, _InputIterator, const
| _Alloc) [with _InputIterator = int, _Tp = std::vectordouble,
| std::allocatordouble , _Alloc = std::allocatorstd::vectordouble,
| std::allocatordouble  ] 
| 
| has anyone encountered problems to compile the module and found a
| solution. I can't found a solution online, only some reference to gcc
| 4.3 not being compatible.
| 
| Any pointers would be appreciated.

It's as I said in the email at

http://tolstoy.newcastle.edu.au/R/e6/help/09/01/1379.html

i.e. the form used in

m = new vector vector double (x, y); 

is no longer valid for g++ 4.3.

Someone (you ?) needs to adapt the code, or it'll sooner or later disappear
from CRAN.

Dirk

-- 
Three out of two people have difficulties with fractions.

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


Re: [R] Printing out a graph using different graphics devices

2009-02-16 Thread Greg Snow
You might want to look at the dev.copy function.  I just tried with your 
example and the postscript device, used the print(plot) command with the 
postscript device open, then switched to the windows graphics device and did 
dev.copy then closed the postscript file, the result had 2 pages, the first 
like you described looked different from the screen, the 2nd (from dev.copy) 
had the same colors and general appearance (I did not compare super closely) as 
the plot on the screen.

Hope this helps,

-- 
Gregory (Greg) L. Snow Ph.D.
Statistical Data Center
Intermountain Healthcare
greg.s...@imail.org
801.408.8111


 -Original Message-
 From: r-help-boun...@r-project.org [mailto:r-help-boun...@r-
 project.org] On Behalf Of Dimitri Liakhovitski
 Sent: Monday, February 16, 2009 10:14 AM
 To: R-Help List
 Subject: [R] Printing out a graph using different graphics devices
 
 Hello, everyone!
 The code below allows me to produce the graph I want (I know - the
 colors are strange, but it's just for the sake of an example).
 After you run the plot- part and then do print(plot) - that's what I
 want.
 However, when I run the bits of code below (with graphics devices) -
 what they print is different from the original plot. In .png, .emf,
 and .tiff - my dots change their shape and my lines (I think) become
 thinner. And in .ps format - the dots stay what they are supposed to
 be but they change their color.
 Could you please explain to me what the reasons are for those changes?
 Also - should I specify my chart characteristics differently depending
 on the device I'll be using?
 Thank you very much!
 Dimitri
 
 library(lattice)
 d=data.frame(xx=c(2.2,2.1,3.3),yy=c(0.1,0.2,0.3),zz=c(2.5,2.0,1.8))
 d[[2]]-as.factor(as.numeric((d[[2]])))
 
 trellis.par.set(superpose.line = list(col=c(green,red), lwd = 2),
superpose.symbol = list(col=c(yellow,blue),cex =
 1.3, pch = 20),
reference.line = list(col = gray, lty =dotted))
 
 plot-dotplot(c(d[[1]],d[[3]])~rep(d[[2]],2),
groups=rep(c(Group 1,Group 2), each=nrow(d)),
main=list(Chart Title,cex=1),
 
type=b,
auto.key = list(space = top, points = TRUE, lines = TRUE),
 
xlab=list(Title for X,cex=.9,font=2),
ylab=list(Title for Y,cex=.9,font=2),
 
panel = function(y,x,...) {
panel.grid(h = -1, v = -1)
panel.xyplot(x, y, ...)
 
ltext(x, y, labels=round(y,3),
  cex=.8,col=black,font=2,
  adj=c(-0.2,1))
 
})
 print(plot)
 
 win.metafile(file=test.emf)
 print(plot)
 dev.off()
 
 postscript(file=test.ps)
 print(plot)
 dev.off()
 
 png(file=test.png)
 print(plot)
 dev.off()
 
 tiff(file=test.tiff)
 print(plot)
 dev.off()
 
 --
 Dimitri Liakhovitski
 MarketTools, Inc.
 dimitri.liakhovit...@markettools.com
 
 __
 R-help@r-project.org mailing list
 https://stat.ethz.ch/mailman/listinfo/r-help
 PLEASE do read the posting guide http://www.R-project.org/posting-
 guide.html
 and provide commented, minimal, self-contained, reproducible code.

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


[R] problem of local ! :-(

2009-02-16 Thread Suresh_FSFM

Dear R- Experts,

Seek your help.

I created a time sequence using:
x[i] -chron(dates, tt, format=c(dates=y-m-d, tt=h:m:s))
first element in the list is displayed as: (09-01-01 00:00:00) 

Now, I want to store this value as date.
If I use: format.Date(x[1],%y-%m-%d %H:%M:%S), I expect following value:
09-01-01 00:00:00

HOWEVER, the value displayed as: 09-01-01 01:00:00

I want to create time sequence starting from 00:00:00 !!!

I realized that this is due to my local setting. I have GMT+1:00 setting.
However, I do not want my local settings to affect my time sequence.
Can someone please suggest me the solution?
Note: 
I do not want to change my local settings before I start R. Because that is
not practical.






-- 
View this message in context: 
http://www.nabble.com/problem-of-%22local%22-%21-%3A-%28-tp22045861p22045861.html
Sent from the R help mailing list archive at Nabble.com.

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


Re: [R] Comparison of age categories using contrasts

2009-02-16 Thread Greg Snow
One approach is to create your own contrasts matrix:

 mycmat - diag(8)
 mycmat[ row(mycmat) == col(mycmat) + 1 ] - -1
 mycmati - solve(mycmat)
 contrasts(agefactor) - mycmati[,-1]

Now when you use agefactor, the intercept will be the first age group and the 
slopes will be the differences between the pairs of groups (make sure that the 
order of the levels of agefactor is correct).

The difference between this method and the contr.sdif function in MASS is how 
the intercept will end up being interpreted (and the dimnames).

Hope this helps,

-- 
Gregory (Greg) L. Snow Ph.D.
Statistical Data Center
Intermountain Healthcare
greg.s...@imail.org
801.408.8111


 -Original Message-
 From: r-help-boun...@r-project.org [mailto:r-help-boun...@r-
 project.org] On Behalf Of Patrick Giraudoux
 Sent: Sunday, February 15, 2009 9:23 PM
 To: r-h...@stat.math.ethz.ch
 Subject: [R] Comparison of age categories using contrasts
 
 Dear listers,
 
 I would like to compare the levels of a factor with 8 age categories
 (0,10] (10,20] (20,30] (30,40] (40,50] (50,60] (60,70] (70,90]
 (however,
 the factor has not been ordered yet). The default in glm is
 cont.treatment (for unordered factors) and that leads to compare each
 level to the first one. I would rather prefer to compare the 2nd to the
 1st, the 3rd to the 2nd, the 4th to the 3rd, etc... My understanding is
 that cont.poly may make the trick, eg specified like this:
 
 mod3-glm(AE~agecat, family=binomial,data=qinghai2,
 contrasts=list(agecat=contr.poly))
 
 but I am not sure to be right.
 
 Would be grateful if a true statistician can confirm or fire me... and
 before definitive fire tell me how to manage with this...
 
 __
 R-help@r-project.org mailing list
 https://stat.ethz.ch/mailman/listinfo/r-help
 PLEASE do read the posting guide http://www.R-project.org/posting-
 guide.html
 and provide commented, minimal, self-contained, reproducible code.

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


Re: [R] Applying functions to partitions

2009-02-16 Thread Martin Morgan
Stavros Macrakis macra...@alum.mit.edu writes:

 Assuming your matrix is:

 mm - matrix(runif(6*6),6,6)

 And your blocks are defined by integers or factors:

cfact - c(1,1,1,2,3,3)
rfact - c(1,1,1,2,2,3)

 Then the following should do the trick:

matrix(tapply(mm, outer(rfact,cfact,paste), mean),
   length(unique(rfact)))

or the variant

  idx - outer(rfact, (cfact - 1) * max(rfact), +)
  matrix(tapply(m, idx, mean), max(rfact))

The assumption is that cfact, rfact are integer valued with max(rfact)
= nrow(m), max(cfact) = ncol(m).

I think Stavros' solution will run in to trouble when there are more
than 9 row blocks, and '10 1' sorts before '2 1', for instance.

Martin


 The 'outer' calculates a joint factor for each element of the matrix; the
 'tapply' treats the matrix as a vector, grouping by factor and calculating
 means; the 'matrix' rearranges them as a matrix corresponding to the
 original block structure.

 Is that what you had in mind?

   -s


 On Mon, Feb 16, 2009 at 12:43 PM, Titus von der Malsburg malsb...@gmail.com
 wrote:


 Hi list!  I have a large matrix which I'd like to partition into blocks
 and for each block I'd like to compute the mean.  Following a example
 where each letter marks a block of the partition:

 a a a d g g
 a a a d g g
 a a a d g g
 b b b e h h
 b b b e h h
 c c c f i i

 I'm only interested in the resulting matrix of means.  How can this be
 done efficiently?

 Thanks!  Titus

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


   [[alternative HTML version deleted]]

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

-- 
Martin Morgan
Computational Biology / Fred Hutchinson Cancer Research Center
1100 Fairview Ave. N.
PO Box 19024 Seattle, WA 98109

Location: Arnold Building M2 B169
Phone: (206) 667-2793

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


Re: [R] rimage

2009-02-16 Thread Hufkens Koen
I would love to fix it however my C++ skills are limited.

Hope someone fixes this before it disappears.

Koen
-Original Message-
From: Dirk Eddelbuettel [mailto:e...@debian.org]
Sent: Mon 16-2-2009 21:49
To: Hufkens Koen
Cc: r-help@r-project.org
Subject: Re: [R] rimage
 

On 16 February 2009 at 21:09, Koen Hufkens wrote:
| Hi list,
| 
| I'm trying to install/compile rimage on ubuntu linux (i386) interpid.
| However, the compilation hangs on:
| 
| gcc -std=gnu99 -I/usr/share/R/include -g -O2   -fpic  -g -O2 -c
| laplacian.c -o laplacian.o
| laplacian.c: In function  laplacian :
| laplacian.c:14: warning: implicit declaration of function  clearFrame 
| g++ -I/usr/share/R/include -g -O2   -fpic  -g -O2 -c matrix.cpp -o
| matrix.o
| /usr/include/c++/4.3/bits/stl_vector.h: In member function  void
| std::vector_Tp, _Alloc::_M_initialize_dispatch(_Integer, _Integer,
| std::__true_type) [with _Integer = int, _Tp = std::vectordouble,
| std::allocatordouble , _Alloc = std::allocatorstd::vectordouble,
| std::allocatordouble  ] :
| /usr/include/c++/4.3/bits/stl_vector.h:290:   instantiated from
|  std::vector_Tp, _Alloc::vector(_InputIterator, _InputIterator, const
| _Alloc) [with _InputIterator = int, _Tp = std::vectordouble,
| std::allocatordouble , _Alloc = std::allocatorstd::vectordouble,
| std::allocatordouble  ] 
| 
| has anyone encountered problems to compile the module and found a
| solution. I can't found a solution online, only some reference to gcc
| 4.3 not being compatible.
| 
| Any pointers would be appreciated.

It's as I said in the email at

http://tolstoy.newcastle.edu.au/R/e6/help/09/01/1379.html

i.e. the form used in

m = new vector vector double (x, y); 

is no longer valid for g++ 4.3.

Someone (you ?) needs to adapt the code, or it'll sooner or later disappear
from CRAN.

Dirk

-- 
Three out of two people have difficulties with fractions.


[[alternative HTML version deleted]]

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


[R] incl.non.slopes=FALSE does not work at predict.lm

2009-02-16 Thread dimitris kapetanakis

Dear all,

I am trying to estimate the prediction from a fixed effects model and their
confidence intervals as well. Though I do not want to include in the
prediction and at the confidence intervals the intercept. For that reason I
used the argument incl.non.slopes=FALSE. But either if it is TRUE or FALSE
it does not have any difference and also the system does not provide any
warning. I really cannot understand what is happening and I use both predict
and predict.lm but there is no difference.

Explicitly the code is:

fe.nox - lm(nox~ state.1  + state.2  + state.3  + state.4  + state.5  +
state.6  + state.7  + state.8  + state.9 + time.1   + time.2   + time.3   +
time.4   + time.5   + time.6   + time.7  + pcinc + I(pcinc^2) + I(pcinc^3),
data=ekc)

p.fe.nox-predict.lm(fe.nox, new, interval = prediction, level=0.95,
incl.non.slopes=FALSE) 

Any Help would be highly appreciated 

Thanks

Dimitris
-- 
View this message in context: 
http://www.nabble.com/incl.non.slopes%3DFALSE-does-not-work-at-predict.lm-tp22046749p22046749.html
Sent from the R help mailing list archive at Nabble.com.

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


Re: [R] incl.non.slopes=FALSE does not work at predict.lm

2009-02-16 Thread Rolf Turner


On 17/02/2009, at 10:54 AM, dimitris kapetanakis wrote:



Dear all,

I am trying to estimate the prediction from a fixed effects model  
and their

confidence intervals as well. Though I do not want to include in the
prediction and at the confidence intervals the intercept. For that  
reason I
used the argument incl.non.slopes=FALSE. But either if it is TRUE  
or FALSE
it does not have any difference and also the system does not  
provide any
warning. I really cannot understand what is happening and I use  
both predict

and predict.lm but there is no difference.

Explicitly the code is:

fe.nox - lm(nox~ state.1  + state.2  + state.3  + state.4  + state. 
5  +
state.6  + state.7  + state.8  + state.9 + time.1   + time.2   +  
time.3   +
time.4   + time.5   + time.6   + time.7  + pcinc + I(pcinc^2) + I 
(pcinc^3),

data=ekc)

p.fe.nox-predict.lm(fe.nox, new, interval = prediction, level=0.95,
incl.non.slopes=FALSE)

Any Help would be highly appreciated


Where do you get a predict.lm() function that has an argument
``incl.non.slopes''???  Neither the help file nor
args(predict.lm) reveal any trace of such an argument.

You must be using a modified version of this function.  So check
with whomever you got it from as to why this argument is not having
the effect you expect.  It is not at all clear to me what you *do*
expect.  Are you trying, artificially, to set the intercept to 0
before predicting?  Why would you want to do that?

Of course you don't get any difference between predict() and  
predict.lm().

The predict() function is generic, and fe.nox is of class lm so the
method predict.lm() will be used.

I'm sure your data could be structured so that your model could be
written with much less verbosity.

cheers,

Rolf Turner

##
Attention:\ This e-mail message is privileged and confid...{{dropped:9}}

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


Re: [R] problem of local ! :-(

2009-02-16 Thread Gabor Grothendieck
The Date class does not work with times and neither it nor
the chron dates and times classes use time zones so
that cannot be the problem if you are using those classes.
Much of this is discussed in R News 4/1.

On Mon, Feb 16, 2009 at 4:05 PM, Suresh_FSFM suresh.ghals...@gmail.com wrote:

 Dear R- Experts,

 Seek your help.

 I created a time sequence using:
 x[i] -chron(dates, tt, format=c(dates=y-m-d, tt=h:m:s))
 first element in the list is displayed as: (09-01-01 00:00:00)

 Now, I want to store this value as date.
 If I use: format.Date(x[1],%y-%m-%d %H:%M:%S), I expect following value:
 09-01-01 00:00:00

 HOWEVER, the value displayed as: 09-01-01 01:00:00

 I want to create time sequence starting from 00:00:00 !!!

 I realized that this is due to my local setting. I have GMT+1:00 setting.
 However, I do not want my local settings to affect my time sequence.
 Can someone please suggest me the solution?
 Note:
 I do not want to change my local settings before I start R. Because that is
 not practical.






 --
 View this message in context: 
 http://www.nabble.com/problem-of-%22local%22-%21-%3A-%28-tp22045861p22045861.html
 Sent from the R help mailing list archive at Nabble.com.

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


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


Re: [R] controlling number of decimals printed in anova tables?

2009-02-16 Thread Michael Friendly

Thanks, Gabor
No, that wasn't it at all.  In print.anova, I found:

   if (length(i - grep(Df$, cn)))
   zap.i - zap.i[!(zap.i %in% i)]

so it only recognizes Df, not df as a column name prefix to print as 
integers.

-Michael

Gabor Grothendieck wrote:

Or safer:

df - as.integer(round(...))

On Mon, Feb 16, 2009 at 10:54 AM, Gabor Grothendieck
ggrothendi...@gmail.com wrote:
  

Try this:

On Mon, Feb 16, 2009 at 9:02 AM, Michael Friendly frien...@yorku.ca wrote:


For glm() models, I often find both the print() and summary() method
disappointing if my main interest
is seeing how well a given model fits. A basic display would just compare
the null model to to my model.

I wrote the function below based on code in some package.
How can I make it so that the df in the table are printed with 0 decimals?
  

Try this:
df - as.integer(c(x$df.null, x$df.residual))





--
Michael Friendly Email: friendly AT yorku DOT ca 
Professor, Psychology Dept.

York University  Voice: 416 736-5115 x66249 Fax: 416 736-5814
4700 Keele Streethttp://www.math.yorku.ca/SCS/friendly.html
Toronto, ONT  M3J 1P3 CANADA

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


Re: [R] Alternate to for-loop

2009-02-16 Thread Stefan Evert

A couple of remarks on vQ's naive benchmark:


f.rep = function(n, m) replicate(n, rnorm(m))


I suppose you meant

f.rep = function(n, m) replicate(n, mean(rnorm(m)))

which doesn't make a substantial speed difference, though.



f.pat = function(n, m) colMeans(array(rnorm(n*m), c(n, m)))

system.time(f.pat(1000, 1000))
system.time(f.rep(1000, 1000))

makes me believe that there is no significant difference in efficiency
between the 'professionally-looking' replicate-based solution and the
'as fast as possible' pat's solution.



True, I get the same timing results on my machine.  But then you  
should also point out that the original for-loop:


	f.for = function(n, m) { res - numeric(n); for (i in 1:n) res[i] -  
mean(rnorm(m)); res }


is exactly as fast as replicate().  So apart from looking more  
professional, there isn't any difference between an explicit loop and  
replicate().


Perhaps loops in R aren't always as slow (compared to matrix  
operations) as one seemed to think.  I ran into a similar issue with a  
simple benchmark the other day, where a plain loop in Lua was faster  
than vectorised code in R ...



I have to say, though, that like Patrick I assumed the goal was to  
obtain a large number of replicates for relatively small sets of  
random numbers, in which case the matrix solution is indeed faster  
(though not as much as I would have thought):


 system.time(f.for(10, 100))
   user  system elapsed
  4.212   0.025   4.273
 system.time(f.rep(10, 100))
   user  system elapsed
  4.109   0.028   4.172
 system.time(f.pat(10, 100))
   user  system elapsed
  1.580   0.134   1.739


Best regards,
Stefan Evert

[ stefan.ev...@uos.de | http://purl.org/stefan.evert ]


PS: Don't feed trolls who say that Lua is better than R. ;-)

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


[R] Problems with labeling a set X axis in chron plots

2009-02-16 Thread Neotropical bat risk assessments
I am having difficulties getting the X-axis labels (dates) to be as 
needed when plotting from chron


The help syntax from chron lists this example:

x - chron(dates = c(02/27/92, 02/27/92, 01/14/92, 02/28/92),


I have activity plots by time on the y-axis and the dates on the 
x-axis. What I need/want is that the dates remain the same for a give 
set of data i.e. 10/25/2006 to 03/30/2007 as with some data sets 
within this time frame there is no activity for all of the dates so 
each plot has a different set of dates.



Below works great but when I try to constrain the dates it crashes...

DF - read.table(textConnection(Lines), header = TRUE, as.is = TRUE)
DF$Date - chron(DF$Date)
DF$Time - times(paste(DF$Time, 0, sep = :))
at - c(0, 1, 2, 3, 4, 5, 6, 17, 18, 19, 20, 21, 22, 23, 24)
plot(Time ~ Date, DF, ylim = 0:1, yaxt = n,main= Centronycteris centralis)
axis(2, at/24, lab = paste(at, 00, sep = :), las = 1, cex.axis = .7)

Thanks to all here on the group,

Bruce Miller

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


Re: [R] Applying functions to partitions

2009-02-16 Thread Stavros Macrakis
On Mon, Feb 16, 2009 at 4:23 PM, Martin Morgan mtmor...@fhcrc.org wrote:

 Stavros Macrakis macra...@alum.mit.edu writes:
 matrix(tapply(mm, outer(rfact,cfact,paste), mean),
length(unique(rfact)))

 or the variant

  idx - outer(rfact, (cfact - 1) * max(rfact), +)
  matrix(tapply(m, idx, mean), max(rfact))

 The assumption is that cfact, rfact are integer valued with max(rfact)
 = nrow(m), max(cfact) = ncol(m).

 I think Stavros' solution will run in to trouble when there are more
 than 9 row blocks, and '10 1' sorts before '2 1', for instance.


Quite so!  Thank you for the correction, and sorry for the sloppy
programming -- using outer/paste like that is indeed a dirty hack.

I suppose the clean way to do this would be to define a cartesian product of
two factors with the induced lexicographic order (is there a standard
function for doing this?):

   `*.factor` - function(f1,f2)
   factor(  t(outer(f1,f2,paste)),
levels=t(outer(unique(f1),unique(f2),paste)),
ordered=TRUE)

and then I think this will work for arbitrary factors rfact and cfact:

matrix(tapply(mm, rfact*cfact, mean),
 length(unique(rfact)))

This allows arbitrary factors, and preserves their input order. Or have I
made another foolish mistake?

   -s

[[alternative HTML version deleted]]

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


Re: [R] Applying functions to partitions

2009-02-16 Thread Bert Gunter
... 

I suppose the clean way to do this would be to define a cartesian product of
two factors with the induced lexicographic order (is there a standard
function for doing this?):


Of course. ?interaction.

-- Bert Gunter
Genentch

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


Re: [R] Problems with labeling a set X axis in chron plots

2009-02-16 Thread David Winsemius


On Feb 16, 2009, at 6:11 PM, Neotropical bat risk assessments wrote:

I am having difficulties getting the X-axis labels (dates) to be as  
needed when plotting from chron


The help syntax from chron lists this example:

x - chron(dates = c(02/27/92, 02/27/92, 01/14/92, 02/28/92),


On my machine I'm reasonably sure the R interpreter would respond to  
that input with a new line and a +.




I have activity plots by time on the y-axis and the dates on the x- 
axis. What I need/want is that the dates remain the same for a give  
set of data i.e. 10/25/2006 to 03/30/2007 as with some data sets  
within this time frame there is no activity for all of the dates so  
each plot has a different set of dates.


The actual code would be sooo helpful here.





Below works great but when I try to constrain the dates it crashes...


Constrain the dates means  ... what?

And it seems very doubtful that the error message was anything like I  
crashed.


Sign me perplexed;
David Winsemius




DF - read.table(textConnection(Lines), header = TRUE, as.is = TRUE)
DF$Date - chron(DF$Date)
DF$Time - times(paste(DF$Time, 0, sep = :))
at - c(0, 1, 2, 3, 4, 5, 6, 17, 18, 19, 20, 21, 22, 23, 24)
plot(Time ~ Date, DF, ylim = 0:1, yaxt = n,main= Centronycteris  
centralis)
axis(2, at/24, lab = paste(at, 00, sep = :), las = 1, cex.axis  
= .7)


Thanks to all here on the group,

Bruce Miller

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


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


[R] Time series prediction

2009-02-16 Thread dan ben moshe
I am trying to predict time series.  I have several samples which
consist of measurement of 4 different variables over different
time periods, and other measurements over subsequent time
periods which I believe is predicted by the 4 variables.
I am thinking of using cluster analysis, to confirm that
there is a basis for my belief.  I therefore need to compare
samples of different lengths, to find the distance between them.
I am asking for suggestions on how to compute a distance
between my samples.
I have thought of using the R time series function spectrum on 
each sample, and comparing the spectrum differences using
the ks test function.
I have also thought of using the dtw package to determine a
difference.  I could also interpolate so each sample is the same
length, and use shape matching.
I would also like to use either regression or a neural network to
try to predict my measurements.  Is anyone aware of prediction
methods which would not require all my samples to be the same
length or how I might deal with different length samples?
Thank you,

Dan



  
[[alternative HTML version deleted]]

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


Re: [R] PDF append help

2009-02-16 Thread somewhereondearth

Hi,
I need to append my multiple plots in pdf files. 
my problem is that I would want to run the R script a number times(closing
and opening) and still want to append. If i keep the dev.off() it wouldnt
let me see my plots while R is open.

any idea!!

Jorge Ivan Velez wrote:
 
 Hi Ramya,
 
 Perhaps
 
 pdf(C:/100plots.pdf)
 for(i in 1:100) plot(rnorm(10), type='b', main='My 100 plots')
 dev.off()
 
 HTH,
 
 Jorge
 
 
 On Tue, Aug 5, 2008 at 12:41 PM, Rajasekaramya
 ramya.vict...@gmail.comwrote:
 

 hi there,

 Is there any function to append the pdf file.

 I want to write in a pdf file some 100 plots(in one single pdf containing
 100 plots) while all the plot are created using a for loop.

 I can create 100 pdf one for each for each plot using a for loop but i
 want
 only one pdf with 100 plots.

 Ramya
 --
 View this message in context:
 http://www.nabble.com/PDF-append-help-tp18835069p18835069.html
 Sent from the R help mailing list archive at Nabble.com.

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

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

-- 
View this message in context: 
http://www.nabble.com/PDF-append-help-tp18835069p22042954.html
Sent from the R help mailing list archive at Nabble.com.

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


[R] Problems with labeling a set X axis in chron plots

2009-02-16 Thread B. Miller
I am having difficulties getting the X-axis labels (dates) to be as 
needed when plotting from chron


The help syntax from chron lists this example:
x - chron(dates = c(02/27/92, 02/27/92, 01/14/92, 02/28/92),

I have activity plots by time on the y-axis and the dates on the 
x-axis.  What I need/want is that the dates remain the same for a 
give set of data i.e. 10/25/2006 to 03/30/2007 as with some data sets 
within this time frame there is no activity for all of the dates so 
each plot has a different set of dates.



Below  works great but when I try to constrain the dates it crashes...

DF - read.table(textConnection(Lines), header = TRUE, as.is = TRUE)
DF$Date - chron(DF$Date)
DF$Time - times(paste(DF$Time, 0, sep = :))
at - c(0, 1, 2, 3, 4, 5, 6, 17, 18, 19, 20, 21, 22, 23, 24)
plot(Time ~ Date, DF, ylim = 0:1, yaxt = n,main= Centronycteris centralis)
axis(2, at/24, lab = paste(at, 00, sep = :), las = 1, cex.axis = .7)

Thanks to all here on the group,

Bruce Miller

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


  1   2   >