Have an idea?

Visit Sawtooth Software Feedback to share your ideas on how we can improve our products.

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).

Any comments welcome.
related to an answer for: CBC design: selecting levels
asked Jan 29 by Andrew Reynolds Bronze (1,085 points)
edited Jan 29 by Andrew Reynolds

1 Answer

+1 vote
Best answer

With user-specified coding, you can take over the coding of the design matrix in the .CSV file you submit to CBC/HB software, so you can accomplish "piecewise coding," which I think is what you want to create the spline.  If you go this route, you'll not be able to use Sawtooth Software's market simulators, unless you do a bit of reorganizing of the part-worth utilities for price in the .CSV file.  If you really needed to use our simulators, I could describe this in a follow-up email to you.

But, the trick is to do the piecewise coding for the "user-specified" columns that will deal with the price attribute.  You can write me an email regarding how to do this, in case you don't already know, as I'm sure you've got my email since we communicate somewhat often.
answered Jan 29 by Bryan Orme Platinum Sawtooth Software, Inc. (134,015 points)
selected Jan 29 by Andrew Reynolds
Oh, upon further inspection of your post, the last coding scheme you talk about indeed is Piecewise Coding, so it appears you've got the idea.  That's the approach I would use.