adding model names to collect.models

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

adding model names to collect.models

Postby markmiller » Tue Jun 03, 2014 4:24 pm

Occasionally I wish I could add model names to the AICc table created by collect.models().
This seems like it might be helpful when models are numerous and complex and parameterizations
differ only slightly. I think I figured out a way, using the code below.

However, my approach intuitively does not appear to be very efficient. I also wonder a
little how general or robust it is.

Does anyone know of an easier way?

The only other way I have thought of so far would be to modify the model.table() function
itself and I have not yet figured out how to do that.

Here is how I am adding the model names to the AICc table:

Code: Select all
###################################################################################

p             = list(formula =~ -1 + stratum + session)
Delta         = list(formula =~  1                    )

Phi0          = list(formula =~ -1 + stratum          )
Psi           = list(formula =~ -1 + stratum + time   )
R             = list(formula =~ -1 + stratum + time   )

model.A  = mark(rd.processed, rd.ddl,
                model.parameters = list( p     = p    ,
                                         Delta = Delta,
                                         Phi0  = Phi0 ,
                                         Psi   = Psi  ,
                                         R     = R    ))

model.A

###################################################################################

p             = list(formula =~  1                    )
Delta         = list(formula =~  1                    )

Phi0          = list(formula =~ -1 + stratum          )
Psi           = list(formula =~ -1 + stratum + time   )
R             = list(formula =~ -1 + stratum + time   )

model.B  = mark(rd.processed, rd.ddl,
                model.parameters = list( p     = p    ,
                                         Delta = Delta,
                                         Phi0  = Phi0 ,
                                         Psi   = Psi  ,
                                         R     = R    ))

model.B

###################################################################################

my.table <- collect.models(, adjust = FALSE, table = TRUE)

my.names <- collect.model.names( lx=ls())

names.in.table <- as.numeric(row.names(model.table(my.table, adjust = FALSE)))

my.model.names <- my.names[names.in.table]

my.table.with.model.names <- cbind(my.model.names, my.table$model.table)
my.table.with.model.names

###################################################################################
markmiller
 
Posts: 49
Joined: Fri Nov 08, 2013 6:23 pm

Re: adding model names to collect.models

Postby jlaake » Tue Jun 03, 2014 4:31 pm

See help for model.table. The default is model.name=TRUE. I think what you want is model.name=FALSE. Just use the names you want. What I do is name them p.1,p.2,... and Phi.1,Phi.2 etc and then set model.name=FALSE with mark.wrapper and I get things like p.1.Phi.1 etc. But you can use whatever naming convention you want.

model.name if TRUE uses the model.name in each mark object which uses
formula notation. If FALSE it uses the R names for the model obtained from
collect.model.names or names assigned to marklist elements
jlaake
 
Posts: 1480
Joined: Fri May 12, 2006 12:50 pm
Location: Escondido, CA

Re: adding model names to collect.models

Postby markmiller » Tue Jun 03, 2014 5:32 pm

Thank you, Jeff. That worked. I had never used the model.table() function until today. Here is the code:

Code: Select all
###################################################################################

my.table <- collect.models(, adjust = FALSE, table = TRUE)

model.table(my.table, model.name = FALSE, adjust=FALSE)

###################################################################################
markmiller
 
Posts: 49
Joined: Fri Nov 08, 2013 6:23 pm


Return to RMark

Who is online

Users browsing this forum: No registered users and 1 guest