Randomize options and attributes in list question

More
1 week 5 days ago #202059 by smontano
Hello LimeSurvey Community. This is my first attempt at working with LS (LS 3.21.4) and I could really use your collective expertise.

I’m designing a survey containing a series of 4 questions that respondents will have to choose between 3 different options from a pool of 5 options, a stated preference experiment. Each option has 2 variables with various attributes that need to be randomized for each respondent.

See below for an example, hopefully a visual will help illustrate what I am trying to do. The highlighted values represent the random choices picked for a question.

Example Question 1:


I’d like to present the randomized choice set in the “List (radio)” question type. Is this possible to accomplish? The option to pick x random questions from a bucket of y forums.limesurvey.org/forum/can-i-do-thi...-bucket-of-y?start=0 is a clever solution but only randomizes the questions and would necessitate creating 1000s of questions spanning the entire set of possible combinations. If this is possible, I would really appreciate some pointers on how to implement this in my survey.

Thank you in advance for your help.
Attachments:

Please Log in to join the conversation.

LimeSurvey Partners
More
1 week 4 days ago #202064 by holch
This looks to me like a Conjoint excercise.

Usually, also to make sure that there are not too many combinations and to guarantee that there is also a suficient number for each atribute, the "cards" are limited to certain combinations.

But any way, to me it is currently NOT clear, what the random choices are, because you have various highlights in your example. E.g. you have the attributes 1 and the attributes 2, but you also have the highlight of the Options A, C and D.

So you would have 5 Options (A, B, C , D, E) and you would show 3 out of those 5, correct?

And then within the option A, if shown there are the variables 1 and 2, with attributes 1 and 2 or a and b respectively.

So far I think this is pretty easy to create. But here is the question: Are these options A, B, C, etc. independent from each other?

What I mean is: If Option A shows attribute B for Variable 2, could Option C also show attribute b for variable 2 or would each of them have to be different?

But as said before, generally the Conjoint design tries to reduce the number of potential combinations, because analysis can become quite complicated and you'd often need a huge amount of respondents to make sure to be able to calculate your result.

So maybe you can explain your design a little bit more.

I answer at the LimeSurvey forum in my spare time, I'm not a LimeSurvey GmbH employee.
No support via private message.

Please Log in to join the conversation.

More
1 week 4 days ago #202068 by smontano
Holch,

Thanks for your response. The random choices in the example provided are:



The picture in my original post had all the possible selections greyed out with the “randomly chosen” values in black. To further clarify Options A, C, D can be viewed as individual scenarios and would be randomly chosen from options A-E. Furthermore, each option or scenario would have 2 randomly chosen “sub options”, the variable attributes.

The options would be independent. To answer your question: If Option A shows attribute B for Variable 2, could Option C also show attribute b for variable 2 or would each of them have to be different?

Yes, Option A and Option B could both contain attribute b for variable 2.

Sounds like you understand what I'm trying to do but, does that clarify my survey design?

I will be reading about Conjoint analysis design in the meantime.
Attachments:

Please Log in to join the conversation.

More
1 week 4 days ago #202072 by holch
What often happens in Conjoint is that the combinations are basically "hard coded" and limited in amount, just to reduce complexity.

I think this is doable, but depending on the number of options and number of variables it can become quite complicated.

The main problem that I currently see is to choose which 3 of the 5 options should be shown, because I currently don't know a way to randomly draw 3 numbers out of 5, but Joff, Tpartner or Denis might have a good idea there.

Maybe there is a way to create an array of random numbers from a pool, I don't know.

For the attributes I don't see a way around to create one equation question per attribute per option. So in your example with 5 different options and each option having 2 attributes, you would need 10 equation questions to create the random assignment of each attribute.

E.g. for Option A you would need to create 2 equation questions:

A1 - Option A, Variable 1 (Brand): Audi, BMW
A2 - Option A, Variable 2 (Color): blue, red
B1 - Option B, Variable 1 (Brand): BMW, Merecedes
B2 - Option B, Variable 2 (Color): red, green, yellow
etc.

So in each of these equation questions you would need to create a random number based on the number of attributes for each variables.

E.g. for B2 it would look something like this:
{if(is_empty(B2),rand(1,3),B2}

This will create a random number between 1 and 3, so either 1 (red), 2 (green) or 3 (yellow).

So then when showing an option you would have to check what random number has been drawn for this and pipe the respective attribute of the variable in to display it into the Option.

So then you could write your different Options like this:
Option B
Brand: {if(B1==1,"BMW","Mercedes")}
Color: {if(B2==1,"red", if(B2==2,"green","yellow"))}

Something like this. But, this might make the creation of questions easier, as you do not have to create each different combination, but keep in mind that you will still have this many different combinations for analysis, so keep in mind how you will analyse this.

I answer at the LimeSurvey forum in my spare time, I'm not a LimeSurvey GmbH employee.
No support via private message.

Please Log in to join the conversation.

More
1 week 2 days ago - 1 week 2 days ago #202217 by smontano
Thank you for the Conjoint Analysis suggestion. I was able to piece together some code to have a working model of what I'd like. There are still some loose ends to tie up. The logic for the combination of attributes still needs to be sorted out but I think that is pretty manageable once decided.

Attached is a file for the work in progress. Randomization of all attributes is complete.However, for one of the attributes (infrastructure type) I'd like to create an array with photos and text descriptors to randomly select from instead of the codes I currently have as place holders. This is probably a simple task but my coding experience is limited to R, I have never worked with Javascript, HTML, CSS.

The other thing that I could use help with is to add a third radio button for option C.

I am extremely grateful for your insight and help thus far!
Attachments:
Last edit: 1 week 2 days ago by smontano.

Please Log in to join the conversation.

More
1 week 2 days ago #202231 by Joffm
Hi,

I see you found the old "apple / banana" example.

By the way: In your example the third answer option is missing.

https://forums.limesurvey.org/forum/can-i-do-this-with-limesurvey/118324-single-choice-with-answer-options-in-a-box#184039

https://forums.limesurvey.org/forum/can-i-do-this-with-limesurvey/110436-multiple-choice-table-discrete-choice-models?start=15#170368


And to find 3 out of 5?
There are only 10 options to do this ( 5 over 3)

1 2 3
1 2 4
1 2 5
1 3 4
1 3 5
1 4 5
2 3 4
2 3 5
2 4 5
3 4 5

So you might create a random number 1-10 and display according to this number

In this example
1 is displayed, if randomnumber in (1,2,3,4,5,6)
2 is displayed, if randomnumber in (1,2,3,7,8,9)
3 is displayed, if randomnumber in (1,4,5,7,8,10)
4 is displayed, if randomnumber in (2,4,6,7,9,10)
5 is displayed, if randomnumber in (3,5,6,8,9,10)


In our example you inserted the pictures, speed and time by javascript.

I do not think it is the best way, because these values are not stored in the database. So you do not know later which values were displayed.

You again may use several random numbers (randomSpeed1, randomSpeed2,...) to show the values.
And as the random numbers are stored you can use them later.


Just include
<td style="text-align: center;"> {if (randomSpeed1==1,'20mph', if(randomSpeed1==2,'25mph', if(randomSpeed1==3,'35mph','40mph')))}</td>
...

Joffm


Volunteers are not paid.
Not because they are worthless, but because they are priceless
Attachments:

Please Log in to join the conversation.

More
1 week 2 days ago #202245 by Joffm
Hi,
here is an idea.

All equations are not hidden yet; so you see what happens.


And the sample

File Attachment:

File Name: limesurvey...7122.lss
File Size:28 KB


Joffm

@Tony:
This time no boats. ;)


Volunteers are not paid.
Not because they are worthless, but because they are priceless
Attachments:

Please Log in to join the conversation.

More
1 week 2 days ago #202257 by smontano
Joffm,

Thanks for taking a look. I tried to import the survey file you attached in your last post but received this error: .

The image you attached looks like what I was hoping to accomplish. It will be necessary to know the respondents selections. I've never worked with LS or JS so I'm learning as I go. It had occurred to me that knowing which options were presented and selected was going to be a challenge since the choices weren't input into the LS fields.

Unfortunately, I am unable to import the file with the modifications you've made. I am eager to test it though.
Attachments:

Please Log in to join the conversation.

More
1 week 2 days ago #202259 by holch
I have seen this error before in the forum this week and the person said that an update solved the problem. Was something database related, an error was introduced during 2h and during these 2h seems like a new release was sent out...

I answer at the LimeSurvey forum in my spare time, I'm not a LimeSurvey GmbH employee.
No support via private message.

Please Log in to join the conversation.

More
1 week 2 days ago #202266 by smontano
My LS access is through my university, I don't believe that I have the ability to update it.

Please Log in to join the conversation.

More
1 week 2 days ago #202278 by Joffm
Hi,
here the script of the main question:
<table border="0" cellpadding="0" cellspacing="0" style="border-collapse:collapse;">
	<tbody>
		<tr>
			<td bgcolor="#f2f2f2" style="text-align: center;" width="0%"> </td>
			<td style="text-align: center;" width="1%"> </td>
			<td bgcolor="#f2f2f2" style="text-align: center;" width="25%"><strong><span style="color:#000000;"><span style="font-size:20px;">A</span></span></strong></td>
			<td style="text-align: center;" width="1%"> </td>
			<td bgcolor="#f2f2f2" style="text-align: center;" width="25%"><strong><span style="color:#000000;"><span style="font-size:20px;">B</span></span></strong></td>
			<td style="text-align: center;" width="1%"> </td>
			<td bgcolor="#f2f2f2" style="text-align: center;" width="25%"><strong><span style="color:#000000;"><span style="font-size:20px;">C</span></span></strong></td>
		</tr>
		<tr style="height: 6px; text-align: center;">
		</tr>
		<tr>
			<td bgcolor="#f2f2f2" style="text-align: center;"><strong><span style="color:#000000;"><span style="font-size:18px;">Infrastructure Type</span></span></strong></td>
			<td style="text-align: center;" width="1%"> </td>
			<td><img src="/lime3/upload/surveys/877122/images/Hamburg-Ballett_{rImage1}.jpg" /></td>
			<td style="text-align: center;" width="1%"> </td>
			<td><img src="/lime3/upload/surveys/877122/images/Hamburg-Ballett_{rImage2}.jpg" /></td>
			<td style="text-align: center;" width="1%"> </td>
			<td><img src="/lime3/upload/surveys/877122/images/Hamburg-Ballett_{rImage3}.jpg" /></td>
		</tr>
		<tr style="height: 6px; text-align: center;">
		</tr>
		<tr>
			<td bgcolor="#f2f2f2" style="text-align: center;"><strong><span style="color:#000000;"><span style="font-size:18px;">Travel Time</span></span></strong></td>
			<td style="text-align: center;" width="1%"> </td>
			<td style="text-align: center;">{if (randomTime1==1,'15 min',if(randomTime1==2,'20 min', if(randomTime1==3,'25 min', if(randomTime1==4,'30 min','35 min'))))}</td>
			<td style="text-align: center;" width="1%"> </td>
			<td style="text-align: center;">{if (randomTime2==1,'15 min',if(randomTime2==2,'20 min', if(randomTime2==3,'25 min', if(randomTime2==4,'30 min','35 min'))))}</td>
			<td style="text-align: center;" width="1%"> </td>
			<td style="text-align: center;">{if (randomTime3==1,'15 min',if(randomTime3==2,'20 min', if(randomTime3==3,'25 min', if(randomTime3==4,'30 min','35 min'))))}</td>
		</tr>
		<tr style="height: 6px; text-align: center;">
		</tr>
		<tr>
		</tr>
		<tr>
			<td bgcolor="#f2f2f2" style="text-align: center;"><strong><span style="color:#000000;"><span style="font-size:18px;">Speed Limit</span></span></strong></td>
			<td style="text-align: center;" width="1%"> </td>
			<td style="text-align: center;">{if (randomSpeed1==1,'20 mph',if(randomSpeed1==2,'25 mph', if(randomSpeed1==3,'35 mph','40 mph')))}</td>
			<td style="text-align: center;" width="1%"> </td>
			<td style="text-align: center;">{if (randomSpeed2==1,'20 mph',if(randomSpeed2==2,'25 mph', if(randomSpeed2==3,'35 mph','40 mph')))}</td>
			<td style="text-align: center;" width="1%"> </td>
			<td style="text-align: center;">{if (randomSpeed3==1,'20 mph',if(randomSpeed3==2,'25 mph', if(randomSpeed3==3,'35 mph','40 mph')))}</td>
		</tr>
		<tr style="height: 6px; text-align: center;">
		</tr>
		<tr>
			<td bgcolor="#f2f2f2" style="text-align: center;"><strong><span style="font-size:18px;"><span style="color:#000000;">Your Choice</span></span></strong></td>
			<td style="text-align: center;" width="0%"> </td>
			<td bgcolor="#f2f2f2" style="text-align: center;"> </td>
			<td style="text-align: center;" width="0%"> </td>
			<td bgcolor="#f2f2f2" style="text-align: center;"> </td>
			<td style="text-align: center;" width="0%"> </td>
			<td bgcolor="#f2f2f2" style="text-align: center;"> </td>
		</tr>
	</tbody>
</table>
<script type="text/javascript" charset="utf-8">
	$(document).on('ready pjax:scriptcomplete',function(){
 
		// Identify this question
		var thisQuestion = $('#question{QID}');
 
		// Move the radios
		$('.question-text table:eq(0) tr:last td:eq(2)', thisQuestion).append($('.subquestion-list .answers-list:eq(0) .answer-item:eq(0) *', thisQuestion));
      	$('.question-text table:eq(0) tr:last td:eq(4)', thisQuestion).append($('.subquestion-list .answers-list:eq(0) .answer-item:eq(1) *', thisQuestion));
		$('.question-text table:eq(0) tr:last td:eq(6)', thisQuestion).append($('.subquestion-list .answers-list:eq(0) .answer-item:eq(2) *', thisQuestion));
 
		// Some classes for presentation
		$('.question-text table:eq(0) input:radio', thisQuestion).closest('td').addClass('answer-item radio-item text-center radio');
		$('.question-text table:eq(0) .radio-item label', thisQuestion).show();
 
		// Click event on the table cells
		$('.question-text table:eq(0) .radio-item', thisQuestion).on('click', function(e) {
			$('input:radio', this).trigger('click');
		});
		$('.question-text table:eq(0) input:radio', thisQuestion).on('click', function(e) {
			e.stopPropagation();
		});
 
		// Clean-up styles
		$('.answer-container', thisQuestion).hide();
		$('.question-text table:eq(0) .label-text', thisQuestion).remove();
		$('.question-text table:eq(0) .radio-text', thisQuestion).css({
			'cursor': 'pointer'
		});
    });
 
 
</script>


As I said, a random number 1-10: with this assignment:
1: 1,2,3
2: 1,2,4
3: 1,2,5
4: 1,3,4
5: 1,3,5
6: 1,4,5
7: 3,4,5
8: 2,3,4
9: 2,3,5
10: 2,4,5


At the start there are 10 questions of type equation:


random1: {if(is_empty(random1),rand(1,10),random1)}
randomSpeed1: {if(is_empty(randomSpeed1),rand(1,4),randomSpeed1)}
randomSpeed2: {if(is_empty(randomSpeed2),rand(1,4),randomSpeed2)}
randomSpeed3: {if(is_empty(randomSpeed3),rand(1,4),randomSpeed3)}
randomTime1: {if(is_empty(randomTime1),rand(1,5),randomTime1)}
randomTime2: {if(is_empty(randomTime2),rand(1,5),randomTime2)}
randomTime3: {if(is_empty(randomTime3),rand(1,5),randomTime3)}
rImage1: {if(random1<7,"1",if(random1>7,"2","3"))}
rImage2: {if(random1<4,"2",if(random1<6,"3",if(random1<8,"4",if(random1<10,"3","4"))))}
rImage3: {if(random1==1,"3",if(random1==2,"4",if(random1==3,"5",if(random1==4 or random1==8,"4","5"))))}

Then the main question.

Joffm

I attach the survey again. Now the equations are hidden; but there is an info page that shows the random numbers.
You do not have permissions to access this page.


Volunteers are not paid.
Not because they are worthless, but because they are priceless

Please Log in to join the conversation.

More
1 week 2 days ago - 1 week 2 days ago #202280 by Joffm
To add:
My pictures all are named
"Hamburg_Ballett_1.jpg"
"Hamburg_Ballett_2.jpg"
"Hamburg_Ballett_3.jpg"
...

Therefore it was sufficient to select the number.

Joffm

File Attachment:

File Name: limesurvey...7122.lss
File Size:32 KB


Volunteers are not paid.
Not because they are worthless, but because they are priceless
Attachments:
Last edit: 1 week 2 days ago by Joffm.

Please Log in to join the conversation.

More
1 week 2 days ago #202289 by holch

My LS access is through my university, I don't believe that I have the ability to update it.

Yeah, that is always tricky. Universities tend to not being very quick when it comes to updates, unfortunately.

What you could do is to install the latest 3.x LTS via XAMPP on your computer for testing purposes. If it works there, then you might want to ask for an update and if they don't want to update, you could always set up your own installation or get a subscription from LS Pro. It is not too expensive either. I don't know if you are required to use the University installation though. Some Universities have weird rules... ;-)

I answer at the LimeSurvey forum in my spare time, I'm not a LimeSurvey GmbH employee.
No support via private message.

Please Log in to join the conversation.

Start now!

Just create your account and start using Limesurvey today.

Register now