Re: [R] Is it possible to create such graph - Which packages can come handy?
Thanks Jean, let me have a look! On Tue, Dec 20, 2016 at 9:49 AM, Adams, Jean <jvad...@usgs.gov> wrote: > You might find the code in this blog post helpful. > http://theanalyticalminds.blogspot.com/2015/03/part-3a-plotting-with-ggplot2.html > > Scroll down to "Analysing the temperature by month - violin geom with > jittered points overlaid". > > This shows a series of violin plots, which is another way to display the > shape of a distribution. > > Jean > > On Tue, Dec 20, 2016 at 9:04 AM, Narendra Modi <bjpmodi2...@gmail.com> > wrote: >> >> Hello Gurus, >> I intend to build attached reference graph in R(r.png). Could you give >> me some ideas on how it can be done, if at all possible? >> >> Basically, I would like to build a Histogram along Y axis for >> different respective X axis ranges. >> As shown in the input.png file, there is a value of EUR for every Lw, >> a simple X-Y scatter plot. >> Now, what if I build ranges of x axis values, i.e 2000-4000, >> 4000-6000, 6000-8000 etc and analyze the histograms of Y axis values >> for those ranges? >> >> Thanks! >> >> __ >> R-help@r-project.org mailing list -- To UNSUBSCRIBE and more, see >> https://stat.ethz.ch/mailman/listinfo/r-help >> PLEASE do read the posting guide >> http://www.R-project.org/posting-guide.html >> and provide commented, minimal, self-contained, reproducible code. > > __ R-help@r-project.org mailing list -- To UNSUBSCRIBE and more, see https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.
[R] Is it possible to create such graph - Which packages can come handy?
Hello Gurus, I intend to build attached reference graph in R(r.png). Could you give me some ideas on how it can be done, if at all possible? Basically, I would like to build a Histogram along Y axis for different respective X axis ranges. As shown in the input.png file, there is a value of EUR for every Lw, a simple X-Y scatter plot. Now, what if I build ranges of x axis values, i.e 2000-4000, 4000-6000, 6000-8000 etc and analyze the histograms of Y axis values for those ranges? Thanks! __ R-help@r-project.org mailing list -- To UNSUBSCRIBE and more, see https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.
Re: [R] Optimize selected variables but not all - nloptr
Thanks Prof Nash. The reason I used nlopr() in my problem is due to non linear constraints. I wonder if optimrx/optim can model the below scenario. I will be elated if it can. The problem in hand goes like this: There are 2 injectors and 2 producers. Consider these as some entity. I have an actual dataset, Act.Matrix; assume row=50, col=2. The predicted dataset is calculated by using the attached equation, i.e for each row of the prediction, that equation is used. The parameters to be evaluated are Tau, and a set of Fij's such that sum of Fij's <=1 . Fij represents connectivity between each inj to each prod, hence for this example there will be a total of 4 fij. and 2 tau (one tau for each producer) The lb for each parameter that I provided is 0 and ub as Inf TAU fijfij2 >> [1,] 14.3 0.010.01449572 >> [2,] 14.3 0.2 0. The constraints being Sum of each column of Fij<=1. With nloptr (algorithm NLOPT_LN_COYLA) , I am able to solve it to some extent. but when the dataset is scaled (consider having 50 producers and 25 injectors!! ), the number of variables to be solved is much higher! Do you think OPTIMX/OPTIMRX can handle non linear constraints like that? if it can then I can definitely use the MASKED parameters. NM On Wed, Oct 19, 2016 at 8:48 PM, ProfJCNash <profjcn...@gmail.com> wrote: > I refer to such parameters as "masked" in my 2014 book Nonlinear parameter > optimization with R tools. > Recently I put package optimrx on R-forge (and optimr with fewer solvers on > CRAN) that allows for masks with > all the parameters. The masks can be specified as you suggest with > start=lower=upper. However, for reasons > I won't go into here, nloptr solvers are not yet included. However, I suspect > either Rvmmin or Rcgmin will > work fine. > > I will guess that nloptr does NOT cater for masks. > > JN > > On 16-10-19 05:59 PM, Narendra Modi wrote: >> Hello All, >> I have a matrix with initial values as below and I need to optimize >> the variables that are greater than 0. >> >> TAU fij fij2 >> [1,] 14.33375 0.000 0.01449572 >> [2,] 14.33375 0.000 0. >> [3,] 14.33375 0.000 0. >> [4,] 14.33375 0.000 0.02206446 >> [5,] 14.33375 0.000 0. >> [6,] 14.33375 0.000 0. >> [7,] 14.33375 0.000 0. >> [8,] 14.33375 0.8279846 0. >> [9,] 14.33375 0.000 0.03695833 >> [10,] 14.33375 0.000 0. >> >> Or structure(c(14.3337481730129, 14.3337481730129, 14.3337481730129, >> 14.3337481730129, 14.3337481730129, 14.3337481730129, 14.3337481730129, >> 14.3337481730129, 14.3337481730129, 14.3337481730129, 0, 0, 0, >> 0, 0, 0, 0, 0.827984553120177, 0, 0, 0.0144957197835888, 0, 0, >> 0.0220644627842788, 0, 0, 0, 0, 0.0369583294835073, 0), .Dim = c(10L, >> 3L), .Dimnames = list(NULL, c("TAU", "fij", "fij2"))) >> >> Is it possible to provide lowerbound and upperbound as 0 for variables >> (< 0 in the initial matrix) and nloptr will consider them "unchanged" >> during optimization? >> >> Rstudio crashes when I try to do that. Is this a bug or I should >> approach it differently? >> >> NM >> >> __ >> R-help@r-project.org mailing list -- To UNSUBSCRIBE and more, see >> https://stat.ethz.ch/mailman/listinfo/r-help >> PLEASE do read the posting guide http://www.R-project.org/posting-guide.html >> and provide commented, minimal, self-contained, reproducible code. >> > > __ > R-help@r-project.org mailing list -- To UNSUBSCRIBE and more, see > https://stat.ethz.ch/mailman/listinfo/r-help > PLEASE do read the posting guide http://www.R-project.org/posting-guide.html > and provide commented, minimal, self-contained, reproducible code. __ R-help@r-project.org mailing list -- To UNSUBSCRIBE and more, see https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.
[R] Optimize selected variables but not all - nloptr
Hello All, I have a matrix with initial values as below and I need to optimize the variables that are greater than 0. TAU fij fij2 [1,] 14.33375 0.000 0.01449572 [2,] 14.33375 0.000 0. [3,] 14.33375 0.000 0. [4,] 14.33375 0.000 0.02206446 [5,] 14.33375 0.000 0. [6,] 14.33375 0.000 0. [7,] 14.33375 0.000 0. [8,] 14.33375 0.8279846 0. [9,] 14.33375 0.000 0.03695833 [10,] 14.33375 0.000 0. Or structure(c(14.3337481730129, 14.3337481730129, 14.3337481730129, 14.3337481730129, 14.3337481730129, 14.3337481730129, 14.3337481730129, 14.3337481730129, 14.3337481730129, 14.3337481730129, 0, 0, 0, 0, 0, 0, 0, 0.827984553120177, 0, 0, 0.0144957197835888, 0, 0, 0.0220644627842788, 0, 0, 0, 0, 0.0369583294835073, 0), .Dim = c(10L, 3L), .Dimnames = list(NULL, c("TAU", "fij", "fij2"))) Is it possible to provide lowerbound and upperbound as 0 for variables (< 0 in the initial matrix) and nloptr will consider them "unchanged" during optimization? Rstudio crashes when I try to do that. Is this a bug or I should approach it differently? NM __ R-help@r-project.org mailing list -- To UNSUBSCRIBE and more, see https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.
Re: [R] Share R.net dll without having to share R script code?
Hi Bob, Could you explain a bit more on this? How do I use/configure base64? Any document/example do you have? On Fri, Oct 14, 2016 at 9:55 AM, Bob Rudis <b...@rud.is> wrote: > Ugly idea/option, but you could base64 encode the R script (solely to > avoid the need to do string quoting) and have that string in the > source of the R.net code, then pass it in to the eval portion or write > it out to a temp dir and pass that to the eval portion of the code. > That way the script is embedded with the DLL and not an extra asset > that needs to be managed. > > On Fri, Oct 14, 2016 at 10:43 AM, Narendra Modi <bjpmodi2...@gmail.com> wrote: >> Thanks Duncan. That's useful to know. >> >> On Fri, Oct 14, 2016 at 9:18 AM, Duncan Murdoch >> <murdoch.dun...@gmail.com> wrote: >>> On 14/10/2016 10:00 AM, Narendra Modi wrote: >>>> >>>> Hello Gurus, >>>> >>>> I have built a code snippet using R.net wherein I call couple of R >>>> scripts to run optimization packages and use the output in C# code. >>>> The way I call the R scripts is just by providing its location in the >>>> C# code. >>>> >>>> So, if I have to share the .dll of the complete program, I will also >>>> have to share the R scripts; actual code. Is there anyway to avoid it; >>>> not having to share the r script code with users/testers. >>>> I am considerably new to R. Any suggestion in this direction is >>>> appreciated! >>>> >>> >>> I don't know what the R.net .dll is, but if it includes R, you need to share >>> the complete source code of anything you distribute that includes it. The R >>> scripts will be only a small part of that. >>> >>> Sharing less than that is a copyright violation, since you are only licensed >>> to distribute R under the GPL license, and it requires that you share code >>> of the original and your modifications. >>> >>> Duncan Murdoch >>> >> >> __ >> R-help@r-project.org mailing list -- To UNSUBSCRIBE and more, see >> https://stat.ethz.ch/mailman/listinfo/r-help >> PLEASE do read the posting guide http://www.R-project.org/posting-guide.html >> and provide commented, minimal, self-contained, reproducible code. __ R-help@r-project.org mailing list -- To UNSUBSCRIBE and more, see https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.
[R] lb and ub for variables - nloptr
Hello All, I use nloptr to perform optimization. In one example,the lb for each variable is 0 and ub is Inf during the first run. x <- c(10,10,10,10) # initial values lb <- c(0,0,0,0) ub <- c(Inf,Inf,Inf,Inf) optimised.answer = 4.2,0.001,20,21 To run the second time for a better match, I set a condition in the ub matrix saying if the value of any of optimized variable in the first run is less than 0.01, set the ub for that variable as 0; both lb and ub for that variable is 0. So I expect that during the second run, this variable is not varied by the optimizer at all. i.e. new.x <- c(4.2,0,20,21) But when I run the optimizer the second time with the "new.x",all the above variable is still varied by the optimizer! Is there anyway to not have the second variable varied? NM __ R-help@r-project.org mailing list -- To UNSUBSCRIBE and more, see https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.
Re: [R] Share R.net dll without having to share R script code?
Thanks Duncan. That's useful to know. On Fri, Oct 14, 2016 at 9:18 AM, Duncan Murdoch <murdoch.dun...@gmail.com> wrote: > On 14/10/2016 10:00 AM, Narendra Modi wrote: >> >> Hello Gurus, >> >> I have built a code snippet using R.net wherein I call couple of R >> scripts to run optimization packages and use the output in C# code. >> The way I call the R scripts is just by providing its location in the >> C# code. >> >> So, if I have to share the .dll of the complete program, I will also >> have to share the R scripts; actual code. Is there anyway to avoid it; >> not having to share the r script code with users/testers. >> I am considerably new to R. Any suggestion in this direction is >> appreciated! >> > > I don't know what the R.net .dll is, but if it includes R, you need to share > the complete source code of anything you distribute that includes it. The R > scripts will be only a small part of that. > > Sharing less than that is a copyright violation, since you are only licensed > to distribute R under the GPL license, and it requires that you share code > of the original and your modifications. > > Duncan Murdoch > __ R-help@r-project.org mailing list -- To UNSUBSCRIBE and more, see https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.
[R] Share R.net dll without having to share R script code?
Hello Gurus, I have built a code snippet using R.net wherein I call couple of R scripts to run optimization packages and use the output in C# code. The way I call the R scripts is just by providing its location in the C# code. So, if I have to share the .dll of the complete program, I will also have to share the R scripts; actual code. Is there anyway to avoid it; not having to share the r script code with users/testers. I am considerably new to R. Any suggestion in this direction is appreciated! Regards, NM __ R-help@r-project.org mailing list -- To UNSUBSCRIBE and more, see https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.
[R] Optimization issue - Solution converges for any initial value
I have put together a R snippet wherein I am trying to get optimum values for which error is minimized. The error is the difference between two matrices. Every time I run the below code, I don't see any optimization happening as in the final answer is the same as the initial estimate regardless of what I mention as initial estimate. Could you please advise on how can I improve it? I have also tried using nloptr but to no avail. To optimize vp.kval my.data.matrix.prod <- matrix(a,nrow = length(a),1) Estimated.Qt.mat <- matrix(b,nrow = nrow(my.data.matrix.prod), ncol = 1) Cum.WInj.matrix <- matrix (c,nrow = nrow(my.data.matrix.prod), ncol = 1) Koval.tD <- matrix(,nrow = nrow(my.data.matrix.prod), ncol = 1) # tD Matrix Koval.fw <- matrix(,nrow = nrow(my.data.matrix.prod), ncol = 1) # fw Matrix Koval.Error.func <- function(vp.kval,n) { #First convert vector(Koval.InitialData.list) to MATRIX and send it to calculate estimated matrix Koval.InitialData.Matrix <- matrix(vp.kval,nrow = 2, 1,byrow = TRUE) # Define Koval Parameters Matrix for the "n" Qo.Koval <- Qo.Koval(Koval.InitialData.Matrix) # Get Qo Estimation from Koval diff.values <- my.data.matrix.prod[,n] - Qo.Koval #FIND DIFFERENCE BETWEEN CAL. MATRIX AND ORIGINAL MATRIX Error <- ((colSums ((diff.values^2), na.rm = TRUE, dims = 1))/nrow(my.data.matrix.prod))^0.5#sum of square root of the diff Error # return error value } Qo.Koval <- function(Koval.InitialData.Matrix) { Qo.Koval.Est <- matrix(,nrow(my.data.matrix.prod), 1) #ncol(my.data.matrix.prod) for(rowno in 1:nrow(my.data.matrix.prod)) #number of rows of data { Koval.tD[rowno,1] = Cum.WInj.matrix[rowno,1] * Koval.InitialData.Matrix[1,1] # Evaluate tD matrix if(Koval.tD[rowno,1] < (1/Koval.InitialData.Matrix[2,1])) { Koval.fw[rowno,1] = 0 } else { if(Koval.tD[rowno,1] > Koval.InitialData.Matrix[2,1]) { Koval.fw[rowno,1] = 1 }else { Koval.fw[rowno,1] = (Koval.InitialData.Matrix[2,1] - sqrt(Koval.InitialData.Matrix[2,1]/Koval.tD[rowno,1]))/(Koval.InitialData.Matrix[2,1]-1) } } Qo.Koval.Est[rowno,1] = Koval.fw[rowno,1] * Estimated.Qt.mat[rowno,1] } Qo.Koval.Est# Return Estimated matrix } vp.kval <- c(10,1) #initial estimate Koval.lb = c(0,0) Koval.ub = c(Inf,Inf) n <- 1 Koval.result <- optim(vp.kval,Koval.Error.func, method = "L-BFGS-B", lower = Koval.lb, upper = Koval.ub, n=n) print(paste(Koval.result$convergence)) print(paste(Koval.result$par)) Here is the input data: a: structure(c(414, 40, 639, 616, 677, 598, 586, 494, 322, 351, 322, 213, 395, 358, 406, 384, 409, 404, 370, 376, 412, 404, 369, 391, 341, 350, 349, 313, 302, 196, 386, 330, 350, 323, 454, 465, 465, 399, 416, 396, 453, 388, 496, 379, 472, 491, 492, 503, 516, 454, 630, 547, 578, 312, 764, 672, 548, 611, 546, 552, 520, 486, 581, 559, 433, 262, 650, 615, 542, 571, 542, 529, 577, 469, 557, 540, 546, 519, 376, 605, 520, 435, 299, 531, 538, 475, 511, 487, 490, 494, 537, 482, 438, 498, 312, 476, 383, 382), .Dim = c(98L, 1L), .Dimnames = list(NULL, "Q2")) b: structure(c(2342.12883525675, 2595.06229039124, 2715.2774272809, 2742.14586849367, 2678.48814516156, 2769.17482063132, 2809.26904957691, 2647.26143288146, 2142.48588931211, 1986.26692938822, 2417.80180308667, 2539.99173834861, 2889.68696098066, 2949.03395956634, 3345.265659123, 3178.09552101488, 3202.97894028497, 3294.04615708455, 3273.96002181006, 3290.59294404149, 3074.57078080845, 2809.00966959208, 2870.20594457832, 2994.89960881099, 3031.51083818418, 2838.72778780229, 2779.83367818986, 2471.70302686638, 2277.52074079803, 2313.67080371772, 2415.57558854185, 2593.57170885689, 2579.65222779155, 2542.47630393453, 2610.16334633228, 2715.1622580481, 2680.04491562794, 2676.08878142995, 2890.5657368073, 2939.98447437336, 2932.41354171428, 2699.29100102243, 2748.9757584712, 2885.90115387751, 2841.03004973532, 3111.28842226602, 3293.09352655985, 3448.16679970445, 3470.58231818316, 3077.6191619663, 2892.81263635983, 2563.00601428125, 2410.40833201752, 2696.80369889632, 3250.95996536945, 3900.33363068933, 3571.89127039948, 3569.09158205254, 3718.94141619046, 3963.05018539626, 4317.67764180387, 4143.2306512351, 4482.33003541385, 4313.47162218783, 4162.58533919444, 4119.75974744111, 4080.01960112015, 4146.78116940934, 3848.98992961189, 3507.00912988581, 3336.3269842557, 3691.50683899193, 3616.0923981163, 3325.14304882807, 3471.79805853069, 3229.60965194249, 3106.05768279943, 3184.66721766981, 3140.79657087168, 3242.97205541341, 3090.78617601495, 3086.74973135927, 3317.74000570974, 3594.90929884806, 3716.02759860505, 3622.91307702134, 3793.8518218782, 3666.82966979173, 3779.4557494045, 3750.98605852729, .45681985961, 3057.22984206785, 3395.04273620089, 3623.47886822009, 3690.34495906538, 3827.97665203175, 3933.61679986677, 3762.82354740958), .Dim = c(98L, 1L)) c: structure(c(2854.17262019504, 91576.5893971961, 171680.262910889,
[R] Upper bound vector in Nloptr
Hello Folks, I am using "nloptr" optimizer in my program as below. my.data.var <- c(10,0.25,0.25,0.25,0.25,0.25, 10,0.25,0.25,0.25,0.25,0.25, 10,0.25,0.25,0.25,0.25,0.25, 10,0.25,0.25,0.25,0.25,0.25) #Option for non-linear optimization algorithm NLOPTR opts = list("algorithm"="NLOPT_LN_COBYLA", "xtol_rel"=1.0e-6, "maxeval"= 1) lb = vector("numeric",length= length(my.data.var)) #NLOPT_LN_COBYLA result <- nloptr(my.data.var,eval_f = Error.func,lb=lb, ub = c(Inf,1,1,1,1,1,Inf,1,1,1,1,1,Inf,1,1,1,1,1,Inf,1,1,1,1,1),eval_g_ineq=constraint.func, opts = opts) As you can see, I have to explicitly define the "upper bound: ub" as a long vector in this scenario. In another case, the number of variables "my.data.var" (24 in the above example) can go up to 100 and hence. the "upper bound" needs to be modified. I would like to avoid writing that explicilty in the "ub". How can I dynamically do it ? I am out of ideas here. Thanks for the help. __ R-help@r-project.org mailing list -- To UNSUBSCRIBE and more, see https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.
[R] Nloptr vs Excel GRG optimization result
Hi All, For a non-linear minimization optimization problem that I have, I am getting better objective function value in Excel(15) as compared to nloptr (73). the nloptr is setup as: opts = list("algorithm"="NLOPT_LN_COBYLA", "xtol_rel"=1.0e-8, "maxeval"= 1) lb = vector("numeric",length= length(my.data.var)) result <- nloptr(my.data.var,eval_f = Error.func,lb=lb, ub = c(Inf,1,1,1,1,1,Inf,1,1,1,1,1,Inf,1,1,1,1,1,Inf,1,1,1,1,1),eval_g_ineq=constraint.func,opts = opts) As observed even with 1 as maximum evaluations, the objective function is way off as compared to Excel's GRG which solved it in 200 iterations. Is there a way to improve the objective function value from nloptr? OR is there any excel's GRG equivalent package in R. Thanks for your time! PD __ R-help@r-project.org mailing list -- To UNSUBSCRIBE and more, see https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.
Re: [R] How to extract "specific"/"last" intercept value from segmented package.
Thanks! that worked. I also tested with the below method although your solution is faster and done in fewer steps. inter <- intercept(segmented.mod) inter.m <- as.matrix(inter$x) inter.row <- nrow(inter.m) answer <- inter.m[inter.row,1] PD On Tue, Jul 5, 2016 at 2:28 PM, <ruipbarra...@sapo.pt> wrote: > Hello, > > Try > > dimnames(inter$x)[[1]] > > You could have seen this by inspecting 'inter': > > str(inter) > > Hope this helps, > > Rui Barradas > > > Citando Narendra Modi <bjpmodi2...@gmail.com>: > > I am able to perform regression on a dataset as below: > > plot(x,y) > lin.mod <- lm(y~x) > m <- mean(x) > m > > segmented.mod <- segmented(lin.mod, seg.Z = ~x, psi= m) > > plot(segmented.mod, add=T) > sl <- slope(segmented.mod) > inter <- intercept(segmented.mod) > > summary(segmented.mod)# Show Summary > sl# show all the slopes > inter # show all the intercepts > > > In my dataset, the above method correctly identifies the breakpoints and > hence I get two intercepts. > > inter > > $x > Est. > intercept1 -3.269 > intercept2 -19.980 > > What I am interested is the "intercept2" value. How can I obtain this? > > The method needs to be dynamic as in if the next dataset has 3 intercepts, > I would like to get "intercept3 value. > > PD > > [[alternative HTML version deleted]] > > __ > R-help@r-project.org mailing list -- To UNSUBSCRIBE and more, see > https://stat.ethz.ch/mailman/listinfo/r-help > PLEASE do read the posting guide > http://www.R-project.org/posting-guide.htmland provide commented, minimal, > self-contained, reproducible code. > > > __ R-help@r-project.org mailing list -- To UNSUBSCRIBE and more, see https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.
[R] How to extract "specific"/"last" intercept value from segmented package.
I am able to perform regression on a dataset as below: plot(x,y) lin.mod <- lm(y~x) m <- mean(x) m segmented.mod <- segmented(lin.mod, seg.Z = ~x, psi= m) plot(segmented.mod, add=T) sl <- slope(segmented.mod) inter <- intercept(segmented.mod) summary(segmented.mod)# Show Summary sl# show all the slopes inter # show all the intercepts In my dataset, the above method correctly identifies the breakpoints and hence I get two intercepts. > inter $x Est. intercept1 -3.269 intercept2 -19.980 What I am interested is the "intercept2" value. How can I obtain this? The method needs to be dynamic as in if the next dataset has 3 intercepts, I would like to get "intercept3 value. PD [[alternative HTML version deleted]] __ R-help@r-project.org mailing list -- To UNSUBSCRIBE and more, see https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.
Re: [R] Non Linear Solver - Optim in R
Ooops. I can change that real quick. Any help on the problem itself Ranjan? Thanks! On Fri, Jun 17, 2016 at 9:22 AM, Ranjan Maitra < maitra.mbox.igno...@inbox.com> wrote: > You need to send e-mail from a properly identifiable address (which has a > correct name/e-mail address) and not a made-up scam address. You can easily > be reported for impersonation! > > Ranjan > > > On Fri, 17 Jun 2016 08:51:59 -0500 Narendra Modi <bjpmodi2...@gmail.com> > wrote: > > > Hello, > > Resending this message in "Plain-text". > > > > Thank you for the add to the list. > > > > I have written a R snippet to solve a non-linear problem using Optim > solver. > > > > The parameters to be solved are supposed to be in a matrix form as > attached > > > > such that summation of columns is <=1 except for the first column. ie, > > P1.F1j + P2.F1j <=1 , P1.F2j + P2.F2j <=1 , P1.F3j + P2.F3j <=1 and so > > on.. > > > > Since OPTIM solver considers "pars" only as vector, I defined the vector > as > > > > my.data.var <- vector("numeric",length = 12) > > > > and in the OPTIM solver, I passed it as > > > > optim(my.data.var, Error.func, method="L-BFGS-B", > > upper=c(Inf,1,1,1,1,1,Inf,1,1,1,1,1)) > > > > Then in the error function, I stacked the vector into a matrix as : > > > > my.data.var.mat <- matrix(my.data.var,nrow = 2, ncol = 6,byrow = TRUE) > > > > So, my first question is how do I define the constraints for each column > > except the first one in the OPTIM solver? As you can see, with the UPPER > > limit in the OPTIM solver, I can fix the upper bound, but there is no way > > for me set the summation constraint to <=1. > > > > Do I need a different solver for this scenario which allows me to use > > Matrix elements as parameters? > > > > Thanks! > > > -- > Important Notice: This mailbox is ignored: e-mails are set to be deleted > on receipt. Please respond to the mailing list if appropriate. For those > needing to send personal or professional e-mail, please use appropriate > addresses. > > > FREE ONLINE PHOTOSHARING - Share your photos online with your friends and > family! > Visit http://www.inbox.com/photosharing to find out more! > > __ > R-help@r-project.org mailing list -- To UNSUBSCRIBE and more, see > https://stat.ethz.ch/mailman/listinfo/r-help > PLEASE do read the posting guide > http://www.R-project.org/posting-guide.html > and provide commented, minimal, self-contained, reproducible code. > [[alternative HTML version deleted]] __ R-help@r-project.org mailing list -- To UNSUBSCRIBE and more, see https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.
[R] Non Linear Solver - Optim in R
Hello, Resending this message in "Plain-text". Thank you for the add to the list. I have written a R snippet to solve a non-linear problem using Optim solver. The parameters to be solved are supposed to be in a matrix form as attached such that summation of columns is <=1 except for the first column. ie, P1.F1j + P2.F1j <=1 , P1.F2j + P2.F2j <=1 , P1.F3j + P2.F3j <=1 and so on.. Since OPTIM solver considers "pars" only as vector, I defined the vector as my.data.var <- vector("numeric",length = 12) and in the OPTIM solver, I passed it as optim(my.data.var, Error.func, method="L-BFGS-B", upper=c(Inf,1,1,1,1,1,Inf,1,1,1,1,1)) Then in the error function, I stacked the vector into a matrix as : my.data.var.mat <- matrix(my.data.var,nrow = 2, ncol = 6,byrow = TRUE) So, my first question is how do I define the constraints for each column except the first one in the OPTIM solver? As you can see, with the UPPER limit in the OPTIM solver, I can fix the upper bound, but there is no way for me set the summation constraint to <=1. Do I need a different solver for this scenario which allows me to use Matrix elements as parameters? Thanks! __ R-help@r-project.org mailing list -- To UNSUBSCRIBE and more, see https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.