check if model converge but no Neg2LnL in model.table

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

check if model converge but no Neg2LnL in model.table

Postby Mnat » Mon Nov 01, 2021 12:05 pm

Hi,
I'm still learning and trying out how Rmark modeling works. I work with a simplified subset of my dataset. I use data of one colony since 2002 and of a second colony since 2013. Therefore I use "remove.unused = T" during data processing to remove years that don't have data for the second colony. That's correct, isn't it?

I'm actually trying out how p is best defined and explore how models behave. Next to time and colony, I added effort (as factor) and Effort (as numeric) to the design data. Effort is the numer of days on which we captured the bats.

However, all models that contain the variable time are the same.

Code: Select all
model                                      npar AICc DeltaAICc       weight Deviance
8           Phi(~1)p(~-1 + time:colony)   28 2607.317  0.000000 2.451896e-01 1345.137
9  Phi(~1)p(~-1 + time:colony + effort)   28 2607.317  0.000000 2.451896e-01 1345.137
10 Phi(~1)p(~-1 + time:colony + Effort)   28 2607.317  0.000000 2.451896e-01 1345.137
11             Phi(~1)p(~time * colony)   28 2607.317  0.000000 2.451896e-01 1345.137
7                       Phi(~1)p(~time)   20 2612.407  5.089894 1.924180e-02 1366.909
6            Phi(~1)p(~Effort * colony)    5 2656.886 49.568486 4.225148e-12 1442.057
3         Phi(~1)p(~-1 + effort:colony)   12 2658.420 51.102640 1.962026e-12 1429.377
5            Phi(~1)p(~effort * colony)   12 2658.420 51.102640 1.962026e-12 1429.377
4         Phi(~1)p(~-1 + Effort:colony)    3 2664.033 56.715769 1.185302e-13 1453.235
1                     Phi(~1)p(~effort)    7 2670.853 63.535978 3.915973e-15 1451.981
2                     Phi(~1)p(~Effort)    3 2677.362 70.044669 0.000000e+00 1466.564

If I look at the model outputs, model 8 looks fine. However, model 9, 10 have 0 for all standart errors for p and model 11 has 0 for all standart errors for p in the second colony (2013-2021). I assume, all time models besides model 8 didn't converge. I tried to test this like it is described in the Rmark workshop notes using

Code: Select all
with(results$model.table, tapply(Neg2LnL, list(Phi,p),unique))


but the model table doesn't contain a column with Neg2LnL.
Whats wrong?

Tanks,
best
Bianca
Mnat
 
Posts: 18
Joined: Wed Apr 10, 2019 4:28 am

Re: check if model converge but no Neg2LnL in model.table

Postby jlaake » Mon Nov 01, 2021 2:26 pm

See help for ?model.table. You have to set use.lnl=TRUE in call to model.table to get Neg2Lnl values to show. I don't have it in front of me but I suppose that was done in the workshop notes.

I wouldn't recommend using remove.unused=TRUE as it isn't really necessary for this example and it can cause problems with mlogit parameters. I originally devised it for an example in which animals were only released every other year. In retrospect I wish I had not done so.

All of those models appear to be identical. If you include time in the model it has a separate parameter for each time, so it is not possible to also include effort. You are trying to fit a slope to a sequence of values that have already been specified by separate estimates. -1+colony:time will specify the same number of parameters as colony*time. In each case columns with all 0 (unused) are dropped. It appears both are dropping the the same number of columns. I would recommend -1+colony:time, ~effort+Time:colony, ~effort*colony, ~effort+ colony as possible models. Time is continuous so it is a slope and can be included with effort which is another slope.
jlaake
 
Posts: 1417
Joined: Fri May 12, 2006 12:50 pm
Location: Escondido, CA

Re: check if model converge but no Neg2LnL in model.table

Postby Mnat » Tue Nov 02, 2021 6:55 am

Thanks a lot for your recommendations and explanations.

However, I'm still a bit confused that the results from (-1+time:colony) are the same like for time*colony. They may specify the same number of parameters, but for my understanding parameters in time*colony have the same intercept, whereas parameters in -1+time:colony not (because I substract the intercept). Therefore I would expect that the values for AIC, weight and Dev are at least slightly different.

I'm also wondering why you recommend effort*colony instead of -1+effort:colony but you also suggest -1+colony:time?!
Mnat
 
Posts: 18
Joined: Wed Apr 10, 2019 4:28 am

Re: check if model converge but no Neg2LnL in model.table

Postby jlaake » Tue Nov 02, 2021 11:57 am

One of the things I suggest in the workshop notes (section 6) is to use the R function model.matrix with your formula and your ddl dataframe to see the design matrix you created. If you have never used the MARK interface to create a design matrix by hand, I suggest you try a simple one so you have a more complete understanding as to what is going on. Or fully read section 4 of the Workshop Notes. Also, you need to spend some time reading about R formulas. This might be one place top start.

https://www.datacamp.com/community/tutorials/r-formula-tutorial

Also read LinearModels.pdf which is in [url] http://www.phidot.org/software/mark/rma ... tation.zip
[/url]

If you browse phidot you will see that I have answered questions like this at least a dozen times.

You also need to understand the difference between a factor variable and a numeric variable. Factor variables like time and colony are categories and create separate intercepts for each category. Numeric variables (like effort) are slopes for lines. If you interact two factor variables and remove the main intercept (-1) you get all combinations of the categories. If you use time*colony you get the same values represented as main effect and interactions as long as there are data for each category. If you interact a numeric variable and a factor variable (effort*colony) you get a separate regression line for each colony. Now please go read section 6 of the workshop notes where this is explained with examples. The first question of your post is answered on page 33 of that section.
jlaake
 
Posts: 1417
Joined: Fri May 12, 2006 12:50 pm
Location: Escondido, CA

Re: check if model converge but no Neg2LnL in model.table

Postby Mnat » Tue Nov 02, 2021 12:21 pm

Thanks for your reply.
luckily, I understand the difference between a factor and a numeric variable.
As written in my initial post, effort was defined as a factor variable and Effort as numeric variable (like time and Time, just to try things out). Therefore, effort*colony is the interaction between two factorial variables in my case. That's why I was confused by your suggestions about effort.
However, I think the misunderstanding is clarified now. :D
Mnat
 
Posts: 18
Joined: Wed Apr 10, 2019 4:28 am


Return to RMark

Who is online

Users browsing this forum: No registered users and 13 guests