similar to: R API - optim

Displaying 20 results from an estimated 400 matches similar to: "R API - optim"

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
2006 Mar 29
1
calling R's optimization routines from C
Hi, I have read R's Writing Extensions manual and am still confused about how to use some of the routines there when I call from C. Specifically, I am writing a little test function which I will optimize using the nmmin function which underlies R's optim() with Nelder-Mead. I guess I wonder what library/header files I should be using. I was using R_ext/Applic.h and linking with libR but I
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,
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
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
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
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,
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
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,
2009 May 27
1
Constrained fits: y~a+b*x-c*x^2, with a,b,c >=0
I wonder whether R has methods for constrained fitting of linear models. I am trying fm<-lm(y~x+I(x^2), data=dat) which most of the time gives indeed the coefficients of an inverted parabola. I know in advance that it has to be an inverted parabola with the maximum constrained to positive (or zero) values of x. The help pages for lm do not contain any info on constrained fitting. Does anyone
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] =
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 Nov 05
1
relative convergence in 'optim'
Dear list, I have a question related to the correct interpretation of the relative convergence criterion used by 'optim'. In the help of the function is it written that: "reltol:Relative convergence tolerance. The algorithm stops if it is unable to reduce the value by a factor of reltol * (abs(val) + reltol) at a step." and I was wondering if the previous criterion is
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 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 Dec 17
2
nlme problems
I'm maximising a reasonably complex function using nlme (version 3.1-65, have also tried 3.1-66) and am having trouble with fixed parameter estimates slightly away from the maximum of the log likelihood. I have profiled the log likelihood and it is a parabola but with sum dips. Interestingly changing the parameterisation moves the dips around slightly. Unfortunately the PNLS step is
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
2005 Apr 20
2
how to get code of a .Internal() function?
Hello, I'm working with the function optim() from stats package, and inside this function is called the function .Internal(optim(....)) and I want to get the code of this function which would help me to understand why the Nelder-Mead algorithm doesn't converge with my data. I'm working under Windows XP. Could you reply to this adress because I don't belong to the mailing list