- Code: Select all
1000000000 1 12 9 10 15 20 144 81 100 225 400 9 10 15 20 81 100 225 400 ;
0100100001 1 12 9 10 15 20 144 81 100 225 400 9 10 15 20 81 100 225 400 ;
0101001010 1 12 9 10 15 20 144 81 100 225 400 9 10 15 20 81 100 225 400 ;
1001111111 1 12 9 10 15 20 144 81 100 225 400 9 10 15 20 81 100 225 400 ;
0010000000 1 12 9 10 15 20 144 81 100 225 400 9 10 15 20 81 100 225 400 ;
This data set is read using the following RMark code:
- Code: Select all
n.days <- 5
mydata <- convert.inp("fake.inp",
covariates = c(paste0("ptemp", seq_along(1:n.days)),
paste0("ptempsq", seq_along(1:n.days)),
paste0("temp", seq_along(1:(n.days-1))),
paste0("tempsq", seq_along(1:(n.days-1)))))
The covariates ptemp and ptempsq are for modelling annual detection using one temperature for each of five days. The covariates temp and tempsq are for modelling annual epsilon and gamma using one temperature value for each of four days. Here the first value in ptemp and ptempsq are discarded when creating temp and tempsq.
Is it possible to restrict the individual covariates in the input data set to ptemp as shown below and create ptempsq, temp and tempsq from inside the RMark R file?
- Code: Select all
1000000000 1 12 9 10 15 20 ;
0100100001 1 12 9 10 15 20 ;
0101001010 1 12 9 10 15 20 ;
1001111111 1 12 9 10 15 20 ;
0010000000 1 12 9 10 15 20 ;
I have over 100 sample days and potentially something close to 2500 individual covariates if using the format shown in the first data set above. I thought creating some covariates within the R file might make the input data file more manageable and might prevent potential problems associated with reading enormously long lines of data.
I have found two examples of creating squared terms in the RMark documentation and Appendix C of the MARK book. But neither seems to implement what I am hoping to do. The example input data file 'indcov2.inp' contains mass and sqmass similar to my initial data set above. I also found an example of squaring a term in the ddl file:
"If we wanted to define a model for p that was a function of age and age squared, we could add the age squared variable as: ddl$p$Agesq=ddl$p$Age^2"
I have tried creating the squared terms and the covariates for epsilon and gamma inside the process.data object using the R code below. This code with the second (smaller) input data set returns the same estimates as the code above with the original data set.
Is the approach below an acceptable way of creating covariates inside RMark?
- Code: Select all
n.days <- 5
mydata <- convert.inp("fakeb.inp",
covariates = c(paste0("ptemp", seq_along(1:n.days))))
mydata.processed = process.data(mydata, begin.time = 1, model = "RDOccupEG",
time.intervals = c(rep(c(0,1), (n.days-1)),0))
mydata.processed$data$ptempsq1 <- mydata.processed$data$ptemp1^2
mydata.processed$data$ptempsq2 <- mydata.processed$data$ptemp2^2
mydata.processed$data$ptempsq3 <- mydata.processed$data$ptemp3^2
mydata.processed$data$ptempsq4 <- mydata.processed$data$ptemp4^2
mydata.processed$data$ptempsq5 <- mydata.processed$data$ptemp5^2
mydata.processed$data$temp1 <- mydata.processed$data$ptemp2
mydata.processed$data$temp2 <- mydata.processed$data$ptemp3
mydata.processed$data$temp3 <- mydata.processed$data$ptemp4
mydata.processed$data$temp4 <- mydata.processed$data$ptemp5
mydata.processed$data$tempsq1 <- mydata.processed$data$ptemp2^2
mydata.processed$data$tempsq2 <- mydata.processed$data$ptemp3^2
mydata.processed$data$tempsq3 <- mydata.processed$data$ptemp4^2
mydata.processed$data$tempsq4 <- mydata.processed$data$ptemp5^2
I found the post at the link below using 'merge_design.covariates' to add covariates to the design matrix ddl object. But I am not sure that is appropriate in my case:
viewtopic.php?f=21&t=4377&p=14595&hilit=data.processed#p14595
Thank you for any thoughts on creating time-varying individual covariates from within RMark code.