Re: [R] fread transforms numbers

2017-03-22 Thread Jeff Newmiller
A) You have been given a workaround (colClasses).

B) 3.2.3 is not the current version of R. Support for older versions may vary 
from CRAN mirror to mirror. You could try another mirror. 

C) Technically, "Linux" is not an operating system, it is a kernel. Debian and 
Fedora are examples of operating systems, and instructions for installing and 
upgrading R on them are different. They also have dedicated R mailing lists, 
and separate instructions for installing and upgrading on them are available on 
CRAN.

D) Typically OS's based on Linux install from source, and the bit64 package 
only depends on R >= 3.0.1, so this seems like your R is just not configured to 
look in an appropriate place for the package. You would have to provide more 
details on your setup to get help from any R mailing list. 
-- 
Sent from my phone. Please excuse my brevity.

On March 22, 2017 7:54:25 PM PDT, Santosh  wrote:
>Dear Rxperts..
>I am using R version 3.2.3 on Linux.. it says bit64 is not available
>for R
>version 3.2.3..
>
>Thanks and your assistance much appreciated!
>Best regards,
>Santosh
>
>
>On Wed, Mar 22, 2017 at 7:50 PM, Santosh  wrote:
>
>> Thanks so much for your suggestions! Will try them out!
>>
>> Santosh
>>
>> On Wed, Mar 22, 2017 at 12:17 PM, Matt Dowle 
>wrote:
>>
>>> Thanks Bill for cc.
>>>
>>> Santosh,
>>>
>>> I'm almost certain you don't have package bit64 installed.  When you
>do
>>> it works fine :
>>>
>>> > remove.packages("bit64")
>>> > data.table::fread("9876543210\n")
>>>   V1
>>> 1: 4.879661e-314
>>> > install.packages("bit64")
>>> > data.table::fread("9876543210\n")
>>>V1
>>> 1: 9876543210
>>>
>>> News for data.table v1.10.2 on CRAN 31 Jan 2017 contained :
>>>
>>> * When fread() or print() see integer64 columns are present, bit64's
>>> namespace is now automatically loaded for convenience.
>>>
>>> However, when data.table loads the namespace there is a bug in this
>>> function :
>>>
>>> > data.table:::require_bit64
>>> function ()
>>> {
>>> tt = try(requireNamespace("bit64", quietly = TRUE))
>>> if (inherits(tt, "try-error"))
>>> warning("Some columns are type 'integer64' but package bit64
>is
>>> not installed. Those columns will print as strange looking floating
>point
>>> data. There is no need to reload the data. Simply
>install.packages('bit64')
>>> to obtain the integer64 print method and print the data again.")
>>> }
>>>
>>> The intent was to display that nice helpful message to you.   Due to
>this
>>> report, I can see now that I shouldn't have wrapped
>requireNamespace() with
>>> try() because  requireNamespace() returns TRUE or FALSE anyway. Even
>though
>>> requireNamespace() prints 'Failed with error' it doesn't actually
>throw an
>>> error.  I'll change data.table's function to the following :
>>>
>>> if (!requireNamespace("bit64", quietly = TRUE))
>>> warning("Some columns ...")
>>>
>>> bit64 is correctly Suggests not Depends.   It's just unfortunate the
>>> intended message wasn't displayed.
>>>
>>> Santosh, in future please follow the data.table support guide here:
>>> https://github.com/Rdatatable/data.table/wiki/Support.  r-help is
>not
>>> supposed to be used for package support.  The main thing though is
>thanks
>>> for helping me find this bug.
>>>
>>> Thanks,
>>> Matt
>>>
>>>
>>> On Wed, Mar 22, 2017 at 10:22 AM, William Dunlap 
>>> wrote:
>>>
 Here is a way to reproduce the problem:
   > data.table::fread("9876543210\n") # number bigger than 2^31-1
 V1
   1: 4.879661e-314
 and your work-around does fix things up
   > data.table::fread("9876543210\n", colClasses="numeric")
  V1
   1: 9876543210

 Bill Dunlap
 TIBCO Software
 wdunlap tibco.com


 On Wed, Mar 22, 2017 at 9:58 AM, Jeff Newmiller
  wrote:
 > You failed to provide a reproducible example, and you posted HTML
>so
 the quality of any answer will be limited by the quality of your
>question.
 >
 > My stab at your problem is that you should read ?fread, and in
 particular should try using the colClasses argument.
 > --
 > Sent from my phone. Please excuse my brevity.
 >
 > On March 22, 2017 8:52:55 AM PDT, Santosh 
 wrote:
 >>Hi
 >>
 >>I have been using "fread" utility of "data.table" packge .. on a
 >>dataset of
 >>about 20 million rows. It's a fantastic package to read datasets.
>Thank
 >>you, Matt D.
 >>
 >>However, I am faced with a peculiar instance of  certain numbers
>in a
 >>column being transformed.
 >>
 >>In the dataset, a column has values ranging from 1 to 9##
 >>(nchar(x)=11, e.g. 98765432109). After using "fread" to read the
 >>dataset,
 >>values in all the columns are displayed correctly upto the first
>1000
 >>rows.
 >>If 

Re: [R] fread transforms numbers

2017-03-22 Thread Santosh
Dear Rxperts..
I am using R version 3.2.3 on Linux.. it says bit64 is not available for R
version 3.2.3..

Thanks and your assistance much appreciated!
Best regards,
Santosh


On Wed, Mar 22, 2017 at 7:50 PM, Santosh  wrote:

> Thanks so much for your suggestions! Will try them out!
>
> Santosh
>
> On Wed, Mar 22, 2017 at 12:17 PM, Matt Dowle  wrote:
>
>> Thanks Bill for cc.
>>
>> Santosh,
>>
>> I'm almost certain you don't have package bit64 installed.  When you do
>> it works fine :
>>
>> > remove.packages("bit64")
>> > data.table::fread("9876543210\n")
>>   V1
>> 1: 4.879661e-314
>> > install.packages("bit64")
>> > data.table::fread("9876543210\n")
>>V1
>> 1: 9876543210
>>
>> News for data.table v1.10.2 on CRAN 31 Jan 2017 contained :
>>
>> * When fread() or print() see integer64 columns are present, bit64's
>> namespace is now automatically loaded for convenience.
>>
>> However, when data.table loads the namespace there is a bug in this
>> function :
>>
>> > data.table:::require_bit64
>> function ()
>> {
>> tt = try(requireNamespace("bit64", quietly = TRUE))
>> if (inherits(tt, "try-error"))
>> warning("Some columns are type 'integer64' but package bit64 is
>> not installed. Those columns will print as strange looking floating point
>> data. There is no need to reload the data. Simply install.packages('bit64')
>> to obtain the integer64 print method and print the data again.")
>> }
>>
>> The intent was to display that nice helpful message to you.   Due to this
>> report, I can see now that I shouldn't have wrapped requireNamespace() with
>> try() because  requireNamespace() returns TRUE or FALSE anyway. Even though
>> requireNamespace() prints 'Failed with error' it doesn't actually throw an
>> error.  I'll change data.table's function to the following :
>>
>> if (!requireNamespace("bit64", quietly = TRUE))
>> warning("Some columns ...")
>>
>> bit64 is correctly Suggests not Depends.   It's just unfortunate the
>> intended message wasn't displayed.
>>
>> Santosh, in future please follow the data.table support guide here:
>> https://github.com/Rdatatable/data.table/wiki/Support.  r-help is not
>> supposed to be used for package support.  The main thing though is thanks
>> for helping me find this bug.
>>
>> Thanks,
>> Matt
>>
>>
>> On Wed, Mar 22, 2017 at 10:22 AM, William Dunlap 
>> wrote:
>>
>>> Here is a way to reproduce the problem:
>>>   > data.table::fread("9876543210\n") # number bigger than 2^31-1
>>> V1
>>>   1: 4.879661e-314
>>> and your work-around does fix things up
>>>   > data.table::fread("9876543210\n", colClasses="numeric")
>>>  V1
>>>   1: 9876543210
>>>
>>> Bill Dunlap
>>> TIBCO Software
>>> wdunlap tibco.com
>>>
>>>
>>> On Wed, Mar 22, 2017 at 9:58 AM, Jeff Newmiller
>>>  wrote:
>>> > You failed to provide a reproducible example, and you posted HTML so
>>> the quality of any answer will be limited by the quality of your question.
>>> >
>>> > My stab at your problem is that you should read ?fread, and in
>>> particular should try using the colClasses argument.
>>> > --
>>> > Sent from my phone. Please excuse my brevity.
>>> >
>>> > On March 22, 2017 8:52:55 AM PDT, Santosh 
>>> wrote:
>>> >>Hi
>>> >>
>>> >>I have been using "fread" utility of "data.table" packge .. on a
>>> >>dataset of
>>> >>about 20 million rows. It's a fantastic package to read datasets. Thank
>>> >>you, Matt D.
>>> >>
>>> >>However, I am faced with a peculiar instance of  certain numbers in a
>>> >>column being transformed.
>>> >>
>>> >>In the dataset, a column has values ranging from 1 to 9##
>>> >>(nchar(x)=11, e.g. 98765432109). After using "fread" to read the
>>> >>dataset,
>>> >>values in all the columns are displayed correctly upto the first 1000
>>> >>rows.
>>> >>If "fread" is applied for reading >1000 rows of  the total of 20Million
>>> >>rows, the values in only this (column (having wide range of values) are
>>> >>displayed as x.xxxe-3yy. (e.g. 3.5639877e-324)
>>> >>
>>> >>I tried reading all the columns as "character" and didn't help.
>>> >>
>>> >>Would highly appreciate your assistance!
>>> >>
>>> >>Thanks so much in advance.
>>> >>
>>> >>Best regards,
>>> >>Santosh
>>> >>
>>> >>   [[alternative HTML version deleted]]
>>> >>
>>> >>__
>>> >>R-help@r-project.org mailing list -- To UNSUBSCRIBE and more, see
>>> >>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@r-project.org mailing list -- To UNSUBSCRIBE and more, see
>>> > https://stat.ethz.ch/mailman/listinfo/r-help
>>> > PLEASE do read the posting guide http://www.R-project.org/posti

Re: [R] fread transforms numbers

2017-03-22 Thread Santosh
Thanks so much for your suggestions! Will try them out!

Santosh

On Wed, Mar 22, 2017 at 12:17 PM, Matt Dowle  wrote:

> Thanks Bill for cc.
>
> Santosh,
>
> I'm almost certain you don't have package bit64 installed.  When you do it
> works fine :
>
> > remove.packages("bit64")
> > data.table::fread("9876543210\n")
>   V1
> 1: 4.879661e-314
> > install.packages("bit64")
> > data.table::fread("9876543210\n")
>V1
> 1: 9876543210
>
> News for data.table v1.10.2 on CRAN 31 Jan 2017 contained :
>
> * When fread() or print() see integer64 columns are present, bit64's
> namespace is now automatically loaded for convenience.
>
> However, when data.table loads the namespace there is a bug in this
> function :
>
> > data.table:::require_bit64
> function ()
> {
> tt = try(requireNamespace("bit64", quietly = TRUE))
> if (inherits(tt, "try-error"))
> warning("Some columns are type 'integer64' but package bit64 is
> not installed. Those columns will print as strange looking floating point
> data. There is no need to reload the data. Simply install.packages('bit64')
> to obtain the integer64 print method and print the data again.")
> }
>
> The intent was to display that nice helpful message to you.   Due to this
> report, I can see now that I shouldn't have wrapped requireNamespace() with
> try() because  requireNamespace() returns TRUE or FALSE anyway. Even though
> requireNamespace() prints 'Failed with error' it doesn't actually throw an
> error.  I'll change data.table's function to the following :
>
> if (!requireNamespace("bit64", quietly = TRUE))
> warning("Some columns ...")
>
> bit64 is correctly Suggests not Depends.   It's just unfortunate the
> intended message wasn't displayed.
>
> Santosh, in future please follow the data.table support guide here:
> https://github.com/Rdatatable/data.table/wiki/Support.  r-help is not
> supposed to be used for package support.  The main thing though is thanks
> for helping me find this bug.
>
> Thanks,
> Matt
>
>
> On Wed, Mar 22, 2017 at 10:22 AM, William Dunlap 
> wrote:
>
>> Here is a way to reproduce the problem:
>>   > data.table::fread("9876543210\n") # number bigger than 2^31-1
>> V1
>>   1: 4.879661e-314
>> and your work-around does fix things up
>>   > data.table::fread("9876543210\n", colClasses="numeric")
>>  V1
>>   1: 9876543210
>>
>> Bill Dunlap
>> TIBCO Software
>> wdunlap tibco.com
>>
>>
>> On Wed, Mar 22, 2017 at 9:58 AM, Jeff Newmiller
>>  wrote:
>> > You failed to provide a reproducible example, and you posted HTML so
>> the quality of any answer will be limited by the quality of your question.
>> >
>> > My stab at your problem is that you should read ?fread, and in
>> particular should try using the colClasses argument.
>> > --
>> > Sent from my phone. Please excuse my brevity.
>> >
>> > On March 22, 2017 8:52:55 AM PDT, Santosh 
>> wrote:
>> >>Hi
>> >>
>> >>I have been using "fread" utility of "data.table" packge .. on a
>> >>dataset of
>> >>about 20 million rows. It's a fantastic package to read datasets. Thank
>> >>you, Matt D.
>> >>
>> >>However, I am faced with a peculiar instance of  certain numbers in a
>> >>column being transformed.
>> >>
>> >>In the dataset, a column has values ranging from 1 to 9##
>> >>(nchar(x)=11, e.g. 98765432109). After using "fread" to read the
>> >>dataset,
>> >>values in all the columns are displayed correctly upto the first 1000
>> >>rows.
>> >>If "fread" is applied for reading >1000 rows of  the total of 20Million
>> >>rows, the values in only this (column (having wide range of values) are
>> >>displayed as x.xxxe-3yy. (e.g. 3.5639877e-324)
>> >>
>> >>I tried reading all the columns as "character" and didn't help.
>> >>
>> >>Would highly appreciate your assistance!
>> >>
>> >>Thanks so much in advance.
>> >>
>> >>Best regards,
>> >>Santosh
>> >>
>> >>   [[alternative HTML version deleted]]
>> >>
>> >>__
>> >>R-help@r-project.org mailing list -- To UNSUBSCRIBE and more, see
>> >>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@r-project.org mailing list -- To UNSUBSCRIBE and more, see
>> > https://stat.ethz.ch/mailman/listinfo/r-help
>> > PLEASE do read the posting guide http://www.R-project.org/posti
>> ng-guide.html
>> > and provide commented, minimal, self-contained, reproducible code.
>>
>
>

[[alternative HTML version deleted]]

__
R-help@r-project.org mailing list -- To UNSUBSCRIBE and more, see
https://stat.ethz.ch/mailman/listinfo/r-help
PLEASE do read the posting guide http://www.R-project.org/posting-guide.html
and 

Re: [R] Correlation code not working but not sure why

2017-03-22 Thread John C Frain
I can't see anything wrong with your code. You should read the posting
guide and produce a minimal example showing the problem and any other
details requested there.

If I take just the small sample of data that you have provided and run a
slightly adapted version of your code

data = read.table("query.txt",header = TRUE )
data
AllTemps <-
c(data[,"BHCS306"],data[,"BH9OB1U"],data[,"BHCS276"],data[,"BHCS207"])
AirTempC <- data[,"AirTempC"]
airTemps53 <- c(rep(AirTempC, times = 4))
cor.test(AllTemps, airTemps53, alternative = "two.sided", method =
"pearson")

I get the following output - which gives what I require. (I would not
endorse the idea of looking at this correlation. Perhaps some kind of
stacked regression with dummy variables for the sites might be more
appropriate)


> data = read.table("query.txt",header = TRUE )
> data
  BHCS306 BH9OB1U BHCS276 BHCS207 AirTempC
112.212.412.212.7 15.3
212.212.512.312.7 16.2
312.312.512.512.8 16.1
> AllTemps <-
c(data[,"BHCS306"],data[,"BH9OB1U"],data[,"BHCS276"],data[,"BHCS207"])
> AirTempC <- data[,"AirTempC"]
> airTemps53 <- c(rep(AirTempC, times = 4))
> cor.test(AllTemps, airTemps53, alternative = "two.sided", method =
"pearson")

Pearson's product-moment correlation

data:  AllTemps and airTemps53
t = 0.68527, df = 10, p-value = 0.5087
alternative hypothesis: true correlation is not equal to 0
95 percent confidence interval:
 -0.4122189  0.7005406
sample estimates:
  cor
0.2117855


John C Frain
3 Aranleigh Park
Rathfarnham
Dublin 14
Ireland
www.tcd.ie/Economics/staff/frainj/home.html
mailto:fra...@tcd.ie
mailto:fra...@gmail.com

On 22 March 2017 at 14:05, Ashley Patton via R-help 
wrote:

> Good afternoon,
>
> I was wondering if someone could help me with what I am sure is likely to
> be a really simple problem but I cannot work out what I have done wrong. I
> have tried searching the forums/Google etc but can't find anything quite
> like the code I am using other than things that do not differ from what I
> have done. I suspect then that the problem is in my naming of things but I
> don't know what is causing the issue.
>
> I have data that comprises 53 columns containing temperature data for 53
> sites recording continuously for a year, 48 times a day (half hourly). I
> also have one column that contains average air temperature for a city
> during the same time period. I would like to see if my collective site
> temperature data shows any correlation with the city air temperature data
> and so I have attempted to combined the data from the 53 site columns using
> the code below and then repeat the air temperature 53 times to correlate it
> against and then perform a Pearson's correlation. My data looks something
> like this:
>
> Site   BHCS306   BH9OB1U   BHCS276   BHCS207...  AirTempC
>  12.2  12.412.2   12.7
>  15.3
>  12.2  12.512.3   12.7
>  16.2
>  12.3  12.512.5   12.8
>  16.1...
> repeating for 53 sites recording every half hour for a year
>
> The code I used was this:
>
>
> #String together data from all 53 sites into one column
> AllTemps <- c(data[,"BHCS306"],data[,"BH9OB1U"],data[,"BHCS276"],
> data[,"BHCS207AL"],data[,"BHCS178AL"],data[,"BHCS159AL"]
> ,data[,"BHCS318"],data[,"BHCS211"],data[,"BH7OB1L"],
> data[,"BHCS274B"],data[,"BHCS337"],data[,"BH2PB1"],
> data[,"BHCS038"],data[,"BHCS074AL"],data[,"BH9OB1L"],data[,"Site
> 5"],data[,"BH6PB4"],data[,"BH6PB1"],data[,"BHCS329"],
> data[,"BH5PB1T"],data[,"BH4PB1T"],data[,"BHCS233T"],
> data[,"BHCS229"],data[,"BHCS272T"],data[,"BHCS217T"],
> data[,"BHCS283"],data[,"BHCS248"],data[,"BHCS002A"],
> data[,"BHCS245B"],data[,"BH4PB2T"],data[,"BH6PB2"],
> data[,"BH5PB1B"],data[,"BH4PB1B"],data[,"BHCS233B"],
> data[,"BHCS313L"],data[,"BHCS272B"],data[,"BHCS266"],
> data[,"BHCS217B"],data[,"BHCS241"],data[,"BH4PB2B"],
> data[,"BHCS116AL"],data[,"BHCS067A"],data[,"BHCS304L"],
> data[,"BH1OB1L"],data[,"BHCS307L"],data[,"BHCS037C"],
> data[,"BHCS301L"],data[,"BHCS238A"],data[,"BH3OB1"],
> data[,"BHCS308L"],data[,"BHCS278"],data[,"BHCS285"],
> data[,"BHCS133CL"],data[,"BHCS332L"])
>
> #Copy air temp data 53 times
> airTemps53 <- c(rep(AirTempC, times = 53))
>
> #Run correlation between site temps and air temps
> cor.test(AllTemps, airTemps53, alternative = "two.sided", method =
> "pearson")
>
> The error it returned was this:
>
> > #Copy air temp data 53 times
> > airTemps53 <- c(rep(AirTempC, times = 53))
> >
> > #Run correlation between site temps and air temps
> > cor.test(AllTemps, airTemps53, alternative = "two.sided", method =
> "pearson")
> Error in cor.test(AllTemps, airTemps53, alternative = "two.sided", method
> = "pearson") :
>   object 'AllTemps' not found
>
> Can anyone spot my mistake? I am very new to this so I am sure I have done
> something obvious and silly so please forgive me.
>
> Additionally I 

Re: [R-es] GLM con clusters

2017-03-22 Thread javier.ruben.marcuzzi
Estimado Sebastian Gadea

Leo que usted desea algo de glm, cluster, y nombre la palabra red. Se me viene 
a la cabeza el libro Statistical Analysis of Network Data with R, editorial 
springer, por ahí sus requerimientos no son nada que ver, pero si la palabra 
red hace referencia a redes, ese libro puede aportarle algo.

Javier Rubén Marcuzzi

De: Freddy Omar López Quintero
Enviado: miércoles, 22 de marzo de 2017 17:12
Para: Sebastian Gadea
CC: Lista R
Asunto: Re: [R-es] GLM con clusters

2017-03-22 13:48 GMT-03:00 Sebastian Gadea :

> O sea, quitan el supuesto de independencia entre observaciones de un mismo
> grupo, en este lo indica la variable red. Pero ésto no afecta la estimación
> de los coeficientes, si los intervalos de confianza.
>

Podrías utilizar el paquete pglm (glm para datos de panel).

Para ello debes preparar previamente tus datos utilizando pdata.frame con
el id red. Luego en model del pglm indicas 'pooling' (además de la familia
binomial). Algo como:

pglm(y ~ x1+x2, data=tus_datos, family = binomial, model = "pooling")

​Ojalá sea de utilidad.

¡
​Salud!​


-- 
«Pídeles sus títulos a los que te persiguen, pregúntales
cuándo nacieron, diles que te demuestren su existencia.»

Rafael Cadenas

[[alternative HTML version deleted]]

___
R-help-es mailing list
R-help-es@r-project.org
https://stat.ethz.ch/mailman/listinfo/r-help-es


[[alternative HTML version deleted]]

___
R-help-es mailing list
R-help-es@r-project.org
https://stat.ethz.ch/mailman/listinfo/r-help-es

Re: [R] r question

2017-03-22 Thread Rui Barradas

Hello,

There's a paenthesis missing in

> relativerisk<- matrix(log(c(1,1,2,2),ncol=4,byrow = TRUE)
+ beta_true<-relativerisk
Error: unexpected symbol in:
"relativerisk<- matrix(log(c(1,1,2,2),ncol=4,byrow = TRUE)
beta_true"

The correct instruction would be

relativerisk<- matrix(log(c(1,1,2,2)),ncol=4,byrow = TRUE)

And there's an error in your matrix multiply.

> Ti=exp(x_true%*%beta_true)*ei
Error in x_true %*% beta_true : non-conformable arguments

It can be corrected if you transpose beta_true.

Ti=exp(x_true %*% t(beta_true))*ei

At this point I've stoped running your code, I believe you must revise 
it and try to see what's wrong instruction by instruction. Do that and 
post again.

ALso, get rid of the <<-, use <-
If you do this, I'll explain the difference in the next answer to your 
doubts.


Hope this helps,

Rui Barradas


Em 22-03-2017 08:11, 謝孟珂 escreveu:

Hi ,I have some question about simulate, I don't know how to paste question
to this website,so I paste below.
I use genoud to find the maximum likelihood value, but when I use numcut=3
,it will get error message,like this " coxph.wtest(fit$var[nabeta, nabeta],
temp, control$toler.chol) : NA/NaN/Inf"
and this is my code
library(rgenoud)
library(survival)
N=500
ei=rexp(N)
censor=rep(1,N)
x1=runif(N)
x2=runif(N)
x3=runif(N)
truecut=c(0.3,0.6)
dum1=1*(x1>truecut[1] & x1truecut[2])
x_true=cbind(dum1,dum2,x2,x3)
relativerisk<- matrix(log(c(1,1,2,2),ncol=4,byrow = TRUE)
beta_true<-relativerisk
Ti=exp(x_true%*%beta_true)*ei
confound=cbind(x2,x3)
initial2<-c(0.09,0.299,0.597,-0.17,-1.3,-3.1,-1.4,-1.12)
numcut=2
  
domain2<<-matrix(c(rep(c(0.05,0.95),numcut),rep(c(0,5),numcut+dim(confound)[2])),ncol=2,byrow
= TRUE)

loglikfun <- function(beta, formula) {
   beta1 <- coxph(formula, init = beta,
control=list('iter.max'=0))#iteration is zero
   return(beta1$loglik[2])
}
obj <- function(xx){
   cutoff <- xx[1:numcut_global] #cutpoint
   cut_design <-
cut(target_global,breaks=c(0,sort(cutoff)+seq(0,gap_global*(length(cutoff)-1),by=gap_global),target_max),quantile=FALSE,labels=c(0:numcut_global))
   beta <- -xx[(numcut+1):nvars]  #coefficients of parameters
   logliks <-
loglikfun(beta,Surv(time_global,censor_global)~cut_design+confound_global)
   return(logliks)
}
maxloglik<-function(target,numcut,time,censor,confound,domain2,initial2,gap){
   time_global<<-time
   censor_global<<-censor
   target_global<<-target
   nvars<<-2*numcut+dim(confound)[2]
   confound_global<<-confound
   numcut_global<<-numcut
   target_max<<-max(target)
   gap_global<<-gap
   ccc<-genoud(obj, nvars, max=TRUE, pop.size=100, max.generations=6,
wait.generations=10,
   hard.generation.limit=TRUE, starting.values=initial2,
MemoryMatrix=TRUE,
   Domains=domain2, solution.tolerance=0.001,
   gr=NULL, boundary.enforcement=2, lexical=FALSE,
gradient.check=TRUE)
   ccc$par_corr<-ccc$par #the coefficients of genoud

ccc$par_corr[1:numcut]<-sort(ccc$par[1:numcut])+seq(0,gap_global*(numcut-1),by=gap_global)
#sort cutpoint
   return(ccc)
}


maxloglik(x1,3,Ti,censor,confound,domain2,initial2,0.02)$par_corr

I have no idea about the error ,maybe is my initial is wrong.
thank you
  From Meng-Ke

[[alternative HTML version deleted]]

__
R-help@r-project.org mailing list -- To UNSUBSCRIBE and more, see
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@r-project.org mailing list -- To UNSUBSCRIBE and more, see
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-es] step halving factor reduced below minimum in PNLS step

2017-03-22 Thread Santiago Bueno
Tree dbh haut Btot
1 35.00 18.90 0.357
2 25.00 16.60 0.214
3 23.00 19.50 0.173
4 13.50 15.60 0.060
5 20.00 18.80 0.134
6 23.00 17.40 0.137
7 29.00 19.90 0.428
8 17.60 18.20 0.100
9 31.00 25.30 0.514
10 26.00 23.50 0.273
11 13.00 13.00 0.031
12 32.00 20.70 0.356
13 28.00 28.50 0.349
14 15.00 18.20 0.068
15 19.00 14.90 0.110
16 33.00 14.90 0.260
17 24.00 19.10 0.160
18 22.00 19.20 0.204
19 39.00 25.20 0.724
20 30.00 26.60 0.386
Hello dear all:

I am using above data to run the following code;

library(nlme)

start <- coef(lm(Btot~I(dbh**2*haut),data=dat))

names(start) <- c("a","b")

model1 <-(nlme (Btot~a+b*dbh**2*haut, data=cbind(dat, g="a"), fixed=a+b~1,
start=start,

groups=~g, weights=varPower(form=~dbh)))


I get regression parameters with the intercept being non-significant.
Therefore, I run the following code to obtain an equation without
intercept..


summary(nlme(Btot~b*dbh**2*haut, data=cbind(dat,g="a"), fixed=b~1,
start=start["b"], groups=~g, weights=varPower(form=~dbh)))


When I do run the last code, I get the following error:


Error in nlme.formula(Btot ~ b * dbh**2 * haut, data = cbind(dat, g = "a"),
 :

  step halving factor reduced below minimum in PNLS step

Can someone help??


Best regards,

Santiago

[[alternative HTML version deleted]]

___
R-help-es mailing list
R-help-es@r-project.org
https://stat.ethz.ch/mailman/listinfo/r-help-es


Re: [R-es] GLM con clusters

2017-03-22 Thread Freddy Omar López Quintero
2017-03-22 13:48 GMT-03:00 Sebastian Gadea :

> O sea, quitan el supuesto de independencia entre observaciones de un mismo
> grupo, en este lo indica la variable red. Pero ésto no afecta la estimación
> de los coeficientes, si los intervalos de confianza.
>

Podrías utilizar el paquete pglm (glm para datos de panel).

Para ello debes preparar previamente tus datos utilizando pdata.frame con
el id red. Luego en model del pglm indicas 'pooling' (además de la familia
binomial). Algo como:

pglm(y ~ x1+x2, data=tus_datos, family = binomial, model = "pooling")

​Ojalá sea de utilidad.

¡
​Salud!​


-- 
«Pídeles sus títulos a los que te persiguen, pregúntales
cuándo nacieron, diles que te demuestren su existencia.»

Rafael Cadenas

[[alternative HTML version deleted]]

___
R-help-es mailing list
R-help-es@r-project.org
https://stat.ethz.ch/mailman/listinfo/r-help-es

Re: [R-es] Alternativa a RStudio

2017-03-22 Thread Carlos Ortega
Hola,

No sé si sabes que puedes usar "VIM" como editor dentro de RStudio.

En la barra de menú superior:
Tools >> Global Options >> (en la ventana que aparece) Code >> Editing >> Y
entre las diferentes opciones que aparecen, a mitad de altura de esa
pantalla aparece "Keybindins" un desplegable... ahí podrás seleccionar
"Vim"...

Saludos,
Carlos Ortega
www.qualityexcellence.es


El 22 de marzo de 2017, 18:17, Javier Nieto  escribió:

> Hola a todos, este es mi primer mail y espero enviar muchos más para
> colaborar en lo que pueda. No soy "Lord vim" pero lo recomiendo bastante,
> en mi trabajo lo utilizo alternando su uso con Rstudio.
>
> Conozco la mayoría de las alternativas mencionadas pero con emacs no he
> tenido el gusto, que seguramente tendrá cosas muy buenas.
>
>
>
> Saludos
>
> 
> De: R-help-es  en nombre de
> javier.ruben.marcu...@gmail.com 
> Enviado: miércoles, 22 de marzo de 2017 07:07:50 a. m.
> Para: Freddy Omar López Quintero
> Cc: r-help-es@r-project.org
> Asunto: Re: [R-es] Alternativa a RStudio
>
> Estimado Freddy
>
> Voy a demorar unos días pero probaré, vi un video (en partes saltando
> minutos) donde hacían una comparación entre emacs, rstudio, notepad++.
>
>
>  se puede usar), donde hay partes que son mantenidas por Ubuntu, y ya est
> faltan días), todos los sistemas tienen puntos fuertes y débiles respecto
> a la experiencia de usuario, pienso que por el lado de bash podría haber
> una grata sorpresa, o queda en nada, algo que me llama la atención es que R
> y visual studio ya no se llevan (la versión estable no cita a R), aunque ya
> está la beta de actualización (la última versión estable tiene unas dos
> semanas).
>
> Lo que sí estoy convencido es que JavaScript es bueno pero para cosas
> pequeñas, cuándo comienza a incrementar el número de líneas de código o de
> información a tratar por este la pérdida de eficiencia comienza a
> visualizarse respecto a otros lenguajes compilados, lógicamente JavaScript
> anda en todos lados.
>
> Voy a probar alguna alternativa, sobre todo si tiene autocompletar para
> evitar los errores ortográficos.
>
> Javier Rubén Marcuzzi
>
> De: Freddy Omar López Quintero
> Enviado: miércoles, 22 de marzo de 2017 9:53
> Para: Marcuzzi, Javier Rubén
> CC: r-help-es@r-project.org
> Asunto: Re: [R-es] Alternativa a RStudio
>
> Hola Javier,
>
> Alguno utiliza una alternativa a RStudio
>
> En particular, yo me paseo entre RStudio (sobre todo por demostraciones
> rápidas que debo hacer) y la consola junto al siempre fiel gedit, de Gnome.
>
>
> ía con NotePad++. Husmeando en la web encuentro el proyecto NppToR:
> https://sourceforge.net/projects/npptor/
> [https://a.fsdn.com/allura/p/npptor/icon?1479724788] //sourceforge.net/projects/npptor/>
>
> NppToR: R in Notepad++ download | SourceForge.net sourceforge.net/projects/npptor/>
> sourceforge.net
> Similar to the windows R gui built in editor, NppToR aims to extend the
> functionality of code passing to the Notepad++ code editor. In addition to
> passing ...
>
>
>
> ¡Si lo pruebas y no es mucho abuso, no dejes de darnos una
> retroalimentación de él!
>
> ¡Salud!
>
>
> --
> «Pídeles sus títulos a los que te persiguen, pregúntales
> cuándo nacieron, diles que te demuestren su existencia.»
>
> Rafael Cadenas
>
>
>
> [[alternative HTML version deleted]]
>
> ___
> R-help-es mailing list
> R-help-es@r-project.org
> https://stat.ethz.ch/mailman/listinfo/r-help-es
>
> [[alternative HTML version deleted]]
>
>
> ___
> R-help-es mailing list
> R-help-es@r-project.org
> https://stat.ethz.ch/mailman/listinfo/r-help-es
>



-- 
Saludos,
Carlos Ortega
www.qualityexcellence.es

[[alternative HTML version deleted]]

___
R-help-es mailing list
R-help-es@r-project.org
https://stat.ethz.ch/mailman/listinfo/r-help-es


Re: [R] fread transforms numbers

2017-03-22 Thread Matt Dowle
Thanks Bill for cc.

Santosh,

I'm almost certain you don't have package bit64 installed.  When you do it
works fine :

> remove.packages("bit64")
> data.table::fread("9876543210\n")
  V1
1: 4.879661e-314
> install.packages("bit64")
> data.table::fread("9876543210\n")
   V1
1: 9876543210

News for data.table v1.10.2 on CRAN 31 Jan 2017 contained :

* When fread() or print() see integer64 columns are present, bit64's
namespace is now automatically loaded for convenience.

However, when data.table loads the namespace there is a bug in this
function :

> data.table:::require_bit64
function ()
{
tt = try(requireNamespace("bit64", quietly = TRUE))
if (inherits(tt, "try-error"))
warning("Some columns are type 'integer64' but package bit64 is not
installed. Those columns will print as strange looking floating point data.
There is no need to reload the data. Simply install.packages('bit64') to
obtain the integer64 print method and print the data again.")
}

The intent was to display that nice helpful message to you.   Due to this
report, I can see now that I shouldn't have wrapped requireNamespace() with
try() because  requireNamespace() returns TRUE or FALSE anyway. Even though
requireNamespace() prints 'Failed with error' it doesn't actually throw an
error.  I'll change data.table's function to the following :

if (!requireNamespace("bit64", quietly = TRUE))
warning("Some columns ...")

bit64 is correctly Suggests not Depends.   It's just unfortunate the
intended message wasn't displayed.

Santosh, in future please follow the data.table support guide here:
https://github.com/Rdatatable/data.table/wiki/Support.  r-help is not
supposed to be used for package support.  The main thing though is thanks
for helping me find this bug.

Thanks,
Matt


On Wed, Mar 22, 2017 at 10:22 AM, William Dunlap  wrote:

> Here is a way to reproduce the problem:
>   > data.table::fread("9876543210\n") # number bigger than 2^31-1
> V1
>   1: 4.879661e-314
> and your work-around does fix things up
>   > data.table::fread("9876543210\n", colClasses="numeric")
>  V1
>   1: 9876543210
>
> Bill Dunlap
> TIBCO Software
> wdunlap tibco.com
>
>
> On Wed, Mar 22, 2017 at 9:58 AM, Jeff Newmiller
>  wrote:
> > You failed to provide a reproducible example, and you posted HTML so the
> quality of any answer will be limited by the quality of your question.
> >
> > My stab at your problem is that you should read ?fread, and in
> particular should try using the colClasses argument.
> > --
> > Sent from my phone. Please excuse my brevity.
> >
> > On March 22, 2017 8:52:55 AM PDT, Santosh  wrote:
> >>Hi
> >>
> >>I have been using "fread" utility of "data.table" packge .. on a
> >>dataset of
> >>about 20 million rows. It's a fantastic package to read datasets. Thank
> >>you, Matt D.
> >>
> >>However, I am faced with a peculiar instance of  certain numbers in a
> >>column being transformed.
> >>
> >>In the dataset, a column has values ranging from 1 to 9##
> >>(nchar(x)=11, e.g. 98765432109). After using "fread" to read the
> >>dataset,
> >>values in all the columns are displayed correctly upto the first 1000
> >>rows.
> >>If "fread" is applied for reading >1000 rows of  the total of 20Million
> >>rows, the values in only this (column (having wide range of values) are
> >>displayed as x.xxxe-3yy. (e.g. 3.5639877e-324)
> >>
> >>I tried reading all the columns as "character" and didn't help.
> >>
> >>Would highly appreciate your assistance!
> >>
> >>Thanks so much in advance.
> >>
> >>Best regards,
> >>Santosh
> >>
> >>   [[alternative HTML version deleted]]
> >>
> >>__
> >>R-help@r-project.org mailing list -- To UNSUBSCRIBE and more, see
> >>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@r-project.org mailing list -- To UNSUBSCRIBE and more, see
> > 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@r-project.org mailing list -- To UNSUBSCRIBE and more, see
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] Correlation code not working but not sure why

2017-03-22 Thread Ashley Patton via R-help
Good afternoon,

I was wondering if someone could help me with what I am sure is likely to be a 
really simple problem but I cannot work out what I have done wrong. I have 
tried searching the forums/Google etc but can't find anything quite like the 
code I am using other than things that do not differ from what I have done. I 
suspect then that the problem is in my naming of things but I don't know what 
is causing the issue.

I have data that comprises 53 columns containing temperature data for 53 sites 
recording continuously for a year, 48 times a day (half hourly). I also have 
one column that contains average air temperature for a city during the same 
time period. I would like to see if my collective site temperature data shows 
any correlation with the city air temperature data and so I have attempted to 
combined the data from the 53 site columns using the code below and then repeat 
the air temperature 53 times to correlate it against and then perform a 
Pearson's correlation. My data looks something like this:

Site   BHCS306   BH9OB1U   BHCS276   BHCS207...  AirTempC
 12.2  12.412.2   12.7 15.3
 12.2  12.512.3   12.7 16.2
 12.3  12.512.5   12.8 
16.1... 
repeating for 53 sites recording every half hour for a year

The code I used was this:


#String together data from all 53 sites into one column
AllTemps <- 
c(data[,"BHCS306"],data[,"BH9OB1U"],data[,"BHCS276"],data[,"BHCS207AL"],data[,"BHCS178AL"],data[,"BHCS159AL"],data[,"BHCS318"],data[,"BHCS211"],data[,"BH7OB1L"],data[,"BHCS274B"],data[,"BHCS337"],data[,"BH2PB1"],data[,"BHCS038"],data[,"BHCS074AL"],data[,"BH9OB1L"],data[,"Site
 
5"],data[,"BH6PB4"],data[,"BH6PB1"],data[,"BHCS329"],data[,"BH5PB1T"],data[,"BH4PB1T"],data[,"BHCS233T"],data[,"BHCS229"],data[,"BHCS272T"],data[,"BHCS217T"],data[,"BHCS283"],data[,"BHCS248"],data[,"BHCS002A"],data[,"BHCS245B"],data[,"BH4PB2T"],data[,"BH6PB2"],data[,"BH5PB1B"],data[,"BH4PB1B"],data[,"BHCS233B"],data[,"BHCS313L"],data[,"BHCS272B"],data[,"BHCS266"],data[,"BHCS217B"],data[,"BHCS241"],data[,"BH4PB2B"],data[,"BHCS116AL"],data[,"BHCS067A"],data[,"BHCS304L"],data[,"BH1OB1L"],data[,"BHCS307L"],data[,"BHCS037C"],data[,"BHCS301L"],data[,"BHCS238A"],data[,"BH3OB1"],data[,"BHCS308L"],data[,"BHCS278"],data[,"BHCS285"],data[,"BHCS133CL"],data[,"BHCS332L"])

#Copy air temp data 53 times
airTemps53 <- c(rep(AirTempC, times = 53))

#Run correlation between site temps and air temps
cor.test(AllTemps, airTemps53, alternative = "two.sided", method = "pearson")

The error it returned was this:

> #Copy air temp data 53 times
> airTemps53 <- c(rep(AirTempC, times = 53))
> 
> #Run correlation between site temps and air temps
> cor.test(AllTemps, airTemps53, alternative = "two.sided", method = "pearson")
Error in cor.test(AllTemps, airTemps53, alternative = "two.sided", method = 
"pearson") : 
  object 'AllTemps' not found

Can anyone spot my mistake? I am very new to this so I am sure I have done 
something obvious and silly so please forgive me.

Additionally I was wondering if there was a an easy way to offset the data to 
see if, for example, I can see if there is a lag time between changes in air 
temperature correlating with changes in temperature at my sites or do I need to 
do this by manually offsetting the data in Excel first?

Many thanks,
Ashley

__
R-help@r-project.org mailing list -- To UNSUBSCRIBE and more, see
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-es] GLM con clusters

2017-03-22 Thread Carlos J. Gil Bellosta
Hola, ¿qué tal?

Tienes una discusión sobre esos asuntos aquí
. Puedes usar los
paquetes lmer o nlme (me decantaría por el primero).

Un saludo,

Carlos J. Gil Bellosta
http://www.datanalytics.com

El 22 de marzo de 2017, 17:48, Sebastian Gadea 
escribió:

> Gracias a todos por sus respuestas, perdón si no fui muy claro.
>
> Lo que intento replicar es un análisis realizado en Stata, tengo que hacer
> los mismos cálculos pero en el r.
>
> En Stata lo que se hizo fue:
>
> xi: logistic i.coord i.v11_sexo, vce (cluster red)
>
>
> *Vce (cluster clustvar) especifica que los errores estándar permiten la
> correlación intragrupo, relajando el requisito habitual de que las
> observaciones sean independientes. Es decir, las observaciones son
> independientes entre grupos (grupos) pero no necesariamente dentro de los
> grupos. *
> http://www.stata.com/manuals13/rvce_option.pdf
>
>
> O sea, quitan el supuesto de independencia entre observaciones de un mismo
> grupo, en este lo indica la variable red. Pero ésto no afecta la estimación
> de los coeficientes, si los intervalos de confianza.
>
>
> El 22 de marzo de 2017, 13:38, Xavi tibau alberdi 
> escribió:
>
> > Buenas,
> >
> > No estoy muy seguro de porqué quieres hacer esto. Si no te entiendo mal,
> > quieres hacer una regresión logística, y con los resultados un análisis
> de
> > clústers. Quizá lo mejor seria usar ambos métodos de predicción y
> comparar
> > los resultados. Aún así, si te he entendido bien, entonces la manera de
> > hacerlo sería: primero la regresión y luego recuperas las predicciones.
> Por
> > ejemplo:
> >
> > mylogit <- glm(variable ~ ., data = df, family = "binomial") #Regresion
> > logistica
> >
> > summary(mylogit) #Ves que tal ha quedado.
> >
> > Puedes recuperar las prediciones con 'mylogit$fitted.values' y las puedes
> > poner en el dataframe original
> >
> > df$fitted <- mylogit$fitted.values
> >
> > Luego, puedes realizar un análisis de clusters usando las predicciones.
> >
> > Como se trata de una regresión logística, tendira sentido que antes del
> > analisis redondees los resultados hacia 1 o hacia 0.
> >
> > Espero que esto te sirva.
> >
> > Un saludo,
> >
> > Xavier Tibau
> >
> >
> >
> >
> >
> >
> >
> >
> > 2017-03-22 16:33 GMT+01:00 Sebastian Gadea  >:
> >
> >> Buenas tardes,
> >>
> >> desde Uruguay, quiero realizar una regresión logística,con la función
> GLM,
> >> pero ademas quiero designarle a las observaciones clusters.
> >>
> >> La idea es decirle al programa que las observaciones corresponden a
> >> diferentes clusters.
> >>
> >>
> >> Saludos!
> >> Sebastián.
> >>
> >> [[alternative HTML version deleted]]
> >>
> >> ___
> >> R-help-es mailing list
> >> R-help-es@r-project.org
> >> https://stat.ethz.ch/mailman/listinfo/r-help-es
> >>
> >
> >
>
>
> --
> Saludos!
> Sebastián.
>
> [[alternative HTML version deleted]]
>
> ___
> R-help-es mailing list
> R-help-es@r-project.org
> https://stat.ethz.ch/mailman/listinfo/r-help-es
>

[[alternative HTML version deleted]]

___
R-help-es mailing list
R-help-es@r-project.org
https://stat.ethz.ch/mailman/listinfo/r-help-es


Re: [R] fread transforms numbers

2017-03-22 Thread William Dunlap via R-help
Here is a way to reproduce the problem:
  > data.table::fread("9876543210\n") # number bigger than 2^31-1
V1
  1: 4.879661e-314
and your work-around does fix things up
  > data.table::fread("9876543210\n", colClasses="numeric")
 V1
  1: 9876543210

Bill Dunlap
TIBCO Software
wdunlap tibco.com


On Wed, Mar 22, 2017 at 9:58 AM, Jeff Newmiller
 wrote:
> You failed to provide a reproducible example, and you posted HTML so the 
> quality of any answer will be limited by the quality of your question.
>
> My stab at your problem is that you should read ?fread, and in particular 
> should try using the colClasses argument.
> --
> Sent from my phone. Please excuse my brevity.
>
> On March 22, 2017 8:52:55 AM PDT, Santosh  wrote:
>>Hi
>>
>>I have been using "fread" utility of "data.table" packge .. on a
>>dataset of
>>about 20 million rows. It's a fantastic package to read datasets. Thank
>>you, Matt D.
>>
>>However, I am faced with a peculiar instance of  certain numbers in a
>>column being transformed.
>>
>>In the dataset, a column has values ranging from 1 to 9##
>>(nchar(x)=11, e.g. 98765432109). After using "fread" to read the
>>dataset,
>>values in all the columns are displayed correctly upto the first 1000
>>rows.
>>If "fread" is applied for reading >1000 rows of  the total of 20Million
>>rows, the values in only this (column (having wide range of values) are
>>displayed as x.xxxe-3yy. (e.g. 3.5639877e-324)
>>
>>I tried reading all the columns as "character" and didn't help.
>>
>>Would highly appreciate your assistance!
>>
>>Thanks so much in advance.
>>
>>Best regards,
>>Santosh
>>
>>   [[alternative HTML version deleted]]
>>
>>__
>>R-help@r-project.org mailing list -- To UNSUBSCRIBE and more, see
>>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@r-project.org mailing list -- To UNSUBSCRIBE and more, see
> 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@r-project.org mailing list -- To UNSUBSCRIBE and more, see
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] fread transforms numbers

2017-03-22 Thread Jeff Newmiller
You failed to provide a reproducible example, and you posted HTML so the 
quality of any answer will be limited by the quality of your question.

My stab at your problem is that you should read ?fread, and in particular 
should try using the colClasses argument.
-- 
Sent from my phone. Please excuse my brevity.

On March 22, 2017 8:52:55 AM PDT, Santosh  wrote:
>Hi
>
>I have been using "fread" utility of "data.table" packge .. on a
>dataset of
>about 20 million rows. It's a fantastic package to read datasets. Thank
>you, Matt D.
>
>However, I am faced with a peculiar instance of  certain numbers in a
>column being transformed.
>
>In the dataset, a column has values ranging from 1 to 9##
>(nchar(x)=11, e.g. 98765432109). After using "fread" to read the
>dataset,
>values in all the columns are displayed correctly upto the first 1000
>rows.
>If "fread" is applied for reading >1000 rows of  the total of 20Million
>rows, the values in only this (column (having wide range of values) are
>displayed as x.xxxe-3yy. (e.g. 3.5639877e-324)
>
>I tried reading all the columns as "character" and didn't help.
>
>Would highly appreciate your assistance!
>
>Thanks so much in advance.
>
>Best regards,
>Santosh
>
>   [[alternative HTML version deleted]]
>
>__
>R-help@r-project.org mailing list -- To UNSUBSCRIBE and more, see
>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@r-project.org mailing list -- To UNSUBSCRIBE and more, see
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-es] xtable

2017-03-22 Thread eric

has probado con

{\bf tus datos de la celda}

?

slds, eric.



On 03/22/2017 07:55 AM, Belén Cillero Jiménez wrote:

Buenos días
He hecho una tabla con xtable que tiene 28 filas y 5 columnas, quiero poner en 
negrita los elementos (1,1) y (15,1) y no veo como usar el comando adecuado de 
xtable
Muchas gracias



Belén Cillero Jiménez

Técnico de Estadística

Instituto de Estadística de La Rioja



bcill...@larioja.org

oɯsıɯ ol ǝɹdɯǝıs sɐƃɐɥ ou ,soʇuıʇsıp sopɐʇlnsǝɹ sɐɔsnq ıS



GOBIERNO DE LA RIOJA
AVISO LEGAL: La información contenida en este mensaje es confidencial y está 
destinada a ser leída sólo por la persona a la que va dirigida. Si Ud. no es el 
destinatario señalado le informamos que está prohibida, y puede ser ilegal, 
cualquier divulgación o reproducción de este mensaje.
Antes de imprimir este e-mail piense bien si es necesario hacerlo.

[[alternative HTML version deleted]]

___
R-help-es mailing list
R-help-es@r-project.org
https://stat.ethz.ch/mailman/listinfo/r-help-es



--
Forest Engineer
Master in Environmental and Natural Resource Economics
Ph.D. student in Sciences of Natural Resources at La Frontera University
Member in AguaDeTemu2030, citizen movement for Temuco with green city standards 
for living

Nota: Las tildes se han omitido para asegurar compatibilidad con algunos 
lectores de correo.

___
R-help-es mailing list
R-help-es@r-project.org
https://stat.ethz.ch/mailman/listinfo/r-help-es

Re: [R-es] GLM con clusters

2017-03-22 Thread Freddy Omar López Quintero
​Hola.​

2017-03-22 12:33 GMT-03:00 Sebastian Gadea :

> quiero realizar una regresión logística,con la función GLM,
> pero ademas quiero designarle a las observaciones clusters.
>

​Si no entiendo mal, quieres estimar un modelo marginal; entonces la opción
inmediata (para mí) está en el paquete gee. Su función del mismo nombre
tiene un ejemplo para datos binarios.

Si el modelo que quieres no es marginal sino un modelo mixto más general,
podrías utilizar (entre muchísimas opciones) el paquete lme4,
específicamente la función glmer.

Cabe sin embargo la posibilidad que haya entendido todo mal y debas darnos
un poco más de información para intentar ayudarte mejor.

¡Salud!


-- 
«Pídeles sus títulos a los que te persiguen, pregúntales
cuándo nacieron, diles que te demuestren su existencia.»

Rafael Cadenas

[[alternative HTML version deleted]]

___
R-help-es mailing list
R-help-es@r-project.org
https://stat.ethz.ch/mailman/listinfo/r-help-es

[R] fread transforms numbers

2017-03-22 Thread Santosh
Hi

I have been using "fread" utility of "data.table" packge .. on a dataset of
about 20 million rows. It's a fantastic package to read datasets. Thank
you, Matt D.

However, I am faced with a peculiar instance of  certain numbers in a
column being transformed.

In the dataset, a column has values ranging from 1 to 9##
(nchar(x)=11, e.g. 98765432109). After using "fread" to read the dataset,
values in all the columns are displayed correctly upto the first 1000 rows.
If "fread" is applied for reading >1000 rows of  the total of 20Million
rows, the values in only this (column (having wide range of values) are
displayed as x.xxxe-3yy. (e.g. 3.5639877e-324)

I tried reading all the columns as "character" and didn't help.

Would highly appreciate your assistance!

Thanks so much in advance.

Best regards,
Santosh

[[alternative HTML version deleted]]

__
R-help@r-project.org mailing list -- To UNSUBSCRIBE and more, see
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-es] ggplot2

2017-03-22 Thread Víctor Granda García
Hola Belén,

Para el tamaño del lienzo, como te comenta Carlos, es decírselo en las
opciones del chunk con fig.height y fig.width (ojo, que se lo indicas en
pulgadas, por tanto si lo quieres en cm tienes que hacer el calculo y poner
las pulgadas que corresponden a los cm que quieres).

En cuanto a los márgenes, es cambiar el theme de la gráfica de ggplot de
acuerdo a lo que quieras. Por ejemplo para cambiar el márgen de la etiqueta
del eje y puedes usar:

ggplot(mpg, aes(cty, hwy)) + geom_point()+
  theme(axis.title.y=element_text(vjust=0.1))

o

ggplot(mpg, aes(cty, hwy)) + geom_point()+
  theme(axis.title.y=element_text(margin=margin(0,20,0,0)))

Para el resto de márgenes es muy similar, mira la ayuda de "theme" (o este
documento: http://docs.ggplot2.org/dev/vignettes/themes.html) y encontrarás
una explicación de cada elemento para poder cambiarlo. De hecho, si lo que
pretendes es automatizar todo el proceso de generación de informes, te
recomiendo crear tu propio tema de ggplot2 y usarlo, como dicen en el
documento que te linkeo.

Espero que te sirva,
Un saludo!

El mié., 22 mar. 2017 a las 14:26, 
escribió:

> Estimada Belén
>
> No se exactamente lo que necesita, en mi caso supe utilizar
> https://www.lyx.org/Screenshots, aparte de RMarkdown, pero la mejor
> experiencia, aunque requiere más trabajo, la obtuve con utilizando esa
> mezcla de latex y r (sweave). Con esta última creaba informes que filtraba,
> el análisis de R era uno, pero a un usuario le pasaba los registros que le
> interesaban y a otro los que le correspondían, entonces con in if los
> separaba, al mismo tiempo usaba el colocar distinto colores en las letras
> dentro de xtable (rojo, verde, amarillo), el resultado eran que al correr
> un código se generaban distintos PDF, cada cuál con lo que correspondía y
> vistoso, lógicamente, es muchísimo trabajo y prueba y error. Se puede, pero
> es un rompedero de cabeza, hay que ver si vale la pena el costo del trabajo
> para crear el informe.
>
> Javier Rubén Marcuzzi
>
> De: Belén Cillero Jiménez
> Enviado: miércoles, 22 de marzo de 2017 10:15
> Para: r-help-es@r-project.org
> Asunto: [R-es] ggplot2
>
> Estoy automatizando informes con RMarkdown, y uso xtable y ggplot. Para
> los gráficos necesito un un tamaño fijo para el área de trazado y para el
> margen que contiene los textos de los ejes y las etiquetas.
> ¿Popdríais decirme cómo?
> Muchas gracias
>
>
>
> Belén Cillero Jiménez
>
> Técnico de Estadística
>
> Instituto de Estadística de La Rioja
>
>
>
> bcill...@larioja.org
>
> oɯsıɯ ol ǝɹdɯǝıs sɐƃɐɥ ou ,soʇuıʇsıp sopɐʇlnsǝɹ sɐɔsnq ıS
>
> 
>
> GOBIERNO DE LA RIOJA
> AVISO LEGAL: La información contenida en este mensa...{{dropped:18}}
>
> ___
> R-help-es mailing list
> R-help-es@r-project.org
> https://stat.ethz.ch/mailman/listinfo/r-help-es

-- 
*Víctor Granda García*
Tècnic


v.gra...@creaf.uab.cat
Tel. +34 93 581 33 45


Campus UAB. Edifici C. 08193 Bellaterra (Barcelona) | *www.creaf.cat*


Abans d'imprimir aquest missatge electrònic penseu en el medi ambient.

[[alternative HTML version deleted]]

___
R-help-es mailing list
R-help-es@r-project.org
https://stat.ethz.ch/mailman/listinfo/r-help-es

[R-es] GLM con clusters

2017-03-22 Thread Sebastian Gadea
Buenas tardes,

desde Uruguay, quiero realizar una regresión logística,con la función GLM,
pero ademas quiero designarle a las observaciones clusters.

La idea es decirle al programa que las observaciones corresponden a
diferentes clusters.


Saludos!
Sebastián.

[[alternative HTML version deleted]]

___
R-help-es mailing list
R-help-es@r-project.org
https://stat.ethz.ch/mailman/listinfo/r-help-es


Re: [R] string pattern matching

2017-03-22 Thread William Dunlap via R-help
You did not describe the goal of your pattern matching.  Were you trying
to match any string that could be interpreted as an R expression containing
X1 and X3 as additive terms?   If so, you could turn the string into a one-sided
formula and use the terms() function.  E.g.,

f <- function(string) {
fmla <- as.formula(paste("~", string))
term.labels <- attr(terms(fmla), "term.labels")
all(c("X1","X3") %in% term.labels)
}

> f("X3 + X2 + X1")
[1] TRUE
> f("- X3 + X2 + X1")
[1] FALSE
> f("X3 + X2 + log(X1)")
[1] FALSE
> f("X3 + X2 + log(X1) + X1")
[1] TRUE
Bill Dunlap
TIBCO Software
wdunlap tibco.com


On Wed, Mar 22, 2017 at 6:39 AM, Joe Ceradini  wrote:
> Wow. Thanks to everyone (Jim, Ng Bo Lin, Bert, David, and Ulrik) for
> all the quick and helpful responses. They have given me a better
> understanding of regular expressions, and certainly answered my
> question.
>
> Joe
>
> On Wed, Mar 22, 2017 at 12:22 AM, Ulrik Stervbo  
> wrote:
>> 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 + 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")
>>> [1] TRUE
>>> multigrep("x1 + x4","x1 + x2 + x3")
>>> [1] FALSE
>>>
>>> Jim
>>>
>>> On Wed, Mar 22, 2017 at 10:50 AM, Joe Ceradini 
>>> wrote:
>>> > 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 + x3"
>>> >
>>> > grep("x1 + x2", test, fixed=TRUE, value = TRUE)
>>> > [1] "x1 + x2 + x3"
>>> >
>>> >
>>> > But what if only have "x1 + x3" as the pattern and still want to
>>> > return "x1 + x2 + x3"?
>>> >
>>> > grep("x1 + x3", test, fixed=TRUE, value = TRUE)
>>> > character(0)
>>> >
>>> > I'm sure this looks like an odd question. I'm trying to build a
>>> > function and stuck on this. Rather than dropping the whole function on
>>> > the list, I thought I'd try one piece I needed help with...although I
>>> > suspect that this question itself probably does bode well for my
>>> > function :)
>>> >
>>> > Thanks!
>>> > Joe
>>> >
>>> > __
>>> > R-help@r-project.org mailing list -- To UNSUBSCRIBE and more, see
>>> > 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@r-project.org mailing list -- To UNSUBSCRIBE and more, see
>>> 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.
>
>
>
> --
> Cooperative Fish and Wildlife Research Unit
> Zoology and Physiology Dept.
> University of Wyoming
> joecerad...@gmail.com / 914.707.8506
> wyocoopunit.org
>
> __
> R-help@r-project.org mailing list -- To UNSUBSCRIBE and more, see
> 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@r-project.org mailing list -- To UNSUBSCRIBE and more, see
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] Issue with subset in glm

2017-03-22 Thread Bert Gunter
The subset argument is evaluated in "data" first, then in the caller's
environment, etc.
So:

1) In your first example, stype is a *vector*, and the subset
expression is identically TRUE, hence is equivalent to making the call
without the subset argument.

2) The second call fits the subset with stype = "E", hence is different.

3) "i" is not found in mtcars, hence is looked for in the caller,
where it has the value 4, giving the same subset and result as in the
next call.


Cheers,
Bert


Bert Gunter

"The trouble with having an open mind is that people keep coming along
and sticking things into it."
-- Opus (aka Berkeley Breathed in his "Bloom County" comic strip )


On Tue, Mar 21, 2017 at 8:50 AM, Ganz, Carl  wrote:
> 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 = apistrat,
> subset = apistrat$stype == stype))
> (b <- glm(api00~ell+meals+mobility, data = apistrat,
> subset = apistrat$stype == "E"))
> # should be equal since stype = "E" but they aren't
> coef(a)==coef(b)
>
> # for some reason works as expected here
> i = 4
> (c <- glm(mpg ~ wt, data = mtcars, subset = mtcars$cyl==i))
> (d <- glm(mpg ~ wt, data = mtcars, subset = mtcars$cyl==4))
> coef(c)==coef(d)
>
> I can't really explain what is happening so I would appreciate help.
>
> Kind Regards,
> Carl Ganz
>
> __
> R-help@r-project.org mailing list -- To UNSUBSCRIBE and more, see
> 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@r-project.org mailing list -- To UNSUBSCRIBE and more, see
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] argument to 'which' is not logical

2017-03-22 Thread Jeff Newmiller
The `c` function is extremely common. You CAN redefine this object as a numeric 
variable if you want but I strongly recommend against it. 

I don't recognize the function you are using to create cvfits, but it looks 
like the coef method for that object is not returning a numeric vector, so your 
comparison is with some other kind of object. 

Notice how ugly your code looks below... only you can fix this by setting your 
email program to send plain text to the mailing list. 
-- 
Sent from my phone. Please excuse my brevity.

On March 22, 2017 5:15:04 AM PDT, Allan Tanaka  wrote:
>I'm trying to run the code: inds<-which(c != 0 ), but it gave me
>error: Error in base::which(x, arr.ind, useNames, ...) :   argument to
>'which' is not logical
>Here is code:
>alphas <- seq(0, 1, by=.002)mses <- numeric(501)mins <-
>numeric(501)maxes <- numeric(501)for(i in 1:501){  cvfits <-
>cv.glmnet(Train2, Train$Item_Outlet_Sales, alpha=alphas[i], nfolds=32) 
>loc <- which(cvfits$lambda==cvfits$lambda.min)  maxes[i] <-
>cvfits$lambda %>% max  mins[i] <- cvfits$lambda %>% min  mses[i] <-
>cvfits$cvm[loc]}`%ni%`<-Negate(`%in%`)c<-coef(cvfits,s='lambda.1se',exact=TRUE)inds<-which(c
>!= 0 )
>Here is the c content looks like: > c33 x 1 sparse Matrix of class
>"dgCMatrix"                                           1(Intercept)    
>                 7.476895931Item_Fat_Content.Low.Fat         .        
> Item_Fat_Content.Regular         .          Item_Type.Breads          
>      .          Item_Type.Breakfast              .        
> Item_Type.Canned                 0.003430669Item_Type.Dairy          
>      -0.022579673Item_Type.Frozen.Foods        
> -0.008216547Item_Type.Fruits.and.Vegetables  .        
> Item_Type.Hard.Drinks            .        
> Item_Type.Health.and.Hygiene     .          Item_Type.Household      
>       .          Item_Type.Meat                   .        
> Item_Type.Others                 .          Item_Type.Seafood        
>       .          Item_Type.Snack.Foods            .        
> Item_Type.Soft.Drinks            .          Item_Type.Starchy.Foods  
>       .          Outlet_Establishment_Year.1987
> -0.345927916Outlet_Establishment_Year.1997  
>1.692678186Outlet_Establishment_Year.1998
> -2.259508290Outlet_Establishment_Year.1999   .        
> Outlet_Establishment_Year.2002
> -0.032971913Outlet_Establishment_Year.2004  
>1.756230495Outlet_Establishment_Year.2007   .        
> Outlet_Establishment_Year.2009  -0.549210057Outlet_Size.Medium        
>      0.056897825Outlet_Size.Small              
>-1.706006538Outlet_Location_Type.Tier.3    
> 0.373456218Item_Identifier_CombinedFD       .          Item_MRP      
>                  0.505435352Item_Weight                      .        
> Item_Visibility_MeanRatio       -0.007274202
>   [[alternative HTML version deleted]]
>
>__
>R-help@r-project.org mailing list -- To UNSUBSCRIBE and more, see
>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@r-project.org mailing list -- To UNSUBSCRIBE and more, see
https://stat.ethz.ch/mailman/listinfo/r-help
PLEASE do read the posting guide http://www.R-project.org/posting-guide.html
and provide commented, minimal, self-contained, reproducible code.

[R] r question

2017-03-22 Thread 謝孟珂
Hi ,I have some question about simulate, I don't know how to paste question
to this website,so I paste below.
I use genoud to find the maximum likelihood value, but when I use numcut=3
,it will get error message,like this " coxph.wtest(fit$var[nabeta, nabeta],
temp, control$toler.chol) : NA/NaN/Inf"
and this is my code
library(rgenoud)
library(survival)
N=500
ei=rexp(N)
censor=rep(1,N)
x1=runif(N)
x2=runif(N)
x3=runif(N)
truecut=c(0.3,0.6)
dum1=1*(x1>truecut[1] & x1truecut[2])
x_true=cbind(dum1,dum2,x2,x3)
relativerisk<- matrix(log(c(1,1,2,2),ncol=4,byrow = TRUE)
beta_true<-relativerisk
Ti=exp(x_true%*%beta_true)*ei
confound=cbind(x2,x3)
initial2<-c(0.09,0.299,0.597,-0.17,-1.3,-3.1,-1.4,-1.12)
numcut=2
 
domain2<<-matrix(c(rep(c(0.05,0.95),numcut),rep(c(0,5),numcut+dim(confound)[2])),ncol=2,byrow
= TRUE)

loglikfun <- function(beta, formula) {
  beta1 <- coxph(formula, init = beta,
control=list('iter.max'=0))#iteration is zero
  return(beta1$loglik[2])
}
obj <- function(xx){
  cutoff <- xx[1:numcut_global] #cutpoint
  cut_design <-
cut(target_global,breaks=c(0,sort(cutoff)+seq(0,gap_global*(length(cutoff)-1),by=gap_global),target_max),quantile=FALSE,labels=c(0:numcut_global))
  beta <- -xx[(numcut+1):nvars]  #coefficients of parameters
  logliks <-
loglikfun(beta,Surv(time_global,censor_global)~cut_design+confound_global)
  return(logliks)
}
maxloglik<-function(target,numcut,time,censor,confound,domain2,initial2,gap){
  time_global<<-time
  censor_global<<-censor
  target_global<<-target
  nvars<<-2*numcut+dim(confound)[2]
  confound_global<<-confound
  numcut_global<<-numcut
  target_max<<-max(target)
  gap_global<<-gap
  ccc<-genoud(obj, nvars, max=TRUE, pop.size=100, max.generations=6,
wait.generations=10,
  hard.generation.limit=TRUE, starting.values=initial2,
MemoryMatrix=TRUE,
  Domains=domain2, solution.tolerance=0.001,
  gr=NULL, boundary.enforcement=2, lexical=FALSE,
gradient.check=TRUE)
  ccc$par_corr<-ccc$par #the coefficients of genoud

ccc$par_corr[1:numcut]<-sort(ccc$par[1:numcut])+seq(0,gap_global*(numcut-1),by=gap_global)
#sort cutpoint
  return(ccc)
}


maxloglik(x1,3,Ti,censor,confound,domain2,initial2,0.02)$par_corr

I have no idea about the error ,maybe is my initial is wrong.
thank you
 From Meng-Ke

[[alternative HTML version deleted]]

__
R-help@r-project.org mailing list -- To UNSUBSCRIBE and more, see
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] argument to 'which' is not logical

2017-03-22 Thread Allan Tanaka
I'm trying to run the code: inds<-which(c != 0 ), but it gave me error: Error 
in base::which(x, arr.ind, useNames, ...) :   argument to 'which' is not logical
Here is code:
alphas <- seq(0, 1, by=.002)mses <- numeric(501)mins <- numeric(501)maxes <- 
numeric(501)for(i in 1:501){  cvfits <- cv.glmnet(Train2, 
Train$Item_Outlet_Sales, alpha=alphas[i], nfolds=32)  loc <- 
which(cvfits$lambda==cvfits$lambda.min)  maxes[i] <- cvfits$lambda %>% max  
mins[i] <- cvfits$lambda %>% min  mses[i] <- 
cvfits$cvm[loc]}`%ni%`<-Negate(`%in%`)c<-coef(cvfits,s='lambda.1se',exact=TRUE)inds<-which(c
 != 0 )
Here is the c content looks like: > c33 x 1 sparse Matrix of class "dgCMatrix"  
                                         1(Intercept)                      
7.476895931Item_Fat_Content.Low.Fat         .          Item_Fat_Content.Regular 
        .          Item_Type.Breads                 .          
Item_Type.Breakfast              .          Item_Type.Canned                 
0.003430669Item_Type.Dairy                 -0.022579673Item_Type.Frozen.Foods   
       -0.008216547Item_Type.Fruits.and.Vegetables  .          
Item_Type.Hard.Drinks            .          Item_Type.Health.and.Hygiene     .  
        Item_Type.Household              .          Item_Type.Meat              
     .          Item_Type.Others                 .          Item_Type.Seafood   
             .          Item_Type.Snack.Foods            .          
Item_Type.Soft.Drinks            .          Item_Type.Starchy.Foods          .  
        Outlet_Establishment_Year.1987  
-0.345927916Outlet_Establishment_Year.1997   
1.692678186Outlet_Establishment_Year.1998  
-2.259508290Outlet_Establishment_Year.1999   .          
Outlet_Establishment_Year.2002  -0.032971913Outlet_Establishment_Year.2004   
1.756230495Outlet_Establishment_Year.2007   .          
Outlet_Establishment_Year.2009  -0.549210057Outlet_Size.Medium               
0.056897825Outlet_Size.Small               
-1.706006538Outlet_Location_Type.Tier.3      
0.373456218Item_Identifier_CombinedFD       .          Item_MRP                 
        0.505435352Item_Weight                      .          
Item_Visibility_MeanRatio       -0.007274202
[[alternative HTML version deleted]]

__
R-help@r-project.org mailing list -- To UNSUBSCRIBE and more, see
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] string pattern matching

2017-03-22 Thread Joe Ceradini
Wow. Thanks to everyone (Jim, Ng Bo Lin, Bert, David, and Ulrik) for
all the quick and helpful responses. They have given me a better
understanding of regular expressions, and certainly answered my
question.

Joe

On Wed, Mar 22, 2017 at 12:22 AM, Ulrik Stervbo  wrote:
> 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 + 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")
>> [1] TRUE
>> multigrep("x1 + x4","x1 + x2 + x3")
>> [1] FALSE
>>
>> Jim
>>
>> On Wed, Mar 22, 2017 at 10:50 AM, Joe Ceradini 
>> wrote:
>> > 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 + x3"
>> >
>> > grep("x1 + x2", test, fixed=TRUE, value = TRUE)
>> > [1] "x1 + x2 + x3"
>> >
>> >
>> > But what if only have "x1 + x3" as the pattern and still want to
>> > return "x1 + x2 + x3"?
>> >
>> > grep("x1 + x3", test, fixed=TRUE, value = TRUE)
>> > character(0)
>> >
>> > I'm sure this looks like an odd question. I'm trying to build a
>> > function and stuck on this. Rather than dropping the whole function on
>> > the list, I thought I'd try one piece I needed help with...although I
>> > suspect that this question itself probably does bode well for my
>> > function :)
>> >
>> > Thanks!
>> > Joe
>> >
>> > __
>> > R-help@r-project.org mailing list -- To UNSUBSCRIBE and more, see
>> > 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@r-project.org mailing list -- To UNSUBSCRIBE and more, see
>> 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.



-- 
Cooperative Fish and Wildlife Research Unit
Zoology and Physiology Dept.
University of Wyoming
joecerad...@gmail.com / 914.707.8506
wyocoopunit.org

__
R-help@r-project.org mailing list -- To UNSUBSCRIBE and more, see
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-es] ggplot2

2017-03-22 Thread javier.ruben.marcuzzi
Estimada Belén

No se exactamente lo que necesita, en mi caso supe utilizar 
https://www.lyx.org/Screenshots, aparte de RMarkdown, pero la mejor 
experiencia, aunque requiere más trabajo, la obtuve con utilizando esa mezcla 
de latex y r (sweave). Con esta última creaba informes que filtraba, el 
análisis de R era uno, pero a un usuario le pasaba los registros que le 
interesaban y a otro los que le correspondían, entonces con in if los separaba, 
al mismo tiempo usaba el colocar distinto colores en las letras dentro de 
xtable (rojo, verde, amarillo), el resultado eran que al correr un código se 
generaban distintos PDF, cada cuál con lo que correspondía y vistoso, 
lógicamente, es muchísimo trabajo y prueba y error. Se puede, pero es un 
rompedero de cabeza, hay que ver si vale la pena el costo del trabajo para 
crear el informe.

Javier Rubén Marcuzzi 

De: Belén Cillero Jiménez
Enviado: miércoles, 22 de marzo de 2017 10:15
Para: r-help-es@r-project.org
Asunto: [R-es] ggplot2

Estoy automatizando informes con RMarkdown, y uso xtable y ggplot. Para los 
gráficos necesito un un tamaño fijo para el área de trazado y para el margen 
que contiene los textos de los ejes y las etiquetas.
¿Popdríais decirme cómo?
Muchas gracias



Belén Cillero Jiménez

Técnico de Estadística

Instituto de Estadística de La Rioja



bcill...@larioja.org

oɯsıɯ ol ǝɹdɯǝıs sɐƃɐɥ ou ,soʇuıʇsıp sopɐʇlnsǝɹ sɐɔsnq ıS



GOBIERNO DE LA RIOJA
AVISO LEGAL: La información contenida en este mensa...{{dropped:18}}

___
R-help-es mailing list
R-help-es@r-project.org
https://stat.ethz.ch/mailman/listinfo/r-help-es

Re: [R-es] Alternativa a RStudio

2017-03-22 Thread javier.ruben.marcuzzi
Estimado Freddy

Voy a demorar unos días pero probaré, vi un video (en partes saltando minutos) 
donde hacían una comparación entre emacs, rstudio, notepad++.

Pero por otro lado, Windows 10 tiene bash (no se si está finalizado, pero se 
puede usar), donde hay partes que son mantenidas por Ubuntu, y ya está el 
anuncio de la nueva versión de Windows (no recuerdo la fecha pero faltan días), 
todos los sistemas tienen puntos fuertes y débiles respecto a la experiencia de 
usuario, pienso que por el lado de bash podría haber una grata sorpresa, o 
queda en nada, algo que me llama la atención es que R y visual studio ya no se 
llevan (la versión estable no cita a R), aunque ya está la beta de 
actualización (la última versión estable tiene unas dos semanas).

Lo que sí estoy convencido es que JavaScript es bueno pero para cosas pequeñas, 
cuándo comienza a incrementar el número de líneas de código o de información a 
tratar por este la pérdida de eficiencia comienza a visualizarse respecto a 
otros lenguajes compilados, lógicamente JavaScript anda en todos lados.

Voy a probar alguna alternativa, sobre todo si tiene autocompletar para evitar 
los errores ortográficos. 

Javier Rubén Marcuzzi

De: Freddy Omar López Quintero
Enviado: miércoles, 22 de marzo de 2017 9:53
Para: Marcuzzi, Javier Rubén
CC: r-help-es@r-project.org
Asunto: Re: [R-es] Alternativa a RStudio

​Hola Javier,​

Alguno utiliza una alternativa a RStudio

​En particular, yo me paseo entre RStudio (sobre todo por demostraciones 
rápidas que debo hacer) y la consola junto al siempre fiel gedit, de Gnome.​ 

Este último par es suficiente para mí. En Windows talvez yo lo intentaría con 
NotePad++. Husmeando en la web encuentro el proyecto NppToR: 
https://sourceforge.net/projects/npptor/
¡Si lo pruebas y no es mucho abuso, no dejes de darnos una retroalimentación de 
él!

¡​Salud!​


-- 
«Pídeles sus títulos a los que te persiguen, pregúntales
cuándo nacieron, diles que te demuestren su existencia.»

Rafael Cadenas



[[alternative HTML version deleted]]

___
R-help-es mailing list
R-help-es@r-project.org
https://stat.ethz.ch/mailman/listinfo/r-help-es

Re: [R] Data and Variables from Tables

2017-03-22 Thread Shawn Way
I implemented the second as well.  It was much easier to create a function to 
automate this as well as assign  the results to a single data.frame

Shawn Way, PE

-Original Message-
From: Jeff Newmiller [mailto:jdnew...@dcn.davis.ca.us] 
Sent: Tuesday, March 21, 2017 5:40 PM
To: r-help@r-project.org; Shawn Way ; Enrico Schumann 

Cc: r-help@r-project.org
Subject: Re: [R] Data and Variables from Tables

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 case (row) I am 
interested in using and pass around 1-row data frames to the computation 
functions.
--
Sent from my phone. Please excuse my brevity.

On March 21, 2017 3:18:38 PM PDT, Shawn Way  wrote:
>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-help@r-project.org
>Subject: Re: [R] Data and Variables from Tables
>
>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 | 1 | kg/hr|
>> | \beta| 2 | \frac{m^3}{hr} |
>> | G| .25 | in   |
>>
>> This all works well and looks great.
>>
>> What I am trying to do is use this to generate variables for 
>> programming as well.  For example, when processed I would have the 
>> following variables:
>>
>> A <- 1
>> beta <- 2
>> G <- .25
>>
>> Has anyone done something like this or can someone point me in the 
>> right direction to do this?
>>
>> Shawn Way
>>
>
>You may be looking for ?assign.
>
>  df <- data.frame(Symbol = c("A", "\\beta",  "G"),
>   Value  = c(  1,2, 0.25))
>  
>  ## remove backslashes
>  df[["Symbol"]] <- gsub("\\", "", df[["Symbol"]], fixed = TRUE)
>  
>  for (i in seq_len(nrow(df)))
>  assign(df[i, "Symbol"], df[i, "Value"])
>  
>But depending on what you want to do, it may be cleaner/safer to keep 
>the variables from the table together in a list.
>
>tbl <- as.list(df[["Value"]])
>names(tbl) <- df[["Symbol"]]
>
>## $A
>## [1] 1
>## 
>## $beta
>## [1] 2
>## 
>## $G
>## [1] 0.25
>
>
>--
>Enrico Schumann
>Lucerne, Switzerland
>http://enricoschumann.net
>
>__
>R-help@r-project.org mailing list -- To UNSUBSCRIBE and more, see 
>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@r-project.org mailing list -- To UNSUBSCRIBE and more, see
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-es] xtable

2017-03-22 Thread javier.ruben.marcuzzi
Estimada Belén Cillero Jiménez

Mire un ejemplo en 
https://cran.r-project.org/web/packages/xtable/vignettes/xtableGallery.pdf, 
página 12.

Javier Rubén Marcuzzi

De: Belén Cillero Jiménez
Enviado: miércoles, 22 de marzo de 2017 8:11
Para: r-help-es@r-project.org
Asunto: [R-es] xtable

Buenos días
He hecho una tabla con xtable que tiene 28 filas y 5 columnas, quiero poner en 
negrita los elementos (1,1) y (15,1) y no veo como usar el comando adecuado de 
xtable
Muchas gracias



Belén Cillero Jiménez

Técnico de Estadística

Instituto de Estadística de La Rioja



bcill...@larioja.org

oɯsıɯ ol ǝɹdɯǝıs sɐƃɐɥ ou ,soʇuıʇsıp sopɐʇlnsǝɹ sɐɔsnq ıS



GOBIERNO DE LA RIOJA
AVISO LEGAL: La información contenida en este mensa...{{dropped:18}}

___
R-help-es mailing list
R-help-es@r-project.org
https://stat.ethz.ch/mailman/listinfo/r-help-es

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

2017-03-22 Thread Santiago Bueno
Tree dbh haut Btot
1 35.00 18.90 0.357
2 25.00 16.60 0.214
3 23.00 19.50 0.173
4 13.50 15.60 0.060
5 20.00 18.80 0.134
6 23.00 17.40 0.137
7 29.00 19.90 0.428
8 17.60 18.20 0.100
9 31.00 25.30 0.514
10 26.00 23.50 0.273
11 13.00 13.00 0.031
12 32.00 20.70 0.356
13 28.00 28.50 0.349
14 15.00 18.20 0.068
15 19.00 14.90 0.110
16 33.00 14.90 0.260
17 24.00 19.10 0.160
18 22.00 19.20 0.204
19 39.00 25.20 0.724
20 30.00 26.60 0.386
Hello dear all:

I am using above data to run the following code;

library(nlme)

start <- coef(lm(Btot~I(dbh**2*haut),data=dat))

names(start) <- c("a","b")

model1 <-(nlme (Btot~a+b*dbh**2*haut, data=cbind(dat, g="a"), fixed=a+b~1,
start=start,

groups=~g, weights=varPower(form=~dbh)))


I get regression parameters with the intercept being non-significant.
Therefore, I run the following code to obtain an equation without
intercept..


summary(nlme(Btot~b*dbh**2*haut, data=cbind(dat,g="a"), fixed=b~1,
start=start["b"], groups=~g, weights=varPower(form=~dbh)))


When I do run the last code, I get the following error:


Error in nlme.formula(Btot ~ b * dbh**2 * haut, data = cbind(dat, g = "a"),
 :

  step halving factor reduced below minimum in PNLS step

Can someone help??


Best regards,

Santiago

On Wed, Mar 22, 2017 at 2:26 AM, Michael Dayan 
wrote:

> 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,
> >
> > 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 use the betareg package to run the fit with
> initial
> > values for the parameters alpha1, beta1, alpha2, beta2 and lambda? I saw
> in
> > the documentation that I would need to use the 'start' option of the
> > betareg function, with start described as "an optional vector with
> starting
> > values for all parameters (including phi)". However I could not find how
> to
> > define this list given my alpha1, beta1, alpha2, beta2 and lambda.
> >
> > The current code I have is:
> > mydata$y <- 
> > bmix <- betamix(y ~ 1 | 1, data = mydata, k = 2, fstol = 1e-08, maxit =
> > 200, fsmaxit = 200)
> >
> >
> > And I suspect I would need to do something along the lines:
> >
> > initial.vals <- c(?, ?, ?, ?, ?)
> > bmix <- betamix(y ~ 1 | 1, data = mydata, k = 2, fstol = 1e-08, maxit =
> > 200, fsmaxit = 200, control=betareg.control(start=initial.vals)))
> >
> > But I do not know what to use for initial.vals.
>
> If there were sensitivity to data, then wouldn't  that depend on your
> (unprovided) data?
>
>
> >
> > Best wishes,
> >
> > Michael
> >
> >   [[alternative HTML version deleted]]
> >
> > __
> > R-help@r-project.org mailing list -- To UNSUBSCRIBE and more, see
> > https://stat.ethz.ch/mailman/listinfo/r-help
> > PLEASE do read the posting guide http://www.R-project.org/
> posting-guide.html
> > and provide commented, minimal, self-contained, reproducible code.
>
> David Winsemius
> Alameda, CA, USA
>
> [[alternative HTML version deleted]]
>
> __
> R-help@r-project.org mailing list -- To UNSUBSCRIBE and more, see
> 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@r-project.org mailing list -- To UNSUBSCRIBE and more, see
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-es] R - Markdown

2017-03-22 Thread Mauricio Mardones Inostroza
Genial muchachos!!!

con sus tips, lo he solucionado

Agradezco un millon!

El 22 de marzo de 2017, 7:32, Freddy Omar López Quintero <
freddy.lopez.quint...@gmail.com> escribió:

>
> 2017-03-21 21:50 GMT-03:00 Genaro Contreras :
>
>> Si no la tienes puedes instalar miktek que es una distribución
>> de látex para Windows
>>
>
> ​Y si tienes instalado miktex, debes especificar el lugar donde se
> encuentra pdflatex en tu ordenador, que RStudio no lo encuentra. Aunque
> puede variar un poco según la versión del Windows que tengas, este enlace
> (hecho para Windows 7) puede serte de utilidad:
>
> http://stackoverflow.com/questions/27004849/object-pdflatex-
> not-found-on-windows-7
>
> ¡Salud!
>
>
> --
> «Pídeles sus títulos a los que te persiguen, pregúntales
> cuándo nacieron, diles que te demuestren su existencia.»
>
> Rafael Cadenas
>
>


-- 

*Mauricio Mardones Inostroza*

Investigador Departamento Evaluación de Recursos
Instituto de Fomento Pesquero - IFOP
Valparaíso - Chile
+56-32-21514 42

www.ifop.cl

[[alternative HTML version deleted]]

___
R-help-es mailing list
R-help-es@r-project.org
https://stat.ethz.ch/mailman/listinfo/r-help-es

[R] Extracting Monthly timeseries data for a defined period using ncdf4 package

2017-03-22 Thread കുഞ്ഞായി kunjaai
Dear All,

I am trying to extract a time series dataset from a netCDF file.

I want to extract data for the time period  1971-1  to 1990-12-31 only.

time axis units is  'days since 1850-1-1'

For one or two files I can use "count" argument,  but I have more than 100
such files and its time units are different.

Is there any easy way to extract the particular time period using ncdf4
package?

Thank you in advance.


-- 
DILEEPKUMAR. R
J R F, IIT DELHI

[[alternative HTML version deleted]]

__
R-help@r-project.org mailing list -- To UNSUBSCRIBE and more, see
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-es] xtable

2017-03-22 Thread Belén Cillero Jiménez
Buenos días
He hecho una tabla con xtable que tiene 28 filas y 5 columnas, quiero poner en 
negrita los elementos (1,1) y (15,1) y no veo como usar el comando adecuado de 
xtable
Muchas gracias



Belén Cillero Jiménez

Técnico de Estadística

Instituto de Estadística de La Rioja



bcill...@larioja.org

oɯsıɯ ol ǝɹdɯǝıs sɐƃɐɥ ou ,soʇuıʇsıp sopɐʇlnsǝɹ sɐɔsnq ıS



GOBIERNO DE LA RIOJA
AVISO LEGAL: La información contenida en este mensaje es confidencial y está 
destinada a ser leída sólo por la persona a la que va dirigida. Si Ud. no es el 
destinatario señalado le informamos que está prohibida, y puede ser ilegal, 
cualquier divulgación o reproducción de este mensaje.
Antes de imprimir este e-mail piense bien si es necesario hacerlo.

[[alternative HTML version deleted]]

___
R-help-es mailing list
R-help-es@r-project.org
https://stat.ethz.ch/mailman/listinfo/r-help-es

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

2017-03-22 Thread Achim Zeileis

On Wed, 22 Mar 2017, Michael Dayan wrote:


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.


Presently, flexmix() that betamix() is built on cannot take the parameters 
directly for initialization. However, it is possible to pass a matrix with 
initial 'cluster' probabilities. This can be easily generated using 
dbeta().


For a concrete example consider the data generated in this discussion on 
SO:


http://stats.stackexchange.com/questions/114959/mixture-of-beta-distributions-full-example

Using that data with random starting values requires 42 iterations until 
convergence:


set.seed(0)
m1 <- betamix(y ~ 1 | 1, data = d, k = 2)
m1

## Call:
## betamix(formula = y ~ 1 | 1, data = d, k = 2)
## 
## Cluster sizes:

##   1   2
##  50 100
## 
## convergence after 42 iterations


Instead we could initialize with the posterior probabilities obtained at 
the observed data (d$y), the true alpha/beta parameters (10; 30 vs. 30; 
10) and the true cluster proportions (2/3 vs. 1/3):


p <- cbind(2/3 * dbeta(d$y, 10, 30), 1/3 * dbeta(d$y, 30, 10))
p <- p/rowSums(p)

This converges after only 2 iterations:

set.seed(0)
m2 <- betamix(y ~ 1 | 1, data = d, k = 2, cluster = p)
m2

## Call:
## betamix(formula = y ~ 1 | 1, data = d, k = 2, cluster = p)
## 
## Cluster sizes:

##   1   2
## 100  50
## 
## convergence after 2 iterations


Up to label switching and small numerical differences, the parameter 
estimates agree. (Of course, these are on the mu/phi scale and not 
alpha/beta as explained in the SO post linked above.)


coef(m1)
##(Intercept) (phi)_(Intercept)
## Comp.11.196286  3.867808
## Comp.2   -1.096487  3.898976
coef(m2)
##(Intercept) (phi)_(Intercept)
## Comp.1   -1.096487  3.898976
## Comp.21.196286  3.867808



On Mar 22, 2017 04:30, "David Winsemius"  wrote:



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
maximum of 200 iterations and a tolerance of 1e-08.

My question is: how to use the betareg package to run the fit with initial
values for the parameters alpha1, beta1, alpha2, beta2 and lambda? I saw

in

the documentation that I would need to use the 'start' option of the
betareg function, with start described as "an optional vector with

starting

values for all parameters (including phi)". However I could not find how

to

define this list given my alpha1, beta1, alpha2, beta2 and lambda.

The current code I have is:
mydata$y <- 
bmix <- betamix(y ~ 1 | 1, data = mydata, k = 2, fstol = 1e-08, maxit =
200, fsmaxit = 200)


And I suspect I would need to do something along the lines:

initial.vals <- c(?, ?, ?, ?, ?)
bmix <- betamix(y ~ 1 | 1, data = mydata, k = 2, fstol = 1e-08, maxit =
200, fsmaxit = 200, control=betareg.control(start=initial.vals)))

But I do not know what to use for initial.vals.


If there were sensitivity to data, then wouldn't  that depend on your
(unprovided) data?




Best wishes,

Michael

  [[alternative HTML version deleted]]

__
R-help@r-project.org mailing list -- To UNSUBSCRIBE and more, see
https://stat.ethz.ch/mailman/listinfo/r-help
PLEASE do read the posting guide http://www.R-project.org/

posting-guide.html

and provide commented, minimal, self-contained, reproducible code.


David Winsemius
Alameda, CA, USA

[[alternative HTML version deleted]]

__
R-help@r-project.org mailing list -- To UNSUBSCRIBE and more, see
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@r-project.org mailing list -- To UNSUBSCRIBE and more, see
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] A request

2017-03-22 Thread PIKAL Petr
Hi

> -Original Message-
> From: R-help [mailto:r-help-boun...@r-project.org] On Behalf Of RAHUL
> 14BCE0064
> Sent: Monday, March 20, 2017 12:24 PM
> To: r-help@r-project.org
> Subject: [R] A request
>
> Hello there!!
>
> Could somebody please go through the question (
> http://stats.stackexchange.com/questions/268323/string-kernels-in-r)?
>

Page not found so no question to go through.


> In short I need the reference to the algorithms used for string kernels in
> Kernlab package in R.

There are plenty references in docs and if it is still not enough you can go 
through actual code.

Cheers
Petr


>
>
> Thank you.
>
> Regards:
> Rahul
>
>   [[alternative HTML version deleted]]
>
> __
> R-help@r-project.org mailing list -- To UNSUBSCRIBE and more, see
> 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.


Tento e-mail a jakékoliv k němu připojené dokumenty jsou důvěrné a jsou určeny 
pouze jeho adresátům.
Jestliže jste obdržel(a) tento e-mail omylem, informujte laskavě neprodleně 
jeho odesílatele. Obsah tohoto emailu i s přílohami a jeho kopie vymažte ze 
svého systému.
Nejste-li zamýšleným adresátem tohoto emailu, nejste oprávněni tento email 
jakkoliv užívat, rozšiřovat, kopírovat či zveřejňovat.
Odesílatel e-mailu neodpovídá za eventuální škodu způsobenou modifikacemi či 
zpožděním přenosu e-mailu.

V případě, že je tento e-mail součástí obchodního jednání:
- vyhrazuje si odesílatel právo ukončit kdykoliv jednání o uzavření smlouvy, a 
to z jakéhokoliv důvodu i bez uvedení důvodu.
- a obsahuje-li nabídku, je adresát oprávněn nabídku bezodkladně přijmout; 
Odesílatel tohoto e-mailu (nabídky) vylučuje přijetí nabídky ze strany příjemce 
s dodatkem či odchylkou.
- trvá odesílatel na tom, že příslušná smlouva je uzavřena teprve výslovným 
dosažením shody na všech jejích náležitostech.
- odesílatel tohoto emailu informuje, že není oprávněn uzavírat za společnost 
žádné smlouvy s výjimkou případů, kdy k tomu byl písemně zmocněn nebo písemně 
pověřen a takové pověření nebo plná moc byly adresátovi tohoto emailu případně 
osobě, kterou adresát zastupuje, předloženy nebo jejich existence je adresátovi 
či osobě jím zastoupené známá.

This e-mail and any documents attached to it may be confidential and are 
intended only for its intended recipients.
If you received this e-mail by mistake, please immediately inform its sender. 
Delete the contents of this e-mail with all attachments and its copies from 
your system.
If you are not the intended recipient of this e-mail, you are not authorized to 
use, disseminate, copy or disclose this e-mail in any manner.
The sender of this e-mail shall not be liable for any possible damage caused by 
modifications of the e-mail or by delay with transfer of the email.

In case that this e-mail forms part of business dealings:
- the sender reserves the right to end negotiations about entering into a 
contract in any time, for any reason, and without stating any reasoning.
- if the e-mail contains an offer, the recipient is entitled to immediately 
accept such offer; The sender of this e-mail (offer) excludes any acceptance of 
the offer on the part of the recipient containing any amendment or variation.
- the sender insists on that the respective contract is concluded only upon an 
express mutual agreement on all its aspects.
- the sender of this e-mail informs that he/she is not authorized to enter into 
any contracts on behalf of the company except for cases in which he/she is 
expressly authorized to do so in writing, and such authorization or power of 
attorney is submitted to the recipient or the person represented by the 
recipient, or the existence of such authorization is known to the recipient of 
the person represented by the recipient.
__
R-help@r-project.org mailing list -- To UNSUBSCRIBE and more, see
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-es] Alternativa a RStudio

2017-03-22 Thread Fernando Arce via R-help-es
No se porque se ha repetido un mensaje mio pero totalmente descuadrado 
quizas tenemos un "lord Vim" entre nosotros presto para inciar la enesima 
"emacs vs vim war"?
perdon por el chiste 

El Miércoles 22 de marzo de 2017 14:38, Fernando Arce via R-help-es 
 escribió:
 

 Estimado Javier.
A parte de los modos concretos que hay en R para trabajar con texto y codigo, 
en emacs tienes el modo .org que permite integrar codigo de diferentes 
lenguajes.
Aqui dejo un enlace donde se pueden descargar versiones actualizadas de emacs 
que vienen ya con el modo ess para windows y mac (y con el modo org.):Vincent 
Goulet - Emacs

  
|  
|  
|  
|  |    |

  |

  |
|  
|  |  
Vincent Goulet - Emacs
 De Vincent Goulet Site of Vincent Goulet, Ph.D., �cole d'actuariat of 
Universit� Laval. Research activities, development of R ...  |  |

  |

  |

 

Con eso debería instalar todo lo necesario, para windows o mac, con un par de 
clicks.Hay menus para trabajar con el raton y todo eso aunque basicos (no es un 
gran entorno gráfico), no se muy bien como eran porque los deshabilité para 
ganar espacio de trabajo en las pantallas. Al final te haces a los comandos, 
mucho mas practicos que los clicks de ratonsaludosFer


  

 El Miércoles 22 de marzo de 2017 12:55, "javier.ruben.marcu...@gmail.com" 
 escribió:
 

 #yiv9736703588 -- filtered {font-family:Helvetica;panose-1:2 11 5 4 2 2 2 2 2 
4;}#yiv9736703588 filtered {panose-1:2 4 5 3 5 4 6 3 2 4;}#yiv9736703588 
filtered {font-family:Calibri;panose-1:2 15 5 2 2 2 4 3 2 4;}#yiv9736703588 
p.yiv9736703588MsoNormal, #yiv9736703588 li.yiv9736703588MsoNormal, 
#yiv9736703588 div.yiv9736703588MsoNormal 
{margin:0cm;margin-bottom:.0001pt;font-size:11.0pt;}#yiv9736703588 a:link, 
#yiv9736703588 span.yiv9736703588MsoHyperlink 
{color:blue;text-decoration:underline;}#yiv9736703588 a:visited, #yiv9736703588 
span.yiv9736703588MsoHyperlinkFollowed 
{color:#954F72;text-decoration:underline;}#yiv9736703588 
.yiv9736703588MsoChpDefault {}#yiv9736703588 filtered {margin:70.85pt 3.0cm 
70.85pt 3.0cm;}#yiv9736703588 div.yiv9736703588WordSection1 {}#yiv9736703588 
Estimado Fernando Arce  Hace mucho que no uso Emacs, recuerdo que lo vi por 
primera vez cuándo compre una versión de suse 5.3, que instale en un Pentium 
III. Podría explorarlo, creo que está XEmacs con algo de entorno gráfico, la 
experiencia de usuario es nada que ver, lo que más me gusto (Linux y macosX) 
era texmacs, voy a ver si aún está, permitía tener texto (que pasaba a latex 
“solito”, y algo semejante a RStudio respecto a la posibilidad de colocar 
fragmentos de códigos, yo supe colocar parte de R, gnuplot, octave,  todo en el 
mismo archivo y se arreglaba solito, paso bastante tiempo, eran herramientas 
muy buenas, ya me había olvidado.  Javier Rubén Marcuzzi  De: Fernando Arce
Enviado: martes, 21 de marzo de 2017 21:31
Para: javier.ruben.marcu...@gmail.com
CC: R-help-es
Asunto: Re: [R-es] Alternativa a RStudio  Buenos dias, que tal?  yo utilizo 
emacs ess (emacs speaking statistics). Para mi es de lejos la mejor herramienta 
para interactuar con R. No es lo mas sencillo de aprender, por la naturaleza de 
emacs, pero es lo mas completo. ESS da soporte a R, S-Plus, JAGS, Julia y algun 
otro scripting software, pero emacs basicamente da soporte a todo. Por ejemplo, 
los tres "clasicos" que mas se utilizan en mi entorno, R, matlab y python, 
pueden ejecutarse desde emacs, lo cual es una ventaja tener un mismo entorno de 
trabajo y no tres diferentes, sobre todo si se utiliza mayoritariamente 1 como 
es mi caso.Sin embargo, no es tan utilizado por la curva de aprendizaje (uno de 
los nombres chistosos no oficiales de EMACS es "Escape Meta Alter Control 
Shift", en una mañana de trabajo no se cuantas veces podré presional las teclas 
Control, Alter o Shift, pero varios cientos (o miles) minimo).  No es algo que 
recomiende a todo el mundo, pero es una alternativa que a mi me satisface, no 
asi RStudio, que desinstalé del todo, y lo paso realmente mal cuando a veces 
interactuo con codigo en ordenadores de compañeros que tienen RStudio 
instalado. Me pasa como con ggplot2 (o con el tidyverse), aprendi a utilizar 
R-base para hacer graficos (bueno, sigo aprendiendo...) así que ahí me quedé. 
Llámame carroza o viejo, pero no me quites emacs :-D    De todos modos tu 
llevas ya tiempo usando R asi que podrias ser un potencial usuario de emacs, 
pero solo lo recomiendo a gente que pase la mayor parte de su jornada delante 
de R o escribiendo R.  Las demas alternativas tampoco las conozco demasiado 
como para opinar, probe bastantes (tinn-r, rackward etc...) y la unica que me 
gustó fue notepad++ con el plug-in  NtppToR.  Tinn-R recuerdo que era bastante 
"trendy" antes del advenimiento de R-Studio. Alguien lo usa?  Saludos  Fer  El 
Miércoles 22 de marzo de 2017 10:19, "javier.ruben.marcu...@gmail.com" 
 escribió:  Estimado Fernando


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

2017-03-22 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,
>
> 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 use the betareg package to run the fit with initial
> values for the parameters alpha1, beta1, alpha2, beta2 and lambda? I saw
in
> the documentation that I would need to use the 'start' option of the
> betareg function, with start described as "an optional vector with
starting
> values for all parameters (including phi)". However I could not find how
to
> define this list given my alpha1, beta1, alpha2, beta2 and lambda.
>
> The current code I have is:
> mydata$y <- 
> bmix <- betamix(y ~ 1 | 1, data = mydata, k = 2, fstol = 1e-08, maxit =
> 200, fsmaxit = 200)
>
>
> And I suspect I would need to do something along the lines:
>
> initial.vals <- c(?, ?, ?, ?, ?)
> bmix <- betamix(y ~ 1 | 1, data = mydata, k = 2, fstol = 1e-08, maxit =
> 200, fsmaxit = 200, control=betareg.control(start=initial.vals)))
>
> But I do not know what to use for initial.vals.

If there were sensitivity to data, then wouldn't  that depend on your
(unprovided) data?


>
> Best wishes,
>
> Michael
>
>   [[alternative HTML version deleted]]
>
> __
> R-help@r-project.org mailing list -- To UNSUBSCRIBE and more, see
> https://stat.ethz.ch/mailman/listinfo/r-help
> PLEASE do read the posting guide http://www.R-project.org/
posting-guide.html
> and provide commented, minimal, self-contained, reproducible code.

David Winsemius
Alameda, CA, USA

[[alternative HTML version deleted]]

__
R-help@r-project.org mailing list -- To UNSUBSCRIBE and more, see
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] string pattern matching

2017-03-22 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 + 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")
> [1] TRUE
> multigrep("x1 + x4","x1 + x2 + x3")
> [1] FALSE
>
> Jim
>
> On Wed, Mar 22, 2017 at 10:50 AM, Joe Ceradini 
> wrote:
> > 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 + x3"
> >
> > grep("x1 + x2", test, fixed=TRUE, value = TRUE)
> > [1] "x1 + x2 + x3"
> >
> >
> > But what if only have "x1 + x3" as the pattern and still want to
> > return "x1 + x2 + x3"?
> >
> > grep("x1 + x3", test, fixed=TRUE, value = TRUE)
> > character(0)
> >
> > I'm sure this looks like an odd question. I'm trying to build a
> > function and stuck on this. Rather than dropping the whole function on
> > the list, I thought I'd try one piece I needed help with...although I
> > suspect that this question itself probably does bode well for my
> > function :)
> >
> > Thanks!
> > Joe
> >
> > __
> > R-help@r-project.org mailing list -- To UNSUBSCRIBE and more, see
> > 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@r-project.org mailing list -- To UNSUBSCRIBE and more, see
> 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@r-project.org mailing list -- To UNSUBSCRIBE and more, see
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.