RMark: RD Occupancy-Time Dependent Covariate on p

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

RMark: RD Occupancy-Time Dependent Covariate on p

Postby bacollier » Mon Dec 01, 2008 4:08 pm

All,
Working with a robust design occupancy modeling approach, I have a covariate (1/0) I am interested in using for modeling detection that indicates whether the species was present in the previous primary sampling period in some abundance (>x or <x). I thought I could treat it as a time-dependent covariate on the primary session using the approach outlined in RMark What's new v1.8.2, but, I keep getting

> wwdo.results<-run.wwdo.models()
Error in make.mark.model(data.proc, title = title, covariates = covariates, :

Error: Variable f used in formula is not defined in data

I defined the variable as f(nnnn) so each of 40 primary occasions (1968-2007) is represented as f1968, f1969, ..., f2007. Am I defining it wrong specific to the primary occasions as I thought fnnnn would be the same as using x1, x2, x3?

Thanks
Bret
bacollier
 
Posts: 230
Joined: Fri Nov 26, 2004 10:33 am
Location: Louisiana State University

Postby jlaake » Mon Dec 01, 2008 4:24 pm

When you post something like this you'll need to add more details. Like names(df) where df is the dataframe you are using, names(ddl$par) where par is the variable (eg Psi) where the formula is being used. Also add the snippet of code that shows the call to process.data and make.design.data and the model formula etc. One obvious thing to check is to make sure your begin.time is set correctly such that it will match the variable names.

--jeff
jlaake
 
Posts: 1479
Joined: Fri May 12, 2006 12:50 pm
Location: Escondido, CA

Postby bacollier » Mon Dec 01, 2008 4:52 pm

Sorry Jeff, forgot to think about posting guide rules.

I think the problem I am having has to do with tying the 'f' variable to detection. Since detection estimates for a robust design comes from the secondary occasion data, maybe I am not able to model detection as a function of a covariate that is measured based on the primary occasions?

> names(wwdo.data)
[1] "ch" "ID" "statenum" "route" "distCity" "areaCity" "area10" "Ecoarea" "FL" "Ecoreg" "dist1968" "dist1977" "f1968" "f1969" "f1970" "f1971" "f1972" "f1973" "f1974" "f1975" "f1976"
[22] "f1977" "f1978" "f1979" "f1980" "f1981" "f1982" "f1983" "f1984" "f1985" "f1986" "f1987" "f1988" "f1989" "f1990" "f1991" "f1992" "f1993" "f1994" "f1995" "f1996" "f1997"
[43] "f1998" "f1999" "f2000" "f2001" "f2002" "f2003" "f2004" "f2005" "f2006" "f2007"
>

> names(wwdo.ddl$p)
[1] "group" "time" "session" "Time" "c"


#model function
run.wwdo.models=function()
{
# Set time intervals
time_intervals<-c(rep(c(rep(0, 49), rep(1,1)), 39), rep(0, 49))

# Process data for analysis
wwdo.process<-process.data(wwdo.data, model="RDOccupPG", time.intervals=time_intervals)
wwdo.ddl<-make.design.data(wwdo.process)

# Create candidate model variables
#parameters for occupancy

Psi.dot=list(formula=~1)

#Paramters for detection
p.f=list(formula=~f)

#Paramters for gamma

gam.dot=list(formula=~1)


# Test model for f
model.0<-mark(wwdo.process, wwdo.ddl, model.parameters=list(p=p.f, Psi=Psi.dot, Gamma=gam.dot), invisible=FALSE)


return(collect.models())
}
wwdo.results<-run.wwdo.models()
options(width=250)
wwdo.results
bacollier
 
Posts: 230
Joined: Fri Nov 26, 2004 10:33 am
Location: Louisiana State University

Postby jlaake » Mon Dec 01, 2008 5:01 pm

I don't believe that is the problem. If you were to do a summary of ddl$p then you would see that the time values are 1,2...etc. You did not assign a begin.timesuch that it would create time fields that matched the values 19xx you used with f.

--jeff
jlaake
 
Posts: 1479
Joined: Fri May 12, 2006 12:50 pm
Location: Escondido, CA

Postby jlaake » Mon Dec 01, 2008 5:58 pm

I hit the send button too quickly on that last message. If the design data for time in p are not setup the way you want, you always have the option of copying the current time variable to another variable (eg Occasion) in the design data and then defining the value of time as it suits your needs so that it will create the correct variable name. It simply concatenates the variable name prefix (f in this case) to the value of time and then uses the variable with that name. If you have further problems with this, write me off list and we'll summarize for the list.

As an aside, design data can be modified and added to suit your needs. The only thing you should never do is to sort the design data in an order other than their original order. Doing so will misalign the design data with the parameters. Other than that, you can add/modify any fields you want. This is the best way to create subsets (factors) or add numeric occasion-specific covariates.

--jeff
jlaake
 
Posts: 1479
Joined: Fri May 12, 2006 12:50 pm
Location: Escondido, CA

Postby bacollier » Tue Dec 02, 2008 5:00 pm

All,
Offlist, Jeff worked this out with me: In short (and I hope I word this right), the issue was how assignment of individual covariates work. I had 2000 primary-secondary specific occasions (40 years of 50 surveys per year), but, since the covariate of interest I though affected detection was only primary specific, I only needed 40.

So, the mismatch was between the primary covariate levels and could not be solved with begin.time. Looking at the ddl$p in a dataset one can see the columns for time (1-2000 in my case) and session (1-40 in my case). Since session always starts with 1 and goes through the number of sessions (40 in my case), then I could create a new variable (primary) and then create a new session variable that begins with the first year (1968 in my case) which gives the solution for my issue being

ddl$p$primary=ddl$p$session
ddl$p$session= as.numeric(ddl$p$session)+1967
summary(ddl$p) #use only as a check
bacollier
 
Posts: 230
Joined: Fri Nov 26, 2004 10:33 am
Location: Louisiana State University


Return to RMark

Who is online

Users browsing this forum: No registered users and 2 guests

cron