Skip to content
This repository has been archived by the owner on Jul 29, 2020. It is now read-only.

Commit

Permalink
small changes to Week 7 lecture
Browse files Browse the repository at this point in the history
  • Loading branch information
James-Thorson committed May 8, 2018
1 parent e5e2dea commit 3215142
Show file tree
Hide file tree
Showing 3 changed files with 9 additions and 5 deletions.
Binary file not shown.
3 changes: 3 additions & 0 deletions Week 7 -- spatiotemporal models/Lecture/Lecture_7.R
Original file line number Diff line number Diff line change
Expand Up @@ -40,3 +40,6 @@ unlist( Report[c('Range','SigmaO','SigmaE')] )
Cov_Dt = Opt$SD$cov
Corr_Dt = cov2cor( Cov_Dt )

#
plot( x=SimList$b_t, y=Opt$SD$value )
matplot( x=1:SimList$n_years, y=cbind(SimList$b_t/mean(SimList$b_t),Opt$SD$value/mean(Opt$SD$value)), col=c("black","red"), type="l", lwd=2 )
11 changes: 6 additions & 5 deletions Week 7 -- spatiotemporal models/Lecture/spatial_index_model.cpp
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@

#include <TMB.hpp>

// Function for detecting NAs
template<class Type>
bool isNA(Type x){
Expand Down Expand Up @@ -68,11 +69,11 @@ Type objective_function<Type>::operator() ()
Type jnll = jnll_comp.sum();

// Derived quantities
vector<Type> D_t( n_t );
D_t.setZero();
vector<Type> b_t( n_t );
b_t.setZero();
for( int t=0; t<n_t; t++){
for( int s=0; s<n_s; s++){
D_t(t) += a_s(s) * exp(log_d_st(s,t));
b_t(t) += a_s(s) * exp(log_d_st(s,t));
}}

// Reporting
Expand All @@ -82,8 +83,8 @@ Type objective_function<Type>::operator() ()
REPORT( SigmaE );
REPORT( SigmaO );
REPORT( log_d_st );
REPORT( D_t );
ADREPORT( D_t );
REPORT( b_t );
ADREPORT( b_t );

return jnll;
}

0 comments on commit 3215142

Please sign in to comment.