Dear all, I have been trying to find a simple solution to my problem without success, though i have a feeling a simple syntaxe detail coul make the job. I am doing a polynomial linear regression with 2 independent variables such as : lm(A ~ B + I(B^2) + I(lB^3) + C, data=Dataset)) R return me a coefficient per independent variable, and I would need the coefficient of the C parameter to equal 1. I've been loonking at "parameter constraints" on the internet but it's always much more complicated that just "removing" the fit of a coefficient (or setting it to 1). I know many package allows to "not fit" an intercept with a "-1" parameter in the syntaxe, does that exists for independent variables ? Regards, [[alternative HTML version deleted]]
> -----Original Message----- > I am doing a polynomial linear regression with 2 independent variables > such as : > > lm(A ~ B + I(B^2) + I(lB^3) + C, data=Dataset)) > > R return me a coefficient per independent variable, and I? would need > the coefficient of the C parameter to equal 1.Leaving aside the question of fitting simple polynomial coefficients instead of orthogonal polynomials - generally frowned upon, but not always serious - the problem you describe is one in which you are not fitting C at all; you're assuming C adds exactly. What you're really fitting is the difference between A and C. Try fitting A-C ~ B + I(B^2) + I(lB^3) to obtain the coefficients you're looking for. But be aware that you will still have a constant intercept, so the model you will have fitted is A = b0 + b1.B +b2.B^2 +b3.B^3 + C + error S Ellison ******************************************************************* This email and any attachments are confidential. Any use...{{dropped:8}}
You want the offset function in the formula: lm( A ~ B + I(B^2) + offset(C), data=Dataset) This will force the coefficient on C to be 1, if you wanted a coefficient of another value then just do the multiplication yourself, e.g. offset( 2 * C ) for a slope of 2. Also you can use poly(B,2) to fit a linear and quadratic terms on B. On Thu, Oct 17, 2013 at 3:45 AM, Robert U <tacsunday@yahoo.fr> wrote:> Dear all, > > I have been trying to find a simple solution to my problem without > success, though i have a feeling a simple syntaxe detail coul make the job. > > I am doing a polynomial linear regression with 2 independent variables > such as : > > lm(A ~ B + I(B^2) + I(lB^3) + C, data=Dataset)) > > R return me a coefficient per independent variable, and I would need the > coefficient of the C parameter to equal 1. > > > I've been loonking at "parameter constraints" on the internet but it's > always much more complicated that just "removing" the fit of a coefficient > (or setting it to 1). > > > I know many package allows to "not fit" an intercept with a "-1" parameter > in the syntaxe, does that exists for independent variables ? > > Regards, > [[alternative HTML version deleted]] > > > ______________________________________________ > R-help@r-project.org mailing list > 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. > >-- Gregory (Greg) L. Snow Ph.D. 538280@gmail.com [[alternative HTML version deleted]]