Revision 1109 trunk/src/df1b2separable/df1b2lme.cpp
df1b2lme.cpp (revision 1109)  

2  2 
* $Id$ 
3  3 
* 
4  4 
* Author: David Fournier 
5 
* Copyright (c) 20082012 Regents of the University of California


5 
* Copyright (c) 20082012 Regents of the University of California 

6  6 
*/ 
7  7 
/** 
8  8 
* \file 
...  ...  
42  42 
ad_exit(1); 
43  43 
} 
44  44 
df1b2_gradlist::set_no_derivatives(); 
45 
int nvar=initial_params::nvarcalc_all();


45 
int nvar=initial_params::nvarcalc_all(); 

46  46 
dvector x(1,nvar); 
47 
initial_params::xinit_all(x);


47 
initial_params::xinit_all(x); 

48  48 
initial_df1b2params::reset_all(x); 
49  49 
for (int i=1;i<=nvar;i++) y(i)=x(i); 
50  50 
step=get_newton_raphson_info_banded(pfmin); 
...  ...  
56  56 
ad_exit(1); 
57  57 
} 
58  58  
59 


60  59 
dvector df0=exp(2.0*value(*variance_components_vector)); 
61 


60  
62  61 
dvector vsave(mmin,mmax); 
63  62 
vsave=value(*variance_components_vector); 
64  63 
for(int ic=mmin;ic<=mmax;ic++) 
65 
{


64 
{ 

66  65 
(*variance_components_vector)(ic)+=0.2; 
67 


66  
68  67 
// test newton raphson 
69  68 
switch(hesstype) 
70  69 
{ 
...  ...  
80  79 
} 
81  80  
82  81 
df1b2_gradlist::set_no_derivatives(); 
83 
int nvar=initial_params::nvarcalc_all();


82 
int nvar=initial_params::nvarcalc_all(); 

84  83 
dvector x(1,nvar); 
85 
initial_params::xinit_all(x);


84 
initial_params::xinit_all(x); 

86  85 
initial_df1b2params::reset_all(x); 
87  86 
for (int i=1;i<=nvar;i++) y(i)=x(i); 
88  87 
step=get_newton_raphson_info_banded(pfmin); 
...  ...  
124  123 
{ 
125  124 
int mmin=variance_components_vector>indexmin(); 
126  125 
int mmax=variance_components_vector>indexmax(); 
127 


128 
initial_params::set_inactive_only_random_effects();


126  
127 
initial_params::set_inactive_only_random_effects(); 

129  128 
independent_variables xx(1,mmaxmmin+1); 
130  129 
initial_params::xinit(xx); // get the initial values into the 
131  130 
dvar_vector vxx=dvar_vector(xx); 
...  ...  
143  142 
case 4: 
144  143 
{ 
145  144 
for(int ic=mmin;ic<=mmax;ic++) 
146 
{


145 
{ 

147  146 
if (var_flag==1) 
148  147 
{ 
149 
vHess+=


148 
vHess+= 

150  149 
(*variance_components_vector)(ic)*((*Hess_components)(ic)); 
151  150 
} 
152  151 
else 
...  ...  
177  176 
ADUNCONST(double,f) 
178  177 
//int i,j; 
179  178  
180 
initial_params::set_inactive_only_random_effects();


179 
initial_params::set_inactive_only_random_effects(); 

181  180 
gradient_structure::set_NO_DERIVATIVES(); 
182  181 
initial_params::reset(x); // get current x values into the model 
183  182 
gradient_structure::set_YES_DERIVATIVES(); 
184  183  
185 
initial_params::set_active_only_random_effects();


184 
initial_params::set_active_only_random_effects(); 

186  185 
dvector g=get_gradient_lme(pfmin); 
187  186  
188  187 
reset_gradient_stack(); 
189  188 
// this is the main loop to do inner optimization 
190  189 
//for (i=1;i<=xsize;i++) { y(i)=x(i); } 
191  190 
//for (i=1;i<=usize;i++) { y(i+xsize)=uhat(i); } 
192 


191  
193  192 
dvar_matrix vHess=get_hessian_from_components_lme(pfmin); 
Also available in: Unified diff