[R] JSM 2018 Invited Session Proposals on Statistical Graphics and Data Visualization Due by September 7, 2017
Dear Colleagues, If you work in the statistical graphics and/or data visualization fields, please consider organizing an invited session for the JSM 2018 conference in Vancouver, whose theme is “#LeadWithStatistics.” ASA's Section on Statistical Graphics will sponsor 3 invited sessions at JSM 2018, with a further 1-2 proposals having the potential to be included in the JSM 2018 conference program through open competition. Invited session proposals need to be submitted by September 7th, 2017 via the website: http://ww2.amstat.org/meetings/jsm/2018/submissions.cfm. When submitting your proposal, please list the ASA Section on Statistical Graphics as the sponsor of your invited session. Invited sessions include invited papers and panels: * Invited paper sessions consist of 2–6 presenters and/or discussants. * Invited panels have 3–6 panelists providing commentary on a particular topic. An invited session proposal includes a session title, general description of the session, list of participants, and tentative talk titles. If you are interested in organizing an invited session, you need to select a session topic and solicit potential speakers. Once you have a sufficient number of committed speakers, you can submit your proposal online by the September 7, 2017 deadline. To have the best chance of receiving an invited session slot, you need to: * Have solid new work in an important field; * Know some of your competitors working in the same field; * Be willing to reach out to your competitors and forge a session with energy in it. For more details, please refer to http://ww2.amstat.org/meetings/jsm/2018/invitedsessions.cfm. Many thanks, Isabella Isabella R. Ghement, Ph.D. JSM 2018 Program Chair for the ASA Section on Statistical Graphics E-mail: isabe...@ghement.ca Isabella R. Ghement, Ph.D. Ghement Statistical Consulting Company Ltd. 301-7031 Blundell Road, Richmond, B.C., Canada, V6Y 1J5 Tel: 604-767-1250 Fax: 604-270-3922 E-mail: isabe...@ghement.ca Web: www.ghement.ca __ R-help@r-project.org mailing list -- To UNSUBSCRIBE and more, see 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] Error in predict.lm() for models with no intercept?
Hi everyone, Could there be an error in the predict() function in R for models without intercepts which include one or more predictors? When using the predict() function to obtain the standard errors of the fitted values produced by a linear model (lm), the behaviour of the standard errors seems to mirror that of models which include an intercept (which should not happen). Here is an attempt to produce standard errors (and hence confidence bands) for the fitted values in a linear model with a single predictor and no intercept using R code: ## simulate a response y and two predictors x and z x [[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] Error in predict.lm() for models with no intercept?
Hi Antonio, I've just sent an e-mail to the r-help list with some R code which shows that the standard errors of the fitted values are indeed computed incorrectly by R (please see below). Let's hope that there will be at least one helpful answer to the question. Best, Isabella On Tue 16/09/14 3:06 PM , isabe...@ghement.ca sent: Hi everyone, Could there be an error in the predict() function in R for models without intercepts which include one or more predictors? When using the predict() function to obtain the standard errors of the fitted values produced by a linear model (lm), the behaviour of the standard errors seems to mirror that of models which include an intercept (which should not happen). Here is an attempt to produce standard errors (and hence confidence bands) for the fitted values in a linear model with a single predictor and no intercept using R code: ## simulate a response y and two predictors x and z x [[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] Error in predict.lm() for models without intercept?
Hi everyone, It appears my R code didn't come through the first time (thanks for letting me know, Ista). Here is my message again: Could there be an error in the predict() function in R for models without intercepts which include one or more predictors? When using the predict() function to obtain the standard errors of the fitted values produced by a linear model (lm), the behaviour of the standard errors seems to mirror that of models which include an intercept (which should not happen). Here is an attempt to produce standard errors (and hence confidence bands) for the fitted values in a linear model with a single predictor and no intercept using R code: ## simulate a response y and two predictors x and z x <- rnorm(100,mean=0, sd=1) z <- runif(100,min=-1,max=1) y <- 1*x + 2*z + rnorm(100,mean=0, sd=1) ## fit a linear model with no intercept but with one predictor mod <- lm(y ~ 0 + x) ## compute confidence bands (i.e., fitted values +/- 1.96 standard errors of fitted values) conf.band.x <- predict(mod,newdata=data.frame(x = seq(from=ceiling(min(x)),to=floor(max(x)),by=0.01)), interval="confidence") ## display confidence bands conf.band.x <- data.frame(lwr=conf.band.x[,"lwr"], fit=conf.band.x[,"fit"], upr=conf.band.x[,"upr"]) matplot(x=seq(from=ceiling(min(x)),to=floor(max(x)),by=0.01), y=conf.band.x, type="l", xlab="x", ylab="y") abline(v=mean(x),lty=3,col="magenta") title("Effect of x on y") According to statistical theory, in a model with no intercept and one predictor, the standard errors should be directly proportional to the value of x at which they are evaluated. If x=0, the standard errors should also be zero. If x increases, the standard errors should also increase. The resulting plot produced by matplot shows this is not the case - the standard errors appear to increase as one moves away from the average value of x. We would expect this behaviour if the model included an intercept, which is not the case here. Here is some R code for looking at standard errors of fitted values when the model includes no intercept and two predictors x and z. In this code, the value of the predictor z is set to its average level. ## linear model with no intercept but with two predictors mod <- lm(y ~ 0 + x + z) conf.band.x <- predict(mod,newdata=data.frame(x = seq(from=ceiling(min(x)),to=floor(max(x)),by=0.01), z = mean(z)), interval="confidence") conf.band.x <- data.frame(lwr=conf.band.x[,"lwr"], fit=conf.band.x[,"fit"], upr=conf.band.x[,"upr"]) matplot(x=seq(from=ceiling(min(x)),to=floor(max(x)),by=0.01), y=conf.band.x, type="l", xlab="x", ylab="y") abline(v=mean(x),lty=3,col="magenta") title("Partial Effect of x on y (obtained by setting z to its average level)") Again, the standard errors seem to behave as though they would come from a model with an intercept (given that they are flaring up as one moves away from the average value of the predictor x). I would very much appreciate any clarifications or suggestions for how to fix this problem. If the problem is confirmed, it appears to also carry over to the effects package in R, which constructs plots similar to the ones produced by matplot above by relying on the predict() function. Many thanks, Isabella Isabella R. Ghement, Ph.D. Ghement Statistical Consulting Company Ltd. 301-7031 Blundell Road, Richmond, B.C., Canada, V6Y 1J5 Tel: 604-767-1250 Fax: 604-270-3922 E-mail: isabe...@ghement.ca Web: www.ghement.ca __ 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] Error in predict.lm() for models without intercept?
Hi Rolf, BODY { font-family:Arial, Helvetica, sans-serif;font-size:12px; } Thanks very much for your response. You are right - my simulated example works as intended, so it can't be used to get to the bottom of this problem (if it is a problem at all). Here is another example, which is the one I actually worked with when I thought maybe something is not quite right in the universe. The example is based on a real data set (please keep it confidential), which is attached to this e-mail as mod.data.csv. This data set includes terminal run numbers for salmon, recorded at Age_5, Age_4, Age_3 and Age_2. A model of the form lm(Age_5 ~ 0 + Age_4 + Age_3 + Age_2) is fitted to these data and the goal is to visualize the effects of Age_4, Age_3 and Age_2 on Age_5. For biological reasons, this model is supposed to not have an intercept. The attachment Effect_1.pdf shows what these effects look like. If the model has no intercept, should the confidence bands still flare up as one moves away from the value of the predictor whose effect we care about? The attachment Effect_2.pdf replicates the effects plots but this time using the effects package. If predict() is correct, should we expect from statistical theory to see that the confidence bands have this particular behaviour? Intuitively, I would have expected them to look like a fan plot that starts out at zero and then flares up as we move away from zero. Here is the R code I used to create the two attached plots (with R x64 3.1.0). In this code, Age_5 becomes y, Age_4 becomes x, Age_3 becomes z and Age_2 becomes v. ## read mod.data into R mod.data single predictor and no intercept using R code: > > ## simulate a response y and two predictors x and z > > x > z > y > > ## fit a linear model with no intercept but with one predictor > > mod > ## compute confidence bands (i.e., fitted values +/- 1.96 standard errors of fitted values) > > conf.band.x interval="confidence") > > ## display confidence bands > > conf.band.x fit=conf.band.x[,"fit"], > upr=conf.band.x[,"upr"]) > > matplot(x=seq(from=ceiling(min(x)),to=floor(max(x)),by=0.01), y=conf.band.x, type="l", xlab="x", ylab="y") > abline(v=mean(x),lty=3,col="magenta") > title("Effect of x on y") > > According to statistical theory, in a model with no intercept and one predictor, the standard errors should be directly > proportional to the value of x at which they are evaluated. If x=0, the standard errors should also be zero. If x increases, > the standard errors should also increase. The resulting plot produced by matplot shows this is not the case - the standard > errors appear to increase as one moves away from the average value of x. We would expect this behaviour if the model included > an intercept, which is not the case here. > > Here is some R code for looking at standard errors of fitted values when the model includes no intercept and two predictors x > and z. In this code, the value of the predictor z is set to its average level. > ## linear model with no intercept but with two predictors > > mod > conf.band.x z = mean(z)), > interval="confidence") > > conf.band.x fit=conf.band.x[,"fit"], > upr=conf.band.x[,"upr"]) > > matplot(x=seq(from=ceiling(min(x)),to=floor(max(x)),by=0.01), y=conf.band.x, type="l", xlab="x", ylab="y") > abline(v=mean(x),lty=3,col="magenta") > title("Partial Effect of x on y (obtained by setting z to its average level)") > > Again, the standard errors seem to behave as though they would come from a model with an intercept (given that they are > flaring up as one moves away from the average value of the predictor x). > > I would very much appreciate any clarifications or suggestions for how to fix this problem. > > If the problem is confirmed, it appears to also carry over to the effects package in R, which constructs plots similar to the > ones produced by matplot above by relying on the predict() function. -- Rolf Turner Technical Editor ANZJS __ 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 split a plot into vertical subregions with width proportional to length of a character string?
BODY { font-family:Arial, Helvetica, sans-serif;font-size:12px; }Hello, I am trying to create a plot whose x-axis is wide enough to accommodate the following: a) a character string on the left side (i.e., Text 1); b) a known range of values in the middle (i.e., Range); c) a character string on the right side (i.e., Label 2) The plot would start with the range of values in the middle and would be expanded to the left and right by a width proportional to the length of Text 1 and Label 2, respectively. (The width would need to be expressed in the same units as those of the middle range of values.) In R, how can I determine the width of Text 1 and Label 2 and express it in the same units as those pertaining to Range? (I know how to determine the width of these character strings in inches for a given plot via strwidth(), but for some reason I am not able to connect that width to the units of Range.) Here is some R code illustrating what the plot would look like: plot(NA, xlim=c(1,10), ylim=c(1,5),type="N") abline(v=1,lty=2,col="red") abline(v=2,lty=2,col="red") abline(v=8,lty=3,col="blue") abline(v=10,lty=3,col="blue") text(1,3,"Text 1",pos=4) text(8,3,"Label 2",pos=4) arrows(2,3,8,3,code=3, length=0.1,lwd=2) text(5,3,"Range",pos=3) Thank you in advance for any ideas you can provide. Isabella Isabella R. Ghement, Ph.D. Ghement Statistical Consulting Company Ltd. 301-7031 Blundell Road, Richmond, B.C., Canada, V6Y 1J5 Tel: 604-767-1250 Fax: 604-270-3922 E-mail: isabe...@ghement.ca Web: www.ghement.ca [[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] Robust ARMA Fitting in R?
Hello, BODY { font-family:Arial, Helvetica, sans-serif;font-size:12px; } Does any one know if there are any functions/packages available in R for robust fitting of ARMA time series models (e.g., similar to the function arima.rob() in S-PLUS)? Many thanks and kind regards, Isabella Isabella R. Ghement, Ph.D. Ghement Statistical Consulting Company 301-7031 Blundell Road, Richmond, B.C., Canada, V6Y 1J5 Tel: 604-767-1250 Fax: 604-270-3922 E-mail: isabe...@ghement.ca Web: www.ghement.ca [[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] Robust ARMA Fitting in R?
BODY { font-family:Arial, Helvetica, sans-serif;font-size:12px; } Hi Berend, Many thanks for your prompt reply. I followed your instructions but couldn't find what I was looking for. I was hoping that someone who's already worked with such a function could be able to point it out to me. My Google searches came up empty handed. Kind regards, Isabella Isabella R. Ghement, Ph.D. Ghement Statistical Consulting Company 301-7031 Blundell Road, Richmond, B.C., Canada, V6Y 1J5 Tel: 604-767-1250 Fax: 604-270-3922 E-mail: isabe...@ghement.ca Web: www.ghement.ca On Thu 01/03/12 10:29 AM , Berend Hasselman b...@xs4all.nl sent: On 01-03-2012, at 19:03, wrote: > > > Hello, BODY { font-family:Arial, Helvetica, > sans-serif;font-size:12px; } > > Does any one know if there are any functions/packages available in R > for robust fitting of ARMA time series models (e.g., similar to the > function arima.rob() in S-PLUS)? CRAN: http://cran.r-project.org/ [2] In Task Views (left side) goto TimeSeries. And search for "arima" on that page. Berend Links: -- [2] http://sitemail.netnation.com/parse.php?redirect=http%3A%2F%2Fcran.r-project.org%2F [[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] meboot - can it handle outliers and missing values?
Hi everyone, I would like to use your meboot package in R in a power simulation study, where meboot stands for Maximum Entropy Bootstrap. In this study, each time series that will be bootstrapped includes both missing values and outliers. Can meboot accomodate these two features, which are the hallmark of many real time series? If yes, I would very much appreciate your thoughts on how this can be achieved in R. Many thanks and kind regards, Isabella Isabella R. Ghement, Ph.D. Ghement Statistical Consulting Company 301-7031 Blundell Road, Richmond, B.C., Canada, V6Y 1J5 Tel: 604-767-1250 Fax: 604-270-3922 E-mail: isabe...@ghement.ca Web: www.ghement.ca [[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] Problems with R2WinBUGS
Hello, I am trying to use R2WinBUGS to conduct a mixed treatment comparison (MTC) analysis. On the surface, it seems to me that I am following the correct steps: (1) reading the data into R, (2) specifying initial values for the parameters in the model and (3) fitting the model to the data using the bugs() function in R2WinBUGS.However, I get the error message âincompatible copyâ when running bugs(), which is a bit confusing, given that I was able to fit the same model without problems in WinBUGS. The WinBUGS log file produced after calling bugs() indicates that the following items were successfully checked: âmodel is syntactically correctâ, âdata loadedâ and âmodel compiledâ. I suspect R2WinBUGS does not like the initialization of the model parameters (?!) â the log file abruptly ends after listing the inits() command. Has anyone encountered similar problems with R2WinBUGS? If so, can you please point me in the right direction? Is there a preferred way to initialize the values of the parameters? Things one should do or should not do? In case this may help, here is the R code that I used: library(R2WinBUGS) s = c(1,1,2,2,3,3,4,4,5,5,6,6,7,7,8,8,9,9,10,10, 11,11,12,12,13,13,14,14,15,15,16,16,17,17,18,18,19,19,20,20) t = c(1,2, 1,2, 1,2, 1,2, 1,2, 1,3, 1,3, 1,4, 1,4, 1,4, 1,4, 1,4, 1,4, 1,4, 1,4, 1,4, 1,4, 1,4, 1,5, 1,5) r = c(320,297, 1,5, 82,61, 68,70, 212,185, 138,143, 5,4, 78,87, 3,0, 0,1, 135,106, 306,298, 12,13, 79,55, 4,3, 9,5, 0,1, 641,631, 77,80, 9,1) n = c(636,619, 114,240, 1410,1428, 1199,1211, 5137,5168, 1052,1050, 285,283, 1634,2219, 532,530, 254,254, 3293,3302, 2913,2891, 431,433, 3966,3866, 223,224, 81,83, 154,151, 5185,5170, 3301, 3304, 459,460) b = c(rep(1,40)) N = 40 NS = 20 NT = 5 data <- list("s","t","r","n","b","N","NS","NT") inits <- function(){ list(T=c(0.02,0.02,0.02,0.02,0.02), best=c(0,0.4,0.07,0.13,0.3), d=c(NA,0,0,0,0), lor=c(-0.12,0.03,-0.07,-0.06,0.16,0.04,0.06,0.11,-0.09,0.01), mu=c(0,0,0,0,0, 0,0,0,0,0, 0,0,0,0,0, 0,0,0,0,0), or=c(0.88,1.04,0.92,0.95,1.18,1.05,1.08,0.90,0.92,1.02), p=c(0.50,0.47,0.01,0.01,0.05,0.04,0.06,0.05,0.04,0.03,0.13, 0.13,0.01,0.01,0.04,0.04,0.00,0.00,0.00,0.00, 0.03,0.03,0.10,0.10,0.03,0.02,0.01,0.01,0.01, 0.01,0.08,0.08,0.00,0.00,0.12,0.11,0.02,0.02,0.01,0.01)) } model.sim = bugs(data,inits, model.file="model.bug", parameters=c("T","best","d","lor","mu","or","p"), n.chains=1,n.iter=2,n.burnin=5000,n.thin=1, bugs.directory="c:/Program Files/WinBUGS14/", codaPkg=FALSE, debug=FALSE) Thank you in advance for any help you may be able to provide! Sincerely, Isabella Isabella R. Ghement, Ph.D. Ghement Statistical Consulting Company 301-7031 Blundell Road, Richmond, B.C., Canada, V6Y 1J5 Tel: 604-767-1250 Fax: 604-270-3922 E-mail: [EMAIL PROTECTED] Web: www.ghement.ca __ 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 R2WinBUGS
Dear Ben, Thank you very much for your reply to my R2WinBUGS query. As requested, I am attaching the following files to this e-mail: 1) The .odc file containing the WinBUGS code I am trying to run from R. The nodes to be monitored for posterior inference are: T, best, d, lor, mu, or and p. 2) The .R file containing the call to the bugs() function in the package R2WinBUGS. 3) The .bug file containing the model specification used when calling bugs(). Please note that I have tried to specify the initial values of the parameters using a list rather than a function (as suggested by Peter Alspach), and got the following error message: Error in bugs(data, inits, model.file = "model.bug", parameters = c("T", : Number of initialized chains (length(inits)) != n.chains Many thanks for any insight you may be able to provide into why the call to R2WinBUGS breaks down. In case this may be needed, I am using R 2.6.2 and WinBUGS 1.4. Kind regards, Isabella Isabella R. Ghement, Ph.D. Ghement Statistical Consulting Company 301-7031 Blundell Road, Richmond, B.C., Canada, V6Y 1J5 Tel: 604-767-1250 Fax: 604-270-3922 E-mail: [EMAIL PROTECTED] Web: [2]www.ghement.ca On Wed , Ben Bolker sent: ghement.ca> writes: > > > Hello, > > I am trying to use R2WinBUGS to conduct a mixed treatment comparison (MTC) > analysis. > Thank you in advance for any help you may be able to provide! > Can you please provide your model.bug file? Ben Bolker __ [EMAIL PROTECTED] mailing list [4]https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide [5]http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code. References 1. mailto:[EMAIL PROTECTED] 2. http://www.ghement.ca/ 3. javascript:top.opencompose('[EMAIL PROTECTED]','','','') 4. file://localhost/tmp/parse.php?redirect=https%3A%2F%2Fstat.ethz.ch%2Fmailman%2Flistinfo%2Fr-help 5. file://localhost/tmp/parse.php?redirect=http%3A%2F%2Fwww.R-project.org%2Fposting-guide.html __ 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 R2WinBUGS
Hello, Further to my previous e-mail, I think I know why I am having problems with the initialization of model parameters in R2WinBUGS. My model.bug file contains a portion of code which defines some pairwise odds ratios (e.g., or[1,2], or[1,3], or[1,4], or[2,3], or[2,4], or[3,4]) as seen below: for (c in 1:(NT-1)) { for (k in (c+1):NT) { or[c,k] <- log(d[k] - d[c]) } } Apparently, R2WinBUGS can't recognize these values because they form an incomplete matrix. In trying to solve this issue, I arrived at the conclusion that R2WinBUGS may not be able to recognize WinBUGS parameters specified as a matrix (be it complete or incomplete). Is my understanding correct? Any thoughts on how to overcome this predicament would be greatly appreciated. (Thank you very much to Peter Alspach for helping me to narrow down this problem.) Many thanks! Isabella Isabella R. Ghement, Ph.D. Ghement Statistical Consulting Company 301-7031 Blundell Road, Richmond, B.C., Canada, V6Y 1J5 Tel: 604-767-1250 Fax: 604-270-3922 E-mail: [EMAIL PROTECTED] Web: [2]www.ghement.ca References 1. mailto:[EMAIL PROTECTED] 2. http://www.ghement.ca/ __ 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] Unexpected behaviour for as.date()
Hi everyone, I am trying to use the function as.date() from the "dates" package in R 2.10.0 to convert a character date to a Julian date, as follows: > as.date("02-MAY-01", order="mdy") # convert May 2, 2001 to a Julian date [1] 2May1 However, when trying to convert a character date from the year 2000 to a Julian date, I get an instead of the desired Julian date: > as.date("02-MAY-00", order="mdy") # convert May 2, 2000 to a Julian date [1] Not quite sure why R is unable to handle this type of date (perhaps it thinks it comes from the year 1900?!). Is there a way to force R to convert character dates from the year 2000 into Julian dates? I need to perform this conversion in order to compute the difference between two dates, one of which happens to come from the year 2000. Many thanks! Isabella __ 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] Unexpected behaviour for as.date()
Hi Berwin, Many thanks for your fast reply! It's evening time in Vancouver, Canada but it must be day time in Australia, so good day to you. Sorry about the confusion regarding the library name - I am using the "date" library, as you pointed out. I tried the solution you suggested and find that am having problems getting R to extract the year from an object created by as.date(): d <- as.date(sub("-00", "-2000", "02-MAY-00"),order="dmy") strptime(d, "%d%b%y")$year d <- as.date(sub("-07", "-2007", "02-MAY-07"),order="dmy") strptime(d, "%d%b%y")$year Try this as well, just in case: d <- as.date("02-MAY-07",order="dmy") strptime(d, "%d%b%y")$year How does one extract (a meaningful) year from the object d above? Kind regards, Isabella Isabella R. Ghement, Ph.D. Ghement Statistical Consulting Company 301-7031 Blundell Road, Richmond, B.C., Canada, V6Y 1J5 Tel: 604-767-1250 Fax: 604-270-3922 E-mail: isabe...@ghement.ca Web: www.ghement.ca -Original Message- From: Berwin A Turlach [mailto:ber...@maths.uwa.edu.au] Sent: November 10, 2009 7:13 PM To: Isabella Ghement Cc: r-help@r-project.org Subject: Re: [R] Unexpected behaviour for as.date() G'day Isabella, On Tue, 10 Nov 2009 18:40:11 -0800 "Isabella Ghement" wrote: > I am trying to use the function as.date() from the "dates" package As far as I can tell, there is no package called "dates", did you mean the package "date"? > in R 2.10.0 to convert a character date to a Julian date, as follows: > > > as.date("02-MAY-01", order="mdy") # convert May 2, 2001 to a Julian > > date > [1] 2May1 Are you sure that you are doing what your comments imply? Try: R> library(date) R> as.date("02-MAY-01", order="mdy") [1] 2May1 R> as.date("02-MAY-2001", order="mdy") [1] 2May2001 R> as.numeric(as.date("02-MAY-01", order="mdy")) [1] -21428 R> as.numeric(as.date("02-MAY-2001", order="mdy")) [1] 15097 > However, when trying to convert a character date from the year 2000 > to a Julian date, I get an instead of the desired Julian date: > > > as.date("02-MAY-00", order="mdy") # convert May 2, 2000 to a Julian > > date > [1] > > Not quite sure why R is unable to handle this type of date (perhaps it > thinks it comes from the year 1900?!). My guess it thinks it comes from the year 0. Not sure why it cannot handle such dates. But then, as far as I know, there is actually some discussion about whether the year 0 exist or whether we went straight from 1BC to 1AD.. > Is there a way to force R to convert character dates from the year > 2000 into Julian dates? Presumably you will need something like: R> as.date(sub("-00", "-2000", "02-MAY-00")) [1] 2May2000 HTH. Cheers, Berwin == Full address Berwin A Turlach Tel.: +61 (8) 6488 3338 (secr) School of Maths and Stats (M019)+61 (8) 6488 3383 (self) The University of Western Australia FAX : +61 (8) 6488 1028 35 Stirling Highway Crawley WA 6009e-mail: ber...@maths.uwa.edu.au Australiahttp://www.maths.uwa.edu.au/~berwin __ 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] Unexpected behaviour for as.date()
Hi David, Thank you so much for your reply - the quick answer is that I inherited the R code I am working with from someone else so I am trying to use the same functions they have used. In hindsight, this did not make my life any easier - on the contrary. Of course, little did I know that I would find a bug in as.date() for the year 2000 and that I would not be able to apply strptime() to objects produced by as.date(). In the future, if given the option, I will stick with the as.Date() function you suggested. Kind regards, Isabella -Original Message- From: David Winsemius [mailto:dwinsem...@comcast.net] Sent: November 10, 2009 8:58 PM To: Isabella Ghement Cc: Berwin A Turlach; r-help@r-project.org Subject: Re: [R] Unexpected behaviour for as.date() On Nov 10, 2009, at 11:11 PM, Isabella Ghement wrote: > Hi Berwin, > > Many thanks for your fast reply! It's evening time in Vancouver, > Canada but > it must be day time in Australia, so > good day to you. > > Sorry about the confusion regarding the library name - I am using > the "date" > library, as you pointed out. > > I tried the solution you suggested and find that am having problems > getting > R to extract the year > from an object created by as.date(): > > d <- as.date(sub("-00", "-2000", "02-MAY-00"),order="dmy") > strptime(d, "%d%b%y")$year I do not have much, correction, make that no experience with the data package. I am wondering why you do not use the more "mainstream" function, as.Date: > d <- as.Date("02-MAY-07",format="%d-%b-%y") > d [1] "2007-05-02" It returns a Date formatted object that is the number of days from the origin, "1970-01-01". R generally "prefers" dates in the -MM-DD format, but allows conversion. ?Date Differences and addition are supported: > d - 1:10 [1] "2007-05-01" "2007-04-30" "2007-04-29" "2007-04-28" "2007-04-27" "2007-04-26" "2007-04-25" [8] "2007-04-24" "2007-04-23" "2007-04-22" > d + 1:10 [1] "2007-05-03" "2007-05-04" "2007-05-05" "2007-05-06" "2007-05-07" "2007-05-08" "2007-05-09" [8] "2007-05-10" "2007-05-11" "2007-05-12" > Sys.Date() - d Time difference of 923 days > > > d <- as.date(sub("-07", "-2007", "02-MAY-07"),order="dmy") > strptime(d, "%d%b%y")$year > > Try this as well, just in case: > > d <- as.date("02-MAY-07",order="dmy") > strptime(d, "%d%b%y")$year > > How does one extract (a meaningful) year from the object d above? > > Kind regards, > > Isabella > > Isabella R. Ghement, Ph.D. > Ghement Statistical Consulting Company > -Original Message- > From: Berwin A Turlach [mailto:ber...@maths.uwa.edu.au] > Sent: November 10, 2009 7:13 PM > To: Isabella Ghement > Cc: r-help@r-project.org > Subject: Re: [R] Unexpected behaviour for as.date() > > > G'day Isabella, > > On Tue, 10 Nov 2009 18:40:11 -0800 > "Isabella Ghement" wrote: > >> I am trying to use the function as.date() from the "dates" package > > As far as I can tell, there is no package called "dates", did you mean > the package "date"? > >> in R 2.10.0 to convert a character date to a Julian date, as follows: >> >>> as.date("02-MAY-01", order="mdy") # convert May 2, 2001 to a Julian >>> date >> [1] 2May1 > > Are you sure that you are doing what your comments imply? Try: > > R> library(date) > R> as.date("02-MAY-01", order="mdy") > [1] 2May1 > R> as.date("02-MAY-2001", order="mdy") > [1] 2May2001 > R> as.numeric(as.date("02-MAY-01", order="mdy")) > [1] -21428 > R> as.numeric(as.date("02-MAY-2001", order="mdy")) > [1] 15097 > >> However, when trying to convert a character date from the year 2000 >> to a Julian date, I get an instead of the desired Julian date: >> >>> as.date("02-MAY-00", order="mdy") # convert May 2, 2000 to a Julian >>> date >> [1] >> >> Not quite sure why R is unable to handle this type of date (perhaps >> it >> thinks it comes from the year 1900?!). > > My guess it thinks it comes from the year 0. Not sure why it cannot > handle such dates. But then, as far as I know, there is actually some > discussion about whether the year 0 exist or whether we went stra
Re: [R] Unexpected behavior for as.date()
Re: [R] Unexpected behavior for as.date()Hi Terry, Many thanks for your clarifications! It's useful to know where and why things break down and also have a couple of back up options just in case. For now, I'll be extra careful with the date() library; in the future, I'll switch to working with as.Date() and strptime() if possible. Kind regards, Isabella P.S. Many thanks also to all the contributors to this post who kindly offered alternative solutions to my problem. I really appreciate your time and insights. -Original Message- From: Therneau, Terry M., Ph.D. [mailto:thern...@mayo.edu] Sent: November 11, 2009 6:53 AM To: isabe...@ghement.ca Cc: r-help@r-project.org Subject: Re: [R] Unexpected behavior for as.date() The date library was written 20 or so years ago. It was a very good first effort, but the newer Date library has superior functionality in nearly every way. The date library is still available, for legacy projects such as yours, but I do not advise it for new work. To answer your specific questions: 1. What you have is a real bug. The underlying C routine that scans through the text returns "0" as a marker for any string it can't figure out, a year of 'abc' or month 'charlie' for example. The S function then turns these into NA. I never, ever thought about year 0. In our longer term studies at Mayo we have birth dates in the 1800s, it is rather surprising that a birth date of 1900 hadn't caught me sometime in the past. I'll fix this. 2. The date library predates the strptime function by over 10 years. It is not a huge surprise that I neglected to include support for it -- my oracular abilities are limited. For an inherited project such as this I would suggest reading the date() documentation as a first step; it is not very long since the package is simple. You want the date.mdy function, which is more straightforward than strptime (with less capabilities of course). Terry Therneau [[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] Comparing Proportions Among Groups
Hi everyone, I am trying to compare proportions among groups using the logistic regression approach as follows: 1) Fit the model log(p_i/(1-p_i)) = M + G_i, where p_i is the probability of success in group i and G_i is the effect of group i, i=1,..,I. 2) Test the hypotheses: Ho: G_1 = G_2 = ... = G_I (the probability of success is the same for all groups) versus Ha: at least two G_i's are different (at least two groups have different probabilities of success) I am wondering if there any R functions available for accomplishing these tasks. Using dummy variables is one option, but is it possible to solve this problem in R without resorting to the use of dummy variables? Many thanks and kind regards, Isabella Isabella R. Ghement, Ph.D. Ghement Statistical Consulting Company 301-7031 Blundell Road, Richmond, B.C., Canada, V6Y 1J5 Tel: 604-767-1250 Fax: 604-270-3922 E-mail: isabe...@ghement.ca Web: www.ghement.ca __ 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] Lack-of-fit test for linear mixed effects model (lme) including two fixed effects
Dear list members, I fitted a linear mixed effects model using the lme function from nlme package. In the model I included two fixed effects, one being continuous and one a factor having 4 categories. Furthermore, I have one random effect (id) which I want to include as a random intercept only. I used the following code: fit1 <- lme(outcome ~ fixed1 + fixed2, random = ~1|id) Now I would like to perform a lack-of-fit test. In a previous post (where there was only one continuous fixed effect) I have seen the following suggestion: fit1 <- lme(outcome ~ fixed1, random = ~1|id, method="ML") fit2 <- lme(outcome ~ factor(fixed1, ordered=TRUE), random = ~1|id, method="ML") anova(fit1,fit2) Now my questions are: 1) How do I perform a lack-of-fit test with one continuous and one factor as fixed affects? 2) Is it necessary to set method=ML for the lack-of-fit test? 3) If I have to use method=ML for the lack-of-fit test, should I use method=ML also in my model taht I would like to interpret? In my original model I used REML, but only because this is the default in lme and I did not change it. As I have not applied a lack-of-fit test before, I would really be glad for any help! Best regards, John __ 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] Gage R & R
Hello, Could you let me know if there any R packages available for performing Gage R & R studies. Thank you! Sincerely, Isabella Isabella R. Ghement, Ph.D. Ghement Statistical Consulting Company 301-7031 Blundell Road, Richmond, B.C., Canada, V6Y 1J5 Tel: 604-767-1250 Fax: 604-270-3922 E-mail: [EMAIL PROTECTED] Web: www.ghement.ca __ 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.