Calling newDArch in darch package - r

I am reading Learning bayes model with R, and I installed darch package. I get an error when running below code
library(darch)
darch <- newDArch(c(2,4,1),batchSize = 2,genWeightFunc = generateWeights)
The error is Error: could not find function "newDArch"
Can someone help me. Thank!

Related

Error in expand_dims(X_train, axis = 2) : attempt to apply non-function

I tried to use keras in R to do deep learning
trend_train <- ts(global_GDP[1:28,c(3)], start=c(1981), end=c(2008))
lstm_num_timesteps <- 5
X_train <- t(sapply(1:(length(trend_train) - lstm_num_timesteps),
function(x) trend_train[x:(x + lstm_num_timesteps - 1)]))
X_train[1:5, ]
X_train <- expand_dims(X_train, axis = 2)
When try to use expand_dims(), it showed error as follows
Error in expand_dims(X_train, axis = 2) : attempt to apply non-function
Couldn't figure out what's going on here as there is no wrong with the expand_dims(). Anyone could help? Thanks
I have come across the same issue trying to build an LSTM using Keras library in R.
expand_dims() seems to be a function from kerasR library https://rdrr.io/cran/kerasR/man/expand_dims.html
If you are using keras (not kerasR package), this function is not available. This corresponding function in keras package is k_expand_dims
I also realised that this only works with keras 2.1.2. I had to upgrade from v 2.0.9 to make this work.
Hope this helps.

doparallel package in caret train model under linux

I have a problem when I run the train function in caret with parallel processing, for example, when I run a simple R code like:
library(doParallel); cl <- makeCluster(4);
registerDoParallel(cl)
require(caret);data(BloodBrain);
set.seed(123)
fit1 <- train(bbbDescr, logBBB, "knn"); fit1
stopCluster(cl); registerDoSEQ();
I get this error message
Error in e$fun(obj, substitute(ex), parent.frame(), e$data) :
worker initialization failed: there is no package called ‘caret’
I installed last vesion of caret under R 3.3.0.
I installed the R version and caret version on windows, it is work.
any one have any suggestion about this??

Running GAM function from mgcv package with R 3.2.2

I have recently run into a problem running a GAM model from a previously working code. I believe it is related to an updated R-Version and an updated Version of the mgcv package. It would be great to know if anyone has the same problem or has a solution to it.
I am currently running R version 3.2.2 (2015-08-14) -- "Fire Safety"
on Windows. I am using the mgcv Package 1.8-7. Below is an example code that re-produces the error message, when run on my computer.
###Load package
library(mgcv)
This is mgcv 1.8-7.
###Simulate some example data
set.seed(2) ## simulate some data...
dat <- gamSim(1,n=400,dist="normal",scale=2)
###Run normal model
b <- gam(y~s(x0)+s(x1)+s(x2)+s(x3),data=dat, family=gaussian())
This works.
###change the smoothness selection method to REML
b0 <- gam(y~s(x0)+s(x1)+s(x2)+s(x3),data=dat,method="REML")
Gives the following error message:
Error in .C(C_gdi1, X = as.double(x[good, ]), E = as.double(Sr), Eb = as.double(Eb), : Incorrect number of arguments (48), expecting 47 for 'gdi1'
Thanks for your help!
I have re-installed R and the mgcv package and it seems as if this has resolved the issue.

Locked package namespace

I am using the "BMA" package in R 3.1.0, and get an error when running one of the functions in the package, iBMA.glm. When running the example in the package documentation:
## Not run:
############ iBMA.glm
library("MASS")
library("BMA")
data(birthwt)
y<- birthwt$lo
x<- data.frame(birthwt[,-1])
x$race<- as.factor(x$race)
x$ht<- (x$ht>=1)+0
x<- x[,-9]
x$smoke <- as.factor(x$smoke)
x$ptl<- as.factor(x$ptl)
x$ht <- as.factor(x$ht)
x$ui <- as.factor(x$ui)
### add 41 columns of noise
noise<- matrix(rnorm(41*nrow(x)), ncol=41)
colnames(noise)<- paste('noise', 1:41, sep='')
x<- cbind(x, noise)
iBMA.glm.out<- iBMA.glm( x, y, glm.family="binomial",
factor.type=FALSE, verbose = TRUE,
thresProbne0 = 5 )
summary(iBMA.glm.out)
I get the error:
Error in registerNames(names, package, ".__global__", add) :
The namespace for package "BMA" is locked; no changes in the global variables list may be made.
I get the error in RStudio running R 3.1.0 on Ubuntu.
on Windows 7, from RStudio and the R console I get a similar error:
Error in utils::globalVariables(c("nastyHack_glm.family", "nastyHack_x.df")) :
The namespace for package "BMA" is locked; no changes in the global variables list may be made.
I also get the same error when running my own data in the function. I'm not clear on what this error means and how to work around the error to be actually able to use the function. Any advice would be appreciated!

R rms package error when using rcs()

Been looking into Harrell's rms package for R and I am getting an error whenever I try to use the spline function rcs() inside a formula. This happens with all datasets. Is there some R setting I am missing?
library(rms)
df = read.csv("http://www.ats.ucla.edu/stat/data/binary.csv")
m = lrm(admit~ rcs(gre), df)
Error in rcspline.eval(x, nk = nknots, inclx = TRUE, pc = pc, fractied = fractied) :
unused argument (fractied = fractied)
What is "fractied"? I haven't been able to find a clear explanation.
I'm using Windows 7, R version 3.1.0, rms version 4.2.0

Resources