| Type: | Package | 
| Title: | Test of Independence & Image Structural Similarity Measure PSSIM | 
| Version: | 0.1.0 | 
| Author: | Luann C. Jung, Haiyan Wang, Diego Maldonado, Sharad Silwal, Siti Tolos, Suojin Wang | 
| Maintainer: | Haiyan Wang <hwang@ksu.edu> | 
| Description: | Test-based Image structural similarity measure and test of independence. This package implements the key functions of two tasks: (1) computing image structural similarity measure PSSIM of Wang, Maldonado and Silwal (2011) <doi:10.1016/j.csda.2011.04.021>; and (2) test of independence between a response and a covariate in presence of heteroscedastic treatment effects proposed by Wang, Tolos, and Wang (2010) <doi:10.1002/cjs.10068>. | 
| License: | GPL-2 | 
| Encoding: | UTF-8 | 
| LazyData: | true | 
| RoxygenNote: | 7.1.0 | 
| Depends: | R (≥ 3.5.0) | 
| Imports: | stats, parallel | 
| NeedsCompilation: | no | 
| Packaged: | 2020-09-02 20:06:16 UTC; hwang | 
| Repository: | CRAN | 
| Date/Publication: | 2020-09-10 09:50:03 UTC | 
Test of independence in presence of heteroscedastic treatments
Description
NPtest_indept performs the test of independence between the response variable and a single covariate when there is potentially heteroscedastic treatment effects present (see Wang, Tolos and Wang (2010)).
Usage
NPtest_indept(dat, k = 7)
Arguments
| dat | A data frame with three columns named X, trt, and Y, where X is the covarite, trt is the treatment level, and Y is the response variable. | 
| k | An odd integer to specify the number of nearest neighbors to be used in augmentation. Generally recommend to use 3, 5, or 7. | 
Value
A list containing the following variables:
Asys_var: the asymptotic variance for the test statistics
Tstat: the test statistic
pvalue: the p-value of the test under H0: independence between X and Y.
References
Haiyan Wang, Siti Tolos, and Suojin Wang (2010). A Distribution Free Nonparametric Test to Detect Dependence Between a Response Variable and Covariate in Presence of Heteroscedastic Treatment Effects. The Canadian Journal of Statistics. 38(3), 408433. Doi:10.1002/cjs.10068
Examples
n=64;  X=runif(n); trt=gl(2, n/2)
e=rnorm(n, 0, 0.1)
Y=ifelse(trt==1, 4*(X-0.5)^2+e, 2*X+e)
dat=data.frame(X, Y, trt)
NPtest_indept(dat, k=7)
Image structural similarity measure PSSIM based on hypothesis test
Description
PSSIM_snow computes image structural similarity PSSIM of Wang, Maldonado and Silwal (2011) using parallel programming.
Usage
PSSIM_snow(
  A,
  A1,
  nprocess = min(8, parallel::detectCores()),
  b = 64,
  a = 2,
  vs = 32,
  wavecoeff = FALSE,
  cs = 2,
  dyn = FALSE
)
Arguments
| A | a grayscale image stored as a matrix. | 
| A1 | grayscale image stored as a matix. Same dimension as A. | 
| nprocess | number of cores (workers) to use for parallel computation. Note: In personal computer, nprocess =detectCores() is good to use. On cluster machine, nprocess need to be specified to a number that is no more than its number of cores (for courtesy) | 
| b | Number of columns in each block. Suggest to use default value 64. | 
| a | Number of rows in each block. Suggest to use default value 2. | 
| vs | Block shift size. Suggest to use default value 32. | 
| wavecoeff | logical of whether the input matrices are wavelet coefficients. Currently, wavelet version is not implemented. This parameter is a placeholder for future implementation. | 
| cs | dividing factor to split index. | 
| dyn | logical, whether dynamic scheduling should be used. | 
Value
: Image structural similarity based on PSSIM. The value is in [0,1] with values close to 0 meaning the two images are different and values close to 1 meaning the two iamges are similar.
References
Haiyan Wang, Diego Maldonado, and Sharad Silwal (2011). A Nonparametric-Test-Based Structural Similarity Measure for Digital Images. Computational Statistics and Data Analysis. 55: 2925-2936. Doi:10.1016/j.csda.2011.04.021
Examples
  A=miniimagematrix$A
  B=miniimagematrix$B
  # see it with image(A, axes=FALSE, col  = gray((0:255)/256) )
  PSSIM_snow(A, B, nprocess=2)
Nearest neighbor augmentatation based on ranks
Description
The function makepseudo performs the nearest neighbor augmentation based on the rank of covariate values according to the scheme discribed on page 410-411 of Wang, Tolos and Wang (2010)
Usage
makepseudo(N, n, k, a, alltrt)
Arguments
| N | total number of covariate values. | 
| n | vector of sample sizes from all treatments | 
| k | number of nearest neighbors | 
| a | number of treatment levels in the data | 
| alltrt | a matrix of dimension 3x | 
Value
A list containing the following: psudo: a 3-d array of the dimension (k, a, N) that stores the augmented observations based on k-nearest neighbor rule in Wang, Tolos and Wang (2010). index: a 3-d array of the dimension (k, a, N) that stores the index of which observation was used for augmentation.
References
Haiyan Wang, Siti Tolos, and Suojin Wang (2010). A Distribution Free Nonparametric Test to Detect Dependence Between a Response Variable and Covariate in Presence of Heteroscedastic Treatment Effects. The Canadian Journal of Statistics. 38(3), 408433. Doi:10.1002/cjs.10068
Examples
 a=2; n=c(7,9); N=sum(n);  X=runif(N);
 trt=c(rep(1,n[1]), rep(2, n[2])); e=rnorm(N, 0, 0.1)
 Y=ifelse(trt==1, 4*(X-0.5)^2+e, 2*X+e)
 ranksuse=unlist(tapply(X, trt, rank) )
 alltrt=rbind(Y, X, ranksuse )
 aug=makepseudo(N,n, k=3, a, alltrt)
Index in one vector mapped to treatment and observation index
Description
Function mapindex() maps the 1-d index r=1,...,N to 2-d index i=1, ...a, j=1, ..., ni. Generally the covariate values from all treatments are stored together in one vector and r=1,...,N enumerates the values. For any integer between 1 and N, mapindex tells which treatment the rth value belongs to, and which observation in the identified treatment.
Usage
mapindex(r, n)
Arguments
| r | an integer between 1 and sum(n). | 
| n | a vector of the sample sizes. | 
Value
the 2-d index, where the first gives which treatment the value belongs to and the second gives which observation in that treatment.
Examples
r=5; n=c(7, 8); mapindex(r, n)
r=7; n=c(7, 8); mapindex(r, n)
r=9; n=c(7, 8); mapindex(r, n)
Mini-image data matrice for example
Description
The matrices are grayscale images in matrix format.
Usage
data(miniimagematrix)
Format
A list with two grayscale image matrices
- A
- A matrix for one image 
- B
- A matrix for a second image 
Examples
 
data(miniimagematrix)
miniimagematrix$A
Starting and ending position in a vector
Description
Function trt_position() gives the starting and ending index of covariate values in the i1th group if all the covariate values from all treatment groups are together in a vector. E.g., covariate values in group 1 start from 1st value to the n1 th value; those in group 2 start from n1+1 and end at (n1+n2)th value. This function is for retrieving the position of an observations when the covariate values from all treatments are stored together in one vector.
Usage
trt_position(i1, n)
Arguments
| i1 | an integer between 1 and length(n). | 
| n | the vector of sample sizes. | 
Examples
i = 2; n=c(7, 8); trt_position(i, n)