search for: pcls

Displaying 17 results from an estimated 17 matches for "pcls".

Did you mean: cls
2010 Dec 06
1
use pcls to solve least square fitting with constraints
Hi, I have a least square fitting problem with linear inequality constraints. pcls seems capable of solving it so I tried it, unfortunately, it is stuck with the following error: > M <- list() > M$y = Dmat[,1] > M$X = Cmat > M$Ain = as.matrix(Amat) > M$bin = rep(0, dim(Amat)[1]) > M$p=qr.solve(as.matrix(Cmat), Dmat[,1]) > M$w = rep(1, length(M$y)) > M$C...
2020 Nov 03
2
Query on constrained regressions using -mgcv- and -pcls-
Hello all, I'll level with you: I'm puzzled! How is it that this constrained regression routine using -pcls- runs satisfactorily (courtesy of Tian Zheng): library(mgcv) options(digits=3) x.1=rnorm(100, 0, 1) x.2=rnorm(100, 0, 1) x.3=rnorm(100, 0, 1) x.4=rnorm(100, 0, 1) y=1+0.5*x.1-0.2*x.2+0.3*x.3+0.1*x.4+rnorm(100, 0, 0.01) x.mat=cbind(rep(1, length(y)), x.1, x.2, x.3, x.4) ls.print(lsfit(x.mat, y, int...
2004 Mar 01
1
non-negative least-squares
...all, I am trying to do an inversion of electromagnetic data with non-negative least squares method (Tikhonov regularisation) and have got it programmed in S-Plus. However I am trying to move all my scripts from S-Plus to R. Is there an equivalent to nnls.fit in R? I think this can be done with pcls? Right? S-Plus script: A, L and data are matrices, lambda is a vector of possible lambda (smoothing) values > "nntik"<-function(A,L,data,lambda) > { > H<-rbind(A,lambda*L) > i<-1:(nrow(L)+length(data)) > q<-ifelse(i<=length(data),data[i],0) > nntik<-...
2013 Mar 19
0
linear model with equality and inequality (redundant) constraints
...t be possible to estimate a linear model with equality and inequality redundant constraints? I also understand that quadratic programming is the key for that, but I was not able to ?translate? my simple linear problem with constraints for using solve.QP(quadprog) and ic.est(ic.infer). I have found pcls(mgcv) more user-friendly. And below you could find my attempt to fit the toy-data with this function with and without redundant constraints. Thanks in advance for any help you could provide, Carlo Giovanni Camarda rm(list = ls()) library(mgcv) ## estimate p: E(r) = X p, s.t. ## C p ==...
2013 Mar 11
1
Use pcls in "mgcv" package to achieve constrained cubic spline
...# Create Design matrix, constraints etc. for monotonic spline.... sm<-smoothCon(s(x,k=10,bs="cr"),dat,knots=NULL)[[1]] F<-mono.con(sm$xp); # get constraints G<-list(X=sm$X,C=matrix(0,0,0),sp=f.ug$sp,p=sm$xp,y=y,w=y*0+1) G$Ain<-F$A;G$bin<-F$b;G$S<-sm$S;G$off<-0 p<-pcls(G); # fit spline (using s.p. from unconstrained fit) fv<-Predict.matrix(sm,data.frame(x=x))%*%p lines(x,fv,col=2) lines(x,f,col="blue")            Thanks a lot!!             Victor [[alternative HTML version deleted]]
2009 Feb 25
1
monotonic GAM with more than one term
Hi, Does anyone know how to fit a GAM where one or more smooth terms are constrained to be monotonic, in the presence of "by" variables or other terms? I looked at the example in ?pcls but so far have not been able to adapt it to the case where there is more than one predictor. For example, require(mgcv) set.seed(0) n<-100 # Generate data from a monotonic truth. x<-runif(100)*4-1 x<-sort(x) m <- structure(rep(1:2,50), .Label=c("one","two"), cl...
2013 Jul 19
0
mgcv: Impose monotonicity constraint on single or more smooth terms
...d be the same so the dimension of the matrices from finite differencing are the same? A couple of (perhaps quite basic) specific questions to the example code: ## Preliminary unconstrained gam fit... G <- gam(y~s(x)+s(z)+s(v,k=20),fit=FALSE) So first create G which is going to be the input to pcls() to fit the constrained model. Then fit the unconstrained version: b <- gam(G=G) (skipping this part of the example that calculates finite differences contained in Xx and Xz where Xx is always positive, and Xz is not - z is the covariate that we want to apply the constraint to…) Now the const...
2006 Sep 04
2
Fitting generalized additive models with constraints?
Hello, I am trying to fit a GAM for a simple model, a simple model, y ~ s(x0) + s(x1) ; with a constraint that the fitted smooth functions s(x0) and s(x1) have to each always be >0. >From the library documentation and a search of the R-site and R-help archives I have not been able to decipher whether the following is possible using this, or other GAM libraries, or whether I will have to try
2007 Nov 25
1
GAM with constraints
Hi, I am trying to build GAM with linear constraints, for a general link function, not only identity. If I understand it correctly, the function pcls() can solve the problem, if the smoothness penalties are given. What I need is to incorporate the constraints before calculating the penalties. Can this be done in R? Any help would be greately appreciated. -- View this message in context: http://www.nabble.com/GAM-with-constraints-tf4869470.html...
2003 Sep 26
1
least squares regression using (inequality) restrictions
Dear R Users, I would like to make a lesast squares regression similar to that what is done by the command "lm". But additionally, I would like to impose some restrictions: 1) The sum of all regression coefficients should be equal to 1. 2) Each coefficient should assume a value between 0 and 1. (inequality restrictions) Which command is the best to use in order to solve this problem
2013 Mar 06
1
Constrained cubic smoothing spline
Hello everone,            Anyone who knows how to force a cubic smoothing spline to pass through a particular point?            I found on website  someone said that we can use "cobs package" to force the spline pass through certain points or impose shape           constraints (increasing, decreasing). However,  this package is using  B-spline and can only do linear and quadratic
2003 Jan 30
2
mgcv, gam
Hola! I have some problems with gam in mgcv. Firts a detail: it would be nice igf gam would accept an na.action argument, but that not the main point. I want to have a smooth term for time over a year, the same pattern repeating in succesive years. It would be natural then to impose the condition s(0)=s(12). Is this possible within mgcv? I tried to obtain this with trigonometric terms, aca:
2002 Mar 27
1
non-decreasing smoother
Hello Is there a simple way of fitting a 'smooth curve' to a time series with the additional constraint that the first derivative be not negative? I know that if I choose a "large enough" window for a moving average sort of filter on my data I end up with a non-decreasing curve anyway, but I'm wondering if there is a pre-built method that can include the constraint from
2005 Mar 01
1
constraining initial slope in smoother.spline
Hello. I want to fit a smoother spline (or an equivalent local regression method) to a series of data in which the initial value of the 1st derivative (slope) is constrained to a specific value. Is it possible to do this? If so, how? Bill Shipley [[alternative HTML version deleted]]
2007 Sep 05
1
Monotone splines
Hello, i have a little problem with R and i hope you can help me. I want to use splines to estimate a function but i want to force the interpolation to be monotone. Is this possible with R ? Thank you, Rémi. --------------------------------- [[alternative HTML version deleted]]
2013 Mar 23
1
Time trends with GAM
Hi all, I am using GAM to model time trends in a logistic regression. Yet I would like to extract the the fitted spline from it to add it to another model, that cannot be fitted in GAM or GAMM. Thus I have 2 questions: 1) How can I fit a smoother over time so that I force one knot to be at a particular location while letting the model to find the other knots? 2) how can I extract the matrix
2002 Apr 09
2
Restricted Least Squares
Hi, I need help regarding estimating a linear model where restrictions are imposed on the coefficients. An example is as follows: Y_{t+2}=a1Y_{t+1} + a2 Y_t + b x_t + e_t restriction a1+ a2 =1 Is there a function or a package that can estimate the coefficient of a model like this? I want to estimate the coefficients rather than test them. Thank you for your help Ahmad Abu Hammour --------------