# Sensitivity with correlated inputs

**URL:** <https://uqworld.org/t/sensitivity-with-correlated-inputs/2024>\
**Category:** Community Q&A and How To\
**Tags:** sensitivity, pce, ancova\
**Created:** [November 10, 2023, 5:15pm UTC](https://uqworld.org/t/sensitivity-with-correlated-inputs/2024 "2023-11-10T17:15:26Z")\
**Posts on this page:** 7\
**Page:** 1

<div class="post-metadata">

**Author:** ![giansteve](https://uqworld.org/user_avatar/uqworld.org/giansteve/32/973_2.png) [@giansteve](https://uqworld.org/u/giansteve)\
**Post date:** [November 10, 2023, 5:15pm UTC](https://uqworld.org/t/sensitivity-with-correlated-inputs/2024/1 "2023-11-10T17:15:26Z")

</div>

Hi there,

I am trying to compute the ANCOVA sensitivity indices using UQlab.  
In my problem, I have correlated inputs, and the input dimension is M=20. My output is also dynamic, meaning I have different time instances. But for now, I will consider N\_{out} = 1 for simplicity. I collected the data from a computational study of one colleague of mine. Therefore, I do not possess the model for the computation of more samples. I got my list of input and output with sample size N\_s = 800.

If I understood correctly, the ANCOVA analysis needs the input and output domain characteristics (not the samples), the model, and the sample size to compute the PCE. If correct, can I perform an ANCOVA without the model definition? I try to run it without the model definition, but I keep getting the same error:

```matlab
Error: There is no MODEL provided!
While initializing the analysis
Error in uq_initialize_uq_sensitivity (line 730)
                error('While initializing the analysis');

```

I paste here part of the code from which I get the error:

```matlab
%% loading the data
% input files
inputMatrix= load('FE_Results_23-XP005-V7-inputData1.csv');
% output files
output_sim = load('FE_Results_23-XP005-V7-output.csv');

%% Input module
ModelOpts.Marginals(1).Type = 'Uniform';
ModelOpts.Marginals(1).Parameters = [22.99, 24.00];
ModelOpts.Marginals(2).Type = 'Beta';
ModelOpts.Marginals(2).Parameters = [1268.35, 1270.81];
ModelOpts.Marginals(3).Type = 'Logistic';
...

% Dependence
ModelOpts.Copula.Type = 'Gaussian';
ModelOpts.Copula.Parameters = [1, 0.0099, -0.0042, 0.05...] % 20 times 20 array

myInput = uq_createInput(ModelOpts);

%% ANCOVA sensitivity indices
clear('ANCOVAAnalysis','ANCOVASensOpts')
ANCOVASensOpts.Type = 'Sensitivity';
ANCOVASensOpts.Method = 'ANCOVA';

ANCOVASensOpts.ANCOVA.Samples.X = inputMatrix;
ANCOVASensOpts.ANCOVA.Samples.Y = output_sim;

ANCOVAAnalysis = uq_createAnalysis(ANCOVASensOpts);

```

I also tried to compute a PCE surrogate from my data (input and output) and use it as a model for the ANCOVA. In this case, I do not get the error I mentioned above. However, I am not sure that this approach really makes sense.

Thank you for reading this far, and for any help you can provide

Greetings  
Gian

---

<div class="post-metadata">

**Author:** ![styfen.schaer](https://uqworld.org/user_avatar/uqworld.org/styfen.schaer/32/849_2.png) [@styfen.schaer](https://uqworld.org/u/styfen.schaer)\
**Post date:** [November 14, 2023, 4:34pm UTC](https://uqworld.org/t/sensitivity-with-correlated-inputs/2024/2 "2023-11-14T16:34:06Z")

</div>

Hi @giansteve

Can you provide a minimal reproducible example, i.e. fill in the missing part in your script and add data? It doesn’t have to be the real data, dummy data is fine.

Best regards  
Styfen

---

<div class="post-metadata">

**Author:** ![giansteve](https://uqworld.org/user_avatar/uqworld.org/giansteve/32/973_2.png) [@giansteve](https://uqworld.org/u/giansteve)\
**Post date:** [November 15, 2023, 9:14am UTC](https://uqworld.org/t/sensitivity-with-correlated-inputs/2024/3 "2023-11-15T09:14:19Z")

</div>

Hi @styfen.schaer,

thank you for your message.  
Here you can find the zip file with the Matlab file and input and output data. I trimmed the input and output space to make their dummy versions. The problem is still the same.

[example\_uqlab.zip](https://uqworld.org/uploads/short-url/uK9J9LCeIiNUKMIa6yXBDBS4egG.zip) (48.0 KB)

Thank you in advance 😊  
Gian

---

<div class="post-metadata">

**Author:** ![styfen.schaer](https://uqworld.org/user_avatar/uqworld.org/styfen.schaer/32/849_2.png) [@styfen.schaer](https://uqworld.org/u/styfen.schaer)\
**Post date:** [November 15, 2023, 1:02pm UTC](https://uqworld.org/t/sensitivity-with-correlated-inputs/2024/4 "2023-11-15T13:02:01Z")

</div>

Hi @giansteve

Is it possible that you have uploaded the wrong file? To me, it looks like `main_SA_v3.m` is trying to load the real data from an absolute path from your machine. The dummy input also has fewer dimensions than the one specified in the script. 🙂

---

<div class="post-metadata">

**Author:** ![giansteve](https://uqworld.org/user_avatar/uqworld.org/giansteve/32/973_2.png) [@giansteve](https://uqworld.org/u/giansteve)\
**Post date:** [November 15, 2023, 1:25pm UTC](https://uqworld.org/t/sensitivity-with-correlated-inputs/2024/5 "2023-11-15T13:25:05Z")

</div>

Oplá, sorry. I updated the wrong file in the zip folder, “it never happened to me” 🤣  
I modified the uploaded file in the message above. It should be fine now.

---

<div class="post-metadata">

**Author:** ![styfen.schaer](https://uqworld.org/user_avatar/uqworld.org/styfen.schaer/32/849_2.png) [@styfen.schaer](https://uqworld.org/u/styfen.schaer)\
**Post date:** [November 16, 2023, 1:18pm UTC](https://uqworld.org/t/sensitivity-with-correlated-inputs/2024/6 "2023-11-16T13:18:12Z")

</div>

Hello @giansteve

Thanks for the updated data and script, I can now reproduce the error. It is indeed a bug in UQLab. The fix is very simple. Enter `edit uq_initialize_uq_sensitivity.m` and update the if statement in line 728 from:

```matlab
if isempty(Internal.Model)
    ...
end

```

to

```matlab
if isempty(Internal.Model) && SamplesEmpty
    ...
end

```

If you run it with the dummy data, you will see another error. However, this one is related to the dummy data where one of the outputs is constant.

In any case, thanks for reporting this!

---

<div class="post-metadata">

**Author:** ![giansteve](https://uqworld.org/user_avatar/uqworld.org/giansteve/32/973_2.png) [@giansteve](https://uqworld.org/u/giansteve)\
**Post date:** [November 16, 2023, 1:37pm UTC](https://uqworld.org/t/sensitivity-with-correlated-inputs/2024/7 "2023-11-16T13:37:48Z")

</div>

Hi @styfen.schaer ,

thank you so much for this 😊  
Best  
Gian
