Re: [R] SAS and R complement each other

2013-03-03 Thread Frank Harrell
I'm not sure why you posted the original note. I quit using SAS in 1991 and haven't needed it yet. Frank RogerJDeAngelis wrote > Sorry about the double post. But I keep getting 'post' rejections, so I > resubmitted about an hour later. - Frank Harrell Department of Biostatistics, Vanderb

Re: [R] Help searching a matrix for only certain records

2013-03-03 Thread Matt Borkowski
I appreciate all the feedback on this. I ended up using this line to solve my problem, just because I stumbled upon it first... > alldata <- alldata[alldata$REC.TYPE == "SAO  " | alldata$REC.TYPE == > "FM-15",,drop=FALSE] But I think Jim's solution would work equally as well. I was a bit confus

Re: [R] Empirical Bayes Estimator for Poisson-Gamma Parameters

2013-03-03 Thread Nicole Ford
Did you try using MLE to approximate the marginal? On Mar 3, 2013, at 5:26 AM, Ali A. Bromideh wrote: > Dear Nicole, > > First of all, my sincere gratitude goes to your kind reply. As I told to Mr. > Gunter, this is a part of my research and differs from homework. However, I > am going to cla

Re: [R] Creating 3d partial dependence plots

2013-03-03 Thread Duncan Murdoch
On 13-03-03 7:08 PM, Jerrod Parker wrote: Help, I've been having a difficult time trying to create 3d partial dependence plots using "rgl". It looks like this question has been asked a couple times, but I'm unable to find a clear answer googling. I've tried creating x, y, and z variables by ex

[R] Creating 3d partial dependence plots

2013-03-03 Thread Jerrod Parker
Help, I've been having a difficult time trying to create 3d partial dependence plots using "rgl". It looks like this question has been asked a couple times, but I'm unable to find a clear answer googling. I've tried creating x, y, and z variables by extracting them from the partialPlot output to

Re: [R] caret pls model statistics

2013-03-03 Thread Max Kuhn
That the most common formula, but not the only one. See Kvålseth, T. (1985). Cautionary note about $R^2$. *American Statistician*, *39*(4), 279–285. Traditionally, the symbol 'R' is used for the Pearson correlation coefficient and one way to calculate R^2 is... R^2. Max On Sun, Mar 3, 2013 a

Re: [R] distribution functions and lists

2013-03-03 Thread Duncan Murdoch
On 13-03-03 3:39 PM, Oleguer Plana Ripoll wrote: Dear Milan and other users, Thank you for your help, it worked. The problem is that the function "do.call" is not ready for vectors and I need it in order to integrate it afterwards. do.call() is fine, it's the argument list that needs fixing.

Re: [R] distribution functions and lists

2013-03-03 Thread Oleguer Plana Ripoll
Dear Milan and other users, Thank you for your help, it worked. The problem is that the function "do.call" is not ready for vectors and I need it in order to integrate it afterwards. With the pweibull, I can write: pweibull(1,shape=1) pweibull(2,shape=1) pweibull(1:2,shape=1) When I do the same

Re: [R] caret pls model statistics

2013-03-03 Thread Charles Determan Jr
I was under the impression that in PLS analysis, R2 was calculated by 1- (Residual sum of squares) / (Sum of squares). Is this still what you are referring to? I am aware of the linear R2 which is how well two variables are correlated but the prior equation seems different to me. Could you expla

Re: [R] distribution functions and lists

2013-03-03 Thread Milan Bouchet-Valat
Le dimanche 03 mars 2013 à 19:49 +0100, Oleguer Plana Ripoll a écrit : > Hello everyone, > > I have a quick question but I am stuck with it and I do not know how > to solve it. > > Imagine I need the distribution function of a Weibull(1,1) at t=3, > then I will write pweibull(3,1,1). > > I want

[R] distribution functions and lists

2013-03-03 Thread Oleguer Plana Ripoll
Hello everyone, I have a quick question but I am stuck with it and I do not know how to solve it. Imagine I need the distribution function of a Weibull(1,1) at t=3, then I will write pweibull(3,1,1). I want to keep the shape and scale parameters in a list (or a vector or whatever). Then I hav

Re: [R] Help searching a matrix for only certain records

2013-03-03 Thread Matt Borkowski
Thank you for your response Jim! I will give this one a try! But a couple followup questions... In my search for a solution, I had seen something stating match() is much more efficient than subset() and will cut down significantly on computing time. Is there any truth to that? Also, I found th

Re: [R] Help searching a matrix for only certain records

2013-03-03 Thread arun
HI, You could also use ?data.table() n<- 30 set.seed(51)  mat1<- as.matrix(data.frame(REC.TYPE= sample(c("SAO","FAO","FL-1","FL-2","FL-15"),n,replace=TRUE),Col2=rnorm(n),Col3=runif(n),stringsAsFactors=FALSE))  dat1<- as.data.frame(mat1,stringsAsFactors=FALSE)  table(mat1[,1]) #  # FAO  FL-1

Re: [R] Random Sample with constraints

2013-03-03 Thread Ted Harding
On 03-Mar-2013 16:29:05 Angelo Scozzarella Tiscali wrote: > For example, I want to simulate different populations with same mean and > standard deviation but different distribution. > > Il giorno 03/mar/2013, alle ore 17:14, Angelo Scozzarella Tiscali ha scritto: >> Dear R friends, >> >> I'd lik

Re: [R] Help searching a matrix for only certain records

2013-03-03 Thread jim holtman
If you are using matrices, then here is several ways of doing it for size 300,000. You can determine if the difference of 0.1 seconds is important in terms of the performance you are after. It is taking you more time to type in the statements than it is taking them to execute: > n <- 30 > te

Re: [R] Random Sample with constraints

2013-03-03 Thread Angelo Scozzarella Tiscali
For example, I want to simulate different populations with same mean and standard deviation but different distribution. Il giorno 03/mar/2013, alle ore 17:14, Angelo Scozzarella Tiscali ha scritto: > Dear R friends, > > I'd like to generate random sample (variable size and range) without a >

Re: [R] Help searching a matrix for only certain records

2013-03-03 Thread Jim Holtman
there are way "more efficient" ways of doing many of the operations , but you probably won't see any differences unless you have very large objects (several hunfred thousand entries), or have to do it a lot of times. My background is in computer performance and for the most part I have found th

Re: [R] Random Sample with constraints

2013-03-03 Thread Ben Bolker
Angelo Scozzarella Tiscali tiscali.it> writes: > > Dear R friends, > > I'd like to generate random sample (variable size and range) without a specified distribution but with > given mean and standard deviation. > > Could you help me? > The problem is underspecified, so no, we can't. A

[R] Random Sample with constraints

2013-03-03 Thread Angelo Scozzarella Tiscali
Dear R friends, I'd like to generate random sample (variable size and range) without a specified distribution but with given mean and standard deviation. Could you help me? thanks in advance Angelo __ R-help@r-project.org mailing list https://stat.e

Re: [R] Help searching a matrix for only certain records

2013-03-03 Thread arun
Hi, Try this: set.seed(51)  mat1<- as.matrix(data.frame(REC.TYPE= sample(c("SAO","FAO","FL-1","FL-2","FL-15"),20,replace=TRUE),Col2=rnorm(20),Col3=runif(20),stringsAsFactors=FALSE))  dat1<- as.data.frame(mat1,stringsAsFactors=FALSE) dat1[grepl("SAO|FL-15",dat1$REC.TYPE),] #   REC.TYPE    Col2

Re: [R] Kolmogorov-Smirnov: calculate p value given as input the test statistic

2013-03-03 Thread Prof Brian Ripley
On 03/03/2013 09:58, Rani Elkon wrote: Dear all, I calculate the test statistic for the KS test outside R, and wish to use R only to calculate the corresponding p-value. There is no public way to do this in R. But you can read the code of ks.test and see how it does it, and extract the cod

Re: [R] Errors-In-Variables in R

2013-03-03 Thread John Fox
Dear Cedric, If I understand correctly what you want to do, and if you're willing to assume that the variables are normally distributed, then you should be able to use any of the latent-variable structural-equation-modeling packages in R, such as sem, OpenMX, or lavaan. Here's an artificial exam

Re: [R] caret pls model statistics

2013-03-03 Thread Charles Determan Jr
Thank you for your response Max. Is there some literature that you make that statement? I am confused as I have seen many publications that contain R^2 and Q^2 following PLSDA analysis. The analysis usually is to discriminate groups (ie. classification). Are these papers incorrect in using thes

Re: [R] Kolmogorov-Smirnov: calculate p value given as input the test statistic

2013-03-03 Thread Rui Barradas
Hello, You can compute the p-value from the test statistic if you know the samples' sizes. R calls functions written in C for the several cases, for the two samples case, this is the code (edited) n.x <- 100 # length of 1st sample n.y <- 100 # length of 2nd sample STATISTIC <- 1.23 PVAL <-

Re: [R] Help searching a matrix for only certain records

2013-03-03 Thread jim holtman
Try this: dataset <- subset(dataset, grepl("(SAO |FL-15)", REC.TYPE)) On Sun, Mar 3, 2013 at 1:11 AM, Matt Borkowski wrote: > Let me start by saying I am rather new to R and generally consider myself to > be a novice programmer...so don't assume I know what I'm doing :) > > I have a large matr

[R] Kolmogorov-Smirnov: calculate p value given as input the test statistic

2013-03-03 Thread Rani Elkon
Dear all, I calculate the test statistic for the KS test outside R, and wish to use R only to calculate the corresponding p-value. Is there a way for doing this? (as far as I see, ks.test() requires raw data as input). Alternatively, is there a way to provide the ks.test() the two CDFs (two

[R] Help searching a matrix for only certain records

2013-03-03 Thread Matt Borkowski
Let me start by saying I am rather new to R and generally consider myself to be a novice programmer...so don't assume I know what I'm doing :) I have a large matrix, approximately 300,000 x 14. It's essentially a 20-year dataset of 15-minute data. However, I only need the rows where the column I

Re: [R] Empirical Bayes Estimator for Poisson-Gamma Parameters

2013-03-03 Thread Ali A. Bromideh
Dear Nicole, First of all, my sincere gratitude goes to your kind reply. As I told to Mr. Gunter, this is a part of my research and differs from homework. However, I am going to clarify the problem. Suppose we have received an observation from a Poisson distr. i.e. Y_1~Pois(Lam_1), where Lam_1~Gam

Re: [R] if value is in vector, perform this function

2013-03-03 Thread Patrick Burns
I forgot to say: Also do not depend on equality in this situation. You want to test equality with a tolerance. See Circle 1 of 'The R Inferno': http://www.burns-stat.com/documents/books/the-r-inferno/ I also see that 't' is a vector unlike what I was thinking before, thus you want to use 'ifels

Re: [R] if value is in vector, perform this function

2013-03-03 Thread Berend Hasselman
On 03-03-2013, at 00:57, Louise Stevenson wrote: > Hi, > > I'm trying to set up R to run a simulation of two populations in which every > 3.5 days, the initial value of one of the populations is reset to 1.5. I'm > simulation an experiment we did in which we fed Daphnia populations twice a

Re: [R] if value is in vector, perform this function

2013-03-03 Thread Patrick Burns
I think the command you want is: if(t %in% feed_days) C_A <- 1.5 else C_A <- 0 Do not confuse `%in%` (which is essentially "are the left-hand values in the right-hand vector) with "in" of the `for` loop. By the way, if(t == TRUE) is redundant -- better is: if(t) Pat On 02/03/2013 23:57