

Hello,
I am performing a sensitivity analysis using a Latin Hypercube sampling. However, I have difficulty to draw a Hypercube sample for one variable. I�ve generated this variable from a Poisson distribution as follows:
set.seed(5)
mortality_probability < round(ppois(seq(0, 7, by = 1), lambda = 0.9), 2)
barplot(mortality_probability, names.arg = seq(0, 7, by = 1), xlab = "Age class", ylab = "Probability")
How can I draw a Hypercube sample for the variable �mortality_probability� so that this variable exhibits the same pattern as the observed distribution?
Here is a reproducible code to draw Hypercube samples (my sensitivity analysis includes several parameters and the variables �var1� and �var2� follow a uniform distribution):
library(lhs)
set.seed(1)
parm < c("var1", "var2", "mortality_probability")
X < randomLHS(100, length(parm))
Any suggestions would be much welcome.
Thanks for your time
Marine
[[alternative HTML version deleted]]
______________________________________________
[hidden email] mailing list  To UNSUBSCRIBE and more, see
https://stat.ethz.ch/mailman/listinfo/rhelpPLEASE do read the posting guide http://www.Rproject.org/postingguide.htmland provide commented, minimal, selfcontained, reproducible code.


> How can I draw a Hypercube sample for the variable mortality_probability so
> that this variable exhibits the same pattern as the observed distribution?
One simple way is to use the uniform random output of randomLHS as input to the quantile function for your desired distribution(s).
For example:
q < randomLHS(1000, 3)
colnames(q) < c("A", "B", "mort")
q[, "mort"] < qpois(q[,"mort"], 1.5)
S Ellison
*******************************************************************
This email and any attachments are confidential. Any use, copying or
disclosure other than by the intended recipient is unauthorised. If
you have received this message in error, please notify the sender
immediately via +44(0)20 8943 7000 or notify [hidden email]
and delete this message and any copies from your computer and network.
LGC Limited. Registered in England 2991879.
Registered office: Queens Road, Teddington, Middlesex, TW11 0LY, UK
______________________________________________
[hidden email] mailing list  To UNSUBSCRIBE and more, see
https://stat.ethz.ch/mailman/listinfo/rhelpPLEASE do read the posting guide http://www.Rproject.org/postingguide.htmland provide commented, minimal, selfcontained, reproducible code.


Thanks for your answer.
However, my variable is simulated from the cumulative distribution function of the Poisson distribution. So, the pattern obtained from the function "qpois" is not the same as the observed pattern (i.e., obtained from the function "ppois")
set.seed(5)
mortality_probability < round(ppois(seq(0, 7, by = 1), lambda = 0.9), 2)
barplot(mortality_probability, names.arg = seq(0, 7, by = 1), xlab = "Age class", ylab = "Probability")
library(lhs)
set.seed(1)
parm < c("var1", "var2", "mortality_probability")
X < randomLHS(100, length(parm))
colnames(X) < c("var1", "var2", "mortality_probability")
X[, "mortality_probability"] < qpois(X[, "mortality_probability"], 0.9)
hist(X[, "mortality_probability"])
Thanks for your time
Marine
________________________________
De : S Ellison < [hidden email]>
Envoy� : lundi 7 ao�t 2017 14:36
� : Marine Regis; [hidden email]
Objet : RE: Latin hypercube sampling from a nonuniform distribution
> How can I draw a Hypercube sample for the variable mortality_probability so
> that this variable exhibits the same pattern as the observed distribution?
One simple way is to use the uniform random output of randomLHS as input to the quantile function for your desired distribution(s).
For example:
q < randomLHS(1000, 3)
colnames(q) < c("A", "B", "mort")
q[, "mort"] < qpois(q[,"mort"], 1.5)
S Ellison
*******************************************************************
This email and any attachments are confidential. Any use...{{dropped:11}}
______________________________________________
[hidden email] mailing list  To UNSUBSCRIBE and more, see
https://stat.ethz.ch/mailman/listinfo/rhelpPLEASE do read the posting guide http://www.Rproject.org/postingguide.htmland provide commented, minimal, selfcontained, reproducible code.


> However, my variable is simulated from the cumulative distribution function
> of the Poisson distribution.
Then I am afraid I don't know what you're trying to achieve.
Or why.
However, the principle holds; write a function that maps [0,1] to the 'pattern' you want, do that and apply it to the result from randomLHS.
It happens that for generating data that follow a given probability distribution F, that function is the quantile function for F so you often do not need to write it.
*******************************************************************
This email and any attachments are confidential. Any use...{{dropped:8}}
______________________________________________
[hidden email] mailing list  To UNSUBSCRIBE and more, see
https://stat.ethz.ch/mailman/listinfo/rhelpPLEASE do read the posting guide http://www.Rproject.org/postingguide.htmland provide commented, minimal, selfcontained, reproducible code.


Thanks for your answer.
I have attached the plot for representing the variable. I think that I need to draw a Hypercube sample for each age class (i.e., for 0, 1, 2, 3, 4, 5, 6, 7) in a given simulation (i.e., N = 1) and the LHS values for all age classes should be like the observed cumulative distribution (see attached figure). Thus, the output of randomLHS should be a matrix with 100 rows (N = 100 simulations) and 7 columns (7 age classes) containing LHS values and each row should exhibit the same pattern as the observed cumulative distribution.
With the command “qpois(X[, "mortality_probability"], 0.9)”, I don’t obtain a LHS value for each age class and the distribution is not a cumulative distribution as in the attached figure. So, I am afraid I don’t know how to do that.
Thanks so much for your time
Marine
________________________________
De : S Ellison < [hidden email]>
Envoyé : mardi 8 août 2017 14:48
À : Marine Regis; [hidden email]
Objet : RE: Latin hypercube sampling from a nonuniform distribution
> However, my variable is simulated from the cumulative distribution function
> of the Poisson distribution.
Then I am afraid I don't know what you're trying to achieve.
Or why.
However, the principle holds; write a function that maps [0,1] to the 'pattern' you want, do that and apply it to the result from randomLHS.
It happens that for generating data that follow a given probability distribution F, that function is the quantile function for F so you often do not need to write it.
*******************************************************************
This email and any attachments are confidential. Any use, copying or
disclosure other than by the intended recipient is unauthorised. If
you have received this message in error, please notify the sender
immediately via +44(0)20 8943 7000 or notify [hidden email]
and delete this message and any copies from your computer and network.
LGC Limited. Registered in England 2991879.
Registered office: Queens Road, Teddington, Middlesex, TW11 0LY, UK
______________________________________________
[hidden email] mailing list  To UNSUBSCRIBE and more, see
https://stat.ethz.ch/mailman/listinfo/rhelpPLEASE do read the posting guide http://www.Rproject.org/postingguide.htmland provide commented, minimal, selfcontained, reproducible code.


> I think that I need to
> draw a Hypercube sample for each age class (i.e., for 0, 1, 2, 3, 4, 5, 6, 7) in a
> given simulation (i.e., N = 1) and the LHS values for all age classes should be
> like the observed cumulative distribution (see attached figure).
> output of randomLHS should be a matrix with 100 rows (N = 100 simulations)
> and 7 columns (7 age classes) containing LHS values and each row should
> exhibit the same pattern as the observed cumulative distribution.
If you want each row to hold _different_ cumulative probabilities drawn at random from something, but broadly following your chosen nonrandom pattern, it sounds like you will need to decide what joint distribution you want to draw those probabilities from so that the cumulative 'probability' is strictly monotonic. You might then be able to work out how to map the multivariate [0,1] output of randomLHS to generate the relevant points. It's possible that a simple kludge applied rowwise to [0,1] values might work, but a) I can't think of one quickly and b) I'd have a hard time defending it if I did.
It sounds like you need to find a nearby statistician and explain what you are trying to achieve. They should be able to tell you either how to get there or, perhaps, why it's not sensible to start and what to do instead.
Sorry I can't help further
S.
*******************************************************************
This email and any attachments are confidential. Any use...{{dropped:8}}
______________________________________________
[hidden email] mailing list  To UNSUBSCRIBE and more, see
https://stat.ethz.ch/mailman/listinfo/rhelpPLEASE do read the posting guide http://www.Rproject.org/postingguide.htmland provide commented, minimal, selfcontained, reproducible code.

