[R] MANOVA usage
Hello, I had a couple questions about manova modeling in R. I have calculated a manova model, and generated a summary.manova output using both the Wilks test and Pillai test. The output is essentially the same, except that the Wilks lambda = 1 - Pillai. Is this normal? (The output from both is appended below.) My other question is about the use of MANOVA. If I have one variable which has a higher F-stat value (~60) than the MANOVA fstat (~20), but the other 15 variables all have lower ANOVA F-stat values (~5-10), am I still okay in using the MANOVA? (If I remove the one highly significant variable, the MANOVA f-stat is still larger than the other univariate F-stats). Thanks very much for your help, Aalim Output from Manova tests: summary.manova(fit) Df Pillai approx F num Df den DfPr(F) response 1 0.9725 19.8967 16 9 4.193e-05 *** Residuals 24 --- Signif. codes: 0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1 summary.manova(fit, test=Wilks) Df Wilks approx F num Df den DfPr(F) response 1 0.0275 19.8967 16 9 4.193e-05 *** Residuals 24 --- Signif. codes: 0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1 [[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 and provide commented, minimal, self-contained, reproducible code.
Re: [R] applying lm on an array of observations with common design matrix
On Thu, 22 Feb 2007, Petr Klasterecky wrote: Ranjan Maitra napsal(a): On Sun, 18 Feb 2007 07:46:56 + (GMT) Prof Brian Ripley [EMAIL PROTECTED] wrote: On Sat, 17 Feb 2007, Ranjan Maitra wrote: Dear list, I have a 4-dimensional array Y of dimension 330 x 67 x 35 x 51. I have a design matrix X of dimension 330 x 4. I want to fit a linear regression of each lm( Y[, i, j, k] ~ X). for each i, j, k. Can I do it in one shot without a loop? Yes. YY - YY dim(YY) - c(330, 67*35*51) fit - lm(YY ~ X) Actually, I am also interested in getting the p-values of some of the coefficients -- lets say the coefficient corresponding to the second column of the design matrix. Can the same be done using array-based operations? Use lapply(summary(fit), function(x) coef(x)[3,4]) (since there is a intercept, you want the third coefficient). In this context, can one also get the variance-covariance matrix of the coefficients? Sure: lapply(summary(fit), function(x) {$(x,cov.unscaled)}) But that is not the variance-covariance matrix (and it is an unusual way to write x$cov.unscaled)! Add indexing if you do not want the whole matrix. You can extract whatever you want, just take a look at ?summary.lm, section Value. It is unclear to me what the questioner expects: the estimated coefficients for different responses are independent. For a list of matrices applying to each response one could mimic vcov.lm and do lapply(summary(fit, corr=FALSE), function(so) so$sigma^2 * so$cov.unscaled) -- 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 and provide commented, minimal, self-contained, reproducible code.
Re: [R] write fixed format
YIHSU CHEN yihsu.chen at ucmerced.edu writes: Dear R users; Is there a function in R that I can put text with proper alignments in a fixed format. For instance, if I have three fields: A, B and C, where both A and C are text with 3 characters and left alignment; B is a numeric one with 2 decimals and 3 integer space digits. How can I put the following row in a file? (note there is a space between a and 2, and after b.) (A=aaa, B=23.11 and C=bb) aaa 23.11bb Check write.fwf() in gdata package. It might help you, but you will have to create new column to have B and C together i.e. without any space between. Gregor __ 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 and provide commented, minimal, self-contained, reproducible code.
[R] how to install a package in R on a linux machine?
I downloaded the tar.gz file from r-project website (and saved it in a local directory) and wish to use the package in R. But I am not sure how to use the install.packages command. I tried a few times and still couldn't figure out the correct way to install this package. [[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 and provide commented, minimal, self-contained, reproducible code.
[R] Spatial error model estimation
Greetings to the list, I was trying to estimate spatial error model in R, somehow I got the message below. Would you please help me with it? Many thanks in advance. Error in solve.default(asyvar, tol = tol.solve) : system is computationally singular: reciprocal condition number = 5.6964e-18 Regards, Dong __ 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 and provide commented, minimal, self-contained, reproducible code.
Re: [R] 3F2 hypergeometric function
Hello Joe On 21 Feb 2007, at 16:22, Lucke, Joseph F wrote: Does anyone have code for the 3F2 hypergeometric function? I am looking for code similar to the 2F1 hypergeometric function implemented as hyperg_2F1 in the GSL package. TIA. ---Joe The GSL library does not have a hyperg_3F2, so neither does the gsl package. BUT the Davies package does have a hyperg() function that is written in such a way that it would be a cinch to convert it from 2F1 to 3F2. Let me know how you get on Robin __ 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 and provide commented, minimal, self-contained, reproducible code. -- Robin Hankin Uncertainty Analyst National Oceanography Centre, Southampton 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 and provide commented, minimal, self-contained, reproducible code.
[R] Move y label in xyplot
Is there any way to make xyplot draw the y label to the right of the graph instead of to the left? Any help appreciated. Regards, M.Sc. Ola Caster Uppsala University, Sweden [[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 and provide commented, minimal, self-contained, reproducible code.
Re: [R] how to install a package in R on a linux machine?
The easiest is perhaps to do install.packages(packagename) this downloads the package and installs it into the default R package library on your machine. If you want to install it to a different directory use the 'lib' argument of 'install.packages'. If you don't want to download the package again but want to use the downloaded one, use the following command: install.packages(repos=NULL, pkgs=the.file.you've.downloaded) You can also install R packages from the command line, like this: R CMD INSTALL -l lib.directectory downloaded.package.file Gabor On Thu, Feb 22, 2007 at 04:44:25PM +0800, gallon li wrote: I downloaded the tar.gz file from r-project website (and saved it in a local directory) and wish to use the package in R. But I am not sure how to use the install.packages command. I tried a few times and still couldn't figure out the correct way to install this package. [[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 and provide commented, minimal, self-contained, reproducible code. -- Csardi Gabor [EMAIL PROTECTED]MTA RMKI, ELTE TTK __ 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 and provide commented, minimal, self-contained, reproducible code.
Re: [R] MANOVA usage
On Thu, 22 Feb 2007, Aalim Weljie wrote: Hello, I had a couple questions about manova modeling in R. I have calculated a manova model, and generated a summary.manova output using both the Wilks test and Pillai test. The output is essentially the same, except that the Wilks lambda = 1 - Pillai. Is this normal? (The output from both is appended below.) For a 1-df test, yes: all the statistics give the same test (as ?summary.manova does say). My other question is about the use of MANOVA. If I have one variable which has a higher F-stat value (~60) than the MANOVA fstat (~20), but the other 15 variables all have lower ANOVA F-stat values (~5-10), am I still okay in using the MANOVA? (If I remove the one highly significant variable, the MANOVA f-stat is still larger than the other univariate F-stats). OK for what purpose? Using (M)ANOVA for variable selection has many issues. Thanks very much for your help, Aalim Output from Manova tests: summary.manova(fit) Df Pillai approx F num Df den DfPr(F) response 1 0.9725 19.8967 16 9 4.193e-05 *** Residuals 24 --- Signif. codes: 0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1 summary.manova(fit, test=Wilks) Df Wilks approx F num Df den DfPr(F) response 1 0.0275 19.8967 16 9 4.193e-05 *** Residuals 24 --- Signif. codes: 0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1 [[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 and provide commented, minimal, self-contained, reproducible code. -- 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 and provide commented, minimal, self-contained, reproducible code.
[R] Accessing the class of an object with two elements.
Hi R, Here's my question about accessing the class of an object. I have an object dat which can take any two of the classes, (dates times) or (chron dates times). Note that the classes have two elements within it. I want to read these classes in such a way that v=class(dat) # let class(dat)= dates times If(class(dat)==v) k=1 else k=0 The problem is I can't read the above class. The error which I get for the above if statement is as follows: Warning message: the condition has length 1 and only the first element will be used in: if (class(index(intra)) == v) k = 1 How should I proceed with this? Any ideas? I tried with readline to read the class and access it in the 'if' statement...But doesn't work :-( Thanks in advance, Shubha [[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 and provide commented, minimal, self-contained, reproducible code.
[R] Sorting rows of a binary matrix
Hallo, The command: x - 3 mat - as.matrix(expand.grid(rep(list(0:1), x))) generates a matrix with 2^x columns containing the binary representations of the decimals from 0 to (2^x-1), here from 0 to 7. But the rows are not sorted in this order. How can sort the rows the ascending order of the decimals they represent, preferably without a function which converts binaries to decimals (which I have)? Alternatively, generate a matrix that has the rows sorted that way? Thanks, Serguei [[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 and provide commented, minimal, self-contained, reproducible code.
Re: [R] Sorting rows of a binary matrix
I'm sure there are more elegant ways, but this should work: ix-order(mat[,1],mat[,2],mat[,3]) ix [1] 1 5 3 7 2 6 4 8 mat[ix,] Var1 Var2 Var3 1000 5001 3010 7011 2100 6101 4110 8111 On 22/02/07, Serguei Kaniovski [EMAIL PROTECTED] wrote: Hallo, The command: x - 3 mat - as.matrix(expand.grid(rep(list(0:1), x))) generates a matrix with 2^x columns containing the binary representations of the decimals from 0 to (2^x-1), here from 0 to 7. But the rows are not sorted in this order. How can sort the rows the ascending order of the decimals they represent, preferably without a function which converts binaries to decimals (which I have)? Alternatively, generate a matrix that has the rows sorted that way? Thanks, Serguei [[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 and provide commented, minimal, self-contained, reproducible code. -- = David Barron Said Business School University of Oxford Park End Street Oxford OX1 1HP __ 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 and provide commented, minimal, self-contained, reproducible code.
Re: [R] Trying to get an apply to work with a list in applying names totables
--- Marc Schwartz [EMAIL PROTECTED] wrote: I might suggest an alternative, since you seem to be creating the underlying data set from scratch. Thanks Marc. I see what you're suggesting but I am not creating the data from scratch. The data base represented by cc is an SPSS file that I have inherited. Still I am having to do enough mucking about with the SPSS file anyway that your approach might be the best way to go if I do this again. I wish I had asked this question a week ago! Create the data frame with the requisite data structures to start with and then perform the table operations: # First create your vectors as factors. See ?factor aa - factor(c(2,2,1,1,2), levels = 1:2, labels = c(yes, no)) bb - factor(c(5,6,6,7,4), levels = 4:7, labels = letters[1:4]) # Now create your data frame using the names you want for each column cc - data.frame(abby = aa, billy = bb) Now run the table on each column: lapply(cc, table) $abby yes no 2 3 $billy a b c d 1 1 2 1 See ?lapply as well. Note that a data frame is a list: is.list(cc) [1] TRUE is.data.frame(cc) [1] TRUE as.list(cc) $abby [1] no no yes yes no Levels: yes no $billy [1] b c c d a Levels: a b c d HTH, Marc Schwartz On Wed, 2007-02-21 at 17:15 +0100, ONKELINX, Thierry wrote: John, Two things. You don't need to pout the cc variable in the apply. Use instead something like this. apply(cc, 2, fn1, y = mylist) But this still doesn't solve your problem. You'll need to rewrite your function like this. fn2 - function(x, y, i){ + tt - table(x[, i]) + names(tt) - y[[i]] + return(tt) + } sapply(1:ncol(cc), fn2, x = cc, y = mylist) [[1]] yes no 2 3 [[2]] a b c d 1 1 2 1 Cheers, Thierry -Oorspronkelijk bericht- Van: [EMAIL PROTECTED] [mailto:[EMAIL PROTECTED] Namens John Kane Verzonden: woensdag 21 februari 2007 16:47 Aan: R R-help Onderwerp: [R] Trying to get an apply to work with a list in applying names totables I am trying to use apply and a list to supply names to a set of tables I want to generate. Below is an example that I hope mimics the larger original problem. EXAMPLE aa - c( 2,2,1,1,2) bb - c(5,6,6,7,4) aan - c(yes, no) bbn - c(a, b, c, d) mynames - c(abby, billy) mylist - list(aan, bbn); names(mylist) - mynames cc - data.frame(aa,bb) fn1 - function(x,y) {tt - table(x); names(tt)- mylist[[y]]} jj -apply(cc, 2, fn1(cc,mylist)) RESULT: Error in fn1(cc, mylist) : invalid subscript type To be honest I didn't expect it to work since that fin1(cc looks recursive but oh well... Can anyone offer a solution or some advice here. It would be greatly appreciated __ 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 and provide commented, minimal, self-contained, reproducible code.
Re: [R] Spatial error model estimation
On Thu, 22 Feb 2007, Dong GUO wrote: Greetings to the list, I was trying to estimate spatial error model in R, somehow I got the message below. Would you please help me with it? Many thanks in advance. Error in solve.default(asyvar, tol = tol.solve) : system is computationally singular: reciprocal condition number = 5.6964e-18 (This refers to function errorsarlm() in package spdep) Please see ?errorsarlm, the problem is explained there as follows: tol.solve: the tolerance for detecting linear dependencies in the columns of matrices to be inverted - passed to 'solve()' (default=1.0e-10). This may be used if necessary to extract coefficient standard errors (for instance lowering to 1e-12), but errors in 'solve()' may constitute indications of poorly scaled variables: if the variables have scales differing much from the autoregressive coefficient, the values in this matrix may be very different in scale, and inverting such a matrix is analytically possible by definition, but numerically unstable; rescaling the RHS variables alleviates this better than setting tol.solve to a very small value. Regards, Dong __ 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 and provide commented, minimal, self-contained, reproducible code. -- Roger Bivand Economic Geography Section, Department of Economics, Norwegian School of Economics and Business Administration, Helleveien 30, N-5045 Bergen, Norway. voice: +47 55 95 93 55; fax +47 55 95 95 43 e-mail: [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 and provide commented, minimal, self-contained, reproducible code.
[R] daisy function in cluster- coerced NAs
I am currently using the function daisy in package cluster to create a dissimilarity matrix because my multivariate dataset contain missing data and variables of various types including factors, symmetric and asymmetric binary and quantitative. This is a step prior to using pco within ecodist. There is a warning which comes twice NAs introduced by coercion I've used the option: type = list(asymm = c(4:30,32:42), symm= c(31,43)) to indicate which are binary variables and their symmetry. The remaining variables I have left alone since if they are numerical they are already in the data frame as int or num and if they are factors they are already in the dataframe as Factor. Can anyone advise me: a) does this coercion matter? b) If it does matter, how can I track down where/how it is happening? Thank you in advance, Roger Humphry Roger Humphry, PhD. EPI, SCRI, Dundee, DD2 5DA 01382 560042 (Internal Ext: 2528) _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ SCRI, Invergowrie, Dundee, DD2 5DA. The Scottish Crop Research Institute is a charitable company limited by guarantee. Registered in Scotland No: SC 29367. Recognised by the Inland Revenue as a Scottish Charity No: SC 006662. DISCLAIMER: \ \ This email is from the Scottish Crop Re...{{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 and provide commented, minimal, self-contained, reproducible code.
Re: [R] random uniform sample of points on an ellipsoid (e.g. WGS84)
On 21 Feb 2007, Russell Senior wrote: I am interested in making a random sample from a uniform distribution of points over the surface of the earth, using the WGS84 ellipsoid as a model for the earth. I know how to do this for a sphere, but would like to do better. I can supply random numbers, want latitude longitude pairs out. Can anyone point me at a solution? Thanks very much. http://www.csit.fsu.edu/~burkardt/f_src/random_data/random_data.html looks promising, untried. -- Roger Bivand Economic Geography Section, Department of Economics, Norwegian School of Economics and Business Administration, Helleveien 30, N-5045 Bergen, Norway. voice: +47 55 95 93 55; fax +47 55 95 95 43 e-mail: [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 and provide commented, minimal, self-contained, reproducible code.
[R] investigating interactions with mixed models
I'm investigating a number of dependent variables using mixed models, e.g. data.lmer45 = lmer(ampStopB ~ (type + stress + MorD)^3 + (1|speaker) + (1|word), data=data) The p-values for some of the 2-way and 3-way interactions are significant at a 0.05 level and I have been trying to find out how to understand the exact nature of the interactions. Does anyone know if it is possible to run post-hoc tests on mixed model (lmer) objects? I have read about TukeyHSD but it seems that this can only be run on anova (aov) objects. Any suggestions would be gratefully appreciated! Rachel Baker -- -- PhD student Dept of Linguistics Sidgwick Avenue University of Cambridge Cambridge __ 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 and provide commented, minimal, self-contained, reproducible code.
[R] residuals and glm
Hi all, I have some problems to compute the residuals from a glm model with binomial distribution. Suppose I have the following result : resfit-glm(y~x1+x2,weights=we,family=binomial(link=logit)) Now I would like to obtain the residuals . the command residuals(resfit) and the vector resfit$residuals give different results, and they do not correspond to residuals E(yi)-yi (that is resfit$fitted-resfit$y) so, I would like to know what formula is applied to compute these residuals. And moreover, if I want to compute the standardized residuals, what is the right command from the glmfit result. Is it (resfit$fitted-resfit$y)/sqrt(1/resfit$prior*resfit$fitt*(1-resfit$fitt)) ?? Thanks for your help, Olivier. __ 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 and provide commented, minimal, self-contained, reproducible code.
Re: [R] Sorting rows of a binary matrix
Hello Serguei, Is this what you need? myfunc - function(x) { create - function(idx) { rep.int(c(rep.int(0,2^(idx-1)), rep.int(1,2^(idx-1))), 2^x/2^idx) } sapply(rev(seq(x)), create) } myfunc(3) [,1] [,2] [,3] [1,]000 [2,]001 [3,]010 [4,]011 [5,]100 [6,]101 [7,]110 [8,]111 For numerical values only, this is faster than expand.grid(). Alternatively (for multiple values in separate varaibles), you could use the function createMatrix() in package QCA. HTH, Adrian On Thursday 22 February 2007 12:50, Serguei Kaniovski wrote: Hallo, The command: x - 3 mat - as.matrix(expand.grid(rep(list(0:1), x))) generates a matrix with 2^x columns containing the binary representations of the decimals from 0 to (2^x-1), here from 0 to 7. But the rows are not sorted in this order. How can sort the rows the ascending order of the decimals they represent, preferably without a function which converts binaries to decimals (which I have)? Alternatively, generate a matrix that has the rows sorted that way? Thanks, Serguei [[alternative HTML version deleted]] -- Adrian Dusa Romanian Social Data Archive 1, Schitu Magureanu Bd 050025 Bucharest sector 5 Romania Tel./Fax: +40 21 3126618 \ +40 21 3120210 / int.101 __ R-help@stat.math.ethz.ch mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.
Re: [R] residuals and glm
You really need to look at ?glm and ?residuals.glm. resfit$residuals are the *working* residuals, which are not typically very useful in themselves. Far better to use the extractor function. This enables you to obtain a number of different types of residuals, but the default (and therefore the type you have obtained) are deviance residuals. You can also specify other types, such as pearson residuals. Hope this helps. David On 22/02/07, Martin Olivier [EMAIL PROTECTED] wrote: Hi all, I have some problems to compute the residuals from a glm model with binomial distribution. Suppose I have the following result : resfit-glm(y~x1+x2,weights=we,family=binomial(link=logit)) Now I would like to obtain the residuals . the command residuals(resfit) and the vector resfit$residuals give different results, and they do not correspond to residuals E(yi)-yi (that is resfit$fitted-resfit$y) so, I would like to know what formula is applied to compute these residuals. And moreover, if I want to compute the standardized residuals, what is the right command from the glmfit result. Is it (resfit$fitted-resfit$y)/sqrt(1/resfit$prior*resfit$fitt*(1-resfit$fitt)) ?? Thanks for your help, Olivier. __ 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 and provide commented, minimal, self-contained, reproducible code. -- = David Barron Said Business School University of Oxford Park End Street Oxford OX1 1HP __ 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 and provide commented, minimal, self-contained, reproducible code.
Re: [R] residuals and glm
On Thu, 22 Feb 2007, Martin Olivier wrote: I have some problems to compute the residuals from a glm model with binomial distribution. Suppose I have the following result : resfit-glm(y~x1+x2,weights=we,family=binomial(link=logit)) Now I would like to obtain the residuals . the command residuals(resfit) and the vector resfit$residuals give different results, and they do not correspond to residuals E(yi)-yi (that is resfit$fitted-resfit$y) ?residuals.glm should help you, but note that residuals are always conventionally (observed - fitted), not as you give. ?glm tells you what resfit$residuals is, and it seems to be not what you think it is. so, I would like to know what formula is applied to compute these residuals. And moreover, if I want to compute the standardized residuals, what is the right command from the glmfit result. Is it (resfit$fitted-resfit$y)/sqrt(1/resfit$prior*resfit$fitt*(1-resfit$fitt)) ?? See ?rstandard and print(rstandard.glm). -- 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 and provide commented, minimal, self-contained, reproducible code.
[R] Combining tapply() and cor.test()?
Hello, fellow R-users. Let me describe the setup first. I have a data.frame, a sample of which is reported below: Company.Name Periods Returns MFR.Factor 350 Wartsila Oyj A 1996-07-31 6.82 0.02 351Custodia Holding AG 1996-07-31 4.15-0.02 352 Wartsila Oyj 1996-07-31 7.73 0.09 353 GEA Group AG 1996-07-3110.12 0.04 354LEGRAND ORD 1996-07-31 -7.46-0.20 355 Mayr-Melnhof Karton AG 1996-07-31 4.71-0.05 356GEVAERT NPV 1996-08-30 NA NA 357NOKIA K FMA2.50 1996-08-30 7.65 0.03 358 Altadis S.A. 1996-08-30 7.65 0.55 359 Metrovacesa S.A. 1996-08-30 4.55-0.17 360 Oce N.V. 1996-08-309.43 0.23 The variable Periods is a date object, shows the month. Variables Returns and MFR.Factor are numeric. For each month the number of Returns and MFR.Factors varies, sometimes it is 350, sometimes 320 etc. What I need is to use cor.test(Returns, MFR.Factor,...) for each month, and produce a dataframe with columns: Period, cor.estimate, p.value. The simplest way would be with tapply() using variable Period as a factor, but tapply() only applies FUN to just one cell. What is the most painless way to achieve my objective? Thank you in advance for your help! Best, Sergey __ 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 and provide commented, minimal, self-contained, reproducible code.
Re: [R] residuals and glm
David Barron wrote: You really need to look at ?glm and ?residuals.glm. resfit$residuals are the *working* residuals, which are not typically very useful in themselves. Far better to use the extractor function. This enables you to obtain a number of different types of residuals, but the default (and therefore the type you have obtained) are deviance residuals. You can also specify other types, such as pearson residuals. Hope this helps. David And in the Design package's lrm and residuals.lrm function (called by resid(fit)) you can get partial residuals that when smoothed estimate covariate effects. I do prefer direct modeling instead of looking at any of the residuals though, e.g., adding nonlinear or interaction terms to logistic models. Usually I find that residuals in simple binary logistic models are most useful in checking for overly influential observations. Frank Harrell On 22/02/07, Martin Olivier [EMAIL PROTECTED] wrote: Hi all, I have some problems to compute the residuals from a glm model with binomial distribution. Suppose I have the following result : resfit-glm(y~x1+x2,weights=we,family=binomial(link=logit)) Now I would like to obtain the residuals . the command residuals(resfit) and the vector resfit$residuals give different results, and they do not correspond to residuals E(yi)-yi (that is resfit$fitted-resfit$y) so, I would like to know what formula is applied to compute these residuals. And moreover, if I want to compute the standardized residuals, what is the right command from the glmfit result. Is it (resfit$fitted-resfit$y)/sqrt(1/resfit$prior*resfit$fitt*(1-resfit$fitt)) ?? Thanks for your help, Olivier. __ 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 and provide commented, minimal, self-contained, reproducible code. -- Frank E Harrell Jr Professor and Chair School of Medicine Department of Biostatistics Vanderbilt University __ 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 and provide commented, minimal, self-contained, reproducible code.
Re: [R] Sorting rows of a binary matrix
And, for multiple bases: myfunc - function(cols, bases) { create - function(idx) { rep.int(c(sapply(seq_len(bases)-1, function(x) rep.int(x, bases^(idx-1, bases^cols/bases^idx) } sapply(rev(seq_len(cols)), create) } # For 3 columns in base 2 myfunc(3, 2) # For 3 columns in base 3 myfunc(3, 3) hth, Adrian On Thursday 22 February 2007 15:00, Adrian Dusa wrote: Hello Serguei, Is this what you need? myfunc - function(x) { create - function(idx) { rep.int(c(rep.int(0,2^(idx-1)), rep.int(1,2^(idx-1))), 2^x/2^idx) } sapply(rev(seq(x)), create) } myfunc(3) [,1] [,2] [,3] [1,]000 [2,]001 [3,]010 [4,]011 [5,]100 [6,]101 [7,]110 [8,]111 For numerical values only, this is faster than expand.grid(). Alternatively (for multiple values in separate varaibles), you could use the function createMatrix() in package QCA. HTH, Adrian On Thursday 22 February 2007 12:50, Serguei Kaniovski wrote: Hallo, The command: x - 3 mat - as.matrix(expand.grid(rep(list(0:1), x))) generates a matrix with 2^x columns containing the binary representations of the decimals from 0 to (2^x-1), here from 0 to 7. But the rows are not sorted in this order. How can sort the rows the ascending order of the decimals they represent, preferably without a function which converts binaries to decimals (which I have)? Alternatively, generate a matrix that has the rows sorted that way? Thanks, Serguei [[alternative HTML version deleted]] -- Adrian Dusa Romanian Social Data Archive 1, Schitu Magureanu Bd 050025 Bucharest sector 5 Romania Tel./Fax: +40 21 3126618 \ +40 21 3120210 / int.101 __ R-help@stat.math.ethz.ch mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.
Re: [R] Combining tapply() and cor.test()?
?by On 2/22/07, Sergey Goriatchev [EMAIL PROTECTED] wrote: Hello, fellow R-users. Let me describe the setup first. I have a data.frame, a sample of which is reported below: Company.Name Periods Returns MFR.Factor 350 Wartsila Oyj A 1996-07-31 6.82 0.02 351Custodia Holding AG 1996-07-31 4.15-0.02 352 Wartsila Oyj 1996-07-31 7.73 0.09 353 GEA Group AG 1996-07-3110.12 0.04 354LEGRAND ORD 1996-07-31 -7.46-0.20 355 Mayr-Melnhof Karton AG 1996-07-31 4.71-0.05 356GEVAERT NPV 1996-08-30 NA NA 357NOKIA K FMA2.50 1996-08-30 7.65 0.03 358 Altadis S.A. 1996-08-30 7.65 0.55 359 Metrovacesa S.A. 1996-08-30 4.55-0.17 360 Oce N.V. 1996-08-309.43 0.23 The variable Periods is a date object, shows the month. Variables Returns and MFR.Factor are numeric. For each month the number of Returns and MFR.Factors varies, sometimes it is 350, sometimes 320 etc. What I need is to use cor.test(Returns, MFR.Factor,...) for each month, and produce a dataframe with columns: Period, cor.estimate, p.value. The simplest way would be with tapply() using variable Period as a factor, but tapply() only applies FUN to just one cell. What is the most painless way to achieve my objective? Thank you in advance for your help! Best, Sergey __ 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 and provide commented, minimal, self-contained, reproducible code. -- Jim Holtman Cincinnati, OH +1 513 646 9390 What is the problem you are trying to solve? [[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 and provide commented, minimal, self-contained, reproducible code.
[R] Error in solve.default
I am trying to run the following function (a hierarchical bayes linear model) and receive the error in solve.default. The function was originally written for an older version of SPlus. Can anyone give me some insights into where the problem is? Thanks R 2.4.1 on MAC OSX 2mb ram Mark Grant [EMAIL PROTECTED] attach(Aspirin.frame) hblm(Diff ~ 1, s = SE) Error in solve.default(R, rinv) : 'a' is 0-diml traceback() 6: .Call(La_dgesv, a, b, tol, PACKAGE = base) 5: solve.default(R, rinv) 4: solve(R, rinv) 3: summary.blm(fit) 2: eb.calc(rho[i], X, Y, s.e., df.se, corrs, prior, ...) 1: hblm(Diff ~ 1, s = SE) hblm function(formula, s.e., df.se = Inf, corrs = F, prior = NULL, fast.calc = F, ...) { # hblm() # main program to create hblm object call - match.call() call.ab - abbrev.hblm.call(call) taumin - (sum(1/s.e.^2))^-0.5 if(is.null(prior$error)) { prior$error$df - 1 prior$error$sd - taumin } s.e..old - s.e. if(max(s.e.) == Inf) s.e.[s.e. == Inf] - taumin * 1 wts - s.e.^(-2) # changed 1.10.2007 DMR df.se - 1/mean(1/df.se) if(df.se == Inf) { if(is.null(prior$tau)) prior$tau - taumin * sqrt(length(wts)) } fit - lm(formula, weights = wts, qr = T, x = T, y = T, singular = T, ...) X - fit$x Y - fit$y Terms - fit$terms rss - sum(wts * fit$residuals^2) levs - hat(fit$qr) tau.rss - (max(0, rss - fit$df.residual)/sum((1 - levs) * wts))^0.5 log.r - if(tau.rss 0) log(tau.rss) else log(taumin) maxval - max1d(l.p.d.log.r, start = log.r, step = taumin/exp(log.r), x = X, y = Y, s.e. = s.e., df.se = df.se, prior = prior, ...) log.r - maxval$x se.lr - (2 * maxval$h)^(-0.5) g.h.v - gauss.hermite.vals(log.r, se.lr, fast.calc) rho - exp(g.h.v$x) r - length(rho) k - nrow(X) p - ncol(X) tau - sig - lpd - array(0, dim = r) coefs - array(0, dim = c(r, p, 3), dimnames = list(NULL, dimnames(X)[[ 2]], c(Mean, S.D., Prob 0))) cov.c - array(0, dim = c(r, p, p), dimnames = append(dimnames(X)[c(2, 2)], list(NULL), 0)) means - array(0, dim = c(r, k, 3), dimnames = list(NULL, names(Y), c( Post.Mn, Post.SD, Prob 0))) if(corrs) cov.m - array(0, dim = c(r, k, k), dimnames = list(NULL, names( Y), names(Y))) for(i in 1:r) { fit - eb.calc(rho[i], X, Y, s.e., df.se, corrs, prior, ...) tau[i] - fit$tau sig[i] - fit$sigma lpd[i] - fit$lpd coefs[i, , ] - fit$coefs cov.c[i, , ] - fit$cov.c means[i, , ] - fit$means if(corrs) cov.m[i, , ] - fit$cov.means } prob - (exp(lpd) * g.h.v$w)/sum(exp(lpd) * g.h.v$w) if(fit$df.post == Inf) { K1 - K2 - 1 } else { K1 - sqrt(fit$df.post/2) * exp(lgamma((fit$df.post - 1)/2) - lgamma(fit$df.post/2)) K2 - fit$df.post/(fit$df.post - 2) } tausq.m - K2 * prob %*% tau^2 tau.m - K1 * prob %*% tau tau.sd - sqrt(tausq.m - tau.m^2) sigsq.m - K2 * prob %*% sig^2 sig.m - K1 * prob %*% sig sig.sd - sqrt(sigsq.m - sig.m^2) coefs.m - prob %ip% coefs cov.c.m - K2 * (prob %ip% cov.c) coef.d - coefs[, , 1] - matrix(coefs.m[, 1], nrow = r, ncol = p, byrow = T) coef.v - array(0, dim = dim(cov.c.m), dimnames = dimnames(cov.c.m)) for(i in 1:r) coef.v - coef.v + prob[i] * outer(coef.d[i, ], coef.d[i, ]) coefs.m[, 2] - sqrt(diag(cov.c.m) + diag(coef.v)) shrink - matrix(0, nrow = k, ncol = 6, dimnames = list(names(Y), c(Y, Prior Mn, (Y-Prior)/SE, Post.Mn, Post.SD, Prob 0))) fitted - X %*% coefs.m[, 1] residuals - (Y - fitted)/s.e. shrink[, 1:3] - matrix(c(Y, fitted, residuals), ncol = 3) shrink[, 4:6] - prob %ip% means means.d - means[, , 1] - matrix(shrink[, 4], nrow = r, ncol = k, byrow = T) means.v - prob %*% means.d^2 shrink[, 5] - sqrt(K2 * (prob %*% means[, , 2]^2) + means.v) corr.m.m - if(!corrs) NULL else { covm - matrix(0, nrow = k, ncol = k, dimnames = list(names(Y), names(Y))) for(i in 1:r) { covd - means.d[i, ] %o% means.d[i, ] covm - covm + prob[i] * (covd + K2 * cov.m[i, , ]) } covm/(shrink[, 5] %o% shrink[, 5]) } trace - list(rho = rho, tau = tau, sigma = sig, lpd = lpd, prob = prob,
Re: [R] Combining tapply() and cor.test()?
one approach is the following: dat - data.frame( Period = as.Date(rep(c(1996-07-31, 1996-08-31, 1996-09-30), each = 15)), Returns = rnorm(45), MFR.Factor = runif(45) ) ### do.call(rbind, lapply(split(dat[c(Returns, MFR.Factor)], dat$Period), function (x) { cr - cor.test(x$Returns, x$MFR.Factor, method = spearman) c(estimate = cr$estimate, p.value = cr$p.value) })) 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/(0)16/336899 Fax: +32/(0)16/337015 Web: http://med.kuleuven.be/biostat/ http://www.student.kuleuven.be/~m0390867/dimitris.htm - Original Message - From: Sergey Goriatchev [EMAIL PROTECTED] To: r-help@stat.math.ethz.ch Sent: Thursday, February 22, 2007 2:35 PM Subject: [R] Combining tapply() and cor.test()? Hello, fellow R-users. Let me describe the setup first. I have a data.frame, a sample of which is reported below: Company.Name Periods Returns MFR.Factor 350 Wartsila Oyj A 1996-07-31 6.82 0.02 351Custodia Holding AG 1996-07-31 4.15-0.02 352 Wartsila Oyj 1996-07-31 7.73 0.09 353 GEA Group AG 1996-07-3110.12 0.04 354LEGRAND ORD 1996-07-31 -7.46-0.20 355 Mayr-Melnhof Karton AG 1996-07-31 4.71-0.05 356GEVAERT NPV 1996-08-30 NA NA 357NOKIA K FMA2.50 1996-08-30 7.65 0.03 358 Altadis S.A. 1996-08-30 7.65 0.55 359 Metrovacesa S.A. 1996-08-30 4.55-0.17 360 Oce N.V. 1996-08-309.43 0.23 The variable Periods is a date object, shows the month. Variables Returns and MFR.Factor are numeric. For each month the number of Returns and MFR.Factors varies, sometimes it is 350, sometimes 320 etc. What I need is to use cor.test(Returns, MFR.Factor,...) for each month, and produce a dataframe with columns: Period, cor.estimate, p.value. The simplest way would be with tapply() using variable Period as a factor, but tapply() only applies FUN to just one cell. What is the most painless way to achieve my objective? Thank you in advance for your help! Best, Sergey __ 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 and provide commented, minimal, self-contained, reproducible code. Disclaimer: http://www.kuleuven.be/cwis/email_disclaimer.htm __ 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 and provide commented, minimal, self-contained, reproducible code.
Re: [R] random uniform sample of points on an ellipsoid (e.g. WG
On 22-Feb-07 Roger Bivand wrote: On 21 Feb 2007, Russell Senior wrote: I am interested in making a random sample from a uniform distribution of points over the surface of the earth, using the WGS84 ellipsoid as a model for the earth. I know how to do this for a sphere, but would like to do better. I can supply random numbers, want latitude longitude pairs out. Can anyone point me at a solution? Thanks very much. http://www.csit.fsu.edu/~burkardt/f_src/random_data/random_data.html looks promising, untried. Hmmm ... That page didn't seem to be directly useful, since on my understanding of the code (and comments) listed under subroutine uniform_on_ellipsoid_map(dim_num, n, a, r, seed, x) UNIFORM_ON_ELLIPSOID_MAP maps uniform points onto an ellipsoid. in http://www.csit.fsu.edu/~burkardt/f_src/random_data/random_data.f90 it takes points uniformly distributed on a sphere and then linearly transforms these onto an ellipsoid. This will not give unform density over the surface of the ellipsoid: indeed the example graph they show of points on an ellipse generated in this way clearly appear to be more dense at the ends of the ellipse, and less dense on its sides. See: http://www.csit.fsu.edu/~burkardt/f_src/random_data/ uniform_on_ellipsoid_map.png [all one line] Indeed, if I understand their method correctly, in the case of a horizontal ellipse it is equivalent (modulo rotating the result) to distributing the points uniformly over a circle, and then stretching the circle sideways. This will preserve the vertical distribution (so at the two ends of the major axis it has the same density as on the circle) but diluting the horizontal distribution (so that at the two ends of the minor axis the density isless than on the circle). I did have a notion about this, but sat on it expecting that someone would come up with a slick solution -- which hasn't happened yet. For the application you have in hand, uniform distribution over a sphere is a fairly close approximation to uniform distriobution over the ellipspoid -- but not quite. But a rejection method, applied to points uniform on the sphere, can give you points uniform on the ellipsoid and, because of the close approximation of the sphere to the ellipsoid, you would not be rejecting many points. The outline strategy I had in mind (I haven't worked out details) is based on the following. Consider a point X0 on the sphere, at radial distance r0 from the centre of the sphere (same as the centre of the ellipsoid). Let the radius through that point meet the ellipsoid at a point X1, at radial distance R1. Let dS0 be an element of area at X0 on the sphere, which projects radially onto an element of area dS1 on the ellipsoid. You want all elements dS1 of equal size to be equally likely to receive a random point. Let the angle between the tangent plane to the ellipsoid at X1, and the tangent plane to the sphere at X0, be phi. The the ratio of areas dS1/dS0 is R(X0), say, where R(X0) = dS1/dS0 = r1^2/(r0^2 * cos(phi)) and the smaller this ratio, the less likely you want a point u.d. on the sphere to give rise to a point on the ellipsoid. Now define a rejection probability P(X0) by P(X0) = R(X0)/sup[R(X)] taking the supremum over X on the sphere. Then sample points X0 unformly on the sphere, rejecting each on with probability P(X0), and continue sampling until you have the number of points that you need. Maybe someone has a better idea ... (or code for the above!) Ted. E-Mail: (Ted Harding) [EMAIL PROTECTED] Fax-to-email: +44 (0)870 094 0861 Date: 22-Feb-07 Time: 14:10: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 and provide commented, minimal, self-contained, reproducible code.
[R] Updating or installing R packages on Windows Vista
Hi, Windows Vista includes additional security mechanisms (User Access Control) whose defaults make it difficult to install or update R packages. To avoid these problems you need to go to Computer- Program Files Right click on the R directory and select properties. Now select the security tab. Give your user ( which is the use R whose priviledges R runs under) Full Control to the R directory. This should solve the install/update issues. Keep up the good work. Chris Albert [[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 and provide commented, minimal, self-contained, reproducible code.
Re: [R] Updating or installing R packages on Windows Vista
Or you can right-click on the R icon and choose Run as administrator. That way you won't alter the security settings and forget to re-set them. After the packages are installed R will load in the usual way by clicking on the icon. Charles Annis, P.E. [EMAIL PROTECTED] phone: 561-352-9699 eFax: 614-455-3265 http://www.StatisticalEngineering.com -Original Message- From: [EMAIL PROTECTED] [mailto:[EMAIL PROTECTED] On Behalf Of Christopher Albert Sent: Wednesday, February 21, 2007 10:23 PM To: r-help@stat.math.ethz.ch Subject: [R] Updating or installing R packages on Windows Vista Hi, Windows Vista includes additional security mechanisms (User Access Control) whose defaults make it difficult to install or update R packages. To avoid these problems you need to go to Computer- Program Files Right click on the R directory and select properties. Now select the security tab. Give your user ( which is the use R whose priviledges R runs under) Full Control to the R directory. This should solve the install/update issues. Keep up the good work. Chris Albert [[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 and provide commented, minimal, self-contained, reproducible code. __ 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 and provide commented, minimal, self-contained, reproducible code.
Re: [R] how much performance penalty does this incur, scalar as a vector of one element?
I think the short answer is not much. Longer answer: In an interpreted framework with double precision floating point scalars there is little chance of avoiding fresh allocations for each scalar; given that, the overhead associated with length checks can be made negligible. (That isn't to say it currently is--it may or may not be, but you asked about design.) Systems that support integer scalars often represent them as immediate values within pointers by sacrificing one or two bits of precision in the integers, but that doesn't work for double precision floats except possibly on 64-bit systems. Though even there it would be possible to use an efficient internal representation of vectors of length one without changing the concept that everything is a vector. As we think about compilation there are opportunities to produce more efficient code if values can be assumed to be scalars, but that can be accomplished by adding a declaration mechanism. So again the answer in terms of efficiency cost is not much. The APL view of everything as an array, with zero-dimensional arrays being scalars and higher-dimensional arrays being real entities rather than decorated vectors, is in many ways conceptually cleaner and might in hindsight have been a better choice for that reason, but efficiency isn't really a consideration. Best, luke On Wed, 21 Feb 2007, Jason Liao wrote: I have been comparing R with other languages and systems. One peculiar feature of R is there is no scalar. Instead, it is just a vector of length one. I wondered how much performance penalty this deign cause, particular in situations with many scalars in a program. Thanks. Jason Liao, http://www.geocities.com/jg_liao Associate Professor of Biostatistics Drexel University School of Public Health 245 N. 15th Street, Mail Stop 660 Philadelphia, PA 19102-1192 phone 215-762-3934 TV dinner still cooling? Check out Tonight's Picks on Yahoo! TV. __ 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 and provide commented, minimal, self-contained, reproducible code. -- Luke Tierney Chair, Statistics and Actuarial Science Ralph E. Wareham Professor of Mathematical Sciences University of Iowa Phone: 319-335-3386 Department of Statistics andFax: 319-335-3017 Actuarial Science 241 Schaeffer Hall email: [EMAIL PROTECTED] Iowa City, IA 52242 WWW: http://www.stat.uiowa.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 and provide commented, minimal, self-contained, reproducible code.
[R] List filtration
Hello R-ologists, Imagine you have a list list like so: list [[1]] [1] IPI00776145.1 IPI00776187.1 [[2]] [1] Something IPI00807764.1 IPI00807887.1 [[3]] [1] IPI00807764.1 [[4]] [1] Somethingelse What I need to achieve is a filtered list list2 like so: list2 [[1]] [1] IPI00776145.1 [[2]] [1] IPI00807764.1 [[3]] [1] IPI00807764.1 So: - if sublist-entry 1 start with ^IPI make it the list-entry. - otherwise chose the first ^IPI sublist-entry present. - delete the list-entry if not ^IPI sublist-entry present. Can anybody nudge me towards an elegant solution without looping - I have LOTS of entries to process ... Thanks for your Teachings, Joh __ 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 and provide commented, minimal, self-contained, reproducible code.
[R] several Filled.contour plots on the same device...
hello - a question about filled.contour plots, for which i haven't found a response in previous posts - sorry if already treated. i'd like to draw several filled.contour plots (that is, maps) on the same device (a postscript file, actually). I know about layout(matrix) , split.screen or par(mfrow) : it works well for simple plots, but with filled.contour plots, i get several pages instead of one page divided into several cells. I'd really like to get these maps directly on one graphs, without having to process them afterwards. Does anyone know something about that ? Thank you for your help, Alexis Berg Ingénieur de recherche LOCEAN (IPSL) - Paris [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 and provide commented, minimal, self-contained, reproducible code.
[R] Package for Screen Scrapers?
Hi All, I was doing clustering on some genes, and wanted to verify the clustering results using another website. Essentially, I upload two files (in Step 1 Step 3) at this website: http://db.yeastgenome.org/cgi-bin/GO/goTermFinder The website then outputs a graph, which I save. Are there any package that might help me with the screen scraping? Ideally, I would be calling the screen scraper from within the R code. many thanks! - Have a burning question? Go to Yahoo! Answers and get answers from real people who know. [[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 and provide commented, minimal, self-contained, reproducible code.
[R] Diagnostic Tests: Jarque-Bera Test / RAMSEY
Hello R-Users, The following questions are not R-technical, but more of general statistical nature. 1. NORMALITY I built a normal linear regression model and now I want to check for the residual normality assumption. If I check the distribution graphically and look at the descriptive characteristics (skewness and kurtosis are below 1), I would confirm that the residuals are normally distributed. basicStats(IQR.in.mi02.nw.tdv.mix$residuals) round.ans..digits...6. nobs 19316.00 NAs 0.00 Minimum -0.639527 Maximum 0.693383 1. Quartile -0.083753 3. Quartile 0.06 Mean 0.00 Median0.004641 Sum 0.00 SE Mean 0.001047 LCL Mean -0.002053 UCL Mean 0.002053 Variance 0.021186 Stdev 0.145554 Skewness -0.164821 Kurtosis 0.937282 However, when I use the jarque.bera.test(), the assumption of normality is rejected. jarque.bera.test(IQR.in.mi02.nw.tdv.mix$residuals) Jarque Bera Test data: IQR.in.mi02.nw.tdv.mix$residuals X-squared = 795.1296, df = 2, p-value 2.2e-16 Therefore, I am wondering how good are the diagnostic test for the normality assumption? Do you they work for large sample as well? If not, what other diagnostic measures for normality exist for large samples? In many statistic textbooks it is mentioned that for large samples the significance tests are independent from the distributions of residuals. Why is that? 2. RAMSEY TEST I made several scatterplots (residuals ~ predictors). Here everything looks fine but when I apply the RAMSEY resettest(), the assumption of linearity is rejected. My model does not show any signs of multicollinearity and all independent variables have strong linear relationship with the dependent variable. Therefore, I am wondering how well the RAMSEY resettest works in general. What other tests exist? Again, I would like to apologize for the asking no specific R-technical questions. But I would really appreciate any help. Thanks, Simon [[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 and provide commented, minimal, self-contained, reproducible code.
[R] Cross-tabulations next to each other
I have the following relatively simple problem. Say we have three factors, and we want to create a cross-tabulation against each of the other two: x - factor(rbinom(5, 1, 1/2)) y - factor(rbinom(5, 1, 1/2)) z - factor(rbinom(5, 1, 1/2)) table(x,y) table(x,z) This looks like: y x 0 1 0 2 0 1 1 2 z x 0 1 0 1 1 1 2 1 I would like to get (surely this will look a mess in non-monospaced fonts): yz x 0 1 0 1 0 2 0 1 1 1 1 2 2 1 Or something along those lines. Then I would like to convert this to a LaTeX table, in the obvious sort of way. I couldn't find an answer with a quick look through the documentation. Are these two things already done, before I try to roll my own? Haris Skiadas Department of Mathematics and Computer Science Hanover College __ 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 and provide commented, minimal, self-contained, reproducible code.
[R] R CMD CHECK question
hi, I have two private packages, the first (`pkc') depending on the second one (`roiutils'). The source code and DESCRIPTION files describes the dependency as it should be ('Imports', `require'), at least I think so. now, running R CMD CHECK pkc yields the following output in which I have inserted my questions (lines starting with --): * checking for working latex ... OK * using log directory '/Users/vdh/rfiles/Rlibrary/.check/pkc.Rcheck' * using R version 2.4.0 (2006-10-03) * checking for file 'pkc/DESCRIPTION' ... OK * this is package 'pkc' version '1.1' * checking package dependencies ... OK * checking if this is a source package ... OK * checking whether package 'pkc' can be installed ... WARNING Found the following significant warnings: missing link(s): readroi readroi readroi figure readroi conv3exmodel readroi missing link(s): figure readroi -- there _are_ links to the mentioned functions (from `roiutils') in the -- manpages of `pkc'. after installing the libs, the help system works just -- fine. why is it, that CHECK is complaining? can one selectively switch of -- this warning? or how have I to specify the links to tell CHECK that -- everything is OK? * checking package directory ... OK * checking for portable file names ... OK * checking for sufficient/correct file permissions ... OK * checking DESCRIPTION meta-information ... OK * checking top-level files ... OK * checking index information ... OK * checking package subdirectories ... OK * checking R files for syntax errors ... OK * checking R files for non-ASCII characters ... OK * checking whether the package can be loaded ... OK * checking whether the package can be loaded with stated dependencies ... OK * checking whether the name space can be loaded with stated dependencies ... OK * checking S3 generic/method consistency ... OK * checking replacement functions ... OK * checking foreign function calls ... OK * checking R code for possible problems ... OK * checking Rd files ... WARNING Rd files with unknown sections: /Users/vdh/rfiles/Rlibrary/pkc/man/fitdemo.Rd: example See the chapter 'Writing R documentation files' in manual 'Writing R Extensions'. * checking Rd cross-references ... WARNING Missing link(s) in documentation object 'compfit.Rd': readroi readroi readroi figure readroi conv3exmodel readroi Missing link(s) in documentation object 'exp3fit.Rd': figure readroi -- this seems the same problem as above, right? any hints appreciated, joerg __ 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 and provide commented, minimal, self-contained, reproducible code.
[R] Crosstabbing multiple response data
Using R version 2.4.1 (2006-12-18) on Windows, I have a dataset which resembles this: idatt1att2att3 1110 2100 3011 4111 ratings - data.frame(id = c(1,2,3,4), att1 = c(1,1,0,1), att2 = c(1,0,0,1), att3 = c(0,1,1,1)) I would like to get a cross tab of counts of co-ocurrence, which might resemble this: att1att2att3 att1 2 1 att222 att312 with the hope of understanding, at least pairwise, what things hang together. (Yes, there are much, much better ways to do this statistically including clustering and binary corrected correlation, but the audience I am working with asked for this version for a specific reason.) (Later on, I would also like to convert to percentages of the total unique pop, so the final version of the table would be att1att2att3 att1 50% 25% att250%50% att325%50% But I can do this in excel if I can get the first table out.) I have tried the reshape library, but could not get anything resembling this (both on its own, as well as feeding in to table()). (I have also played with transposing and using some comments from this list from 2002 and 2004, but the questioners appear to assume more knowledge than I have in use of R; the example in the posting guide was also more complex than I was ready for, I'm afraid.) Sample of some of my efforts: library(reshape) melt(ratings,id=c(id)) ds1 - melt(ratings,id=c(id)) table(ds1$variable, ds1$variable) # returns only rowcounts, 3 along diagonal xtabs(formula = value ~ ds1$variable + ds1$variable , data=ds1) # returns only a single row of collapsed counts, appears to not allow 1 variable in multiple uses I suspect I am close, so any nudges in the right direction would be helpful. Thanks much, Michael PS: www.rseek.org is very impressive, I heartily encourage its use. [[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 and provide commented, minimal, self-contained, reproducible code.
Re: [R] List filtration
try this: lis. - lapply(lis, function(x) if (length(ind - grep(^IPI, x))) x[ind[1]] else NULL) lis.[!sapply(lis., is.null)] 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/(0)16/336899 Fax: +32/(0)16/337015 Web: http://med.kuleuven.be/biostat/ http://www.student.kuleuven.be/~m0390867/dimitris.htm - Original Message - From: Johannes Graumann [EMAIL PROTECTED] To: r-help@stat.math.ethz.ch Sent: Thursday, February 22, 2007 3:33 PM Subject: [R] List filtration Hello R-ologists, Imagine you have a list list like so: list [[1]] [1] IPI00776145.1 IPI00776187.1 [[2]] [1] Something IPI00807764.1 IPI00807887.1 [[3]] [1] IPI00807764.1 [[4]] [1] Somethingelse What I need to achieve is a filtered list list2 like so: list2 [[1]] [1] IPI00776145.1 [[2]] [1] IPI00807764.1 [[3]] [1] IPI00807764.1 So: - if sublist-entry 1 start with ^IPI make it the list-entry. - otherwise chose the first ^IPI sublist-entry present. - delete the list-entry if not ^IPI sublist-entry present. Can anybody nudge me towards an elegant solution without looping - I have LOTS of entries to process ... Thanks for your Teachings, Joh __ 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 and provide commented, minimal, self-contained, reproducible code. Disclaimer: http://www.kuleuven.be/cwis/email_disclaimer.htm __ 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 and provide commented, minimal, self-contained, reproducible code.
Re: [R] List filtration
On Thu, 2007-02-22 at 15:33 +0100, Johannes Graumann wrote: Hello R-ologists, [snip] So: - if sublist-entry 1 start with ^IPI make it the list-entry. - otherwise chose the first ^IPI sublist-entry present. - delete the list-entry if not ^IPI sublist-entry present. One way to do it would be: l - list(c(IPI00776145.1, IPI00776187.1), c(Something, IPI00807764.1, IPI00807887.1), c(IPI00807764.1), c(Somethingelse)) f - function(x) { r - grep(^IPI, x, value=TRUE) if (length(r) 0) return(r[1]) else return(NA) } l2 - unlist(lapply(l, f)) l2 - l2[!is.na(l2)] But I'm sure that more elegant solutions will be posted --- Rajarshi Guha [EMAIL PROTECTED] GPG Fingerprint: 0CCA 8EE2 2EEB 25E2 AB04 06F7 1BB9 E634 9B87 56EE --- Writing software is more fun than working. __ 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 and provide commented, minimal, self-contained, reproducible code.
[R] how to show date with this subset
Dear List, Thankyou to Jim and Marc for their help on my previous question. I have a data frame of five columns, the first being a list of dates and the other four columns are numeric values. I wanted to list the days where all 4 columns of values are less than in the previous row. I used the following which works fine, except it doesnt show the dates for each row (the values from column 1). differences - apply(x, 2, diff) all.lower.diffs - subset(differences, apply(differences, 1, function(x){all(x0)} I tried using the following loop instead, but it would only apply to the first column of every row(warning condition has length1 and only first element will be used): for ( i in 2:length(x[,1])) if (x[i,]x[i-1,]) {print(x[i,])} How can I resolve with either method? Any help much appreciated. Regards, Alf Sammassimo. __ 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 and provide commented, minimal, self-contained, reproducible code.
[R] Debugging S Plus
Does anyone know the basic commands to debug in s plus. I know how to debug in r, but I'm having trouble finding similar tools. Mostly what I want to know is what is the equivalent of the debug() command, and what do I use to move to the next line, and get the values of different variables. Thanks! -cjkogan111 -- View this message in context: http://www.nabble.com/Error-Message-Documentation-tf2283899.html#a9101832 Sent from the R help mailing list archive at Nabble.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 and provide commented, minimal, self-contained, reproducible code.
Re: [R] List filtration
Thanks for your help! Joh Dimitris Rizopoulos wrote: try this: lis. - lapply(lis, function(x) if (length(ind - grep(^IPI, x))) x[ind[1]] else NULL) lis.[!sapply(lis., is.null)] 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/(0)16/336899 Fax: +32/(0)16/337015 Web: http://med.kuleuven.be/biostat/ http://www.student.kuleuven.be/~m0390867/dimitris.htm - Original Message - From: Johannes Graumann [EMAIL PROTECTED] To: r-help@stat.math.ethz.ch Sent: Thursday, February 22, 2007 3:33 PM Subject: [R] List filtration Hello R-ologists, Imagine you have a list list like so: list [[1]] [1] IPI00776145.1 IPI00776187.1 [[2]] [1] Something IPI00807764.1 IPI00807887.1 [[3]] [1] IPI00807764.1 [[4]] [1] Somethingelse What I need to achieve is a filtered list list2 like so: list2 [[1]] [1] IPI00776145.1 [[2]] [1] IPI00807764.1 [[3]] [1] IPI00807764.1 So: - if sublist-entry 1 start with ^IPI make it the list-entry. - otherwise chose the first ^IPI sublist-entry present. - delete the list-entry if not ^IPI sublist-entry present. Can anybody nudge me towards an elegant solution without looping - I have LOTS of entries to process ... Thanks for your Teachings, Joh __ 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 and provide commented, minimal, self-contained, reproducible code. Disclaimer: http://www.kuleuven.be/cwis/email_disclaimer.htm __ 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 and provide commented, minimal, self-contained, reproducible code. __ 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 and provide commented, minimal, self-contained, reproducible code.
Re: [R] Cross-tabulations next to each other
maybe cbind() is close to what you're looking for, e.g., tb1 - table(x, y) tb2 - table(x, z) cbind(tb1, tb2) Best, Dimitris Dimitris Rizopoulos Ph.D. Student Biostatistical Centre School of Public Health Catholic University of Leuven Address: Kapucijnenvoer 35, Leuven, Belgium Tel: +32/(0)16/336899 Fax: +32/(0)16/337015 Web: http://med.kuleuven.be/biostat/ http://www.student.kuleuven.be/~m0390867/dimitris.htm - Original Message - From: Charilaos Skiadas [EMAIL PROTECTED] To: R-Mailingliste r-help@stat.math.ethz.ch Sent: Thursday, February 22, 2007 4:01 PM Subject: [R] Cross-tabulations next to each other I have the following relatively simple problem. Say we have three factors, and we want to create a cross-tabulation against each of the other two: x - factor(rbinom(5, 1, 1/2)) y - factor(rbinom(5, 1, 1/2)) z - factor(rbinom(5, 1, 1/2)) table(x,y) table(x,z) This looks like: y x 0 1 0 2 0 1 1 2 z x 0 1 0 1 1 1 2 1 I would like to get (surely this will look a mess in non-monospaced fonts): yz x 0 1 0 1 0 2 0 1 1 1 1 2 2 1 Or something along those lines. Then I would like to convert this to a LaTeX table, in the obvious sort of way. I couldn't find an answer with a quick look through the documentation. Are these two things already done, before I try to roll my own? Haris Skiadas Department of Mathematics and Computer Science Hanover College __ 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 and provide commented, minimal, self-contained, reproducible code. Disclaimer: http://www.kuleuven.be/cwis/email_disclaimer.htm __ 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 and provide commented, minimal, self-contained, reproducible code.
Re: [R] Cross-tabulations next to each other
Hi Dimitris, On Feb 22, 2007, at 10:27 AM, Dimitris Rizopoulos wrote: maybe cbind() is close to what you're looking for, e.g., tb1 - table(x, y) tb2 - table(x, z) cbind(tb1, tb2) Yes, that was my first thought too, and it does place the values where I want them, but it completely destroys the names, which I'd like to keep, i.e. it doesn't treat it as a table any more. The resulting LaTeX table I would like to have a very top row, with multicolumn titles, one for each factor, then a second row with the levels for each factor, and then below those the data. I could I guess add that stuff separately, but I was hoping someone had already done that part. Best, Dimitris Haris Skiadas Department of Mathematics and Computer Science Hanover College __ 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 and provide commented, minimal, self-contained, reproducible code.
Re: [R] how to show date with this subset
On Fri, 23 Feb 2007, Alfonso Sammassimo wrote: Dear List, Thankyou to Jim and Marc for their help on my previous question. I have a data frame of five columns, the first being a list of dates and the other four columns are numeric values. I wanted to list the days where all 4 columns of values are less than in the previous row. I used the following which works fine, except it doesnt show the dates for each row (the values from column 1). differences - apply(x, 2, diff) Please don't use apply() columnwise on data frames: it turns them into matrices. Here you could use tmp - lapply(x[2:5], diff) ind - do.call(pmax, tmp) 0 x[c(FALSE, ind), ] all.lower.diffs - subset(differences, apply(differences, 1, function(x){all(x0)} I tried using the following loop instead, but it would only apply to the first column of every row(warning condition has length1 and only first element will be used): for ( i in 2:length(x[,1])) if (x[i,]x[i-1,]) {print(x[i,])} ^all(^) How can I resolve with either method? Any help much appreciated. Regards, Alf Sammassimo. -- 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 and provide commented, minimal, self-contained, reproducible code.
Re: [R] Crosstabbing multiple response data
Try this: tab - crossprod(as.matrix(ratings[,-1])) tab - tab - diag(diag(tab)) tab tab / nrow(ratings) On 2/22/07, Michael Wexler [EMAIL PROTECTED] wrote: Using R version 2.4.1 (2006-12-18) on Windows, I have a dataset which resembles this: idatt1att2att3 1110 2100 3011 4111 ratings - data.frame(id = c(1,2,3,4), att1 = c(1,1,0,1), att2 = c(1,0,0,1), att3 = c(0,1,1,1)) I would like to get a cross tab of counts of co-ocurrence, which might resemble this: att1att2att3 att1 2 1 att222 att312 with the hope of understanding, at least pairwise, what things hang together. (Yes, there are much, much better ways to do this statistically including clustering and binary corrected correlation, but the audience I am working with asked for this version for a specific reason.) (Later on, I would also like to convert to percentages of the total unique pop, so the final version of the table would be att1att2att3 att1 50% 25% att250%50% att325%50% But I can do this in excel if I can get the first table out.) I have tried the reshape library, but could not get anything resembling this (both on its own, as well as feeding in to table()). (I have also played with transposing and using some comments from this list from 2002 and 2004, but the questioners appear to assume more knowledge than I have in use of R; the example in the posting guide was also more complex than I was ready for, I'm afraid.) Sample of some of my efforts: library(reshape) melt(ratings,id=c(id)) ds1 - melt(ratings,id=c(id)) table(ds1$variable, ds1$variable) # returns only rowcounts, 3 along diagonal xtabs(formula = value ~ ds1$variable + ds1$variable , data=ds1) # returns only a single row of collapsed counts, appears to not allow 1 variable in multiple uses I suspect I am close, so any nudges in the right direction would be helpful. Thanks much, Michael PS: www.rseek.org is very impressive, I heartily encourage its use. [[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 and provide commented, minimal, self-contained, reproducible code. __ 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 and provide commented, minimal, self-contained, reproducible code.
[R] adjacency matrix?
I'm curious to know if it's possible to easily generate a grid (lattice) and obtain the adjacency matrix. For example, I would like to display a 3x3 (or 10x10) lattice then then generate the 10 x 10 adjacency matrix matrix( 1:9, 3,3, byrow=TRUE ) [,1] [,2] [,3] [1,]123 [2,]456 [3,]789 and then use the mathgraph(?) package to generate the adjacency matrix? I've been able to generate a simple graph as well as some basic graphs like the one above but have two concatenate lots of simple graphs together, gr - c( mathgraph( ~ 1 / c(2,4) ), mathgraph( ~ 2 / c(1,3,5) ), mathgraph( ~ 3 / c(2,6) ), mathgraph( ~ 4 / c(1,5,7) ), mathgraph( ~ 5 / c(2,4,6,8) ), mathgraph( ~ 6 / c(3,5,9) ), mathgraph( ~ 7 / c(4,8) ), mathgraph( ~ 8 / c(5,7,9) ), mathgraph( ~ 9 / c(6,8) ) ) and then plot( gr ) and adjamat( gr ) which yields a correct adjacency matrix. Since the names of the nodes are the values in the elements, is there are easier way to accomplish this? Thanks, Jeff. -- Jeff D. Hamann Forest Informatics, Inc. PO Box 1421 Corvallis, Oregon 97339-1421 phone 541-754-1428 [EMAIL PROTECTED] www.forestinformatics.com __ R-help@stat.math.ethz.ch mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.
Re: [R] Accessing the class of an object with two elements.
Le Jeudi 22 Février 2007 05:37, Shubha Vishwanath Karanth a écrit : Hi R, Here's my question about accessing the class of an object. I have an object dat which can take any two of the classes, (dates times) or (chron dates times). Note that the classes have two elements within it. I want to read these classes in such a way that v=class(dat) # let class(dat)= dates times If(class(dat)==v) k=1 else k=0 The problem is I can't read the above class. The error which I get for the above if statement is as follows: Warning message: the condition has length 1 and only the first element will be used in: if (class(index(intra)) == v) k = 1 How should I proceed with this? Any ideas? I tried with readline to read the class and access it in the 'if' statement...But doesn't work :-( Well, given your code the condition in the 'if' statement will return c(TRUE, TRUE), hence the warning. Executing your code piece by piece would tell you that. That said, you probably rather want to use inherit() for such purposes. HTH -- Vincent Goulet, Associate Professor École d'actuariat Université Laval, Québec [EMAIL PROTECTED] http://vgoulet.act.ulaval.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 and provide commented, minimal, self-contained, reproducible code.
Re: [R] Diagnostic Tests: Jarque-Bera Test / RAMSEY
I suspect that your data is non-normal. You might try the diagnostics in the nortest package and refer to the text Thode (2002), Testing for Normality, Marcel Decker, quoted in the references to that package. A QQ diagram might help to reveal the problems with your data. John Frain On 22/02/07, Simon P. Kempf [EMAIL PROTECTED] wrote: Hello R-Users, The following questions are not R-technical, but more of general statistical nature. 1. NORMALITY I built a normal linear regression model and now I want to check for the residual normality assumption. If I check the distribution graphically and look at the descriptive characteristics (skewness and kurtosis are below 1), I would confirm that the residuals are normally distributed. basicStats(IQR.in.mi02.nw.tdv.mix$residuals) round.ans..digits...6. nobs 19316.00 NAs 0.00 Minimum -0.639527 Maximum 0.693383 1. Quartile -0.083753 3. Quartile 0.06 Mean 0.00 Median0.004641 Sum 0.00 SE Mean 0.001047 LCL Mean -0.002053 UCL Mean 0.002053 Variance 0.021186 Stdev 0.145554 Skewness -0.164821 Kurtosis 0.937282 However, when I use the jarque.bera.test(), the assumption of normality is rejected. jarque.bera.test(IQR.in.mi02.nw.tdv.mix$residuals) Jarque Bera Test data: IQR.in.mi02.nw.tdv.mix$residuals X-squared = 795.1296, df = 2, p-value 2.2e-16 Therefore, I am wondering how good are the diagnostic test for the normality assumption? Do you they work for large sample as well? If not, what other diagnostic measures for normality exist for large samples? In many statistic textbooks it is mentioned that for large samples the significance tests are independent from the distributions of residuals. Why is that? 2. RAMSEY TEST I made several scatterplots (residuals ~ predictors). Here everything looks fine but when I apply the RAMSEY resettest(), the assumption of linearity is rejected. My model does not show any signs of multicollinearity and all independent variables have strong linear relationship with the dependent variable. Therefore, I am wondering how well the RAMSEY resettest works in general. What other tests exist? Again, I would like to apologize for the asking no specific R-technical questions. But I would really appreciate any help. Thanks, Simon [[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 and provide commented, minimal, self-contained, reproducible code. -- John C Frain Trinity College Dublin Dublin 2 Ireland www.tcd.ie/Economics/staff/frainj/home.html mailto:[EMAIL PROTECTED] mailto:[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 and provide commented, minimal, self-contained, reproducible code.
Re: [R] several Filled.contour plots on the same device...
The problem is that filled.contour uses the layout function internally which messes up any other use of layout, split.screen, or mfrow. One alternative is to use the levelplot function from the lattice package, or you could use filled.contour to make several full page plots to a pdf file, then use an external utility like pdfpages to combine them onto a single page. Hope this helps, -- Gregory (Greg) L. Snow Ph.D. Statistical Data Center Intermountain Healthcare [EMAIL PROTECTED] (801) 408-8111 -Original Message- From: [EMAIL PROTECTED] [mailto:[EMAIL PROTECTED] On Behalf Of [EMAIL PROTECTED] Sent: Thursday, February 22, 2007 4:15 AM To: r-help@stat.math.ethz.ch Subject: [R] several Filled.contour plots on the same device... hello - a question about filled.contour plots, for which i haven't found a response in previous posts - sorry if already treated. i'd like to draw several filled.contour plots (that is, maps) on the same device (a postscript file, actually). I know about layout(matrix) , split.screen or par(mfrow) : it works well for simple plots, but with filled.contour plots, i get several pages instead of one page divided into several cells. I'd really like to get these maps directly on one graphs, without having to process them afterwards. Does anyone know something about that ? Thank you for your help, Alexis Berg Ingénieur de recherche LOCEAN (IPSL) - Paris [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 and provide commented, minimal, self-contained, reproducible code. __ 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 and provide commented, minimal, self-contained, reproducible code.
Re: [R] Sorting rows of a binary matrix
On Thu, 22 Feb 2007, Serguei Kaniovski wrote: Hallo, The command: x - 3 mat - as.matrix(expand.grid(rep(list(0:1), x))) generates a matrix with 2^x columns containing the binary representations of the decimals from 0 to (2^x-1), here from 0 to 7. But the rows are not sorted in this order. How can sort the rows the ascending order of the decimals they represent, preferably without a function which converts binaries to decimals (which I have)? Alternatively, generate a matrix that has the rows sorted that way? The alternative: mat - as.matrix(expand.grid(rep(list(0:1), x))[ , x:1 ] ) Thanks, Serguei [[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 and provide commented, minimal, self-contained, reproducible code. Charles C. Berry(858) 534-2098 Dept of Family/Preventive Medicine E mailto:[EMAIL PROTECTED] UC San Diego http://biostat.ucsd.edu/~cberry/ La Jolla, San Diego 92093-0901 __ 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 and provide commented, minimal, self-contained, reproducible code.
[R] S Plus Debugging
Hello, I am trying to debug in S+. I know how to debug in r, but the commands in S+ seem to be different. I am just looking for a command that allows me to debug the function, and then commands that allow me to step through and find the values of different variables. Thanks! -cjkogan111 -- View this message in context: http://www.nabble.com/S-Plus-Debugging-tf3274285.html#a9105226 Sent from the R help mailing list archive at Nabble.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 and provide commented, minimal, self-contained, reproducible code.
[R] Help using Sweave with wireframe or cloud
Hi, I used the sweave package to get a 3D plot echo=F,fig=F= wireframe(volcano, shade = TRUE, aspect = c(61/87, 0.4), light.source = c(10,0,10)) @ but it gives an error message for the pdf file of this picture. Any one could help ? Thanks in advance, Matthieu [[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 and provide commented, minimal, self-contained, reproducible code.
Re: [R] Crosstabbing multiple response data
res - crossprod( as.matrix( ratings[ , -1] ) ) diag(res) - print(res, quote=F) att1 att2 att3 att1 21 att2 2 2 att3 12 res2 - crossprod(as.matrix( ratings[ , -1])) * 100 / nrow( ratings ) res2[] - paste( res2, %, sep= ) diag(res2) - print(res2, quote=F) att1 att2 att3 att1 50% 25% att2 50% 50% att3 25% 50% Be sure to bone up on format and sprintf before taking this into production. On Thu, 22 Feb 2007, Michael Wexler wrote: Using R version 2.4.1 (2006-12-18) on Windows, I have a dataset which resembles this: idatt1att2att3 1110 2100 3011 4111 ratings - data.frame(id = c(1,2,3,4), att1 = c(1,1,0,1), att2 = c(1,0,0,1), att3 = c(0,1,1,1)) I would like to get a cross tab of counts of co-ocurrence, which might resemble this: att1att2att3 att1 2 1 att222 att312 with the hope of understanding, at least pairwise, what things hang together. (Yes, there are much, much better ways to do this statistically including clustering and binary corrected correlation, but the audience I am working with asked for this version for a specific reason.) (Later on, I would also like to convert to percentages of the total unique pop, so the final version of the table would be att1att2att3 att1 50% 25% att250%50% att325%50% But I can do this in excel if I can get the first table out.) I have tried the reshape library, but could not get anything resembling this (both on its own, as well as feeding in to table()). (I have also played with transposing and using some comments from this list from 2002 and 2004, but the questioners appear to assume more knowledge than I have in use of R; the example in the posting guide was also more complex than I was ready for, I'm afraid.) Sample of some of my efforts: library(reshape) melt(ratings,id=c(id)) ds1 - melt(ratings,id=c(id)) table(ds1$variable, ds1$variable) # returns only rowcounts, 3 along diagonal xtabs(formula = value ~ ds1$variable + ds1$variable , data=ds1) # returns only a single row of collapsed counts, appears to not allow 1 variable in multiple uses I suspect I am close, so any nudges in the right direction would be helpful. Thanks much, Michael PS: www.rseek.org is very impressive, I heartily encourage its use. [[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 and provide commented, minimal, self-contained, reproducible code. Charles C. Berry(858) 534-2098 Dept of Family/Preventive Medicine E mailto:[EMAIL PROTECTED] UC San Diego http://biostat.ucsd.edu/~cberry/ La Jolla, San Diego 92093-0901 __ 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 and provide commented, minimal, self-contained, reproducible code.
Re: [R] Help using Sweave with wireframe or cloud
Matthieu Cornec wrote: Hi, I used the sweave package to get a 3D plot echo=F,fig=F= wireframe(volcano, shade = TRUE, aspect = c(61/87, 0.4), light.source = c(10,0,10)) @ but it gives an error message for the pdf file of this picture. Any one could help ? Try this. echo=FALSE,fig=TRUE= library(lattice) print(wireframe(volcano, shade = TRUE, aspect = c(61/87, 0.4), light.source = c(10,0,10))) @ Thanks in advance, Matthieu -- Kevin E. Thorpe Biostatistician/Trialist, Knowledge Translation Program Assistant Professor, Department of Public Health Sciences Faculty of Medicine, University of Toronto email: [EMAIL PROTECTED] Tel: 416.864.5776 Fax: 416.864.6057 __ 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 and provide commented, minimal, self-contained, reproducible code.
[R] How to print a double quote
Can anyone tell me how to get R to include a double quote in the middle of a character string? For example, the following code is close: fnd-Open fnd 'test' cat(fnd) Open fnd 'test' But instead of Open fnd 'test' I need: Open fnd test. Difference seems minor, but I am writing batch files for another program to read in and it has to have the double quotes to work. Thanks in advance for any help or ideas, Roger ** * This message is for the named person's use only. It may contain confidential, proprietary or legally privileged information. No right to confidential or privileged treatment of this message is waived or lost by any error in transmission. If you have received this message in error, please immediately notify the sender by e-mail, delete the message and all copies from your system and destroy any hard copies. You must not, directly or indirectly, use, disclose, distribute, print or copy any part of this message if you are not the intended recipient. __ 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 and provide commented, minimal, self-contained, reproducible code.
Re: [R] How to print a double quote
cat('Open fnd test\n') Open fnd test cat(Open fnd \test\\n) Open fnd test Bos, Roger wrote: Can anyone tell me how to get R to include a double quote in the middle of a character string? For example, the following code is close: fnd-Open fnd 'test' cat(fnd) Open fnd 'test' But instead of Open fnd 'test' I need: Open fnd test. Difference seems minor, but I am writing batch files for another program to read in and it has to have the double quotes to work. Thanks in advance for any help or ideas, Roger ** * This message is for the named person's use only. It may contain confidential, proprietary or legally privileged information. No right to confidential or privileged treatment of this message is waived or lost by any error in transmission. If you have received this message in error, please immediately notify the sender by e-mail, delete the message and all copies from your system and destroy any hard copies. You must not, directly or indirectly, use, disclose, distribute, print or copy any part of this message if you are not the intended recipient. __ 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 and provide commented, minimal, self-contained, reproducible code. __ 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 and provide commented, minimal, self-contained, reproducible code.
Re: [R] How to print a double quote
try cat(Open fnd \test\) which is the same as for C. HTH. Ranjan On Thu, 22 Feb 2007 14:09:26 -0500 Bos, Roger [EMAIL PROTECTED] wrote: Can anyone tell me how to get R to include a double quote in the middle of a character string? For example, the following code is close: fnd-Open fnd 'test' cat(fnd) Open fnd 'test' But instead of Open fnd 'test' I need: Open fnd test. Difference seems minor, but I am writing batch files for another program to read in and it has to have the double quotes to work. Thanks in advance for any help or ideas, Roger ** * This message is for the named person's use only. It may contain confidential, proprietary or legally privileged information. No right to confidential or privileged treatment of this message is waived or lost by any error in transmission. If you have received this message in error, please immediately notify the sender by e-mail, delete the message and all copies from your system and destroy any hard copies. You must not, directly or indirectly, use, disclose, distribute, print or copy any part of this message if you are not the intended recipient. __ 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 and provide commented, minimal, self-contained, reproducible code. __ 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 and provide commented, minimal, self-contained, reproducible code.
Re: [R] applying lm on an array of observations with common design matrix
On Thu, 22 Feb 2007 08:17:38 + (GMT) Prof Brian Ripley [EMAIL PROTECTED] wrote: On Thu, 22 Feb 2007, Petr Klasterecky wrote: Ranjan Maitra napsal(a): On Sun, 18 Feb 2007 07:46:56 + (GMT) Prof Brian Ripley [EMAIL PROTECTED] wrote: On Sat, 17 Feb 2007, Ranjan Maitra wrote: Dear list, I have a 4-dimensional array Y of dimension 330 x 67 x 35 x 51. I have a design matrix X of dimension 330 x 4. I want to fit a linear regression of each lm( Y[, i, j, k] ~ X). for each i, j, k. Can I do it in one shot without a loop? Yes. YY - YY dim(YY) - c(330, 67*35*51) fit - lm(YY ~ X) Actually, I am also interested in getting the p-values of some of the coefficients -- lets say the coefficient corresponding to the second column of the design matrix. Can the same be done using array-based operations? Use lapply(summary(fit), function(x) coef(x)[3,4]) (since there is a intercept, you want the third coefficient). In this context, can one also get the variance-covariance matrix of the coefficients? Sure: lapply(summary(fit), function(x) {$(x,cov.unscaled)}) But that is not the variance-covariance matrix (and it is an unusual way to write x$cov.unscaled)! Add indexing if you do not want the whole matrix. You can extract whatever you want, just take a look at ?summary.lm, section Value. It is unclear to me what the questioner expects: the estimated coefficients for different responses are independent. For a list of matrices applying to each response one could mimic vcov.lm and do lapply(summary(fit, corr=FALSE), function(so) so$sigma^2 * so$cov.unscaled) Thanks! Actually, I am really looking to compare the coefficients (let us say second and the third) beta2 - beta4 = 0 for each regression. Basically, get the two-sided p-value for the test statistic for each regression. One way of doing that is to get the dispersion matrix of each regression and then to compute the t-statistic and the p-value. That is the genesis of the question above. Is there a better way? Many thanks and best wishes, Ranjan __ 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 and provide commented, minimal, self-contained, reproducible code.
Re: [R] How to print a double quote
On Thu, 22 Feb 2007, Bos, Roger wrote: Can anyone tell me how to get R to include a double quote in the middle of a character string? FAQ 7.37 Why does backslash behave strangely inside strings? For example, the following code is close: fnd-Open fnd 'test' cat(fnd) Open fnd 'test' But instead of Open fnd 'test' I need: Open fnd test. Difference seems minor, but I am writing batch files for another program to read in and it has to have the double quotes to work. Thanks in advance for any help or ideas, Roger ** * This message is for the named person's use only. It may contain confidential, proprietary or legally privileged information. No right to confidential or privileged treatment of this message is waived or lost by any error in transmission. If you have received this message in error, please immediately notify the sender by e-mail, delete the message and all copies from your system and destroy any hard copies. You must not, directly or indirectly, use, disclose, distribute, print or copy any part of this message if you are not the intended recipient. __ 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 and provide commented, minimal, self-contained, reproducible code. -- Roger Bivand Economic Geography Section, Department of Economics, Norwegian School of Economics and Business Administration, Helleveien 30, N-5045 Bergen, Norway. voice: +47 55 95 93 55; fax +47 55 95 95 43 e-mail: [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 and provide commented, minimal, self-contained, reproducible code.
[R] Principal Component Analysis explained variance
Hi there, How can I know the explaned variance of a PC axis generated by prcomp()? Kind regards, miltinho Brazil __ [[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 and provide commented, minimal, self-contained, reproducible code.
Re: [R] Principal Component Analysis explained variance
Milton Cezar Ribeiro wrote: Hi there, How can I know the explaned variance of a PC axis generated by prcomp()? From the standard deviations of each component, you could do something like this maybe: prcomp(USArrests, scale = TRUE)$sdev^2 / ncol(USArrests) [1] 0.62006039 0.24744129 0.08914080 0.04335752 Kind regards, miltinho Brazil __ [[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 and provide commented, minimal, self-contained, reproducible code. -- Chuck Cleland, Ph.D. NDRI, Inc. 71 West 23rd Street, 8th floor New York, NY 10010 tel: (212) 845-4495 (Tu, Th) tel: (732) 512-0171 (M, W, F) fax: (917) 438-0894 __ 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 and provide commented, minimal, self-contained, reproducible code.
Re: [R] how to install a package in R on a linux machine?
I tried a few times and still couldn't figure out the correct way to install this package. Help us to help you, Gallon. Which error comes out? install.packages(packagename) this downloads the package and installs it into the default R package library on your machine. Of course, on a normal installation R need to be run by root to do this, in order to write in a system directory like /usr/lib/. If you want to install it to a different directory use the 'lib' argument of 'install.packages'. Again, the user running R must have writing access to the directory specified by the 'lib' option. This option allows to install R packages in a directory in your /home, typically. Maybe you want to try (dependencies=TRUE) to automagically download and install dependencies. And of course you downloaded the appropriate package for you R version. __ 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 and provide commented, minimal, self-contained, reproducible code.
[R] question about boxplot
Here is a question from an old guy: I want to use the boxplot function as follows: boxplot( p.prop ~ R + bins ) This command makes nice boxplot for the factor R crossed with the factor bins. I am having alot of trouble getting control of the labels on the X axis. I want to control it more by specifying what the labels are, controling the 'size' of those labels (by using cex), and then control the rotation of the character strings of those labels (by using srt or crt). There is a names argument to boxplot, but I haven't had much luck controlling what it prints, the size of the font, and the character rotation. Can somebody enlighten me on how to do this? Please respond to my work email address: [EMAIL PROTECTED] Many thanks! Phil Smith Centers for Disease COntrol and Prevention [[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 and provide commented, minimal, self-contained, reproducible code.
[R] problem with weights on lmer function
Hi, I try to make a model using lmer, but the weigths is not accept. m1-lmer(ocup/total~tempo+(tempo|estacao),family=binomial,weights=total) Erro em lmer(ocup/total ~ tempo + (tempo | estacao), family = binomial, : object `weights' of incorrect type I dont understand why this error, with glm this work. the total object is a vector. Any idea? Thanks Ronaldo -- God is subtle, but he is not malicious. -- Albert Einstein -- Prof. Ronaldo Reis Júnior | .''`. UNIMONTES/Depto. Biologia Geral/Lab. Ecologia Evolutiva | : :' : Campus Universitário Prof. Darcy Ribeiro, Vila Mauricéia | `. `'` CP: 126, CEP: 39401-089, Montes Claros - MG - Brasil | `- Fone: (38) 3229-8190 | [EMAIL PROTECTED] | [EMAIL PROTECTED] | ICQ#: 5692561 | LinuxUser#: 205366 __ 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 and provide commented, minimal, self-contained, reproducible code.
[R] JGR launcher for linux
Hi, anybody have a JGR launcher for linux? Maybe a script that launch JGR directly without open R then library(JGR) and JGR(). Thanks Ronaldo -- Deflector shields just came on, Captain. -- Prof. Ronaldo Reis Júnior | .''`. UNIMONTES/Depto. Biologia Geral/Lab. Ecologia Evolutiva | : :' : Campus Universitário Prof. Darcy Ribeiro, Vila Mauricéia | `. `'` CP: 126, CEP: 39401-089, Montes Claros - MG - Brasil | `- Fone: (38) 3229-8190 | [EMAIL PROTECTED] | [EMAIL PROTECTED] | ICQ#: 5692561 | LinuxUser#: 205366 __ 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 and provide commented, minimal, self-contained, reproducible code.
[R] confidence intervals
Hi, I'm having trouble with the confidence interval of the nls function. I did my home work, and searched acros the support list until I came up with following solution of Peter Dalgaard: example(predict.nls) se.fit - sqrt(apply(attr(predict(fm,list(Time = tt)),gradient),1, function(x) sum(vcov(fm)*outer(x,x matplot(tt, predict(fm,list(Time = tt))+ outer(se.fit,qnorm(c(.5, .025,.975))),type=l) points(demand ~ Time, data = BOD) One slight issue is that it doesn't work if newdata is omitted, but then you can easily get the gradient from fm$m$gradient() I tried this with my own data: Data - data.frame(Temp=rep(c(25,40),each=3), Mnd = c(1:3),Degr = c(0.057,0.077,0.108,0.148,0.198,0.223)) model - nls(Degr~exp((A/(Temp)+log(Mnd))*B),Data,start=list(A=-10,B=1)) Months - c(1,2,3,6,9,12,24,48) se.fit - sqrt(apply(attr(predict(model,list(Temp = 25,Mnd=Months)),gradient),1, function(x) sum(vcov(fm)*outer(x,x But unfortunately I get an error ( Error in apply(attr(predict(model, list(Temp = 25, Mnd = Months)), gradient), : dim(X) must have a positive length) When I try using the gradient of the model instead of using the new data then there is no problem: se.fit - sqrt(apply(model$m$gradient(),1, function(x) sum(vcov(model)*outer(x,x matplot(Data$Mnd, predict(model,list(Temp = Data$Temp,Mnd=Data$Mnd))+outer(se.fit,qnorm(c(.5, 025,.975))),type=l) But how about calculating confidence intervals of new data? How do I get an gradient for these values? I'm using Windows XP, R 2.4.1. Thanks Bart [[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 and provide commented, minimal, self-contained, reproducible code.
[R] R equivalent of the VAR function in S+Finmetrics
I was looking at the systemfit package and it seems like I could use it to solve OLS systems ( which is essentially what VARs are ) but the lag length would have to be known beforehand, I think. Does anyone know if there is an equivalent of the VAR function in Eric Zivot's S+Finmetrics package where the lag length can be selected based on some kind of criterion such as BIC for example. Thanks for any idea/suggestions. This is not an offer (or solicitation of an offer) to buy/se...{{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 and provide commented, minimal, self-contained, reproducible code.
Re: [R] JGR launcher for linux
Isn't it right in front of you? I get: JGR() Starting JGR ... (You can use /usr/local/lib64/R/library/JGR/cont/run to start JGR directly) ^^^ Andy From: Ronaldo Reis Junior Hi, anybody have a JGR launcher for linux? Maybe a script that launch JGR directly without open R then library(JGR) and JGR(). Thanks Ronaldo -- Deflector shields just came on, Captain. -- Prof. Ronaldo Reis Júnior | .''`. UNIMONTES/Depto. Biologia Geral/Lab. Ecologia Evolutiva | : :' : Campus Universitário Prof. Darcy Ribeiro, Vila Mauricéia `. | `'` CP: 126, CEP: 39401-089, Montes Claros - MG - Brasil | `- Fone: (38) 3229-8190 | [EMAIL PROTECTED] | | [EMAIL PROTECTED] | ICQ#: 5692561 | LinuxUser#: 205366 __ 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 and provide commented, minimal, self-contained, reproducible code. -- Notice: This e-mail message, together with any attachments,...{{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 and provide commented, minimal, self-contained, reproducible code.
Re: [R] question about boxplot
On Feb 22, 2007, at 2:56 PM, Smith, Phil ((CDC/CCID/NCIRD)) wrote: boxplot( p.prop ~ R + bins ) This command makes nice boxplot for the factor R crossed with the factor bins. I am having alot of trouble getting control of the labels on the X axis. I want to control it more by specifying what the labels are, controling the 'size' of those labels (by using cex), and then control the rotation of the character strings of those labels (by using srt or crt). There is a names argument to boxplot, but I haven't had much luck controlling what it prints, the size of the font, and the character rotation. Would you consider an easy way out---an alternative with reasonable defaults? data(ToothGrowth) bwplot(dose ~ len | supp, ToothGrowth) _ Professor Michael Kubovy University of Virginia Department of Psychology USPS: P.O.Box 400400Charlottesville, VA 22904-4400 Parcels:Room 102Gilmer Hall McCormick RoadCharlottesville, VA 22903 Office:B011+1-434-982-4729 Lab:B019+1-434-982-4751 Fax:+1-434-982-4766 WWW:http://www.people.virginia.edu/~mk9y/ __ 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 and provide commented, minimal, self-contained, reproducible code.
[R] is a time series regression model a causal forecasting model?
I have a semantics question, I am reading Bowerman and O'Connell and they state that forecasting models fall into two categories, univariate and causal. My question is whether a time series regression model that relates the time series of interest to functions of time such as the day of the week or month of the year could be considered a causal model? thanks, spencer [[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 and provide commented, minimal, self-contained, reproducible code.
Re: [R] how to install a package in R on a linux machine?
Hi, try this: $sudo R CMD INSTALL downloaded.package.tar.gz If you don't use 'sudo' (or do not have privileges to do so), you need to either become root (with su) or ask the administrator of the machine you are using to install the package for you regards, Roberto On 2/22/07, Gabor Csardi [EMAIL PROTECTED] wrote: The easiest is perhaps to do install.packages(packagename) this downloads the package and installs it into the default R package library on your machine. If you want to install it to a different directory use the 'lib' argument of 'install.packages'. If you don't want to download the package again but want to use the downloaded one, use the following command: install.packages(repos=NULL, pkgs=the.file.you've.downloaded) You can also install R packages from the command line, like this: R CMD INSTALL -l lib.directectory downloaded.package.file Gabor On Thu, Feb 22, 2007 at 04:44:25PM +0800, gallon li wrote: I downloaded the tar.gz file from r-project website (and saved it in a local directory) and wish to use the package in R. But I am not sure how to use the install.packages command. I tried a few times and still couldn't figure out the correct way to install this package. [[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 and provide commented, minimal, self-contained, reproducible code. -- Csardi Gabor [EMAIL PROTECTED]MTA RMKI, ELTE TTK __ 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 and provide commented, minimal, self-contained, reproducible code. __ 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 and provide commented, minimal, self-contained, reproducible code.
[R] A question regarding cutree
Hi Everyone, I am doing hierarchical clustering analysis and have a question regarding cutree. I am doing things like this: hc - hclust(dist(X)) a - cutree(hc, k=2) Basically a is a vector containing the assignments of 1 or 2 for each sample. May I know how cutree decides to assign 1 and 2's to each sample (in other words, how clusters 1 and 2 are decided)? I am having the feeling that Sample 1 will be always assigned to Cluster 1, but I am not sure about this. Thank you! Best, Jun __ 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 and provide commented, minimal, self-contained, reproducible code.
Re: [R] investigating interactions with mixed models
Hello Rachel, I don't think that there is any infrastructure for these procedures on lmer objects, yet. If you are willing to use lme instead, then the multcomp package seems to provide post-hoc tests. It is worth noting that there is some doubt as to the validity of the reference distributions for tests of fixed effects in the presence of random effects. http://cran.r-project.org/doc/FAQ/R-FAQ.html#Why-are-p_002dvalues-not-displayed-when-using-lmer_0028_0029_003f Cheers Andrew On Thu, Feb 22, 2007 at 12:32:44PM +, R. Baker wrote: I'm investigating a number of dependent variables using mixed models, e.g. data.lmer45 = lmer(ampStopB ~ (type + stress + MorD)^3 + (1|speaker) + (1|word), data=data) The p-values for some of the 2-way and 3-way interactions are significant at a 0.05 level and I have been trying to find out how to understand the exact nature of the interactions. Does anyone know if it is possible to run post-hoc tests on mixed model (lmer) objects? I have read about TukeyHSD but it seems that this can only be run on anova (aov) objects. Any suggestions would be gratefully appreciated! Rachel Baker -- -- PhD student Dept of Linguistics Sidgwick Avenue University of Cambridge Cambridge __ 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 and provide commented, minimal, self-contained, reproducible code. -- Andrew Robinson Department of Mathematics and StatisticsTel: +61-3-8344-9763 University of Melbourne, VIC 3010 Australia Fax: +61-3-8344-4599 http://www.ms.unimelb.edu.au/~andrewpr http://blogs.mbs.edu/fishing-in-the-bay/ __ 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 and provide commented, minimal, self-contained, reproducible code.
Re: [R] problem with weights on lmer function
Hi Ronaldo, I suggest that you send us a small, well-documented, code example that we can reproduce. It certainly looks as though there is a problem, but given this information it's hard to know what it is! Cheers Andrew On Thu, Feb 22, 2007 at 06:22:03PM -0200, Ronaldo Reis Junior wrote: Hi, I try to make a model using lmer, but the weigths is not accept. m1-lmer(ocup/total~tempo+(tempo|estacao),family=binomial,weights=total) Erro em lmer(ocup/total ~ tempo + (tempo | estacao), family = binomial, : object `weights' of incorrect type I dont understand why this error, with glm this work. the total object is a vector. Any idea? Thanks Ronaldo -- God is subtle, but he is not malicious. -- Albert Einstein -- Prof. Ronaldo Reis J?nior | .''`. UNIMONTES/Depto. Biologia Geral/Lab. Ecologia Evolutiva | : :' : Campus Universit?rio Prof. Darcy Ribeiro, Vila Mauric?ia | `. `'` CP: 126, CEP: 39401-089, Montes Claros - MG - Brasil | `- Fone: (38) 3229-8190 | [EMAIL PROTECTED] | [EMAIL PROTECTED] | ICQ#: 5692561 | LinuxUser#: 205366 __ 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 and provide commented, minimal, self-contained, reproducible code. -- Andrew Robinson Department of Mathematics and StatisticsTel: +61-3-8344-9763 University of Melbourne, VIC 3010 Australia Fax: +61-3-8344-4599 http://www.ms.unimelb.edu.au/~andrewpr http://blogs.mbs.edu/fishing-in-the-bay/ __ 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 and provide commented, minimal, self-contained, reproducible code.
Re: [R] investigating interactions with mixed models
?interaction.plot Should help you. This works on the data, not the model. A 3-way interaction just means that the 2-way interaction differs among the various levels of the 3rd factor. Clever use of trellis plots (?xyplot -- especially ?panel.linejoin -- gives greater flexibility, but it requires that a steeper learning curve be climbed). In general, the presence of interactions is just another manifestation of the response varying nonlinearly in the factors (**not** in the parameters, of course -- it's a linear model after all). This is essentially always the case, it's just a question of whether the signal/noise ratio (which depends on sample size) is large enough to see it via P-values. So by all means look at the plots and try to understand and interpret what's going on; but by no means assume that p-values above and below a threshhold of .05 are a clear guide to determining this. As usual, statistical significance and scientific relevance are not equivalent, and the degree of overlap between the two is often difficult to judge. Cheers, Bert Gunter Genentech Nonclinical Statistics South San Francisco, CA 94404 650-467-7374 -Original Message- From: [EMAIL PROTECTED] [mailto:[EMAIL PROTECTED] On Behalf Of Andrew Robinson Sent: Thursday, February 22, 2007 2:32 PM To: R. Baker Cc: r-help@stat.math.ethz.ch Subject: Re: [R] investigating interactions with mixed models Hello Rachel, I don't think that there is any infrastructure for these procedures on lmer objects, yet. If you are willing to use lme instead, then the multcomp package seems to provide post-hoc tests. It is worth noting that there is some doubt as to the validity of the reference distributions for tests of fixed effects in the presence of random effects. http://cran.r-project.org/doc/FAQ/R-FAQ.html#Why-are-p_002dvalues-not-displa yed-when-using-lmer_0028_0029_003f Cheers Andrew On Thu, Feb 22, 2007 at 12:32:44PM +, R. Baker wrote: I'm investigating a number of dependent variables using mixed models, e.g. data.lmer45 = lmer(ampStopB ~ (type + stress + MorD)^3 + (1|speaker) + (1|word), data=data) The p-values for some of the 2-way and 3-way interactions are significant at a 0.05 level and I have been trying to find out how to understand the exact nature of the interactions. Does anyone know if it is possible to run post-hoc tests on mixed model (lmer) objects? I have read about TukeyHSD but it seems that this can only be run on anova (aov) objects. Any suggestions would be gratefully appreciated! Rachel Baker -- -- PhD student Dept of Linguistics Sidgwick Avenue University of Cambridge Cambridge __ 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 and provide commented, minimal, self-contained, reproducible code. -- Andrew Robinson Department of Mathematics and StatisticsTel: +61-3-8344-9763 University of Melbourne, VIC 3010 Australia Fax: +61-3-8344-4599 http://www.ms.unimelb.edu.au/~andrewpr http://blogs.mbs.edu/fishing-in-the-bay/ __ 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 and provide commented, minimal, self-contained, reproducible code. __ 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 and provide commented, minimal, self-contained, reproducible code.
Re: [R] Chi-Square test
?pchisq On 2/21/07, Mohsen Jafarikia [EMAIL PROTECTED] wrote: Hello all, I am doing a Likelihood Ratio (LR) test in my simulation and I have a vector LR values (each with 1 degree of freedom) at the end of my simulation. Can anybody tell me how I can write a 'R' code which gives me the p-value for each of those LR values. Thanks [[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 and provide commented, minimal, self-contained, reproducible code. -- WenSui Liu A lousy statistician who happens to know a little programming (http://spaces.msn.com/statcompute/blog) __ 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 and provide commented, minimal, self-contained, reproducible code.
Re: [R] manova discriminant functions: Addendum
Three weeks later, I have almost completely solved my problem (quoted below; about within-subjects manova, and discriminant function analysis to compliment a manova analysis). So for anyone who was secretly hoping someone would respond to me: * manova does not handle within-subjects variables in a manner which is very intuitive for those not in the field of statistics or mathematics. The anova.mlm functions allow this sort of analysis, but for applied statisticians (read: social scientists), dealing with inner vs outer projections is a bit opaque. * However, a bit of knowledge on what repeated measures MANOVA really does is very helpful. (No, really, it helps to know what you're trying to do!) The general idea is that you create contrast columns for the within-subjects factors, such that the contrast columns are orthogonal. Then, you submit these to a general MANOVA with between-subject predictors to test the within-between interactions. * For within-subjects main effects, it's easier (for me) to just compute the hypothesis matrix myself. With orthogonal contrast factors, it's pretty simple: each row of the hypothesis matrix is the product of the column of means for the contrast columns times the mean for that row's contrast, times the number of observations. The error matrix can be taken directly from the fit for the interaction (see point 2); then, H %*% ginv(E) gives the effect matrix for the within subjects main effect, whose eigenvalues can be evaluated with the appropriate degrees of freedom. I wrote a function to do this, if anyone is interested. * The current implementation of the Pillai() function uses Pillai's (1954) approximation of an F value for a given V, despite the much more robust and (seemingly) uncontroversial method of estimating F put forth by Muller in 1998. This is, of course, what SPSS and SAS do (unless you require SAS to do exact tests, which is still a misnomer), but it doesn't seem to me like R ought to do things poorly just to give the same results as SPSS. * Estimating several within-subjects effects basically amounts to providing the relevant contrast matrices to the interaction analyses, and then testing subsets relative to the overall residual matrix and the right number of df. * To get discriminant functions and variable loadings, use the lda() function. The fact that these are provided by manova() analogues in other software packages was just a red herring! * However, this also does not work for discovering within-subjects discriminant functions. And that, I'm afraid, is where I'm now stuck...any suggestions on an lda() analogue for within-subject factors? An example: data - data.frame(treat=factor(rep(c(Control,Treatment),3)), time1=c(1,5,1,5,1,5), time2=c(2,8,1,7,2,6), time3=c(3,9,3,9,2,10)) data.poly - data[,2:4] %*% contr.poly(3) Now, discriminant functions on predicting the difference between Control and Treatment, using the three timepoints is easy: Convert them to orthogonal contrast variables, and then see how to discriminate treatment conditions based on the linear and quadratic effects of time: lda(data$treat ~ data.poly) ...but my question is how to do an lda predicting whether an observation came from the time1, time2, or time3 column. Thanks, Adam On Mon, 5 Feb 2007, Adam D. I. Kramer wrote: As an addendum to my earlier post, I am having another difficulty with getting manova() to behave as I would like: when I specify contrasts for my independent variable(s), I am unsure of how to test them. This is a contrived example of both of my questions: Assume three alertness measurements, alert1 alert2 alert3, a within-subjects variable measuring their alertness at three timepoints, minutes after taking the drug (alert1), one hour (alert2), and two hours (alert3). The between-subjects variable is dosage, with dose==0 when subjects have had no drug, dose==1 when they have had a single dose, dose==2 when they have had a double dose. My intuition says to do the following: alert - cbind(alert1,alert2,alert3) %*% contr.poly(3) contrasts(dose) - matrix(c(2,-1,-1,0,1,-1),3,2) m - manova(alert ~ dose) ...what I want is two main effects (dose and alert) and one interaction (dose by alert), but also main effect and interaction for the two individual contrasts for dose. For the main effect for alert, and all of the dose*alert interactions, I need the discriminant function loadings of my two alertness contrasts in order to interpret the manner in which alertness is varying (e.g., is it varying in a linear or quadratic way). m2 - manova (alert ~ dose) summary(m2) ...gives me a test for the dose * alertness interaction. Good! But I can't seem to find the contrasts I asked for for dose. In univariate ANOVA, I usually just call summary.lm() which gives me t-test coefficients for each level
[R] Wrinting integers in a matrix faile
Hello everyone, I am using the following program to get the p-value of some numbers (column 'LR' of the data.dat file). I want to write the 1st and 2nd column of the output file (data.out) as an integer while the program change them to double. Could anybody please tell me how I can write the code which writes the values of the first two columns as integer? Thanks library ('MASS') MP-read.table(file='data.dat') names(MP)-c('B','R','S','L','LR','Q') a-as.matrix((1-pchisq(MP$LR, df=1))) b-cbind(MP$B,MP$R,a,MP$S,MP$L,MP$LR,MP$Q) write.matrix(b,'data.out') __ 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 and provide commented, minimal, self-contained, reproducible code.
[R] mixture of 2 normals - starting values
Hi, I have a problem of estimating a mixture of two normal distributions. I need to find the starting points automatically, since this is a part of a larger piece of image processing code. I found the mix2normal1 function in VGAM package that mentions a method of finding starting values for mu1 and mu2 but refers the reader to a book by Everitt and Hand. Unfortunately, I do not have an easy access to this book. Could anybody point me to a description of the method that I could use? Any help will be appreciated. Thanks in advance, Andy __ Andy Jaworski 518-1-01 Process Laboratory 3M Corporate Research Laboratory - E-mail: [EMAIL PROTECTED] Tel: (651) 733-6092 Fax: (651) 736-3122 __ 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 and provide commented, minimal, self-contained, reproducible code.
Re: [R] mixture of 2 normals - starting values
Hi, Try MCLUST package. You can use the hierarchical clustering to find the starting values of your EM. Xiaohui [EMAIL PROTECTED] wrote: Hi, I have a problem of estimating a mixture of two normal distributions. I need to find the starting points automatically, since this is a part of a larger piece of image processing code. I found the mix2normal1 function in VGAM package that mentions a method of finding starting values for mu1 and mu2 but refers the reader to a book by Everitt and Hand. Unfortunately, I do not have an easy access to this book. Could anybody point me to a description of the method that I could use? Any help will be appreciated. Thanks in advance, Andy __ Andy Jaworski 518-1-01 Process Laboratory 3M Corporate Research Laboratory - E-mail: [EMAIL PROTECTED] Tel: (651) 733-6092 Fax: (651) 736-3122 __ 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 and provide commented, minimal, self-contained, reproducible code. __ 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 and provide commented, minimal, self-contained, reproducible code.
[R] Extracting a subset from a dataframe
Good day everyone, Can anyone suggest an effective method to solve the following problem: I have 2 dataframes D1 and D2 as follows: D1: dates ws wc pwc 2005-10-19:12:00 10.8 80 81 2005-10-20:12:00 12.3 5 15 2005-10-21:15:00 12.3 3 15 2005-10-22:15:00 11.3 13 95 2005-10-23:12:00 12.3 13 2 2005-10-24:15:00 10.3 2 95 2005-10-25:15:00 10.3 2 2 D2: dates ws wc pwc 2005-02-02:15:00 17.5 5 96 2005-02-19:15:00 20.1 15 97 2005-02-20:18:00 16.5 95 95 2005-03-03:18:00 10.3 95 95 2005-03-04:00:00 13.4 13 95 2005-10-22:15:00 11.3 13 95 2005-10-25:15:00 10.3 2 2 I want to create another dataframe made up of the values of dataframe1 which are not common with dataframe2, ie. newD = D1 - (D1 intersection D2) that is, newD: datesws wc pwc 2005-10-19:12:00 10.8 80 81 2005-10-20:12:00 12.3 5 15 2005-10-21:15:00 12.3 3 15 2005-10-23:12:00 12.3 13 2 2005-10-24:15:00 10.3 2 95 Thanks for any help you can provide, Augusto Augusto Sanabria. MSc, PhD. Mathematical Modeller Risk Research Group Geospatial Earth Monitoring Division Geoscience Australia (www.ga.gov.au) Cnr. Jerrabomberra Av. Hindmarsh Dr. Symonston ACT 2601 Ph. (02) 6249-9155 __ 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 and provide commented, minimal, self-contained, reproducible code.
Re: [R] Extracting a subset from a dataframe
Try: D1[setdiff(D1$dates,D2$dates) , ] Xiaohui [EMAIL PROTECTED] wrote: Good day everyone, Can anyone suggest an effective method to solve the following problem: I have 2 dataframes D1 and D2 as follows: D1: dates ws wc pwc 2005-10-19:12:00 10.8 80 81 2005-10-20:12:00 12.3 5 15 2005-10-21:15:00 12.3 3 15 2005-10-22:15:00 11.3 13 95 2005-10-23:12:00 12.3 13 2 2005-10-24:15:00 10.3 2 95 2005-10-25:15:00 10.3 2 2 D2: dates ws wc pwc 2005-02-02:15:00 17.5 5 96 2005-02-19:15:00 20.1 15 97 2005-02-20:18:00 16.5 95 95 2005-03-03:18:00 10.3 95 95 2005-03-04:00:00 13.4 13 95 2005-10-22:15:00 11.3 13 95 2005-10-25:15:00 10.3 2 2 I want to create another dataframe made up of the values of dataframe1 which are not common with dataframe2, ie. newD = D1 - (D1 intersection D2) that is, newD: datesws wc pwc 2005-10-19:12:00 10.8 80 81 2005-10-20:12:00 12.3 5 15 2005-10-21:15:00 12.3 3 15 2005-10-23:12:00 12.3 13 2 2005-10-24:15:00 10.3 2 95 Thanks for any help you can provide, Augusto Augusto Sanabria. MSc, PhD. Mathematical Modeller Risk Research Group Geospatial Earth Monitoring Division Geoscience Australia (www.ga.gov.au) Cnr. Jerrabomberra Av. Hindmarsh Dr. Symonston ACT 2601 Ph. (02) 6249-9155 __ 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 and provide commented, minimal, self-contained, reproducible code. __ 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 and provide commented, minimal, self-contained, reproducible code.
Re: [R] Extracting a subset from a dataframe
Augusto cnd - D1$dates %in% D2$dates D1[!cnd,] should do it. Med venlig hilsen / Regards Frede Aakmann Tøgersen Forsker / Scientist AARHUS UNIVERSITET / UNIVERSITY OF AARHUS Det Jordbrugsvidenskabelige Fakultet / Faculty of Agricultural Sciences Forskningscenter Foulum / Research Centre Foulum Genetik og Bioteknologi / Dept. of Genetics and Biotechnology Blichers Allé 20, P.O. BOX 50 DK-8830 Tjele Tel: +45 8999 1900 Direct: +45 8999 1878 Mobile: +45 E-mail: [EMAIL PROTECTED] mailto:[EMAIL PROTECTED] Web: www.agrsci.dk https://djfpost.agrsci.dk/exchweb/bin/redir.asp?URL=http://www.agrsci.dk/ Tilmeld dig DJF's nyhedsbrev / Subscribe Faculty of Agricultural Sciences Newsletter https://djfpost.agrsci.dk/exchweb/bin/redir.asp?URL=http://www.agrsci.dk/user/register?lan=dan-DK . Denne email kan indeholde fortrolig information. Enhver brug eller offentliggørelse af denne email uden skriftlig tilladelse fra DJF er ikke tilladt. Hvis De ikke er den tiltænkte adressat, bedes De venligst straks underrette DJF samt slette emailen. This email may contain information that is confidential. Any use or publication of this email without written permission from Faculty of Agricultural Sciences is not allowed. If you are not the intended recipient, please notify Faculty of Agricultural Sciences immediately and delete this email. Fra: [EMAIL PROTECTED] på vegne af [EMAIL PROTECTED] Sendt: fr 23-02-2007 07:26 Til: R-help@stat.math.ethz.ch Emne: [R] Extracting a subset from a dataframe Good day everyone, Can anyone suggest an effective method to solve the following problem: I have 2 dataframes D1 and D2 as follows: D1: dates ws wc pwc 2005-10-19:12:00 10.8 80 81 2005-10-20:12:00 12.3 5 15 2005-10-21:15:00 12.3 3 15 2005-10-22:15:00 11.3 13 95 2005-10-23:12:00 12.3 13 2 2005-10-24:15:00 10.3 2 95 2005-10-25:15:00 10.3 2 2 D2: dates ws wc pwc 2005-02-02:15:00 17.5 5 96 2005-02-19:15:00 20.1 15 97 2005-02-20:18:00 16.5 95 95 2005-03-03:18:00 10.3 95 95 2005-03-04:00:00 13.4 13 95 2005-10-22:15:00 11.3 13 95 2005-10-25:15:00 10.3 2 2 I want to create another dataframe made up of the values of dataframe1 which are not common with dataframe2, ie. newD = D1 - (D1 intersection D2) that is, newD: datesws wc pwc 2005-10-19:12:00 10.8 80 81 2005-10-20:12:00 12.3 5 15 2005-10-21:15:00 12.3 3 15 2005-10-23:12:00 12.3 13 2 2005-10-24:15:00 10.3 2 95 Thanks for any help you can provide, Augusto Augusto Sanabria. MSc, PhD. Mathematical Modeller Risk Research Group Geospatial Earth Monitoring Division Geoscience Australia (www.ga.gov.au) Cnr. Jerrabomberra Av. Hindmarsh Dr. Symonston ACT 2601 Ph. (02) 6249-9155 __ 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 and provide commented, minimal, self-contained, reproducible code. __ 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 and provide commented, minimal, self-contained, reproducible code.