lloyd no_last_name
2014-Aug-22 18:00 UTC
[R] I cannot register but I have a burning Question about mcmcPack
I want to construct a simple MCMC Neural Net with normal errors library(nnet) nn.ts <- nnet( y=response, x = data.frame(result$bestColSpace), size = 2, skip = T, softmax=F, entropy=F, linout = T, maxit = 150, Hess = F, trace F, Wts=result$coefficients[[1]] ) L1Metric(nn.ts$residuals) [1] 0.6978838 # I created a maximum likelihood version of # my regular nn function *mcmcNN = function( proposed.nwts, # proposed wts in Neural Net * *y=result$response, # response vector * *X=result$bestColSpace ) # matrix same rows as y* *{ * result$coefficients = proposed.nwts uHat = pureNN( result )$fit; # expected values of the NN given X, y and proposed parms singlelikelihoods = dnorm(y, mean = uHat, sd = sd(x=(y-uHat)), log = T) LL = sum(singlelikelihoods) return( LL ); *} # end of function mcmcNN* # function for metropolis-hastings and I ran the Metropolis-hastings in library(mcmcPack); *post.samp <- MCMCmetrop1R( mcmcNN, theta.init = nn.ts$wts,* X=result$bestColSpace, y=response, V=NULL, # or =covV thin=4, mcmc=12000, burnin=12000, tune=rep( 0.55, length(nn.ts$wts) ), logfun=TRUE, force.samp=T ) # with each row of parms ( neural net weights ) in the posterior sample # I computed the fitted.values with my neural net function # next, I located the best fit of all of these 12,000 models # I even started init.theta with the nnet weights > minErr # from all proposed paramaters ( NN wts ) with fixed X and y [1] 0.8727279 This is significantly worse than nnet; The neural net, being nonlinear regression, is sensitive to initial values. Therefore, it will find a local minimum. I expected mcmc to return the global minimum ( average absolute deviation ). Thanx, Lloyd L Is there some way I can help R-users? [[alternative HTML version deleted]]