Re: [R] question about R graphics-example plot attached
Does 'rug' help you ? example(rug) ?rug Cheers Mathieu. jia ding a écrit : -- Forwarded message -- From: jia ding [EMAIL PROTECTED] Date: Nov 2, 2005 4:03 PM Subject: question about R graphics-example plot attached To: [EMAIL PROTECTED] Suppose I have the data set like this: A 1 3 7 10 B 5 9 13 The numbers here actually is A or B's occurence positions.So it means, position 1,3,7,10 is A;position 5,9,13 is B's occurence. I want the plot is a line with a little dot (or bar) at the position 1(A-show red), position 3(A-red),position 5(B-blue),7(A-red),10(A-red),13(B-blue) I am not sure, If I explained very clearly about my question. What a pity google group not support to attach a file. Otherwise,I can provide an example. Thanks for the help! Thanks Marc. DJ -- Mathieu Basille - Doctorant .. | Laboratoire de Biométrie et Biologie Evolutive | |Université Claude Bernard Lyon1 - France| `' [EMAIL PROTECTED] __ R-help@stat.math.ethz.ch mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide! http://www.R-project.org/posting-guide.html
Re: [R] SWeave - can I see output in the source?
On Fri, 18 Nov 2005 13:49:36 -0500, Duncan Murdoch (DM) wrote: I'm working on a Latex document with lots of R code in it, so naturally enough it would be a good idea to use SWeave. But then I don't get to see the output as I'm editing. Or do I? Is there a tool to process a .Rnw file and incorporate the output from the commands into it (in a form that is not used for producing the output .tex file, but which is updated each time I process the file)? I'm not sure if I understand the question correctly, but if you edit Sweave files in Emacs using ESS you can send the code lines to a running R process, and there you see the output. At least that's how I write my Sweave files. When I want to see all at once I typically do a tangle source. Best, Fritz __ R-help@stat.math.ethz.ch mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide! http://www.R-project.org/posting-guide.html
[R] help with apply, please
Dear list, I have a problem with a toy example: mtrx - matrix(c(1,1,0,1,1,1,0,1,1,0,0,1), nrow=3) rownames(ma) - letters[1:3] I would like to determine which is the minimum combination of rows that covers all columns with at least a 1. None of the rows covers all columns; all three rows clearly covers all columns, but there are simpler combinations (1st and the 3rd, or 2nd and 3rd) which also covers all columns. I solved this problem by creating a second logical matrix which contains all possible combinations of rows: tt - matrix(as.logical(c(1,0,0,0,1,0,0,0,1,1,1,0,1,0,1,0,1,1,1,1,1)), nrow=3) and then subset the first matrix and check if all columns are covered. This solution, though, is highly inneficient and I am certain that a combination of apply or something will do. ### possibles - NULL length.possibles - NULL ## I guess the minimum solution is has half the number of rows guesstimate - floor(nrow(tt)/2) + nrow(tt) %% 2 checked - logical(nrow(tt)) repeat { ifelse(checked[guesstimate], break, checked[guesstimate] - TRUE) partials - as.matrix(tt[, colSums(tt) == guesstimate]) layer.solution - logical(ncol(partials)) for (j in 1:ncol(partials)) { if (length(which(colSums(mtrx[partials[, j], ]) 0)) == ncol(mtrx)) { layer.solution[j] - TRUE } } if (sum(layer.solution) == 0) { if (!is.null(possibles)) break guesstimate - guesstimate + 1 } else { for (j in which(layer.solution)) { possible.solution - rownames(mtrx)[partials[, j]] possibles[[length(possibles) + 1]] - possible.solution length.possibles - c(length.possibles, length(possible.solution)) } guesstimate - guesstimate - 1 } } final.solution - possibles[which(length.possibles == min(length.possibles))] ### More explicitely (if useful) it is about reducing a prime implicants chart in a Quine-McCluskey boolean minimisation algorithm. I tried following the original algorithm applying row dominance and column dominance, but (as I am not a computer scientist), I am unable to apply it. If you have a better solution for this, I would be gratefull if you'd share it. Thank you in advance, Adrian -- Adrian DUSA Romanian Social Data Archive 1, Schitu Magureanu Bd 050025 Bucharest sector 5 Romania Tel./Fax: +40 21 3126618 \ +40 21 3120210 / int.101 __ R-help@stat.math.ethz.ch mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide! http://www.R-project.org/posting-guide.html
[R] cointegration rank
Dear R - helpers, I am using the urca package to estimate cointegration relations, and I would be really grateful if somebody could help me with this questions: After estimating the unrestriced VAR with ca.jo I would like to impose the rank restriction (for example rank = 1) and then obtain the restricted estimate of PI to be utilized to estimate the VECM model. Is it possible? It seems to me that the function cajools estimates the VECM without the restrictions. Did I miss something? How is it possible to impose them? Thanks a lot in advance! Carlo __ R-help@stat.math.ethz.ch mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide! http://www.R-project.org/posting-guide.html
Re: [R] SWeave - can I see output in the source?
On 11/19/2005 6:13 AM, [EMAIL PROTECTED] wrote: On Fri, 18 Nov 2005 13:49:36 -0500, Duncan Murdoch (DM) wrote: I'm working on a Latex document with lots of R code in it, so naturally enough it would be a good idea to use SWeave. But then I don't get to see the output as I'm editing. Or do I? Is there a tool to process a .Rnw file and incorporate the output from the commands into it (in a form that is not used for producing the output .tex file, but which is updated each time I process the file)? I'm not sure if I understand the question correctly, but if you edit Sweave files in Emacs using ESS you can send the code lines to a running R process, and there you see the output. At least that's how I write my Sweave files. When I want to see all at once I typically do a tangle source. That's bad news for me, because I'm allergic to Emacs. What I had in mind was this: In my .Rnw file, I enter: echo=true= 1:3 @ Then I pass it to some tool, which modifies the .Rnw file, changing it to something like echo=true= 1:3 @ % 1:3 % [1] 1 2 3 (My editor will notice that the tool has changed the file and offer to load the new version at this point. I think that's a reasonably common editor option.) Then I can see what I'm writing about when I describe the results. If I later come along and edit the source to change it to echo=true= 1:4 @ % 1:3 % [1] 1 2 3 then the next time I run the file through the tool it will delete the stale output and modify my file to look like this: echo=true= 1:4 @ % 1:4 % [1] 1 2 3 4 Besides the advantage that I had in mind (being able to see the output as I'm editing, and being confident that it will match the output in the final document), this will mean that I'll have a versionable record of what the output looked like (so I'll be alerted to changes in it caused by updates to R or some package I'm using). I could get this by saving the .tex output, but to me this seems preferable. But I don't have a lot of experience with SWeave yet, so maybe there's a better workflow. Duncan Murdoch __ R-help@stat.math.ethz.ch mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide! http://www.R-project.org/posting-guide.html
Re: [R] help with apply, please
On 11/19/2005 8:00 AM, Adrian DUSA wrote: Dear list, I have a problem with a toy example: mtrx - matrix(c(1,1,0,1,1,1,0,1,1,0,0,1), nrow=3) rownames(ma) - letters[1:3] I would like to determine which is the minimum combination of rows that covers all columns with at least a 1. None of the rows covers all columns; all three rows clearly covers all columns, but there are simpler combinations (1st and the 3rd, or 2nd and 3rd) which also covers all columns. I solved this problem by creating a second logical matrix which contains all possible combinations of rows: tt - matrix(as.logical(c(1,0,0,0,1,0,0,0,1,1,1,0,1,0,1,0,1,1,1,1,1)), nrow=3) and then subset the first matrix and check if all columns are covered. This solution, though, is highly inneficient and I am certain that a combination of apply or something will do. First of all, I imagine there isn't a unique solution, i.e. there are probably several subsets that can't be reduced but which are not equal. Do you care if you find the smallest one of those? If so, it looks like a reasonably hard problem. If not, it's a lot easier: total all of the columns, then see if there is any row whose entries all correspond to columns with counts bigger than 1. Remove it, and continue. This will find a local minimum in one pass through the rows. You could make it better by sorting the rows into an order so that rows that dominate other rows come later, but I think you still wouldn't be guaranteed to find the global min. (By the way, I'm not sure if we have a function that can do this: i.e., given a partial ordering on the rows, sort the matrix so that the resulting order is consistent with it.) Duncan Murdoch ### possibles - NULL length.possibles - NULL ## I guess the minimum solution is has half the number of rows guesstimate - floor(nrow(tt)/2) + nrow(tt) %% 2 checked - logical(nrow(tt)) repeat { ifelse(checked[guesstimate], break, checked[guesstimate] - TRUE) partials - as.matrix(tt[, colSums(tt) == guesstimate]) layer.solution - logical(ncol(partials)) for (j in 1:ncol(partials)) { if (length(which(colSums(mtrx[partials[, j], ]) 0)) == ncol(mtrx)) { layer.solution[j] - TRUE } } if (sum(layer.solution) == 0) { if (!is.null(possibles)) break guesstimate - guesstimate + 1 } else { for (j in which(layer.solution)) { possible.solution - rownames(mtrx)[partials[, j]] possibles[[length(possibles) + 1]] - possible.solution length.possibles - c(length.possibles, length(possible.solution)) } guesstimate - guesstimate - 1 } } final.solution - possibles[which(length.possibles == min(length.possibles))] ### More explicitely (if useful) it is about reducing a prime implicants chart in a Quine-McCluskey boolean minimisation algorithm. I tried following the original algorithm applying row dominance and column dominance, but (as I am not a computer scientist), I am unable to apply it. If you have a better solution for this, I would be gratefull if you'd share it. Thank you in advance, Adrian __ R-help@stat.math.ethz.ch mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide! http://www.R-project.org/posting-guide.html
Re: [R] help with apply, please
Try minizing 1'x subject to 1 = x = 0 and m'x = 1 where m is your mtrx and ' means transpose. It seems to give an integer solution, 1 0 1, with linear programming even in the absence of explicit integer constraints: library(lpSolve) lp(min, rep(1,3), rbind(t(mtrx), diag(3)), rep(c(=, =), 4:3), rep(1,7))$solution On 11/19/05, Adrian DUSA [EMAIL PROTECTED] wrote: Dear list, I have a problem with a toy example: mtrx - matrix(c(1,1,0,1,1,1,0,1,1,0,0,1), nrow=3) rownames(ma) - letters[1:3] I would like to determine which is the minimum combination of rows that covers all columns with at least a 1. None of the rows covers all columns; all three rows clearly covers all columns, but there are simpler combinations (1st and the 3rd, or 2nd and 3rd) which also covers all columns. I solved this problem by creating a second logical matrix which contains all possible combinations of rows: tt - matrix(as.logical(c(1,0,0,0,1,0,0,0,1,1,1,0,1,0,1,0,1,1,1,1,1)), nrow=3) and then subset the first matrix and check if all columns are covered. This solution, though, is highly inneficient and I am certain that a combination of apply or something will do. ### possibles - NULL length.possibles - NULL ## I guess the minimum solution is has half the number of rows guesstimate - floor(nrow(tt)/2) + nrow(tt) %% 2 checked - logical(nrow(tt)) repeat { ifelse(checked[guesstimate], break, checked[guesstimate] - TRUE) partials - as.matrix(tt[, colSums(tt) == guesstimate]) layer.solution - logical(ncol(partials)) for (j in 1:ncol(partials)) { if (length(which(colSums(mtrx[partials[, j], ]) 0)) == ncol(mtrx)) { layer.solution[j] - TRUE } } if (sum(layer.solution) == 0) { if (!is.null(possibles)) break guesstimate - guesstimate + 1 } else { for (j in which(layer.solution)) { possible.solution - rownames(mtrx)[partials[, j]] possibles[[length(possibles) + 1]] - possible.solution length.possibles - c(length.possibles, length(possible.solution)) } guesstimate - guesstimate - 1 } } final.solution - possibles[which(length.possibles == min(length.possibles))] ### More explicitely (if useful) it is about reducing a prime implicants chart in a Quine-McCluskey boolean minimisation algorithm. I tried following the original algorithm applying row dominance and column dominance, but (as I am not a computer scientist), I am unable to apply it. If you have a better solution for this, I would be gratefull if you'd share it. Thank you in advance, Adrian -- Adrian DUSA Romanian Social Data Archive 1, Schitu Magureanu Bd 050025 Bucharest sector 5 Romania Tel./Fax: +40 21 3126618 \ +40 21 3120210 / int.101 __ R-help@stat.math.ethz.ch mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide! http://www.R-project.org/posting-guide.html __ R-help@stat.math.ethz.ch mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide! http://www.R-project.org/posting-guide.html
Re: [R] help with apply, please
On 11/19/05, Gabor Grothendieck [EMAIL PROTECTED] wrote: Try minizing 1'x subject to 1 = x = 0 and m'x = 1 where m is your mtrx and ' means transpose. It seems to give an integer solution, 1 0 1, with linear programming even in the absence of explicit integer constraints: library(lpSolve) lp(min, rep(1,3), rbind(t(mtrx), diag(3)), rep(c(=, =), 4:3), rep(1,7))$solution Just one after thought. The constraint x = 1 will not be active so, eliminating it, the above can be reduced to: lp(min, rep(1,3), rbind(t(mtrx)), rep(=, 4), rep(1,4))$solution On 11/19/05, Adrian DUSA [EMAIL PROTECTED] wrote: Dear list, I have a problem with a toy example: mtrx - matrix(c(1,1,0,1,1,1,0,1,1,0,0,1), nrow=3) rownames(ma) - letters[1:3] I would like to determine which is the minimum combination of rows that covers all columns with at least a 1. None of the rows covers all columns; all three rows clearly covers all columns, but there are simpler combinations (1st and the 3rd, or 2nd and 3rd) which also covers all columns. I solved this problem by creating a second logical matrix which contains all possible combinations of rows: tt - matrix(as.logical(c(1,0,0,0,1,0,0,0,1,1,1,0,1,0,1,0,1,1,1,1,1)), nrow=3) and then subset the first matrix and check if all columns are covered. This solution, though, is highly inneficient and I am certain that a combination of apply or something will do. ### possibles - NULL length.possibles - NULL ## I guess the minimum solution is has half the number of rows guesstimate - floor(nrow(tt)/2) + nrow(tt) %% 2 checked - logical(nrow(tt)) repeat { ifelse(checked[guesstimate], break, checked[guesstimate] - TRUE) partials - as.matrix(tt[, colSums(tt) == guesstimate]) layer.solution - logical(ncol(partials)) for (j in 1:ncol(partials)) { if (length(which(colSums(mtrx[partials[, j], ]) 0)) == ncol(mtrx)) { layer.solution[j] - TRUE } } if (sum(layer.solution) == 0) { if (!is.null(possibles)) break guesstimate - guesstimate + 1 } else { for (j in which(layer.solution)) { possible.solution - rownames(mtrx)[partials[, j]] possibles[[length(possibles) + 1]] - possible.solution length.possibles - c(length.possibles, length(possible.solution)) } guesstimate - guesstimate - 1 } } final.solution - possibles[which(length.possibles == min(length.possibles))] ### More explicitely (if useful) it is about reducing a prime implicants chart in a Quine-McCluskey boolean minimisation algorithm. I tried following the original algorithm applying row dominance and column dominance, but (as I am not a computer scientist), I am unable to apply it. If you have a better solution for this, I would be gratefull if you'd share it. Thank you in advance, Adrian -- Adrian DUSA Romanian Social Data Archive 1, Schitu Magureanu Bd 050025 Bucharest sector 5 Romania Tel./Fax: +40 21 3126618 \ +40 21 3120210 / int.101 __ R-help@stat.math.ethz.ch mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide! http://www.R-project.org/posting-guide.html __ R-help@stat.math.ethz.ch mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide! http://www.R-project.org/posting-guide.html
Re: [R] help with apply, please
On 11/19/05, Gabor Grothendieck [EMAIL PROTECTED] wrote: On 11/19/05, Gabor Grothendieck [EMAIL PROTECTED] wrote: Try minizing 1'x subject to 1 = x = 0 and m'x = 1 where m is your mtrx and ' means transpose. It seems to give an integer solution, 1 0 1, with linear programming even in the absence of explicit integer constraints: library(lpSolve) lp(min, rep(1,3), rbind(t(mtrx), diag(3)), rep(c(=, =), 4:3), rep(1,7))$solution Just one after thought. The constraint x = 1 will not be active so, eliminating it, the above can be reduced to: lp(min, rep(1,3), rbind(t(mtrx)), rep(=, 4), rep(1,4))$solution Although the above is not wrong I should have removed the rbind which is no longer needed and simplifying it further, as it seems that lp will do the rep for you itself for certain arguments, gives: lp(min, rep(1,3), t(mtrx), =, 1)$solution # 1 0 1 On 11/19/05, Adrian DUSA [EMAIL PROTECTED] wrote: Dear list, I have a problem with a toy example: mtrx - matrix(c(1,1,0,1,1,1,0,1,1,0,0,1), nrow=3) rownames(ma) - letters[1:3] I would like to determine which is the minimum combination of rows that covers all columns with at least a 1. None of the rows covers all columns; all three rows clearly covers all columns, but there are simpler combinations (1st and the 3rd, or 2nd and 3rd) which also covers all columns. I solved this problem by creating a second logical matrix which contains all possible combinations of rows: tt - matrix(as.logical(c(1,0,0,0,1,0,0,0,1,1,1,0,1,0,1,0,1,1,1,1,1)), nrow=3) and then subset the first matrix and check if all columns are covered. This solution, though, is highly inneficient and I am certain that a combination of apply or something will do. ### possibles - NULL length.possibles - NULL ## I guess the minimum solution is has half the number of rows guesstimate - floor(nrow(tt)/2) + nrow(tt) %% 2 checked - logical(nrow(tt)) repeat { ifelse(checked[guesstimate], break, checked[guesstimate] - TRUE) partials - as.matrix(tt[, colSums(tt) == guesstimate]) layer.solution - logical(ncol(partials)) for (j in 1:ncol(partials)) { if (length(which(colSums(mtrx[partials[, j], ]) 0)) == ncol(mtrx)) { layer.solution[j] - TRUE } } if (sum(layer.solution) == 0) { if (!is.null(possibles)) break guesstimate - guesstimate + 1 } else { for (j in which(layer.solution)) { possible.solution - rownames(mtrx)[partials[, j]] possibles[[length(possibles) + 1]] - possible.solution length.possibles - c(length.possibles, length(possible.solution)) } guesstimate - guesstimate - 1 } } final.solution - possibles[which(length.possibles == min(length.possibles))] ### More explicitely (if useful) it is about reducing a prime implicants chart in a Quine-McCluskey boolean minimisation algorithm. I tried following the original algorithm applying row dominance and column dominance, but (as I am not a computer scientist), I am unable to apply it. If you have a better solution for this, I would be gratefull if you'd share it. Thank you in advance, Adrian -- Adrian DUSA Romanian Social Data Archive 1, Schitu Magureanu Bd 050025 Bucharest sector 5 Romania Tel./Fax: +40 21 3126618 \ +40 21 3120210 / int.101 __ R-help@stat.math.ethz.ch mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide! http://www.R-project.org/posting-guide.html __ R-help@stat.math.ethz.ch mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide! http://www.R-project.org/posting-guide.html
[R] Autoloading R Commander
How do I go about autoloading R Commander when I start R? Thanks in advance. -- Stephen P. Molnar, Ph.D.Life is a fuzzy set Foundation for ChemistryStochastic and multivariant http://www.geocities.com/FoundationForChemistry __ R-help@stat.math.ethz.ch mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide! http://www.R-project.org/posting-guide.html
Re: [R] help with apply, please
On Saturday 19 November 2005 17:24, Gabor Grothendieck wrote: [...snip...] Although the above is not wrong I should have removed the rbind which is no longer needed and simplifying it further, as it seems that lp will do the rep for you itself for certain arguments, gives: lp(min, rep(1,3), t(mtrx), =, 1)$solution # 1 0 1 Thank you Gabor, this solution is superbe (you never stop amazing me :) Now... it only finds _one_ of the multiple minimum solutions. In the toy example, there are two minimum solutions, hence I reckon the output should have been a list with: [[1]] [1] 1 0 1 [[2]] [1] 0 1 1 Also, thanks to Duncan and yes, I do very much care finding the smallest possible solutions (if I correctly understand your question). It seems that lp function is very promising, but can I use it to find _all_ minimum solutions? Adrian -- Adrian DUSA Arhiva Romana de Date Sociale Bd. Schitu Magureanu nr.1 050025 Bucuresti sectorul 5 Romania Tel./Fax: +40 21 3126618 \ +40 21 3120210 / int.101 __ R-help@stat.math.ethz.ch mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide! http://www.R-project.org/posting-guide.html
Re: [R] Autoloading R Commander
Stephen P. Molnar, Ph.D. wrote: How do I go about autoloading R Commander when I start R? See ?Startup Uwe Ligges Thanks in advance. __ R-help@stat.math.ethz.ch mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide! http://www.R-project.org/posting-guide.html
[R] new article on R at oreillynet.com
An article I wrote that provides a basic introduction to R has been published on Oreillynet.com. The article is titled Analyzing Statistics with GNU/R. Here is the link: http://www.onlamp.com/pub/a/onlamp/2005/11/17/r_for_statistics.html Please feel free to post comments or interesting basic R scripts at the end of the article. Kevin Farnham __ R-help@stat.math.ethz.ch mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide! http://www.R-project.org/posting-guide.html
Re: [R] Autoloading R Commander
On Sat, 19 Nov 2005, Stephen P. Molnar, Ph.D. wrote: How do I go about autoloading R Commander when I start R? Read ?Startup. My first idea would be to make use of a ~/.Rprofile file. `Autoloading' is a technical term in R (see ?autoload), which I presume is not what you meant. My guess is that you want R Commander to be started when you start R. -- Brian D. Ripley, [EMAIL PROTECTED] Professor of Applied Statistics, http://www.stats.ox.ac.uk/~ripley/ University of Oxford, Tel: +44 1865 272861 (self) 1 South Parks Road, +44 1865 272866 (PA) Oxford OX1 3TG, UKFax: +44 1865 272595 __ R-help@stat.math.ethz.ch mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide! http://www.R-project.org/posting-guide.html
Re: [R] Autoloading R Commander
Dear Stephen, I believe that this question has been asked before, though possibly privately rather than on the r-help list. A solution (kindly provided, as I recall, by Brian Ripley) is to put the following in an appropriate start-up file. For example, if you *always* want to start the Rcmdr when R starts, this could go in Rprofile.site in R's etc subdirectory. For more detail, see ?Startup, as others have suggested. local({ old - getOption(defaultPackages) options(defaultPackages = c(old, Rcmdr)) }) I hope this helps, John John Fox Department of Sociology McMaster University Hamilton, Ontario Canada L8S 4M4 905-525-9140x23604 http://socserv.mcmaster.ca/jfox -Original Message- From: [EMAIL PROTECTED] [mailto:[EMAIL PROTECTED] On Behalf Of Stephen P. Molnar, Ph.D. Sent: Saturday, November 19, 2005 10:35 AM To: R Subject: [R] Autoloading R Commander How do I go about autoloading R Commander when I start R? Thanks in advance. -- Stephen P. Molnar, Ph.D. Life is a fuzzy set Foundation for Chemistry Stochastic and multivariant http://www.geocities.com/FoundationForChemistry __ R-help@stat.math.ethz.ch mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide! http://www.R-project.org/posting-guide.html
Re: [R] Autoloading R Commander
Dear Stephen, As a brief addendum, this information (and other information) is in the Rcmdr installation notes, at http://socserv.socsci.mcmaster.ca/jfox/Misc/Rcmdr/installation-notes.html. Sorry I forgot that when I posted my original answer. John John Fox Department of Sociology McMaster University Hamilton, Ontario Canada L8S 4M4 905-525-9140x23604 http://socserv.mcmaster.ca/jfox -Original Message- From: [EMAIL PROTECTED] [mailto:[EMAIL PROTECTED] On Behalf Of John Fox Sent: Saturday, November 19, 2005 11:27 AM To: [EMAIL PROTECTED] Cc: 'R' Subject: Re: [R] Autoloading R Commander Dear Stephen, I believe that this question has been asked before, though possibly privately rather than on the r-help list. A solution (kindly provided, as I recall, by Brian Ripley) is to put the following in an appropriate start-up file. For example, if you *always* want to start the Rcmdr when R starts, this could go in Rprofile.site in R's etc subdirectory. For more detail, see ?Startup, as others have suggested. local({ old - getOption(defaultPackages) options(defaultPackages = c(old, Rcmdr)) }) I hope this helps, John John Fox Department of Sociology McMaster University Hamilton, Ontario Canada L8S 4M4 905-525-9140x23604 http://socserv.mcmaster.ca/jfox -Original Message- From: [EMAIL PROTECTED] [mailto:[EMAIL PROTECTED] On Behalf Of Stephen P. Molnar, Ph.D. Sent: Saturday, November 19, 2005 10:35 AM To: R Subject: [R] Autoloading R Commander How do I go about autoloading R Commander when I start R? Thanks in advance. -- Stephen P. Molnar, Ph.D. Life is a fuzzy set Foundation for Chemistry Stochastic and multivariant http://www.geocities.com/FoundationForChemistry __ R-help@stat.math.ethz.ch mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide! http://www.R-project.org/posting-guide.html __ R-help@stat.math.ethz.ch mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide! http://www.R-project.org/posting-guide.html
[R] predicted values from cv.glm
Hi. Is there a way to get the values predicted from (leave-one-out) cv.glm? It seems like a useful diagnostic to plot observed vs. predicted values. Thanks, Jeff Jeffrey A. Stratford, Ph.D. Postdoctoral Associate 331 Funchess Hall Department of Biological Sciences Auburn University Auburn, AL 36849 334-329-9198 FAX 334-844-9234 http://www.auburn.edu/~stratja __ R-help@stat.math.ethz.ch mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide! http://www.R-project.org/posting-guide.html
[R] Fwd: Autoloading R Commander
-- Forwarded Message -- Subject: [R] Autoloading R Commander Date: Saturday November 19, 2005 10:35 am From: Stephen P. Molnar, Ph.D. [EMAIL PROTECTED] To: R r-help@stat.math.ethz.ch How do I go about autoloading R Commander when I start R? Thanks in advance. -- Stephen P. Molnar, Ph.D.Life is a fuzzy set Foundation for ChemistryStochastic and multivariant http://www.geocities.com/FoundationForChemistry __ R-help@stat.math.ethz.ch mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide! http://www.R-project.org/posting-guide.html --- My thanks to all that answered. The solution, thanks to John Fox is to add: local({ old - getOption(defaultPackages) options(defaultPackages = c(old, Rcmdr)) }) to /usr/local/lib/R/etc/Rprofile.site -- Stephen P. Molnar, Ph.D.Life is a fuzzy set Foundation for ChemistryStochastic and multivariant http://www.geocities.com/FoundationForChemistry __ R-help@stat.math.ethz.ch mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide! http://www.R-project.org/posting-guide.html
Re: [R] Adding points to wireframe
Pierre-Luc Brunelle pierre-luc.brunelle at polymtl.ca writes: I am using function wireframe from package lattice to draw a 3D surface. I would like to add a few points on the surface. I read in a post from Deepayan Sarkar that To do this in a wireframe plot you would probably use the panel function panel.3dscatter. Does someone have an example? When calling panel.3dscatter with only x, y and z arguments I get argument xlim.scaled is missing, with no default. I do not know what value I should give to xlim.scaled. Maybe your got confused by Deepayan's comment. Normally, you don't call panel.3dscatter directly, you will only use it when you want to change the default behaviour of cloud with groups. Try to add the data points to the dataframe you use in the call to wireframe. Dieter __ R-help@stat.math.ethz.ch mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide! http://www.R-project.org/posting-guide.html
Re: [R] help with apply, please
I suspect that the answer is that finding all solutions will be hard. L1 regression is a special case of LP. I learned how to move around the corners of the solution space, and could easily find all of the solutions in the special case of a two-way table. However, sometimes there were a lot of solutions. I would guess that your problem has a lot of solutions as well. One cheat would be to do the LP problem multiple times with the rows of your matrix randomly permuted. Assuming you keep track of the real rows, you could then get a sense of how many solutions there might be. Patrick Burns [EMAIL PROTECTED] +44 (0)20 8525 0696 http://www.burns-stat.com (home of S Poetry and A Guide for the Unwilling S User) Adrian Dusa wrote: On Saturday 19 November 2005 17:24, Gabor Grothendieck wrote: [...snip...] Although the above is not wrong I should have removed the rbind which is no longer needed and simplifying it further, as it seems that lp will do the rep for you itself for certain arguments, gives: lp(min, rep(1,3), t(mtrx), =, 1)$solution # 1 0 1 Thank you Gabor, this solution is superbe (you never stop amazing me :) Now... it only finds _one_ of the multiple minimum solutions. In the toy example, there are two minimum solutions, hence I reckon the output should have been a list with: [[1]] [1] 1 0 1 [[2]] [1] 0 1 1 Also, thanks to Duncan and yes, I do very much care finding the smallest possible solutions (if I correctly understand your question). It seems that lp function is very promising, but can I use it to find _all_ minimum solutions? Adrian __ R-help@stat.math.ethz.ch mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide! http://www.R-project.org/posting-guide.html
Re: [R] help with apply, please
On Saturday 19 November 2005 19:17, Patrick Burns wrote: [snip...] One cheat would be to do the LP problem multiple times with the rows of your matrix randomly permuted. Assuming you keep track of the real rows, you could then get a sense of how many solutions there might be. Thanks for the answer. The trick does work (i.e. it finds all minimum solutions) provided that I permute the rows a sufficient number of times. And I have to compare each solution to the existing (unique) ones, which takes a lot of time... In your experience, what would be the definiton of multiple times for large matrices? My (dumb) solution is guaranteed to find all possible minimums, because it checks every possible combination. For large matrices, though, this would be really slow. I wonder if that could be vectorized in some way; before the LP function, I was thinking there might be a more efficient way to loop over all possible columns (using perhaps the apply family). Thanks again, Adrian -- Adrian DUSA Romanian Social Data Archive 1, Schitu Magureanu Bd 050025 Bucharest sector 5 Romania Tel./Fax: +40 21 3126618 \ +40 21 3120210 / int.101 __ R-help@stat.math.ethz.ch mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide! http://www.R-project.org/posting-guide.html
Re: [R] help with apply, please
On 19-Nov-05 Adrian Dusa wrote: On Saturday 19 November 2005 17:24, Gabor Grothendieck wrote: [...snip...] Although the above is not wrong I should have removed the rbind which is no longer needed and simplifying it further, as it seems that lp will do the rep for you itself for certain arguments, gives: lp(min, rep(1,3), t(mtrx), =, 1)$solution # 1 0 1 Thank you Gabor, this solution is superbe (you never stop amazing me :). Now... it only finds _one_ of the multiple minimum solutions. In the toy example, there are two minimum solutions, hence I reckon the output should have been a list with: [[1]] [1] 1 0 1 [[2]] [1] 0 1 1 Also, thanks to Duncan and yes, I do very much care finding the smallest possible solutions (if I correctly understand your question). It seems that lp function is very promising, but can I use it to find _all_ minimum solutions? Thinking about it, I'm not sure that finding the complete set of solutions (in general, not just to Adrian's toy example) can be done without enumeration, complete up to the stage where it is known that all minimal solutions have been found (and, having said that, I shall probably provoke an expert into refuting me; im which case, all the better!). For example, consider a 9-column matrix with 84 rows, each with 3 1s and 6 0s (nCm(9,3)=84). Every minimal solution is the union of 3 rows, e.g. 1 1 1 0 0 0 0 0 0 0 0 0 1 1 1 0 0 0 0 0 0 0 0 0 1 1 1 and there is a 1:1 correspondence between the choices of 3 out of 9 and the 84 rows. So there are 84 = nCm(9,3) choices of 3 1s for the first row, leaving 6 0s. There are then nCm(6,3) = 20 choices of 3 1s for the second row. Having done that, the choice of the 1s for the third row s determined. But this must be divided by 3! = 6 to give unordered rows, so there are 84*20/6 = 280 different minimal solutions. Without yet having taken this down to the level of R code, I would envisage an algorithm for an N*k matrix M on the following lines. 1. Check that it's possible: sum(colSums(matr)==0) = 0 2. For m = 1:N work through all choices of m rows out of the N; if, for the current value of m, any one of these covers, complete the choices for this value of m, noting which choices cover, and then exit. This will give you all the choices of m out of N rows which cover the columns, for the smallest value of m for which this is possible, and you will not have searched in larger values of m. The function 'combn' in package combinat may be useful here: combn(N,m) returns an array with nCm columns and m rows, where the values in a column are a choice of m out of (1:N). There is an opposite version of this algorithm: If there are not many 1s in matr, then you might guess that a lot of rows may be needed. So it may be more efficient to do it the other way round: Starting with all rows (m=N), leave them out 1 at a time, then 2 at a time, and so on, until you get a value of m such that no choice of m out of N covers the columns. Then (m+1) is the minimal order of a covering set of rows, and you've just found all these. But this may not be sound either, since if one row has many 1s then possibly some few others can make up the covering, so it would be better to do it the original way round. I can't get a clear view of what sort of criterion to apply to determine this issue programmatically. There is bound to be a good algorithm out there somewhere for finding a minimal coveriung set but I don't know it! Comments? Best wishes to all, Ted. E-Mail: (Ted Harding) [EMAIL PROTECTED] Fax-to-email: +44 (0)870 094 0861 Date: 19-Nov-05 Time: 18:51:00 -- XFMail -- __ R-help@stat.math.ethz.ch mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide! http://www.R-project.org/posting-guide.html
Re: [R] Specify Z matrix with lmer function
There is probably a way to do what you want, but I don't know how. You are to be commended for providing a self-contained example citing an interesting article from the Journal of Statistical Software and including the modification necessary to make the S-Plus lme call work in R. I tried several things including the following: fit.r1 - lmer(y~-1+X+(-1+Z|grp)) This seemed to run but gave an answer different from that from lme. I also noted that the lmer documentation said the argument start was a list of relative precision matrices for the random effects. This has the same form as the slot 'Omega' in a fitted model. Only the upper triangle of these symmetric matrices should be stored. This suggested I provide start with a list consiting of R from the QR decomposition of Z: grp.dat.qr - qr(grp.dat[2:26]) grp.dat.R - qr.R(grp.dat.qr) fit.r - lmer(y~-1+X+(-1+Z|grp), start=list(grp=grp.dat.R)) Error in lmer(y ~ -1 + X + (-1 + Z | grp), start = list(grp = grp.dat.R)) : Leading 1 minor of Omega[[1]] not positive definite Some of the diagonal elements of R were negative, so I just changed the sign and tried again: grp.dat.R2 - (diag(sign(diag(grp.dat.R))) +%*% grp.dat.R) fit.r2 - lmer(y~-1+X+(-1+Z|grp), start=list(grp=grp.dat.R2)) Error in lmer(y ~ -1 + X + (-1 + Z | grp), start = list(grp = grp.dat.R2)) : Leading 2 minor of Omega[[1]] not positive definite If I were to do more with this, I'd first review all the documentation I could find on lmer including Doug Bates, Fitting linear mixed models in R, R News, 5(1): 27-30, May 2005, and Linear mixed model implementation in lmer, July 26, 2005, distributed with lme4 and stored on my hard drive under ~\R\R-2.2.0\library\lme4\doc\Implementation.pdf. I might also consult Pinheiro and Bates (2000) Mixed-Effects Models in S and S-PLUS (Springer), which is my primary source for mixed models generally. If I couldn't figure it out from there, I'd then try to work through the code line by line. Since lmer calls standardGeneric, it's not completely obvious how to get the code. Moreover, methods won't get it, because lmer follows the S4 standard (if I understand correctly). Fortunately, 'showMethods(lmer)' produced the following: Function lmer: formula = formula With this information, I then tried, 'getMethod(lmer, formula)', which gave me the desired source code. I could then copy it into a script file, walk through it line by line, and learn something. hope this helps. spencer graves Mark Lyman wrote: Is there a way to specify a Z matrix using the lmer function, where the model is written as y = X*Beta + Z*u + e? I am trying to reproduce smoothing methods illustrated in the paper Smoothing with Mixed Model Software my Long Ngo and M.P. Wand. published in the /Journal of Statistical Software/ in 2004 using the lme4 and Matrix packages. The code and data sets used can be found at http://www.jstatsoft.org/v09/i01/. There original code did not work for me without slight modifications here is the code that I used with my modifications noted. x - fossil$age y - 10*fossil$strontium.ratio knots - seq(94,121,length=25) n - length(x) X - cbind(rep(1,n),x) Z - outer(x,knots,-) Z - Z*(Z0) # I had to create the groupedData object with one group to fit the model I wanted grp - rep(1,n) grp.dat-groupedData(y~Z|grp) fit - lme(y~-1+X,random=pdIdent(~-1+Z),data=grp.dat) I would like to know how I could fit this same model using the lmer function. Specifically can I specify a Z matrix in the same way as I do above in lme? Thanks, Mark __ R-help@stat.math.ethz.ch mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide! http://www.R-project.org/posting-guide.html -- Spencer Graves, PhD Senior Development Engineer PDF Solutions, Inc. 333 West San Carlos Street Suite 700 San Jose, CA 95110, USA [EMAIL PROTECTED] www.pdf.com http://www.pdf.com Tel: 408-938-4420 Fax: 408-280-7915 __ R-help@stat.math.ethz.ch mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide! http://www.R-project.org/posting-guide.html
Re: [R] help with apply, please
Dear Ted, On Saturday 19 November 2005 20:51, Ted Harding wrote: [...snip...] There is bound to be a good algorithm out there somewhere for finding a minimal coveriung set but I don't know it! Comments? Best wishes to all, Ted. My case is probably a subset of your general algorithm. Peaking in the computer science webpages for Quine-McCluskey algorithm, I learned that there are way to simplify a matrix (prime implicants chart) before trying to find the minimum solutions. For example: 1. Row dominance 0 0 1 1 0 0 0 1 1 1 0 0 The second row containes all elements that the first row contains, therefore the first row (dominated) can be droped 2. Column dominance 0 1 0 1 1 1 1 1 0 0 The second column dominates the first column, therefore we can drop the second (dominating) column In a Quine-McCluskey algorithm, the number of rows will always be much lower than the number of columns, and applying the two above principles will make the matrix even more simple. There are algorithms written in other languages (like Java) freely available on the Internet, but I have no idea how to adapt them to R. Best, Adrian -- Adrian DUSA Romanian Social Data Archive 1, Schitu Magureanu Bd 050025 Bucharest sector 5 Romania Tel./Fax: +40 21 3126618 \ +40 21 3120210 / int.101 __ R-help@stat.math.ethz.ch mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide! http://www.R-project.org/posting-guide.html
Re: [R] help with apply, please
On Saturday 19 November 2005 20:51, Ted Harding wrote: [..snip...] There is bound to be a good algorithm out there somewhere for finding a minimal coveriung set but I don't know it! Best wishes to all, Ted. I found this presentation very explicit: http://www.cs.ualberta.ca/~amaral/courses/329/webslides/Topic5-QuineMcCluskey/sld079.htm Best wishes, Adrian -- Adrian DUSA Romanian Social Data Archive 1, Schitu Magureanu Bd 050025 Bucharest sector 5 Romania Tel./Fax: +40 21 3126618 \ +40 21 3120210 / int.101 __ R-help@stat.math.ethz.ch mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide! http://www.R-project.org/posting-guide.html
Re: [R] help with apply, please
On 11/19/05, Adrian DUSA [EMAIL PROTECTED] wrote: On Saturday 19 November 2005 19:17, Patrick Burns wrote: [snip...] One cheat would be to do the LP problem multiple times with the rows of your matrix randomly permuted. Assuming you keep track of the real rows, you could then get a sense of how many solutions there might be. Thanks for the answer. The trick does work (i.e. it finds all minimum solutions) provided that I permute the rows a sufficient number of times. And I have to compare each solution to the existing (unique) ones, which takes a lot of time... In your experience, what would be the definiton of multiple times for large matrices? My (dumb) solution is guaranteed to find all possible minimums, because it checks every possible combination. For large matrices, though, this would be really slow. I wonder if that could be vectorized in some way; before the LP function, I was thinking there might be a more efficient way to loop over all possible columns (using perhaps the apply family). Thanks again, Adrian Getting back to your original question of using apply, solving the LP gives us the number of components in any minimal solution and exhaustive search of all solutions with that many components can be done using combinations from gtools and apply like this: library(gtools) # needed for combinations soln - lp(min, rep(1,3), rbind(t(mtrx)), rep(=, 4), rep(1,4))$solution k - sum(soln) m - nrow(mtrx) combos - combinations(m,k) combos[apply(combos, 1, function(idx) all(colSums(mtrx[idx,]))),] In the example we get: [,1] [,2] [1,]13 [2,]23 which says that rows 1 and 3 of mtrx form one solution and rows 2 and 3 of mtrx form another solution. __ R-help@stat.math.ethz.ch mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide! http://www.R-project.org/posting-guide.html
[R] Crop white border for PDF output
Hi, I produce a series of diagrams with R in order to include them in my documents (LaTeX). However, there is a white border around the diagrams. For some that do not have anything written at the very bottom, the white border is relatively large. The rather big space between figure and caption at the final document looks not nice. It would be best not to have any white border. I played with oma=c(0,0,0,0) and mar=c(0,0,0,0) for single and multiple figure environments, however, without success. Is there an easy way to get rid of the white border for PDF outputs? Thanks for your input. Claus __ R-help@stat.math.ethz.ch mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide! http://www.R-project.org/posting-guide.html
Re: [R] help with apply, please
On Saturday 19 November 2005 22:09, Gabor Grothendieck wrote: Getting back to your original question of using apply, solving the LP gives us the number of components in any minimal solution and exhaustive search of all solutions with that many components can be done using combinations from gtools and apply like this: library(gtools) # needed for combinations soln - lp(min, rep(1,3), rbind(t(mtrx)), rep(=, 4), rep(1,4))$solution k - sum(soln) m - nrow(mtrx) combos - combinations(m,k) combos[apply(combos, 1, function(idx) all(colSums(mtrx[idx,]))),] In the example we get: [,1] [,2] [1,]13 [2,]23 which says that rows 1 and 3 of mtrx form one solution and rows 2 and 3 of mtrx form another solution. I'm speechless. It is exactly what I needed. A billion of thanks! Adrian -- Adrian DUSA Romanian Social Data Archive 1, Schitu Magureanu Bd 050025 Bucharest sector 5 Romania Tel./Fax: +40 21 3126618 \ +40 21 3120210 / int.101 __ R-help@stat.math.ethz.ch mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide! http://www.R-project.org/posting-guide.html
[R] directional correlograms?
I've run out of ideas for a simple solution, so... Does anyone know of a package that can compute directional correlograms? The spatial package seems to work for all directions, Usage: correlogram(krig, nint, plotit = TRUE, ...) but I don't know how to modify the spatial package (if required) or how I can arrange/filter the data to be able to compute directional correlograms so that I may use the spatial::correlogram(). I've used the spatmast package in S+ (but need to be able to do this in R). Thanks, Jeff. -- Jeff D. Hamann Forest Informatics, Inc. PO Box 1421 Corvallis, Oregon 97339-1421 phone 541-754-1428 fax 541-752-0288 [EMAIL PROTECTED] www.forestinformatics.com __ R-help@stat.math.ethz.ch mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide! http://www.R-project.org/posting-guide.html
[R] Attach a time series object
Is there an attach-like command for time series objects? Thanks in advance, Nestor __ R-help@stat.math.ethz.ch mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide! http://www.R-project.org/posting-guide.html
Re: [R] Attach a time series object
Try this: attach(as.list(my.time.series)) On 11/19/05, Nestor Arguea [EMAIL PROTECTED] wrote: Is there an attach-like command for time series objects? Thanks in advance, __ R-help@stat.math.ethz.ch mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide! http://www.R-project.org/posting-guide.html
Re: [R] repeated values, nlme, correlation structures
Spencer Graves a écrit : You are concerned that, using the mean of each age category as variable leads to a loss of information regarding the variance on the weight at each age and nestbox. What information do you think you lose? The variance around the mean weight of each age category. This variation is a priori not considered in the model when using the mean only, and not each value used to compute the mean.. In particular, have you studied the residuals from your fit? I would guess that the you probably have heterscedasticity with the variance of the residuals probably increasing with the age. Plots of the absolute residuals might help identify this. Yes, of course. At this stage using a Continuous AR(1) as Correlation Structure, reduces considerably heteroscedasticity up to quasi-normal. Also, is the number of blue tits in each age constant, or does it change, e.g., as some of the chicks die? Yes, unfortunately, it may happen eventually. To try to assess how much information I lost (especially if some of the chicks died), I might plot the weights in each nest box and connect the dots manually, attempting to assign chick identity to the individual numbers. I might do it two different ways, one best fit, and another worst plausible. Then I might try to fit models to these two augmented data sets as if I had the true chick identity. Then comparing these fits with the one you already have should help you evaluate what information you lost by using the averages AND give you a reasonable shot at recovering that information. If the results were promising, I might generate more than two sets of assignments, involving other people in that task. OK, should not be that difficult (actually the data were given with pseudo-ID numbers on each chicks and I started with this... until I learned they were corresponding to nothing). I suppose one could go as far as possible with the worst possible with random assignements and permutations, and thus comparing the fits. Many thanks for the hint. I was really wondering what may mean no answer on the list... Problem not clear enough, trivial solution or real trouble for statisticians with such data? Quite scaring to a biologist... Now, I am fixed. If the results were promising, I might generate more than two sets of assignments, involving other people in that task. Of course if some capable mixed-effect models specialist is interested in having a look to the data set, I can send it off list. Many thanks again, Spencer, I can stick on the track, now... Best regards, Patrick Bon Chance Spencer Graves Patrick Giraudoux wrote: Dear listers, My request of last week seems not to have drawn someone's attention. Suppose it was not clear enough. I am coping with an observational study where people's aim was to fit growth curve for a population of young blue tits. For logistic reasons, people have not been capable to number each individual, but they have a method to assess their age. Thus, nestboxes were visited occasionnally, youngs aged and weighted. This makes a multilevel data set, with two classification factors: - the nestbox (youngs shared the same parents and general feeding conditions) - age in each nestbox (animals from the same nestbox have been weighed along time, which likely leads to time correlation) Life would have been heaven if individuals were numbered, and thus nlme correlation structure implemented in the package be used easy. As mentioned above, this could not be the case. In a first approach, I actually used the mean weight of the youngs weighed at each age in nest boxes for the variable age, and could get a nice fit with nestbox as random variable and corCAR1(form=~age|nestbox) as covariation structure. modm0c-nlme(pds~Asym/(1+exp((xmid-age)/scal)), fixed=list(Asym~1,xmid~1,scal~1), random=Asym+xmid~1|nestbox,data=croispulm, start=list(fixed=c(10,5,2.2)), method=ML, corr=corCAR1(form=~age|nestbox) ) Assuming that I did not commited some error in setting model parameters (?), this way of doing is not fully satisfying, since using the mean of each age category as variable leads to a loss of information regarding the variance on the weight at each age and nestbox. My question is: is there a way to handle repeated values per group (here several youngs in an age category in each nestbox) in such a case? I would really appreciate an answer, even negative... Kind regards, Patrick __ R-help@stat.math.ethz.ch mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide! http://www.R-project.org/posting-guide.html __ R-help@stat.math.ethz.ch mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide!
Re: [R] Can someone Help in nls() package
When I tried to run your example, I got the following: Error in func(times[1], y, parms) : object Cum2 not found While I couldn't replicate your error, I can tell you that the reason print(coef(fit)) gave the error it did was because nls refuses to return anything when it encounters an error. If it were my problem, I might write a least-squares wrapper and give it to optim(..., hessian=T), as optim will still return an answer when it seems overparameterized, etc.; in that case, computing the eigenvalues and vectors of the hessian can help identify the problem. If optim also generated an error like Missing value or an infinity produced, I might modify 'f' to print its arguments and output. From that, I can usually figure out what I want to do about that. hope this helps. spencer graves Raja Jayaraman wrote: Hello R-Community, we are running aprogram to fit Non-linear differential equations to Aphid population Data and to estimate the birth and death parameters, here is the code: dat-data.frame(Time=c(0:60),Cur=c(5,6.2,59,39,38,44,20.4,19.4,34.2,35.4,38.2,48.2,55.4,113.2, 97,112,115,126,136.6,140.6,147.2,151.6,157.8,170,202,210.4,221.2,224.4,248.2,266, 277,291.4,392,461.2,470,418,410.8,395.6,365.2,189.4,43.4,33.2,32,29,26,26,25.6,24.6, 24,23.4,18.4,17.6,15.8,13.6,10.6,8.4,6.4,5.4,4.2,3.6,2.7)) times-c(0:60) f - function(t,xx,pars){ Cur- xx[1] Cum- xx[2] a - pars[1] b - pars[2] dCur - a*Cur-b*Cur*Cum^2 dCum - Cur list(c(dCur,dCum)) } require(nls) fit - nls(Cur ~ lsoda(c(Cur=1,Cum=1), times, f, c(a=a, b=b))[,2], data=dat, start=list(a=2.5, b=.01), trace=T ) print(coef(fit)) It runs the first iterations and shows the output, after the intial eveluation it send the following error message: 92 : 2.50 0.01 Error in numericDeriv(form[[3]], names(ind), env) : Missing value or an infinity produced when evaluating the model In addition: There were 50 or more warnings (use warnings() to see the first 50) print(coef(fit)) Error in coef(fit) : object fit not found Looking forward to hear soon Thanks Raj [[alternative HTML version deleted]] __ R-help@stat.math.ethz.ch mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide! http://www.R-project.org/posting-guide.html -- Spencer Graves, PhD Senior Development Engineer PDF Solutions, Inc. 333 West San Carlos Street Suite 700 San Jose, CA 95110, USA [EMAIL PROTECTED] www.pdf.com http://www.pdf.com Tel: 408-938-4420 Fax: 408-280-7915 __ R-help@stat.math.ethz.ch mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide! http://www.R-project.org/posting-guide.html
Re: [R] Attach a time series object
That did it. Thanks. Nestor On Saturday 19 November 2005 10:34 pm, you wrote: Try this: attach(as.list(my.time.series)) On 11/19/05, Nestor Arguea [EMAIL PROTECTED] wrote: Is there an attach-like command for time series objects? Thanks in advance, __ R-help@stat.math.ethz.ch mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide! http://www.R-project.org/posting-guide.html