I have read many-a-posts on fixing parameters, and I don't think any of them address the issue I am currently having. I understand that the coding for fixing parameters has been updated and I can use "show.fixed=TRUE" in the summary function to view my fixed parameters and estimated real parameters:
http://www.phidot.org/forum/viewtopic.php?f=21&t=2887
However, once I try to use the model.average function, it's almost as if the fixed parameters are still being registered as NAs. I get an error: Error in deriv.real %*% model$results$beta.vcv : non-conformable arguments.
I have been trying to trouble-shoot what I have done wrong to mangle things up. Here is my code. I am wanting to estimate recruitment (f), and I want to fix Phi and p at each time interval because I have already estimated these parameters using a more robust data set in a previous CJS model:
- Code: Select all
pradel.process <-process.data(Freeman.df,model="Pradrec",time.intervals=c(1,1,1,1),
begin.time=2015)
Freeman.ddl <- make.design.data(pradel.process)
#fixing Phi parameters to the estimates calculated by more robust CJS models#
Freeman.ddl$Phi$fix=NA
Freeman.ddl$Phi$fix[Freeman.ddl$Phi$time==2015]=0.295
Freeman.ddl$Phi$fix[Freeman.ddl$Phi$time==2016]=0.302
Freeman.ddl$Phi$fix[Freeman.ddl$Phi$time==2017]=0.288
Freeman.ddl$Phi$fix[Freeman.ddl$Phi$time==2018]=0.273
#fixing p parameters in the same fashion#
Freeman.ddl$p$fix=NA
Freeman.ddl$p$fix[Freeman.ddl$p$time==2015]=0.31
Freeman.ddl$p$fix[Freeman.ddl$p$time==2016]=0.32
Freeman.ddl$p$fix[Freeman.ddl$p$time==2017]=0.33
Freeman.ddl$p$fix[Freeman.ddl$p$time==2018]=0.34
Freeman.ddl$p$fix[Freeman.ddl$p$time==2019]=0.35
#include covariates for recruitment#
f.weather.covariate.df <- data.frame(time=c(2015,2016,2017,2018,2019),
sum_extreme=scale(c(14,11,16,24,25)),
win_extreme=scale(c(7,7,17,11,13)),
total_precip=scale(c(49.3,49.7,40.3,44.2,22.0)),
wint_precip=scale(c(4.19,8.52,5.3,9.08,3.58)),
sum_precip=scale(c(3.28,9.08,15.05,9.38,3.85)),
wint=scale(c(42.7,46.5,39.6,42.2,40.4)),
summ=scale(c(94.7,94.3,96.3,97.6,96.3)))
Freeman.ddl$f <- merge_design.covariates(Freeman.ddl$f,f.weather.covariate.df)
#make sure fixed parameters are entered correctly#
summary(mark(pradel.process,Freeman.ddl,output=FALSE),show.fixed=TRUE)
Phi.dot=list(formula=~1)
p.dot=list(formula=~1)
f.dot=list(formula=~1)
f.t=list(formula=~time)
# for weather covariates #
f.sum_precip=list(formula=~sum_precip)
f.wint_precip=list(formula=~wint_precip)
f.total_precip=list(formula=~total_precip)
f.win_extreme=list(formula=~win_extreme)
f.sum_extreme=list(formula=~sum_extreme)
# I have even tried entering in fixed parameters this way, but not for this example #
#it still resulted in the same issue#
#Phi.fix=list(formula=~time,fixed=list(time=c(2015:2018),value=c(0.295,0.302,0.288,0.273)))
#p.fix=list(formula=~time,fixed=list(time=c(2015:2019),value=c(0.31,0.32,0.33,0.34,0.35)))
#models#
Phi.dot_p.dot_f.dot<-mark(pradel.process,Freeman.ddl,model.parameters=list(Phi=Phi.dot,p=p.dot,f=f.dot))
Phi.dot_p.dot_f.t<-mark(pradel.process,Freeman.ddl,model.parameters=list(Phi=Phi.dot,p=p.dot,f=f.t))
summary(Phi.dot_p.dot_f.t,show.fixed=TRUE) #once again checking that the fixed parameters are correct #
#models with covariates#
Phi.dot_p.dot_f.sum_extreme<-mark(pradel.process,Freeman.ddl,model.parameters=list(Phi=Phi.dot,p=p.dot,f=f.sum_extreme))
Phi.dot_p.dot_f.win_extreme<-mark(pradel.process,Freeman.ddl,model.parameters=list(Phi=Phi.dot,p=p.dot,f=f.win_extreme))
Phi.dot_p.dot_f.total_precip<-mark(pradel.process,Freeman.ddl,model.parameters=list(Phi=Phi.dot,p=p.dot,f=f.total_precip))
Phi.dot_p.dot_f.wint_precip<-mark(pradel.process,Freeman.ddl,model.parameters=list(Phi=Phi.dot,p=p.dot,f=f.wint_precip))
Phi.dot_p.dot_f.sum_precip<-mark(pradel.process,Freeman.ddl,model.parameters=list(Phi=Phi.dot,p=p.dot,f=f.sum_precip))
#put models into AICc table#
pradel.results<-collect.models(type="Pradrec")
pradel.results
#model average - this is the part that does not work#
mod.avg <- model.average(pradel.results,parameter="f",vcv=T)$estimates
I would love any and all feedback. I understand what I am trying to do, but somewhere in my code, I'm not feeding the model.average function what it needs to compute real estimates for recruitment.
Thank you so much,
Rebekah