# Regression equation including second order terms

Hi guys,

I would like to implement a regression equation for a new shoulder model using multiple regression coefficients with some second order terms. Consider the following example:

FinalKinMeasure = 0.01 * InputKinMeas1 + 0.002 * InputKinMeas1^2 - 0.004 * InputKinMeas2 + 0.1InputKinMeas1InputKinMeas2;

From what I know, the ‘AnyKinMeasureLinComb’ is well suited for regressions with only first order terms and cannot involves interaction terms (i.e. InputKinMeas1*InputKinMeas2), so how can I implement this regression correctly ?

Thank you.

Pierre

Hi Pierre,

Some terms of your regression formula is possible to implement I think, but I can not see how to do the last term where the measures are multiplied.

The second order terms need to be done with the AnyKinMeasureComb
here is an example of its use

``````

// Here's the point of the model: The position of the point along
// the stick is constrained to be on the ellipsoid surface. This is
// done by means of the equation for an ellipsoid with center at
// the origin of the coordinate system:
// x^2/a + y^2/b + z^2/c = 1
// This fits a second order NormComb measure perfectly. The 1 on
// the right hand side of the equation is obtained by driving the
// measure to 1 by a simple driver.
AnyKinEqSimpleDriver ScapThoracGlide1 = {
AnyKinMeasureNormComb Comb = {
AnyKinLinear lin = {
AnyRefFrame &C = Main.MyModel.GlobalRef.EllipNode;
AnyRefFrame &Point = Main.MyModel.Point;
Ref = 0;
};
Order = 2;
Offset = 0;
Weight = {1/Main.MyModel.GlobalRef.R[0],
1/Main.MyModel.GlobalRef.R[1],
1/Main.MyModel.GlobalRef.R[2]};
};
DriverPos = {1};   // RHS of the allipsoid equation
DriverVel = {0};
};

``````

In your case the second order term will look something like this.

``````

AnyKinMeasureNormComb  SecondOrderTerm = {
AnyKinMeasureorg &ref=.MyToBeSecondOrderTerm
Order = 2;
Offset = 0;
Weight = {Coef};
};

``````

This second order term can then be inserted in the linear combination measure.

Concerning the multiplication of the two measures, I currently can not see this to be feasible, but it might not be very difficult to implement, I am not sure.

Best regards
Søren

Hi Soren,

Thank you very much for your quick reply. In the definition of the AnyKinMeasureNormComb, the exponent ‘p’ is further cancelled by the ‘1/p’. How can I make a second order measure with that ?

Thank you.

Pierre

Hi Pierre,

Yes you are right, I overlooked this when I looked at the scapula example, in that example it works because taking the square root on both side still makes this equation fit, in your case this will not work, sorry for that

Best regards
Søren

Hi Soren,

No problem If you find another way to do these measures, I will be more than happy to know. Maybe we could create a new class template ?

Regards.

Pierre

Hi again Soren,

Maybe it is possible to use the Fourier driver to approximate non-linear functions ?

Regards.

Pierre

Hi Soren,

Is it possible to create a combined measure involving the sinus of another measure ? Here is an example in which I compute one of the clavicle DOFs using two components of the thoracohumeral orientation:

ClavicleAngle1 = 0.1 * elevationAngle + 0.4planeOfElevationSIN(elevationAngle);

The sinus of the elevation angle is also the distance along one of the three directions of the thoracohumeral orientation unit vector. If the above equation cannot be obtained, is there any way to get one of the components of the orientation unit vector ? I saw that the AnyKinRotational proposes different ways of computing the orientations (RotVector, DirCosines, EulerParameters, etc.).

Regards.

Pierre

Hi Pierre,

I am sorry I do not see this as possible …

In the equation the multiplication of the two measures in the last term is the problem since it can not be done with a linear combination measure.

Any number of terms is ok as long they are multiplied by a constant.

Concerning the rotational measures please have a look at the wiki pages