Sensitivity analysis using the file option in a subscripted model

Use this forum to post Vensim related questions.
Post Reply
niyousha@vt.edu
Junior Member
Posts: 6
Joined: Thu Aug 24, 2023 7:00 pm
Vensim version: DSS

Sensitivity analysis using the file option in a subscripted model

Post by niyousha@vt.edu »

How to run sensitive analyses using the file option when the model is subscripted? I get errors when using subscripted parameters.
Administrator
Super Administrator
Posts: 4590
Joined: Wed Mar 05, 2003 3:10 am

Re: Sensitivity analysis using the file option in a subscripted model

Post by Administrator »

What errors are you getting?
Advice to posters seeking help (it really helps us to help you)
http://www.ventanasystems.co.uk/forum/v ... f=2&t=4391

Units are important!
http://www.bbc.co.uk/news/magazine-27509559
tomfid
Administrator
Posts: 3811
Joined: Wed May 24, 2006 4:54 am

Re: Sensitivity analysis using the file option in a subscripted model

Post by tomfid »

What error are you seeing?

I'm guessing that you're putting varname[range] in the headers. I don't think that works - you need to provide a separate column for each varname[element].
niyousha@vt.edu
Junior Member
Posts: 6
Joined: Thu Aug 24, 2023 7:00 pm
Vensim version: DSS

Re: Sensitivity analysis using the file option in a subscripted model

Post by niyousha@vt.edu »

This is the error:
Bad constant-"FracDWI[Male.Age15]" in file MCMC4.txt.
niyousha@vt.edu
Junior Member
Posts: 6
Joined: Thu Aug 24, 2023 7:00 pm
Vensim version: DSS

Re: Sensitivity analysis using the file option in a subscripted model

Post by niyousha@vt.edu »

tomfid wrote: Fri Aug 25, 2023 2:24 pm What error are you seeing?

I'm guessing that you're putting varname[range] in the headers. I don't think that works - you need to provide a separate column for each varname[element].
Yes, I inserted the varnames like fracDWI[Male,Age15] in the headers (in a separate column for each of them). How they should be entered?
Administrator
Super Administrator
Posts: 4590
Joined: Wed Mar 05, 2003 3:10 am

Re: Sensitivity analysis using the file option in a subscripted model

Post by Administrator »

Male.Age15 cannot be a correct subscript for Vensim, any subscript elements with a "." need to be quoted.

So the correct syntax would be
FracDWI["Male.Age15"]
Advice to posters seeking help (it really helps us to help you)
http://www.ventanasystems.co.uk/forum/v ... f=2&t=4391

Units are important!
http://www.bbc.co.uk/news/magazine-27509559
Administrator
Super Administrator
Posts: 4590
Joined: Wed Mar 05, 2003 3:10 am

Re: Sensitivity analysis using the file option in a subscripted model

Post by Administrator »

Or try the following, replace the "." with a ",".
FracDWI[Male,Age15]
Advice to posters seeking help (it really helps us to help you)
http://www.ventanasystems.co.uk/forum/v ... f=2&t=4391

Units are important!
http://www.bbc.co.uk/news/magazine-27509559
niyousha@vt.edu
Junior Member
Posts: 6
Joined: Thu Aug 24, 2023 7:00 pm
Vensim version: DSS

Re: Sensitivity analysis using the file option in a subscripted model

Post by niyousha@vt.edu »

Administrator wrote: Fri Aug 25, 2023 2:56 pm Male.Age15 cannot be a correct subscript for Vensim, any subscript elements with a "." need to be quoted.

So the correct syntax would be
FracDWI["Male.Age15"]
sorry for the typo. I used [Male,Age15].
The model is fine; the only problem is when I use sensitivity analyses using the file option. I have separate columns for my parameters in the text file. For example fracDWI[Male,Age15], fracDWI[Male,Age16],...

I am not sure how the headers should be changed to run the sensitivity analysis using the file option.
Administrator
Super Administrator
Posts: 4590
Joined: Wed Mar 05, 2003 3:10 am

Re: Sensitivity analysis using the file option in a subscripted model

Post by Administrator »

If you can upload what you have, we can take a look.
Advice to posters seeking help (it really helps us to help you)
http://www.ventanasystems.co.uk/forum/v ... f=2&t=4391

Units are important!
http://www.bbc.co.uk/news/magazine-27509559
Administrator
Super Administrator
Posts: 4590
Joined: Wed Mar 05, 2003 3:10 am

Re: Sensitivity analysis using the file option in a subscripted model

Post by Administrator »

Maybe the best thing to do is get a simple example working using the sensitivity wizard, that will give you a working file that you can then edit using a text editor.
Advice to posters seeking help (it really helps us to help you)
http://www.ventanasystems.co.uk/forum/v ... f=2&t=4391

Units are important!
http://www.bbc.co.uk/news/magazine-27509559
niyousha@vt.edu
Junior Member
Posts: 6
Joined: Thu Aug 24, 2023 7:00 pm
Vensim version: DSS

Re: Sensitivity analysis using the file option in a subscripted model

Post by niyousha@vt.edu »

Administrator wrote: Fri Aug 25, 2023 3:26 pm If you can upload what you have, we can take a look.
I used a simple version (parameters without any subscript) and I did not get any error. As soon as I add a parameter with subscript, I get error.

I would like to share my text file that I use in my sensitivity analysis but the attachment cannot be a text file so I am attaching an excel file that I use to convert to text.
Attachments
MCMC5.xls
(61.5 KiB) Downloaded 45 times
tomfid
Administrator
Posts: 3811
Joined: Wed May 24, 2006 4:54 am

Re: Sensitivity analysis using the file option in a subscripted model

Post by tomfid »

When I save this as tab-delimited text, Excel quotes the column headers like
"fracDWI[Male,Age15]"
This is a nonstandard behavior, because quotes are not needed when the delimiter is tab (only csv).

Unfortunately this is not legitimate quoting in Vensim (the subscript brackets should not be included).

A quick search/replace of the text file to delete the " should solve the problem.
tomfid
Administrator
Posts: 3811
Joined: Wed May 24, 2006 4:54 am

Re: Sensitivity analysis using the file option in a subscripted model

Post by tomfid »

Another option is to copy-paste the file:

https://superuser.com/questions/206060/ ... out-quotes
niyousha@vt.edu
Junior Member
Posts: 6
Joined: Thu Aug 24, 2023 7:00 pm
Vensim version: DSS

Re: Sensitivity analysis using the file option in a subscripted model

Post by niyousha@vt.edu »

tomfid wrote: Mon Sep 04, 2023 2:49 pm When I save this as tab-delimited text, Excel quotes the column headers like
"fracDWI[Male,Age15]"
This is a nonstandard behavior, because quotes are not needed when the delimiter is tab (only csv).

Unfortunately this is not legitimate quoting in Vensim (the subscript brackets should not be included).

A quick search/replace of the text file to delete the " should solve the problem.


Thank you Tom. Editing the text file (deleting " that excel generated and extra spaces) resolved the problem. Thanks for your help.
Post Reply