Re: [R] Using betareg package to fit beta mixture with given initial parameters

2017-03-21 Thread Michael Dayan
The method of setting the initial values given lambda, alpha1, etc. should not depend on the exact values of lambda, alpha1, etc. in my situation, i.e. it does not depend on my data. On Mar 22, 2017 04:30, "David Winsemius" wrote: > On Mar 21, 2017, at 5:04 AM, Michael Dayan wrote: > > Hi, > >

Re: [R] string pattern matching

2017-03-21 Thread Ulrik Stervbo
Hi Joe, you could also rethink your pattern: grep("x1 \\+ x2", test, value = TRUE) grep("x1 \\+ x", test, value = TRUE) grep("x1 \\+ x[0-9]", test, value = TRUE) HTH Ulrik On Wed, 22 Mar 2017 at 02:10 Jim Lemon wrote: > Hi Joe, > This may help you: > > test <- c("x1", "x2", "x3", "x1 + x2 +

Re: [R] Using betareg package to fit beta mixture with given initial parameters

2017-03-21 Thread David Winsemius
> On Mar 21, 2017, at 5:04 AM, Michael Dayan wrote: > > Hi, > > I would like to fit a mixture of two beta distributions with parameters > (alpha1, beta1) for the first component, (alpha2, beta2) for the second > component, and lambda for the mixing parameter. I also would like to set a > maximu

Re: [R] string pattern matching

2017-03-21 Thread David Winsemius
> On Mar 21, 2017, at 6:31 PM, Bert Gunter wrote: > > It is not clear to me what you mean, but: > >> grep ("x1 \\+.* \\+ x3",test, value = TRUE) > [1] "x1 + x2 + x3" > > ## This will miss "x1 + x3" though. So then this might be acceptable: grep ("x1\\ \\+.* x3", test, value = TRUE) > > se

Re: [R] string pattern matching

2017-03-21 Thread Bert Gunter
It is not clear to me what you mean, but: > grep ("x1 \\+.* \\+ x3",test, value = TRUE) [1] "x1 + x2 + x3" ## This will miss "x1 + x3" though. seems to do what you want, maybe. Perhaps you need to read up about regular expressions and/or clarify what you want to do. Cheers, Bert Bert Gunter "

Re: [R] string pattern matching

2017-03-21 Thread Jim Lemon
Hi Joe, This may help you: test <- c("x1", "x2", "x3", "x1 + x2 + x3") multigrep<-function(x1,x2) { xbits<-unlist(strsplit(x1," ")) nbits<-length(xbits) xans<-rep(FALSE,nbits) for(i in 1:nbits) if(length(grep(xbits[i],x2))) xans[i]<-TRUE return(all(xans)) } multigrep("x1 + x3","x1 + x2 + x3")

[R] string pattern matching

2017-03-21 Thread Joe Ceradini
Hi Folks, Is there a way to find "x1 + x2 + x3" given "x1 + x3" as the pattern? Or is that a ridiculous question, since I'm trying to find something based on a pattern that doesn't exist? test <- c("x1", "x2", "x3", "x1 + x2 + x3") test [1] "x1" "x2" "x3" "x1 + x2 +

Re: [R] Data and Variables from Tables

2017-03-21 Thread Jeff Newmiller
He offered two solutions, and I want to second the vote against the first one. I often put large numbers of configuration variables in a few CSV files organized by topic area and read them in. The resulting data frames are capable of holding multiple cases if desired and I just specify which ca

Re: [R] Data and Variables from Tables

2017-03-21 Thread Shawn Way
That worked perfectly! This makes using a large number of values for programming and their documentation significantly easier. Thank you Shawn Way, PE -Original Message- From: Enrico Schumann [mailto:e...@enricoschumann.net] Sent: Tuesday, March 21, 2017 4:40 PM To: Shawn Way Cc: r-h

Re: [R] Data and Variables from Tables

2017-03-21 Thread Enrico Schumann
On Tue, 21 Mar 2017, Shawn Way writes: > I have an org-mode table with the following structure > that I am pulling into an R data.frame, using the > sfsmisc package and using xtable to print in org-mode > > | Symbol | Value | Units | > |--+---+---| > | A

Re: [R] nlmrt problems - No confInt, NA StdErr, t-, or p-values

2017-03-21 Thread J C Nash
Note that the recently released package nlsr by Duncan Murdoch and I has a slight update in the functions nlxb() and nlfb() as well as a lot of features for symbolic derivative calculation. JN On 2017-03-21 06:57 AM, DANIEL PRECIADO wrote: Dear list, I want to use nlxb (package nlmrt) to fit

[R] Data and Variables from Tables

2017-03-21 Thread Shawn Way
I have an org-mode table with the following structure that I am pulling into an R data.frame, using the sfsmisc package and using xtable to print in org-mode | Symbol | Value | Units | |--+---+---| | A | 1 | kg/hr|

Re: [R] assigning dimnames to arrays

2017-03-21 Thread Jeff Newmiller
Thanks, Bill. Sooo... taking the error literally, temp1 = array(NA, c(3,2,1)) dimnames(temp1)[[3]] = list( "test" ) works, even though mode( dimnames(temp1)[[3]] ) yields "character". Setting all the dimension names simultaneously still feels way better. -- Sent from my phone. Please excu

Re: [R] assigning dimnames to arrays

2017-03-21 Thread William Dunlap via R-help
It happens because dimnames(originalArray) is NULL and when [[<- extends NULL it turns it into a list if the size of the new element is not one but into a vector with the type of new element if the new element's size is one. > str( `[[<-`(NULL, 3, value="One") ) chr [1:3] NA NA "One" > str(

Re: [R] assigning dimnames to arrays

2017-03-21 Thread Jeff Newmiller
While I generally agree that it is better to design code that sets all of the dimension names simultaneously, the discrepancy between behavior when the dimensions are longer than 1 and when they are equal to 1 seems irregular. Someone went to some lengths to make it possible to set dimnames indi

Re: [R] Issue with subset in glm

2017-03-21 Thread David L Carlson
When you use the data= argument in glm(), the function looks in the data.frame for a variable first. You have created two versions of stype, one in the data.frame and one outside it. So your first glm() selects all the cases apistrat since apistrat$stype always equals apistrat$stype. You can see

Re: [R] ESTIMATION OF PANEL VAR

2017-03-21 Thread peter dalgaard
This one was actually clear enough to those exposed to the econometric lingo: Panel = "repeated measurements", VAR = Vector AutoRegression (not to be confused with var() or VaR). -pd > On 20 Mar 2017, at 17:44 , Bert Gunter wrote: > > Excuse my denseness, but huh?? > > If you receive no sati

[R] Issue with subset in glm

2017-03-21 Thread Ganz, Carl
Hello, I am experiencing odd behavior with the subset parameter for glm. It appears that the parameter uses non-standard evaluation, but only in some cases. Below is a reproducible example. library(survey) # for example dataset data(api) stype <- "E" (a <- glm(api00~ell+meals+mobility, data =

[R] Issues in Cubist package (predict function) in R

2017-03-21 Thread Gupta, Swarna
Hi, This mail is in regards with a query we have in usage of Cubist package in R. We are using the CRAN package - "Cubist" for predicting sales. We have a large training dataset which in turn gives a huge specification result file. (Note: Independent variables consists of both character and numer

[R] [R-pkgs] New package: brant

2017-03-21 Thread kontakt
Dear R users, I am pleased to announce the release on CRAN of brant 0.1-1: https://cran.r-project.org/package=brant. I implemented the brant test (Brant, Rollin 1990) in R together with Prof. Marco Steenbergen at our Institute. The function brant() tests the parallel regression assumption for ord

Re: [R] assigning dimnames to arrays

2017-03-21 Thread David Winsemius
> On Mar 20, 2017, at 4:46 PM, Douglas Ezra Morrison > wrote: > > Dear R-Help readers, > > I am writing to ask about some behavior of base::dimnames() that surprised > me. If I create an array with one of its dimensions = 1, and then try to > assign names to that dimension, I get an error unle

Re: [R] nlmrt problems - No confInt, NA StdErr, t-, or p-values

2017-03-21 Thread Gabor Grothendieck
You can use wrapnls from the nlmrt package to get an nls object. Run it instead of nlxb. It runs nlxb followed by nls so that the output is an nls object.. Then you can use all of nls' methods. On occiasion that fails even if nlxb succeeds since the nls optimization can fail independently of nlx

[R] Using betareg package to fit beta mixture with given initial parameters

2017-03-21 Thread Michael Dayan
Hi, I would like to fit a mixture of two beta distributions with parameters (alpha1, beta1) for the first component, (alpha2, beta2) for the second component, and lambda for the mixing parameter. I also would like to set a maximum of 200 iterations and a tolerance of 1e-08. My question is: how to

[R] nlmrt problems - No confInt, NA StdErr, t-, or p-values

2017-03-21 Thread DANIEL PRECIADO
Dear list, I want to use nlxb (package nlmrt) to fit different datasets to a gaussian, obtain parameters (including standard error, t-and p-value) and confidence intervals. nlxb generates the parameters, but very often results in NA standard error,t-and p-values. Furthermore, using confint() t

[R] Kernel Density Estimation: Generate a sample from Epanechnikov Kernel

2017-03-21 Thread Justin Thong
Below are samples from a kernel density estimated "data" with gaussian kernel. I really like this solution of estimation of a kernel because it is nice and elegant. fit<-density(data) rnorm(N, sample(data, size = N, replace = TRUE), fit$bw) #samples from kernel density estimation I am however in

Re: [R] Why is options(digits = 1) displays two digits?

2017-03-21 Thread Martin Maechler
> Gerrit Eichner > on Tue, 21 Mar 2017 10:45:13 +0100 writes: > Hi, Tal, > in print.default it says: > digits: > a non-null value for digits specifies the __minimum__ > number of __significant__ digits to be printed in values. > Maybe this clarifies your obs

Re: [R] Why is options(digits = 1) displays two digits?

2017-03-21 Thread Jim Lemon
I'd say it's about equivalent to suggesting to Vladimir Putin that he stop trying to take over territories bordering Russia. Jim On Tue, Mar 21, 2017 at 8:30 PM, Tal Galili wrote: > This may have been asked before, but I don't understand the behavior > of options(digits = 1) for vectors contain

Re: [R] Why is options(digits = 1) displays two digits?

2017-03-21 Thread Gerrit Eichner
Hi, Tal, in print.default it says: digits: a non-null value for digits specifies the __minimum__ number of __significant__ digits to be printed in values. Maybe this clarifies your observation. Hth -- Gerrit - Dr. Gerrit

[R] Why is options(digits = 1) displays two digits?

2017-03-21 Thread Tal Galili
This may have been asked before, but I don't understand the behavior of options(digits = 1) for vectors containing values such as 0.01 For example, why is this happening: options(digits = 1) > 0.01 [1] 0.01 More examples: > options(digits = 7) > 0.1 [1] 0.1 > 0.01 [1] 0.01 > 0.11 [1] 0.11 > c(0.

Re: [R] Changing cell value for MANY unique pairings of values in 2 columns

2017-03-21 Thread Jim Lemon
Hi Alicia, If I understand this, perhaps: df<-data.frame(VALUE=c("<60","Positive","Negative","Less than 0.30", "12%","<0.2","Unknown"), DESCRIPTION = c("A","A", "B","C","D","E","E"), NUMERIC_VALUE=c(9,9,9,9,9,9,9)) df$NUMERIC_VALUE[df$VALUE == "Positive" & df$DESCRIPTION == "A"]<- 9