Adjust.parameter.count

posts related to the RMark library, which may not be of general interest to users of 'classic' MARK

Adjust.parameter.count

Postby wijw » Thu Jan 05, 2023 6:37 pm

I would like to adjust the parameter count of some models. I have looked at the RMARK documentation and I know I have to use the following code.
Code: Select all
adjust.parameter.count(model, npar)


Here is the code I currently have:
Code: Select all
run.kfm = function()
{
 
S.dot = list(formula = ~1)
S.group = list(formula = ~rt)
S.acc = list(formula = ~acc)
S.mme = list(formula = ~mme)
S.group.acc = list(formula = ~rt*acc)
S.group.acc.add = list(formula = ~rt+acc)
S.group.mme = list(formula = ~mme*rt)
S.group.mme.add = list(formula = ~mme+rt)
S.mme.acc = list(formula = ~mme*acc)
S.mme.acc.add = list(formula = ~mme+acc)

S.mme.acc.add = adjust.parameter.count(S.mme.acc.add, 4)

model.list = create.model.list("Known")

kfm.results = mark.wrapper(model.list,
                           data = kfm.process,
                           ddl = kfm.ddl)


return(kfm.results)
}

kfm.results = run.kfm()
kfm.results


But when I run the code, I get the error message
Error in if (model$results$npar != npar) { : argument is of length zero.


I have tried moving S.mme.acc.add = adjust.parameter.count(S.mme.acc.add, 4) around, but it still gives me the same error message. I am wondering if the error occurs because I am using mark.wrapper function. How should I change my code?

Any advice is appreciated. Thank you.
wijw
 
Posts: 23
Joined: Mon Oct 26, 2020 2:27 pm

Re: Adjust.parameter.count

Postby jlaake » Fri Jan 06, 2023 2:13 pm

Notice that as it describes in help, the argument for adjust.parameter.count is a MARK model object ( a result object). You applied it to a list for a formula.

Adjust count of estimated parameters
Description
Modifies number of estimated parameters and the resulting AICc value for model selection.

Usage
adjust.parameter.count(model, npar)
Arguments
model
MARK model object

npar
Value of count of estimated parameters



Below is an example of how to do this with mark.wrapper.
Code: Select all
library(RMark)
data(dipper)
fit_models=function()
{
  dp=process.data(dipper)
  ddl=make.design.data(dp)
  Phi.1=list(formula=~1)
  Phi.2=list(formula=~time)
  p.1=list(formula=~1)
  p.2=list(formula=~time)
  cml=create.model.list("CJS")
  results=mark.wrapper(cml,data=dp,ddl=ddl)
  results
}
results=fit_models()
#adjust parameters for model 4 in list to 11
results[[4]]=adjust.parameter.count(results[[4]],11)
# note that it is only changed in results[[4]] but not in model.table
results
#redo model.table
results$model.table=model.table(results)
jlaake
 
Posts: 1417
Joined: Fri May 12, 2006 12:50 pm
Location: Escondido, CA

Re: Adjust.parameter.count

Postby wijw » Fri Jan 06, 2023 4:59 pm

Oh, oops. I didn't realize that mistake. Thank you for the clarification.
wijw
 
Posts: 23
Joined: Mon Oct 26, 2020 2:27 pm


Return to RMark

Who is online

Users browsing this forum: Bing [Bot] and 21 guests

cron