Skip to content

Commit

Permalink
version 0.4.3
Browse files Browse the repository at this point in the history
  • Loading branch information
gastonstat committed Mar 23, 2014
1 parent 30aaec0 commit 7881086
Show file tree
Hide file tree
Showing 5 changed files with 17 additions and 8 deletions.
4 changes: 2 additions & 2 deletions DESCRIPTION
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
Package: plspm
Type: Package
Title: Tools for Partial Least Squares Path Modeling (PLS-PM)
Version: 0.4.2
Date: 2013-12-13
Version: 0.4.3
Date: 2014-03-23
Authors@R: c(
person("Gaston", "Sanchez",
email = "gaston.stat@gmail.com", role = c("aut", "cre")),
Expand Down
7 changes: 7 additions & 0 deletions NEWS
Original file line number Diff line number Diff line change
@@ -1,3 +1,10 @@
Version 0.4.3 (2014-03-23)
------------------------------------------------------------

* fixed factorial scheme bug in `get_weights_nonmetric`

* get_dummy allows `x` to include zero

Version 0.4.2 (2013-12-09)
------------------------------------------------------------

Expand Down
6 changes: 4 additions & 2 deletions R/get_dummies.r
Original file line number Diff line number Diff line change
Expand Up @@ -41,14 +41,16 @@ get_dummies <- function(MV, specs)
#' Transforms a vector of natural numbers from 1 to p into the
#' corresponding p x p dummy matrix
#'
#' @param x a vector whose elements are all the natural numbers from 1 to p
#' @param x a vector whose elements are non-negative integers from 0 to p
#' @return the dummy matrix
#' @keywords internal
#' @export
get_dummy <- function(x)
{
n = length(x)
p = max(x, na.rm = TRUE)
# p = max(x, na.rm = TRUE)
# since 'x' could include zero, it's better to use the following:
p = length(unique(x[!is.na(x)]))

# build the (p x p) dummy matrix
Xdummy = matrix(0, n, p)
Expand Down
4 changes: 2 additions & 2 deletions R/get_weights_nonmetric.r
Original file line number Diff line number Diff line change
Expand Up @@ -92,7 +92,7 @@ function(X, path_matrix, blocks, specs)
# =============================================================
E <- switch(specs$scheme,
"centroid" = sign(cor(Y) * link),
"factor" = cov(Y) * link,
"factorial" = cov(Y) * link,
"path" = get_path_scheme(path_matrix, Y))
# internal estimation of LVs 'Z'
Z = Y %*% E
Expand All @@ -114,7 +114,7 @@ function(X, path_matrix, blocks, specs)
Beta <- summary(lm(Z[,q]~QQ[[q]]))$coef[-1,1]
X.star <- matrix(,num_obs,block_sizes[q])
for (p in 1L:block_sizes[q]) {
X.star[,p] <- (1/Beta[p])*(Z[,q] - (QQ[[q]][,-p]%*%Beta[-p]))
X.star[,p] <- (1/Beta[p])*(Z[,q] - (QQ[[q]][,-p,drop=FALSE]%*%Beta[-p]))
if (specs$scaling[[q]][p] == "nom") {
# extract corresponding dummy matrix
# aux_dummy = dummies[[blocks[[q]][p]]]
Expand Down
4 changes: 2 additions & 2 deletions man/get_dummy.Rd
Original file line number Diff line number Diff line change
Expand Up @@ -5,8 +5,8 @@
get_dummy(x)
}
\arguments{
\item{x}{a vector whose elements are all the natural
numbers from 1 to p}
\item{x}{a vector whose elements are non-negative
integers from 0 to p}
}
\value{
the dummy matrix
Expand Down

0 comments on commit 7881086

Please sign in to comment.