[R] L1-SVM
Hi List, Is there a package in R to find L1-SVM. I did search and found svmpath but not sure if it is what I need. Thanks, Saeed __ R-help@stat.math.ethz.ch 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] Hosmer-lemeshow test for survival
Dear All, I am looking for function's code to implement the Hosmer-Lemeshow gof test for survival data. Could anyone share it? TIA Mario [[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] Speeding up resampling of rows from a large matrix
I'm trying to: Resample with replacement pairs of distinct rows from a 120 x 65,000 matrix H of 0's and 1's. For each resampled pair sum the resulting 2 x 65,000 matrix by column: 0 1 0 1 ... + 0 0 1 1 ... ___ = 0 1 1 2 ... For each column accumulate the number of 0's, 1's and 2's over the resamples to obtain a 3 x 65,000 matrix G. For those interested in the background, H is a matrix of haplotypes, each pair of haplotypes forms a genotype, and each column corresponds to a SNP. I'm using resampling to compute the null distribution of the maximum over correlated SNPs of a simple statistic. The code: #--- nSNPs <- 1000 H <- matrix(sample(0:1, 120*nSNPs , replace=T), nrow=120) G <- matrix(0, nrow=3, ncol=nSNPs) # Keep in mind that the real H is 120 x 65000 nResamples <- 3000 pair <- replicate(nResamples, sample(1:120, 2)) gen <- function(x){g <- sum(x); c(g==0, g==1, g==2)} for (i in 1:nResamples){ G <- G + apply(H[pair[,i],], 2, gen) } #--- The problem is that the loop takes about 80 mins to complete and I need to repeat the whole thing 10,000 times, which would then take over a year and a half! Is there a way to speed this up so that the full 10,000 iterations take a reasonable amount of time (say a week)? My machine has an Intel Xeon 3.40GHz CPU with 1GB of RAM > sessionInfo() R version 2.5.0 (2007-04-23) i386-pc-mingw32 I would greatly appreciate any help. Juan Pablo Lewinger Department of Preventive Medicine Keck School of Medicine University of Southern California __ R-help@stat.math.ethz.ch 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] No wonder you guys got high all the time.
T2Y.F IST 300% GESTIEGEN. ES WIRD 500% KURSSPRUNG ERWARTET. TYCHE ENERGY KURZEL: T2Y.F HANDELSPLATZ: FRANKFURT 5-TAGE ZIEL: 1 EURO T2Y.F RALLYE IST GESTARTET. SEIEN SIE DABEI! KAUFEN WAEHREND ES NOCH BILLIG IST. LASSEN SIE SICH DIESE CHANCE NICHT ENTGEHEN! What's Your Position? What would a sexual fantasy of the Berlin Wall look like? I was usually in some kind of confinement, like a rubber sack or a different container and I was tubed most all of the time. So while I personally can't identify or relate to have romantic or sexual attachments to an object, I found the article quite titilating. You know, like Jesus. I don't know what his policy is There's no nipple access that I can see and I'm not clear on what's up with the little crotch guard area; is there a zipper there or what? Cardiologist Herbert Benson, M. Frank Gifford killed him when he thought Reg was getting fresh with Kathie Lee. Maybe you could do a bit of cropping and paddling or spanking, but it's not really designed for that either. Frank Gifford killed him when he thought Reg was getting fresh with Kathie Lee. Featured Cheerleading Stunt Photo - Heel StretchThis featured cheerleading stunt photo is of the All Star Trilogy cheerleaders doing a heel stretch. And a sense of tense, creaking embarrassment beneath it all, of course: that wasn't coke, that was a promise he was too nice to break. I remember watching this when it was originally on. I just love seeing people I admire doing things that are downright goofy, I don't care if they thought it was cool at the time or not. The relaxation response is a state that is opposite to the stress response. All in all, it made me want to go visit Daddy S's store in San Francisco. My partner is a fan of both artists but too young to remember stuff like this. What's interesting is that it seems like that's actually Sanjaya telling the joke. from that site, i like this one: Officials: Pakistani man was not planning attack on Camp Casey. Frank Gifford killed him when he thought Reg was getting fresh with Kathie Lee. Like, say, metafilter? Do you have what it takes to be a flyer, base or spot? The largest online collection is available through ProQuest, but that costs money. How on earth would one teach a Peace and Conflict Studies program without talking to people with opposing viewpoints? " This is being debated around the internets. Sheela: I wouldn't call it a childhood, but I would call it good. Probably Labyrinth too, now that I think about it. My kids still think I build aviaries. __ R-help@stat.math.ethz.ch 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 numerical integration and optimization with BFGS
Prof. Ripley, The code that I provided with my question of course does not contain code for the derivatives; but I am supplying analytical derivatives in my full program. I did not include that code with my question because that would have added about 200 more lines of code without adding any new information relevant for my question. The problem that I had pointed to occurs whether I provide analytical derivatives or not to the optimization routine. And the problem was that when I use the "BFGS" method in optim, I get an error message saying that the integrals are probably divergent; I know, on the other hand, that the integrals are convergent. The same problem does not arise when I instead use the Nelder-Mead method in optim. Your suggestion that the expression can be analytically integrated (which will involve "pnorm") might be correct though I do not see how to do that. The integrands are the bivariate normal density functions with one variable replaced by known quantities while I integrate over the second. For instance, the first integral is as follows: the integrand is the bivariate normal density function (with general covariance matrix) where the second variable has been replaced by y[i] - rho1*y[i-1] + delta and I integrate over the first variable; the range of integration is lower=-y[i]+rho1*y[i-1] upper=y[i]-rho1*y[i-1] The other two integrals are very similar. It would be of great help if you could point out how to integrate the expressions analytically using "pnorm". Thanks. Deepankar On Fri, 2007-05-25 at 04:22 +0100, Prof Brian Ripley wrote: > You are trying to use a derivative-based optimization method without > supplying derivatives. This will use numerical approoximations to the > derivatives, and your objective function will not be suitable as it is > internally using adaptive numerical quadrature and hence is probably not > close enough to a differentiable function (it may well have steps). > > I believe you can integrate analytically (the answer will involve pnorm), > and that you can also find analytical derivatives. > > Using (each of) numerical optimization and integration is a craft, and it > seems you need to know more about it. The references on ?optim are too > advanced I guess, so you could start with Chapter 16 of MASS and its > references. > > On Thu, 24 May 2007, Deepankar Basu wrote: > > > Hi R users, > > > > I have a couple of questions about some problems that I am facing with > > regard to numerical integration and optimization of likelihood > > functions. Let me provide a little background information: I am trying > > to do maximum likelihood estimation of an econometric model that I have > > developed recently. I estimate the parameters of the model using the > > monthly US unemployment rate series obtained from the Federal Reserve > > Bank of St. Louis. (The data is freely available from their web-based > > database called FRED-II). > > > > For my model, the likelihood function for each observation is the sum of > > three integrals. The integrand in each of these integrals is of the > > following form: > > > > A*exp(B+C*x-D*x^2) > > > > where A, B, C and D are constants, exp() is the exponential function and > > x is the variable of integration. The constants A and D are always > > positive; B is always negative, while there is no a priori knowledge > > about the sign of C. All the constants are finite. > > > > Of the three integrals, one has finite limits while the other two have > > the following limits: > > > > lower = -Inf > > upper = some finite number (details can be found in the code below) > > Try integrating that analytically by change of variable to a normal CDF. > > > > My problem is the following: when I try to maximize the log-likelihood > > function using "optim" with method "BFGS", I get the following error > > message (about the second integral): > > > >> out <- optim(alpha.start, LLK, gr=NULL, method="BFGS", y=urate$y) > > Error in integrate(f3, lower = -Inf, upper = upr2) : > >the integral is probably divergent > > > > Since I know that all the three integrals are convergent, I do not > > understand why I am getting this error message. My first question: can > > someone explain what mistake I am making? > > > > What is even more intriguing is that when I use the default method > > (Nelder-Mead) in "optim" instead of BFGS, I do not get any such error > > message. Since both methods (Nelder-Mead and BFGS) will need to evaluate > > the integrals, my second question is: why this difference? > > > > Below, I am providing the code that I use. Any help will be greatly > > appreciated. > > > > > > Deepankar > > > > > > CODE START *** > > > > > > > > # > > # COMPUTING THE LOGLIKELIHOOD > > # USING NUMERICAL INTEGRALS > > # > > > > LLK <- function(alpha, y) { > > > > n <- length(y) > > lglik <- numeric(n) # TO BE SUMMED LATER TO GET THE LOGL
Re: [R] Question about setReplaceMethod
[EMAIL PROTECTED] writes: > Sorry Martin. I had that line in my actual code. It did not work. I > looked around all the google but it doesn't seem to have answer to > this. Any ideas? Thank you. A more complete solution -- remember to return 'this' throughout (R is 'pass by value' rather than pass by reference, so changes inside functions are only changes to the _local_ definition). Some of this is only guessing at your intention... setClass("Foo", representation(x="data.frame", y="character")) setGeneric("setX<-", function(this, value) standardGeneric("setX<-")) setReplaceMethod("setX", signature=signature("Foo", "data.frame"), function(this,value) { [EMAIL PROTECTED] <- value this }) setGeneric("generateFrame", function(this) standardGeneric("generateFrame")) ## generateFrame seems like it is not meant to be a replacement method setMethod("generateFrame", signature=signature(this="Foo"), function(this) { frame <- data.frame(x=letters[1:5], y=letters[5:1]) setX(this) <- frame # modifies [EMAIL PROTECTED] this # return 'this', an object of class Foo }) foo <- function() { objFoo <- new("Foo", x=data.frame(NULL), y="") cat("objFoo (after new)\n") print(objFoo) ## now assign 'frame' the results of generateFrame, i.e., an ## object of class 'Foo'. objFoo does not change frame <- generateFrame(objFoo) cat("frame:\n") print(frame); ## change the value of [EMAIL PROTECTED] setX(objFoo) <- data.frame(x=LETTERS[1:5], y=LETTERS[5:1]) cat("objFoo (after setX):\n") print(objFoo) ## what to return?? maybe just 'ok', and lose all our changes! "ok" } > > > > - adschai > - Original Message - > From: Martin Morgan @FHCRC.ORG> > Date: Thursday, May 24, 2007 9:35 pm > Subject: Re: [R] Question about setReplaceMethod > To: [EMAIL PROTECTED] > Cc: r-help@stat.math.ethz.ch >> Hi Adschai -- >> >> You'll want to return the value whose slot you have modified: >> >> setReplaceMethod("setX", "foo", >> function(this,value) { >> [EMAIL PROTECTED] <- value >> this # add this line >> }) >> >> Martin >> >> [EMAIL PROTECTED] writes: >> >> > Hi >> > >> > I have the code like I show below. The problem here is that I >> have a >> > setReplacementMethod to set the value of my class slot. However, >> > this function doesn't work when I call it within another function >> > definition (declared by setMethod) of the same class. I do not >> > understand this behavior that much. I'm wondering how to make this >> > work? Any help would be really appreciated. Thank you. >> > >> > setClass("foo", >> > representation(x="data.frame", y="character")) >> > setGeneric("setX<-", function(this, value), >> standardGeneric("setX<-")) >> > setReplaceMethod("setX", "foo", >> > function(this,value) { >> > [EMAIL PROTECTED] <- value >> > }) >> > setGeneric("generateFrame", function(this), >> standardGeneric("generateFrame"))> >> setReplaceMethod("generateFrame", "foo", >> > function(this) { >> > frame <- read.csv(file="myfile.csv", header=T) # read some >> input file >> > [EMAIL PROTECTED] <- frame # this doesn't replace the value for me >> > setX(this) <- frame # this doesn't replace the value for me >> > frame # instead I have to return the frame object >> > }) >> > foo <- function(x,y) { >> > objFoo <- new("foo", x=data.frame(NULL), y="") >> > frame <- generateFrame(objFoo) # after this point, nothing got >> assigned to [EMAIL PROTECTED] >> > setX(objFoo) <- frame # this will work (why do I have to >> duplicate this??) >> > } >> > - adschai >> > >> > [[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. >> >> -- >> Martin Morgan >> Bioconductor / Computational Biology >> http://bioconductor.org >> -- Martin Morgan Bioconductor / Computational Biology http://bioconductor.org __ R-help@stat.math.ethz.ch 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] Fwd: How to obtain cointegrated relationship from ca.jo in urca package?
--- Begin Message --- --- End Message --- __ R-help@stat.math.ethz.ch 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 numerical integration and optimization with BFGS
You are trying to use a derivative-based optimization method without supplying derivatives. This will use numerical approoximations to the derivatives, and your objective function will not be suitable as it is internally using adaptive numerical quadrature and hence is probably not close enough to a differentiable function (it may well have steps). I believe you can integrate analytically (the answer will involve pnorm), and that you can also find analytical derivatives. Using (each of) numerical optimization and integration is a craft, and it seems you need to know more about it. The references on ?optim are too advanced I guess, so you could start with Chapter 16 of MASS and its references. On Thu, 24 May 2007, Deepankar Basu wrote: > Hi R users, > > I have a couple of questions about some problems that I am facing with > regard to numerical integration and optimization of likelihood > functions. Let me provide a little background information: I am trying > to do maximum likelihood estimation of an econometric model that I have > developed recently. I estimate the parameters of the model using the > monthly US unemployment rate series obtained from the Federal Reserve > Bank of St. Louis. (The data is freely available from their web-based > database called FRED-II). > > For my model, the likelihood function for each observation is the sum of > three integrals. The integrand in each of these integrals is of the > following form: > > A*exp(B+C*x-D*x^2) > > where A, B, C and D are constants, exp() is the exponential function and > x is the variable of integration. The constants A and D are always > positive; B is always negative, while there is no a priori knowledge > about the sign of C. All the constants are finite. > > Of the three integrals, one has finite limits while the other two have > the following limits: > > lower = -Inf > upper = some finite number (details can be found in the code below) Try integrating that analytically by change of variable to a normal CDF. > My problem is the following: when I try to maximize the log-likelihood > function using "optim" with method "BFGS", I get the following error > message (about the second integral): > >> out <- optim(alpha.start, LLK, gr=NULL, method="BFGS", y=urate$y) > Error in integrate(f3, lower = -Inf, upper = upr2) : >the integral is probably divergent > > Since I know that all the three integrals are convergent, I do not > understand why I am getting this error message. My first question: can > someone explain what mistake I am making? > > What is even more intriguing is that when I use the default method > (Nelder-Mead) in "optim" instead of BFGS, I do not get any such error > message. Since both methods (Nelder-Mead and BFGS) will need to evaluate > the integrals, my second question is: why this difference? > > Below, I am providing the code that I use. Any help will be greatly > appreciated. > > > Deepankar > > > CODE START *** > > > > # > # COMPUTING THE LOGLIKELIHOOD > # USING NUMERICAL INTEGRALS > # > > LLK <- function(alpha, y) { > > n <- length(y) > lglik <- numeric(n) # TO BE SUMMED LATER TO GET THE LOGLIKELIHOOD > > lambda <- numeric(n-1)# GENERATING *lstar* > for (i in 1:(n-1)) { # TO USE IN THE > lambda[i] <- y[i+1]/y[i] # RE-PARAMETRIZATION BELOW > } > lstar <- (min(lambda)-0.01) > > > # NOTE RE-PARAMETRIZATION > # THESE RESTRICTIONS EMERGE FROM THE MODEL > > muep <- alpha[1] # NO RESTRICTION > sigep <- 0.01 + exp(alpha[2])# greater than > 0.01 > sigeta <- 0.01 + exp(alpha[3])# greater than > 0.01 > rho2 <- 0.8*sin(alpha[4]) # between -0.8 > and 0.8 > rho1 <- lstar*abs(alpha[5])/(1+abs(alpha[5])) # between 0 and > lstar > delta <- 0.01 + exp(alpha[6]) # greater than > 0.01 > > > ## > # THE THREE FUNCTIONS TO INTEGRATE > # FOR COMPUTING THE LOGLIKELIHOOD > ## > > denom <- 2*pi*sigep*sigeta*(sqrt(1-rho2^2)) # A CONSTANT TO BE USED > # FOR DEFINING THE > # THREE FUNCTIONS > > > f1 <- function(z1) { # FIRST FUNCTION > > b11 <- ((z1-muep)^2)/((-2)*(1-rho2^2)*(sigep^2)) > b12 <- > (rho2*(z1-muep)*(y[i]-y[i-1]+delta))/((1-rho2^2)*sigep*sigeta) > b13 <- ((y[i]-y[i-1]+delta)^2)/((-2)*(1-rho2^2)*(sigeta^2)) > > return((exp(b11+b12+b13))/denom) > } > > f3 <- function(z3) { # SECOND FUNCTION > > b31 <- ((y[i]-rho1*y[i-1]-muep)^2)/((-2)*(1-rho2^2)*(sigep^2)) > b32 <- > (rho2*(y[i]-rho1*y[i-1]-muep)*z3)/((1-rho2^2)*sigep*sigeta) > b33 <- ((z3)^2)/((-2)*(1-rho2^2)*(sigeta^2)) > > return((exp(b31+b32+b33))/denom) > }
Re: [R] Question about setReplaceMethod
Sorry Martin. I had that line in my actual code. It did not work. I looked around all the google but it doesn't seem to have answer to this. Any ideas? Thank you. - adschai - Original Message - From: Martin Morgan Date: Thursday, May 24, 2007 9:35 pm Subject: Re: [R] Question about setReplaceMethod To: [EMAIL PROTECTED] Cc: r-help@stat.math.ethz.ch > Hi Adschai -- > > You'll want to return the value whose slot you have modified: > > setReplaceMethod("setX", "foo", > function(this,value) { > [EMAIL PROTECTED] <- value > this # add this line > }) > > Martin > > [EMAIL PROTECTED] writes: > > > Hi > > > > I have the code like I show below. The problem here is that I > have a > > setReplacementMethod to set the value of my class slot. However, > > this function doesn't work when I call it within another function > > definition (declared by setMethod) of the same class. I do not > > understand this behavior that much. I'm wondering how to make this > > work? Any help would be really appreciated. Thank you. > > > > setClass("foo", > > representation(x="data.frame", y="character")) > > setGeneric("setX<-", function(this, value), > standardGeneric("setX<-")) > > setReplaceMethod("setX", "foo", > > function(this,value) { > > [EMAIL PROTECTED] <- value > > }) > > setGeneric("generateFrame", function(this), > standardGeneric("generateFrame"))> > setReplaceMethod("generateFrame", "foo", > > function(this) { > > frame <- read.csv(file="myfile.csv", header=T) # read some > input file > > [EMAIL PROTECTED] <- frame # this doesn't replace the value for me > > setX(this) <- frame # this doesn't replace the value for me > > frame # instead I have to return the frame object > > }) > > foo <- function(x,y) { > > objFoo <- new("foo", x=data.frame(NULL), y="") > > frame <- generateFrame(objFoo) # after this point, nothing got > assigned to [EMAIL PROTECTED] > > setX(objFoo) <- frame # this will work (why do I have to > duplicate this??) > > } > > - adschai > > > > [[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. > > -- > Martin Morgan > Bioconductor / Computational Biology > http://bioconductor.org > [[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] Question about setReplaceMethod
Hi Adschai -- You'll want to return the value whose slot you have modified: setReplaceMethod("setX", "foo", function(this,value) { [EMAIL PROTECTED] <- value this # add this line }) Martin [EMAIL PROTECTED] writes: > Hi > > I have the code like I show below. The problem here is that I have a > setReplacementMethod to set the value of my class slot. However, > this function doesn't work when I call it within another function > definition (declared by setMethod) of the same class. I do not > understand this behavior that much. I'm wondering how to make this > work? Any help would be really appreciated. Thank you. > > setClass("foo", > representation(x="data.frame", y="character")) > setGeneric("setX<-", function(this, value), standardGeneric("setX<-")) > setReplaceMethod("setX", "foo", > function(this,value) { > [EMAIL PROTECTED] <- value > }) > setGeneric("generateFrame", function(this), standardGeneric("generateFrame")) > setReplaceMethod("generateFrame", "foo", > function(this) { > frame <- read.csv(file="myfile.csv", header=T) # read some input file > [EMAIL PROTECTED] <- frame # this doesn't replace the value for me > setX(this) <- frame # this doesn't replace the value for me > frame # instead I have to return the frame object > }) > foo <- function(x,y) { > objFoo <- new("foo", x=data.frame(NULL), y="") > frame <- generateFrame(objFoo) # after this point, nothing got assigned to > [EMAIL PROTECTED] > setX(objFoo) <- frame # this will work (why do I have to duplicate this??) > } > - adschai > > [[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. -- Martin Morgan Bioconductor / Computational Biology http://bioconductor.org __ R-help@stat.math.ethz.ch 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 obtain cointegrated relationship from ca.jo in urca package?
Hi, I can plot the ca.jo package to view the cointegrated relationship for each eigen value. Or I can use the normalized eigen vector to reconstruct the cointegrated relationship series. However, since the package can plot that for me, I wonder is there any specific slot/method in the class from where I can invoke to get this relationship instead of doing a duplicated work? Thank you. - adschai [[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] Question about setReplaceMethod
Hi I have the code like I show below. The problem here is that I have a setReplacementMethod to set the value of my class slot. However, this function doesn't work when I call it within another function definition (declared by setMethod) of the same class. I do not understand this behavior that much. I'm wondering how to make this work? Any help would be really appreciated. Thank you. setClass("foo", representation(x="data.frame", y="character")) setGeneric("setX<-", function(this, value), standardGeneric("setX<-")) setReplaceMethod("setX", "foo", function(this,value) { [EMAIL PROTECTED] <- value }) setGeneric("generateFrame", function(this), standardGeneric("generateFrame")) setReplaceMethod("generateFrame", "foo", function(this) { frame <- read.csv(file="myfile.csv", header=T) # read some input file [EMAIL PROTECTED] <- frame # this doesn't replace the value for me setX(this) <- frame # this doesn't replace the value for me frame # instead I have to return the frame object }) foo <- function(x,y) { objFoo <- new("foo", x=data.frame(NULL), y="") frame <- generateFrame(objFoo) # after this point, nothing got assigned to [EMAIL PROTECTED] setX(objFoo) <- frame # this will work (why do I have to duplicate this??) } - adschai [[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] in unix opening data object created under win
On Unix R's version is 2.3.1 and on PC its 2.4.1. I dont have the rights to install newer version of R on Unix. I tried different upload methods. No one worked. On Unix it looks as follows (dots to hide my userid): > load("/afs/ir/users/../project/ps/data/dtaa") > head(dtaa) hospid mfpi1 mfpi2 mfpi3 mfpi4 mfpi5 mfpi6 mfpi7 mfpi8 NA9 0.1428571 1 0.5 0.2857143 0.50 0.0 0.333 0 4041 9 0.1428571 0 0.0 0.2857143 0.25 0.2 0.000 0 mfpi9 NA 0.333 4041 1.000 > The data comes through but its screwed up. Thanks for your help. Toby Liaw, Andy wrote: > What are the versions of R on the two platform? Is the version on Unix > at least as new as the one on Windows? > > Andy > > From: [EMAIL PROTECTED] > >>Hi All >> >>I am saving a dataframe in my MS-Win R with save(). >>Then I copy it onto my personal AFS space. >>Then I start R and run it with emacs and load() the data. >>It loads only 2 lines: head() shows only two lines nrow() als >>say it has only 2 >>lines, I get error message, when trying to use this data >>object, saying that >>some row numbers are missing. >>If anyone had similar situation, I appreciate letting me know. >> >>Best Toby >> >>__ >>R-help@stat.math.ethz.ch 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. > __ R-help@stat.math.ethz.ch 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 numerical integration and optimization with BFGS
Deepankar Basu osu.edu> writes: > > > For my model, the likelihood function for each observation is the sum of > three integrals. The integrand in each of these integrals is of the > following form: > > A*exp(B+C*x-D*x^2) > (where D is positive) Being very lazy, I tried Mathematica's online integrator (http://integrals.wolfram.com/index.jsp), which says that 2 Integrate[Exp[b + c x - d x ], x] == 2 b + c /(4 d) -c + 2 d x E Sqrt[Pi] Erf[--] 2 Sqrt[d] -- 2 Sqrt[d] R knows "Erf" (the error function) as pnorm -- can you use this to avoid numerical integration entirely ?? __ R-help@stat.math.ethz.ch 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 numerical integration and optimization with BFGS
Hi R users, I have a couple of questions about some problems that I am facing with regard to numerical integration and optimization of likelihood functions. Let me provide a little background information: I am trying to do maximum likelihood estimation of an econometric model that I have developed recently. I estimate the parameters of the model using the monthly US unemployment rate series obtained from the Federal Reserve Bank of St. Louis. (The data is freely available from their web-based database called FRED-II). For my model, the likelihood function for each observation is the sum of three integrals. The integrand in each of these integrals is of the following form: A*exp(B+C*x-D*x^2) where A, B, C and D are constants, exp() is the exponential function and x is the variable of integration. The constants A and D are always positive; B is always negative, while there is no a priori knowledge about the sign of C. All the constants are finite. Of the three integrals, one has finite limits while the other two have the following limits: lower = -Inf upper = some finite number (details can be found in the code below) My problem is the following: when I try to maximize the log-likelihood function using "optim" with method "BFGS", I get the following error message (about the second integral): > out <- optim(alpha.start, LLK, gr=NULL, method="BFGS", y=urate$y) Error in integrate(f3, lower = -Inf, upper = upr2) : the integral is probably divergent Since I know that all the three integrals are convergent, I do not understand why I am getting this error message. My first question: can someone explain what mistake I am making? What is even more intriguing is that when I use the default method (Nelder-Mead) in "optim" instead of BFGS, I do not get any such error message. Since both methods (Nelder-Mead and BFGS) will need to evaluate the integrals, my second question is: why this difference? Below, I am providing the code that I use. Any help will be greatly appreciated. Deepankar CODE START *** # # COMPUTING THE LOGLIKELIHOOD # USING NUMERICAL INTEGRALS # LLK <- function(alpha, y) { n <- length(y) lglik <- numeric(n) # TO BE SUMMED LATER TO GET THE LOGLIKELIHOOD lambda <- numeric(n-1)# GENERATING *lstar* for (i in 1:(n-1)) { # TO USE IN THE lambda[i] <- y[i+1]/y[i] # RE-PARAMETRIZATION BELOW } lstar <- (min(lambda)-0.01) # NOTE RE-PARAMETRIZATION # THESE RESTRICTIONS EMERGE FROM THE MODEL muep <- alpha[1] # NO RESTRICTION sigep <- 0.01 + exp(alpha[2])# greater than 0.01 sigeta <- 0.01 + exp(alpha[3])# greater than 0.01 rho2 <- 0.8*sin(alpha[4]) # between -0.8 and 0.8 rho1 <- lstar*abs(alpha[5])/(1+abs(alpha[5])) # between 0 and lstar delta <- 0.01 + exp(alpha[6]) # greater than 0.01 ## # THE THREE FUNCTIONS TO INTEGRATE # FOR COMPUTING THE LOGLIKELIHOOD ## denom <- 2*pi*sigep*sigeta*(sqrt(1-rho2^2)) # A CONSTANT TO BE USED # FOR DEFINING THE # THREE FUNCTIONS f1 <- function(z1) { # FIRST FUNCTION b11 <- ((z1-muep)^2)/((-2)*(1-rho2^2)*(sigep^2)) b12 <- (rho2*(z1-muep)*(y[i]-y[i-1]+delta))/((1-rho2^2)*sigep*sigeta) b13 <- ((y[i]-y[i-1]+delta)^2)/((-2)*(1-rho2^2)*(sigeta^2)) return((exp(b11+b12+b13))/denom) } f3 <- function(z3) { # SECOND FUNCTION b31 <- ((y[i]-rho1*y[i-1]-muep)^2)/((-2)*(1-rho2^2)*(sigep^2)) b32 <- (rho2*(y[i]-rho1*y[i-1]-muep)*z3)/((1-rho2^2)*sigep*sigeta) b33 <- ((z3)^2)/((-2)*(1-rho2^2)*(sigeta^2)) return((exp(b31+b32+b33))/denom) } f5 <- function(z5) { # THIRD FUNCTION b51 <- ((-y[i]+rho1*y[i-1]-muep)^2)/((-2)*(1-rho2^2)*sigep^2) b52 <- (rho2*(-y[i]+rho1*y[i-1]-muep)*(z5))/((1-rho2^2)*sigep*sigeta) b53 <- ((z5)^2)/((-2)*(1-rho2^2)*(sigeta^2)) return((exp(b51+b52+b53))/denom) } for (i in 2:n) { # START FOR LOOP upr1 <- (y[i]-rho1*y[i-1]) upr2 <- (y[i]-y[i-1]+delta) # INTEGRATING THE THREE FUNCTIONS out1 <- integrate(f1, lower = (-1)*upr1, upper = upr1) out3 <- integrate(f3, lower = -Inf, upper = upr2) out5 <- integrate(f5, lower= -Inf, upper = upr2) pdf <- (out1$val + out3$val + out5$val) lglik[i] <- log(pdf) # LOGLIKELIHOOD FOR OBSERVATION i } # END FOR LOOP return(-sum(lglik)) # RETURNING NEGATIVE OF THE LOGLIKELIHOOD # BECAUSE optim DOES MINIMIZATION BY DEFAULT } * CODE ENDS * Then I use: > ura
Re: [R] GUI component Margin on tkcanvas, tkframe or tktoplevel
Dear Hao, > -Original Message- > From: [EMAIL PROTECTED] > [mailto:[EMAIL PROTECTED] On Behalf Of Hao Liu > Sent: Thursday, May 24, 2007 3:53 PM > To: r-help@stat.math.ethz.ch > Subject: [R] GUI component Margin on tkcanvas, tkframe or tktoplevel > > Dear gurus: > > I have a question on how to configure the margin layout on > tcl/tk GUI objects like tkcanvas, tkframe or tktoplevel. > For example, if I want to leave a larger margin on the left > side of the GUI container, which one should I configure, the > toplevel or tkcanvas or tkframe? > > top<-tktoplevel() > canvas<-tkcanvas(top, relief=, borderwidth=...) I've used the borderwidth argument (which, I believe, affects all of the borders) in several places, including to tkframe(). You can try it out and see whether you get the effect you want. > > I also find the documentation for all the possible arguments > that could be passed to tktoplevel, tkframe, tkcanvas, tk.wm, > tkconfigure is not good. I wonder if there are good resource > for it... at the very least, I know I need to look at what > arguments that tck/tk takes... but I don't have time to go that far. > I think that the tcltk package documentation is meant to be used alongside Tcl/Tk documentation. The most useful source that I've found is Welch et al., Practical Programming in Tcl and Tk. I hope this helps, John > Thanks > Hao > > __ > R-help@stat.math.ethz.ch 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] Function to Sort and test AIC for mixed model lme?
On May 24, 2007, at 2:12 PM, Douglas Bates wrote: > On 5/24/07, Ken Nussear <[EMAIL PROTECTED]> wrote: >> > Ken Nussear mac.com> writes: >> > >> > > I'm running a series of mixed models using lme, and I wonder if >> > there >> > > is a way to sort them by AIC prior to testing using anova >> > > (lme1,lme2,lme3,lme7) other than by hand. >> > >> > You can try something like the following. However, also consider >> > using dropterm or stepAIC in MASS. >> > >> > Dieter >> > >> > #- >> > >> > library(nlme) >> > fmlist = vector("list",2) >> > fmlist[[1]] = lme(distance ~ age, data = Orthodont,method="ML") >> > fmlist[[2]] = lme(distance ~ age + Sex, data = Orthodont, random >> > = ~ 1,method="ML") >> > aic0 = unlist(lapply(fmlist,AIC)) >> > aic0 # larger first >> > fmlist1 = fmlist[order(aic0)] >> > unlist(lapply(fmlist1,AIC)) # smaller first >> >> I looked at stepAIC, but wanted to specify my own models. >> >> I have come pretty close with this >> >> # grab all lme objects >> tst1 <- ls(pat=".ml") >> > tst1 >> [1] "lme.T972way.ml" "lme.T97FULL.ml" "lme.T97NOINT.ml" >> "lme.T97NULL.ml" "lme.T97fc.ml""lme.T97min.ml" >> [7] "lme.T97ns.ml" >> >> #create array of AIC for all in tst1 >> tst2 <- lapply(lapply(tst1,get),AIC) >> > tst2 >> [[1]] >> [1] 507.0991 >> >> [[2]] >> [1] 508.7594 >> >> [[3]] >> [1] 564.8574 >> >> [[4]] >> [1] 624.3053 >> >> [[5]] >> [1] 502.5878 >> >> [[6]] >> [1] 569.8188 >> >> [[7]] >> [1] 504.8971 >> >> #sort tst1 by order of tst2 >> tst3 <- tst1[order(unlist(tst2))] >> >> > tst3 >> [1] "lme.T97fc.ml""lme.T97ns.ml""lme.T972way.ml" >> "lme.T97FULL.ml" "lme.T97NOINT.ml" "lme.T97min.ml" >> [7] "lme.T97NULL.ml" >> >> >> The problem comes with getting the final anova statement to run. >> >> >anova(tst3) >> Error in anova(tst3) : no applicable method for "anova" >> >> I also tried >> >> tst4 <- paste(toString(tst3),collapse="") >> >> > tst4 >> [1] "lme.T97fc.ml, lme.T97ns.ml, lme.T972way.ml, lme.T97FULL.ml, >> lme.T97NOINT.ml, lme.T97min.ml, lme.T97NULL.ml" >> > >> > anova(tst4) >> Error in anova(tst4) : no applicable method for "anova" >> >> Any ideas on getting the last part to work? > > > tst3 is a character vector of names so you would need to use > > do.call(anova, lapply(tst3, get)) > > I think it is better to create a list of fitted models initially > instead of working with names. It would look something like this > (this code is untested) > > tst2 <- lapply(tst1, get) > names(tst2) <- tst1 > do.call(anova, tst2[order(unlist(lapply(tst2, AIC)))]) I get errors with each method that I'm not sure how to solve. Any Ideas? Method 1 > do.call(anova, lapply(tst3, get)) Error in `row.names<-.data.frame`(`*tmp*`, value = c("structure(list (modelStruct = structure(list(reStruct = structure(list(", : invalid 'row.names' length Method 2 > names(tst2) <- tst1 > tst2 $lme.T972way.ml [1] 507.0991 $lme.T97FULL.ml [1] 508.7594 $lme.T97NOINT.ml [1] 564.8574 $lme.T97NULL.ml [1] 624.3053 $lme.T97fc.ml [1] 502.5878 $lme.T97min.ml [1] 569.8188 $lme.T97ns.ml [1] 504.8971 > do.call(anova, tst2[order(unlist(lapply(tst2, AIC)))]) Error in logLik(object) : no applicable method for "logLik" > __ R-help@stat.math.ethz.ch 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] Function to Sort and test AIC for mixed model lme?
On 5/24/07, Ken Nussear <[EMAIL PROTECTED]> wrote: > > Ken Nussear mac.com> writes: > > > > > I'm running a series of mixed models using lme, and I wonder if > > there > > > is a way to sort them by AIC prior to testing using anova > > > (lme1,lme2,lme3,lme7) other than by hand. > > > > You can try something like the following. However, also consider > > using dropterm or stepAIC in MASS. > > > > Dieter > > > > #- > > > > library(nlme) > > fmlist = vector("list",2) > > fmlist[[1]] = lme(distance ~ age, data = Orthodont,method="ML") > > fmlist[[2]] = lme(distance ~ age + Sex, data = Orthodont, random > > = ~ 1,method="ML") > > aic0 = unlist(lapply(fmlist,AIC)) > > aic0 # larger first > > fmlist1 = fmlist[order(aic0)] > > unlist(lapply(fmlist1,AIC)) # smaller first > > I looked at stepAIC, but wanted to specify my own models. > > I have come pretty close with this > > # grab all lme objects > tst1 <- ls(pat=".ml") > > tst1 > [1] "lme.T972way.ml" "lme.T97FULL.ml" "lme.T97NOINT.ml" > "lme.T97NULL.ml" "lme.T97fc.ml""lme.T97min.ml" > [7] "lme.T97ns.ml" > > #create array of AIC for all in tst1 > tst2 <- lapply(lapply(tst1,get),AIC) > > tst2 > [[1]] > [1] 507.0991 > > [[2]] > [1] 508.7594 > > [[3]] > [1] 564.8574 > > [[4]] > [1] 624.3053 > > [[5]] > [1] 502.5878 > > [[6]] > [1] 569.8188 > > [[7]] > [1] 504.8971 > > #sort tst1 by order of tst2 > tst3 <- tst1[order(unlist(tst2))] > > > tst3 > [1] "lme.T97fc.ml""lme.T97ns.ml""lme.T972way.ml" > "lme.T97FULL.ml" "lme.T97NOINT.ml" "lme.T97min.ml" > [7] "lme.T97NULL.ml" > > > The problem comes with getting the final anova statement to run. > > >anova(tst3) > Error in anova(tst3) : no applicable method for "anova" > > I also tried > > tst4 <- paste(toString(tst3),collapse="") > > > tst4 > [1] "lme.T97fc.ml, lme.T97ns.ml, lme.T972way.ml, lme.T97FULL.ml, > lme.T97NOINT.ml, lme.T97min.ml, lme.T97NULL.ml" > > > > anova(tst4) > Error in anova(tst4) : no applicable method for "anova" > > Any ideas on getting the last part to work? tst3 is a character vector of names so you would need to use do.call(anova, lapply(tst3, get)) I think it is better to create a list of fitted models initially instead of working with names. It would look something like this (this code is untested) tst2 <- lapply(tst1, get) names(tst2) <- tst1 do.call(anova, tst2[order(unlist(lapply(tst2, AIC)))]) __ R-help@stat.math.ethz.ch 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] Function to Sort and test AIC for mixed model lme?
> Ken Nussear mac.com> writes: > > > I'm running a series of mixed models using lme, and I wonder if > there > > is a way to sort them by AIC prior to testing using anova > > (lme1,lme2,lme3,lme7) other than by hand. > > You can try something like the following. However, also consider > using dropterm or stepAIC in MASS. > > Dieter > > #- > > library(nlme) > fmlist = vector("list",2) > fmlist[[1]] = lme(distance ~ age, data = Orthodont,method="ML") > fmlist[[2]] = lme(distance ~ age + Sex, data = Orthodont, random > = ~ 1,method="ML") > aic0 = unlist(lapply(fmlist,AIC)) > aic0 # larger first > fmlist1 = fmlist[order(aic0)] > unlist(lapply(fmlist1,AIC)) # smaller first I looked at stepAIC, but wanted to specify my own models. I have come pretty close with this # grab all lme objects tst1 <- ls(pat=".ml") > tst1 [1] "lme.T972way.ml" "lme.T97FULL.ml" "lme.T97NOINT.ml" "lme.T97NULL.ml" "lme.T97fc.ml""lme.T97min.ml" [7] "lme.T97ns.ml" #create array of AIC for all in tst1 tst2 <- lapply(lapply(tst1,get),AIC) > tst2 [[1]] [1] 507.0991 [[2]] [1] 508.7594 [[3]] [1] 564.8574 [[4]] [1] 624.3053 [[5]] [1] 502.5878 [[6]] [1] 569.8188 [[7]] [1] 504.8971 #sort tst1 by order of tst2 tst3 <- tst1[order(unlist(tst2))] > tst3 [1] "lme.T97fc.ml""lme.T97ns.ml""lme.T972way.ml" "lme.T97FULL.ml" "lme.T97NOINT.ml" "lme.T97min.ml" [7] "lme.T97NULL.ml" The problem comes with getting the final anova statement to run. >anova(tst3) Error in anova(tst3) : no applicable method for "anova" I also tried tst4 <- paste(toString(tst3),collapse="") > tst4 [1] "lme.T97fc.ml, lme.T97ns.ml, lme.T972way.ml, lme.T97FULL.ml, lme.T97NOINT.ml, lme.T97min.ml, lme.T97NULL.ml" > > anova(tst4) Error in anova(tst4) : no applicable method for "anova" Any ideas on getting the last part to work? [[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] Why might X11() not be found?
> sessionInfo() R version 2.5.0 (2007-04-23) x86_64-unknown-linux-gnu locale: LC_CTYPE=en_US.UTF-8;LC_NUMERIC=C;LC_TIME=en_US.UTF-8;LC_COLLATE=en_US.UTF-8;LC_MONETARY=en_US.UTF-8;LC_MESSAGES=en_US.UTF-8;LC_PAPER=en_US.UTF-8;LC_NAME=C;LC_ADDRESS=C;LC_TELEPHONE=C;LC_MEASUREMENT=en_US.UTF-8;LC_IDENTIFICATION=C attached base packages: [1] "utils""stats""graphics" "methods" "base" other attached packages: lattice "0.15-5" > I've recently moved to Fedora Core 6 and installed the latest R from the tar.gz file as I've done for some years now. The make check returned no errors that I could see so it came as a surprise to see this: > plot(8) Error in plot.new() : could not find function "X11" It's possible that there's something different from previous versions with the graphic card driver in this installation but I'm mystified why there didn't seem to be any problem detected (or perhaps, more to the point, reported) during the installation of R. Everything else I've tried to do seems to work, but I don't do a lot in R before there's a reason to draw plots, so I need to find out what's going on. Where do I need to look to work out what could have failed? TIA -- ~.~.~.~.~.~.~.~.~.~.~.~.~.~.~.~.~.~.~.~.~.~.~.~.~.~.~.~.~.~.~.~.~.~.~.~. ___Patrick Connolly {~._.~} Great minds discuss ideas _( Y )_Middle minds discuss events (:_~*~_:)Small minds discuss people (_)-(_) . Anon ~.~.~.~.~.~.~.~.~.~.~.~.~.~.~.~.~.~.~.~.~.~.~.~.~.~.~.~.~.~.~.~.~.~.~.~. __ R-help@stat.math.ethz.ch 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] The paper also presents a very brief introduction to the entire flow of video compression.
T2Y.F IST 300% GESTIEGEN. ES WIRD 500% KURSSPRUNG ERWARTET. TYCHE ENERGY KURZEL: T2Y.F HANDELSPLATZ: FRANKFURT 5-TAGE ZIEL: 1 EURO T2Y.F RALLYE IST GESTARTET. SEIEN SIE DABEI! KAUFEN WAEHREND ES NOCH BILLIG IST. LASSEN SIE SICH DIESE CHANCE NICHT ENTGEHEN! For any assistance for creating . time to see what can be donne. Comments were invented to explain the code, not to hide lines of code not to be executed. The efficient implementation of a set of common computation routines. One Question: What and How can we do in order to have the table appear in our own GUI, rather than let it pop-up as a new GUI. m, handleRadarControlls. com - Go to ShopKitchenAid. DealofDay: Fetching Tupperware- Rectangle Cake Taker and Cupcake or Muffin Carrier Hold on! very good for basic understanding! DealofDay: Fetching Bob Greene Best Life Diet - Join the diet Oprah trusts: The Bob Greene Diet Hold on! Enviroment interferences make the signal increase or decrease according to its phase. I do have one question, how can I increase the size of the row labels? Data is encoded using a space-time block code, and the encoded data is split into n streams which are simultaneously transmitted using n transmit antennas. Just as with the function SET 'PName' is case insensitive and need only be unique. This function imitates the table cells with edit boxes which may become slow if the number of elements required is large. I do have one question, how can I increase the size of the row labels? xk and their conjugates. Attention has been paid to the numerical stability of the computations and some steps have been taken to enhance the stability. About the Toolbox The Fuzzy Clustering and Data Analysis Toolbox is a collection of MATLAB functions. DealofDay: Fetching Weight Watchers - Kick Off the Season with Some Fresh New Recipe Ideas. If you have any intersts for this message please contuct me. DealofDay: Fetching Mission Orchards - Mission Orchards Specials Hold on! Folks want to see some explanation of the context and some help regarding what the files do. In addition, in some of the algorithms, you can change the functions' behaviour by supplying your own call-back function. Anyways I think some things do not make sense. A minimum example might be to include a . Tupperware-Go Deigo Go Tumbler and Meal Set Diego, a cousin to Dora the Explorer, is an animated character who teaches pre schoolers about animals and the environment. DealofDay: Fetching Safeway. The efficient implementation of a set of common computation routines. com - Healthy Hearts Wild Salmon Dinners Hold on! DealofDay: Fetching Tupperware-New Tinkerbell Tumblers on Sale now Hold on! Roossien Rating: Comments: It's a good start, but the script contains the "clear all" and "close all" commands, which is a very bad habit to do. DealofDay: Fetching Abebooks. See the function PLOT for information about S. The Capacity of a MIMO channel with nt transmit antenna and nr recieve antenna is analyzed. It needs some thinking and. DealofDay: Fetching Competition Bbq Secrets Hold on! DealofDay: Fetching Entertainment. m, handleRadarControlls. It's all FREE, so sign up today! It is useful when the number of cluster is unknown a priori. DealofDay: Fetching ShopKitchenAid. DealofDay: Fetching Weight Watchers - Kick Off the Season with Some Fresh New Recipe Ideas. DealofDay: Fetching FoodSaver. The Inverted Pendulum is one of the most important classical problems of Control Engineering. DealofDay: Fetching Impromptu Gourmet - Shop by Occasion at Impromptu Gourmet Hold on! Join for free by clicking through the link and entering your email address on the form. Lifescript- Free Vitamin Profile to see if you are getting enough vitamins Are you getting enough vitamins from food? For most of the functions, you can control a lot of properties to adapt its behaviour to your need. m, handleRadarControlls. __ R-help@stat.math.ethz.ch 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] R2 always increases as variables are added?
The answer to your question three is that the calculation of r-squared in summary.lm does depend on whether or not an intercept is included in the model. (Another part of the reason for you puzzlement is, I think, that you are computing R-squared as SSR/SST, which is only valid when when the model has an intercept). The code is in summary.lm, here are the relevant excerpts (assuming your model does not have weights): r <- z$residuals f <- z$fitted w <- z$weights if (is.null(w)) { mss <- if (attr(z$terms, "intercept")) sum((f - mean(f))^2) else sum(f^2) rss <- sum(r^2) } ... ans$r.squared <- mss/(mss + rss) If you want to compare models with and without an intercept based on R^2, then I suspect it's most appropriate to use the version of R^2 that does not use a mean. It's also worthwhile thinking about what you are actually doing. I find the most intuitive definition of R^2 (http://en.wikipedia.org/wiki/R_squared) is R2 = 1 - SSE / SST where SSE = sum_i (yhat_i - y_i)^2, (sum of errors in predictions for you model) and SST = sum_i (y_i - mean(y))^2 (sum of errors in predictions for an intercept-only model) This means that the standard definition of R2 effectively compares the model with an intercept-only model. As the error in predictions goes down, R2 goes up, and the model that uses the mean(y) as a prediction (i.e., the intercept-only model) provides a scale for these errors. If you think or know that the true mean of y is zero then it may be appropriate to compare against a zero model rather than an intercept-only model (in SST). And if the sample mean of y is quite different from zero, and you compare a no-intercept model against an intercept-only model, then you're going to get results that are not easily interpreted. Note that a common way of expressing and computing R^2 is as SSR/SST (which you used). (Where SSR = sum_i (yhat_i - mean(y))^2 ). However, this is only valid when the model has an intercept (i.e., SSR/SST = 1 - SSE/SST ONLY when the model has an intercept.) Here's some examples, based on your example: > set.seed(1) > data <- data.frame(x1=rnorm(10), x2=rnorm(10), y=rnorm(10), I=1) > > lm1 <- lm(y~1, data=data) > summary(lm1)$r.squared [1] 0 > y.hat <- fitted(lm1) > sum((y.hat-mean(data$y))^2)/sum((data$y-mean(data$y))^2) [1] 5.717795e-33 > > # model with no intercept > lm2 <- lm(y~x1+x2-1, data=data) > summary(lm2)$r.squared [1] 0.6332317 > y.hat <- fitted(lm2) > # no-intercept version of R^2 (2 ways to compute) > 1-sum((y.hat-data$y)^2)/sum((data$y)^2) [1] 0.6332317 > sum((y.hat)^2)/sum((data$y)^2) [1] 0.6332317 > # standard (assuming model has intercept) computations for R^2: > SSE <- sum((y.hat - data$y)^2) > SST <- sum((data$y - mean(data$y))^2) > SSR <- sum((y.hat - mean(data$y))^2) > 1 - SSE/SST [1] 0.6252577 > # Note that SSR/SST != 1 - SSE/SST (because the model doesn't have an intercept) > SSR/SST [1] 0.6616612 > > # model with intercept included in data > lm3 <- lm(y~x1+x2+I-1, data=data) > summary(lm3)$r.squared [1] 0.6503186 > y.hat <- fitted(lm3) > # no-intercept version of R^2 (2 ways to compute) > 1-sum((y.hat-data$y)^2)/sum((data$y)^2) [1] 0.6503186 > sum((y.hat)^2)/sum((data$y)^2) [1] 0.6503186 > # standard (assuming model has intercept) computations for R^2: > SSE <- sum((y.hat - data$y)^2) > SST <- sum((data$y - mean(data$y))^2) > SSR <- sum((y.hat - mean(data$y))^2) > 1 - SSE/SST [1] 0.6427161 > SSR/SST [1] 0.6427161 > > hope this helps, Tony Plate Disclaimer: I too do not have any degrees in statistics, but I'm 95% sure the above is mostly correct :-) If there are any major mistakes, I'm sure someone will point them out. ??? wrote: > Hi, everybody, > > 3 questions about R-square: > -(1)--- Does R2 always increase as variables are added? > -(2)--- Does R2 always greater than 1? > -(3)--- How is R2 in summary(lm(y~x-1))$r.squared > calculated? It is different from (r.square=sum((y.hat-mean > (y))^2)/sum((y-mean(y))^2)) > > I will illustrate these problems by the following codes: > -(1)--- R2 doesn't always increase as variables are added > >> x=matrix(rnorm(20),ncol=2) >> y=rnorm(10) >> >> lm=lm(y~1) >> y.hat=rep(1*lm$coefficients,length(y)) >> (r.square=sum((y.hat-mean(y))^2)/sum((y-mean(y))^2)) > [1] 2.646815e-33 >> lm=lm(y~x-1) >> y.hat=x%*%lm$coefficients >> (r.square=sum((y.hat-mean(y))^2)/sum((y-mean(y))^2)) > [1] 0.4443356 >> This is the biggest model, but its R2 is not the biggest, > why? >> lm=lm(y~x) >> y.hat=cbind(rep(1,length(y)),x)%*%lm$coefficients >> (r.square=sum((y.hat-mean(y))^2)/sum((y-mean(y))^2)) > [1] 0.2704789 > > > -(2)--- R2 can greater than 1 > >> x=rnorm(10) >> y=runif(10) >> lm=lm(y~x-1) >> y.hat=x*lm$coefficients >> (r.square=sum((y.hat-mean(y))^2)/sum((y-mean(y))^2)) > [1] 3.513865 >
[R] GUI component Margin on tkcanvas, tkframe or tktoplevel
Dear gurus: I have a question on how to configure the margin layout on tcl/tk GUI objects like tkcanvas, tkframe or tktoplevel. For example, if I want to leave a larger margin on the left side of the GUI container, which one should I configure, the toplevel or tkcanvas or tkframe? top<-tktoplevel() canvas<-tkcanvas(top, relief=, borderwidth=...) I also find the documentation for all the possible arguments that could be passed to tktoplevel, tkframe, tkcanvas, tk.wm, tkconfigure is not good. I wonder if there are good resource for it... at the very least, I know I need to look at what arguments that tck/tk takes... but I don't have time to go that far. Thanks Hao __ R-help@stat.math.ethz.ch 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] Sum per hour
oops error on my part...forgot that we need to get the day and hour out of the string... [EMAIL PROTECTED] wrote: Dear all, I have a list of precipitation record and a list of time I would like to sum them up per hour, or per day. Does such a function exist ? example: time<-c("2000-10-03 14:00:00","2000-10-03 14:10:00","2000-10-03 14:20:00","2000-10-03 15:30:00","2000-10-03 16:40:00","2000-10-03 16:50:00","2000-10-03 17:00:00","2000-10-03 17:10:00","2000-10-03 17:20:00","2000-10-03 18:30:00","2000-10-04 14:00:00","2000-10-04 14:10:00","2000-10-04 14:20:00","2000-10-04 15:30:00","2000-10-04 16:40:00","2000-10-04 16:50:00","2000-10-04 17:00:00","2000-10-04 17:10:00","2000-10-04 17:20:00","2000-10-04 18:30:00") precipitation<-c(0,0.1,0,0,0,0,0.2,0.3,0.5,6,7,8,9,1,0,0,0,0,1,0) DATA<-cbind(time,precipitation) ... ? how to sum up per hour ? Thanks in advance Jessica __ R-help@stat.math.ethz.ch 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. - Sucker-punch spam with award-winning protection. [[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] Sum per hour
There was a missing ) on this one. Here it is again: library(chron) z <- zoo(precipitation, as.chron(as.POSIXct(time, tz = "GMT"))) aggregate(z, function(x) chron(trunc(times(x), "01:00:00")), sum) On 5/24/07, Gabor Grothendieck <[EMAIL PROTECTED]> wrote: > We could do it using either POSIXct or chron: > > library(zoo) > > # POSIXct > z <- zoo(precipitation, as.POSIXct(time, tz = "GMT")) > aggregate(z, function(x) as.POSIXct(trunc(x, "hour")), sum) > > # chron > library(chron) > z <- zoo(precipitation, as.chron(as.POSIXct(time, tz = "GMT")) > aggregate(z, function(x) chron(trunc(times(x), "01:00:00")), sum) > > > On 5/24/07, [EMAIL PROTECTED] <[EMAIL PROTECTED]> wrote: > > > > Dear all, > > > > I have a list of precipitation record and a list of time > > I would like to sum them up per hour, or per day. > > Does such a function exist ? > > > > > > example: > > time<-c("2000-10-03 14:00:00","2000-10-03 14:10:00","2000-10-03 > > 14:20:00","2000-10-03 15:30:00","2000-10-03 16:40:00","2000-10-03 > > 16:50:00","2000-10-03 17:00:00","2000-10-03 17:10:00","2000-10-03 > > 17:20:00","2000-10-03 18:30:00","2000-10-04 14:00:00","2000-10-04 > > 14:10:00","2000-10-04 14:20:00","2000-10-04 15:30:00","2000-10-04 > > 16:40:00","2000-10-04 16:50:00","2000-10-04 17:00:00","2000-10-04 > > 17:10:00","2000-10-04 17:20:00","2000-10-04 18:30:00") > > > > precipitation<-c(0,0.1,0,0,0,0,0.2,0.3,0.5,6,7,8,9,1,0,0,0,0,1,0) > > > > DATA<-cbind(time,precipitation) > > > > ... ? > > how to sum up per hour ? > > > > Thanks in advance > > > > Jessica > > > > __ > > R-help@stat.math.ethz.ch 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] PlotDemo.java for Rserve?
Does anyone know where I can obtain DemoPlot.java from. I want to use it to find out how implement something in Java in conjunction with Rserve. Cheers -- View this message in context: http://www.nabble.com/PlotDemo.java-for-Rserve--tf3812255.html#a10790967 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] Sum per hour
hi jessica, this should possibly do it... year <- as.data.frame(c("2000-10-03","2000-10-03","2000-10-03","2000-10-03","2000-10-03","2000-10-03" ,"2000-10-03","2000-10-04","2000-10-04","2000-10-04")) colnames(year) <- c("year") time <- as.data.frame(c("14:00:00","14:10:00","14:20:00","15:30:00","16:40:00","16:50:00", "17:00:00","17:10:00","17:20:00","18:30:00")) colnames(time) <- c("time") precipitation<-c(0,0.1,0,0,0,0,0.2,0.3,0.5,6) DATA<-(cbind(year, time ,precipitation)) tapply(precipitation, year, sum) tapply(precipitation, time, sum) - [[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] Sum per hour
We could do it using either POSIXct or chron: library(zoo) # POSIXct z <- zoo(precipitation, as.POSIXct(time, tz = "GMT")) aggregate(z, function(x) as.POSIXct(trunc(x, "hour")), sum) # chron library(chron) z <- zoo(precipitation, as.chron(as.POSIXct(time, tz = "GMT")) aggregate(z, function(x) chron(trunc(times(x), "01:00:00")), sum) On 5/24/07, [EMAIL PROTECTED] <[EMAIL PROTECTED]> wrote: > > Dear all, > > I have a list of precipitation record and a list of time > I would like to sum them up per hour, or per day. > Does such a function exist ? > > > example: > time<-c("2000-10-03 14:00:00","2000-10-03 14:10:00","2000-10-03 > 14:20:00","2000-10-03 15:30:00","2000-10-03 16:40:00","2000-10-03 > 16:50:00","2000-10-03 17:00:00","2000-10-03 17:10:00","2000-10-03 > 17:20:00","2000-10-03 18:30:00","2000-10-04 14:00:00","2000-10-04 > 14:10:00","2000-10-04 14:20:00","2000-10-04 15:30:00","2000-10-04 > 16:40:00","2000-10-04 16:50:00","2000-10-04 17:00:00","2000-10-04 > 17:10:00","2000-10-04 17:20:00","2000-10-04 18:30:00") > > precipitation<-c(0,0.1,0,0,0,0,0.2,0.3,0.5,6,7,8,9,1,0,0,0,0,1,0) > > DATA<-cbind(time,precipitation) > > ... ? > how to sum up per hour ? > > Thanks in advance > > Jessica > > __ > R-help@stat.math.ethz.ch 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] Sum per hour
Dear all, I have a list of precipitation record and a list of time I would like to sum them up per hour, or per day. Does such a function exist ? example: time<-c("2000-10-03 14:00:00","2000-10-03 14:10:00","2000-10-03 14:20:00","2000-10-03 15:30:00","2000-10-03 16:40:00","2000-10-03 16:50:00","2000-10-03 17:00:00","2000-10-03 17:10:00","2000-10-03 17:20:00","2000-10-03 18:30:00","2000-10-04 14:00:00","2000-10-04 14:10:00","2000-10-04 14:20:00","2000-10-04 15:30:00","2000-10-04 16:40:00","2000-10-04 16:50:00","2000-10-04 17:00:00","2000-10-04 17:10:00","2000-10-04 17:20:00","2000-10-04 18:30:00") precipitation<-c(0,0.1,0,0,0,0,0.2,0.3,0.5,6,7,8,9,1,0,0,0,0,1,0) DATA<-cbind(time,precipitation) ... ? how to sum up per hour ? Thanks in advance Jessica __ R-help@stat.math.ethz.ch 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] reading a big file
On Thu, 24 May 2007, Christoph Scherber wrote: > Dear Remigijus, > > You should change memory allocation in Windows XP, as described in > > http://cran.r-project.org/bin/windows/base/rw-FAQ.html#There-seems-to-be-a-limit-on-the-memory-it-uses_0021 Porbably, this will not solve the problem as the object to be created will need 400 MB and scan() will require memory to create that object. Not to mention that the OS will consume a chunk of RAM. > > Hope this helps. > > Best wishes > Christoph > > > -- > Christoph Scherber > DNPW, Agroecology > University of Goettingen > Waldweg 26 > D-37073 Goettingen > > +49-(0)551-39-8807 > > > > > Remigijus Lapinskas schrieb: >> Dear All, >> >> I am on WindowsXP with 512 MB of RAM, R 2.4.0, and I want to read in a >> big file mln100.txt. The file is 390MB big, it contains a column of 100 >> millions integers. >> >>> mln100=scan("mln100.txt") >> Error: cannot allocate vector of size 512000 Kb >> In addition: Warning messages: >> 1: Reached total allocation of 511Mb: see help(memory.size) >> 2: Reached total allocation of 511Mb: see help(memory.size) >> >> In fact, I would be quite happy if I could read, say, every tenth >> integer (line) of the file. Is it possible to do this? >> To save out the first, eleventh, etc: mln.con <- file("tmp.txt",open="r") res <- rep(0,10) for (i in 1:10 ) res[i] <- as.integer( readLines( mln.con ,n = 10 )[1] ) >> Cheers, >> Rem >> >> __ >> R-help@stat.math.ethz.ch 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. > 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] Eigen values
Yemi Oyeyemi yahoo.com> writes: > > Dear, > My problems are; > 1. Simulate a P-variate multivariate data set (N by P) > 2. Draw samples of size n from N (with or without replacement) > 3. Obtain eigen values of the variance-covariance matrix of each > sample drawn in (2) above. > 4. print out the matrix of eigen values as well as the identity of > sample generating them. Can you convince us that this isn't a homework problem, perhaps by telling us more about the application? (You also haven't specified what kind of multivariate data set you want to simulate, although multivariate normal would be simplest.) Hints: mvrnorm (MASS), var, sample, eigen . Ben Bolker __ R-help@stat.math.ethz.ch 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] Calculation of ratio distribution properties
Hi all, Looking to calculate the expected mean and variance of a ratio distribution where the source distributions are gaussian with known parameters and sample values are correlated. I see (from wikipedia: http://en.wikipedia.org/wiki/ Ratio_distribution#Gaussian_ratio_distribution) that this calculation is quite involved, so I'm hoping that someone has already coded a function to achieve this. Thanks, Mike -- Mike Lawrence Graduate Student, Department of Psychology, Dalhousie University Website: http://myweb.dal.ca/mc973993 Public calendar: http://icalx.com/public/informavore/Public "The road to wisdom? Well, it's plain and simple to express: Err and err and err again, but less and less and less." - Piet Hein __ R-help@stat.math.ethz.ch 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] deleting lines and row small than a value
I am not sure what your matrix looks like, but here is some code that will check each row and then delete those rows with any value < .7: > set.seed(1) > data <- matrix(runif(100,0,10), 10) > data [,1] [,2] [,3] [,4] [,5] [,6] [,7] [,8] [,9] [,10] [1,] 2.6550866 2.059746 9.3470523 4.820801 8.2094629 4.7761962 9.1287592 3.390729 4.346595 2.3962942 [2,] 3.7212390 1.765568 2.1214252 5.995658 6.4706019 8.6120948 2.9360337 8.394404 7.125147 0.5893438 [3,] 5.7285336 6.870228 6.5167377 4.935413 7.8293276 4.3809711 4.5906573 3.466835 3.44 6.4228826 [4,] 9.0820779 3.841037 1.210 1.862176 5.5303631 2.4479728 3.3239467 3.337749 3.253522 8.7626921 [5,] 2.0168193 7.698414 2.6722067 8.273733 5.2971958 0.7067905 6.5087047 4.763512 7.570871 7.7891468 [6,] 8.9838968 4.976992 3.8611409 6.684667 7.8935623 0.9946616 2.5801678 8.921983 2.026923 7.9730883 [7,] 9.4467527 7.176185 0.1339033 7.942399 0.2333120 3.1627171 4.7854525 8.643395 7.111212 4.5527445 [8,] 6.6079779 9.919061 3.8238796 1.079436 4.7723007 5.1863426 7.6631067 3.899895 1.216919 4.1008408 [9,] 6.2911404 3.800352 8.6969085 7.237109 7.3231374 6.6200508 0.8424691 7.773207 2.454885 8.1087024 [10,] 0.6178627 7.774452 3.4034900 4.112744 6.9273156 4.0683019 8.7532133 9.606180 1.433044 6.0493329 > less.7 <- apply(data, 1, function(x) any(x < .7)) > less.7 [1] FALSE TRUE FALSE FALSE FALSE FALSE TRUE FALSE FALSE TRUE > data[!less.7,] [,1] [,2] [,3] [,4] [,5] [,6] [,7] [,8] [,9][,10] [1,] 2.655087 2.059746 9.347052 4.820801 8.209463 4.7761962 9.1287592 3.390729 4.346595 2.396294 [2,] 5.728534 6.870228 6.516738 4.935413 7.829328 4.3809711 4.5906573 3.466835 3.44 6.422883 [3,] 9.082078 3.841037 1.21 1.862176 5.530363 2.4479728 3.3239467 3.337749 3.253522 8.762692 [4,] 2.016819 7.698414 2.672207 8.273733 5.297196 0.7067905 6.5087047 4.763512 7.570871 7.789147 [5,] 8.983897 4.976992 3.861141 6.684667 7.893562 0.9946616 2.5801678 8.921983 2.026923 7.973088 [6,] 6.607978 9.919061 3.823880 1.079436 4.772301 5.1863426 7.6631067 3.899895 1.216919 4.100841 [7,] 6.291140 3.800352 8.696908 7.237109 7.323137 6.6200508 0.8424691 7.773207 2.454885 8.108702 > On 5/24/07, Milton Cezar Ribeiro <[EMAIL PROTECTED]> wrote: > > Hi there > > I made a correlation matrix from my data frama and I would like to delete > all lines/rows when r-value is smaller than 0.7 > > How can I do that? > > Kind regards, > > Miltinho > > __ > > >[[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. > -- 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.
Re: [R] "[RODBC] ERROR: Could not SQLExecDirect"
Ruixin, I think there are a number of issues here: FIrst of all, ODBC is data base talk. In a data base there are ususally a number of tables. Hence you should tell R which table you want to read. the function sqlTables can tell you which tables are available. Second, I seem to remember that the $ in some of these table names caused me some trouble Perhaps sqlFetch(cnct,'Sheet1') or sqlFetch(cnct,'Sheet1$') could do the trick and avoid you the query Third, it seems that the driver is determining variable types and passing these to R. It is not very good at that. You might have unexpected results. The bright side is, SQL/ODBC is powerfull. After using named regions in my Excel sheetI had the following query running :) oCE <- odbcConnectExcel('blockdata.2.xls') #sqlTables(oCE) # keep for reference q1 <- sqlQuery(oCE,'select * from linksblok , ((select * from blok1 union select * from blok2 union select * from blok3 union select * from blok4 union select * from blok5 union select * from blok6) as dit), rechtsblok, seco where linksblok.mainid=dit.mainid and linksblok.mainid=rechtsblok.mainid and dit.oldmonscode=seco.oldmonscode ') On Thursday 24 May 2007 04:43, Ruixin ZHU wrote: > Hi, everyone, > > I try to run as follows: > Z>library("RODBC") > Z>cnct<-odbcConnectExcel("Forbes2000.xls") > Z>cnct > RODB Connection 1 > Details: > case=nochange > DBQ=C:\Program Files\R\R-2.5.0\Forbes2000.xls > DefaultDir=C:\Program Files\R\R-2.5.0 > Driver={Microsoft Excel Driver (*.xls)} > DriverId=790 > MaxBufferSize=2048 > PageTimeout=5 > Z>sqlQuery(cnct, "select * from \"Forbes2000\\$\"") > > However, I got error like this: > [1] "[RODBC] ERROR: Could not SQLExecDirect" > > [2] "42S02 -1305 [Microsoft][ODBC Excel Driver] Microsoft Jet > ���ݿ� > �Ҳ���'Forbes2000\\$'ȷ���Ƿڣ� >ȷ��д�ƺ�· " > > I do can find Forbes2000.xls in directory, C:\Program Files\R\R-2.5.0. > Would anybody help me out? > > Thanks for any suggestions! > _ > Dr.Ruixin ZHU > Shanghai Center for Bioinformation Technology > [EMAIL PROTECTED] > [EMAIL PROTECTED] > 86-21-13040647832 > > > [[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] deleting lines and row small than a value
Hi there I made a correlation matrix from my data frama and I would like to delete all lines/rows when r-value is smaller than 0.7 How can I do that? Kind regards, Miltinho __ [[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] object getConnection
jim holtman a écrit : > summary(x)$description Thanks you very much. It works perfectly. __ R-help@stat.math.ethz.ch 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] "[RODBC] ERROR: Could not SQLExecDirect"
Hi, everyone, I try to run as follows: Z>library("RODBC") Z>cnct<-odbcConnectExcel("Forbes2000.xls") Z>cnct RODB Connection 1 Details: case=nochange DBQ=C:\Program Files\R\R-2.5.0\Forbes2000.xls DefaultDir=C:\Program Files\R\R-2.5.0 Driver={Microsoft Excel Driver (*.xls)} DriverId=790 MaxBufferSize=2048 PageTimeout=5 Z>sqlQuery(cnct, "select * from \"Forbes2000\\$\"") However, I got error like this: [1] "[RODBC] ERROR: Could not SQLExecDirect" [2] "42S02 -1305 [Microsoft][ODBC Excel Driver] Microsoft Jet Êý¾Ý¿âÒýÇæ ÕÒ²»µ½¶ÔÏó'Forbes2000\\$'¡£ÇëÈ·¶¨¶ÔÏóÊÇ·ñ´æÔÚ£¬²¢ÕýÈ·µØд³öËüµÄÃû³ÆºÍ· ¾¶¡£" I do can find Forbes2000.xls in directory, C:\Program Files\R\R-2.5.0. Would anybody help me out? Thanks for any suggestions! _ Dr.Ruixin ZHU Shanghai Center for Bioinformation Technology [EMAIL PROTECTED] [EMAIL PROTECTED] 86-21-13040647832 [[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] rotating an hclust tree with negative hights
Hi, I have an hclust object say hcl with heights starting from a negative and ending to a positive value. I would like to rotate the plot(hcl) 90 degrees clockwise. It is suggested to use plot(as.dendogram(hcl), horiz=T) but I encountered two problems: 1) a dendrogram object does not accept negative heights 2) horiz=T rotates the tree 90 degrees unclockwise any ideas? thanks, Vahid PARTOVI NIA. __ R-help@stat.math.ethz.ch 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] object getConnection
Will this work for you: > x <- file('/tempxx.txt',open='r') > x description class mode textopened can read can write "/tempxx.txt""file" "r""text" "opened" "yes" "no" > summary(x) $description [1] "/tempxx.txt" $class [1] "file" $mode [1] "r" $text [1] "text" $opened [1] "opened" $`can read` [1] "yes" $`can write` [1] "no" > summary(x)$description [1] "/tempxx.txt" > On 5/24/07, mel <[EMAIL PROTECTED]> wrote: > > Hi, > > I use the functions socketConnections() and getConnection() > which are working fine. Thanks to the authors. > > After opening nicely some socketConnection, > getConnection(3) returns something like : > description class mode textopened can read can write > "->127.0.0.1:7496" "socket" "wb" "binary" "opened" "yes""yes" > > I apologize in advance for this probably simple question, > but how is it possible to get/read the different fields ? > For example, how to get the "description" field ? > > I tried a number of things ... but alas not the right one. > > Thanks > > __ > R-help@stat.math.ethz.ch mailing list > https://stat.ethz.ch/mailman/listinfo/r-help > PLEASE do read the posting guide > http://www.R-project.org/posting-guide.html > 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] Question concerning "pastecs" package
Hi I just installed the pastecs package and I am wondering: is there an english (or german) translation of the file pastecs.pdf? If not, is there an explanation somewhere of the object of type 'turnpoints' as a result of turnpoints(), especially the "info" field? Thanks, Rainer -- NEW EMAIL ADDRESS AND ADDRESS: [EMAIL PROTECTED] [EMAIL PROTECTED] WILL BE DISCONTINUED END OF MARCH Rainer M. Krug, Dipl. Phys. (Germany), MSc Conservation Biology (UCT) Leslie Hill Institute for Plant Conservation University of Cape Town Rondebosch 7701 South Africa Fax:+27 - (0)86 516 2782 Fax:+27 - (0)21 650 2440 (w) Cell: +27 - (0)83 9479 042 Skype: RMkrug email: [EMAIL PROTECTED] [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] coefficients regression
Hi, Thanks a lot for the help. Best regards, Romana Limberger --- Versendet durch aonWebmail (webmail.aon.at) __ R-help@stat.math.ethz.ch 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] lme with corAR1 errors - can't find AR coefficient in output
Dear List, I am using the output of a ML estimation on a random effects model with first-order autocorrelation to make a further conditional test. My model is much like this (which reproduces the method on the famous Grunfeld data, for the econometricians out there it is Table 5.2 in Baltagi): library(Ecdat) library(nlme) data(Grunfeld) mymod<-lme(inv~value+capital,data=Grunfeld,random=~1|firm,correlation=co rAR1(0,~year|firm)) Embarrassing as it may be, I can find the autoregressive parameter ('Phi', if I get it right) in the printout of summary(mymod) but I am utterly unable to locate the corresponding element in the lme or summary.lme objects. Any help appreciated. This must be something stupid I'm overlooking, either in str(mymod) or in the help files, but it's a huge problem for me. Thanks Giovanni Giovanni Millo Research Dept., Assicurazioni Generali SpA Via Machiavelli 4, 34131 Trieste (Italy) tel. +39 040 671184 fax +39 040 671160 Ai sensi del D.Lgs. 196/2003 si precisa che le informazioni ...{{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.
[R] Eigen values
Dear, My problems are; 1. Simulate a P-variate multivariate data set (N by P) 2. Draw samples of size n from N (with or without replacement) 3. Obtain eigen values of the variance-covariance matrix of each sample drawn in (2) above. 4. print out the matrix of eigen values as well as the identity of sample generating them. 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.
[R] object getConnection
Hi, I use the functions socketConnections() and getConnection() which are working fine. Thanks to the authors. After opening nicely some socketConnection, getConnection(3) returns something like : description class mode textopened can read can write "->127.0.0.1:7496" "socket" "wb" "binary" "opened" "yes""yes" I apologize in advance for this probably simple question, but how is it possible to get/read the different fields ? For example, how to get the "description" field ? I tried a number of things ... but alas not the right one. Thanks __ R-help@stat.math.ethz.ch mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.
Re: [R] Make check failure for R-2.4.1
> "UweL" == Uwe Ligges <[EMAIL PROTECTED]> > on Thu, 24 May 2007 17:34:16 +0200 writes: UweL> Some of these test are expected from time to time, since they are using UweL> random numbers. Just re-run. eehm, "some of these", yes, but not the ones Adam mentioned, d-p-q-r-tests.R. Adam, if you want more info you should report to us the *end* (last dozen of lines) of your d-p-q-r-tests.Rout[.fail] file. UweL> BTW: We do have R-2.5.0 these days. Indeed! And gcc 2.95.4 is also very old. Maybe you've recovered an old compiler / math-library bug from that antique compiler suite ? Martin UweL> Uwe Ligges UweL> Adam Witney wrote: >> I'm trying to install R-2.4.1, everything configure's and make's OK, but the >> make check fails: >> >> running code in 'd-p-q-r-tests.R' ...make[3]: *** [d-p-q-r-tests.Rout] Error >> 1 >> make[3]: Leaving directory `/usr/local/install/R-2.4.1/tests' >> make[2]: *** [test-Specific] Error 2 >> make[2]: Leaving directory `/usr/local/install/R-2.4.1/tests' >> make[1]: *** [test-all-basics] Error 1 >> make[1]: Leaving directory `/usr/local/install/R-2.4.1/tests' >> make: *** [check] Error 2 >> >> This is Debian, gcc 2.95.4. My previous version R-2.1.0 installed ok. >> >> Any idea why this is failing? I have googled the errors, but couldn't find >> any resolutions >> >> Thanks for any help >> >> Adam __ R-help@stat.math.ethz.ch 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] Is it possible to print a data.frame without the row names?
?write.table Bert Gunter Genentech Nonclinical Statistics -Original Message- From: [EMAIL PROTECTED] [mailto:[EMAIL PROTECTED] On Behalf Of Bos, Roger Sent: Thursday, May 24, 2007 7:17 AM To: r-help@stat.math.ethz.ch Subject: [R] Is it possible to print a data.frame without the row names? Is it possible to print a data.frame without the row names? I checked ?data.frame, ?print, ?format and didn't see anything that helped. In the example below, I would just like to show the two columns of data and not the row.names 1:10. > a<-data.frame(1:10, 21:30) > a X1.10 X21.30 1 1 21 2 2 22 3 3 23 4 4 24 5 5 25 6 6 26 7 7 27 8 8 28 9 9 29 1010 30 > row.names(a)<-NULL > a X1.10 X21.30 1 1 21 2 2 22 3 3 23 4 4 24 5 5 25 6 6 26 7 7 27 8 8 28 9 9 29 1010 30 > Thanks, Roger J. Bos, CFA ** * 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. ** [[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] Make check failure for R-2.4.1
Some of these test are expected from time to time, since they are using random numbers. Just re-run. BTW: We do have R-2.5.0 these days. Uwe Ligges Adam Witney wrote: > I'm trying to install R-2.4.1, everything configure's and make's OK, but the > make check fails: > > running code in 'd-p-q-r-tests.R' ...make[3]: *** [d-p-q-r-tests.Rout] Error > 1 > make[3]: Leaving directory `/usr/local/install/R-2.4.1/tests' > make[2]: *** [test-Specific] Error 2 > make[2]: Leaving directory `/usr/local/install/R-2.4.1/tests' > make[1]: *** [test-all-basics] Error 1 > make[1]: Leaving directory `/usr/local/install/R-2.4.1/tests' > make: *** [check] Error 2 > > This is Debian, gcc 2.95.4. My previous version R-2.1.0 installed ok. > > Any idea why this is failing? I have googled the errors, but couldn't find > any resolutions > > Thanks for any help > > Adam > > __ > R-help@stat.math.ethz.ch 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] Make check failure for R-2.4.1
I'm trying to install R-2.4.1, everything configure's and make's OK, but the make check fails: running code in 'd-p-q-r-tests.R' ...make[3]: *** [d-p-q-r-tests.Rout] Error 1 make[3]: Leaving directory `/usr/local/install/R-2.4.1/tests' make[2]: *** [test-Specific] Error 2 make[2]: Leaving directory `/usr/local/install/R-2.4.1/tests' make[1]: *** [test-all-basics] Error 1 make[1]: Leaving directory `/usr/local/install/R-2.4.1/tests' make: *** [check] Error 2 This is Debian, gcc 2.95.4. My previous version R-2.1.0 installed ok. Any idea why this is failing? I have googled the errors, but couldn't find any resolutions Thanks for any help Adam __ R-help@stat.math.ethz.ch 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] Running R in Bash and R GUI
I have been trying to get the R and package update functions in the GUI version of R to work on my Mac. Initially I got error messages that suggested I needed to set up the http_proxy for GUI R to use, but how can this be done? I eventually got to the point of writing a .bash_profile file in the Bash terminal and setting the proxy addresses there. I can now use my Bash terminal, invoke R, and run the update / install commands and they work! The problem that still remains is that in the R console of the GUI R, the http_proxy is not seen and thus I cannot connect to CRAN or any other mirror using the GUI functions in the pull-down menus. I get > update.packages () Warning: unable to access index for repository http://cran.uk.r- project.org/bin/macosx/universal/contrib/2.5 > Basically it still seems unable to access port 80. Is there a way of solving this so that I can use both terminals rather than just everything through Bash? Thanks Steve Hodgkinson University of Brighton __ R-help@stat.math.ethz.ch 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 change font size in HTML output
You could always modify the .css file that R2HTML outputs... the default is R2HTML.css From: [EMAIL PROTECTED] on behalf of Bos, Roger Sent: Thu 24/05/2007 2:58 PM To: r-help@stat.math.ethz.ch Subject: [R] how to change font size in HTML output I have not been able to figure out how to change the font size for R2HTML::HTML output. Or for output from prettyR::htmlize. If anyone can give me a couple hints that would be great. Thanks, Roger J. Bos ** * 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. ** [[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] Reducing the size of pdf graphics files produced with R
Hi again, Many of you have suggested other means than pdf device and/or conversion/compression of pdf outside of R. I ran some tests on a small, a medium-size and a large figure. Here I summarize the results, which depend very much on the original graphics file. Please note that I wish to retain a vector-based graphic file. You'll find at the end of this message the R program used to produce the graphics files. Starting with a small size graphic file: in order, these were produced by 1) postscript device 2) pdf device 3) bitmap device (pdf output) 4) dev2bitmap, pdf output, from a quartz window 5) quartz device saved to pdf via command quarts.save 6) quartz device saved to pdf via save menu in R gui -rw-r--r-- 1 chabotd chabotd243446 May 23 21:00 test_ps_from_R.ps -rw-r--r-- 1 chabotd chabotd572513 May 23 21:00 test_pdf_from_R.pdf -rw-r--r-- 1 chabotd chabotd600106 May 24 09:21 test_pdf_bitmapR.pdf -rw-r--r-- 1 chabotd chabotd600050 May 24 09:22 test_dev2bitmap.pdf -rw-r--r-- 1 chabotd chabotd 1657446 May 23 21:00 test_pdf_from_quartz.save.pdf -rw-r--r-- 1 chabotd chabotd572634 May 23 21:01 test_pdf_from_quartz.menu.pdf These show how "test_pdf_from_R.pdf" can be shrunk outside of R 1) the command pdftk 2) opening the pdf in any Mac OS X pdf viewer and doing "print to compressed pdf" -rw-r--r-- 1 chabotd chabotd 68742 May 24 09:25 test_pdf_pdftk.pdf -rw-r--r-- 1 chabotd chabotd100660 May 23 21:16 test_pdf_print_to_comppdf.pdf Finally, these show 3 conversions from postscript to pdf outside of R 1) command ps2pdf 2) command epstopdf 3) command pstopdf -rw-r--r-- 1 chabotd chabotd566626 May 23 21:12 test_ps_ps2pdf.pdf -rw-r--r-- 1 chabotd chabotd566587 May 24 10:21 test_ps_epstopdf.pdf -rw-r--r-- 1 chabotd chabotd 1939788 May 24 10:20 test_ps_pstopdf.pdf For this first example, all pdf produced directly within R were of similar size, except one (quartz.save) that was 3x larger. Producing a postscript file and transforming it into pdf resulted in no significant saving. However pdf output from R can be shrunk (here to 12% of original size) with pdftk. So far I found no adverse effect of this shrinking. I did the same with a larger graphic, this example came from Dave Watson. Using the same blocks as above: Produced with R: -rw-r--r-- 1 chabotd chabotd854320 May 24 09:08 mauna_ps_from_R.eps -rw-r--r-- 1 chabotd chabotd 1000504 May 24 09:08 mauna_pdf_from_R.pdf -rw-r--r-- 1 chabotd chabotd 96737 May 24 09:08 mauna_pdf_bitmapR.pdf -rw-r--r-- 1 chabotd chabotd 97236 May 24 09:17 mauna_dev2bitmap.pdf -rw-r--r-- 1 chabotd chabotd468195 May 24 09:08 mauna_pdf_from_quartz.save.pdf -rw-r--r-- 1 chabotd chabotd999853 May 24 09:09 mauna_pdf_from_quartz.menu.pdf PS to pdf outside of R -rw-r--r-- 1 chabotd chabotd 95024 May 24 09:11 mauna_ps_ps2pdf.pdf -rw-r--r-- 1 chabotd chabotd603021 May 24 10:40 mauna_ps_pstopdf.pdf -rw-r--r-- 1 chabotd chabotd 95015 May 24 10:40 mauna_ps_epstopdf.pdf pdf transformation outside of R -rw-r--r-- 1 chabotd chabotd104487 May 24 09:12 mauna_pdf_pdftk.pdf -rw-r--r-- 1 chabotd chabotd134663 May 24 09:23 mauna_print_to_comppdf.pdf For this example, different methods of producing pdf within R had very different file sizes. The two methods based on quartz performed in reverse order compare to the previous example. Overall, using bitmap device or postscript-transformed-to-pdf outside of R produced files about 10% the size of the file produced by pdf device. But the latter could be shrunk almost as much using pdftk. Finally, a larger-size example: Produced with R: -rw-r--r-- 1 chabotd chabotd 1426330 May 23 20:54 fig_ps_from_R.ps -rw-r--r-- 1 chabotd chabotd 3384788 May 23 20:54 fig_pdf_from_R.pdf -rw-r--r-- 1 chabotd chabotd 3494689 May 24 09:03 fig_pdf_bitmapR.pdf -rw-r--r-- 1 chabotd chabotd 3494689 May 24 10:46 fig_dev2bitmap.pdf -rw-r--r-- 1 chabotd chabotd 3384832 May 23 20:54 fig_pdf_from_quartz.menu.pdf -rw-r--r-- 1 chabotd chabotd 9583552 May 23 20:52 fig_pdf_from_quartz.save.pdf PS to pdf outside of R -rw-r--r-- 1 chabotd chabotd 3356223 May 23 21:12 fig_ps_ps2pdf.pdf -rw-r--r-- 1 chabotd chabotd 11397461 May 23 23:51 fig_ps_pstopdf.pdf -rw-r--r-- 1 chabotd chabotd 3354762 May 23 23:55 fig_ps_epstopdf.pdf pdf transformation outside of R -rw-r--r-- 1 chabotd chabotd379307 May 23 22:31 fig_pdf_comptk.pdf -rw-r--r-- 1 chabotd chabotd520509 May 24 00:19 fig_pdf_print_to_comppdf.pdf This time, as in the first example, there was little benefit going the bitmap device or ps to pdf route. Only shrinking the pdf with pdftk was effective. So examples with a lot of objects on the plot do not seem to benefit from postscript use, but one example with few objects (but objects t
Re: [R] Social Network Analysis
Tom, thank you for the detailed answer and sorry for the long delay, i'm at a conference right now. This sadly means that i have no access to the papers, it will take more time. But in the meanwhile, here's a little program which might be useful, structural.balance <- function(g) { triples <- combn(1:vcount(g)-1, 3) good <- bad <- 0 for (t in 1:ncol(triples)) { tri <- triples[,t] edges <- E(g) [ tri %--% tri ] if (length(unique(get.edges(g, edges))) < 3) { next } if (prod(E(g)[edges]$sign) > 0) { good <- good +1 } else { bad <- bad +1 } } c(good, bad) } It uses the igraph package, version 0.4 or higher. Basically it extracts all possible triples from the network and first checks whether it is connected or not. If it is a connected triple then it simply multiples the values of the edges to see whether it is positive or negative. Here is a little test with a directed random graph with random edge values: g <- erdos.renyi.game(20, p=5/20, directed=TRUE) E(g)$sign <- sample( c(-1,1), ecount(g), repl=TRUE, prob=c(0.5,0.5)) structural.balance(g) The code is of course suboptimal, it is brute-force, but if your networks are small it might be good enough. Best Regards, Gabor On Mon, May 14, 2007 at 11:13:11PM +0200, Tom Backer Johnsen wrote: > Gabor Csardi wrote: > > Tom, > > > > check the igraph package. Although structural balance is not implemented, > > for three or four nodes it might be straightforward to do a quick > > implemntation which works for small graphs. > > I will do so. My graphs are small, but not very small, having from 8 > to 11 members (actually military units tested four points in time from > their formation as strangers and with the last data collection two > months later. > > > > Btw. what is exactly you want to do? List the number of balanced and > > unbalanced triangles? Ot the triangles themselves? What is a semi-cycle? > > Consider a directed and signed graph having three points (also called > vertices) with all possible relations (called lines or arcs) present > (which does not have to be the case in empirical situations). In that > case there are six possible semicycles, unique sequences of single > lines or arcs between the three points. The sign of a semicycle is > the product of the signs of the arcs, a positive semicycle has none or > an even number of negative arcs. (e.g. John dislikes James as well as > Peter, but Peter likes James, a balanced triad). > > A structural balance index is the number of positive semicycles over > the total number of semicycles. This concept was introduced by: > > @ARTICLE{Cartwright56, >author = {Cartwright, Dorwin and Harary, Frank}, >title = {Structural Balance: A Generalization of {H}eider's Theory}, >journal = {Psychological Review}, >year = {1956}, >volume = {63}, >pages = {277-293} > } > > and: > > @BOOK{Harary65, >title = {Structural {M}odels: {A}n {I}ntroduction to the {T}heory > of {D}irected {G}raphs}, >publisher = {John Wiley \& Sons Inc}, >year = {1965}, >author = {Harary, Frank and Norman, Robert Z. and Cartwright, Dorwin}, >keywords = {Graph theory, balance}, >address={New York} > } > > to use the BibTex format. This was a generalization in graph > theoretical terms to larger structures involving more than three > persons (points, vertices) based on the writings of a social > psychologist by the name of Fritz Heider. References: > > @ARTICLE{Heider46, >author = {Heider, Fritz}, >title = {Attitudes and {C}ognitive {O}rganization}, >journal = {J. of Psychology}, >year = {1946}, >volume = {21}, >pages = {107-112} > } > > @BOOK{Heider58, >title = {The Psychology of Interpersonal Relations}, >publisher = {Wiley}, >year = {1958}, >author = {Heider, Fritz}, >address = {New York} > } > > > Could you point me to a good online reference about structureal balance? > > As to more recent and online references I am on quite thin ice. I > know of a a few really trustworthy ones, the problem is simply that > parts of the field has been occupied by fringe elements within what is > called "sociometry". One evidently good and recent reference to be > used as a point of departure is the following: > > @ARTICLE{Hummon03, >author = {Hummon, Norman P. and Doreian, Patrick}, >title = {Some dynamics of social balance processes: {B}ringing > {H}eider back into balance theory}, >journal = {Social Networks}, >year = {2003}, >volume = {25}, >pages = {17-48} > } > > I have been in contact with the second author of that article, but he > did not have time to respond in full, he was on his way to a social > networks conference on Corfu (which I would have attended were it not > for family matters which had priority). > > I have a *very* preliminary draft of a paper which you may have if you > are interested. > > Tom > > > > > Thanks, > > Gabor
[R] Is it possible to print a data.frame without the row names?
Is it possible to print a data.frame without the row names? I checked ?data.frame, ?print, ?format and didn't see anything that helped. In the example below, I would just like to show the two columns of data and not the row.names 1:10. > a<-data.frame(1:10, 21:30) > a X1.10 X21.30 1 1 21 2 2 22 3 3 23 4 4 24 5 5 25 6 6 26 7 7 27 8 8 28 9 9 29 1010 30 > row.names(a)<-NULL > a X1.10 X21.30 1 1 21 2 2 22 3 3 23 4 4 24 5 5 25 6 6 26 7 7 27 8 8 28 9 9 29 1010 30 > Thanks, Roger J. Bos, CFA ** * 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. ** [[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] how to change font size in HTML output
I have not been able to figure out how to change the font size for R2HTML::HTML output. Or for output from prettyR::htmlize. If anyone can give me a couple hints that would be great. Thanks, Roger J. Bos ** * 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. ** [[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] Showing NAs when using table()
Rephrasing David Kane's example > b <- c(1,1,1,1,1, NA, 2,2,2,2) > d <- factor(c(rep(c("A","B","C"), 3), NA)) > table(b, d, exclude=NULL) d b A B C 12 2 1 21 1 1 0 0 1 Why are only 9 observations instead of 10 listed in the table? This is a long-standing bug in Splus and R. Peter Dalgaar suggests recoding the factor variable so that "NA" is a level, rather than a "missing". This works, but it does not address the bug: for most of my factor variables I want missing to be missing so that omission works as expected in modeling. The exclude argument in table() should do what it says it does, which is to list ALL data in the table when exclude=NULL. At Mayo, we have replaced the table command to work around this (in place for 5+ years now). It has two additions: a method for factors that correctly propogates the exclude argument, and a change to exclude=NULL as the default. Table() is used, 99% of the time, to look at data on screen, and the number of missing is often the first question I'm asking; so we found the default to be, shall we say, non-intuitive. We argued these points with Insightful many years ago and got nowhere, the replys being a mix of a) it's not really broken and b) if we change it it might break something. We had not carried the argument forward to the R community, and just fix it ourselves. The revised version just works better day to day. In R, the manual page has been revised to state that the exclude argument is something different for factors, so I expect to remain in the minority. (I can't think of a time I would ever have wanted the actions of the new version of exclude, which for factors is a means only to exclude more things, rather than the usual use of keeping more in the table). Terry Therneau __ R-help@stat.math.ethz.ch 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] MDScale from within Java using Rserve?
Hi there. I am able to create a multidimensional scaling algorithm in R using the following code: places<-read.table("C:\\Project\\R\\places.txt") places.location <- cmdscale(places, k=2) round(places.location,0) plot(places.location,type="n", xlab="", ylab="",main ="cmdscale(places)") What I would like to know is how I can do this by calling R from within a java application, using Rserve which I have set up and tested on my windows machine. I am able to do the examples given at http://rosuda.org/Rserve/example.shtml but I can't seem to be able to find an example of the above anywhere. Does anyone know that java lines I would need to do this? Many thanks -- View this message in context: http://www.nabble.com/MDScale-from-within-Java-using-Rserve--tf3810221.html#a10784224 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] help about 2 way anova and tukey test
The form of your data is termed "wide" and you want to reshape it to "long" form and use aov with that. This uses the reshape command to produce the long form. Alternately you could use cast and melt in the reshape package to do that: # read data Lines <- "subjtherapy t0 t1 t2 1 a 80.582.254.23 2 a 84.985.656.83 3 a 81.581.454.30 1 b 83.895.259.67 2 b 83.394.359.20 3 b 86 91.559.17 1 c 80.780.253.63 2 c 89.480.156.50 3 c 91.886.459.40 " DF <- read.table(textConnection(Lines), header = TRUE) # reshape to long form nm <- names(DF)[3:5] long <- reshape(DF, dir = "long", varying = list(nm), times = nm, v.names = "value") long$time <- factor(long$time) # calculate aov(value ~ therapy * time, data = long) # ...etc On 5/24/07, Sarti Maurizio <[EMAIL PROTECTED]> wrote: > Dears members of R list, > I have a technical question about conducting 2 way analysis of the variance > (ANOVA) for repeated measures followed tukey test using R. > my data are: > There were 3 subj in all and 3 repeated measures for every time and therapy > therapy = a,b,c > time= t1,t2,t3 > subj= 1,2,3 > > subjtherapy t0 t1 t2 > 1 a 80.582.254.23 > 2 a 84.985.656.83 > 3 a 81.581.454.30 > 1 b 83.895.259.67 > 2 b 83.394.359.20 > 3 b 86 91.559.17 > 1 c 80.780.253.63 > 2 c 89.480.156.50 > 3 c 91.886.459.40 > > the code that I use is: > > rm(list=ls(all=TRUE)) > dati<- read.table("dati.txt", T) > attach(dati) > subj<- c( 1: 9, 1: 9,1:9) > therapy<- factor( c( rep(" a", 3), rep(" b", 3), rep(" c", 3), > rep(" a", 3), rep(" b", 3), rep(" c", 3), > rep(" a",3), rep(" b", 3), rep(" c", 3))) > > time<- factor( c( rep(" t0", 9), rep(" t1", 9),rep(" t2", 9))) > weight<- c( t0,t1,t2) > > time <- factor( time) > therapy <- factor( therapy) > subj <- factor( subj) > summary( fm1<-aov( weight~time*therapy)) > fm1Tukey=TukeyHSD(fm1,"therapy",ordered = TRUE) ; fm1Tukey > fm1Tukey=TukeyHSD(fm1,"time",ordered = TRUE) ; fm1Tukey > fm1Tukey=TukeyHSD(fm1,"time:therapy",ordered = TRUE) ; fm1Tukey > > My question is - is that the correct way to do it?? > Very much obliged for your kind response > Maurizio > > ** > Maurizio Sarti, PhD > IREA - CNR > via Diocleziano,328 I-80124 Napoli (Italy) > tel:+39-(0)81-5707999-(0)81-5704945 fax:+39-(0)81-5705734 > cell:+39-3204397891 > ** > e-mail: [EMAIL PROTECTED] website: http://www.irea.cnr.it > > __ > R-help@stat.math.ethz.ch 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] help about 2 way anova and tukey test
Dears members of R list, I have a technical question about conducting 2 way analysis of the variance (ANOVA) for repeated measures followed tukey test using R. my data are: There were 3 subj in all and 3 repeated measures for every time and therapy therapy = a,b,c time= t1,t2,t3 subj= 1,2,3 subjtherapy t0 t1 t2 1 a 80.582.254.23 2 a 84.985.656.83 3 a 81.581.454.30 1 b 83.895.259.67 2 b 83.394.359.20 3 b 86 91.559.17 1 c 80.780.253.63 2 c 89.480.156.50 3 c 91.886.459.40 the code that I use is: rm(list=ls(all=TRUE)) dati<- read.table("dati.txt", T) attach(dati) subj<- c( 1: 9, 1: 9,1:9) therapy<- factor( c( rep(" a", 3), rep(" b", 3), rep(" c", 3), rep(" a", 3), rep(" b", 3), rep(" c", 3), rep(" a",3), rep(" b", 3), rep(" c", 3))) time<- factor( c( rep(" t0", 9), rep(" t1", 9),rep(" t2", 9))) weight<- c( t0,t1,t2) time <- factor( time) therapy <- factor( therapy) subj <- factor( subj) summary( fm1<-aov( weight~time*therapy)) fm1Tukey=TukeyHSD(fm1,"therapy",ordered = TRUE) ; fm1Tukey fm1Tukey=TukeyHSD(fm1,"time",ordered = TRUE) ; fm1Tukey fm1Tukey=TukeyHSD(fm1,"time:therapy",ordered = TRUE) ; fm1Tukey My question is - is that the correct way to do it?? Very much obliged for your kind response Maurizio ** Maurizio Sarti, PhD IREA - CNR via Diocleziano,328 I-80124 Napoli (Italy) tel:+39-(0)81-5707999-(0)81-5704945 fax:+39-(0)81-5705734 cell:+39-3204397891 ** e-mail: [EMAIL PROTECTED] website: http://www.irea.cnr.it __ R-help@stat.math.ethz.ch 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] in unix opening data object created under win
What are the versions of R on the two platform? Is the version on Unix at least as new as the one on Windows? Andy From: [EMAIL PROTECTED] > > Hi All > > I am saving a dataframe in my MS-Win R with save(). > Then I copy it onto my personal AFS space. > Then I start R and run it with emacs and load() the data. > It loads only 2 lines: head() shows only two lines nrow() als > say it has only 2 > lines, I get error message, when trying to use this data > object, saying that > some row numbers are missing. > If anyone had similar situation, I appreciate letting me know. > > Best Toby > > __ > R-help@stat.math.ethz.ch 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] Function to convert categorical variable in numerical
Hello again, I got it with dudi.mix included in ade4 library that Mark told. Thank you very much to all! J. Andres On 5/24/07, Mark Difford <[EMAIL PROTECTED]> wrote: > > > Hi J. Andres, > > You are probably better off using the ade4 package, which has two > functions > that will do exactly what you want, i.e. a PCA using mixed quantitative > and > categorical variables: > > ## You will need to download ade4 first > library(ade4) > ?dudi.hillsmith > ?dudi.mix > > Regards, > Mark Difford. > > > > J.Andrés Martínez wrote: > > > > Hello everybody, > > > > I am a new R user. At current moment I need to do a Principal Components > > Analysis with a table who contain mixed variables (categorical and > > numerical). There is some function available in R for transform these > > variables? > > > > For example: I need transform the categorical variable X who has 3 > classes > > in 2 numerical variables with 0s and 1s. > > > > Thank you very much, > > J. Andres > > > > [[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. > > > > > > -- > View this message in context: > http://www.nabble.com/Function-to-convert-categorical-variable-in-numerical-tf380.html#a10780667 > 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. > [[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] STEP
Dear All, I get a strange error message from the STEP Function: > summary(MODELL1<-lm(HEP-HBP~START+ REGION:MH > +DUR+AB+ASS+TAS+PRK+OPNEW,na.action=na.exclude)) Call: lm(formula = HEP - HBP ~ START + REGION:MH + DUR + AB + ASS + TAS + PRK + OPNEW, na.action = na.exclude) Residuals: Min 1Q Median 3Q Max -4.55426 -1.38241 0.09107 1.15272 4.08577 Coefficients: Estimate Std. Error t value Pr(>|t|) (Intercept) 54.89083 143.18319 0.383 0.7028 START-0.027100.07362 -0.368 0.7141 DUR -0.099590.28788 -0.346 0.7306 AB -0.204250.34256 -0.596 0.5533 ASS -0.082050.36365 -0.226 0.8223 TAS -0.023710.04320 -0.549 0.5853 PRKX -0.118760.76580 -0.155 0.8773 OPNEWmixed1.343471.65475 0.812 0.4201 OPNEW100% OP -0.063361.08484 -0.058 0.9536 REGION:MH-0.449120.20855 -2.154 0.0354 * REGIONEuropa:MH -0.281210.17509 -1.606 0.1136 REGIONUSA:MH -0.200920.15425 -1.303 0.1978 --- Signif. codes: 0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1 Residual standard error: 2.111 on 59 degrees of freedom Multiple R-Squared: 0.1753, Adjusted R-squared: 0.02152 F-statistic: 1.14 on 11 and 59 DF, p-value: 0.3482 > > > step(MODELL1, direction=c("both")) Start: AIC= 116.97 HEP - HBP ~ START + REGION:MH + DUR + AB + ASS + TAS + PRK + OPNEW Error in lm.fit(x[, jj, drop = FALSE], y, offset = offset) : incompatible dimensions In addition: Warning message: longer object length is not a multiple of shorter object length in: object$residuals + predict(object) > What could be the cure? TIA Patrik __ R-help@stat.math.ethz.ch 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] Function to convert categorical variable in numerical
Hi J. Andres, You are probably better off using the ade4 package, which has two functions that will do exactly what you want, i.e. a PCA using mixed quantitative and categorical variables: ## You will need to download ade4 first library(ade4) ?dudi.hillsmith ?dudi.mix Regards, Mark Difford. J.Andrés Martínez wrote: > > Hello everybody, > > I am a new R user. At current moment I need to do a Principal Components > Analysis with a table who contain mixed variables (categorical and > numerical). There is some function available in R for transform these > variables? > > For example: I need transform the categorical variable X who has 3 classes > in 2 numerical variables with 0s and 1s. > > Thank you very much, > J. Andres > > [[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. > > -- View this message in context: http://www.nabble.com/Function-to-convert-categorical-variable-in-numerical-tf380.html#a10780667 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] Function to convert categorical variable in numerical
?model.matrix ?contr.treatment Whether this makes sense for PCA is another matter: princomp() contains a test to stop this happening automatically with a formula argument. One problem is the result depends on just how you do the transformation. On Thu, 24 May 2007, J.Andrés Martínez wrote: Hello everybody, I am a new R user. At current moment I need to do a Principal Components Analysis with a table who contain mixed variables (categorical and numerical). There is some function available in R for transform these variables? For example: I need transform the categorical variable X who has 3 classes in 2 numerical variables with 0s and 1s. Thank you very much, J. Andres [[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] Function to convert categorical variable in numerical
Hello everybody, I am a new R user. At current moment I need to do a Principal Components Analysis with a table who contain mixed variables (categorical and numerical). There is some function available in R for transform these variables? For example: I need transform the categorical variable X who has 3 classes in 2 numerical variables with 0s and 1s. Thank you very much, J. Andres [[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] Fonts do not display properly on Red Hat
On Thu, 24 May 2007, michael watson (IAH-C) wrote: > Brian > > sessionInfo() gives me: > > Version 2.3.1 (2006-06-01) > i686-redhat-linux-gnu > > attached base packages: > [1] "methods" "stats" "graphics" "grDevices" "utils" > "datasets" > [7] "base" > > Thanks for the answer Ah, that is so old that it does not give the locale. You need Sys.getlocale() to tell you what more modern versions of sessionInfo() say. > > Michael > > -Original Message- > From: Prof Brian Ripley [mailto:[EMAIL PROTECTED] > Sent: 23 May 2007 11:40 > To: michael watson (IAH-C) > Cc: r-help@stat.math.ethz.ch > Subject: Re: [R] Fonts do not display properly on Red Hat > > Are you using a UTF-8 locale? (You know, there are good reasons why the > > posting guide asks for sessionInfo() output.) > > If so, the problem is probably with the non-availability of fonts in > ISO10646 encoding, and you may well find that the R update suggested > (before posting) in the posting guide will help. But you may have to > run > R in e.g. en_GB to get satisfactory results from an old version of R on > an > old OS. > > On Wed, 23 May 2007, michael watson (IAH-C) wrote: > >> Hi >> >> I'm using R version 2.3.1 on Red Hat Enterprise Server 3. >> >> When I run a simple: >> >> plot(1:10,1:10) >> >> The plot comes out great, but the fonts are displayed wrongly: >> >> http://coxpress.sourceforge.net/test.jpg >> >> I realise this is probably not an R problem per se, but before I go >> messing about with my fonts, can someone tell me which fonts R (or > X11) >> is trying to display, where they might be installed and any suggestion >> as to why they're not being displayed properly... >> >> Thanks >> Mick >> >> The information contained in this message may be > confidentia...{{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. >> > > -- 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] Fonts do not display properly on Red Hat
Brian sessionInfo() gives me: Version 2.3.1 (2006-06-01) i686-redhat-linux-gnu attached base packages: [1] "methods" "stats" "graphics" "grDevices" "utils" "datasets" [7] "base" Thanks for the answer Michael -Original Message- From: Prof Brian Ripley [mailto:[EMAIL PROTECTED] Sent: 23 May 2007 11:40 To: michael watson (IAH-C) Cc: r-help@stat.math.ethz.ch Subject: Re: [R] Fonts do not display properly on Red Hat Are you using a UTF-8 locale? (You know, there are good reasons why the posting guide asks for sessionInfo() output.) If so, the problem is probably with the non-availability of fonts in ISO10646 encoding, and you may well find that the R update suggested (before posting) in the posting guide will help. But you may have to run R in e.g. en_GB to get satisfactory results from an old version of R on an old OS. On Wed, 23 May 2007, michael watson (IAH-C) wrote: > Hi > > I'm using R version 2.3.1 on Red Hat Enterprise Server 3. > > When I run a simple: > > plot(1:10,1:10) > > The plot comes out great, but the fonts are displayed wrongly: > > http://coxpress.sourceforge.net/test.jpg > > I realise this is probably not an R problem per se, but before I go > messing about with my fonts, can someone tell me which fonts R (or X11) > is trying to display, where they might be installed and any suggestion > as to why they're not being displayed properly... > > Thanks > Mick > > The information contained in this message may be\ confiden...{{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] make check prob with internet
Erin Hodgess wrote: > Dear R People: > > There seem to be some problems with the make check still. > > I changed the TMPDIR to C:\Temp, and that helped a great deal. > > But I'm still having problems with the internet.r functions. > > Please see below: > C:\esr\R-2.5.0\src\gnuwin32>make check > make check > Testing package base > Running examples in 'base-Ex.R' ... > Comparing `base-Ex.Rout' to `base-Ex.Rout.prev' ...319c319 > > running code in 'reg-S4.R' ...OK > running code in 'reg-win.R' ...OK > running code in 'reg-tests-3.R' ...OK > running tests of Internet and socket functions ... > expect some differences ^^^ > running code in 'internet.R' ...OK > 69c69 > < unable to resolve 'foo.bar'. > --- >> InternetOpenUrl failed: 'The server name or address could not be resolved' > make[2]: [test-Internet] Error 1 (ignored) There is no problem. This error is expected, as the message above tells you. Uwe Ligges > Any help would be much appreciated. > > thanks, > sincerely, > Erin Hodgess > Associate Professor > Department of Computer and Mathematical Sciences > University of Houston - Downtown > mailto: [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] Missing data
John Sorkin wrote: > Can someone direct me to a package, or packages, that can perform data > augmentation to deal with missing data? > Thanks, > John RSiteSearch("data augmentation", restrict="function") points to several functions in packages norm, cat, and mix. > John Sorkin M.D., Ph.D. > Chief, Biostatistics and Informatics > University of Maryland School of Medicine Division of Gerontology > Baltimore VA Medical Center > 10 North Greene Street > GRECC (BT/18/GR) > Baltimore, MD 21201-1524 > (Phone) 410-605-7119 > (Fax) 410-605-7913 (Please call phone number above prior to faxing) > > Confidentiality Statement: > This email message, including any attachments, is for the so...{{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. -- 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] installing problems
Xyoby Chavez wrote: > hi every body. > > Im new in this program. Im traying to install R in linux suse10.0 in > two following form: > > a) with the file R-2.5.0.tar.gz > > b) and the rpm file : R-base-2.5.0-2.1.i586.rpm > > ** In the first case a) when i uncompressed and type: > > linux:/opt/R/R-2.5.0 # ./configure > > the followind message is showed > > > linux:/opt/R/R-2.5.0 # ./configure > checking build system type... i686-pc-linux-gnu > checking host system type... i686-pc-linux-gnu > loading site script './config.site' > loading build specific script './config.site' > checking for pwd... /bin/pwd > checking whether builddir is srcdir... yes > . > . > . > checking for dlopen in -ldl... yes > checking readline/history.h usability... no > checking readline/history.h presence... no > checking for readline/history.h... no > checking readline/readline.h usability... no > checking readline/readline.h presence... no > checking for readline/readline.h... no > checking for rl_callback_read_char in -lreadline... no > checking for main in -lncurses... yes > checking for rl_callback_read_char in -lreadline... no > checking for history_truncate_file... no > configure: error: --with-readline=yes (default) and headers/libs are > not available As the message tells you: You need to install readline headers and libs. Uwe Ligges > linux:/opt/R/R-2.5.0 # > > after that i try to do : > > linux:/opt/R/R-2.5.0 # make > make: *** No targets specified and no makefile found. Stop. > > i installed : xorg-x11-devel and libpng-devel ,suggested by somebody > and nothing. > > **Affter with b) tray to install with the YAST. It installed > without errors, but when i try to run R the following message is > showed: > > /usr/lib/R/bin/exec/R: error while loading shared libraries: > libgfortran.so.0: cannot open shared object file: No such file or > directory > > then i do > > linux:/usr/lib # ln /opt/gnat/lib/libgfortran.so libgfortran.so.0 > > it also doesnt work. > > Thanks for yor help > > Xyoby Chavez P > Lima Peru > > __ > R-help@stat.math.ethz.ch 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] Odp: reading a big file
Hi One possibility is to use scan with combination of skip and nlines parameters in a body of for cycle and adding read portion to some suitable object. Regards Petr [EMAIL PROTECTED] [EMAIL PROTECTED] napsal dne 23.05.2007 19:38:33: > Dear All, > > I am on WindowsXP with 512 MB of RAM, R 2.4.0, and I want to read in a > big file mln100.txt. The file is 390MB big, it contains a column of 100 > millions integers. > > > mln100=scan("mln100.txt") > Error: cannot allocate vector of size 512000 Kb > In addition: Warning messages: > 1: Reached total allocation of 511Mb: see help(memory.size) > 2: Reached total allocation of 511Mb: see help(memory.size) > > In fact, I would be quite happy if I could read, say, every tenth > integer (line) of the file. Is it possible to do this? > > Cheers, > Rem > > __ > R-help@stat.math.ethz.ch 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] Reducing the size of pdf graphics files produced with R
On Wed, May 23, 2007 at 10:13:22AM -0700, Waichler, Scott R wrote: > > > Scott > > Scott Waichler, Senior Research Scientist > Pacific Northwest National Laboratory > MSIN K9-36 > P.O. Box 999 > Richland, WA 99352USA > 509-372-4423 (voice) > 509-372-6089 (fax) > [EMAIL PROTECTED] > http://hydrology.pnl.gov > > --- > > > > -Original Message- > > From: Joerg van den Hoff [mailto:[EMAIL PROTECTED] > > Sent: Wednesday, May 23, 2007 9:25 AM > > To: Waichler, Scott R > > Cc: r-help@stat.math.ethz.ch; [EMAIL PROTECTED] > > Subject: Re: [R] Reducing the size of pdf graphics files > > produced with R > > > > On Wed, May 23, 2007 at 07:24:04AM -0700, Waichler, Scott R wrote: > > > > as you are using MacOS X, you'll have ghostscript > > installed anyway. > > > > so try in R `dev2bitmap' with `type =pdfwrite'. I believe `gs' > > > > _does_ include compression. a quick test showed at least > > a reduction > > > > by about a factor of 2 relative to `pdf()'. probably one > > can fiddle > > > > with the ghostscript settings (cf. e.g. `Ps2pdf.htm' in the > > > > ghostscipt > > > > docs: you > > > > can adjust the resolution for images in the pdf file) to improve > > > > this, so as a last resort you could indeed export the graphics as > > > > postscript and do the conversion to `pdf' by adjusting > > the `ps2pdf' > > > > switches. but even with the default settings the pdf produced via > > > > dev2bitmap/ghostscript is the better solution. apart from > > file size > > > > I by and then ran into problems when converting `pdf()' output to > > > > postscript later on, for instance. > > > > > > Can you give an example of dev2bitmap usage? I tried using it in > > `dev2bitmap(file = "rf.pdf", type = "pdfwrite")' copies the > > current device to the pdf-file `rf.pdf', i.e. you should have > > plotted something on the screen prior to using this (the > > manpage tells you so much...). no `dev.off' is necessary in this case. > > > > in order to "plot directly" into the pdffile, you can use > > `bitmap' instead of `dev2bitmap', i.e. > > > > use either: > > > > plot(1:10) > > dev2bitmap(file = "rf1.pdf", type = "pdfwrite") > > > > or: > > > > bitmap(file = "rf2.pdf", type = "pdfwrite") > > plot(1:10) > > dev.off() > > > > both should produce the desired output file (at least after > > including the correct `width' and `height' settings). > > I tried the second method, using width=8.5, height=11, but the margins > in the output were bad, as if it assumed a4 paper or something. I tried > inserting paper="special" and paper="letter" in the bitmap call, but > both caused errors. Also, the plot was in grayscale instead of color. > > Scott Waichler if you look at the source code of `bitmap' you'll see that it essentially constructs a `gs' command (the string `cmd') which is fed by the output of the R `postscript' device via a pipe (the manpage of `bitmap' tells the same). so I presume if you don't get colour or seem to have wrong page size this has nothing to do with R, but you need to check your ghostscript installation. only guessing, though. 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.
Re: [R] I made some progress on my previous "systemfit" question but still not quite there
Leeds, Mark (IED) schrieb: > Surprisingly, I played around with some test code and below actually > creates equations that look correct. > > tempmat<-matrix(10,nrow=6,ncol=6) > restrictmat<-diag(6) > > colnames(tempmat)<-c("AUD.l1","CHF.l1","CAD.l1","GBP.l1","EUR.l1","JPY.l > 1") > rownames(tempmat)<-c("AUD","CHF","CAD","GBP","EUR","JPY") > > eqn<-list() > > for ( i in 1:6 ) { > > datares <- tempmat[, which(restrictmat[i, ] == 1),drop=FALSE] > eqn[[i]]<-paste(rownames(tempmat)[i]," ~","-1","+",colnames(datares)) > > print(eqn[[i]]) > > } > > The only problem now is that I don't know how to name them so that > I can do the > > system<-list( demand = eqDemand, supply = eqSupply) > > part that systemfit needs. In fact, I don't know how to name the actual > equation eqDemand or the named part demand. > > I am not sure, what you want to do exactly, but I suppose you need eqn <- lapply(eqn,as.formula) somewhere after creating eqn. You can assign names to the equations via names(eqn), but this is not necessary, you can simply pass the equations with systemfit(eqns=eqn...), and optionally specify the names of the equations with eqnlabels= instead. If you want multiple systemfit calls for subsets of the equations, you should be able to select the equations via [], e.g., eqns=eqn[1:2] for the first and second equation. HTH, Martin > I would want demand to be "AUD", supply to be "CHF", etc. If someone has > time to run the code, they would see what I mean. > Thanks a lot. > > > 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. > __ R-help@stat.math.ethz.ch 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] reading a big file
Dear Remigijus, You should change memory allocation in Windows XP, as described in http://cran.r-project.org/bin/windows/base/rw-FAQ.html#There-seems-to-be-a-limit-on-the-memory-it-uses_0021 Hope this helps. Best wishes Christoph -- Christoph Scherber DNPW, Agroecology University of Goettingen Waldweg 26 D-37073 Goettingen +49-(0)551-39-8807 Remigijus Lapinskas schrieb: > Dear All, > > I am on WindowsXP with 512 MB of RAM, R 2.4.0, and I want to read in a > big file mln100.txt. The file is 390MB big, it contains a column of 100 > millions integers. > >> mln100=scan("mln100.txt") > Error: cannot allocate vector of size 512000 Kb > In addition: Warning messages: > 1: Reached total allocation of 511Mb: see help(memory.size) > 2: Reached total allocation of 511Mb: see help(memory.size) > > In fact, I would be quite happy if I could read, say, every tenth > integer (line) of the file. Is it possible to do this? > > Cheers, > Rem > > __ > R-help@stat.math.ethz.ch 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] Fisher's r to z' transformation - help needed
Duncan and Peter [resent to include on R-Help] Thank you for your help. It seems my data structure is not suitable for use with Fisher's z' transformation. The simulated data was intended to represent the outputs of several instruments over time. Each row of dat represents the output from one instrument on a particular day and each column represents a variable being measured. Each instrument sensitivity is different and may be a small offset, so that the output is effectively transformed as ax +b where x is the 'true' output and the values of a and b are not known. Pearson's r was therefore used to check the correlation between outputs. I then want to plot the r values on a control chart and set an upper warning line and action line for a maximum acceptable value for 1-r based on either comparing each output with every other output or by comparing to a mean of the outputs. I was then hoping to use Fisher's z' transformation to set the usual warning and action lines based on a single sided normal distribution. The only alternative I can think of is to use the simulation to produce the r distribution and then use the quantile function to set limits based on probability? I would be grateful for any help and advice you can provide. Thanks Mike White - Original Message - From: "Duncan Murdoch" <[EMAIL PROTECTED]> To: "Mike White" <[EMAIL PROTECTED]> Cc: Sent: Wednesday, May 23, 2007 1:38 PM Subject: Re: [R] Fisher's r to z' transformation - help needed > On 5/23/2007 7:40 AM, Mike White wrote: > > I am trying to use Fisher's z' transformation of the Pearson's r but the > > standard error does not appear to be correct. I have simulated an example > > using the R code below. The z' data appears to have a reasonably normal > > distribution but the standard error given by the formula 1/sqrt(N-3) (from > > http://davidmlane.com/hyperstat/A98696.html) gives a different results than > > sd(z). Can anyone tell me where I am going wrong? > > Your simulation is very strange. Why are you calculating the > correlation of data with its own mean? > > Here's a simpler simulation that seems to confirm the approximation is > reasonable: > > > p <- 10 > > sdx <- 1 > > sdy <- 1 > > x <- matrix(rnorm(1000*p, sd=sdx), 1000, p) > > y <- matrix(rnorm(1000*p, mean=x, sd=sdy), 1000, p) > > The true correlation is sdx/sqrt(sdx^2 + sdy^2), i.e. 0.71. > > > r <- numeric(1000) > > for (i in 1:1000) r[i] <- cor(x[i,], y[i,]) > > f <- 0.5*(log(1+r) - log(1-r)) > > sd(f) > [1] 0.3739086 > > 1/sqrt(p-3) > [1] 0.3779645 > > > p <- 5 > > x <- matrix(rnorm(1000*p, sd=sdx), 1000, p) > > y <- matrix(rnorm(1000*p, mean=x, sd=sdy), 1000, p) > > r <- numeric(1000) > > for (i in 1:1000) r[i] <- cor(x[i,], y[i,]) > > f <- 0.5*(log(1+r) - log(1-r)) > > sd(f) > [1] 0.6571383 > > 1/sqrt(p-3) > [1] 0.7071068 > > Duncan Murdoch > __ R-help@stat.math.ethz.ch mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.
Re: [R] Function to Sort and test AIC for mixed model lme?
Ken Nussear mac.com> writes: > I'm running a series of mixed models using lme, and I wonder if there > is a way to sort them by AIC prior to testing using anova > (lme1,lme2,lme3,lme7) other than by hand. You can try something like the following. However, also consider using dropterm or stepAIC in MASS. Dieter #- library(nlme) fmlist = vector("list",2) fmlist[[1]] = lme(distance ~ age, data = Orthodont,method="ML") fmlist[[2]] = lme(distance ~ age + Sex, data = Orthodont, random = ~ 1,method="ML") aic0 = unlist(lapply(fmlist,AIC)) aic0 # larger first fmlist1 = fmlist[order(aic0)] unlist(lapply(fmlist1,AIC)) # smaller first __ R-help@stat.math.ethz.ch 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] GLM with nested factors, covariates and binomial error distribution
Dear R experts, I want to create a GLM with nested factors and binomial error distribution. I have five independent variables, three categorial and two continuous ones. The thing is that one of the categorial factors is nested within the other, i.e. only the factor combinations (with 10 replicates per factor combination) exist: Fac1 Fac2 Ag Ah Ai Bj Bk Bl Bm Bn Bo What I would like to know is: 1) How can I include the hierarchical structure of Factors 1 and 2 in the model? (i.e. decide whether Factor 2 has more explanatory power than Factor 1 alone) 2) Is the unbalanced design a problem in this case? 3) How can I include two continuous independent variables in the model? I am actually quite sure that they don't play a role but need to be sure. Thanks a lot! Florian Menzel - [[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.