Re: [R] Tetrachoric correlation in R vs. stata
Dear Janet, A good thing to do when different software gives different answers is to check each against known results. I'm away from home, and don't have all of the examples that I used to check polychor(), but I dug up the following. The polychor() function produces output that agrees with both of these sources. How does Stata do? > # example from Drasgow (1988), pp. 69-74 in Kotz and Johnson, > # Encyclopedia of statistical sciences. Vol. 7. > tab [,1] [,2] [,3] [1,] 58 521 [2,] 26 583 [3,]8 129 > polychor(tab, std.err=TRUE) Polychoric Correlation, 2-step est. = 0.42 (0.07474) Test of bivariate normality: Chisquare = 11.55, df = 3, p = 0.009078 > polychor(tab, ML=TRUE, std.err=TRUE) Polychoric Correlation, ML est. = 0.4191 (0.07616) Test of bivariate normality: Chisquare = 11.54, df = 3, p = 0.009157 Row Thresholds Threshold Std.Err. 1 -0.02988 0.08299 2 1.13300 0.10630 Column Thresholds Threshold Std.Err. 1 -0.2422 0.08361 21.5940 0.13720 > tab # example from Brown (1977) Applied Statistics, 26:343-351. [,1] [,2] [1,] 1562 42 [2,] 383 94 > polychor(tab) [1] 0.595824 > Regards, John On Fri, 23 Jun 2006 14:33:31 -0700 Janet Rosenbaum <[EMAIL PROTECTED]> wrote: > Peter --- Thanks for pointing out the omitted information. The > hazards > of attempting to be brief. > > In R, I am using polychor(vec1, vec2, std.err=T) and have used both > the > ML and 2 step estimates, which give virtually identical answers. I > am > explicitly using only the 632 complete cases in R to make sure > missing > data is handled the same way as in stata. > > Here's my data: > > 522 54 > 3422 > > > polychor(v1, v2, std.err=T, ML=T) > > Polychoric Correlation, ML est. = 0.5172 (0.08048) > Test of bivariate normality: Chisquare = 8.063e-06, df = 0, p = NaN > > Row Thresholds > Threshold Std.Err. > 1 1.349 0.07042 > > > Column Thresholds > Threshold Std.Err. > 1 1.174 0.06458 > Warning message: > NaNs produced in: pchisq(q, df, lower.tail, log.p) > > In stata, I get: > > . tetrachoric t1_v19a ct1_ix17 > > Tetrachoric correlations (N=632) > > -- > Variable | t1_v19a ct1_ix17 > -+ > t1_v19a |1 > ct1_ix17 |.6169 1 > -- > > Thanks for your help. > > Janet > > > > Peter Dalgaard wrote: > > Janet Rosenbaum <[EMAIL PROTECTED]> writes: > > > >> I hope someone here knows the answer to this since it will save me > from > >> delving deep into documentation. > >> > >> Based on 22 pairs of vectors, I have noticed that tetrachoric > >> correlation coefficients in stata are almost uniformly higher than > those > >> in R, sometimes dramatically so (TCC=.61 in stata, .51 in R; .51 > in > >> stata, .39 in R). Stata's estimate is higher than R's in 20 out > of 22 > >> computations, although the estimates always fall within the 95% CI > for > >> the TCC calculated by R. > >> > >> Do stata and R calculate TCC in dramatically different ways? Is > the > >> handling of missing data perhaps different? Any thoughts? > >> > >> Btw, I am sending this question only to the R-help list. > > > > > > A bit more information seems necessary: > > > > - tetrachoric correlations depend on 4 numbers, so you should be > able > > to give a direct example > > > > - you're not telling us how you calculate the TCC in R. This is not > > obvious (package polycor?). > > > > > > > This email message is for the sole use of the intended\ > ...{{dropped}} __ R-help@stat.math.ethz.ch mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide! http://www.R-project.org/posting-guide.html
Re: [R] R Reporting - PDF/HTML mature presentation quality package?
zubin wrote: > Hello, searching for the key packages so i can output, Text, Tables ,and > Graphics into a HTML or PDF report - have R create these reports in an > easy and efficient way without LaTeX - I have searched the R pages but > don't see any mature packages - anyone have any advice on a easy to use > R package one can use for generating publication quality reports? > Outputting HTML or PDF. Doing this without LaTeX is like doing statistical analysis without linear models and the Wilcoxon test. -- 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
Re: [R] data frame search
which is part of base R so look again. On 6/24/06, Bart Joosen <[EMAIL PROTECTED]> wrote: > Thanks, couldn't find this function, > > Best regards > > Bart > > - Original Message - > From: "Gabor Grothendieck" <[EMAIL PROTECTED]> > To: "Bart Joosen" <[EMAIL PROTECTED]> > Cc: > Sent: Saturday, June 24, 2006 1:15 PM > Subject: Re: [R] data frame search > > > > Try this: > > > > which(DF1 == 4, arr.ind = TRUE) > > > > > > On 6/24/06, Bart Joosen <[EMAIL PROTECTED]> wrote: > >> Hi, > >> > >> I want to make a data frame which contains the positions of some searched > >> values in another data frame. > >> > >> Like: > >> Dataframe 1: > >> > >> 1 2 3 4 1 2 3 4 > >> 2 3 4 1 2 3 4 2 > >> 4 1 2 3 2 3 4 1 > >> > >> Let's say I searched on "4", then Dataframe 2 should contain: > >> x y > >> 1 4 > >> 1 8 > >> 2 3 > >> 2 7 > >> 3 1 > >> 3 7 > >> > >> I have written a routine, but it seems to me that it isn't that perfect: > >> x<- 0 > >> > >> y<- 0 > >> > >> for (j in 1:ncol(df)) { > >> > >> for (i in 1:nrow(df)) { > >> > >> if (df[i,j] == 3) { > >> > >> x <- c(x,i) > >> > >> y <- c(y,j) > >> > >> } > >> > >> } > >> > >> } > >> > >> df2 <- data.frame(x,y) > >> > >> df2 <- df2[-1,] > >> > >> Can someone come up with an elegant/faster solution, because the ultimate > >> goal of this routine is to analyze an jpg image. > >> > >> Kind regards > >> > >> Bart > > > __ R-help@stat.math.ethz.ch mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide! http://www.R-project.org/posting-guide.html
[R] Rebuild private R package.
Hello! Suppose I have my own R-package with long src/ subdirectory. If I edit only one file from this directory what I have to do to make R recompile only this file and resulting *.so library but not the all other source files? It looks to me like the default behaviour has changed in R-2.3.1. Thank you. M.Kondrin __ R-help@stat.math.ethz.ch mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide! http://www.R-project.org/posting-guide.html
[R] R Reporting - PDF/HTML mature presentation quality package?
Hello, searching for the key packages so i can output, Text, Tables ,and Graphics into a HTML or PDF report - have R create these reports in an easy and efficient way without LaTeX - I have searched the R pages but don't see any mature packages - anyone have any advice on a easy to use R package one can use for generating publication quality reports? Outputting HTML or PDF. __ R-help@stat.math.ethz.ch mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide! http://www.R-project.org/posting-guide.html
Re: [R] Producing png plot in batch mode
Thanks again Prof Ripley. Under FreeBSD 6.1 I eliminated the three lines you suggested in Makevars.in and the package was compiled like a charm. Bye Vittorio Alle 16:28, sabato 24 giugno 2006, Prof Brian Ripley ha scritto: > The advice in the posting guide was to ask the package maintainer (Cc:ed > here). Please report what he had to say, as it would be helpful to the > rest of us. > > Note that the src/Makevars.in has > > # we need to add JNI specific stuff here > ifdef DEBUG > PKG_CFLAGS+=-DJGD_DEBUG > endif > > which is GNU-make specific, so you could just delete those three lines and > try again (or use GNU make). > > On Sat, 24 Jun 2006, vittorio wrote: > > SorThanks for the reply!!!.ry for my being so lazy and thanks a lot for > > your kind replies. > > > > Well, I tried to install GDD under freebsd (this time I read cafrefully > > the package docs and checked if the required libgd and > > freetype2 were installed and they were) BUT there's > > something wrong with "Makevars": > > > > > > NbBSD# R CMD INSTALL GDD_0.1-8.tar.gz > > * Installing *source* package 'GDD' ... > > checking for gcc... cc > > checking for C compiler default output file name... a.out > > checking whether the C compiler works... yes > > checking whether we are cross compiling... no > > checking for suffix of executables... > > checking for suffix of object files... o > > checking whether we are using the GNU C compiler... yes > > checking whether cc accepts -g... yes > > checking for cc option to accept ANSI C... none needed > > checking how to run the C preprocessor... cc -E > > checking for egrep... grep -E > > checking for ANSI C header files... yes > > checking for sys/wait.h that is POSIX.1 compatible... yes > > checking for sys/types.h... yes > > checking for sys/stat.h... yes > > checking for stdlib.h... yes > > checking for string.h... yes > > checking for memory.h... yes > > checking for strings.h... yes > > checking for inttypes.h... yes > > checking for stdint.h... yes > > checking for unistd.h... yes > > checking for string.h... (cached) yes > > checking sys/time.h usability... yes > > checking sys/time.h presence... yes > > checking for sys/time.h... yes > > checking for unistd.h... (cached) yes > > checking for an ANSI C-conforming const... yes > > checking whether time.h and sys/time.h may both be included... yes > > checking for stdlib.h... (cached) yes > > checking for GNU libc compatible malloc... yes > > checking return type of signal handlers... void > > checking for memset... yes > > checking for mkdir... yes > > checking for rmdir... yes > > checking for gdlib-config... /usr/local/bin/gdlib-config > > libgd-flags according to gdlib-config: > > -I/usr/local/include -L/usr/local/lib -L/usr/local/lib -lgd > > if that is not correct, fix your gd installation > > checking gd.h usability... yes > > checking gd.h presence... yes > > checking for gd.h... yes > > checking for gdImageCreateFromPng in -lgd... yes > > checking usability of FreeType in GD... yes > > checking whether GD programs can be compiled... yes > > configure: creating ./config.status > > config.status: creating src/Makevars > > config.status: creating src/gddconfig.h > > ** libs > > "Makevars", line 2: Need an operator > > "Makevars", line 4: Need an operator > > make: fatal errors encountered -- cannot continue > > chmod: /usr/local/lib/R/library/GDD/libs/*: No such file or directory > > ERROR: compilation failed for package 'GDD' > > ** Removing '/usr/local/lib/R/library/GDD' > > > > > > What should I do? > > > > Vittorio > > > > Alle 16:29, venerdì 23 giugno 2006, Marc Schwartz (via MN) ha scritto: > >> On Fri, 2006-06-23 at 17:23 +0100, Vittorio wrote: > >>> I have set up an R procedure that is launched every three hours by > >>> crontab in a unix server. Crontab runs at regular intervals the > >>> following line: > >>> R CMD BATH myprog.R > >>> > >>> myprog.R (which by the way uses > >>> R2HTML) should create an updated png graph to be referred to and seen > >>> in an intranet web-page index.html. > >>> > >>> The problem is that both: > >>> > >>> png > >>> () > >>> plot(...) > >>> dev.off() > >>> > >>> AND: > >>> > >>> plot(...) > >>> HTMLplot(...) > >>> > >>> fail when > >>> launched in a batch manner compalining that they need an X11() instance > >>> to be used (I understand that they work only in a graphic context and > >>> intarictively). > >>> > >>> How can I obtain that png file? > >> > >> See R FAQ 7.19 How do I produce PNG graphics in batch mode? > >> > >> HTH, > >> > >> Marc Schwartz > > > > __ > > R-help@stat.math.ethz.ch mailing list > > https://stat.ethz.ch/mailman/listinfo/r-help > > PLEASE do read the posting guide! > > http://www.R-project.org/posting-guide.html __ R-help@stat.math.ethz.ch mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide! http://www.R-project.org/posting-guide.h
Re: [R] Producing png plot in batch mode - Problems compiling GDD
Alle 21:42, sabato 24 giugno 2006, vittorio ha scritto: > Thanks again Prof Ripley. > Under FreeBSD 6.1 I eliminated the three lines you suggested in Makevars.in > and the package was compiled like a charm. > > Bye > Vittorio > > Alle 16:28, sabato 24 giugno 2006, Prof Brian Ripley ha scritto: > > The advice in the posting guide was to ask the package maintainer (Cc:ed > > here). Please report what he had to say, as it would be helpful to the > > rest of us. > > > > Note that the src/Makevars.in has > > > > # we need to add JNI specific stuff here > > ifdef DEBUG > >PKG_CFLAGS+=-DJGD_DEBUG > > endif > > > > which is GNU-make specific, so you could just delete those three lines > > and try again (or use GNU make). > > > > On Sat, 24 Jun 2006, vittorio wrote: > > > SorThanks for the reply!!!.ry for my being so lazy and thanks a lot for > > > your kind replies. > > > > > > Well, I tried to install GDD under freebsd (this time I read > > > cafrefully the package docs and checked if the required libgd and > > > freetype2 were installed and they were) BUT there's > > > something wrong with "Makevars": > > > > > > > > > NbBSD# R CMD INSTALL GDD_0.1-8.tar.gz > > > * Installing *source* package 'GDD' ... > > > checking for gcc... cc > > > checking for C compiler default output file name... a.out > > > checking whether the C compiler works... yes > > > checking whether we are cross compiling... no > > > checking for suffix of executables... > > > checking for suffix of object files... o > > > checking whether we are using the GNU C compiler... yes > > > checking whether cc accepts -g... yes > > > checking for cc option to accept ANSI C... none needed > > > checking how to run the C preprocessor... cc -E > > > checking for egrep... grep -E > > > checking for ANSI C header files... yes > > > checking for sys/wait.h that is POSIX.1 compatible... yes > > > checking for sys/types.h... yes > > > checking for sys/stat.h... yes > > > checking for stdlib.h... yes > > > checking for string.h... yes > > > checking for memory.h... yes > > > checking for strings.h... yes > > > checking for inttypes.h... yes > > > checking for stdint.h... yes > > > checking for unistd.h... yes > > > checking for string.h... (cached) yes > > > checking sys/time.h usability... yes > > > checking sys/time.h presence... yes > > > checking for sys/time.h... yes > > > checking for unistd.h... (cached) yes > > > checking for an ANSI C-conforming const... yes > > > checking whether time.h and sys/time.h may both be included... yes > > > checking for stdlib.h... (cached) yes > > > checking for GNU libc compatible malloc... yes > > > checking return type of signal handlers... void > > > checking for memset... yes > > > checking for mkdir... yes > > > checking for rmdir... yes > > > checking for gdlib-config... /usr/local/bin/gdlib-config > > > libgd-flags according to gdlib-config: > > > -I/usr/local/include -L/usr/local/lib -L/usr/local/lib -lgd > > > if that is not correct, fix your gd installation > > > checking gd.h usability... yes > > > checking gd.h presence... yes > > > checking for gd.h... yes > > > checking for gdImageCreateFromPng in -lgd... yes > > > checking usability of FreeType in GD... yes > > > checking whether GD programs can be compiled... yes > > > configure: creating ./config.status > > > config.status: creating src/Makevars > > > config.status: creating src/gddconfig.h > > > ** libs > > > "Makevars", line 2: Need an operator > > > "Makevars", line 4: Need an operator > > > make: fatal errors encountered -- cannot continue > > > chmod: /usr/local/lib/R/library/GDD/libs/*: No such file or directory > > > ERROR: compilation failed for package 'GDD' > > > ** Removing '/usr/local/lib/R/library/GDD' > > > > > > > > > What should I do? > > > > > > Vittorio > > > > > > Alle 16:29, venerdì 23 giugno 2006, Marc Schwartz (via MN) ha scritto: > > >> On Fri, 2006-06-23 at 17:23 +0100, Vittorio wrote: > > >>> I have set up an R procedure that is launched every three hours by > > >>> crontab in a unix server. Crontab runs at regular intervals the > > >>> following line: > > >>> R CMD BATH myprog.R > > >>> > > >>> myprog.R (which by the way uses > > >>> R2HTML) should create an updated png graph to be referred to and > > >>> seen in an intranet web-page index.html. > > >>> > > >>> The problem is that both: > > >>> > > >>> png > > >>> () > > >>> plot(...) > > >>> dev.off() > > >>> > > >>> AND: > > >>> > > >>> plot(...) > > >>> HTMLplot(...) > > >>> > > >>> fail when > > >>> launched in a batch manner compalining that they need an X11() > > >>> instance to be used (I understand that they work only in a graphic > > >>> context and intarictively). > > >>> > > >>> How can I obtain that png file? > > >> > > >> See R FAQ 7.19 How do I produce PNG graphics in batch mode? > > >> > > >> HTH, > > >> > > >> Marc Schwartz > > > > > > __ > > > R-help@stat.math.ethz.ch mailing list > > > https://stat.et
Re: [R] How to use mle or similar with integrate?
Could you use 'optim' directly? This won't return a nice object of class 'mle', but it will give you parameter estimates. If you want an object of class 'mle', have you worked through the examples in the help file? Also, are your arguments "a" and "b" are scalars? If yes, did you try passing them to your 'minuslogl' function in the 'fixed' argument? If this won't work for you, you can try the functions 'mle.' and 'profile.mle' below. If I'm not mistaken, the standard 'mle' requires the 'fixed' argument to be a named list of scalars. I don't remember now for sure, but I think the 'mle.' function below differs from the standard 'mle' only in allowing 'fixed' arguments of length greater than 1 and then dropping them from operations that require scalars. My 'profile.mle' is modified from the function in 'stats4' to make error termination less likely, at least for the applications I used. Hope this helps. Spencer Graves p.s. I thought about sending this to someone, but the "Maintainer" for the "stats4" package is the "R Core Team <[EMAIL PROTECTED]>", and I decided not to bother that whole group. ### mle. <- function(minuslogl, start = formals(minuslogl), method = "BFGS", fixed = list(), ...) { call <- match.call() n <- names(fixed) fullcoef <- formals(minuslogl) if (any(!n %in% names(fullcoef)))stop( "some named arguments in 'fixed' are not arguments to the supplied log-likelihood") fullcoef[n] <- fixed if (!missing(start) && (!is.list(start) || is.null(names(start stop("'start' must be a named list") start[n] <- NULL start <- sapply(start, eval.parent) nm <- names(start) oo <- match(nm, names(fullcoef)) if (any(is.na(oo))) stop("some named arguments in 'start' are not arguments to the supplied log-likelihood") start <- start[order(oo)] f <- function(p) { l <- as.list(p) names(l) <- nm l[n] <- fixed do.call("minuslogl", l) } dots <- list(...) oout <- optim(start, f, method = method, hessian = TRUE, ...) oout$fixed <- fixed oout$dots <- list(...) coef <- oout$par vcov <- if (length(coef)) solve(oout$hessian) else matrix(numeric(0), 0, 0) min <- oout$value fcoef <- fullcoef fcoef[nm] <- coef len.coef <- sapply(fcoef, length) # Drop "fixed" arguments of length != 1 as they # almost certainly relate arguments of "minuslogl" # that are NOT parameters to be estimated. f.coef <- fcoef[len.coef==1] newMLE <- new("mle", call = call, coef = coef, fullcoef = unlist(f.coef), vcov = vcov, min = min, details = oout, minuslogl = minuslogl, method = method) } # #getMethods("profile", "package:stats4") profile.mle <- function (fitted, ...){ .local <- function (fitted, which = 1:p, maxsteps = 100, alpha = 0.01, zmax = sqrt(qchisq(1 - alpha/2, p)), del = zmax/5, trace = FALSE, ...) { onestep <- function(step, call, fixed) { bi <- B0[i] + sgn * step * del * std.err[i] # Additional fix for profile # Get original fix { if(is.list(fixed) && (length(fixed)>0)){ fixed[[pi]] <- NULL k. <- length(fixed) fix2 <- vector(k.+1, mode="list") names(fix2) <- c(names(fixed), pi) fix2[1:k.] <- fixed fix2[k.+1] <- bi } else{ fix2 <- list(bi) names(fix2) <- pi } } call$fixed <- fix2 pfit <- try(eval.parent(call, 2), silent = TRUE) if (inherits(pfit, "try-error")) return(NA) else { zz <- 2 * ([EMAIL PROTECTED] - [EMAIL PROTECTED]) ri <- pv0 ri[, names([EMAIL PROTECTED])] <- [EMAIL PROTECTED] ri[, pi] <- bi if(zz<=0){ msg0 <- paste("Profiling has found a better ", "solution (log(LR) = ", zz, " <0), so the ", "original fit had not converged: ", "This will be ignored for now, but try ", "mle(..., start=list(", sep="") pars <- paste(Pnames, coef(pfit), sep="=") pars. <- paste(pars, collapse=", ") msg1 <- paste(msg0, pars., ")).\n", sep="") warning(msg1) } z0 <- max(zz, 0) z <- sgn * sqrt(z0) pvi <<- rbind(pvi, ri) zi <<- c(zi, z) } if (trace) cat(bi, z, "\n") ### end subfunction onestep ##
Re: [R] Producing png plot in batch mode - Problems compiling GDD
Thanks again Prof Ripley. Under FreeBSD 6.1 I eliminated the three lines you suggested in Makevars.in and the package was compiled like a charm. Bye Vittorio Alle 16:28, sabato 24 giugno 2006, Prof Brian Ripley ha scritto: > The advice in the posting guide was to ask the package maintainer (Cc:ed > here). Please report what he had to say, as it would be helpful to the > rest of us. > > Note that the src/Makevars.in has > > # we need to add JNI specific stuff here > ifdef DEBUG >PKG_CFLAGS+=-DJGD_DEBUG > endif > > which is GNU-make specific, so you could just delete those three lines and > try again (or use GNU make). > > On Sat, 24 Jun 2006, vittorio wrote: > > SorThanks for the reply!!!.ry for my being so lazy and thanks a lot for > > your kind replies. > > > > Well, I tried to install GDD under freebsd (this time I read cafrefully > > the package docs and checked if the required libgd and > > freetype2 were installed and they were) BUT there's > > something wrong with "Makevars": > > > > > > NbBSD# R CMD INSTALL GDD_0.1-8.tar.gz > > * Installing *source* package 'GDD' ... > > checking for gcc... cc > > checking for C compiler default output file name... a.out > > checking whether the C compiler works... yes > > checking whether we are cross compiling... no > > checking for suffix of executables... > > checking for suffix of object files... o > > checking whether we are using the GNU C compiler... yes > > checking whether cc accepts -g... yes > > checking for cc option to accept ANSI C... none needed > > checking how to run the C preprocessor... cc -E > > checking for egrep... grep -E > > checking for ANSI C header files... yes > > checking for sys/wait.h that is POSIX.1 compatible... yes > > checking for sys/types.h... yes > > checking for sys/stat.h... yes > > checking for stdlib.h... yes > > checking for string.h... yes > > checking for memory.h... yes > > checking for strings.h... yes > > checking for inttypes.h... yes > > checking for stdint.h... yes > > checking for unistd.h... yes > > checking for string.h... (cached) yes > > checking sys/time.h usability... yes > > checking sys/time.h presence... yes > > checking for sys/time.h... yes > > checking for unistd.h... (cached) yes > > checking for an ANSI C-conforming const... yes > > checking whether time.h and sys/time.h may both be included... yes > > checking for stdlib.h... (cached) yes > > checking for GNU libc compatible malloc... yes > > checking return type of signal handlers... void > > checking for memset... yes > > checking for mkdir... yes > > checking for rmdir... yes > > checking for gdlib-config... /usr/local/bin/gdlib-config > > libgd-flags according to gdlib-config: > > -I/usr/local/include -L/usr/local/lib -L/usr/local/lib -lgd > > if that is not correct, fix your gd installation > > checking gd.h usability... yes > > checking gd.h presence... yes > > checking for gd.h... yes > > checking for gdImageCreateFromPng in -lgd... yes > > checking usability of FreeType in GD... yes > > checking whether GD programs can be compiled... yes > > configure: creating ./config.status > > config.status: creating src/Makevars > > config.status: creating src/gddconfig.h > > ** libs > > "Makevars", line 2: Need an operator > > "Makevars", line 4: Need an operator > > make: fatal errors encountered -- cannot continue > > chmod: /usr/local/lib/R/library/GDD/libs/*: No such file or directory > > ERROR: compilation failed for package 'GDD' > > ** Removing '/usr/local/lib/R/library/GDD' > > > > > > What should I do? > > > > Vittorio > > > > Alle 16:29, venerdì 23 giugno 2006, Marc Schwartz (via MN) ha scritto: > >> On Fri, 2006-06-23 at 17:23 +0100, Vittorio wrote: > >>> I have set up an R procedure that is launched every three hours by > >>> crontab in a unix server. Crontab runs at regular intervals the > >>> following line: > >>> R CMD BATH myprog.R > >>> > >>> myprog.R (which by the way uses > >>> R2HTML) should create an updated png graph to be referred to and seen > >>> in an intranet web-page index.html. > >>> > >>> The problem is that both: > >>> > >>> png > >>> () > >>> plot(...) > >>> dev.off() > >>> > >>> AND: > >>> > >>> plot(...) > >>> HTMLplot(...) > >>> > >>> fail when > >>> launched in a batch manner compalining that they need an X11() instance > >>> to be used (I understand that they work only in a graphic context and > >>> intarictively). > >>> > >>> How can I obtain that png file? > >> > >> See R FAQ 7.19 How do I produce PNG graphics in batch mode? > >> > >> HTH, > >> > >> Marc Schwartz > > > > __ > > R-help@stat.math.ethz.ch mailing list > > https://stat.ethz.ch/mailman/listinfo/r-help > > PLEASE do read the posting guide! > > http://www.R-project.org/posting-guide.html __ R-help@stat.math.ethz.ch mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide! http://www.R-project.org/posting-guide.h
[R] getting the smoother matrix from smooth.spline
Can anyone tell me the trick for obtaining the smoother matrix from smooth.spline when there are non-unique values for x. I have the following code but, of course, it only works when all values of x are unique. ## get the smoother matrix (x having unique values smooth.matrix = function(x, df){ n = length(x); A = matrix(0, n, n); for(i in 1:n){ y = rep(0, n); y[i]=1; yi = smooth.spline(x, y, df=df)$y; A[,i]= yi; } (A+t(A))/2; } Thanks for any assistance, Gregory - - Get a sneak peak at messages with a handy reading pane. [[alternative HTML version deleted]] __ R-help@stat.math.ethz.ch mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide! http://www.R-project.org/posting-guide.html
Re: [R] data frame search
Thanks, couldn't find this function, Best regards Bart - Original Message - From: "Gabor Grothendieck" <[EMAIL PROTECTED]> To: "Bart Joosen" <[EMAIL PROTECTED]> Cc: Sent: Saturday, June 24, 2006 1:15 PM Subject: Re: [R] data frame search > Try this: > > which(DF1 == 4, arr.ind = TRUE) > > > On 6/24/06, Bart Joosen <[EMAIL PROTECTED]> wrote: >> Hi, >> >> I want to make a data frame which contains the positions of some searched >> values in another data frame. >> >> Like: >> Dataframe 1: >> >> 1 2 3 4 1 2 3 4 >> 2 3 4 1 2 3 4 2 >> 4 1 2 3 2 3 4 1 >> >> Let's say I searched on "4", then Dataframe 2 should contain: >> x y >> 1 4 >> 1 8 >> 2 3 >> 2 7 >> 3 1 >> 3 7 >> >> I have written a routine, but it seems to me that it isn't that perfect: >> x<- 0 >> >> y<- 0 >> >> for (j in 1:ncol(df)) { >> >> for (i in 1:nrow(df)) { >> >> if (df[i,j] == 3) { >> >> x <- c(x,i) >> >> y <- c(y,j) >> >> } >> >> } >> >> } >> >> df2 <- data.frame(x,y) >> >> df2 <- df2[-1,] >> >> Can someone come up with an elegant/faster solution, because the ultimate >> goal of this routine is to analyze an jpg image. >> >> Kind regards >> >> Bart > __ R-help@stat.math.ethz.ch mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide! http://www.R-project.org/posting-guide.html
Re: [R] Producing png plot in batch mode
The advice in the posting guide was to ask the package maintainer (Cc:ed here). Please report what he had to say, as it would be helpful to the rest of us. Note that the src/Makevars.in has # we need to add JNI specific stuff here ifdef DEBUG PKG_CFLAGS+=-DJGD_DEBUG endif which is GNU-make specific, so you could just delete those three lines and try again (or use GNU make). On Sat, 24 Jun 2006, vittorio wrote: SorThanks for the reply!!!.ry for my being so lazy and thanks a lot for your kind replies. Well, I tried to install GDD under freebsd (this time I read cafrefully the package docs and checked if the required libgd and freetype2 were installed and they were) BUT there's something wrong with "Makevars": NbBSD# R CMD INSTALL GDD_0.1-8.tar.gz * Installing *source* package 'GDD' ... checking for gcc... cc checking for C compiler default output file name... a.out checking whether the C compiler works... yes checking whether we are cross compiling... no checking for suffix of executables... checking for suffix of object files... o checking whether we are using the GNU C compiler... yes checking whether cc accepts -g... yes checking for cc option to accept ANSI C... none needed checking how to run the C preprocessor... cc -E checking for egrep... grep -E checking for ANSI C header files... yes checking for sys/wait.h that is POSIX.1 compatible... yes checking for sys/types.h... yes checking for sys/stat.h... yes checking for stdlib.h... yes checking for string.h... yes checking for memory.h... yes checking for strings.h... yes checking for inttypes.h... yes checking for stdint.h... yes checking for unistd.h... yes checking for string.h... (cached) yes checking sys/time.h usability... yes checking sys/time.h presence... yes checking for sys/time.h... yes checking for unistd.h... (cached) yes checking for an ANSI C-conforming const... yes checking whether time.h and sys/time.h may both be included... yes checking for stdlib.h... (cached) yes checking for GNU libc compatible malloc... yes checking return type of signal handlers... void checking for memset... yes checking for mkdir... yes checking for rmdir... yes checking for gdlib-config... /usr/local/bin/gdlib-config libgd-flags according to gdlib-config: -I/usr/local/include -L/usr/local/lib -L/usr/local/lib -lgd if that is not correct, fix your gd installation checking gd.h usability... yes checking gd.h presence... yes checking for gd.h... yes checking for gdImageCreateFromPng in -lgd... yes checking usability of FreeType in GD... yes checking whether GD programs can be compiled... yes configure: creating ./config.status config.status: creating src/Makevars config.status: creating src/gddconfig.h ** libs "Makevars", line 2: Need an operator "Makevars", line 4: Need an operator make: fatal errors encountered -- cannot continue chmod: /usr/local/lib/R/library/GDD/libs/*: No such file or directory ERROR: compilation failed for package 'GDD' ** Removing '/usr/local/lib/R/library/GDD' What should I do? Vittorio Alle 16:29, venerdì 23 giugno 2006, Marc Schwartz (via MN) ha scritto: On Fri, 2006-06-23 at 17:23 +0100, Vittorio wrote: I have set up an R procedure that is launched every three hours by crontab in a unix server. Crontab runs at regular intervals the following line: R CMD BATH myprog.R myprog.R (which by the way uses R2HTML) should create an updated png graph to be referred to and seen in an intranet web-page index.html. The problem is that both: png () plot(...) dev.off() AND: plot(...) HTMLplot(...) fail when launched in a batch manner compalining that they need an X11() instance to be used (I understand that they work only in a graphic context and intarictively). How can I obtain that png file? See R FAQ 7.19 How do I produce PNG graphics in batch mode? HTH, Marc Schwartz __ R-help@stat.math.ethz.ch mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide! http://www.R-project.org/posting-guide.html -- Brian D. Ripley, [EMAIL PROTECTED] Professor of Applied Statistics, http://www.stats.ox.ac.uk/~ripley/ University of Oxford, Tel: +44 1865 272861 (self) 1 South Parks Road, +44 1865 272866 (PA) Oxford OX1 3TG, UKFax: +44 1865 272595__ R-help@stat.math.ethz.ch mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide! http://www.R-project.org/posting-guide.html
[R] smoothing splines and degrees of freedom
Hi, If I set df=2 in my smooth.spline function, is that equivalent to running a linear regression through my data? It appears that df=# of data points gives the interpolating spline and that df = 2 gives the linear regression, but I just want to confirm this. Thank you, Steven __ R-help@stat.math.ethz.ch mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide! http://www.R-project.org/posting-guide.html
[R] my poor post formatting in "data frame search" and "Problems creating packages" (a summary)
I'm trying to figure out how to get my mail client (gmail) to interface more elegantly with the help list for submissions so they don't appear as attachments. Sorry about that. A quick summary: - Although I was pleased with my solution to Bart Joosen's query about data frames, Gabor's solution using which() is clearly more elegant. - My post to Robert Robinson's query about problems creating simple packages will be expanded in more detail as I work on a 'howto' summarizing my recent experience creating packages. Thanks, again, to Duncan, Max, Jeff, and Dirk for their guidance. Jay __ R-help@stat.math.ethz.ch mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide! http://www.R-project.org/posting-guide.html
Re: [R] data frame search
I'll suggest an algorithm with a little code but haven't actually tried it. R loves vector/matrix operations (and, incidentally, you probably ought to be using matrices here and not data frames, particularly if the images are "large"). Here is your matrix from your example (I'll call this x) 1 2 3 4 1 2 3 4 2 3 4 1 2 3 4 2 4 1 2 3 2 3 4 1 Create two more matrices (I'll call the mask1 and mask2): 1 1 1 1 1 1 1 1 2 2 2 2 2 2 2 2 3 3 3 3 3 3 3 3 1 2 3 4 5 6 7 8 1 2 3 4 5 6 7 8 1 2 3 4 5 6 7 8 To find the coordinates in x where x is 4: coords <- cbind(mask1[x==4], mask2[x==4]) Jay - Your original query was: Hi, I want to make a data frame which contains the positions of some searched values in another data frame. Like: Dataframe 1: 1 2 3 4 1 2 3 4 2 3 4 1 2 3 4 2 4 1 2 3 2 3 4 1 Let's say I searched on "4", then Dataframe 2 should contain: x y 1 4 1 8 2 3 2 7 3 1 3 7 I have written a routine, but it seems to me that it isn't that perfect: < CODE DELETED BY JAY TO SAVE SPACE> Can someone come up with an elegant/faster solution, because the ultimate goal of this routine is to analyze an jpg image. Kind regards Bart -- John W. Emerson (Jay) Assistant Professor of Statistics Yale University http://www.stat.yale.edu/~jay [[alternative HTML version deleted]] __ R-help@stat.math.ethz.ch mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide! http://www.R-project.org/posting-guide.html
Re: [R] Problems creating packages.
> I'm creating my own package for personal and I'm having trouble > getting it to a point where R (v 2.3.1) will recognise it. I've > followed two different tutorials for how to create the package > structure and the DESCRIPTION file ( > http://web.maths.unsw.edu.au/~wand/webcpdg/rpack.html , > http://www.maths.bris.ac.uk/~maman/computerstuff/Rhelp/Rpackages.html#Lin-Lin > . I'm still getting errors where when I try to load the library in R > by using library(samp) I get an error: > > Error in library(samp) : 'samp' is not a valid package -- installed < 2.0.0? I'm going out on a limb, here, but others were quick to offer me advice and I didn't yet see a reply to your query. I assume (from the links you provide and the use of sudo) that you are working in Linux. Your R CMD check fails to find latex, which would be my first cause for concern. Either you have an old or unusual linux system (unlikely) or there appears to be a path problem (much more likely are probably related to using sudo). That is worth tracking down, though it probably isn't the primary (or even the most R-specific) problem. I don't think the problem is related to the contents of your files, per se, but rather the organization of the files and folders in the source package. I had success starting with package.skeleton() and working from there. The error about "only *source* packages can be checked" is something I encountered once when I tried R CMD check on a binary package rather than a source package (a binary package would be produced by "R CMD build --binary packagename" once you get to that point), and a source package is a beast of the form produced by package.skeleton(). I'm a newbie to making packages myself, and apologize for any inaccuracies or errors above (and please correct me, folks)! Regards, Jay -- John W. Emerson (Jay) Assistant Professor of Statistics Yale University http://www.stat.yale.edu/~jay [[alternative HTML version deleted]] __ R-help@stat.math.ethz.ch mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide! http://www.R-project.org/posting-guide.html
Re: [R] Producing png plot in batch mode
SorThanks for the reply!!!.ry for my being so lazy and thanks a lot for your kind replies. Well, I tried to install GDD under freebsd (this time I read cafrefully the package docs and checked if the required libgd and freetype2 were installed and they were) BUT there's something wrong with "Makevars": NbBSD# R CMD INSTALL GDD_0.1-8.tar.gz * Installing *source* package 'GDD' ... checking for gcc... cc checking for C compiler default output file name... a.out checking whether the C compiler works... yes checking whether we are cross compiling... no checking for suffix of executables... checking for suffix of object files... o checking whether we are using the GNU C compiler... yes checking whether cc accepts -g... yes checking for cc option to accept ANSI C... none needed checking how to run the C preprocessor... cc -E checking for egrep... grep -E checking for ANSI C header files... yes checking for sys/wait.h that is POSIX.1 compatible... yes checking for sys/types.h... yes checking for sys/stat.h... yes checking for stdlib.h... yes checking for string.h... yes checking for memory.h... yes checking for strings.h... yes checking for inttypes.h... yes checking for stdint.h... yes checking for unistd.h... yes checking for string.h... (cached) yes checking sys/time.h usability... yes checking sys/time.h presence... yes checking for sys/time.h... yes checking for unistd.h... (cached) yes checking for an ANSI C-conforming const... yes checking whether time.h and sys/time.h may both be included... yes checking for stdlib.h... (cached) yes checking for GNU libc compatible malloc... yes checking return type of signal handlers... void checking for memset... yes checking for mkdir... yes checking for rmdir... yes checking for gdlib-config... /usr/local/bin/gdlib-config libgd-flags according to gdlib-config: -I/usr/local/include -L/usr/local/lib -L/usr/local/lib -lgd if that is not correct, fix your gd installation checking gd.h usability... yes checking gd.h presence... yes checking for gd.h... yes checking for gdImageCreateFromPng in -lgd... yes checking usability of FreeType in GD... yes checking whether GD programs can be compiled... yes configure: creating ./config.status config.status: creating src/Makevars config.status: creating src/gddconfig.h ** libs "Makevars", line 2: Need an operator "Makevars", line 4: Need an operator make: fatal errors encountered -- cannot continue chmod: /usr/local/lib/R/library/GDD/libs/*: No such file or directory ERROR: compilation failed for package 'GDD' ** Removing '/usr/local/lib/R/library/GDD' What should I do? Vittorio Alle 16:29, venerdì 23 giugno 2006, Marc Schwartz (via MN) ha scritto: > On Fri, 2006-06-23 at 17:23 +0100, Vittorio wrote: > > I have set up an R procedure that is launched every three hours by > > crontab in a unix server. Crontab runs at regular intervals the > > following line: > > R CMD BATH myprog.R > > > > myprog.R (which by the way uses > > R2HTML) should create an updated png graph to be referred to and seen > > in an intranet web-page index.html. > > > > The problem is that both: > > > > png > > () > > plot(...) > > dev.off() > > > > AND: > > > > plot(...) > > HTMLplot(...) > > > > fail when > > launched in a batch manner compalining that they need an X11() instance > > to be used (I understand that they work only in a graphic context and > > intarictively). > > > > How can I obtain that png file? > > See R FAQ 7.19 How do I produce PNG graphics in batch mode? > > HTH, > > Marc Schwartz __ R-help@stat.math.ethz.ch mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide! http://www.R-project.org/posting-guide.html
Re: [R] Not able to save the work space
Unfortunately you have not told us what the message was, nor the R platform nor how you were trying to save the `work space'. The most likely explanation is that you do not have permission to write the image file. But we need a lot more details to be able to help you without excessive guessing. On Thu, 22 Jun 2006, [EMAIL PROTECTED] wrote: > Hello, > > I am trying to save my work space but I recieve the following message error > in save.image(name), how can > I overcome this problem? > > Ahmad A. Al-Mallahi > Laboratory of Bioproduction Engineering > Graduate School of Agriculture > Hokkaido University > Sapporo-Japan > > __ > R-help@stat.math.ethz.ch mailing list > https://stat.ethz.ch/mailman/listinfo/r-help > PLEASE do read the posting guide! http://www.R-project.org/posting-guide.html Please do supply the information it asks for. -- Brian D. Ripley, [EMAIL PROTECTED] Professor of Applied Statistics, http://www.stats.ox.ac.uk/~ripley/ University of Oxford, Tel: +44 1865 272861 (self) 1 South Parks Road, +44 1865 272866 (PA) Oxford OX1 3TG, UKFax: +44 1865 272595 __ R-help@stat.math.ethz.ch mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide! http://www.R-project.org/posting-guide.html
Re: [R] difference in results from R vs SPSS
Thanks for the reply. The mistake in 1 resulted to be due to using a different number of decimal places in the data. As regards 2, will check it out again. Thanks again. Fiona Sammut wrote: Hi all, 1. I am doing some data analysis using both R and SPSS, to get used to both software packages. I had performed linear regression in R and SPSS for a number of times before this last one and the resulting coefficient values always matched. However, this last data set I was analyzing using simple linear regression and using the command lm(y~x), gave me different readings from R and SPSS: R:y= 33.803 + 6.897x SPSS: y= 47.589 + 6.263x I have no doubts regarding the procedure employed in SPSS and I am sure I am using the same dataset for both software packages. My guess is you have missing values defined in SPSS but don't have those same values set to NA in R. Have you requested basic descriptive statistics in both programs and found that they match? Also, perhaps x a factor in R. If so, how are its contrasts set? 2. Correct me if I am wrong, but from what I've read, it seems that the command /anova /in R works out an analysis of variance without including the intercept. Is that so? Cause again I am working out an anova in R and SPSS and I got different resulting sums of squares and different degrees of freedom. I thought this was because one package is working with an intercept and the other isn't. I don't think this has anything to do with the discrepancy. Can anyone enlighten me as to what might have happened in both 1. and 2. please? Are they both due to my poor knowledge of R or could occurences as above happen? 3. I would like a reference to a command which can be used to fit a distribution to a disrete distribution. library(MASS) ?fitdistr Thanks in advance for your consideration. - Fiona Sammut __ R-help@stat.math.ethz.ch mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide! http://www.R-project.org/posting-guide.html __ R-help@stat.math.ethz.ch mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide! http://www.R-project.org/posting-guide.html
Re: [R] difference in results from R vs SPSS
Fiona Sammut wrote: > Hi all, > > 1. I am doing some data analysis using both R and SPSS, to get used to > both software packages. I had performed linear regression in R and SPSS > for a number of times before this last one and the resulting coefficient > values always matched. However, this last data set I was analyzing > using simple linear regression and using the command lm(y~x), gave me > different readings from R and SPSS: > > R:y= 33.803 + 6.897x > > SPSS: y= 47.589 + 6.263x > > I have no doubts regarding the procedure employed in SPSS and I am sure > I am using the same dataset for both software packages. My guess is you have missing values defined in SPSS but don't have those same values set to NA in R. Have you requested basic descriptive statistics in both programs and found that they match? Also, perhaps x a factor in R. If so, how are its contrasts set? > 2. Correct me if I am wrong, but from what I've read, it seems that the > command /anova /in R works out an analysis of variance without including > the intercept. Is that so? Cause again I am working out an anova in R > and SPSS and I got different resulting sums of squares and different > degrees of freedom. I thought this was because one package is working > with an intercept and the other isn't. I don't think this has anything to do with the discrepancy. > Can anyone enlighten me as to what might have happened in both 1. and 2. > please? Are they both due to my poor knowledge of R or could occurences > as above happen? > > > 3. I would like a reference to a command which can be used to fit a > distribution to a disrete distribution. library(MASS) ?fitdistr > Thanks in advance for your consideration. > > - Fiona Sammut > > __ > R-help@stat.math.ethz.ch mailing list > https://stat.ethz.ch/mailman/listinfo/r-help > PLEASE do read the posting guide! http://www.R-project.org/posting-guide.html -- 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
Re: [R] data frame search
Try this: which(DF1 == 4, arr.ind = TRUE) On 6/24/06, Bart Joosen <[EMAIL PROTECTED]> wrote: > Hi, > > I want to make a data frame which contains the positions of some searched > values in another data frame. > > Like: > Dataframe 1: > > 1 2 3 4 1 2 3 4 > 2 3 4 1 2 3 4 2 > 4 1 2 3 2 3 4 1 > > Let's say I searched on "4", then Dataframe 2 should contain: > x y > 1 4 > 1 8 > 2 3 > 2 7 > 3 1 > 3 7 > > I have written a routine, but it seems to me that it isn't that perfect: > x<- 0 > > y<- 0 > > for (j in 1:ncol(df)) { > > for (i in 1:nrow(df)) { > > if (df[i,j] == 3) { > > x <- c(x,i) > > y <- c(y,j) > > } > > } > > } > > df2 <- data.frame(x,y) > > df2 <- df2[-1,] > > Can someone come up with an elegant/faster solution, because the ultimate > goal of this routine is to analyze an jpg image. > > Kind regards > > Bart __ R-help@stat.math.ethz.ch mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide! http://www.R-project.org/posting-guide.html
[R] difference in results from R vs SPSS
Hi all, 1. I am doing some data analysis using both R and SPSS, to get used to both software packages. I had performed linear regression in R and SPSS for a number of times before this last one and the resulting coefficient values always matched. However, this last data set I was analyzing using simple linear regression and using the command lm(y~x), gave me different readings from R and SPSS: R:y= 33.803 + 6.897x SPSS: y= 47.589 + 6.263x I have no doubts regarding the procedure employed in SPSS and I am sure I am using the same dataset for both software packages. 2. Correct me if I am wrong, but from what I've read, it seems that the command /anova /in R works out an analysis of variance without including the intercept. Is that so? Cause again I am working out an anova in R and SPSS and I got different resulting sums of squares and different degrees of freedom. I thought this was because one package is working with an intercept and the other isn't. Can anyone enlighten me as to what might have happened in both 1. and 2. please? Are they both due to my poor knowledge of R or could occurences as above happen? 3. I would like a reference to a command which can be used to fit a distribution to a disrete distribution. Thanks in advance for your consideration. - Fiona Sammut __ R-help@stat.math.ethz.ch mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide! http://www.R-project.org/posting-guide.html
[R] Not able to save the work space
Hello, I am trying to save my work space but I recieve the following message error in save.image(name), how can I overcome this problem? Ahmad A. Al-Mallahi Laboratory of Bioproduction Engineering Graduate School of Agriculture Hokkaido University Sapporo-Japan __ R-help@stat.math.ethz.ch mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide! http://www.R-project.org/posting-guide.html
[R] Overlaying 2D kernel density plots on scatterplot matrix
Hi all We are pretty new to R here and trying to achieve something that we believe is possible but it¹s not easy to work out how to do it. We are producing scatterplot matrices for e.g. 10 variables. What we would like to do is superimpose 2D kernel density estimators on top of each plot so that we end up with a scatterplot matrix of 2D kernel density (contour) plots. The kernel density plots don¹t have to be very sophisticated i.e. default settings and greyscale are fine we can work on details later. What has stumped us so far is how you attach¹ the kernel density results to the scatterplot results and then overlay them. Any ideas, links or code gratefully received. TIA and please CC answers here if possible Michael __ R-help@stat.math.ethz.ch mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide! http://www.R-project.org/posting-guide.html
[R] data frame search
Hi, I want to make a data frame which contains the positions of some searched values in another data frame. Like: Dataframe 1: 1 2 3 4 1 2 3 4 2 3 4 1 2 3 4 2 4 1 2 3 2 3 4 1 Let's say I searched on "4", then Dataframe 2 should contain: x y 1 4 1 8 2 3 2 7 3 1 3 7 I have written a routine, but it seems to me that it isn't that perfect: x<- 0 y<- 0 for (j in 1:ncol(df)) { for (i in 1:nrow(df)) { if (df[i,j] == 3) { x <- c(x,i) y <- c(y,j) } } } df2 <- data.frame(x,y) df2 <- df2[-1,] Can someone come up with an elegant/faster solution, because the ultimate goal of this routine is to analyze an jpg image. Kind regards 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
Re: [R] Tetrachoric correlation in R vs. stata
Dear Peter, Thanks for fielding the followup to this question -- I didn't see it until Saturday morning. Janet says that polychor() gives virtually the same ML and 2-step estimates, but (thinking about it) I believe that these should be identical within rounding error in the 2 x 2 case, and that appears to be true. Janet's example shows that the print method for polycor objects tries to compute a test of bivariate normality even for tetrachoric correlations where the df for the test are 0, producing a warning. I've fixed that and uploaded a new version of the package to CRAN. Regards, John On 24 Jun 2006 00:30:03 +0200 Peter Dalgaard <[EMAIL PROTECTED]> wrote: > Janet Rosenbaum <[EMAIL PROTECTED]> writes: > > > Peter --- Thanks for pointing out the omitted information. The > > hazards of attempting to be brief. > > > > In R, I am using polychor(vec1, vec2, std.err=T) and have used both > > the ML and 2 step estimates, which give virtually identical > answers. > > I am explicitly using only the 632 complete cases in R to make sure > > missing data is handled the same way as in stata. > > > > Here's my data: > > > > 522 54 > > 34 22 > > > > > polychor(v1, v2, std.err=T, ML=T) > > > > Polychoric Correlation, ML est. = 0.5172 (0.08048) > > Test of bivariate normality: Chisquare = 8.063e-06, df = 0, p = NaN > > > > Row Thresholds > > Threshold Std.Err. > > 1 1.349 0.07042 > > > > > > Column Thresholds > > Threshold Std.Err. > > 1 1.174 0.06458 > > Warning message: > > NaNs produced in: pchisq(q, df, lower.tail, log.p) > > > > In stata, I get: > > > > . tetrachoric t1_v19a ct1_ix17 > > > > Tetrachoric correlations (N=632) > > > > -- > > Variable | t1_v19a ct1_ix17 > > -+ > > t1_v19a |1 > > ct1_ix17 |.6169 1 > > -- > > Well, > > > pmvnorm(c(1.349,1.174),c(Inf,Inf), > +sigma=matrix(c(1,.5172,.5172,1),2))*632 > [1] 22.00511 > attr(,"error") > [1] 1e-15 > attr(,"msg") > [1] "Normal Completion" > > pnorm(1.349)*632 > [1] 575.9615 > > pnorm(1.174)*632 > [1] 556.0352 > > so the estimates from R appear to be consistent with the table. In > contrast, plugging in the .6169 from Stata gives > > > > pmvnorm(c(1.349,1.174),c(Inf,Inf), > + sigma=matrix(c(1,.6169,.6169,1),2))*632 > [1] 26.34487 > ... > > You might want to follow up on > > http://www.ats.ucla.edu/stat/stata/faq/tetrac.htm > > > > Thanks for your help. > > > > Janet > > > > > > > > Peter Dalgaard wrote: > > > Janet Rosenbaum <[EMAIL PROTECTED]> writes: > > > > > >> I hope someone here knows the answer to this since it will save > me > > >> from delving deep into documentation. > > >> > > >> Based on 22 pairs of vectors, I have noticed that tetrachoric > > >> correlation coefficients in stata are almost uniformly higher > than > > >> those in R, sometimes dramatically so (TCC=.61 in stata, .51 in > R; > > >> .51 in stata, .39 in R). Stata's estimate is higher than R's in > 20 > > >> out of 22 computations, although the estimates always fall > within > > >> the 95% CI for the TCC calculated by R. > > >> > > >> Do stata and R calculate TCC in dramatically different ways? Is > > >> the handling of missing data perhaps different? Any thoughts? > > >> > > >> Btw, I am sending this question only to the R-help list. > > > A bit more information seems necessary: > > > - tetrachoric correlations depend on 4 numbers, so you should be > able > > > to give a direct example > > > - you're not telling us how you calculate the TCC in R. This is > not > > > obvious (package polycor?). > > > > > > > > > > > > > This email message is for the sole use of the intended > rec...{{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 John Fox Department of Sociology McMaster University Hamilton, Ontario, Canada http://socserv.mcmaster.ca/jfox/ __ R-help@stat.math.ethz.ch mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide! http://www.R-project.org/posting-guide.html