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
537a87ae
Commit
537a87ae
authored
8 years ago
by
Maria Voigt
Browse files
Options
Downloads
Patches
Plain Diff
fix bugs in random crossvalidation
parent
5c6f4940
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/model_fitting/abundance_model.R
+9
-6
9 additions, 6 deletions
src/model_fitting/abundance_model.R
with
9 additions
and
6 deletions
src/model_fitting/abundance_model.R
+
9
−
6
View file @
537a87ae
...
@@ -52,7 +52,7 @@ option_list <- list (
...
@@ -52,7 +52,7 @@ option_list <- list (
dest
=
"exclude_grid_rand_perc"
,
dest
=
"exclude_grid_rand_perc"
,
type
=
"integer"
,
type
=
"integer"
,
default
=
NA
,
default
=
NA
,
help
=
"perce
m
t cells to be excluded"
,
help
=
"perce
n
t cells to be excluded"
,
metavar
=
"10"
),
metavar
=
"10"
),
make_option
(
c
(
"-q"
,
"--quiet"
),
dest
=
"verbose_script"
,
make_option
(
c
(
"-q"
,
"--quiet"
),
dest
=
"verbose_script"
,
action
=
"store_false"
,
action
=
"store_false"
,
...
@@ -115,6 +115,9 @@ if(is_verbose){print(paste("exclude grid", exclude_grid))}
...
@@ -115,6 +115,9 @@ if(is_verbose){print(paste("exclude grid", exclude_grid))}
exclude_grid_rand
<-
options
$
exclude_grid_rand
exclude_grid_rand
<-
options
$
exclude_grid_rand
if
(
is_verbose
){
print
(
paste
(
"exclude grid random"
,
exclude_grid_rand
))}
if
(
is_verbose
){
print
(
paste
(
"exclude grid random"
,
exclude_grid_rand
))}
exclude_grid_rand_perc
<-
options
$
exclude_grid_rand_perc
if
(
is_verbose
){
print
(
paste
(
"exclude_grid_rand_perc"
,
exclude_grid_rand_perc
))}
#---------#
#---------#
# Globals #
# Globals #
#---------#
#---------#
...
@@ -364,7 +367,7 @@ m_terms <- c("1",
...
@@ -364,7 +367,7 @@ m_terms <- c("1",
"I(rain_dry^2)"
)
"I(rain_dry^2)"
)
save.image
(
file.path
(
outdir
,
"image_before_model.RData"
))
save.image
(
file.path
(
outdir
,
paste0
(
"image_before_model
_"
,
exclude_grid_rand
,
"
.RData"
))
)
# save model_terms here
# save model_terms here
model_terms
<-
names
(
glm.nb
(
as.formula
(
paste
(
"nr_nests~"
,
paste
(
m_terms
,
model_terms
<-
names
(
glm.nb
(
as.formula
(
paste
(
"nr_nests~"
,
paste
(
m_terms
,
...
@@ -513,13 +516,13 @@ results_res <- foreach(i = 1:nrow(all_model_terms),
...
@@ -513,13 +516,13 @@ results_res <- foreach(i = 1:nrow(all_model_terms),
}
}
if
(
!
is.na
(
exclude_grid_rand
)){
if
(
!
is.na
(
exclude_grid_rand
)){
predictors_excluded_grid_pred
<-
predictors_excluded_grid_rand
predictors_excluded_grid_
rand_
pred
<-
predictors_excluded_grid_rand
predictors_excluded_grid_pred
$
offset_term
<-
0
predictors_excluded_grid_
rand_
pred
$
offset_term
<-
0
prediction_transect_excluded_grid
<-
predict.glm
(
res
,
prediction_transect_excluded_grid
_rand
<-
predict.glm
(
res
,
newdata
=
predictors_excluded_grid_rand
,
newdata
=
predictors_excluded_grid_rand
,
type
=
"response"
)
type
=
"response"
)
cross_lm_random
=
lm
(
log
(
predictors_excluded_grid_rand
$
ou_dens
+
1
)
~
cross_lm_random
=
lm
(
log
(
predictors_excluded_grid_rand
$
ou_dens
+
1
)
~
log
(
prediction_transect_excluded_rand
om
+
1
))
log
(
prediction_transect_excluded_
grid_
rand
+
1
))
result
[
,
"R2_cross"
]
<-
summary
(
cross_lm_random
)
$
r.squared
result
[
,
"R2_cross"
]
<-
summary
(
cross_lm_random
)
$
r.squared
result
[
,
"nr_excluded"
]
<-
nr_excluded
result
[
,
"nr_excluded"
]
<-
nr_excluded
...
...
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