r - Optimizing a simple linear curve (constant and coefficient estimated from a regression) -


i trying calculate turning point of a few functions have estimated coefficient , constant regression. i'm using optimize function curves linear.

my function looks like: f<- function(x){    beta* x + alpha } 

mind: beta , alpha both vectors here. when running optimisation optimize, i'm getting following error:

 error in optimize(f, interval = c(10, 20), lower = (10),  :        invalid function value in 'optimize' 

is because optimize running optimisation mathematically, beta , alphas need single parameters? if knows better way of doing please contribute!

thank in advance :)

if functions linear, @ minimum @ lower end of range beta>=0, , @ upper end of range if beta<=0 - no need use optimize().

it's not entirely clear you're expecting code - if want return x each set of parameters, @ optim() instead , have f return sum, or run optimize on each set of parameters in turn using apply() function or loop.

one other thing syntax bit wonky - imagine mean:

> f<- function(x){ +     beta* x + alpha + } > alpha <- 1 > beta <- 2 > optimize(f,c(10,20)) $minimum [1] 10.00006  $objective [1] 21.00011 

Comments

Popular posts from this blog

javascript - gulp-nodemon - nodejs restart after file change - Error: listen EADDRINUSE events.js:85 -

Fatal Python error: Py_Initialize: unable to load the file system codec. ImportError: No module named 'encodings' -

javascript - oscilloscope of speaker input stops rendering after a few seconds -