Description Usage Arguments Details Value Note See Also Examples
Convert formula to pim formula (incorporating L/R and poset)
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 | pimformula(formula, data, interpretation = c("difference", "regular",
"marginal", "symmetric"), verbosity = 0, leftsuffix = "_L",
rightsuffix = "_R", extra.variables = character(), lhs = c("PO", "<",
"<="), rhsreplacers = list(F = Freplacetext, O = Oreplacetext, L =
Lreplacetext, R = Rreplacetext), lhsreplacer = LHSreplacetext,
interactions.difference = (interpretation != "marginal"),
extra.nicenames = data.frame(org = character(), nice = character(),
stringsAsFactors = FALSE))
pim.fit.prep(formula, data, blocking.variables = character(),
poset = t(combn(nrow(data), 2)), leftsuffix = "_L", rightsuffix = "_R",
interpretation = c("difference", "regular", "marginal", "symmetric"),
na.action = na.fail, lhs = c("PO", "<", "<="), verbosity = 0,
nicenames = TRUE, interactions.difference = (interpretation !=
"marginal"), extra.nicenames = data.frame(org = character(), nice =
character(), stringsAsFactors = FALSE), check.symmetric = TRUE, link,
threshold = 1e-06, weights = NULL,
pseudoweights = pseudoweights.default)
pseudoweights.default(poset, weights)
|
formula |
Original formula |
data |
Context where the formula |
interpretation |
If |
verbosity |
The higher this value, the more levels of progress and debug information is displayed (note: in R for Windows, turn off buffered output) |
leftsuffix, rightsuffix |
Suffixes that will be added to the 'left' and 'right' observation's column name in the pseudo-observation. Note: no checking is done that these suffixes are safe, so the wrong suffixes may lead to unexpected behaviour. |
extra.variables |
Character vector of column names you want to force present in the pseudo-observations |
lhs |
|
rhsreplacers |
List of functions (see |
lhsreplacer |
Function like |
interactions.difference |
If |
extra.nicenames |
Should be a |
blocking.variables |
Character vector holding column names that hold blocking variables. |
poset |
Matrix of two columns indicating what the original observation number is for the left and right real observation in the pseudo-observation. |
na.action |
Defaults to |
nicenames |
Defaults to |
check.symmetric |
Defaults to |
link, threshold |
See |
weights |
Defaults to |
pseudoweights |
Defaults to |
Main function, doing the actual work.
The idea is to convert the formula to text and replace 4(+) kind of "spiced" variables:
O(var) gets replaced with I(var_R<var_L) (see Oreplacetext
for exact formulation)
F(var) gets replaced with Sum I(var_R=i)I(var_L=j) (see Freplacetext
for exact formulation)
L(var) gets replaced with var_L
R(var) gets replaced with var_R
var not in any of the above cases gets replaced by either var_R-varL (interpretation!="marginal")
or by var_L (interpretation=="marginal")
Some sanity checks are already performed, but not all of them (I guess)
This is the default for the pseudoweights
parameter to pim.fit.prep
and will simply multiply the weights of each observation to get to the weight of the
pseudo-observations.
For pimformula
: an object of class "pimformula". The items in this object are:
newformula |
The formula containing all suffixed variable names |
left.variables |
|
right.variables |
|
names |
Character vector holding the names for each individual term in the right hand side of the formula. Note: currently this is in no way cleaned up! |
full.colnames |
Character vector holding the constructed parts in the formula. Should
have the same length as |
nice.colnames |
Character vector holding nicer names the constructed parts in the formula.
Should have the same length as |
For pim.fit.prep
: an object of class "pimfitdata". The items in this object are:
X |
The design matrix in pseudo-observation space |
Y |
The pseudo-observations |
poset |
Matrix of two columns indicating what the original observation number is
for the left and right real observation in the pseudo-observation. Note: in some cases this
is not the passed in |
intercept |
Holds |
pimformula |
Result of |
original.colnames |
If |
weights |
Vector of weights for every item in |
For pseudoweights.default
: a vector holding one "pseudo-weight",
i.e. a weight per pseudo-observation. May be NULL
if the incoming
weight was as well.
TODO: Should probably disallow using intercept in some cases Also have to consider whether passing in contrasts is relevant/possible
1 2 3 4 5 6 7 8 9 10 11 12 13 14 | set.seed(1)
iris$out<-factor(sample(2, nrow(iris), replace=TRUE))
iris$xord<-as.ordered(iris$Species)
pimformula(out~Sepal.Length, data=iris)
pimformula(out~I((R(Sepal.Length) - L(Sepal.Length))/sqrt(R(Sepal.Length) * L(Sepal.Length)) ), data=iris, interpretation="regular")
pimformula(out~O(xord), data=iris, interpretation="regular")
pimformula(out~F(Species), data=iris, interpretation="regular")
set.seed(1)
iris$out<-factor(sample(2, nrow(iris), replace=TRUE))
iris$xord<-as.ordered(iris$Species)
pim.fit.prep(out~Sepal.Length, data=iris)
pim.fit.prep(out~I((R(Sepal.Length) - L(Sepal.Length))/sqrt(R(Sepal.Length) * L(Sepal.Length)) ), data=iris, interpretation="regular")
pim.fit.prep(out~O(xord), data=iris, interpretation="regular")
pim.fit.prep(out~F(Species), data=iris, interpretation="regular")
|
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.