simulateUsedAvail(data, parms, n.used, m, link="logit")
Arguments
data
a matrix or data frame.
parms
coefficients corresponding to the columns of the design matrix
derived as model.matrix(~., data).
n.used, m
number of used points (n.used)
and number of available points for each (m).
link
character, the type of link function to be used.
Value
A used-available data frame.
Author(s)
Subhash Lele, Peter Solymos
Examples
n.used <- 1000
m <- 10
n <- n.used * m
set.seed(1234)
x <- data.frame(x1=rnorm(n), x2=runif(n))
cfs <- c(1.5,-1,0.5)
dat1 <- simulateUsedAvail(x, cfs, n.used, m, link="log")
str(dat1)
dat2 <- simulateUsedAvail(x, cfs, n.used, m, link="logit")
str(dat2)
Results
R version 3.3.1 (2016-06-21) -- "Bug in Your Hair"
Copyright (C) 2016 The R Foundation for Statistical Computing
Platform: x86_64-pc-linux-gnu (64-bit)
R is free software and comes with ABSOLUTELY NO WARRANTY.
You are welcome to redistribute it under certain conditions.
Type 'license()' or 'licence()' for distribution details.
R is a collaborative project with many contributors.
Type 'contributors()' for more information and
'citation()' on how to cite R or R packages in publications.
Type 'demo()' for some demos, 'help()' for on-line help, or
'help.start()' for an HTML browser interface to help.
Type 'q()' to quit R.
> library(ResourceSelection)
ResourceSelection 0.2-6 2016-02-15
> png(filename="/home/ddbj/snapshot/RGM3/R_CC/result/ResourceSelection/simulateUsedAvail.Rd_%03d_medium.png", width=480, height=480)
> ### Name: simulateUsedAvail
> ### Title: Simulate Used-Aavailable Data
> ### Aliases: simulateUsedAvail
> ### Keywords: manip
>
> ### ** Examples
>
> n.used <- 1000
> m <- 10
> n <- n.used * m
> set.seed(1234)
> x <- data.frame(x1=rnorm(n), x2=runif(n))
> cfs <- c(1.5,-1,0.5)
> dat1 <- simulateUsedAvail(x, cfs, n.used, m, link="log")
> str(dat1)
'data.frame': 11000 obs. of 3 variables:
$ status: num 1 1 1 1 1 1 1 1 1 1 ...
$ x1 : num -0.477 -2.353 -0.179 -2.18 -0.861 ...
$ x2 : num 0.0885 0.0821 0.5495 0.3842 0.7608 ...
> dat2 <- simulateUsedAvail(x, cfs, n.used, m, link="logit")
> str(dat2)
'data.frame': 11000 obs. of 3 variables:
$ status: num 1 1 1 1 1 1 1 1 1 1 ...
$ x1 : num -0.914 -1.341 0.799 0.905 0.355 ...
$ x2 : num 0.11 0.146 0.848 0.576 0.714 ...
>
>
>
>
>
> dev.off()
null device
1
>