Re: [R] pstoedit
On Wed, 13 Apr 2005, BORGULYA [iso-8859-2] Gábor wrote: Has onyone experience with pstoedit (http://www.pstoedit.net/pstoedit) to convert eps graphs generated by R on Linux to Windows formats (WMF or EMF)? Does this way work? Is there an other, better way? You can only do that using pstoedit on Windows. ^^ A much better way on Windows is to run the R code on R for Windows and use its win.metafile() device. Another better way is to use Adobe Illustrator. The ability to generate WMF on Unix is a long-standing wish at http://developer.r-project.org/WindowsTODO.html but no one has ever contributed a working device (although it would be no harder than say the PDF device). Note that because of font differences, conversion from EPS to WMF can only ever be approximate. The fact that the website of pstoedit mentions that a Better Enhanced Windows Meta Files (EMF) plugin exists for Windows 9x/NT/2K/XP only makes me expect poor quality. Am I right? No quality at all unless you are using Windows where it is unnecessary. -- 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] lm() with many responses
On Tue, 12 Apr 2005, John Pitney wrote: I have one array of predictors, one observation per row, and one array of responses, also arranged one observation per row. I arrange these into a data.frame and call lm() with a pasted-together formula. I would like to call lm() with a number of responses in excess of 100, but for some reason, 39 seems to be a limit. Why do I get an invalid variable names error from model.frame() when supplying 40 or more responses? Your expression is too long. Create the response matrix and pass that to the formula, rather than passing an expression. There is a 500-char internal limit on variable names in model.frame.default. That should be enough As a workaround, I can loop through groups of 39 responses in separate calls to lm(), but that seems inefficient and possibly version- or platform-dependent. Here is my best effort at a minimal example showing the problem. It's not easy to cut-and-paste, though. --- begin pasted R session --- test.this - function(n.resp, n.obs, n.pred) { + my.resp - matrix(runif(n.resp * n.obs), nrow=n.obs) + my.resp.names - paste(Response, 1:n.resp, sep=.) + my.pred - matrix(runif(n.pred * n.obs), nrow=n.obs) + my.pred.names - paste(Predictor, 1:n.pred, sep=.) + my.formula - as.formula(paste(cbind(, + paste(my.resp.names, collapse=, ), ) ~ , + paste(my.pred.names, collapse= + ))) + d.tmp - cbind(my.pred, my.resp) + d.tmp - as.data.frame(d.tmp) + names(d.tmp) - c(my.pred.names, my.resp.names) + my.lm - lm(my.formula, data=d.tmp, model=F, qr=F, x=F, y=F, + na.action=na.exclude) + my.lm + } # Now, try it. 39 response vectors is OK, but 40 causes an error: m1 - test.this(40, 10, 2) Error in model.frame(formula, rownames, variables, varnames, extras, extranames, : invalid variable names m1 - test.this(39, 10, 2) # No error for n.resp == 39. # Also, shouldn't qr=F in the call to lm() turn off output of m1$qr? Only if it were implemented. # m1$qr exists. I'd like to save memory and omit it if possible. str(m1$qr) List of 5 $ qr : num [1:10, 1:3] -3.162 0.316 0.316 0.316 0.316 ... ..- attr(*, dimnames)=List of 2 .. ..$ : chr [1:10] 1 2 3 4 ... .. ..$ : chr [1:3] (Intercept) Predictor.1 Predictor.2 ..- attr(*, assign)= int [1:3] 0 1 2 $ qraux: num [1:3] 1.32 1.34 1.42 $ pivot: int [1:3] 1 2 3 $ tol : num 1e-07 $ rank : int 3 - attr(*, class)= chr qr # Here's my version: version _ platform i386-pc-mingw32 arch i386 os mingw32 system i386, mingw32 status major2 minor0.1 year 2004 month11 day 15 language R --- end pasted R session --- Best regards, John __ 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 -- 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
[R] how to separate a string
hello, i wonder how is string represent in R. if i have a string s= hello, how can i refer to first character in the string s? also if i have s1 = hello.1, s2 = ok.1, how can i separate the s1 into hello 1 and s2 into ok and 1? I have tried to use the substring function, but i don't where i can get the index for . in the string? Thank you so much C-Ming April 12, 2005 - [[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
[R] Re: how to separate a string
To get the first character from a string, use substr(s, 1, 1) To split strings at a period, use strsplit(s, \\.) (the period must be quoted, as . matches anything in a regular expression). To get the index for . in a string, see ?regexpr, but you will not need to do that if you use strsplit(). Cheers, Rich On 4/13/05, Cuichang Zhao [EMAIL PROTECTED] wrote: hello, i wonder how is string represent in R. if i have a string s= hello, how can i refer to first character in the string s? also if i have s1 = hello.1, s2 = ok.1, how can i separate the s1 into hello 1 and s2 into ok and 1? I have tried to use the substring function, but i don't where i can get the index for . in the string? Thank you so much C-Ming April 12, 2005 - [[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 -- Rich FitzJohn rich.fitzjohn at gmail.com |http://homepages.paradise.net.nz/richa183 You are in a maze of twisty little functions, all alike __ 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] [R-pkgs] New version of catspec package
I've uploaded a new version of catspec to CRAN. Catspec is for estimating certain special categorical models. It also contains ctab, a function for creating one-way, two-way, and multi-way percentage tables (nothing special there really). Ctab can now print more than one percentage type, as well as table marginals. The first special model in catspec is mclgen. Mclgen restructures a data frame so a multinomial logistic model can be estimated using a condition logit program. Doing so provides much more flexibility for imposing restrictions on the response variable. The second special (set of) models is sqtab, for estimating loglinear models for square tables (aka mobility models) such as symmetry, quasi-independence. One application can be to specify such models as multinomial logistic models with covariates, using mclgen. John Hendrickx ___ R-packages mailing list [EMAIL PROTECTED] https://stat.ethz.ch/mailman/listinfo/r-packages __ 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] Inf +1i vs 1+Inf*1i
Hi If I have a - Inf + 1i then Re(a) is Inf, and Im(a) is 1, as expected. But if b - 1 + Inf * 1i, then Im(b) = Inf , as expected, but Re(b) = NaN, which I didn't expect. Why this asymmetry? How to define an object with Re(b)=1, Im(b)=Inf? -- Robin Hankin Uncertainty Analyst Southampton Oceanography Centre European Way, Southampton SO14 3ZH, UK tel 023-8059-7743 __ 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] Inf +1i vs 1+Inf*1i
Robin, You could try b - complex(real=1, im=Inf) -- scar Manuel Rueda Palacio Viceintervencin Consejera de Hacienda Junta de Castilla y Len Tfno: 983414092 e-mail: [EMAIL PROTECTED] -- -Mensaje original- De: [EMAIL PROTECTED] [mailto:[EMAIL PROTECTED] nombre de Robin Hankin Enviado el: mircoles, 13 de abril de 2005 9:51 Para: R-help@stat.math.ethz.ch Asunto: [R] Inf +1i vs 1+Inf*1i Hi If I have a - Inf + 1i then Re(a) is Inf, and Im(a) is 1, as expected. But if b - 1 + Inf * 1i, then Im(b) = Inf , as expected, but Re(b) = NaN, which I didn't expect. Why this asymmetry? How to define an object with Re(b)=1, Im(b)=Inf? -- Robin Hankin Uncertainty Analyst Southampton Oceanography Centre European Way, Southampton SO14 3ZH, UK tel 023-8059-7743 __ 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] Combine univariate time series
Hallo everyone I have two univariate time series (class ts) describing the same variable. They have the same resolution, but span different periods in time with a big gap in between. I need to append one to the other such that they are one object, with the gap filled with NAs. The method ts.union produces a multivariate time series where the time axis is correct, but the individual time series are not combined into one. Thanks a lot for a reply, Jörg Dr. Jörg Klausen phone : +41 (0)44 823 41 27 EMPA (134)/GAW/QA-SAC fax : +41 (0)44 821 62 44 Überlandstrasse 129 mailto: [EMAIL PROTECTED] CH-8600 Dübendorf http://www.empa.ch/gaw Switzerlandhttp://www.empa.ch/gaw/gawsis [[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
Re: [R] Inf +1i vs 1+Inf*1i
Robin == Robin Hankin [EMAIL PROTECTED] on Wed, 13 Apr 2005 08:51:19 +0100 writes: Robin Hi Robin If I have Robin a - Inf + 1i Robin then Robin Re(a) is Inf, and Im(a) is 1, as expected. Robin But if Robin b - 1 + Inf * 1i, Robin then Robin Im(b) = Inf , as expected, but Re(b) = NaN, which I didn't expect. Robin Why this asymmetry? I think this is a (very long standing) buglet in our complex arithmetic, since you can directly see 1+ 1i*Inf [1] NaN+Infi Robin How to define an object with Re(b)=1, Im(b)=Inf? {Oscar already mentionedb - complex(real=1, im=Inf) } Martin Maechler, ETH Zurich __ 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] Inf +1i vs 1+Inf*1i
Actually, the problem comes from Inf * 1i (or 1i * Inf) and the 0 * Inf |- NaN which of course is `correct' in general, but a bit undesirable in the rule (a + bi) * (c + di) = (ac - bd) + (ad + bc)i {and similarly in complex division}. Note that the same problem also leads to 1 * complex(re=0, im=Inf) [1] NaN+Infi which is even more ugly, since '1 * z' really should return 'z' for all z. Martin BTW: S-plus (6.2.1) also returns NaN (printing NA. S+ has no complex versions of 'NaN') MM == Martin Maechler [EMAIL PROTECTED] on Wed, 13 Apr 2005 10:17:00 +0200 writes: Robin == Robin Hankin [EMAIL PROTECTED] on Wed, 13 Apr 2005 08:51:19 +0100 writes: Robin Hi Robin If I have Robin a - Inf + 1i Robin then Robin Re(a) is Inf, and Im(a) is 1, as expected. Robin But if Robin b - 1 + Inf * 1i, Robin then Robin Im(b) = Inf , as expected, but Re(b) = NaN, which I didn't expect. Robin Why this asymmetry? MM I think this is a (very long standing) buglet in our complex MM arithmetic, since you can directly see 1+ 1i*Inf MM [1] NaN+Infi Robin How to define an object with Re(b)=1, Im(b)=Inf? MM {Oscar already mentionedb - complex(real=1, im=Inf) } MM Martin Maechler, ETH Zurich MM __ MM R-help@stat.math.ethz.ch mailing list MM https://stat.ethz.ch/mailman/listinfo/r-help MM 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] range.bars in stl
Hi, In stlmethods(stats) says: range.bars logical indicating if each plot should have a bar at its right side which are of equal heights in user coordinates. I don't understand the meaning of: which are of equal heights in user coordinates I'm working with monthly time series, with a clear seasonal cycle, but a not so clear trend, is just what I'm looking for. How do I interprate the height of such bars? Thanks Antonio __ 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] glm: mustart, different default for quasi and quasipoisson
Hallo, for the quasipoisson family the default for mustart is y+ 0.1, for the quasi family with 'variance=mu' the default is y + 0.1 * (y == 0) I would like to know, whether the setting for quasipoisson is preferable for count data in relation to the quasi setting. regards Ulrich Ulrich Halekoh, PhD, Biometry Research Unit Danish Institute of Agricultural Sciences Research Centre Foulum, DK-8830 Tjele, Denmark _ platform i386-pc-mingw32 arch i386 os mingw32 system i386, mingw32 status major2 minor0.1 year 2004 month11 day 15 language R __ 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] Combine univariate time series
On Wed, 13 Apr 2005, Joerg Klausen wrote: I have two univariate time series (class ts) describing the same variable. They have the same resolution, but span different periods in time with a big gap in between. I need to append one to the other such that they are one object, with the gap filled with NAs. The method ts.union produces a multivariate time series where the time axis is correct, but the individual time series are not combined into one. Use window() to create an extended series, then indexing to insert the other in the correct place. E.g. x1 - ts(1:10, start=1900) x2 - ts(70:80, start=1970) xx - window(x1, end=1980, extend=TRUE) xx[71:81] - x2 -- 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] range.bars in stl
On Wed, 13 Apr 2005, antonio rodríguez wrote: In stlmethods(stats) says: For informatively, in the help for plot.stl: range.bars logical indicating if each plot should have a bar at its right side which are of equal heights in user coordinates. I don't understand the meaning of: which are of equal heights in user coordinates Plot it and see. The bars each cover say 100 units on the y axis. -- 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] range.bars in stl
El Miércoles, 13 de Abril de 2005 11:12, Prof Brian Ripley escribió: On Wed, 13 Apr 2005, antonio rodríguez wrote: In stlmethods(stats) says: For informatively, in the help for plot.stl: range.bars logical indicating if each plot should have a bar at its right side which are of equal heights in user coordinates. I don't understand the meaning of: which are of equal heights in user coordinates Plot it and see. The bars each cover say 100 units on the y axis. OK, I see it now. Thanks arv __ 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] Inf +1i vs 1+Inf*1i
On Apr 13, 2005, at 09:40 am, Martin Maechler wrote: Actually, the problem comes from Inf * 1i (or 1i * Inf) and the 0 * Inf |- NaN which of course is `correct' in general, but a bit undesirable in the rule (a + bi) * (c + di) = (ac - bd) + (ad + bc)i thanks for this Martin. Now I see what is going on, I wouldn't describe this as undesirable because (1+0i) * (0 + Inf i) depends on the behaviour of the infinite limit in the second bracket compared with the zero limit in the first. To wit, f() and g() both calculate 1*(Inf i): f - function(n){(1+1i/sqrt(n))*(0+n*1i)} g - function(n){(1+1i/n)*(0+sqrt(n)*1i)} f(1e8) [1] -1+1e+08i g(1e8) [1] -1e-04+1i So perhaps it's unreasonable to expect complex arithmetic to guess what I want. very best wishes rksh Robin Hankin Uncertainty Analyst Southampton Oceanography Centre European Way, Southampton SO14 3ZH, UK tel 023-8059-7743 __ 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] abstol in nnet
Hello All, I would like to know what fit criterion (abstol arg) is in nnet. Is it the threshold for the difference btw the max output and target values? Is the value at each iteration also the difference btw max of output and target values over all output units (case of multiple classes)? How could value displayed at each iteration be related to SSE and abstol be related to threshold SSE, respectively? Look forward to your reply Haleh __ 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] pstoedit
On 13-Apr-05 Prof Brian Ripley wrote: On Wed, 13 Apr 2005, BORGULYA [iso-8859-2] Gábor wrote: Has onyone experience with pstoedit (http://www.pstoedit.net/pstoedit) to convert eps graphs generated by R on Linux to Windows formats (WMF or EMF)? Does this way work? Is there an other, better way? You can only do that using pstoedit on Windows. ^^ Well, I have pstoedit on Linux and with pstoedit -f emf infile.eps outfile.emf I get what is claimed to be Enhanced Windows metafile and which can be imported into Word (though then it is subsequently somewhat resistant to editing operations, such as rotating if it's the wrong way up). On the other hand, pstoedit -f wmf infile.eps outfile.wmf which is supposed to produce a Windows metafile, produces something which Word resists importing. Best wishes to all, Ted. E-Mail: (Ted Harding) [EMAIL PROTECTED] Fax-to-email: +44 (0)870 094 0861 Date: 13-Apr-05 Time: 09:36:21 -- 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] A suggestion for predict function(s)
I must respectfully disagree. Why carry extra copies of data arround? This is probably OK for small to medium sized data, but definitely not for large data. Besides, in your example, it may do different things depending on whether newdata is supplied: model.matrix is not necessarily the same as the original data frame. You need a bit more work to get the right model.matrix that correspond to the newdata. It's not clear to me whether you want to return model matrix or model frame, but in either case it's not sufficient to just use `newdata'. Andy From: Ross Darnell Maybe a useful addition to the predict functions would be to return the values of the predictor variables. It just (unless there are problems) requires an extra line. I have inserted an example below. predict.glm - function (object, newdata = NULL, type = c(link, response, terms), se.fit = FALSE, dispersion = NULL, terms = NULL, na.action = na.pass, ...) { type - match.arg(type) na.act - object$na.action object$na.action - NULL if (!se.fit) { if (missing(newdata)) { pred - switch(type, link = object$linear.predictors, response = object$fitted, terms = predict.lm(object, se.fit = se.fit, scale = 1, type = terms, terms = terms)) if (!is.null(na.act)) pred - napredict(na.act, pred) } else { pred - predict.lm(object, newdata, se.fit, scale = 1, type = ifelse(type == link, response, type), terms = terms, na.action = na.action) switch(type, response = { pred - family(object)$linkinv(pred) }, link = , terms = ) } } else { if (inherits(object, survreg)) dispersion - 1 if (is.null(dispersion) || dispersion == 0) dispersion - summary(object, dispersion = dispersion)$dispersion residual.scale - as.vector(sqrt(dispersion)) pred - predict.lm(object, newdata, se.fit, scale = residual.scale, type = ifelse(type == link, response, type), terms = terms, na.action = na.action) fit - pred$fit se.fit - pred$se.fit switch(type, response = { se.fit - se.fit * abs(family(object)$mu.eta(fit)) fit - family(object)$linkinv(fit) }, link = , terms = ) if (missing(newdata) !is.null(na.act)) { fit - napredict(na.act, fit) se.fit - napredict(na.act, se.fit) } predictors - if (missing(newdata)) model.matrix(object) else newdata pred - list(predictors=predictors, fit = fit, se.fit = se.fit, residual.scale = residual.scale) } pred #__ end of R code Ross Darnell -- School of Health and Rehabilitation Sciences University of Queensland, Brisbane QLD 4072 AUSTRALIA Email: [EMAIL PROTECTED] Phone: +61 7 3365 6087 Fax: +61 7 3365 4754 Room:822, Therapies Bldg. http://www.shrs.uq.edu.au/shrs/school_staff/ross_darnell.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-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] R as programming language: references?
Jan T. Kim [EMAIL PROTECTED] writes: I don't know what Federico Calboli has in mind, but as for myself, upon starting with R, I've been looking for an R language reference in the style of the Python reference (http://docs.python.org/ref/ref.html). The specification of the grammar and the associated semantics of a language gives me the kind of in-depth conceptual understanding that I like to have, and I find this more difficult to accrue for R than for other languages. For example, I'm still not certain whether I'm able to correctly predict how many copies of an object are created during the execution of some code, and consequently, I'm not really confident that my code is reasonably optimal. I'd appreciate pointers to any (more or less hidden) gems I may have overlooked, of course. The R language definition manual is pretty much of that variety. It has the parser specification at the end rather than at the beginning, but otherwise it is quite similar in structure to the Python one. The document has developed at glacial speed for several years. It probably could do with some restructuring and rewriting (by whom?), but you also have to be aware that some aspects of R, notably computing on the language, creates interdependences in the specification that are not present in other languages. I.e., the parsing section needs to talk about parse trees and their representation as R objects, hence it is useful to have discussed the structure of an R object first. -- O__ Peter Dalgaard Blegdamsvej 3 c/ /'_ --- Dept. of Biostatistics 2200 Cph. N (*) \(*) -- University of Copenhagen Denmark Ph: (+45) 35327918 ~~ - ([EMAIL PROTECTED]) FAX: (+45) 35327907 __ 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] How to plot Contour with NA in dataframe
Dear friends, I am trying to produce Contour Plot with R, but there are some NA in my data matrix. After I ran the following R script, I got the error message:no proper `z' matrix specified. Does anybody know how to plot contour chart with R for the non-strict matrix? Thank you in advance!!! myData-read.table('C:/MyDoc/TestData.txt',sep=',') x - 10*1:nrow(myData) y - 10*1:ncol(myData) filled.contour(x, y, myData, color = terrain.colors, plot.title = title(main = The Topography of Maunga Whau, xlab = Meters North, ylab = Meters West), plot.axes = { axis(1, seq(100, 800, by = 100)) axis(2, seq(100, 600, by = 100)) }, key.title = title(main=Height\n(meters)), key.axes = axis(4, seq(4, 8, by = 1))) C:/myDoc/TestData.txt is shown as below: 4.95,,5.6250,5.6667,5.90,5.80,5.50,5.70,5.0250,5.90,5.7250,5.75,5.70,5.30,,6,5.50,5.65,,5.7750,5.70,4.90,6.05,,5.4750,5.85,5.55,,,5.8250,5.65,5.75,,5.5750,5.4750,5.3750,5.8750,5.9250,5.55,6.3750,5.70,5.7833,,5.55, ,5.5250,4.856.15,5.8667,,5.20,5.5750,5.74,5.7667,6.7333,6.05,5.8833,5.80,5.8750,,6.15,,5.6250,5.5375,5.65,6,5.8250,5.55,5.85,5.65,5.89,6.15,5.60,,5.65,5.7250,,5.25,6.25,,5.5667,5.9750,6.0250,,,6.35 5.45,,6.30,5.7167,,5.50,6.05,5.8333,5.5833,5.6250,5.70,5.9250,5.7750,6.20,5.5333,5.6625,5.40,5.75,,6,5.5333,,5.6250,5.55,5.65,5.55,5.70,,6.15,5.90,5.7167,6.1167,5.15,6.10,5.4750,,5.75,5.45,5.95,,5.95,5.36676.15,,, ,5.7250,5.75,6,,,5.65,,6.30,5.65,,5.4750,5.60,5.4167,5.8250,,,6.25,6.30,,5.60,6.15,6.10,5.85,,5.8750,5.65,5.9750,5.80,5.65,5.90,6.15,5.5667,5.75,,,6,5.85,5.75,5.7250,5.75 5.75,,6.1167,,5.3250,,5.9167,5.55,,6.05,5.70,5.7250,5.50,6.15,5.40,5.40,5.40,5.70,5.4250,5.7250,5.45,,,5.85,5.85,5.7750,5.8750,5.25,5.45,5.75,5.70,5.65,5.4750,5.7250,5.70,6.10,6.05,5.6875,5.60,,5.80,,,5.65, 5.6250,6.25,5.60,5.90,6.0750,5.80,5.45,5.60,5.50,5.7375,5.60,6,5.9667,5.6833,5.90,5.8333,5.6750,,5.6750,5.7250,5.6833,5.6333,5.65,6.05,,5.57,5.75,5.2750,5.50,,5.6750,5.85,5.6750,6.35,,5.35, ,5.20,,5.5833,5.8333,5.9250,5.7750,5.6667,5.85,5.95,,6.35,5.55,5.3750,,6.30,5.15,5.40,5.55,,5.75,5.45,6.60,,5.45,5.25,,5.25,5.80,5.45,4.80,,5.4250,5.7750,5.15,5.55,5.35,,5.85,5.7667,,,5.60,, ,,,5.15,,6.05,5.4333,5.70,,5.75,6.05,5.15,5.75,5.60,,6.1750,,6.055.5625,5.4167,,5.6250,5.50,5.90,5.95,5.90,6.0250,5.9667,6,5.70,6,5.90,6,5.55,5.8167,5.7750,5.30,,5.77505.40,,, ,6.0667,5.45,5.60,5.55,5.95,5.8750,5.8750,5.80,5.91675.85,5.75,5.5167,,5.8750,,5.45,6.0250,,5.80,5.9375,5.7750,5.5167,,5.8750,5.60,5.8625,5.6333,,5.50,5.2625,5.65,,5.30,5.35,,5.7250,,5.8333,5.85,5.70,,5.30,,, 5.7750,6,5.55,,5.45,5.4125,5.9917,5.50,5.65,5.9750,,,5.7667,5.8333,5.79,5.85,,5.90,5.9833,6.05,,6.3250,6.0750,,5.25,5.85,6.20,,5.45,,,5.65,5.7250,5.9250,6.50,5.35,5.95,,5.8833,5.80,5.95,5.60,5.75,,5.90,6.45,,, 5.6833,5.60,,5.55,5.1250,,6.05,5.75,5.75,5.6833,6,5.55,6.15,5.45,5.70,6.1250,5.67,5.75,5.55,5.35,5.55,5.9750,5.80,5.60,5.9125,5.9375,5.25,5.85,5.4375,6.10,5.55,,,5.6167,5.6167,5.25,6.25,6.1750,5.85,5.5375,5.8250,6.036.10,,, 5.95,5.4667,6.45,5.7375,,5.55,5.6667,5.70,,5.7750,5.50,5.65,5.90,5.8750,5.9750,6,5.6750,,5.8167,,5.50,5.4250,5.65,6,6.1250,5.25,5.90,5.6875,5.6250,,6.2750,6.15,5.7750,5.9250,5.20,5.57,5.92,,5.35,,5.45,5.40,,, 5.65,4.95,5.70,,5.9167,5.3750,5.3750,5.45,5.6167,6.0250,5.8750,5.55,5.85,6.2833,5.9125,5.55,7.85,5.50,6,,5.53,5.35,5.8250,5.75,5.90,5.7167,5.70,5.90,5.4250,5.4750,5.9333,5.95,5.9750,5.45,5.5333,6.2167,5.20,5.10,,5.37,5.7250,5.5167,,, 5.7667,5.65,5.95,,5.95,5.10,5.60,5.70,5.80,5.5625,6.10,5.45,5.5250,,5.6375,6.20,,5.60,5.3750,,5.95,5.5250,5.35,5.70,5.4250,5.75,5.0750,5.60,5.7833,5.50,5.4250,5.85,6.05,5.05,5.7750,,6.20,6.40,5.35,5.6250,5.65,5.755.50,,4.80, 5.9250,5.15,6.0250,5.15,5.40,,6,,,5.8750,,6.10,,5.6750,5.8750,,6.15,6.30,5.80,5.9667,5.95,5.90,5.50,5.8167,5.60,6.0750,5.10,4.95,5.95,5.35,,5.70,6.05,5.7750,5.7250,5.35,5.8250,5.55,5.7667,7.65,5.75,5.8250,,,5.40
Re: [R] pstoedit
On Wed, 13 Apr 2005 [EMAIL PROTECTED] wrote: On 13-Apr-05 Prof Brian Ripley wrote: On Wed, 13 Apr 2005, BORGULYA [iso-8859-2] Gábor wrote: Has onyone experience with pstoedit (http://www.pstoedit.net/pstoedit) to convert eps graphs generated by R on Linux to Windows formats (WMF or EMF)? Does this way work? Is there an other, better way? You can only do that using pstoedit on Windows. ^^ Well, I have pstoedit on Linux and with pstoedit -f emf infile.eps outfile.emf I get what is claimed to be Enhanced Windows metafile and which can be imported into Word (though then it is subsequently somewhat resistant to editing operations, such as rotating if it's the wrong way up). Maybe, but the URL quoted says pstoedit 3.40 # Windows Meta Files (WMF) (Windows 9x/NT only) # Enhanced Windows Meta Files (EMF) (Windows 9x/NT only) so the quoted URL claims otherwise for the current version. -- 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] How to plot Contour with NA in dataframe
[EMAIL PROTECTED] wrote: Dear friends, I am trying to produce Contour Plot with R, but there are some NA in my data matrix. After I ran the following R script, I got the error message:no proper `z' matrix specified. Does anybody know how to plot contour chart with R for the non-strict matrix? Thank you in advance!!! myData-read.table('C:/MyDoc/TestData.txt',sep=',') x - 10*1:nrow(myData) y - 10*1:ncol(myData) filled.contour(x, y, myData, color = terrain.colors, plot.title = title(main = The Topography of Maunga Whau, xlab = Meters North, ylab = Meters West), plot.axes = { axis(1, seq(100, 800, by = 100)) axis(2, seq(100, 600, by = 100)) }, key.title = title(main=Height\n(meters)), key.axes = axis(4, seq(4, 8, by = 1))) C:/myDoc/TestData.txt is shown as below: 4.95,,5.6250,5.6667,5.90,5.80,5.50,5.70,5.0250,5.90,5.7250,5.75,5.70,5.30,,6,5.50,5.65,,5.7750,5.70,4.90,6.05,,5.4750,5.85,5.55,,,5.8250,5.65,5.75,,5.5750,5.4750,5.3750,5.8750,5.9250,5.55,6.3750,5.70,5.7833,,5.55, ,5.5250,4.856.15,5.8667,,5.20,5.5750,5.74,5.7667,6.7333,6.05,5.8833,5.80,5.8750,,6.15,,5.6250,5.5375,5.65,6,5.8250,5.55,5.85,5.65,5.89,6.15,5.60,,5.65,5.7250,,5.25,6.25,,5.5667,5.9750,6.0250,,,6.35 5.45,,6.30,5.7167,,5.50,6.05,5.8333,5.5833,5.6250,5.70,5.9250,5.7750,6.20,5.5333,5.6625,5.40,5.75,,6,5.5333,,5.6250,5.55,5.65,5.55,5.70,,6.15,5.90,5.7167,6.1167,5.15,6.10,5.4750,,5.75,5.45,5.95,,5.95,5.36676.15,,, ,5.7250,5.75,6,,,5.65,,6.30,5.65,,5.4750,5.60,5.4167,5.8250,,,6.25,6.30,,5.60,6.15,6.10,5.85,,5.8750,5.65,5.9750,5.80,5.65,5.90,6.15,5.5667,5.75,,,6,5.85,5.75,5.7250,5.75 5.75,,6.1167,,5.3250,,5.9167,5.55,,6.05,5.70,5.7250,5.50,6.15,5.40,5.40,5.40,5.70,5.4250,5.7250,5.45,,,5.85,5.85,5.7750,5.8750,5.25,5.45,5.75,5.70,5.65,5.4750,5.7250,5.70,6.10,6.05,5.6875,5.60,,5.80,,,5.65, 5.6250,6.25,5.60,5.90,6.0750,5.80,5.45,5.60,5.50,5.7375,5.60,6,5.9667,5.6833,5.90,5.8333,5.6750,,5.6750,5.7250,5.6833,5.6333,5.65,6.05,,5.57,5.75,5.2750,5.50,,5.6750,5.85,5.6750,6.35,,5.35, ,5.20,,5.5833,5.8333,5.9250,5.7750,5.6667,5.85,5.95,,6.35,5.55,5.3750,,6.30,5.15,5.40,5.55,,5.75,5.45,6.60,,5.45,5.25,,5.25,5.80,5.45,4.80,,5.4250,5.7750,5.15,5.55,5.35,,5.85,5.7667,,,5.60,, ,,,5.15,,6.05,5.4333,5.70,,5.75,6.05,5.15,5.75,5.60,,6.1750,,6.055.5625,5.4167,,5.6250,5.50,5.90,5.95,5.90,6.0250,5.9667,6,5.70,6,5.90,6,5.55,5.8167,5.7750,5.30,,5.77505.40,,, ,6.0667,5.45,5.60,5.55,5.95,5.8750,5.8750,5.80,5.91675.85,5.75,5.5167,,5.8750,,5.45,6.0250,,5.80,5.9375,5.7750,5.5167,,5.8750,5.60,5.8625,5.6333,,5.50,5.2625,5.65,,5.30,5.35,,5.7250,,5.8333,5.85,5.70,,5.30,,, 5.7750,6,5.55,,5.45,5.4125,5.9917,5.50,5.65,5.9750,,,5.7667,5.8333,5.79,5.85,,5.90,5.9833,6.05,,6.3250,6.0750,,5.25,5.85,6.20,,5.45,,,5.65,5.7250,5.9250,6.50,5.35,5.95,,5.8833,5.80,5.95,5.60,5.75,,5.90,6.45,,, 5.6833,5.60,,5.55,5.1250,,6.05,5.75,5.75,5.6833,6,5.55,6.15,5.45,5.70,6.1250,5.67,5.75,5.55,5.35,5.55,5.9750,5.80,5.60,5.9125,5.9375,5.25,5.85,5.4375,6.10,5.55,,,5.6167,5.6167,5.25,6.25,6.1750,5.85,5.5375,5.8250,6.036.10,,, 5.95,5.4667,6.45,5.7375,,5.55,5.6667,5.70,,5.7750,5.50,5.65,5.90,5.8750,5.9750,6,5.6750,,5.8167,,5.50,5.4250,5.65,6,6.1250,5.25,5.90,5.6875,5.6250,,6.2750,6.15,5.7750,5.9250,5.20,5.57,5.92,,5.35,,5.45,5.40,,, 5.65,4.95,5.70,,5.9167,5.3750,5.3750,5.45,5.6167,6.0250,5.8750,5.55,5.85,6.2833,5.9125,5.55,7.85,5.50,6,,5.53,5.35,5.8250,5.75,5.90,5.7167,5.70,5.90,5.4250,5.4750,5.9333,5.95,5.9750,5.45,5.5333,6.2167,5.20,5.10,,5.37,5.7250,5.5167,,, 5.7667,5.65,5.95,,5.95,5.10,5.60,5.70,5.80,5.5625,6.10,5.45,5.5250,,5.6375,6.20,,5.60,5.3750,,5.95,5.5250,5.35,5.70,5.4250,5.75,5.0750,5.60,5.7833,5.50,5.4250,5.85,6.05,5.05,5.7750,,6.20,6.40,5.35,5.6250,5.65,5.755.50,,4.80, 5.9250,5.15,6.0250,5.15,5.40,,6,,,5.8750,,6.10,,5.6750,5.8750,,6.15,6.30,5.80,5.9667,5.95,5.90,5.50,5.8167,5.60,6.0750,5.10,4.95,5.95,5.35,,5.70,6.05,5.7750,5.7250,5.35,5.8250,5.55,5.7667,7.65,5.75,5.8250,,,5.40
Re: [R] Combine univariate time series
On 4/13/05, Joerg Klausen [EMAIL PROTECTED] wrote: Hallo everyone I have two univariate time series (class ts) describing the same variable. They have the same resolution, but span different periods in time with a big gap in between. I need to append one to the other such that they are one object, with the gap filled with NAs. The method ts.union produces a multivariate time series where the time axis is correct, but the individual time series are not combined into one. If ts1 and ts2 are two ts series: both - ts.union(ts1, ts2) pmax(both[,1], both[,2], na.rm = TRUE) __ 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] pstoedit
On 4/13/05, Prof Brian Ripley [EMAIL PROTECTED] wrote: On Wed, 13 Apr 2005 [EMAIL PROTECTED] wrote: On 13-Apr-05 Prof Brian Ripley wrote: On Wed, 13 Apr 2005, BORGULYA [iso-8859-2] Gábor wrote: Has onyone experience with pstoedit (http://www.pstoedit.net/pstoedit) to convert eps graphs generated by R on Linux to Windows formats (WMF or EMF)? Does this way work? Is there an other, better way? You can only do that using pstoedit on Windows. ^^ Well, I have pstoedit on Linux and with pstoedit -f emf infile.eps outfile.emf I get what is claimed to be Enhanced Windows metafile and which can be imported into Word (though then it is subsequently somewhat resistant to editing operations, such as rotating if it's the wrong way up). Maybe, but the URL quoted says pstoedit 3.40 # Windows Meta Files (WMF) (Windows 9x/NT only) # Enhanced Windows Meta Files (EMF) (Windows 9x/NT only) so the quoted URL claims otherwise for the current version. If you follow the link for exact support, you find out that it supports EMF using a wemf - Wogls version of EMF wemfc - Wogls version of EMF with experimental clip support wemfnss - Wogls version of EMF - no subpathes which is apparently different than the MS Windows EMF support. How, it isn't clear from the documentation. best, -tony Commit early,commit often, and commit in a repository from which we can easily roll-back your mistakes (AJR, 4Jan05). A.J. Rossini [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] functions(t.test) on variables by groups
Hai Lin [EMAIL PROTECTED] writes: Dear R users, I have a data frame with categorical Vars. Groups and a couple columns of numeric Vars. I am trying to make two-sample t.test on each variable(s01-s03) by Groups. A data generated as following: zot - data.frame(Groups=rep(letters[1:2], each=4), s01=rnorm(8), s02=rnorm(8), s03=rnorm(8)) I have written a piece with a for loop. for (i in 1:(length(zot)-1)) { print(t.test(zot[,i+1]~zot[,1])) } I wish something can be easier extracted or can save it within for loop, or not even using for loop. Something like this? lapply(zot[-1],function(x)t.test(x~zot$Groups)) -- O__ Peter Dalgaard Blegdamsvej 3 c/ /'_ --- Dept. of Biostatistics 2200 Cph. N (*) \(*) -- University of Copenhagen Denmark Ph: (+45) 35327918 ~~ - ([EMAIL PROTECTED]) FAX: (+45) 35327907 __ 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] easy question: obtaining rw1080.exe
Dear All, Can anyone please tell me where I can obtain uncompiled binary instalation files for R version 1.8. (i.e. rw1080.exe)? I can only find the uncompiled source code on CRAN today. Thank you, Mary Wisz [EMAIL PROTECTED] [[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
Re: [R] pstoedit
On 13-Apr-05 Prof Brian Ripley wrote: On Wed, 13 Apr 2005 [EMAIL PROTECTED] wrote: On 13-Apr-05 Prof Brian Ripley wrote: On Wed, 13 Apr 2005, BORGULYA [iso-8859-2] Gábor wrote: Has onyone experience with pstoedit (http://www.pstoedit.net/pstoedit) to convert eps graphs generated by R on Linux to Windows formats (WMF or EMF)? Does this way work? Is there an other, better way? You can only do that using pstoedit on Windows. ^^ Well, I have pstoedit on Linux and with pstoedit -f emf infile.eps outfile.emf I get what is claimed to be Enhanced Windows metafile and which can be imported into Word (though then it is subsequently somewhat resistant to editing operations, such as rotating if it's the wrong way up). Maybe, but the URL quoted says pstoedit 3.40 # Windows Meta Files (WMF) (Windows 9x/NT only) # Enhanced Windows Meta Files (EMF) (Windows 9x/NT only) so the quoted URL claims otherwise for the current version. Indeed, on the face of it. My version is 3.33 (the predecessor of 3.4), and it does produce both WMF and EMF files (even if Windows does not like the WMF files, though able to accept the EMF files). However, if from that site (above) you go to the changelog you can read, under Version 3.40 (changed from 3.33): # disabled the WMF driver when libemf is used (all non-Windows systems). Libemf does not really handle WMF files. A CreateMetaFile effectively creates an EnhMetaFile - but that confuses programs which expect an real WMF file in a file with a .wmf suffix. # added a workaround in the EMF driver for a bug/problem in the libemf which is used under *nix for EMF generation. The problem in libemf is that if text is rendered using the simple TextOut function call the resulting EMF file is no longer usable under newer versions of Windows. For more details see the description of the -nfw option of the wmf format driver. This suggests that while WMF has been disabled for pstoedit on non-Windows systems, the EMF driver should still work. However, having only 3.33 at the moment I can't test the above. However, for others interested it may be worth a try. (The first # also contains a possible explanation why the .wmf file I made with the WMF driver wasn't read by Windows: if it's really an EMF files carrying a .wmf filename extension, and the .wmf leads Windows to expect WMF content rather than the EMF content it really has, then this could happen; but it didn't like it either when explicitly asked to import it as an EMF, nor when the extension was changed to .emf) Best wishes, Ted. E-Mail: (Ted Harding) [EMAIL PROTECTED] Fax-to-email: +44 (0)870 094 0861 Date: 13-Apr-05 Time: 13:44:13 -- 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
[R] install.packages and MacOS 10.3.8
Dear Listers, I am trying to install packages via install.packages() from MacOS 10.3.8. Installing work fine when run from the menu, but the following command (useful for setting up each computer of the student computer room) leads nowhere for some reasons: pack-c(ade4,adehabitat,geoR,gstat,KernSmooth,lattice,leaps) install.packages(pack,dependencies=T) trying URL `http://cran.r-project.org/src/contrib/PACKAGES' Content type `text/plain; charset=iso-8859-1' length 51500 bytes opened URL == downloaded 50Kb also installing the dependencies 'SparseM', 'gee', 'waveslim', 'splancs', 'maptools', 'spdep', 'pixmap', 'ape', 'tripack' trying URL `http://cran.r-project.org/src/contrib/SparseM_0.60.tar.gz' Content type `application/x-tar' length 1064262 bytes opened URL == downloaded 1039Kb trying URL `http://cran.r-project.org/src/contrib/gee_4.13-10.tar.gz' Content type `application/x-tar' length 49586 bytes opened URL == downloaded 48Kb trying URL `http://cran.r-project.org/src/contrib/waveslim_1.4.tar.gz' Content type `application/x-tar' length 358305 bytes opened URL == (etc) * Installing *source* package 'SparseM' ... ** libs /Library/Frameworks/R.framework/Resources/bin/SHLIB: line 1: make: command not found ERROR: compilation failed for package 'SparseM' * Installing *source* package 'gee' ... ** libs /Library/Frameworks/R.framework/Resources/bin/SHLIB: line 1: make: command not found ERROR: compilation failed for package 'gee' etc... Can anybody tell me what goes wrong with this command (which usually work without any problem with R 2.0.1 and Windows XP). Thanks in advance, 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
Re: [R] easy question: obtaining rw1080.exe
Wisz, Mary Susanne wrote: Dear All, Can anyone please tell me where I can obtain uncompiled binary You mean compiled, for sure. instalation files for R version 1.8. (i.e. rw1080.exe)? Why do you want an outdated version of R? Binaries are not archived on CRAN. You can either try to compile yourself or send me a private message - I could put that OUTDATED binary up on our web server for you. Uwe I can only find the uncompiled source code on CRAN today. Thank you, Mary Wisz [EMAIL PROTECTED] [[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 __ 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] install.packages and MacOS 10.3.8
Patrick Giraudoux wrote: Dear Listers, I am trying to install packages via install.packages() from MacOS 10.3.8. Installing work fine when run from the menu, but the following command (useful for setting up each computer of the student computer room) leads nowhere for some reasons: pack-c(ade4,adehabitat,geoR,gstat,KernSmooth,lattice,leaps) install.packages(pack,dependencies=T) trying URL `http://cran.r-project.org/src/contrib/PACKAGES' Content type `text/plain; charset=iso-8859-1' length 51500 bytes opened URL == downloaded 50Kb also installing the dependencies 'SparseM', 'gee', 'waveslim', 'splancs', 'maptools', 'spdep', 'pixmap', 'ape', 'tripack' trying URL `http://cran.r-project.org/src/contrib/SparseM_0.60.tar.gz' [SNIP] * Installing *source* package 'SparseM' ... ** libs /Library/Frameworks/R.framework/Resources/bin/SHLIB: line 1: make: command not found ERROR: compilation failed for package 'SparseM' * Installing *source* package 'gee' ... ** libs /Library/Frameworks/R.framework/Resources/bin/SHLIB: line 1: make: command not found ERROR: compilation failed for package 'gee' etc... Can anybody tell me what goes wrong with this command (which usually work without any problem with R 2.0.1 and Windows XP). So at least make and probably much more is missing on your machines (or not in your path or whatever). You might want to try install.binaries() instead (which is similar to install.packages() on Windows, since it installs binary packages rather than trying to compile and install source packages) - or set up your machines with the required set of tools. Uwe Ligges Thanks in advance, 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! http://www.R-project.org/posting-guide.html
[R] R binaries for UMBUTU Linux?
Has anyone out there compiled R for the Umbutu Linux* (neé Debian) v. 5.04 distribution for Intel-type platforms (32 and 64 bit) ? Thank you, Derek Eder * Umbutu, a popular new Linux distribution, not a Nigerian scam, I promise!http://www.ubuntulinux.org/ -- Derek Eder SDS KLINIKEN Vasaplatsen 8 SE 411 34 Göteborg (Gothenburg) Sweden phone: +46 (31)* - 10 77 80 fax: +46 (31)* - 10 77 81 mobile: +46 (31)* 0709 721 283 * note: (031) within Sweden webpage: www.sdskliniken.se www.neuro.gu.se/sad __ 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] easy question: obtaining rw1080.exe
From: Uwe Ligges Wisz, Mary Susanne wrote: Dear All, Can anyone please tell me where I can obtain uncompiled binary You mean compiled, for sure. instalation files for R version 1.8. (i.e. rw1080.exe)? Why do you want an outdated version of R? Binaries are not archived on CRAN. You can either try to compile yourself or send me a private message - I could put that OUTDATED binary up on our web server for you. Just googling for `rw1080.exe' turns up: http://mcs.une.edu.au/~nkn/resource/ which has http://mcs.une.edu.au/~nkn/resource/rw1080.exe Andy Uwe I can only find the uncompiled source code on CRAN today. Thank you, Mary Wisz [EMAIL PROTECTED] [[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 __ 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] R binaries for Ubuntu (!) Linux?
When I set up an old weak PC to become a real workstation at home, by installing Ubuntu (spelling!), I was able to quickly get many debian packages that were not part of ubuntu proper (including R-base-dev, ess) by outcommenting something like universe (forgot the exact name) in the /etc/apt/sources.list file, and then simply something like apt-get install r-base-dev apt-get install r-recommended apt-get install r-doc-info apt-get install ess Martin Maechler, ETH Zurich Derek == Derek Eder [EMAIL PROTECTED] on Wed, 13 Apr 2005 15:19:19 +0200 writes: Derek Has anyone out there compiled R for the Umbutu Linux* (neé Debian) v. Derek 5.04 distribution for Intel-type platforms (32 and 64 bit) ? Derek Thank you, Derek Derek Eder Derek * Umbutu, a popular new Linux distribution, not a Nigerian scam, I Derek promise!http://www.ubuntulinux.org/ Please fix the spelling, it's ubuntu -- how do you manage to achieve two typos in one word ?! __ 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] R binaries for UMBUTU Linux?
Derek Eder wrote: Has anyone out there compiled R for the Umbutu Linux* (neé Debian) v. 5.04 distribution for Intel-type platforms (32 and 64 bit) ? * Umbutu, a popular new Linux distribution, not a Nigerian scam, I promise!http://www.ubuntulinux.org/ That's 'Ubuntu'. If you run the package manager (synaptic) and set up your repository settings to include 'universe' then you should see a bunch of R-related stuff in the 'Mathematics (universe)' section, for R 2.0.1. You should then be only a few clicks away from an R install. If you need any help setting up the Ubuntu package manager in this way, best to ask on an Ubuntu discussion list. Baz __ 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] R binaries for UMBUTU Linux?
Derek Eder [EMAIL PROTECTED] writes: Has anyone out there compiled R for the Umbutu Linux* (neé Debian) v. 5.04 distribution for Intel-type platforms (32 and 64 bit) ? Thank you, Derek Eder Er, U*bun*tu, you mean? I believe you just use the standard Debian packages and tools like apt-get to install them. Have a look at http://tolstoy.newcastle.edu.au/R/help/05/02/11878.html (which shows that Dirk cannot spell it either...) and related messages in that thread. -- O__ Peter Dalgaard Blegdamsvej 3 c/ /'_ --- Dept. of Biostatistics 2200 Cph. N (*) \(*) -- University of Copenhagen Denmark Ph: (+45) 35327918 ~~ - ([EMAIL PROTECTED]) FAX: (+45) 35327907 __ 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] R binaries for UMBUTU Linux?
On Wed, 2005-04-13 at 15:19 +0200, Derek Eder wrote: Has anyone out there compiled R for the Umbutu Linux* (neé Debian) v. 5.04 distribution for Intel-type platforms (32 and 64 bit) ? Thank you, Derek Eder * Umbutu, a popular new Linux distribution, not a Nigerian scam, I promise!http://www.ubuntulinux.org/ Well, if you mean Ubuntu (and Debian is still there: she's not married to Ubuntu but kept her name), I have some experience (though not on Intel -- later about that). First, it seems that R is not in standard Ubuntu base, but you can find it in the universe, and install as a binary. However, the rhythms are a bit off. Previous Ubuntu release was about simultaneously with the R-2.0.x release, and you got R-1.9.1 in Ubuntu. The current release of Ubuntu was last week, and R is up to next week. This means that you're lagging behind by one cycle in R with these predictable and regular release cycles. However, Ubuntu is a Linux which means that you can compile R from the sources quite easily. I did this with Ubuntu 4.04, and compilation went smoothly (like usually). However, I did this in ppc (32bit, or G4), and some tests failed (at least in 'foreign': I haven't studied this in more detail). The base R seems to work OK, though. Alternatively, you can use real Debian packages from its testing repository. Ubuntu does not recommend using native Debian packages, but I guess with R you can do this fairly safely (the general problem is a potential conflict in version naming which may lead to conflicts in upgrades, but I think this is OK with R). So you may get the latest Debian (testing) packages -- as soon as they get through the jungle of dependencies and appear in Debian. cheers, jari oksanen -- Jari Oksanen -- Dept Biology, Univ Oulu, 90014 Oulu, Finland __ 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] Binary Matrices
I'm wanting to perform analysis (e.g. using eigen()) of binary matrices - i.e. matrices comprising 0s and 1s. For example: n-1000 test.mat-matrix(round(runif(n^2)),n,n) eigen(test.mat,only.values=T) Is there a more efficient way of setting up test.mat, as each cell only requires a binary digit? I imagine R is setting up a structure which could contain n^2 floats. Thanks in advance for any help. Regards, Mark This message has been checked for viruses but the contents of an attachment may still contain software viruses, which could damage your computer system: you are advised to perform your own checks. Email communications with the University of Nottingham may be monitored as permitted by UK legislation. __ 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] questions about discriminant analysis
i konw the lda and qda in MASS can do discriminant analysis.and lda complete the Fisher's method.and qda is the Quadratic discriminant analysis. 1,my first question is if qda do the Mahalanobis's method? 2,as some textbook say,when using fisher's method,we proceed by assuming that the within-group covariance structure for our data is the same across groups,so we need test for equailty of covariance matrices. my question is :when i using lda,should i test equailty of covariance matrices first? and can R do these? thank you ! __ 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] Binary Matrices
Mark Edmondson-Jones wrote: I'm wanting to perform analysis (e.g. using eigen()) of binary matrices - i.e. matrices comprising 0s and 1s. For example: n-1000 test.mat-matrix(round(runif(n^2)),n,n) eigen(test.mat,only.values=T) Is there a more efficient way of setting up test.mat, as each cell only requires a binary digit? I imagine R is setting up a structure which could contain n^2 floats. No. In principle you could use logicals, but that does not help for further calculations in eigen(). Uwe Ligges Thanks in advance for any help. Regards, Mark This message has been checked for viruses but the contents of an attachment may still contain software viruses, which could damage your computer system: you are advised to perform your own checks. Email communications with the University of Nottingham may be monitored as permitted by UK legislation. __ 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] Binary Matrices
you mean something like this: matrix(sample(0:1, n*n, TRUE), n, n) I hope it helps. Best, Dimitris Dimitris Rizopoulos Ph.D. Student Biostatistical Centre School of Public Health Catholic University of Leuven Address: Kapucijnenvoer 35, Leuven, Belgium Tel: +32/16/336899 Fax: +32/16/337015 Web: http://www.med.kuleuven.ac.be/biostat/ http://www.student.kuleuven.ac.be/~m0390867/dimitris.htm - Original Message - From: Mark Edmondson-Jones [EMAIL PROTECTED] To: r-help@stat.math.ethz.ch Sent: Wednesday, April 13, 2005 3:50 PM Subject: [R] Binary Matrices I'm wanting to perform analysis (e.g. using eigen()) of binary matrices - i.e. matrices comprising 0s and 1s. For example: n-1000 test.mat-matrix(round(runif(n^2)),n,n) eigen(test.mat,only.values=T) Is there a more efficient way of setting up test.mat, as each cell only requires a binary digit? I imagine R is setting up a structure which could contain n^2 floats. Thanks in advance for any help. Regards, Mark This message has been checked for viruses but the contents of an attachment may still contain software viruses, which could damage your computer system: you are advised to perform your own checks. Email communications with the University of Nottingham may be monitored as permitted by UK legislation. __ 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] Data Mining in Europe, please advise
Our CEO, Dr. Dan Steinberg, is planning to visit Europe in May. He would like the opportunity to introduce statisticians (and statistically minded people) to data mining, data mining applications and to forefront data mining tools. Our algorithms are probably familiar to many statisticians (CART, MARS, MART, TreeNet and RandomForests), although it isn't necessary to be a statistician to use our tools. We co-develop with Jerome Friedman of Stanford University and Leo Breiman of Berkeley. I am trying to locate people/companies who would benefit from data mining. If you know of any, I would appreciate it if you would let me know. Below is a list of presentations from our recent conferences. This will give you a sense of our customers and how they currently use our tools. Please contact me directly if you would like for me to arrange an onsite meeting with Dr. Steinberg. In a meeting, he could demo our tools.even on your data. And if any of the presentations (listed below) interest you, please let me know. Sincerely, Lisa Solomon [EMAIL PROTECTED] mailto:[EMAIL PROTECTED]:%20%5BR%5D%20please%20advise%20re:%20data%20mining%20in%20Germany 001-619-543-8880 x109 PRESENTATION TITLES AND SPEAKERS BUSINESS-ORIENTED (BIOMED-ORIENTED FOLLOWS) Beng-Hai Chea Citibank, N. A. Committee of Decision Trees Solution for Personal Bankruptcy Prediction David Goldsmith MDT Advisers, Combined Time Series and Cross Sectional CART Modeling for Common Stock Selection Whitney W. Olsen, MD Olsen Capital Management Does Using CART Need to be Complex? Or, Exploiting the Predictive Structure of Financial Time Series in the Presence of Intermittent High Order Chaos Arnab Dey and Ritesh Aggarwal Inductis Application of CART in Determining Reserve Levels for Customer Loyalty Points Paolo Manasse International Monetary Fund Rules of Thumb for Sovereign Debt Crises Ali Moazami, MortgageIT Holdings Inc. and Shaolin Li, BlackRock Mortgage Business Transformation Program using CART-based Joint Risk Modeling with practical discussion of CART/TreeNet Glenn Hofmann HSBC Marketing Strategies for Retail Customers Based on Predictive Behavior Models John Trimble Wells Fargo Bank Improving Customer Retention by Identifying Characteristics of Auto Loan Prepayers using Mars David Poole ATT Labs - Research An Out-of-Memory Implementation of the PRIM Procedure for Massive Datasets Don Cozine BarnesandNoble.com CART for Prim-like Analysis to Augment Predefined Market Zones, Boost Response Rates for Direct Mail Campaigns and to Identify and Exclude Irrelevant Subsections of a Heterogeneous Database from Modeling Dennis Newhart International Steel Group Using CART to Analyze and Improve Operating and Quality Issues in the Steel Industry with Perspectives on Six Sigma Linus Nilsson Capgemini Fault Detection in Industrial Process Plants using CART and MARS Larry Lai, DIRECTV, Inc. Variable Derivation and Selection For Customer Churn Models Jon Farrar Union Bank's Use of CART to Identify Customer Attrition and Screen Application Fraud BIOMEDICAL PRESENTATIONS: Data Mining for Epidemiological Research: Identifying Relationships That Cannot Be Identified In Any Other Way Shenghan Lai, Johns Hopkins Medical School Drug Discovery Clinical Trials and Random Forests at Novartis John Warner, Novartis Model Drift in a Predictive Model of Obstructive Sleep Apnea Brydon Grant, University of Buffalo Medical School Using MARS for the Prediction of the Apnea-Hypopnea Index Brydon Grant, University of Buffalo Medical School Using CART and TreeNet to Discern Models in Genetics: Alzheimer Disease, Alcoholism, Cocaine Addiction and Aging Marsha Wilcox, Boston University Medical School Comparison of Several Tree-Based Methods to Detect Complex Gene Interactions Laurent Briollais, Mount Sinai Hospital Using CART to Develop a Diagnostic Tool for Erectile Dysfunction Joseph C. Cappelleri, Pfizer Models for Recurrence of Low Back Disorder in Industry: A Comparison of Logistic Regression and CART Deborah Burr, Ohio State University School of Public Health A Comparison of Hybrid CART/TreeNET - Generalized Additive Model and Support Vector Machine Tools for Drug Discovery and Pre-Clinical Drug Development Wayne Danter, Critical Outcome Technologies, Inc. Drug Discovery using CART and MARS Wayne Danter, Critical Outcome Technologies, Inc. Application of CART for the Control of Bacroftian Filariasis (leading to elephantitis and West Nile. Fever) in Andara Pradesh, India U. Suryanarayana Murty, Indian Institute of Chemical Technology Generating a Connected Weighted Graph for the Analysis of HIV Data Using CART 5 George Towfic, Clarke College Umbilical Cord Length, Other Placental Growth Measures, Placental Weight and Birthweight Carrie Salafia, Columbia University School of Public Health Experiences when applying MARS and CART in the Disciplines of Biodiversity, Conservation and Wildlife Modeling: The GIS Link Falk Huettmann, Institute of
RE: [R] Binary Matrices
Actually n^2 doubles. You could insert as.integer() around the call to round(runif()), to make the matrix have storage mode integer, but when you call eigen you need a matrix of doubles anyway, so you're not really saving space. If your matrices are large and have mostly zeros, you might benefit from the SparseM package or the Matrix package. Reid Huntsinger -Original Message- From: [EMAIL PROTECTED] [mailto:[EMAIL PROTECTED] On Behalf Of Mark Edmondson-Jones Sent: Wednesday, April 13, 2005 9:51 AM To: r-help@stat.math.ethz.ch Subject: [R] Binary Matrices I'm wanting to perform analysis (e.g. using eigen()) of binary matrices - i.e. matrices comprising 0s and 1s. For example: n-1000 test.mat-matrix(round(runif(n^2)),n,n) eigen(test.mat,only.values=T) Is there a more efficient way of setting up test.mat, as each cell only requires a binary digit? I imagine R is setting up a structure which could contain n^2 floats. Thanks in advance for any help. Regards, Mark This message has been checked for viruses but the contents of an attachment may still contain software viruses, which could damage your computer system: you are advised to perform your own checks. Email communications with the University of Nottingham may be monitored as permitted by UK legislation. __ 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] R binaries for UMBUTU Linux?
Peter Dalgaard p.dalgaard at biostat.ku.dk writes: Derek Eder derek.eder at sdskliniken.se writes: Has anyone out there compiled R for the Umbutu Linux* (ne Debian) v. 5.04 distribution for Intel-type platforms (32 and 64 bit) ? [...] Er, U*bun*tu, you mean? I believe you just use the standard Debian packages and tools like apt-get to install them. Have a look at http://tolstoy.newcastle.edu.au/R/help/05/02/11878.html (which shows that Dirk cannot spell it either...) and related messages in that thread. Yes, I think we can reject the null hypothesis of Dirk can type at all convential significance levels. Dirk __ 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] Perhaps Off-topic lme question
Berton Gunter wrote: A question on lme() : details: nlme() in R 2.1.0 beta or 2.0.1 The data,y, consisted of 82 data value in 5 groups of sizes 3 9 8 28 34 . I fit a simple one level random effects model by: myfit - lme( y~1, rand = ~1|Group) The REML estimates of between and within Group effects are .0032 and .53, respectively; the between group component is essentially zero as is clearly evident from a plot of the data. So, thus far, no problem. However, the confidence interval for the between Groups sd that I get from intervals(myfit) goes from essentially 0 to infinity (6 x 10^13, actually). I assume that this is because the between component estimate is too close to the boundary of 0 so that the likelihood approximations with default control values fail, but I would appreciate a more definitive comment from someone who knows what they're talking about. If anyone cares to try this, the data in group order are below (i.e., first 3 from Group 1, next 9 from Group 2, etc.). The REML and ML estimates for the variance component associated with groups in these data are zero but the way they are estimated in the lme function will always provide non-zero estimates. As you have seen the intervals constructed in such cases are essentially [0, infinity). The lmer function in the lme4 package does somewhat better in that it shows that the estimates are on the boundary of the parameter space. For technical reasons at present that boundary is not at zero but at a very small value - a relative variance of 10^{-10}. (The optimization uses an analytic gradient and I haven't worked out what to give the optimizer for the gradient when the relative variance is zero so I use a small positive value for the boundary instead.) However, if you use a value greater than 2 for the msVerbose control option you will see that the optimizer has converged on the boundary. bert - data.frame(grp = factor(rep(1:5, c(3, 9, 8, 28, 34))), resp = scan(/tmp/bert.txt)) Read 82 items library(lme4) (fm1 - lmer(resp ~ 1 + (1|grp), bert, control = list(msV=3))) N = 1, M = 5 machine precision = 2.22045e-16 At X0, 0 variables are exactly at the bounds At iterate 0 f= 132.39 |proj g|=0.0084942 iterations 1 function evaluations 2 segments explored during Cauchy searches 1 BFGS updates skipped 0 active bounds at final generalized Cauchy point 1 norm of the final projected gradient 0 final function value 132.1 F = 132.1 final value 132.099870 converged Linear mixed-effects model fit by REML Formula: resp ~ 1 + (1 | grp) Data: bert AIC BIClogLik MLdeviance REMLdeviance 138.0999 145.3200 -66.04993 128.2635 132.0999 Random effects: Groups NameVariance Std.Dev. grp (Intercept) 2.8325e-11 5.3221e-06 Residual 2.8325e-01 5.3221e-01 # of obs: 82, groups: grp, 5 Fixed effects: Estimate Std. Error DF t value Pr(|t|) (Intercept) 15.352683 0.058773 81 261.22 2.2e-16 The important information from the optimizer is that there is 1 active bound at the final point. Also the estimate for the variance component for grp is exactly 1e-10 times the variance component from the residual. __ 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] Fluctuating asymmetry and measurement error
Hi all, Has anyone tested for FA in R? I need to seperate out the variance due to measurement error from variation between individuals (following Palmer Strobeck 1986). Andy Higginson Animal Behaviour and Ecology Research Group School of Biology University of Nottingham NG7 2RD U.K. This message has been checked for viruses but the contents of an attachment may still contain software viruses, which could damage your computer system: you are advised to perform your own checks. Email communications with the University of Nottingham may be monitored as permitted by UK legislation. __ 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] Behavior of apply() when used with start()
Can someone explain why starts1 and starts2 are diffferent in the example below? After running this program a - c(1:3) b - c(2:3) tsa - ts(a) tsb - ts(b, start = 2) arr - cbind(tsa, tsb) starts1 - cbind(start(tsa), start(tsb)) starts2 - apply(arr, 2, start) I get: starts1 [,1] [,2] [1,]12 [2,]11 starts2 tsa tsb [1,] 1 1 [2,] 1 1 Thanks for the help. FS __ 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] Binary Matrices
-Original Message- From: Uwe Ligges Mark Edmondson-Jones wrote: I'm wanting to perform analysis (e.g. using eigen()) of binary matrices - i.e. matrices comprising 0s and 1s. For example: n-1000 test.mat-matrix(round(runif(n^2)),n,n) eigen(test.mat,only.values=T) Is there a more efficient way of setting up test.mat, as each cell only requires a binary digit? I imagine R is setting up a structure which could contain n^2 floats. No. In principle you could use logicals, ... but that doesn't save any memory: object.size(integer(1e6)) [1] 428 object.size(logical(1e6)) [1] 428 but that does not help for further calculations in eigen(). Besides, if the problem size is really 1000 x 1000, one matrix in double precision is only 8MB. As Reid said, if the matrix is sparse, there's probably a lot more saving in both memory and computation by using SparseM and Matrix packages. Cheers, Andy Uwe Ligges Thanks in advance for any help. Regards, Mark This message has been checked for viruses but the contents of an attachment may still contain software viruses, which could damage your computer system: you are advised to perform your own checks. Email communications with the University of Nottingham may be monitored as permitted by UK legislation. __ 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-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] Binary Matrices
1000x1000 is only indicative. I need to generate larger (adjacency) matrices using a variety of models. Most are sparse, with a high proportion of zeros and so SparseM sounds very promising. I will investigate. Thanks, Mark Liaw, Andy [EMAIL PROTECTED] 13/04/2005 -Original Message- From: Uwe Ligges Mark Edmondson-Jones wrote: I'm wanting to perform analysis (e.g. using eigen()) of binary matrices - i.e. matrices comprising 0s and 1s. For example: n-1000 test.mat-matrix(round(runif(n^2)),n,n) eigen(test.mat,only.values=T) Is there a more efficient way of setting up test.mat, as each cell only requires a binary digit? I imagine R is setting up a structure which could contain n^2 floats. No. In principle you could use logicals, ... but that doesn't save any memory: object.size(integer(1e6)) [1] 428 object.size(logical(1e6)) [1] 428 but that does not help for further calculations in eigen(). Besides, if the problem size is really 1000 x 1000, one matrix in double precision is only 8MB. As Reid said, if the matrix is sparse, there's probably a lot more saving in both memory and computation by using SparseM and Matrix packages. Cheers, Andy Uwe Ligges Thanks in advance for any help. Regards, Mark This message has been checked for viruses but the contents of an attachment may still contain software viruses, which could damage your computer system: you are advised to perform your own checks. Email communications with the University of Nottingham may be monitored as permitted by UK legislation. __ 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 -- -- This message has been checked for viruses but the contents of an attachment may still contain software viruses, which could damage your computer system: you are advised to perform your own checks. Email communications with the University of Nottingham may be monitored as permitted by UK legislation. __ 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] install.packages and MacOS 10.3.8
Dear Uwe, That install.binaries() was exactly what I needed... Thanks a lot. Uwe Ligges a écrit : Patrick Giraudoux wrote: Dear Listers, I am trying to install packages via install.packages() from MacOS 10.3.8. Installing work fine when run from the menu, but the following command (useful for setting up each computer of the student computer room) leads nowhere for some reasons: pack-c(ade4,adehabitat,geoR,gstat,KernSmooth,lattice,leaps) install.packages(pack,dependencies=T) trying URL `http://cran.r-project.org/src/contrib/PACKAGES' Content type `text/plain; charset=iso-8859-1' length 51500 bytes opened URL == downloaded 50Kb also installing the dependencies 'SparseM', 'gee', 'waveslim', 'splancs', 'maptools', 'spdep', 'pixmap', 'ape', 'tripack' trying URL `http://cran.r-project.org/src/contrib/SparseM_0.60.tar.gz' [SNIP] * Installing *source* package 'SparseM' ... ** libs /Library/Frameworks/R.framework/Resources/bin/SHLIB: line 1: make: command not found ERROR: compilation failed for package 'SparseM' * Installing *source* package 'gee' ... ** libs /Library/Frameworks/R.framework/Resources/bin/SHLIB: line 1: make: command not found ERROR: compilation failed for package 'gee' etc... Can anybody tell me what goes wrong with this command (which usually work without any problem with R 2.0.1 and Windows XP). So at least make and probably much more is missing on your machines (or not in your path or whatever). You might want to try install.binaries() instead (which is similar to install.packages() on Windows, since it installs binary packages rather than trying to compile and install source packages) - or set up your machines with the required set of tools. Uwe Ligges Thanks in advance, 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! http://www.R-project.org/posting-guide.html
[R] R in Windows
Has anyone tried to create dialog boxes for Windows in R so that one doesn't have to type in so much information but rather enter it in a menu-based format. If not, does anyone plan on doing this in the future if it's possible? Thanks. George (Kelley) George A. Kelley, DA, FACSM Professor Director, Meta-Analytic Research Group School of Medicine Department of Community Medicine PO Box 9190 Robert C. Byrd Health Sciences Center Room 2350-A West Virginia University Morgantown, WV 26506-9190 Office Phone: 304-293-6279 Lab Phone: 304-293-6280 Fax: 304-293-5891 E-mail: [EMAIL PROTECTED] Website: http://www.hsc.wvu.edu/som/cmed __ 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] Perhaps Off-topic lme question
Many thanks, Doug. Your explanation was clear and informative. I appreciate your taking the time. -- Bert Gunter Genentech Non-Clinical Statistics South San Francisco, CA __ 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] pstoedit
Ted, Have you tried bringing the eps files directly into Word? The version I am using (Word 2002 = Word 10.x) can incorporate eps files and even generates its own previews. Maybe you don't need to make the conversion at all. Regards, ...Mike At 4/13/2005 04:36 AM, you wrote: On 13-Apr-05 Prof Brian Ripley wrote: On Wed, 13 Apr 2005, BORGULYA [iso-8859-2] Gábor wrote: Has onyone experience with pstoedit (http://www.pstoedit.net/pstoedit) to convert eps graphs generated by R on Linux to Windows formats (WMF or EMF)? Does this way work? Is there an other, better way? You can only do that using pstoedit on Windows. ^^ Well, I have pstoedit on Linux and with pstoedit -f emf infile.eps outfile.emf I get what is claimed to be Enhanced Windows metafile and which can be imported into Word (though then it is subsequently somewhat resistant to editing operations, such as rotating if it's the wrong way up). On the other hand, pstoedit -f wmf infile.eps outfile.wmf which is supposed to produce a Windows metafile, produces something which Word resists importing. Best wishes to all, Ted. E-Mail: (Ted Harding) [EMAIL PROTECTED] Fax-to-email: +44 (0)870 094 0861 Date: 13-Apr-05 Time: 09:36:21 -- 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 -- Michael Prager, Ph.D. Population Dynamics Team, NMFS SE Fisheries Science Center NOAA Center for Coastal Fisheries and Habitat Research Beaufort, North Carolina 28516 http://shrimp.ccfhrb.noaa.gov/~mprager/ __ 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] How to plot Contour with NA in dataframe
Duncan Murdoch [EMAIL PROTECTED] wrote in message news:[EMAIL PROTECTED] [EMAIL PROTECTED] wrote: Your problem isn't the NA values, it's the fact that the contour functions want a matrix, and you're passing a data.frame. If you use as.matrix on it, it converts to character mode, presumably because your last column is entirely missing (so is read as mode logical, not numeric). Use this massaging on it and the plot will work: myData - as.matrix(as.data.frame(lapply(myData,as.numeric))) This looks unnecessarily complicated here, but appears to be necessary. I normally would try to use only as.matrix here but this can fail as shown below, but sometimes can work. R's rules about this conversion seem somewhat arbitrary to me. Example 3, in particular, doesn't make sense to me. Can anyone share some insight on what is going on? == Dummy.txt 1,2,3 4,5,6 # 1. Integers, no missing values; as.matrix good enough for conversion # Results make sense. myData - read.table('Dummy.txt',sep=',') typeof(myData) [1] list class(myData) [1] data.frame myData - as.matrix(myData) myData V1 V2 V3 1 1 2 3 2 4 5 6 typeof(myData) [1] integer class(myData) [1] matrix == Dummy.txt 1,,3 4,2.5,6 # 2. Doubles, missing values; as.matrix good enough for conversion # Results make sense. myData - read.table('Dummy.txt',sep=',') myData - as.matrix(myData) myData V1 V2 V3 1 1 NA 3 2 4 2.5 6 typeof(myData) [1] double class(myData) [1] matrix == Dummy.txt 1,,3 # 3. Drop second row of data from 2 above. Now instead of integers or doubles, # the type is character after using as.matrix? # Results don't make sense. Why did dropping the second row of data change # the type to character here? myData - read.table('Dummy.txt',sep=',') myData - as.matrix(myData) myData V1 V2 V3 1 1 NA 3 typeof(myData) [1] character class(myData) [1] matrix == Dummy.txt 1,,3 # 4. More complicated solution than 3 above, like what Duncan suggested, # but this gives expected results myData - read.table('Dummy.txt',sep=',') myData - as.matrix(as.data.frame(lapply(myData,as.numeric))) myData V1 V2 V3 1 1 NA 3 typeof(myData) [1] double class(myData) [1] matrix == Thanks for any help in clarifying this R subtilty. efg -- Earl F. Glynn Scientific Programmer Stowers Institute for Medical Research __ 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] R in Windows
On Wed, 2005-04-13 at 10:51 -0400, George Kelley wrote: Has anyone tried to create dialog boxes for Windows in R so that one doesn't have to type in so much information but rather enter it in a menu-based format. If not, does anyone plan on doing this in the future if it's possible? Thanks. George (Kelley) There are a variety of GUI's being actively developed for R. More information is here: http://www.sciviews.org/_rgui/ I don't use it actively, but I might specifically suggest that you review John Fox' R Commander: http://socserv.mcmaster.ca/jfox/Misc/Rcmdr/ It is written in tcl/tk, which makes it cross-platform compatible if that is an issue for you. HTH, Marc Schwartz __ 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] logistic regression weights problem
Hi All, I have a problem with weighted logistic regression. I have a number of SNPs and a case/control scenario, but not all genotypes are as guaranteed as others, so I am using weights to downsample the importance of individuals whose genotype has been heavily inferred. My data is quite big, but with a dummy example: status - c(1,1,1,0,0) SNPs - matrix( c(1,0,1,0,0,0,0,1,0,1,0,1,0,1,1), ncol =3) weight - c(0.2, 0.1, 1, 0.8, 0.7) glm(status ~ SNPs, weights = weight, family = binomial) Call: glm(formula = status ~ SNPs, family = binomial, weights = weight) Coefficients: (Intercept)SNPs1SNPs2SNPs3 -2.079 42.282 -18.964 NA Degrees of Freedom: 4 Total (i.e. Null); 2 Residual Null Deviance: 3.867 Residual Deviance: 0.6279 AIC: 6.236 Warning messages: 1: non-integer #successes in a binomial glm! in: eval(expr, envir, enclos) 2: fitted probabilities numerically 0 or 1 occurred in: glm.fit(x = X, y = Y, weights = weights, start = start, etastart = etastart, NB I do not get warning (2) for my data so I'll completely disregard it. Warning (1) looks suspiciously like a multiplication of my C/C status by the weights... what exacly is glm doing with the weight vector? In any case, how would I go about weighting my individuals in a logistic regression? Regards, Federico Calboli -- Federico C. F. Calboli Department of Epidemiology and Public Health Imperial College, St Mary's Campus Norfolk Place, London W2 1PG Tel +44 (0)20 7594 1602 Fax (+44) 020 7594 3193 f.calboli [.a.t] imperial.ac.uk f.calboli [.a.t] gmail.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
RE: [R] Binary Matrices
Mark == Mark Edmondson-Jones [EMAIL PROTECTED] on Wed, 13 Apr 2005 15:40:26 +0100 writes: Mark 1000x1000 is only indicative. I need to generate Mark larger (adjacency) matrices using a variety of models. Mark Most are sparse, with a high proportion of zeros and Mark so SparseM sounds very promising. I will investigate. As others have said, you can use either 'SparseM' or 'Matrix'. The latter has also good code for sparse matrices, and actually I know that Doug Bates was going to implement sparse logical matrices in the next few days. Those actually need (quite) a bit less space than sparse double matrices, since you only need to store the indices of the TRUE entries. Martin Liaw, Andy [EMAIL PROTECTED] 13/04/2005 -Original Message- From: Uwe Ligges Mark Edmondson-Jones wrote: I'm wanting to perform analysis (e.g. using eigen()) of binary matrices - i.e. matrices comprising 0s and 1s. For example: n-1000 test.mat-matrix(round(runif(n^2)),n,n) eigen(test.mat,only.values=T) Is there a more efficient way of setting up test.mat, as each cell only requires a binary digit? I imagine R is setting up a structure which could contain n^2 floats. No. In principle you could use logicals, Mark ... but that doesn't save any memory: object.size(integer(1e6)) Mark [1] 428 object.size(logical(1e6)) Mark [1] 428 but that does not help for further calculations in eigen(). Mark Besides, if the problem size is really 1000 x 1000, one matrix in Mark double precision is only 8MB. As Reid said, if the matrix is sparse, Mark there's probably a lot more saving in both memory and computation Mark by using SparseM and Matrix packages. Mark Cheers, Mark Andy Uwe Ligges Thanks in advance for any help. Regards, Mark This message has been checked for viruses but the contents of an attachment may still contain software viruses, which could damage your computer system: you are advised to perform your own checks. Email communications with the University of Nottingham may be monitored as permitted by UK legislation. __ 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 Mark -- Mark -- Mark This message has been checked for viruses but the contents of an attachment Mark may still contain software viruses, which could damage your computer system: Mark you are advised to perform your own checks. Email communications with the Mark University of Nottingham may be monitored as permitted by UK legislation. Mark __ Mark R-help@stat.math.ethz.ch mailing list Mark https://stat.ethz.ch/mailman/listinfo/r-help Mark 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] lme problem
Milos Zarkovic said the following on 2005-04-12 16:40: I have recently started using R. For the start I have tried to repeat examples from Milliken Johnson Analysis of Messy Data - Analysis of Covariance, but I can not replicate it in R. The example is chocolate chip experiment. Response variable vas time to dissolve chocolate chip in seconds (time), covariate was time to dissolve butterscotch chip (bstime), and type was a type of chocolate chip. Problem is that I obtain different degrees of freedom compared to one in the book. Could it be sum of squares problem (type III vs. type I)? Milliken Johnson use SAS for calculations and this is program the used: proc mixed data=mmacov method=type3; class type; model time=type bstime*type/solution noint. The PROC MIXED code above doesn't correspond to the R code below. My R code is: LME.1=lme(time~bstime:type+type-1,data=CCE,random=~1|type) In your `lme' call, a random effect for each of the levels of `type' has been added to the model. Since the analysis performed by PROC MIXED doesn't have any random effects it can be reproduced in R using the `lm' function. The results below match those of Milliken Johnson p. 49 (using PROC MIXED) and the results on p. 43 (using PROC GLM). fit - lm(time ~ bstime:type + type - 1, data = CCE) summary(fit) Call: lm(formula = time ~ bstime:type + type - 1, data = CCE) Residuals: Min 1Q Median 3Q Max -16.982 -3.196 -0.250 1.400 21.694 Coefficients: Estimate Std. Error t value Pr(|t|) typeBlue MM 17.974416.1923 1.110 0.27845 typeButton21.571910.7832 2.001 0.05738 . typeChoc Chip 16.916715.1673 1.115 0.27622 typeRed MM 26.576013.1722 2.018 0.05545 . typeSmall MM 22.197729.0849 0.763 0.45310 typeSnow Cap 8.7000 9.4131 0.924 0.36495 bstime:typeBlue MM1.0641 0.6187 1.720 0.09887 . bstime:typeButton 1.3352 0.3743 3.567 0.00164 ** bstime:typeChoc Chip 1.1667 0.7302 1.598 0.12373 bstime:typeRed MM 0.5300 0.5564 0.953 0.35075 bstime:typeSmall MM 0.1919 0.9881 0.194 0.84775 bstime:typeSnow Cap0.9000 0.3999 2.250 0.03428 * --- Signif. codes: 0 `***' 0.001 `**' 0.01 `*' 0.05 `.' 0.1 ` ' 1 Residual standard error: 8.196 on 23 degrees of freedom Multiple R-Squared: 0.9774, Adjusted R-squared: 0.9656 F-statistic: 82.8 on 12 and 23 DF, p-value: 5.616e-16 and summary is: Value Std.Error DF t-valuep-value typeBlue MM18.0 18.5 0 0.97 NaN typeButton21.6 14.1 0 1.53 NaN typeChoc Chip 16.9 17.7 0 0.96 NaN typeRed MM26.6 16.0 0 1.66 NaN typeSmall MM 22.2 30.5 0 0.73 NaN typeSnow Cap 8.7 13.1 0 0.67 NaN bstime:typeBlue MM 1.1 0.6 24 1.72 0.098 bstime:typeButton 1.3 0.4 24 3.57 0.002 bstime:typeChoc Chip 1.2 0.7 24 1.60 0.123 bstime:typeRed MM 0.5 0.6 24 0.95 0.350 bstime:typeSmall MM 0.2 1.0 24 0.19 0.848 bstime:typeSnow Cap 0.9 0.4 24 2.25 0.034 However in Milliken Johnson all df are 23. Values (estimates) are almost identical, but there are some small differences in SE and t. Using anova(LME.1) I obtain numDF denDF F-value p-value type6 0 18.19 NaN bstime:type 624 4.04 0.0061 but in the book it is: numDF denDF F-value p-value type6 23 2.00 0.1075 bstime:type 6 23 4.04 0.0066 The tests reported by Milliken Johnson are based on so called Type III sums of squares. If you want to reproduce these, try the `Anova' function in John Fox's indispensable `car' package. library(car) options(contrasts = c(contr.sum, contr.poly)) Anova(fit, type = III) Anova Table (Type III tests) Response: time Sum Sq Df F value Pr(F) type 805.13 6 1.9976 0.107510 bstime:type 1628.79 6 4.0412 0.006557 ** Residuals 1545.01 23 --- Signif. codes: 0 `***' 0.001 `**' 0.01 `*' 0.05 `.' 0.1 ` ' 1 HTH, Henric Data are at the end of the letter. I am not sure what I did wrong. Sincerely, Milos Zarkovic ** Milos Zarkovic MD, Ph.D. Associate Professor of Internal Medicine Institute of Endocrinology Dr Subotica 13 11000 Beograd Serbia Tel +381-63-202-925 Fax +381-11-685-357 Email [EMAIL PROTECTED]
Re: [R] Fitting a mixed negative binomial model
Ben Bolker said the following on 2005-04-12 21:40: This is a little bit tricky (nonlinear, mixed, count data ...) Off the top of my head, without even looking at the documentation, I think your best bet for this problem would be to use the weights statement to allow the variance to be proportional to the mean (and add a normal error term for individuals) -- this would be close to equivalent to the log-Poisson model used by Elston et al. (Parasitology 2001, 122, 563-569, Analysis of aggregation, a worked example: numbers of ticks on red grouse chicks), and might do what you want. A recent posting http://finzi.psych.upenn.edu/R/Rhelp02a/archive/48429.html suggests that an R function for fitting the negative binomial mixed-effects model actually exists. HTH, Henric __ 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] Behavior of apply() when used with start()
On Wed, 13 Apr 2005, Fernando Saldanha wrote: Can someone explain why starts1 and starts2 are diffferent in the example below? Yes, at least one person can. Actually, anyone who looked could: arr Time Series: Start = 1 End = 3 Frequency = 1 tsa tsb 1 1 NA 2 2 2 3 3 3 Note the times series attributes apply to the whole matrix. After running this program a - c(1:3) b - c(2:3) tsa - ts(a) tsb - ts(b, start = 2) arr - cbind(tsa, tsb) starts1 - cbind(start(tsa), start(tsb)) starts2 - apply(arr, 2, start) I get: starts1 [,1] [,2] [1,]12 [2,]11 starts2 tsa tsb [1,] 1 1 [2,] 1 1 -- 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] R in Windows
On Wed, 13 Apr 2005, Marc Schwartz wrote: On Wed, 2005-04-13 at 10:51 -0400, George Kelley wrote: Has anyone tried to create dialog boxes for Windows in R so that one doesn't have to type in so much information but rather enter it in a menu-based format. If not, does anyone plan on doing this in the future if it's possible? Thanks. George (Kelley) There are a variety of GUI's being actively developed for R. More information is here: http://www.sciviews.org/_rgui/ I don't use it actively, but I might specifically suggest that you review John Fox' R Commander: http://socserv.mcmaster.ca/jfox/Misc/Rcmdr/ It is written in tcl/tk, which makes it cross-platform compatible if that is an issue for you. And R for Windows comes with the sources for a `windlgs' package to illustrate how to do guess what? -- 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
[R] Normalization and missing values
Hi all -- I've got a large dataset which consists of a bunch of different scales, and I'm preparing to perform a cluster analysis. I need to normalize the data so I can calculate the difference matrix. First, I didn't see a function in R which does normalization -- did I miss it? What's the best way to do it? Second, what's the best way to deal with missing values? Obviously, I could just set them to 0 (the mean of the normalized scales), but I'm not sure that's the best way. -- Chris __ 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] logistic regression weights problem
On Wed, 13 Apr 2005, Federico Calboli wrote: I have a problem with weighted logistic regression. I have a number of SNPs and a case/control scenario, but not all genotypes are as guaranteed as others, so I am using weights to downsample the importance of individuals whose genotype has been heavily inferred. My data is quite big, but with a dummy example: status - c(1,1,1,0,0) SNPs - matrix( c(1,0,1,0,0,0,0,1,0,1,0,1,0,1,1), ncol =3) weight - c(0.2, 0.1, 1, 0.8, 0.7) glm(status ~ SNPs, weights = weight, family = binomial) Call: glm(formula = status ~ SNPs, family = binomial, weights = weight) Coefficients: (Intercept)SNPs1SNPs2SNPs3 -2.079 42.282 -18.964 NA Degrees of Freedom: 4 Total (i.e. Null); 2 Residual Null Deviance: 3.867 Residual Deviance: 0.6279 AIC: 6.236 Warning messages: 1: non-integer #successes in a binomial glm! in: eval(expr, envir, enclos) 2: fitted probabilities numerically 0 or 1 occurred in: glm.fit(x = X, y = Y, weights = weights, start = start, etastart = etastart, NB I do not get warning (2) for my data so I'll completely disregard it. Warning (1) looks suspiciously like a multiplication of my C/C status by the weights... what exacly is glm doing with the weight vector? Using it in the GLM definition. If you specify 0=y_i=1 and weights a_i, this is how you specify Binomial(a_i, a_iy_i). Look up any book on GLMs and see what it says about the binomial. E.g. MASS4 pp. 184, 190. In any case, how would I go about weighting my individuals in a logistic regression? Use the cbind(yes, no) form of specification. Note though that the `weights' in a GLM are case weights and not arbitrary downweighting factors and aspects of the output (e.g. AIC, anova) depend on this. A different implementation of (differently) weighted GLM is svyglm() in package 'survey'. -- 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
[R] Summary: GLMMs: Negative Binomial family in R
Here is a summary of responses to my original email (see my query at the bottom). Thank you to Achim Zeileis , Anders Nielsen, Pierre Kleiber and Dave Fournier who all helped out with advice. I hope that their responses will help some of you too. * Check out glm.nb() from package MASS fits negative binomial GLMs. * For known theta, you can plug negative.binomial(theta) into glmmPQL() for example. (Both functions are also available in MASS.) Look at package zicounts for zero-inflated Poisson and NB models. For these models, there is also code available at http://pscl.stanford.edu/content.html which also hosts code for hurdle models. * Consider using the function supplied in the post: https://stat.ethz.ch/pipermail/r-help/2005-March/066752.html for fitting negative binomial mixed effects models. * Check out these recent postings to the R list: http://finzi.psych.upenn.edu/R/Rhelp02a/archive/48429.html http://finzi.psych.upenn.edu/R/Rhelp02a/archive/48646.html *this refers to the random effects module of AD Model Builderthat can be called from R via the driver functon glmm.admb(). Their example problem fits the model with a negative binomial. The function can be downloaded from http://otter-rsch.com/admbre/examples/nbmm/nbmm.html *** My Original Query Greetings R Users! I have a data set of count responses for which I have made repeated observations on the experimental units (stream reaches) over two air photo dates, hence the mixed effect. I have been using Dr. Jim Lindsey's GLMM function found in his repeated measures package with the poisson family. My problem though is that I don't think the poisson distribution is the right one to discribe my data which is overdispersed; the variance is greater than the mean. I have read that the negative binomial regression models can account for some of the differences among observations by adding in a error term that independent of the the covariates. I haven't yet come across a mixed effects model that can use the negative binomial distribution. If any of you know of such a function - I will certainly look forward to hearing from you! Additionally, if any of you have insight on zero-inflated data, and testing for this, I'd be interested in your comments too. I'll post a summary of your responses to this list. Best Regards, Nadele Flynn, M.Sc. candidate. University of Alberta __ 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] Anova for GLMM (lme4) is a valid method?
Hi, I try to make a binomial analysis using GLMM in a longitudinal data file. Is correct to use anova(model) to access the significance of the fixed terms? Thanks Ronaldo -- Todos somos iguais perante a lei, mas nao perante os encarregados de faze-las cumprir. -- S. Jerzy Lec -- | // | \\ [***] | ( õ õ ) [Ronaldo Reis Júnior] | V [UFV/DBA-Entomologia] |/ \ [36571-000 Viçosa - MG ] | /(.''`.)\ [Fone: 31-3899-4007 ] | /(: :' :)\ [EMAIL PROTECTED]] |/ (`. `'` ) \[ICQ#: 5692561 | LinuxUser#: 205366 ] |( `- ) [***] | _/ \_Powered by GNU/Debian Woody/Sarge __ 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] Normalization and missing values
Normalization: ?scale -- or, more usually, an argument in the clustering function (see package cluster where stand is the argument in the various functions. Other packages may have similar capabilties). Missing Values: A HUGE and COMPLEX issue. One Reference: ANALYSIS OF INCOMPLETE MULTIVARIATE DATA by J.L. Schafer (Chapman and Hall); Donald Rubin has published several books and many papers on this, so anything by him is another good resource. Setting missings to 0 will clearly produce nonsense, as two cases with lots of missings in corresponding coordinates will cluster together when there is no reason for them to do so. Set them to NA, but as some clustering routines work only with complete cases, this might leave you with a data set of size 0. So you need clustering methods that can work with missing data, e.g. pam, clara, etc.; but of course one doesn't quite know what to make of two cases that are deemed to be close on the basis of, say, 10% of nonmissing shared coordinates as compared to cases that are close based on all shared coordinates. You can't expect statistical procedures to rescue you from poor data. -- Bert Gunter Genentech Non-Clinical Statistics South San Francisco, CA The business of the statistician is to catalyze the scientific learning process. - George E. P. Box -Original Message- From: [EMAIL PROTECTED] [mailto:[EMAIL PROTECTED] On Behalf Of Chris Bergstresser Sent: Wednesday, April 13, 2005 9:37 AM To: r-help@stat.math.ethz.ch Subject: [R] Normalization and missing values Hi all -- I've got a large dataset which consists of a bunch of different scales, and I'm preparing to perform a cluster analysis. I need to normalize the data so I can calculate the difference matrix. First, I didn't see a function in R which does normalization -- did I miss it? What's the best way to do it? Second, what's the best way to deal with missing values? Obviously, I could just set them to 0 (the mean of the normalized scales), but I'm not sure that's the best way. -- Chris __ 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] Binary Matrices
Martin Maechler wrote: As others have said, you can use either 'SparseM' or 'Matrix'. The latter has also good code for sparse matrices, and actually I know that Doug Bates was going to implement sparse logical matrices in the next few days. The old 8-bit assembly language programmer in me baulks at this flippant waste of memory. Storing a *single bit* in 4 bytes? That would reduce the maximum number of bits you could store on a Z80-based machine with a fully maxed-out 64k of RAM to 16384, minus the 8k or whatever your system ROM was. No, the real solution to this problem lies in the 'rawToChar' functions, and its friends. You could pack your entire binary matrix into a character string, and store 8 bits per byte. A factor of 32 improvement in storage (plus a little overhead). You could go the whole hog and write a new binary matrix class, but that would probably be silly, much easier to just write two functions that packed a binary matrix into this form, and unpacked it back into full numeric matrix form. And of course this method doesn't rely on the matrix being sparse, or use run-length encoding or other compression scheme. Its a flat factor of 32 compression. Okay, I'm being slightly sarcastic here, and if it wasn't time to go home now I'd have a quick bash at this, just to see what you can do with R's rawToChar function and friends. Never knew they existed until now. Baz __ 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] Fitting a mixed negative binomial model
I *think* (but am not sure) that these guys were actually (politely) advertising a commercial package that they're developing. But, looking at the web page, it seems that this module may be freely available -- can't tell at the moment. Ben On Wed, 13 Apr 2005, Henric Nilsson wrote: Ben Bolker said the following on 2005-04-12 21:40: This is a little bit tricky (nonlinear, mixed, count data ...) Off the top of my head, without even looking at the documentation, I think your best bet for this problem would be to use the weights statement to allow the variance to be proportional to the mean (and add a normal error term for individuals) -- this would be close to equivalent to the log-Poisson model used by Elston et al. (Parasitology 2001, 122, 563-569, Analysis of aggregation, a worked example: numbers of ticks on red grouse chicks), and might do what you want. A recent posting http://finzi.psych.upenn.edu/R/Rhelp02a/archive/48429.html suggests that an R function for fitting the negative binomial mixed-effects model actually exists. HTH, Henric -- 620B Bartram Hall[EMAIL PROTECTED] Zoology Department, University of Floridahttp://www.zoo.ufl.edu/bolker Box 118525 (ph) 352-392-5697 Gainesville, FL 32611-8525 (fax) 352-392-3704 __ 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] Normalization and missing values
Bert Gunter wrote: You can't expect statistical procedures to rescue you from poor data. That should ***definitely*** go into the fortune package data base!!! cheers, Rolf Turner [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] Behavior of apply() when used with start()
Maybe one person can, but I am not sure who is that person. When I called starts2 - apply(arr, 2, start) I was not asking for the attibutes of the whole matrix. It rather seems to me that cbind() is the culprit. When it copies the time series tsa and tsb it seems to reset their start attributes to 1. In any case, I did what I wanted to do by using list() instead of cbind() and lapply() instead of apply(). FS On 4/13/05, Prof Brian Ripley [EMAIL PROTECTED] wrote: On Wed, 13 Apr 2005, Fernando Saldanha wrote: Can someone explain why starts1 and starts2 are diffferent in the example below? Yes, at least one person can. Actually, anyone who looked could: arr Time Series: Start = 1 End = 3 Frequency = 1 tsa tsb 1 1 NA 2 2 2 3 3 3 Note the times series attributes apply to the whole matrix. After running this program a - c(1:3) b - c(2:3) tsa - ts(a) tsb - ts(b, start = 2) arr - cbind(tsa, tsb) starts1 - cbind(start(tsa), start(tsb)) starts2 - apply(arr, 2, start) I get: starts1 [,1] [,2] [1,]12 [2,]11 starts2 tsa tsb [1,] 1 1 [2,] 1 1 -- 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] Normalization and missing values
On 04/13/05 11:36, Chris Bergstresser wrote: Hi all -- I've got a large dataset which consists of a bunch of different scales, and I'm preparing to perform a cluster analysis. I need to normalize the data so I can calculate the difference matrix. First, I didn't see a function in R which does normalization -- did I miss it? What's the best way to do it? Look at scale(). Might be what you mean. Second, what's the best way to deal with missing values? Obviously, I could just set them to 0 (the mean of the normalized scales), but I'm not sure that's the best way. Lots of ways to deal with missing data. The ones I've found most helpful are in the Hmisc library, particularly transcan() and aregImpute(). See http://www.psych.upenn.edu/~baron/rpsych/rpsych.html#SECTION000715000 for an example of the latter. But, in general, the right way to deal with missing data depends on the assumptions you make. As a novice, I found the following article to be helpful: Schafer, J. L., Graham, J. W. (2002). Missing data: Our view of the state of the art. Psychological Methods, 7, 147-177. -- Jonathan Baron, Professor of Psychology, University of Pennsylvania Home page: http://www.sas.upenn.edu/~baron R search page: http://finzi.psych.upenn.edu/ __ 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] Normalization and missing values
before I know the scale() function, I just do it by coding it myself. But probably you could find some cool stuffs in dprep library. I've never tried it anyway. for missing values, it is way more complex and also depends on the methodology you are going to use. some methods are more tolerant to missing values but others aren't. So the short answer is that there is no BEST way. On 4/13/05, Chris Bergstresser [EMAIL PROTECTED] wrote: Hi all -- I've got a large dataset which consists of a bunch of different scales, and I'm preparing to perform a cluster analysis. I need to normalize the data so I can calculate the difference matrix. First, I didn't see a function in R which does normalization -- did I miss it? What's the best way to do it? Second, what's the best way to deal with missing values? Obviously, I could just set them to 0 (the mean of the normalized scales), but I'm not sure that's the best way. -- Chris __ 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 -- WenSui Liu, MS MA Senior Decision Support Analyst Division of Health Policy and Clinical Effectiveness Cincinnati Children Hospital Medical Center __ 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] Normalization and missing values
On Wed, 13 Apr 2005 14:33:25 -0300 (ADT) Rolf Turner wrote: Bert Gunter wrote: You can't expect statistical procedures to rescue you from poor data. That should ***definitely*** go into the fortune package data base!!! :-) added for the next release. Z cheers, Rolf Turner [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 __ 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] extracting one element of correlation matrices from a list poroduced by the 'by' statement
I am producing 2X2 correlation matrices by a class variable. I need to extract a vector of correlation coefficients only. I am doing that in a loop (see below) but I am sure there would be a simpler way. Please help! by(d1[,c(2,3)],d1[,1],cor) d1[, 1]: 1 c e c 1.000 0.1972309 e 0.1972309 1.000 - d1[, 1]: 2 c e c 1.000 0.2469402 e 0.2469402 1.000 - d1[, 1]: 3 c e c 1.000 0.3177058 e 0.3177058 1.000 - d1[, 1]: 4 c e c 1.000 0.3492043 e 0.3492043 1.000 - d1[, 1]: 5 c e c 1.000 0.3385547 e 0.3385547 1.000 - d1[, 1]: 6 c e c 1.000 0.2876410 e 0.2876410 1.000 - d1[, 1]: 7 c e c 1.000 0.3374766 e 0.3374766 1.000 - d1[, 1]: 8 ce c 1.00 0.438019 e 0.438019 1.00 - d1[, 1]: 9 c e c 1.000 0.3452468 e 0.3452468 1.000 - d1[, 1]: 10 c e c 1.000 0.3746597 e 0.3746597 1.000 *** t- rep(0,10) ind=0 for(r in 1:10) { +ind=ind+1 +t[ind] - by(d1[,c(2,3)],d1[,1],cor)[[r]][1,2] +} t [1] 0.1972309 0.2469402 0.3177058 0.3492043 0.3385547 0.2876410 0.3374766 0.4380190 0.3452468 0.3746597 [[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
[R] GAMM in mgcv - degrees of freedom for smooth terms
Is it possible to set the degrees of freedom for the smooth term in a gamm to a specfic value? This can be done using gam in mgcv as follows: tst.gam-gam(y~s(x, k=6, fx=T)) However, this doesn't seem to work with gamm: tst.gamm-gamm(y~s(x, k=6, fx=TRUE, bs=cr)) Instead, this results in the following error message: Error in parse(file, n, text, prompt) : parse error Similarly, tst.gamm-gamm(y~s(x, k=5, fx=T), random=list(grp=~1)) Error in FUN(X[[1]], ...) : Elements in object must be formulas or pdMat objects I am using mgcv 1.2-3 with Windows XP. Thanks, Doug Swain __ 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] GAMM in mgcv - significance of smooth terms
In the summary of the gam object produced by gamm, the Approximate significance of smooth terms appears to be a test of the improvement in fit over a linear model, rather than a test of the significance of the overall effect of x on y: test.gamm-gamm(y~te(x, bs=cr), random=list(grp=~1)) summary(test.gamm$gam) . . . Approximate significance of smooth terms: edf chi.sq p-value te(x)3.691 11.597 0.017802 Is my interpretation of this correct? If so, is it possible to calculate a test of the overall effect of x from the information saved for a gamm object? Thanks, Doug Swain __ 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] Normalization and missing values
the way of scaling, IMHO, really depends on the distribution of each column in your original files. if each column in your data follows a normal distrbution, then a standard normalization will fit your requirement. My previous research in microarray data shows me a simple linear standardization might be good enough for some purpose. If your columns differ in magnitude, then some data transformation like (log) might be needed first. Ed On 4/13/05, Achim Zeileis [EMAIL PROTECTED] wrote: On Wed, 13 Apr 2005 14:33:25 -0300 (ADT) Rolf Turner wrote: Bert Gunter wrote: You can't expect statistical procedures to rescue you from poor data. That should ***definitely*** go into the fortune package data base!!! :-) added for the next release. Z cheers, Rolf Turner [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 __ 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] Fitting a mixed negative binomial model
I *think* (but am not sure) that these guys were actually (politely) advertising a commercial package that they're developing. But, looking at the web page, it seems that this module may be freely available -- can't tell at the moment. Ben The Software for negative binomial mixed models will be free ie free as in you can use it without paying anything. It is built using our proprietary software. The idea is to show how our software is good for building nonlinear statstical models including those with random effects. Turning our stand alone software into somethng that can be called easily from r has been a bit of a steep learning curve for me, but we are making progress. So far we have looked at 3 models. The model in Booth et al. (easy). An overdispersed data set that turned out probably be a zero inflated poisson (faily easy but the negative binomial is only fit to be rejected for the simpler model) and what appears to be a true negative binomial (difficult but doable) and we are discussing the form of the model with the person who wishes to analyze it. A few more data sets would be useful if anyone has an application so that we can ensure the robustness of our software. Dave -- Internal Virus Database is out-of-date. Checked by AVG Anti-Virus. __ 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] Normalization and missing values
On 13-Apr-05 Berton Gunter wrote: You can't expect statistical procedures to rescue you from poor data. But they can kiss it better. (:-x) Ted. E-Mail: (Ted Harding) [EMAIL PROTECTED] Fax-to-email: +44 (0)870 094 0861 Date: 13-Apr-05 Time: 19:13:01 -- 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
[R] Re: [R-SIG-Mac] BUG in RODBC with OS X?
Just for the record - this problem concerns Actual drivers for Mac OS X 10.3 (later OS X versions are not affected). The current temporary work-around is to install iODBC Runtime supplied with the Actual drivers and compile RODBC as follows (in bash assuming sufficient privileges): LIBS='-framework iODBC' PKG_CFLAGS='-I/Library/Frameworks/ iODBC.framework/Headers' R CMD INSTALL RODBC_1.1-3.tar.gz Simon __ 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] generalized regression neural nets
Is there a R package that can do GRNN? Thanks. __ 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] extracting one element of correlation matrices from a list poroduced by the 'by' statement
Mohammad A. Chaudhary [EMAIL PROTECTED] writes: I am producing 2X2 correlation matrices by a class variable. I need to extract a vector of correlation coefficients only. I am doing that in a loop (see below) but I am sure there would be a simpler way. Please help! by(d1[,c(2,3)],d1[,1],cor) . c e c 1.000 0.3746597 e 0.3746597 1.000 *** t- rep(0,10) ind=0 for(r in 1:10) { +ind=ind+1 +t[ind] - by(d1[,c(2,3)],d1[,1],cor)[[r]][1,2] +} t [1] 0.1972309 0.2469402 0.3177058 0.3492043 0.3385547 0.2876410 0.3374766 0.4380190 0.3452468 0.3746597 One way could be sapply(by(d1[2:3],d1[,1],cor),[,1,2) another is by(d1[2:3],d1[,1],function(f)cor(f)[1,2]) or, (this possibility never occurred to me before) by(d1[2:3],d1[,1], with, cor(c,e)) You might want to wrap the last two in a c() construct but they actually are vectors already, they just don't look it when print.by has done its work. -- O__ Peter Dalgaard Blegdamsvej 3 c/ /'_ --- Dept. of Biostatistics 2200 Cph. N (*) \(*) -- University of Copenhagen Denmark Ph: (+45) 35327918 ~~ - ([EMAIL PROTECTED]) FAX: (+45) 35327907 __ 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] logistic regression weights problem
On Wed, 2005-04-13 at 17:42 +0100, Prof Brian Ripley wrote: Use the cbind(yes, no) form of specification. Note though that the `weights' in a GLM are case weights and not arbitrary downweighting factors and aspects of the output (e.g. AIC, anova) depend on this. A different implementation of (differently) weighted GLM is svyglm() in package 'survey'. I tried to use cbind() on a slightly modified dummy set to get get rid of all warnings and that's what I got: status - c(1,1,1,0,0) SNPs - matrix( c(1,0,1,0,0,1,0,1,0,1,0,1,0,1,1), ncol =3) weight - c(0.2, 0.1, 1, 0.8, 0.7) using cbind() glm(cbind(status, 1-status) ~ SNPs, weights = weight, family = binomial) Call: glm(formula = cbind(status, 1 - status) ~ SNPs, family = binomial, weights = weight) Coefficients: (Intercept)SNPs1SNPs2SNPs3 -2.079 43.132 -19.487 NA Degrees of Freedom: 4 Total (i.e. Null); 2 Residual Null Deviance: 3.867 Residual Deviance: 0.6279 AIC: 6.236 ### NOT using cbind() glm(status~ SNPs, weights = weight, family = binomial) Call: glm(formula = status ~ SNPs, family = binomial, weights = weight) Coefficients: (Intercept)SNPs1SNPs2SNPs3 -2.079 42.944 -19.366 NA Degrees of Freedom: 4 Total (i.e. Null); 2 Residual Null Deviance: 3.867 Residual Deviance: 0.6279 AIC: 6.236 Warning message: non-integer #successes in a binomial glm! in: eval(expr, envir, enclos) ## The anova() call of the cbind() model seems happy: ### mod - glm(cbind(status, 1-status) ~ SNPs, weights = weight, family = binomial) anova(mod, test = Chi) Analysis of Deviance Table Model: binomial, link: logit Response: cbind(status, 1 - status) Terms added sequentially (first to last) Df Deviance Resid. Df Resid. Dev P(|Chi|) NULL 4 3.8673 SNPs 2 3.2394 2 0.62790.1980 # The real data modeldoes not show warnings when I use cbind() but it still shows warning when I call anova() on the model: ### anova(glm(cbind(sta, 1-sta) ~ (X1 + X2 + X3 + X4 + X5) * breed, family= binomial, weights =igf$we, igf),test=Chi) Analysis of Deviance Table Model: binomial, link: logit Response: cbind(sta, 1 - sta) Terms added sequentially (first to last) Df Deviance Resid. Df Resid. Dev P(|Chi|) NULL330 372.89 X1 1 0.14 329 372.75 0.71 X2 1 0.26 328 372.49 0.61 X3 1 0.001121 327 372.49 0.97 X4 1 2.63 326 369.86 0.10 X5 1 1.87 325 367.99 0.17 breed 3 5.41 322 362.58 0.14 X1:breed 3 2.98 319 359.60 0.39 X2:breed 3 1.21 316 358.39 0.75 X3:breed 2 1.32 314 357.08 0.52 X4:breed 3 1.75 311 355.33 0.63 X5:breed 2 2.38 309 352.95 0.30 Warning messages: 1: non-integer #successes in a binomial glm! in: eval(expr, envir, enclos) 2: non-integer #successes in a binomial glm! in: eval(expr, envir, enclos) 3: non-integer #successes in a binomial glm! in: eval(expr, envir, enclos) 4: non-integer #successes in a binomial glm! in: eval(expr, envir, enclos) 5: non-integer #successes in a binomial glm! in: eval(expr, envir, enclos) 6: non-integer #successes in a binomial glm! in: eval(expr, envir, enclos) 7: non-integer #successes in a binomial glm! in: eval(expr, envir, enclos) 8: non-integer #successes in a binomial glm! in: eval(expr, envir, enclos) 9: non-integer #successes in a binomial glm! in: eval(expr, envir, enclos) 10: non-integer #successes in a binomial glm! in: eval(expr, envir, enclos) ## Why such inconsistency? Regards, Federico Calboli -- Federico C. F. Calboli Department of Epidemiology and Public Health Imperial College, St Mary's Campus Norfolk Place, London W2 1PG Tel +44 (0)20 7594 1602 Fax (+44) 020 7594 3193 f.calboli [.a.t] imperial.ac.uk f.calboli [.a.t] gmail.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
RE: [R] extracting one element of correlation matrices from a list poroduced by the 'by' statement
Great! Thank you very much. Looks R has unlimited possibilities. Regards, Ashraf -Original Message- From: [EMAIL PROTECTED] [mailto:[EMAIL PROTECTED] On Behalf Of Peter Dalgaard Sent: Wednesday, April 13, 2005 4:11 PM To: Mohammad A. Chaudhary Cc: r-help@stat.math.ethz.ch Subject: Re: [R] extracting one element of correlation matrices from a list poroduced by the 'by' statement Mohammad A. Chaudhary [EMAIL PROTECTED] writes: I am producing 2X2 correlation matrices by a class variable. I need to extract a vector of correlation coefficients only. I am doing that in a loop (see below) but I am sure there would be a simpler way. Please help! by(d1[,c(2,3)],d1[,1],cor) . c e c 1.000 0.3746597 e 0.3746597 1.000 *** t- rep(0,10) ind=0 for(r in 1:10) { +ind=ind+1 +t[ind] - by(d1[,c(2,3)],d1[,1],cor)[[r]][1,2] +} t [1] 0.1972309 0.2469402 0.3177058 0.3492043 0.3385547 0.2876410 0.3374766 0.4380190 0.3452468 0.3746597 One way could be sapply(by(d1[2:3],d1[,1],cor),[,1,2) another is by(d1[2:3],d1[,1],function(f)cor(f)[1,2]) or, (this possibility never occurred to me before) by(d1[2:3],d1[,1], with, cor(c,e)) You might want to wrap the last two in a c() construct but they actually are vectors already, they just don't look it when print.by has done its work. -- O__ Peter Dalgaard Blegdamsvej 3 c/ /'_ --- Dept. of Biostatistics 2200 Cph. N (*) \(*) -- University of Copenhagen Denmark Ph: (+45) 35327918 ~~ - ([EMAIL PROTECTED]) FAX: (+45) 35327907 __ 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] i param in for loop does not takes zeros?
Hi all Is there any reason why the parameter i in a for loop ignores a value of zero? For example sim=c() p=.2 for(i in 0:5) {sim[i]=dbinom(i,5,p) } sim [1] 0.40960 0.20480 0.05120 0.00640 0.00032 In this example the quantile i= 0 was ignored since dbinom(0,5,p) [1] 0.32768 The same behaviour occurs if I use a while loop to perform the same calculation: sim=c() p=.2 i=0 while(i 6) {sim[i]=dbinom(i,5,p) i=i+1 } sim [1] 0.40960 0.20480 0.05120 0.00640 0.00032 How can I perform a loop passing a zero value parameter? I know I can use an if statement for i=0 but I was wondering why the loop is ignoring the zero value. Many thanks! Francisco __ 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] terminate R program when trying to access out-of-bounds array element?
I want R to stop running a script (after printing an error message) when an array subscript larger than the length of the array is used, for example x = c(1) print(x[2]) rather than printing NA, since trying to access such an element may indicate an error in my program. Is there a way to get this behavior in R? Explicit testing with the is.na() function everywhere does not seem like a good solution. Thanks. __ 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] i param in for loop does not takes zeros?
The for loop is not ignoring the zero at all, but the assignment is, since R indexes starting at 1, not zero. sim - c() sim[0] - 1 sim numeric(0) To run this loop this way, you need to add one to the index: for ( i in 0:5 ) sim[i+1] - dbinom(i, 5, p) However, you'd be better off passing your vector of values directly to dbinom(): dbinom(0:5, 5, p) [1] 0.32768 0.40960 0.20480 0.05120 0.00640 0.00032 all(dbinom(0:5, 5, p) == sim) [1] TRUE Cheers, Rich On 4/14/05, Francisco J. Zagmutt [EMAIL PROTECTED] wrote: Hi all Is there any reason why the parameter i in a for loop ignores a value of zero? For example sim=c() p=.2 for(i in 0:5) {sim[i]=dbinom(i,5,p) } sim [1] 0.40960 0.20480 0.05120 0.00640 0.00032 In this example the quantile i= 0 was ignored since dbinom(0,5,p) [1] 0.32768 The same behaviour occurs if I use a while loop to perform the same calculation: sim=c() p=.2 i=0 while(i 6) {sim[i]=dbinom(i,5,p) i=i+1 } sim [1] 0.40960 0.20480 0.05120 0.00640 0.00032 How can I perform a loop passing a zero value parameter? I know I can use an if statement for i=0 but I was wondering why the loop is ignoring the zero value. Many thanks! Francisco __ 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 -- Rich FitzJohn rich.fitzjohn at gmail.com |http://homepages.paradise.net.nz/richa183 You are in a maze of twisty little functions, all alike __ 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] i param in for loop does not takes zeros?
Thanks to Rich, Douglas and Erin. Off course the problem was the index! I was looking at the wrong place!! Thanks for your help! Francisco From: Rich FitzJohn [EMAIL PROTECTED] Reply-To: Rich FitzJohn [EMAIL PROTECTED] To: Francisco J. Zagmutt [EMAIL PROTECTED] CC: R-help@stat.math.ethz.ch Subject: Re: [R] i param in for loop does not takes zeros? Date: Thu, 14 Apr 2005 09:36:21 +1200 The for loop is not ignoring the zero at all, but the assignment is, since R indexes starting at 1, not zero. sim - c() sim[0] - 1 sim numeric(0) To run this loop this way, you need to add one to the index: for ( i in 0:5 ) sim[i+1] - dbinom(i, 5, p) However, you'd be better off passing your vector of values directly to dbinom(): dbinom(0:5, 5, p) [1] 0.32768 0.40960 0.20480 0.05120 0.00640 0.00032 all(dbinom(0:5, 5, p) == sim) [1] TRUE Cheers, Rich On 4/14/05, Francisco J. Zagmutt [EMAIL PROTECTED] wrote: Hi all Is there any reason why the parameter i in a for loop ignores a value of zero? For example sim=c() p=.2 for(i in 0:5) {sim[i]=dbinom(i,5,p) } sim [1] 0.40960 0.20480 0.05120 0.00640 0.00032 In this example the quantile i= 0 was ignored since dbinom(0,5,p) [1] 0.32768 The same behaviour occurs if I use a while loop to perform the same calculation: sim=c() p=.2 i=0 while(i 6) {sim[i]=dbinom(i,5,p) i=i+1 } sim [1] 0.40960 0.20480 0.05120 0.00640 0.00032 How can I perform a loop passing a zero value parameter? I know I can use an if statement for i=0 but I was wondering why the loop is ignoring the zero value. Many thanks! Francisco __ 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 -- Rich FitzJohn rich.fitzjohn at gmail.com | http://homepages.paradise.net.nz/richa183 You are in a maze of twisty little functions, all alike __ 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] terminate R program when trying to access out-of-bounds array element?
Hi, You could try redefining [, so that if any element subsetted returned an NA, it would throw an error, e.g.: (Warning: Largely untested! - this will almost certainly cause problems in other classes that use [ to subset. Possibly defining this as [.default would be better...) [ - function(x, ...) { res - (base::[)(x, ...) if ( any(is.na(res)) ) stop(An element was NA in a subset) res } x - 1:5 x[4] [1] 4 x[7] Error in x[7] : An element was NA in a subset However, you'll probably find this is a little over-zealous, e.g.: y - c(1:3, NA, 4) y[5] [1] 4 y[4] Error in y[4] : An element was NA in a subset If you just want to check for an NA at printing, defining a function like this might be more appropriate: print.or.stop - function(x) { if ( any(is.na(x)) ) stop(An element was NA in a subset) print(x) } You could write a more complicated [ function that does a bunch of testing, to see if the element extracted is going to be out of the extent of the vector (rather than a genuine NA), but since there are a number of ways elements can be extracted from vectors (numeric, logical and character indices can all be used to index vectors, and these have recycling rules, etc), this is probably much more work than a few checks in your code where an NA would actually indicate an error. Cheers, Rich On 4/14/05, Vivek Rao [EMAIL PROTECTED] wrote: I want R to stop running a script (after printing an error message) when an array subscript larger than the length of the array is used, for example x = c(1) print(x[2]) rather than printing NA, since trying to access such an element may indicate an error in my program. Is there a way to get this behavior in R? Explicit testing with the is.na() function everywhere does not seem like a good solution. Thanks. __ 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 -- Rich FitzJohn rich.fitzjohn at gmail.com |http://homepages.paradise.net.nz/richa183 You are in a maze of twisty little functions, all alike __ 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] terminate R program when trying to access out-of-bounds arrayelement?
WHOA! Do not redefine R functions (especially [ !) in this way! That's what R classes and methods (either S3 or S4) are for. Same applies to print methods. See the appropriate sections of the R language definition and the book S PROGRAMMING by VR. Please do not offer advice of this sort if you are not knowledgeable about R/S Programming, as it might be taken seriously. -- Bert Gunter Genentech Non-Clinical Statistics South San Francisco, CA The business of the statistician is to catalyze the scientific learning process. - George E. P. Box -Original Message- From: [EMAIL PROTECTED] [mailto:[EMAIL PROTECTED] On Behalf Of Rich FitzJohn Sent: Wednesday, April 13, 2005 2:51 PM To: Vivek Rao Cc: r-help@stat.math.ethz.ch Subject: Re: [R] terminate R program when trying to access out-of-bounds arrayelement? Hi, You could try redefining [, so that if any element subsetted returned an NA, it would throw an error, e.g.: (Warning: Largely untested! - this will almost certainly cause problems in other classes that use [ to subset. Possibly defining this as [.default would be better...) [ - function(x, ...) { res - (base::[)(x, ...) if ( any(is.na(res)) ) stop(An element was NA in a subset) res } x - 1:5 x[4] [1] 4 x[7] Error in x[7] : An element was NA in a subset However, you'll probably find this is a little over-zealous, e.g.: y - c(1:3, NA, 4) y[5] [1] 4 y[4] Error in y[4] : An element was NA in a subset If you just want to check for an NA at printing, defining a function like this might be more appropriate: print.or.stop - function(x) { if ( any(is.na(x)) ) stop(An element was NA in a subset) print(x) } You could write a more complicated [ function that does a bunch of testing, to see if the element extracted is going to be out of the extent of the vector (rather than a genuine NA), but since there are a number of ways elements can be extracted from vectors (numeric, logical and character indices can all be used to index vectors, and these have recycling rules, etc), this is probably much more work than a few checks in your code where an NA would actually indicate an error. Cheers, Rich On 4/14/05, Vivek Rao [EMAIL PROTECTED] wrote: I want R to stop running a script (after printing an error message) when an array subscript larger than the length of the array is used, for example x = c(1) print(x[2]) rather than printing NA, since trying to access such an element may indicate an error in my program. Is there a way to get this behavior in R? Explicit testing with the is.na() function everywhere does not seem like a good solution. Thanks. __ 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 -- Rich FitzJohn rich.fitzjohn at gmail.com | http://homepages.paradise.net.nz/richa183 You are in a maze of twisty little functions, all alike __ 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] barplot usage
Hi, Im trying to make a barplot with the following dataframe, with information on relative frequency per sediment type (ST) for some species: Species ST1 ST2 ST3 SP_A 10 6030 ... At x-axis are (should be ...) the species names and at y-axis the frequency per sediment, in stacked bars. I tried to use barplot command but with no results. Could anyone help me on this? Thanks in advance, Samantha - WebMail Bignet - O seu provedor do litoral www.bignet.com.br __ 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] terminate R program when trying to access out-of-bounds arrayelement?
On Wed, 2005-04-13 at 15:03 -0700, Berton Gunter wrote: WHOA! Do not redefine R functions (especially [ !) in this way! That's what R classes and methods (either S3 or S4) are for. Same applies to print methods. See the appropriate sections of the R language definition and the book S PROGRAMMING by VR. Please do not offer advice of this sort if you are not knowledgeable about R/S Programming, as it might be taken seriously. I think that we have another entry for the fortunes package... :-) Best regards, Marc __ 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] terminate R program when trying to access out-of-bounds a rray element?
As Bert said, redefining functions like [ is surely inadvisable, because of possibility of breaking codes that depend on the intended behavior. This is a language _feature_. If the problem is indexing beyond array extent, just check for it: Are any values that are going to be used for indexing larger than the length of the object? E.g., if (any(idx length(x))) stop(index out of bound) result - x[i] If this is still too much work for you, Perhaps R is not for you... Andy From: Rich FitzJohn Hi, You could try redefining [, so that if any element subsetted returned an NA, it would throw an error, e.g.: (Warning: Largely untested! - this will almost certainly cause problems in other classes that use [ to subset. Possibly defining this as [.default would be better...) [ - function(x, ...) { res - (base::[)(x, ...) if ( any(is.na(res)) ) stop(An element was NA in a subset) res } x - 1:5 x[4] [1] 4 x[7] Error in x[7] : An element was NA in a subset However, you'll probably find this is a little over-zealous, e.g.: y - c(1:3, NA, 4) y[5] [1] 4 y[4] Error in y[4] : An element was NA in a subset If you just want to check for an NA at printing, defining a function like this might be more appropriate: print.or.stop - function(x) { if ( any(is.na(x)) ) stop(An element was NA in a subset) print(x) } You could write a more complicated [ function that does a bunch of testing, to see if the element extracted is going to be out of the extent of the vector (rather than a genuine NA), but since there are a number of ways elements can be extracted from vectors (numeric, logical and character indices can all be used to index vectors, and these have recycling rules, etc), this is probably much more work than a few checks in your code where an NA would actually indicate an error. Cheers, Rich On 4/14/05, Vivek Rao [EMAIL PROTECTED] wrote: I want R to stop running a script (after printing an error message) when an array subscript larger than the length of the array is used, for example x = c(1) print(x[2]) rather than printing NA, since trying to access such an element may indicate an error in my program. Is there a way to get this behavior in R? Explicit testing with the is.na() function everywhere does not seem like a good solution. Thanks. __ 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 -- Rich FitzJohn rich.fitzjohn at gmail.com | http://homepages.paradise.net.nz/richa183 You are in a maze of twisty little functions, all alike __ 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] barplot usage
On Wed, 2005-04-13 at 19:05 -0300, Antonio Olinto wrote: Hi, Im trying to make a barplot with the following dataframe, with information on relative frequency per sediment type (ST) for some species: Species ST1 ST2 ST3 SP_A 10 6030 ... At x-axis are (should be ...) the species names and at y-axis the frequency per sediment, in stacked bars. I tried to use barplot command but with no results. Could anyone help me on this? Thanks in advance, Samantha You could use something like the following (presuming that your data is a data frame called 'df'): barplot(t(df[2:4]), names.arg = as.character(df$Species)) Note that the row values that you have (excluding the Species name) need to be rotated 90 degrees as follows: t(df[2:4]) 1 ... ST1 10 ... ST2 60 ... ST3 30 ... In this case, each column represents the segments of each stacked bar (or if you set 'beside = TRUE', the individual bars in a group of bars) Then the labels below each bar in the plot come from the df$Species column. I used as.character(df$Species) presuming that this column might be a factor. If not, you can eliminate the use of as.character() here. HTH, Marc Schwartz __ 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] A suggestion for predict function(s)
Liaw, Andy wrote: I must respectfully disagree. Why carry extra copies of data arround? This is probably OK for small to medium sized data, but definitely not for large data. Besides, in your example, it may do different things depending on whether newdata is supplied: model.matrix is not necessarily the same as the original data frame. You need a bit more work to get the right model.matrix that correspond to the newdata. It's not clear to me whether you want to return model matrix or model frame, but in either case it's not sufficient to just use `newdata'. Andy From: Ross Darnell Maybe a useful addition to the predict functions would be to return the values of the predictor variables. It just (unless there are problems) requires an extra line. I have inserted an example below. predict.glm - function (object, newdata = NULL, type = c(link, response, terms), se.fit = FALSE, dispersion = NULL, terms = NULL, na.action = na.pass, ...) { type - match.arg(type) na.act - object$na.action object$na.action - NULL if (!se.fit) { if (missing(newdata)) { pred - switch(type, link = object$linear.predictors, response = object$fitted, terms = predict.lm(object, se.fit = se.fit, scale = 1, type = terms, terms = terms)) if (!is.null(na.act)) pred - napredict(na.act, pred) } else { pred - predict.lm(object, newdata, se.fit, scale = 1, type = ifelse(type == link, response, type), terms = terms, na.action = na.action) switch(type, response = { pred - family(object)$linkinv(pred) }, link = , terms = ) } } else { if (inherits(object, survreg)) dispersion - 1 if (is.null(dispersion) || dispersion == 0) dispersion - summary(object, dispersion = dispersion)$dispersion residual.scale - as.vector(sqrt(dispersion)) pred - predict.lm(object, newdata, se.fit, scale = residual.scale, type = ifelse(type == link, response, type), terms = terms, na.action = na.action) fit - pred$fit se.fit - pred$se.fit switch(type, response = { se.fit - se.fit * abs(family(object)$mu.eta(fit)) fit - family(object)$linkinv(fit) }, link = , terms = ) if (missing(newdata) !is.null(na.act)) { fit - napredict(na.act, fit) se.fit - napredict(na.act, se.fit) } predictors - if (missing(newdata)) model.matrix(object) else newdata pred - list(predictors=predictors, fit = fit, se.fit = se.fit, residual.scale = residual.scale) } pred #__ end of R code Ross Darnell -- School of Health and Rehabilitation Sciences University of Queensland, Brisbane QLD 4072 AUSTRALIA Email: [EMAIL PROTECTED] Phone: +61 7 3365 6087 Fax: +61 7 3365 4754 Room:822, Therapies Bldg. http://www.shrs.uq.edu.au/shrs/school_staff/ross_darnell.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 -- Notice: This e-mail message, together with any attachment...{{dropped}} __ 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] terminate R program when trying to access out-of-bounds array element?
One way could be to make a special class with an indexing method that checks for out-of-bounds numeric indices. Here's an example for vectors: setOldClass(c(oobcvec)) x - 1:3 class(x) - oobcvec x [1] 1 2 3 attr(,class) [1] oobcvec [.oobcvec - function(x, ..., drop=T) { +if (!missing(..1) is.numeric(..1) any(is.na(..1) | ..1 1 | ..1 length(x))) +stop(numeric vector out of range) +NextMethod([) + } x[2:3] [1] 2 3 x[2:4] Error in [.oobcvec(x, 2:4) : numeric vector out of range Then, for vectors for which you want out-of-bounds checks done when they indexed, set the class to oobcvec. This should work for simple vectors (I checked, and it works if the vectors have names). If you want this write a method like this for indexing matrices, you can use ..1 and ..2 to refer to the i and j indices. If you want to also be able to check for missing character indices, you'll just need to add more code. Note that the above example disallows 0 and negative indices, which may or may not be what you want. If you're extensively using other classes that you've defined, and you want out-of-bounds checking for them, then you need to integrate the checks into the subsetting methods for those classes -- you can't just use the above approach. hope this helps, Tony Plate Vivek Rao wrote: I want R to stop running a script (after printing an error message) when an array subscript larger than the length of the array is used, for example x = c(1) print(x[2]) rather than printing NA, since trying to access such an element may indicate an error in my program. Is there a way to get this behavior in R? Explicit testing with the is.na() function everywhere does not seem like a good solution. Thanks. __ 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] terminate R program when trying to access out-of-bounds array element?
Oops. The message in the 'stop' should be something more like numeric index out of range. -- Tony Plate Tony Plate wrote: One way could be to make a special class with an indexing method that checks for out-of-bounds numeric indices. Here's an example for vectors: setOldClass(c(oobcvec)) x - 1:3 class(x) - oobcvec x [1] 1 2 3 attr(,class) [1] oobcvec [.oobcvec - function(x, ..., drop=T) { +if (!missing(..1) is.numeric(..1) any(is.na(..1) | ..1 1 | ..1 length(x))) +stop(numeric vector out of range) +NextMethod([) + } x[2:3] [1] 2 3 x[2:4] Error in [.oobcvec(x, 2:4) : numeric vector out of range Then, for vectors for which you want out-of-bounds checks done when they indexed, set the class to oobcvec. This should work for simple vectors (I checked, and it works if the vectors have names). If you want this write a method like this for indexing matrices, you can use ..1 and ..2 to refer to the i and j indices. If you want to also be able to check for missing character indices, you'll just need to add more code. Note that the above example disallows 0 and negative indices, which may or may not be what you want. If you're extensively using other classes that you've defined, and you want out-of-bounds checking for them, then you need to integrate the checks into the subsetting methods for those classes -- you can't just use the above approach. hope this helps, Tony Plate Vivek Rao wrote: I want R to stop running a script (after printing an error message) when an array subscript larger than the length of the array is used, for example x = c(1) print(x[2]) rather than printing NA, since trying to access such an element may indicate an error in my program. Is there a way to get this behavior in R? Explicit testing with the is.na() function everywhere does not seem like a good solution. Thanks. __ 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-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] multinom and contrasts
Hi, I found that using different contrasts (e.g. contr.helmert vs. contr.treatment) will generate different fitted probabilities from multinomial logistic regression using multinom(); while the fitted probabilities from binary logistic regression seem to be the same. Why is that? and for multinomial logisitc regression, what contrast should be used? I guess it's helmert? here is an example script: library(MASS) library(nnet) multinomial logistic options(contrasts=c('contr.treatment','contr.poly')) xx-multinom(Type~Infl+Cont,data=housing[-c(1,10,11,22,25,30),]) yy-predict(xx,type='probs') yy[1:10,] options(contrasts=c('contr.helmert','contr.poly')) xx-multinom(Type~Infl+Cont,data=housing[-c(1,10,11,22,25,30),]) zz-predict(xx,type='probs') zz[1:10,] # binary logistic options(contrasts=c('contr.treatment','contr.poly')) obj.glm-glm(Cont~Infl+Type,family='binomial',data=housing[-c(1,10,11,22,25,30),]) yy-predict(xx,type='response') options(contrasts=c('contr.helmert','contr.poly')) obj.glm-glm(Cont~Infl+Type,family='binomial',data=housing[-c(1,10,11,22,25,30),]) zz-predict(xx,type='response') Thanks __ 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] Map a string to an object
Is there a way in R to get an object whose name is given by a string? That is, like a function getObject(mystring) such that getObject('astring') returns the object astring (assuming it exists)? Thanks. FS __ 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] Map a string to an object
On Wed, 2005-04-13 at 19:46 -0400, Fernando Saldanha wrote: Is there a way in R to get an object whose name is given by a string? That is, like a function getObject(mystring) such that getObject('astring') returns the object astring (assuming it exists)? Thanks. Yep. You are close. See ?get x - 1:10 get(x) [1] 1 2 3 4 5 6 7 8 9 10 get(ls) function (name, pos = -1, envir = as.environment(pos), all.names = FALSE, pattern) { if (!missing(name)) { nameValue - try(name) ... HTH, Marc Schwartz __ 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