Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
M
manuscript_code
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Wiki
Requirements
Code
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Locked files
Deploy
Releases
Model registry
Monitor
Incidents
Analyze
Value stream analytics
Contributor analytics
Repository analytics
Issue analytics
Insights
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
Maria Voigt
manuscript_code
Commits
f1501f64
Commit
f1501f64
authored
8 years ago
by
Maria Voigt
Browse files
Options
Downloads
Patches
Plain Diff
adapting the script to new model
deleting human density as interaction over years deleting zero inflation term
parent
5c3dce0e
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
src/prediction/abundance_prediction.R
+3
-10
3 additions, 10 deletions
src/prediction/abundance_prediction.R
with
3 additions
and
10 deletions
src/prediction/abundance_prediction.R
+
3
−
10
View file @
f1501f64
...
...
@@ -71,15 +71,10 @@ predictor_names_coeffs <- gsub("coeff_","", names(coeffs))
# paste0("I(", predictor_names_coeffs, "^2)")]
#quadratic_terms_names <- gsub("I\\(|\\^2\\)", "", quadratic_terms_names )
interaction_terms_names
<-
c
(
"human_pop_dens"
)
quadratic_terms_names
<-
c
(
"rain_dry"
)
predictor_names_coeffs
<-
predictor_names_coeffs
[
predictor_names_coeffs
!=
"(Intercept)"
]
# don't include interaction or quadratic term
predictor_names
<-
predictor_names_coeffs
[
!
grepl
(
"I(*)"
,
predictor_names_coeffs
)]
predictor_names
<-
predictor_names
[
!
grepl
(
"year[:punct:]*"
,
predictor_names
)]
# this is not a good fix, the problem is that with the second grepl also variable "year" gone
predictor_names
<-
c
(
"year"
,
predictor_names
)
# predictors for year on grid
print
(
paste
(
"these are predictor names: "
,
predictor_names
))
predictors_path
<-
path.to.current
(
indir_predictors
,
paste0
(
"predictors_abundance_"
,
...
...
@@ -106,12 +101,10 @@ print(paste("this is nrow predictors", nrow(predictors)))
intercept
<-
rep
(
1
,
nrow
(
predictors
))
predictor_estimates
<-
cbind
(
intercept
,
predictors
[
,
predictor_names
],
predictors
[
,
quadratic_terms_names
]
*
predictors
[
,
quadratic_terms_names
],
predictors
[
,
"year"
]
*
predictors
[
,
interaction_terms_names
])
predictors
[
,
quadratic_terms_names
]
*
predictors
[
,
quadratic_terms_names
])
names
(
predictor_estimates
)
<-
c
(
"intercept"
,
predictor_names
,
paste0
(
"I("
,
quadratic_terms_names
,
"^2)"
),
paste0
(
"year:"
,
interaction_terms_names
))
paste0
(
"I("
,
quadratic_terms_names
,
"^2)"
))
...
...
@@ -128,7 +121,7 @@ pred_estimates_sum <- apply(pred_estimates_wcoeffs, 1, sum)
# check this
# sonst zeroinflated part. wahrscheinlichkeit das null ist durhc 1- --> wahrscheinl das es 1 ist
# wahrscheinlich macht es auch sinn da prediktoren drin zu haben in zeroinflated part
pred_estimates_calc
<-
exp
(
pred_estimates_sum
)
*
(
1
-
(
1
/
(
1
+
exp
(
-
(
coeff_
(
Intercept
))))))
pred_estimates_calc
<-
exp
(
pred_estimates_sum
)
pred_estimates_weighted
<-
pred_estimates_calc
*
coeff_weights
$
w_aic
return
(
sum
(
pred_estimates_weighted
))
}
...
...
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