Re: [R] error using glmmML()
On Jun 21, 2011, at 11:13 PM, Tom Kraft wrote: Dear all, This question is basic but I am stumped. After running the below, I receive the message: non-integer #successes in a binomial glm! model1 - glmmML(y~Brood.Size*Density+Date.Placed+Species+Placed.Emerging+Year +rate.of.parperplot, data = data, cluster= data$Patch, family=binomial(link=logit)) My response variable is sex ratio, and I have learned quickly not to use proportion values as data. Instead, my response variable y is a 2 column matrix that looks like the following but with more rows. Column 1 would be number of males and column 2 would be number of females in a brood. [,1][,2] [1,] 18 19 [2,]7 37 [3,]5 26 [4,]4 16 [5,]6 19 [6,]4 15 [7,] 15 14 [8,] 15 29 All the numbers in both columns are integers. You have not demonstrated that this is so. You could have offered str(data) What happens if you first do: data$y - as.integer(data$y) # ? (Sometimes floating points will be printed as though they were integers.) -- David I am able to use this same format for my response variable when using the glmer() function with no problem. In the documentation for glmmML, it says For the binomial families, the response can be a two-column matrix. Isn't that what I am using? Is it immediately obvious to anyone what is wrong with my input? Or perhaps I am doing something else wrong? Thanks so much in advance, Tom [[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. David Winsemius, MD West Hartford, CT __ 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] Tricky (?) conversion from data.frame to matrix where not all pairs exist
Marius Hofert m_hof...@web.de on Wed, 22 Jun 2011 01:00:21 +0200 writes: Thanks a lot! Works like charm :-))) Cheers, well, I'd still *strongly* vote for Bill Dunlap's version. Martin Marius On 2011-06-22, at 24:51 , Dennis Murphy wrote: Ahhh...you want a matrix. xtabs() doesn't easily allow coercion to a matrix object, so try this instead: library(reshape) as.matrix(cast(df, year ~ block, fill = 0)) a b c 2000 1 0 5 2001 2 4 6 2002 3 0 0 Hopefully this is more helpful... Dennis On Tue, Jun 21, 2011 at 3:35 PM, Dennis Murphy djmu...@gmail.com wrote: Hi: xtabs(value ~ year + block, data = df) block year a b c 2000 1 0 5 2001 2 4 6 2002 3 0 0 HTH, Dennis On Tue, Jun 21, 2011 at 3:13 PM, Marius Hofert m_hof...@web.de wrote: Dear expeRts, In the minimal example below, I have a data.frame containing three blocks of years (the years are subsets of 2000 to 2002). For each year and block a certain value is given. I would like to create a matrix that has row names given by all years (2000, 2001, 2002), and column names given by all blocks (a, b, c); the entries are then given by the corresponding value or zero if not year-block combination exists. What's a short way to achieve this? Of course one can setup a matrix and use for loops (see below)... but that's not nice. The problem is that the years are not running from 2000 to 2002 for all three blocks (the second block only has year 2001, the third one has only 2000 and 2001). In principle, table() nicely solves such a problem (see below) and fills in zeros. This is what I would like in the end, but all non-zero entries should be given by df$value, not (as table() does) by their counts. Cheers, Marius (df - data.frame(year=c(2000, 2001, 2002, 2001, 2000, 2001), block=c(a,a,a,b,c,c), value=1:6)) table(df[,1:2]) # complements the years and fills in 0 year - c(2000, 2001, 2002) block - c(a, b, c) res - matrix(0, nrow=3, ncol=3, dimnames=list(year, block)) for(i in 1:3){ # year for(j in 1:3){ # block for(k in 1:nrow(df)){ if(df[k,year]==year[i] df[k,block]==block[j]) res[i,j] - df[k,value] } } } res # does the job; but seems complicated __ 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] working with sparse matrix
David Winsemius dwinsem...@comcast.net on Tue, 21 Jun 2011 12:07:47 -0400 writes: On Jun 21, 2011, at 11:44 AM, Patrick Breheny wrote: On 06/21/2011 09:48 AM, davefrederick wrote: Hi, I have a 500x 53380 sparse matrix and I am trying to dichotomize it. Under sna package I have found event2dichot yet it doesnt recognize sparse matrix and requires adjacency matrix or array. I tried to run a simple loop code for (i in 1:500) for (j in 1:53380) if (matrix[i,j]0) matrix[i,j]=1 The code you are running does not require a loop: A - cbind(c(1,0),c(0,2)) A [,1] [,2] [1,]10 [2,]02 A[A0] - 1 A [,1] [,2] [1,] 1 0 [2,] 0 1 However, for large sparse matrices, this and other operations will be faster if the matrix is explicitly stored as a sparse matrix, as implemented in the 'Matrix' package. require(Matrix) M - Matrix(0, 10,10) # empty sparse matrix M[1:10, 1] - 1 M[1:10, 2] - 2 M[1:10, 3] - -3 M[M 0] - 1 M 10 x 10 sparse Matrix of class dgCMatrix [1,] 1 1 -3 . . . . . . . [2,] 1 1 -3 . . . . . . . [3,] 1 1 -3 . . . . . . . [4,] 1 1 -3 . . . . . . . [5,] 1 1 -3 . . . . . . . [6,] 1 1 -3 . . . . . . . [7,] 1 1 -3 . . . . . . . [8,] 1 1 -3 . . . . . . . [9,] 1 1 -3 . . . . . . . [10,] 1 1 -3 . . . . . . . M2 - as.matrix(M) M2 [,1] [,2] [,3] [,4] [,5] [,6] [,7] [,8] [,9] [,10] [1,]11 -3000000 0 [2,]11 -3000000 0 [3,]11 -3000000 0 [4,]11 -3000000 0 [5,]11 -3000000 0 [6,]11 -3000000 0 [7,]11 -3000000 0 [8,]11 -3000000 0 [9,]11 -3000000 0 [10,]11 -3000000 0 There might have been a one or two second pause while the last command was executing for this test: M - Matrix(0, 500, 53380 ) M[1:10, 1] - 1 M[1:10, 2] - 2 M[1:10, 3] - -3 M[M 0] - 1 Yes, that's much better, thank you, David. Just a short note: The above technique of M - Matrix(0, n, m) M[i,j] - v1 M[k,l] - v2 ... maybe natural to produce a sparse matrix, and ok for such very small examples, but it is typically *MUCH MUCH* less efficient than directly using the sparseMatrix() orspMatrix() functions which the Matrix package provides. M2 - as.matrix(M) Why would you have to make your sparse matrix dense? (It won't work for much larger matrices anyway: They can't exist in your RAM as dense ..)... Yes, I see you work with further code that does not accept sparse matrices. The glmnet package (lasso, etc) does it very nicely, {and if you use package 'MatrixModels', with model.Matrix() you can even use formulas to construct sparse (model) matrices as input for glmnet !}. After my imminent vacation {three weeks to Columbia and Ecuador!}, I'll gladly help package authors (eg of sna) to change their code such that it should work with sparse matrices. With regards, Martin Maechler, ETH Zurich -- David. -- Patrick Breheny Assistant Professor Department of Biostatistics Department of Statistics University of Kentucky David Winsemius, MD West Hartford, CT __ 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] ipred: possible to use svm in errorest?
On 21.06.2011 13:56, Daniel Stahl wrote: Dear all, is it possible to run the support vector machine command svm from the package e1071 within the errorest function from the library ipred? It works fine for lda and rda but I get an error message (see below) Thank you for your help. Best wsihes, Daneil # Classification data(iris) # force predict to return class labels only mypredict.lda- function(object, newdata) predict(object, newdata = newdata)$class # 10-fold cv of LDA for Iris data errorest(Species ~ ., data=iris, model=svm, estimator = cv, predict= mypredict.lda) Error in predict(object, newdata = newdata)$class : $ operator is invalid for atomic vectors The point of specifying a predict function is to tell errorest how to get the classes from predict(). Since predict.svm already returns the classes you can omit it: errorest(Species ~ ., data=iris, model=svm, estimator = cv) Uwe Ligges -- __ 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] [SOLVED] Italic fontfaces on specific labels.
Thank you for your help... It works very well! El mar, 21-06-2011 a las 20:03 -0700, Bert Gunter escribió: ?strip.default __ 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] Saved EPS/PDF graphics not same as JPG/BMP graphics
I guess you use the menu to save the plots from your Windows device into files rather than starting separate devices explicitly? If so, please use explicit calls to the devices and everything happens as you define it. Uwe Ligges On 22.06.2011 04:31, John Kruschke wrote: When I save a particular plot as JPG or BMP, the saved image is an accurate copy of that plot. But when I save the same plot as EPS or PDF, some text elements are incorrectly altered. An example is attached. Notice in the top middle and top right panels, the x-axis labels have correct subscript 1 in the JPG, but incorrect subscript 2 in the EPS. I'm using R 2.13.0 on Windows 7. Any clues regarding the source of this error and its solution would be appreciated. For example, are there EPS/PDF device drivers that need to be separately updated? Many thanks. John K. Kruschke, Professor http://www.indiana.edu/%7Ekruschke/DoingBayesianDataAnalysis/ __ 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] distribute variance
Hi All, I would like to use R to do some computation. However, before I proceed to write an R script, I have difficulty to find out a solution for the question below. Please note that the question below is not relating to question in R. I have a table below, 2009 2010 2011 2012 2013 2014 Albert 77.28 77.77 77.83 78.11 78.14 78.45 Edmund 87.20 88.00 88.43 89.05 89.07 91.06 Sandy 92.39 92.68 93.68 93.92 96.25 96.49 David 340.60 343.01 344.11 345.75 348.38 351.81 Kean 115.20 115.57 116.45 117.18 117.41 118.46 Janet 128.76 128.93 130.28 132.09 132.68 133.00 Lily 133.92 135.50 135.60 137.10 137.25 137.80 Total 975.35 981.46 986.38 993.20 999.18 1,007.07 Above table shows the total sales made by each sale person from year 2009-2014. A user can change the values in the table, let say, the total sales for Simon from 2009 to 2014 would like to be change to values as below, David 408.72 411.61 412.93 414.90 418.05 422.17 The total sales number should remain unchanged upon the changes made on David. The variance has to be absorbed proportionately by other sales person. Does anyone know a method to distribute the variance to others? Here was my first thought for the solution, For year 2009, the sales for David is changed to 408.72 from 340.60, so the difference is (408.72 -340.60) = 68.12. I'm thinking to divide the difference 68.12 by 6, which is 11.353. The sales for other persons will be subtracted 11.353. 2009 Albert 65.9243 Edmmund 75.8446 Sandy 81.0398 David 408.724 Kean 103.848 Janet 117.405 Lily 122.566 total 975.352 However, I've found out this doesn't work for case like a person sales is not sufficient for the subtraction. Let say if a person's total sales is 10++, then 10++ minus 11.353 would be a negative value. This is just an example, which may not be make sense to the case above. Does anyone have a better solution to distribute the variance, may be by weight or something? You help is very much appreciated. Again, I would like to emphasize that my question above is not related to R code, I just want to find out a methodology to solve the problem above. Thanks! [[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] Time-series analysis with treatment effects - statistical approach
Subject: [R] Time-series analysis with treatment effects - statistical approach Hello all R listers, I'm struggling to select an appropriate statistical method for my data set. I have collected soil moisture measurements every hour for 2 years. There are 75 sensors taking these automated measurements, spread evenly across 4 treatments and a control. I'm not interested in being able to predict soil future soil moisture trends, but rather in knowing whether the treatment affected soil moisture response overall. In particular, it would be interesting to inspect treatment related response within defined periods. For example, a visual inspection of my data suggests that soil moisture is equivalent across treatments during wet winter months, but during the dry summer months, a treatment effect appears. Any help on this topic would be very appreciated. I've looked far and wide through academic literature for similar experimental designs, but have not had any success as yet. Can you post your data? This makes it more interesting for potential responders and makes it more likely you get a relevant answer or observation. I guess the stats people would just suggest something like anova and you could just compare moisture means among the treatments and controls but presumably things are not stationary and it may be easy to get confusing results. http://en.wikipedia.org/wiki/Analysis_of_variance Usually there is some analysis plan made up a priori I would imagine or at least there is prior literature in your field. I guess citeseer or google scholar/books may be useful if you have some key words or author names. The data you have sounds to an engineer just like any other discrete time signal and maybe digital signal processing literature would be of interest. Presumably you have some models to test, and more details depend on the specifics of your competing hypotheses. Kalman filtering maybe? Cheers, Justin Dr. Justin Morgenroth New Zealand School of Forestry Christchurch, New Zealand -- View this message in context: http://r.789695.n4.nabble.com/Time-series-analysis-with-treatment-effects-statistical-approach-tp3615856p3615856.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.
Re: [R] Saved EPS/PDF graphics not same as JPG/BMP graphics
The error happens when using the savePlot() command, like this: savePlot( file=TestSavePlot.eps , type=eps ) savePlot( file=TestSavePlot.jpg , type=jpg ) The images in the two saved files are not the same, with the JPG being correct but the EPS being wrong. When you suggest starting separate devices explicitly, what do you mean? (I've skimmed through the results of ??device, but can't make sense of it.) Thank you! John K. Kruschke, Professor 2011/6/22 Uwe Ligges lig...@statistik.tu-dortmund.de I guess you use the menu to save the plots from your Windows device into files rather than starting separate devices explicitly? If so, please use explicit calls to the devices and everything happens as you define it. Uwe Ligges On 22.06.2011 04:31, John Kruschke wrote: When I save a particular plot as JPG or BMP, the saved image is an accurate copy of that plot. But when I save the same plot as EPS or PDF, some text elements are incorrectly altered. An example is attached. Notice in the top middle and top right panels, the x-axis labels have correct subscript 1 in the JPG, but incorrect subscript 2 in the EPS. I'm using R 2.13.0 on Windows 7. Any clues regarding the source of this error and its solution would be appreciated. For example, are there EPS/PDF device drivers that need to be separately updated? Many thanks. John K. Kruschke, Professor http://www.indiana.edu/%**7Ekruschke/**DoingBayesianDataAnalysis/http://www.indiana.edu/%7Ekruschke/DoingBayesianDataAnalysis/ __** R-help@r-project.org mailing list https://stat.ethz.ch/mailman/**listinfo/r-helphttps://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/** posting-guide.html 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] Saved EPS/PDF graphics not same as JPG/BMP graphics
On 22.06.2011 13:50, John Kruschke wrote: The error happens when using the savePlot() command, like this: savePlot( file=TestSavePlot.eps , type=eps ) savePlot( file=TestSavePlot.jpg , type=jpg ) Well, plot directly into a device, for postscript: postscript(estSavePlot.eps, additionalArguments .) plot(1:10) dev.off() Uwe Ligges The images in the two saved files are not the same, with the JPG being correct but the EPS being wrong. When you suggest starting separate devices explicitly, what do you mean? (I've skimmed through the results of ??device, but can't make sense of it.) Thank you! John K. Kruschke, Professor 2011/6/22 Uwe Liggeslig...@statistik.tu-dortmund.de I guess you use the menu to save the plots from your Windows device into files rather than starting separate devices explicitly? If so, please use explicit calls to the devices and everything happens as you define it. Uwe Ligges On 22.06.2011 04:31, John Kruschke wrote: When I save a particular plot as JPG or BMP, the saved image is an accurate copy of that plot. But when I save the same plot as EPS or PDF, some text elements are incorrectly altered. An example is attached. Notice in the top middle and top right panels, the x-axis labels have correct subscript 1 in the JPG, but incorrect subscript 2 in the EPS. I'm using R 2.13.0 on Windows 7. Any clues regarding the source of this error and its solution would be appreciated. For example, are there EPS/PDF device drivers that need to be separately updated? Many thanks. John K. Kruschke, Professor http://www.indiana.edu/%**7Ekruschke/**DoingBayesianDataAnalysis/http://www.indiana.edu/%7Ekruschke/DoingBayesianDataAnalysis/ __** R-help@r-project.org mailing list https://stat.ethz.ch/mailman/**listinfo/r-helphttps://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/** posting-guide.htmlhttp://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] Tricky (?) conversion from data.frame to matrix where not all pairs exist
On Jun 21, 2011, at 6:51 PM, Dennis Murphy wrote: Ahhh...you want a matrix. xtabs() doesn't easily allow coercion to a matrix object, so try this instead: What am I missing? A contingency table already inherits from matrix- class and if you insisted on coercion it appears simple: xtb - xtabs(value ~ year + block, data = df) is.matrix(xtb) [1] TRUE as.matrix(xtb) block year a b c 2000 1 0 5 2001 2 4 6 2002 3 0 0 -- David. library(reshape) as.matrix(cast(df, year ~ block, fill = 0)) a b c 2000 1 0 5 2001 2 4 6 2002 3 0 0 Hopefully this is more helpful... Dennis On Tue, Jun 21, 2011 at 3:35 PM, Dennis Murphy djmu...@gmail.com wrote: Hi: xtabs(value ~ year + block, data = df) block year a b c 2000 1 0 5 2001 2 4 6 2002 3 0 0 HTH, Dennis On Tue, Jun 21, 2011 at 3:13 PM, Marius Hofert m_hof...@web.de wrote: Dear expeRts, In the minimal example below, I have a data.frame containing three blocks of years (the years are subsets of 2000 to 2002). For each year and block a certain value is given. I would like to create a matrix that has row names given by all years (2000, 2001, 2002), and column names given by all blocks (a, b, c); the entries are then given by the corresponding value or zero if not year-block combination exists. What's a short way to achieve this? Of course one can setup a matrix and use for loops (see below)... but that's not nice. The problem is that the years are not running from 2000 to 2002 for all three blocks (the second block only has year 2001, the third one has only 2000 and 2001). In principle, table() nicely solves such a problem (see below) and fills in zeros. This is what I would like in the end, but all non-zero entries should be given by df$value, not (as table() does) by their counts. Cheers, Marius (df - data.frame(year=c(2000, 2001, 2002, 2001, 2000, 2001), block=c(a,a,a,b,c,c), value=1:6)) table(df[,1:2]) # complements the years and fills in 0 year - c(2000, 2001, 2002) block - c(a, b, c) res - matrix(0, nrow=3, ncol=3, dimnames=list(year, block)) for(i in 1:3){ # year for(j in 1:3){ # block for(k in 1:nrow(df)){ if(df[k,year]==year[i] df[k,block]==block[j]) res[i,j] - df[k,value] } } } res # does the job; but seems complicated David Winsemius, MD West Hartford, CT __ 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] GLS models and variance explained
Dear list, Inspecting residuals of my linear models, I detected spatial autocorrelation. In order to take this into account, I decided to use the GLS method with the correlation = corGaus ( ~ X + Y). Then, I can sort my GLS models based on their AIC. But ... how to know the proportion of the variance explained by the best one (it can be best of the worst models) ? R-squared value has not the same meaning for OLS and GLS ... - Could the R2 value calculated with the OLS model (using lm) constitute a potential proxy of the variance explained by the GLS model ? (the answer is probably no) - Is a R-squared based on sqrt(cor(obs, predicted)) a better approach ? - What about pseudo R-squared like Nagelkerke's ? Suggestions for any better approach are welcome ! Thanks in advance, Arnaud __ 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] Tricky (?) conversion from data.frame to matrix where not all pairs exist
I saw it as an xtabs object - I didn't think to check whether it was also a matrix object. Thanks for the clarification, David. Dennis On Wed, Jun 22, 2011 at 4:59 AM, David Winsemius dwinsem...@comcast.net wrote: On Jun 21, 2011, at 6:51 PM, Dennis Murphy wrote: Ahhh...you want a matrix. xtabs() doesn't easily allow coercion to a matrix object, so try this instead: What am I missing? A contingency table already inherits from matrix-class and if you insisted on coercion it appears simple: xtb - xtabs(value ~ year + block, data = df) is.matrix(xtb) [1] TRUE as.matrix(xtb) block year a b c 2000 1 0 5 2001 2 4 6 2002 3 0 0 -- David. library(reshape) as.matrix(cast(df, year ~ block, fill = 0)) a b c 2000 1 0 5 2001 2 4 6 2002 3 0 0 Hopefully this is more helpful... Dennis On Tue, Jun 21, 2011 at 3:35 PM, Dennis Murphy djmu...@gmail.com wrote: Hi: xtabs(value ~ year + block, data = df) block year a b c 2000 1 0 5 2001 2 4 6 2002 3 0 0 HTH, Dennis On Tue, Jun 21, 2011 at 3:13 PM, Marius Hofert m_hof...@web.de wrote: Dear expeRts, In the minimal example below, I have a data.frame containing three blocks of years (the years are subsets of 2000 to 2002). For each year and block a certain value is given. I would like to create a matrix that has row names given by all years (2000, 2001, 2002), and column names given by all blocks (a, b, c); the entries are then given by the corresponding value or zero if not year-block combination exists. What's a short way to achieve this? Of course one can setup a matrix and use for loops (see below)... but that's not nice. The problem is that the years are not running from 2000 to 2002 for all three blocks (the second block only has year 2001, the third one has only 2000 and 2001). In principle, table() nicely solves such a problem (see below) and fills in zeros. This is what I would like in the end, but all non-zero entries should be given by df$value, not (as table() does) by their counts. Cheers, Marius (df - data.frame(year=c(2000, 2001, 2002, 2001, 2000, 2001), block=c(a,a,a,b,c,c), value=1:6)) table(df[,1:2]) # complements the years and fills in 0 year - c(2000, 2001, 2002) block - c(a, b, c) res - matrix(0, nrow=3, ncol=3, dimnames=list(year, block)) for(i in 1:3){ # year for(j in 1:3){ # block for(k in 1:nrow(df)){ if(df[k,year]==year[i] df[k,block]==block[j]) res[i,j] - df[k,value] } } } res # does the job; but seems complicated David Winsemius, MD West Hartford, CT __ 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] (no subject)
..I cant imagine myself without this site! http://www.stadcopolyproducts.com/friends.page.php?utopic=07x1 [[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] Tricky (?) conversion from data.frame to matrix where not all pairs exist
Hi, and what's the simplest way to obtain a *data.frame* with all years? The matching seems more difficult here because the years can/will show up several times... (df - data.frame(year=c(2000, 2001, 2002, 2001, 2000, 2001), block=c(a,a,a,b,c,c), value=1:6)) (df. - data.frame(year=rep(2000:2002, 3), block=rep(c(a, b, c), each=3), value=0)) # how to fill in the given values? Cheers, Marius On 2011-06-22, at 14:40 , Dennis Murphy wrote: I saw it as an xtabs object - I didn't think to check whether it was also a matrix object. Thanks for the clarification, David. Dennis On Wed, Jun 22, 2011 at 4:59 AM, David Winsemius dwinsem...@comcast.net wrote: On Jun 21, 2011, at 6:51 PM, Dennis Murphy wrote: Ahhh...you want a matrix. xtabs() doesn't easily allow coercion to a matrix object, so try this instead: What am I missing? A contingency table already inherits from matrix-class and if you insisted on coercion it appears simple: xtb - xtabs(value ~ year + block, data = df) is.matrix(xtb) [1] TRUE as.matrix(xtb) block year a b c 2000 1 0 5 2001 2 4 6 2002 3 0 0 -- David. library(reshape) as.matrix(cast(df, year ~ block, fill = 0)) a b c 2000 1 0 5 2001 2 4 6 2002 3 0 0 Hopefully this is more helpful... Dennis On Tue, Jun 21, 2011 at 3:35 PM, Dennis Murphy djmu...@gmail.com wrote: Hi: xtabs(value ~ year + block, data = df) block year a b c 2000 1 0 5 2001 2 4 6 2002 3 0 0 HTH, Dennis On Tue, Jun 21, 2011 at 3:13 PM, Marius Hofert m_hof...@web.de wrote: Dear expeRts, In the minimal example below, I have a data.frame containing three blocks of years (the years are subsets of 2000 to 2002). For each year and block a certain value is given. I would like to create a matrix that has row names given by all years (2000, 2001, 2002), and column names given by all blocks (a, b, c); the entries are then given by the corresponding value or zero if not year-block combination exists. What's a short way to achieve this? Of course one can setup a matrix and use for loops (see below)... but that's not nice. The problem is that the years are not running from 2000 to 2002 for all three blocks (the second block only has year 2001, the third one has only 2000 and 2001). In principle, table() nicely solves such a problem (see below) and fills in zeros. This is what I would like in the end, but all non-zero entries should be given by df$value, not (as table() does) by their counts. Cheers, Marius (df - data.frame(year=c(2000, 2001, 2002, 2001, 2000, 2001), block=c(a,a,a,b,c,c), value=1:6)) table(df[,1:2]) # complements the years and fills in 0 year - c(2000, 2001, 2002) block - c(a, b, c) res - matrix(0, nrow=3, ncol=3, dimnames=list(year, block)) for(i in 1:3){ # year for(j in 1:3){ # block for(k in 1:nrow(df)){ if(df[k,year]==year[i] df[k,block]==block[j]) res[i,j] - df[k,value] } } } res # does the job; but seems complicated David Winsemius, MD West Hartford, CT __ 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] Help interpreting ANCOVA results
I think you should write out your model formula and then go over it term by term to see which term adds what to your understanding of the data. If necessary, pick up a text about the interpretation of coefficients. For example, you will find that Reduction is not just the slope for the condition QF:High. It is the slope for the entire sample. This implies you make an assumption that the slope is the same across all four conditions that the Dialect and Prediction dummies create. Best, Daniel Peter Milne wrote: Please help me interpret the following results. The full model (Schwa~Dialect*Prediction*Reduction) was reduced via both update() and step(). The minimal adequate model is: ancova-lm(Schwa~Dialect+Prediction+Reduction+Dialect:Prediction) Schwa is response variable Dialect is factor, two levels (QF,SF) Prediction is factor, two levels (High,Low) Reduction is covariate summary(ancova) yields: Coefficients: Estimate Std. Error t value Pr(|t|) (Intercept) 0.580470.09865 5.8849e-07 *** DialectSF -0.118190.08513 -1.388 0.173315 PredictionLow -0.493090.13650 -3.612 0.000896 *** Reduction -0.534880.15354 -3.484 0.001289 ** DialectSF:PredictionLow 0.494940.14627 3.384 0.001703 ** I know that the (Intercept) is the intercept for the first levels of both factors (QF.High) I know that Reduction is the slope for the first levels of both factors (QF.High) What i don't know is: Is DialectSF the difference in intercepts between QF.High and SF.High? Is PredictionLow the difference in intercepts between QF.High and QF.Low? Is DialectSF:PredictionLow the difference in slope from Reduction? If it's the slope, how do I find out the intercept? With 2X2 factors and one interaction term, how many parameters am I estimating? One slope and 4 intercepts? Or 3 intercepts and 2 slopes? Thanks, Peter [[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://r.789695.n4.nabble.com/Help-interpreting-ANCOVA-results-tp3615352p3617024.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] Tricky (?) conversion from data.frame to matrix where not all pairs exist
On Jun 22, 2011, at 9:19 AM, Marius Hofert wrote: Hi, and what's the simplest way to obtain a *data.frame* with all years? The matching seems more difficult here because the years can/will show up several times... (df - data.frame(year=c(2000, 2001, 2002, 2001, 2000, 2001), block=c(a,a,a,b,c,c), value=1:6)) (df. - data.frame(year=rep(2000:2002, 3), block=rep(c(a, b, c), each=3), value=0)) # how to fill in the given values? These days I think most people would reach for melt() in either reshape or reshape2 packages: require(reshape2) Loading required package: reshape2 melt(xtb) year block value 1 2000 a 1 2 2001 a 2 3 2002 a 3 4 2000 b 0 5 2001 b 4 6 2002 b 0 7 2000 c 5 8 2001 c 6 9 2002 c 0 It seems to do a good job of guessing what you want whereas the reshape function in my hands is very failure prone (... yes, the failings are mine.) -- David Cheers, Marius On 2011-06-22, at 14:40 , Dennis Murphy wrote: I saw it as an xtabs object - I didn't think to check whether it was also a matrix object. Thanks for the clarification, David. Dennis On Wed, Jun 22, 2011 at 4:59 AM, David Winsemius dwinsem...@comcast.net wrote: On Jun 21, 2011, at 6:51 PM, Dennis Murphy wrote: Ahhh...you want a matrix. xtabs() doesn't easily allow coercion to a matrix object, so try this instead: What am I missing? A contingency table already inherits from matrix-class and if you insisted on coercion it appears simple: xtb - xtabs(value ~ year + block, data = df) is.matrix(xtb) [1] TRUE as.matrix(xtb) block year a b c 2000 1 0 5 2001 2 4 6 2002 3 0 0 -- David. library(reshape) as.matrix(cast(df, year ~ block, fill = 0)) a b c 2000 1 0 5 2001 2 4 6 2002 3 0 0 Hopefully this is more helpful... Dennis On Tue, Jun 21, 2011 at 3:35 PM, Dennis Murphy djmu...@gmail.com wrote: Hi: xtabs(value ~ year + block, data = df) block year a b c 2000 1 0 5 2001 2 4 6 2002 3 0 0 HTH, Dennis On Tue, Jun 21, 2011 at 3:13 PM, Marius Hofert m_hof...@web.de wrote: Dear expeRts, In the minimal example below, I have a data.frame containing three blocks of years (the years are subsets of 2000 to 2002). For each year and block a certain value is given. I would like to create a matrix that has row names given by all years (2000, 2001, 2002), and column names given by all blocks (a, b, c); the entries are then given by the corresponding value or zero if not year-block combination exists. What's a short way to achieve this? Of course one can setup a matrix and use for loops (see below)... but that's not nice. The problem is that the years are not running from 2000 to 2002 for all three blocks (the second block only has year 2001, the third one has only 2000 and 2001). In principle, table() nicely solves such a problem (see below) and fills in zeros. This is what I would like in the end, but all non-zero entries should be given by df$value, not (as table() does) by their counts. Cheers, Marius (df - data.frame(year=c(2000, 2001, 2002, 2001, 2000, 2001), block=c(a,a,a,b,c,c), value=1:6)) table(df[,1:2]) # complements the years and fills in 0 year - c(2000, 2001, 2002) block - c(a, b, c) res - matrix(0, nrow=3, ncol=3, dimnames=list(year, block)) for(i in 1:3){ # year for(j in 1:3){ # block for(k in 1:nrow(df)){ if(df[k,year]==year[i] df[k,block]==block[j]) res[i,j] - df[k,value] } } } res # does the job; but seems complicated David Winsemius, MD West Hartford, CT __ 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. David Winsemius, MD West Hartford, CT __ 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 Needed on Merging Columns by Summation
Dear Sirs/Madam, I am a beginner to R, and I am currently working on a data matrix which looks like this: head(oligo) ko:K1 ko:K3 ko:K5 ko:K8 ko:K9 ko:K00010 ko:K00012 AAA 370 631 365 67 164 455 491 KAA 603 1208 170 15768 495 922 NAA60 110 10744 5194 DAA 183 80241 62 26 166 263 CAA5812581 1 23 8 TAA 451 468 20190 131 320 518 For certain specific columns, I need to merge the columns in such a way that the elements get added together. For example, in order to merge the first and the second columns, my output for the first row shld be ko:K1/ko:K3 AAA 1001 (i.e. 370+631) KAA1811 (i.e. 603+1208) and so on for the whole column. A colleague suggested using rowsum, but that seems to add up all the rows for ALL the columns and not just specified ones. Also, the output doesnt contain the column or row headers. Could you please suggest a solution? Yours sincerely Nabila Binte Zahur __ 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] analysing a three level reponse
Hello, I am struggling to figure out how to analyse a dataset I have inherited (please note this was conducted some time ago, so the data is as it is, and I know it isn't perfect!). A brief description of the experiment follows: Pots of grass were grown in 1l pots of standad potting medium for 1 month with a regular light and watering regime. At this point they were randomly given 1l of one of 4 different pesticides at one of 4 different concentrations (100%, 75%, 50% or 25% in water). There were 20 pots of grass for each pesticide/concentration giving 320 pots. There were no control (untreated) pots. The response was measured after 1 week and recorded as either: B1 - grass dead B2 - grass affected but not dead B3 - no visible effect I could analyse this as lethal effect vs non-lethal effect (B1 vs B2+B3) or some effect vs no effect (B1+B2 vs B3) binomial model, but I can't see how to do it with three levels. Any pointing in the right direction greatly appreciated! Thanks Matt -- Disclaimer: This email and any files transmitted with it are confidential and intended solely for the use of the individual or entity to whom they are addressed. If you have received this email in error please notify me at matt.el...@basc.org.uk then delete it. BASC may monitor email traffic. By replying to this e-mail you consent to BASC monitoring the content of any email you send or receive from BASC. Any views expressed in this message are those of the individual sender, except where the sender specifies with authority, states them to be the views of the British Association for Shooting and Conservation. BASC can confirm that this email message and any attachments have been scanned for the presence of computer viruses but recommends that you make your own virus checks. Registered Industrial and Provident Society No.: 28488R. Registered Office: Marford Mill, Rossett, Wrexham, LL12 0HL. -- [[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 with winbugs code
Good afternoon sir, i'm a student in Indonesia who study technology management, i need to review the software i'v been develop, i was told to use bayesian SEM because i don't have large sample. i don't know much about statistics but i try to make a code via winbugs.. and a i got a problem. here i attach my winbugs code and my model. could you hep me to find what's wrong with my code? thank you very much for your answer __ 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 plot 4 variable/distribution as tetrahedral
Dear all, I am a new user of R. I want use R to plot four momentum vectors(variable) in form of tetrahedral. The data(momentum vector) is in form of distribution(e.g. momentum of particle1 vs intensity). Thanks in advance. Best Regards Rajesh -- View this message in context: http://r.789695.n4.nabble.com/How-to-plot-4-variable-distribution-as-tetrahedral-tp3616629p3616629.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 to add label to lines()
I am plotting a number of lines on a standard plot. I would like to add labels at the end (rhs) of each line. is there a way to do this other than defining the individual xy coordinates and placing each label using text() Thanks Nevil Amos __ 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] Help Needed on Merging Columns by Summation
Hi: Based on the information you provided, I would suggest looking into the transform() and within() functions in base R, and perhaps the mutate() function in package plyr. HTH, Dennis On Tue, Jun 21, 2011 at 11:35 PM, Nabila Binte Zahur nab...@nus.edu.sg wrote: Dear Sirs/Madam, I am a beginner to R, and I am currently working on a data matrix which looks like this: head(oligo) ko:K1 ko:K3 ko:K5 ko:K8 ko:K9 ko:K00010 ko:K00012 AAA 370 631 365 67 164 455 491 KAA 603 1208 170 157 68 495 922 NAA 60 110 10 7 44 51 94 DAA 183 802 41 62 26 166 263 CAA 58 12 58 1 1 23 8 TAA 451 468 201 90 131 320 518 For certain specific columns, I need to merge the columns in such a way that the elements get added together. For example, in order to merge the first and the second columns, my output for the first row shld be ko:K1/ko:K3 AAA 1001 (i.e. 370+631) KAA 1811 (i.e. 603+1208) and so on for the whole column. A colleague suggested using rowsum, but that seems to add up all the rows for ALL the columns and not just specified ones. Also, the output doesnt contain the column or row headers. Could you please suggest a solution? Yours sincerely Nabila Binte Zahur __ 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] Tricky (?) conversion from data.frame to matrix where not all pairs exist
Hi David, thanks for the quick response. That's nice. Is there also a way without loading an additional package? I'd prefer loading less packages if possible. Cheers, Marius On 2011-06-22, at 15:38 , David Winsemius wrote: On Jun 22, 2011, at 9:19 AM, Marius Hofert wrote: Hi, and what's the simplest way to obtain a *data.frame* with all years? The matching seems more difficult here because the years can/will show up several times... (df - data.frame(year=c(2000, 2001, 2002, 2001, 2000, 2001), block=c(a,a,a,b,c,c), value=1:6)) (df. - data.frame(year=rep(2000:2002, 3), block=rep(c(a, b, c), each=3), value=0)) # how to fill in the given values? These days I think most people would reach for melt() in either reshape or reshape2 packages: require(reshape2) Loading required package: reshape2 melt(xtb) year block value 1 2000 a 1 2 2001 a 2 3 2002 a 3 4 2000 b 0 5 2001 b 4 6 2002 b 0 7 2000 c 5 8 2001 c 6 9 2002 c 0 It seems to do a good job of guessing what you want whereas the reshape function in my hands is very failure prone (... yes, the failings are mine.) -- David Cheers, Marius On 2011-06-22, at 14:40 , Dennis Murphy wrote: I saw it as an xtabs object - I didn't think to check whether it was also a matrix object. Thanks for the clarification, David. Dennis On Wed, Jun 22, 2011 at 4:59 AM, David Winsemius dwinsem...@comcast.net wrote: On Jun 21, 2011, at 6:51 PM, Dennis Murphy wrote: Ahhh...you want a matrix. xtabs() doesn't easily allow coercion to a matrix object, so try this instead: What am I missing? A contingency table already inherits from matrix-class and if you insisted on coercion it appears simple: xtb - xtabs(value ~ year + block, data = df) is.matrix(xtb) [1] TRUE as.matrix(xtb) block year a b c 2000 1 0 5 2001 2 4 6 2002 3 0 0 -- David. library(reshape) as.matrix(cast(df, year ~ block, fill = 0)) a b c 2000 1 0 5 2001 2 4 6 2002 3 0 0 Hopefully this is more helpful... Dennis On Tue, Jun 21, 2011 at 3:35 PM, Dennis Murphy djmu...@gmail.com wrote: Hi: xtabs(value ~ year + block, data = df) block year a b c 2000 1 0 5 2001 2 4 6 2002 3 0 0 HTH, Dennis On Tue, Jun 21, 2011 at 3:13 PM, Marius Hofert m_hof...@web.de wrote: Dear expeRts, In the minimal example below, I have a data.frame containing three blocks of years (the years are subsets of 2000 to 2002). For each year and block a certain value is given. I would like to create a matrix that has row names given by all years (2000, 2001, 2002), and column names given by all blocks (a, b, c); the entries are then given by the corresponding value or zero if not year-block combination exists. What's a short way to achieve this? Of course one can setup a matrix and use for loops (see below)... but that's not nice. The problem is that the years are not running from 2000 to 2002 for all three blocks (the second block only has year 2001, the third one has only 2000 and 2001). In principle, table() nicely solves such a problem (see below) and fills in zeros. This is what I would like in the end, but all non-zero entries should be given by df$value, not (as table() does) by their counts. Cheers, Marius (df - data.frame(year=c(2000, 2001, 2002, 2001, 2000, 2001), block=c(a,a,a,b,c,c), value=1:6)) table(df[,1:2]) # complements the years and fills in 0 year - c(2000, 2001, 2002) block - c(a, b, c) res - matrix(0, nrow=3, ncol=3, dimnames=list(year, block)) for(i in 1:3){ # year for(j in 1:3){ # block for(k in 1:nrow(df)){ if(df[k,year]==year[i] df[k,block]==block[j]) res[i,j] - df[k,value] } } } res # does the job; but seems complicated David Winsemius, MD West Hartford, CT __ 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. David Winsemius, MD West Hartford, CT __ 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 add label to lines()
On 11-06-21 10:31 AM, Nevil Amos wrote: I am plotting a number of lines on a standard plot. I would like to add labels at the end (rhs) of each line. is there a way to do this other than defining the individual xy coordinates and placing each label using text() Probably, but what you describe is the best way. Duncan Murdoch __ 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] Help Needed on Merging Columns by Summation
On Wed, Jun 22, 2011 at 2:35 AM, Nabila Binte Zahur nab...@nus.edu.sg wrote: Dear Sirs/Madam, I am a beginner to R, and I am currently working on a data matrix which looks like this: head(oligo) ko:K1 ko:K3 ko:K5 ko:K8 ko:K9 ko:K00010 ko:K00012 AAA 370 631 365 67 164 455 491 KAA 603 1208 170 157 68 495 922 NAA 60 110 10 7 44 51 94 DAA 183 802 41 62 26 166 263 CAA 58 12 58 1 1 23 8 TAA 451 468 201 90 131 320 518 For certain specific columns, I need to merge the columns in such a way that the elements get added together. For example, in order to merge the first and the second columns, my output for the first row shld be ko:K1/ko:K3 AAA 1001 (i.e. 370+631) KAA 1811 (i.e. 603+1208) and so on for the whole column. Define a by vector (called collapse here) that has equal numbers for columns to be collapsed and distinct numbers for those that are not to be collapsed.We then transpose, use rowsum and transpose back. Assuming DF is the data frame we have: collapse - c(1, 1, 3:7) setNames(as.data.frame(t(rowsum(t(DF), collapse))), tapply(names(DF), collapse, paste, collapse = /)) -- Statistics Software Consulting GKX Group, GKX Associates Inc. tel: 1-877-GKX-GROUP email: ggrothendieck at gmail.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] Package warnings
On 11-06-21 11:58 PM, steven mosher wrote: Thanks to all your help I've just finished my first package and I have a couple of questions I want to submit to CRAN but I have 1 warning checking for code/documentation mismatches ... WARNING Data sets with usage in documentation object 'FILE.PARAMETERS' but not in code: FILE.PARAMETERS I actually have a few instances with the same issue. I have a handful of data objects, things like URLs and some file parameters ( like column widths etc). These are declared in an R file and then loaded (lazyData no) There are help files for all these objects, and some of them get used in the code as defaults for when functions are called foo- function( x, y=FILE.PARAMETERS) So why do I get this warning? is it one I have to fix? and should I be asking this on the dev list? Yes, you should fix almost all warnings, and yes, questions like this belong on the R-devel list. When you ask there, it would be helpful to be very specific: show us the start of the Rd file that is being complained about (the \usage and \docType sections are of particular interest), and give us the exact details about how the data object is being created. Duncan Murdoch Thanks again for all your help, hope this is right place to ask. [[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] analysing a three level reponse
You could analyze these data with a multinomial logit model, with an ordinal response. I don't have my copy handy, but I know that Agresti (Categorical Data Analysis, Wiley) covers these models. Cheers David Cross d.cr...@tcu.edu www.davidcross.us On Jun 22, 2011, at 8:19 AM, Matt Ellis (Research) wrote: Hello, I am struggling to figure out how to analyse a dataset I have inherited (please note this was conducted some time ago, so the data is as it is, and I know it isn't perfect!). A brief description of the experiment follows: Pots of grass were grown in 1l pots of standad potting medium for 1 month with a regular light and watering regime. At this point they were randomly given 1l of one of 4 different pesticides at one of 4 different concentrations (100%, 75%, 50% or 25% in water). There were 20 pots of grass for each pesticide/concentration giving 320 pots. There were no control (untreated) pots. The response was measured after 1 week and recorded as either: B1 - grass dead B2 - grass affected but not dead B3 - no visible effect I could analyse this as lethal effect vs non-lethal effect (B1 vs B2+B3) or some effect vs no effect (B1+B2 vs B3) binomial model, but I can't see how to do it with three levels. Any pointing in the right direction greatly appreciated! Thanks Matt -- Disclaimer: This email and any files transmitted with it are confidential and intended solely for the use of the individual or entity to whom they are addressed. If you have received this email in error please notify me at matt.el...@basc.org.uk then delete it. BASC may monitor email traffic. By replying to this e-mail you consent to BASC monitoring the content of any email you send or receive from BASC. Any views expressed in this message are those of the individual sender, except where the sender specifies with authority, states them to be the views of the British Association for Shooting and Conservation. BASC can confirm that this email message and any attachments have been scanned for the presence of computer viruses but recommends that you make your own virus checks. Registered Industrial and Provident Society No.: 28488R. Registered Office: Marford Mill, Rossett, Wrexham, LL12 0HL. -- [[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] Tricky (?) conversion from data.frame to matrix where not all pairs exist
On Jun 22, 2011, at 9:46 AM, Marius Hofert wrote: Hi David, thanks for the quick response. That's nice. Is there also a way without loading an additional package? I'd prefer loading less packages if possible. xtb - xtabs(value ~ year + block, data = df) xtb block year a b c 2000 1 0 5 2001 2 4 6 2002 3 0 0 as.data.frame(xtb) year block Freq 1 2000 a1 2 2001 a2 3 2002 a3 4 2000 b0 5 2001 b4 6 2002 b0 7 2000 c5 8 2001 c6 9 2002 c0 xt.df - as.data.frame(xtb) xt.df[xt.df[,3] != 0 , ] year block Freq 1 2000 a1 2 2001 a2 3 2002 a3 5 2001 b4 7 2000 c5 8 2001 c6 As Hadley pointed out yesterday this does coerce the margin names to factors, str(xt.df) 'data.frame': 9 obs. of 3 variables: $ year : Factor w/ 3 levels 2000,2001,..: 1 2 3 1 2 3 1 2 3 $ block: Factor w/ 3 levels a,b,c: 1 1 1 2 2 2 3 3 3 $ Freq : num 1 2 3 0 4 0 5 6 0 -- David. Cheers, Marius On 2011-06-22, at 15:38 , David Winsemius wrote: On Jun 22, 2011, at 9:19 AM, Marius Hofert wrote: Hi, and what's the simplest way to obtain a *data.frame* with all years? The matching seems more difficult here because the years can/will show up several times... (df - data.frame(year=c(2000, 2001, 2002, 2001, 2000, 2001), block=c(a,a,a,b,c,c), value=1:6)) (df. - data.frame(year=rep(2000:2002, 3), block=rep(c(a, b, c), each=3), value=0)) # how to fill in the given values? These days I think most people would reach for melt() in either reshape or reshape2 packages: require(reshape2) Loading required package: reshape2 melt(xtb) year block value 1 2000 a 1 2 2001 a 2 3 2002 a 3 4 2000 b 0 5 2001 b 4 6 2002 b 0 7 2000 c 5 8 2001 c 6 9 2002 c 0 It seems to do a good job of guessing what you want whereas the reshape function in my hands is very failure prone (... yes, the failings are mine.) -- David Cheers, Marius On 2011-06-22, at 14:40 , Dennis Murphy wrote: I saw it as an xtabs object - I didn't think to check whether it was also a matrix object. Thanks for the clarification, David. Dennis On Wed, Jun 22, 2011 at 4:59 AM, David Winsemius dwinsem...@comcast.net wrote: On Jun 21, 2011, at 6:51 PM, Dennis Murphy wrote: Ahhh...you want a matrix. xtabs() doesn't easily allow coercion to a matrix object, so try this instead: What am I missing? A contingency table already inherits from matrix-class and if you insisted on coercion it appears simple: xtb - xtabs(value ~ year + block, data = df) is.matrix(xtb) [1] TRUE as.matrix(xtb) block year a b c 2000 1 0 5 2001 2 4 6 2002 3 0 0 -- David. library(reshape) as.matrix(cast(df, year ~ block, fill = 0)) a b c 2000 1 0 5 2001 2 4 6 2002 3 0 0 Hopefully this is more helpful... Dennis On Tue, Jun 21, 2011 at 3:35 PM, Dennis Murphy djmu...@gmail.com wrote: Hi: xtabs(value ~ year + block, data = df) block year a b c 2000 1 0 5 2001 2 4 6 2002 3 0 0 HTH, Dennis On Tue, Jun 21, 2011 at 3:13 PM, Marius Hofert m_hof...@web.de wrote: Dear expeRts, In the minimal example below, I have a data.frame containing three blocks of years (the years are subsets of 2000 to 2002). For each year and block a certain value is given. I would like to create a matrix that has row names given by all years (2000, 2001, 2002), and column names given by all blocks (a, b, c); the entries are then given by the corresponding value or zero if not year-block combination exists. What's a short way to achieve this? Of course one can setup a matrix and use for loops (see below)... but that's not nice. The problem is that the years are not running from 2000 to 2002 for all three blocks (the second block only has year 2001, the third one has only 2000 and 2001). In principle, table() nicely solves such a problem (see below) and fills in zeros. This is what I would like in the end, but all non-zero entries should be given by df$value, not (as table() does) by their counts. Cheers, Marius (df - data.frame(year=c(2000, 2001, 2002, 2001, 2000, 2001), block=c(a,a,a,b,c,c), value=1:6)) table(df[,1:2]) # complements the years and fills in 0 year - c(2000, 2001, 2002) block - c(a, b, c) res - matrix(0, nrow=3, ncol=3, dimnames=list(year, block)) for(i in 1:3){ # year for(j in 1:3){ # block for(k in 1:nrow(df)){ if(df[k,year]==year[i] df[k,block]==block[j]) res[i,j] - df[k,value] } } } res # does the job; but seems complicated David Winsemius, MD West Hartford, CT __ 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. David Winsemius, MD West Hartford, CT
Re: [R] How to add label to lines()
On Jun 21, 2011, at 10:31 AM, Nevil Amos wrote: I am plotting a number of lines on a standard plot. I would like to add labels at the end (rhs) of each line. is there a way to do this other than defining the individual xy coordinates and placing each label using text() Without an example it is difficult to know if your coding is efficient. The text fn is vectorized, so there may be a one-liner that does what you could be currently doing piecemeal. plot(1,1) for( b in 1-(1:5)/20) abline(a=0,b=b) text(1.4, 1.4*(1-(1:5)/20), as.character(1-(1:5)/20) ) -- David Winsemius, MD West Hartford, CT __ 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] Documenting variables, dataframes and files?
Every now and then I realize that my attempts to document what all dataframes consist of are unsufficient. So far, I have been writing notes in an external file. Are there any better ways to do this within R? One possibility could be to set up the data as packages, but I would like to have a solution on a lower level, closer to data. I can't find any pointers in the standard manuals. Suggestions are most welcome. Robert ** Robert Lundqvist Norrbotten regional council Sweden [[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] Setting up list of many equations for systemfit
Thanks for the suggestion, Dennis. Unfortunately, I was not able to make it work. Maybe I'm not using as.formula properly. I posted below some new things I tried. What am I doing wrong? Thanks for any feedback! Rita First attempt: eqSystem2 -paste(paste(form, 1:4, sep=), as.formula(paste(EQ, 1:4,sep=)),sep==) eqSystem2 RESULT: [1] form1=~form2=Y1 form3=X1 + X2 + X4 form4=~ Second attempt: eqSystem2 -paste(paste(form, 1:4, sep=), paste(EQ, 1:4,sep=),sep==) eqSystem2 -as.formula(eqSystem2) eqSystem2 RESULT:Y1 ~ X1 + X2 + X4 Third attempt: eqSystem2 -paste(paste(form, 1:4, sep=),paste(EQ, 1:4,sep=), sep==) eqSystem2 -as.list(eqSystem2) eqSystem2 -as.formula(eqSystem2) eqSystem2 RESULT: Error in formula.default(object, env = baseenv()) : invalid formula [[1]] [1] form1=EQ1 [[2]] [1] form2=EQ2 [[3]] [1] form3=EQ3 [[4]] [1] form4=EQ4 Fourth attempt: eqSystem2 -paste(paste(form, 1:4, sep=),paste(EQ, 1:4,sep=), sep==) eqSystem2 -as.formula(eqSystem2) eqSystem2 -as.list(eqSystem2) eqSystem2 RESULT: [[1]] `~` [[2]] Y1 [[3]] X1 + X2 + X4 Date: Wed, 22 Jun 2011 01:36:28 +0300 From: d.kazakiew...@gmail.com To: ritacarre...@hotmail.com CC: r-help@r-project.org Subject: Re: [R] Setting up list of many equations for systemfit Why don't try as.formula() function On 22.06.2011 01:22, Rita Carreira wrote: Dear List Members,I am trying to set up a large system of equations and I am trying to find a simple way to set up the list command under the package system fit. Here is the example from system fit and what I am trying to do: EQ1- Y1 ~ X1 + X2 + X4EQ2- Y2 ~ X2 + X3EQ3- Y3 ~ X2 + X3 + X4EQ4- Y4 ~ X1 + X3 + X4eqSystem-list(form1 = EQ1, form2 = EQ2, form3 = EQ3, form4 = EQ4) #atempt 1 to automate above:eqSystem1-paste(paste(form, 1:4, sep=), paste(EQ, 1:4,sep=),sep==) #attempt 2 automate above:eqSystem2-as.list(paste(paste(form, 1:4, sep=), paste(EQ, 1:4,sep=),sep==)) Here are the results: The results that I want to get: eqSystem1$form1Y1 ~ X1 + X2 + X4 $form2Y2 ~ X2 + X3 $form3Y3 ~ X2 + X3 + X4 $form4Y4 ~ X1 + X3 + X4 The results of my attempts:attempt 1: eqSystem1 [1] form1=EQ1 form2=EQ2 form3=EQ3 form4=EQ4 attempt 2: eqSystem2[[1]] [1] form1=EQ1 [[2]] [1] form2=EQ2 [[3]] [1] form3=EQ3 [[4]] [1] form4=EQ4 Does anyone have any ideas on how to correct my code? Thanks, Rita = If you think education is expensive, try ignorance.--Derek Bok [[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. [[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] setting 'layout' locally within functions
Using layout I've created a function that makes a 2 panel plot - comprising a main plot, and a sub-panel with custom legend. I would now like to use layout to create multiple panels with plots created by my function, however the values for layout set in the function act globally, stopping me from setting this up how I want. So if I say: layout(matrix(1:2, 1,2)) my.plot(data) I end up with a single plot according the layout format specified by the function, rather than a plot generated by the function in the left hand panel of the matrix that should be specified by the first layout command. Is there a way to use layout in a subsetable, hierarchical way? Thanks, Simon -- View this message in context: http://r.789695.n4.nabble.com/setting-layout-locally-within-functions-tp3617257p3617257.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] analysing a three level reponse
The best method would probably be proportional odds regression using polyr() in 'MASS'. At least it's a starting point. At 09:19 AM 6/22/2011, Matt Ellis \(Research\) wrote: Hello, I am struggling to figure out how to analyse a dataset I have inherited (please note this was conducted some time ago, so the data is as it is, and I know it isn't perfect!). A brief description of the experiment follows: Pots of grass were grown in 1l pots of standad potting medium for 1 month with a regular light and watering regime. At this point they were randomly given 1l of one of 4 different pesticides at one of 4 different concentrations (100%, 75%, 50% or 25% in water). There were 20 pots of grass for each pesticide/concentration giving 320 pots. There were no control (untreated) pots. The response was measured after 1 week and recorded as either: B1 - grass dead B2 - grass affected but not dead B3 - no visible effect I could analyse this as lethal effect vs non-lethal effect (B1 vs B2+B3) or some effect vs no effect (B1+B2 vs B3) binomial model, but I can't see how to do it with three levels. Any pointing in the right direction greatly appreciated! Thanks Matt -- Disclaimer: This email and any files transmitted with it are confidential and intended solely for the use of the individual or entity to whom they are addressed. If you have received this email in error please notify me at matt.el...@basc.org.uk then delete it. BASC may monitor email traffic. By replying to this e-mail you consent to BASC monitoring the content of any email you send or receive from BASC. Any views expressed in this message are those of the individual sender, except where the sender specifies with authority, states them to be the views of the British Association for Shooting and Conservation. BASC can confirm that this email message and any attachments have been scanned for the presence of computer viruses but recommends that you make your own virus checks. Registered Industrial and Provident Society No.: 28488R. Registered Office: Marford Mill, Rossett, Wrexham, LL12 0HL. -- [[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. Robert A. LaBudde, PhD, PAS, Dpl. ACAFS e-mail: r...@lcfltd.com Least Cost Formulations, Ltd.URL: http://lcfltd.com/ 824 Timberlake Drive Tel: 757-467-0954 Virginia Beach, VA 23464-3239Fax: 757-467-2947 Vere scire est per causas scire __ 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 using glmmML()
Tom, thanks for spotting a bug in glmmML; internally, glmmML sorts data by cluster. The bug is that I missed to sort the weights accordingly. Weights are produced when the response is a two-column matrix, as in your case. So, glmmML calls glm.fit with wrong weights, and the warning comes from that. Unfortunately, this also affects the rest of the fitting procedure. I will fix this asap. Meanwhile, a possible workaround: Sort your data.frame by cluster before calling glmmML. Göran On Wed, Jun 22, 2011 at 5:13 AM, Tom Kraft thomas.s.kr...@dartmouth.edu wrote: Dear all, This question is basic but I am stumped. After running the below, I receive the message: non-integer #successes in a binomial glm! model1 - glmmML(y~Brood.Size*Density+Date.Placed+Species+Placed.Emerging+Year+rate.of.parperplot, data = data, cluster= data$Patch, family=binomial(link=logit)) My response variable is sex ratio, and I have learned quickly not to use proportion values as data. Instead, my response variable y is a 2 column matrix that looks like the following but with more rows. Column 1 would be number of males and column 2 would be number of females in a brood. [,1] [,2] [1,] 18 19 [2,] 7 37 [3,] 5 26 [4,] 4 16 [5,] 6 19 [6,] 4 15 [7,] 15 14 [8,] 15 29 All the numbers in both columns are integers. I am able to use this same format for my response variable when using the glmer() function with no problem. In the documentation for glmmML, it says For the binomial families, the response can be a two-column matrix. Isn't that what I am using? Is it immediately obvious to anyone what is wrong with my input? Or perhaps I am doing something else wrong? Thanks so much in advance, Tom [[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. -- Göran Broström __ 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] Package warnings
Thanks Duncan, I'll join Dev and ask the questions over there. Steve On Wed, Jun 22, 2011 at 7:19 AM, Duncan Murdoch murdoch.dun...@gmail.comwrote: On 11-06-21 11:58 PM, steven mosher wrote: Thanks to all your help I've just finished my first package and I have a couple of questions I want to submit to CRAN but I have 1 warning checking for code/documentation mismatches ... WARNING Data sets with usage in documentation object 'FILE.PARAMETERS' but not in code: FILE.PARAMETERS I actually have a few instances with the same issue. I have a handful of data objects, things like URLs and some file parameters ( like column widths etc). These are declared in an R file and then loaded (lazyData no) There are help files for all these objects, and some of them get used in the code as defaults for when functions are called foo- function( x, y=FILE.PARAMETERS) So why do I get this warning? is it one I have to fix? and should I be asking this on the dev list? Yes, you should fix almost all warnings, and yes, questions like this belong on the R-devel list. When you ask there, it would be helpful to be very specific: show us the start of the Rd file that is being complained about (the \usage and \docType sections are of particular interest), and give us the exact details about how the data object is being created. Duncan Murdoch Thanks again for all your help, hope this is right place to ask. [[alternative HTML version deleted]] __** R-help@r-project.org mailing list https://stat.ethz.ch/mailman/**listinfo/r-helphttps://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/** posting-guide.html 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] Documenting variables, dataframes and files?
There is a 'comment' function. It sets an attribute which gets carried along with the dataframe when it is saved or copied: df1 -data.frame(NA) df1 NA. 1 NA comment(df1) - empty dataframe comment(df1) [1] empty dataframe df2 - df1 comment(df2) - c(comment(df1), copy of df1) comment(df2) [1] empty dataframe copy of df1 comment(df1) - c(empty dataframe, summary(df1)) comment(df1) [1] empty dataframe Mode:logicalNA's:1 On Jun 22, 2011, at 10:57 AM, Robert Lundqvist wrote: Every now and then I realize that my attempts to document what all dataframes consist of are unsufficient. So far, I have been writing notes in an external file. Are there any better ways to do this within R? One possibility could be to set up the data as packages, but I would like to have a solution on a lower level, closer to data. I can't find any pointers in the standard manuals. Suggestions are most welcome. Robert ** Robert Lundqvist Norrbotten regional council Sweden [[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. David Winsemius, MD West Hartford, CT __ 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] Documenting variables, dataframes and files?
Have a look at the AnnotatedDataFrame class in the Biobase package [1]. Here is the description from the manual: An ‘AnnotatedDataFrame’ consists of two parts. There is a collection of samples and the values of variables measured on those samples. There is also a description of each variable measured. The components of an ‘AnnotatedDataFrame’ can be accessed with ‘pData’ and ‘varMetadata’. Hope this helps, Laurent [1] http://bioconductor.org/packages/release/bioc/html/Biobase.html On 22 June 2011 15:57, Robert Lundqvist robert.lundqv...@nll.se wrote: Every now and then I realize that my attempts to document what all dataframes consist of are unsufficient. So far, I have been writing notes in an external file. Are there any better ways to do this within R? One possibility could be to set up the data as packages, but I would like to have a solution on a lower level, closer to data. I can't find any pointers in the standard manuals. Suggestions are most welcome. Robert ** Robert Lundqvist Norrbotten regional council Sweden [[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] Hardy Weinberg
H-W only gives you the expected frequency of AA, AB, and BB genotypes (i.e. a 1x3 table): minor - runif(1, 0.05, 0.25) major - 1-minor AA - minor^2 AB - 2*minor*major BB - major^2 df - cbind(AA, AB, BB) -Aaron On Tue, Jun 21, 2011 at 9:30 PM, Jim Silverton jim.silver...@gmail.comwrote: Hello all, I am interested in simulating 10,000 2 x 3 tables for SNPs data with the Hardy Weinberg formulation. Is there a quick way to do this? I am assuming that the minor allelle frequency is uniform in (0.05, 0.25). -- Thanks, Jim. [[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. [[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] VGAM constraints-related puzzle
Hello R users, I have a puzzle with the VGAM package, on my first excursion into generalized additive models, in that this very nice package seems to want to do either more or less than what I want. Precisely, I have a 4-component outcome, y, and am fitting multinomial logistic regression with one predictor x. What I would like to find out is, is there a single nonlinear function f(x) which acts in place of the linear predictor x. There is a mechanistic reason to believe this is sensible. So I'd like to fit a model \eta_j = \beta_{ (j) 0 } + \beta_{ (j) x } f(x) where both the function f(x) and its scaling coefficients \beta_{ (j) x } are fit simultaneously. Here \eta_j is the linear predictor, the logodds of outcome j vs the reference outcome. I cannot see how to fit exactly this. Instead I seem to be able to do the following: vgam(formula = y ~ s(x), family = multinomial) fits the model \eta_j = \beta_{ (j) 0 } + \beta_{ (j) x } f_j (x) i.e. a different function f_j (x) is fit for each outcome. vgam(formula = y ~ s(x), family = multinomial, constraints = list(`(Intercept)`= diag(1,3), 's(x)' = matrix(c(1,1,1),3,1)) ) fits the model \eta_j = \beta_{ (j) 0 } + f (x) i.e. a single function f (x) is fit, but scaled the same for each outcome. I'd like one function, scaled differently. Of course, vgam(formula = y ~ x, family = multinomial) fits the model \eta_j = \beta_{ (j) 0 } + \beta_{ (j) x } x which has the scaling, but not the nonlinear function. Perhaps this is achievable using bs(), xij, and vglm, or even via the constraint matrix, but I did not succeed. Any help appreciated! Edward -- Edward Wallace, PhD Postdoctoral fellow, Drummond lab Harvard FAS center for Systems Biology ewall...@cgr.harvard.edu 773-517-4009 __ 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] VAR with excluded lags
Hi, I would like to fit a Vector Auto Regression with lags that are not consecutive with the vars package (or other if there is one as good). Is it possible? For example, rather than having lags 1, 2, 3, 4, 5 have 1, 2, 5. Thanks. -- View this message in context: http://r.789695.n4.nabble.com/VAR-with-excluded-lags-tp3617485p3617485.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] binary in R
Does really nobody has a coment to this question? Dear R-help members I would like to use the R package goalprog, weighted and lexicographical goal programming and optimization to optimize a location problem. In my model I need a yes or no decision - in this case, whether to select a site or not - are represented by 1 and 0. Does somebody has experience with this problem and know how this could be done? Thanks for your help in andvance. Best wishes Jürg Altwegg -- __ 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] strange date problem - May 3, 1992 is NA
is.na(strptime(5/2/1992, format=%m/%d/%Y)) [1] FALSE is.na(strptime(5/3/1992, format=%m/%d/%Y)) [1] TRUE Any idea what's going on with this? Running strptime against all dates from around 1946, only 5/3/1992 was converted as NA. Even stranger, it still seems to have a value associated with it (even though is.na thinks it's NA): strptime(5/3/1992, format=%m/%d/%Y) [1] 1992-05-03 Thanks, Allie 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.
Re: [R] binary in R
Jürg. It's not that nobody knows the answer, necessarily, it's that your inquiry is so vague we don't know what the *question* is, let alone the answer. We don't know anything about your data, your intended function and model, anything. A toy reproducible example with clear explanation would be the most useful for helping us to help you. The posting guide explains more about what the R helpers need to know to be able to answer questions. Sarah On Wed, Jun 22, 2011 at 1:12 PM, Jürg Altwegg jaltw...@gmx.net wrote: Does really nobody has a coment to this question? Dear R-help members I would like to use the R package goalprog, weighted and lexicographical goal programming and optimization to optimize a location problem. In my model I need a yes or no decision - in this case, whether to select a site or not - are represented by 1 and 0. Does somebody has experience with this problem and know how this could be done? Thanks for your help in andvance. Best wishes Jürg Altwegg -- Sarah Goslee http://www.functionaldiversity.org __ 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] Linking 2 columns in 2 databases and applying a function
Hi all, I have two datasets, one that represents a long-term time series and one that represents summary data for the time series. It looks something like this: x-data.frame(Year=c(2001,2001,2001,2001,2001,2001,2002,2002,2002,2002,2002,2002), Month=c(1,1,1,2,2,2),Q=c(5,5,5,6,6,6,3,3,3,4,4,5)) y-data.frame(Year=c(2001,2001,2002,2002),Month=c(1,2,1,2),Threshold_Q=c(5,5,4,4)) What I'd like to do is link the Year and Month fields in both dataframes then determine if Q exceeds Q_Threshold (by noting it with something like 1 or 0 in a new field in the dataframe x). If I were doing this in the more-familiar-to-me Matlab, I'd just write a pair of nested for-loops. But as we know, this won't fly in R. I've tried reading the help pages and seeking for solutions on the net, with no luck (I'm relatively new to R and the help pages are still a bit opaque to me). It seems like the functions apply or lapply are key, but I can't make sense of their syntax. Any advice/help?!? Many thanks, Ryan -- Ryan Utz, Ph.D. Aquatic Ecologist/STREON Scientist National Ecological Observatory Network Home/Cell: (724) 272-7769 Work: (720) 746-4844 ext. 2488 [[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] strange date problem - May 3, 1992 is NA
Hi, On Wed, Jun 22, 2011 at 11:40 AM, Alexander Shenkin ashen...@ufl.edu wrote: is.na(strptime(5/2/1992, format=%m/%d/%Y)) [1] FALSE is.na(strptime(5/3/1992, format=%m/%d/%Y)) [1] TRUE I can't reproduce your problem on R 2.13.0 on linux: strptime(5/2/1992, format=%m/%d/%Y) [1] 1992-05-02 is.na(strptime(5/2/1992, format=%m/%d/%Y)) [1] FALSE strptime(5/3/1992, format=%m/%d/%Y) [1] 1992-05-03 is.na(strptime(5/3/1992, format=%m/%d/%Y)) [1] FALSE My suspicion is that you imported the data from a spreadsheet and there's some formatting glitch that's not showing up. If you type the string 5/3/1992 into the command by hand, do you still get the same result? If so, then we need to know your OS and version of R, at least. Any idea what's going on with this? Running strptime against all dates from around 1946, only 5/3/1992 was converted as NA. Even stranger, it still seems to have a value associated with it (even though is.na thinks it's NA): strptime(5/3/1992, format=%m/%d/%Y) [1] 1992-05-03 This makes no sense to me. Sarah -- Sarah Goslee http://www.functionaldiversity.org __ 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] strange date problem - May 3, 1992 is NA
On 6/22/2011 1:03 PM, Sarah Goslee wrote: Hi, On Wed, Jun 22, 2011 at 11:40 AM, Alexander Shenkin ashen...@ufl.edu wrote: is.na(strptime(5/2/1992, format=%m/%d/%Y)) [1] FALSE is.na(strptime(5/3/1992, format=%m/%d/%Y)) [1] TRUE I can't reproduce your problem on R 2.13.0 on linux: strptime(5/2/1992, format=%m/%d/%Y) [1] 1992-05-02 is.na(strptime(5/2/1992, format=%m/%d/%Y)) [1] FALSE strptime(5/3/1992, format=%m/%d/%Y) [1] 1992-05-03 is.na(strptime(5/3/1992, format=%m/%d/%Y)) [1] FALSE My suspicion is that you imported the data from a spreadsheet and there's some formatting glitch that's not showing up. If you type the string 5/3/1992 into the command by hand, do you still get the same result? Copy and pasting the above lines reproduces the problem on my setup. If so, then we need to know your OS and version of R, at least. sessionInfo() R version 2.12.1 (2010-12-16) Platform: i386-pc-mingw32/i386 (32-bit) locale: [1] LC_COLLATE=English_United States.1252 LC_CTYPE=English_United States.1252LC_MONETARY=English_United States.1252 LC_NUMERIC=C [5] LC_TIME=English_United States.1252 attached base packages: [1] grid grDevices datasets splines graphics stats tcltk utils methods base other attached packages: [1] ggplot2_0.8.9 proto_0.3-8 reshape_0.8.4 plyr_1.4 svSocket_0.9-51 TinnR_1.0.3 R2HTML_2.2 Hmisc_3.8-3 survival_2.36-2 loaded via a namespace (and not attached): [1] cluster_1.13.2 digest_0.4.2lattice_0.19-17 svMisc_0.9-61 tools_2.12.1 Any idea what's going on with this? Running strptime against all dates from around 1946, only 5/3/1992 was converted as NA. Even stranger, it still seems to have a value associated with it (even though is.na thinks it's NA): strptime(5/3/1992, format=%m/%d/%Y) [1] 1992-05-03 This makes no sense to me. Sarah __ 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] strange date problem - May 3, 1992 is NA
On Jun 22, 2011, at 2:03 PM, Sarah Goslee wrote: Hi, On Wed, Jun 22, 2011 at 11:40 AM, Alexander Shenkin ashen...@ufl.edu wrote: is.na(strptime(5/2/1992, format=%m/%d/%Y)) [1] FALSE is.na(strptime(5/3/1992, format=%m/%d/%Y)) [1] TRUE I can't reproduce your problem on R 2.13.0 on linux: I also cannot reproduce it on a Mac with 2.13.0 beta is.na(strptime(5/3/1992, format=%m/%d/%Y)) [1] FALSE sessionInfo() R version 2.13.0 beta (2011-04-04 r55296) Platform: x86_64-apple-darwin9.8.0/x86_64 (64-bit) locale: [1] en_US.UTF-8/en_US.UTF-8/C/C/en_US.UTF-8/en_US.UTF-8 attached base packages: [1] grid splines stats graphics grDevices utils datasets [8] methods base other attached packages: [1] reshape2_1.1gplots_2.8.0caTools_1.12 [4] bitops_1.0-4.1 gdata_2.8.1 gtools_2.6.2 [7] gamair_0.0-7mgcv_1.7-6 Matrix_0.999375-50 [10] latticeExtra_0.6-16 RColorBrewer_1.0-2 rms_3.3-0 [13] Hmisc_3.8-3 survival_2.36-9 sos_1.3-0 [16] brew_1.0-6 lattice_0.19-26 loaded via a namespace (and not attached): [1] cluster_1.13.3 nlme_3.1-101 plyr_1.5.2 stringr_0.4 [5] tools_2.13.0 strptime(5/2/1992, format=%m/%d/%Y) [1] 1992-05-02 is.na(strptime(5/2/1992, format=%m/%d/%Y)) [1] FALSE strptime(5/3/1992, format=%m/%d/%Y) [1] 1992-05-03 is.na(strptime(5/3/1992, format=%m/%d/%Y)) [1] FALSE My suspicion is that you imported the data from a spreadsheet and there's some formatting glitch that's not showing up. If you type the string 5/3/1992 into the command by hand, do you still get the same result? If so, then we need to know your OS and version of R, at least. Any idea what's going on with this? Running strptime against all dates from around 1946, only 5/3/1992 was converted as NA. Even stranger, it still seems to have a value associated with it (even though is.na thinks it's NA): strptime(5/3/1992, format=%m/%d/%Y) [1] 1992-05-03 This makes no sense to me. Sarah -- Sarah Goslee http://www.functionaldiversity.org __ 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. David Winsemius, MD West Hartford, CT __ 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] Linking 2 columns in 2 databases and applying a function
For example, you can merge the two data frames and do a direct comparison: df-merge(x,y,all.x=T,all.y=F) df df$Qdf$Threshold_Q HTH, Daniel Ryan Utz-2 wrote: Hi all, I have two datasets, one that represents a long-term time series and one that represents summary data for the time series. It looks something like this: x-data.frame(Year=c(2001,2001,2001,2001,2001,2001,2002,2002,2002,2002,2002,2002), Month=c(1,1,1,2,2,2),Q=c(5,5,5,6,6,6,3,3,3,4,4,5)) y-data.frame(Year=c(2001,2001,2002,2002),Month=c(1,2,1,2),Threshold_Q=c(5,5,4,4)) What I'd like to do is link the Year and Month fields in both dataframes then determine if Q exceeds Q_Threshold (by noting it with something like 1 or 0 in a new field in the dataframe x). If I were doing this in the more-familiar-to-me Matlab, I'd just write a pair of nested for-loops. But as we know, this won't fly in R. I've tried reading the help pages and seeking for solutions on the net, with no luck (I'm relatively new to R and the help pages are still a bit opaque to me). It seems like the functions apply or lapply are key, but I can't make sense of their syntax. Any advice/help?!? Many thanks, Ryan -- Ryan Utz, Ph.D. Aquatic Ecologist/STREON Scientist National Ecological Observatory Network Home/Cell: (724) 272-7769 Work: (720) 746-4844 ext. 2488 [[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://r.789695.n4.nabble.com/Linking-2-columns-in-2-databases-and-applying-a-function-tp3617710p3617775.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] strange date problem - May 3, 1992 is NA
On Wed, Jun 22, 2011 at 2:28 PM, David Winsemius dwinsem...@comcast.net wrote: On Jun 22, 2011, at 2:03 PM, Sarah Goslee wrote: Hi, On Wed, Jun 22, 2011 at 11:40 AM, Alexander Shenkin ashen...@ufl.edu wrote: is.na(strptime(5/2/1992, format=%m/%d/%Y)) [1] FALSE is.na(strptime(5/3/1992, format=%m/%d/%Y)) [1] TRUE I can't reproduce your problem on R 2.13.0 on linux: I also cannot reproduce it on a Mac with 2.13.0 beta Which strongly suggests that you should start by upgrading your R installation if at all possible. I'd also recommend trying it on a default R session, with no extra packages loaded, and no items in your workspace. It's possible that something else is interfering. On linux, that's achieved by typing R --vanilla at the command line. I'm afraid I don't know how to do it for Windows, but should be similarly straightforward. -- Sarah Goslee http://www.functionaldiversity.org __ 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] Help Needed on Merging Columns by Summation
I assume that you are working in package MatrixCalc. Lets say you have a matrix X. You can call the columns of X this way: X[,1] for the first column X[,2] for the second column X[,3] for the third column Etc. So lets say that you want to add the first and third column, then you would just do X[,1] + X[,3] If you wanted to call that quantity later on, it might be helpful to give it a name: NewQ - X[,1] + X[,3] Good luck,Rita On Wed, Jun 22, 2011 at 2:35 AM, Nabila Binte Zahur nab...@nus.edu.sg wrote: Dear Sirs/Madam, I am a beginner to R, and I am currently working on a data matrix which looks like this: head(oligo) ko:K1 ko:K3 ko:K5 ko:K8 ko:K9 ko:K00010 ko:K00012 AAA 370 631 365 67 164 455 491 KAA 603 1208 170 15768 495 922 NAA60 110 107 44 5194 DAA 183 80241 62 26 166 263 CAA5812581 1 23 8 TAA 451 468 20190 131 320 518 For certain specific columns, I need to merge the columns in such a way that the elements get added together. For example, in order to merge the first and the second columns, my output for the first row shld be ko:K1/ko:K3 AAA 1001 (i.e. 370+631) KAA1811 (i.e. 603+1208) and so on for the whole column. Rita = If you think education is expensive, try ignorance.--Derek Bok [[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] strange date problem - May 3, 1992 is NA
On 6/22/2011 1:34 PM, Sarah Goslee wrote: On Wed, Jun 22, 2011 at 2:28 PM, David Winsemius dwinsem...@comcast.net wrote: On Jun 22, 2011, at 2:03 PM, Sarah Goslee wrote: Hi, On Wed, Jun 22, 2011 at 11:40 AM, Alexander Shenkin ashen...@ufl.edu wrote: is.na(strptime(5/2/1992, format=%m/%d/%Y)) [1] FALSE is.na(strptime(5/3/1992, format=%m/%d/%Y)) [1] TRUE I can't reproduce your problem on R 2.13.0 on linux: I also cannot reproduce it on a Mac with 2.13.0 beta Which strongly suggests that you should start by upgrading your R installation if at all possible. I'd also recommend trying it on a default R session, with no extra packages loaded, and no items in your workspace. It's possible that something else is interfering. On linux, that's achieved by typing R --vanilla at the command line. I'm afraid I don't know how to do it for Windows, but should be similarly straightforward. Thanks Sarah. Still getting the problem. I should surely upgrade, but still, not a bad idea to get to the bottom of this, or at least have it documented as a known issue. BTW, I'm on Windows 7 Pro x64. (running Rgui.exe --vanilla): is.na(strptime(5/3/1992, format=%m/%d/%Y)) [1] TRUE is.na(strptime(5/2/1992, format=%m/%d/%Y)) [1] FALSE sessionInfo() R version 2.12.1 (2010-12-16) Platform: i386-pc-mingw32/i386 (32-bit) locale: [1] LC_COLLATE=English_United States.1252 [2] LC_CTYPE=English_United States.1252 [3] LC_MONETARY=English_United States.1252 [4] LC_NUMERIC=C [5] LC_TIME=English_United States.1252 attached base packages: [1] stats graphics grDevices utils datasets methods base __ 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] Documenting variables, dataframes and files?
The memisc package also offers functionality for documenting data. Jan On 06/22/2011 04:57 PM, Robert Lundqvist wrote: Every now and then I realize that my attempts to document what all dataframes consist of are unsufficient. So far, I have been writing notes in an external file. Are there any better ways to do this within R? One possibility could be to set up the data as packages, but I would like to have a solution on a lower level, closer to data. I can't find any pointers in the standard manuals. Suggestions are most welcome. Robert ** Robert Lundqvist Norrbotten regional council Sweden [[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] Linking 2 columns in 2 databases and applying a function
1st of all Dr Utz, thanks for your recent pubs on regional differences between the piedmont and coastal plain streams. and to add to Daniels post (giving your binary yes/no): df-merge(x,y,all.x=T,all.y=F) df[exceed] - ifelse(df$Qdf$Threshold_Q , 1, 0) ## now look at df df Daniel Malter wrote: For example, you can merge the two data frames and do a direct comparison: df-merge(x,y,all.x=T,all.y=F) df df$Qdf$Threshold_Q HTH, Daniel Ryan Utz-2 wrote: Hi all, I have two datasets, one that represents a long-term time series and one that represents summary data for the time series. It looks something like this: x-data.frame(Year=c(2001,2001,2001,2001,2001,2001,2002,2002,2002,2002,2002,2002), Month=c(1,1,1,2,2,2),Q=c(5,5,5,6,6,6,3,3,3,4,4,5)) y-data.frame(Year=c(2001,2001,2002,2002),Month=c(1,2,1,2),Threshold_Q=c(5,5,4,4)) What I'd like to do is link the Year and Month fields in both dataframes then determine if Q exceeds Q_Threshold (by noting it with something like 1 or 0 in a new field in the dataframe x). If I were doing this in the more-familiar-to-me Matlab, I'd just write a pair of nested for-loops. But as we know, this won't fly in R. I've tried reading the help pages and seeking for solutions on the net, with no luck (I'm relatively new to R and the help pages are still a bit opaque to me). It seems like the functions apply or lapply are key, but I can't make sense of their syntax. Any advice/help?!? Many thanks, Ryan -- Ryan Utz, Ph.D. Aquatic Ecologist/STREON Scientist National Ecological Observatory Network Home/Cell: (724) 272-7769 Work: (720) 746-4844 ext. 2488 [[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://r.789695.n4.nabble.com/Linking-2-columns-in-2-databases-and-applying-a-function-tp3617710p3617861.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] strange date problem - May 3, 1992 is NA
For what it's worth, I cannot reproduce this problem under a nearly identical instance of R (R 2.12.1, Win 7 Pro 64-bit). I also can't reproduce the problem with R 2.13.0. You've got something truly weird going on with your particular instance of R. is.na(strptime(5/3/1992, format=%m/%d/%Y)) [1] FALSE is.na(strptime(5/2/1992, format=%m/%d/%Y)) [1] FALSE sessionInfo() R version 2.12.1 (2010-12-16) Platform: i386-pc-mingw32/i386 (32-bit) locale: [1] LC_COLLATE=English_United States.1252 [2] LC_CTYPE=English_United States.1252 [3] LC_MONETARY=English_United States.1252 [4] LC_NUMERIC=C [5] LC_TIME=English_United States.1252 attached base packages: [1] stats graphics grDevices utils datasets methods base other attached packages: [1] rj_0.5.2-1 lattice_0.19-17 loaded via a namespace (and not attached): [1] grid_2.12.1 rJava_0.8-8 tools_2.12.1 On Wed, Jun 22, 2011 at 2:40 PM, Alexander Shenkin ashen...@ufl.edu wrote: On 6/22/2011 1:34 PM, Sarah Goslee wrote: On Wed, Jun 22, 2011 at 2:28 PM, David Winsemius dwinsem...@comcast.net wrote: On Jun 22, 2011, at 2:03 PM, Sarah Goslee wrote: Hi, On Wed, Jun 22, 2011 at 11:40 AM, Alexander Shenkin ashen...@ufl.edu wrote: is.na(strptime(5/2/1992, format=%m/%d/%Y)) [1] FALSE is.na(strptime(5/3/1992, format=%m/%d/%Y)) [1] TRUE I can't reproduce your problem on R 2.13.0 on linux: I also cannot reproduce it on a Mac with 2.13.0 beta Which strongly suggests that you should start by upgrading your R installation if at all possible. I'd also recommend trying it on a default R session, with no extra packages loaded, and no items in your workspace. It's possible that something else is interfering. On linux, that's achieved by typing R --vanilla at the command line. I'm afraid I don't know how to do it for Windows, but should be similarly straightforward. Thanks Sarah. Still getting the problem. I should surely upgrade, but still, not a bad idea to get to the bottom of this, or at least have it documented as a known issue. BTW, I'm on Windows 7 Pro x64. (running Rgui.exe --vanilla): is.na(strptime(5/3/1992, format=%m/%d/%Y)) [1] TRUE is.na(strptime(5/2/1992, format=%m/%d/%Y)) [1] FALSE sessionInfo() R version 2.12.1 (2010-12-16) Platform: i386-pc-mingw32/i386 (32-bit) locale: [1] LC_COLLATE=English_United States.1252 [2] LC_CTYPE=English_United States.1252 [3] LC_MONETARY=English_United States.1252 [4] LC_NUMERIC=C [5] LC_TIME=English_United States.1252 attached base packages: [1] stats graphics grDevices utils datasets methods base __ 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. -- ___ Luke Miller Postdoctoral Researcher Marine Science Center Northeastern University Nahant, MA (781) 581-7370 x318 __ 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] Linking 2 columns in 2 databases and applying a function
Daniel, That indeed does work... and I didn't even need to learn a new function. Thanks! -- Ryan Utz, Ph.D. Aquatic Ecologist/STREON Scientist National Ecological Observatory Network Home/Cell: (724) 272-7769 Work: (720) 746-4844 ext. 2488 [[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] caret's Kappa for categorical resampling
Hello, When evaluating different learning methods for a categorization problem with the (really useful!) caret package, I'm getting confusing results from the Kappa computation. The data is about 20,000 rows and a few dozen columns, and the categories are quite asymmetrical, 4.1% in one category and 95.9% in the other. When I train a ctree model as: model - train(dat.dts, dat.dts.class, method='ctree', tuneLength=8, trControl=trainControl(number = 5, workers=1), metric='Kappa') I get the following puzzling numbers: mincriterion Accuracy Kappa Accuracy SD Kappa SD 0.01 0.961 0.0609 0.00151 0.0264 0.15 0.962 0.049 0.00116 0.0248 0.29 0.963 0.0405 0.00227 0.035 0.43 0.964 0.0349 0.00257 0.0247 0.57 0.964 0.0382 0.0022 0.0199 0.71 0.964 0.0354 0.00255 0.0257 0.85 0.964 0.036 0.00224 0.024 0.99 0.965 0.0091 0.00173 0.0203 (mincriterion determines the likelihood of accepting a split into the tree.) The Accuracy numbers look sorta reasonable, if not great; the model overfits and barely beats the base rate if it builds a complicated tree. But the Kappa numbers go the opposite direction, and here's where I'm not sure what's going on. The examples in the vingette show Accuracy and Kappa being positively correlated. I thought Kappa was just (Accuracy - baserate)/(1 - baserate), but the reported Kappa is definitely not that. Suggestions? Aside from looking for a better model, which would be good advice here, what metric would you recommend? Thank you! -Harlan [[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] mlogit model that contains both individual-specific parameters and universal parameters
Hello, I am pretty new to mlogit, and still trying to figure out what models to use.I have a data set of N individuals, each of which faces I alternatives. The utility function of individual n, for choice i is: u(i,n) = alpha(i) * x1(i,n) + beta * x2(i,n) where alpha(i) is the individual specific parameter, and beta is shared among all individuals. I don't really know how to set this up in mlogit. If I assumed that beta is individual-specific (beta(i)), then I can divide the data set to many subsets, each of which corresponds to a particular individual i, and run this model for each subset to estimate alpha(i) and beta(i). y ~ x1 + x2 This can be done just fine. I have gone over tutorials by Train and by Heshner but I haven't found out how to solve this problem yet. Any suggestions are welcome. Thank you so much for your time! [[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] Package warnings
Thanks all the issue is closed. in this case I had a data element FILE.PARAMETERS = list() the .Rd files created by package.skelton() for data objects had the following for \usage. \usage{data(FILE.PARAMETERS)} I left that as is and CHECK throws a warning. checking for code/documentation mismatches ... WARNING Data sets with usage in documentation object 'FILE.PARAMETERS' but not in code: changing \usage cleared the warning \usage{FILE.PARAMETERS} clears check! crantastic, no warnings, no errors! On Wed, Jun 22, 2011 at 8:29 AM, steven mosher mosherste...@gmail.comwrote: Thanks Duncan, I'll join Dev and ask the questions over there. Steve On Wed, Jun 22, 2011 at 7:19 AM, Duncan Murdoch murdoch.dun...@gmail.comwrote: On 11-06-21 11:58 PM, steven mosher wrote: Thanks to all your help I've just finished my first package and I have a couple of questions I want to submit to CRAN but I have 1 warning checking for code/documentation mismatches ... WARNING Data sets with usage in documentation object 'FILE.PARAMETERS' but not in code: FILE.PARAMETERS I actually have a few instances with the same issue. I have a handful of data objects, things like URLs and some file parameters ( like column widths etc). These are declared in an R file and then loaded (lazyData no) There are help files for all these objects, and some of them get used in the code as defaults for when functions are called foo- function( x, y=FILE.PARAMETERS) So why do I get this warning? is it one I have to fix? and should I be asking this on the dev list? Yes, you should fix almost all warnings, and yes, questions like this belong on the R-devel list. When you ask there, it would be helpful to be very specific: show us the start of the Rd file that is being complained about (the \usage and \docType sections are of particular interest), and give us the exact details about how the data object is being created. Duncan Murdoch Thanks again for all your help, hope this is right place to ask. [[alternative HTML version deleted]] __** R-help@r-project.org mailing list https://stat.ethz.ch/mailman/**listinfo/r-helphttps://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/** posting-guide.html 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] setting 'layout' locally within functions
Hi On 23/06/2011 2:58 a.m., Simon Goodman wrote: Using layout I've created a function that makes a 2 panel plot - comprising a main plot, and a sub-panel with custom legend. I would now like to use layout to create multiple panels with plots created by my function, however the values for layout set in the function act globally, stopping me from setting this up how I want. So if I say: layout(matrix(1:2, 1,2)) my.plot(data) I end up with a single plot according the layout format specified by the function, rather than a plot generated by the function in the left hand panel of the matrix that should be specified by the first layout command. Is there a way to use layout in a subsetable, hierarchical way? You have just described the 'grid' graphics package. Paul Thanks, Simon -- View this message in context: http://r.789695.n4.nabble.com/setting-layout-locally-within-functions-tp3617257p3617257.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. -- Dr Paul Murrell Department of Statistics The University of Auckland Private Bag 92019 Auckland New Zealand 64 9 3737599 x85392 p...@stat.auckland.ac.nz http://www.stat.auckland.ac.nz/~paul/ __ 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] strange date problem - May 3, 1992 is NA
The isdst value -1 doesn't seem right. Shouldn't it be either 0 (not daylight savings time) or 1 (yes dst)? I've only seen isdst==-1 when all the other entries were NA (that happens when the string doesn't match the format). In the parts of the US where daylight savings time is used the switchover took place near the beginning of April in 1992, so you should have isdst=1 by May 3. Perhaps you have an odd timezone file on your machine. Bill Dunlap Spotfire, TIBCO Software wdunlap tibco.com -Original Message- From: Alexander Shenkin [mailto:ashen...@ufl.edu] Sent: Wednesday, June 22, 2011 1:07 PM To: William Dunlap Subject: Re: [R] strange date problem - May 3, 1992 is NA Hi Bill, Thanks for your reply. The results look almost identical to my eyes, except for the mysterious TRUE... methods(is.na) [1] is.na.data.frame is.na.numeric_version is.na.POSIXlt trace(methods(is.na), quote(cat( is.na: class(x)=, class(x), \n))) Tracing function is.na.data.frame in package base Tracing function is.na.numeric_version in package base Tracing function is.na.POSIXlt in package base [1] is.na.data.frame is.na.numeric_version is.na.POSIXlt z - strptime(5/3/1992, format=%m/%d/%Y) is.na(z) Tracing is.na.POSIXlt(z) on entry is.na: class(x)= POSIXlt POSIXt [1] TRUE str(unclass(z)) List of 9 $ sec : num 0 $ min : int 0 $ hour : int 0 $ mday : int 3 $ mon : int 4 $ year : int 92 $ wday : int 0 $ yday : int 123 $ isdst: int -1 sessionInfo() R version 2.12.1 (2010-12-16) Platform: i386-pc-mingw32/i386 (32-bit) locale: [1] LC_COLLATE=English_United States.1252 [2] LC_CTYPE=English_United States.1252 [3] LC_MONETARY=English_United States.1252 [4] LC_NUMERIC=C [5] LC_TIME=English_United States.1252 attached base packages: [1] stats graphics grDevices utils datasets methods base loaded via a namespace (and not attached): [1] tools_2.12.1 thanks, allie On 6/22/2011 1:50 PM, William Dunlap wrote: What do you get for the following commands, which show which is.na method is getting called and the internal structure of the dataset made by strptime? methods(is.na) [1] is.na.data.frame is.na.numeric_version is.na.POSIXlt trace(methods(is.na), quote(cat( is.na: class(x)=, class(x), \n))) Tracing function is.na.data.frame in package base Tracing function is.na.numeric_version in package base Tracing function is.na.POSIXlt in package base [1] is.na.data.frame is.na.numeric_version is.na.POSIXlt z - strptime(5/3/1992, format=%m/%d/%Y) is.na(z) Tracing is.na.POSIXlt(z) on entry is.na: class(x)= POSIXlt POSIXt [1] FALSE str(unclass(z)) List of 9 $ sec : num 0 $ min : int 0 $ hour : int 0 $ mday : int 3 $ mon : int 4 $ year : int 92 $ wday : int 0 $ yday : int 123 $ isdst: int 1 Bill Dunlap Spotfire, TIBCO Software wdunlap tibco.com -Original Message- From: r-help-boun...@r-project.org [mailto:r-help-boun...@r-project.org] On Behalf Of Alexander Shenkin Sent: Wednesday, June 22, 2011 11:41 AM To: Sarah Goslee; r-help@r-project.org Subject: Re: [R] strange date problem - May 3, 1992 is NA On 6/22/2011 1:34 PM, Sarah Goslee wrote: On Wed, Jun 22, 2011 at 2:28 PM, David Winsemius dwinsem...@comcast.net wrote: On Jun 22, 2011, at 2:03 PM, Sarah Goslee wrote: Hi, On Wed, Jun 22, 2011 at 11:40 AM, Alexander Shenkin ashen...@ufl.edu wrote: is.na(strptime(5/2/1992, format=%m/%d/%Y)) [1] FALSE is.na(strptime(5/3/1992, format=%m/%d/%Y)) [1] TRUE I can't reproduce your problem on R 2.13.0 on linux: I also cannot reproduce it on a Mac with 2.13.0 beta Which strongly suggests that you should start by upgrading your R installation if at all possible. I'd also recommend trying it on a default R session, with no extra packages loaded, and no items in your workspace. It's possible that something else is interfering. On linux, that's achieved by typing R --vanilla at the command line. I'm afraid I don't know how to do it for Windows, but should be similarly straightforward. Thanks Sarah. Still getting the problem. I should surely upgrade, but still, not a bad idea to get to the bottom of this, or at least have it documented as a known issue. BTW, I'm on Windows 7 Pro x64. (running Rgui.exe --vanilla): is.na(strptime(5/3/1992, format=%m/%d/%Y)) [1] TRUE is.na(strptime(5/2/1992, format=%m/%d/%Y)) [1] FALSE sessionInfo() R version 2.12.1 (2010-12-16) Platform: i386-pc-mingw32/i386 (32-bit) locale: [1] LC_COLLATE=English_United States.1252 [2] LC_CTYPE=English_United States.1252 [3] LC_MONETARY=English_United States.1252 [4] LC_NUMERIC=C [5] LC_TIME=English_United States.1252 attached base packages: [1] stats graphics grDevices utils datasets methods base
Re: [R] strange date problem - May 3, 1992 is NA
I can reproduce your problem when using a time that doesn't exist because it is between 2am and 3am on the Sunday that we switch from winter time to summer time: z - strptime(paste(paste(sep=/, 4, 5, 1992), 2:30), format=%m/%d/%Y %H:%M) z [1] 1992-04-05 02:30:00 is.na(z) [1] TRUE str(unclass(z)) List of 9 $ sec : num 0 $ min : int 30 $ hour : int 2 $ mday : int 5 $ mon : int 3 $ year : int 92 $ wday : int 0 $ yday : int 95 $ isdst: int -1 Perhaps your time zone description file has the time changing around midnight on May 3, 1992. Bill Dunlap Spotfire, TIBCO Software wdunlap tibco.com -Original Message- From: r-help-boun...@r-project.org [mailto:r-help-boun...@r-project.org] On Behalf Of William Dunlap Sent: Wednesday, June 22, 2011 1:23 PM To: Alexander Shenkin; r-help@r-project.org Subject: Re: [R] strange date problem - May 3, 1992 is NA The isdst value -1 doesn't seem right. Shouldn't it be either 0 (not daylight savings time) or 1 (yes dst)? I've only seen isdst==-1 when all the other entries were NA (that happens when the string doesn't match the format). In the parts of the US where daylight savings time is used the switchover took place near the beginning of April in 1992, so you should have isdst=1 by May 3. Perhaps you have an odd timezone file on your machine. Bill Dunlap Spotfire, TIBCO Software wdunlap tibco.com -Original Message- From: Alexander Shenkin [mailto:ashen...@ufl.edu] Sent: Wednesday, June 22, 2011 1:07 PM To: William Dunlap Subject: Re: [R] strange date problem - May 3, 1992 is NA Hi Bill, Thanks for your reply. The results look almost identical to my eyes, except for the mysterious TRUE... methods(is.na) [1] is.na.data.frame is.na.numeric_version is.na.POSIXlt trace(methods(is.na), quote(cat( is.na: class(x)=, class(x), \n))) Tracing function is.na.data.frame in package base Tracing function is.na.numeric_version in package base Tracing function is.na.POSIXlt in package base [1] is.na.data.frame is.na.numeric_version is.na.POSIXlt z - strptime(5/3/1992, format=%m/%d/%Y) is.na(z) Tracing is.na.POSIXlt(z) on entry is.na: class(x)= POSIXlt POSIXt [1] TRUE str(unclass(z)) List of 9 $ sec : num 0 $ min : int 0 $ hour : int 0 $ mday : int 3 $ mon : int 4 $ year : int 92 $ wday : int 0 $ yday : int 123 $ isdst: int -1 sessionInfo() R version 2.12.1 (2010-12-16) Platform: i386-pc-mingw32/i386 (32-bit) locale: [1] LC_COLLATE=English_United States.1252 [2] LC_CTYPE=English_United States.1252 [3] LC_MONETARY=English_United States.1252 [4] LC_NUMERIC=C [5] LC_TIME=English_United States.1252 attached base packages: [1] stats graphics grDevices utils datasets methods base loaded via a namespace (and not attached): [1] tools_2.12.1 thanks, allie On 6/22/2011 1:50 PM, William Dunlap wrote: What do you get for the following commands, which show which is.na method is getting called and the internal structure of the dataset made by strptime? methods(is.na) [1] is.na.data.frame is.na.numeric_version is.na.POSIXlt trace(methods(is.na), quote(cat( is.na: class(x)=, class(x), \n))) Tracing function is.na.data.frame in package base Tracing function is.na.numeric_version in package base Tracing function is.na.POSIXlt in package base [1] is.na.data.frame is.na.numeric_version is.na.POSIXlt z - strptime(5/3/1992, format=%m/%d/%Y) is.na(z) Tracing is.na.POSIXlt(z) on entry is.na: class(x)= POSIXlt POSIXt [1] FALSE str(unclass(z)) List of 9 $ sec : num 0 $ min : int 0 $ hour : int 0 $ mday : int 3 $ mon : int 4 $ year : int 92 $ wday : int 0 $ yday : int 123 $ isdst: int 1 Bill Dunlap Spotfire, TIBCO Software wdunlap tibco.com -Original Message- From: r-help-boun...@r-project.org [mailto:r-help-boun...@r-project.org] On Behalf Of Alexander Shenkin Sent: Wednesday, June 22, 2011 11:41 AM To: Sarah Goslee; r-help@r-project.org Subject: Re: [R] strange date problem - May 3, 1992 is NA On 6/22/2011 1:34 PM, Sarah Goslee wrote: On Wed, Jun 22, 2011 at 2:28 PM, David Winsemius dwinsem...@comcast.net wrote: On Jun 22, 2011, at 2:03 PM, Sarah Goslee wrote: Hi, On Wed, Jun 22, 2011 at 11:40 AM, Alexander Shenkin ashen...@ufl.edu wrote: is.na(strptime(5/2/1992, format=%m/%d/%Y)) [1] FALSE is.na(strptime(5/3/1992, format=%m/%d/%Y)) [1] TRUE I can't reproduce your problem on R 2.13.0 on linux: I also cannot reproduce it on a Mac with 2.13.0 beta Which strongly suggests that you should start by upgrading your R installation if at all possible. I'd also recommend trying it on a default R session, with no extra packages
Re: [R] strange date problem - May 3, 1992 is NA
Wow. Setting my timezone to UTC -5 Bogota (where there is no daylight savings time), I get the error: is.na(strptime(5/3/1992, format=%m/%d/%Y)) [1] TRUE But setting it to UTC -5 East Coast Time (whether or not I tell windows to adjust for DST) I get: is.na(strptime(5/3/1992, format=%m/%d/%Y)) [1] FALSE Can others test this on their systems? How strange. I wonder how much tropical forest carbon this will account for. :-) Thanks, Allie On 6/22/2011 3:23 PM, William Dunlap wrote: The isdst value -1 doesn't seem right. Shouldn't it be either 0 (not daylight savings time) or 1 (yes dst)? I've only seen isdst==-1 when all the other entries were NA (that happens when the string doesn't match the format). In the parts of the US where daylight savings time is used the switchover took place near the beginning of April in 1992, so you should have isdst=1 by May 3. Perhaps you have an odd timezone file on your machine. Bill Dunlap Spotfire, TIBCO Software wdunlap tibco.com -Original Message- From: Alexander Shenkin [mailto:ashen...@ufl.edu] Sent: Wednesday, June 22, 2011 1:07 PM To: William Dunlap Subject: Re: [R] strange date problem - May 3, 1992 is NA Hi Bill, Thanks for your reply. The results look almost identical to my eyes, except for the mysterious TRUE... methods(is.na) [1] is.na.data.frame is.na.numeric_version is.na.POSIXlt trace(methods(is.na), quote(cat( is.na: class(x)=, class(x), \n))) Tracing function is.na.data.frame in package base Tracing function is.na.numeric_version in package base Tracing function is.na.POSIXlt in package base [1] is.na.data.frame is.na.numeric_version is.na.POSIXlt z - strptime(5/3/1992, format=%m/%d/%Y) is.na(z) Tracing is.na.POSIXlt(z) on entry is.na: class(x)= POSIXlt POSIXt [1] TRUE str(unclass(z)) List of 9 $ sec : num 0 $ min : int 0 $ hour : int 0 $ mday : int 3 $ mon : int 4 $ year : int 92 $ wday : int 0 $ yday : int 123 $ isdst: int -1 sessionInfo() R version 2.12.1 (2010-12-16) Platform: i386-pc-mingw32/i386 (32-bit) locale: [1] LC_COLLATE=English_United States.1252 [2] LC_CTYPE=English_United States.1252 [3] LC_MONETARY=English_United States.1252 [4] LC_NUMERIC=C [5] LC_TIME=English_United States.1252 attached base packages: [1] stats graphics grDevices utils datasets methods base loaded via a namespace (and not attached): [1] tools_2.12.1 thanks, allie On 6/22/2011 1:50 PM, William Dunlap wrote: What do you get for the following commands, which show which is.na method is getting called and the internal structure of the dataset made by strptime? methods(is.na) [1] is.na.data.frame is.na.numeric_version is.na.POSIXlt trace(methods(is.na), quote(cat( is.na: class(x)=, class(x), \n))) Tracing function is.na.data.frame in package base Tracing function is.na.numeric_version in package base Tracing function is.na.POSIXlt in package base [1] is.na.data.frame is.na.numeric_version is.na.POSIXlt z - strptime(5/3/1992, format=%m/%d/%Y) is.na(z) Tracing is.na.POSIXlt(z) on entry is.na: class(x)= POSIXlt POSIXt [1] FALSE str(unclass(z)) List of 9 $ sec : num 0 $ min : int 0 $ hour : int 0 $ mday : int 3 $ mon : int 4 $ year : int 92 $ wday : int 0 $ yday : int 123 $ isdst: int 1 Bill Dunlap Spotfire, TIBCO Software wdunlap tibco.com -Original Message- From: r-help-boun...@r-project.org [mailto:r-help-boun...@r-project.org] On Behalf Of Alexander Shenkin Sent: Wednesday, June 22, 2011 11:41 AM To: Sarah Goslee; r-help@r-project.org Subject: Re: [R] strange date problem - May 3, 1992 is NA On 6/22/2011 1:34 PM, Sarah Goslee wrote: On Wed, Jun 22, 2011 at 2:28 PM, David Winsemius dwinsem...@comcast.net wrote: On Jun 22, 2011, at 2:03 PM, Sarah Goslee wrote: Hi, On Wed, Jun 22, 2011 at 11:40 AM, Alexander Shenkin ashen...@ufl.edu wrote: is.na(strptime(5/2/1992, format=%m/%d/%Y)) [1] FALSE is.na(strptime(5/3/1992, format=%m/%d/%Y)) [1] TRUE I can't reproduce your problem on R 2.13.0 on linux: I also cannot reproduce it on a Mac with 2.13.0 beta Which strongly suggests that you should start by upgrading your R installation if at all possible. I'd also recommend trying it on a default R session, with no extra packages loaded, and no items in your workspace. It's possible that something else is interfering. On linux, that's achieved by typing R --vanilla at the command line. I'm afraid I don't know how to do it for Windows, but should be similarly straightforward. Thanks Sarah. Still getting the problem. I should surely upgrade, but still, not a bad idea to get to the bottom of this, or at least have it documented as a known issue. BTW, I'm on Windows 7 Pro x64. (running Rgui.exe --vanilla): is.na(strptime(5/3/1992, format=%m/%d/%Y)) [1] TRUE is.na(strptime(5/2/1992, format=%m/%d/%Y)) [1] FALSE sessionInfo() R
Re: [R] strange date problem - May 3, 1992 is NA
On 6/22/2011 12:09 PM, Luke Miller wrote: For what it's worth, I cannot reproduce this problem under a nearly identical instance of R (R 2.12.1, Win 7 Pro 64-bit). I also can't reproduce the problem with R 2.13.0. You've got something truly weird going on with your particular instance of R. is.na(strptime(5/3/1992, format=%m/%d/%Y)) [1] FALSE is.na(strptime(5/2/1992, format=%m/%d/%Y)) [1] FALSE sessionInfo() R version 2.12.1 (2010-12-16) Platform: i386-pc-mingw32/i386 (32-bit) locale: [1] LC_COLLATE=English_United States.1252 [2] LC_CTYPE=English_United States.1252 [3] LC_MONETARY=English_United States.1252 [4] LC_NUMERIC=C [5] LC_TIME=English_United States.1252 attached base packages: [1] stats graphics grDevices utils datasets methods base other attached packages: [1] rj_0.5.2-1 lattice_0.19-17 loaded via a namespace (and not attached): [1] grid_2.12.1 rJava_0.8-8 tools_2.12.1 Like Luke, I can not reproduce what you see in (an old installation of) R 2.12.1 (and it also didn't have rj, lattice, grid, rJava, or tools attached or loaded in any way). My vague gut feeling is it might be a timezone/daylight savings time related issue (though usually times have to be involved). At least, that is a common problem with weird things happening with dates. What do you get as output for the following? Sys.timezone() Sys.info() conflicts() dput(strptime(5/3/1992, format=%m/%d/%Y)) dput(as.POSIXct(strptime(5/3/1992, format=%m/%d/%Y))) dput(strptime(5/2/1992, format=%m/%d/%Y)) dput(as.POSIXct(strptime(5/2/1992, format=%m/%d/%Y))) On Wed, Jun 22, 2011 at 2:40 PM, Alexander Shenkinashen...@ufl.edu wrote: On 6/22/2011 1:34 PM, Sarah Goslee wrote: On Wed, Jun 22, 2011 at 2:28 PM, David Winsemiusdwinsem...@comcast.net wrote: On Jun 22, 2011, at 2:03 PM, Sarah Goslee wrote: Hi, On Wed, Jun 22, 2011 at 11:40 AM, Alexander Shenkinashen...@ufl.edu wrote: is.na(strptime(5/2/1992, format=%m/%d/%Y)) [1] FALSE is.na(strptime(5/3/1992, format=%m/%d/%Y)) [1] TRUE I can't reproduce your problem on R 2.13.0 on linux: I also cannot reproduce it on a Mac with 2.13.0 beta Which strongly suggests that you should start by upgrading your R installation if at all possible. I'd also recommend trying it on a default R session, with no extra packages loaded, and no items in your workspace. It's possible that something else is interfering. On linux, that's achieved by typing R --vanilla at the command line. I'm afraid I don't know how to do it for Windows, but should be similarly straightforward. Thanks Sarah. Still getting the problem. I should surely upgrade, but still, not a bad idea to get to the bottom of this, or at least have it documented as a known issue. BTW, I'm on Windows 7 Pro x64. (running Rgui.exe --vanilla): is.na(strptime(5/3/1992, format=%m/%d/%Y)) [1] TRUE is.na(strptime(5/2/1992, format=%m/%d/%Y)) [1] FALSE sessionInfo() R version 2.12.1 (2010-12-16) Platform: i386-pc-mingw32/i386 (32-bit) locale: [1] LC_COLLATE=English_United States.1252 [2] LC_CTYPE=English_United States.1252 [3] LC_MONETARY=English_United States.1252 [4] LC_NUMERIC=C [5] LC_TIME=English_United States.1252 attached base packages: [1] stats graphics grDevices utils datasets methods base __ 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 S. Diggs, PhD Senior Research Associate, Department of Surgery Oregon Health Science 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] strange date problem - May 3, 1992 is NA
On 6/22/2011 3:34 PM, Brian Diggs wrote: On 6/22/2011 12:09 PM, Luke Miller wrote: For what it's worth, I cannot reproduce this problem under a nearly identical instance of R (R 2.12.1, Win 7 Pro 64-bit). I also can't reproduce the problem with R 2.13.0. You've got something truly weird going on with your particular instance of R. is.na(strptime(5/3/1992, format=%m/%d/%Y)) [1] FALSE is.na(strptime(5/2/1992, format=%m/%d/%Y)) [1] FALSE sessionInfo() R version 2.12.1 (2010-12-16) Platform: i386-pc-mingw32/i386 (32-bit) locale: [1] LC_COLLATE=English_United States.1252 [2] LC_CTYPE=English_United States.1252 [3] LC_MONETARY=English_United States.1252 [4] LC_NUMERIC=C [5] LC_TIME=English_United States.1252 attached base packages: [1] stats graphics grDevices utils datasets methods base other attached packages: [1] rj_0.5.2-1 lattice_0.19-17 loaded via a namespace (and not attached): [1] grid_2.12.1 rJava_0.8-8 tools_2.12.1 Like Luke, I can not reproduce what you see in (an old installation of) R 2.12.1 (and it also didn't have rj, lattice, grid, rJava, or tools attached or loaded in any way). My vague gut feeling is it might be a timezone/daylight savings time related issue (though usually times have to be involved). At least, that is a common problem with weird things happening with dates. What do you get as output for the following? Sys.timezone() Sys.info() conflicts() dput(strptime(5/3/1992, format=%m/%d/%Y)) dput(as.POSIXct(strptime(5/3/1992, format=%m/%d/%Y))) dput(strptime(5/2/1992, format=%m/%d/%Y)) dput(as.POSIXct(strptime(5/2/1992, format=%m/%d/%Y))) Sys.timezone() [1] COT Sys.info() sysname release version nodename machine Windows 7 x64 build 7601, Service Pack 1 machine_namex86 login user username username conflicts() [1] untangle.specials body-format.pval round.POSIXt trunc.POSIXt units dput(strptime(5/3/1992, format=%m/%d/%Y)) structure(list(sec = 0, min = 0L, hour = 0L, mday = 3L, mon = 4L, year = 92L, wday = 0L, yday = 123L, isdst = -1L), .Names = c(sec, min, hour, mday, mon, year, wday, yday, isdst ), class = c(POSIXlt, POSIXt)) dput(as.POSIXct(strptime(5/3/1992, format=%m/%d/%Y))) structure(NA_real_, class = c(POSIXct, POSIXt), tzone = ) dput(strptime(5/2/1992, format=%m/%d/%Y)) structure(list(sec = 0, min = 0L, hour = 0L, mday = 2L, mon = 4L, year = 92L, wday = 6L, yday = 122L, isdst = 0L), .Names = c(sec, min, hour, mday, mon, year, wday, yday, isdst ), class = c(POSIXlt, POSIXt)) dput(as.POSIXct(strptime(5/2/1992, format=%m/%d/%Y))) structure(704782800, class = c(POSIXct, POSIXt), tzone = ) On Wed, Jun 22, 2011 at 2:40 PM, Alexander Shenkinashen...@ufl.edu wrote: On 6/22/2011 1:34 PM, Sarah Goslee wrote: On Wed, Jun 22, 2011 at 2:28 PM, David Winsemiusdwinsem...@comcast.net wrote: On Jun 22, 2011, at 2:03 PM, Sarah Goslee wrote: Hi, On Wed, Jun 22, 2011 at 11:40 AM, Alexander Shenkinashen...@ufl.edu wrote: is.na(strptime(5/2/1992, format=%m/%d/%Y)) [1] FALSE is.na(strptime(5/3/1992, format=%m/%d/%Y)) [1] TRUE I can't reproduce your problem on R 2.13.0 on linux: I also cannot reproduce it on a Mac with 2.13.0 beta Which strongly suggests that you should start by upgrading your R installation if at all possible. I'd also recommend trying it on a default R session, with no extra packages loaded, and no items in your workspace. It's possible that something else is interfering. On linux, that's achieved by typing R --vanilla at the command line. I'm afraid I don't know how to do it for Windows, but should be similarly straightforward. Thanks Sarah. Still getting the problem. I should surely upgrade, but still, not a bad idea to get to the bottom of this, or at least have it documented as a known issue. BTW, I'm on Windows 7 Pro x64. (running Rgui.exe --vanilla): is.na(strptime(5/3/1992, format=%m/%d/%Y)) [1] TRUE is.na(strptime(5/2/1992, format=%m/%d/%Y)) [1] FALSE sessionInfo() R version 2.12.1 (2010-12-16) Platform: i386-pc-mingw32/i386 (32-bit) locale: [1] LC_COLLATE=English_United States.1252 [2] LC_CTYPE=English_United States.1252 [3] LC_MONETARY=English_United States.1252 [4] LC_NUMERIC=C [5] LC_TIME=English_United States.1252 attached base packages: [1] stats graphics grDevices utils datasets methods base __ 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
Re: [R] strange date problem - May 3, 1992 is NA
On 6/22/2011 1:23 PM, William Dunlap wrote: The isdst value -1 doesn't seem right. Shouldn't it be either 0 (not daylight savings time) or 1 (yes dst)? I've only seen isdst==-1 when all the other entries were NA (that happens when the string doesn't match the format). A isdst of -1 indicates that the dst status of that time is not known. I've seen (and submitted patches to use) this when internally mucking with the parts of a POSIXlt. Changing, say, the hour of a valid POSIXlt value may result in a configuration which is not consistent (crossed a DST boundary). This POSIXlt behaves fairly well, but when converted to a POSIXct, gives NA. These conversions often happen behind the scenes. In particular: is.na.POSIXlt function (x) is.na(as.POSIXct(x)) environment: namespace:base It may be that as.POSIXct.POSIXlt can handle isdst==-1 when the DST status is unambiguous, but maybe not when it is. I'm curious what the specifics of the timezone Alexander is working in. In the parts of the US where daylight savings time is used the switchover took place near the beginning of April in 1992, so you should have isdst=1 by May 3. Perhaps you have an odd timezone file on your machine. Bill Dunlap Spotfire, TIBCO Software wdunlap tibco.com -Original Message- From: Alexander Shenkin [mailto:ashen...@ufl.edu] Sent: Wednesday, June 22, 2011 1:07 PM To: William Dunlap Subject: Re: [R] strange date problem - May 3, 1992 is NA Hi Bill, Thanks for your reply. The results look almost identical to my eyes, except for the mysterious TRUE... methods(is.na) [1] is.na.data.frame is.na.numeric_version is.na.POSIXlt trace(methods(is.na), quote(cat( is.na: class(x)=, class(x), \n))) Tracing function is.na.data.frame in package base Tracing function is.na.numeric_version in package base Tracing function is.na.POSIXlt in package base [1] is.na.data.frame is.na.numeric_version is.na.POSIXlt z- strptime(5/3/1992, format=%m/%d/%Y) is.na(z) Tracing is.na.POSIXlt(z) on entry is.na: class(x)= POSIXlt POSIXt [1] TRUE str(unclass(z)) List of 9 $ sec : num 0 $ min : int 0 $ hour : int 0 $ mday : int 3 $ mon : int 4 $ year : int 92 $ wday : int 0 $ yday : int 123 $ isdst: int -1 sessionInfo() R version 2.12.1 (2010-12-16) Platform: i386-pc-mingw32/i386 (32-bit) locale: [1] LC_COLLATE=English_United States.1252 [2] LC_CTYPE=English_United States.1252 [3] LC_MONETARY=English_United States.1252 [4] LC_NUMERIC=C [5] LC_TIME=English_United States.1252 attached base packages: [1] stats graphics grDevices utils datasets methods base loaded via a namespace (and not attached): [1] tools_2.12.1 thanks, allie On 6/22/2011 1:50 PM, William Dunlap wrote: What do you get for the following commands, which show which is.na method is getting called and the internal structure of the dataset made by strptime? methods(is.na) [1] is.na.data.frame is.na.numeric_version is.na.POSIXlt trace(methods(is.na), quote(cat( is.na: class(x)=, class(x), \n))) Tracing function is.na.data.frame in package base Tracing function is.na.numeric_version in package base Tracing function is.na.POSIXlt in package base [1] is.na.data.frame is.na.numeric_version is.na.POSIXlt z- strptime(5/3/1992, format=%m/%d/%Y) is.na(z) Tracing is.na.POSIXlt(z) on entry is.na: class(x)= POSIXlt POSIXt [1] FALSE str(unclass(z)) List of 9 $ sec : num 0 $ min : int 0 $ hour : int 0 $ mday : int 3 $ mon : int 4 $ year : int 92 $ wday : int 0 $ yday : int 123 $ isdst: int 1 Bill Dunlap Spotfire, TIBCO Software wdunlap tibco.com -Original Message- From: r-help-boun...@r-project.org [mailto:r-help-boun...@r-project.org] On Behalf Of Alexander Shenkin Sent: Wednesday, June 22, 2011 11:41 AM To: Sarah Goslee; r-help@r-project.org Subject: Re: [R] strange date problem - May 3, 1992 is NA On 6/22/2011 1:34 PM, Sarah Goslee wrote: On Wed, Jun 22, 2011 at 2:28 PM, David Winsemius dwinsem...@comcast.net wrote: On Jun 22, 2011, at 2:03 PM, Sarah Goslee wrote: Hi, On Wed, Jun 22, 2011 at 11:40 AM, Alexander Shenkin ashen...@ufl.edu wrote: is.na(strptime(5/2/1992, format=%m/%d/%Y)) [1] FALSE is.na(strptime(5/3/1992, format=%m/%d/%Y)) [1] TRUE I can't reproduce your problem on R 2.13.0 on linux: I also cannot reproduce it on a Mac with 2.13.0 beta Which strongly suggests that you should start by upgrading your R installation if at all possible. I'd also recommend trying it on a default R session, with no extra packages loaded, and no items in your workspace. It's possible that something else is interfering. On linux, that's achieved by typing R --vanilla at the command line. I'm afraid I don't know how to do it for Windows, but should be similarly straightforward. Thanks Sarah. Still getting the problem. I should surely upgrade, but still, not a bad idea to get to the bottom of this, or at least have it documented as a known issue.
[R] Appending to list
So im here now b/c im incredibly frustrated. Please consider the following: #Try 1 Data_-list() Sn-1:12 for(sn in Sn){ for(i in 1:10){ Data.X - rnorm(100,0,10) Data_[[paste(sn,i,sep=-)]]-Data.X } } ##Try 2 Data_-list() Sn-1:12 for(sn in Sn){ for(i in 1:10){ Data.X - rnorm(100,0,10) Data_[[sn]][[i]]-Data.X } } In Try 1 i am able to append separately each of the 120 different combinations of element types. But if i want to retrieve the data i have to create a separate value by 're' pasting the two element names (sn,i) together instead of just referencing them via subscripts [[sn]][[i]]. I have code for some other things where this works fine and the code im working on currently only craps out on certain data and its all the same (between different element types) so i cant figure out what the deal is. Doing things the way my code is written in Try 2 i return: $TRN[[11]] [1] 3488.300 384592.030 33478.449 20542.162 28967.105 9667.843 39702.814 250780.450 55615.836 12023.944 [11] 2060.849 3001.797 9252.429 86008.546 1209.302 26470.770 11700.330 7575.689 328187.431 $TRN[[12]] [1] 2645.294 70933.649 34832.911 203584.014 7040.440 49305.850 53736.759 22394.943 223590.439 26145.437 [11] 42278.920 41736.813 40478.030 $TRN_CLUST [1] 0 0 0 0 0 0 0 0 0 0 0 0 Where $TRN[[n]] goes from 1-12 (only show 11,12 here) and $TRN_CLUST should do the same but there are times when i have missing values, hence the zero, but it doesnt store it the same (e.g $TRN_CLUST[[1]] [1] 0 $TRN_CLUST[[2]] [1] 0 What nuance am i missing here? Hope my question and issue are clear. Thanks Josh -- View this message in context: http://r.789695.n4.nabble.com/Appending-to-list-tp3618093p3618093.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] AIC() vs. mle.aic() vs. step()?
I know this a newbie question, but I've only just started using AIC for model comparison and after a bunch of different keyword searches I've failed to find a page laying out what the differences are between the AIC scores assigned by AIC() and mle.aic() using default settings. I started by using mle.aic() to find the best submodels, but then I wanted to also be able to make comparisons with a couple of submodels that were nowhere near the top, so I started calculating AIC values using AIC(). What I found was that not only the scores, but also the ranking of the models was different. I'm not sure if this has to do with the fact that mle.aic() scores are based on the full model, or some sort of difference in penalties, or something else. Could anybody enlighten me as to the differences between these functions, or how I can use the same scoring system to find the best models and also compare to far inferior models? Failing that, could someone point me to an appropriate resource that might help me understand? Thanks in advance, Alexandra __ 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] strange date problem - May 3, 1992 is NA
On 6/22/2011 1:37 PM, Alexander Shenkin wrote: On 6/22/2011 3:34 PM, Brian Diggs wrote: On 6/22/2011 12:09 PM, Luke Miller wrote: For what it's worth, I cannot reproduce this problem under a nearly identical instance of R (R 2.12.1, Win 7 Pro 64-bit). I also can't reproduce the problem with R 2.13.0. You've got something truly weird going on with your particular instance of R. is.na(strptime(5/3/1992, format=%m/%d/%Y)) [1] FALSE is.na(strptime(5/2/1992, format=%m/%d/%Y)) [1] FALSE sessionInfo() R version 2.12.1 (2010-12-16) Platform: i386-pc-mingw32/i386 (32-bit) locale: [1] LC_COLLATE=English_United States.1252 [2] LC_CTYPE=English_United States.1252 [3] LC_MONETARY=English_United States.1252 [4] LC_NUMERIC=C [5] LC_TIME=English_United States.1252 attached base packages: [1] stats graphics grDevices utils datasets methods base other attached packages: [1] rj_0.5.2-1 lattice_0.19-17 loaded via a namespace (and not attached): [1] grid_2.12.1 rJava_0.8-8 tools_2.12.1 Like Luke, I can not reproduce what you see in (an old installation of) R 2.12.1 (and it also didn't have rj, lattice, grid, rJava, or tools attached or loaded in any way). My vague gut feeling is it might be a timezone/daylight savings time related issue (though usually times have to be involved). At least, that is a common problem with weird things happening with dates. What do you get as output for the following? Sys.timezone() Sys.info() conflicts() dput(strptime(5/3/1992, format=%m/%d/%Y)) dput(as.POSIXct(strptime(5/3/1992, format=%m/%d/%Y))) dput(strptime(5/2/1992, format=%m/%d/%Y)) dput(as.POSIXct(strptime(5/2/1992, format=%m/%d/%Y))) Sys.timezone() [1] COT Sys.info() sysname release version nodename machine Windows 7 x64 build 7601, Service Pack 1 machine_namex86 login user username username conflicts() [1] untangle.specials body-format.pval round.POSIXt trunc.POSIXt units dput(strptime(5/3/1992, format=%m/%d/%Y)) structure(list(sec = 0, min = 0L, hour = 0L, mday = 3L, mon = 4L, year = 92L, wday = 0L, yday = 123L, isdst = -1L), .Names = c(sec, min, hour, mday, mon, year, wday, yday, isdst ), class = c(POSIXlt, POSIXt)) dput(as.POSIXct(strptime(5/3/1992, format=%m/%d/%Y))) structure(NA_real_, class = c(POSIXct, POSIXt), tzone = ) dput(strptime(5/2/1992, format=%m/%d/%Y)) structure(list(sec = 0, min = 0L, hour = 0L, mday = 2L, mon = 4L, year = 92L, wday = 6L, yday = 122L, isdst = 0L), .Names = c(sec, min, hour, mday, mon, year, wday, yday, isdst ), class = c(POSIXlt, POSIXt)) dput(as.POSIXct(strptime(5/2/1992, format=%m/%d/%Y))) structure(704782800, class = c(POSIXct, POSIXt), tzone = ) Fun :) So, not being familiar with COT, I looked it up to see what/when the daylight savings times switch overs are/were. http://www.timeanddate.com/worldclock/timezone.html?n=41syear=1990 Daylight savings time started (in 1992 only) on Midnight between Saturday, May 2 and Sunday, May 3 and ended (in 1993) on Midnight between Saturday, April 3 and Sunday, April 4. In particular, it went from Saturday, May 2, 1992 11:59:59 PM to Sunday, May 3 1992 1:00:00 AM. So there was no midnight on May 3. So when strptime converts the date, it, by default, sets the time to midnight. Except that is not valid according to the DST rules (which is why isdst gets set to -1). When converting to a POSIXct, it becomes NA. There are probably a lot of places in R that assume midnight is a valid time, and so I don't know what all will or will not work in that timezone (you probably will also have problems with seq and cut on POSIXct/POSIXlt's in that timezone at least). I'd recommend using a different timezone. Or, if you don't need times, using Date (which doesn't have timezones and so avoids this): as.Date(5/3/1992, format=%m/%d/%Y) On Wed, Jun 22, 2011 at 2:40 PM, Alexander Shenkinashen...@ufl.edu wrote: On 6/22/2011 1:34 PM, Sarah Goslee wrote: On Wed, Jun 22, 2011 at 2:28 PM, David Winsemiusdwinsem...@comcast.net wrote: On Jun 22, 2011, at 2:03 PM, Sarah Goslee wrote: Hi, On Wed, Jun 22, 2011 at 11:40 AM, Alexander Shenkinashen...@ufl.edu wrote: is.na(strptime(5/2/1992, format=%m/%d/%Y)) [1] FALSE is.na(strptime(5/3/1992, format=%m/%d/%Y)) [1] TRUE I can't reproduce your problem on R 2.13.0 on linux: I also cannot reproduce it on a Mac with 2.13.0 beta Which strongly suggests that you should start by upgrading your R installation if at all possible. I'd also recommend trying it on a default R session, with no extra packages loaded, and no items in your workspace. It's possible that something else is interfering. On linux, that's achieved by typing R --vanilla at the command line.
Re: [R] mlogit model that contains both individual-specific parameters and universal parameters
On Wed, 22 Jun 2011, Quang Anh Duong wrote: Hello,? I am pretty new to mlogit, and still trying to figure out what models to use.I have a data set of N individuals, each of which faces I alternatives. The utility function of individual n, for choice i is:? u(i,n) = alpha(i) * x1(i,n) + beta * x2(i,n)? where alpha(i) is the individual specific parameter, and beta is shared among all individuals. I don't really know how to set this up in mlogit.? I guess you mean that alpha(i) is the alternative-specific coefficient of the individual-specific regressor x1(n)? And x2(i,n) is an alternative-specific regressor with coefficient beta. If so, the model is y ~ x2 | x1. (Possibly, you may want to exclude the alternative-specific intercepts.) But see the extensive package vignettes for more details: vignette(mlogit, package = mlogit) vignette(Exercises, package = mlogit) hth, Z If I assumed that beta is individual-specific (beta(i)), then I can divide the data set to many subsets, each of which corresponds to a particular individual i, and run this model for each subset to estimate alpha(i) and beta(i).? y ~ x1 + x2? This can be done just fine.? I have gone over tutorials by Train and by Heshner but I haven't found out how to solve this problem yet. Any suggestions are welcome. Thank you so much for your time! [[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] Factor Analysis with orthogonal and oblique rotation
Hello I seem to find only two types of rotation for the factanal function in R, the Varimax and Promax, but is it possible to run a orthogonal and oblique rotations in R? Thanks in advance Rosario __ 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] strange date problem - May 3, 1992 is NA
On 6/22/2011 4:09 PM, Brian Diggs wrote: On 6/22/2011 1:37 PM, Alexander Shenkin wrote: On 6/22/2011 3:34 PM, Brian Diggs wrote: On 6/22/2011 12:09 PM, Luke Miller wrote: For what it's worth, I cannot reproduce this problem under a nearly identical instance of R (R 2.12.1, Win 7 Pro 64-bit). I also can't reproduce the problem with R 2.13.0. You've got something truly weird going on with your particular instance of R. is.na(strptime(5/3/1992, format=%m/%d/%Y)) [1] FALSE is.na(strptime(5/2/1992, format=%m/%d/%Y)) [1] FALSE sessionInfo() R version 2.12.1 (2010-12-16) Platform: i386-pc-mingw32/i386 (32-bit) locale: [1] LC_COLLATE=English_United States.1252 [2] LC_CTYPE=English_United States.1252 [3] LC_MONETARY=English_United States.1252 [4] LC_NUMERIC=C [5] LC_TIME=English_United States.1252 attached base packages: [1] stats graphics grDevices utils datasets methods base other attached packages: [1] rj_0.5.2-1 lattice_0.19-17 loaded via a namespace (and not attached): [1] grid_2.12.1 rJava_0.8-8 tools_2.12.1 Like Luke, I can not reproduce what you see in (an old installation of) R 2.12.1 (and it also didn't have rj, lattice, grid, rJava, or tools attached or loaded in any way). My vague gut feeling is it might be a timezone/daylight savings time related issue (though usually times have to be involved). At least, that is a common problem with weird things happening with dates. What do you get as output for the following? Sys.timezone() Sys.info() conflicts() dput(strptime(5/3/1992, format=%m/%d/%Y)) dput(as.POSIXct(strptime(5/3/1992, format=%m/%d/%Y))) dput(strptime(5/2/1992, format=%m/%d/%Y)) dput(as.POSIXct(strptime(5/2/1992, format=%m/%d/%Y))) Sys.timezone() [1] COT Sys.info() sysname release version nodename machine Windows 7 x64 build 7601, Service Pack 1 machine_namex86 login user username username conflicts() [1] untangle.specials body-format.pval round.POSIXt trunc.POSIXt units dput(strptime(5/3/1992, format=%m/%d/%Y)) structure(list(sec = 0, min = 0L, hour = 0L, mday = 3L, mon = 4L, year = 92L, wday = 0L, yday = 123L, isdst = -1L), .Names = c(sec, min, hour, mday, mon, year, wday, yday, isdst ), class = c(POSIXlt, POSIXt)) dput(as.POSIXct(strptime(5/3/1992, format=%m/%d/%Y))) structure(NA_real_, class = c(POSIXct, POSIXt), tzone = ) dput(strptime(5/2/1992, format=%m/%d/%Y)) structure(list(sec = 0, min = 0L, hour = 0L, mday = 2L, mon = 4L, year = 92L, wday = 6L, yday = 122L, isdst = 0L), .Names = c(sec, min, hour, mday, mon, year, wday, yday, isdst ), class = c(POSIXlt, POSIXt)) dput(as.POSIXct(strptime(5/2/1992, format=%m/%d/%Y))) structure(704782800, class = c(POSIXct, POSIXt), tzone = ) Fun :) So, not being familiar with COT, I looked it up to see what/when the daylight savings times switch overs are/were. http://www.timeanddate.com/worldclock/timezone.html?n=41syear=1990 Daylight savings time started (in 1992 only) on Midnight between Saturday, May 2 and Sunday, May 3 and ended (in 1993) on Midnight between Saturday, April 3 and Sunday, April 4. In particular, it went from Saturday, May 2, 1992 11:59:59 PM to Sunday, May 3 1992 1:00:00 AM. So there was no midnight on May 3. So when strptime converts the date, it, by default, sets the time to midnight. Except that is not valid according to the DST rules (which is why isdst gets set to -1). When converting to a POSIXct, it becomes NA. There are probably a lot of places in R that assume midnight is a valid time, and so I don't know what all will or will not work in that timezone (you probably will also have problems with seq and cut on POSIXct/POSIXlt's in that timezone at least). I'd recommend using a different timezone. Or, if you don't need times, using Date (which doesn't have timezones and so avoids this): as.Date(5/3/1992, format=%m/%d/%Y) Thanks for your detective work, Brian! Nice one. I am now using date, and so _my_ problem is solved. However, it must be the case that others have and will continue to run across this problem (and perhaps won't even realize it, thus tossing away data). Indeed, it seems like there are quite a number of places that have DST switching at midnight: http://www.google.com/search?q=Midnight+site%3Ahttp%3A%2F%2Fwww.timeanddate.com%2Fworldclock%2Ftimezone.html . I assume all these timezones would come across a similar problem as mine? What would be the best route to try to get this smoothed over in R-core? On Wed, Jun 22, 2011 at 2:40 PM, Alexander Shenkinashen...@ufl.edu wrote: On 6/22/2011 1:34 PM, Sarah Goslee wrote: On Wed, Jun 22, 2011 at 2:28 PM, David Winsemiusdwinsem...@comcast.net
Re: [R] Factor Analysis with orthogonal and oblique rotation
Varimax is orthogonal, promax is oblique. Varimax is generally not recommended. See: Preacher, K. J., MacCallum, R. C. (2003). Repairing Tom Swift's electric factor analysis machine. Understanding Statistics, 2(1), 13-43. (Google the title and you'll find a PDF). The fa() function in the psych package has more flavors of extraction and rotation. Jeremy On 22 June 2011 14:02, Rosario Garcia Gil m.rosario.gar...@slu.se wrote: Hello I seem to find only two types of rotation for the factanal function in R, the Varimax and Promax, but is it possible to run a orthogonal and oblique rotations in R? Thanks in advance Rosario __ 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] Unreasonable syntax error
I second the fortune nomination, probably the 1st paragraph is sufficient for a fortune. -- 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-bounces@r- project.org] On Behalf Of Ted Harding Sent: Tuesday, June 21, 2011 1:25 AM To: r-help@r-project.org Subject: Re: [R] Unreasonable syntax error How long can a fortune be? Bill's response is fortune-worthy in its entirety! I would intensify his advice to NOT to use Microsoft Word. Note the Full Stop. I will spare people the full catalogue of misfortunes I have observed, but feel inclined to cite the case of someone to whom I once sent a PostScript file, who, naively, opened it in Word which, helpfully (as Bill emphasises), was in Autosave mode. Within a few seconds the file was scrambled beyond recovery. Best wishes to all, Ted. On 20-Jun-11 22:47:49, bill.venab...@csiro.au wrote: The advice is always NOT to use Microsoft Word to edit an R file. That stuff is poisonous. Microsoft word, typical of all Microsoft software, does not do what you tell it to do but helpfully does what it thinks you meant to ask it to do but were too dumb to do so. Even notepad, gawdelpus, would be better. When I look at your script the first sign of trouble I see is: Error: unexpected input in: s[1,3,k]- (0.1) * runif(1)+ 0.1; s[1,1,k]- (0.02) * runif(1)+ 0.98 ¨ which is the spurious character Microsoft word has helpfully inserted to make it all look nice. It's downhill all the way from there. (R does not expect Microsoft Word, just as nobody expects the Spanish Inquisition. See http://www.youtube.com/watch?v=CSe38dzJYkY). Bill Venables. -Original Message- From: r-help-boun...@r-project.org [mailto:r-help-boun...@r-project.org] On Behalf Of james198877 Sent: Tuesday, 21 June 2011 7:13 AM To: r-help@r-project.org Subject: [R] Unreasonable syntax error http://r.789695.n4.nabble.com/file/n3612530/PSC.r PSC.r Hi all, I just wrote a program in R by editing it in Microsoft Word and then pasting into the text editor of R. The above is the file. And below is what the console complains Why doesn't it recognise 'r'?? I have to mention that at least when I typed this first several lines into the console, the first error didn't appear. I don't try the next errors as there would be too many lines to type...I'm not sure if this is something about Word http://r.789695.n4.nabble.com/file/n3612530/lastsave.txt lastsave.txt Thanks a lot for your help!!! E-Mail: (Ted Harding) ted.hard...@wlandres.net Fax-to-email: +44 (0)870 094 0861 Date: 21-Jun-11 Time: 08:25:11 -- XFMail -- __ 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] Appending to list
You lost me with the TRN and TRN_CLUSTER bits, but are you trying to make a list of lists? Data_ - list() SN - 1:12 for(sn in SN) { + Data_[[sn]] - list() + for(i in 1:10) { + Data.X - rnorm(5, 0, 10) + Data_[[sn]][[i]] - Data.X + }} Data_[[3]][[2]] [1] -5.687070 -2.365589 12.378359 10.797234 -3.815883 Data_[[5]][[9]] [1] 3.705303 -6.955137 -0.730882 2.108603 -2.898769 By the way, calling your data Data_ is generally a really bad idea. Sarah On Wed, Jun 22, 2011 at 4:10 PM, LCOG1 jr...@lcog.org wrote: So im here now b/c im incredibly frustrated. Please consider the following: #Try 1 Data_-list() Sn-1:12 for(sn in Sn){ for(i in 1:10){ Data.X - rnorm(100,0,10) Data_[[paste(sn,i,sep=-)]]-Data.X } } ##Try 2 Data_-list() Sn-1:12 for(sn in Sn){ for(i in 1:10){ Data.X - rnorm(100,0,10) Data_[[sn]][[i]]-Data.X } } In Try 1 i am able to append separately each of the 120 different combinations of element types. But if i want to retrieve the data i have to create a separate value by 're' pasting the two element names (sn,i) together instead of just referencing them via subscripts [[sn]][[i]]. I have code for some other things where this works fine and the code im working on currently only craps out on certain data and its all the same (between different element types) so i cant figure out what the deal is. Doing things the way my code is written in Try 2 i return: $TRN[[11]] [1] 3488.300 384592.030 33478.449 20542.162 28967.105 9667.843 39702.814 250780.450 55615.836 12023.944 [11] 2060.849 3001.797 9252.429 86008.546 1209.302 26470.770 11700.330 7575.689 328187.431 $TRN[[12]] [1] 2645.294 70933.649 34832.911 203584.014 7040.440 49305.850 53736.759 22394.943 223590.439 26145.437 [11] 42278.920 41736.813 40478.030 $TRN_CLUST [1] 0 0 0 0 0 0 0 0 0 0 0 0 Where $TRN[[n]] goes from 1-12 (only show 11,12 here) and $TRN_CLUST should do the same but there are times when i have missing values, hence the zero, but it doesnt store it the same (e.g $TRN_CLUST[[1]] [1] 0 $TRN_CLUST[[2]] [1] 0 What nuance am i missing here? Hope my question and issue are clear. Thanks Josh Sarah Goslee http://www.functionaldiversity.org __ 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] question about read.columns
HI, Dear R community, I have a large data set names dd.txt, the columns are: there are 2402 variables. a1, b1, ..z1, a11, b11, ...z11, a111, b111, ..z111.. IF I dont know the relative position of the columns, but I know I need the following variables: var-c(a1, c1,a11,b11,f111) Can I use read.columns to read the data into R? I have tried the following codes, but it does not work hh-read.columns(/house/homedirs/c/cdu/operon/gh/dd.dimer, required.col=NULL, text.to.search=var, sep=\t, skip=0, quote=, fill=T) dim(hh) 468, 2402 hh-read.columns(/house/homedirs/c/cdu/operon/gh/dd.dimer, required.col=var, text.to.search=, sep=\t, skip=0, quote=, fill=T) dim(hh) 0, 0 Can anyone help me with this? Thanks, -- Sincerely, Changbin -- [[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] question about read.columns
On Wed, Jun 22, 2011 at 5:45 PM, Changbin Du changb...@gmail.com wrote: HI, Dear R community, I have a large data set names dd.txt, the columns are: there are 2402 variables. a1, b1, ..z1, a11, b11, ...z11, a111, b111, ..z111.. IF I dont know the relative position of the columns, but I know I need the following variables: var-c(a1, c1,a11,b11,f111) Can I use read.columns to read the data into R? I have tried the following codes, but it does not work hh-read.columns(/house/homedirs/c/cdu/operon/gh/dd.dimer, required.col=NULL, text.to.search=var, sep=\t, skip=0, quote=, fill=T) Depending on the precise format of the input you might be able to use read.csv.sql in sqldf. (You may need to modify the args a bit relative to what is shown below but the basic idea is hopefully clear.) See ?read.csv.sql and also the examples on the sqldf home page (http://sqldf.googlecode.com) for more info. library(sqldf) DF - read.csv.sql(myfile, header = FALSE, sep = \t, sql = select a1,c1,a11,b11,f111 from file) -- Statistics Software Consulting GKX Group, GKX Associates Inc. tel: 1-877-GKX-GROUP email: ggrothendieck at gmail.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] Hardy Weinberg
I am interested in simulating 10,000 2 x 3 tables for SNPs data with the Hardy Weinberg formulation. Is there a quick way to do this? I am assuming that the minor allelle frequency is uniform in (0.05, 0.25). rmultinom() with HWE expectations __ 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] question about read.columns
Hi, Gabor, Thanks so much, I will try it and let you know the results. Appreciated! On Wed, Jun 22, 2011 at 2:54 PM, Gabor Grothendieck ggrothendi...@gmail.com wrote: On Wed, Jun 22, 2011 at 5:45 PM, Changbin Du changb...@gmail.com wrote: HI, Dear R community, I have a large data set names dd.txt, the columns are: there are 2402 variables. a1, b1, ..z1, a11, b11, ...z11, a111, b111, ..z111.. IF I dont know the relative position of the columns, but I know I need the following variables: var-c(a1, c1,a11,b11,f111) Can I use read.columns to read the data into R? I have tried the following codes, but it does not work hh-read.columns(/house/homedirs/c/cdu/operon/gh/dd.dimer, required.col=NULL, text.to.search=var, sep=\t, skip=0, quote=, fill=T) Depending on the precise format of the input you might be able to use read.csv.sql in sqldf. (You may need to modify the args a bit relative to what is shown below but the basic idea is hopefully clear.) See ?read.csv.sql and also the examples on the sqldf home page (http://sqldf.googlecode.com) for more info. library(sqldf) DF - read.csv.sql(myfile, header = FALSE, sep = \t, sql = select a1,c1,a11,b11,f111 from file) -- Statistics Software Consulting GKX Group, GKX Associates Inc. tel: 1-877-GKX-GROUP email: ggrothendieck at gmail.com -- Sincerely, Changbin -- Changbin Du DOE Joint Genome Institute Bldg 400 Rm 457 2800 Mitchell Dr Walnut Creet, CA 94598 Phone: 925-927-2856 [[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] question about read.columns
I found the following errors: library(sqldf) Loading required package: DBI Loading required package: RSQLite Loading required package: RSQLite.extfuns *Error: package 'RSQLite' 0.8-0 is loaded, but = 0.9.1 is required by 'RSQLite.extfuns'* hh-read.csv.sql(/house/homedirs/c/cdu/operon/gh5/hypo_re.dimer, header=FALSE, sep=\t,sql=select varr from file, quote=, fill=T) *Error: could not find function read.csv.sql* On Wed, Jun 22, 2011 at 2:57 PM, Changbin Du changb...@gmail.com wrote: Hi, Gabor, Thanks so much, I will try it and let you know the results. Appreciated! On Wed, Jun 22, 2011 at 2:54 PM, Gabor Grothendieck ggrothendi...@gmail.com wrote: On Wed, Jun 22, 2011 at 5:45 PM, Changbin Du changb...@gmail.com wrote: HI, Dear R community, I have a large data set names dd.txt, the columns are: there are 2402 variables. a1, b1, ..z1, a11, b11, ...z11, a111, b111, ..z111.. IF I dont know the relative position of the columns, but I know I need the following variables: var-c(a1, c1,a11,b11,f111) Can I use read.columns to read the data into R? I have tried the following codes, but it does not work hh-read.columns(/house/homedirs/c/cdu/operon/gh/dd.dimer, required.col=NULL, text.to.search=var, sep=\t, skip=0, quote=, fill=T) Depending on the precise format of the input you might be able to use read.csv.sql in sqldf. (You may need to modify the args a bit relative to what is shown below but the basic idea is hopefully clear.) See ?read.csv.sql and also the examples on the sqldf home page (http://sqldf.googlecode.com) for more info. library(sqldf) DF - read.csv.sql(myfile, header = FALSE, sep = \t, sql = select a1,c1,a11,b11,f111 from file) -- Statistics Software Consulting GKX Group, GKX Associates Inc. tel: 1-877-GKX-GROUP email: ggrothendieck at gmail.com -- Sincerely, Changbin -- Changbin Du DOE Joint Genome Institute Bldg 400 Rm 457 2800 Mitchell Dr Walnut Creet, CA 94598 Phone: 925-927-2856 -- Sincerely, Changbin -- Changbin Du DOE Joint Genome Institute Bldg 400 Rm 457 2800 Mitchell Dr Walnut Creet, CA 94598 Phone: 925-927-2856 [[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] question about read.columns
On Wed, Jun 22, 2011 at 6:01 PM, Changbin Du changb...@gmail.com wrote: I found the following errors: library(sqldf) Loading required package: DBI Loading required package: RSQLite Loading required package: RSQLite.extfuns Error: package 'RSQLite' 0.8-0 is loaded, but = 0.9.1 is required by 'RSQLite.extfuns' hh-read.csv.sql(/house/homedirs/c/cdu/operon/gh5/hypo_re.dimer, header=FALSE, sep=\t,sql=select varr from file, quote=, fill=T) Error: could not find function read.csv.sql Make sure you are using the most recent versions of R, RSQLite and sqldf. packageVersion(sqldf) [1] ‘0.4.1’ packageVersion(RSQLite) [1] ‘0.9.4’ R.version.string [1] R version 2.13.0 Patched (2011-06-09 r56106) -- Statistics Software Consulting GKX Group, GKX Associates Inc. tel: 1-877-GKX-GROUP email: ggrothendieck at gmail.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] question about read.columns
My R is 2.12.0. R.version.string [1] R version 2.12.0 (2010-10-15) packageVersion(RSQLite) [1] '0.8.0' packageVersion(sqldf) [1] '0.3.5' So it seems I have to update or install the 2.13.0 version in my linux machine. On Wed, Jun 22, 2011 at 3:04 PM, Gabor Grothendieck ggrothendi...@gmail.com wrote: On Wed, Jun 22, 2011 at 6:01 PM, Changbin Du changb...@gmail.com wrote: I found the following errors: library(sqldf) Loading required package: DBI Loading required package: RSQLite Loading required package: RSQLite.extfuns Error: package 'RSQLite' 0.8-0 is loaded, but = 0.9.1 is required by 'RSQLite.extfuns' hh-read.csv.sql(/house/homedirs/c/cdu/operon/gh5/hypo_re.dimer, header=FALSE, sep=\t,sql=select varr from file, quote=, fill=T) Error: could not find function read.csv.sql Make sure you are using the most recent versions of R, RSQLite and sql packageVersion(sqldf) [1] 0.4.1 packageVersion(RSQLite) [1] 0.9.4 R.version.string [1] R version 2.13.0 Patched (2011-06-09 r56106) -- Statistics Software Consulting GKX Group, GKX Associates Inc. tel: 1-877-GKX-GROUP email: ggrothendieck at gmail.com -- Sincerely, Changbin -- Changbin Du DOE Joint Genome Institute Bldg 400 Rm 457 2800 Mitchell Dr Walnut Creet, CA 94598 Phone: 925-927-2856 [[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] question about read.columns
On Wed, Jun 22, 2011 at 6:10 PM, Changbin Du changb...@gmail.com wrote: My R is 2.12.0. R.version.string [1] R version 2.12.0 (2010-10-15) packageVersion(RSQLite) [1] '0.8.0' packageVersion(sqldf) [1] '0.3.5' So it seems I have to update or install the 2.13.0 version in my linux machine. R 2.12 might work but you should certainly update your packages. -- Statistics Software Consulting GKX Group, GKX Associates Inc. tel: 1-877-GKX-GROUP email: ggrothendieck at gmail.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] question about read.columns
I will try this first. Thanks, Gabor! On Wed, Jun 22, 2011 at 3:15 PM, Gabor Grothendieck ggrothendi...@gmail.com wrote: On Wed, Jun 22, 2011 at 6:10 PM, Changbin Du changb...@gmail.com wrote: My R is 2.12.0. R.version.string [1] R version 2.12.0 (2010-10-15) packageVersion(RSQLite) [1] '0.8.0' packageVersion(sqldf) [1] '0.3.5' So it seems I have to update or install the 2.13.0 version in my linux machine. R 2.12 might work but you should certainly update your packages. -- Statistics Software Consulting GKX Group, GKX Associates Inc. tel: 1-877-GKX-GROUP email: ggrothendieck at gmail.com -- Sincerely, Changbin -- Changbin Du DOE Joint Genome Institute Bldg 400 Rm 457 2800 Mitchell Dr Walnut Creet, CA 94598 Phone: 925-927-2856 [[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] question about read.columns
INstalling of RSQLite was successful. in R: packageVersion(RSQLite) [1] '0.9.4' When I try to install sqldf, I found the following errors: install.packages(sqldf) Installing package(s) into '/house/homedirs/c/cdu/library/' (as 'lib' is unspecified) trying URL 'http://cran.cnr.Berkeley.edu/src/contrib/sqldf_0.4-0.tar.gz' Content type 'application/x-gzip' length 19920 bytes (19 Kb) opened URL == downloaded 19 Kb *ERROR: failed to lock directory '/house/homedirs/c/cdu/library' for modifying Try removing '/house/homedirs/c/cdu/library/00LOCK' * The downloaded packages are in '/tmp/RtmpszmT38/downloaded_packages' Warning message: In install.packages(sqldf) : installation of package 'sqldf' had non-zero exit status When I try to remove the */house/homedirs/c/cdu/library/00LOCK'* by rm -r 00LOCK, I got the following errors: cdu@nuuk:~/library$ rm -r 00LOCK *rm: cannot remove `00LOCK/RSQLite/libs/.nfs0001301e52e4': Device or resource busy* Not known what happened. Gabor, do you have any idea? Thanks! On Wed, Jun 22, 2011 at 3:24 PM, Changbin Du changb...@gmail.com wrote: I will try this first. Thanks, Gabor! On Wed, Jun 22, 2011 at 3:15 PM, Gabor Grothendieck ggrothendi...@gmail.com wrote: On Wed, Jun 22, 2011 at 6:10 PM, Changbin Du changb...@gmail.com wrote: My R is 2.12.0. R.version.string [1] R version 2.12.0 (2010-10-15) packageVersion(RSQLite) [1] '0.8.0' packageVersion(sqldf) [1] '0.3.5' So it seems I have to update or install the 2.13.0 version in my linux machine. R 2.12 might work but you should certainly update your packages. -- Statistics Software Consulting GKX Group, GKX Associates Inc. tel: 1-877-GKX-GROUP email: ggrothendieck at gmail.com -- Sincerely, Changbin -- Changbin Du DOE Joint Genome Institute Bldg 400 Rm 457 2800 Mitchell Dr Walnut Creet, CA 94598 Phone: 925-927-2856 -- Sincerely, Changbin -- Changbin Du DOE Joint Genome Institute Bldg 400 Rm 457 2800 Mitchell Dr Walnut Creet, CA 94598 Phone: 925-927-2856 [[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] question about read.columns
On Wed, Jun 22, 2011 at 7:07 PM, Changbin Du changb...@gmail.com wrote: INstalling of RSQLite was successful. in R: packageVersion(RSQLite) [1] '0.9.4' When I try to install sqldf, I found the following errors: install.packages(sqldf) Installing package(s) into '/house/homedirs/c/cdu/library/' (as 'lib' is unspecified) trying URL 'http://cran.cnr.Berkeley.edu/src/contrib/sqldf_0.4-0.tar.gz' Content type 'application/x-gzip' length 19920 bytes (19 Kb) opened URL == downloaded 19 Kb ERROR: failed to lock directory '/house/homedirs/c/cdu/library' for modifying Try removing '/house/homedirs/c/cdu/library/00LOCK' The downloaded packages are in '/tmp/RtmpszmT38/downloaded_packages' Warning message: In install.packages(sqldf) : installation of package 'sqldf' had non-zero exit status When I try to remove the /house/homedirs/c/cdu/library/00LOCK' by rm -r 00LOCK, I got the following errors: cdu@nuuk:~/library$ rm -r 00LOCK rm: cannot remove `00LOCK/RSQLite/libs/.nfs0001301e52e4': Device or resource busy Not known what happened. Gabor, do you have any idea? Thanks! You will need to remove the lock file. Try shutting down any processes that could be trying to access it *e.g. all R processes and all shells) and then try removing it again. If need be change the file's permissions and/or try as root. -- Statistics Software Consulting GKX Group, GKX Associates Inc. tel: 1-877-GKX-GROUP email: ggrothendieck at gmail.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] Fantastic! So many interesting and useful!
http://bakaneko.fr/friends.page.php?igjhotmailID=28aq2 [[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] plotmath: unexpected SPECIAL
Hello R Masters and the Rest of Us: The first of these works fine, the 2nd is accepted but too literal (the %-% is shown in the plot label and in the wrong position). The 3rd throws and error due to unexpected SPECIAL. Would someone recommend a way to format this? I want the two phrases connected by a right arrow. TIA, these things always elude me. Bryan *** Bryan Hanson Professor of Chemistry Biochemistry DePauw University xlab1 -expression(paste(Phase Angle , phi, Neat-O)) xlab2 - expression(paste(treatment: low stress, high stress, sep = %-%)) xlab3 - expression(paste(treatment: low stress, %-%, high stress)) plot(1:10, main = xlab1) plot(1:10, main = xlab2) __ 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 analysis with treatment effects - statistical approach
Hi Mike, here's a sample of my data so that you get an idea what I'm working with. http://r.789695.n4.nabble.com/file/n3618615/SampleDataSet.txt SampleDataSet.txt Also, I've uploaded an image showing a sample graph of daily soil moisture by treatment. The legend shows IP, IP+, PP, PP+ which are the 4 treatments. Also, I've included precipitation to show the soil moisture response to precip. http://r.789695.n4.nabble.com/file/n3618615/MeanWaterPrecipColour2ndSeasonOnly.jpeg I have used ANOVA previously, but I don't like it for 2 reasons. The first is that I have to average away all of the interesting variation. But mainly, it becomes quite cumbersome to do a separate ANOVA for each day (700+ days) or even each week (104 weeks). Thanks for your help, -Justin -- View this message in context: http://r.789695.n4.nabble.com/Time-series-analysis-with-treatment-effects-statistical-approach-tp3615856p3618615.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] plotmath: unexpected SPECIAL
Interesting. I don't know the explanation, but look at this: # works plot(1:10, 1:10, xlab=expression(a %-% b)) # doesn't work plot(1:10, 1:10, xlab=expression(%-%)) # works plot(1:10, 1:10, xlab=expression(paste(something %-% else))) # doesn't work plot(1:10, 1:10, xlab=expression(paste(something, %-%, else))) The doesn't work examples give the same error you report: Error: unexpected SPECIAL in plot(1:10, 1:10, xlab=expression(%-% And then there's: # doesn't work, as expected plot(1:10, 1:10, xlab=expression(paste(something phi else))) # works plot(1:10, 1:10, xlab=expression(paste(something, phi, else))) # works plot(1:10, 1:10, xlab=expression(paste(something %==% else))) # doesn't work plot(1:10, 1:10, xlab=expression(paste(something, %==%, else))) So it seems that when using an expression element bracketed by percent signs, the commas in paste cause an error, even though they are otherwise necessary. Hm. This is on a clean R 2.11 session on linux (I know, but that's the latest version in the UNR repository, and I don't use R enough on this netbook to install a non-repo version). I can try again tomorrow on an up-to-date system. Sarah - Hide quoted text - On Wed, Jun 22, 2011 at 8:10 PM, Bryan Hanson han...@depauw.edu wrote: Hello R Masters and the Rest of Us: The first of these works fine, the 2nd is accepted but too literal (the %-% is shown in the plot label and in the wrong position). The 3rd throws and error due to unexpected SPECIAL. Would someone recommend a way to format this? I want the two phrases connected by a right arrow. TIA, these things always elude me. Bryan -- Sarah Goslee http://www.functionaldiversity.org __ 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] plotmath: unexpected SPECIAL
On Jun 22, 2011, at 8:10 PM, Bryan Hanson wrote: Hello R Masters and the Rest of Us: The first of these works fine, the 2nd is accepted but too literal (the %-% is shown in the plot label and in the wrong position). The 3rd throws and error due to unexpected SPECIAL. Would someone recommend a way to format this? I want the two phrases connected by a right arrow. TIA, these things always elude me. Bryan *** Bryan Hanson Professor of Chemistry Biochemistry DePauw University xlab1 -expression(paste(Phase Angle , phi, Neat-O)) xlab2 - expression(paste(treatment: low stress, high stress, sep = %-%)) xlab3 - expression(paste(treatment: low stress, %-%, high stress)) plot(1:10, main = xlab1) plot(1:10, main = xlab2) Doesn't seem that %-% works without flanking terms xlab3 - expression(treatment*:~low~stress %-% high~stress) plot(1, main=xlab3) Or: xlab3 - expression(treatment: low stress %-% high~stress) plot(1, main=xlab3) -- David Winsemius, MD West Hartford, CT __ 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] plotmath: unexpected SPECIAL
Thanks to both David and Sarah. I'm glad I asked, as I had tried some of the combos Sarah suggested and observed the same behavior, which puzzled me. David, thanks for reminding me about ~ as that is a different way to get a space into the string. I just don't use plotmath often enough to become decent at it. Thanks again. Bryan On Jun 22, 2011, at 8:49 PM, David Winsemius wrote: On Jun 22, 2011, at 8:10 PM, Bryan Hanson wrote: Hello R Masters and the Rest of Us: The first of these works fine, the 2nd is accepted but too literal (the %-% is shown in the plot label and in the wrong position). The 3rd throws and error due to unexpected SPECIAL. Would someone recommend a way to format this? I want the two phrases connected by a right arrow. TIA, these things always elude me. Bryan *** Bryan Hanson Professor of Chemistry Biochemistry DePauw University xlab1 -expression(paste(Phase Angle , phi, Neat-O)) xlab2 - expression(paste(treatment: low stress, high stress, sep = %-%)) xlab3 - expression(paste(treatment: low stress, %-%, high stress)) plot(1:10, main = xlab1) plot(1:10, main = xlab2) Doesn't seem that %-% works without flanking terms xlab3 - expression(treatment*:~low~stress %-% high~stress) plot(1, main=xlab3) Or: xlab3 - expression(treatment: low stress %-% high~stress) plot(1, main=xlab3) -- David Winsemius, MD West Hartford, CT __ 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] plotmath: unexpected SPECIAL
Hi: From the plotmath help page: x %-% y x right-arrow y so this is behaving like a binary operator. There happen to be several of these in plotmath On Wed, Jun 22, 2011 at 5:49 PM, Sarah Goslee sarah.gos...@gmail.com wrote: Interesting. I don't know the explanation, but look at this: # works plot(1:10, 1:10, xlab=expression(a %-% b)) # doesn't work plot(1:10, 1:10, xlab=expression(%-%)) Because there are no operands. This behavior can be replicated from the command line: 10 %/% 2 [1] 5 %/% Error: unexpected SPECIAL in %/% I think this explains the rest of the non-working examples as well, since you wouldn't do such things with binary operators. # works plot(1:10, 1:10, xlab=expression(paste(something %-% else))) # doesn't work plot(1:10, 1:10, xlab=expression(paste(something, %-%, else))) The doesn't work examples give the same error you report: Error: unexpected SPECIAL in plot(1:10, 1:10, xlab=expression(%-% And then there's: # doesn't work, as expected plot(1:10, 1:10, xlab=expression(paste(something phi else))) phi is not an operator... # works plot(1:10, 1:10, xlab=expression(paste(something, phi, else))) # works plot(1:10, 1:10, xlab=expression(paste(something %==% else))) # doesn't work plot(1:10, 1:10, xlab=expression(paste(something, %==%, else))) So it seems that when using an expression element bracketed by percent signs, the commas in paste cause an error, even though they are otherwise necessary. Hm. This is on a clean R 2.11 session on linux (I know, but that's the latest version in the UNR repository, and I don't use R enough on this netbook to install a non-repo version). I can try again tomorrow on an up-to-date system. Sarah - Hide quoted text - On Wed, Jun 22, 2011 at 8:10 PM, Bryan Hanson han...@depauw.edu wrote: Hello R Masters and the Rest of Us: The first of these works fine, the 2nd is accepted but too literal (the %-% is shown in the plot label and in the wrong position). The 3rd throws and error due to unexpected SPECIAL. Would someone recommend a way to format this? I want the two phrases connected by a right arrow. TIA, these things always elude me. Bryan -- Sarah Goslee http://www.functionaldiversity.org __ 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] plotmath: unexpected SPECIAL
Dennis, Thanks. That makes sense, but I don't think it's clearly documented. The default assumption that I and at least some others in this discussion made is that everything in the list of plotmath features in the helpfile works the same way, since they're all in the same list. And if for some of them you need paste, then you must for all. The examples weren't much help in that regard. I think there are reasons that plotmath confuses so many. Sarah On Wed, Jun 22, 2011 at 9:03 PM, Dennis Murphy djmu...@gmail.com wrote: Hi: From the plotmath help page: x %-% y x right-arrow y so this is behaving like a binary operator. There happen to be several of these in plotmath On Wed, Jun 22, 2011 at 5:49 PM, Sarah Goslee sarah.gos...@gmail.com wrote: Interesting. I don't know the explanation, but look at this: # works plot(1:10, 1:10, xlab=expression(a %-% b)) # doesn't work plot(1:10, 1:10, xlab=expression(%-%)) Because there are no operands. This behavior can be replicated from the command line: 10 %/% 2 [1] 5 %/% Error: unexpected SPECIAL in %/% I think this explains the rest of the non-working examples as well, since you wouldn't do such things with binary operators. # works plot(1:10, 1:10, xlab=expression(paste(something %-% else))) # doesn't work plot(1:10, 1:10, xlab=expression(paste(something, %-%, else))) The doesn't work examples give the same error you report: Error: unexpected SPECIAL in plot(1:10, 1:10, xlab=expression(%-% And then there's: # doesn't work, as expected plot(1:10, 1:10, xlab=expression(paste(something phi else))) phi is not an operator... # works plot(1:10, 1:10, xlab=expression(paste(something, phi, else))) # works plot(1:10, 1:10, xlab=expression(paste(something %==% else))) # doesn't work plot(1:10, 1:10, xlab=expression(paste(something, %==%, else))) So it seems that when using an expression element bracketed by percent signs, the commas in paste cause an error, even though they are otherwise necessary. Hm. This is on a clean R 2.11 session on linux (I know, but that's the latest version in the UNR repository, and I don't use R enough on this netbook to install a non-repo version). I can try again tomorrow on an up-to-date system. Sarah - Hide quoted text - On Wed, Jun 22, 2011 at 8:10 PM, Bryan Hanson han...@depauw.edu wrote: Hello R Masters and the Rest of Us: The first of these works fine, the 2nd is accepted but too literal (the %-% is shown in the plot label and in the wrong position). The 3rd throws and error due to unexpected SPECIAL. Would someone recommend a way to format this? I want the two phrases connected by a right arrow. TIA, these things always elude me. Bryan __ 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] several messages
On Mon, 20 Jun 2011, Jim Silverton wrote: I a using plink on a large SNP dataset with a .map and .ped file. I want to get some sort of file say a list of all the SNPs that plink is saying that I have. ANyideas on how to do this? All the SNPs you have are listed in the .map file. An easy way to put the data in to R, if there isn't too much, is to do this: plink --file whatever --out whatever --recodeA That will make a file called whatever.raw, single space delimited, consisting of minor allele counts (0, 1, 2, NA) that you can bring into R like this: data - read.table(whatever.raw, delim= , header=T) If you have tons of data, you'll want to work with the compact binary format (four genotypes per byte): plink --file whatever --out whatever --make-bed Then see David Duffy's reply. However, I'm not sure if R can work with the compact format in memory. It might expand those genotypes (minor allele counts) from two-bit integers to double-precision floats. What does read.plink() create in memory? There is another package I've been meaning to look at that is supposed to help with the memory management problem for large genotype files: http://cran.r-project.org/web/packages/ff/ I haven't used it yet, but I am hopeful. Maybe David Duffy or someone else here will know more about it. If you have a lot of data, also consider chopping the data into pieces before loading it into R. That's what we do. With a 100 core system, I break the data into 100 files (I use the GNU/Linux split command and a few other tricks) and have all 100 cores run at once to analyze the data. When I work with genotype data as allele counts using Octave, I store the data, both in files and in memory, as unsigned 8-bit integers, using 3 as the missing value. That's still inefficient compared to the PLINK system, but it is way better than using doubles. Best, Mike -- Michael B. Miller, Ph.D. Minnesota Center for Twin and Family Research Department of Psychology University of Minnesota __ 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] Re; Getting SNPS from PLINK to R
Resending to correct bad subject line... On Mon, 20 Jun 2011, Jim Silverton wrote: I a using plink on a large SNP dataset with a .map and .ped file. I want to get some sort of file say a list of all the SNPs that plink is saying that I have. ANyideas on how to do this? All the SNPs you have are listed in the .map file. An easy way to put the data in to R, if there isn't too much, is to do this: plink --file whatever --out whatever --recodeA That will make a file called whatever.raw, single space delimited, consisting of minor allele counts (0, 1, 2, NA) that you can bring into R like this: data - read.table(whatever.raw, delim= , header=T) If you have tons of data, you'll want to work with the compact binary format (four genotypes per byte): plink --file whatever --out whatever --make-bed Then see David Duffy's reply. However, I'm not sure if R can work with the compact format in memory. It might expand those genotypes (minor allele counts) from two-bit integers to double-precision floats. What does read.plink() create in memory? There is another package I've been meaning to look at that is supposed to help with the memory management problem for large genotype files: http://cran.r-project.org/web/packages/ff/ I haven't used it yet, but I am hopeful. Maybe David Duffy or someone else here will know more about it. If you have a lot of data, also consider chopping the data into pieces before loading it into R. That's what we do. With a 100 core system, I break the data into 100 files (I use the GNU/Linux split command and a few other tricks) and have all 100 cores run at once to analyze the data. When I work with genotype data as allele counts using Octave, I store the data, both in files and in memory, as unsigned 8-bit integers, using 3 as the missing value. That's still inefficient compared to the PLINK system, but it is way better than using doubles. Best, Mike -- Michael B. Miller, Ph.D. Minnesota Center for Twin and Family Research Department of Psychology University of Minnesota __ 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 analysis with treatment effects - statistical approach
Date: Wed, 22 Jun 2011 17:21:52 -0700 From: jmo...@student.canterbury.ac.nz To: r-help@r-project.org Subject: Re: [R] Time-series analysis with treatment effects - statistical approach Hi Mike, here's a sample of my data so that you get an idea what I'm working with. Thanks, data helps make statements easier to test :) I'm quite busy at moment but I will try to look during dead time. http://r.789695.n4.nabble.com/file/n3618615/SampleDataSet.txt SampleDataSet.txt Also, I've uploaded an image showing a sample graph of daily soil moisture by treatment. The legend shows IP, IP+, PP, PP+ which are the 4 treatments. Also, I've included precipitation to show the soil moisture response to precip. Personally I'd try to write a simple physical model or two and see which one(s) fit best. It shouldn't be too hard to find sources and sinks of water and write a differential equation with a few parameters. There are probably online lecture notes that cover this or related examples. You probably suspect a mode of action for the treatments, see if that is consistent with observed dyanmics. You may need to go get temperature and cloud data but it may or may not be worth it. http://r.789695.n4.nabble.com/file/n3618615/MeanWaterPrecipColour2ndSeasonOnly.jpeg I have used ANOVA previously, but I don't like it for 2 reasons. The first is that I have to average away all of the interesting variation. But mainly, There are a number of assumptions that go into that to make it useful. If you are just drawing samples from populations of identical independent things great but here I would look at things related to non-stationary statistics of time series. it becomes quite cumbersome to do a separate ANOVA for each day (700+ days) or even each week (104 weeks). I discovered a way to do repetitive tasks that can be concisely specified using something called a computer. Writing loops is pretty easy, don't give up due to cumbersomeness. Also, you could try a few simple things like plotting difference charts ( plot treatment minus control for example). If you approach this purely empirically, there are time series packages and maybe the econ/quant financial analysts would have some thoughts that wouldn't be well known in your field. Thanks for your help, -Justin -- View this message in context: http://r.789695.n4.nabble.com/Time-series-analysis-with-treatment-effects-statistical-approach-tp3615856p3618615.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.
[R] numerical integration and 'non-finite function value' error
Dear R users, I have a question about numerical integration in R. I am facing the 'non-finite function value' error while integrating the function xf(x) using 'integrate'. f(x) is a probability density function and assumed to follow the three parameter (min = 0) beta distribution for which I have estimated the parameters. The function is integrated over two ranges, say (0, a) and (a, Inf). The error 'non-finite function value' happens when I do the integration for the second range. I have 10 different density functions for 10 different data series and for some of them replacing Inf by the Max of f(x) gives me an estimate of the area while for others this doesn't work. What does the error mean and how can I address it? Is replacing a max for Inf appropriate? I really appreciate any clues. -- View this message in context: http://r.789695.n4.nabble.com/numerical-integration-and-non-finite-function-value-error-tp3618486p3618486.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] Subsetting data systematically
I would like to subset data from a larger dataset and generate a smaller dataset. However, I don't want to use sample() because it does it randomly. I would like to take non-random subsamples, for example, every 2nd number, or every 3rd number. Is there a procedure that does this? Thanks, Nate -- View this message in context: http://r.789695.n4.nabble.com/Subsetting-data-systematically-tp3618516p3618516.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] lme convergence failure within a loop
Hi R-users, I'm attempting to fit a number of mixed models, all with the same structure, across a spatial grid with data points collected at various time points within each grid cell. I'm trying to use a 'for' loop to try the model fit on each grid cell. In some cells lme does not converge, giving me the error: Error message: In lme.formula(logarea ~ year + summ_d, data = grid2, random = ~year + : nlminb problem, convergence error code = 1 message = iteration limit reached without convergence (9) When I get the error, the program aborts, and my loop stops. I'm not too worried about the error, as a generic mixed model structure may not be the best fit for every cell. I expect the optimization to fail in some places. I want to be able to detect when the algorithm has failed to converge automatically, so that I can continue my loop and record the places where the model does fit. I've used the lmeControl method with returnObject=TRUE options to allow me to continue looping, however I want to be able to flag the places where the convergence failed so that I can reject these gridcells and not mistakenly claim that the model fits at these points. Is there a way to do this? My example code shows the relevant lines of code-- what I'm hoping for is a way to determine that the convergence failed and record this as a boolean value, or something similar. Thanks, Sam Nicol #(set working directory) #read data grid2 - read.csv(grid2.csv, header= TRUE, sep = ,, na.strings=-1) library(nlme) #attempt to fit model after setting control options lmeCtlList - lmeControl(maxIter=50, msMaxIter=50, tolerance=1e-4, msTol=1e-5, nlmStepMax=5, returnObject=TRUE ) #msVerbose=TRUE global_model3 - lme(logarea ~ year+summ_d, data= grid2, random= ~ year + summ_d | subject, control=lmeCtlList) __ 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.