[R] Class and object problem
Dear all, I have a problem with accessing class attributes. I was unable to solve this yet, but someone may know how to solve it. I'm trying to extract some information from the summary, and Akaike weight has the desired value. Object for a model fitted using the glmmML function from the glmmML package: result <- glmmML(cbind (y, n-y)~ x+a+b+c, family = binomial, data, cluster$B!K(B library(MASS) stepAIC(result) Then calculated the delta AIC by hand (following is the best four). model1 <- 0.0 model2 <- 1.8 model3 <- 4.2 model4 <- 6.2 Then followed equation as below: *W <- exp(-0.5 * Delta) / sum(exp(-0.5 * Delta))* However, result was always same value as [1] even each delta AIC is different values. I don't know why happened. I've also tried Ben's AIC tab in the bbmle package under the Ben's suggestion: > summary <- stepAIC(result) > AICtab(summary) When I try to run the code from within a package, error came up as UseMethod("logLik") no method to use "logLik". I've tried adding > slot <-summary (result) > slotName (slot) but it didn't help, slotName is NULL. Thanks for any kind of suggestions! Odette [[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] statistical significance, nonlinear regression
See ?confint2 in the nlrwr package for confidence intervals and for more info on hypothesis testing in nonlinear regression focused on R see the book associated with that package. On Wed, Dec 24, 2008 at 6:20 PM, adam99 wrote: > > I am using nonlinear regression to fit a couple of variables to a set of > measurements. I would like to do some significance tests for the estimated > parameters. I am able to check the confidence intervals using the Jacobian > coming out of nonlinear regression. > > I do see in a paper which shows t-value (it says estimated by White > method??), f-value, f-test, and j-test, are these available in matlab, or I > could code them myself but I need details about these tests. I would be glad > if you could provide a reference... > > Thanks > -- > View this message in context: > http://www.nabble.com/statistical-significance%2C-nonlinear-regression-tp21156969p21156969.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-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] statistical significance, nonlinear regression
On Dec 24, 2008, at 6:20 PM, adam99 wrote: I am using nonlinear regression to fit a couple of variables to a set of measurements. I would like to do some significance tests for the estimated parameters. I am able to check the confidence intervals using the Jacobian coming out of nonlinear regression. I do see in a paper which shows t-value (it says estimated by White method??), f-value, f-test, and j-test, are these available in matlab, or I could code them myself but I need details about these tests. I would be glad if you could provide a reference... Gosset WS, "On the Probable Error of the Mean". (1908), Biometrika, 6:1. Fisher RA, The Distribution of the Partial Correlation Coefficient", (1924), Metron, 3: 329. -- David Winsemius Thanks -- View this message in context: http://www.nabble.com/statistical-significance%2C-nonlinear-regression-tp21156969p21156969.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-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] statistical significance, nonlinear regression
Tests of statistical significance and/or confidence intervals for individual parameters in nonlinear regression are often meaningless and misguided. Nonlinear regression is **inherently** different than linear regression. It may make no physical sense whatever to eliminate *any* of the parameters describing, say, a series of interrelated chemical interactions. Determining what sequence of "nested" models to consider (which is the only thing that makes sense) is typically difficult and subject specific. Finally, statistical inference for nonlinear models is almost never exact, and the standard (e.g. likelihood based) approximations can be way off for small samples and certain data configurations. As for references -- are you kidding?! There are tons of books and papers out there. As you did not provide your identity, we have no idea what line of work you're in -- but you might start by looking for tutorials on the subject pitched to your profession and level of statistical understanding. Google is your friend here. -- Bert Gunter Genentech Nonclinical Statistics -Original Message- From: r-help-boun...@r-project.org [mailto:r-help-boun...@r-project.org] On Behalf Of adam99 Sent: Wednesday, December 24, 2008 3:21 PM To: r-help@r-project.org Subject: [R] statistical significance, nonlinear regression I am using nonlinear regression to fit a couple of variables to a set of measurements. I would like to do some significance tests for the estimated parameters. I am able to check the confidence intervals using the Jacobian coming out of nonlinear regression. I do see in a paper which shows t-value (it says estimated by White method??), f-value, f-test, and j-test, are these available in matlab, or I could code them myself but I need details about these tests. I would be glad if you could provide a reference... Thanks -- View this message in context: http://www.nabble.com/statistical-significance%2C-nonlinear-regression-tp211 56969p21156969.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-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] overwrite title
Lacking specifics about what you actually did, one can only guess. Have you yet tried setting ..., main = "" , within the plot call, whatever that might have been? Failing that, the way to specify the color of the "main" argument to title() is not bg (which is an argument for the plot device), but rather col.main At least that is how I read the par() help page. plot(1:10) title(main = "test") #... now title(main="test", col.main="white") Doesn't completely white it out on my screen display. -- David Winsemius On Dec 24, 2008, at 2:27 PM, whizvast wrote: Hi, useRs- I have a plot with a title generated automatically. I need to overwrite the title, but I can't figure out how to do that. I've tried the following: title( "abc", bg='white') But, that does not set the title background as white. Now I am stuck and need your help. Thanks- -- View this message in context: http://www.nabble.com/overwrite-title-tp21156936p21156936.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-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] overwrite title
Hi, useRs- I have a plot with a title generated automatically. I need to overwrite the title, but I can't figure out how to do that. I've tried the following: title( "abc", bg='white') But, that does not set the title background as white. Now I am stuck and need your help. Thanks- -- View this message in context: http://www.nabble.com/overwrite-title-tp21156936p21156936.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] command Polygenic gives error message concerning dimensions of data
Dear Sir/Madam, Since a few day now I try to use the command "polygenic" from the GenAbel package. However, I keep bumping up against an error message: "Error in polygenic(Testo, kin = kinship, data = data1) : dimension of outcome and kinship.matrix do not match". My data exists of 1240 individuals with 74 markers. It mainly consists of small families (2 or more brothers, father and mother; otherwise only the brothers are given). Genotypes are provided for the largest part of the members, whereas the phenotype is only given for the male individuals. I imported the data using the convert.snp.ped and load.gwaa.data commands. The kinship table was constructed with "makekinship". When I look at the dimensions of the kinship table, it is exactly the same as the number of individuals in my dataset. I also provide you with the following information because maybe that gives a clue on where things are going wrong. When using the genetic control method via the qtscore command, I get the following message:" data1.qt<-qtscore(Testo~age+BMI,data1) Warning messages: 1: In qtscore(Testo ~ age + BMI, data1) : 265 observations deleted due to missingness 2: In qtscore(Testo ~ age + BMI, data1) : Number of observations < 100, Lambda estimate is unreliable. Results for only a few SNPs are returned. Can you tell me what I'm missing? Thank you in advance, Kindest Regards, Veerle Bogaert Ghent University Hospital Veerle Bogaert Ghent University Hospital Department of Endocrinology 6K12 I.E. De Pintelaan 185 9000 Ghent Belgium Tel +32 9 332 34 13 Fax +32 9 332 38 86 __ 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] Implementing a linear restriction in lm()
Dear All! I want to test a coeffcient restriction beta=1 in a univariate model lm (y~x). Entering lm((y-x)~1) does not help since anova test requires the same dependent variable. What is the right way to proceed? Thank you for your help and marry xmas, Serguei Kaniovski Austrian Institute of Economic Research (WIFO) P.O.Box 91 Tel.: +43-1-7982601-231 1103 Vienna, AustriaFax: +43-1-7989386 Mail: serguei.kaniov...@wifo.ac.at http://www.wifo.ac.at/Serguei.Kaniovski [[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] snowfall sfInit error
Dear Mr. Ripley, snowfall 1.7 is finished, and is now working on Windows as intended - sorry for my oversight of that error. The given example now runs (as a sidenote: snow does not have to loaded explicitely, snowfall will do that). Also the NWS startup is fixed now (thanks to M. Schmidtberger for a small patch) and an error in sfSapply is fixed. Otherwise minor things were corrected or added. I uploaded the package to CRAN yesterday and beside it is downloadable from our site http://www.imbi.uni-freiburg.de/parallel Greetings, Jochen Knaus On Sat, 6 Dec 2008, chi...@gmail.com wrote: Dear all, I am trying to execute the simple example in snowfall http://cran.r-project.org/web/packages/snowfall/vignettes/snowfall.pdf ... require(snow) require(snowfall) sfInit( parallel=TRUE, cpus=2 ) sfLapply( 1:10, exp ) sfStop() I have installed the snow and snowfall packages in R on a machine with windows xp, however, after running the "sfInit( parallel=TRUE, cpus=2 )" line I get an error ... Error in system("whoami", intern = TRUE, ignore.stderr = TRUE) : whoami not found Error in paste(sep = "_", "R", uname, format(Sys.time(), "%H%M%S_%m%d%y")) : object "uname" not found I am the only (administrator) user of the computer. It has a dual core processor, and is not networked. I would be greatful if someone could tell me how to proceed. Follow the posting guide (see the footer of this message) and talk to the maintainer of 'snowfall'. Most likely it is not intended to be used on Windows, but has not declared that. 'whoami' and 'uname' are Unix programs, not Windows ones, but R's Sys.info() provides equivalent information. Kind regards Chibisi [[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.
[R] How to skip re-installing CRAN packages when updating R?
Dear R-helpers: I am new to R and would like to seek your expert opinion on installation tip. Many thanks in advance. I want to update my R to the newest version and wonder the following two questions: Question 1: How can I install R and its contributed packages in a way so when updating R in the future, I do NOT need to re-install contributed packages used by R of last version. Question 2: Is it an ok-practice to just install all the CRAN packages (i.e., install.packages(available.packages()[,1]) ). Does someone do so? The reason I ask the second question is that if installing all available packages does Not consume too much time (say less than 2 hours), too much computer resource (I have big harddrive, so harddrive is probably not a concern. I guess computing speed will not be affected but not sure...) then, I do not need to bother Question 1 and will just install all available packages when updating R. Many Thanks in advance. Merry Christmas! -Sean [[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] statistical significance, nonlinear regression
I am using nonlinear regression to fit a couple of variables to a set of measurements. I would like to do some significance tests for the estimated parameters. I am able to check the confidence intervals using the Jacobian coming out of nonlinear regression. I do see in a paper which shows t-value (it says estimated by White method??), f-value, f-test, and j-test, are these available in matlab, or I could code them myself but I need details about these tests. I would be glad if you could provide a reference... Thanks -- View this message in context: http://www.nabble.com/statistical-significance%2C-nonlinear-regression-tp21156969p21156969.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] xlsolutions courses
Any opinions on the list about these courses? Are they addressed to business analysts who are whizzes at Excel? To programmers? To statisticians? To mathematicians? Has anyone on the list attended them? Did they find them more useful than working through a book or some online resource? -s On Wed, Dec 24, 2008 at 11:08 AM, s...@xlsolutions-corp.com < s...@xlsolutions-corp.com> wrote: > -USAR2009 is on April 26-29- > (1) R/S-PLUS Fundamentals and Programming Techniques > http://www.xlsolutions-corp.com/coursedetail.asp?id=30 > (2) ...R/S System: Advanced Programming > http://www.xlsolutions-corp.com/coursedetail.asp?id=16 > [[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] filling values in a vector using smaller vector
Milton Huang wrote: > Thank you both for such beautiful solutions. Just what I was looking for! I > love the Internet, R, and the R-list! There is so much opportunity to learn. > > In fact, looking at the replace function, I see the two solutions are the > same: > > >> replace >> > function (x, list, values) > { > x[list] <- values > x > } > > > not exactly. an application of replace generates a local copy of the data, and whatever you pass to replace as x will not be modified, while if you do the assignment yourself, you'll modify the data. > Thanks again. You made my day. Have a happy holiday season. > you too! meRRy chRistmas and a happy new yeaR to all subscRibeRs. vQ __ 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] ggplot2 Xlim
would you make this reproducible, please. Think cut and paste out of email into R. ?dput my guess would be the breaks argument On Wed, Dec 24, 2008 at 12:31 PM, Felipe Carrillo wrote: > Hi: I need some help. > I am ploting a bar graph but I can't adjust my x axis scale > I use this code: > i <- qplot(ForkLength,Number,data=FL,geom="bar") >i + geom_bar(colour="blue",fill="grey65") # too crowded > > FL_dat <- ggplot(FL,aes(x=ForkLength,y=Number)) + > geom_bar(colour="green",fill="grey65") >FL_dat + scale_x_continuous(limits=c(20,170)) # Can't see anything > > FL Number > 29 22.9 > 30 63.4 > 31 199.3 > 32 629.6 > 33 2250.1 > 34 7452.5 > 35 19352.9 > 36 17655.5 > 37 13020.6 > 38 5856.0 > 39 2039.4 > 40 1261.2 > 41 780.2 > 42 826.6 > 43 739.0 > 44 608.2 > 45 694.3 > 46 599.5 > 47 690.4 > 48 762.9 > 49 594.6 > 50 771.7 > 51 695.3 > 52 784.5 > 53 780.1 > 54 823.6 > 55 883.2 > 56 747.6 > 57 834.4 > 58 716.7 > 59 632.8 > 60 670.4 > 61 511.0 > 62 577.4 > 63 538.0 > 64 452.3 > 65 451.7 > 66 355.7 > 67 294.1 > 68 278.8 > 69 165.5 > 70 208.7 > 71 161.6 > 72 159.9 > 73 100.9 > 74 84.4 > 75 110.3 > 76 69.3 > 77 60.7 > 78 63.2 > 79 28.8 > 80 46.1 > 81 34.6 > 82 37.1 > 83 35.5 > 84 35.7 > 85 24.3 > 86 17.5 > 87 24.9 > 88 21.5 > 89 17.4 > 90 14.0 > 91 7.8 > 92 10.1 > 93 6.8 > 94 2.9 > 95 4.0 > 96 7.3 > 97 4.6 > 98 4.0 > 99 1.7 > 100 5.0 > 101 11.3 > 102 3.0 > 103 5.2 > 104 9.4 > 105 6.4 > 106 1.0 > 107 8.5 > 108 8.6 > 109 10.1 > 110 9.0 > 111 11.7 > 112 16.0 > 113 3.1 > 114 7.6 > 115 3.9 > 116 7.0 > 117 6.9 > 118 8.1 > 119 2.0 > 121 3.7 > 122 1.9 > 123 4.0 > 124 6.3 > 126 2.0 > 127 2.0 > 128 1.0 > 129 2.0 > 132 2.0 > 134 7.3 > 135 1.0 > 136 1.0 > 139 1.0 > 142 1.0 > 145 1.0 > 152 2.0 > 161 2.5 > 172 1.0 > > > Felipe D. Carrillo > Supervisory Fishery Biologist > Department of the Interior > US Fish & Wildlife Service > California, USA > > __ > 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. > -- Stephen Sefick Let's not spend our time and resources thinking about things that are so little or so large that all they really do for us is puff us up and make us feel like gods. We are mammals, and have not exhausted the annoying little problems of being mammals. -K. Mullis __ 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] problem installing R packages in Windows Vista
Check out: https://stat.ethz.ch/pipermail/r-help/2008-October/176486.html On Wed, Dec 24, 2008 at 3:04 AM, norman Maiwashe wrote: > ** High Priority ** > > I have recently installed the R program in Windows Vista. However, I am > experiencing problem installing some of the packages. Specifically, I wanted > to install BRugs package running R as an administrator. I issued the > following command in R and received the following error message. > >> install.packages("BRugs") > Warning in install.packages("BRugs"): > argument 'lib' is missing: 'C\Users\norman\Documents/R/win-library/2.8' > Warning: unable to access index for repository > http://cran-za.r-project.org/bin/windows/contrib/2.8 > Warning: unable to access index for repository > http://www.stats.ox.ac.uk/pub/RWin/bin/windows/contrib/2.8 > Warning message: package 'BRugs' is not available > > Your prompt response will be greatly appreciated. > > > > Disclaimer\ \ This message is confidential and may be co...{{dropped:20}} > > __ > 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] Non-finite finite difference error
Ravi, thank you for the explanation - that makes perfect sense, and it wouldn't have occurred to me to suspect a negative parameter based on the error. Using the elaborated syntax from the help page yields a lovely fit. Regards, Jason On Wed, Dec 24, 2008 at 10:57 AM, Ravi Varadhan wrote: > Hi Jason, > > The error message indicates that there was problem in estimating the > gradient of objective function. It has nothing to do with your second data > point. This could happen for a variety of reasons, but the most proximate > cause of the problem seems due to a parameter being negative during the > iteration. The best solution, most often, is to provide a better (or > atleast a different) starting value. Look at the example in the help page > for "fitdistr": > > fitdistr(x, dgamma, list(shape = 1, rate = 0.1), lower = 0.01) > > Note that the above command specifies lower bounds on both the shape and > the rate parameter (hence a different optimziation algorithm will be used in > "optim"). > > Best, > Ravi. > > > Ravi Varadhan, Ph.D. > Assistant Professor, > Division of Geriatric Medicine and Gerontology > School of Medicine > Johns Hopkins University > > Ph. (410) 502-2619 > email: rvarad...@jhmi.edu > > > - Original Message - > From: js.augus...@gmail.com > Date: Tuesday, December 23, 2008 11:27 pm > Subject: [R] Non-finite finite difference error > To: r-help@r-project.org > > > > Hello, I'm trying to use fitdistr() from the MASS package to fit a > > gamma > > distribution to a set of data. The data set is too large (1167 > > values) to > > reproduce in an email, but the summary statistics are: > > > > Min. 1st Qu. Median Mean 3rd Qu. Max. > > 116.7 266.7 666.7 1348.0 1642.0 16720.0 > > > > The call I'm trying to make is: > > fitdistr(x,"gamma") > > > > and the error is: > > Error in optim(x = c(3466.676842, 1666.749002, 2500.067852, > > 1200.053892, : > > non-finite finite-difference value [2] > > In addition: Warning message: > > In dgamma(x, shape, scale, log) : NaNs produced > > > > I found a couple of other posts from folks who were getting the same > > error > > from optim(), but did not find any useful tips for my situation. The > > error > > seems to indicate a problem with value 2 in my data set > > (1666.749002), but > > nothing seems odd about that value. > > > > I'm willing to pass along the full data set as an attachment if it > > would > > help. > > > > Thank you in advance! > > > > Jason S. Augustyn, Ph.D. > > > > [[alternative HTML version deleted]] > > > > __ > > R-help@r-project.org mailing list > > > > PLEASE do read the posting guide > > 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] Viewing code
since 'glm' is an object, just type its name at the command prompt: > glm function (formula, family = gaussian, data, weights, subset, na.action, start = NULL, etastart, mustart, offset, control = glm.control(...), model = TRUE, method = "glm.fit", x = FALSE, y = TRUE, contrasts = NULL, ...) { call <- match.call() if (is.character(family)) family <- get(family, mode = "function", envir = parent.frame()) if (is.function(family)) family <- family() if (is.null(family$family)) { print(family) stop("'family' not recognized") } ... On Wed, Dec 24, 2008 at 12:49 PM, Stephen Collins wrote: > How do you view the code for a built-in R command (i.e., if I want to see > what R is doing when I run a glm() statement)? > > Regards, > > Stephen > >[[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. > -- Jim Holtman Cincinnati, OH +1 513 646 9390 What is the problem that you are trying to solve? __ 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] Tick and Label Color in Plot
Dear All, I would like to plot two quantities using two different scales along the two vertical y axes. On top of this, I would like to use two different colors (let us say red and blue) for the two vertical axes, their labels, their ticks and the text for each tick. I paste below a code snippet x <- c(4,10,50,98) temp <- c(1.3e-1,4.92e-2,9.48e-3,4.84e-3) conc <- c(1.92,5.08,26.35,51.56) conc2 <- c(7.5e-1,1.14,2.12,4.7) b <- diff(range(temp))/diff(range(conc)) a <- min(temp) - b*min(conc) pdf("D_k_and_R_mobility.pdf") par(mar=c(4.5,5,2,4.2)+0.1) plot(x, temp, type="b",lwd=2,col="transparent",lty=2,xlab=expression(paste(k)) ,ann=FALSE,yaxt="none", ylim=range(c(0.,1.4e-1)), xaxt="none", xlim=range(c(0,100)),cex.lab=1.4,cex.axis=1.2) lines(x, temp, col="blue",type="b",lwd=2,lty=1,pch=2) ticks <-c(0, 0.035,0.07,0.105, 0.14) axis(side=2,at=ticks,labels=FALSE, col = "blue",cex.lab=1.4,cex.axis=1.2) mtext(side = 2, text = ticks, at = ticks, col = "blue", line = 1,cex.lab=1.4,cex.axis=1.2) mtext(side = 2, text = expression(paste(D[k])), line = 3,cex.lab=2.4,cex.axis=6.2, col="blue") ticks <-c(0, 25,50,75, 100) axis(side=1,at=ticks, labels = ticks, col = "black",cex.lab=1.4,cex.axis=1.2) lines(x, a + b*conc, col="red",type="b",lwd=2,lty=1,pch=4) lines(x, a + b*conc2, col="red",type="b",lwd=2,lty=1,pch=6) ticks <-c(0,10,20,30,40,50) axis(4, at=a + b*ticks, labels=ticks,cex.lab=1.4,cex.axis=1.2, col="red") #this controls the 4th axis and what I want to do there! mtext(expression(paste(R[g(m)])),cex=1.4, 4, 3, col="red") legend(50,0.1, c(expression(paste(D[k])), expression(paste(R[m])),expression(paste(R[g]))), lwd=c(2,2,2),lty=c(2,1,1),pch = c(1,4,6),col=c("blue", "red","red"),box.lwd=1,box.lty=1, ,xjust = 1, yjust = 1) dev.off() The result is NOT what I am looking for, since I am having a lot of troubles in tuning both the color and the size of the labels, tick locations and so on. Can anyone "fix" this example? I had a look at http://tolstoy.newcastle.edu.au/R/help/03b/2708.html and http://www.mail-archive.com/r-h...@stat.math.ethz.ch/msg07033.html but obviously I am not quite there yet. Kind Regards and merry Xmas Lorenzo __ 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] Fata; error:
Hi Antonio, Sounds like your .RData file might be corrupt. Did you try deleting it (or renaming it) and starting R again? The .RData file should be in the directory where you started R. HTH, Brian -Original Message- From: r-help-boun...@r-project.org [mailto:r-help-boun...@r-project.org] On Behalf Of Antonio Paredes Sent: Wednesday, December 24, 2008 12:45 PM To: r-help@r-project.org Subject: [R] Fata; error: I just installed R 2.8.1 for windows. When I try to start the software I get the following: Fatal error: unable to restore saved data in .RData. Note that on my previous section I tried to read a large dataset and I got a message stating that no enough memory was avaliable (I don't have the complete log for that section) I wanted to ask how can I go about solving this problem, or do I need to remove and then reinstall R in order to solve the problem. I also wanted to know if someone can provide me with a reference (pdf, published book, or article) about the difference aspects of dealing with memory in R. -- -Tony [[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. -- This message w/attachments (message) may be privileged, confidential or proprietary, and if you are not an intended recipient, please notify the sender, do not use or share it and delete it. Unless specifically indicated, this message is not an offer to sell or a solicitation of any investment products or other financial product or service, an official confirmation of any transaction, or an official statement of Merrill Lynch. Subject to applicable law, Merrill Lynch may monitor, review and retain e-communications (EC) traveling through its networks/systems. The laws of the country of each sender/recipient may impact the handling of EC, and EC may be archived, supervised and produced in countries other than the country in which you are located. This message cannot be guaranteed to be secure or error-free. This message is subject to terms available at the following link: http://www.ml.com/e-communications_terms/. By messaging with Merrill Lynch you consent to the foregoing. -- __ 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] Viewing code
How do you view the code for a built-in R command (i.e., if I want to see what R is doing when I run a glm() statement)? Regards, Stephen [[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] Fata; error:
I just installed R 2.8.1 for windows. When I try to start the software I get the following: Fatal error: unable to restore saved data in .RData. Note that on my previous section I tried to read a large dataset and I got a message stating that no enough memory was avaliable (I don't have the complete log for that section) I wanted to ask how can I go about solving this problem, or do I need to remove and then reinstall R in order to solve the problem. I also wanted to know if someone can provide me with a reference (pdf, published book, or article) about the difference aspects of dealing with memory in R. -- -Tony [[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] ggplot2 Xlim
Hi: I need some help. I am ploting a bar graph but I can't adjust my x axis scale I use this code: i <- qplot(ForkLength,Number,data=FL,geom="bar") i + geom_bar(colour="blue",fill="grey65") # too crowded FL_dat <- ggplot(FL,aes(x=ForkLength,y=Number)) + geom_bar(colour="green",fill="grey65") FL_dat + scale_x_continuous(limits=c(20,170)) # Can't see anything FL Number 29 22.9 30 63.4 31 199.3 32 629.6 33 2250.1 34 7452.5 35 19352.9 36 17655.5 37 13020.6 38 5856.0 39 2039.4 40 1261.2 41 780.2 42 826.6 43 739.0 44 608.2 45 694.3 46 599.5 47 690.4 48 762.9 49 594.6 50 771.7 51 695.3 52 784.5 53 780.1 54 823.6 55 883.2 56 747.6 57 834.4 58 716.7 59 632.8 60 670.4 61 511.0 62 577.4 63 538.0 64 452.3 65 451.7 66 355.7 67 294.1 68 278.8 69 165.5 70 208.7 71 161.6 72 159.9 73 100.9 74 84.4 75 110.3 76 69.3 77 60.7 78 63.2 79 28.8 80 46.1 81 34.6 82 37.1 83 35.5 84 35.7 85 24.3 86 17.5 87 24.9 88 21.5 89 17.4 90 14.0 91 7.8 92 10.1 93 6.8 94 2.9 95 4.0 96 7.3 97 4.6 98 4.0 99 1.7 100 5.0 101 11.3 102 3.0 103 5.2 104 9.4 105 6.4 106 1.0 107 8.5 108 8.6 109 10.1 110 9.0 111 11.7 112 16.0 113 3.1 114 7.6 115 3.9 116 7.0 117 6.9 118 8.1 119 2.0 121 3.7 122 1.9 123 4.0 124 6.3 126 2.0 127 2.0 128 1.0 129 2.0 132 2.0 134 7.3 135 1.0 136 1.0 139 1.0 142 1.0 145 1.0 152 2.0 161 2.5 172 1.0 Felipe D. Carrillo Supervisory Fishery Biologist Department of the Interior US Fish & Wildlife Service California, USA __ 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] Compressing String in R
Sorry, I meant `[.gene` where gene would be your new class. -s On Wed, Dec 24, 2008 at 11:00 AM, Stavros Macrakis wrote: > You might consider using the 'bit' library and use two bits per base. You > could then wrap this in an object with appropriate functions (bit.`[`, > etc.). > >-s > > > On Wed, Dec 24, 2008 at 10:26 AM, Gundala Viswanath wrote: > >> Dear all, >> >> What's the R way to compress the string into smaller 2~3 char/digit >> length. >> In particular I want to compress string of length >=30 characters, >> e.g. ACGATACGGCGACCACCGAGATCTACACTCTTCC >> >> The reason I want to do that is because, there are billions >> of such string I want to print out. And I need to save disk space. >> >> - Gundala Viswanath >> Jakarta - Indonesia >> >> __ >> 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] Interval censored Data in survreg() with zero values!
The problem is that you are not coding your data the way that I would; program authors do not always anticipate what others will do! The Weibull distribution has support on (0, infinity). Using Surv(t1, t2, type='interval2'), you can have a left censored observation where time of event < t: represented as (NA, t) a right censored observation where time of event >t: represented as (t, NA) an interval censored observations t1<=time <= t2 : represented as (t1,t2) Notice that the NA is just a trick of representation, it does not cause something to be omitted from the data. The survreg code assumes that the third form will only be used when t1 and t2 are strictly within the range of the data. (Which is how I would do it, so is of course the OBVIOUS thing anyone would do :-) For a Weibull with event between 0 and t the right-censored representation (NA,t) and the interval censored representation (0,t) are mathematically equivalent, but the program doesn't like the second form. This is on my list of enhancements to add. It may even get to the top of the list someday. Terry Therneau - Hello, I have interval censored data, censored between (0, 100). I used the tobit function in the AER package which in turn backs on survreg. Actually I'm struggling with the distribution. Data is asymmetrically distributed, so first choice would be a Weibull distribution. Unfortunately the Weibull doesn't allow for zero values in time data, as it requires x > 0. So I tried the exponential distribution that allows x to be >= 0 and the log-normal that sets x <= 0 to 0. Still I get the same error: " Fehler in survreg(formula = Surv(ifelse(A16_1_1 >= 100, 100, ifelse(A16_1_1 <= : Invalid survival times for this distribution " __ 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] Compressing String in R
Since you only have 4 characters, you can can create a table of all the combinations of 4 of them and this will reduce to one byte instead of 4. This is fine if you just want to store them. > x <- expand.grid(c("A","C","G","T"), + c("A", "C", "G", "T"), + c("A", "C", "G", "T"), + c("A", "C", "G", "T")) > gene.table <- apply(x, 1, paste, collapse='') > # convert the string (right now it is length mod 4. more logic if not > multiple of 4 > gene <- "ACGATACGGCGACCACCGAGATCTACACTCTT" > # break into 4 character strings > start <- seq(1, by=4, to=nchar(gene)) > strings <- mapply(substr, gene, start, start+3) > # create new compressed string > comp <- as.raw(match(strings, gene.table) - 1) > # convert back > paste(gene.table[as.integer(comp) + 1], collapse='') [1] "ACGATACGGCGACCACCGAGATCTACACTCTT" > On Wed, Dec 24, 2008 at 10:26 AM, Gundala Viswanath wrote: > Dear all, > > What's the R way to compress the string into smaller 2~3 char/digit length. > In particular I want to compress string of length >=30 characters, > e.g. ACGATACGGCGACCACCGAGATCTACACTCTTCC > > The reason I want to do that is because, there are billions > of such string I want to print out. And I need to save disk space. > > - Gundala Viswanath > Jakarta - Indonesia > > __ > 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. > -- Jim Holtman Cincinnati, OH +1 513 646 9390 What is the problem that you are trying to solve? __ 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] 2009 Courses***R/S-PLUS Advanced & Fundamentals - January 2009. Also check out our New&Emerging Courses.
Happy Holidays! We've updated our courses lists to add New&Emerging Courses for 2009. --USAR2009 is on April 26-29- (1) R/S-PLUS Fundamentals and Programming Techniques http://www.xlsolutions-corp.com/coursedetail.asp?id=30 * San Francisco ** January 26-27, 2009 * New York ** January 26-27, 2009 (2) R/S System: Advanced Programming http://www.xlsolutions-corp.com/coursedetail.asp?id=16 * San Francisco ** January 29-30, 2009 * Boston ** January 29-30, 2009 Ask for group discount and reserve your seat Now - Earlybird Rates. Payment due after the class! Email Sue Turner: s...@xlsolutions-corp.com http://www.xlsolutions-corp.com/rplus (3) New&Emerging Courses a-Applied Survival Analysis for Business Intelligence Using R/R-PLUS b-Advanced Clustering Techniques in R/R-PLUS c-Advanced Analytics for Business Intelligence Using R/R-PLUS d-Modeling Financial Time Series in R and S/PLUS Email us for group discounts. Email Sue Turner: s...@xlsolutions-corp.com Phone: 206-686-1578 Please let us know if you and your colleagues are interested in this class to take advantage of group discount. Register now to secure your seat! Cheers, Elvis Miller, PhD Manager Training. XLSolutions Corporation 206 686 1578 www.xlsolutions-corp.com el...@xlsolutions-corp.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] filling values in a vector using smaller vector
Thank you both for such beautiful solutions. Just what I was looking for! I love the Internet, R, and the R-list! There is so much opportunity to learn. In fact, looking at the replace function, I see the two solutions are the same: > replace function (x, list, values) { x[list] <- values x } Thanks again. You made my day. Have a happy holiday season. -milton == On Wednesday 24 December 2008 1:46 am, you wrote: > Wacek Kusnierczyk wrote: > > Milton Huang wrote: > >>> Dear list members: > >>> > >>> I am looking for an elegant (or efficient) way to accomplish the > >>> following: > >>> > >>> take a large boolean vector and fill the TRUE values with the values > >>> from a smaller boolean vector that has a length that is the number of > >>> TRUE values of the large vector. > >>> > >>> Example: > >>> > >>> large<- c(FALSE, FALSE, FALSE, TRUE, FALSE, FALSE, TRUE, FALSE, FALSE, > >>> FALSE, TRUE, FALSE) > >>> > >>> small<- c(TRUE, FALSE, TRUE) > >>> > >>> desired output = c(FALSE, FALSE, FALSE, *TRUE*, FALSE, FALSE, *FALSE*, > >>> FALSE, FALSE, FALSE, *TRUE*, FALSE) > > > > replace(large, which(large), small) > > in fact, this will do: > > replace(large, large, small) > > vQ -- I believe the following does what is wanted: desired <- large desired[large] <- small Patrick Burns patr...@burns-stat.com +44 (0)20 8525 0696 http://www.burns-stat.com (home of S Poetry and "A Guide for the Unwilling S User") __ 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] Compressing String in R
You might consider using the 'bit' library and use two bits per base. You could then wrap this in an object with appropriate functions (bit.`[`, etc.). -s On Wed, Dec 24, 2008 at 10:26 AM, Gundala Viswanath wrote: > Dear all, > > What's the R way to compress the string into smaller 2~3 char/digit length. > In particular I want to compress string of length >=30 characters, > e.g. ACGATACGGCGACCACCGAGATCTACACTCTTCC > > The reason I want to do that is because, there are billions > of such string I want to print out. And I need to save disk space. > > - Gundala Viswanath > Jakarta - Indonesia > > __ > 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] Non-finite finite difference error
Hi Jason, The error message indicates that there was problem in estimating the gradient of objective function. It has nothing to do with your second data point. This could happen for a variety of reasons, but the most proximate cause of the problem seems due to a parameter being negative during the iteration. The best solution, most often, is to provide a better (or atleast a different) starting value. Look at the example in the help page for "fitdistr": fitdistr(x, dgamma, list(shape = 1, rate = 0.1), lower = 0.01) Note that the above command specifies lower bounds on both the shape and the rate parameter (hence a different optimziation algorithm will be used in "optim"). Best, Ravi. Ravi Varadhan, Ph.D. Assistant Professor, Division of Geriatric Medicine and Gerontology School of Medicine Johns Hopkins University Ph. (410) 502-2619 email: rvarad...@jhmi.edu - Original Message - From: js.augus...@gmail.com Date: Tuesday, December 23, 2008 11:27 pm Subject: [R] Non-finite finite difference error To: r-help@r-project.org > Hello, I'm trying to use fitdistr() from the MASS package to fit a > gamma > distribution to a set of data. The data set is too large (1167 > values) to > reproduce in an email, but the summary statistics are: > > Min. 1st Qu. Median Mean 3rd Qu. Max. > 116.7 266.7 666.7 1348.0 1642.0 16720.0 > > The call I'm trying to make is: > fitdistr(x,"gamma") > > and the error is: > Error in optim(x = c(3466.676842, 1666.749002, 2500.067852, > 1200.053892, : > non-finite finite-difference value [2] > In addition: Warning message: > In dgamma(x, shape, scale, log) : NaNs produced > > I found a couple of other posts from folks who were getting the same > error > from optim(), but did not find any useful tips for my situation. The > error > seems to indicate a problem with value 2 in my data set > (1666.749002), but > nothing seems odd about that value. > > I'm willing to pass along the full data set as an attachment if it > would > help. > > Thank you in advance! > > Jason S. Augustyn, Ph.D. > > [[alternative HTML version deleted]] > > __ > R-help@r-project.org mailing list > > PLEASE do read the posting guide > 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] Compressing String in R
Dear all, What's the R way to compress the string into smaller 2~3 char/digit length. In particular I want to compress string of length >=30 characters, e.g. ACGATACGGCGACCACCGAGATCTACACTCTTCC The reason I want to do that is because, there are billions of such string I want to print out. And I need to save disk space. - Gundala Viswanath Jakarta - Indonesia __ 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] VarFunc or log-transformation
Dear list members, I constructed this model: bao1<-lme(sla~mg, random=~pop/nr.tree, weights=varPower(form=~sla|pop) variables: - sla = continuus - mg = factor - pop = factor - nr.tree = factor So, the variance of sla increases with sla, dependent of the pop. However, I fitted another (homoscedastic) model, where I transformed sla to log(sla): bao2<-lme(log(sla)~mg, random=~pop/nr.tree) This second model predicts in a better way the observations than the first model (observed with a sla against fitted(.) plot). Which model is the most convenient? Are there advantages/disadvantages in the use of these models? Thanks in advance, Sebastiaan De Smedt Department of Bioscience Engineering University of Antwerp Belgium Tel.: +32 (0)3 265 35 17 Fax.: +32 (0)3 265 32 25 [[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] Using 'cat' on data frame
On Dec 24, 2008, at 2:35 AM, Gundala Viswanath wrote: Dear all, I have the following data frame: raw.count Var1 Freq 1 AA 707 2 AC14 3 AT 3 But why when printint it using 'cat', it doesn't print the desired string "AAA" ? cat(raw.count$Var1, "\n") 1 2 3 What's wrong with my cat command above. "What's wrong" is that Var1 is a factor rather than a character vector. Veslot's answers provide the proper method for dealing with that situation. -- David Winsemius - Gundala Viswanath __ 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] selecting a subset of a matrix based on a value occurring in 5 records
> mat[,colSums(mat!=0)>=5] Jacques VESLOT CEMAGREF - UR Hydrobiologie Route de Cézanne - CS 40061 13182 AIX-EN-PROVENCE Cedex 5, France Tél. + 0033 04 42 66 99 76 fax+ 0033 04 42 66 99 34 email jacques.ves...@cemagref.fr >-Message d'origine- >De : r-help-boun...@r-project.org [mailto:r-help-boun...@r-project.org] De la >part >de Bob Green >Envoyé : mercredi 24 décembre 2008 13:17 >À : r-help@r-project.org >Objet : [R] selecting a subset of a matrix based on a value occurring in 5 >records > > >Hello, > >>I am hoping for some advice as to how I might create a subset of a >>matrix. The matrix is 176 x 3530. The rows are individual records >>and the columns words. I want to create a new matrix that only >>consists of words which occur in at least 5 records. For example, >>if column 7 is "charges" and this only appears in 4 records/rows >>this variable would not be included, whereas if column 109 was the >>word "monitor" and occurred in 95 records it would be saved into the >>new matrix. Values in the matrix are numbers, such that if a word >>does not occur in a record the cell contains a zero, whereas if it >>occurs 7 times there is a value of 7 for that record. It is the >>number of records rather than the than the column total that is the >>criteria for determing inclusion into the matrix. > > >Any suggestions on how I might reduce the size of this matrix so as >to include only those columns in which a word occurs at least in 5 >records is much appreciated, > >regards > >Bob > >__ >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] selecting a subset of a matrix based on a value occurring in 5 records
Hello, I am hoping for some advice as to how I might create a subset of a matrix. The matrix is 176 x 3530. The rows are individual records and the columns words. I want to create a new matrix that only consists of words which occur in at least 5 records. For example, if column 7 is "charges" and this only appears in 4 records/rows this variable would not be included, whereas if column 109 was the word "monitor" and occurred in 95 records it would be saved into the new matrix. Values in the matrix are numbers, such that if a word does not occur in a record the cell contains a zero, whereas if it occurs 7 times there is a value of 7 for that record. It is the number of records rather than the than the column total that is the criteria for determing inclusion into the matrix. Any suggestions on how I might reduce the size of this matrix so as to include only those columns in which a word occurs at least in 5 records is much appreciated, regards Bob __ 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] AR(2) coefficient interpretation
Stephen, when I think about you're problem I'm a little worried as it should be is very simple. If you think of a the more straightforward AR(1) model y_t = a0 + b*y_t-1 the intercept is the the value y_t=a0 on the scatterplot of y_t vs. y_t-1. For your first series labelled "a" for example the scatter plot (in Excel) shows that this intercept computed using the linest function is about 57,000,000. For the 2-d regression y_t on y_t-1 and y_t-2 there are only 9 data points and the ls parameters are b1 b2 a0 (Embedded image moved to file: pic10548.jpg) This gives quite good fit to the data - the lm model in R should give the same values (I havn't tried it). Try it and see if the coeffs agree with arima - if not, it may be there's something funny going on in arima in R. So you want an AR model and you're unsure of arima use lm on lagged values. Gerard "Stephen Oman" To "Gerard M. Keogh" 23/12/2008 13:40 cc Subject Re: [R] AR(2) coefficient interpretation Hi Gerard, Thank you for your reply. My point is even though the model is not suitable, the intercept shouldn't be 5 point sth when the univariate data is more than 100 million so I wonder whether my interpretation of those coefficients are correct. Anyway, i have done the acf and pacf and it seems AR(2) is the right model. Stephen On Mon, Dec 22, 2008 at 8:33 AM, Gerard M. Keogh wrote: 12 obs isn't much for an ar model to work off! but in any event, did you check the acf of your data and did it geometrically decay after 2 steps to 0? If not the model is unsuitable. Gerard Stephen Oman To Sent by: r-help@r-project.org r-help-boun...@r- cc project.org Subject [R] AR(2) coefficient 22/12/2008 15:06 interpretation I am a beginner in using R and I need help in the interpretation of AR result by R. I used 12 observations for my AR(2) model and it turned out the intercept showed 5.23 while first and second AR coefficients showed 0.40 and 0.46. It is because my raw data are in million so it seems the intercept is too small and it doesn't make sense. Did i make any mistake in my code? My code is as follows: r<-read.table("data.txt", dec=",", header=T) attach(r) fit<-arima(a, c(2,0,0)) Thank you for your help first. -- View this message in context: http://www.nabble.com/AR%282%29-coefficient-interpretation-tp21129322p21129322.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. ** The information transmitted is intended only for the person or entity to which it is addressed and may contain confidential and/or privileged material. Any review, retransmission, dissemination or other use of, or taking of any action in reliance upon, this information by persons or entities other than the intended recipient is prohibited. If you received this in error, please contact the sender and delete the material from any computer. It is the policy of the Department of Justice, Equality and Law Reform and the Agencies and Offices using its IT services to disallow the sending of offensive material. Should you consider that the material contained in this message is offensive you should contact the sender immediately and al
Re: [R] 4 questions regarding hypothesis testing, survey package, ts on samples, plotting
Ben Bolker wrote: Khawaja, Aman wrote: I need to answer one of the question in my open source test is: What are the four questions asked about the parameters in hypothesis testing? Please check the posting guide. * We don't answer homework questions ("open source" doesn't mean that other people answer the questions for you, it means you can find the answers outside your own head -- and in any case, we don't have any of way of knowing that the test is really open). * this is not an R question but a statistics question * please don't post the same question multiple times Besides, this is really unanswerable without access to your teaching material, which probably has a list of four questions somewhere... It is a bit like the History question: "Who was what in what of whom?" (Answer: "King Gustav Adolf was a thorn in the eye of Christian IV") -- O__ Peter Dalgaard Øster Farimagsgade 5, Entr.B c/ /'_ --- Dept. of Biostatistics PO Box 2099, 1014 Cph. K (*) \(*) -- University of Copenhagen Denmark Ph: (+45) 35327918 ~~ - (p.dalga...@biostat.ku.dk) FAX: (+45) 35327907 __ 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] filling values in a vector using smaller vector
Wacek Kusnierczyk wrote: > Milton Huang wrote: >> >> >>> Dear list members: >>> >>> I am looking for an elegant (or efficient) way to accomplish the following: >>> >>> take a large boolean vector and fill the TRUE values with the values from a >>> smaller boolean vector that has a length that is the number of TRUE values >>> of >>> the large vector. >>> >>> Example: >>> >>> large<- c(FALSE, FALSE, FALSE, TRUE, FALSE, FALSE, TRUE, FALSE, FALSE, >>> FALSE, >>> TRUE, FALSE) >>> >>> small<- c(TRUE, FALSE, TRUE) >>> >>> desired output = c(FALSE, FALSE, FALSE, *TRUE*, FALSE, FALSE, *FALSE*, >>> FALSE, >>> FALSE, FALSE, *TRUE*, FALSE) >>> >>> >>> > replace(large, which(large), small) > in fact, this will do: replace(large, large, small) vQ __ 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] filling values in a vector using smaller vector
I believe the following does what is wanted: desired <- large desired[large] <- small Patrick Burns patr...@burns-stat.com +44 (0)20 8525 0696 http://www.burns-stat.com (home of S Poetry and "A Guide for the Unwilling S User") Milton Huang wrote: Dear list members: I am looking for an elegant (or efficient) way to accomplish the following: take a large boolean vector and fill the TRUE values with the values from a smaller boolean vector that has a length that is the number of TRUE values of the large vector. Example: large<- c(FALSE, FALSE, FALSE, TRUE, FALSE, FALSE, TRUE, FALSE, FALSE, FALSE, TRUE, FALSE) small<- c(TRUE, FALSE, TRUE) desired output = c(FALSE, FALSE, FALSE, *TRUE*, FALSE, FALSE, *FALSE*, FALSE, FALSE, FALSE, *TRUE*, FALSE) (without the asterisks! ) my first thought as someone new to R was ifelse(large,small, large) but that returns: c(FALSE FALSE FALSE TRUE FALSE FALSE TRUE FALSE FALSE FALSE FALSE FALSE) because small is cycled to match the size of large instead of the size of the TRUE subset of large. I am guessing that there is probably a way to do this without writing a loop, but I just don't know the syntax. -mph __ 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] filling values in a vector using smaller vector
Wacek Kusnierczyk wrote: > Milton Huang wrote: > >> Dear list members: >> >> I am looking for an elegant (or efficient) way to accomplish the following: >> >> take a large boolean vector and fill the TRUE values with the values from a >> smaller boolean vector that has a length that is the number of TRUE values >> of >> the large vector. >> >> Example: >> >> large<- c(FALSE, FALSE, FALSE, TRUE, FALSE, FALSE, TRUE, FALSE, FALSE, >> FALSE, >> TRUE, FALSE) >> >> small<- c(TRUE, FALSE, TRUE) >> >> desired output = c(FALSE, FALSE, FALSE, *TRUE*, FALSE, FALSE, *FALSE*, >> FALSE, >> FALSE, FALSE, *TRUE*, FALSE) >> >> >> > > large[which(large)] = small > # large[which(large)] = paste("*", small, "*", sep="") to see it's as > you specify > ?which > oops, i read your mail too quickly, assumed you wanted to make an in-place replacement. the functional way would be: replace(large, which(large), small) vQ __ 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] filling values in a vector using smaller vector
Milton Huang wrote: > Dear list members: > > I am looking for an elegant (or efficient) way to accomplish the following: > > take a large boolean vector and fill the TRUE values with the values from a > smaller boolean vector that has a length that is the number of TRUE values of > the large vector. > > Example: > > large<- c(FALSE, FALSE, FALSE, TRUE, FALSE, FALSE, TRUE, FALSE, FALSE, > FALSE, > TRUE, FALSE) > > small<- c(TRUE, FALSE, TRUE) > > desired output = c(FALSE, FALSE, FALSE, *TRUE*, FALSE, FALSE, *FALSE*, > FALSE, > FALSE, FALSE, *TRUE*, FALSE) > > large[which(large)] = small # large[which(large)] = paste("*", small, "*", sep="") to see it's as you specify ?which vQ __ 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] filling values in a vector using smaller vector
Dear list members: I am looking for an elegant (or efficient) way to accomplish the following: take a large boolean vector and fill the TRUE values with the values from a smaller boolean vector that has a length that is the number of TRUE values of the large vector. Example: large<- c(FALSE, FALSE, FALSE, TRUE, FALSE, FALSE, TRUE, FALSE, FALSE, FALSE, TRUE, FALSE) small<- c(TRUE, FALSE, TRUE) desired output = c(FALSE, FALSE, FALSE, *TRUE*, FALSE, FALSE, *FALSE*, FALSE, FALSE, FALSE, *TRUE*, FALSE) (without the asterisks! ) my first thought as someone new to R was ifelse(large,small, large) but that returns: c(FALSE FALSE FALSE TRUE FALSE FALSE TRUE FALSE FALSE FALSE FALSE FALSE) because small is cycled to match the size of large instead of the size of the TRUE subset of large. I am guessing that there is probably a way to do this without writing a loop, but I just don't know the syntax. -mph __ 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] problem installing R packages in Windows Vista
This is not a problem in R, but with Internet access from your system. It is an FAQ, see http://cran.r-project.org/bin/windows/base/rw-FAQ.html#The-Internet-download-functions-fail_002e Another possibility is to download the file http://www.stats.ox.ac.uk/pub/RWin/bin/windows/contrib/2.8/BRugs_0.4-2.zip and use the menu item to install from a local zip file. On Wed, 24 Dec 2008, norman Maiwashe wrote: ** High Priority ** Please make it a high priority to read the posting guide and rw-FAQ: see the footer to this message. I have recently installed the R program in Windows Vista. However, I am experiencing problem installing some of the packages. Specifically, I wanted to install BRugs package running R as an administrator. I issued the following command in R and received the following error message. I don't see an *error* message here. (warning != error .) It is warning you of a problem on your machine or, possibly, the system you are accessing. install.packages("BRugs") Warning in install.packages("BRugs"): argument 'lib' is missing: 'C\Users\norman\Documents/R/win-library/2.8' Warning: unable to access index for repository http://cran-za.r-project.org/bin/windows/contrib/2.8 Warning: unable to access index for repository http://www.stats.ox.ac.uk/pub/RWin/bin/windows/contrib/2.8 Warning message: package 'BRugs' is not available Your prompt response will be greatly appreciated. Disclaimer\ \ This message is confidential and may be co...{{dropped:20}} __ 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 D. Ripley, rip...@stats.ox.ac.uk 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@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] problem installing R packages in Windows Vista
** High Priority ** I have recently installed the R program in Windows Vista. However, I am experiencing problem installing some of the packages. Specifically, I wanted to install BRugs package running R as an administrator. I issued the following command in R and received the following error message. > install.packages("BRugs") Warning in install.packages("BRugs"): argument 'lib' is missing: 'C\Users\norman\Documents/R/win-library/2.8' Warning: unable to access index for repository http://cran-za.r-project.org/bin/windows/contrib/2.8 Warning: unable to access index for repository http://www.stats.ox.ac.uk/pub/RWin/bin/windows/contrib/2.8 Warning message: package 'BRugs' is not available Your prompt response will be greatly appreciated. Disclaimer\ \ This message is confidential and may be co...{{dropped:20}} __ 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.