similar to: calling R's optimization routines from C

Displaying 20 results from an estimated 500 matches similar to: "calling R's optimization routines from C"

2006 Apr 13
1
bus error on calling nmmin
Hi, I'm trying to get a toy program making use of nmmin to run successfully. I've gotten to the point of compiling. However, when I attempt to run my executable, I guess a bus error. I see that someone else has asked about using nmmin before <http://tolstoy.newcastle.edu.au/R/help/06/03/23944.html>, but I haven't come across any replies. Is there some documentation on how to
2007 Oct 13
1
R API - optim
I am trying to use the R API to call optim functions (nmmin, vmmin, lbfgsb, etc.) through a C program but I couldn't find the shared library to link under the R-2.6.0 build which is compiled under Linux (REL5). main.cpp:35: undefined reference to `Rf_initEmbeddedR(int, char**)' main.cpp:41: undefined reference to `nmmin' Thanks in advance for any help. ------------------------
2008 Oct 31
0
R help for invoking nmmin()
My code is as follows: #include <iostream> #include <cmath> using namespace std; #define MATHLIB_STANDALONE 1 extern "C" { #include "R_ext/Applic.h" } typedef struct TT{ double ** tempX; double * tempY; int tempN; } TT, *MM; double fn(int N, double * beta, void * ex){ double total = 0; int i = 0,j = 0; double * betaFn = new double[N]; MM tmp = (MM)ex;
2008 Oct 03
1
Memory crash
Hello, I get a segfault when running glmmboot in my own package glmmML. Has happened many time before, but this time I get no hint of where in my C functions the error might be. I give the output below. Can this be an R bug? I suspect it has to do with repeated calls to 'vmmin' like this: for (...){ vmax = vmaxget(); vmmin(*p, b, &Fmin, bfun,
2006 Mar 24
0
using R's optimization routines from C
Dear all, I have been trying to use R's optimization routines from C and I have some questions. Specifically, I am testing the usage of nmmin which performs Nelder-Mead optimization in order to learn how to do the above exercise. I understand from the notes in Chapter 5 that the declaration for both optimfn as well as nmmin are included in the header file R_ext/Applic.h so I have included
2005 Mar 09
1
nnet abstol
Hi, I am using nnet to learn transfer functions. For each transfer function I can estimate the best possible Mean Squared Error (MSE). So, rather than trying to grind the MSE to 0, I would like to use abstol to stop training once the best MSE is reached. Can anyone confirm that the abstol parameter in the nnet function is the MSE, or is it the Sum-of-Squares (SSE)? Best regards, Sam.
2008 Mar 07
1
parameters for lbfgsb (function for optimization)
Can anyone help me with lbfgsb (function for optimization)? It takes the following parameters: void lbfgsb (int n, int lmm, double *x, double *lower, double *upper, int *nbd, double *Fmin, optimfn fn, optimgr gr, int *fail, void *ex, double factr, double pgtol, int *fncount, int *grcount, int maxit, char *msg, int trace, int nREPORT); What do I put for parameter ex (11th parameter)? I looked at
2009 Nov 02
2
a prolem with constrOptim
Hi, I apologize for the long message but the problem I encountered can't be stated in a few lines. I am having some problems with the function constrOptim. My goal is to maximize the likelihood of product of K multinomials, each with four catagories under linear constraints on the parameter values. I have found that the function does not work for many data configurations. #The likelihood
2009 Mar 25
2
Listing of LAPACK error codes
Professor Ripley commented on LAPACK error codes: https://stat.ethz.ch/pipermail/r-help/2007-March/127702.html and says "Internal LAPACK errors are usually problems with arithmetic accuracy, and as such are compiler- and CPU-specific." Is there a listing for the error codes from Lapack routine 'dsyevr'? Especially I am interested about the meaning and handling of error codes 1
2012 Jan 05
2
difference of the multinomial logistic regression results between multinom() function in R and SPSS
Dear all, I have found some difference of the results between multinom() function in R and multinomial logistic regression in SPSS software. The input data, model and parameters are below: choles <- c(94, 158, 133, 164, 162, 182, 140, 157, 146, 182); sbp <- c(105, 121, 128, 149, 132, 103, 97, 128, 114, 129); case <- c(1, 3, 3, 2, 1, 2, 3, 1, 2, 2); result <- multinom(case ~ choles
2004 Oct 18
1
nnet learning
Hi, I am trying to make a neural network learning a "noisy sine wave". Suppose I generate my data like so.. x <- seq(-2*pi, 2*pi, length=500) y <- sin(x) + rnorm(500, sd=sqrt(0.075)) I then train the neural net on the first 400 points using c <- nnet(as.matrix(x[1:400]),as.matrix(y[1:400]), size=3, maxit=10000, abstol=0.075, decay=0.007) Inspecting the fit of the training
2012 Oct 10
1
"optim" and "nlminb"
#optim package estimate<-optim(init.par,Linn,hessian=TRUE, method=c("L-BFGS-B"),control = list(trace=1,abstol=0.001),lower=c(0,0,0,0,-Inf,-Inf,-Inf,-Inf,-Inf,-Inf,-Inf,-Inf,-Inf),upper=c(1,1,1,1,Inf,Inf,Inf,Inf,Inf,Inf,Inf,Inf,Inf)) #nlminb package estimate<-nlminb(init.par,Linn,gr=NULL,hessian=TRUE,control =
2012 Oct 28
0
lbfgsb from C
Hi, I wanted to use R's lbfgsb method for minimization from C. Unfortunately, my toy examples always crashes (segmentation fault). What's wrong with it? double eval(int n, double* par, void *ex) { double result = 0; for (int i=0; i<n; ++i) { result += par[i]*par[i]; } printf("result=%.2f\n", result); return result; } void grad(int n, double *par, double *gr,
2007 Oct 23
0
API for optimization with Simulated annealing
Dear list, I was trying to use the R API for optimization method "Simulated annealing" void samin(int n, double *x, double *Fmin, optimfn fn, int maxit, int tmax, double temp, int trace, void *ex); but I encountered the following problem: The implementation of the function samin (as seen in src/main/optim.c) passes its void * argument "ex" into the function
2005 Apr 13
0
abstol in nnet
Hello All, I would like to know what fit criterion (abstol arg) is in nnet. Is it the threshold for the difference btw the max output and target values? Is the value at each iteration also the difference btw max of output and target values over all output units (case of multiple classes)? How could value displayed at each iteration be related to SSE and abstol be related to threshold SSE,
2004 Sep 30
1
polr (MASS) and lrm (Design) differences in tests of statistical signifcance
Greetings: I'm running R-1.9.1 on Fedora Core 2 Linux. I tested a proportional odds logistic regression with MASS's polr and Design's lrm. Parameter estimates between the 2 are consistent, but the standard errors are quite different, and the conclusions from the t and Wald tests are dramatically different. I cranked the "abstol" argument up quite a bit in the polr
2008 Jul 05
3
Editing the "..." argument
Dear all, I'd like tweaking the ... arguments that one user can pass in my function for fitting a model. More precisely, my objective function is (really) problematic to optimize using the "optim" function. Consequently, I'd like to add in the "control" argument of the latter function a "ndeps = rep(something, #par)" and/or "parscale =
2012 Jun 08
0
Working with optim in C
I've searched to find examples of how to work with the C versions of optim. I've separated out the function just to test on it alone, and currently I'm attempting to use fmmin as follows: !~~CODE ~~! double optimfn(int n, double *par, void *ex) { double * lambda = (double*)malloc(sizeof(double)*n); double sum = 0; for(int i =0; i < n; i++) { lambda[i] =
2006 Nov 30
0
Preventing early stopping in neural network (nnet package)
Hello there, I'm back again with another question about the neural network package. I'm having trouble getting the network to run for the maximum number of iterations. It always stops early, usually after 100 iterations claiming to have converged at an answer. Now, for my purposes I want it to run for the entire number of epochs, and I'm been looking at modifying the abstol
2007 Jan 19
8
kate editor for R
Like kile for LaTeX, Linux/KDE's kate editor is an excellent editor for R, with easy code submission to a running R process. Syntax highlighting is good. I have not been able to figure out two things: - how to automatically reformat a line or region of text using good indentation rules (Emacs/ESS make this so easy by just hitting Tab while the cursor is in a line, or highlighting a