Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
I
Impact démographique des collisions aviaires avec les éoliennes
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Wiki
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Build
Pipelines
Jobs
Pipeline schedules
Artifacts
Deploy
Releases
Package Registry
Model registry
Operate
Environments
Terraform modules
Monitor
Incidents
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Terms and privacy
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
CEFE
Interactions Humains-Animaux
Impact démographique des collisions aviaires avec les éoliennes
Commits
28d1ab41
Commit
28d1ab41
authored
3 years ago
by
thierrychambert
Browse files
Options
Downloads
Patches
Plain Diff
Get metrics : changed 'mean' by 'median' as the average metric
parent
049c54ca
No related branches found
No related tags found
No related merge requests found
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
R/get_metrics.R
+19
-12
19 additions, 12 deletions
R/get_metrics.R
with
19 additions
and
12 deletions
R/get_metrics.R
+
19
−
12
View file @
28d1ab41
...
...
@@ -17,7 +17,7 @@
#' @param cumulated_impacts Logical. Must be set to TRUE if the output array N corresponds to
#' a cumulated impacts demographic analysis (see ?run_simul).
#'
#' @return a list of metric outputs : mean, SD, 95% C.I. of the
#' @return a list of metric outputs : me
di
an, SD, 95% C.I. of the
#' @export
#'
#' @examples
...
...
@@ -34,6 +34,12 @@ get_metrics <- function(N, cumulated_impacts = FALSE){
warning
<-
NULL
### Impact of each SCENARIO #####
DR_N_sc
<-
array
(
NA
,
dim
=
c
(
dim
(
N
)[
2
],
dim
(
N
)[
4
],
dim
(
N
)[
3
]),
dimnames
=
list
(
paste0
(
"year"
,
1
:
dim
(
N
)[
2
]),
NULL
,
paste0
(
"sc"
,
(
1
:
dim
(
N
)[
3
])
-1
)
))
impact_sc
<-
array
(
NA
,
dim
=
c
(
dim
(
N
)[
2
],
4
,
dim
(
N
)[
3
]),
dimnames
=
list
(
paste0
(
"year"
,
1
:
dim
(
N
)[
2
]),
c
(
"avg"
,
"se"
,
"lci"
,
"uci"
),
...
...
@@ -50,8 +56,8 @@ get_metrics <- function(N, cumulated_impacts = FALSE){
## Create a warning if the sample size (number of useable iterations for calculation) becomes too small
spl_size
<-
apply
(
N_ref
,
1
,
function
(
x
)
sum
(
!
is.nan
(
x
))
)
function
(
x
)
sum
(
!
is.nan
(
x
))
)
# Warning message, if required
if
(
min
(
spl_size
)
<
200
)
warning
<-
paste0
(
...
...
@@ -59,12 +65,13 @@ get_metrics <- function(N, cumulated_impacts = FALSE){
min
(
which
(
spl_size
<
200
)),
", due to high extinction rate.
Use more simulations to get accurate proportions and uncertainty metrics."
)
)
for
(
j
in
1
:
dim
(
N
)[
3
]){
# Relative Difference of Population Size
DR_N
<-
(
colSums
(
N
[,,
j
,])
-
N_ref
)
/
N_ref
DR_N_sc
[,,
j
]
<-
DR_N
# Remove cases where impact > 0
sel
<-
which
(
DR_N
>
0
,
arr.ind
=
TRUE
)
...
...
@@ -73,10 +80,8 @@ get_metrics <- function(N, cumulated_impacts = FALSE){
DR_N
<-
DR_N
[,
-
sel2
]
}
# Impact metric : Average value
impact_sc
[,
"avg"
,
j
]
<-
apply
(
DR_N
,
1
,
mean
,
na.rm
=
TRUE
)
# Impact metric : SE
# Impact metric : Median and SE
impact_sc
[,
"avg"
,
j
]
<-
apply
(
DR_N
,
1
,
median
,
na.rm
=
TRUE
)
impact_sc
[,
"se"
,
j
]
<-
apply
(
DR_N
,
1
,
sd
,
na.rm
=
TRUE
)
# Impact metric : Upper and Lower Confidence Intervals for DR_N
...
...
@@ -105,6 +110,7 @@ get_metrics <- function(N, cumulated_impacts = FALSE){
# Save scenario impacts into a list
scenario_impacts
<-
list
(
DR_N
=
DR_N_sc
,
impact
=
impact_sc
,
Pext
=
Pext_sc
,
DR_Pext
=
DR_Pext_sc
)
...
...
@@ -122,7 +128,7 @@ get_metrics <- function(N, cumulated_impacts = FALSE){
dimnames
=
list
(
paste0
(
"year"
,
1
:
dim
(
N
)[
2
]),
c
(
"avg"
,
"se"
,
"lci"
,
"uci"
),
paste0
(
"sc"
,
(
1
:
dim
(
N
)[
3
])
-1
)
))
))
Pext_indiv
<-
DR_Pext_indiv
<-
NA
...
...
@@ -164,8 +170,8 @@ get_metrics <- function(N, cumulated_impacts = FALSE){
DR_N
<-
DR_N
[,
-
sel2
]
}
# Mean and SE
impact_indiv
[,
"avg"
,
j
]
<-
apply
(
DR_N
,
1
,
mean
,
na.rm
=
TRUE
)
# Me
di
an and SE
impact_indiv
[,
"avg"
,
j
]
<-
apply
(
DR_N
,
1
,
me
di
an
,
na.rm
=
TRUE
)
impact_indiv
[,
"se"
,
j
]
<-
apply
(
DR_N
,
1
,
sd
,
na.rm
=
TRUE
)
# Upper and Lower Confidence Intervals for DR_N
...
...
@@ -197,12 +203,13 @@ get_metrics <- function(N, cumulated_impacts = FALSE){
# Save individual wind farm impacts into a list
indiv_impacts
<-
list
(
DR_N
=
DR_N
,
impact
=
impact_indiv
,
Pext
=
Pext_indiv
,
DR_Pext
=
DR_Pext_indiv
)
}
# end if "c
i=
umulated_impacts"
}
# end if "cumulated_impacts"
...
...
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment