How to input missing values for single season Occupancy modelling?

1,689 views
Skip to first unread message

mabidu...@gmail.com

unread,
Aug 31, 2014, 10:20:19 AM8/31/14
to unma...@googlegroups.com
Hi everyone,

I am using Unmarked package to model occupancy for the first time. For my analysis, I have 65 sites, maximum 12 replications, 5 site covariates and 1 survey covariate. My data has many missing values in detection history that matches survey covariates. 

In the past I have used PRESENCE where missing values were replaced by "-". I already have tried blank cells as missing values and models run alright. I have tried parametric bootstrapping with goodness-of-fit using chi-square and Freeman-Tukey, but retruns NA values. I have added na.rm=TRUE and works fine; however I am not sure if I am doing it right (please see the code in the following)-

code: fitstats <- function(pi_SL_CWED_psi_distvil_CWED) {
  observed <- getY(pi_SL_CWED_psi_distvil_CWED@data)
  expected <- fitted(pi_SL_CWED_psi_distvil_CWED)
  resids <- residuals(pi_SL_CWED_psi_distvil_CWED)
  sse <- sum(resids^2, na.rm=TRUE)
  chisq <- sum(((observed - expected)^2 / expected), na.rm=TRUE)
  freeTuke <- sum(((sqrt(observed) - sqrt(expected))^2), na.rm=TRUE)
  out <- c(SSE=sse, Chisq=chisq, freemanTukey=freeTuke)
  return(out)
}
(pb <- parboot(pi_SL_CWED_psi_distvil_CWED, fitstats, nsim=1000, report=1))

pi_SL_CWED_psi_distvil_CWED is my global model
 
I also tried to estimate MacKenzie and Bailey (2004) goodness-of-fit test using mb.gof.test in AICCmodavg package. It gives an error message- Error in preds.p.not.na[j, ] : incorrect number of dimensions. I am really stuck with my analysis at this point. 

I think this is due to the high number of missing values. I would really appreciate if anyone could let me know how to input missing values in Unmarked or if I am doing somethign wrong. 

Thanks in advance!

Abid

Marc.Ma...@uqat.ca

unread,
Sep 2, 2014, 8:38:27 AM9/2/14
to unma...@googlegroups.com
Hi Abid,

You should use NA to indicate missing values in your data set. An other option is using the na.strings argument in read.table( ) when importing your data set and setting it to read.table(, na.strings = "-").

Also be sure to use the most recent version of AICcmodavg.

Let me know if the problem persists,

Marc

--
____________________________________
Marc J. Mazerolle
Centre d'étude de la forêt
Université du Québec en Abitibi-Témiscamingue
445 boulevard de l'Université
Rouyn-Noranda, Québec J9X 5E4, Canada
Tel: (819) 762-0971 ext. 2458
Email: marc.ma...@uqat.ca

De : unma...@googlegroups.com [unma...@googlegroups.com] de la part de mabidu...@gmail.com [mabidu...@gmail.com]
Envoyé : dimanche 31 août 2014 10:20
À : unma...@googlegroups.com
Objet : [unmarked] How to input missing values for single season Occupancy modelling?

--
You received this message because you are subscribed to the Google Groups "unmarked" group.
To unsubscribe from this group and stop receiving emails from it, send an email to unmarked+u...@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

mabidu...@gmail.com

unread,
Sep 3, 2014, 2:18:06 PM9/3/14
to unma...@googlegroups.com
Hi Marc,

Thanks for your reply. I tried your suggestions (NA, and "-") but still getting same error message. Is it possible that this error is due to huge missing values (about 40%). Only a few of my sites have data on all/most occasions that accounted for this huge missing values. 

Though I have already run the occupancy models in PRESENCE, I would like to know what went wrong in R and possibly continue future Occupancy modellings using Unmarked and AIcmodavg.

I would really appreciate if you keep me in loop on your thoughts about the high number of missing values.

Best

Abid

Marc J. Mazerolle

unread,
Sep 15, 2014, 9:48:54 AM9/15/14
to unma...@googlegroups.com
Hi,

Abid sent me his code and occupancy data set for debugging. The problem
was that there was only a single detection history without missing
values, which triggered an error in mb.gof.test( ). The changes will be
included in the next version of AICcmodavg before the end of the month.

Sincerely,

Marc
--
____________________________________
Marc J. Mazerolle
Centre d'étude de la forêt
Université du Québec en Abitibi-Témiscamingue
445 boulevard de l'Université
Rouyn-Noranda, Québec J9X 5E4, Canada
Tel: (819) 762-0971 ext. 2458
Email: marc.ma...@uqat.ca


-------- Message initial --------
De: mabidu...@gmail.com
À: unma...@googlegroups.com
Sujet: Re: [unmarked] How to input missing values for single season
Occupancy modelling?
Date: Wed, 3 Sep 2014 11:18:06 -0700
________________________________________________________________
number of dimensions.I am really stuck with my analysis at this

James Tolliver

unread,
Oct 6, 2016, 2:41:49 PM10/6/16
to unmarked, marc.ma...@uqat.ca
The package accommodates when there are missing y's but I have been trying to use this with missing covariates and it seems to always give me this error: 

Error in chisq.missing[, "Expected"] : incorrect number of dimensions 

I was wondering if there was any way to use this command and tell it not to generate expected values for NA covariates.

Thank you,
James Tolliver  

Richard Schuster

unread,
Oct 6, 2016, 4:25:00 PM10/6/16
to unma...@googlegroups.com
Hi James,

In general people might advise against using observations with missing covariate values, but if you need to you could impute those yourself using the average value of the covariate. Not sure if there are functions out there that do that, my guess is there are. If not, I would calculate means, search each covariate for NA's and replace NA's with mean values. But again, could be problematic and I would advise against this if reasonable.

Cheers,
Richard
-- 
Richard Schuster

Liber Ero Postdoctoral Fellow
Department of Biology
Carleton University
Email: ma...@richard-schuster.com
http://richard-schuster.com/
Twitter: @RicSchuster
ph: 250-635-2321

Mazerolle, Marc J.

unread,
Oct 6, 2016, 4:41:53 PM10/6/16
to James Tolliver, unmarked
James,

if you have missing covariates, then these should correspond to missing y's. Otherwise, you run the risk of having different data sets for different models. Usually, you should see a warning that some observations were deleted during fitting with unmarked functions. However, it is better to take care of these NA's before the analysis, as advised by Richard S.

Regarding the error message from mb.gof.test( ), I found the source of the problem with certain "weird" data sets. I can send you a patch for the function (send me an email offlist), or you can wait for the next release of AICcmodavg in the coming weeks.

Hope it helps,

Marc
--
____________________________________
Marc J. Mazerolle
Département des sciences du bois et de la forêt
2405 rue de la Terrasse
Université Laval
Québec, Québec G1V 0A6, Canada
Tel: (418) 656-2131 ext. 7120
Email: marc.ma...@uqat.ca

De : James Tolliver [tolli...@gmail.com]
Envoyé : jeudi 6 octobre 2016 14:35
À : unmarked
Cc : Mazerolle, Marc J.
Objet : Re: [unmarked] How to input missing values for single season Occupancy modelling?

Reply all
Reply to author
Forward
0 new messages