# How to code/implement splines in CBCHB?

Lets use a simple example e.g. Price ranges between 0 and 10 and we want a cut (or knot) at 5 (based on prior knowledge).

A spline function in this context would aim to be linear between knots and not have any 'jumps' either side of the knot. Typically with part-worths we measure the knots and might interpolate between them but some studies require much more than the 'around' 5 price levels recommended.

The problem:
If price is 1 we'll want a contribution to a 'total price utility' from the 0-5 band and nothing from the 5-10 band.
If price is 6 we'll want a contribution to a 'total price utility' from the 0-5 band where price = 5 and an additional contribution of 1 price unit from the 5-10 band.

The options for Attribute Information are either Linear or User Specified.

If you choose Linear then CBCHB transforms the values to zero centre them (the help file also recommends rescaling them to be between -1 and +1).

My understanding (and where I am possibly confused) is this is what happens …

If price is 1:
Range 0-5. Coding value =(1-midpoint)/range=(1-2.5)/5= -0.3
Range 5-10. Coding value = 0? … but this implies the midpoint of 7.5

If price is 6:
Range 0-5. Coding value = (5-2.5)/5 = 0.5
Range 5-10. Coding value = (Position within range - average position within range ) / range = ((6-5)-2.5)/6 = -0.25

So this would work for '6' but is problematic for '1'. By problematic I mean that I don't know how to code for the range not travelled. So this might not be the way to go.

The other option is User specified.

I think this is the one to use if it treats the underlying values as linear. My understanding is that the software doesn't do any re-scaling / centering with this option.

If price is 1:
Range 0-5. Coded as 1.
Range 5-10. Coded as zero.

If price is 6:
Range 0-5. Coded as 5.
Range 5-10. Coded as 1.

So this appears to work (with the possibility of scaling the ranges back to 0-1 to help with convergence).

related to an answer for: CBC design: selecting levels
edited Jan 29, 2018