as.2pdata: Converts a data frame to a list made for fitting LBH model

Description Usage Arguments Details Value See Also Examples

View source: R/2pdata.r

Description

The default method transforms the data into a format that fits the framework of the unit level model of Lyu, Berg and Hofmann.

Usage

1
2
3
4
5
6
7
8
as.2pdata(
  f_pos,
  f_zero = f_pos,
  f_area,
  data,
  transform = "BoxCox",
  lambda = 0
)

Arguments

f_pos

an object of class formula: a symbolic description of the fixed effect model to be fitted to the positive part.

f_zero

an object of class formula: a symbolic description of the fixed effect model to be fitted to the binary part. Default value is to using the same formula as the positive part (f_pos).

f_area

an object of class formula: a symbolic description of the area code to be fitted to both the positive part and the negative part.

data

sample data containing the variables named in f_pos, f_zero and f_area. Any sampling units containing missing entries in the model data frame are removed.

transform

type of transformation for the positive responses to be chosen between the "BoxCox" and "power" families. Default value is "Boxcox".

lambda

value for the parameter of the family of transformations specified in transform. Default value is 0, which gives the log transformation for the two possible families.

Details

The response variable in the formula f_zero is ignored. I(y>0) will be used for the binary part where y is the response variable in the formula f_pos.
Although this function allows a general transformation family for the positive part, the Empirical Bayes predictor of area means developed in the paper of Lyu, Berg and Hofmann (ebLBH) assumes a log transformation is used. A general transformation family is provided in this function so as to facilitate a profile likelihood analysis together with the function mleLBH to check the assumption of a log transformation for the positive part, i.e., whether lambda is significantly different from 0. See here for an example of profiling lambda with respect to the BoxCox transformation family.

Value

An object of the class "2pdata" which is a list with the following components:

See Also

bxcx

Examples

1
2
3
  erosion_2p <- as.2pdata(f_pos = RUSLE2~logR+logK+logS,
                          f_zero = ~logR+logS+crop2+crop3,
                          f_area = ~cty, data = erosion)

XiaodanLyu/saezero documentation built on Sept. 20, 2020, 5:59 a.m.