Re: [R] delta and sd parameters for power.t.test

2017-12-14 Thread David Winsemius
> On Dec 14, 2017, at 2:26 PM, Lasse Kliemann wrote: > > What is the rationale behind having both the delta and sd parameters for > the power.t.test function? One is the standard deviation of the hypothesized data (or pooled sd in the case of two sample) under the "alternative" and one is the

[R] delta and sd parameters for power.t.test

2017-12-14 Thread Lasse Kliemann
What is the rationale behind having both the delta and sd parameters for the power.t.test function? For the relevant noncentrality parameter, we only need the ratio delta/sd. If my effect size is given as Cohen's d, then I only got that ratio and not sd. As far as I see, in such a case, I can spec

[R] GAM Poisson

2017-12-14 Thread Miluji Sb
Dear all, I apologize as this may not be a strictly R question. I am running GAM models using the mgcv package. I was wondering if the interpretation of the smooth splines of the 'x' variable is the same in the following two cases: # Linear probability model m1 <- gam(count ~ factor(city) + fact

Re: [R] Errors in reading in txt files

2017-12-14 Thread MacQueen, Don
In addition to which, I would recommend df <- read.table("DATAM", header = TRUE, fill = TRUE, stringsAsFactors=FALSE) and then converting the Time column to POSIXct date-time values using as.POSIXct() specifying the format using formatting codes found in ?strptime because the times are not in

Re: [R] Errors in reading in txt files

2017-12-14 Thread Berend Hasselman
> On 14 Dec 2017, at 20:01, Ista Zahn wrote: > > On Thu, Dec 14, 2017 at 1:58 PM, Berend Hasselman wrote: >> >>> On 14 Dec 2017, at 19:36, lily li wrote: >>> >>> Hi R users, >>> >>> I have a question about reading from text files. The file has the structure >>> below: >>> >>> Time

Re: [R] Errors in reading in txt files

2017-12-14 Thread Ista Zahn
On Thu, Dec 14, 2017 at 1:58 PM, Berend Hasselman wrote: > >> On 14 Dec 2017, at 19:36, lily li wrote: >> >> Hi R users, >> >> I have a question about reading from text files. The file has the structure >> below: >> >> TimeColumn1 Column2 >> 01.01.2001-12:00:00 > > T

Re: [R] Errors in reading in txt files

2017-12-14 Thread lily li
Thanks, Berend. I thought R can recognize the space automatically, such as na.strings="", or sep=' '. On Thu, Dec 14, 2017 at 11:58 AM, Berend Hasselman wrote: > > > On 14 Dec 2017, at 19:36, lily li wrote: > > > > Hi R users, > > > > I have a question about reading from text files. The file ha

Re: [R] help with recursive function

2017-12-14 Thread William Dunlap via R-help
recursive_funlp <- function(dataset = dat1, func = funlp2) { ... if (!(any(data1$norm_sd >= 1))) { df1 <- dat1 return(df1) } else { df2 <- recursive_funlp() # GIVE SOME ARGUMENTS HERE return(df2) } } Whe

Re: [R] Errors in reading in txt files

2017-12-14 Thread Berend Hasselman
> On 14 Dec 2017, at 19:36, lily li wrote: > > Hi R users, > > I have a question about reading from text files. The file has the structure > below: > > TimeColumn1 Column2 > 01.01.2001-12:00:00 This line does not contain 3 elements; only one. You'll have to fix t

[R] Errors in reading in txt files

2017-12-14 Thread lily li
Hi R users, I have a question about reading from text files. The file has the structure below: TimeColumn1 Column2 01.01.2001-12:00:00 01.01.2001-24:00:0012 11 01.02.2001-12:00:0013 10 01.02.2001-24:00:0011

Re: [R] help with recursive function

2017-12-14 Thread DIGHE, NILESH [AG/2362]
When I run the code without stopifnot, the code takes 5 min to run and then it throws an error listed below without producing any results. Error: node stack overflow In addition: There were 50 or more warnings (use warnings() to see the first 50) Error during wrapup: node stack overflow Thanks. N

Re: [R] help with recursive function

2017-12-14 Thread William Dunlap via R-help
Your code contains the lines stopifnot(!(any(data1$norm_sd >= 1))) if(!(any(data1$norm_sd >= 1))) { df1 <- dat1 return(df1) } stop() "throws an error", causing the current function and all functions in the call stack to abort and return n

[R] permutation test for Cox proportional hazards regression model

2017-12-14 Thread linda porz
I would like to perform a permutation test for Cox proportional hazards regression model. I only find it for t-test and other tests (e.g. comparing two medians). Is there a way that I can perform a Cox PH model in R or SAS for the LR-test? I am doing the following B <- 1000; LRtestx <- rep(NA,B)

Re: [R] help with recursive function

2017-12-14 Thread DIGHE, NILESH [AG/2362]
Eric: I will try and see if I can figure out the issue by debugging as you suggested. I don’t know why my code after stopifnot is not getting executed where I like the code to run the funlp2 function when the if statement is TRUE but when it is false, I like it to keep running until the stopifn

Re: [R] help with recursive function

2017-12-14 Thread Eric Berger
If you are trying to understand why the "stopifnot" condition is met you can replace it by something like: if ( any(dat2$norm_sd >= 1) ) browser() This will put you in a debugging session where you can examine your variables, e.g. > dat$norm_sd HTH, Eric On Thu, Dec 14, 2017 at 5:33 PM, E

Re: [R] help with recursive function

2017-12-14 Thread Eric Berger
The message is coming from your stopifnot() condition being met. On Thu, Dec 14, 2017 at 5:31 PM, DIGHE, NILESH [AG/2362] < nilesh.di...@monsanto.com> wrote: > Hi, I accidently left out few lines of code from the calclp function. > Updated function is pasted below. > > I am still getting the sam

Re: [R] help with recursive function

2017-12-14 Thread DIGHE, NILESH [AG/2362]
Hi, I accidently left out few lines of code from the calclp function. Updated function is pasted below. I am still getting the same error “Error: !(any(data1$norm_sd >= 1)) is not TRUE“ I would appreciate any help. Nilesh dput(calclp) function (dataset) { dat1 <- funlp1(dataset) recursi

Re: [R] help with recursive function

2017-12-14 Thread DIGHE, NILESH [AG/2362]
Eric: Thanks for taking time to look into my problem. Despite of making the change you suggested, I am still getting the same error. I am wondering if the logic I am using in the stopifnot and if functions is a problem. I like the recursive function to stop whenever the norm_sd column has zero

Re: [R] help with recursive function

2017-12-14 Thread Eric Berger
My own typo ... whoops ... !( any(dat2$norm_sd >= 1 )) On Thu, Dec 14, 2017 at 3:43 PM, Eric Berger wrote: > You seem to have a typo at this expression (and some others like it) > > Namely, you write > > any(!dat2$norm_sd) >= 1 > > when you possibly meant to write > > !( any(dat2$norm_sd) >=

Re: [R] help with recursive function

2017-12-14 Thread Eric Berger
You seem to have a typo at this expression (and some others like it) Namely, you write any(!dat2$norm_sd) >= 1 when you possibly meant to write !( any(dat2$norm_sd) >= 1 ) i.e. I think your ! seems to be in the wrong place. HTH, Eric On Thu, Dec 14, 2017 at 3:26 PM, DIGHE, NILESH [AG/2362]

[R] help with recursive function

2017-12-14 Thread DIGHE, NILESH [AG/2362]
Hi, I need some help with running a recursive function. I like to run funlp2 recursively. When I try to run recursive function in another function named "calclp" I get this "Error: any(!dat2$norm_sd) >= 1 is not TRUE". I have never built a recursive function before so having trouble executing it

[R] multiple instances of predictor variable per model

2017-12-14 Thread Sima Usvyatsov
I’m running a model on animal behavior in response to shipping. In most cases, there is only one ship in the study area at one time. Ship length, distance from the animals, speed, angle from animals, and ship direction (as east/west bound) are among shipping-related covariates (with multiple intera

Re: [R] change in behavior of c.trellis

2017-12-14 Thread Duncan Murdoch
This looks like a bug in latticeExtra: in the c.trellis function there are these lines: ## some prepanel functions require a 'subscripts' argument in each 'panel.args' if ("subscripts" %in% c(names(formals(obj1$prepanel.default)), names(formals(obj1$prepane

Re: [R] overlay two histograms ggplot

2017-12-14 Thread Thierry Onkelinx
Dear Elahe, Something like joint <- rbind( data.frame(x = gg$Az, veg = gg$veg, type = "Alz"), data.frame(x = tt$Cont, veg = gg$veg, type = "Cont") ) ggplot(joint, aes(x = x, fill = veg, colour = type)) + geom_plot(alpha = 0.2) Best regards, ir. Thierry Onkelinx Statisticus / Statistician V

[R] Distributions for gbm models

2017-12-14 Thread Patrick Connolly
On page 409 of "Applied Predictive Modeling" by Max Kuhn, it states that the gbm function can accomodate only two class problems when referring to the distribution parameter. >From gbm help re: the distribution parameter: Currently available options are "gaussian" (squared error),

Re: [R] Aggregation across two variables in data.table

2017-12-14 Thread PIKAL Petr
Hi Are you aware of function aggregate? result <- with(data_tmp, aggregate(Theta, list(Marital, Education), mean)) should do the trick. Cheers Petr > -Original Message- > From: R-help [mailto:r-help-boun...@r-project.org] On Behalf Of Michael > Haenlein > Sent: Thursday, December 14, 2