[R] Tackling of convergence issues in gamlss vs glm2

2018-05-10 Thread Nik Tuzov

Hello:

I'd like to know how and if the GLM convergence problems are addressed in 
gamlss.
For simplicity, let's focus on Normal and Negative Binomial with log link.
The convergence issues of the glm() function were alleviated in 2011 when glm2 
package was released.
Package gamlss was released in 2012, so it might still use the glm-like 
solution or call glm() directly. 
Is that the case or the improvements from glm2 have been incorporated into 
gamlss also?

Regards,
Nik

__
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] Learning advanced R

2018-03-13 Thread Nik Tuzov

Hello:

Could you please suggest the best way to become an "advanced" R programmer.
I went through "R for dummies" by de Vries and Meys and I can see two ways
to proceed:

1) Get a more advanced textbook. E.g. could you recommend Gentleman, 
"R for Bioinformatics"?

2) Because textbooks are limited and become obsolete fast, I can focus on 
learning state-of-the-art packages, 
but for that I need to find a list of most useful general purpose packages 
(foreach, doParallel, etc) that is
updated in real time. Does such list exist?

Your recommendations are very welcome.

Thanks,
Nik

__
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] Package gamlss used inside foreach() and %dopar% fails to find an object

2018-03-12 Thread Nik Tuzov

Hello Mikis:

Thanks a lot, it worked. Could you tell me what the problem was?

Regards,
Nik


- Original Message -
From: r-help-requ...@r-project.org
To: "r-help" 
Sent: Sunday, March 11, 2018 6:00:02 AM
Subject: R-help Digest, Vol 181, Issue 11

Send R-help mailing list submissions to
r-help@r-project.org

To subscribe or unsubscribe via the World Wide Web, visit
https://stat.ethz.ch/mailman/listinfo/r-help
or, via email, send a message with subject or body 'help' to
r-help-requ...@r-project.org

You can reach the person managing the list at
r-help-ow...@r-project.org

When replying, please edit your Subject line so it is more specific
than "Re: Contents of R-help digest..."


Today's Topics:

   1. . Package gamlss used inside foreach() and %dopar% fails to
  find an object (Nik Tuzov) (Dimitrios Stasinopoulos)
   2. error message from sqldf (Ding, Yuan Chun)
   3. Re: error message from sqldf
  (=?iso-8859-1?Q?Jos=E9_Mar=EDa?= Mateos)

--

Message: 1
Date: Sat, 10 Mar 2018 13:34:59 +
From: Dimitrios Stasinopoulos 
To: r-help@r-project.org
Cc: Nik ntuzov.com>
Subject: [R] . Package gamlss used inside foreach() and %dopar% fails
to find an object (Nik Tuzov)
Message-ID:
<424dc535-4caf-4dd5-8bd5-eb19bf6f7...@staff.londonmet.ac.uk>
Content-Type: text/plain; charset="utf-8"

Dear Nik 

Try the following code 


loo_predict.mu <- function(model.obj, input.data) {
  yhat <- foreach(i = 1 : nrow(input.data), .packages="gamlss", .combine = 
rbind) %dopar% {
updated.model.obj <- update(model.obj, data = input.data[-i, ])
predict(updated.model.obj, what = "mu", data = input.data[-i, ],
newdata = input.data[i,], type = "response")
  }
  return(data.frame(result = yhat[, 1], row.names = NULL))
}

par.run <- loo_predict.mu(model3, input.processed.cut)

The predict command in this case also need the old data.

Thanks
Mikis 



Prof Dimitrios Mikis Stasinopoulos
stasi...@staff.londonmet.ac.uk




[[alternative HTML version deleted]]




--

Message: 2
Date: Sat, 10 Mar 2018 21:30:42 +
From: "Ding, Yuan Chun" 
To: "r-help@r-project.org" 
Subject: [R] error message from sqldf
Message-ID:
coh.org>
Content-Type: text/plain; charset="utf-8"

Dear R users,

I got the following error message from running sqldf code in R.   do you know 
how to fix it?  I read the sqldf package instruction and did not find a 
solution.

Thank you,

Ding

chr10 <- sqldf("select * from manifest where CHR==10")

UCN3cpg <-  sqldf("select * from chr10 where MAPINFO between 5405573 and 
5407594),
overwrite = TRUE")
Error: Table chr10 exists in database, and both overwrite and append are FALSE


>





-
-SECURITY/CONFIDENTIALITY WARNING-
This message (and any attachments) are intended solely f...{{dropped:22}}




--

Message: 3
Date: Sat, 10 Mar 2018 16:53:35 -0500
From: =?iso-8859-1?Q?Jos=E9_Mar=EDa?= Mateos 
To: r-help@r-project.org
Subject: Re: [R] error message from sqldf
Message-ID: <20180310215335.GD5049@equipaje>
Content-Type: text/plain; charset="iso-8859-1"

On Sat, Mar 10, 2018 at 09:30:42PM +, Ding, Yuan Chun wrote:
> chr10 <- sqldf("select * from manifest where CHR==10")
> 
> UCN3cpg <-  sqldf("select * from chr10 where MAPINFO between 5405573 and 
> 5407594),
> overwrite = TRUE")
> Error: Table chr10 exists in database, and both overwrite and append are FALSE

Could it be that `chr10` already exists when you try to run your code. 
What about rewriting it as:

chr10 <- sqldf("select * from manifest where CHR==10", overwrite = TRUE)

Also, it seems to me that the second line is not closing the quotes 
properly. Shouldn't this be correct instead?

UCN3cpg <-  sqldf("select * from chr10 where MAPINFO between 5405573 and 
5407594",
  overwrite = TRUE)

Cheers,

-- 
José María (Chema) Mateos
https://rinzewind.org/blog-es || https://rinzewind.org/blog-en




--

Subject: Digest Footer

___
R-help@r-project.org mailing list
https://stat.ethz.ch/mailman/listinfo/r-help
PLEASE do read the posting guide http://www.R-project.org/posting-guide.html
and provide commented, minimal, self-contained, reproducible code.


--

End of R-help Digest, Vol 181, Issue 11

__
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] Package gamlss used inside foreach() and %dopar% fails to find an object

2018-03-09 Thread Nik Tuzov

Hello Jeff:

Thanks for replying.
I made a mistake in my original post.
The same error is generated with %do% as well, so it seems to be gamlss-related.

Nik


- Original Message -
From: "Jeff Newmiller" 
To: "r-help" , "Nik Tuzov" 
Sent: Friday, March 9, 2018 11:16:21 AM
Subject: Re: [R] Package gamlss used inside foreach() and %dopar% fails to find 
an object

If the code you are running in parallel is complicated, maybe foreach is not 
sophisticated enough to find all the variables you refer to. Maybe use 
parallel::clusterExport yourself? But be a aware that passing parameters is 
much safer than directly accessing globals in parallel processing, so this 
might just be your warning to not do that anyway. 
-- 
Sent from my phone. Please excuse my brevity.

On March 9, 2018 7:50:44 AM PST, Nik Tuzov  wrote:
>
>Hello all:
>
>Please help me with this "can't find object" issue. I'm trying to get
>leave-one-out predicted values for Beta-binomial regression.  
>It may be the gamlss issue because the code seems to work when %do% is
>used. I have searched for similar issues, but haven't managed to figure
>it out. This is on Windows 10 platform.
>
>Thanks in advance,
>Nik
>
># --
>
>library('gamlss')
>library('foreach')
>library('doParallel')
>
>registerDoParallel(cores = 4)
># Generate data
>set.seed(314)
>sample.size <- 30
>input.processed.cut <- data.frame(TP = round(runif(sample.size) * 100),
>
> FP = round(runif(sample.size) * 100), 
>  x = runif(sample.size))
># Fit Beta-binomial
>model3 <- gamlss(formula = cbind(TP, FP) ~ x,   
> family = BB,  
> data = input.processed.cut) 
>
># Get the leave-one-out values
>loo_predict.mu <- function(model.obj, input.data) {
>yhat <- foreach(i = 1 : nrow(input.data), .packages="gamlss", .combine
>= rbind) %dopar% {
>updated.model.obj <- update(model.obj, data = input.data[-i, ])
>predict(updated.model.obj, what = "mu", newdata = input.data[i,], type
>= "response")
>  }
>  return(data.frame(result = yhat[, 1], row.names = NULL))
>}
>
>par.run <- loo_predict.mu(model3, input.processed.cut)
>
># Error in { : task 1 failed - "object 'input.data' not found" 
>
>#
>
>
>> version
>   _   
>platform   x86_64-w64-mingw32  
>arch   x86_64  
>os mingw32 
>system x86_64, mingw32 
>status 
>major  3   
>minor  4.3 
>year   2017
>month  11  
>day30  
>svn rev73796   
>language   R   
>version.string R version 3.4.3 (2017-11-30)
>nickname   Kite-Eating Tree
>
>__
>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] Package gamlss used inside foreach() and %dopar% fails to find an object

2018-03-09 Thread Nik Tuzov

Hello all:

Please help me with this "can't find object" issue. I'm trying to get 
leave-one-out predicted values for Beta-binomial regression.  
It may be the gamlss issue because the code seems to work when %do% is used. I 
have searched for similar issues, but haven't managed to figure it out. This is 
on Windows 10 platform.

Thanks in advance,
Nik

# --

library('gamlss')
library('foreach')
library('doParallel')

registerDoParallel(cores = 4)
# Generate data
set.seed(314)
sample.size <- 30
input.processed.cut <- data.frame(TP = round(runif(sample.size) * 100), 
  FP = round(runif(sample.size) * 100), 
  x = runif(sample.size))
# Fit Beta-binomial
model3 <- gamlss(formula = cbind(TP, FP) ~ x,   
 family = BB,  
 data = input.processed.cut) 

# Get the leave-one-out values
loo_predict.mu <- function(model.obj, input.data) {
  yhat <- foreach(i = 1 : nrow(input.data), .packages="gamlss", .combine = 
rbind) %dopar% {
updated.model.obj <- update(model.obj, data = input.data[-i, ])
predict(updated.model.obj, what = "mu", newdata = input.data[i,], type = 
"response")
  }
  return(data.frame(result = yhat[, 1], row.names = NULL))
}

par.run <- loo_predict.mu(model3, input.processed.cut)

# Error in { : task 1 failed - "object 'input.data' not found" 

# 

> version
   _   
platform   x86_64-w64-mingw32  
arch   x86_64  
os mingw32 
system x86_64, mingw32 
status 
major  3   
minor  4.3 
year   2017
month  11  
day30  
svn rev73796   
language   R   
version.string R version 3.4.3 (2017-11-30)
nickname   Kite-Eating Tree

__
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.